?? registercontainer.cpp
字號:
/*
* ============================================================================
* Name : CRegisterContainer from CCoeControl, MCoeControlObserver
* Part of : Hello
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "RegisterContainer.h"
#include <aknviewappui.h> //for iEikonEnv
#include "Common.h"
#include <eiklabel.h>
#include "EveryDayAppUi.h"
#include <eikedwin.h>
#include <aknnotewrappers.h>
#include <barsread.h>
#include <aknnumseced.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CRegisterContainer::CRegisterContainer()
{
m_pLabel1 = NULL;
m_pEdit1 = NULL;
m_pLabel2 = NULL;
m_pEdit2 = NULL;
m_pLabel3 = NULL;
m_pEdit3 = NULL;
}
// EPOC default constructor can leave.
void CRegisterContainer::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());
iEikonEnv->ReadResource(Text,R_QTN_MH_PASSWORD_TITLE);
m_pLabel2=new(ELeave) CEikLabel;
m_pLabel2->SetContainerWindowL(*this);
m_pLabel2->SetTextL(Text);
m_pLabel2->SetExtent(TPoint(10,60), m_pLabel2->MinimumSize());
iEikonEnv->ReadResource(Text,R_QTN_MH_ENSUREPW_TITLE);
m_pLabel3=new(ELeave) CEikLabel;
m_pLabel3->SetContainerWindowL(*this);
m_pLabel3->SetTextL(Text);
m_pLabel3->SetExtent(TPoint(10,100), m_pLabel3->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));
m_pEdit1->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);//設置只能輸入數字輸入模式
m_pEdit1->SetFocus(ETrue);//焦點
m_pEdit2 = new(ELeave) CEikEdwin;
m_pEdit2->SetContainerWindowL(*this);
m_pEdit2->ConstructL(EAknEditorFlagDefault, 10, 6, 1);
m_pEdit2->SetExtent(TPoint(70,60), TSize(80,18));
m_pEdit2->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);//設置只能輸入數字輸入模式
m_pEdit2->SetTextL(&_L(""));
m_pEdit2->SetFocus(EFalse);
m_pEdit3 = new(ELeave) CEikEdwin;
m_pEdit3->SetContainerWindowL(*this);
m_pEdit3->ConstructL(EAknEditorFlagDefault, 10, 6, 1);
m_pEdit3->SetExtent(TPoint(70,100), TSize(80,18));
m_pEdit3->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
m_pEdit3->SetTextL(&_L(""));
m_pEdit3->SetFocus(EFalse);
SetRect(aRect);
ActivateL();
}
// Destructor
CRegisterContainer::~CRegisterContainer()
{
MEM_FREE(m_pLabel1);
MEM_FREE(m_pEdit1);
MEM_FREE(m_pLabel2);
MEM_FREE(m_pEdit2);
MEM_FREE(m_pLabel3);
MEM_FREE(m_pEdit3);
}
// ---------------------------------------------------------
// 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_pEdit3;
break;
}
default:
{
return NULL;
}
}
}
// ---------------------------------------------------------
// 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(KRgbWhite);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
//畫一長方形
if(m_pEdit1->IsFocused()) // username 獲得焦點
{
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);
if(m_pEdit3->IsFocused())
{
gc.SetPenColor(KRgbRed);
}
else
{
gc.SetPenColor(KRgbBlack);
}
//畫一長方形(TPoint(70,100), TSize(80,18));
gc.SetPenStyle(CGraphicsContext::ESolidPen);
TRect rect3;
rect3.iTl = TPoint(69, 99);
rect3.iBr = TPoint(152,119);
gc.DrawRect(rect3);
}
// ---------------------------------------------------------
// CRegisterContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CRegisterContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (NULL != m_pEdit1)
{
if (m_pEdit1->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit1->SetFocus(EFalse);
m_pEdit2->SetFocus(ETrue);
m_pEdit3->SetFocus(EFalse);
DrawDeferred();
return EKeyWasConsumed;
}
return m_pEdit1->OfferKeyEventL(aKeyEvent, aType);
}
}
if (NULL != m_pEdit2)
{
if (m_pEdit2->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit2->SetFocus(EFalse);
m_pEdit3->SetFocus(EFalse);
m_pEdit1->SetFocus(ETrue);
DrawDeferred();
return EKeyWasConsumed;
}
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit2->SetFocus(EFalse);
m_pEdit3->SetFocus(ETrue);
m_pEdit1->SetFocus(EFalse);
DrawDeferred();
return EKeyWasConsumed;
}
return m_pEdit2->OfferKeyEventL(aKeyEvent, aType);
}
}
if (NULL != m_pEdit3)
{
if (m_pEdit3->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit3->SetFocus(EFalse);
m_pEdit2->SetFocus(ETrue);
m_pEdit1->SetFocus(EFalse);
DrawDeferred();
/* DrawNow();*/
return EKeyWasConsumed;
}
return m_pEdit3->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::GetUserInf(TDes& aName,TDes& aWord,TDes& aPswd)
// {
// m_pEdit1->GetText(aName);
// m_pEdit2->GetText(aWord);
// m_pEdit3->GetText(aPswd);
// }
void CRegisterContainer::GetName(TDes& aName)
{
m_pEdit1->GetText(aName);
}
void CRegisterContainer::GetPassWord(TDes& aWord)
{
m_pEdit2->GetText(aWord);
}
void CRegisterContainer::GetPswd(TDes& aPswd)
{
m_pEdit3->GetText(aPswd);
}
// End of File
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -