|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef LCDGRAPHICS_H |
|
19 #define LCDGRAPHICS_H |
|
20 |
|
21 #include <lcdui.h> |
|
22 #include <reflcdui.h> // for direct container/content |
|
23 #include <lcdgr.h> |
|
24 #include <lcdgdrv.h> |
|
25 #include "LcdSurface.h" |
|
26 |
|
27 #ifdef __SERIES60_ |
|
28 #include <AknPictographInterface.h> |
|
29 #include <AknPictographDrawerInterface.h> |
|
30 |
|
31 class CMIDPictograph; |
|
32 #endif |
|
33 |
|
34 class CCoeControl; |
|
35 class CFbsBitmap; |
|
36 class CLcdImage; |
|
37 class CLcdGraphicsDriver; |
|
38 |
|
39 TBool IsStronglyRightToLeft(const TDesC& aText); |
|
40 void ArcVectors(TPoint& aStart, TPoint& aEnd, const TRect& aRect, TInt aStartAngle, TInt aArcAngle); |
|
41 |
|
42 /** |
|
43 * Native peer to javax.microedition.lcdui.Graphics. |
|
44 */ |
|
45 NONSHARABLE_CLASS(CLcdGraphics) : public CBase |
|
46 { |
|
47 public: |
|
48 static CLcdGraphics* NewL(CLcdGraphicsDriver& aDriver, CCoeControl& aWindow, MDirectContainer& aContainer, TBool aUpdate); |
|
49 static CLcdGraphics* NewL(CLcdGraphicsDriver& aDriver, const CFbsBitmap* aBitmap); |
|
50 |
|
51 /** |
|
52 * function takes ownership of aSurface - do not push aSurface onto cleanup stack |
|
53 */ |
|
54 static CLcdGraphics* NewL(CLcdGraphicsDriver& aDriver, CLcdSurface* aSurface); |
|
55 |
|
56 ~CLcdGraphics(); |
|
57 |
|
58 /** |
|
59 * Prepare to draw |
|
60 */ |
|
61 void Begin(); |
|
62 |
|
63 /** |
|
64 * drawing complete. |
|
65 */ |
|
66 void End(); |
|
67 |
|
68 /** |
|
69 * flush drawing in rect at <CODE>aPosition</CODE> of size <CODE>aSize</CODE> |
|
70 * (in device coords) to surface. |
|
71 */ |
|
72 void Flush(const TPoint& aPosition, const TSize& aSize); |
|
73 |
|
74 TUint32 QuantizeColor(TUint32 aColor); |
|
75 |
|
76 void Reset(const TSize& aSize); |
|
77 |
|
78 void SetColor(TUint32 aColor); |
|
79 TUint32 Color() const; |
|
80 |
|
81 void SetStrokeStyle(TStrokeStyle aStyle); |
|
82 TStrokeStyle StrokeStyle() const; |
|
83 |
|
84 void SetFont(TUint32 aFontID); |
|
85 |
|
86 void SetClipRect(const TPoint& aPosition, const TSize& aSize); |
|
87 const TRect& ClipRect() const; |
|
88 |
|
89 void Translate(const TPoint& aPoint); |
|
90 const TPoint& Origin() const; |
|
91 |
|
92 void CopyArea(const TPoint& aPosition, const TSize& aSize, const TPoint& aPoint, TInt aAnchor); |
|
93 void DrawLine(const TPoint& aStart, const TPoint& aEnd); |
|
94 void DrawRect(const TPoint& aPosition, const TSize& aSize); |
|
95 void FillRect(const TPoint& aPosition, const TSize& aSize); |
|
96 void DrawRoundRect(const TPoint& aPosition, const TSize& aSize, const TSize& aCornerDiameter); |
|
97 void FillRoundRect(const TPoint& aPosition, const TSize& aSize, const TSize& aCornerDiameter); |
|
98 void DrawArc(const TPoint& aPosition, const TSize& aSize, TInt aStartAngle, TInt aAngle); |
|
99 void FillArc(const TPoint& aPosition, const TSize& aSize, TInt aStartAngle, TInt aAngle); |
|
100 void DrawText(const TDesC& aText, const TPoint& aPoint, TInt aAnchor); |
|
101 void FillTriangle(const TPoint* aPoints); |
|
102 TInt DrawPixels |
|
103 ( |
|
104 TInt aType, |
|
105 const TUint8* aAddress, |
|
106 TInt aLength, |
|
107 TInt aScanLength, |
|
108 TBool aAlpha, |
|
109 const TPoint& aPosition, |
|
110 const TSize& aSize, |
|
111 TInt aTransform, |
|
112 TBool aPremultiplied |
|
113 ); |
|
114 |
|
115 /** |
|
116 * Renders image |
|
117 * @param aImage Source image |
|
118 * @param aPoint Render point |
|
119 * @param aAnchor Maps the render point, source image and render surface |
|
120 * @param aPremultiplied If true then a target color channel is premultiplied with alpha value. |
|
121 */ |
|
122 void DrawImage(const CLcdImage& aImage, const TPoint& aPoint, TInt aAnchor, |
|
123 TBool aPremultiplied = EFalse); |
|
124 /** |
|
125 * Renders image region |
|
126 * @param aImage Source image |
|
127 * @param aPoint Source point |
|
128 * @param aRegion Source width and height |
|
129 * @param aTransform Defines transform mode |
|
130 * @param aPoint Render point |
|
131 * @param aAnchor Maps the render point, region and render surface |
|
132 * @param aPremultiplied If true then a target color channel is premultiplied with alpha value. |
|
133 */ |
|
134 TInt DrawRegion( |
|
135 const CLcdImage& aImage, const TPoint& aRegionPos, const TSize& aRegionSize, |
|
136 TInt aTransform, const TPoint& aPoint, TInt aAnchor, TBool aPremultiplied = EFalse); |
|
137 |
|
138 /** |
|
139 * @see MMIDCanvas::DrawBackground() |
|
140 * @since S60 5.0 |
|
141 */ |
|
142 void DrawBackground(MMIDCanvas* aCanvas, const TPoint& aPosition, const TSize& aSize); |
|
143 |
|
144 /** |
|
145 * Support for MMIDGraphics::Bitmap()/MMIDGraphics:Window(). |
|
146 * |
|
147 *@return the drawing surface for this graphics instance. |
|
148 */ |
|
149 CLcdSurface* Surface(); |
|
150 |
|
151 #ifdef RD_JAVA_NGA_ENABLED |
|
152 /** |
|
153 * Copies graphics content |
|
154 * @param aSrcGraphics The source graphics |
|
155 * @return KErrNone if succeeded. |
|
156 * @since S60 9.2 |
|
157 */ |
|
158 TInt CopyGraphics(CLcdGraphics* aSrcGraphics); |
|
159 |
|
160 /** |
|
161 * Gets current clip rectangle. |
|
162 * @return The clip rectangle in user coordinates |
|
163 * @since S60 9.2 |
|
164 */ |
|
165 inline TRect CurrentClipRectInTargetCoords() const; |
|
166 |
|
167 /** |
|
168 * Gets current origin. |
|
169 * @return The origin in user coordinates |
|
170 * @since S60 9.2 |
|
171 */ |
|
172 inline TPoint CurrentOriginInTargetCoords() const; |
|
173 |
|
174 /** |
|
175 * Gets current font. |
|
176 * @return The current font |
|
177 * @since S60 9.2 |
|
178 */ |
|
179 inline CFont* CurrentFont() const; |
|
180 |
|
181 #endif // RD_JAVA_NGA_ENABLED |
|
182 |
|
183 /** |
|
184 * Sets the flag, which indicates that rendering target is framebuffer |
|
185 * of CanavsGraphicsItem. |
|
186 */ |
|
187 void SetCanvasGraphicsItemtarget(TBool aIsCanvasGraphicsItemTarget); |
|
188 |
|
189 private: |
|
190 CLcdGraphics(CLcdGraphicsDriver& aDriver, CLcdSurface* aSurface); |
|
191 void ConstructL(); |
|
192 |
|
193 private: |
|
194 enum TState |
|
195 { |
|
196 EPenOn = 1, |
|
197 EBrushOn = 2, |
|
198 EPenColor = 4, |
|
199 EBrushColor = 8 |
|
200 }; |
|
201 |
|
202 private: |
|
203 inline void SetPenOn(); |
|
204 inline void SetPenOff(); |
|
205 inline void SetBrushOn(); |
|
206 inline void SetBrushOff(); |
|
207 inline void LineMode(); |
|
208 inline void FillMode(); |
|
209 inline void OutlineMode(); |
|
210 |
|
211 private: |
|
212 CLcdGraphicsDriver& iLcdDriver; |
|
213 CLcdGraphicsDevice* iLcdDevice; |
|
214 TUint32 iLcdDrawCaps; |
|
215 |
|
216 #ifdef __SERIES60_ |
|
217 CMIDPictograph* iMIDPictograph; |
|
218 #endif |
|
219 |
|
220 CLcdSurface* iSurface; |
|
221 TAcceleratedBitmapInfo iBitmap; // data owned by surface |
|
222 TBitmapLockCount iCount; |
|
223 CBitmapContext* iContext; // owned by surface |
|
224 |
|
225 TRect iDeviceBounds; // surface drawable area in device coords |
|
226 TRect iDeviceClipRect; // clip rect in device coords |
|
227 TPoint iDeviceOrigin; // origin in device coords. |
|
228 |
|
229 TInt iState; |
|
230 TStrokeStyle iStrokeStyle; |
|
231 TUint32 iColor; |
|
232 CFont* iFont; |
|
233 TFontUnderline iUnderline; |
|
234 TRect iClipRect; |
|
235 TPoint iOrigin; |
|
236 TInt iHeight; |
|
237 |
|
238 // this flag indicates that rendering target is framebuffer of CanavsGraphicsItem |
|
239 TBool iIsCanvasGraphicsItemTarget; |
|
240 }; |
|
241 |
|
242 ///////////////////////////////////////////////////////////// |
|
243 // CMIDPictograph is for Pictograpgh in S60 |
|
244 // |
|
245 //////////////////////////////////////////////////////////// |
|
246 #ifdef __SERIES60_ |
|
247 |
|
248 class CMIDPictograph : public CBase, public MAknPictographAnimatorCallBack |
|
249 { |
|
250 public: |
|
251 static CMIDPictograph* NewL(); |
|
252 |
|
253 CAknPictographInterface* PictographInterface(); |
|
254 |
|
255 // From MAknPictographAnimatorCallBack |
|
256 void DrawPictographArea(); |
|
257 |
|
258 virtual ~CMIDPictograph(); |
|
259 protected: |
|
260 CMIDPictograph(); |
|
261 void ConstructL(); |
|
262 |
|
263 private: |
|
264 CAknPictographInterface* iPictographInterface; |
|
265 }; |
|
266 |
|
267 #endif // end of __SERIES60_ |
|
268 |
|
269 #ifdef RD_JAVA_NGA_ENABLED |
|
270 // --------------------------------------------------------------------------- |
|
271 // CLcdGraphics::CurrentClipRectInTargetCoords |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 inline TRect CLcdGraphics::CurrentClipRectInTargetCoords() const |
|
275 { |
|
276 return iDeviceClipRect; |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // CLcdGraphics::CurrentOriginInTargetCoords |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 inline TPoint CLcdGraphics::CurrentOriginInTargetCoords() const |
|
284 { |
|
285 return iDeviceOrigin; |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CLcdGraphics::CurrentFont |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 inline CFont* CLcdGraphics::CurrentFont() const |
|
293 { |
|
294 return iFont; |
|
295 } |
|
296 |
|
297 #endif // RD_JAVA_NGA_ENABLED |
|
298 |
|
299 #endif // LCDGRAPHICS_H |
|
300 |