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

📄 guiclock8_maincontainer.cpp__.htm

📁 symbian clock 源代码..........
💻 HTM
字号:
<html><head><title>Exercise_GUIClock.rar GUIClock8_maincontainer.cpp</title>
<LINK href="/inc/read_style.css" type=text/css rel=stylesheet></head>
<body>
<p><a href=http://www.pudn.com>www.pudn.com</a> &gt; <a href="http://www.pudn.com/downloads91/sourcecode/comm/symbian/detail348522.html">Exercise_GUIClock.rar</a> &gt GUIClock8_maincontainer.cpp</p><!-- saved from http://www.pudn.com -->
<script src="/inc/gg_read1.js"></script><BR>
<pre name="code" class="cpp">
// GUIClock_CGUIClockMainContainer.cpp 
// ------------------------------ 
// 
// Copyright (c) 2000 Symbian Ltd.  All rights reserved. 
// 
 
//////////////////////////////////////////////////////////////////////// 
// 
// Source file for the implementation of the  
// application view class - CGUIClockMainContainer 
// 
//////////////////////////////////////////////////////////////////////// 
 
#include "GUIClock8.h" 
#include "math.h" 
#include "DiaclockCtrl.h" 
#include "DigclockCtrl.h" 
 
// 
//             Constructor for the view. 
// 
CGUIClockMainContainer::CGUIClockMainContainer() 
{ 
	iSelectIndex = 0; 
} 
 
 
//             Static NewL() function to start the standard two 
//             phase construction. 
// 
CGUIClockMainContainer* CGUIClockMainContainer::NewL(const TRect& aRect) 
{ 
	CGUIClockMainContainer* self = new(ELeave) CGUIClockMainContainer(); 
	CleanupStack::PushL(self); 
	self->ConstructL(aRect); 
	CleanupStack::Pop(); 
	return self; 
} 
 
 
// 
//             Destructor for the view. 
// 
CGUIClockMainContainer::~CGUIClockMainContainer() 
{ 
	if(iDigClock) 
		delete iDigClock; 
	if(iDiaClock) 
		delete iDiaClock; 
} 
 
 
//             Second phase construction. 
// 
void CGUIClockMainContainer::ConstructL(const TRect& aRect) 
{ 
	// Control is a window owning control 
	CreateWindowL(); 
	 
	iDigClock = new (ELeave) CDigClockCtrl; 
	iDigClock->SetContainerWindowL(*this); 
	iDigClock->ConstructL(); 
	 
	iDiaClock = new (ELeave) CDiaClockCtrl; 
	iDiaClock->SetContainerWindowL(*this); 
	iDiaClock->ConstructL(); 
	 
	// Extent of the control. This is 
	// the whole rectangle available to application. 
	// The rectangle is passed to us from the application UI. 
	SetRect(aRect); 
	// At this stage, the control is ready to draw so 
	// we tell the UI framework by activating it. 
	ActivateL(); 
} 
 
 
//             Drawing the view - in this example,  
//             consists of drawing a simple outline rectangle 
//             and then drawing the text in the middle. 
//             We use the Normal font supplied by the UI. 
// 
//             In this example, we don't use the redraw 
//             region because it's easier to redraw to 
//             the whole client area. 
// 
void CGUIClockMainContainer::Draw(const TRect& /*aRect*/) const 
{ 
	CWindowGc & gc = SystemGc(); 
	gc.Clear(); 
} 
 
 
 
 
void CGUIClockMainContainer::UpdateClock(TTime aTime) 
{ 
	iDateTime = aTime.DateTime(); 
	iDiaClock->SetTime(iDateTime); 
	iDigClock->SetTime(iDateTime); 
 
	this->DrawNow(); 
} 
 
 
CCoeControl* CGUIClockMainContainer::ComponentControl(TInt aIndex) const 
{ 
	switch (aIndex) 
	{ 
	case 0: 
		return iDigClock; 
		break; 
	case 1: 
		return iDiaClock; 
		break; 
	} 
	return NULL; 
} 
 
void CGUIClockMainContainer::SizeChanged() 
{ 
	//调整布局 
	TRect rect = this->Rect(); 
	TInt wid = rect.Height()*2/3 > rect.Width() ?  
		rect.Width(): rect.Height()*2/3; 
 
	iDiaClockRect.iTl.iX = (rect.Width() - wid)/2; 
	iDiaClockRect.iBr.iX = iDiaClockRect.iTl.iX + wid; 
	iDiaClockRect.iTl.iY = rect.iTl.iY; 
	iDiaClockRect.iBr.iY = rect.iTl.iY + wid; 
	iDiaClock->SetRect(iDiaClockRect); 
 
	iDigClockRect.iTl.iX = 0; 
	iDigClockRect.iTl.iY = iDiaClockRect.iBr.iY+4; 
	iDigClockRect.iBr.iX = rect.iBr.iX; 
	iDigClockRect.iBr.iY = iDigClockRect.iTl.iY + rect.Height()*1/3-5; 
	iDigClock->SetRect(iDigClockRect); 
} 
 
 
TKeyResponse CGUIClockMainContainer::OfferKeyEventL(const TKeyEvent& aEvent,TEventCode aType) 
{ 
	TBool processed = FALSE; 
 
	if(aType == EEventKey)	 
	{ 
		if(aEvent.iScanCode == EStdKeyDownArrow) 
		{ 
			iSelectIndex = (iSelectIndex +1) % 2; 
			processed = TRUE; 
		} 
		else if(aEvent.iScanCode == EStdKeyUpArrow) 
		{ 
			iSelectIndex = (iSelectIndex - 1) % 2; 
			processed = TRUE; 
		} 
		if(processed) 
		{ 
			if(iSelectIndex == 0) 
			{ 
				iDiaClock->SetSelected(TRUE); 
				iDigClock->SetSelected(FALSE); 
			} 
			else 
			{ 
				iDiaClock->SetSelected(FALSE); 
				iDigClock->SetSelected(TRUE); 
			} 
			DrawNow(); 
			return EKeyWasConsumed; 
		} 
	} 
	return EKeyWasNotConsumed; 
 
} 
 
 
</pre>
<script src="/inc/gg_read2.js"></script><BR>
<script src="http://s117.cnzz.com/stat.php?id=1236358&web_id=1236358&show=pic" language="JavaScript" charset="gb2312"></script>
</body></html>

⌨️ 快捷键说明

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