multiviewexamcontainer2.cpp

来自「国内著名嵌入式培训机构内部资料,内含一些实例代码,包括技术专题书籍」· C++ 代码 · 共 110 行

CPP
110
字号
/*
============================================================================
 Name        : CMultiViewExamContainer2 from MultiViewExamContainer2.cpp
 Author      : Hou maoqing
 Version     :
 Copyright   : Copyright (c) Hou maoqing 2008
 Description : Container control implementation
============================================================================
*/

// INCLUDE FILES
#include "MultiViewExamContainer2.h"

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


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

// ---------------------------------------------------------
// CMultiViewExamContainer2::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CMultiViewExamContainer2::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
CMultiViewExamContainer2::~CMultiViewExamContainer2()
	{
	delete iLabel;
	delete iToDoLabel;
	}

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

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

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

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

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

⌨️ 快捷键说明

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