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

📄 ecomexamplecontainer.cpp

📁 symbian S60 2nd ECom的一个很好的例子
💻 CPP
字号:
/**
*
* @brief Definition of CEComExampleContainer
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "EComExampleContainer.h"

// System includes
#include <eiklabel.h> // CEikLabel
#include <EComExample.rsg> // R_LABEL_TEXT
#include <StringLoader.h> // StringLoader
#include <shapeinterface.h>

// CONSTANTS

// N.B. #define'd as DLL cannot contain writeable static data
#define KLabelPosition TPoint(10,10)
_LIT8 (KCircleText,"Circle");
_LIT8 (KRectangleText,"Rectangle");

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

/**
* Symbian OS 2nd phase constructor.  Creates a Window for the controls, which it contains.
* Constructs a label and adds it to the window, which it then activates.
* @param aRect The rectangle for this window
*/
void CEComExampleContainer::ConstructL(const TRect& aRect)
	{
	CreateWindowL();

	iShape = CShape::NewL();	
	iLabel = new (ELeave) CEikLabel;
	iLabel->SetContainerWindowL(*this);

	HBufC* labelText;
	labelText = StringLoader::LoadLC(R_LABEL_TEXT);	// Pushes labelText onto the Cleanup Stack.
	iLabel->SetTextL(*labelText);
	CleanupStack::PopAndDestroy(labelText);

	SetRect(aRect);
	ActivateL();
	}

/**
* Symbian OS 2 phase constructor.
* Constructs the CEComExampleContainer using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CEComExampleContainer
*/
CEComExampleContainer* CEComExampleContainer::NewL(const TRect& aRect)
	{
	CEComExampleContainer* self = CEComExampleContainer::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

/**
* Symbian OS 2 phase constructor.
* Constructs the CEComExampleContainer using the constructor and ConstructL
* method, leaving the constructed object on the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CEComExampleContainer
*/
CEComExampleContainer* CEComExampleContainer::NewLC(const TRect& aRect)
	{
	CEComExampleContainer* self = new (ELeave) CEComExampleContainer;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

/**
* Destructor.  Frees up memory for the iLabel.
*/
CEComExampleContainer::~CEComExampleContainer()
	{
	delete iLabel;
	delete iShape;
	}

/**
*
* Called by framework when the view size is changed.  Resizes the
* iLabel accordingly.
*
*/
void CEComExampleContainer::SizeChanged()
	{
	iLabel->SetExtent(KLabelPosition, iLabel->MinimumSize());
	}

/**
* Called by the framework in compound controls
* @return The number of controls in this CEComExampleContainer
*/
TInt CEComExampleContainer::CountComponentControls() const
	{
	return 1; // return number of controls inside this container
	}

/**
* Called by the framework in compound controls
* @param The index of the control to return
* @return The control for aIndex
*/
CCoeControl* CEComExampleContainer::ComponentControl(TInt aIndex) const
	{
	switch (aIndex)
		{
		case 0:
			return iLabel;
		default:
			return NULL;
		}
	}

/**
* Called by the framework to draw this control.  Clears the area in
* aRect.
* @param aRect in which to draw
*/
void CEComExampleContainer::Draw(const TRect& aRect) const
	{
	CWindowGc& gc = SystemGc();
	gc.Clear(aRect);

	// draw the 'cursor' crosshair, size 10 pixels by 10 pixels
	gc.SetPenSize(TSize(1,1));
    gc.SetPenColor(KRgbBlack);
	if(iShape)
		iShape->Draw(gc);

	}


void CEComExampleContainer::DrawCircleL()
	{
	delete iShape;
	iShape = NULL;
	iShape = CShape::NewL (KCircleText);
	DrawDeferred();
	}

void CEComExampleContainer::DrawRectangleL()
	{
	delete iShape;
	iShape = NULL;
	iShape = CShape::NewL (KRectangleText);
	DrawDeferred();

	}

// End of File

⌨️ 快捷键说明

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