103
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Lots of different Drawing Commands
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
gc->SetBrushColor(TRgb::Gray4(2));
|
|
19 |
gc->Clear();
|
|
20 |
gc->SetBrushColor(TRgb::Gray4(0));
|
|
21 |
gc->Clear(TRect(2,2,20,5));
|
|
22 |
gc->DrawRect(TRect(size));
|
|
23 |
gc->SetBrushOrigin(TPoint(1,2));
|
|
24 |
gc->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
|
|
25 |
gc->DrawRect(TRect(30,2,60,8));
|
|
26 |
gc->SetBrushOrigin(TPoint(0,0));
|
|
27 |
gc->UseBrushPattern(aBitmap);
|
|
28 |
gc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
|
|
29 |
gc->DrawRect(TRect(60,2,90,8));
|
|
30 |
gc->SetBrushStyle(CGraphicsContext::ENullBrush);
|
|
31 |
gc->DiscardBrushPattern();
|
|
32 |
//
|
|
33 |
gc->SetPenColor(TRgb::Gray4(1));
|
|
34 |
gc->DrawLine(TPoint(10,12),TPoint(22,20));
|
|
35 |
gc->SetPenSize(TSize(4,2));
|
|
36 |
gc->DrawLine(TPoint(22,10),TPoint(40,20));
|
|
37 |
gc->SetPenStyle(CGraphicsContext::EDottedPen);
|
|
38 |
gc->SetPenSize(TSize(1,1));
|
|
39 |
gc->SetPenColor(TRgb::Gray4(0));
|
|
40 |
gc->DrawLine(TPoint(40,11),TPoint(60,20));
|
|
41 |
gc->SetPenStyle(CGraphicsContext::ESolidPen);
|
|
42 |
gc->Plot(TPoint(60,10));
|
|
43 |
//
|
|
44 |
gc->BitBlt(TPoint(size.AsPoint()-TPoint(20,20)),aBitmap);
|
|
45 |
gc->BitBlt(TPoint(10,30),aBitmap,TRect(0,1,8,9));
|
|
46 |
gc->BitBltMasked(TPoint(10,40),aBitmap,TRect(1,2,8,9),aMaskBitmap,ETrue);
|
|
47 |
gc->BitBltMasked(TPoint(20,40),aBitmap,TRect(0,0,9,9),aMaskBitmap,EFalse);
|
|
48 |
gc->SetOrigin(TPoint(5,50));
|
|
49 |
gc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
|
|
50 |
gc->SetPenColor(TRgb::Gray4(3));
|
|
51 |
gc->SetClippingRect(TRect(0,0,20,15));
|
|
52 |
//gc->DrawArc(TRect(0,0,20,15),TPoint(10,0),TPoint(1,8));
|
|
53 |
gc->CancelClippingRect();
|
|
54 |
gc->SetDrawMode(CGraphicsContext::EDrawModePEN);
|
|
55 |
gc->SetPenColor(TRgb::Gray4(0));
|
|
56 |
gc->MoveTo(TPoint(25,0));
|
|
57 |
gc->DrawLineTo(TPoint(40,5));
|
|
58 |
gc->DrawLineBy(TPoint(-20,10));
|
|
59 |
//
|
|
60 |
CArrayFixFlat<TPoint>* polyLineArray=new(ELeave) CArrayFixFlat<TPoint>(4);
|
|
61 |
CleanupStack::PushL(polyLineArray);
|
|
62 |
polyLineArray->AppendL(TPoint(8,0));
|
|
63 |
polyLineArray->AppendL(TPoint(16,10));
|
|
64 |
polyLineArray->AppendL(TPoint(0,3));
|
|
65 |
polyLineArray->AppendL(TPoint(16,3));
|
|
66 |
polyLineArray->AppendL(TPoint(0,10));
|
|
67 |
polyLineArray->AppendL(TPoint(8,0));
|
|
68 |
gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
69 |
gc->SetOrigin(TPoint(50,50));
|
|
70 |
gc->DrawPolyLine(polyLineArray);
|
|
71 |
gc->SetOrigin(TPoint(75,50));
|
|
72 |
gc->DrawPolyLine(&(polyLineArray->At(0)),polyLineArray->Count());
|
|
73 |
polyLineArray->Delete(5);
|
|
74 |
gc->SetOrigin(TPoint(0,65));
|
|
75 |
gc->DrawPolygon(polyLineArray,CGraphicsContext::EWinding);
|
|
76 |
gc->SetOrigin(TPoint(25,65));
|
|
77 |
gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EWinding);
|
|
78 |
gc->SetOrigin(TPoint(50,65));
|
|
79 |
gc->DrawPolygon(polyLineArray,CGraphicsContext::EAlternate);
|
|
80 |
gc->SetOrigin(TPoint(75,65));
|
|
81 |
gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EAlternate);
|
|
82 |
CleanupStack::PopAndDestroy();
|
|
83 |
gc->SetBrushStyle(CGraphicsContext::ENullBrush);
|
|
84 |
gc->SetOrigin(TPoint(0,0));
|
|
85 |
//
|
|
86 |
gc->DrawPie(TRect(5,80,30,100),TPoint(10,65),TPoint(35,80));
|
|
87 |
gc->DrawEllipse(TRect(35,80,60,100));
|
|
88 |
gc->DrawRoundRect(TRect(65,80,80,100),TSize(5,3));
|
|
89 |
gc->DrawBitmap(TRect(10,105,40,120),aBitmap);
|
|
90 |
gc->DrawBitmap(TRect(45,105,105,125),aBitmap,TRect(5,5,25,20));
|
|
91 |
//gc->DrawBitmap(TRect(110,40,205,125),aBitmap,TRect(5,5,25,20));
|
|
92 |
if (aExtraDrawBitMap)
|
|
93 |
gc->DrawBitmap(TPoint(110,70),aBitmap);
|
|
94 |
//
|
|
95 |
gc->UseFont(aFont);
|
|
96 |
TInt height=aFont->HeightInPixels();
|
|
97 |
TInt ascent=aFont->AscentInPixels();
|
|
98 |
TInt ypos=5;
|
|
99 |
TInt xpos=100;
|
|
100 |
gc->DrawText(_L("Test1"),TPoint(xpos,ypos+ascent));
|
|
101 |
gc->DrawText(_L("Test2"),TRect(xpos,ypos+height,xpos+50,5+height*2),ascent);
|
|
102 |
gc->DrawText(_L("Test3"),TRect(xpos,ypos+height*2,xpos+80,5+height*3),ascent,CGraphicsContext::ERight,10);
|
|
103 |
//
|
|
104 |
ypos+=ascent+height*3;
|
|
105 |
gc->SetUnderlineStyle(EUnderlineOn);
|
|
106 |
gc->DrawText(_L("ULine"),TPoint(xpos,ypos));
|
|
107 |
gc->SetUnderlineStyle(EUnderlineOff);
|
|
108 |
//
|
|
109 |
gc->SetStrikethroughStyle(EStrikethroughOn);
|
|
110 |
gc->DrawText(_L("Strike"),TPoint(xpos+50,ypos));
|
|
111 |
gc->SetStrikethroughStyle(EStrikethroughOff);
|
|
112 |
gc->SetCharJustification(15,3);
|
|
113 |
gc->DrawText(_L("abc"),TPoint(xpos+100,ypos));
|
|
114 |
//
|
|
115 |
gc->SetWordJustification(10,1);
|
|
116 |
gc->DrawText(_L("Two Words"),TPoint(xpos+5,ypos+height));
|
|
117 |
//
|
|
118 |
xpos = 80;
|
|
119 |
ypos = 40;
|
|
120 |
RRegion clipRegion(2);
|
|
121 |
//
|
|
122 |
clipRegion.AddRect(TRect(xpos, ypos+10, xpos+30, ypos+20));
|
|
123 |
clipRegion.AddRect(TRect(xpos, ypos+30, xpos+30, ypos+40));
|
|
124 |
gc->SetClippingRegion(clipRegion);
|
|
125 |
//
|
|
126 |
gc->DrawTextVertical(_L("Vertical Text"), TPoint(xpos+10, ypos+10), EFalse);
|
|
127 |
gc->DrawTextVertical(_L("Vertical Text Box"), TRect(xpos+40, ypos+10, xpos+60, ypos+100), 15, EFalse);
|
|
128 |
//
|
|
129 |
gc->CancelClippingRegion();
|
|
130 |
clipRegion.Close();
|
|
131 |
//
|
|
132 |
gc->AlphaBlendBitmaps(TPoint(xpos+60, ypos+100), aBitmap, TRect(0, 0, 20,20), aMaskBitmap, TPoint(0, 0));
|
|
133 |
//
|
|
134 |
gc->SetPenColor(TRgb::Gray4(3));
|
|
135 |
gc->SetBrushColor(TRgb::Gray4(0));
|
|
136 |
gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
137 |
xpos = 0;
|
|
138 |
ypos = 120;
|
|
139 |
TRect mapColorRect(xpos, ypos, xpos+20, ypos+20);
|
|
140 |
gc->DrawRect(mapColorRect);
|
|
141 |
TRgb colours[4] = { TRgb::Gray4(3), TRgb::Gray4(0), TRgb::Gray4(0), TRgb::Gray4(3) };
|
|
142 |
gc->MapColors(mapColorRect, colours, 2, ETrue);
|
|
143 |
//
|
|
144 |
gc->DiscardFont();
|