📄 registercontainer.cpp
字号:
/*
* ============================================================================
* Name : CRegisterContainer from CCoeControl, MCoeControlObserver
* Part of : Register
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#define MEM_FREE(q) if (NULL!=q){delete q; q = NULL;}
#include <FairyLand.rsg>
#include "FairyLand.hrh"
#include "RegisterContainer.h"
#include "FairyLandappui.h"
#include "RegisterView.h"
#include <eikseced.h>
#include <eiklabel.h> //for CEikLabel
#include <eikedwin.h> //for CEikEdwin
#include <barsread.h> //for resource reader
#include <AknNumSecEd.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CRegisterContainer::CRegisterContainer()
{
m_pLabel1 = NULL;
m_pLabel2 = NULL;
m_pLabel3 = NULL;
m_pEdit1 = NULL;
m_pEdit2 = NULL;
m_pRssEdit = NULL;
}
// EPOC default constructor can leave.
void CRegisterContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
TBuf<32> RegisterName;
CEikonEnv::Static()->ReadResource(RegisterName, R_QTN_MH_LOGON_LABEL_NAME);
TBuf<32> RegisterPassWord1;
CEikonEnv::Static()->ReadResource(RegisterPassWord1, R_QTN_MH_LOGON_LABEL_PASSWORD);
TBuf<32> RegisterPassWord2;
CEikonEnv::Static()->ReadResource(RegisterPassWord2, R_QTN_MH_LOGON_LABEL_PASSWORD_CONFIRM);
//Label1
m_pLabel1 = new(ELeave) CEikLabel;
m_pLabel1->SetContainerWindowL(*this);
m_pLabel1->SetTextL(RegisterName);
m_pLabel1->SetExtent(TPoint(20,20), m_pLabel1->MinimumSize());
//Label2
m_pLabel2 = new(ELeave) CEikLabel;
m_pLabel2->SetContainerWindowL(*this);
m_pLabel2->SetTextL(RegisterPassWord1);
m_pLabel2->SetExtent(TPoint(20,60), m_pLabel2->MinimumSize());
//Label3
m_pLabel3 = new(ELeave) CEikLabel;
m_pLabel3->SetContainerWindowL(*this);
m_pLabel3->SetTextL(RegisterPassWord2);
m_pLabel3->SetExtent(TPoint(20,100), m_pLabel3->MinimumSize());
//Edit1
m_pEdit1 = new(ELeave) CEikEdwin;
m_pEdit1->SetContainerWindowL(*this);
m_pEdit1->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
m_pEdit1->SetExtent(TPoint(70,20), TSize(80,20));
// m_pEdit1->SetTextL(&_L("name"));
m_pEdit1->SetFocus(ETrue);
//Edit2
m_pEdit2 = new(ELeave)CAknNumericSecretEditor;
m_pEdit2->SetContainerWindowL(*this);
TResourceReader read;
CEikonEnv::Static()->CreateResourceReaderLC(read,R_MY_SEC_ED);
m_pEdit2->ConstructFromResourceL(read);
CleanupStack::PopAndDestroy();
m_pEdit2->SetExtent( TPoint( 70,60 ),TSize( 80,20 ) );
m_pEdit2->SetFocus(EFalse);
//Edit from RSS
m_pRssEdit = new(ELeave) CAknNumericSecretEditor;
m_pRssEdit->SetContainerWindowL(*this);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader,R_MY_SEC_ED);
m_pRssEdit->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();
m_pRssEdit->SetExtent(TPoint(70,100), TSize(80,20));
m_pRssEdit->SetFocus(EFalse);
SetRect(aRect);
ActivateL();
}
// Destructor
CRegisterContainer::~CRegisterContainer()
{
MEM_FREE(m_pLabel1);
MEM_FREE(m_pLabel2);
MEM_FREE(m_pLabel3);
MEM_FREE(m_pEdit1);
MEM_FREE(m_pEdit2);
MEM_FREE(m_pRssEdit);
}
// ---------------------------------------------------------
// CRegisterContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CRegisterContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CRegisterContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CRegisterContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CRegisterContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CRegisterContainer::CountComponentControls() const
{
return 6; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CRegisterContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CRegisterContainer::ComponentControl(TInt aIndex) const
{
// return NULL;
switch (aIndex)
{
case 0:
{
return m_pLabel1;
break;
}
case 1:
{
return m_pLabel2;
break;
}
case 2:
{
return m_pLabel3;
break;
}
case 3:
{
return m_pEdit1;
break;
}
case 4:
{
return m_pEdit2;
break;
}
case 5:
{
return m_pRssEdit;
break;
}
default:
{
return NULL;
break;
}
}
}
// ---------------------------------------------------------
// CRegisterContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CRegisterContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbCyan);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CRegisterContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CRegisterContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
//return EKeyWasNotConsumed;
if (m_pEdit1)
{
if (m_pEdit1->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit1->SetFocus(EFalse);
m_pEdit2->SetFocus(ETrue);
m_pRssEdit->SetFocus(EFalse);
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit1->SetFocus(EFalse);
m_pEdit2->SetFocus(EFalse);
m_pRssEdit->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEdit1->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEdit2)
{
if (m_pEdit2->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit1->SetFocus(EFalse);
m_pEdit2->SetFocus(EFalse);
m_pRssEdit->SetFocus(ETrue);
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit2->SetFocus(EFalse);
m_pEdit1->SetFocus(ETrue);
m_pRssEdit->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_pEdit2->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pRssEdit)
{
if (m_pRssEdit->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit1->SetFocus(ETrue);
m_pEdit2->SetFocus(EFalse);
m_pRssEdit->SetFocus(EFalse);
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit1->SetFocus(EFalse);
m_pRssEdit->SetFocus(EFalse);
m_pEdit2->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pRssEdit->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CRegisterContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CRegisterContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CRegisterContainer::GetLoginName(TDes &aName)
{
m_pEdit1->GetText(aName);
}
void CRegisterContainer::GetLoginPassWord1(TDes &password1)
{
m_pEdit2->GetText(password1);
}
void CRegisterContainer::GetLoginPassWord2(TDes &password2)
{
m_pRssEdit->GetText(password2);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -