Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
23 The default screen number.
26 const TInt KDefaultScreenNo = 0;
28 class TOpenFontCharMetrics;
32 Number of twips per inch.
36 const TInt KTwipsPerInch=1440;
39 Number of twips per point.
43 const TInt KTwipsPerPoint=20;
46 Number of points per inch.
50 const TInt KPointsPerInch=72;
53 Number of twips per cm.
57 const TInt KTwipsPerCm=567;
58 #if defined(__NO_CLASS_CONSTS__)
60 A4 paper size in twips.
64 #define KA4PaperSizeInTwips TSize(11906,16838)
66 /** Legal paper size in twips.
70 #define KLegalPaperSizeInTwips TSize(12240,20160)
73 Executive paper size in twips.
77 #define KExecutivePaperSizeInTwips TSize(10440,15120)
79 Letter paper size in twips.
83 #define KLetterPaperSizeInTwips TSize(12240,15840)
86 Com-10 paper size in twips.
90 #define KCom_10PaperSizeInTwips TSize(5940,13680)
93 Monarch paper size in twips.
97 #define KMonarchPaperSizeInTwips TSize(5580,10800)
100 DL paper size in twips.
104 #define KDLPaperSizeInTwips TSize(6236,12472)
107 C5 paper size in twips.
111 #define KC5PaperSizeInTwips TSize(9184,12983)
117 const TSize KA4PaperSizeInTwips(11906,16838);
118 const TSize KLegalPaperSizeInTwips(12240,20160);
119 const TSize KExecutivePaperSizeInTwips(10440,15120);
120 const TSize KLetterPaperSizeInTwips(12240,15840);
121 const TSize KCom_10PaperSizeInTwips(5940,13680);
122 const TSize KMonarchPaperSizeInTwips(5580,10800);
123 const TSize KDLPaperSizeInTwips(6236,12472);
124 const TSize KC5PaperSizeInTwips(9184,12983);
128 Declaration of constant TUids for APIExtension to use as identifiers.
132 const TUid KGetUnderlineMetrics = {0x102827FB};
133 const TUid KSetFastBlendDisabled = {0x10285A30};
134 const TUid KSetShadowColor = {0x10282DA1};
135 const TUid KGetShadowColor = {0x10282DA2};
136 const TUid KUidIsFbsBitmapGc = {0x10285BBE};
139 This enumeration holds the possible panic codes that may be raised
140 by the GDI API on detecting an unrecoverable error. */
144 EGdiPanic_Unknown = 0,
145 /** One or more of the input parameters to the interface were invalid */
146 EGdiPanic_InvalidInputParam = 1,
147 /** Insufficient text for successful completion of the method */
148 EGdiPanic_OutOfText = 2,
149 /** Internal failure. */
150 EGdiPanic_Invariant = 3
153 /** 24-bit RGB colour value with 8 bits each for red, green and blue.
155 All Graphics drawing functions are specified in terms of a 32-bit TRgb colour
156 containing the three colour values plus 8 bits for alpha channel. For hardware which
157 does not support 24-bit colour, a mapping from TRgb to display colours is
160 Generally, the convention for the alpha blending fact is 0 = transparent,
161 255 = opaque, unless otherwise stated. The exception to this are the TRgb constructor
162 taking a single value, where the top byte of the passed in parameter is used for
163 alpha information and the function Value(), which returns alpha information in the top byte.
164 In both these cases, 0 means opaque, 255 means transparent.
166 The supported display modes are enumerated in the TDisplayMode type. In each
167 display mode a unique index can represent each physical colours supported,
168 and which can be mapped onto a full RGB value. The mappings are as follows:
170 16-colour displays use the EGA colour set: black, white, and then both light
171 and dark versions of grey, red, green, blue, cyan, magenta and yellow
173 256-colour displays support 216 colours made up of 6x6x6 RGB values, each
174 containing all possible multiples of 51 for R,G,B values. Additionally, all
175 remaining 10 shades of pure red, green, blue and grey are represented, by
176 adding all remaining multiples of 17. This use of 256 colours is sometimes
177 known as the Netscape colour cube.
179 4096-colour displays effectively support RGB values with 4 bits per primary
182 64k-colour displays effectively support RGB values with 5 bits allocated to
183 red, 6 to green and 5 to blue
185 16 million-colour displays support true colour with 8 bits allocated to each
191 @see DynamicPalette */
196 inline TRgb(TUint32 aValue);
197 inline TRgb(TUint32 aInternalValue, TInt aAlpha);
198 inline TRgb(TInt aRed,TInt aGreen,TInt aBlue);
199 inline TRgb(TInt aRed, TInt aGreen, TInt aBlue, TInt aAlpha);
200 inline TInt Red() const;
201 inline TInt Green() const;
202 inline TInt Blue() const;
203 inline TInt Alpha() const;
204 IMPORT_C void SetRed(TInt aRed);
205 IMPORT_C void SetGreen(TInt aGreen);
206 IMPORT_C void SetBlue(TInt aBlue);
207 IMPORT_C void SetAlpha(TInt aAlpha);
208 IMPORT_C static TRgb Gray2(TInt aGray2);
209 IMPORT_C static TRgb Gray4(TInt aGray4);
210 IMPORT_C static TRgb Gray16(TInt aGray16);
211 IMPORT_C static TRgb Gray256(TInt aGray256);
212 IMPORT_C static TRgb Color16(TInt aColor16);
213 IMPORT_C static TRgb Color256(TInt aColor256);
214 IMPORT_C static TRgb Color4K(TInt aColor4K);
215 IMPORT_C static TRgb Color64K(TInt aColor64K);
216 IMPORT_C static TRgb Color16M(TInt aColor16M);
217 IMPORT_C TInt Gray2() const;
218 IMPORT_C TInt Gray4() const;
219 IMPORT_C TInt Gray16() const;
220 IMPORT_C TInt Gray256() const;
221 IMPORT_C TInt Color16() const;
222 IMPORT_C TInt Color256() const;
223 IMPORT_C TInt Color4K() const;
224 IMPORT_C TInt Color64K() const;
225 IMPORT_C TInt Color16M() const;
226 inline TBool operator==(const TRgb& aColor) const;
227 inline TBool operator!=(const TRgb& aColor) const;
228 inline TRgb operator~() const;
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 TRgb& operator^=(const TRgb& aColor);
235 inline TUint32 Value() const;
236 inline TUint32 Internal() const;
237 inline void SetInternal(TUint32 aInternal);
238 IMPORT_C TInt Difference(const TRgb& aColor) const;
239 IMPORT_C void InternalizeL(RReadStream& aStream);
240 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
241 IMPORT_C static TRgb Color16MU(TInt a0RGB);
242 IMPORT_C TInt Color16MU() const;
243 IMPORT_C static TRgb Color16MA(TUint aARGB);
244 IMPORT_C TUint Color16MA() const;
245 IMPORT_C static TRgb Color16MAP(TUint aARGB);
246 IMPORT_C TUint Color16MAP() const;
247 IMPORT_C TUint _Color16MAP() const;
248 IMPORT_C static TRgb _Color16MAP(TUint aARGB);
249 inline TInt _Gray2() const;
250 inline TInt _Gray4() const;
251 inline TInt _Gray16() const;
252 inline TInt _Gray256() const;
253 inline TInt _Color4K() const;
254 inline TInt _Color64K() const;
255 inline TInt _Color16M() const;
256 inline TInt _Color16MU() const;
257 inline TUint _Color16MA() const;
258 inline static TRgb _Gray2(TInt aGray2);
259 inline static TRgb _Gray4(TInt aGray4);
260 inline static TRgb _Gray16(TInt aGray16);
261 inline static TRgb _Gray256(TInt aGray256);
262 inline static TRgb _Color4K(TInt aColor4K);
263 inline static TRgb _Color64K(TInt aColor64K);
264 inline static TRgb _Color16M(TInt aColor16M);
265 inline static TRgb _Color16MU(TInt a0RGB);
266 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)
299 /** No display mode */
301 /** Monochrome display mode (1 bpp) */
303 /** Four grayscales display mode (2 bpp) */
305 /** 16 grayscales display mode (4 bpp) */
307 /** 256 grayscales display mode (8 bpp) */
309 /** Low colour EGA 16 colour display mode (4 bpp) */
311 /** 256 colour display mode (8 bpp) */
313 /** 64,000 colour display mode (16 bpp) */
315 /** True colour display mode (24 bpp) */
317 /** (Not an actual display mode used for moving buffers containing bitmaps) */
319 /** 4096 colour display (12 bpp). */
321 /** True colour display mode (32 bpp, but top byte is unused and unspecified) */
323 /** Display mode with alpha (24bpp colour plus 8bpp alpha) */
325 /** Pre-multiplied Alpha display mode (24bpp color multiplied with the alpha channel value, plus 8bpp alpha) */
327 //Any new display mode should be insterted here!
328 //There might be up to 255 display modes, so value of the last
329 //inserted EColorXXX enum item should be less than 256 -
336 /** A set of static utility functions to get information about a display mode.
340 class TDisplayModeUtils
343 IMPORT_C static TBool IsDisplayModeColor(TDisplayMode aDispMode);
344 IMPORT_C static TBool IsDisplayModeValid(TDisplayMode aDispMode);
345 IMPORT_C static TInt NumDisplayModeColors(TDisplayMode aDispMode);
346 IMPORT_C static TInt NumDisplayModeBitsPerPixel(TDisplayMode aDispMode);
349 /** Utility function to check if a display mode has Alpha channel information
350 @param aDisplayMode - the display mode being queried
351 @return ETrue if display mode contains Alpha information.
355 inline TBool IsAlphaChannel(TDisplayMode aDisplayMode);
356 /** Provides user-definable palette support to the GDI.
358 A palette is a user-defined set of colours, which is a subset of the full
359 range of 24-bit colours. This allows users the advantages of having a low
360 bpp colour mode whilst being able to specify the colours available in that
361 mode. To give an example, the EColor16 mode provides a palette of 16 colours
362 as it provides a mapping between an integer index and a TRgb colour (see the
363 table EGA Low-colour constants). Only a palette of 16 colour enables you to
364 change the palette. Palettes are also used to allow 24-bit bitmaps to be stored
365 in a more compressed form by finding the actual number of different colours
366 used in the bitmap, creating a palette to allow the mapping of these colours
367 to a smaller index space, and encoding the bitmaps pixels using indexes
368 to this new index space.
370 A palette has a size which is set at its creation and cannot be altered
371 the number of entries in the palette. Each entry in a palette is a mapping
372 between that entrys index and a TRgb value. Palette entries can be got
373 and set at any time between the palettes creation and destruction. The
374 GDIs palette support also provides functions to find the nearest palette
375 colour to a requested TRgb colour.
379 class CPalette : public CBase
382 IMPORT_C static CPalette* NewL(TInt aNumberOfEntries);
383 IMPORT_C static CPalette* NewDefaultL(TDisplayMode aDispMode);
384 IMPORT_C ~CPalette();
385 IMPORT_C void Clear();
386 inline TInt Entries() const;
387 IMPORT_C TRgb GetEntry(TInt aPaletteIndex) const;
388 IMPORT_C TRgb NearestEntry(const TRgb& aColor) const;
389 IMPORT_C TInt NearestIndex(const TRgb& aColor) const;
390 IMPORT_C void SetEntry(TInt aPaletteIndex,const TRgb& aPaletteEntry);
391 IMPORT_C void GetDataPtr(TInt aFirstColor,TInt aNumColors,TPtr8& aPtr);
394 void ConstructL(TInt aNumberOfEntries);
401 /** Enables conversion, in both directions, between a TRgb object and an index
402 into an arbitrary 256 colour palette.
409 IMPORT_C void Construct(const CPalette& aPalette);
410 IMPORT_C TInt Color256(TRgb aRgb) const;
411 IMPORT_C void Color256(TUint8* aDestination,const TRgb* aSource,TInt aNumPixels) const;
412 inline TRgb Color256(TInt aColor256) const;
413 IMPORT_C static const TColor256Util* Default();
415 /** 256 colour lookup table.
417 Each entry is a 32 bit value which corresponds to a TRgb value in the
418 palette passed to Construct(). If there are more than 256 colours in the
419 palette, the first 256 colours are used in this table. If there are fewer
420 than 256 entries, the remaining entries in the table are set to zero. */
421 TUint32 iColorTable[256];
423 /** Inverse colour lookup table.
425 It has 4096 entries. Each entry is the index of a colour in the palette
426 that the object was created with (see Construct()) that most closely
427 matches the 4096 degrees of intensity of red, green and blue on a uniform
428 16x16x16 colour cube.
430 It is called "inverse" because iColorTable maps indices (0..255) to TRgb
431 values, but this table maps TRgb values to palette indices. */
432 TUint8 iInverseColorTable[0x1000];
436 /** Linear digital differential analyser.
438 This is used to calculate the pixels which most closely approximate a specified
439 straight line, or when scaling a bitmap. Note that a line is infinitely thin,
440 and can only be approximated by pixels with real width and height.
442 Functions are provided for: pixel line traversing; jumping to a rectangle or
450 /** LDDA Line mode. */
453 /** Centres scan-lines in the pixel line */
455 /** Starts at the beginning of a complete scan line. Used for bitmap
460 IMPORT_C TLinearDDA();
461 IMPORT_C TLinearDDA(const TLinearDDA& aLine);
462 IMPORT_C void Construct(const TPoint& aStart,const TPoint& aFinish,TLineMode aMode=ECenter);
463 IMPORT_C TBool SingleStep(TPoint& aPosition);
464 IMPORT_C TBool SingleScanline(TPoint& aStartPosition,TPoint& aEndPosition);
465 IMPORT_C TBool NextStep(TPoint& aPosition);
466 IMPORT_C void JumpToRect(const TRect& aRect);
467 IMPORT_C void JumpToXCoord(const TInt aXCoord,TInt& aYCoord);
468 IMPORT_C void JumpToYCoord(TInt& aXCoord,const TInt aYCoord);
469 IMPORT_C void JumpToXCoord2(TInt aXCoord,TInt& aYCoord);
470 IMPORT_C void JumpToYCoord2(TInt& aXCoord,TInt aYCoord);
472 void UpdatePosition();
489 TBool iBoundingRectSet;
497 Fonts can be either upright or italic.
503 /** Font posture is normal (upright). */
505 /** Font posture is italic. */
510 Font stroke weight flags.
514 enum TFontStrokeWeight
516 /** Font stroke weight is normal. */
518 /** Font stroke weight is bold. */
523 Font print position flags.
524 Fonts can be normal, superscript or subscript.
528 enum TFontPrintPosition
530 /** Font is normal. */
532 /** Font is superscript. */
533 EPrintPosSuperscript,
534 /** Font is subscript. */
539 Font underline flags.
545 /** Font is not underlined. */
547 /** Font is underlined. */
552 Font strike-through flags.
556 enum TFontStrikethrough
558 /** Font is not struck-through. */
560 /** Font is struck-through. */
565 The maximum length of a typeface name (in characters).
569 const TInt KMaxTypefaceNameLength=0x18;
572 /** Typeface name and attributes.
574 This class identifies a typeface by name, and contains the combination of
575 attributes of the typeface. These attributes define whether it is a symbol
576 typeface, whether the typeface is proportional, and whether it is serif or
579 The combination of attributes for a typeface are stored in a bitmask, with
580 the various bits indicating different attributes. The bitmask is calculated
581 for any particular attribute combination by ORing the enumerated value for
582 each individual attribute.
591 /** Typeface is a proportional typeface (e.g. Swiss)
594 /** Typeface is a serif typeface (e.g. Times)
597 /** Typeface is a symbol typeface (e.g. Symbol)
602 IMPORT_C TTypeface();
603 IMPORT_C TBool operator==(const TTypeface& aTypeface) const;
604 IMPORT_C void InternalizeL(RReadStream& aStream);
605 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
606 IMPORT_C void SetAttributes(TInt aAttributes);
607 IMPORT_C void SetIsProportional(TBool aIsProportional);
608 IMPORT_C void SetIsSerif(TBool aIsSerif);
609 IMPORT_C void SetIsSymbol(TBool aIsSymbol);
610 IMPORT_C TInt Attributes() const;
611 IMPORT_C TBool IsProportional() const;
612 IMPORT_C TBool IsSerif() const;
613 IMPORT_C TBool IsSymbol() const;
614 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
615 IMPORT_C void SetScriptTypeForMetrics(TInt aScript);
616 IMPORT_C TInt ScriptTypeForMetrics() const;
618 void ResetAttributes();
619 void ResetScriptType();
621 /** The typeface name. */
622 TBufC<KMaxTypefaceNameLength> iName;
629 An enumerated type for the format of a glyph bitmap. This type is currently
630 used to indicate whether glyph bitmaps for scalable fonts are drawn anti-aliased.
631 Additional values may be defined in the future.
633 @see TFontStyle::SetBitmapType()
634 @see CFbsTypefaceStore::SetDefaultBitmapType()
638 enum TGlyphBitmapType
640 /** The font store's default glyph bitmap format is used. */
641 EDefaultGlyphBitmap = 0,
642 /** The standard monochrome format: no anti-aliasing, 1 bit per pixel,
643 run-length encoded. */
644 EMonochromeGlyphBitmap,
645 /** Standard 8-bits-per-pixel with anti-aliasing. */
646 EAntiAliasedGlyphBitmap,
647 /** The format used when sub-pixel font rendering is used. */
648 ESubPixelGlyphBitmap,
649 /** The format used when outline and shadow font rendering is used.
651 If the raterizer supports the outline and shadow fonts, it will set the bitmaptype as
652 EFourColourBlendGlyphBitmap but only when glyph bitmap type is set as EAntiAliasedGlyphBitmap and
653 when any of the EDropShadow or EOutline effect is on. Only rasterizer providers can use this enum.
657 EFourColourBlendGlyphBitmap,
662 Defines a set of font effects flags.
664 @publishedPartner For use by system/UI software.
667 NONSHARABLE_CLASS(FontEffect)
672 ENone = 0x0, // No effects.
673 EAlgorithmicBold= 0x10, // Font is algorithmic bold (a.k.a pseudo bold.)
674 EDropShadow = 0x20, // Font has a drop shadow.
675 EOutline = 0x40, // Font is an outline font.
676 EEmbossed = 0x80, // Font is embossed.
677 EEngraved = 0x100, // Font is engraved.
678 ESoftEdge = 0x200, // Font is soft edged.
679 EReserved1 = 0x400, // Reserved for Symbian use.
680 EReserved2 = 0x800, // Reserved for Symbian use.
681 EReserved3 = 0x1000, // Reserved for Symbian use.
682 EReserved4 = 0x2000, // Reserved for Symbian use.
683 EReserved5 = 0x4000, // Reserved for Symbian use.
684 EReserved6 = 0x8000, // Reserved for Symbian use.
687 IMPORT_C static TBool IsEffectOn(TEffect aEffect, TUint32 aFontEffect);
688 IMPORT_C static void SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect);
692 /** Encapsulates a font style.
694 The font style information is comprised of:
696 the posture of the font upright or italic
698 the stroke weight of the font normal or bold
700 the print position of the font normal, subscript or superscript
702 Note that the underline and strike-through attributes are not included in
703 this class, but are set in the graphics context.
705 @see CGraphicsContext::SetUnderlineStyle()
706 @see CGraphicsContext::SetStrikethroughStyle()
713 IMPORT_C TFontStyle();
714 IMPORT_C TFontStyle(TFontPosture aPost,TFontStrokeWeight aStrWgt,TFontPrintPosition aPrintPos);
715 IMPORT_C void InternalizeL(RReadStream& aStream);
716 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
717 IMPORT_C TFontPosture Posture() const;
718 IMPORT_C TFontStrokeWeight StrokeWeight() const;
719 IMPORT_C TFontPrintPosition PrintPosition() const;
720 IMPORT_C void SetPosture(TFontPosture aPosture);
721 IMPORT_C void SetStrokeWeight(TFontStrokeWeight aStrokeWeight);
722 IMPORT_C void SetPrintPosition(TFontPrintPosition aPrintPosition);
723 inline TGlyphBitmapType BitmapType() const;
724 inline void SetBitmapType(TGlyphBitmapType aBitmapType);
725 IMPORT_C TBool operator==(const TFontStyle& aFontStyle) const;
726 IMPORT_C TUint32 Effects() const;
727 IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
728 IMPORT_C void SetEffects(TUint32 aEffects);
729 IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
739 TUint32 iFlags; // bitmap type - 16 bits (high), font effects - 12 bits (middle), style - 4 bits (low)
747 Specifies the font specification in device independent terms.
754 IMPORT_C TFontSpec();
755 IMPORT_C TFontSpec(const TDesC& aTypefaceName,TInt aHeight);
756 IMPORT_C TBool operator==(const TFontSpec& aFontSpec) const;
757 IMPORT_C void InternalizeL(RReadStream& aStream);
758 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
759 IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
760 IMPORT_C TInt ScriptTypeForMetrics() const;
764 /** The height of the typeface (in twips). */
766 /** The font style of the typeface. */
767 TFontStyle iFontStyle;
772 /** Typeface family support information.
774 This data-only class includes the name and attributes of a typeface, how many
775 font heights are available, its minimum and maximum heights, and whether or
776 not it is scaleable a typeface is scaleable if it supports heights at
777 fixed intervals between the minimum and maximum heights.
781 class TTypefaceSupport
784 /** The name and attributes of the typeface. */
786 /** The number of distinct font heights available in the typeface. */
788 /** The typeface's minimum font height, in twips. */
789 TInt iMinHeightInTwips;
790 /** The typeface's maximum font height, in twips. */
791 TInt iMaxHeightInTwips;
792 /** Whether the typeface is scaleable. ETrue if it is scaleable, otherwise
794 TBool iIsScalable; // supports heights from min to max at fixed interval
798 The percentage used to multiply a normal font height when calculating its
799 superscript or subscript height.
803 const TInt KSuperSubScalingPercentage=67;
806 The percentage of a font height used to calculate its baseline offset for a
807 superscript print position.
811 const TInt KSuperscriptOffsetPercentage=-28;
814 The percentage of a font height used to calculate its baseline offset for a
815 subscript print position.
819 const TInt KSubscriptOffsetPercentage=14;
825 /** Typeface store abstract base interface.
827 This class provides the interface to a store for typefaces.
833 class CTypefaceStore : public CBase
836 IMPORT_C ~CTypefaceStore();
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 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips()
844 yielding (virtually) the same result. However clients are strongly encouraged to use the new
845 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
846 character within any given text string will fit within the given amount of twips, whereas the design
847 height is an aesthetic unit decided by the font designer without strict physical meaning, which
848 may result in cropped characters.
850 @param aFont On return, contains a pointer to the nearest font.
851 @param aFontSpec The specification of the font to be matched.
852 @return KErrNone if successful; a system-wide error code otherwise.
854 @deprecated Use GetNearestFontToDesignHeightInTwips
856 virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
859 Gets the font which is the nearest to the given font specification.
861 When the font is no longer needed, call @c ReleaseFont().
863 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the
864 same result. However clients are strongly encouraged to use the new
865 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
866 character within any given text string will fit within the given amount of twips, whereas the design
867 height is an aesthetic unit decided by the font designer without strict physical meaning, which
868 may result in cropped characters.
870 @param aFont On return, contains a pointer to the nearest font.
871 @param aFontSpec The specification of the font to be matched.
872 @return KErrNone if successful; a system-wide error code otherwise.
876 virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
879 Gets the font which is the nearest to the given font specification.
881 When the font is no longer needed, call @c ReleaseFont().
883 The font and bitmap server returns a pointer to the nearest matching font
884 from those available. Matches to max height of font - this does its best
885 to return a font that will fit within the maximum height specified (but
886 note that variations due to hinting algorithms may rarely result in this
887 height being exceeded by up to one pixel). Problems can also be
888 encountered with bitmap fonts where the typeface exists but doesn't have
891 @param aFont On return, contains a pointer to the nearest font.
892 @param aFontSpec The specification of the font to be matched.
893 @param aMaxHeight The maximum height within which the font must fit.
894 @return KErrNone if successful; a system-wide error code otherwise.
898 virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) = 0;
900 /** Gets the number of typefaces supported by the typeface store.
902 @return The number of supported typefaces. */
903 virtual TInt NumTypefaces() const=0;
905 /** Gets typeface information for a specified typeface index.
907 This information is returned in aTypefaceSupport, and
908 includes the typeface name and typeface attributes, the number of font
909 heights, the maximum and minimum font heights, and whether it is a
912 @param aTypefaceSupport On return, if the function executed successfully,
913 this object contains the typeface information.
914 @param aTypefaceIndex A typeface index number, in the range: zero to
915 (NumTypefaces() - 1). */
916 virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
918 /** Gets the height of the font with specified height and typeface indices,
921 The value returned is rounded up or down to the nearest font height in twips.
923 @param aTypefaceIndex A typeface index number, in the range: 0 to
924 (NumTypefaces() - 1).
925 @param aHeightIndex A font height index number.
926 @return The height of the font, in twips. */
927 virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
928 IMPORT_C void ReleaseFont(CFont* aFont);
929 IMPORT_C static TInt BaselineOffset(TInt aHeight,TFontPrintPosition aPos);
930 IMPORT_C static TInt SuperSubHeight(TInt aHeight,TFontPrintPosition aPos);
932 IMPORT_C CTypefaceStore();
933 IMPORT_C void ConstructL();
934 IMPORT_C void AddFontL(CFont* aFont);
935 IMPORT_C TBool IncrementFontCount(const CFont* aFont);
937 TBool FindFont(const CFont* aFont, TInt& aIdx) const;
939 NONSHARABLE_CLASS(TFontAccess)
941 Pairs a font with a count of how many clients of the typeface store
942 are accessing that font.
947 /** A device specific font. */
949 /** The number of clients accessing the font. */
953 /** A list of fonts accessed by clients of the typeface store, which pairs
954 a font with a count of the number of clients accessing the font.
956 Implemented as an array of TFontAccess objects.
958 An object is added to this array for every font accessed. If the font is
959 released by all clients, and the access count drops to zero, the font is
960 removed from the list. */
961 CArrayFixFlat<TFontAccess>* iFontAccess;
964 /** The maximum number of entries in the font cache.
967 const TInt KMaxFontCacheEntries=32;
971 When a CFont* needs to be found for a particular TFontSpec, the cache can
972 be searched to see if the TFontSpec is already in the cache. If the TFontSpec
973 is in the cache, its corresponding CFont* can be returned. Otherwise
974 GetNearestFontInTwips() must be used to search all of the available fonts for
975 the nearest CFont- a procedure which takes much longer than a simple cache
978 The current font cache should be destroyed and a new cache created whenever
979 the zoom factor or device map changes, as these changes break the relation
980 between CFont and TFontSpec.
984 class CFontCache : public CBase
987 IMPORT_C CFontCache();
988 IMPORT_C CFontCache(TInt aMaxEntries);
989 IMPORT_C ~CFontCache();
990 IMPORT_C CFont* Search(const TFontSpec& aFontSpec);
991 IMPORT_C CFont* AddEntryL(CFont* aFont,const TFontSpec& aFontSpec);
992 IMPORT_C CFont* RemoveFirstEntry();
994 /** The number of cache hits since the font cache was created i.e.
995 successful results from CFontCache::Search(). */
997 /** The number of cache misses since the font cache was created i.e.
998 unsuccessful results from CFontCache::Search(). */
1001 class CFontCacheEntry : public CBase
1004 CFontCacheEntry(CFont* aFont,const TFontSpec& aFontSpec,CFontCacheEntry* aNext);
1008 CFontCacheEntry* iNext;
1013 CFontCacheEntry* iFirst;
1016 /** Interface class for mapping between twips and device-specific units (pixels).
1018 TZoomFactor is derived from MGraphicsDeviceMap.
1020 @see CGraphicsDevice
1025 class MGraphicsDeviceMap
1028 IMPORT_C MGraphicsDeviceMap();
1029 IMPORT_C virtual ~MGraphicsDeviceMap();
1030 IMPORT_C TPoint TwipsToPixels(const TPoint& aTwipPoint) const;
1031 IMPORT_C TRect TwipsToPixels(const TRect& aTwipRect) const;
1032 IMPORT_C TPoint PixelsToTwips(const TPoint& aPixelPoint) const;
1033 IMPORT_C TRect PixelsToTwips(const TRect& aPixelRect) const;
1035 /** Converts a horizontal dimension from twips to pixels.
1037 An implementation is supplied by a derived class.
1039 @param aTwips A horizontal dimension of a device in twips.
1040 @return A horizontal dimension of a device in pixels. */
1041 virtual TInt HorizontalTwipsToPixels(TInt aTwips) const=0;
1043 /** Converts a vertical dimension from twips to pixels.
1045 An implementation is supplied by a derived class.
1047 @param aTwips A vertical dimension of a device in twips.
1048 @return A vertical dimension of a device in pixels. */
1049 virtual TInt VerticalTwipsToPixels(TInt aTwips) const=0;
1051 /** Converts a horizontal dimension from pixels to twips.
1053 An implementation is supplied by a derived class.
1055 @param aPixels A horizontal dimension of a device in pixels.
1056 @return A horizontal dimension of a device in twips. */
1057 virtual TInt HorizontalPixelsToTwips(TInt aPixels) const=0;
1059 /** Converts a vertical dimension from pixels to twips.
1061 An implementation is supplied by a derived class.
1063 @param aPixels A vertical dimension of a device in pixels.
1064 @return A vertical dimension of a device in twips. */
1065 virtual TInt VerticalPixelsToTwips(TInt aPixels) const=0;
1068 Gets the font which is the nearest to the given font specification.
1070 When the font is no longer needed, call @c ReleaseFont().
1072 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips()
1073 yielding (virtually) the same result. However clients are strongly encouraged to use the new
1074 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
1075 character within any given text string will fit within the given amount of twips, whereas the design
1076 height is an aesthetic unit decided by the font designer without strict physical meaning, which
1077 may result in cropped characters.
1079 @param aFont On return, contains a pointer to the nearest font.
1080 @param aFontSpec The specification of the font to be matched.
1081 @return KErrNone if successful; a system-wide error code otherwise.
1083 @deprecated Use GetNearestFontToDesignHeightInTwips
1085 virtual TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)=0;
1088 Gets the font which is the nearest to the given font specification.
1090 When the font is no longer needed, call @c ReleaseFont().
1092 This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the
1093 same result. However clients are strongly encouraged to use the new
1094 @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every
1095 character within any given text string will fit within the given amount of twips, whereas the design
1096 height is an aesthetic unit decided by the font designer without strict physical meaning, which
1097 may result in cropped characters.
1099 @param aFont On return, contains a pointer to the nearest font.
1100 @param aFontSpec The specification of the font to be matched.
1101 @return KErrNone if successful; a system-wide error code otherwise.
1105 virtual TInt GetNearestFontToDesignHeightInTwips(
1106 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; }
1109 Gets the font which is the nearest to the given font specification.
1111 When the font is no longer needed, call @c ReleaseFont().
1113 The font and bitmap server returns a pointer to the nearest matching font
1114 from those available. Matches to max height of font - this does its best
1115 to return a font that will fit within the maximum height specified (but
1116 note that variations due to hinting algorithms may rarely result in this
1117 height being exceeded by up to one pixel). Problems can also be
1118 encountered with bitmap fonts where the typeface exists but doesn't have
1119 a font small enough.
1121 @param aFont On return, contains a pointer to the nearest font.
1122 @param aFontSpec The specification of the font to be matched.
1123 @param aMaxHeight The maximum height within which the font must fit.
1124 This overrides the height specified in aFontSpec.
1125 @return KErrNone if successful; a system-wide error code otherwise.
1129 virtual TInt GetNearestFontToMaxHeightInTwips(
1130 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; }
1132 /** Releases the specified font.
1134 It is used to indicate that the specified font is no longer needed for use
1135 by the device map. As fonts can be shared between applications, this
1136 function does not delete the copy of the font from RAM unless the font was
1137 only being used by this particular device map.
1139 An implementation is supplied by a derived class.
1141 @param aFont A pointer to the font to be released. */
1142 virtual void ReleaseFont(CFont* aFont)=0;
1145 class CGraphicsContext;
1147 /** Specifies the interface for concrete device classes.
1149 It holds information on the capabilities and attributes of a graphics device.
1150 The CBitmapDevice and CPrinterDevice classes are derived from CGraphicsDevice.
1152 @see CGraphicsDevice
1157 class CGraphicsDevice : public CBase , public MGraphicsDeviceMap
1160 /** Gets the display mode of the device.
1162 @return The display mode of the device. */
1163 virtual TDisplayMode DisplayMode() const=0;
1165 /** Gets the size of the device area in pixels.
1167 @return The width and height of the device area, in pixels */
1168 virtual TSize SizeInPixels() const=0;
1170 /** Gets the size of the device area in twips.
1172 @return The width and height of the device area, in twips */
1173 virtual TSize SizeInTwips() const=0;
1175 /** Creates a graphics context for the device.
1177 @param aGC On return, contains a pointer to the created graphics context.
1178 @return KErrNone, if successful; otherwise, another of the system-wide error
1180 virtual TInt CreateContext(CGraphicsContext*& aGC)=0;
1182 /** Gets the number of typefaces supported by the graphics device.
1184 @return The number of typefaces supported. */
1185 virtual TInt NumTypefaces() const=0;
1187 /** Gets typeface information for a specified typeface.
1189 This information is returned in aTypefaceSupport, and includes:
1191 the typeface name and typeface attributes
1193 the number of font heights
1195 the maximum and minimum font heights
1197 whether it is a scalable typeface
1199 @param aTypefaceSupport On return, contains the typeface information.
1200 @param aTypefaceIndex A typeface index number, in the range: zero to
1201 (NumTypefaces() - 1).
1202 @see NumTypefaces() */
1203 virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
1205 /** Get the height of a font in twips.
1207 The font is identified by typeface and height.
1209 The value returned is rounded up or down to the nearest font height in twips.
1211 @param aTypefaceIndex An index identifying the typeface, in the range: 0
1212 to (NumTypefaces() - 1).
1213 @param aHeightIndex An index identifying the font height, in the range: 0
1214 to (iNumHeights - 1). Note that iNumHeights is in the TTypefaceSupport
1215 object returned by TypefaceSupport().
1216 @return The height of the font, in twips. */
1217 virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
1219 /** Gets the palette attributes of the device.
1221 @param aModifiable On return, holds information on whether or not the device's
1222 palette is modifiable (ETrue) or fixed (EFalse).
1223 @param aNumEntries On return, holds the number of entries in the device's
1225 virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const=0;
1227 /** Sets the device's palette.
1229 @param aPalette The new palette for the device. */
1230 virtual void SetPalette(CPalette* aPalette)=0;
1232 /** Gets the device's current palette.
1234 @param aPalette On return, holds the device's current palette.
1235 @return KErrNone, if successful; otherwise, another of the system-wide error
1237 virtual TInt GetPalette(CPalette*& aPalette) const=0;
1242 Code section range information.
1244 A code section defines the bitmaps for characters in a specified range -
1245 the range is stored in objects of this type.
1247 @deprecated This is not used anywhere in version 6.0.
1252 /** The beginning of the range. */
1254 /** The end of the range. */
1259 UIDs corresponding to the CFont API extension functions
1263 const TUid KFontCapitalAscent = {0x1020498E};
1264 const TUid KFontMaxAscent = {0x10204B10};
1265 const TUid KFontStandardDescent = {0x10204B11};
1266 const TUid KFontMaxDescent = {0x10205AFC};
1267 const TUid KFontLineGap = {0x10204B12};
1271 /** Abstract font interface.
1273 The CFont class provides a device-independent interface to a device-dependent
1274 font usually obtained from a call to GetNearestFont...() on a graphics device.
1275 It is used as a handle in CGraphicsContext::UseFont() and to obtain
1276 device-dependent information about the font - notably the pixel width of a text
1280 @see CGraphicsContext::UseFont()
1284 class CFont : public CBase
1286 friend class CTypefaceStore;
1289 /** Text direction flags.
1291 This enum is used in TMeasureTextInput and determines whether the text is
1292 drawn horizontally or vertically. Note: text is drawn vertically in some
1293 styles of Japanese, etc.
1295 @see TMeasureTextInput */
1298 /** Text is drawn horizontally. */
1299 /** Text is drawn horizontally. */
1301 /** Text is drawn vertically. */
1305 /** Complicated parameter block used for contextual glyph selection,
1306 ligature creation and diacritic placement when drawing text in complex
1309 This class declares a constructor, another scoped class, and several other
1310 enums. However this class is unlikely to be useful to third party developers.
1312 @see CFont::GetCharacterPosition()
1313 @see CFont::GetCharacterPosition2()
1317 class TPositionParam
1320 /** Standard constructor. */
1322 iDirection(EHorizontal),
1331 EMaxInputChars = 18, // ligatures cannot be made from more than 18 components
1332 EMaxOutputGlyphs = 8 // output can consist of up to 8 characters (one base and 7 combining characters)
1335 /**Flags for TPositionParam::iFlags. */
1338 /** Input text is logically ordered not visually ordered. */
1342 /** Input: Orientation (EHorizontal or EVertical) in which to draw
1345 /** Input: Flags from TFlags. */
1347 /** Input: Text containing the characters to be positioned. */
1350 /** Input and output: Position within iText to shape. On exit
1351 it will index the first character not positioned */
1353 /** Input and output: Pen position. */
1356 /** Output of GetCharacterPosition and GetCharacterPosition2.
1357 @see CFont::GetCharacterPosition
1358 @see CFont::GetCharacterPosition2
1364 /** Standard constructor. */
1365 TOutput() : iBitmapSize(TSize::EUninitialized),
1366 iBounds(TRect::EUninitialized) {}
1367 /** Character or glyph code. */
1369 /** Bitmap data for the glyph, if available */
1370 const TUint8* iBitmap;
1371 /** Size of the bitmap before algorithmic bolding, size
1372 multiplication, etc. */
1374 /** Bitmap bounds relative to the original pen position. */
1378 /** Information about the glyphs that were output. */
1379 TOutput iOutput[EMaxOutputGlyphs];
1380 /** Number of glyphs actually output. */
1385 /** Input parameter block.
1387 This is optionally used by CFont::MeasureText(), which is the powerful text
1388 measurement function underlying all the other text measurement functions.
1390 @see CFont::MeasureText()
1394 class TMeasureTextInput
1397 TMeasureTextInput():
1399 iEndInputChar(KMaxTInt),
1400 iDirection(EHorizontal),
1402 iMaxAdvance(KMaxTInt),
1403 iMaxBounds(KMaxTInt),
1411 /**Flags for TMeasureTextInput::iFlags. */
1414 /** Input text is visually ordered left-to-right. */
1416 /** Input text is visually ordered right-to-left.
1417 Overrides EFVisualOrder. */
1418 EFVisualOrderRightToLeft = 2,
1419 /** Flag to consider side bearings when checking bounds for line-break */
1420 EFIncludePenPositionInBoundsCheck = 4
1423 /** Starting index specifying first input character in iText.
1425 Together with iEndInputChar, this allows some context before and
1426 after the measured text to be supplied so that shaping can work
1428 TInt iStartInputChar;
1430 /** Index specifying the final input character.
1432 Together with iStartInputChar, this allows some context before and
1433 after the measured text to be supplied so that shaping can work
1437 /** The direction in which to draw the text. */
1440 /** Flags from TFlags. */
1443 /** The maximum advance. */
1446 /** The maximum width (or height if drawing vertically) of bounds. */
1449 /** The number of glyph groups to be letter-spaced. */
1452 /** The amount of space to be used for letter spacing. */
1453 TInt iCharJustExcess;
1455 /** The number of spaces to be used for word spacing. */
1458 /** The amount of space to be used for word spacing. */
1459 TInt iWordJustExcess;
1462 /** Output parameter block.
1464 This is optionally used by CFont::MeasureText(), which is the powerful text
1465 measurement function underlying all the other text measurement functions.
1467 @see CFont::MeasureText()
1471 class TMeasureTextOutput
1474 /** The number of input characters that would be drawn.
1476 This may be less than the length of the text if a maximum advance or bounding
1477 box size is specified. */
1479 /** The number of glyphs that would be drawn. */
1481 /** The number of groups that would be drawn.
1483 A group is a base glyph plus one or more combining characters. */
1485 /** The number of word spaces (U+0020) that would be drawn. */
1487 /** The bounding box of all the glyphs that would be drawn. */
1489 /** The maximum width and height of any glyph. */
1490 TSize iMaxGlyphSize;
1494 Data availability flags.
1496 Some fonts like printer fonts may only have width information and can return
1497 ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize
1498 the rest of the data if necessary.
1500 @see GetCharacterData()
1504 enum TCharacterDataAvailability
1506 /** No font information available. */
1508 /** Width information only is available. */
1509 ECharacterWidthOnly,
1510 /** All character data is available. */
1515 // virtual functions have been made protected and public non-virtual ones
1516 // added to convert CFont to a handle-body pattern. SC is kept throught the
1517 // new functions and BC is kept by keeping the protected functions in the
1518 // same place in the class, and therefore in the same place in the vtable
1521 This member is internal and not intended for use. Please see derived class for implementation
1524 virtual TUid DoTypeUid() const=0;
1526 This member is internal and not intended for use. Please see derived class for implementation
1529 virtual TInt DoHeightInPixels() const=0;
1531 This member is internal and not intended for use. Please see derived class for implementation
1534 virtual TInt DoAscentInPixels() const=0;
1535 IMPORT_C virtual TInt DoDescentInPixels() const;
1537 This member is internal and not intended for use. Please see derived class for implementation
1540 virtual TInt DoCharWidthInPixels(TChar aChar) const=0;
1542 This member is internal and not intended for use. Please see derived class for implementation
1545 virtual TInt DoTextWidthInPixels(const TDesC& aText) const=0;
1547 This member is internal and not intended for use. Please see derived class for implementation
1550 virtual TInt DoBaselineOffsetInPixels() const=0;
1552 This member is internal and not intended for use. Please see derived class for implementation
1555 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const=0;
1557 This member is internal and not intended for use. Please see derived class for implementation
1560 virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0;
1562 This member is internal and not intended for use. Please see derived class for implementation
1565 virtual TInt DoMaxCharWidthInPixels() const=0;
1567 This member is internal and not intended for use. Please see derived class for implementation
1570 virtual TInt DoMaxNormalCharWidthInPixels() const=0;
1572 This member is internal and not intended for use. Please see derived class for implementation
1575 virtual TFontSpec DoFontSpecInTwips() const=0;
1578 IMPORT_C virtual TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
1579 IMPORT_C virtual TBool DoGetCharacterPosition(TPositionParam& aParam) const;
1580 IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
1583 IMPORT_C virtual ~CFont();
1586 inline TInt FontCapitalAscent() const;
1587 inline TInt FontMaxAscent() const;
1588 inline TInt FontStandardDescent() const;
1589 inline TInt FontMaxDescent() const;
1590 inline TInt FontLineGap() const;
1591 inline TInt FontMaxHeight() const;
1594 /** Gets run-time identity of the actual font type. This enables safe casting to
1597 For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid.
1598 You would need to cast to a CFbsFont to get a character bounding box. Similarly,
1599 a CBitmapFont returns KCBitmapFontUidVal.
1601 @return The font-type identifier. */
1602 IMPORT_C TUid TypeUid() const;
1604 /** Gets the font height in pixels.
1605 Note that this deprecated function is replaced by the new @c FontMaxHeight().
1607 @return The font height in pixels.
1608 @see FontMaxHeight()
1610 IMPORT_C TInt HeightInPixels() const;
1612 /** Gets the font ascent in pixels.
1613 Note that this deprecated function is replaced by the new @c FontMaxAscent()
1614 or in some cases @c FontCapitalAscent().
1616 @return The font ascent in pixels.
1617 @see FontCapitalAscent()
1618 @see FontMaxAscent()
1620 IMPORT_C TInt AscentInPixels() const;
1622 /** Gets the font descent in pixels.
1623 Note that this deprecated function is replaced by the new @c FontMaxDescent()
1624 or in some cases @c FontStandardDescent().
1626 @return The font descent in pixels.
1627 @see FontStandardDescent()
1628 @see FontMaxDescent()
1630 IMPORT_C TInt DescentInPixels() const;
1632 /** Gets the width in pixels in this font of the specified character.
1634 Note: For OpenType fonts this function returns the horizontal advance of
1635 the character, which may be different from the actual width.
1637 @param aChar The character whose width should be determined.
1638 @return The width in pixels of the specified character in this font. */
1639 IMPORT_C TInt CharWidthInPixels(TChar aChar) const;
1641 /** Gets the width in pixels of the specified descriptor when displayed in this
1644 @param aText The descriptor whose width should be determined.
1645 @return The width of the specified descriptor when displayed in this font,
1647 IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const;
1649 /** Gets the baseline offset in pixels.
1651 The baseline offset is how far a font is raised or lowered from its normal
1654 @return Offset from normal baseline, in pixels. */
1655 IMPORT_C TInt BaselineOffsetInPixels() const;
1657 /** Gets how much of the specified descriptor can be displayed in this font without
1658 exceeding the specified width.
1662 This function does not display any of the descriptor itself - it is used
1663 before display, to test whether the whole descriptor can be displayed.
1665 @param aText The descriptor.
1666 @param aWidthInPixels The available width for character display.
1667 @return The number of characters which will be able to be displayed without
1668 exceeding the specified width. The count starts from the beginning of the
1670 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const;
1672 /** Gets how much of the specified descriptor can be displayed in this font without
1673 exceeding the specified width.
1675 It also returns the excess width - defined as the specified available width
1676 minus the width of the portion of the descriptor which can be displayed without
1677 exceeding the available width.
1679 @param aText The descriptor.
1680 @param aWidthInPixels The available width for character display.
1681 @param aExcessWidthInPixels The excess width after displaying the portion of
1682 the descriptor, in pixels.
1683 @return The number of characters which will be able to be displayed without
1684 exceeding the specified width. The count starts from the beginning of the
1686 IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
1688 /** Gets the width in pixels of the widest character in this font.
1690 @return The width of the maximum width character, in pixels. */
1691 IMPORT_C TInt MaxCharWidthInPixels() const;
1693 /** Gets the width in pixels of the widest normal character in this font.
1695 Normal characters include all character in a character set except non-alphabetic
1696 characters (e.g. the copyright symbol, or a block graphics symbol, for example).
1698 @return The width of the maximum width normal character, in pixels. */
1699 IMPORT_C TInt MaxNormalCharWidthInPixels() const;
1701 /** Gets the font specification of this font in twips.
1703 @return The font specification of this font (in twips). */
1704 IMPORT_C TFontSpec FontSpecInTwips() const;
1705 IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
1706 IMPORT_C TBool GetCharacterPosition(TPositionParam& aParam) const;
1707 IMPORT_C TInt WidthZeroInPixels() const;
1708 IMPORT_C TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL, TMeasureTextOutput* aOutput = NULL) const;
1709 IMPORT_C static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter);
1710 IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
1711 IMPORT_C TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const;
1716 /** Abstract base class for all graphics contexts.
1718 Created by a CGraphicsDevice.
1720 Provides the 'context' in which you are drawing to an associated device, in
1721 the sense that it holds the settings for drawing, such as the pen and brush
1722 settings (e.g. color, line styles) and the font settings (e.g. bold, underline,
1723 italic). These settings are device-independent.
1725 Also provides the clipping region (the visible drawing area).
1727 The settings and clipping area can be updated while drawing.
1729 This class also contains the main drawing functions, and all drawing is done
1730 through a CGraphicsContext.
1732 The graphics context deals with pixels of device-dependent size and uses fonts
1733 with device-dependent size and representation. The sizes and fonts to be passed
1734 to the class functions therefore need to be converted from size-independent
1735 units to size-dependent units first. This is done by an MGraphicsDeviceMap
1736 derived class. This may be a TZoomFactor or the CGraphicsDevice.
1738 See CGraphicsContext::Reset() for the default graphics context settings immediately
1745 class CGraphicsContext : public CBase
1756 /** Text is left-aligned. */
1758 /** Text is centred. */
1760 /** Text is right-aligned. */
1765 Drawing mode components.
1766 This enum is not intended to be used directly, but provides components for
1767 the easy specification of drawing modes in the TDrawMode enum.
1771 enum TDrawModeComponents
1795 This enum builds on the drawing mode components in the TDrawModeComponents
1798 If the pen colour is p, brush colour is b and screen colour is s, the effect
1799 of TDrawMode::EDrawModeAND is P=p&s and B=b&s. In other words, the effective
1800 colour of the pen on the screen, P, is that produced by the bitwise ANDing
1801 of the current screen colour and the current pen colour. The effect is similar
1802 for the effective brush colour, B.
1804 The effective pen and brush colour are given in the table using the key
1805 Inputs: pen colour is p, brush colour is b and screen colour is s
1806 Outputs: effective brush colour is B, effective pen colour is P.
1808 Some notes on using EDrawModeWriteAlpha:-
1810 - It is rare for client code to need to use this draw mode: see the documentation
1811 of SetDrawMode() for more information.
1812 - EDrawModeWriteAlpha should only be used with DrawRect(), Clear(), BitBlt(), and BitBltMasked()
1813 with EGray2 mask (and DrawBitmap() and DrawBitmapMasked()). For other draw operations, it is not
1814 supported, and may have unintended effects.
1815 - EDrawModeWriteAlpha has the same effect as EDrawModePEN, unless the brush colour has transparency
1816 (DrawRect(), Clear()), or the source bitmap is EColor16MA (and has transparency) (BitBlt(), BitBltMasked())
1817 - EDrawModeWriteAlpha has the same effect as EDrawModePEN if the draw mode of the destination does not
1818 support alpha blending. (Blending is only supported in 24bpp and 32bpp colour i.e. EColor16M, EColor16MU, EColor16MA)
1819 - In these cases, EDrawModePEN does alpha blending, whereas EDrawModeWriteAlpha means don't do alpha blending.
1827 /** Bitwise ANDs the pen and brush colours with the screen colour.
1830 /** Inverts the pen and brush colours before ANDing. P=(~p)&s,
1832 EDrawModeNOTAND=EInvertScreen|EAnd,
1833 /** Uses both pen and brush colour as they are. P=p, B=b */
1834 EDrawModePEN=EPenmode,
1835 /** Inverts the screen colour before ANDing. P=p&(~s), B=b&(~s) */
1836 EDrawModeANDNOT=EAnd|EInvertPen,
1837 /** Bitwise XORs the pen and brush colours with the screen colour.
1840 /** Bitwise ORs the pen and brush colours with the screen colour.
1843 /** Inverts the screen and pen and brush colours before ANDing.
1844 P=(~p)&(~s), B=(~b)&(~s) */
1845 EDrawModeNOTANDNOT=EInvertScreen|EAnd|EInvertPen,
1846 /** Inverts the pen and brush colours before XORing. P=(~p)^s,
1848 EDrawModeNOTXOR=EInvertScreen|EXor,
1849 /** Inverts the colour of each pixel that is drawn over, (pen and
1850 brush attributes are ignored). P=~s, B=~s */
1851 EDrawModeNOTSCREEN=EInvertScreen,
1852 /** Inverts the pen and brush colours before ORing. P=(~p)|s,
1854 EDrawModeNOTOR=EInvertScreen|EOr,
1855 /** Inverts the pen and brush colours. P=~p, B=~b */
1856 EDrawModeNOTPEN=EInvertPen|EPenmode,
1857 /** Inverts the screen, pen and brush colours before ORing. P=p|(~s),
1859 EDrawModeORNOT=EOr|EInvertPen,
1860 /** NOT OR NOT mode. P=(~p)|(~s), B=(~b)|(~s) */
1861 EDrawModeNOTORNOT=EInvertScreen|EOr|EInvertPen,
1862 /** Writes alpha information in the source directly into the destination, rather than blending. */
1863 EDrawModeWriteAlpha=EWriteAlpha,
1867 Pen styles. The screen pattern unit in each definition below describes the
1868 pattern drawn by the line 1 represents a pixel drawn, 0 represents a
1869 pixel that is not affected.
1875 /** The pen does not draw. Screen pattern unit = 00... */
1877 /** A solid line (default). Screen pattern unit = 11... */
1879 /** A dotted line. Screen pattern unit = 1000... */
1881 /** A dashed line. Screen pattern unit = 111000... */
1883 /** A line of alternating dashes and dots. Screen pattern unit =
1886 /** A line of alternating single dashes and pairs of dots. Screen
1887 pattern unit = 11110011001100... */
1898 /** The brush fill has no effect (default). */
1900 /** The brush fills with a solid single colour, determined by
1901 SetBrushColor() and the drawing mode. */
1903 /** The brush fills with a selected bitmap pattern, set by
1904 UseBrushPattern(). */
1906 /** The brush fills with vertical hatching lines going from top to
1908 EVerticalHatchBrush,
1909 /** The brush fills with diagonal hatching lines going from bottom
1910 left to top right. */
1911 EForwardDiagonalHatchBrush,
1912 /** The brush fills with horizontal hatching lines going from left
1914 EHorizontalHatchBrush,
1915 /** The brush fills with rearward diagonal hatching lines going from top
1916 left to bottom right. */
1917 ERearwardDiagonalHatchBrush,
1918 /** The brush fills with horizontal and vertical hatching lines going
1919 from left to right plus lines going from top to bottom giving the
1920 effect of a grid of small squares */
1921 ESquareCrossHatchBrush,
1922 /** The brush fills with forward diagonal and rearward diagonal hatching
1923 lines going from bottom left to top right plus lines going from top left
1924 to bottom right giving the effect of a grid of small diamonds. */
1925 EDiamondCrossHatchBrush
1929 Rules used to fill self crossing polygons.
1931 The filling of a polygon proceeds as follows: for a given point in the
1934 if the rule is TFillRule::EAlternate (default) and it has an odd winding
1935 number, then fill the surrounding area.
1937 if the rule is TFillRule::EWinding and it has a winding number greater than
1938 zero, then fill the surrounding area.
1944 /** Only fill areas with odd winding numbers. */
1946 /** Fill areas with winding numbers greater than zero. */
1950 /** Parameters to control the drawing of text. */
1951 struct TDrawTextParam
1955 iDirection(CFont::EHorizontal),
1960 /** Reserved for future use. */
1963 /** the direction in which to draw the text. */
1964 CFont::TTextDirection iDirection;
1965 /** number of glyph groups to be letterspaced */
1967 /** amount of space to be used for letterspacing */
1968 TInt iCharJustExcess;
1969 /** number of spaces to be used for wordspacing*/
1971 /** amount of space to be used for wordspacing*/
1972 TInt iWordJustExcess;
1976 /** Parameters for extended text drawing and measuring. It is used by
1977 CGraphicsContext::DrawTextExtended() to indicate whether text should be
1978 drawn from right-to-left or left-to-right. */
1979 struct TDrawTextExtendedParam : public TDrawTextParam
1982 /** Constructor. Initialises iParRightToLeft to EFalse. */
1983 TDrawTextExtendedParam():
1984 iParRightToLeft(EFalse)
1987 /** ETrue if the text direction is right-to-left (for scripts like
1988 Arabic and Hebrew). EFalse if left-to-right. */
1989 TBool iParRightToLeft;
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 region. The default
2060 clipping rectangle is the full device area.
2062 @param aRect The clipping rectangle. */
2063 virtual void SetClippingRect(const TRect& aRect)=0;
2065 /** Cancels any clipping rectangle.
2067 Clipping thus reverts to the full device area, the default.
2069 @see SetClippingRect() */
2070 virtual void CancelClippingRect()=0;
2072 /** Resets the graphics context to its default settings:
2074 the drawing mode is TDrawMode::EDrawModePen (pen and brush colours used as
2077 there is no clipping rectangle
2079 the pen settings are: black, solid, single pixel size
2081 the brush style is null
2083 no text font is selected */
2084 virtual void Reset()=0;
2086 /** Sets the device font to be used for text drawing.
2088 If the font is already in memory, then that copy is shared.
2092 The CFont* argument must have been previously initialised by calling
2093 MGraphicsDeviceMap::GetNearestFontInTwips() with the required
2094 font-specification. If the CFont* has not been initialised
2095 correctly, and therefore does not point to an available font-bitmap,
2096 then a panic is raised.
2098 When the font is no longer required, use DiscardFont() to free up the
2099 memory used. If UseFont() is used again without using DiscardFont() then
2100 the previous font is discarded automatically.
2102 If no font has been selected, and an attempt is made to draw text with
2103 DrawText(), then a panic is raised.
2105 @param aFont A device font
2106 @see MGraphicsDeviceMap::GetNearestFontInTwips() */
2107 virtual void UseFont(const CFont* aFont)=0;
2109 /** Discards a font.
2111 This frees up the memory used, if the font is not being shared.
2113 The function can be called when no font is in use. */
2114 virtual void DiscardFont()=0;
2116 /** Sets the underline style.
2118 This is applied to all subsequently drawn text.
2120 @param aUnderlineStyle The underline style on or off. */
2121 virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle)=0;
2123 /** Sets the strikethrough style.
2125 This is applied to all subsequently drawn text.
2127 @param aStrikethroughStyle The strikethrough style on or off. */
2128 virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)=0;
2129 IMPORT_C static TInt JustificationInPixels(TInt aExcessPixels,TInt aTotalUnits,TInt aFirstUnit,TInt aNumUnits);
2130 IMPORT_C static TInt JustificationInPixels(TInt& aExcessPixels,TInt& aTotalUnits);
2132 /** Adjusts the spaces between words to stretch or squeeze to a certain
2135 The function is required by the Text Views API, and is not intended for
2136 regular use by developers.
2138 The text line that is to be justified has a certain number of gaps (spaces)
2139 between the words. It also has a distance (in pixels) between the end of
2140 the last word and the actual end of the line (right hand margin, usually).
2141 These excess width pixels are distributed amongst the gaps between the words
2142 to achieve full justification of the text line. Spaces become fat spaces to
2143 keep underlining/strikethrough consistent. Pixels are distributed to the
2144 inter-word gaps starting from the left end of the string. The spacing
2145 between characters in each word remains unchanged.
2147 After a call to SetWordJustification(), subsequent calls to either of the
2148 two DrawText() functions are affected until the number of spaces specified
2149 by aNumSpaces is used up.
2151 The easiest way to find out the excess width and number of spaces is to call
2152 CFont::MeasureText(). This function can also perform counting, which is
2153 finding how much of some text will fit into a given width.
2155 Use CFont::TextCount() to return the excess width.
2157 For example, in the string "To be, or not to be", there are five inter-word
2158 gaps. If there are six excess pixels they will be distributed in the
2159 proportion 2, 1, 1, 1, 1 between the words. If there are nine excess pixels
2160 they will be distributed in the proportion 2, 2, 2, 2, 1 between the words.
2164 If the excess width is zero, then calling SetWordJustification() has no
2167 At first sight it may appear that SetWordJustification() is not required
2168 because you can simply call DrawText() for each word. However, underlined
2169 justified text does not work using this strategy you get a non-underlined
2170 gap between the space and the beginning of the next word.
2172 @param aExcessWidth The width (in pixels) to be distributed between the
2173 specified number of spaces. It may be positive, in which case the text is
2174 stretched, or negative, in which case it is shrunk.
2175 @param aNumGaps The number of word spaces (characters with the code U+0020)
2176 over which the change in width is distributed. */
2177 virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps)=0;
2179 /** Sets character justification.
2181 This function is required by the Text Views API, and is not intended for
2182 regular use by developers.
2184 It affects the strings of text used in the calls to DrawText() that follow,
2185 until the number of characters drawn equals aNumChars.
2187 The text line that is to be justified has a certain number of characters
2188 this includes the spaces between the words. It also has a distance (in
2189 pixels) between the end of the last word and the actual end of the line
2190 (right hand margin, usually). These excess width pixels are distributed
2191 amongst all the characters, increasing the gaps between them, to achieve
2192 full justification of the text line.
2194 Use CFont::TextCount() to return the excess width.
2198 This function is provided to allow simulation of printer fonts on screen.
2199 Due to the fact that fully-scalable fonts are not used before v5, large
2200 printer fonts can be simulated by using the nearest smaller font and
2201 widening it slightly.
2203 If the excess width is zero, then calling SetCharJustification() has no
2206 SetCharJustification() is required for WYSIWYG where the layout uses
2207 printer font metrics but screen fonts have to be drawn on the screen.
2208 Because continuously scalable typefaces (c.f. TrueType) are not used
2209 before v5 and because screen fonts are coarser and less numerous in
2210 their variety than the printer fonts, the best matching smaller screen
2211 font must be used with character justification to simulate the printer
2214 There is also a situation where the gaps between characters on screen have
2215 to be reduced with character clipping. The screen font that best matches
2216 the printer font may have the required height, but has characters that are
2217 too wide. A line of text that works on the printer will then be too long
2218 on the screen, unless it is squashed horizontally. The number of pixels
2219 that overlap the end of the screen line must now be removed from the gaps
2220 between the characters, i.e. there is a negative excess width. This
2221 situation is especially important where adding a TAB on screen gives
2222 perfectly acceptable printout, but would push the last character of the
2223 line off the right hand side of the screen.
2225 In practice what you do in printer layout mode is:
2227 Calculate where the line breaks will come on the printer. To do this you
2228 use a printer font (which in practice means a table of character widths
2229 of the font that the printer will use).
2231 Now change to use a screen font that is the closest font which is no taller
2232 that the printer font. In practice it will often be fatter maybe only for
2233 certain characters such as 'i'.
2235 You have to recalculate the width of the characters using the screen fonts.
2236 You can do this using CFont::TextWidth() as you have already determined how
2237 many characters will fit on the line.
2239 If, in the screen font, the characters are not as wide as the line then you
2240 can just use word justification to expand the line. You would only do this
2241 if the text is to be justified.
2243 If, however, the characters are wider than the line then you would use
2244 character justification to clip each character. You would need to do this
2245 even if the line is not justified.
2247 Thus, in practice, character justification will only very rarely be used to
2248 expand a line of characters.
2250 @param aExcessWidth The excess width (in pixels) to be distributed between
2251 the specified number of characters.
2252 @param aNumChars The number of characters involved. */
2253 virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars)=0;
2255 /** Sets the pen colour.
2257 The effective pen colour depends on the drawing mode. The default pen colour
2262 The pen is used to draw lines, the outlines of filled shapes, and text. The
2263 class provides member functions to set the colour of the pen, the style of
2264 line and the line size drawn.
2266 @param aColor An RGB colour for the pen.
2267 @see CGraphicsContext::SetDrawMode() */
2268 virtual void SetPenColor(const TRgb& aColor)=0;
2270 /** Sets the line drawing style for the pen.
2272 There are 6 pen styles. If no pen style is set, then the default is
2273 TPenStyle::ESolidPen. To use a pen style, its full context must be given,
2274 e.g. for a null pen:
2276 CGraphicsContext::TPenStyle::ENullPen
2279 The pen is used to draw lines, the outlines of filled shapes, and text.
2280 CGraphicsContext member functions are provided to set the colour of the
2281 pen, the style of line and the line size drawn.
2283 The TPenStyle::ENullPen style should be used if a border is not required
2284 around a filled shape.
2286 Dotted and dashed pen styles have a device dependant implementation, always
2287 give single-pixel size lines on the screen whatever the pen size set
2288 by SetPenSize() and can only be used for straight lines, polylines,
2289 non-rounded rectangles and polygons.
2291 The dotted/dashed pattern is continued, without re-starting, for all
2292 consecutively drawn straight lines, i.e.
2294 the outlines of rectangles the pattern starts in the top left corner.
2295 It is reset at the end of the function call.
2297 the outlines of polygons the pattern starts at the first point. It is
2298 reset at the end of the function call.
2300 polylines and straight lines the pattern starts at the first point
2301 initially. Consecutive calls to DrawLine() and/or DrawPolyLine(), whether
2302 the lines are concatenated or not, continue the pattern. It can be reset
2303 by a further call to SetPenStyle() using the same dotted/dashed style
2306 @param aPenStyle A pen style.
2307 @see CGraphicsContext::TPenStyle */
2308 virtual void SetPenStyle(TPenStyle aPenStyle)=0;
2310 /** Sets the line drawing size for the pen.
2312 Lines of size greater than one pixel:
2314 are drawn with rounded ends that extend beyond the end points, (as if the
2315 line is drawn using a circular pen tip of the specified size).
2317 are always drawn in TDrawMode::EDrawModePEN mode, overriding whatever mode
2318 has been set using SetDrawMode().
2322 The pen is used to draw lines, the outlines of filled shapes, and text. The
2323 class provides member functions to set the colour of the pen, the style of
2324 line and the line size drawn.
2326 Wide straight lines and arcs have rounded ends so that concatenated wide
2327 lines have smoothly rounded corners at the vertexes.
2329 When lines are made wide, the extra strips of pixels are added equally to
2330 both sides of the line. This works precisely for lines of odd pixel size
2331 (3, 5, 7, etc.). Wide lines of even pixel size, (2, 4, 6, etc.),
2332 have the extra strip of pixels added to the right and/or below the line.
2334 Wide outlines of ellipses and wide line arcs are drawn with the pixels
2335 distributed either side of a thin (single pixel wide) true ellipse
2336 constructed in the normal manner. Wide ellipses and arcs of even pixel
2337 size have the extra strip of pixels added to the right and/or below the
2338 curved line. This gives a slight asymmetry to ellipses.
2340 If the pen style is dotted or dashed, the size specification is ignored: a
2341 single-pixel wide primitive is drawn, (this is device dependant).
2343 A line size of zero is handled as if the pen style had been set to
2344 TPenStyle::ENullPen.
2346 @param aSize A line size. The default is 1 pixel. */
2347 virtual void SetPenSize(const TSize& aSize)=0;
2349 /** Sets the brush colour.
2351 The effective brush colour depends on the drawing mode.
2355 The brush is used for filling shapes and the background of text boxes. The
2356 brush has colour, style, pattern and pattern origin parameters.
2358 If no brush colour has been set, it defaults to white. However the default
2359 brush style is null, so when drawing to a window the default appears to be
2360 the window's background colour.
2362 @param aColor An RGB colour for the brush.
2363 @see SetDrawMode() */
2364 virtual void SetBrushColor(const TRgb& aColor)=0;
2366 /** Sets the brush style.
2368 Ten brush styles are provided, including six built-in hatching patterns.
2369 Note: The brush is used for filling shapes and the background of text boxes.
2370 The brush has colour, style, pattern and pattern origin parameters.
2371 Note: Use TBrushStyle::ENullBrush to draw the outline of a fillable
2372 shape on its own, without filling.
2373 Note: If the TBrushStyle::EPatternedBrush style is set, but no bitmap
2374 pattern has been selected using UseBrushPattern(), then the function panics.
2375 Note: Hatching lines are done in the current pen colour, set using SetPenColor().
2376 The hatching pattern starts at the brush origin, set using SetBrushOrigin().
2377 @see TBrushStyle::ENullBrush
2378 @see TBrushStyle::EPatternedBrush
2379 @see UseBrushPattern()
2381 @see SetBrushOrigin()
2384 @param aBrushStyle A brush style. */
2385 virtual void SetBrushStyle(TBrushStyle aBrushStyle)=0;
2387 /** Sets the brush pattern origin.
2389 This specifies the top left-hand corner position for the pattern tile around
2390 which copies of the pattern are tiled.
2392 The brush pattern may be a built-in style, or a bitmap. To use a bitmap, the
2393 brush must have a pattern set and the brush style must be set to
2394 TBrushStyle::EPatternedBrush.
2398 The brush is used for filling shapes and the background of text boxes. The
2399 brush has colour, style, pattern and pattern origin parameters.
2401 If SetBrushOrigin() is not used, then the origin defaults to (0,0).
2403 This brush origin remains in effect for all fillable shapes drawn
2404 subsequently, until a new brush origin is set. Shapes can thus be
2405 considered as windows onto a continuous pattern field (covering the whole
2406 clipping region of a screen device, or the whole device area of a printer).
2408 @param aOrigin An origin point for the brush. The coordinates are relative
2409 to the rectangle to fill, i.e. specify 0,0 to align the pattern flush with
2410 the top and left hand sides of the rectangle.
2411 @see SetBrushStyle()
2412 @see UseBrushPattern() */
2413 virtual void SetBrushOrigin(const TPoint& aOrigin)=0;
2415 /** Sets the brush pattern to the specified bitmap.
2417 For the brush to actually use the bitmap, TBrushStyle::EPatternedBrush must
2418 be used to set the brush style.
2420 When the brush pattern is no longer required, use DiscardBrushPattern() to
2421 free up the memory used, if the bitmap is not being shared.
2422 If UseBrushPattern() is used again without using DiscardBrushPattern()
2423 then the previous pattern is discarded automatically.
2427 The brush is used for filling shapes and the background of text boxes. The
2428 brush has colour, style, pattern and pattern origin parameters.
2430 When loading a bitmap, the bitmap is checked to see if it is already in
2431 memory. If the bitmap is already there, then that copy is shared.
2433 The brush does not need to have a pattern set at all. There are several
2434 built-in hatching patterns which can be selected using SetBrushStyle().
2436 @param aBitmap A bitmap pattern for the brush.
2437 @see SetBrushStyle() */
2438 virtual void UseBrushPattern(const CFbsBitmap* aBitmap)=0;
2440 /** Discards a non-built-in brush pattern.
2442 This frees up the memory used by the bitmap, if it is not being shared by
2447 The brush is used for filling shapes and the background of text boxes. The
2448 brush has colour, style, pattern and pattern origin parameters.
2450 If DiscardBrushPattern() is used, with no brush pattern set, then there is
2452 virtual void DiscardBrushPattern()=0;
2455 /** Sets the drawing point relative to the co-ordinate origin.
2457 A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing
2458 point as the start point for the line drawn.
2462 The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline()
2463 also change the internal drawing position to the last point of the drawn
2466 The internal drawing position is set to the co-ordinate origin if no drawing
2467 or moving operations have yet taken place.
2469 @param aPoint The new internal drawing position. */
2470 virtual void MoveTo(const TPoint& aPoint)=0;
2472 /** Sets the drawing point relative to the current co-ordinates.
2474 A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing point
2475 as the start point for the line drawn.
2479 The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline()
2480 also change the internal drawing position to the last point of the drawn
2483 The internal drawing position is set to the co-ordinate origin if no drawing
2484 or moving operations have yet taken place.
2486 @param aVector The amount by which the internal drawing position is to move. */
2487 virtual void MoveBy(const TPoint& aVector)=0;
2489 /** Draws a single point. The point is drawn with the current pen settings
2490 using the current drawing mode.
2494 If the pen size is greater than one pixel, a filled circle of the current
2495 pen colour is drawn, with the pen size as the diameter and the plotted point
2496 as the centre. If the pen size is an even number of pixels, the extra pixels
2497 are drawn below and to the right of the centre.
2499 @param aPoint The point to be drawn.
2500 @see SetPenSize() */
2501 virtual void Plot(const TPoint& aPoint)=0;
2505 The arc is considered a portion of an ellipse. The ellipse is defined by the
2508 The pixels at both the start point and the end point are drawn.
2510 The arc itself is the segment of the ellipse drawn in an anti-clockwise
2511 direction from the start point to the end point.
2515 A rectangle is used in the construction of the ellipse of which the arc is
2516 a segment. This rectangle is passed as an argument of type TRect.
2518 A wide line arc is drawn with the pixels distributed either side of a true
2519 ellipse, in such a way that the outer edge of the line would touch the edge
2520 of the construction rectangle. In other words, the ellipse used to
2521 construct it is slightly smaller than that for a single pixel line size.
2523 If the specified start or end point is at the centre of the ellipse, then
2524 the line that defines the start or end of the arc defaults to one extending
2525 vertically above the centre point.
2527 If the start and end point are the same point or are points on the same line
2528 through the ellipse centre then a complete unfilled ellipse is drawn.
2530 @param aRect A rectangle in which to draw the ellipse, of which the arc is
2532 @param aStart The point defining the start of the arc. It defines one end of
2533 a line from the geometric centre of the ellipse. The point of intersection
2534 between this line and the ellipse defines the start point of the arc.
2535 @param aEnd The point defining the end of the arc. It defines one end of a
2536 second line from the geometric centre of the ellipse. The point of
2537 intersection between this line and the ellipse defines the end point of the
2539 @see DrawEllipse() */
2540 virtual void DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0;
2542 /** Draws a straight line between two points.
2544 @param aPoint1 The point at the start of the line.
2545 @param aPoint2 The point at the end of the line. */
2546 virtual void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)=0;
2548 /** Draws a straight line from the current drawing point to a specified
2551 @param aPoint The point at the end of the line.
2554 virtual void DrawLineTo(const TPoint& aPoint)=0;
2556 /** Draws a straight line relative to the current drawing point, using a
2559 The start point of the line is the current drawing point. The specified
2561 is added to the drawing point to give the end point of the line
2563 @param aVector The vector to add to the current internal drawing position,
2564 giving the end point of the line.
2567 virtual void DrawLineBy(const TPoint& aVector)=0;
2569 /** Draws a polyline from a set of points in an array.
2571 A polyline is a series of concatenated straight lines joining a set of
2574 @param aPointList An array containing the points on the polyline. */
2575 virtual void DrawPolyLine(const CArrayFix<TPoint>* aPointList)=0;
2577 /** Draws a polyline from a set of points in a list.
2579 A polyline is a series of concatenated straight lines joining a set of
2582 @param aPointList Pointer to a set of points on the polyline.
2583 @param aNumPoints Number of points in the list. */
2584 virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)=0;
2586 /** Draws and fills a pie slice.
2588 The pie slice is an area bounded by:
2590 the arc of an ellipse drawn in an anticlockwise direction from the start
2591 point to the end point
2593 the straight line drawn to the start point from the geometric centre of the
2596 the straight line to the end point from the geometric centre of the ellipse.
2600 A rectangle is used in the construction of the pie slice. This rectangle is
2601 passed as an argument of type TRect. The curved edge of the pie slice is an
2602 arc of an ellipse constructed within the rectangle.
2604 The line drawn by the pen goes inside the specified rectangle.
2606 The pixels at the end point of the arc are not drawn.
2608 A wide line edged pie slice has the arc drawn with the pixels distributed
2609 either side of a true ellipse. This is done in such a way that the outer
2610 edge of the line touches the edge of the construction rectangle. In other
2611 words, the ellipse used to construct it is slightly smaller than that for
2612 a single pixel line size.
2614 If the specified start or end point is at the centre of the ellipse, then
2615 the line that defines the start or end of the arc defaults to one extending
2616 vertically above the centre point.
2618 If the start and end point are the same point or are points on the same line
2619 through the ellipse centre then a complete filled ellipse is drawn. A line
2620 is also drawn from the edge to the ellipse centre.
2622 @param aRect A rectangle in which to draw the ellipse bounding the pie slice.
2623 @param aStart A point defining the start of the arc bounding the pie slice.
2624 It defines one end of a line from the geometrical centre of the ellipse. The
2625 point of intersection between this line and the ellipse defines the start
2627 @param aEnd A point to define the end of the arc bounding the pie slice. It
2628 defines one end of a second line from the geometrical centre of the ellipse.
2629 The point of intersection between this line and the ellipse defines the end
2630 point of the arc. */
2631 virtual void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0;
2633 /** Draws and fills an ellipse.
2635 The ellipse is drawn inside the rectangle defined by the TRect argument. Any
2636 rectangle that has odd pixel dimensions, has the bottom right corner trimmed
2637 to give even pixel dimensions before the ellipse is constructed.
2641 A wide outline ellipse is drawn with the pixels distributed either side of
2642 a true ellipse, in such a way that the outer edge of the line touches the
2643 edge of the construction rectangle. In other words, the ellipse used to
2644 construct it is smaller than that for a single pixel line size.
2646 @param aRect The rectangle in which the ellipse is drawn. */
2647 virtual void DrawEllipse(const TRect& aRect)=0;
2649 /** Draws and fills a rectangle.
2651 @param aRect The rectangle to be drawn. */
2652 virtual void DrawRect(const TRect& aRect)=0;
2654 /** Draws and fills a rectangle with rounded corners.
2656 The rounded corners are each constructed as an arc of an ellipse.
2658 The line drawn by the pen, if any, goes inside the specified rectangle.
2662 Dotted and dashed pen styles cannot be used for the outline of a rounded
2665 If either corner size dimension is greater than half the corresponding
2666 rectangle length, the corner size dimension is reduced to half the
2669 @param aRect The rectangle to be drawn.
2670 @param aCornerSize The dimensions of each corner.
2672 virtual void DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)=0;
2674 /** Draws and fills a polygon defined using an array of points.
2676 The first point in the array defines the start of the first side of the
2677 polygon. The second point defines the second vertex (the end point of the
2678 first side and the start point of the second side).
2680 The final side of the polygon is drawn using the last point from the array,
2681 and the line is drawn to the start point of the first side.
2683 Self-crossing polygons are filled according to the specified fill rule.
2685 @param aPointList An array of points, specifying the vertices of the polygon.
2686 @param aFillRule The fill rule. By default, this is TFillRule::EAlternate.
2687 @return KErrNone, if successful; otherwise, another of the system-wide error
2689 virtual TInt DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule=EAlternate)=0;
2691 /** Draws and fills a polygon defined using a list of points.
2693 The first point in the list defines the start of the first side of the
2694 polygon. The second point defines the second vertex (the end point of the
2695 first side and the start point of the second side).
2697 The final side of the polygon is drawn using the last point from the list,
2698 and the line is drawn to the start point of the first side.
2700 Self-crossing polygons are filled according to the specified fill rule.
2702 @param aPointList Pointer to list of points, specifying the vertices of the
2704 @param aNumPoints The number of points in the list.
2705 @param aFillRule The fill rule. By default this is TFillRule::EAlternate.
2706 @return KErrNone, if successful; otherwise, another of the system-wide error
2708 virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate)=0;
2710 /** Draws a bitmap at the specified point.
2712 The point specifies the top left hand corner of the bitmap. The bitmap is
2713 compressed or stretched based on its internally stored size in twips.
2717 This member function uses the bitmap's size in twips and does a
2718 stretch/compress blit using a linear DDA.
2720 As this function scales the bitmap, it is unavoidably slow. Therefore, where
2721 possible, use CBitmapContext::BitBlt() instead. If the bitmap has to be
2722 scaled, consider creating another bitmap along with an CFbsBitmapDevice etc,
2723 doing DrawBitmap() once and using BitBlt() subsequently.
2725 Note that all bitmaps are clipped to the device boundaries.
2727 @param aTopLeft The point where the top left pixel of the bitmap is to be
2729 @param aSource A source bitmap
2731 virtual void DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource)=0;
2733 /** Draws a bitmap to fit a given rectangle.
2735 The bitmap is compressed or stretched based on its internally stored size
2740 This member function uses the bitmap's size in pixels and does a
2741 stretch/compress blit using a linear DDA.
2743 As this function scales the bitmap, it is unavoidably slow. Therefore,
2744 where possible, use CBitmapContext::BitBlt() instead. If the bitmap has
2745 to be scaled, consider creating another bitmap along with an
2746 CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt()
2749 Note that all bitmaps are clipped to the device boundaries.
2751 @param aDestRect The rectangle within which the bitmap is to be drawn.
2752 @param aSource A source bitmap.
2754 virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)=0;
2756 /** Draws a specified rectangle of a source bitmap to fit into a given
2757 destination rectangle.
2761 This member function uses rectangle sizes in pixels and does a
2762 stretch/compress blit using a linear DDA.
2764 As this function scales the bitmap, it is unavoidably slow. Therefore,
2765 where possible, use CBitmapContext::BitBlt() instead. If the bitmap has
2766 to be scaled, consider creating another bitmap along with an
2767 CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt()
2770 Note that all bitmaps are clipped to the device boundaries.
2772 @param aDestRect The rectangle within which the bitmap is to be drawn.
2773 @param aSource A source bitmap.
2774 @param aSourceRect The rectangle in the source bitmap that is copied to the
2775 destination rectangle.
2777 virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect)=0;
2779 /** Draws a specified rectangle of a source bitmap to fit into a given rectangle using a given mask.
2783 This member function uses rectangle sizes in pixels and does a
2784 stretch/compress blit using a linear DDA.
2787 @param aDestRect The rectangle within which the bitmap is to be drawn.
2788 @param aBitmap The source bitmap
2789 @param aSourceRect The rectangle in the source bitmap that is to be drawn
2790 @param aMaskBitmap The mask to be applied to the source bitmap while drawing
2791 @param aInvertMask Flag to indicate if the mask should be inverted.
2793 virtual void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0;
2795 /** Draws a specified rectangle from a wserv bitmap and its mask into
2798 The function compresses/stretches the specified rectangle from the bitmap
2799 to fit the destination rectangle.
2800 The mask bitmap can be used as either a positive or negative mask. Masked
2801 pixels are not mapped to the destination rectangle.
2803 A black and white (binary) mask bitmap is used. With aInvertMask=EFalse, black
2804 pixels in the mask bitmap stop corresponding pixels in the source bitmap from
2805 being transferred to the destination rectangle. With aInvertMask=ETrue, white
2806 pixels in the mask bitmap stop corresponding pixels in the source bitmap from
2807 being transferred to the destination rectangle.
2809 Note: this member function uses rectangle sizes in pixels and does a stretch/compress
2810 blit using a linear DDA.
2812 @param aDestRect The rectangle within which the masked bitmap is to be drawn.
2813 @param aBitmap A source wserv bitmap.
2814 @param aSourceRect The rectangle in the source bitmap that is copied to the
2815 destination rectangle.
2816 @param aMaskBitmap A mask wserv bitmap.
2817 @param aInvertMask If false, a source pixel that is masked by a black pixel
2818 is not transferred to the destination rectangle. If true, then a source pixel
2819 that is masked by a white pixel is not transferred to the destination rectangle. */
2820 virtual void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask)=0;
2822 /** Draws text without a surrounding box.
2824 The text baseline is aligned with the y co-ordinate of the specified point,
2825 and the left end of the text is aligned with the x co-ordinate of the
2830 Text drawing is done with the pen, and is subject to the pen colour. The
2831 effective text colour also depends on the drawing mode. The size and style
2832 of the text depends on the font used. The layout of the text depends on the
2833 justification mode set.
2835 @param aText The text string to be drawn.
2836 @param aPosition A point specifying the position of the left end of the text. */
2837 virtual void DrawText(const TDesC& aText,const TPoint& aPosition) = 0;
2839 /** Draws text inside a box.
2841 The surrounding box is filled with the current brush colour (not a pattern)
2842 and is drawn without any outline. The effective box colour depends on the
2843 drawing mode - if a brush colour has not been set then the brush defaults
2844 to white. The brush may be set to TBrushStyle::ENullBrush if text
2845 positioning relative to a box is required, but the box should not be filled.
2847 The font used is that set by UseFont(). If no font is in use then a panic
2850 The alignment of the text within the box can be specified.
2852 Text drawn within a box is also clipped to that box. Unless you intend to
2853 clip the top off the text, aBaselineOffset should be greater than or equal
2854 to the ascent of the current font.
2858 If the offset is negative, zero, or less than font height this is handled
2859 as would be expected, i.e. no text will be seen in the box in the first two
2860 instances, and the top of the text will be clipped in the latter case.
2864 For the drawing of right-aligned text, aLeftMargin indicates the margin from
2865 the right of aBox - where a positive value results in a leftwards offset.
2867 Negative margins can be used to display portions of the text string clipped
2868 by the box. A negative margin for left aligned text would clip the start of
2869 the text string. Similarly, a negative margin for right aligned text would
2870 clip the end of the text string.
2872 If the margin is greater than the width of the box then no text will be
2875 The margin is still honoured for centred text - centred text will not be
2876 centred in the box, unless the margin is zero.
2880 Text drawing is done with the pen, and is thus subject to the pen colour.
2881 The effective text colour also depends on the drawing mode. The size and
2882 style of the text depends on the used font. The layout of the text depends
2883 on the justification mode set.
2885 @param aText The text string to be drawn.
2886 @param aBox The box to draw the text in.
2887 @param aBaselineOffset An offset from the top of the box to the text
2889 @param aAlignment The text alignment mode default is left aligned.
2890 @param aLeftMargin The left margin for left-aligned text, or the right
2892 for right-aligned text default is zero. */
2893 virtual void DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TTextAlign aAlignment = ELeft,
2894 TInt aLeftMargin = 0) = 0;
2895 IMPORT_C virtual void DrawText(const TDesC& aText,const TPoint& aPosition,const TDrawTextParam& aParam);
2896 IMPORT_C virtual void Reserved();
2897 IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TPoint& aPosition,const TDrawTextExtendedParam& aParam);
2899 /** Maps pixels in the specified rectangle.
2900 The function tries to match the colour of a pixel with one of the RGB values
2901 in an array of RGB pairs. If there is a match, the colour is changed to the
2902 value specified in the other RGB in the RGB pair.
2903 @param aRect The rectangle in which pixels are to be mapped.
2904 @param aColors A pointer to a set of RGB pairs.
2905 @param aNumPairs The number of pairs
2906 @param aMapForwards ETrue, mapping is done from the first RGB to the second
2907 RGB in the pair; EFalse, mapping is done from the second RGB to the first
2909 virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards) = 0;
2911 /** Sets the clipping region.
2912 @param aClippingRegion The new clipping region.
2913 @return KErrNone if successful; KErrArgument if the TRegion is not valid; KErrNoMemory if there is insufficient memory.
2914 @see CGraphicsContext::CancelClippingRegion()*/
2915 virtual TInt SetClippingRegion(const TRegion &aRegion) = 0;
2917 /** Cancels the current clipping region.
2918 @see CGraphicsContext::SetClippingRegion()*/
2919 virtual void CancelClippingRegion() = 0;
2921 /** Draws vertical text in the specified direction.
2922 @param aText The text to be drawn.
2923 @param aPos Point of origin of the text baseline.
2924 @param aUp Direction. ETrue for up, EFalse for down. */
2925 virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp) = 0;
2927 /** Draws text vertically in the specified direction, within a box of the specified size.
2928 @param aText The text to be drawn.
2929 @param aBox The bounding box within which the text should be drawn, and which it is clipped to.
2930 @param aBaselineOffset The height of the top of the characters from their text baseline.
2931 @param aUp The direction. ETrue for up, EFalse for down.
2932 @param aVert The text alignment.
2933 @param aMargin The margin. */
2934 virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0) = 0;
2936 IMPORT_C TInt GetUnderlineMetrics(TInt& aTop,TInt& aBottom);
2938 /** Set the font's shadow colour
2939 @param aShadowColor Shadow colour to be set.
2940 @return KErrNone, if successful; otherwise, another of the system-wide errors. */
2941 IMPORT_C TInt SetShadowColor(const TRgb& aShadowColor);
2943 /** Get the font's shadow colour
2944 @param aShadowColor Shadow colour of the font returned by the funtion.
2945 @return KErrNone, if successful; otherwise, another of the system-wide errors. */
2946 IMPORT_C TInt GetShadowColor(TRgb& aShadowColor);
2948 /** Determine if the Gc is a CFbsBitGc
2949 @return ETrue, if the Gc is a CFbsBitGc, EFalse otherwise
2952 IMPORT_C TBool IsFbsBitGc() const;
2957 An APIExtension method to allow the addition of new APIs to retain compatibility
2958 with previous versions of gdi.dll
2959 @param aOutput is for output
2960 @param aInput is for input
2961 @see CGraphicsContext
2964 IMPORT_C virtual TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput);
2967 A reserved virtual function for future use.
2969 IMPORT_C virtual void Reserved_CGraphicsContext_2();
2973 /** An abstract, device-independent, interface to bitmapped graphics contexts.
2975 This holds the setting used to draw to a CBitmapDevice.
2977 The default settings of a CBitmapContext object immediately after construction
2980 drawing mode is EDrawModePen (pen and brush colours used as they are)
2982 no clipping rectangle
2984 pen settings are: black, solid, single pixel width
2988 no text font selected
2990 The classes CFbsBitGc and CWindowGc are derived from this class.
2996 class CBitmapContext : public CGraphicsContext
2999 /** Clears the whole bitmap.
3001 The cleared area is filled with the current brush colour.
3003 This pure virtual function is implemented in derived classes. */
3004 virtual void Clear()=0;
3006 /** Clears a rectangular area of a bitmap.
3008 The cleared area is filled with the current brush colour.
3010 This pure virtual function is implemented in derived classes.
3012 @param aRect The rectangle to clear. */
3013 virtual void Clear(const TRect& aRect)=0;
3015 /** Copies a rectangle.
3017 This pure virtual function is implemented in derived classes.
3019 @param aOffset The offset from the top left corner of the rectangle to be
3020 copied to the top left corner of the copy.
3021 @param aRect The rectangular area to be copied. */
3022 virtual void CopyRect(const TPoint& aOffset,const TRect& aRect)=0;
3024 /** Performs a bitmap block transfer.
3026 This pure virtual function is implemented in derived classes.
3028 @param aPoint The destination for the top left corner of the transferred bitmap.
3029 It is relative to the top left corner of the destination bitmap, which may be the screen.
3030 @param aBitmap A memory-resident bitmap. */
3031 virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap)=0;
3033 /** Performs a bitmap block transfer of a rectangular piece of a bitmap.
3035 If the specified rectangle is larger than the bitmap then the bitmap is
3038 This pure virtual function is implemented in derived classes.
3040 @param aPoint The destination for the top left corner of the transferred bitmap.
3041 It is relative to the top left corner of the destination bitmap, which may be the screen.
3043 @param aBitmap A memory-resident bitmap
3044 @param aRect A rectangle defining the portion of the bitmap to transfer.
3045 Its coordinates are relative to the top left corner of the source bitmap. */
3046 virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aRect)=0;
3048 /** Performs a masked bitmap block transfer.
3050 The mask bitmap can be used as either a positive or negative mask. Masked
3051 pixels are not mapped to the destination rectangle.
3053 This function uses either a black and white (binary) mask bitmap, or if
3054 aMaskBitmap's display mode is EGray256, alpha blending is used. Use of
3055 any other mode may result in unpredictable results
3057 With aInvertMask=EFalse, black pixels in the mask bitmap stop corresponding
3058 pixels in the source bitmap from being transferred to the destination rectangle.
3059 With aInvertMask=ETrue, white pixels in the mask bitmap stop corresponding
3060 pixels in the source bitmap from being transferred to the destination
3063 Note that if the mask bitmap is smaller than the source bitmap, then it is
3064 tiled across the bitmap. Note that the mask is applied before the piece of
3065 the bitmap is defined - the mask is tiled relative to the top left of the
3066 original source bitmap rather than the top left of the bitmap piece.
3068 This pure virtual function is implemented in derived classes.
3070 @param aPoint The destination for the top left corner of the transferred bitmap.
3071 It is relative to the top left corner of the destination bitmap, which may be the screen.
3072 @param aBitmap A memory-resident source bitmap.
3073 @param aSourceRect A rectangle defining the piece of the bitmap to be drawn,
3074 with co-ordinates relative to the top left corner of the bitmap.
3075 @param aMaskBitmap A mask bitmap
3076 @param aInvertMask If EFalse, a source pixel that is masked by a black pixel
3077 is not transferred to the destination rectangle. If ETrue, then a source
3078 pixel that is masked by a white pixel is not transferred to the destination
3080 virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0;
3082 /** Sets whether the graphics context is faded.
3084 @param aFaded ETrue to fade the GC; EFalse to unfade it. */
3085 virtual void SetFaded(TBool aFaded)=0;
3087 /** Sets the fading parameters.
3089 This function allows you to override the map used when drawing with a faded
3090 graphics context (GC). However if you draw to a faded window with a faded
3091 GC, then fading on the GC is ignored and the fading of the window is used.
3093 Fading is used to change the colour of a window to make other windows stand
3094 out. Fading can either make a faded window closer to white or closer to
3097 Fading re-maps colours in the faded GC to fall between the specified black
3098 and white map values. If aBlackMap=0 and aWhiteMap=255 then the colours are
3099 mapped unchanged. As the values converge the colours are mapped to a smaller
3100 range - so the differences between colours in the faded GC decrease. If
3101 the values are reversed then the colours are inverted (i.e. where the GC
3102 would be black, it is now white).
3104 @param aBlackMap Black map fading parameter. Unfaded this is 0.
3105 @param aWhiteMap White map fading parameter. Unfaded this is 255. */
3106 virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)=0;
3109 Performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using
3110 the data from aAlphaBmp as an alpha blending factor.
3111 The formula used is:
3112 (S * A + W * (255 - A)) / 255, where:
3113 - S - a pixel from aSrcBmp;
3114 - W - a pixel from the window;
3115 - A - a pixel from aAlphaBmp;
3116 The contents of source and alpha bitmap are preserved.
3117 The calculated alpha blended pixels are written to the destination CBitmapContext.
3118 @param aDestPt Position in the target the result should be drawn to.
3119 @param aSrcBmp A pointer to the source bitmap.
3120 @param aSrcRect The part of the source bitmap that should be used.
3121 @param aAlphaBmp A pointer to the bitmap used as an alpha blending factor.
3122 @param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source
3123 for the alpha blending. The size of the area is the same as the
3124 source bitmap area - aSrcRect parameter.
3125 @return KErrNone, if successful; otherwise, another of the system-wide error codes.*/
3127 virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0;
3130 The method performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using
3131 the data from aAlphaBmp as an alpha blending factor.
3132 For information on how this function works, see the other overload.
3133 @param aDestPt Position in the target the result should be drawn to.
3134 @param aSrcBmp A pointer to the source bitmap.
3135 @param aSrcRect The part of the source bitmap that should be used.
3136 @param aAlphaBmp A pointer to the bitmap used as an alpha blending factor.
3137 @param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source
3138 for the alpha blending. The size of the area is the same as the
3139 source bitmap area - aSrcRect parameter.
3140 @return KErrNone, if successful; otherwise, another of the system-wide error codes.*/
3141 virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0;
3146 Implementations from CGraphicsContext
3147 @see CGraphicsContext::APIExtension(TUid, TAny*&, TAny*)
3149 IMPORT_C TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput);
3151 Implementations from CGraphicsContext
3152 @see CGraphicsContext::Reserved_CGraphicsContext_2()
3154 IMPORT_C void Reserved_CGraphicsContext_2();
3156 IMPORT_C virtual void Reserved_CBitmapContext_1();
3157 IMPORT_C virtual void Reserved_CBitmapContext_2();
3158 IMPORT_C virtual void Reserved_CBitmapContext_3();
3161 /** Defines an abstract interface for the capabilities and attributes of a
3162 bitmapped graphics device.
3164 The class specialises the graphics device interface CGraphicsDevice for bitmaps
3165 graphics. The Window Server Client-Side API provides one implementation of
3166 the interface, CWsScreenDevice, for screen drawing. Another implementation,
3167 CFbsBitmapDevice, is used for drawing to in-memory bitmaps. A third,
3168 CFbsScreenDevice, is used (rarely) to access the screen directly, without the
3169 mediation of the window server.
3173 class CBitmapDevice : public CGraphicsDevice
3176 /** Gets the RGB colour of an individual pixel on a bitmapped graphics
3179 This pure virtual function is implemented in derived classes.
3181 @param aColor On return, should contain the RGB colour of the pixel.
3182 @param aPixel The (x,y) co-ordinates of the pixel. The top left pixel is
3184 virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const=0;
3186 /** Copies a scanline into a buffer.
3188 The pixels are converted from the display mode format on the bitmapped
3189 graphics device to the format of the specified device display mode.
3191 By specifying the start pixel and the number of pixels, either the whole or
3192 a portion of a bitmapped graphics device pixel row may be copied.
3194 This pure virtual function is implemented in derived classes.
3196 @param aBuf An 8 bit modifiable descriptor buffer into which pixels are
3197 copied; it must be sufficiently large to store all the scanline pixels.
3198 @param aStartPixel The (x,y) co-ordinates of the first pixel of the bitmap
3199 scanline to be put into the buffer.
3200 @param aLength The number of pixels to put into the buffer.
3201 @param aDispMode The display mode into which to convert the pixels. */
3202 virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const=0;
3204 /** Adds a font file to the device's typeface store. The specified font
3205 file must be accessible to any process, i.e. not located inside an
3206 application's private directory.
3208 This pure virtual function is implemented in derived classes.
3210 @param aName The name of the font file.
3211 @param aId On return, contains an ID for the font file.
3212 @return KErrNone, if successful; otherwise, another of the system-wide error
3214 virtual TInt AddFile(const TDesC& aName,TInt& aId)=0;
3216 /** Removes a font file from the font store.
3218 This pure virtual function is implemented in derived classes.
3220 @param aId The ID of the font file to be removed. The default is 0. */
3221 virtual void RemoveFile(TInt aId=0)=0;
3224 Gets the font which is the nearest to the given font specification.
3226 When the font is no longer needed, call @c ReleaseFont().
3228 Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInPixels()
3229 yielding (virtually) the same result. However clients are strongly encouraged to use the new
3230 @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every
3231 character within any given text string will fit within the given amount of pixels, whereas the design
3232 height is an aesthetic unit decided by the font designer without strict physical meaning, which
3233 may result in cropped characters.
3235 @param aFont On return, contains a pointer to the nearest font.
3236 @param aFontSpec The specification of the font to be matched.
3237 @return KErrNone if successful; a system-wide error code otherwise.
3239 @deprecated Use GetNearestFontToDesignHeightInPixels
3241 virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
3244 Gets the font which is the nearest to the given font specification.
3246 When the font is no longer needed, call @c ReleaseFont().
3248 This new function replaces the deprecated @c GetNearestFontInPixels() yielding (virtually) the
3249 same result. However clients are strongly encouraged to use the new
3250 @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every
3251 character within any given text string will fit within the given amount of pixels, whereas the design
3252 height is an aesthetic unit decided by the font designer without strict physical meaning, which
3253 may result in cropped characters.
3255 @param aFont On return, contains a pointer to the nearest font.
3256 @param aFontSpec The specification of the font to be matched.
3257 @return KErrNone if successful; a system-wide error code otherwise.
3261 virtual TInt GetNearestFontToDesignHeightInPixels(
3262 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; }
3265 Gets the font which is the nearest to the given font specification.
3267 When the font is no longer needed, call @c ReleaseFont().
3269 The font and bitmap server returns a pointer to the nearest matching font
3270 from those available. Matches to max height of font - this does its best
3271 to return a font that will fit within the maximum height specified (but
3272 note that variations due to hinting algorithms may rarely result in this
3273 height being exceeded by up to one pixel). Problems can also be
3274 encountered with bitmap fonts where the typeface exists but doesn't have
3275 a font small enough.
3277 @param aFont On return, contains a pointer to the nearest font.
3278 @param aFontSpec The specification of the font to be matched.
3279 @param aMaxHeight The maximum height within which the font must fit.
3280 This overrides the height specified in aFontSpec.
3281 @return KErrNone if successful; a system-wide error code otherwise.
3285 virtual TInt GetNearestFontToMaxHeightInPixels(
3286 CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; }
3288 /** Gets the height, in pixels, of the specified typeface at one of its
3291 The typeface is identified by by an index. For a given typeface, there are
3292 a discrete number of heights; the specific height is also identified by an
3295 The value returned is rounded up or down to the nearest font height in
3298 This pure virtual function is implemented in derived classes.
3300 @param aTypefaceIndex A typeface index number, in the range: 0 to
3301 (NumTypefaces() - 1).
3302 @param aHeightIndex A font height index number, in the range: 0 to
3303 (iNumHeights - 1) where iNumHeights is a public data member of the
3304 TTypefaceSupport object returned by TypefaceSupport().
3305 @return The height of the font, in pixels.
3306 @see TTypefaceSupport
3307 @see CGraphicsDevice::NumTypefaces()
3308 @see CGraphicsDevice::TypefaceSupport() */
3309 virtual TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
3310 inline TInt CreateBitmapContext(CBitmapContext*& aGC);
3313 /** A set of margins used for cropping a picture.
3315 Margins are specified in twips or pixels.
3322 IMPORT_C void InternalizeL(RReadStream& aStream);
3323 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3324 IMPORT_C TBool operator==(const TMargins& aMargins) const;
3325 IMPORT_C TBool operator!=(const TMargins& aMargins) const;
3327 /** Left margin, (in twips or pixels). */
3329 /** Right margin, (in twips or pixels). */
3331 /** Top margin, (in twips or pixels). */
3333 /** Bottom margin, (in twips or pixels). */
3337 /** Picture capabilities.
3339 These include the types of scaling that can be applied to a picture, and whether
3340 or not it is croppable.
3344 class TPictureCapability
3347 /** Scaling types. */
3350 /** The picture is not scalable. */
3352 /** The picture is fully scalable. */
3354 /** The picture is scalable to any size, as long as its aspect ratio
3355 (the ratio of its height to its width) remains constant. */
3356 EScaleableMaintainingAspectRatio
3359 inline TPictureCapability(TScalingType aScalingType,TBool aCroppable);
3361 /** Whether or not the picture is croppable. */
3362 TScalingType iScalingType;
3363 /** Scaling type. */
3367 /** Abstract base class for: drawing a picture to a graphics context, storing
3368 and restoring the picture.
3370 The class defines the protocol for a number of concrete picture classes. Its
3371 main role is to support glass doors used in object embedding.
3373 The class provides a protocol for the provision of scaling and cropping
3374 functions by derived classes, together with default implementations.
3376 Its main function is Draw(), which draws the picture onto the graphics context
3377 at a particular point. It also has two important pure virtual functions:
3378 ExternalizeL() and GetOriginalSizeInTwips().
3380 A picture has both an original representation and an on-screen representation.
3381 The original representation has a size in twips, and can somehow be drawn.
3382 The on-screen representation is assumed to be drawn under the control of an
3383 application which may wish to re-size or scale the original in some way, to
3384 crop it at the edges, and/or to ensure it fits within a particular defined
3387 The class provides several functions that allow an application to set scaling
3388 and cropping before invoking the Draw() function to draw the picture on-screen.
3389 It is up to the internal workings of the function to determine the order of
3390 application cropping and scaling.
3394 class CPicture : public CBase
3397 /** Options for detaching pictures from stores. Used by DetachFromStoreL(). */
3400 /** Internalise all data that is required to fully store the picture
3401 later; null any references to containing stores. */
3403 /** Internalise enough information to draw the picture (and no more);
3404 null any references to containing stores. */
3408 IMPORT_C virtual ~CPicture();
3409 /** Draws a picture.
3411 @param aGc The graphics context.
3412 @param aTopLeft The co-ordinates where the top left corner pixel of the
3413 picture should be placed. Note that whether this is actually drawn depends
3414 on the clipping area defined.
3415 @param aClipRect A clipping rectangle that defines the area to which the
3416 function should draw. An implementation should never draw outside this
3417 rectangle. Note that the graphics context may also have a clipping rectangle
3419 @param aMap The device map for the graphics device. The implementation
3420 should use this to find the scaling to apply to the picture. */
3421 virtual void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap) const=0;
3422 IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore) const; // assumes no sub streams
3423 virtual void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull) {}
3425 /** Externalises the picture to a stream.
3427 The presence of this function means that the standard templated stream
3428 operator<<() is available to externalise objects of this class.
3430 A derived class must supply an implementation of this function.
3432 @param aStream The write stream. */
3433 virtual void ExternalizeL(RWriteStream& aStream) const =0;
3435 /** Gets the pictur's original size, in twips.
3437 @param aSize The size of the picture, in twips */
3438 virtual void GetOriginalSizeInTwips(TSize& aSize) const =0;
3439 IMPORT_C virtual void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); // does nothing
3440 IMPORT_C virtual void SetCropInTwips(const TMargins& aMargins); // does nothing
3441 IMPORT_C virtual TPictureCapability Capability() const; // no scale, no crop
3442 IMPORT_C virtual void GetCropInTwips(TMargins& aMargins) const; // returns no crop
3443 IMPORT_C virtual TInt ScaleFactorWidth() const; // returns no scaling
3444 IMPORT_C virtual TInt ScaleFactorHeight() const; // returns no scaling
3445 IMPORT_C virtual TBool LineBreakPossible(TUint aClass,TBool aBeforePicture,TBool aHaveSpaces) const;
3446 IMPORT_C virtual TBool NativePixelSize(TSize& aPixelSize);
3448 IMPORT_C void GetSizeInPixels(MGraphicsDeviceMap* aMap, TSize& aSize) const;
3449 IMPORT_C void SetSizeInPixels(MGraphicsDeviceMap* aMap, const TSize& aSize);
3450 IMPORT_C void AddCropInPixels(MGraphicsDeviceMap* aMap, const TMargins& aMargins);
3451 IMPORT_C void GetSizeInTwips(TSize& aSize) const;
3452 IMPORT_C void SetSizeInTwips(const TSize& aSize);
3453 IMPORT_C void ResetToOriginal();
3455 IMPORT_C CPicture();
3459 /** Picture header providing an interface to a stored picture. The header holds:
3461 the picture's type, encoded as a UID, which ensures that it will be restored
3462 to the correct picture type
3464 the picture's size, which facilitates deferred loading
3466 the stream ID of the picture body, which is replaced by a pointer to the picture
3467 object when it has been restored.
3471 class TPictureHeader
3474 IMPORT_C TPictureHeader();
3475 IMPORT_C void InternalizeL(RReadStream& aStream);
3476 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3477 IMPORT_C void DeletePicture();
3479 /** A swizzle storing either the ID of the stream in which the picture is
3480 stored, or a pointer to the internalised picture. */
3481 TSwizzle<CPicture> iPicture;
3482 /** A UID specifying the type of the picture. */
3484 /** The original size of the picture. */
3489 /** Abstract interface for instantiating and restoring new CPicture derived
3492 A concrete derived class creates pictures of one or more specific types. The
3493 class has no member data and just one function, NewPictureL, that needs to
3494 be provided by derived classes.
3498 class MPictureFactory
3501 /** Interface to the picture restoration process that ensures that a
3502 picture of the correct type is restored.
3504 The class of the object to be restored is determined by the UID of the
3505 stored picture, contained in the specified picture header.
3507 The function can allow the restoration of:
3509 just one CPicture-derived class, returning an error if the UID indicates
3510 that the stored picture is not of the required type
3512 many different CPicture-derived classes, using the UID to choose which of
3513 the possible CPicture-derived classes should be instantiated
3515 @param aHeader The picture header that should be restored.
3516 @param aDeferredPictureStore The store in which both the header and picture
3518 virtual void NewPictureL(TPictureHeader& aHeader,const CStreamStore& aDeferredPictureStore)const=0;
3524 The maximum length of a printer model name.
3525 @see TPrinterModelName
3529 const TInt KMaxPrinterModelNameLength=0x20;
3532 Defines a modifiable buffer descriptor that can contain the name of a
3533 printer model. The maximum length of the buffer is 32.
3538 typedef TBuf<KMaxPrinterModelNameLength> TPrinterModelName;
3540 /** Page specification for a print operation.
3542 The page specification consists of the page orientation and the page
3543 size in twips or pixels. By default, the page orientation is portrait.
3544 When using landscape orientation, the left hand side of the page
3554 /**The available page orientations. */
3555 enum TPageOrientation
3557 /** Portrait page orientation */
3559 /** Landscape page orientation */
3563 IMPORT_C TPageSpec();
3564 IMPORT_C TPageSpec(TPageOrientation aOrientation,const TSize& aSize);
3565 IMPORT_C void InternalizeL(RReadStream& aStream);
3566 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3567 IMPORT_C TSize OrientedPageSize() const;
3568 IMPORT_C TBool operator==(const TPageSpec& aPageSpec) const;
3569 IMPORT_C TBool operator!=(const TPageSpec& aPageSpec) const;
3571 /** The width and height of the page in portrait orientation in twips or
3574 Note that OrientedPageSize() returns the width and height in reverse order
3575 for a landscape portrait. */
3576 TSize iPortraitPageSize;
3577 /** The page orientation. */
3578 TPageOrientation iOrientation;
3582 /** Controls the attributes of the band to be printed.
3584 An object of this type is passed as a parameter to functions.
3585 MPageRegionPrinter::PrintBandL() and CPrinterControl::QueueGetBand().
3586 @see MPageRegionPrinter::PrintBandL()
3587 @see CPrinterControl::QueueGetBand()
3592 class TBandAttributes
3595 /** The width and height of the band in twips or pixels. */
3597 /** ETrue to draw no text to the band; EFalse to draw text. */
3598 TBool iTextIsIgnored; // any text drawing to this band is ignored
3599 /** ETrue to draw no graphics to the band; EFalse to draw graphics. */
3600 TBool iGraphicsIsIgnored; // any graphics drawing to this band is ignored
3601 /** ETrue if band is the first band on the page; EFalse if not. */
3602 TBool iFirstBandOnPage;
3605 /** Printer port interface.
3607 This interface is used as the base class for the various types of
3608 printer port. New printer port classes should be derived from this
3609 class.After allocation and construction, a pointer to a concrete
3610 printer port should be passed to
3611 CPrintSetup::StartPrintL().
3612 @see CPrintSetup::StartPrintL()
3617 class CPrinterPort : public CBase
3620 /** Writes data asynchronously to the printer port.
3622 @param aBuf Data to be written to the port
3623 @param aRequestStatus A reference to the request status object. If the
3624 request is cancelled, this should be set to KErrCancel; if the request
3625 completes normally, this should be set to KErrNone. */
3626 virtual void WriteRequest(const TDesC8& aBuf,TRequestStatus& aRequestStatus)=0;
3628 /** Cancels an outstanding WriteRequest() operation. */
3629 virtual void Cancel()=0;
3633 /** Detailed information about a printer model.
3639 class TPrinterModelEntry
3642 /** The name of the printer model. */
3643 TPrinterModelName iModelName;
3644 /** If ETrue, then a printer port is required. */
3645 TBool iRequiresPrinterPort;
3646 /** The UID associated with this printer model. */
3649 IMPORT_C void InternalizeL(RReadStream& aStream);
3650 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3654 /** Information about a printer model.
3656 An instance of this class consists of a TPrinterModelEntry and a stream ID,
3657 and is passed to CPrinterDevice::SetModel().
3663 class TPrinterModelHeader
3666 /** The printer model. */
3667 TPrinterModelEntry iEntry;
3668 /** The stream ID for model data. */
3669 TStreamId iModelDataStreamId;
3671 IMPORT_C void InternalizeL(RReadStream& aStream);
3672 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
3676 /** Printer control interface.
3678 This abstract base class acts as the interface between a CPrinterDevice object
3679 and the printer. It creates the context for, and controls the progress and
3680 termination of the print job.
3682 Only those who need to add new printer drivers should write derived classes.
3683 After instantiation of such a class, using CPrinterDevice::CreateControlL(),
3684 the object can be accessed via the iControl member of CPrinterDevice.
3690 class CPrinterControl : public CBase
3693 /** Flags indicating whether there is more on the page to print. */
3696 /** Indicates there is more to print on the current page. */
3698 /** Indicates there is no more to print on the current page. */
3702 IMPORT_C ~CPrinterControl();
3704 /** Gets the number of bands per page.
3706 @return The number of bands on each page. */
3707 virtual TInt BandsPerPage()=0;
3709 /** Prints the next band on the page.
3711 This is an asynchronous function.
3712 @param aStatus Request status object. On successful completion
3713 contains KErrNone, otherwise another of the system-wide
3715 @param aBand On return, indicates the attributes of the band, including
3716 its height and width and whether or not the device will ignore one or
3717 other of graphics or text output. This information may be used by
3718 applications to draw more efficiently, or may be ignored
3719 @return EMoreOnPage, if any unprinted bands remain on the
3720 current page. ENoMoreOnPage, if the current band is last on
3722 virtual TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand)=0; // returns affirmative if more to print on current page
3724 /** Terminates the print process.
3726 This is an asynchronous function and is called when no more bands in
3727 the document remain to be printed.Note that all bands have been
3728 printed when no more pages or copies remain to be printed, and
3729 QueueGetBand() returns ENoMoreToPrint.
3731 @param aStatus Request status object. On successful completion contains
3732 KErrNone, otherwise another of the system-wide error codes. */
3733 virtual void QueueEndPrint(TRequestStatus& aStatus)=0;
3735 /** Aborts the print process before it has completed.
3737 This function should be called if QueueGetBand() reports an error. */
3738 virtual void AbortPrint()=0; // tidy up synchronously in a short time, return success code
3740 IMPORT_C CPrinterControl(CPrinterPort* aPrinterPort);
3745 /** Not printing. */
3750 /** Printing state. */
3752 /** Printer port. */
3753 CPrinterPort* iPrinterPort;
3756 class CDictionaryStore;
3759 /** Printer graphics device interface.
3761 This abstract class represents a physical graphics device that is used for
3764 This class is used to:
3766 set and get the page specification
3768 map between the co-ordinates of the printed page (in twips) and the co-ordinates
3769 of the image device (in pixels)
3771 get and set the printer model entry
3773 create and delete a printer control.
3775 A printer driver is defined in terms of a printer device and a printer control.
3776 A printer device can own either a single or no printer control. The control
3777 determines the progress and termination of the print job and is responsible
3778 for producing output.
3780 @see CPrinterControl
3784 class CPrinterDevice : public CGraphicsDevice
3787 IMPORT_C ~CPrinterDevice();
3789 /** Gets the current page specification in twips.
3791 @return The current page specification, in twips. */
3792 inline TPageSpec CurrentPageSpecInTwips() const {return(iCurrentPageSpecInTwips);}
3794 /** Sets the page specification in twips.
3796 @param aPageSpec The page specification in twips. */
3797 IMPORT_C virtual void SelectPageSpecInTwips(const TPageSpec& aPageSpec);
3798 IMPORT_C virtual TRect PrintablePageInPixels() const;
3800 /** Gets the printer model entry.
3802 @return The printer model entry. */
3803 virtual TPrinterModelEntry Model()const =0;
3805 /** Sets the printer model header and the store.
3807 @param aModel The printer model header.
3808 @param aStore The store.
3809 @return KErrNone if successful; otherwise, another of the system-wide
3811 virtual TInt SetModel(const TPrinterModelHeader& aModel,CStreamStore& aStore)=0;
3813 /** Creates a printer control.
3815 The printer control is an instance of a CPrinterControl derived class; it
3816 is assigned to this printer device's iControl member.
3818 Note that this function is called by CPrintSetup::StartPrintL().
3820 @param aPrinterPort Pointer to an instance of a printer port. */
3821 virtual void CreateControlL(CPrinterPort* aPrinterPort)=0;
3822 IMPORT_C virtual void DeleteControl();
3824 /** Externalizes printer properties to the store.
3826 The default implementation is empty.
3828 @param aStream The read stream. */
3829 virtual void InternalizePropertiesL(RReadStream& /*aStream*/) {}
3831 /** Externalizes printer properties to the store.
3833 The default implementation is empty.
3835 @param aStream The write stream. */
3836 virtual void ExternalizePropertiesL(RWriteStream& /*aStream*/) const {}
3837 IMPORT_C void RestorePropertiesL();
3838 IMPORT_C void StorePropertiesL() const;
3840 IMPORT_C CPrinterDevice();
3842 /** The printer control.
3844 This may be NULL. If implemented, it provides control over the print
3846 CPrinterControl* iControl;
3848 /** Current page specification in twips. */
3849 TPageSpec iCurrentPageSpecInTwips;
3853 /** Printer model list interface.
3855 Functions provided by this abstract base class can be used to extract printer
3856 model information from the list of printer models. This class would typically
3857 be used to implement printer selection in a dialog box.
3863 class CPrinterModelList : public CBase
3866 /** Gets the number of printer models in the printer model list.
3868 @return The number of printer models. */
3869 virtual TInt ModelCount() const=0;
3871 /**Gets printer model name.
3873 This is the name of the printer model at the specified index within
3874 the list of printer models.
3876 @param anIndex The index of the printer model within the array of
3877 printer models. Note that this number must be between zero and
3879 @return Name of printer model, up to 32 characters long */
3880 virtual const TPrinterModelEntry operator[](TInt anIndex)=0;
3882 /** Gets a printer models index within the model list from its UID.
3884 @param aModelUid The UID of the printer model.
3885 @return The index of the printer model within the array of printer models.*/
3886 virtual TInt UidToNum(TUid aModelUid) const=0;
3890 /** Interface for printing in bands.
3892 This class provides a single PrintBandL() function that prints
3893 the body of each page band by band. Classes derived from this interface must
3894 provide an implementation of the PrintBandL() function.
3899 class MPageRegionPrinter
3904 Implementations should set up a graphics context to which all drawing should
3905 take place using CGraphicsDevice::CreateContext(). All co-ordinate
3906 calculations should be done in twips, and converted into pixels before
3907 starting the print job.
3909 @param aDevice Pointer to the graphics device representing the printer.
3910 @param aPageNo The number of the page containing the band to be printed.
3911 @param aBandInPixels Attributes of the band to be printed. */
3912 virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBandInPixels)=0;
3916 The UID value of a printer specification data store.
3920 const TInt KPdrStoreFileUidVal=268435514;
3922 const TInt KPdlUidVal=268450588;
3923 const TInt KUdlUidVal=268450589;
3926 /** Printer specific user interface.
3928 The class is used to implement a printer specific setup dialog. A concrete
3929 implementation of the class is supplied in a UDL (i.e. a UI DLL).
3931 CPrinterDriver::CreatePrinterDriverUIL() is used to construct a CPrinterDriverUI
3932 object for a specific printer. (This function calls the ordinal 1 exported
3933 function of the UDL that performs the construction of the CPrinterDriverUI
3936 @see CPrinterDriver::CreatePrinterDriverUIL()
3940 class CPrinterDriverUI : public CBase
3943 IMPORT_C CPrinterDriverUI();
3945 IMPORT_C virtual TBool BeforePrintL();
3946 IMPORT_C virtual void AfterPrintL();
3947 IMPORT_C virtual void SetPropertiesL();
3948 IMPORT_C virtual TBool CanSetProperties();
3950 /** Sets the printer device.
3952 @param aPrinterDevice The printer device. */
3953 virtual TInt SetPrinterDevice(CPrinterDevice* aPrinterDevice)=0;
3959 /** Provides access to a store containing printer specification data.
3961 Printer specification data is held as a direct file store, and usually has
3964 A printer driver is implemented as two files: a PDR file containing the printer
3965 specification data and a PDL file containing the code to link the printer
3966 with the graphics printing system.
3968 The printer specification data is generated by compiling a text file (a .pd
3969 file type) using the pdrtran tool. Printer specification data defines:
3971 the name of the associated PDL
3973 a list of one or more models supported by this driver, identified by name
3976 device information such as the size of the device, typeface information for
3977 each model, including which typefaces are supported, the heights available
3978 in each typeface and the width of each character in a font.
3980 @see CPrinterDriverUI
3984 class CPrinterDriver : public CBase
3987 IMPORT_C static CPrinterDriver* NewL();
3988 IMPORT_C ~CPrinterDriver();
3989 IMPORT_C void OpenPdrL(const TDesC &aName);
3990 IMPORT_C void Close();
3991 IMPORT_C TInt NumModels() const;
3992 IMPORT_C TPrinterModelEntry Model(TInt aNum) const;
3994 /** Gets the associated graphics printer device.
3996 @return The physical graphics device used for printing. */
3997 inline CPrinterDevice* PrinterDevice() {return iPrinterDevice;}
3998 IMPORT_C CPrinterDevice* CreatePrinterDeviceL(TUid aModelUid);
3999 IMPORT_C CPrinterDriverUI* CreatePrinterDriverUIL();
4002 void DeletePrinterDevice();
4003 void DoOpenPdrL(const TDesC &aName);
4004 void DoCreatePrinterDeviceL(TUid aModelUid);
4005 void LoadLibraryL(RLibrary& aLibrary,const TDesC& aExt,TUid aUid2);
4008 CFileStore *iPdrStore;
4010 TPrinterModelHeader* iModelList;
4013 RLibrary iPdlLibrary;
4014 CPrinterDevice* iPrinterDevice;
4015 RLibrary iUdlLibrary;
4018 class RResourceFile;
4021 /** Implements a printer model list interface for a collection of PDR files.
4025 class CPdrModelList : public CPrinterModelList
4028 IMPORT_C static CPdrModelList* NewL();
4029 IMPORT_C virtual ~CPdrModelList();
4030 IMPORT_C TInt ModelCount() const;
4031 IMPORT_C const TPrinterModelEntry operator [] (TInt anIndex);
4032 IMPORT_C TInt UidToNum(TUid aModelUid) const; // returns KErrNotFound the model uid is not matched
4033 IMPORT_C void AddDirectoryL(const TDesC& aDir);
4034 IMPORT_C CPrinterModelList* ScanForModelsL();
4035 IMPORT_C CPrinterDriver* CreatePrinterDriverL(TInt anIndex);
4043 TFileName iFileName;
4049 TPrinterModelEntry iEntry;
4053 void ScanDirectoryL(TInt aDirIndex);
4054 void ListModelsL(TInt aFileIndex, TParse& aParser, TFileName& aNameOfLoadedResourceFile, TFileName& aTempFileName, RResourceFile& aResourceFile, HBufC8*& aResource);
4055 HBufC* NewPathBufL(const TFileEntry& aFileEntry);
4057 CArrayFixSeg<TModelEntry>* iModelArray;
4058 CArrayFixFlat<TFileEntry>* iFileArray;
4059 CArrayFixFlat<HBufC*>* iDirectoryArray;
4064 /** The interface for mapping between twips and device-specific units enriched
4065 with facilities to allow zooming.
4067 The class is recursive, because a TZoomFactor object can have a
4068 MGraphicsDeviceMap (which could itself be a TZoomFactor) in its member data.
4069 This allows a zoom factor object to contain another zoom factor object, and
4070 is used to allow objects with different zoom factors to be embedded in each
4071 other to an arbitrary depth by the application architecture.
4075 class TZoomFactor : public MGraphicsDeviceMap
4078 IMPORT_C TZoomFactor();
4079 IMPORT_C ~TZoomFactor();
4080 inline TZoomFactor(const MGraphicsDeviceMap* aDevice);
4081 inline TZoomFactor(const TZoomFactor* aDevice);
4082 IMPORT_C TInt ZoomFactor() const;
4083 IMPORT_C void SetZoomFactor(TInt aZoomFactor);
4084 inline void SetGraphicsDeviceMap(const MGraphicsDeviceMap* aDevice);
4085 inline const MGraphicsDeviceMap* GraphicsDeviceMap() const;
4086 IMPORT_C void SetTwipToPixelMapping(const TSize& aSizeInPixels,const TSize& aSizeInTwips);
4087 IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwipWidth) const;
4088 IMPORT_C TInt VerticalTwipsToPixels(TInt aTwipHeight) const;
4089 IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixelWidth) const;
4090 IMPORT_C TInt VerticalPixelsToTwips(TInt aPixelHeight) const;
4091 IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
4092 IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
4093 IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
4094 IMPORT_C void ReleaseFont(CFont* aFont);
4097 /** One to one zoom factor. */
4098 enum {EZoomOneToOne=1000};
4101 const MGraphicsDeviceMap* iDevice;
4105 Provides methods to map a TLanguage type to some pre-defined glyph samples.
4106 Samples are defined per writing script, e.g. specifying ELangFrench or
4107 ELangGerman will return the same set of samples.
4108 These samples are typically the tallest and 'deep'est characters w.r.t
4109 various scripts, useful for font rasterizers when calculating metrics.
4112 NONSHARABLE_CLASS(GlyphSample)
4116 Writing scripts defined according to Unicode.
4120 EScriptDefault = 0x0, // No script, can't be bothered
4121 EScriptNone = 0x1, // No script, really
4122 EScriptOther = 0x2, // Unsupported scripts
4123 EScriptLatin = 0x3, // European
4124 EScriptGreek = 0x4, // European
4125 EScriptCyrillic = 0x5, // European
4126 EScriptHebrew = 0x6, // Middle Eastern
4127 EScriptArabic = 0x7, // Middle Eastern
4128 EScriptDevanagari = 0x8, // Indic
4129 EScriptThai = 0x9, // SE Asian
4130 EScriptHanIdeographs = 0xA, // E Asian
4133 IMPORT_C static TInt TLanguage2TScript(TLanguage aLanguage);
4134 IMPORT_C static const TPtrC TScript2GlyphSample(TInt aScript);
4136 static const TInt KTLanguage2TScript[];
4137 static const TText* const KTScript2GlyphSample[];
4141 Structure used as a package for GetUnderlineMetrics to pass to the relevant
4142 section of APIExtension.