📄 lookovermemocontainer.cpp
字号:
/*
* ============================================================================
* Name : CLookOverMemoContainer from CCoeControl, MCoeControlObserver
* Part of : LookOverMemo
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
#define MEM_FREE(p) if (NULL!=p){delete p; p = NULL;} //标签控件新加
// INCLUDE FILES
#include <FairyLand.rsg>
#include "FairyLand.hrh"
#include "LookOverMemoContainer.h"
#include <eiklabel.h> //for CEikLabel
#include <eikedwin.h> //for CEikEdwin
#include <barsread.h> //for resource reade
#include "FairyLandAppUi.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CLookOverMemoContainer::CLookOverMemoContainer()
{
m_pLabel = NULL;
m_pEdit = NULL;
m_pLabel2 = NULL;
m_pEdit2 = NULL;
}
// EPOC default constructor can leave.
void CLookOverMemoContainer::ConstructL(const TRect& aRect,TInt aIndex)
{
CreateWindowL();
CFairyLandAppUi* pApp=(CFairyLandAppUi*)CEikonEnv::Static()->AppUi();
iArray=pApp->GetArray();
//Label
m_pLabel=new(ELeave) CEikLabel;
m_pLabel->SetContainerWindowL(*this);
TBuf<20> buf1;
CEikonEnv::Static()->ReadResource(buf1, R_QTN_MH_TITLE);
m_pLabel->SetTextL(buf1);
m_pLabel->SetExtent(TPoint(10,10), m_pLabel->MinimumSize());
// m_pLabel->SetTextL(_L("Title: "));
//Edit
m_pEdit = new(ELeave)CEikEdwin;
m_pEdit->SetContainerWindowL(*this);
TBuf<32> Title;
Title.Copy((iArray->At(aIndex).GetTitle())->Des());
m_pEdit->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
m_pEdit->SetExtent(TPoint(50,10), TSize(110,20));
m_pEdit->SetTextL(&Title);
m_pEdit->SetFocus(EFalse);
//Label2
m_pLabel2=new(ELeave) CEikLabel;
m_pLabel2->SetContainerWindowL(*this);
TBuf<20> buf2;
CEikonEnv::Static()->ReadResource(buf2, R_QTN_MH_CONTENT);
m_pLabel2->SetTextL(buf2);
m_pLabel2->SetExtent(TPoint(10,40), m_pLabel->MinimumSize());
//Edit2
m_pEdit2 = new(ELeave) CEikEdwin;
m_pEdit2->SetContainerWindowL(*this);
m_pEdit2->ConstructL(EAknEditorFlagDefault, 10, 500, 10);
m_pEdit2->SetExtent(TPoint(50,40), TSize(110,90));
if (iArray->At(aIndex).GetContent()!=NULL)
{
TBuf<500> Content;
Content.Copy((iArray->At(aIndex).GetContent())->Des());
m_pEdit2->SetTextL(&Content);
}
SetRect(aRect);
ActivateL();
}
// Destructor
CLookOverMemoContainer::~CLookOverMemoContainer()
{
MEM_FREE(m_pLabel);
MEM_FREE(m_pEdit);
MEM_FREE(m_pLabel2);
MEM_FREE(m_pEdit2);
}
// ---------------------------------------------------------
// CLookOverMemoContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLookOverMemoContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CLookOverMemoContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLookOverMemoContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CLookOverMemoContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CLookOverMemoContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CLookOverMemoContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CLookOverMemoContainer::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
{
return m_pLabel;
break;
}
case 1:
{
return m_pEdit;
break;
}
case 2:
{
return m_pLabel2;
break;
}
case 3:
{
return m_pEdit2;
break;
}
default:
{
return NULL;
break;
}
}
}
// ---------------------------------------------------------
// CLookOverMemoContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLookOverMemoContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbCyan);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CLookOverMemoContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CLookOverMemoContainer::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);
return EKeyWasConsumed;
}
return m_pEdit->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEdit2)
{
if (m_pEdit2->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pEdit2->SetFocus(EFalse);
m_pEdit->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEdit2->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CLookOverMemoContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLookOverMemoContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CLookOverMemoContainer::GetLoginName(TDes &aName, TDes &passwd)
{
m_pEdit->GetText(aName);
m_pEdit2->GetText(passwd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -