⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 digclockctrl.cpp

📁 symbian中时钟的应用开发 一个动态的时钟.
💻 CPP
字号:
// DigClockCtrl.cpp: implementation of the CDigClockCtrl class.
//
//////////////////////////////////////////////////////////////////////

#include <coemain.h>

#include "DigClockCtrl.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDigClockCtrl::CDigClockCtrl()
{
	
}

CDigClockCtrl::~CDigClockCtrl()
{
	
}



void CDigClockCtrl::ConstructL()
{
}

void CDigClockCtrl::Draw(const TRect& /*aRect*/) const
{
	// Window graphics context
	CWindowGc& gc = SystemGc();
	// Area in which we shall draw
	TRect      drawRect = Rect();
	// Font used for drawing text
	
	// Start with a clear screen
	gc.Clear(drawRect);
//	gc.DrawRect(drawRect);
	
	// Draw an outline rectangle (the default pen
	// and brush styles ensure this) slightly
	// smaller than the drawing area.
	
	this->DrawClock(gc,drawRect,iTime.Hour(),iTime.Minute(),iTime.Second());
	
}
void CDigClockCtrl::DrawClock(CWindowGc& aGc,const TRect &  aRect,TInt aHour/*<=12*/,TInt aMin,TInt aSec) const
{

	// Format the time into a descriptor, and handle any errors
	TBuf<32> timeAsText;
	_LIT (KTimeFormat, "%d: %d : %d");
	timeAsText.Format(KTimeFormat,aHour,aMin,aSec);
	// Write the time to the display
	if(iSelected)
		aGc.SetPenColor(TRgb(255,0,0));
	else
		aGc.SetPenColor(TRgb(0,0,0));
	
	const CFont*   fontUsed = iCoeEnv->NormalFont();
	aGc.UseFont(fontUsed);
	// Draw the text in the middle of the rectangle.
	TInt   baselineOffset=(aRect.Height() - fontUsed->HeightInPixels())/2; 

	aGc.DrawText(timeAsText,aRect,baselineOffset,CGraphicsContext::ECenter, 0);
	// Finished using the font
	aGc.DiscardFont();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -