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

📄 draw.cpp

📁 symbian 图像开发 绘制png jpeg bmp gif 等 多种
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Draw.cpp
//
// Copyright (c) 2000 Symbian Ltd.  All rights reserved.

#include "GraphicsControl.h"

#include <coemain.h>

// Text printed to the console in UpdateModeL()
_LIT(KTxtUpdateModelCase0,"point in center of screen");
_LIT(KTxtUpdateModelCase1,"bolder point in center of screen");
_LIT(KTxtUpdateModelCase2,"really bold point in center of screen");
_LIT(KTxtUpdateModelCase3,"a line");
_LIT(KTxtUpdateModelCase4,"a thicker line");
_LIT(KTxtUpdateModelCase5,"really thick - note round ends and clipping");
_LIT(KTxtUpdateModelCase6,"dotted line");
_LIT(KTxtUpdateModelCase7,"dot-dash line");
_LIT(KTxtUpdateModelCase8,"triangle using relative drawing");
_LIT(KTxtUpdateModelCase9,"thick triangle - note rounded corners");
_LIT(KTxtUpdateModelCase10,"dotted triangle - note pattern continuation");
_LIT(KTxtUpdateModelCase11,"centered ellipse");
_LIT(KTxtUpdateModelCase12,"arc - part of ellipse");
_LIT(KTxtUpdateModelCase13,"arc - other part - see also construction elements");
_LIT(KTxtUpdateModelCase14,"pie slices");
_LIT(KTxtUpdateModelCase15,"centered rectangle with rounded corners");
_LIT(KTxtUpdateModelCase16,"rounded rectangle showing corner ellipse");
_LIT(KTxtUpdateModelCase17,"polyline");
_LIT(KTxtUpdateModelCase18,"polygon with winding-fill rule");
_LIT(KTxtUpdateModelCase19,"polygon using alternate-fill rule");
_LIT(KTxtUpdateModelCase20,"copying using CopyRect()");
_LIT(KTxtUpdateModelCase21,"left-justified boxed text");
_LIT(KTxtUpdateModelCase22,"centered boxed text");
_LIT(KTxtUpdateModelCase23,"right-justified offset text");
_LIT(KTxtUpdateModelCase24,"cross-hatched box");
_LIT(KTxtUpdateModelCase25,"teeny preview font!");
_LIT(KTxtUpdateModelDefault,"overran!");
	
void CDrawControl::UpdateModelL()
	{
	switch (Phase())
		{
		case 0:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase0);
			break;
		case 1:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase1);
			break;
		case 2:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase2);
			break;
		case 3:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase3);
			break;
		case 4:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase4);
			break;
		case 5:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase5);
			break;
		case 6:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase6);
			break;
		case 7:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase7);
			break;
		case 8:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase8);
			break;
		case 9:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase9);
			break;
		case 10:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase10);
			break;
		case 11:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase11);
			break;
		case 12:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase12);
			break;
		case 13:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase13);
			break;
		case 14:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase14);
			break;
		case 15:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase15);
			break;
		case 16:
			{
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase16);
			}
			break;
		case 17:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase17);
			break;
		case 18:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase18);
			break;
		case 19:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase19);
			break;
		case 20:
			{
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase20);
			}
			break;
		case 21:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase21);
			break;
		case 22:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase22);
			break;
		case 23:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase23);
			break;
		case 24:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase24);
			break;
		case 25:
			iGraphObserver->NotifyStatus(KTxtUpdateModelCase25);
			break;
		default:
			iGraphObserver->NotifyStatus(KTxtUpdateModelDefault);
			break;
		}
	}


// Text printed to the console in UpdateModeL()
_LIT(KTxtDrawCase21,"White text left justified in dark gray box");
_LIT(KTxtDrawCase22,"White text centered in black box");
_LIT(KTxtDrawCase23,"Dark gray text right justified in lite gray box");
_LIT(KTxtDrawCase25,"This text overwrites the cleared area");

	
void CDrawControl::Draw(const TRect& /* aRect */) const
	{
	// put the next line back in to see the individual drawing actions
	// (iCoeEnv->WsSession()).SetAutoFlush(ETrue);
	// draw surrounding rectangle
	CWindowGc& gc=SystemGc(); // graphics context we draw to
	gc.UseFont(iMessageFont); // use the system message font
	gc.Clear();
	SystemGc().DrawRect(Rect()); // surrounding rectangle to draw into
	TRect rect=Rect(); // a centered rectangle of the default size
	TRect ellipseRect=Rect(); // for arcs and ellipse
	ellipseRect.Shrink(10,10); // set size so inside the border rectangle
	TRect box=Rect(); // a smaller centered rectangle, for text in a box
	box.Shrink(10,10); // set size of text box
	TRect tinyBox=Rect(); // a tiny box to clear
	tinyBox.Shrink(220,90); // set size of tiny box to clear
	TInt offset=0; // offset, for text in a box
	TPoint screenCenterPoint=rect.Center(); // the center of the screen 
	// set up a pair of construction points for arc and pie slice drawing
	// set up the size for half a screen (divided vertically)
	TPoint constructionPoint1(15,15); // outside the construction ellipse
	TPoint constructionPoint2(200,150); // inside the construction ellipse
	// set up a pair of points for drawing diagonal lines
	TPoint startPoint(50,50);
	TPoint endPoint(590,190);
	// set up an array of points for drawing a polyline and a polygon etc
	// will be used relative to top left of rectangle
	TPoint point1(20,20);
	TPoint point2(100,190);
	TPoint point3(110,90);
	TPoint point4(50,150);
	TPoint point5(200,150);
	CArrayFix<TPoint>* mypoints;
	mypoints = new CArrayFixFlat<TPoint>(5);
	mypoints->AppendL(point1);
	mypoints->AppendL(point2);
	mypoints->AppendL(point3);
	mypoints->AppendL(point4);
	mypoints->AppendL(point5);
	// set up a black, a dark gray, a lite gray and a white RGB color
	TRgb black(0,0,0);
	TRgb darkGray(85,85,85);
	TRgb liteGray(170,170,170);
	TRgb white(255,255,255); // appears as blank screen gray-green color
	// Set up a "bold" size for the pen tip to (default is 1,1)
	TSize penSizeBold(3,3);
	// Set up a "fat" size for the pen tip
	TSize penSizeFat(30,30);
	// decide what to do, and do it
	switch (Phase())
		{
		case 0:
			// draw a single pixel point in the center of the screen
			// it is so small that some text is needed to explain the screen...
			gc.Plot(screenCenterPoint);
			break;
		case 1:
			// draw a "bold" point 3 pixels across
 			gc.SetPenSize(penSizeBold);
			gc.Plot(screenCenterPoint);
			break;
		case 2:
			// draw a "fat" point (circular blob),
			// illustrating the effect of a very wide pen
 			gc.SetPenSize(penSizeFat);
			gc.Plot(screenCenterPoint);
			break;
		case 3:
			// draw a thin line fromtop left to bottom right
			gc.DrawLine(startPoint,endPoint);
			break;
		case 4:
			// draw a "bold" line fromtop left to bottom right
 			gc.SetPenSize(penSizeBold);
			gc.DrawLine(startPoint,endPoint);
			break;
		case 5:
			// draw a rather wide line from top left to bottom right,

⌨️ 快捷键说明

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