|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of CHuiCanvasAlfPainter. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUICANVASALFPAINTER_H__ |
|
21 #define __HUICANVASALFPAINTER_H__ |
|
22 |
|
23 #include <uiacceltk/HuiVisual.h> |
|
24 #include "uiacceltk/HuiTextMesh.h" |
|
25 //#include <uiacceltk/HuiCanvasPainter.h> |
|
26 #include "huicanvaspainter.h" |
|
27 |
|
28 enum THuiCanvasCommands |
|
29 { |
|
30 // Draw ops |
|
31 EHuiCanvasDrawImage, |
|
32 EHuiCanvasDrawText, |
|
33 EHuiCanvasDrawLines, |
|
34 EHuiCanvasDrawEllipse, |
|
35 EHuiCanvasDrawPoints, |
|
36 EHuiCanvasDrawPolygon, |
|
37 EHuiCanvasDrawRects, |
|
38 |
|
39 // Setters |
|
40 EHuiCanvasSetTextStyle, |
|
41 EHuiCanvasSetPenColor, |
|
42 EHuiCanvasSetPenWidth, |
|
43 EHuiCanvasSetOpacity, |
|
44 EHuiCanvasSetPolygonDrawMode, |
|
45 EHuiCanvasSetTextAlign, |
|
46 |
|
47 // Transformations |
|
48 EHuiCanvasLoadIdentity, |
|
49 EHuiCanvasTranslate, |
|
50 EHuiCanvasScale, |
|
51 EHuiCanvasRotate, |
|
52 |
|
53 // Misc |
|
54 EHuiCanvasPrepareDrawText |
|
55 }; |
|
56 |
|
57 NONSHARABLE_STRUCT( THuiCanvasDrawImageParams ) |
|
58 { |
|
59 TInt iTexture; |
|
60 TReal32 iDestinationRectTopLeftX; |
|
61 TReal32 iDestinationRectTopLeftY; |
|
62 TReal32 iDestinationRectBottomRightX; |
|
63 TReal32 iDestinationRectBottomRightY; |
|
64 }; |
|
65 |
|
66 NONSHARABLE_STRUCT( THuiCanvasDrawTextParams ) |
|
67 { |
|
68 TReal32 iDestinationRectTopLeftX; |
|
69 TReal32 iDestinationRectTopLeftY; |
|
70 TReal32 iDestinationRectBottomRightX; |
|
71 TReal32 iDestinationRectBottomRightY; |
|
72 }; |
|
73 |
|
74 |
|
75 NONSHARABLE_STRUCT( THuiCanvasDrawEllipseParams ) |
|
76 { |
|
77 TReal32 iDestinationRectTopLeftX; |
|
78 TReal32 iDestinationRectTopLeftY; |
|
79 TReal32 iDestinationRectBottomRightX; |
|
80 TReal32 iDestinationRectBottomRightY; |
|
81 }; |
|
82 |
|
83 NONSHARABLE_STRUCT( THuiCanvasSetTextStyleParams ) |
|
84 { |
|
85 TInt iTextStyleId; |
|
86 }; |
|
87 |
|
88 NONSHARABLE_STRUCT( THuiCanvasDrawTextCachedTextEntry ) |
|
89 { |
|
90 TInt iId; |
|
91 CHuiTextMesh* iTextMesh; |
|
92 }; |
|
93 |
|
94 NONSHARABLE_STRUCT( THuiCanvasSetPenColorParams ) |
|
95 { |
|
96 TRgb iPenColor; |
|
97 }; |
|
98 NONSHARABLE_STRUCT( THuiCanvasSetPenWidthParams ) |
|
99 { |
|
100 TReal32 iPenWidth; |
|
101 }; |
|
102 NONSHARABLE_STRUCT( THuiCanvasSetOpacityParams ) |
|
103 { |
|
104 TReal32 iOpacity; |
|
105 }; |
|
106 NONSHARABLE_STRUCT( THuiCanvasSetPolygonDrawModeParams ) |
|
107 { |
|
108 THuiFillMode iPolygonDrawMode; |
|
109 }; |
|
110 NONSHARABLE_STRUCT( THuiCanvasSetTextAlignParams ) |
|
111 { |
|
112 TInt iTextAlignHorizontal; |
|
113 TInt iTextAlignVertical; |
|
114 }; |
|
115 |
|
116 |
|
117 // Transformations |
|
118 NONSHARABLE_STRUCT( THuiCanvasLoadIdentityParams ) |
|
119 { |
|
120 TInt iDummy; |
|
121 }; |
|
122 |
|
123 NONSHARABLE_STRUCT( THuiCanvasTranslateParams ) |
|
124 { |
|
125 TReal32 iX; |
|
126 TReal32 iY; |
|
127 TReal32 iZ; |
|
128 }; |
|
129 |
|
130 NONSHARABLE_STRUCT( THuiCanvasScaleParams ) |
|
131 { |
|
132 TReal32 iX; |
|
133 TReal32 iY; |
|
134 TReal32 iZ; |
|
135 }; |
|
136 |
|
137 NONSHARABLE_STRUCT( THuiCanvasRotateParams ) |
|
138 { |
|
139 TReal32 iAngle; |
|
140 TReal32 iX; |
|
141 TReal32 iY; |
|
142 TReal32 iZ; |
|
143 }; |
|
144 |
|
145 |
|
146 |
|
147 /** |
|
148 * This class is used internally by the toolkit and thus should |
|
149 * not be used by the applications directly. |
|
150 */ |
|
151 NONSHARABLE_CLASS(CHuiCanvasAlfPainter) : public CHuiCanvasPainter |
|
152 { |
|
153 |
|
154 private: |
|
155 /** |
|
156 * Constructor. |
|
157 */ |
|
158 CHuiCanvasAlfPainter(); |
|
159 |
|
160 /** |
|
161 * Second-phase constructor. |
|
162 */ |
|
163 void ConstructL(); |
|
164 |
|
165 |
|
166 public: |
|
167 /** |
|
168 * Constructor. |
|
169 */ |
|
170 static CHuiCanvasAlfPainter* NewL(); |
|
171 |
|
172 /** |
|
173 * Destructor. |
|
174 */ |
|
175 ~CHuiCanvasAlfPainter(); |
|
176 |
|
177 |
|
178 public: // From CHuiCanvasPainter |
|
179 |
|
180 /** |
|
181 * Sets buffer that contains canvas drawing commands. This |
|
182 * method clears previous buffer(s). |
|
183 * |
|
184 * @param aCommands Commanbuffer |
|
185 */ |
|
186 virtual void SetCommandSetL( const TDesC8& aCommands ); |
|
187 |
|
188 /** |
|
189 * Clears buffer(s) that contains canvas drawing commands. |
|
190 */ |
|
191 virtual void ClearCommandSet(); |
|
192 |
|
193 /** |
|
194 * Adds buffer that contains more canvas drawing commands, |
|
195 * those will be executed after the buffers that has been |
|
196 * added previously. |
|
197 * @param aMoreCommands Commanbuffer |
|
198 */ |
|
199 virtual void AddCommandSetL( const TDesC8& aMoreCommands ); |
|
200 |
|
201 /** |
|
202 * Adds partial buffer that contains more canvas drawing commands. These |
|
203 * commands are appended to the commands set previously with this method |
|
204 * until param aLastPart has value ETrue. After that whole command set |
|
205 * will be added among possibly already existing command sets and |
|
206 * it will be drawable. |
|
207 * |
|
208 * @param aMoreCommands Commanbuffer |
|
209 * @param aLastPart EFalse if there are more commands to be added into this |
|
210 * command set before it is wanted to be available for drawing. ETrue if |
|
211 * command set is ready and no more parts are expected. |
|
212 */ |
|
213 virtual void AddPartialCommandSetL( const TDesC8& aMoreCommands, TBool aLastPart ); |
|
214 |
|
215 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
216 virtual void SetTrackCommandSet( TFileName& aFileName, TBool aTrack ); |
|
217 #endif |
|
218 |
|
219 /** |
|
220 * Clears internal cached texts and images. |
|
221 */ |
|
222 virtual void ClearCache(); |
|
223 |
|
224 /** |
|
225 * Handles the command buffer(s), either draws or performs a scan. |
|
226 */ |
|
227 virtual void HandleBufferL(TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint aPos ) ; |
|
228 virtual void HandleBufferL(TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint aPos, TPtrC8 aCommands, CHuiCanvasCommandBuffer *buf) { } |
|
229 |
|
230 /** |
|
231 * Returns the number of rectangular areas which contain something that is |
|
232 * drawn by the painter. |
|
233 * |
|
234 * @return number of painted areas. |
|
235 * @see PaintedArea() |
|
236 */ |
|
237 virtual TInt PaintedAreaCount() const; |
|
238 |
|
239 /** |
|
240 * Returns information of the painted area at given index. |
|
241 * |
|
242 * @aIndex Index of the painted area. |
|
243 * @return Painted area info. |
|
244 * @see PaintedAreaCount() |
|
245 */ |
|
246 virtual THuiCanvasPaintedArea PaintedArea(TInt aIndex); |
|
247 |
|
248 /** |
|
249 * Draws content of the window in pixel format to the given bitmap. |
|
250 * This method may not be supported in all commanbuffertype/renderer combinations. |
|
251 * |
|
252 * @param aTargetBuffer where content of the window is to be drawn. NULL if the drawing |
|
253 * is to be stopped. |
|
254 * |
|
255 * @return KErrNotSupported if the current renderer/painter does not support the |
|
256 * feature. Leave happens in other unexpected error situtations. |
|
257 * |
|
258 */ |
|
259 virtual TInt SetCapturingBufferL(CFbsBitmap* /*aTarget*/); |
|
260 |
|
261 /** |
|
262 * Tells painter to enable/disable render buffer (if it is supported by the |
|
263 * painter implementation) |
|
264 * |
|
265 * @return KErrNotSupported if the current renderer/painter does not support the |
|
266 */ |
|
267 virtual TInt EnableRenderBuffer(TBool aEnable = ETrue); |
|
268 |
|
269 virtual CHuiCanvasGc& CanvasGc() const; |
|
270 |
|
271 private: |
|
272 void ClearHuiTextCache(); |
|
273 |
|
274 private: |
|
275 // Hui command buffer handling |
|
276 RArray<THuiCanvasDrawTextCachedTextEntry> iCachedTexts; |
|
277 RArray<TReal32> iPointCords; |
|
278 CHuiCanvasGc* iCanvasGc; |
|
279 THuiRealRect iPaintedRect; |
|
280 }; |
|
281 #endif // __HUICANVASALFPAINTER_H__ |