📄 graphicexameffectcontainer.cpp
字号:
/*
============================================================================
Name : CGraphicExamEffectContainer from GraphicExamEffectContainer.h
Author : hou maoqing
Version :
Copyright : Copyright (c) Hou maoqing 2008
Description : Declares container control for application.
============================================================================
*/
// INCLUDE FILES
#include "GraphicExamEffectContainer.h"
#include <eiklabel.h> // for example label control
#include <akniconutils.h>
#include <aknutils.h>
#include <graphic_svg.mbg>
_LIT(KSvgPath, "\\resource\\apps\\graphic_svg.mif");
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CGraphicExamEffectContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CGraphicExamEffectContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect(aRect);
//加载svg矢量图
TFileName svgFile (KSvgPath);
User::LeaveIfError (CompleteWithAppPath (svgFile));
iSoundSvg=AknIconUtils::CreateIconL(svgFile,EMbmGraphic_svgSound);
AknIconUtils::SetSize(iSoundSvg, TSize(50,50), EAspectRatioNotPreserved);
// 创建离屏位图、位图设备、位图设备上下文
iOffScreenBitmap = new ( ELeave ) CFbsBitmap();
CleanupStack::PushL( iOffScreenBitmap );
User::LeaveIfError( iOffScreenBitmap->Create( Rect().Size(),EColor4K ) );
CleanupStack::Pop();
iOffScreenBitmapDevice = CFbsBitmapDevice::NewL(iOffScreenBitmap );
iOffScreenBitmapDevice->CreateContext( iOffScreenBitmapGc );
//位图放缩工具
m_nScaler=100;
iScaler = CMdaBitmapScaler::NewL();
ActivateL();
}
// Destructor
CGraphicExamEffectContainer::~CGraphicExamEffectContainer()
{
delete iOffScreenBitmapGc;
iOffScreenBitmapGc = NULL;
delete iOffScreenBitmapDevice;
iOffScreenBitmapDevice = NULL;
delete iOffScreenBitmap;
iOffScreenBitmap = NULL;
delete iSoundSvg;
delete iScaler;
}
// ---------------------------------------------------------
// CGraphicExamEffectContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CGraphicExamEffectContainer::SizeChanged()
{
// TODO: Add here control resize code etc.
}
// ---------------------------------------------------------
// CGraphicExamEffectContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CGraphicExamEffectContainer::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CGraphicExamEffectContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CGraphicExamEffectContainer::ComponentControl(TInt aIndex) const
{
return NULL;
}
// ---------------------------------------------------------
// CGraphicExamEffectContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CGraphicExamEffectContainer::Draw(const TRect& aRect) const
{
//清除位图设备下文中的背景
iOffScreenBitmapGc->SetPenStyle( CGraphicsContext::ENullPen );
iOffScreenBitmapGc->SetBrushColor( KRgbGray );
iOffScreenBitmapGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
iOffScreenBitmapGc->DrawRect( aRect );
iOffScreenBitmapGc->SetPenStyle(CGraphicsContext::ESolidPen);
iOffScreenBitmapGc->DrawEllipse(Rect());
iOffScreenBitmapGc->BitBlt(aRect.iTl,iSoundSvg);
CWindowGc& gc = SystemGc();
gc.BitBlt( Rect().iTl,iOffScreenBitmap );
}
// ---------------------------------------------------------
// CGraphicExamEffectContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CGraphicExamEffectContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
void CGraphicExamEffectContainer::MiuoConvertComplete(TInt aError)
{
this->DrawDeferred();
}
/**
* From MMdaImageUtilObserver derivation.
* Used to inform client code that a file creation operation
* has completed.
* Following this the image data will be stored in the file created previously
*
* @param aError An error code value in case manipulation step failed
*/
void CGraphicExamEffectContainer::MiuoCreateComplete(TInt aError)
{
}
/**
* From MMdaImageUtilObserver derivation.
* Used to inform client code that an open operation has completed allowing the
* subsequent encoding or decoding of an image file
*
* @param aError An error code value in case manipulation step failed
*/
void CGraphicExamEffectContainer::MiuoOpenComplete(TInt aError)
{
}
void CGraphicExamEffectContainer::ScaleZoomInImageL()
{
m_nScaler*=1.5;
iScaler->ScaleL(*this, *iSoundSvg, TSize(m_nScaler, m_nScaler));
}
void CGraphicExamEffectContainer::ScaleZoomOutImageL()
{
m_nScaler*=0.5;
iScaler->ScaleL(*this, *iSoundSvg, TSize(m_nScaler, m_nScaler));
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -