📄 creatinfocontainer.cpp
字号:
/*
* ============================================================================
* Name : CCreatInfoContainer from CCoeControl, MCoeControlObserver
* Part of : CreatInfo
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <eiklabel.h> // for example label control
#include <barsread.h> // for resource reader
#include <eikedwin.h> // for CEikEdwin
#include <eikgted.h> // for CEikGlobalTextEditor
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "CreatInfoContainer.h"
#include "eikenv.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CCreatInfoContainer::CCreatInfoContainer()
{
m_pLabelName = NULL;
m_pLabelCode = NULL;
m_pEditName = NULL;
m_pEditCode = NULL;
}
// EPOC default constructor can leave.
void CCreatInfoContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//label sName
TBuf<32> sName;
iCoeEnv->ReadResource(sName, R_QTN_FRMES_LABEL_CVIEW_NAME);
m_pLabelName = new (ELeave) CEikLabel;
m_pLabelName->SetContainerWindowL(*this);
m_pLabelName->SetTextL(sName);
m_pLabelName->SetExtent(TPoint(20, 30), m_pLabelName->MinimumSize());
//edit sName new
m_pEditName = new (ELeave) CEikEdwin(/*TGulBorder::ESingleBlack*/);
m_pEditName->SetContainerWindowL(*this);
m_pEditName->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 16, 1);
m_pEditName->SetExtent(TPoint(80, 25), TSize(80, 20));
//label sCode
TBuf<32> sCode;
iCoeEnv->ReadResource(sCode, R_QTN_FRMES_LABEL_CVIEW_CODE);
m_pLabelCode = new (ELeave) CEikLabel;
m_pLabelCode->SetContainerWindowL(*this);
m_pLabelCode->SetTextL(sCode);
m_pLabelCode->SetExtent(TPoint(20, 60), m_pLabelCode->MinimumSize());
//edit sCode rss
m_pEditCode=new(ELeave)CEikEdwin;
m_pEditCode->SetContainerWindowL(*this);
// TResourceReader reader;
// iEikonEnv->CreateResourceReaderLC(reader,R_CREATEINFO_INCODE_EDITOR);
// m_pEditCode->ConstructFromResourceL(reader);
// CleanupStack::PopAndDestroy();
m_pEditCode->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 16, 1);
m_pEditCode->SetExtent(TPoint(80, 55), TSize(80, 20));
m_pEditCode->SetAknEditorInputMode(EAknEditorNumericInputMode);
m_pEditCode->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);
m_pEditCode->SetMaxLength(16);
m_pEditName->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}
// Destructor
CCreatInfoContainer::~CCreatInfoContainer()
{
if(m_pLabelName)
{
delete m_pLabelName;
m_pLabelName = NULL;
}
if(m_pLabelCode)
{
delete m_pLabelCode;
m_pLabelCode = NULL;
}
if(m_pEditName)
{
delete m_pEditName;
m_pEditName = NULL;
}
if(m_pEditCode)
{
delete m_pEditCode;
m_pEditCode = NULL;
}
}
// ---------------------------------------------------------
// CCreatInfoContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreatInfoContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CCreatInfoContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreatInfoContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CCreatInfoContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CCreatInfoContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CCreatInfoContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CCreatInfoContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pLabelName;
break;
case 1:
return m_pEditName;
break;
case 2:
return m_pLabelCode;
break;
case 3:
return m_pEditCode;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CCreatInfoContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreatInfoContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbCyan);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CCreatInfoContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CCreatInfoContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pEditName)
{
if (m_pEditName->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEditName->SetFocus(EFalse);
m_pEditCode->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEditName->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEditCode)
{
if (m_pEditCode->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEditCode->SetFocus(EFalse);
m_pEditName->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEditCode->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CCreatInfoContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreatInfoContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CCreatInfoContainer::GetInput (TDes& aName, TDes& aCode)
{
m_pEditName->GetText(aName);
m_pEditCode->GetText(aCode);
return;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -