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

📄 myclockcontainer.cpp

📁 Symbian 平台上活动对象的一个实例。
💻 CPP
字号:
/*
============================================================================
 Name		: MyClockContainer.cpp
 Author	  : 
 Copyright   : Your copyright notice
 Description : Container control implementation
============================================================================
*/

// INCLUDE FILES
#include "MyClockContainer.h"

#include <eiklabel.h>  // for example label control
#include "TimerModel.h"

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CMyClockContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
const TInt CMyClockContainer::KTimeStringLength = 7;

CMyClockContainer* CMyClockContainer::newL(const TRect& aRect, const CTimerModel& aModel)
{
   CMyClockContainer* self=new(ELeave)CMyClockContainer(aModel);
   CleanupStack::PushL(self);
   self->ConstructL(aRect);
   CleanupStack::Pop();
   return self;
}
CMyClockContainer::CMyClockContainer(const CTimerModel& aModel):iModel(aModel)
{
	
}


void CMyClockContainer::ConstructL(const TRect& aRect)
	{
	CreateWindowL();
 //   iModel=aModel;

    iLabel = new(ELeave) CEikLabel;
    TBuf<KTimeStringLength> timeString;
    const TTime& time = iModel.Time();
    time.FormatL(timeString, KTimeFormat);
    iLabel->SetTextL(timeString);
    TSize size(iLabel->MinimumSize());
    TPoint position((aRect.Width()-size.iWidth)/2, (aRect.Height()-size.iHeight)/2);
    iLabel->SetPosition(position);



	SetRect(aRect);
	ActivateL();
	}

// Destructor
CMyClockContainer::~CMyClockContainer()
	{
	delete iLabel;

	}
void CMyClockContainer::RefreshL()
    {
    TBuf<KTimeStringLength> timeString;
    const TTime& time = iModel.Time();
    time.FormatL(timeString, KTimeFormat);
    iLabel->SetTextL(timeString);
    DrawDeferred();                       // DRAW
    }

// ---------------------------------------------------------
// CMyClockContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CMyClockContainer::SizeChanged()
	{
	// TODO: Add here control resize code etc.
	//iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );

	}

// ---------------------------------------------------------
// CMyClockContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CMyClockContainer::CountComponentControls() const
	{
	return 1; // return nbr of controls inside this container
	}

// ---------------------------------------------------------
// CMyClockContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CMyClockContainer::ComponentControl(TInt aIndex) const
	{
	switch ( aIndex )
		{
		case 0:
			return iLabel;

		default:
			return NULL;
		}
	}

// ---------------------------------------------------------
// CMyClockContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CMyClockContainer::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 );
	}

// ---------------------------------------------------------
// CMyClockContainer::HandleControlEventL(
//	 CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CMyClockContainer::HandleControlEventL(
	CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
	{
	// TODO: Add your control event handler code here
	}



⌨️ 快捷键说明

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