drawing_appview.cpp

来自「Symbian OS C++ for Mobile Phones v3 Exam」· C++ 代码 · 共 108 行

CPP
108
字号
// Drawing_AppView.cpp
// ------------------------------
//
// Copyright (c) 2002 - 2007 Symbian Software Ltd.  All rights reserved.
//

////////////////////////////////////////////////////////////////////////
//
// Source file for the implementation of the 
// application view class - CExampleAppView
//
////////////////////////////////////////////////////////////////////////

#include "Drawing.h"


void CExampleAppView::ConstructL(const TRect& aRect)
	{
	// give myself a window: the control is a window-owning control
	CreateWindowL();
	SetRect(aRect); // Extent of the control, passed to us from the application UI.
					// The rectangle available for drawing, with co-ordinates which
					// are relative to the whole screen. The control has to have
					// this area set.
	TRect drawingRect=Rect(); // The rectangle available for drawing, with the top left
	                // and bottom right co-ordinates relating only to this area (i.e.
	                // the top left point of the drawing area has the co-ordinate (0,0)).
	                // This makes the division of the drawing area into two areas,
	                // each with its own control, simpler.
	// vertical mid-point coordinate
	TInt midX=(drawingRect.iTl.iX+drawingRect.iBr.iX)/2;
	TInt midY=(drawingRect.iTl.iY+drawingRect.iBr.iY)/2;
	// construct upper left control
	TRect upperLeft=drawingRect;
	upperLeft.iBr.iX=midX;
	upperLeft.iBr.iY=midY;
	iControl0=CExampleHelloControl::NewL(*this,upperLeft);
	iControl0->SetFullRedraw(EFalse);
	// construct lower left control
	TRect lowerLeft=drawingRect;
	lowerLeft.iBr.iX=midX;
	lowerLeft.iTl.iY=midY;
	iControl1=CExampleHelloControl::NewL(*this,lowerLeft);
	// construct upper right control
	TRect upperRight=drawingRect;
	upperRight.iTl.iX=midX;
	upperRight.iBr.iY=midY;
	iControl2=CExampleHelloControl::NewL(*this,upperRight);
	// construct lower right control
	TRect lowerRight=drawingRect;
	lowerRight.iTl.iX=midX;
	lowerRight.iTl.iY=midY;
	iControl3=CExampleHelloControl::NewL(*this, lowerRight);
	iControl3->SetFullRedraw(EFalse);
	// At this stage, the control is ready to draw so
    // we tell the UI framework by activating it.
	ActivateL();
	}

CExampleAppView::~CExampleAppView()
	{
	delete iControl0;
	delete iControl1;
	delete iControl2;
	delete iControl3;
	}

void CExampleAppView::ZoomInL()
	{
	iControl0->SetZoomInL();
	iControl0->DrawNow();
	iControl1->SetZoomInL();
	iControl1->DrawNow();
	iControl2->SetZoomInL();
	iControl2->DrawNow();
	iControl3->SetZoomInL();
	iControl3->DrawNow();
	}

void CExampleAppView::ZoomOutL()
	{
	iControl0->SetZoomOutL();
	iControl0->DrawNow();
	iControl1->SetZoomOutL();
	iControl1->DrawNow();
	iControl2->SetZoomOutL();
	iControl2->DrawNow();
	iControl3->SetZoomOutL();
	iControl3->DrawNow();
	}

TInt CExampleAppView::CountComponentControls() const
	{
	return 4;
	}

CCoeControl* CExampleAppView::ComponentControl(TInt aIndex) const
	{
	switch (aIndex)
		{
	case 0: return iControl0;
	case 1: return iControl1;
	case 2: return iControl2;
	case 3: return iControl3;
	default: return NULL;
		}
	}

⌨️ 快捷键说明

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