|
1 /******************************************************************************* |
|
2 * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #ifndef ESWTGRAPHICS_H |
|
14 #define ESWTGRAPHICS_H |
|
15 |
|
16 |
|
17 #include <e32base.h> |
|
18 #include "eswt.h" |
|
19 |
|
20 |
|
21 class MSwtGc; |
|
22 class TRequestStatus; |
|
23 |
|
24 |
|
25 /** |
|
26 * Utility base class for managing reference-counted objects |
|
27 */ |
|
28 class MSwtRefCounted |
|
29 { |
|
30 protected: |
|
31 inline MSwtRefCounted(); |
|
32 virtual ~MSwtRefCounted() {}; |
|
33 |
|
34 public: |
|
35 inline void AddRef() const; |
|
36 inline void RemoveRef() const; |
|
37 inline TInt RefCount() const; |
|
38 |
|
39 private: |
|
40 mutable TInt iRefCount; |
|
41 }; |
|
42 |
|
43 |
|
44 /** |
|
45 * Initialises the reference count to 1. |
|
46 */ |
|
47 inline MSwtRefCounted::MSwtRefCounted() |
|
48 : iRefCount(1) |
|
49 { |
|
50 } |
|
51 |
|
52 /** |
|
53 * Increases the object's reference count by 1. |
|
54 */ |
|
55 inline void MSwtRefCounted::AddRef() const |
|
56 { |
|
57 ++iRefCount; |
|
58 } |
|
59 |
|
60 /** |
|
61 * Decreases the object's reference count by 1. |
|
62 * If the reference count reaches 0, the object is destroyed. |
|
63 */ |
|
64 inline void MSwtRefCounted::RemoveRef() const |
|
65 { |
|
66 if (--iRefCount == 0) |
|
67 delete const_cast<MSwtRefCounted*>(this); |
|
68 } |
|
69 |
|
70 /** |
|
71 * Returns the object's current reference count. |
|
72 */ |
|
73 inline TInt MSwtRefCounted::RefCount() const |
|
74 { |
|
75 return iRefCount; |
|
76 } |
|
77 |
|
78 /** |
|
79 * Object containing the data needed for the |
|
80 * org.eclipse.swt.graphics.PaletteData class. |
|
81 */ |
|
82 class MSwtPaletteData |
|
83 { |
|
84 // Data types |
|
85 public: |
|
86 /** |
|
87 * Data structure for direct palettes |
|
88 * |
|
89 * To extract a component from a colour: first apply the mask and then |
|
90 * shift the result by the specified value. |
|
91 * |
|
92 * To combine components in order to build a colour, for each component: |
|
93 * first shift by the opposite of the specified value and then apply the |
|
94 * mask. Finally, combine all three components with a OR operator. |
|
95 * |
|
96 * In both cases, a positive value indicates a left shift whereas a |
|
97 * negative one indicates a right shift. |
|
98 */ |
|
99 struct TDirectData |
|
100 { |
|
101 TInt iRedMask; // The red mask for a direct palette. |
|
102 TInt iGreenMask; // The green mask for a direct palette. |
|
103 TInt iBlueMask; // The blue mask for a direct palette. |
|
104 TInt iRedShift; // The red shift for a direct palette. |
|
105 TInt iGreenShift; // The green shift for a direct palette. |
|
106 TInt iBlueShift; // The blue shift for a direct palette. |
|
107 }; |
|
108 |
|
109 // Methods |
|
110 public: |
|
111 virtual ~MSwtPaletteData() {} |
|
112 |
|
113 /** |
|
114 * Test whether a palette is a direct or an indirect one |
|
115 */ |
|
116 virtual TBool IsDirect() const =0; |
|
117 |
|
118 /** |
|
119 * Returns the data of a direct palette |
|
120 */ |
|
121 virtual const TDirectData& DirectData() const =0; |
|
122 |
|
123 /** |
|
124 * Returns the data of an indirect palette |
|
125 */ |
|
126 virtual const CPalette* IndirectData() const =0; |
|
127 }; |
|
128 |
|
129 /** |
|
130 * Object containing the data needed for the |
|
131 * org.eclipse.swt.graphics.ImageData class. |
|
132 */ |
|
133 class MSwtImageData |
|
134 { |
|
135 // Data types |
|
136 public: |
|
137 struct TInfo |
|
138 { |
|
139 TSize iSize; // The size of the image, in pixels. |
|
140 TInt iDepth; // The color depth of the image, in bits per pixel. |
|
141 TInt iScanlinePad; // The scanline padding. |
|
142 TInt iBytesPerLine; // The number of bytes per scanline. |
|
143 TInt iTransparentPixel; // The transparent pixel. |
|
144 TInt iMaskPad; // An icon-specific field containing the scanline pad of the mask. |
|
145 TInt iAlpha; // The global alpha value to be used for every pixel. |
|
146 TSwtImageType iType; // The type of file from which the image was read. |
|
147 TPoint iTopLeft; // The coordinates of the top-left corner of the image within the logical screen. |
|
148 TSwtGifDisposal iDisposalMethod; // A description of how to dispose of the current image before displaying the next. |
|
149 TInt iDelayTime; // The time to delay before displaying the next image in an animation |
|
150 }; |
|
151 |
|
152 // Methods |
|
153 public: |
|
154 virtual ~MSwtImageData() {} |
|
155 virtual const TInfo& Info() const =0; |
|
156 virtual const MSwtPaletteData& Palette() const =0; |
|
157 virtual const HBufC8& PixelBuffer() const =0; |
|
158 virtual const HBufC8* MaskBuffer() const =0; |
|
159 virtual const HBufC8* AlphaBuffer() const =0; |
|
160 }; |
|
161 |
|
162 /** |
|
163 * Interface class for the |
|
164 * org.eclipse.swt.graphics.Color class. |
|
165 */ |
|
166 class MSwtColor |
|
167 { |
|
168 protected: |
|
169 virtual ~MSwtColor() {} // Made protected to prevent destruction through the interface |
|
170 |
|
171 public: |
|
172 /** |
|
173 * Disposes of (i.e. destroys) the colour |
|
174 */ |
|
175 virtual void Dispose() =0; |
|
176 |
|
177 /** |
|
178 * Retrieves the RGB value representing the colour such as it would |
|
179 * appear on the associated device. |
|
180 */ |
|
181 virtual TRgb RgbValue() const =0; |
|
182 }; |
|
183 |
|
184 /** |
|
185 * Interface class for the org.eclipse.swt.graphics.Drawable interface. |
|
186 * Devices and GCs have been restricted to bitmap ones rather than fully |
|
187 * generic ones as no printer support is available in eSWT. |
|
188 */ |
|
189 class MSwtDrawable |
|
190 { |
|
191 protected: |
|
192 virtual ~MSwtDrawable() {} // Made protected to prevent destruction through the interface |
|
193 |
|
194 public: |
|
195 /** |
|
196 * Creates a new graphics context to draw on. |
|
197 */ |
|
198 virtual MSwtGc* NewGcL() =0; |
|
199 |
|
200 /** |
|
201 * The native device used by this drawable |
|
202 */ |
|
203 virtual CBitmapDevice& GraphicsDevice() =0; |
|
204 |
|
205 /** |
|
206 * Called after the Drawable's content has been modified. |
|
207 */ |
|
208 virtual void HandleUpdate() =0; |
|
209 }; |
|
210 |
|
211 /** |
|
212 * Interface class for the org.eclipse.swt.graphics.Drawable |
|
213 * interface as applied to the window server's GCs. |
|
214 */ |
|
215 class MSwtWindowDrawable : public MSwtDrawable |
|
216 { |
|
217 protected: |
|
218 virtual ~MSwtWindowDrawable() {} // Made protected to prevent destruction through the interface |
|
219 }; |
|
220 |
|
221 /** |
|
222 * Interface class for the org.eclipse.swt.graphics.Drawable |
|
223 * interface as applied to the font & bitmap server's GCs. |
|
224 */ |
|
225 class MSwtBitmapDrawable : public MSwtDrawable |
|
226 { |
|
227 protected: |
|
228 virtual ~MSwtBitmapDrawable() {} // Made protected to prevent destruction through the interface |
|
229 }; |
|
230 |
|
231 /** |
|
232 * Interface class for the org.eclipse.swt.graphics.Font class. |
|
233 * Fonts are not intended to be disposed of while they are referenced by some |
|
234 * control and/or GC. Nonetheless, a broken application may loosely follow the |
|
235 * SWT coding guidelines and fail to do so, thereby causing an access violation. |
|
236 * In order to prevent such behaviour, fonts are reference counted, see |
|
237 * MSwtRefCounted. |
|
238 */ |
|
239 class MSwtFont : public MSwtRefCounted |
|
240 { |
|
241 protected: |
|
242 /** |
|
243 * Destructor |
|
244 */ |
|
245 virtual ~MSwtFont() {}; |
|
246 |
|
247 public: |
|
248 |
|
249 /** |
|
250 * Disposes of (i.e. destroys) the font. |
|
251 * The font is disposed of by calling its RemoveRef() method. |
|
252 * It is therefore an error to try and dispose of a font whose reference |
|
253 * count is higher than 1. |
|
254 */ |
|
255 virtual void Dispose() =0; |
|
256 |
|
257 /** |
|
258 * Returns the native font object. |
|
259 */ |
|
260 virtual const CFont& Font() const =0; |
|
261 |
|
262 /** |
|
263 * Returns the height of the native font, in points. |
|
264 * The design height of a font is the "aesthetic" height specified by the designer |
|
265 * and not the actual "physical" height. See Symbian's Improved_Font_Metrics_How_To.doc |
|
266 */ |
|
267 virtual TInt DesignHeightInPoints() const =0; |
|
268 |
|
269 /** |
|
270 * Returns the typeface name of the native font. |
|
271 * The new descriptor should then be freed when no more needed. |
|
272 * If the font has been substituted, this function will return the original |
|
273 * name used to create the font, not the substituted name. |
|
274 */ |
|
275 virtual HBufC* GetNameL() const =0; |
|
276 |
|
277 /** |
|
278 * Returns the style of the native font. |
|
279 */ |
|
280 virtual TInt Style() const =0; |
|
281 |
|
282 /** |
|
283 * Returns the width in pixels of the specified descriptor when displayed in this font. |
|
284 */ |
|
285 virtual TInt TextWidthInPixels(const TDesC& aText) const=0; |
|
286 }; |
|
287 |
|
288 /** |
|
289 * Structure containing the data needed for the |
|
290 * org.eclipse.swt.graphics.FontMetrics class. |
|
291 */ |
|
292 struct TSwtFontMetrics |
|
293 { |
|
294 TInt iAscent; // Ascent of the font, measured in pixels. |
|
295 TInt iAverageCharWidth; // Average character width, measured in pixels. |
|
296 TInt iDescent; // Descent of the font, measured in pixels. |
|
297 TInt iHeight; // Height of the font, measured in pixels. |
|
298 TInt iLeading; // Leading area of the font, measured in pixels. |
|
299 }; |
|
300 |
|
301 |
|
302 struct TSwtFontData |
|
303 { |
|
304 TFontSpec iFontSpec; |
|
305 }; |
|
306 |
|
307 |
|
308 /** |
|
309 * Interface class for the org.eclipse.swt.graphics.Device class. |
|
310 */ |
|
311 class MSwtDevice : public MSwtBitmapDrawable |
|
312 { |
|
313 protected: |
|
314 virtual ~MSwtDevice() {} // Made protected to prevent destruction through the interface |
|
315 |
|
316 public: |
|
317 /** |
|
318 * Creates a Color object for this device. |
|
319 */ |
|
320 virtual MSwtColor* CreateColorL(const TRgb& aRgbValue) const =0; |
|
321 |
|
322 /** |
|
323 * Returns a rectangle describing device's size and location. |
|
324 */ |
|
325 virtual TRect Bounds() const =0; |
|
326 |
|
327 /** |
|
328 * Returns a rectangle which describes the area of the device which |
|
329 * is capable of displaying data. |
|
330 */ |
|
331 virtual TRect ClientArea() const =0; |
|
332 |
|
333 /** |
|
334 * Returns the bit depth of the screen. |
|
335 */ |
|
336 virtual TInt Depth() const =0; |
|
337 |
|
338 /** |
|
339 * Returns the dots per inch resolution of the device. |
|
340 */ |
|
341 virtual TSize Dpi() const =0; |
|
342 |
|
343 /** |
|
344 * Returns font data objects which describe the fonts that match |
|
345 * the given arguments. For each font, the available heights will be provided. |
|
346 * @param aFaceName The name of the font to look for. If empty, all fonts |
|
347 * will be returned. |
|
348 * @param aScalable If true only scalable fonts are returned, otherwise |
|
349 * only non-scalable fonts are returned. |
|
350 * @return An array containing the TSwtFontData objects |
|
351 * describing each font. |
|
352 */ |
|
353 virtual CArrayFixFlat<TSwtFontData>* GetFontListL( |
|
354 const TDesC& aFaceName, TBool aScalable) const=0; |
|
355 |
|
356 /** |
|
357 * Returns the matching standard color for the given constant. |
|
358 * @param aId SWT color constant |
|
359 * @return The Symbian OS' matching standard color. Any value other |
|
360 * than one of the SWT color constants which is passed |
|
361 * in will result in the color black. |
|
362 */ |
|
363 virtual TRgb GetSystemColor(TSwtColorId aId) const =0; |
|
364 |
|
365 /** |
|
366 * Returns a reasonable font for applications to use. |
|
367 * @return The system font, cannot be NULL |
|
368 */ |
|
369 virtual const MSwtFont* GetSystemFont() const =0; |
|
370 |
|
371 /** |
|
372 * Returns the default height of a font. |
|
373 * This height is used for the Java FontData constructor with no argument. |
|
374 */ |
|
375 virtual TInt GetDefaultFontHeightL() =0; |
|
376 }; |
|
377 |
|
378 |
|
379 /** |
|
380 * Interface class for the org.eclipse.swt.graphics.Image class. |
|
381 * |
|
382 * Images are not intended to be disposed of while they are referenced by some |
|
383 * control and/or GC. Nonetheless, a broken application may loosely follow the |
|
384 * SWT coding guidelines and fail to do so, thereby causing an access violation. |
|
385 * |
|
386 * In order to prevent such behaviour, images are reference counted, see |
|
387 * MSwtRefCounted. |
|
388 */ |
|
389 class MSwtImage |
|
390 : public MSwtBitmapDrawable |
|
391 , public MSwtRefCounted |
|
392 { |
|
393 protected: |
|
394 virtual ~MSwtImage() {} // Made protected to prevent destruction through the interface |
|
395 |
|
396 public: |
|
397 /** |
|
398 * Disposes of (i.e. destroys) the image. |
|
399 * The image is disposed of by calling its RemoveRef() method. |
|
400 * It is therefore an error to try and dispose of an image whose reference |
|
401 * count is higher than 1. |
|
402 */ |
|
403 virtual void Dispose() =0; |
|
404 |
|
405 /** |
|
406 * Retrieves the underlying native bitmap representing the alpha channel |
|
407 * @param aInvertedIfMonochrome if true and the main mask is monochrome |
|
408 * the result bitmap is inverted. if false or if main mask is not |
|
409 * monochrome, the returned bitmap is not inverted. |
|
410 * The returned value may be NULL. |
|
411 * Call this only after calling SubBitmap! |
|
412 */ |
|
413 virtual const CFbsBitmap* MaskBitmap(TBool aInvertedIfMonochrome = EFalse) const =0; |
|
414 |
|
415 /** |
|
416 * Retrieves a reference to a scaled copy of the main mask. |
|
417 * @param aInvertedIfMonochrome if true and the main mask is monochrome |
|
418 * the result bitmap is inverted. if false or if main mask is not |
|
419 * monochrome, the returned bitmap is not inverted. |
|
420 * The returned value may be NULL. |
|
421 * Call this only after calling SubBitmap! |
|
422 */ |
|
423 virtual const CFbsBitmap* SubMaskBitmap(const TSize& aSize, |
|
424 TBool aInvertedIfMonochrome = EFalse) const =0; |
|
425 |
|
426 /** |
|
427 * Returns the bounds of the image. |
|
428 * The iTl member of the return value is always (0,0). |
|
429 */ |
|
430 virtual TRect GetBounds() const =0; |
|
431 |
|
432 /** |
|
433 * Returns the image's data. |
|
434 */ |
|
435 virtual MSwtImageData* GetImageDataL() const =0; |
|
436 |
|
437 protected: |
|
438 virtual CFbsBitmap& GetBitmap() const =0; |
|
439 virtual CFbsBitmap& GetSubBitmap(const TSize& aSize) const =0; |
|
440 |
|
441 public: |
|
442 /** |
|
443 * Retrieves a const reference to the underlying native bitmap. |
|
444 */ |
|
445 inline const CFbsBitmap& Bitmap() const |
|
446 { |
|
447 return GetBitmap(); |
|
448 } |
|
449 |
|
450 /** |
|
451 * Retrieves a reference to the underlying native bitmap. |
|
452 */ |
|
453 inline CFbsBitmap& Bitmap() |
|
454 { |
|
455 return GetBitmap(); |
|
456 } |
|
457 |
|
458 /** |
|
459 * Retrieves a const reference to a scaled copy of the native bitmap. |
|
460 * Allocates memory in the object even if the object is const (see mutable). |
|
461 * The allocated copy is owned by the image object. |
|
462 * If memory allocation or bitmap scaling fails, NULL is returned. |
|
463 * If aSize equals the size of the main bitmap, the main bitmap is returned. |
|
464 * Call this before calling SubMaskBitmap! |
|
465 */ |
|
466 inline const CFbsBitmap& SubBitmap(const TSize& aSize) const |
|
467 { |
|
468 return GetSubBitmap(aSize); |
|
469 } |
|
470 |
|
471 /** |
|
472 * Retrieves a reference to a scaled copy of the native bitmap. |
|
473 * Allocates memory in the object even if the object is const (see mutable). |
|
474 * The allocated copy is owned by the image object. |
|
475 * If memory allocation or bitmap scaling fails, NULL is returned. |
|
476 * If aSize equals the size of the main bitmap, the main bitmap is returned. |
|
477 * Call this before calling SubMaskBitmap! |
|
478 */ |
|
479 inline CFbsBitmap& SubBitmap(const TSize& aSize) |
|
480 { |
|
481 return GetSubBitmap(aSize); |
|
482 } |
|
483 |
|
484 public: |
|
485 /** |
|
486 * Means for clients to register their use of a scaled bitmap copy. |
|
487 * If aSize equals the size of the main bitmap, the main bitmap is referenced. |
|
488 * @return KErrNotFound if a copy of that size not found. |
|
489 * KErrNone if reference added ok. |
|
490 */ |
|
491 virtual TInt AddSubRef(const TSize& aSize) const =0; |
|
492 |
|
493 /** |
|
494 * Means for clients to deregister their use of a scaled bitmap copy. |
|
495 * If aSize equals the size of the main bitmap, the main bitmap is dereferenced. |
|
496 * If no clients left for that copy, the bitmap copy is destroyed. |
|
497 * @return KErrNotFound if a copy of that size not found. |
|
498 * KErrNone if reference removed ok. |
|
499 */ |
|
500 virtual TInt RemoveSubRef(const TSize& aSize) const =0; |
|
501 |
|
502 /** |
|
503 * Return the number of clients using the a scaled bitmap copy. |
|
504 * If aSize equals the size of the main bitmap, the main reference count is returned. |
|
505 */ |
|
506 virtual TInt SubRefCount(const TSize& aSize) const = 0; |
|
507 |
|
508 /** |
|
509 * Create a bitmap with alpha channel based on underlying native bitmap. |
|
510 */ |
|
511 virtual CFbsBitmap* BitmapWithAlphaLC() = 0; |
|
512 }; |
|
513 |
|
514 |
|
515 /** |
|
516 * Interface class for the org.eclipse.swt.graphics.GC class. |
|
517 */ |
|
518 class MSwtGc |
|
519 { |
|
520 protected: |
|
521 virtual ~MSwtGc() {} // Made protected to prevent destruction through the interface |
|
522 |
|
523 public: |
|
524 /** |
|
525 * Signature for a function destroying native GCs. |
|
526 * Must not leave. |
|
527 */ |
|
528 typedef void (*TDestructor)(CBitmapContext* aGc); |
|
529 |
|
530 public: |
|
531 /** |
|
532 * Disposes of (i.e. destroys) the GC |
|
533 */ |
|
534 virtual void Dispose() =0; |
|
535 |
|
536 /** |
|
537 * The native bitmap context used by this GC |
|
538 */ |
|
539 virtual CBitmapContext& BitmapContext() =0; |
|
540 /** |
|
541 * Sets alpha value. |
|
542 */ |
|
543 virtual void SetAlpha(TInt aAlpha) =0; |
|
544 |
|
545 /** |
|
546 * Sets the background color. |
|
547 */ |
|
548 virtual void SetBackground(const MSwtColor& aColor) =0; |
|
549 |
|
550 /** |
|
551 * Sets the foreground color. |
|
552 */ |
|
553 virtual void SetForeground(const MSwtColor& aColor) =0; |
|
554 |
|
555 /** |
|
556 * Returns the current line style. |
|
557 */ |
|
558 virtual TSwtLineStyle LineStyle() const =0; |
|
559 |
|
560 /** |
|
561 * Sets the current line style. |
|
562 */ |
|
563 virtual void SetLineStyleL(TSwtLineStyle aLineStyle) =0; |
|
564 |
|
565 /** |
|
566 * Returns the width that will be used when drawing lines. |
|
567 */ |
|
568 virtual TInt LineWidth() const =0; |
|
569 |
|
570 /** |
|
571 * Sets the width that will be used when drawing lines. |
|
572 */ |
|
573 virtual void SetLineWidth(TInt aLineWidth) =0; |
|
574 |
|
575 /** |
|
576 * Returns ETrue if this GC is drawing in X-OR mode, |
|
577 * EFalse otherwise. |
|
578 */ |
|
579 virtual TBool XORMode() const =0; |
|
580 |
|
581 /** |
|
582 * Sets the drawing mode to X-Or or plain. |
|
583 */ |
|
584 virtual void SetXORMode(TBool aXor) =0; |
|
585 |
|
586 /** |
|
587 * Sets the current font. |
|
588 */ |
|
589 virtual void SetFont(const MSwtFont* aFont) =0; |
|
590 |
|
591 /** |
|
592 * Copies a rectangular area into the provided Image. |
|
593 * @param aImage The image to copy data to |
|
594 * @param aPoint The position of the data to be copied |
|
595 */ |
|
596 virtual void CopyAreaL(MSwtImage& aImage, const TPoint& aPoint) const =0; |
|
597 |
|
598 /** |
|
599 * Copies a rectangular area to a given position. |
|
600 */ |
|
601 virtual void CopyArea(const TRect& aSource, const TPoint& aDestination) =0; |
|
602 |
|
603 #ifdef RD_JAVA_NGA_ENABLED |
|
604 /** |
|
605 * Ensure that all drawing commands have been issued and |
|
606 * alf side has finished rendering. |
|
607 */ |
|
608 virtual TInt FinishOperationL(void) =0; |
|
609 #endif // RD_JAVA_NGA_ENABLED |
|
610 |
|
611 /** |
|
612 * Calls DrawImageFromBitmaps() to draw image that was sent from M2G. |
|
613 * @param aBitmapHandles Contains handles for image bitmap and mask of the |
|
614 * image. |
|
615 * @param aSrcePos The position of the rectangle in the source image |
|
616 * @param aSrceSize The size of the rectangle in the source image; |
|
617 * if (-1,-1) the whole image is to be taken. |
|
618 * @param aDestPos The position to draw at |
|
619 * @param aDestSize The size of the drawn area; if (-1,-1) then the same |
|
620 * size as the source is used. |
|
621 * @param aUseNativeClear Used while drawinq M2G animations to clear the |
|
622 * background. |
|
623 */ |
|
624 virtual void DrawM2GImageL(const TInt* aBitmapHandles, const TPoint& aSrcePos, |
|
625 const TSize& aSrceSize, const TPoint& aDestPos, const TSize& aDestSize, |
|
626 const TBool aUseNativeClear) =0; |
|
627 |
|
628 /** |
|
629 * Calls DrawImageFromBitmaps() method to draw a portion of an image. |
|
630 * @param aImage The image to draw. |
|
631 * @param aSrcePos The position of the rectangle in the source image |
|
632 * @param aSrceSize The size of the rectangle in the source image; |
|
633 * if (-1,-1) the whole image is to be taken. |
|
634 * @param aDestPos The position to draw at |
|
635 * @param aDestSize The size of the drawn area; if (-1,-1) then the same |
|
636 * size as the source is used. |
|
637 */ |
|
638 virtual void DrawImage(const MSwtImage& aImage, const TPoint& aSrcePos, |
|
639 const TSize& aSrceSize, const TPoint& aDestPos, const TSize& aDestSize) =0; |
|
640 |
|
641 /** |
|
642 * Does the actual drawing of portion of a an the image at the specified |
|
643 * coordinates. If the source and destination rectangle do not have the same size, |
|
644 * the image will be scaled accordingly. |
|
645 * @param aBitmap The bitmap of the image to draw. |
|
646 * @param aMask The mask for the bitmap. |
|
647 * @param aSrcePos The position of the rectangle in the source image |
|
648 * @param aSrceSize The size of the rectangle in the source image; |
|
649 * if (-1,-1) the whole image is to be taken. |
|
650 * @param aDestPos The position to draw at |
|
651 * @param aDestSize The size of the drawn area; if (-1,-1) then the same |
|
652 * size as the source is used. |
|
653 * @prama aUseNativeClear Used while drawinq M2G animations to clear the background |
|
654 */ |
|
655 virtual void DrawImageFromBitmaps(const CFbsBitmap& aBitmap, const CFbsBitmap* aMask, |
|
656 const TPoint& aSrcePos, const TSize& aSrceSize, const TPoint& aDestPos, |
|
657 const TSize& aDestSize, const TBool aUseNativeClear) =0; |
|
658 |
|
659 /** |
|
660 * Draws a pixel, using the current foreground colour, at the specified point. |
|
661 */ |
|
662 virtual void DrawPoint(const TPoint& aPoint) =0; |
|
663 |
|
664 /** |
|
665 * Draws a line, using the current foreground colour, between two points. |
|
666 */ |
|
667 virtual void DrawLine(const TPoint& aPoint1, const TPoint& aPoint2) =0; |
|
668 |
|
669 /** |
|
670 * Draws the polyline which is defined by the specified array of |
|
671 * points, using the current foreground colour. |
|
672 */ |
|
673 virtual void DrawPolyline(const TPoint* aPoints, TInt aCount) =0; |
|
674 |
|
675 /** |
|
676 * Draws the closed polygon which is defined by the specified array |
|
677 * of points, using the current foreground colour. |
|
678 */ |
|
679 virtual void DrawPolygon(const TPoint* aPoints, TInt aCount) =0; |
|
680 |
|
681 /** |
|
682 * Fills the interior of the closed polygon which is defined by the |
|
683 * specified array of points, using the current background color. |
|
684 */ |
|
685 virtual void FillPolygon(const TPoint* aPoints, TInt aCount) =0; |
|
686 |
|
687 /** |
|
688 * Draws the outline of a rectangle, using the current foreground colour. |
|
689 */ |
|
690 virtual void DrawRectangle(const TRect& aRect) =0; |
|
691 |
|
692 /** |
|
693 * Fills the interior of a rectangle, using the current background colour. |
|
694 */ |
|
695 virtual void FillRectangle(const TRect& aRect) =0; |
|
696 |
|
697 /** |
|
698 * Fills the interior of the specified rectangle with a gradient |
|
699 * between the current foreground and background colours. |
|
700 */ |
|
701 virtual void FillGradientRectangle(const TRect& aRect, TBool aVertical, |
|
702 TBool aInvertGradient) =0; |
|
703 |
|
704 /** |
|
705 * Draws the outline of a round-cornered rectangle, using the current |
|
706 * foreground colour. |
|
707 */ |
|
708 virtual void DrawRoundRectangle(const TRect& aRect, const TSize& aArcSize) =0; |
|
709 |
|
710 /** |
|
711 * Fills the interior of a round-cornered rectangle, using the |
|
712 * current background colour. |
|
713 */ |
|
714 virtual void FillRoundRectangle(const TRect& aRect, const TSize& aArcSize) =0; |
|
715 |
|
716 /** |
|
717 * Draws the outline of an oval, using the current foreground colour, |
|
718 * within the specified rectangular area. |
|
719 */ |
|
720 virtual void DrawOval(const TRect& aRect) =0; |
|
721 |
|
722 /** |
|
723 * Fills the interior of an oval, within the specified rectangular |
|
724 * area, with the current background colour. |
|
725 */ |
|
726 virtual void FillOval(const TRect& aRect) =0; |
|
727 |
|
728 /** |
|
729 * Draws the outline of a circular or elliptical arc within the specified area. |
|
730 * The resulting arc begins at aStartAngle and extends for ArcAngle |
|
731 * degrees, using the current colour. Angles are interpreted such that 0 |
|
732 * degrees is at the 3 o'clock position. A positive value indicates a |
|
733 * counter-clockwise rotation while a negative value indicates a clockwise |
|
734 * rotation. |
|
735 * @param aRect The bounding rectangle of the ellipse the arc is part of. |
|
736 * @param aStartAngle The arc's start angle, in degrees |
|
737 * @param aArcAngle The arc's aperture, in degrees |
|
738 */ |
|
739 virtual void DrawArc(const TRect& aRect, TInt aStartAngle, TInt aArcAngle) =0; |
|
740 |
|
741 /** |
|
742 * Fills the interior of a circular or elliptical arc within the |
|
743 * specified rectangular area, with the receiver's background colour. |
|
744 * @param aRect The bounding rectangle of the ellipse the arc is part of. |
|
745 * @param aStartAngle The arc's start angle, in degrees |
|
746 * @param aArcAngle The arc's aperture, in degrees |
|
747 */ |
|
748 virtual void FillArc(const TRect& aRect, TInt aStartAngle, TInt aArcAngle) =0; |
|
749 |
|
750 /** |
|
751 * Returns the width (in pixels) of a character in the current font. |
|
752 * @param aChar The character whose width to retrieve |
|
753 */ |
|
754 virtual TInt GetCharWidth(const TChar& aChar) const =0; |
|
755 |
|
756 /** |
|
757 * Returns the advance width (in pixels) of a character in the current font. |
|
758 * @param aChar The character whose advance width to retrieve |
|
759 */ |
|
760 virtual TInt GetAdvanceWidth(const TChar& aChar) const =0; |
|
761 |
|
762 /** |
|
763 * Returns information about the current font. |
|
764 * @param aMetrics The structure to fill with metrics information |
|
765 */ |
|
766 virtual void GetFontMetrics(TSwtFontMetrics& aMetrics) const =0; |
|
767 |
|
768 /** |
|
769 * Returns the extent of the given string. |
|
770 * Tab expansion, line delimiter and mnemonic processing are performed |
|
771 * according to the specified flags. |
|
772 * @param aText The text to be measured. |
|
773 * @param aFlags Flags, can be any combination of KSwtDrawTransparent, |
|
774 * KSwtDrawDelimiter, KSwtDrawTab and |
|
775 * KSwtDrawMnemonic. |
|
776 */ |
|
777 virtual TSize TextExtentL(TDes& aText, TInt aFlags) const =0; |
|
778 |
|
779 /** |
|
780 * Draws the given text, using the current font and foreground colour. |
|
781 * Tab expansion, line delimiter and transparent processing are performed |
|
782 * according to the specified flags. Mnemonics is not supported by Symbian. |
|
783 * @param aText The text to be drawn |
|
784 * @param aPosition The position to draw the text at |
|
785 * @param aFlags Flags, can be any combination of KSwtDrawTransparent, |
|
786 * KSwtDrawDelimiter, KSwtDrawTab and |
|
787 * KSwtDrawMnemonic. |
|
788 */ |
|
789 virtual void DrawTextL(TDes& aText, const TPoint& aPosition, TInt aFlags) =0; |
|
790 |
|
791 /** |
|
792 * Returns ETrue if this GC has a clipping region set |
|
793 * to it, and EFalse otherwise. |
|
794 */ |
|
795 virtual TBool IsClipped() const =0; |
|
796 |
|
797 /** |
|
798 * Returns the bounding rectangle of the clipping region. |
|
799 * The returned rectangle is expressed in GC coordinates. If no clipping |
|
800 * region is set, the returned rectangle is the GC's. |
|
801 */ |
|
802 virtual TRect ClippingRect() const =0; |
|
803 |
|
804 /** |
|
805 * Sets the clipping region to the specified rectangle. |
|
806 * @param aRect The clipping rectangle to set, in GC coordinates. |
|
807 */ |
|
808 virtual void SetClippingRect(const TRect& aRect) =0; |
|
809 |
|
810 /** |
|
811 * Cancels the clipping region |
|
812 */ |
|
813 virtual void CancelClipping() =0; |
|
814 |
|
815 /** |
|
816 * Returns the font. |
|
817 */ |
|
818 virtual const MSwtFont* Font() const =0; |
|
819 |
|
820 /** |
|
821 * Draw a rectangle which has the appearance of the platform's |
|
822 * focus rectangle. |
|
823 * If there is no such thing as a focus rectangle, this method must draw |
|
824 * a rectangle with the GC's foreground colour. |
|
825 * @param aRect The rectangle to draw |
|
826 */ |
|
827 virtual void DrawFocusRect(const TRect& aRect, const MSwtUiUtils& aUtils) =0; |
|
828 |
|
829 /* |
|
830 * Sets the current brush rgb value directly to the given value |
|
831 * without any color transformation. |
|
832 * @param aRgb the value to set |
|
833 */ |
|
834 virtual void SetBrushRgbValue(const TRgb& aRgb) =0; |
|
835 |
|
836 /* |
|
837 * Sets the current pen rgb value directly to the given value |
|
838 * without any color transformation. |
|
839 * @param aRgb the value to set |
|
840 */ |
|
841 virtual void SetPenRgbValue(const TRgb& aRgb) =0; |
|
842 }; |
|
843 |
|
844 |
|
845 typedef CArrayPtrFlat<MSwtImageData> CSwtImageDataArray; |
|
846 |
|
847 /** |
|
848 * Interface class for the org.eclipse.swt.graphics.ImageDataLoader class. |
|
849 */ |
|
850 class MSwtImageDataLoader |
|
851 { |
|
852 protected: |
|
853 virtual ~MSwtImageDataLoader() {} // Made protected to prevent destruction through the interface |
|
854 |
|
855 public: |
|
856 |
|
857 /** |
|
858 * Function in charge of decoding an image from ImageData. |
|
859 * If any error happened due to an IO failure the method leaves. If the |
|
860 * destination already exists the method leaves. |
|
861 * @param aImageData The image's data. |
|
862 * @param aFormat The destination format of the image (see TSwtImageType). |
|
863 * Possible types are PNG, JPG and GIF. |
|
864 * @param aDestination The pathname and the file's name of the result file. |
|
865 */ |
|
866 virtual void EncodeImageToFileL(MSwtImageData& aImageData, TInt aFormat, const TDesC& aDestination) =0; |
|
867 |
|
868 /** |
|
869 * Function in charge of decoding an image from an ImageData. |
|
870 * If any error happened due to an IO failure the method leaves. If the |
|
871 * destination already exists the method leaves. |
|
872 * @return A buffer owned by the object containing the data. |
|
873 * @param aImageData The image's data. |
|
874 * @param aFormat The destination format of the image (see TSwtImageType). |
|
875 * Possible types are PNG, JPG, GIF. |
|
876 */ |
|
877 virtual HBufC8* EncodeImageToStreamL(MSwtImageData& aImageData, TInt aFormat) =0; |
|
878 |
|
879 /** |
|
880 * Function in charge of decoding an image from a file. |
|
881 * @param aFileName is the pathname and the file's name of the image file to decode |
|
882 */ |
|
883 virtual void DecodeImageL(const TDesC& aFileName) =0; |
|
884 |
|
885 /** |
|
886 * Function in charge of decoding an image from a buffer. |
|
887 * @param aBuffer contains the whole data to decode |
|
888 */ |
|
889 virtual void DecodeWholeImageFromBufferL(const TDesC8& aBuffer) =0; |
|
890 |
|
891 /** |
|
892 * Function in charge of returning the decoded ImageData. Does not transfer ownership |
|
893 */ |
|
894 virtual CSwtImageDataArray* GetImageData() =0; |
|
895 |
|
896 /** |
|
897 * The class is not a control but the dispose method has the |
|
898 * same effect as it has in control classes : |
|
899 * it frees the object and its associated resources. |
|
900 */ |
|
901 virtual void Dispose() =0; |
|
902 |
|
903 /** |
|
904 * Function in charge of decoding an image from a buffer. This method is synchronous and enable |
|
905 * to save memory space by filling the image buffer step by step (use AppendDataL(const HBufC8& aBuffer) |
|
906 * param aBuffer contains a piece of the whole image data to decode |
|
907 */ |
|
908 virtual void DecodeImageFromBufferL(const TDesC8& aBuffer) =0; |
|
909 |
|
910 /** |
|
911 * Enables to add data when a first call to DecodeImageFromBufferL has been initialized |
|
912 * |
|
913 * @param aBuffer contains a piece of the whole image data to decode. |
|
914 */ |
|
915 virtual void AppendDataL(const TDesC8& aBuffer) =0; |
|
916 |
|
917 /** |
|
918 * Simple getter that return the logical values for height |
|
919 */ |
|
920 virtual TInt GetLogicalScreenHeight() =0; |
|
921 |
|
922 /** |
|
923 * Simple getter that return the logical values for width |
|
924 */ |
|
925 virtual TInt GetLogicalScreenWidth() =0; |
|
926 }; |
|
927 |
|
928 #endif // ESWTGRAPHICS_H |