detailinfocontainer.cpp
来自「symbian 3nd 实现短信息收发」· C++ 代码 · 共 216 行
CPP
216 行
/*
* ============================================================================
* Name : CDetailInfoContainer from CCoeControl, MCoeControlObserver
* Part of : DetailInfo
* 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 "DetailInfoContainer.h"
#include "FrMesAppUi.h"
#include "FrMesDB.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CDetailInfoContainer::CDetailInfoContainer()
{
m_pLabelName = NULL;
m_pLabelCode = NULL;
m_pLabelNameD = NULL;
m_pLabelCodeD = NULL;
}
// EPOC default constructor can leave.
void CDetailInfoContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//label sNameD && sCodeD
TBuf<32> sNameD;
TBuf<32> sCodeD;
TInt ntem;
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
ntem = pApp->m_pDB->m_CurrentIndex;//获得当前数组索引
pApp->m_pDB->GetItem(ntem,sNameD,sCodeD);//获得要显示的信息
m_pLabelNameD = new (ELeave) CEikLabel;
m_pLabelNameD->SetContainerWindowL(*this);
if(sNameD.Length()>8)//如果姓名大于8个字符,分两行显示
{
sNameD.Insert(8,_L("\n"));
}
m_pLabelNameD->SetTextL(sNameD);
m_pLabelNameD->SetExtent(TPoint(60, 40), TSize(100, 40));
m_pLabelCodeD = new (ELeave) CEikLabel;
m_pLabelCodeD->SetContainerWindowL(*this);
m_pLabelCodeD->SetTextL(sCodeD);
if(sNameD.Length()>8)//根据姓名长度设定电话显示的坐标
{
m_pLabelCodeD->SetExtent(TPoint(60, 80), TSize(110, 20));
}
else
m_pLabelCodeD->SetExtent(TPoint(60, 70), TSize(110, 20));
//label sName
TBuf<32> sName;
iCoeEnv->ReadResource(sName, R_QTN_FRMES_LABLE_NAME);
m_pLabelName = new (ELeave) CEikLabel;
m_pLabelName->SetContainerWindowL(*this);
m_pLabelName->SetTextL(sName);
m_pLabelName->SetExtent(TPoint(20, 40), m_pLabelName->MinimumSize());
//label sCode
TBuf<32> sCode;
iCoeEnv->ReadResource(sCode, R_QTN_FRMES_LABLE_TEL);
m_pLabelCode = new (ELeave) CEikLabel;
m_pLabelCode->SetContainerWindowL(*this);
m_pLabelCode->SetTextL(sCode);
if(sNameD.Length()>8)//根据姓名长度设置“电话:”标题的坐标
{
m_pLabelCode->SetExtent(TPoint(20, 80), m_pLabelCode->MinimumSize());
}
else
m_pLabelCode->SetExtent(TPoint(20, 70), m_pLabelCode->MinimumSize());
SetRect(aRect);
ActivateL();
}
// Destructor
CDetailInfoContainer::~CDetailInfoContainer()
{
if(m_pLabelName)
{
delete m_pLabelName;
m_pLabelName = NULL;
}
if(m_pLabelCode)
{
delete m_pLabelCode;
m_pLabelCode = NULL;
}
if(m_pLabelNameD)
{
delete m_pLabelNameD;
m_pLabelNameD = NULL;
}
if(m_pLabelCodeD)
{
delete m_pLabelCodeD;
m_pLabelCodeD = NULL;
}
}
// ---------------------------------------------------------
// CDetailInfoContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CDetailInfoContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CDetailInfoContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CDetailInfoContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CDetailInfoContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CDetailInfoContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CDetailInfoContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CDetailInfoContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pLabelName;
break;
case 1:
return m_pLabelCode;
break;
case 2:
return m_pLabelNameD;
break;
case 3:
return m_pLabelCodeD;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CDetailInfoContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CDetailInfoContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbCyan);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CDetailInfoContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CDetailInfoContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CDetailInfoContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CDetailInfoContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// End of File
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?