📄 shenxianonecontainer.cpp
字号:
/*
* ============================================================================
* Name : CShenxianOneContainer from CCoeControl, MCoeControlObserver
* Part of : ShenxianOne
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <Shenxian.rsg>
#include "Shenxian.hrh"
#include "ShenxianOneContainer.h"
#include <eiklabel.h>
#include <eikedwin.h>
#include <barsread.h>
#include <eikenv.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CShenxianOneContainer::CShenxianOneContainer()
{
m_plabelName = NULL;
m_plabelPassword = NULL;
m_peditName = NULL;
m_peditPassword = NULL;
}
// EPOC default constructor can leave.
void CShenxianOneContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
/************设置标签****************************************************************/
m_plabelName = new (ELeave) CEikLabel;
CleanupStack::PushL(m_plabelName);
m_plabelName->SetContainerWindowL(*this);
TBuf<32> sTmplabelName;
CEikonEnv::Static()->ReadResource(sTmplabelName,R_QTN_MH_NAME );
m_plabelName->SetTextL(sTmplabelName);
m_plabelName->SetExtent(TPoint(10,20),m_plabelName->MinimumSize( ) );
CleanupStack::Pop( m_plabelName );
/*************************************************************************************/
m_plabelPassword = new (ELeave) CEikLabel;
CleanupStack::PushL(m_plabelPassword);
m_plabelPassword->SetContainerWindowL(*this);
TBuf<32> sTmplabelPass;
CEikonEnv::Static()->ReadResource(sTmplabelPass,R_QTN_MH_PASSWORD );
m_plabelPassword->SetTextL(sTmplabelPass);
m_plabelPassword->SetExtent(TPoint(10,60),m_plabelPassword->MinimumSize( ) );
CleanupStack::Pop( m_plabelPassword );
/***********设置编辑框****************************************************************/
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader,R_AKNEXEDITOR_ONE_EDWIN);
m_peditName = new(ELeave) CEikEdwin;
m_peditName->SetContainerWindowL(*this);
m_peditName->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy( );
m_peditName->SetAknEditorCurrentInputMode(EAknEditorTextInputMode);
m_peditName->SetExtent(TPoint(70,20),TSize(80,20));
m_peditName->SetTextL(&_L(""));
m_peditName->SetFocus(ETrue);
/*********************************************************************************/
TResourceReader readeragein;
iCoeEnv->CreateResourceReaderLC(readeragein,R_AKNEXEDITOR_ONE_EDWIN);
m_peditPassword = new(ELeave) CEikEdwin;
m_peditPassword->SetContainerWindowL(*this);
m_peditPassword->ConstructFromResourceL(readeragein);
CleanupStack::PopAndDestroy();
m_peditPassword->SetAknEditorCurrentInputMode(EAknEditorSecretAlphaInputMode);
m_peditPassword->SetExtent(TPoint(70,60),TSize(80,20));
m_peditPassword->SetTextL(&_L(""));
m_peditPassword->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}
// Destructor
CShenxianOneContainer::~CShenxianOneContainer()
{
DELPTR(m_plabelName);
DELPTR(m_plabelPassword);
DELPTR(m_peditName);
DELPTR(m_peditPassword);
}
// ---------------------------------------------------------
// CShenxianOneContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianOneContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CShenxianOneContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianOneContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CShenxianOneContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CShenxianOneContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CShenxianOneContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CShenxianOneContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
{
return m_plabelName;
break;
}
case 1:
{
return m_plabelPassword;
break;
}
case 2:
{
return m_peditName;
break;
}
case 3:
{
return m_peditPassword;
break;
}
default:
{
return NULL;
break;
}
}
}
// ---------------------------------------------------------
// CShenxianOneContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianOneContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbRed);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
// const CFont *nor = CEikonEnv::Static()->TitleFont();
// gc.UseFont(nor);
// gc.DrawText(*(message->GetName()),TPoint(20,60));
// gc.DrawText(*(message->GetTel()),TPoint(20,80));
// gc.DrawText(*(message->GetEmail()),TPoint(20,100));
// gc.DrawText(*(message->GetAddress()),TPoint(20,120));
// gc.DiscardFont();
}
// ---------------------------------------------------------
// CShenxianOneContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CShenxianOneContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_peditName)
{
if (m_peditName->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_peditName->SetFocus(EFalse);
m_peditPassword->SetFocus(ETrue);
return EKeyWasConsumed;
}
else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_peditName->SetFocus(ETrue);
m_peditPassword->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_peditName->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_peditPassword)
{
if (m_peditPassword->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_peditName->SetFocus(EFalse);
m_peditPassword->SetFocus(ETrue);
return EKeyWasConsumed;
}
else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_peditName->SetFocus(ETrue);
m_peditPassword->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_peditPassword->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CShenxianOneContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianOneContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -