📄 basicdrawcontainer2.cpp
字号:
/*
* ============================================================================
* Name : CBasicDrawContainer2 from BasicDrawContainer2.cpp
* Part of : BasicDraw
* Created : 2006-4-15 by Hewei
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright: Myself
* ============================================================================
*/
// INCLUDE FILES
#include "BasicDrawContainer2.h"
#include <gdi.h>
#include <aknutils.h>
//color:
const TInt KColorBlue=210;
const TInt KColorRed=35;
const TInt KColorGreen=185;
const TInt KColorYellow=5;
const TInt KColorBlack=215;
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CBasicDrawContainer2::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CBasicDrawContainer2::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect(aRect);
ActivateL();
}
// Destructor
CBasicDrawContainer2::~CBasicDrawContainer2()
{
}
// ---------------------------------------------------------
// CBasicDrawContainer2::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CBasicDrawContainer2::SizeChanged()
{
}
// ---------------------------------------------------------
// CBasicDrawContainer2::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CBasicDrawContainer2::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CBasicDrawContainer2::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CBasicDrawContainer2::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
default:
return NULL;
}
}
// ---------------------------------------------------------
// CBasicDrawContainer2::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CBasicDrawContainer2::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.Clear(aRect);
//set color:
TRgb colorBlue=AKN_LAF_COLOR(KColorBlue);
TRgb colorRed=AKN_LAF_COLOR(KColorRed);
TRgb colorGreen=AKN_LAF_COLOR(KColorGreen);
TRgb colorYellow=AKN_LAF_COLOR(KColorYellow);
TRgb colorBlack=AKN_LAF_COLOR(KColorBlack);
//set draw property
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
//center point
TPoint CenterPoint=aRect.Center();
//draw line
gc.SetPenColor(colorBlack);
TPoint Line1Start=TPoint(0,CenterPoint.iY);
TPoint Line1End=TPoint(aRect.iBr.iX,CenterPoint.iY);
TPoint Line2Start=TPoint(CenterPoint.iX,0);
TPoint Line2End=TPoint(CenterPoint.iX,aRect.iBr.iY);
gc.DrawLine(Line1Start,Line1End);
gc.DrawLine(Line2Start,Line2End);
//draw rect:
gc.SetPenColor(KColorBlack);
gc.SetBrushColor(KColorBlue);
TRect rect;
rect.iTl=TPoint(0,0);
rect.iBr=CenterPoint;
gc.DrawRect(rect);
//draw circle
TRect circleRect;
TSize IncrementSize=TSize(30,25);
TSize Extent(30,30);
TPoint centerInX(CenterPoint.iX,0);
circleRect.iTl=centerInX+IncrementSize;
circleRect.iBr=circleRect.iTl+Extent;
gc.SetBrushColor(colorGreen);
gc.DrawEllipse(circleRect);
//draw Ellipse
TPoint Start=TPoint(0,CenterPoint.iY);
TPoint End=TPoint(CenterPoint.iX,aRect.iBr.iY);
TRect EllipseRect(Start,End);
gc.SetBrushColor(colorYellow);
gc.DrawEllipse(EllipseRect);
//draw Pie
TRect pieRect;
pieRect.iTl=CenterPoint;
pieRect.iBr=aRect.iBr;
TPoint pieStart=TPoint(CenterPoint.iX+(aRect.iBr.iX-CenterPoint.iX)/2,aRect.iBr.iY);
TPoint pieEnd=TPoint(CenterPoint.iX,CenterPoint.iY+(aRect.iBr.iY-CenterPoint.iY)/2);
gc.SetBrushColor(colorBlue);
gc.DrawPie(pieRect,pieStart,pieEnd);
}
// ---------------------------------------------------------
// CBasicDrawContainer2::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CBasicDrawContainer2::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -