Update contrib.
1 // Copyright (c) 1998-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include <displaymode.h>
24 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
25 #include <graphics/gdi/glyphsample.h>
26 #include <graphics/gdi/gdiconsts.h>
27 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
29 class TOpenFontCharMetrics;
31 class CGraphicsContext;
32 class TTextParameters;
35 Number of twips per inch.
39 const TInt KTwipsPerInch=1440;
42 Number of twips per point.
46 const TInt KTwipsPerPoint=20;
49 Number of points per inch.
53 const TInt KPointsPerInch=72;
56 Number of twips per cm.
60 const TInt KTwipsPerCm=567;
61 #if defined(__NO_CLASS_CONSTS__)
63 A4 paper size in twips.
67 #define KA4PaperSizeInTwips TSize(11906,16838)
69 /** Legal paper size in twips.
73 #define KLegalPaperSizeInTwips TSize(12240,20160)
76 Executive paper size in twips.
80 #define KExecutivePaperSizeInTwips TSize(10440,15120)
82 Letter paper size in twips.
86 #define KLetterPaperSizeInTwips TSize(12240,15840)
89 Com-10 paper size in twips.
93 #define KCom_10PaperSizeInTwips TSize(5940,13680)
96 Monarch paper size in twips.
100 #define KMonarchPaperSizeInTwips TSize(5580,10800)
103 DL paper size in twips.
107 #define KDLPaperSizeInTwips TSize(6236,12472)
110 C5 paper size in twips.
114 #define KC5PaperSizeInTwips TSize(9184,12983)
120 const TSize KA4PaperSizeInTwips(11906,16838);
121 const TSize KLegalPaperSizeInTwips(12240,20160);
122 const TSize KExecutivePaperSizeInTwips(10440,15120);
123 const TSize KLetterPaperSizeInTwips(12240,15840);
124 const TSize KCom_10PaperSizeInTwips(5940,13680);
125 const TSize KMonarchPaperSizeInTwips(5580,10800);
126 const TSize KDLPaperSizeInTwips(6236,12472);
127 const TSize KC5PaperSizeInTwips(9184,12983);
132 This enumeration holds the possible panic codes that may be raised
133 by the GDI API on detecting an unrecoverable error. */
137 EGdiPanic_Unknown = 0,
138 /** One or more of the input parameters to the interface were invalid */
139 EGdiPanic_InvalidInputParam = 1,
140 /** Insufficient text for successful completion of the method */
141 EGdiPanic_OutOfText = 2,
142 /** Internal failure. */
143 EGdiPanic_Invariant = 3,
144 /** Unused panic codes. Can be reused if needed. */
145 EGdiPanic_Unused1 = 4,
146 EGdiPanic_Unused2 = 5,
147 /** Setting a typeface name that is too long */
148 EGdiPanic_TypefaceNameOverflow = 6,
152 /** 24-bit RGB colour value with 8 bits each for red, green and blue.
154 All Graphics drawing functions are specified in terms of a 32-bit TRgb colour
155 containing the three colour values plus 8 bits for alpha channel. For hardware which
156 does not support 24-bit colour, a mapping from TRgb to display colours is
159 Generally, the convention for the alpha blending fact is 0 = transparent,
160 255 = opaque, unless otherwise stated. The exception to this are the TRgb constructor
161 taking a single value, where the top byte of the passed in parameter is used for
162 alpha information and the function Value(), which returns alpha information in the top byte.
163 In both these cases, 0 means opaque, 255 means transparent.
165 The supported display modes are enumerated in the TDisplayMode type. In each
166 display mode a unique index can represent each physical colours supported,
167 and which can be mapped onto a full RGB value. The mappings are as follows:
169 16-colour displays use the EGA colour set: black, white, and then both light
170 and dark versions of grey, red, green, blue, cyan, magenta and yellow
172 256-colour displays support 216 colours made up of 6x6x6 RGB values, each
173 containing all possible multiples of 51 for R,G,B values. Additionally, all
174 remaining 10 shades of pure red, green, blue and grey are represented, by
175 adding all remaining multiples of 17. This use of 256 colours is sometimes
176 known as the Netscape colour cube.
178 4096-colour displays effectively support RGB values with 4 bits per primary
181 64k-colour displays effectively support RGB values with 5 bits allocated to
182 red, 6 to green and 5 to blue
184 16 million-colour displays support true colour with 8 bits allocated to each
190 @see DynamicPalette */
195 inline TRgb(TUint32 aValue);
196 inline TRgb(TUint32 aInternalValue, TInt aAlpha);
197 inline TRgb(TInt aRed,TInt aGreen,TInt aBlue);
198 inline TRgb(TInt aRed, TInt aGreen, TInt aBlue, TInt aAlpha);
199 inline TInt Red() const;
200 inline TInt Green() const;
201 inline TInt Blue() const;
202 inline TInt Alpha() const;
203 IMPORT_C void SetRed(TInt aRed);
204 IMPORT_C void SetGreen(TInt aGreen);
205 IMPORT_C void SetBlue(TInt aBlue);
206 IMPORT_C void SetAlpha(TInt aAlpha);
207 IMPORT_C static TRgb Gray2(TInt aGray2);
208 IMPORT_C static TRgb Gray4(TInt aGray4);
209 IMPORT_C static TRgb Gray16(TInt aGray16);
210 IMPORT_C static TRgb Gray256(TInt aGray256);
211 IMPORT_C static TRgb Color16(TInt aColor16);
212 IMPORT_C static TRgb Color256(TInt aColor256);
213 IMPORT_C static TRgb Color4K(TInt aColor4K);
214 IMPORT_C static TRgb Color64K(TInt aColor64K);
215 IMPORT_C static TRgb Color16M(TInt aColor16M);
216 IMPORT_C TInt Gray2() const;
217 IMPORT_C TInt Gray4() const;
218 IMPORT_C TInt Gray16() const;
219 IMPORT_C TInt Gray256() const;
220 IMPORT_C TInt Color16() const;
221 IMPORT_C TInt Color256() const;
222 IMPORT_C TInt Color4K() const;
223 IMPORT_C TInt Color64K() const;
224 IMPORT_C TInt Color16M() const;
225 inline TBool operator==(const TRgb& aColor) const;
226 inline TBool operator!=(const TRgb& aColor) const;
227 inline TRgb operator~() const;
228 inline TRgb operator&(const TRgb& aColor);
229 inline TRgb operator|(const TRgb& aColor);
230 inline TRgb operator^(const TRgb& aColor);
231 inline TRgb& operator&=(const TRgb& aColor);
232 inline TRgb& operator|=(const TRgb& aColor);
233 inline TRgb& operator^=(const TRgb& aColor);
234 inline TUint32 Value() const;
235 inline TUint32 Internal() const;
236 inline void SetInternal(TUint32 aInternal);
237 IMPORT_C TInt Difference(const TRgb& aColor) const;
238 IMPORT_C void InternalizeL(RReadStream& aStream);
239 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
240 IMPORT_C static TRgb Color16MU(TInt a0RGB);
241 IMPORT_C TInt Color16MU() const;
242 IMPORT_C static TRgb Color16MA(TUint aARGB);
243 IMPORT_C TUint Color16MA() const;
244 IMPORT_C static TRgb Color16MAP(TUint aARGB);
245 IMPORT_C TUint Color16MAP() const;
246 IMPORT_C TUint _Color16MAP() const;
247 IMPORT_C static TRgb _Color16MAP(TUint aARGB);
248 inline TInt _Gray2() const;
249 inline TInt _Gray4() const;
250 inline TInt _Gray16() const;
251 inline TInt _Gray256() const;
252 inline TInt _Color4K() const;
253 inline TInt _Color64K() const;
254 inline TInt _Color16M() const;
255 inline TInt _Color16MU() const;
256 inline TUint _Color16MA() const;
257 inline static TRgb _Gray2(TInt aGray2);
258 inline static TRgb _Gray4(TInt aGray4);
259 inline static TRgb _Gray16(TInt aGray16);
260 inline static TRgb _Gray256(TInt aGray256);
261 inline static TRgb _Color4K(TInt aColor4K);
262 inline static TRgb _Color64K(TInt aColor64K);
263 inline static TRgb _Color16M(TInt aColor16M);
264 inline static TRgb _Color16MU(TInt a0RGB);
265 inline static TRgb _Color16MA(TUint aARGB);
275 #define KRgbBlack TRgb(0x000000)
276 #define KRgbDarkGray TRgb(0x555555)
277 #define KRgbDarkRed TRgb(0x000080)
278 #define KRgbDarkGreen TRgb(0x008000)
279 #define KRgbDarkYellow TRgb(0x008080)
280 #define KRgbDarkBlue TRgb(0x800000)
281 #define KRgbDarkMagenta TRgb(0x800080)
282 #define KRgbDarkCyan TRgb(0x808000)
283 #define KRgbRed TRgb(0x0000ff)
284 #define KRgbGreen TRgb(0x00ff00)
285 #define KRgbYellow TRgb(0x00ffff)
286 #define KRgbBlue TRgb(0xff0000)
287 #define KRgbMagenta TRgb(0xff00ff)
288 #define KRgbCyan TRgb(0xffff00)
289 #define KRgbGray TRgb(0xaaaaaa)
290 #define KRgbWhite TRgb(0xffffff)
291 #define KRgbTransparent TRgb(0x000000,0x00)
293 /** A set of static utility functions to get information about a display mode.
297 class TDisplayModeUtils
300 IMPORT_C static TBool IsDisplayModeColor(TDisplayMode aDispMode);
301 IMPORT_C static TBool IsDisplayModeValid(TDisplayMode aDispMode);
302 IMPORT_C static TInt NumDisplayModeColors(TDisplayMode aDispMode);
303 IMPORT_C static TInt NumDisplayModeBitsPerPixel(TDisplayMode aDispMode);
306 /** Provides user-definable palette support to the GDI.
308 A palette is a user-defined set of colours, which is a subset of the full
309 range of 24-bit colours. This allows users the advantages of having a low
310 bpp colour mode whilst being able to specify the colours available in that
311 mode. To give an example, the EColor16 mode provides a palette of 16 colours
312 as it provides a mapping between an integer index and a TRgb colour (see the
313 table EGA Low-colour constants). Only a palette of 16 colour enables you to
314 change the palette. Palettes are also used to allow 24-bit bitmaps to be stored
315 in a more compressed form by finding the actual number of different colours
316 used in the bitmap, creating a palette to allow the mapping of these colours
317 to a smaller index space, and encoding the bitmaps pixels using indexes
318 to this new index space.
320 A palette has a size which is set at its creation and cannot be altered
321 the number of entries in the palette. Each entry in a palette is a mapping
322 between that entrys index and a TRgb value. Palette entries can be got
323 and set at any time between the palettes creation and destruction. The
324 GDIs palette support also provides functions to find the nearest palette
325 colour to a requested TRgb colour.
329 class CPalette : public CBase
332 IMPORT_C static CPalette* NewL(TInt aNumberOfEntries);
333 IMPORT_C static CPalette* NewDefaultL(TDisplayMode aDispMode);
334 IMPORT_C ~CPalette();
335 IMPORT_C void Clear();
336 inline TInt Entries() const;
337 IMPORT_C TRgb GetEntry(TInt aPaletteIndex) const;
338 IMPORT_C TRgb NearestEntry(const TRgb& aColor) const;
339 IMPORT_C TInt NearestIndex(const TRgb& aColor) const;
340 IMPORT_C void SetEntry(TInt aPaletteIndex,const TRgb& aPaletteEntry);
341 IMPORT_C void GetDataPtr(TInt aFirstColor,TInt aNumColors,TPtr8& aPtr);
344 void ConstructL(TInt aNumberOfEntries);
351 /** Enables conversion, in both directions, between a TRgb object and an index
352 into an arbitrary 256 colour palette.
359 IMPORT_C void Construct(const CPalette& aPalette);
360 IMPORT_C TInt Color256(TRgb aRgb) const;
361 IMPORT_C void Color256(TUint8* aDestination,const TRgb* aSource,TInt aNumPixels) const;
362 inline TRgb Color256(TInt aColor256) const;
363 IMPORT_C static const TColor256Util* Default();
365 /** 256 colour lookup table.
367 Each entry is a 32 bit value which corresponds to a TRgb value in the
368 palette passed to Construct(). If there are more than 256 colours in the
369 palette, the first 256 colours are used in this table. If there are fewer
370 than 256 entries, the remaining entries in the table are set to zero. */
371 TUint32 iColorTable[256];
373 /** Inverse colour lookup table.
375 It has 4096 entries. Each entry is the index of a colour in the palette
376 that the object was created with (see Construct()) that most closely
377 matches the 4096 degrees of intensity of red, green and blue on a uniform
378 16x16x16 colour cube.
380 It is called "inverse" because iColorTable maps indices (0..255) to TRgb
381 values, but this table maps TRgb values to palette indices. */
382 TUint8 iInverseColorTable[0x1000];
386 /** Linear digital differential analyser.
388 This is used to calculate the pixels which most closely approximate a specified
389 straight line, or when scaling a bitmap. Note that a line is infinitely thin,
390 and can only be approximated by pixels with real width and height.
392 Functions are provided for: pixel line traversing; jumping to a rectangle or
400 /** LDDA Line mode. */
403 /** Centres scan-lines in the pixel line */
405 /** Starts at the beginning of a complete scan line. Used for bitmap
410 IMPORT_C TLinearDDA();
411 IMPORT_C TLinearDDA(const TLinearDDA& aLine);
412 IMPORT_C void Construct(const TPoint& aStart,const TPoint& aFinish,TLineMode aMode=ECenter);
413 IMPORT_C TBool SingleStep(TPoint& aPosition);
414 IMPORT_C TBool SingleScanline(TPoint& aStartPosition,TPoint& aEndPosition);
415 IMPORT_C TBool NextStep(TPoint& aPosition);
416 IMPORT_C void JumpToRect(const TRect& aRect);
417 IMPORT_C void JumpToXCoord(const TInt aXCoord,TInt& aYCoord);
418 IMPORT_C void JumpToYCoord(TInt& aXCoord,const TInt aYCoord);
419 IMPORT_C void JumpToXCoord2(TInt aXCoord,TInt& aYCoord);
420 IMPORT_C void JumpToYCoord2(TInt& aXCoord,TInt aYCoord);
422 void UpdatePosition();
439 TBool iBoundingRectSet;
440 TInt16 iInsideX; // boolean, defined as TInt16 to maintain binary compatibility
441 TInt16 iInsideY; // boolean, defined as TInt16 to maintain binary compatibility
448 Fonts can be either upright or italic.
454 /** Font posture is normal (upright). */
456 /** Font posture is italic. */
461 Font stroke weight flags.
465 enum TFontStrokeWeight
467 /** Font stroke weight is normal. */
469 /** Font stroke weight is bold. */
474 Font print position flags.
475 Fonts can be normal, superscript or subscript.
479 enum TFontPrintPosition
481 /** Font is normal. */
483 /** Font is superscript. */
484 EPrintPosSuperscript,
485 /** Font is subscript. */
490 Font underline flags.
496 /** Font is not underlined. */
498 /** Font is underlined. */
503 Font strike-through flags.
507 enum TFontStrikethrough
509 /** Font is not struck-through. */
511 /** Font is struck-through. */
516 The maximum length of a typeface name (in characters).
520 const TInt KMaxTypefaceNameLength=0x18;
523 /** Typeface name and attributes.
525 This class identifies a typeface by name, and contains the combination of
526 attributes of the typeface. These attributes define whether it is a symbol
527 typeface, whether the typeface is proportional, and whether it is serif or
530 The combination of attributes for a typeface are stored in a bitmask, with
531 the various bits indicating different attributes. The bitmask is calculated
532 for any particular attribute combination by ORing the enumerated value for
533 each individual attribute.
542 /** Typeface is a proportional typeface (e.g. Swiss)
545 /** Typeface is a serif typeface (e.g. Times)
548 /** Typeface is a symbol typeface (e.g. Symbol)
553 IMPORT_C TTypeface();
554 IMPORT_C TBool operator==(const TTypeface& aTypeface) const;
555 IMPORT_C void InternalizeL(RReadStream& aStream);
556 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
557 IMPORT_C void SetAttributes(TInt aAttributes);
558 IMPORT_C void SetIsProportional(TBool aIsProportional);
559 IMPORT_C void SetIsSerif(TBool aIsSerif);
560 IMPORT_C void SetIsSymbol(TBool aIsSymbol);
561 IMPORT_C TInt Attributes() const;
562 IMPORT_C TBool IsProportional() const;
563 IMPORT_C TBool IsSerif() const;
564 IMPORT_C TBool IsSymbol() const;
565 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
566 IMPORT_C void SetScriptTypeForMetrics(TInt aScript);
567 IMPORT_C TInt ScriptTypeForMetrics() const;
568 IMPORT_C void SetName(const TDesC& aName);
569 IMPORT_C const TDesC& Name() const;
571 void ResetAttributes();
572 void ResetScriptType();
574 /** The typeface name. */
575 TBufC<KMaxTypefaceNameLength> iName;
582 An enumerated type for the format of a glyph bitmap. This type is currently
583 used to indicate whether glyph bitmaps for scalable fonts are drawn anti-aliased.
584 Additional values may be defined in the future.
586 @see TFontStyle::SetBitmapType()
587 @see CFbsTypefaceStore::SetDefaultBitmapType()
591 enum TGlyphBitmapType
593 /** The font store's default glyph bitmap format is used. */
594 EDefaultGlyphBitmap = 0,
595 /** The standard monochrome format: no anti-aliasing, 1 bit per pixel,
596 run-length encoded. */
597 EMonochromeGlyphBitmap,
598 /** Standard 8-bits-per-pixel with anti-aliasing. */
599 EAntiAliasedGlyphBitmap,
600 /** The format used when sub-pixel font rendering is used. */
601 ESubPixelGlyphBitmap,
602 /** The format used when outline and shadow font rendering is used.
604 If the raterizer supports the outline and shadow fonts, it will set the bitmaptype as
605 EFourColourBlendGlyphBitmap but only when glyph bitmap type is set as EAntiAliasedGlyphBitmap and
606 when any of the EDropShadow or EOutline effect is on. Only rasterizer providers can use this enum.
608 EFourColourBlendGlyphBitmap,
610 This is used for glyphs, and not fonts, and is needed to inform the font drawing routines
611 that the character should be drawn using the overall font setting.
612 For Internal Use Only.
614 EGlyphBitmapTypeNotDefined,
616 This is used to inform the rasterizer that the best match should be
617 found for the bitmap type based upon its knowledge.
618 For Internal Use Only.
620 EAntiAliasedOrMonochromeGlyphBitmap,
624 Defines a set of font effects flags.
628 WARNING: This Class is for use by system/UI software ONLY.
630 NONSHARABLE_CLASS(FontEffect)
635 ENone = 0x0, // No effects.
636 EAlgorithmicBold= 0x10, // Font is algorithmic bold (a.k.a pseudo bold.)
637 EDropShadow = 0x20, // Font has a drop shadow.
638 EOutline = 0x40, // Font is an outline font.
639 EEmbossed = 0x80, // Font is embossed.
640 EEngraved = 0x100, // Font is engraved.
641 ESoftEdge = 0x200, // Font is soft edged.
642 EReserved1 = 0x400, // Reserved for Symbian use.
643 EReserved2 = 0x800, // Reserved for Symbian use.
644 EReserved3 = 0x1000, // Reserved for Symbian use.
645 EReserved4 = 0x2000, // Reserved for Symbian use.
646 EReserved5 = 0x4000, // Reserved for Symbian use.
647 EReserved6 = 0x8000, // Reserved for Symbian use.
650 IMPORT_C static TBool IsEffectOn(TEffect aEffect, TUint32 aFontEffect);
651 IMPORT_C static void SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect);
654 /** Encapsulates a font style.
656 The font style information is comprised of:
658 the posture of the font upright or italic
660 the stroke weight of the font normal or bold
662 the print position of the font normal, subscript or superscript
664 Note that the underline and strike-through attributes are not included in
665 this class, but are set in the graphics context.
667 @see CGraphicsContext::SetUnderlineStyle()
668 @see CGraphicsContext::SetStrikethroughStyle()
675 IMPORT_C TFontStyle();
676 IMPORT_C TFontStyle(TFontPosture aPost,TFontStrokeWeight aStrWgt,TFontPrintPosition aPrintPos);
677 IMPORT_C void InternalizeL(RReadStream& aStream);
678 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
679 IMPORT_C TFontPosture Posture() const;
680 IMPORT_C TFontStrokeWeight StrokeWeight() const;
681 IMPORT_C TFontPrintPosition PrintPosition() const;
682 IMPORT_C void SetPosture(TFontPosture aPosture);
683 IMPORT_C void SetStrokeWeight(TFontStrokeWeight aStrokeWeight);
684 IMPORT_C void SetPrintPosition(TFontPrintPosition aPrintPosition);
685 inline TGlyphBitmapType BitmapType() const;
686 inline void SetBitmapType(TGlyphBitmapType aBitmapType);
687 IMPORT_C TBool operator==(const TFontStyle& aFontStyle) const;
688 IMPORT_C TUint32 Effects() const;
689 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
690 IMPORT_C void SetEffects(TUint32 aEffects);
691 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
701 TUint32 iFlags; // bitmap type - 16 bits (high), font effects - 12 bits (middle), style - 4 bits (low)
709 Specifies the font specification in device independent terms.
716 IMPORT_C TFontSpec();
717 IMPORT_C TFontSpec(const TDesC& aTypefaceName,TInt aHeight);
718 IMPORT_C TBool operator==(const TFontSpec& aFontSpec) const;
719 IMPORT_C void InternalizeL(RReadStream& aStream);
720 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
721 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
722 IMPORT_C TInt ScriptTypeForMetrics() const;
726 /** The height of the typeface (in twips). */
728 /** The font style of the typeface. */
729 TFontStyle iFontStyle;
734 /** Typeface family support information.
736 This data-only class includes the name and attributes of a typeface, how many
737 font heights are available, its minimum and maximum heights, and whether or
738 not it is scaleable a typeface is scaleable if it supports heights at
739 fixed intervals between the minimum and maximum heights.
743 class TTypefaceSupport
746 /** The name and attributes of the typeface. */
748 /** The number of distinct font heights available in the typeface. */
750 /** The typeface's minimum font height, in twips. */
751 TInt iMinHeightInTwips;
752 /** The typeface's maximum font height, in twips. */
753 TInt iMaxHeightInTwips;
754 /** Whether the typeface is scaleable. ETrue if it is scaleable, otherwise
756 TBool iIsScalable; // supports heights from min to max at fixed interval
760 The percentage used to multiply a normal font height when calculating its
761 superscript or subscript height.
765 const TInt KSuperSubScalingPercentage=67;
768 The percentage of a font height used to calculate its baseline offset for a
769 superscript print position.
773 const TInt KSuperscriptOffsetPercentage=-28;
776 The percentage of a font height used to calculate its baseline offset for a
777 subscript print position.
781 const TInt KSubscriptOffsetPercentage=14;
785 /** Typeface store abstract base interface.
787 This class provides the interface to a store for typefaces.
793 class CTypefaceStore : public CBase
796 IMPORT_C ~CTypefaceStore();
799 Gets the font which is the nearest to the given font specification.
801 When the font is no longer needed, call @c ReleaseFont().
803 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips()
804 yielding (virtually) the same result. However clients are strongly encouraged to use the new
805 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
806 character within any given text string will fit within the given amount of twips, whereas the design
807 height is an aesthetic unit decided by the font designer without strict physical meaning, which
808 may result in cropped characters.
810 @param aFont On return, contains a pointer to the nearest font.
811 @param aFontSpec The specification of the font to be matched.
812 @return KErrNone if successful; a system-wide error code otherwise.
814 @deprecated Use GetNearestFontToDesignHeightInTwips
816 virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
819 Gets the font which is the nearest to the given font specification.
821 When the font is no longer needed, call @c ReleaseFont().
823 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the
824 same result. However clients are strongly encouraged to use the new
825 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
826 character within any given text string will fit within the given amount of twips, whereas the design
827 height is an aesthetic unit decided by the font designer without strict physical meaning, which
828 may result in cropped characters.
830 @param aFont On return, contains a pointer to the nearest font.
831 @param aFontSpec The specification of the font to be matched.
832 @return KErrNone if successful; a system-wide error code otherwise.
836 virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
839 Gets the font which is the nearest to the given font specification.
841 When the font is no longer needed, call @c ReleaseFont().
843 The font and bitmap server returns a pointer to the nearest matching font
844 from those available. Matches to max height of font - this does its best
845 to return a font that will fit within the maximum height specified (but
846 note that variations due to hinting algorithms may rarely result in this
847 height being exceeded by up to one pixel). Problems can also be
848 encountered with bitmap fonts where the typeface exists but doesn't have
851 @param aFont On return, contains a pointer to the nearest font.
852 @param aFontSpec The specification of the font to be matched.
853 @param aMaxHeight The maximum height within which the font must fit.
854 @return KErrNone if successful; a system-wide error code otherwise.
858 virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) = 0;
860 /** Gets the number of typefaces supported by the typeface store.
862 @return The number of supported typefaces. */
863 virtual TInt NumTypefaces() const=0;
865 /** Gets typeface information for a specified typeface index.
867 This information is returned in aTypefaceSupport, and
868 includes the typeface name and typeface attributes, the number of font
869 heights, the maximum and minimum font heights, and whether it is a
872 @param aTypefaceSupport On return, if the function executed successfully,
873 this object contains the typeface information.
874 @param aTypefaceIndex A typeface index number, in the range: zero to
875 (NumTypefaces() - 1). */
876 virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
878 /** Gets the height of the font with specified height and typeface indices,
881 The value returned is rounded up or down to the nearest font height in twips.
883 @param aTypefaceIndex A typeface index number, in the range: 0 to
884 (NumTypefaces() - 1).
885 @param aHeightIndex A font height index number.
886 @return The height of the font, in twips. */
887 virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
888 IMPORT_C void ReleaseFont(CFont* aFont);
889 IMPORT_C static TInt BaselineOffset(TInt aHeight,TFontPrintPosition aPos);
890 IMPORT_C static TInt SuperSubHeight(TInt aHeight,TFontPrintPosition aPos);
892 IMPORT_C CTypefaceStore();
893 IMPORT_C void ConstructL();
894 IMPORT_C void AddFontL(CFont* aFont);
895 IMPORT_C TBool IncrementFontCount(const CFont* aFont);
897 TBool FindFont(const CFont* aFont, TInt& aIdx) const;
898 NONSHARABLE_CLASS(TFontAccess)
900 Pairs a font with a count of how many clients of the typeface store
901 are accessing that font.
905 /** A device specific font. */
907 /** The number of clients accessing the font. */
911 /** A list of fonts accessed by clients of the typeface store, which pairs
912 a font with a count of the number of clients accessing the font.
914 Implemented as an array of TFontAccess objects.
916 An object is added to this array for every font accessed. If the font is
917 released by all clients, and the access count drops to zero, the font is
918 removed from the list. */
919 CArrayFixFlat<TFontAccess>* iFontAccess;
922 /** The maximum number of entries in the font cache.
925 const TInt KMaxFontCacheEntries=32;
929 When a CFont* needs to be found for a particular TFontSpec, the cache can
930 be searched to see if the TFontSpec is already in the cache. If the TFontSpec
931 is in the cache, its corresponding CFont* can be returned. Otherwise
932 GetNearestFontInTwips() must be used to search all of the available fonts for
933 the nearest CFont- a procedure which takes much longer than a simple cache
936 The current font cache should be destroyed and a new cache created whenever
937 the zoom factor or device map changes, as these changes break the relation
938 between CFont and TFontSpec.
942 class CFontCache : public CBase
945 IMPORT_C CFontCache();
946 IMPORT_C CFontCache(TInt aMaxEntries);
947 IMPORT_C ~CFontCache();
948 IMPORT_C CFont* Search(const TFontSpec& aFontSpec);
949 IMPORT_C CFont* AddEntryL(CFont* aFont,const TFontSpec& aFontSpec);
950 IMPORT_C CFont* RemoveFirstEntry();
952 /** The number of cache hits since the font cache was created i.e.
953 successful results from CFontCache::Search(). */
955 /** The number of cache misses since the font cache was created i.e.
956 unsuccessful results from CFontCache::Search(). */
959 class CFontCacheEntry : public CBase
962 CFontCacheEntry(CFont* aFont,const TFontSpec& aFontSpec,CFontCacheEntry* aNext);
966 CFontCacheEntry* iNext;
971 CFontCacheEntry* iFirst;
974 /** Interface class for mapping between twips and device-specific units (pixels).
976 TZoomFactor is derived from MGraphicsDeviceMap.
983 class MGraphicsDeviceMap
986 IMPORT_C MGraphicsDeviceMap();
987 IMPORT_C virtual ~MGraphicsDeviceMap();
988 IMPORT_C TPoint TwipsToPixels(const TPoint& aTwipPoint) const;
989 IMPORT_C TRect TwipsToPixels(const TRect& aTwipRect) const;
990 IMPORT_C TPoint PixelsToTwips(const TPoint& aPixelPoint) const;
991 IMPORT_C TRect PixelsToTwips(const TRect& aPixelRect) const;
993 /** Converts a horizontal dimension from twips to pixels.
995 An implementation is supplied by a derived class.
997 @param aTwips A horizontal dimension of a device in twips.
998 @return A horizontal dimension of a device in pixels. */
999 virtual TInt HorizontalTwipsToPixels(TInt aTwips) const=0;
1001 /** Converts a vertical dimension from twips to pixels.
1003 An implementation is supplied by a derived class.
1005 @param aTwips A vertical dimension of a device in twips.
1006 @return A vertical dimension of a device in pixels. */
1007 virtual TInt VerticalTwipsToPixels(TInt aTwips) const=0;
1009 /** Converts a horizontal dimension from pixels to twips.
1011 An implementation is supplied by a derived class.
1013 @param aPixels A horizontal dimension of a device in pixels.
1014 @return A horizontal dimension of a device in twips. */
1015 virtual TInt HorizontalPixelsToTwips(TInt aPixels) const=0;
1017 /** Converts a vertical dimension from pixels to twips.
1019 An implementation is supplied by a derived class.
1021 @param aPixels A vertical dimension of a device in pixels.
1022 @return A vertical dimension of a device in twips. */
1023 virtual TInt VerticalPixelsToTwips(TInt aPixels) const=0;
1026 Gets the font which is the nearest to the given font specification.
1028 When the font is no longer needed, call @c ReleaseFont().
1030 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips()
1031 yielding (virtually) the same result. However clients are strongly encouraged to use the new
1032 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
1033 character within any given text string will fit within the given amount of twips, whereas the design
1034 height is an aesthetic unit decided by the font designer without strict physical meaning, which
1035 may result in cropped characters.
1037 @param aFont On return, contains a pointer to the nearest font.
1038 @param aFontSpec The specification of the font to be matched.
1039 @return KErrNone if successful; a system-wide error code otherwise.
1041 @deprecated Use GetNearestFontToDesignHeightInTwips
1043 virtual TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)=0;
1046 Gets the font which is the nearest to the given font specification.
1048 When the font is no longer needed, call @c ReleaseFont().
1050 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the
1051 same result. However clients are strongly encouraged to use the new
1052 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
1053 character within any given text string will fit within the given amount of twips, whereas the design
1054 height is an aesthetic unit decided by the font designer without strict physical meaning, which
1055 may result in cropped characters.
1057 @param aFont On return, contains a pointer to the nearest font.
1058 @param aFontSpec The specification of the font to be matched.
1059 @return KErrNone if successful; a system-wide error code otherwise.
1063 virtual TInt GetNearestFontToDesignHeightInTwips(
1064 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; }
1067 Gets the font which is the nearest to the given font specification.
1069 When the font is no longer needed, call @c ReleaseFont().
1071 The font and bitmap server returns a pointer to the nearest matching font
1072 from those available. Matches to max height of font - this does its best
1073 to return a font that will fit within the maximum height specified (but
1074 note that variations due to hinting algorithms may rarely result in this
1075 height being exceeded by up to one pixel). Problems can also be
1076 encountered with bitmap fonts where the typeface exists but doesn't have
1077 a font small enough.
1079 @param aFont On return, contains a pointer to the nearest font.
1080 @param aFontSpec The specification of the font to be matched.
1081 @param aMaxHeight The maximum height within which the font must fit.
1082 This overrides the height specified in aFontSpec.
1083 @return KErrNone if successful; a system-wide error code otherwise.
1087 virtual TInt GetNearestFontToMaxHeightInTwips(
1088 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; }
1090 /** Releases the specified font.
1092 It is used to indicate that the specified font is no longer needed for use
1093 by the device map. As fonts can be shared between applications, this
1094 function does not delete the copy of the font from RAM unless the font was
1095 only being used by this particular device map.
1097 An implementation is supplied by a derived class.
1099 @param aFont A pointer to the font to be released. */
1100 virtual void ReleaseFont(CFont* aFont)=0;
1103 class CGraphicsContext;
1105 /** Specifies the interface for concrete device classes.
1107 It holds information on the capabilities and attributes of a graphics device.
1108 The CBitmapDevice and CPrinterDevice classes are derived from CGraphicsDevice.
1110 @see CGraphicsDevice
1115 class CGraphicsDevice : public CBase , public MGraphicsDeviceMap
1118 /** Gets the display mode of the device.
1120 @return The display mode of the device. */
1121 virtual TDisplayMode DisplayMode() const=0;
1123 /** Gets the size of the device area in pixels.
1125 @return The width and height of the device area, in pixels */
1126 virtual TSize SizeInPixels() const=0;
1128 /** Gets the size of the device area in twips.
1130 @return The width and height of the device area, in twips */
1131 virtual TSize SizeInTwips() const=0;
1133 /** Creates a graphics context for the device.
1135 @param aGC On return, contains a pointer to the created graphics context.
1136 @return KErrNone, if successful; otherwise, another of the system-wide error
1138 virtual TInt CreateContext(CGraphicsContext*& aGC)=0;
1140 /** Gets the number of typefaces supported by the graphics device.
1142 @return The number of typefaces supported. */
1143 virtual TInt NumTypefaces() const=0;
1145 /** Gets typeface information for a specified typeface.
1147 This information is returned in aTypefaceSupport, and includes:
1149 the typeface name and typeface attributes
1151 the number of font heights
1153 the maximum and minimum font heights
1155 whether it is a scalable typeface
1157 @param aTypefaceSupport On return, contains the typeface information.
1158 @param aTypefaceIndex A typeface index number, in the range: zero to
1159 (NumTypefaces() - 1).
1160 @see NumTypefaces() */
1161 virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
1163 /** Get the height of a font in twips.
1165 The font is identified by typeface and height.
1167 The value returned is rounded up or down to the nearest font height in twips.
1169 @param aTypefaceIndex An index identifying the typeface, in the range: 0
1170 to (NumTypefaces() - 1).
1171 @param aHeightIndex An index identifying the font height, in the range: 0
1172 to (iNumHeights - 1). Note that iNumHeights is in the TTypefaceSupport
1173 object returned by TypefaceSupport().
1174 @return The height of the font, in twips. */
1175 virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
1177 /** Gets the palette attributes of the device.
1179 @param aModifiable On return, holds information on whether or not the device's
1180 palette is modifiable (ETrue) or fixed (EFalse).
1181 @param aNumEntries On return, holds the number of entries in the device's
1183 virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const=0;
1185 /** Sets the device's palette.
1187 Setting the palette is only possible if the device has a modifiable palette,
1188 which can be determined by calling PaletteAttributes().
1190 @param aPalette The new palette for the device. */
1191 virtual void SetPalette(CPalette* aPalette)=0;
1193 /** Gets the device's current palette.
1195 This function is only supported if the device has a modifiable palette,
1196 which can be determined by calling PaletteAttributes().
1198 @param aPalette On return, holds the device's current palette.
1199 @return KErrNone, if successful; otherwise, another of the system-wide error
1201 virtual TInt GetPalette(CPalette*& aPalette) const=0;
1206 Code section range information.
1208 A code section defines the bitmaps for characters in a specified range -
1209 the range is stored in objects of this type.
1211 @deprecated This is not used anywhere in version 6.0.
1216 /** The beginning of the range. */
1218 /** The end of the range. */
1223 WARNING: this Class is for internal use ONLY. Compatibility is not guaranteed in future releases.
1224 UIDs corresponding to the CFont API extension functions
1227 const TUid KFontCapitalAscent = {0x1020498E};
1228 const TUid KFontMaxAscent = {0x10204B10};
1229 const TUid KFontStandardDescent = {0x10204B11};
1230 const TUid KFontMaxDescent = {0x10205AFC};
1231 const TUid KFontLineGap = {0x10204B12};
1232 const TUid KFontGetFontTable = {0x102872C1};
1233 const TUid KFontGetGlyphOutline = {0x102872C2};
1234 const TUid KFontReleaseGlyphOutline = {0x2002A1FD};
1235 const TUid KFontReleaseFontTable = {0x2002AC24};
1238 /** Abstract font interface.
1240 The CFont class provides a device-independent interface to a device-dependent
1241 font usually obtained from a call to GetNearestFont...() on a graphics device.
1242 It is used as a handle in CGraphicsContext::UseFont() and to obtain
1243 device-dependent information about the font - notably the pixel width of a text
1247 @see CGraphicsContext::UseFont()
1251 class CFont : public CBase
1253 friend class CTypefaceStore;
1256 /** Text direction flags.
1258 This enum is used in TMeasureTextInput and determines whether the text is
1259 drawn horizontally or vertically. Note: text is drawn vertically in some
1260 styles of Japanese, etc.
1262 @see TMeasureTextInput */
1265 /** Text is drawn horizontally. */
1266 /** Text is drawn horizontally. */
1268 /** Text is drawn vertically. */
1272 /** Complicated parameter block used for contextual glyph selection,
1273 ligature creation and diacritic placement when drawing text in complex
1276 This class declares a constructor, another scoped class, and several other
1277 enums. However this class is unlikely to be useful to third party developers.
1279 @see CFont::GetCharacterPosition()
1280 @see CFont::GetCharacterPosition2()
1284 class TPositionParam
1287 /** Standard constructor. */
1289 iDirection(EHorizontal),
1298 EMaxInputChars = 18, // ligatures cannot be made from more than 18 components
1299 EMaxOutputGlyphs = 8 // output can consist of up to 8 characters (one base and 7 combining characters)
1302 /**Flags for TPositionParam::iFlags. */
1305 /** Input text is logically ordered not visually ordered. */
1309 /** Input: Orientation (EHorizontal or EVertical) in which to draw
1312 /** Input: Flags from TFlags. */
1314 /** Input: Text containing the characters to be positioned. */
1317 /** Input and output: Position within iText to shape. On exit
1318 it will index the first character not positioned */
1320 /** Input and output: Pen position. */
1323 /** Output of GetCharacterPosition and GetCharacterPosition2.
1324 @see CFont::GetCharacterPosition
1325 @see CFont::GetCharacterPosition2
1331 /** Standard constructor. */
1332 TOutput() : iBitmapSize(TSize::EUninitialized),
1333 iBounds(TRect::EUninitialized) {}
1334 /** Character or glyph code. */
1336 /** Bitmap data for the glyph, if available */
1337 const TUint8* iBitmap;
1338 /** Size of the bitmap before algorithmic bolding, size
1339 multiplication, etc. */
1341 /** Bitmap bounds relative to the original pen position. */
1345 /** Information about the glyphs that were output. */
1346 TOutput iOutput[EMaxOutputGlyphs];
1347 /** Number of glyphs actually output. */
1352 /** Input parameter block.
1354 This is optionally used by CFont::MeasureText(), which is the powerful text
1355 measurement function underlying all the other text measurement functions.
1357 @see CFont::MeasureText()
1361 class TMeasureTextInput
1364 TMeasureTextInput():
1366 iEndInputChar(KMaxTInt),
1367 iDirection(EHorizontal),
1369 iMaxAdvance(KMaxTInt),
1370 iMaxBounds(KMaxTInt),
1378 /**Flags for TMeasureTextInput::iFlags. */
1381 /** Input text is visually ordered left-to-right. */
1383 /** Input text is visually ordered right-to-left.
1384 Overrides EFVisualOrder. */
1385 EFVisualOrderRightToLeft = 2,
1386 /** Flag to consider side bearings when checking bounds for line-break */
1387 EFIncludePenPositionInBoundsCheck = 4
1390 /** Starting index specifying first input character in iText.
1392 Together with iEndInputChar, this allows some context before and
1393 after the measured text to be supplied so that shaping can work
1395 TInt iStartInputChar;
1397 /** Index specifying the final input character.
1399 Together with iStartInputChar, this allows some context before and
1400 after the measured text to be supplied so that shaping can work
1404 /** The direction in which to draw the text. */
1407 /** Flags from TFlags. */
1410 /** The maximum advance. */
1413 /** The maximum width (or height if drawing vertically) of bounds. */
1416 /** The number of glyph groups to be letter-spaced. */
1419 /** The amount of space to be used for letter spacing. */
1420 TInt iCharJustExcess;
1422 /** The number of spaces to be used for word spacing. */
1425 /** The amount of space to be used for word spacing. */
1426 TInt iWordJustExcess;
1429 /** Output parameter block.
1431 This is optionally used by CFont::MeasureText(), which is the powerful text
1432 measurement function underlying all the other text measurement functions.
1434 @see CFont::MeasureText()
1438 class TMeasureTextOutput
1441 /** The number of input characters that would be drawn.
1443 This may be less than the length of the text if a maximum advance or bounding
1444 box size is specified. */
1446 /** The number of glyphs that would be drawn. */
1448 /** The number of groups that would be drawn.
1450 A group is a base glyph plus one or more combining characters. */
1452 /** The number of word spaces (U+0020) that would be drawn. */
1454 /** The bounding box of all the glyphs that would be drawn. */
1456 /** The maximum width and height of any glyph. */
1457 TSize iMaxGlyphSize;
1461 Data availability flags.
1463 Some fonts like printer fonts may only have width information and can return
1464 ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize
1465 the rest of the data if necessary.
1467 @see GetCharacterData()
1471 enum TCharacterDataAvailability
1473 /** No font information available. */
1475 /** Width information only is available. */
1476 ECharacterWidthOnly,
1477 /** All character data is available. */
1482 // virtual functions have been made protected and public non-virtual ones
1483 // added to convert CFont to a handle-body pattern. SC is kept throught the
1484 // new functions and BC is kept by keeping the protected functions in the
1485 // same place in the class, and therefore in the same place in the vtable
1488 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1490 virtual TUid DoTypeUid() const=0;
1493 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1495 virtual TInt DoHeightInPixels() const=0;
1498 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1500 virtual TInt DoAscentInPixels() const=0;
1501 IMPORT_C virtual TInt DoDescentInPixels() const;
1504 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1506 virtual TInt DoCharWidthInPixels(TChar aChar) const=0;
1509 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1511 virtual TInt DoTextWidthInPixels(const TDesC& aText) const=0;
1514 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1516 virtual TInt DoBaselineOffsetInPixels() const=0;
1519 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1521 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const=0;
1524 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1526 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0;
1529 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1531 virtual TInt DoMaxCharWidthInPixels() const=0;
1534 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1536 virtual TInt DoMaxNormalCharWidthInPixels() const=0;
1539 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation.
1541 virtual TFontSpec DoFontSpecInTwips() const=0;
1544 IMPORT_C virtual TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
1545 IMPORT_C virtual TBool DoGetCharacterPosition(TPositionParam& aParam) const;
1546 IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
1549 IMPORT_C virtual ~CFont();
1552 inline TInt FontCapitalAscent() const;
1553 inline TInt FontMaxAscent() const;
1554 inline TInt FontStandardDescent() const;
1555 inline TInt FontMaxDescent() const;
1556 inline TInt FontLineGap() const;
1557 inline TInt FontMaxHeight() const;
1560 /** Gets run-time identity of the actual font type. This enables safe casting to
1563 For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid.
1564 You would need to cast to a CFbsFont to get a character bounding box. Similarly,
1565 a CBitmapFont returns KCBitmapFontUidVal.
1567 @return The font-type identifier. */
1568 IMPORT_C TUid TypeUid() const;
1570 /** Gets the font height in pixels.
1571 Note that this deprecated function is replaced by the new @c FontMaxHeight().
1573 @return The font height in pixels.
1574 @see FontMaxHeight()
1576 IMPORT_C TInt HeightInPixels() const;
1578 /** Gets the font ascent in pixels.
1579 Note that this deprecated function is replaced by the new @c FontMaxAscent()
1580 or in some cases @c FontCapitalAscent().
1582 @return The font ascent in pixels.
1583 @see FontCapitalAscent()
1584 @see FontMaxAscent()
1586 IMPORT_C TInt AscentInPixels() const;
1588 /** Gets the font descent in pixels.
1589 Note that this deprecated function is replaced by the new @c FontMaxDescent()
1590 or in some cases @c FontStandardDescent().
1592 @return The font descent in pixels.
1593 @see FontStandardDescent()
1594 @see FontMaxDescent()
1596 IMPORT_C TInt DescentInPixels() const;
1598 /** Gets the width in pixels in this font of the specified character.
1600 Note: For OpenType fonts this function returns the horizontal advance of
1601 the character, which may be different from the actual width.
1603 @param aChar The character whose width should be determined.
1604 @return The width in pixels of the specified character in this font. */
1605 IMPORT_C TInt CharWidthInPixels(TChar aChar) const;
1607 /** Gets the width in pixels of the specified descriptor when displayed in this
1610 @param aText The descriptor whose width should be determined.
1611 @return The width of the specified descriptor when displayed in this font,
1613 IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const;
1615 /** Gets the baseline offset in pixels.
1617 The baseline offset is how far a font is raised or lowered from its normal
1620 @return Offset from normal baseline, in pixels. */
1621 IMPORT_C TInt BaselineOffsetInPixels() const;
1623 /** Gets how much of the specified descriptor can be displayed in this font without
1624 exceeding the specified width.
1628 This function does not display any of the descriptor itself - it is used
1629 before display, to test whether the whole descriptor can be displayed.
1631 @param aText The descriptor.
1632 @param aWidthInPixels The available width for character display.
1633 @return The number of characters which will be able to be displayed without
1634 exceeding the specified width. The count starts from the beginning of the
1636 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const;
1638 /** Gets how much of the specified descriptor can be displayed in this font without
1639 exceeding the specified width.
1641 It also returns the excess width - defined as the specified available width
1642 minus the width of the portion of the descriptor which can be displayed without
1643 exceeding the available width.
1645 @param aText The descriptor.
1646 @param aWidthInPixels The available width for character display.
1647 @param aExcessWidthInPixels The excess width after displaying the portion of
1648 the descriptor, in pixels.
1649 @return The number of characters which will be able to be displayed without
1650 exceeding the specified width. The count starts from the beginning of the
1652 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
1654 /** Gets the width in pixels of the widest character in this font.
1656 @return The width of the maximum width character, in pixels. */
1657 IMPORT_C TInt MaxCharWidthInPixels() const;
1659 /** Gets the width in pixels of the widest normal character in this font.
1661 Normal characters include all character in a character set except non-alphabetic
1662 characters (e.g. the copyright symbol, or a block graphics symbol, for example).
1664 @return The width of the maximum width normal character, in pixels. */
1665 IMPORT_C TInt MaxNormalCharWidthInPixels() const;
1667 /** Gets the font specification of this font in twips.
1669 @return The font specification of this font (in twips). */
1670 IMPORT_C TFontSpec FontSpecInTwips() const;
1671 IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
1672 IMPORT_C TBool GetCharacterPosition(TPositionParam& aParam) const;
1673 IMPORT_C TInt WidthZeroInPixels() const;
1674 IMPORT_C TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL, TMeasureTextOutput* aOutput = NULL) const;
1675 IMPORT_C static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter);
1676 IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
1677 IMPORT_C TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const;
1679 /** Gets the width in pixels of the specified descriptor when displayed in this
1682 @param aText The descriptor whose width should be determined.
1683 @param aParam Parameter block that controls how much of aText is measured
1684 @return The width of the specified descriptor when displayed in this font,
1686 IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const;
1691 /** Abstract base class for all graphics contexts.
1693 Created by a CGraphicsDevice.
1695 Provides the 'context' in which you are drawing to an associated device, in
1696 the sense that it holds the settings for drawing, such as the pen and brush
1697 settings (e.g. color, line styles) and the font settings (e.g. bold, underline,
1698 italic). These settings are device-independent.
1700 Also provides the clipping region (the visible drawing area).
1702 The settings and clipping area can be updated while drawing.
1704 This class also contains the main drawing functions, and all drawing is done
1705 through a CGraphicsContext.
1707 The graphics context deals with pixels of device-dependent size and uses fonts
1708 with device-dependent size and representation. The sizes and fonts to be passed
1709 to the class functions therefore need to be converted from size-independent
1710 units to size-dependent units first. This is done by an MGraphicsDeviceMap
1711 derived class. This may be a TZoomFactor or the CGraphicsDevice.
1713 See CGraphicsContext::Reset() for the default graphics context settings immediately
1720 class CGraphicsContext : public CBase
1731 /** Text is left-aligned. */
1733 /** Text is centred. */
1735 /** Text is right-aligned. */
1740 Drawing mode components.
1741 This enum is not intended to be used directly, but provides components for
1742 the easy specification of drawing modes in the TDrawMode enum.
1746 enum TDrawModeComponents
1770 This enum builds on the drawing mode components in the TDrawModeComponents
1773 If the pen colour is p, brush colour is b and screen colour is s, the effect
1774 of TDrawMode::EDrawModeAND is P=p&s and B=b&s. In other words, the effective
1775 colour of the pen on the screen, P, is that produced by the bitwise ANDing
1776 of the current screen colour and the current pen colour. The effect is similar
1777 for the effective brush colour, B.
1779 The effective pen and brush colour are given in the table using the key
1780 Inputs: pen colour is p, brush colour is b and screen colour is s
1781 Outputs: effective brush colour is B, effective pen colour is P.
1783 Some notes on using EDrawModeWriteAlpha:-
1785 - It is rare for client code to need to use this draw mode: see the documentation
1786 of SetDrawMode() for more information.
1787 - EDrawModeWriteAlpha should only be used with DrawRect(), Clear(), BitBlt(), and BitBltMasked()
1788 with EGray2 mask (and DrawBitmap() and DrawBitmapMasked()). For other draw operations, it is not
1789 supported, and may have unintended effects.
1790 - EDrawModeWriteAlpha has the same effect as EDrawModePEN, unless the brush colour has transparency
1791 (DrawRect(), Clear()), or the source bitmap is EColor16MA (and has transparency) (BitBlt(), BitBltMasked())
1792 - EDrawModeWriteAlpha has the same effect as EDrawModePEN if the draw mode of the destination does not
1793 support alpha blending. (Blending is only supported in 24bpp and 32bpp colour i.e. EColor16M, EColor16MU, EColor16MA)
1794 - In these cases, EDrawModePEN does alpha blending, whereas EDrawModeWriteAlpha means don't do alpha blending.
1802 /** Bitwise ANDs the pen and brush colours with the screen colour.
1805 /** Inverts the pen and brush colours before ANDing. P=(~p)&s,
1807 EDrawModeNOTAND=EInvertScreen|EAnd,
1808 /** Uses both pen and brush colour as they are. P=p, B=b */
1809 EDrawModePEN=EPenmode,
1810 /** Inverts the screen colour before ANDing. P=p&(~s), B=b&(~s) */
1811 EDrawModeANDNOT=EAnd|EInvertPen,
1812 /** Bitwise XORs the pen and brush colours with the screen colour.
1815 /** Bitwise ORs the pen and brush colours with the screen colour.
1818 /** Inverts the screen and pen and brush colours before ANDing.
1819 P=(~p)&(~s), B=(~b)&(~s) */
1820 EDrawModeNOTANDNOT=EInvertScreen|EAnd|EInvertPen,
1821 /** Inverts the pen and brush colours before XORing. P=(~p)^s,
1823 EDrawModeNOTXOR=EInvertScreen|EXor,
1824 /** Inverts the colour of each pixel that is drawn over, (pen and
1825 brush attributes are ignored). P=~s, B=~s */
1826 EDrawModeNOTSCREEN=EInvertScreen,
1827 /** Inverts the screen colour before ORing. P=p|(~s),
1829 EDrawModeNOTOR=EInvertScreen|EOr,
1830 /** Inverts the pen and brush colours. P=~p, B=~b */
1831 EDrawModeNOTPEN=EInvertPen|EPenmode,
1832 /** Inverts the pen and brush colours before ORing. P=(~p)|s,
1834 EDrawModeORNOT=EOr|EInvertPen,
1835 /** Inverts the screen and pen and brush colours before ORing.
1836 P=(~p)|(~s), B=(~b)|(~s) */
1837 EDrawModeNOTORNOT=EInvertScreen|EOr|EInvertPen,
1838 /** Writes alpha information in the source directly into the destination, rather than blending. */
1839 EDrawModeWriteAlpha=EWriteAlpha,
1843 Pen styles. The screen pattern unit in each definition below describes the
1844 pattern drawn by the line 1 represents a pixel drawn, 0 represents a
1845 pixel that is not affected.
1851 /** The pen does not draw. Screen pattern unit = 00... */
1853 /** A solid line (default). Screen pattern unit = 11... */
1855 /** A dotted line. Screen pattern unit = 1000... */
1857 /** A dashed line. Screen pattern unit = 111000... */
1859 /** A line of alternating dashes and dots. Screen pattern unit =
1862 /** A line of alternating single dashes and pairs of dots. Screen
1863 pattern unit = 11110011001100... */
1874 /** The brush fill has no effect (default). */
1876 /** The brush fills with a solid single colour, determined by
1877 SetBrushColor() and the drawing mode. */
1879 /** The brush fills with a selected bitmap pattern, set by
1880 UseBrushPattern(). */
1882 /** The brush fills with vertical hatching lines going from top to
1884 EVerticalHatchBrush,
1885 /** The brush fills with diagonal hatching lines going from bottom
1886 left to top right. */
1887 EForwardDiagonalHatchBrush,
1888 /** The brush fills with horizontal hatching lines going from left
1890 EHorizontalHatchBrush,
1891 /** The brush fills with rearward diagonal hatching lines going from top
1892 left to bottom right. */
1893 ERearwardDiagonalHatchBrush,
1894 /** The brush fills with horizontal and vertical hatching lines going
1895 from left to right plus lines going from top to bottom giving the
1896 effect of a grid of small squares */
1897 ESquareCrossHatchBrush,
1898 /** The brush fills with forward diagonal and rearward diagonal hatching
1899 lines going from bottom left to top right plus lines going from top left
1900 to bottom right giving the effect of a grid of small diamonds. */
1901 EDiamondCrossHatchBrush
1905 Rules used to fill self crossing polygons.
1907 The filling of a polygon proceeds as follows: for a given point in the
1910 if the rule is TFillRule::EAlternate (default) and it has an odd winding
1911 number, then fill the surrounding area.
1913 if the rule is TFillRule::EWinding and it has a winding number greater than
1914 zero, then fill the surrounding area.
1920 /** Only fill areas with odd winding numbers. */
1922 /** Fill areas with winding numbers greater than zero. */
1926 /** Parameters to control the drawing of text. */
1927 struct TDrawTextParam
1931 iDirection(CFont::EHorizontal),
1936 /** Reserved for future use. */
1939 /** the direction in which to draw the text. */
1940 CFont::TTextDirection iDirection;
1941 /** number of glyph groups to be letterspaced */
1943 /** amount of space to be used for letterspacing */
1944 TInt iCharJustExcess;
1945 /** number of spaces to be used for wordspacing*/
1947 /** amount of space to be used for wordspacing*/
1948 TInt iWordJustExcess;
1952 /** Parameters for extended text drawing and measuring. It is used by
1953 CGraphicsContext::DrawTextExtended() to indicate whether text should be
1954 drawn from right-to-left or left-to-right. */
1955 struct TDrawTextExtendedParam : public TDrawTextParam
1958 /** Constructor. Initialises iParRightToLeft to EFalse. */
1959 TDrawTextExtendedParam():
1960 iParRightToLeft(EFalse)
1963 /** ETrue if the text direction is right-to-left (for scripts like
1964 Arabic and Hebrew). EFalse if left-to-right. */
1965 TBool iParRightToLeft;
1969 Parameters used in drawing text within supplied context.
1970 It is used by CGraphicsContext::DrawText() and CGraphicsContext::DrawTextVertical() family of API's
1971 to draw text from iStart to iEnd withing the supplied text descriptor.
1973 class TTextParameters
1985 /* Reserved for future use */
1992 /** Gets a pointer to the graphics context's graphics device.
1994 @return A pointer to the graphics device. */
1995 virtual CGraphicsDevice* Device() const=0;
1997 /** Sets the position of the co-ordinate origin.
1999 All subsequent drawing operations are done relative to this origin.
2001 @param aPos The origin. The default origin is TPoint(0,0) the top left
2002 corner of the screen. */
2003 virtual void SetOrigin(const TPoint& aPos=TPoint(0,0))=0;
2005 /** Sets the drawing mode.
2007 The way that the pen and brush draw depends on the drawing mode. The drawing
2008 mode affects the colour that is actually drawn, because it defines the way
2009 that the current screen colour logically combines with the current pen colour
2010 and brush colour. There are many drawing modes, each giving different logical
2011 combinations of pen, brush and screen colours. Each mode is produced by ORing
2012 together different combinations of seven drawing mode components.
2014 The three most important modes are TDrawMode::EDrawModePEN, TDrawMode::EDrawModeNOTSCREEN
2015 and TDrawMode::EDrawModeXOR. The default drawing mode is TDrawMode::EDrawModePEN.
2017 The drawing mode is over-ridden for line and shape drawing functions when
2018 a wide pen line has been selected. It is forced to TDrawMode::EDrawModePEN.
2019 This is to prevent undesired effects at line joins (vertexes).
2023 TDrawMode::EDrawModeAND gives a "colour filter" effect. For example:
2025 - ANDing with white gives the original colour
2026 - ANDing with black gives black
2028 TDrawMode::EDrawModeOR gives a "colour boost" effect. For example:
2030 - ORing with black gives the original colour
2031 - ORing with white gives white
2033 TDrawMode::EDrawModeXOR gives an "Exclusive OR" effect. For example:
2035 - white XOR black gives white
2036 - white XOR white gives black
2037 - black XOR black gives black
2039 TDrawMode::EDrawModeWriteAlpha should not normally need to be used by client code.
2040 The following are exceptions:-
2042 - When a client side EColor16MA bitmap needs to have a transparent background
2043 (because you are intending to blend it onto something else), then you need to set
2044 EDrawModeWriteAlpha to Clear() it.
2045 - When you want to BitBlt() with an EColor16MA source bitmap that is opaque everywhere,
2046 then using EDrawModeWriteAlpha is more efficient than EDrawModePEN, because the bitmap
2047 does not need to be blended.
2049 Note that if you have a transparent brush or source bitmap and you are drawing to a window,
2050 then it is a defect to use EDrawModeWriteAlpha.
2052 @param aDrawingMode The drawing mode.
2053 @see CGraphicsContext::TDrawMode
2054 @see CGraphicsContext::TDrawModeComponents */
2055 virtual void SetDrawMode(TDrawMode aDrawingMode)=0;
2057 /** Sets the clipping rectangle.
2059 The area of visible drawing depends on the clipping rectangle, any items
2060 that fall outside the extent of the clipping rectangle will not be drawn.
2061 The default clipping rectangle is the full device area.
2063 Note that clipping is additive. If a clipping region has been set using SetClippingRegion()
2064 then clipping will be to the intersection of that region and this rectangle.
2066 @param aRect The rectangle to be used as the clipping rectangle. Note that
2067 this rectangle is tranformed by the current co-ordinate origin before it is used.
2068 The co-ordinate origin is set using SetOrigin().
2070 @see CGraphicsContext::SetClippingRegion()
2071 @see CGraphicsContext::SetOrigin() */
2072 virtual void SetClippingRect(const TRect& aRect)=0;
2074 /** Cancels any clipping rectangle.
2076 Clipping thus reverts to the full device area, the default.
2078 @see SetClippingRect() */
2079 virtual void CancelClippingRect()=0;
2081 /** Resets the graphics context to its default settings:
2083 the drawing mode is TDrawMode::EDrawModePen (pen and brush colours used as
2086 there is no clipping rectangle
2088 the pen settings are: black, solid, single pixel size
2090 the brush style is null
2092 no text font is selected */
2093 virtual void Reset()=0;
2095 /** Sets the device font to be used for text drawing.
2097 If the font is already in memory, then that copy is shared.
2101 The CFont* argument must have been previously initialised by calling
2102 MGraphicsDeviceMap::GetNearestFontInTwips() with the required
2103 font-specification. If the CFont* has not been initialised
2104 correctly, and therefore does not point to an available font-bitmap,
2105 then a panic is raised.
2107 When the font is no longer required, use DiscardFont() to free up the
2108 memory used. If UseFont() is used again without using DiscardFont() then
2109 the previous font is discarded automatically.
2111 If no font has been selected, and an attempt is made to draw text with
2112 DrawText(), then a panic is raised.
2114 @param aFont A device font
2115 @see MGraphicsDeviceMap::GetNearestFontInTwips() */
2116 virtual void UseFont(const CFont* aFont)=0;
2118 /** Discards a font.
2120 This frees up the memory used, if the font is not being shared.
2122 The function can be called when no font is in use. */
2123 virtual void DiscardFont()=0;
2125 /** Sets the underline style.
2127 This is applied to all subsequently drawn text.
2129 @param aUnderlineStyle The underline style on or off. */
2130 virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle)=0;
2132 /** Sets the strikethrough style.
2134 This is applied to all subsequently drawn text.
2136 @param aStrikethroughStyle The strikethrough style on or off. */
2137 virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)=0;
2138 IMPORT_C static TInt JustificationInPixels(TInt aExcessPixels,TInt aTotalUnits,TInt aFirstUnit,TInt aNumUnits);
2139 IMPORT_C static TInt JustificationInPixels(TInt& aExcessPixels,TInt& aTotalUnits);
2141 /** Adjusts the spaces between words to stretch or squeeze to a certain
2144 The function is required by the Text Views API, and is not intended for
2145 regular use by developers.
2147 The text line that is to be justified has a certain number of gaps (spaces)
2148 between the words. It also has a distance (in pixels) between the end of
2149 the last word and the actual end of the line (right hand margin, usually).
2150 These excess width pixels are distributed amongst the gaps between the words
2151 to achieve full justification of the text line. Spaces become fat spaces to
2152 keep underlining/strikethrough consistent. Pixels are distributed to the
2153 inter-word gaps starting from the left end of the string. The spacing
2154 between characters in each word remains unchanged.
2156 After a call to SetWordJustification(), subsequent calls to either of the
2157 two DrawText() functions are affected until the number of spaces specified
2158 by aNumSpaces is used up.
2160 The easiest way to find out the excess width and number of spaces is to call
2161 CFont::MeasureText(). This function can also perform counting, which is
2162 finding how much of some text will fit into a given width.
2164 Use CFont::TextCount() to return the excess width.
2166 For example, in the string "To be, or not to be", there are five inter-word
2167 gaps. If there are six excess pixels they will be distributed in the
2168 proportion 2, 1, 1, 1, 1 between the words. If there are nine excess pixels
2169 they will be distributed in the proportion 2, 2, 2, 2, 1 between the words.
2173 If the excess width is zero, then calling SetWordJustification() has no
2176 At first sight it may appear that SetWordJustification() is not required
2177 because you can simply call DrawText() for each word. However, underlined
2178 justified text does not work using this strategy you get a non-underlined
2179 gap between the space and the beginning of the next word.
2181 @param aExcessWidth The width (in pixels) to be distributed between the
2182 specified number of spaces.
2183 @param aNumGaps The number of word spaces (characters with the code U+0020)
2184 over which the change in width is distributed. */
2185 virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps)=0;
2187 /** Sets character justification.
2189 This function is required by the Text Views API, and is not intended for
2190 regular use by developers.
2192 It affects the strings of text used in the calls to DrawText() that follow,
2193 until the number of characters drawn equals aNumChars.
2195 The text line that is to be justified has a certain number of characters
2196 this includes the spaces between the words. It also has a distance (in
2197 pixels) between the end of the last word and the actual end of the line
2198 (right hand margin, usually). These excess width pixels are distributed
2199 amongst all the characters, increasing the gaps between them, to achieve
2200 full justification of the text line.
2202 Use CFont::TextCount() to return the excess width.
2206 This function is provided to allow simulation of printer fonts on screen.
2207 Due to the fact that fully-scalable fonts are not used before v5, large
2208 printer fonts can be simulated by using the nearest smaller font and
2209 widening it slightly.
2211 If the excess width is zero, then calling SetCharJustification() has no
2214 SetCharJustification() is required for WYSIWYG where the layout uses
2215 printer font metrics but screen fonts have to be drawn on the screen.
2216 Because continuously scalable typefaces (c.f. TrueType) are not used
2217 before v5 and because screen fonts are coarser and less numerous in
2218 their variety than the printer fonts, the best matching smaller screen
2219 font must be used with character justification to simulate the printer
2222 There is also a situation where the gaps between characters on screen have
2223 to be reduced with character clipping. The screen font that best matches
2224 the printer font may have the required height, but has characters that are
2225 too wide. A line of text that works on the printer will then be too long
2226 on the screen, unless it is squashed horizontally. The number of pixels
2227 that overlap the end of the screen line must now be removed from the gaps
2228 between the characters, i.e. there is a negative excess width. This
2229 situation is especially important where adding a TAB on screen gives
2230 perfectly acceptable printout, but would push the last character of the
2231 line off the right hand side of the screen.
2233 In practice what you do in printer layout mode is:
2235 Calculate where the line breaks will come on the printer. To do this you
2236 use a printer font (which in practice means a table of character widths
2237 of the font that the printer will use).
2239 Now change to use a screen font that is the closest font which is no taller
2240 that the printer font. In practice it will often be fatter maybe only for
2241 certain characters such as 'i'.
2243 You have to recalculate the width of the characters using the screen fonts.
2244 You can do this using CFont::TextWidth() as you have already determined how
2245 many characters will fit on the line.
2247 If, in the screen font, the characters are not as wide as the line then you
2248 can just use word justification to expand the line. You would only do this
2249 if the text is to be justified.
2251 If, however, the characters are wider than the line then you would use
2252 character justification to clip each character. You would need to do this
2253 even if the line is not justified.
2255 Thus, in practice, character justification will only very rarely be used to
2256 expand a line of characters.
2258 @param aExcessWidth The excess width (in pixels) to be distributed between
2259 the specified number of characters. It may be positive, in which case the text is
2260 stretched, or negative, in which case it is shrunk.
2261 @param aNumChars The number of characters involved. */
2262 virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars)=0;
2264 /** Sets the pen colour.
2266 The effective pen colour depends on the drawing mode. The default pen colour
2271 The pen is used to draw lines, the outlines of filled shapes, and text. In case
2272 of outlined text, the pen is used to draw the outline of the font.
2274 The class provides member functions to set the colour of the pen, the style of
2275 line and the line size drawn.
2277 @param aColor An RGB colour for the pen.
2278 @see CGraphicsContext::SetDrawMode() */
2279 virtual void SetPenColor(const TRgb& aColor)=0;
2281 /** Sets the line drawing style for the pen.
2283 There are 6 pen styles. If no pen style is set, then the default is
2284 TPenStyle::ESolidPen. To use a pen style, its full context must be given,
2285 e.g. for a null pen:
2287 CGraphicsContext::TPenStyle::ENullPen
2290 The pen is used to draw lines, the outlines of filled shapes, and text.
2291 CGraphicsContext member functions are provided to set the colour of the
2292 pen, the style of line and the line size drawn.
2294 The TPenStyle::ENullPen style should be used if a border is not required
2295 around a filled shape.
2297 Dotted and dashed pen styles have a device dependant implementation, always
2298 give single-pixel size lines on the screen whatever the pen size set
2299 by SetPenSize() and can only be used for straight lines, polylines,
2300 non-rounded rectangles and polygons.
2302 The dotted/dashed pattern is continued, without re-starting, for all
2303 consecutively drawn straight lines, i.e.
2305 the outlines of rectangles the pattern starts in the top left corner.
2306 It is reset at the end of the function call.
2308 the outlines of polygons the pattern starts at the first point. It is
2309 reset at the end of the function call.
2311 polylines and straight lines the pattern starts at the first point
2312 initially. Consecutive calls to DrawLine() and/or DrawPolyLine(), whether
2313 the lines are concatenated or not, continue the pattern. It can be reset
2314 by a further call to SetPenStyle() using the same dotted/dashed style
2317 @param aPenStyle A pen style.
2318 @see CGraphicsContext::TPenStyle */
2319 virtual void SetPenStyle(TPenStyle aPenStyle)=0;
2321 /** Sets the line drawing size for the pen.
2323 Lines of size greater than one pixel:
2325 are drawn with rounded ends that extend beyond the end points, (as if the
2326 line is drawn using a circular pen tip of the specified size).
2328 are always drawn in TDrawMode::EDrawModePEN mode, overriding whatever mode
2329 has been set using SetDrawMode().
2333 The pen is used to draw lines, the outlines of filled shapes, and text. The
2334 class provides member functions to set the colour of the pen, the style of
2335 line and the line size drawn.
2337 Wide straight lines and arcs have rounded ends so that concatenated wide
2338 lines have smoothly rounded corners at the vertexes.
2340 When lines are made wide, the extra strips of pixels are added equally to
2341 both sides of the line. This works precisely for lines of odd pixel size
2342 (3, 5, 7, etc.). Wide lines of even pixel size, (2, 4, 6, etc.),
2343 have the extra strip of pixels added to the right and/or below the line.
2345 Wide outlines of ellipses and wide line arcs are drawn with the pixels
2346 distributed either side of a thin (single pixel wide) true ellipse
2347 constructed in the normal manner. Wide ellipses and arcs of even pixel
2348 size have the extra strip of pixels added to the right and/or below the
2349 curved line. This gives a slight asymmetry to ellipses.
2351 If the pen style is dotted or dashed, the size specification is ignored: a
2352 single-pixel wide primitive is drawn, (this is device dependant).
2354 A line size of zero is handled as if the pen style had been set to
2355 TPenStyle::ENullPen.
2357 @param aSize A line size. The default is 1 pixel. */
2358 virtual void SetPenSize(const TSize& aSize)=0;
2360 /** Sets the brush colour.
2362 The effective brush colour depends on the drawing mode.
2366 The brush is used for filling shapes and the background of text boxes. In
2367 case of outlined text, the brush is used for filling the font. The brush
2368 has colour, style, pattern and pattern origin parameters.
2370 If no brush colour has been set, it defaults to white. However the default
2371 brush style is null, so when drawing to a window the default appears to be
2372 the window's background colour.
2374 @param aColor An RGB colour for the brush.
2375 @see SetDrawMode() */
2376 virtual void SetBrushColor(const TRgb& aColor)=0;
2378 /** Sets the brush style.
2380 Ten brush styles are provided, including six built-in hatching patterns.
2381 Note: The brush is used for filling shapes and the background of text boxes.
2382 The brush has colour, style, pattern and pattern origin parameters.
2383 Note: Use TBrushStyle::ENullBrush to draw the outline of a fillable
2384 shape on its own, without filling.
2385 Note: If the TBrushStyle::EPatternedBrush style is set, but no bitmap
2386 pattern has been selected using UseBrushPattern(), then the function panics.
2387 Note: Hatching lines are done in the current pen colour, set using SetPenColor().
2388 The hatching pattern starts at the brush origin, set using SetBrushOrigin().
2389 @see TBrushStyle::ENullBrush
2390 @see TBrushStyle::EPatternedBrush
2391 @see UseBrushPattern()
2393 @see SetBrushOrigin()
2396 @param aBrushStyle A brush style. */
2397 virtual void SetBrushStyle(TBrushStyle aBrushStyle)=0;
2399 /** Sets the brush pattern origin.
2401 This specifies the top left-hand corner position for the pattern tile around
2402 which copies of the pattern are tiled.
2404 The brush pattern may be a built-in style, or a bitmap. To use a bitmap, the
2405 brush must have a pattern set and the brush style must be set to
2406 TBrushStyle::EPatternedBrush.
2410 The brush is used for filling shapes and the background of text boxes. The
2411 brush has colour, style, pattern and pattern origin parameters.
2413 If SetBrushOrigin() is not used, then the origin defaults to (0,0).
2415 This brush origin remains in effect for all fillable shapes drawn
2416 subsequently, until a new brush origin is set. Shapes can thus be
2417 considered as windows onto a continuous pattern field (covering the whole
2418 clipping region of a screen device, or the whole device area of a printer).
2420 @param aOrigin An origin point for the brush. The coordinates are relative
2421 to the rectangle to fill, i.e. specify 0,0 to align the pattern flush with
2422 the top and left hand sides of the rectangle.
2423 @see SetBrushStyle()
2424 @see UseBrushPattern() */
2425 virtual void SetBrushOrigin(const TPoint& aOrigin)=0;
2427 /** Sets the brush pattern to the specified bitmap.
2429 For the brush to actually use the bitmap, TBrushStyle::EPatternedBrush must
2430 be used to set the brush style.
2432 When the brush pattern is no longer required, use DiscardBrushPattern() to
2433 free up the memory used, if the bitmap is not being shared.
2434 If UseBrushPattern() is used again without using DiscardBrushPattern()
2435 then the previous pattern is discarded automatically.
2439 The brush is used for filling shapes and the background of text boxes. The
2440 brush has colour, style, pattern and pattern origin parameters.
2442 When loading a bitmap, the bitmap is checked to see if it is already in
2443 memory. If the bitmap is already there, then that copy is shared.
2445 The brush does not need to have a pattern set at all. There are several
2446 built-in hatching patterns which can be selected using SetBrushStyle().
2448 @param aBitmap A bitmap pattern for the brush.
2449 @see SetBrushStyle() */
2450 virtual void UseBrushPattern(const CFbsBitmap* aBitmap)=0;
2452 /** Discards a non-built-in brush pattern.
2454 This frees up the memory used by the bitmap, if it is not being shared by
2459 The brush is used for filling shapes and the background of text boxes. The
2460 brush has colour, style, pattern and pattern origin parameters.
2462 If DiscardBrushPattern() is used, with no brush pattern set, then there is
2464 virtual void DiscardBrushPattern()=0;
2467 /** Sets the drawing point relative to the co-ordinate origin.
2469 A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing
2470 point as the start point for the line drawn.
2474 The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline()
2475 also change the internal drawing position to the last point of the drawn
2478 The internal drawing position is set to the co-ordinate origin if no drawing
2479 or moving operations have yet taken place.
2481 @param aPoint The new internal drawing position. */
2482 virtual void MoveTo(const TPoint& aPoint)=0;
2484 /** Sets the drawing point relative to the current co-ordinates.
2486 A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing point
2487 as the start point for the line drawn.
2491 The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline()
2492 also change the internal drawing position to the last point of the drawn
2495 The internal drawing position is set to the co-ordinate origin if no drawing
2496 or moving operations have yet taken place.
2498 @param aVector The amount by which the internal drawing position is to move. */
2499 virtual void MoveBy(const TPoint& aVector)=0;
2501 /** Draws a single point. The point is drawn with the current pen settings
2502 using the current drawing mode.
2506 If the pen size is greater than one pixel, a filled circle of the current
2507 pen colour is drawn, with the pen size as the diameter and the plotted point
2508 as the centre. If the pen size is an even number of pixels, the extra pixels
2509 are drawn below and to the right of the centre.
2511 @param aPoint The point to be drawn.
2512 @see SetPenSize() */
2513 virtual void Plot(const TPoint& aPoint)=0;
2517 The arc is considered a portion of an ellipse. The ellipse is defined by the
2520 The pixels at both the start point and the end point are drawn.
2522 The arc itself is the segment of the ellipse drawn in an anti-clockwise
2523 direction from the start point to the end point.
2527 A rectangle is used in the construction of the ellipse of which the arc is
2528 a segment. This rectangle is passed as an argument of type TRect.
2530 A wide line arc is drawn with the pixels distributed either side of a true
2531 ellipse, in such a way that the outer edge of the line would touch the edge
2532 of the construction rectangle. In other words, the ellipse used to
2533 construct it is slightly smaller than that for a single pixel line size.
2535 If the specified start or end point is at the centre of the ellipse, then
2536 the line that defines the start or end of the arc defaults to one extending
2537 vertically above the centre point.
2539 If the start and end point are the same point or are points on the same line
2540 through the ellipse centre then a complete unfilled ellipse is drawn.
2542 @param aRect A rectangle in which to draw the ellipse, of which the arc is
2544 @param aStart The point defining the start of the arc. It defines one end of
2545 a line from the geometric centre of the ellipse. The point of intersection
2546 between this line and the ellipse defines the start point of the arc.
2547 @param aEnd The point defining the end of the arc. It defines one end of a
2548 second line from the geometric centre of the ellipse. The point of
2549 intersection between this line and the ellipse defines the end point of the
2551 @see DrawEllipse() */
2552 virtual void DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0;
2554 /** Draws a straight line between two points.
2556 @param aPoint1 The point at the start of the line.
2557 @param aPoint2 The point at the end of the line. */
2558 virtual void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)=0;
2560 /** Draws a straight line from the current drawing point to a specified
2563 @param aPoint The point at the end of the line.
2566 virtual void DrawLineTo(const TPoint& aPoint)=0;
2568 /** Draws a straight line relative to the current drawing point, using a
2571 The start point of the line is the current drawing point. The specified
2573 is added to the drawing point to give the end point of the line
2575 @param aVector The vector to add to the current internal drawing position,
2576 giving the end point of the line.
2579 virtual void DrawLineBy(const TPoint& aVector)=0;
2581 /** Draws a polyline from a set of points in an array.
2583 A polyline is a series of concatenated straight lines joining a set of
2586 @param aPointList An array containing the points on the polyline. */
2587 virtual void DrawPolyLine(const CArrayFix<TPoint>* aPointList)=0;
2589 /** Draws a polyline from a set of points in a list.
2591 A polyline is a series of concatenated straight lines joining a set of
2594 @param aPointList Pointer to a set of points on the polyline.
2595 @param aNumPoints Number of points in the list. */
2596 virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)=0;
2598 /** Draws and fills a pie slice.
2600 The pie slice is an area bounded by:
2602 the arc of an ellipse drawn in an anticlockwise direction from the start
2603 point to the end point
2605 the straight line drawn to the start point from the geometric centre of the
2608 the straight line to the end point from the geometric centre of the ellipse.
2612 A rectangle is used in the construction of the pie slice. This rectangle is
2613 passed as an argument of type TRect. The curved edge of the pie slice is an
2614 arc of an ellipse constructed within the rectangle.
2616 The line drawn by the pen goes inside the specified rectangle.
2618 The pixels at the end point of the arc are not drawn.
2620 A wide line edged pie slice has the arc drawn with the pixels distributed
2621 either side of a true ellipse. This is done in such a way that the outer
2622 edge of the line touches the edge of the construction rectangle. In other
2623 words, the ellipse used to construct it is slightly smaller than that for
2624 a single pixel line size.
2626 If the specified start or end point is at the centre of the ellipse, then
2627 the line that defines the start or end of the arc defaults to one extending
2628 vertically above the centre point.
2630 If the start and end point are the same point or are points on the same line
2631 through the ellipse centre then a complete filled ellipse is drawn. A line
2632 is also drawn from the edge to the ellipse centre.
2634 @param aRect A rectangle in which to draw the ellipse bounding the pie slice.
2635 @param aStart A point defining the start of the arc bounding the pie slice.
2636 It defines one end of a line from the geometrical centre of the ellipse. The
2637 point of intersection between this line and the ellipse defines the start
2639 @param aEnd A point to define the end of the arc bounding the pie slice. It
2640 defines one end of a second line from the geometrical centre of the ellipse.
2641 The point of intersection between this line and the ellipse defines the end
2642 point of the arc. */
2643 virtual void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0;
2645 /** Draws and fills an ellipse.
2647 The ellipse is drawn inside the rectangle defined by the TRect argument. Any
2648 rectangle that has odd pixel dimensions, has the bottom right corner trimmed
2649 to give even pixel dimensions before the ellipse is constructed.
2653 A wide outline ellipse is drawn with the pixels distributed either side of
2654 a true ellipse, in such a way that the outer edge of the line touches the
2655 edge of the construction rectangle. In other words, the ellipse used to
2656 construct it is smaller than that for a single pixel line size.
2658 @param aRect The rectangle in which the ellipse is drawn. */
2659 virtual void DrawEllipse(const TRect& aRect)=0;
2661 /** Draws and fills a rectangle.
2663 @param aRect The rectangle to be drawn. */
2664 virtual void DrawRect(const TRect& aRect)=0;
2666 /** Draws and fills a rectangle with rounded corners.
2668 The rounded corners are each constructed as an arc of an ellipse.
2670 The line drawn by the pen, if any, goes inside the specified rectangle.
2674 Dotted and dashed pen styles cannot be used for the outline of a rounded
2677 If either corner size dimension is greater than half the corresponding
2678 rectangle length, the corner size dimension is reduced to half the
2681 @param aRect The rectangle to be drawn.
2682 @param aCornerSize The dimensions of each corner.
2684 virtual void DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)=0;
2686 /** Draws and fills a polygon defined using an array of points.
2688 The first point in the array defines the start of the first side of the
2689 polygon. The second point defines the second vertex (the end point of the
2690 first side and the start point of the second side).
2692 The final side of the polygon is drawn using the last point from the array,
2693 and the line is drawn to the start point of the first side.
2695 Self-crossing polygons are filled according to the specified fill rule.
2697 @param aPointList An array of points, specifying the vertices of the polygon.
2698 @param aFillRule The fill rule. By default, this is TFillRule::EAlternate.
2699 @return KErrNone, if successful; otherwise, another of the system-wide error
2701 virtual TInt DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule=EAlternate)=0;
2703 /** Draws and fills a polygon defined using a list of points.
2705 The first point in the list defines the start of the first side of the
2706 polygon. The second point defines the second vertex (the end point of the
2707 first side and the start point of the second side).
2709 The final side of the polygon is drawn using the last point from the list,
2710 and the line is drawn to the start point of the first side.
2712 Self-crossing polygons are filled according to the specified fill rule.
2714 @param aPointList Pointer to list of points, specifying the vertices of the
2716 @param aNumPoints The number of points in the list.
2717 @param aFillRule The fill rule. By default this is TFillRule::EAlternate.
2718 @return KErrNone, if successful; otherwise, another of the system-wide error
2720 virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate)=0;
2722 /** Draws a bitmap at the specified point.
2724 The point specifies the top left hand corner of the bitmap. The bitmap is
2725 compressed or stretched based on its internally stored size in twips.
2729 This member function uses the bitmap's size in twips and does a
2730 stretch/compress blit using a linear DDA.
2732 As this function scales the bitmap, it is unavoidably slow. Therefore, where
2733 possible, use CBitmapContext::BitBlt() instead. If the bitmap has to be
2734 scaled, consider creating another bitmap along with an CFbsBitmapDevice etc,
2735 doing DrawBitmap() once and using BitBlt() subsequently.
2737 Note that all bitmaps are clipped to the device boundaries.
2739 @param aTopLeft The point where the top left pixel of the bitmap is to be
2741 @param aSource A source bitmap
2743 virtual void DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource)=0;
2745 /** Draws a bitmap to fit a given rectangle.
2747 The bitmap is compressed or stretched based on its internally stored size
2752 This member function uses the bitmap's size in pixels and does a
2753 stretch/compress blit using a linear DDA.
2755 As this function scales the bitmap, it is unavoidably slow. Therefore,
2756 where possible, use CBitmapContext::BitBlt() instead. If the bitmap has
2757 to be scaled, consider creating another bitmap along with an
2758 CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt()
2761 Note that all bitmaps are clipped to the device boundaries.
2763 @param aDestRect The rectangle within which the bitmap is to be drawn.
2764 @param aSource A source bitmap.
2766 virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)=0;
2768 /** Draws a specified rectangle of a source bitmap to fit into a given
2769 destination rectangle.
2773 This member function uses rectangle sizes in pixels and does a
2774 stretch/compress blit using a linear DDA.
2776 As this function scales the bitmap, it is unavoidably slow. Therefore,
2777 where possible, use CBitmapContext::BitBlt() instead. If the bitmap has
2778 to be scaled, consider creating another bitmap along with an
2779 CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt()
2782 Note that all bitmaps are clipped to the device boundaries.
2784 @param aDestRect The rectangle within which the bitmap is to be drawn.
2785 @param aSource A source bitmap.
2786 @param aSourceRect The rectangle in the source bitmap that is copied to the
2787 destination rectangle.
2789 virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect)=0;
2791 /** Draws a specified rectangle of a source bitmap to fit into a given rectangle using a given mask.
2795 This member function uses rectangle sizes in pixels and does a
2796 stretch/compress blit using a linear DDA.
2799 @param aDestRect The rectangle within which the bitmap is to be drawn.
2800 @param aBitmap The source bitmap
2801 @param aSourceRect The rectangle in the source bitmap that is to be drawn
2802 @param aMaskBitmap The mask to be applied to the source bitmap while drawing
2803 @param aInvertMask Flag to indicate if the mask should be inverted.
2805 virtual void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0;
2807 /** Draws a specified rectangle from a wserv bitmap and its mask into
2810 The function compresses/stretches the specified rectangle from the bitmap
2811 to fit the destination rectangle.
2812 The mask bitmap can be used as either a positive or negative mask. Masked
2813 pixels are not mapped to the destination rectangle.
2815 A black and white (binary) mask bitmap is used. With aInvertMask=EFalse, black
2816 pixels in the mask bitmap stop corresponding pixels in the source bitmap from
2817 being transferred to the destination rectangle. With aInvertMask=ETrue, white
2818 pixels in the mask bitmap stop corresponding pixels in the source bitmap from
2819 being transferred to the destination rectangle.
2821 Note: this member function uses rectangle sizes in pixels and does a stretch/compress
2822 blit using a linear DDA.
2824 @param aDestRect The rectangle within which the masked bitmap is to be drawn.
2825 @param aBitmap A source wserv bitmap.
2826 @param aSourceRect The rectangle in the source bitmap that is copied to the
2827 destination rectangle.
2828 @param aMaskBitmap A mask wserv bitmap.
2829 @param aInvertMask If false, a source pixel that is masked by a black pixel
2830 is not transferred to the destination rectangle. If true, then a source pixel
2831 that is masked by a white pixel is not transferred to the destination rectangle. */
2832 virtual void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask)=0;
2834 /** Draws text without a surrounding box.
2836 The text baseline is aligned with the y co-ordinate of the specified point,
2837 and the left end of the text is aligned with the x co-ordinate of the
2842 Text drawing is done with the pen, and is subject to the pen colour. The
2843 effective text colour also depends on the drawing mode. The size and style
2844 of the text depends on the font used. The layout of the text depends on the
2845 justification mode set.
2847 @param aText The text string to be drawn.
2848 @param aPosition A point specifying the position of the left end of the text. */
2849 virtual void DrawText(const TDesC& aText,const TPoint& aPosition) = 0;
2851 /** Draws text inside a box.
2853 The surrounding box is filled with the current brush colour (not a pattern)
2854 and is drawn without any outline. The effective box colour depends on the
2855 drawing mode - if a brush colour has not been set then the brush defaults
2856 to white. The brush may be set to TBrushStyle::ENullBrush if text
2857 positioning relative to a box is required, but the box should not be filled.
2859 The font used is that set by UseFont(). If no font is in use then a panic
2862 The alignment of the text within the box can be specified.
2864 Text drawn within a box is also clipped to that box. Unless you intend to
2865 clip the top off the text, aBaselineOffset should be greater than or equal
2866 to the ascent of the current font.
2870 If the offset is negative, zero, or less than font height this is handled
2871 as would be expected, i.e. no text will be seen in the box in the first two
2872 instances, and the top of the text will be clipped in the latter case.
2876 For the drawing of right-aligned text, aLeftMargin indicates the margin from
2877 the right of aBox - where a positive value results in a leftwards offset.
2879 Negative margins can be used to display portions of the text string clipped
2880 by the box. A negative margin for left aligned text would clip the start of
2881 the text string. Similarly, a negative margin for right aligned text would
2882 clip the end of the text string.
2884 If the margin is greater than the width of the box then no text will be
2887 The margin is still honoured for centred text - centred text will not be
2888 centred in the box, unless the margin is zero.
2892 Text drawing is done with the pen, and is thus subject to the pen colour.
2893 The effective text colour also depends on the drawing mode. The size and
2894 style of the text depends on the used font. The layout of the text depends
2895 on the justification mode set.
2897 @param aText The text string to be drawn.
2898 @param aBox The box to draw the text in.
2899 @param aBaselineOffset An offset from the top of the box to the text
2901 @param aAlignment The text alignment mode default is left aligned.
2902 @param aLeftMargin The left margin for left-aligned text, or the right
2904 for right-aligned text default is zero. */
2905 virtual void DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TTextAlign aAlignment = ELeft,
2906 TInt aLeftMargin = 0) = 0;
2907 IMPORT_C virtual void DrawText(const TDesC& aText,const TPoint& aPosition,const TDrawTextParam& aParam);
2908 IMPORT_C virtual void Reserved();
2909 IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TPoint& aPosition,const TDrawTextExtendedParam& aParam);
2911 /** Maps pixels in the specified rectangle.
2912 The function tries to match the colour of a pixel with one of the RGB values
2913 in an array of RGB pairs. If there is a match, the colour is changed to the
2914 value specified in the other RGB in the RGB pair.
2915 @param aRect The rectangle in which pixels are to be mapped.
2916 @param aColors A pointer to a set of RGB pairs.
2917 @param aNumPairs The number of pairs
2918 @param aMapForwards ETrue, mapping is done from the first RGB to the second
2919 RGB in the pair; EFalse, mapping is done from the second RGB to the first
2921 virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards) = 0;
2923 /** Sets the clipping region, any items that fall outside the extent of the clipping
2924 region will not be drawn.
2926 Note that clipping is additive. If a clipping rectangle has been set using SetClippingRect()
2927 then clipping will be to the intersection of that rectangle and this region.
2929 @param aRegion The new clipping region. Note that clipping region co-ordinates are
2930 used as absolute co-ordinates, they are not transformed by the current co-ordinate
2931 origin before use (as occurs in SetClippingRect()).
2933 @return KErrNone if successful; KErrArgument if the TRegion is not valid; KErrNoMemory if there is insufficient memory.
2935 @see CGraphicsContext::CancelClippingRegion()
2936 @see CGraphicsContext::SetClippingRect() */
2937 virtual TInt SetClippingRegion(const TRegion &aRegion) = 0;
2939 /** Cancels the current clipping region.
2940 @see CGraphicsContext::SetClippingRegion()*/
2941 virtual void CancelClippingRegion() = 0;
2943 /** Draws vertical text in the specified direction.
2944 @param aText The text to be drawn.
2945 @param aPos Point of origin of the text baseline.
2946 @param aUp Direction. ETrue for up, EFalse for down. */
2947 virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp) = 0;
2949 /** Draws text vertically in the specified direction, within a box of the specified size.
2950 @param aText The text to be drawn.
2951 @param aBox The bounding box within which the text should be drawn, and which it is clipped to.
2952 @param aBaselineOffset The height of the top of the characters from their text baseline.
2953 @param aUp The direction. ETrue for up, EFalse for down.
2954 @param aVert The text alignment.
2955 @param aMargin The margin. */
2956 virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0) = 0;
2958 IMPORT_C TInt GetUnderlineMetrics(TInt& aTop,TInt& aBottom);
2960 /** Set the font's shadow colour
2961 @param aShadowColor Shadow colour to be set.
2962 @return KErrNone, if successful; otherwise, another of the system-wide errors. */
2963 IMPORT_C TInt SetShadowColor(const TRgb& aShadowColor);
2965 /** Get the font's shadow colour
2966 @param aShadowColor Shadow colour of the font returned by the funtion.
2967 @return KErrNone, if successful; otherwise, another of the system-wide errors. */
2968 IMPORT_C TInt GetShadowColor(TRgb& aShadowColor);
2970 /** Determine if the Gc is a CFbsBitGc
2971 @return ETrue, if the Gc is a CFbsBitGc, EFalse otherwise
2973 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
2975 IMPORT_C TBool IsFbsBitGc() const;
2977 IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition);
2978 IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0);
2979 IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextParam& aParam);
2981 IMPORT_C void DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPos,TBool aUp);
2982 IMPORT_C void DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
2984 IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextExtendedParam& aParam);
2989 An APIExtension method to allow the addition of new APIs to retain compatibility
2990 with previous versions of gdi.dll
2991 @param aOutput is for output
2992 @param aInput is for input
2993 @see CGraphicsContext
2995 WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.
2997 IMPORT_C virtual TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput);
3000 A reserved virtual function for future use.
3002 IMPORT_C virtual void Reserved_CGraphicsContext_2();
3006 /** An abstract, device-independent, interface to bitmapped graphics contexts.
3008 This holds the setting used to draw to a CBitmapDevice.
3010 The default settings of a CBitmapContext object immediately after construction
3013 drawing mode is EDrawModePen (pen and brush colours used as they are)
3015 no clipping rectangle
3017 pen settings are: black, solid, single pixel width
3021 no text font selected
3023 The classes CFbsBitGc and CWindowGc are derived from this class.
3029 class CBitmapContext : public CGraphicsContext
3032 /** Clears the whole bitmap.
3034 The cleared area is filled with the current brush colour.
3036 This pure virtual function is implemented in derived classes. */
3037 virtual void Clear()=0;
3039 /** Clears a rectangular area of a bitmap.
3041 The cleared area is filled with the current brush colour.
3043 This pure virtual function is implemented in derived classes.
3045 @param aRect The rectangle to clear. */
3046 virtual void Clear(const TRect& aRect)=0;
3048 /** Copies a rectangle.
3050 This pure virtual function is implemented in derived classes.
3052 @param aOffset The offset from the top left corner of the rectangle to be
3053 copied to the top left corner of the copy.
3054 @param aRect The rectangular area to be copied. */
3055 virtual void CopyRect(const TPoint& aOffset,const TRect& aRect)=0;
3057 /** Performs a bitmap block transfer.
3059 This pure virtual function is implemented in derived classes.
3061 @param aPoint The destination for the top left corner of the transferred bitmap.
3062 It is relative to the top left corner of the destination bitmap, which may be the screen.
3063 @param aBitmap A memory-resident bitmap. */
3064 virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap)=0;
3066 /** Performs a bitmap block transfer of a rectangular piece of a bitmap.
3068 If the specified rectangle is larger than the bitmap then the bitmap is
3071 This pure virtual function is implemented in derived classes.
3073 @param aPoint The destination for the top left corner of the transferred bitmap.
3074 It is relative to the top left corner of the destination bitmap, which may be the screen.
3076 @param aBitmap A memory-resident bitmap
3077 @param aRect A rectangle defining the portion of the bitmap to transfer.
3078 Its coordinates are relative to the top left corner of the source bitmap. */
3079 virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aRect)=0;
3081 /** Performs a masked bitmap block transfer.
3083 The mask bitmap can be used as either a positive or negative mask. Masked
3084 pixels are not mapped to the destination rectangle.
3086 This function uses either a black and white (binary) mask bitmap, or if
3087 aMaskBitmap's display mode is EGray256, alpha blending is used. Use of
3088 any other mode may result in unpredictable results
3090 With aInvertMask=EFalse, black pixels in the mask bitmap stop corresponding
3091 pixels in the source bitmap from being transferred to the destination rectangle.
3092 With aInvertMask=ETrue, white pixels in the mask bitmap stop corresponding
3093 pixels in the source bitmap from being transferred to the destination
3096 Note that if the mask bitmap is smaller than the source bitmap, then it is
3097 tiled across the bitmap. Note that the mask is applied before the piece of
3098 the bitmap is defined - the mask is tiled relative to the top left of the
3099 original source bitmap rather than the top left of the bitmap piece.
3101 This pure virtual function is implemented in derived classes.
3103 @param aPoint The destination for the top left corner of the transferred bitmap.
3104 It is relative to the top left corner of the destination bitmap, which may be the screen.
3105 @param aBitmap A memory-resident source bitmap.
3106 @param aSourceRect A rectangle defining the piece of the bitmap to be drawn,
3107 with co-ordinates relative to the top left corner of the bitmap.
3108 @param aMaskBitmap A mask bitmap
3109 @param aInvertMask If EFalse, a source pixel that is masked by a black pixel
3110 is not transferred to the destination rectangle. If ETrue, then a source
3111 pixel that is masked by a white pixel is not transferred to the destination
3113 virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0;
3115 /** Sets whether the graphics context is faded.
3117 @param aFaded ETrue to fade the GC; EFalse to unfade it. */
3118 virtual void SetFaded(TBool aFaded)=0;
3120 /** Sets the fading parameters.
3122 This function allows you to override the map used when drawing with a faded
3123 graphics context (GC). However if you draw to a faded window with a faded
3124 GC, then fading on the GC is ignored and the fading of the window is used.
3126 Fading is used to change the colour of a window to make other windows stand
3127 out. Fading can either make a faded window closer to white or closer to
3130 Fading re-maps colours in the faded GC to fall between the specified black
3131 and white map values. If aBlackMap=0 and aWhiteMap=255 then the colours are
3132 mapped unchanged. As the values converge the colours are mapped to a smaller
3133 range - so the differences between colours in the faded GC decrease. If
3134 the values are reversed then the colours are inverted (i.e. where the GC
3135 would be black, it is now white).
3137 @param aBlackMap Black map fading parameter. Unfaded this is 0.
3138 @param aWhiteMap White map fading parameter. Unfaded this is 255. */
3139 virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)=0;
3142 Performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using
3143 the data from aAlphaBmp as an alpha blending factor.
3144 The formula used is:
3145 (S * A + W * (255 - A)) / 255, where:
3146 - S - a pixel from aSrcBmp;
3147 - W - a pixel from the window;
3148 - A - a pixel from aAlphaBmp;
3149 The contents of source and alpha bitmap are preserved.
3150 The calculated alpha blended pixels are written to the destination CBitmapContext.
3151 @param aDestPt Position in the target the result should be drawn to.
3152 @param aSrcBmp A pointer to the source bitmap.
3153 @param aSrcRect The part of the source bitmap that should be used.
3154 @param aAlphaBmp A pointer to the bitmap used as an alpha blending factor.
3155 @param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source
3156 for the alpha blending. The size of the area is the same as the
3157 source bitmap area - aSrcRect parameter.*/
3159 virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0;
3162 The method performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using
3163 the data from aAlphaBmp as an alpha blending factor.
3164 For information on how this function works, see the other overload.
3165 @param aDestPt Position in the target the result should be drawn to.
3166 @param aSrcBmp A pointer to the source bitmap.
3167 @param aSrcRect The part of the source bitmap that should be used.
3168 @param aAlphaBmp A pointer to the bitmap used as an alpha blending factor.
3169 @param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source
3170 for the alpha blending. The size of the area is the same as the
3171 source bitmap area - aSrcRect parameter.*/
3172 virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0;
3177 Implementations from CGraphicsContext
3178 @see CGraphicsContext::APIExtension(TUid, TAny*&, TAny*)
3180 IMPORT_C TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput);
3182 Implementations from CGraphicsContext
3183 @see CGraphicsContext::Reserved_CGraphicsContext_2()
3185 IMPORT_C void Reserved_CGraphicsContext_2();
3187 IMPORT_C virtual void Reserved_CBitmapContext_1();
3188 IMPORT_C virtual void Reserved_CBitmapContext_2();
3189 IMPORT_C virtual void Reserved_CBitmapContext_3();
3192 /** Defines an abstract interface for the capabilities and attributes of a
3193 bitmapped graphics device.
3195 The class specialises the graphics device interface CGraphicsDevice for bitmaps
3196 graphics. The Window Server Client-Side API provides one implementation of
3197 the interface, CWsScreenDevice, for screen drawing. Another implementation,
3198 CFbsBitmapDevice, is used for drawing to in-memory bitmaps. A third,
3199 CFbsScreenDevice, is used (rarely) to access the screen directly, without the
3200 mediation of the window server.
3204 class CBitmapDevice : public CGraphicsDevice
3207 /** Gets the RGB colour of an individual pixel on a bitmapped graphics
3210 This pure virtual function is implemented in derived classes.
3212 @param aColor On return, should contain the RGB colour of the pixel.
3213 @param aPixel The (x,y) co-ordinates of the pixel. The top left pixel is
3215 virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const=0;
3217 /** Copies a scanline into a buffer.
3219 The pixels are converted from the display mode format on the bitmapped
3220 graphics device to the format of the specified device display mode.
3222 By specifying the start pixel and the number of pixels, either the whole or
3223 a portion of a bitmapped graphics device pixel row may be copied.
3225 This pure virtual function is implemented in derived classes.
3227 @param aBuf An 8 bit modifiable descriptor buffer into which pixels are
3228 copied; it must be sufficiently large to store all the scanline pixels.
3229 @param aStartPixel The (x,y) co-ordinates of the first pixel of the bitmap
3230 scanline to be put into the buffer.
3231 @param aLength The number of pixels to put into the buffer.
3232 @param aDispMode The display mode into which to convert the pixels. */
3233 virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const=0;
3235 /** Adds a font file to the device's typeface store. The specified font
3236 file must be accessible to any process, i.e. not located inside an
3237 application's private directory.
3239 This pure virtual function is implemented in derived classes.
3241 @param aName The name of the font file.
3242 @param aId On return, contains an ID for the font file.
3243 @return KErrNone, if successful; otherwise, another of the system-wide error
3245 virtual TInt AddFile(const TDesC& aName,TInt& aId)=0;
3247 /** Removes a font file from the font store.
3249 This pure virtual function is implemented in derived classes.
3251 @param aId The ID of the font file to be removed. The default is 0. */
3252 virtual void RemoveFile(TInt aId=0)=0;
3255 Gets the font which is the nearest to the given font specification.
3257 When the font is no longer needed, call @c ReleaseFont().
3259 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInPixels()
3260 yielding (virtually) the same result. However clients are strongly encouraged to use the new
3261 @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every
3262 character within any given text string will fit within the given amount of pixels, whereas the design
3263 height is an aesthetic unit decided by the font designer without strict physical meaning, which
3264 may result in cropped characters.
3266 @param aFont On return, contains a pointer to the nearest font.
3267 @param aFontSpec The specification of the font to be matched.
3268 @return KErrNone if successful; a system-wide error code otherwise.
3270 @deprecated Use GetNearestFontToDesignHeightInPixels
3272 virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
3275 Gets the font which is the nearest to the given font specification.
3277 When the font is no longer needed, call @c ReleaseFont().
3279 This new function replaces the deprecated @c GetNearestFontInPixels() yielding (virtually) the
3280 same result. However clients are strongly encouraged to use the new
3281 @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every
3282 character within any given text string will fit within the given amount of pixels, whereas the design
3283 height is an aesthetic unit decided by the font designer without strict physical meaning, which
3284 may result in cropped characters.
3286 @param aFont On return, contains a pointer to the nearest font.
3287 @param aFontSpec The specification of the font to be matched.
3288 @return KErrNone if successful; a system-wide error code otherwise.
3292 virtual TInt GetNearestFontToDesignHeightInPixels(
3293 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; }
3296 Gets the font which is the nearest to the given font specification.
3298 When the font is no longer needed, call @c ReleaseFont().
3300 The font and bitmap server returns a pointer to the nearest matching font
3301 from those available. Matches to max height of font - this does its best
3302 to return a font that will fit within the maximum height specified (but
3303 note that variations due to hinting algorithms may rarely result in this
3304 height being exceeded by up to one pixel). Problems can also be
3305 encountered with bitmap fonts where the typeface exists but doesn't have
3306 a font small enough.
3308 @param aFont On return, contains a pointer to the nearest font.
3309 @param aFontSpec The specification of the font to be matched.
3310 @param aMaxHeight The maximum height within which the font must fit.
3311 This overrides the height specified in aFontSpec.
3312 @return KErrNone if successful; a system-wide error code otherwise.
3316 virtual TInt GetNearestFontToMaxHeightInPixels(
3317 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; }
3319 /** Gets the height, in pixels, of the specified typeface at one of its
3322 The typeface is identified by by an index. For a given typeface, there are
3323 a discrete number of heights; the specific height is also identified by an
3326 The value returned is rounded up or down to the nearest font height in
3329 This pure virtual function is implemented in derived classes.
3331 @param aTypefaceIndex A typeface index number, in the range: 0 to
3332 (NumTypefaces() - 1).
3333 @param aHeightIndex A font height index number, in the range: 0 to
3334 (iNumHeights - 1) where iNumHeights is a public data member of the
3335 TTypefaceSupport object returned by TypefaceSupport().
3336 @return The height of the font, in pixels.
3337 @see TTypefaceSupport
3338 @see CGraphicsDevice::NumTypefaces()
3339 @see CGraphicsDevice::TypefaceSupport() */
3340 virtual TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
3341 inline TInt CreateBitmapContext(CBitmapContext*& aGC);
3344 /** A set of margins used for cropping a picture.
3346 Margins are specified in twips or pixels.
3353 IMPORT_C void InternalizeL(RReadStream& aStream);
3354 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3355 IMPORT_C TBool operator==(const TMargins& aMargins) const;
3356 IMPORT_C TBool operator!=(const TMargins& aMargins) const;
3358 /** Left margin, (in twips or pixels). */
3360 /** Right margin, (in twips or pixels). */
3362 /** Top margin, (in twips or pixels). */
3364 /** Bottom margin, (in twips or pixels). */
3368 /** Picture capabilities.
3370 These include the types of scaling that can be applied to a picture, and whether
3371 or not it is croppable.
3375 class TPictureCapability
3378 /** Scaling types. */
3381 /** The picture is not scalable. */
3383 /** The picture is fully scalable. */
3385 /** The picture is scalable to any size, as long as its aspect ratio
3386 (the ratio of its height to its width) remains constant. */
3387 EScaleableMaintainingAspectRatio
3390 inline TPictureCapability(TScalingType aScalingType,TBool aCroppable);
3392 /** Whether or not the picture is croppable. */
3393 TScalingType iScalingType;
3394 /** Scaling type. */
3398 /** Abstract base class for: drawing a picture to a graphics context, storing
3399 and restoring the picture.
3401 The class defines the protocol for a number of concrete picture classes. Its
3402 main role is to support glass doors used in object embedding.
3404 The class provides a protocol for the provision of scaling and cropping
3405 functions by derived classes, together with default implementations.
3407 Its main function is Draw(), which draws the picture onto the graphics context
3408 at a particular point. It also has two important pure virtual functions:
3409 ExternalizeL() and GetOriginalSizeInTwips().
3411 A picture has both an original representation and an on-screen representation.
3412 The original representation has a size in twips, and can somehow be drawn.
3413 The on-screen representation is assumed to be drawn under the control of an
3414 application which may wish to re-size or scale the original in some way, to
3415 crop it at the edges, and/or to ensure it fits within a particular defined
3418 The class provides several functions that allow an application to set scaling
3419 and cropping before invoking the Draw() function to draw the picture on-screen.
3420 It is up to the internal workings of the function to determine the order of
3421 application cropping and scaling.
3425 class CPicture : public CBase
3428 /** Options for detaching pictures from stores. Used by DetachFromStoreL(). */
3431 /** Internalise all data that is required to fully store the picture
3432 later; null any references to containing stores. */
3434 /** Internalise enough information to draw the picture (and no more);
3435 null any references to containing stores. */
3439 IMPORT_C virtual ~CPicture();
3440 /** Draws a picture.
3442 @param aGc The graphics context.
3443 @param aTopLeft The co-ordinates where the top left corner pixel of the
3444 picture should be placed. Note that whether this is actually drawn depends
3445 on the clipping area defined.
3446 @param aClipRect A clipping rectangle that defines the area to which the
3447 function should draw. An implementation should never draw outside this
3448 rectangle. Note that the graphics context may also have a clipping rectangle
3450 @param aMap The device map for the graphics device. The implementation
3451 should use this to find the scaling to apply to the picture. */
3452 virtual void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap) const=0;
3453 IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore) const; // assumes no sub streams
3454 virtual void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull) {}
3456 /** Externalises the picture to a stream.
3458 The presence of this function means that the standard templated stream
3459 operator<<() is available to externalise objects of this class.
3461 A derived class must supply an implementation of this function.
3463 @param aStream The write stream. */
3464 virtual void ExternalizeL(RWriteStream& aStream) const =0;
3466 /** Gets the pictur's original size, in twips.
3468 @param aSize The size of the picture, in twips */
3469 virtual void GetOriginalSizeInTwips(TSize& aSize) const =0;
3470 IMPORT_C virtual void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); // does nothing
3471 IMPORT_C virtual void SetCropInTwips(const TMargins& aMargins); // does nothing
3472 IMPORT_C virtual TPictureCapability Capability() const; // no scale, no crop
3473 IMPORT_C virtual void GetCropInTwips(TMargins& aMargins) const; // returns no crop
3474 IMPORT_C virtual TInt ScaleFactorWidth() const; // returns no scaling
3475 IMPORT_C virtual TInt ScaleFactorHeight() const; // returns no scaling
3476 IMPORT_C virtual TBool LineBreakPossible(TUint aClass,TBool aBeforePicture,TBool aHaveSpaces) const;
3477 IMPORT_C virtual TBool NativePixelSize(TSize& aPixelSize);
3479 IMPORT_C void GetSizeInPixels(MGraphicsDeviceMap* aMap, TSize& aSize) const;
3480 IMPORT_C void SetSizeInPixels(MGraphicsDeviceMap* aMap, const TSize& aSize);
3481 IMPORT_C void AddCropInPixels(MGraphicsDeviceMap* aMap, const TMargins& aMargins);
3482 IMPORT_C void GetSizeInTwips(TSize& aSize) const;
3483 IMPORT_C void SetSizeInTwips(const TSize& aSize);
3484 IMPORT_C void ResetToOriginal();
3486 IMPORT_C CPicture();
3490 /** Picture header providing an interface to a stored picture. The header holds:
3492 the picture's type, encoded as a UID, which ensures that it will be restored
3493 to the correct picture type
3495 the picture's size, which facilitates deferred loading
3497 the stream ID of the picture body, which is replaced by a pointer to the picture
3498 object when it has been restored.
3502 class TPictureHeader
3505 IMPORT_C TPictureHeader();
3506 IMPORT_C void InternalizeL(RReadStream& aStream);
3507 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3508 IMPORT_C void DeletePicture();
3510 /** A swizzle storing either the ID of the stream in which the picture is
3511 stored, or a pointer to the internalised picture. */
3512 TSwizzle<CPicture> iPicture;
3513 /** A UID specifying the type of the picture. */
3515 /** The original size of the picture. */
3520 /** Abstract interface for instantiating and restoring new CPicture derived
3523 A concrete derived class creates pictures of one or more specific types. The
3524 class has no member data and just one function, NewPictureL, that needs to
3525 be provided by derived classes.
3529 class MPictureFactory
3532 /** Interface to the picture restoration process that ensures that a
3533 picture of the correct type is restored.
3535 The class of the object to be restored is determined by the UID of the
3536 stored picture, contained in the specified picture header.
3538 The function can allow the restoration of:
3540 just one CPicture-derived class, returning an error if the UID indicates
3541 that the stored picture is not of the required type
3543 many different CPicture-derived classes, using the UID to choose which of
3544 the possible CPicture-derived classes should be instantiated
3546 @param aHeader The picture header that should be restored.
3547 @param aDeferredPictureStore The store in which both the header and picture
3549 virtual void NewPictureL(TPictureHeader& aHeader,const CStreamStore& aDeferredPictureStore)const=0;
3555 The maximum length of a printer model name.
3556 @see TPrinterModelName
3560 const TInt KMaxPrinterModelNameLength=0x20;
3563 Defines a modifiable buffer descriptor that can contain the name of a
3564 printer model. The maximum length of the buffer is 32.
3569 typedef TBuf<KMaxPrinterModelNameLength> TPrinterModelName;
3571 /** Page specification for a print operation.
3573 The page specification consists of the page orientation and the page
3574 size in twips or pixels. By default, the page orientation is portrait.
3575 When using landscape orientation, the left hand side of the page
3585 /**The available page orientations. */
3586 enum TPageOrientation
3588 /** Portrait page orientation */
3590 /** Landscape page orientation */
3594 IMPORT_C TPageSpec();
3595 IMPORT_C TPageSpec(TPageOrientation aOrientation,const TSize& aSize);
3596 IMPORT_C void InternalizeL(RReadStream& aStream);
3597 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3598 IMPORT_C TSize OrientedPageSize() const;
3599 IMPORT_C TBool operator==(const TPageSpec& aPageSpec) const;
3600 IMPORT_C TBool operator!=(const TPageSpec& aPageSpec) const;
3602 /** The width and height of the page in portrait orientation in twips or
3605 Note that OrientedPageSize() returns the width and height in reverse order
3606 for a landscape portrait. */
3607 TSize iPortraitPageSize;
3608 /** The page orientation. */
3609 TPageOrientation iOrientation;
3613 /** Controls the attributes of the band to be printed.
3615 An object of this type is passed as a parameter to functions.
3616 MPageRegionPrinter::PrintBandL() and CPrinterControl::QueueGetBand().
3617 @see MPageRegionPrinter::PrintBandL()
3618 @see CPrinterControl::QueueGetBand()
3623 class TBandAttributes
3626 /** The width and height of the band in twips or pixels. */
3628 /** ETrue to draw no text to the band; EFalse to draw text. */
3629 TBool iTextIsIgnored; // any text drawing to this band is ignored
3630 /** ETrue to draw no graphics to the band; EFalse to draw graphics. */
3631 TBool iGraphicsIsIgnored; // any graphics drawing to this band is ignored
3632 /** ETrue if band is the first band on the page; EFalse if not. */
3633 TBool iFirstBandOnPage;
3636 /** Printer port interface.
3638 This interface is used as the base class for the various types of
3639 printer port. New printer port classes should be derived from this
3640 class.After allocation and construction, a pointer to a concrete
3641 printer port should be passed to
3642 CPrintSetup::StartPrintL().
3643 @see CPrintSetup::StartPrintL()
3648 class CPrinterPort : public CBase
3651 /** Writes data asynchronously to the printer port.
3653 @param aBuf Data to be written to the port
3654 @param aRequestStatus A reference to the request status object. If the
3655 request is cancelled, this should be set to KErrCancel; if the request
3656 completes normally, this should be set to KErrNone. */
3657 virtual void WriteRequest(const TDesC8& aBuf,TRequestStatus& aRequestStatus)=0;
3659 /** Cancels an outstanding WriteRequest() operation. */
3660 virtual void Cancel()=0;
3664 /** Detailed information about a printer model.
3670 class TPrinterModelEntry
3673 /** The name of the printer model. */
3674 TPrinterModelName iModelName;
3675 /** If ETrue, then a printer port is required. */
3676 TBool iRequiresPrinterPort;
3677 /** The UID associated with this printer model. */
3680 IMPORT_C void InternalizeL(RReadStream& aStream);
3681 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3685 /** Information about a printer model.
3687 An instance of this class consists of a TPrinterModelEntry and a stream ID,
3688 and is passed to CPrinterDevice::SetModel().
3694 class TPrinterModelHeader
3697 /** The printer model. */
3698 TPrinterModelEntry iEntry;
3699 /** The stream ID for model data. */
3700 TStreamId iModelDataStreamId;
3702 IMPORT_C void InternalizeL(RReadStream& aStream);
3703 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3707 /** Printer control interface.
3709 This abstract base class acts as the interface between a CPrinterDevice object
3710 and the printer. It creates the context for, and controls the progress and
3711 termination of the print job.
3713 Only those who need to add new printer drivers should write derived classes.
3714 After instantiation of such a class, using CPrinterDevice::CreateControlL(),
3715 the object can be accessed via the iControl member of CPrinterDevice.
3721 class CPrinterControl : public CBase
3724 /** Flags indicating whether there is more on the page to print. */
3727 /** Indicates there is more to print on the current page. */
3729 /** Indicates there is no more to print on the current page. */
3733 IMPORT_C ~CPrinterControl();
3735 /** Gets the number of bands per page.
3737 @return The number of bands on each page. */
3738 virtual TInt BandsPerPage()=0;
3740 /** Prints the next band on the page.
3742 This is an asynchronous function.
3743 @param aStatus Request status object. On successful completion
3744 contains KErrNone, otherwise another of the system-wide
3746 @param aBand On return, indicates the attributes of the band, including
3747 its height and width and whether or not the device will ignore one or
3748 other of graphics or text output. This information may be used by
3749 applications to draw more efficiently, or may be ignored
3750 @return EMoreOnPage, if any unprinted bands remain on the
3751 current page. ENoMoreOnPage, if the current band is last on
3753 virtual TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand)=0; // returns affirmative if more to print on current page
3755 /** Terminates the print process.
3757 This is an asynchronous function and is called when no more bands in
3758 the document remain to be printed.Note that all bands have been
3759 printed when no more pages or copies remain to be printed, and
3760 QueueGetBand() returns ENoMoreToPrint.
3762 @param aStatus Request status object. On successful completion contains
3763 KErrNone, otherwise another of the system-wide error codes. */
3764 virtual void QueueEndPrint(TRequestStatus& aStatus)=0;
3766 /** Aborts the print process before it has completed.
3768 This function should be called if QueueGetBand() reports an error. */
3769 virtual void AbortPrint()=0; // tidy up synchronously in a short time, return success code
3771 IMPORT_C CPrinterControl(CPrinterPort* aPrinterPort);
3776 /** Not printing. */
3781 /** Printing state. */
3783 /** Printer port. */
3784 CPrinterPort* iPrinterPort;
3787 class CDictionaryStore;
3790 /** Printer graphics device interface.
3792 This abstract class represents a physical graphics device that is used for
3795 This class is used to:
3797 set and get the page specification
3799 map between the co-ordinates of the printed page (in twips) and the co-ordinates
3800 of the image device (in pixels)
3802 get and set the printer model entry
3804 create and delete a printer control.
3806 A printer driver is defined in terms of a printer device and a printer control.
3807 A printer device can own either a single or no printer control. The control
3808 determines the progress and termination of the print job and is responsible
3809 for producing output.
3811 @see CPrinterControl
3815 class CPrinterDevice : public CGraphicsDevice
3818 IMPORT_C ~CPrinterDevice();
3820 /** Gets the current page specification in twips.
3822 @return The current page specification, in twips. */
3823 inline TPageSpec CurrentPageSpecInTwips() const {return(iCurrentPageSpecInTwips);}
3825 /** Sets the page specification in twips.
3827 @param aPageSpec The page specification in twips. */
3828 IMPORT_C virtual void SelectPageSpecInTwips(const TPageSpec& aPageSpec);
3829 IMPORT_C virtual TRect PrintablePageInPixels() const;
3831 /** Gets the printer model entry.
3833 @return The printer model entry. */
3834 virtual TPrinterModelEntry Model()const =0;
3836 /** Sets the printer model header and the store.
3838 @param aModel The printer model header.
3839 @param aStore The store.
3840 @return KErrNone if successful; otherwise, another of the system-wide
3842 virtual TInt SetModel(const TPrinterModelHeader& aModel,CStreamStore& aStore)=0;
3844 /** Creates a printer control.
3846 The printer control is an instance of a CPrinterControl derived class; it
3847 is assigned to this printer device's iControl member.
3849 Note that this function is called by CPrintSetup::StartPrintL().
3851 @param aPrinterPort Pointer to an instance of a printer port. */
3852 virtual void CreateControlL(CPrinterPort* aPrinterPort)=0;
3853 IMPORT_C virtual void DeleteControl();
3855 /** Externalizes printer properties to the store.
3857 The default implementation is empty.
3859 @param aStream The read stream. */
3860 virtual void InternalizePropertiesL(RReadStream& /*aStream*/) {}
3862 /** Externalizes printer properties to the store.
3864 The default implementation is empty.
3866 @param aStream The write stream. */
3867 virtual void ExternalizePropertiesL(RWriteStream& /*aStream*/) const {}
3868 IMPORT_C void RestorePropertiesL();
3869 IMPORT_C void StorePropertiesL() const;
3871 IMPORT_C CPrinterDevice();
3873 /** The printer control.
3875 This may be NULL. If implemented, it provides control over the print
3877 CPrinterControl* iControl;
3879 /** Current page specification in twips. */
3880 TPageSpec iCurrentPageSpecInTwips;
3884 /** Printer model list interface.
3886 Functions provided by this abstract base class can be used to extract printer
3887 model information from the list of printer models. This class would typically
3888 be used to implement printer selection in a dialog box.
3894 class CPrinterModelList : public CBase
3897 /** Gets the number of printer models in the printer model list.
3899 @return The number of printer models. */
3900 virtual TInt ModelCount() const=0;
3902 /**Gets printer model name.
3904 This is the name of the printer model at the specified index within
3905 the list of printer models.
3907 @param anIndex The index of the printer model within the array of
3908 printer models. Note that this number must be between zero and
3910 @return Name of printer model, up to 32 characters long */
3911 virtual const TPrinterModelEntry operator[](TInt anIndex)=0;
3913 /** Gets a printer models index within the model list from its UID.
3915 @param aModelUid The UID of the printer model.
3916 @return The index of the printer model within the array of printer models.*/
3917 virtual TInt UidToNum(TUid aModelUid) const=0;
3921 /** Interface for printing in bands.
3923 This class provides a single PrintBandL() function that prints
3924 the body of each page band by band. Classes derived from this interface must
3925 provide an implementation of the PrintBandL() function.
3930 class MPageRegionPrinter
3935 Implementations should set up a graphics context to which all drawing should
3936 take place using CGraphicsDevice::CreateContext(). All co-ordinate
3937 calculations should be done in twips, and converted into pixels before
3938 starting the print job.
3940 @param aDevice Pointer to the graphics device representing the printer.
3941 @param aPageNo The number of the page containing the band to be printed.
3942 @param aBandInPixels Attributes of the band to be printed. */
3943 virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBandInPixels)=0;
3947 The UID value of a printer specification data store.
3951 const TInt KPdrStoreFileUidVal=268435514;
3953 const TInt KPdlUidVal=268450588;
3954 const TInt KUdlUidVal=268450589;
3957 /** Printer specific user interface.
3959 The class is used to implement a printer specific setup dialog. A concrete
3960 implementation of the class is supplied in a UDL (i.e. a UI DLL).
3962 CPrinterDriver::CreatePrinterDriverUIL() is used to construct a CPrinterDriverUI
3963 object for a specific printer. (This function calls the ordinal 1 exported
3964 function of the UDL that performs the construction of the CPrinterDriverUI
3967 @see CPrinterDriver::CreatePrinterDriverUIL()
3971 class CPrinterDriverUI : public CBase
3974 IMPORT_C CPrinterDriverUI();
3976 IMPORT_C virtual TBool BeforePrintL();
3977 IMPORT_C virtual void AfterPrintL();
3978 IMPORT_C virtual void SetPropertiesL();
3979 IMPORT_C virtual TBool CanSetProperties();
3981 /** Sets the printer device.
3983 @param aPrinterDevice The printer device. */
3984 virtual TInt SetPrinterDevice(CPrinterDevice* aPrinterDevice)=0;
3990 /** Provides access to a store containing printer specification data.
3992 Printer specification data is held as a direct file store, and usually has
3995 A printer driver is implemented as two files: a PDR file containing the printer
3996 specification data and a PDL file containing the code to link the printer
3997 with the graphics printing system.
3999 The printer specification data is generated by compiling a text file (a .pd
4000 file type) using the pdrtran tool. Printer specification data defines:
4002 the name of the associated PDL
4004 a list of one or more models supported by this driver, identified by name
4007 device information such as the size of the device, typeface information for
4008 each model, including which typefaces are supported, the heights available
4009 in each typeface and the width of each character in a font.
4011 @see CPrinterDriverUI
4015 class CPrinterDriver : public CBase
4018 IMPORT_C static CPrinterDriver* NewL();
4019 IMPORT_C ~CPrinterDriver();
4020 IMPORT_C void OpenPdrL(const TDesC &aName);
4021 IMPORT_C void Close();
4022 IMPORT_C TInt NumModels() const;
4023 IMPORT_C TPrinterModelEntry Model(TInt aNum) const;
4025 /** Gets the associated graphics printer device.
4027 @return The physical graphics device used for printing. */
4028 inline CPrinterDevice* PrinterDevice() {return iPrinterDevice;}
4029 IMPORT_C CPrinterDevice* CreatePrinterDeviceL(TUid aModelUid);
4030 IMPORT_C CPrinterDriverUI* CreatePrinterDriverUIL();
4033 void DeletePrinterDevice();
4034 void DoOpenPdrL(const TDesC &aName);
4035 void DoCreatePrinterDeviceL(TUid aModelUid);
4036 void LoadLibraryL(RLibrary& aLibrary,const TDesC& aExt,TUid aUid2);
4039 CFileStore *iPdrStore;
4041 TPrinterModelHeader* iModelList;
4044 RLibrary iPdlLibrary;
4045 CPrinterDevice* iPrinterDevice;
4046 RLibrary iUdlLibrary;
4049 class RResourceFile;
4052 /** Implements a printer model list interface for a collection of PDR files.
4056 class CPdrModelList : public CPrinterModelList
4059 IMPORT_C static CPdrModelList* NewL();
4060 IMPORT_C virtual ~CPdrModelList();
4061 IMPORT_C TInt ModelCount() const;
4062 IMPORT_C const TPrinterModelEntry operator [] (TInt anIndex);
4063 IMPORT_C TInt UidToNum(TUid aModelUid) const; // returns KErrNotFound the model uid is not matched
4064 IMPORT_C void AddDirectoryL(const TDesC& aDir);
4065 IMPORT_C CPrinterModelList* ScanForModelsL();
4066 IMPORT_C CPrinterDriver* CreatePrinterDriverL(TInt anIndex);
4074 TFileName iFileName;
4080 TPrinterModelEntry iEntry;
4084 void ScanDirectoryL(TInt aDirIndex);
4085 void ListModelsL(TInt aFileIndex, TParse& aParser, TFileName& aNameOfLoadedResourceFile, TFileName& aTempFileName, RResourceFile& aResourceFile, HBufC8*& aResource);
4086 HBufC* NewPathBufL(const TFileEntry& aFileEntry);
4088 CArrayFixSeg<TModelEntry>* iModelArray;
4089 CArrayFixFlat<TFileEntry>* iFileArray;
4090 CArrayFixFlat<HBufC*>* iDirectoryArray;
4095 /** The interface for mapping between twips and device-specific units enriched
4096 with facilities to allow zooming.
4098 The class is recursive, because a TZoomFactor object can have a
4099 MGraphicsDeviceMap (which could itself be a TZoomFactor) in its member data.
4100 This allows a zoom factor object to contain another zoom factor object, and
4101 is used to allow objects with different zoom factors to be embedded in each
4102 other to an arbitrary depth by the application architecture.
4106 class TZoomFactor : public MGraphicsDeviceMap
4109 IMPORT_C TZoomFactor();
4110 IMPORT_C ~TZoomFactor();
4111 inline TZoomFactor(const MGraphicsDeviceMap* aDevice);
4112 inline TZoomFactor(const TZoomFactor* aDevice);
4113 IMPORT_C TInt ZoomFactor() const;
4114 IMPORT_C void SetZoomFactor(TInt aZoomFactor);
4115 inline void SetGraphicsDeviceMap(const MGraphicsDeviceMap* aDevice);
4116 inline const MGraphicsDeviceMap* GraphicsDeviceMap() const;
4117 IMPORT_C void SetTwipToPixelMapping(const TSize& aSizeInPixels,const TSize& aSizeInTwips);
4118 IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwipWidth) const;
4119 IMPORT_C TInt VerticalTwipsToPixels(TInt aTwipHeight) const;
4120 IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixelWidth) const;
4121 IMPORT_C TInt VerticalPixelsToTwips(TInt aPixelHeight) const;
4122 IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
4123 IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
4124 IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
4125 IMPORT_C void ReleaseFont(CFont* aFont);
4128 /** One to one zoom factor. */
4129 enum {EZoomOneToOne=1000};
4132 const MGraphicsDeviceMap* iDevice;
4135 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
4136 #include <graphics/gdi/gdistructs.h>
4137 #include <graphics/gdi/gdiinline.inl>
4138 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS