demonsymcontainer2.cpp

来自「symbian下的一个例子」· C++ 代码 · 共 110 行

CPP
110
字号
/*
============================================================================
 Name        : CDemonsymContainer2 from DemonsymContainer2.cpp
 Author      : huhao
 Version     :
 Copyright   : baidu
 Description : Container control implementation
============================================================================
*/

// INCLUDE FILES
#include "DemonsymContainer2.h"

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


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

// ---------------------------------------------------------
// CDemonsymContainer2::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CDemonsymContainer2::ConstructL(const TRect& aRect)
	{
	CreateWindowL();

	iLabel = new (ELeave) CEikLabel;
	iLabel->SetContainerWindowL( *this );
	iLabel->SetTextL( _L("Example View 2") );

	iToDoLabel = new (ELeave) CEikLabel;
	iToDoLabel->SetContainerWindowL( *this );
	iToDoLabel->SetTextL( _L("Add Your controls\n here") );

	SetRect(aRect);
	ActivateL();
	}

// Destructor
CDemonsymContainer2::~CDemonsymContainer2()
	{
	delete iLabel;
	delete iToDoLabel;
	}

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

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

// ---------------------------------------------------------
// CDemonsymContainer2::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CDemonsymContainer2::ComponentControl(TInt aIndex) const
	{
	switch ( aIndex )
		{
		case 0:
			return iLabel;
		case 1:
			return iToDoLabel;
		default:
			return NULL;
		}
	}

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

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

⌨️ 快捷键说明

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