📄 createcardcontainer.cpp
字号:
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "CreateCardContainer.h"
#include <eiklabel.h> // for example label control
#include <eikedwin.h> // for CEikEdwin
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CCreateCardContainer::CCreateCardContainer()
{
m_pLabelFamilyName = NULL;
m_pEditFamilyName = NULL;
m_pLabelFirstName = NULL;
m_pEditFirstName = NULL;
m_pLabelTelephone = NULL;
m_pEditTelephone = NULL;
}
// EPOC default constructor can leave.
void CCreateCardContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//label FamilyName
TBuf<32> sFamilyName;
iCoeEnv->ReadResource(sFamilyName, R_QTN_LABEL_CREATE_FAMILYNAME);
m_pLabelFamilyName = new (ELeave) CEikLabel;
m_pLabelFamilyName->SetContainerWindowL(*this);
m_pLabelFamilyName->SetTextL(sFamilyName);
m_pLabelFamilyName->SetExtent(TPoint(20, 30), m_pLabelFamilyName->MinimumSize());
//edit FamilyName
m_pEditFamilyName = new (ELeave) CEikEdwin(/*TGulBorder::ESingleBlack*/);
m_pEditFamilyName->SetContainerWindowL(*this);
m_pEditFamilyName->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 16, 1);
m_pEditFamilyName->SetExtent(TPoint(60, 25), TSize(80, 20));
//label FirstName
TBuf<32> sFirstName;
iCoeEnv->ReadResource(sFirstName, R_QTN_LABEL_CREATE_FIRSTNAME);
m_pLabelFirstName = new (ELeave) CEikLabel;
m_pLabelFirstName->SetContainerWindowL(*this);
m_pLabelFirstName->SetTextL(sFirstName);
m_pLabelFirstName->SetExtent(TPoint(20, 60), m_pLabelFirstName->MinimumSize());
//edit FirstName
m_pEditFirstName = new (ELeave) CEikEdwin(/*TGulBorder::ESingleBlack*/);
m_pEditFirstName->SetContainerWindowL(*this);
m_pEditFirstName->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 16, 1);
m_pEditFirstName->SetExtent(TPoint(60, 55), TSize(80, 20));
//label Telephone
TBuf<32> sTelephone;
iCoeEnv->ReadResource(sTelephone, R_QTN_LABEL_CREATE_TELEPHONE);
m_pLabelTelephone = new (ELeave) CEikLabel;
m_pLabelTelephone->SetContainerWindowL(*this);
m_pLabelTelephone->SetTextL(sTelephone);
m_pLabelTelephone->SetExtent(TPoint(20, 90), m_pLabelTelephone->MinimumSize());
//edit sCode rss
m_pEditTelephone=new(ELeave)CEikEdwin;
m_pEditTelephone->SetContainerWindowL(*this);
m_pEditTelephone->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 16, 1);
m_pEditTelephone->SetExtent(TPoint(60, 85), TSize(80, 20));
m_pEditTelephone->SetAknEditorInputMode(EAknEditorNumericInputMode);
m_pEditTelephone->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
m_pEditTelephone->SetMaxLength(16);
m_pEditFamilyName->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}
// Destructor
CCreateCardContainer::~CCreateCardContainer()
{
if (m_pLabelFamilyName)
{
delete m_pLabelFamilyName;
m_pLabelFamilyName = NULL;
}
if (m_pEditFamilyName)
{
delete m_pEditFamilyName;
m_pEditFamilyName = NULL;
}
if (m_pLabelFirstName)
{
delete m_pLabelFirstName;
m_pLabelFirstName = NULL;
}
if (m_pEditFirstName)
{
delete m_pEditFirstName;
m_pEditFirstName = NULL;
}
if (m_pLabelTelephone)
{
delete m_pLabelTelephone;
m_pLabelTelephone = NULL;
}
if (m_pEditTelephone)
{
delete m_pEditTelephone;
m_pEditTelephone = NULL;
}
}
// ---------------------------------------------------------
// CAknExEditorContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateCardContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CCreateCardContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateCardContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CCreateCardContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CCreateCardContainer::CountComponentControls() const
{
return 6; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CCreateCardContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CCreateCardContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pLabelFamilyName;
break;
case 1:
return m_pEditFamilyName;
break;
case 2:
return m_pLabelFirstName;
break;
case 3:
return m_pEditFirstName;
break;
case 4:
return m_pLabelTelephone;
break;
case 5:
return m_pEditTelephone;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CCreateCardContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateCardContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbYellow);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CCreateCardContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CCreateCardContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pEditFamilyName)
{
if (m_pEditFamilyName->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEditFamilyName->SetFocus(EFalse);
m_pEditFirstName->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEditFamilyName->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEditFirstName)
{
if (m_pEditFirstName->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEditFirstName->SetFocus(EFalse);
m_pEditTelephone->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEditFirstName->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEditTelephone)
{
if (m_pEditTelephone->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEditTelephone->SetFocus(EFalse);
m_pEditFamilyName->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEditTelephone->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CCreateCardContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateCardContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CCreateCardContainer::GetInputFamilyName(TDes& aName)
{
m_pEditFamilyName->GetText(aName);
}
void CCreateCardContainer::GetInputFirstName(TDes& aName)
{
m_pEditFirstName->GetText(aName);
}
void CCreateCardContainer::GetInputTelephone(TDes& aName)
{
m_pEditTelephone->GetText(aName);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -