📄 graphicexamcontainer2.cpp
字号:
/*
============================================================================
Name : CGraphicExamContainer2 from GraphicExamContainer2.cpp
Author : hou maoqing
Version :
Copyright : Copyright (c) Hou maoqing 2008
Description : Container control implementation
============================================================================
*/
// INCLUDE FILES
#include "GraphicExamContainer2.h"
#include <EIKENV.H>
#include <akniconutils.h>
#include <aknutils.h>
#include <graphic_bmp.mbg> // Bitmap enumeration
#include <graphic_svg.mbg> // Bitmap enumeration
// CONSTANTS
_LIT(KBitmapPath, "\\resource\\apps\\graphic_bmp.mbm");
_LIT(KSvgPath, "\\resource\\apps\\graphic_svg.mif");
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CGraphicExamContainer2::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CGraphicExamContainer2::ConstructL(const TRect& aRect)
{
CreateWindowL();
//加载位图
TFileName bitmapFile (KBitmapPath);
User::LeaveIfError (CompleteWithAppPath (bitmapFile));
iBackgroundImage = iEikonEnv->CreateBitmapL( bitmapFile,EMbmGraphic_bmpImage1 );
iImage2 = iEikonEnv->CreateBitmapL( bitmapFile,EMbmGraphic_bmpImage2 );
iImage2mask = iEikonEnv->CreateBitmapL( bitmapFile,EMbmGraphic_bmpImage2_mask );
//加载svg矢量图
TFileName svgFile (KSvgPath);
User::LeaveIfError (CompleteWithAppPath (svgFile));
AknIconUtils::CreateIconL(iSoundSvg, iSoundSvgMask, svgFile, EMbmGraphic_svgSound,EMbmGraphic_svgSound_mask);
//iSoundSvg=AknIconUtils::CreateIconL(svgFile,EMbmGraphic_svgSound);
AknIconUtils::SetSize(iSoundSvg, TSize(50,50), EAspectRatioNotPreserved);
AknIconUtils::SetSize(iSoundSvgMask, TSize(50,50), EAspectRatioNotPreserved);
SetRect(aRect);
ActivateL();
}
// Destructor
CGraphicExamContainer2::~CGraphicExamContainer2()
{
delete iBackgroundImage;
delete iImage2;
delete iImage2mask;
delete iSoundSvg;
delete iSoundSvgMask;
}
// ---------------------------------------------------------
// CGraphicExamContainer2::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CGraphicExamContainer2::SizeChanged()
{
// TODO: Add here control resize code etc.
//iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
//iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize() );
}
// ---------------------------------------------------------
// CGraphicExamContainer2::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CGraphicExamContainer2::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CGraphicExamContainer2::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CGraphicExamContainer2::ComponentControl(TInt aIndex) const
{
return NULL;
}
// ---------------------------------------------------------
// CGraphicExamContainer2::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CGraphicExamContainer2::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
//清空窗口上的内容
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
gc.SetBrushStyle( CGraphicsContext::ENullBrush );
//绘制客户区背景
//gc.BitBlt( Rect().iTl,iBackgroundImage );
gc.DrawBitmap(aRect,iBackgroundImage);
//在客户区的第一行绘制位图图标
//绘制非透明位图
TPoint ptPos=aRect.iTl;
gc.BitBlt(ptPos,iImage2);
//绘制透明位图
TSize size=iImage2->SizeInPixels();
TRect sourceRect( TPoint( 0,0 ),size);
ptPos.iX+=size.iWidth;
gc.BitBltMasked(ptPos,iImage2,sourceRect,iImage2mask,ETrue);
//绘制放缩的透明位图
ptPos.iX+=size.iWidth;
size.iWidth*=2;
size.iHeight*=2;
TRect destRect(ptPos,size);
gc.DrawBitmapMasked(destRect,iImage2,sourceRect,iImage2mask,ETrue);
//在客户区的第2行绘制SVG图图标
//绘制非透明SVG图
ptPos=aRect.iTl;
ptPos.iY+=100;
gc.BitBlt(ptPos,iSoundSvg);
//绘制透明SVG图
TSize size2=iSoundSvg->SizeInPixels();
TRect sourceRect2( TPoint( 0,0 ),size2);
ptPos.iX+=size2.iWidth;
gc.BitBltMasked(ptPos,iSoundSvg,sourceRect2,iSoundSvgMask,ETrue);
}
// ---------------------------------------------------------
// CGraphicExamContainer2::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CGraphicExamContainer2::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -