📄 tempcontainer.cpp
字号:
#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <helloldci.mbg>
#include <HelloLDCI.rsg>
#include "HelloLDCIAppUi.h"
#include "TempContainer.h"
#include "AddressCenter.h"
CTempContainer::CTempContainer()
{
}
// EPOC default constructor can leave.
void CTempContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect( aRect );
ActivateL();
}
// destructor
CTempContainer::~CTempContainer()
{
}
void CTempContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CTempContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CTempContainer::CountComponentControls() const
{
// return number of controls inside this container
return 0;
}
// ---------------------------------------------------------
// CTempContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CTempContainer::ComponentControl( TInt /*aIndex*/ ) const
{
return NULL;
}
// ---------------------------------------------------------
// CTempContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CTempContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.Clear(Rect());
//设置背景色
// gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
// gc.SetBrushColor(KRgbBlue);
// gc.DrawRect(Rect());
//2009-02-12上机课讲解,如何添加背景图片
//添加背景图片
TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
pathMbm.Copy(_L("z:\\system\\apps\\HELLOLDCI\\helloldci.mbm"));
#else
//手机上执行如下代码:2009-02-10 15:00
CHelloLDCIAppUi* pApp = (CHelloLDCIAppUi*)CEikonEnv::Static()->AppUi();
pApp->GetAppPath(pathMbm);
pathMbm.Append(_L("helloldci.mbm"));
#endif
//绘制背景图片
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(pathMbm, EMbmHelloldciBlackground_i);
gc.BitBlt(TPoint(0, 0), bitmap);
delete bitmap;
//如果设置遮障可做如下处理:
// CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(pathMbm, EMbmHelloldciSnoopy_2_mask);
// gc.BitBltMasked (TPoint(10, 10), bitmap, bitmap->SizeInPixels(), bitmapMask, ETrue);
// delete bitmapMask;
//设置字体颜色2009-02-15
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetPenColor(KRgbYellow);
//绘制文字
const CFont * font = CEikonEnv::Static()->NormalFont();
gc.UseFont(font);
gc.DrawText(*(m_pAddressCenter->GetName()),TPoint(aRect.Width()/8,aRect.Height()/4));
gc.DrawText(*(m_pAddressCenter->GetTel()),TPoint(aRect.Width()/8,aRect.Height()/2));
//在面板上绘制中文字符
TBuf<32> sTmpTitle;
//从资源文件中读取中文字符,其中R_HD_TEMPVIEW_DRAW1是由helloldci.rsg引用
CEikonEnv::Static()->ReadResource(sTmpTitle, R_HD_TEMPVIEW_DRAW1);
gc.DrawText(sTmpTitle,TPoint(aRect.Width()/8,aRect.Height()/2+30));
gc.DiscardFont();
//绘制直线
// gc.DrawLine(TPoint(20,20),TPoint(50,50));
//绘制矩形
// gc.DrawRect(TRect(TPoint(10, 10), TSize(20, 20)));
}
// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
// const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CTempContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
return EKeyWasNotConsumed;
}
void CTempContainer::SetAddress(CAddressCenter* aAddressCenter)
{
m_pAddressCenter = aAddressCenter;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -