📄 imagesviewercontainer.cpp
字号:
/*
============================================================================
Name : CImagesViewerContainer from ImagesViewerContainer.h
Author :
Version :
Copyright : Your copyright notice
Description : Container control implementation
============================================================================
*/
// INCLUDE FILES
#include "ImagesViewerContainer.h"
_LIT(KJpgFileName, "c:\\Nokia\\Images\\Pictures\\test.jpg");
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CImagesViewerContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CImagesViewerContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iBitmap = NULL;
iImageEngine = CImageConverterEngine::NewL(this);
iImageEngine->StartToDecodeL(KJpgFileName);
SetRect(aRect);
ActivateL();
}
// Destructor
CImagesViewerContainer::~CImagesViewerContainer()
{
delete iImageEngine;
delete iBitmap;
}
// ---------------------------------------------------------
// CImagesViewerContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CImagesViewerContainer::SizeChanged()
{
// TODO: Add here control resize code etc.
}
// ---------------------------------------------------------
// CImagesViewerContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CImagesViewerContainer::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CImagesViewerContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CImagesViewerContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
default:
return NULL;
}
}
// ---------------------------------------------------------
// CImagesViewerContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CImagesViewerContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// TODO: Add your drawing code here
// example code...
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
if(iBitmap)
{
TRect rect = Rect();
TSize size = iBitmap->SizeInPixels();
gc.DrawBitmap(TRect(TPoint(5, 5), TSize(rect.Width() - 10, (size.iHeight * size.iWidth)/(rect.Width() - 10))), iBitmap);
}
}
// ---------------------------------------------------------
// CImagesViewerContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CImagesViewerContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
void CImagesViewerContainer::NotifyCompletion( TInt aErr )
{
if(aErr == KErrNone)
{
delete iBitmap;
iBitmap = iImageEngine->iBitmap;
iImageEngine->iBitmap = NULL;
DrawNow();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -