📄 modifycardcontainer.cpp
字号:
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "ModifyCardContainer.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.
//
CModifyCardContainer::CModifyCardContainer()
{
m_pLabelFamilyName = NULL;
m_pEditFamilyName = NULL;
m_pLabelFirstName = NULL;
m_pEditFirstName = NULL;
m_pLabelTelephone = NULL;
m_pEditTelephone = NULL;
}
// EPOC default constructor can leave.
void CModifyCardContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//label FamilyName
TBuf<32> sFamilyName;
iCoeEnv->ReadResource(sFamilyName, R_QTN_FRMES_LABEL_CVIEW_NAME);
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(80, 25), TSize(80, 20));
m_pEditFamilyName->SetTextL(&sTempFamilyName);
//label FirstName
TBuf<32> sFirstName;
iCoeEnv->ReadResource(sFirstName, R_QTN_FRMES_LABEL_CVIEW_CODE);
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(80, 55), TSize(80, 20));
m_pEditFirstName->SetTextL(&sTempFirstName);
//label Telephone
TBuf<32> sTelephone;
iCoeEnv->ReadResource(sTelephone, R_QTN_FRMES_LABEL_CVIEW_CODE);
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(80, 85), TSize(80, 20));
m_pEditTelephone->SetTextL(&sTempTelephone);
m_pEditTelephone->SetAknEditorInputMode(EAknEditorNumericInputMode);
m_pEditTelephone->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
m_pEditTelephone->SetMaxLength(16);
m_pEditFamilyName->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}
// Destructor
CModifyCardContainer::~CModifyCardContainer()
{
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 CModifyCardContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CModifyCardContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyCardContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CModifyCardContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CModifyCardContainer::CountComponentControls() const
{
return 6; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CModifyCardContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CModifyCardContainer::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;
}
}
// ---------------------------------------------------------
// CModifyCardContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyCardContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CModifyCardContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CModifyCardContainer::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;
}
// ---------------------------------------------------------
// CModifyCardContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyCardContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CModifyCardContainer::GetFamilyName(TDes& aFamName)
{
sTempFamilyName.Copy(aFamName);
}
void CModifyCardContainer::GetFirstName(TDes& aFirName)
{
sTempFirstName.Copy(aFirName);
}
void CModifyCardContainer::GetTelephone(TDes& aPhone)
{
sTempTelephone.Copy(aPhone);
}
void CModifyCardContainer::SetFamilyName(TDes& aFamName)
{
m_pEditFamilyName->GetText(aFamName);
}
void CModifyCardContainer::SetFirstName(TDes& aFirName)
{
m_pEditFirstName->GetText(aFirName);
}
void CModifyCardContainer::SetTelephone(TDes& aPhone)
{
m_pEditTelephone->GetText(aPhone);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -