?? logincontainer.cpp
字號(hào):
/*
* ============================================================================
* Name : CLoginContainer from CCoeControl, MCoeControlObserver
* Part of : Hello
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "LoginContainer.h"
#include <aknviewappui.h>
#include "Common.h"
#include <eiklabel.h> //for CEikLabel
#include <eikedwin.h> //for CEikEdit
#include <aknnotewrappers.h>
#include <barsread.h>
#include <aknnotewrappers.h>
#include <aknnumseced.h>
#include "EveryDayAppUi.h"
#include "File.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CLoginContainer::CLoginContainer()
{
m_pLabel1 = NULL;
m_pEdit1 = NULL;
m_pLabel2 = NULL;
m_pEdit2 = NULL;
}
// EPOC default constructor can leave.
void CLoginContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//Label
TBuf<32> Text;
iEikonEnv->ReadResource(Text,R_QTN_MH_USERNAME_TITLE);
m_pLabel1 = new(ELeave) CEikLabel;
m_pLabel1->SetContainerWindowL(*this);
m_pLabel1->SetTextL(Text);
m_pLabel1->SetExtent(TPoint(10,20), m_pLabel1->MinimumSize());
//Edit
m_pEdit1 = new(ELeave) CEikEdwin;
m_pEdit1->SetContainerWindowL(*this);
m_pEdit1->ConstructL(EAknEditorFlagDefault, 10, 11, 1);
m_pEdit1->SetExtent(TPoint(70,20), TSize(80,18)); //TPoint坐標(biāo)起點(diǎn),TSize方框大小
m_pEdit1->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);//設(shè)置只能輸入數(shù)字輸入模式
m_pEdit1->SetFocus(ETrue);//焦點(diǎn)
//Label
iEikonEnv->ReadResource(Text, R_QTN_MH_PASSWORD_TITLE);
m_pLabel2 = new(ELeave) CEikLabel;
m_pLabel2->SetContainerWindowL(*this);
m_pLabel2->SetTextL(Text);//m_pLabel2->SetTextL(_L("Pass Word :"));
m_pLabel2->SetExtent(TPoint(10,60), m_pLabel2->MinimumSize());
//Edit
TResourceReader reader1;
iCoeEnv->CreateResourceReaderLC(reader1,R_PASSWORD_BUFNUM);
m_pEdit2 = new (ELeave) CAknNumericSecretEditor() ;
m_pEdit2->SetContainerWindowL(*this);
m_pEdit2->ConstructFromResourceL(reader1);
CleanupStack::PopAndDestroy();
m_pEdit2->SetExtent(TPoint(70,60), TSize(80,18));
m_pEdit2->SetFocus(EFalse);
m_pEdit2->SetBorder(ENone);
SetRect(aRect);
ActivateL();
}
// Destructor
CLoginContainer::~CLoginContainer()
{
MEM_FREE(m_pLabel1);
MEM_FREE(m_pEdit1);
MEM_FREE(m_pLabel2);
MEM_FREE(m_pEdit2);
}
// ---------------------------------------------------------
// CLoginContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CLoginContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CLoginContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CLoginContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CLoginContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CLoginContainer::ComponentControl(TInt aIndex) const
{
// return NULL;
switch(aIndex)
{
case 0:
{
return m_pLabel1;
break;
}
case 1:
{
return m_pEdit1;
break;
}
case 2:
{
return m_pLabel2;
break;
}
case 3:
{
return m_pEdit2;
break;
}
default:
{
return NULL;
break;
}
}
}
// ---------------------------------------------------------
// CLoginContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbWhite);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
//畫一長方形
if(m_pEdit1->IsFocused()) // username 獲得焦點(diǎn)
{
gc.SetPenColor(KRgbRed);
}
else
{
gc.SetPenColor(KRgbBlack);
}
gc.SetPenStyle(CGraphicsContext::ESolidPen);
TRect rect1;
rect1.iTl = TPoint(69, 18);
rect1.iBr = TPoint(152,40);
gc.DrawRect(rect1);
if(m_pEdit2->IsFocused())
{
gc.SetPenColor(KRgbRed);
}
else
{
gc.SetPenColor(KRgbBlack);
}
//畫一長方形
gc.SetPenStyle(CGraphicsContext::ESolidPen);
TRect rect2;
rect2.iTl = TPoint(69, 58);
rect2.iBr = TPoint(152, 80);
gc.DrawRect(rect2);
}
// ---------------------------------------------------------
// CLoginContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CLoginContainer::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);
DrawDeferred();
return EKeyWasNotConsumed;
}
return m_pEdit1->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEdit2)
{
if(m_pEdit2->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit1->SetFocus(ETrue);
m_pEdit2->SetFocus(EFalse);
DrawDeferred();
return EKeyWasNotConsumed;
}
return m_pEdit2->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CLoginContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CLoginContainer::GetName(TDes& aName)
{
m_pEdit1->GetText(aName);
}
void CLoginContainer::GetPassWord(TDes& aPassword)
{
m_pEdit2->GetText(aPassword);
}
// End of File
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -