📄 orclogincontainer.cpp
字号:
#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <eiklabel.h>
#include <eikedwin.h>
#include <Aknnumseced.h>
#include <barsread.h>
#include <eikenv.h>
#include <eikseced.h> // CAknNumericSecretEditor
#include "ORCLoginContainer.h"
#include "Orcer.rsg"
CORCLoginContainer::CORCLoginContainer()
{
m_pUserPhon = NULL;
m_pUserPsw = NULL;
m_pAfirmPsw = NULL;
m_pLabName = NULL;
m_pLabPsw = NULL;
m_pLabFirmPsw = NULL;
iState = 0;
}
// EPOC default constructor can leave.
void CORCLoginContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetListBox();
SetRect( aRect );
ActivateL();
}
// destructor
CORCLoginContainer::~CORCLoginContainer()
{
if(m_pAfirmPsw)
{
delete m_pAfirmPsw;
m_pAfirmPsw = NULL;
}
if(m_pLabFirmPsw)
{
delete m_pLabFirmPsw;
m_pLabFirmPsw = NULL;
}
if(m_pLabPsw)
{
delete m_pLabPsw;
m_pLabPsw = NULL;
}
if(m_pLabName)
{
delete m_pLabName;
m_pLabName = NULL;
}
if(m_pUserPhon)
{
delete m_pUserPhon;
m_pUserPhon = NULL;
}
if(m_pUserPsw)
{
delete m_pUserPsw;
m_pUserPsw = NULL;
}
}
void CORCLoginContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CORCLoginContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CORCLoginContainer::CountComponentControls() const
{
// return number of controls inside this container
return 6;
}
// ---------------------------------------------------------
// CORCLoginContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CORCLoginContainer::ComponentControl( TInt aIndex ) const
{
switch(aIndex)
{
case 0:
return m_pLabName;
break;
case 1:
return m_pLabPsw;
break;
case 2:
return m_pUserPhon;
break;
case 3:
return m_pUserPsw;
break;
case 4:
return m_pLabFirmPsw;
break;
case 5:
return m_pAfirmPsw;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CORCLoginContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CORCLoginContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
gc.Clear(Rect());
// gc.DrawRect(TRect(TPoint(10, 10), TSize(20, 20)));
}
// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
// const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CORCLoginContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
if (m_pUserPhon)
{
if (m_pUserPhon->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pUserPhon->SetFocus(EFalse);
m_pUserPsw->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pUserPhon->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pUserPsw)
{
if (m_pUserPsw->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pUserPsw->SetFocus(EFalse);
m_pUserPhon->SetFocus(ETrue);
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow)&&(iState != 0))
{
m_pUserPsw->SetFocus(EFalse);
m_pAfirmPsw->SetFocus(ETrue);
iState = 0;
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow)&&(iState == 0))
{
m_pUserPsw->SetFocus(EFalse);
m_pUserPhon->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pUserPsw->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pAfirmPsw)
{
if (m_pAfirmPsw->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pAfirmPsw->SetFocus(EFalse);
m_pUserPsw->SetFocus(ETrue);
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pAfirmPsw->SetFocus(EFalse);
m_pUserPhon->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pAfirmPsw->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
void CORCLoginContainer::SetListBox()
{
m_pLabName = new (ELeave) CEikLabel;
m_pLabName->SetContainerWindowL(*this);
TBuf<32> buf;
CEikonEnv::Static()->ReadResource(buf, R_QTN_LOGIN_NUMBER);
m_pLabName->SetTextL(buf);
m_pLabName->SetExtent( TPoint(10,10), m_pLabName->MinimumSize() );
m_pLabPsw = new (ELeave) CEikLabel;
m_pLabPsw->SetContainerWindowL(*this);
TBuf<32> sbuf;
CEikonEnv::Static()->ReadResource(sbuf, R_QTN_LOGIN_PASSWORD);
m_pLabPsw->SetTextL(sbuf);
m_pLabPsw->SetExtent( TPoint(10,50), m_pLabName->MinimumSize() );
m_pUserPhon = new (ELeave) CEikEdwin(TGulBorder::ESingleBlack);
m_pUserPhon->SetContainerWindowL(*this);
m_pUserPhon->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 11, 11, 1);
m_pUserPhon->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
m_pUserPhon->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
m_pUserPhon->SetAknEditorFlags(EAknEditorFlagLatinInputModesOnly);
m_pUserPhon->SetExtent(TPoint(60, 10), TSize(100, 20));
m_pUserPhon->SetFocus(ETrue);
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader,R_PASSWORD_STAR_BUF);
m_pUserPsw = new (ELeave) CAknNumericSecretEditor() ;
m_pUserPsw->SetContainerWindowL(*this);
m_pUserPsw->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();
m_pUserPsw->SetExtent(TPoint(60, 50), TSize(100, 20));
m_pUserPsw->SetFocus(EFalse);
m_pLabFirmPsw = new(ELeave) CEikLabel;
m_pLabFirmPsw->SetContainerWindowL(*this);
TBuf<32> sbuf1;
CEikonEnv::Static()->ReadResource(sbuf1, R_QTN_LOGIN_AFFIRM);
m_pLabFirmPsw->SetTextL(sbuf1);
m_pLabFirmPsw->SetExtent( TPoint(10,90), m_pLabFirmPsw->MinimumSize() );
m_pLabFirmPsw->MakeVisible(EFalse);
TResourceReader aFirmReader;
iCoeEnv->CreateResourceReaderLC(aFirmReader,R_PASSWORD_STAR_AFIRM_BUF);
m_pAfirmPsw = new (ELeave) CAknNumericSecretEditor() ;
m_pAfirmPsw->SetContainerWindowL(*this);
m_pAfirmPsw->ConstructFromResourceL(aFirmReader);
CleanupStack::PopAndDestroy();
m_pAfirmPsw->SetExtent(TPoint(60, 90), TSize(100, 20));
m_pAfirmPsw->SetFocus(EFalse);
m_pAfirmPsw->MakeVisible(EFalse);
}
void CORCLoginContainer::SetVisible()
{
m_pLabFirmPsw->MakeVisible(ETrue);
m_pAfirmPsw->MakeVisible(ETrue);
}
void CORCLoginContainer::SetUnVisible()
{
m_pLabFirmPsw->MakeVisible(EFalse);
m_pAfirmPsw->MakeVisible(EFalse);
}
void CORCLoginContainer::SetState(TInt aState)
{
iState = aState;
}
void CORCLoginContainer::GetUserPhon(TDes& aPhon)
{
m_pUserPhon->GetText(aPhon);
}
void CORCLoginContainer::GetUserPsw(TDes& aPsw)
{
m_pUserPsw->GetText(aPsw);
}
void CORCLoginContainer::GetAfirmPws(TDes& aAfirmPsw)
{
m_pAfirmPsw->GetText(aAfirmPsw);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -