drawing_appview.cpp

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

CPP
159
字号
// 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"
#include <QikCommand.h>


CExampleAppView* CExampleAppView::NewL(CQikAppUi& aAppUi)
	{
	CExampleAppView* self = new(ELeave) CExampleAppView(aAppUi);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop();
	return self;
	}

CExampleAppView::CExampleAppView(CQikAppUi& aAppUi)
	:CQikViewBase(aAppUi,KNullViewId), iCommandManager(CQikCommandManager::Static())
    {	
    }

void CExampleAppView::ConstructL()
	{
	BaseConstructL();
	}
	
void CExampleAppView::ViewConstructL()
    {
	ViewConstructFromResourceL(R_EXAMPLE_UI_CONFIGURATIONS);
	InitComponentArrayL();

	// construct upper left control
	iControl0=CExampleHelloControl::NewL(*this);
	iControl0->SetFullRedraw(EFalse);
	AddControlLC(iControl0,0);
	CleanupStack::Pop(iControl0);
	// construct lower left control
	iControl1=CExampleHelloControl::NewL(*this);
	AddControlLC(iControl1,1);
	CleanupStack::Pop(iControl1);

	// construct upper right control
	iControl2=CExampleHelloControl::NewL(*this);
	AddControlLC(iControl2,2);
	CleanupStack::Pop(iControl2);
	// construct lower right control
	iControl3=CExampleHelloControl::NewL(*this);
	iControl3->SetFullRedraw(EFalse);
	AddControlLC(iControl3,3);
	CleanupStack::Pop(iControl3);
	}

void CExampleAppView::SizeChanged()
	{
	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;
	// set rectangle of upper left control
	TRect upperLeft=drawingRect;
	upperLeft.iBr.iX=midX;
	upperLeft.iBr.iY=midY;
	iControl0->SetRect(upperLeft);
	// set rectangle of lower left control
	TRect lowerLeft=drawingRect;
	lowerLeft.iBr.iX=midX;
	lowerLeft.iTl.iY=midY;
	iControl1->SetRect(lowerLeft);
	// set rectangle of upper right control
	TRect upperRight=drawingRect;
	upperRight.iTl.iX=midX;
	upperRight.iBr.iY=midY;
	iControl2->SetRect(upperRight);
	// set rectangle of lower right control
	TRect lowerRight=drawingRect;
	lowerRight.iTl.iX=midX;
	lowerRight.iTl.iY=midY;
	iControl3->SetRect(lowerRight);
	}
	
CExampleAppView::~CExampleAppView()
	{
	}

/**
Returns the view Id

@return Returns the Uid of the view
*/
TVwsViewId CExampleAppView::ViewId()const
	{
	return TVwsViewId(KUidExampleApp,KUidExampleView);
	}

void CExampleAppView::HandleCommandL(CQikCommand& aCommand)
	{
	switch(aCommand.Id())
		{
	case EExampleCmd1:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_CMD1);
		break;
	case EExampleCmd2:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_CMD2);
		break;
	case EExampleCmd3:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_CMD3);
		break;
	case EExampleCmd4:
		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_CMD4);
		break;
	case EEikCmdZoomIn:
		ZoomInL();
		break;
	case EEikCmdZoomOut:
		ZoomOutL();
		break;
	default:
		CQikViewBase::HandleCommandL(aCommand);
		}
	}

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();
	}

⌨️ 快捷键说明

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