📄 bookoperationcontainer.cpp
字号:
/*
* ============================================================================
* Name : CBookOperationContainer from CCoeControl, MCoeControlObserver
* Part of : BookOperation
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <FairyLand.rsg>
#include "FairyLand.hrh"
#include "BookOperationContainer.h"
#include <eiklabel.h> //for CEikLabel
#include <eikedwin.h> //for CEikEdit
#include <barsread.h> //for resource reader
#include <eikenv.h> //for CEikonEnv
#include "FairyLandAppUi.h"
#include <fbs.h> //for CFbsBitmap
// ================= MEMBER BookOperationS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CBookOperationContainer::CBookOperationContainer()
{
m_pLabel = NULL;
m_pEdit = NULL;
m_pLabel2 = NULL;
m_pEdit2 = NULL;
m_pLabel3 = NULL;
m_pEdit3 = NULL;
}
// EPOC default constructor can leave.
void CBookOperationContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
TBuf<32> FamilyName;
CEikonEnv::Static()->ReadResource(FamilyName, R_QTN_MH_FAMILY_NAME);
TBuf<32> GivenName;
CEikonEnv::Static()->ReadResource(GivenName, R_QTN_MH_GIVE_NAME);
TBuf<32> Moblile;
CEikonEnv::Static()->ReadResource(Moblile, R_QTN_MH_MOBLILE);
m_pLabel = new(ELeave) CEikLabel;
m_pLabel->SetContainerWindowL(*this);
m_pLabel->SetTextL( FamilyName );
m_pLabel->SetExtent(TPoint(10,20), m_pLabel->MinimumSize());
m_pEdit = new(ELeave)CEikEdwin;
m_pEdit->SetContainerWindowL(*this);
m_pEdit->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
m_pEdit->SetExtent(TPoint(70,20), TSize(80,20));
// m_pEdit->SetTextL(&_L(""));
m_pEdit->SetFocus(ETrue);
m_pLabel2 = new(ELeave) CEikLabel;
m_pLabel2->SetContainerWindowL(*this);
m_pLabel2->SetTextL( GivenName );
m_pLabel2->SetExtent(TPoint(10,60), m_pLabel2->MinimumSize());
m_pEdit2 = new(ELeave)CEikEdwin;
m_pEdit2->SetContainerWindowL(*this);
m_pEdit2->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
m_pEdit2->SetExtent(TPoint(70,60), TSize(80,20));
// m_pEdit2->SetTextL(&_L(""));
m_pLabel3 = new(ELeave) CEikLabel;
m_pLabel3->SetContainerWindowL(*this);
m_pLabel3->SetTextL( Moblile );
m_pLabel3->SetExtent(TPoint(10,100), m_pLabel3->MinimumSize());
//Edit3
m_pEdit3 = new(ELeave)CEikEdwin;
m_pEdit3->SetContainerWindowL(*this);
m_pEdit3->ConstructL(EAknEditorFlagDefault, 11, 11, 1);
m_pEdit3->SetExtent(TPoint(70,100), TSize(80,20));
m_pEdit3->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
m_pEdit3->SetAknEditorAllowedInputModes(2);
// m_pEdit3->SetTextL(&_L(""));
SetRect(aRect);
ActivateL();
}
// Destructor
CBookOperationContainer::~CBookOperationContainer()
{
MEM_FREE(m_pLabel);
MEM_FREE(m_pEdit);
MEM_FREE(m_pLabel2);
MEM_FREE(m_pEdit2);
MEM_FREE(m_pLabel3);
MEM_FREE(m_pEdit3);
}
// ---------------------------------------------------------
// CBookOperationContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookOperationContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CBookOperationContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookOperationContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CBookOperationContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CBookOperationContainer::CountComponentControls() const
{
return 6; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CBookOperationContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CBookOperationContainer::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
{
return m_pLabel;
}
case 1:
{
return m_pEdit;
}
case 2:
{
return m_pLabel2;
}
case 3:
{
return m_pEdit2;
}
case 4:
{
return m_pLabel3;
}
case 5:
{
return m_pEdit3;
}
default:
{
return NULL;
}
}
}
// ---------------------------------------------------------
// CBookOperationContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookOperationContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbYellow);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CBookOperationContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CBookOperationContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pEdit)
{
if (m_pEdit->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit->SetFocus(EFalse);
m_pEdit2->SetFocus(ETrue);
m_pEdit3->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_pEdit->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEdit2)
{
if (m_pEdit2->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit->SetFocus(ETrue);
m_pEdit2->SetFocus(EFalse);
m_pEdit3->SetFocus(EFalse);
return EKeyWasConsumed;
}
else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEdit->SetFocus(EFalse);
m_pEdit3->SetFocus(ETrue);
m_pEdit2->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_pEdit2->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEdit3)
{
if (m_pEdit3->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit->SetFocus(EFalse);
m_pEdit2->SetFocus(ETrue);
m_pEdit3->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_pEdit3->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CBookOperationContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookOperationContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CBookOperationContainer::GetLoginName(TDes &aFamilyName, TDes &aGivenName, TDes &aMobile)
{
m_pEdit->GetText(aFamilyName);
m_pEdit2->GetText(aGivenName);
m_pEdit3->GetText(aMobile);
}
void CBookOperationContainer::SetLoginName(HBufC* &pFamily, HBufC* &pGiven, HBufC* &pMobile)
{
m_pEdit->SetTextL(pFamily);
m_pEdit2->SetTextL(pGiven);
m_pEdit3->SetTextL(pMobile);
}
void CBookOperationContainer::SetEditChange( )
{
m_pEdit->SetReadOnly(ETrue);
m_pEdit2->SetReadOnly(ETrue);
m_pEdit3->SetReadOnly(ETrue);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -