os/graphics/graphicsdeviceinterface/gdi/inc/GDI.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __GDI_H__
    17 #define __GDI_H__
    18 
    19 #include <e32base.h>
    20 #include <f32file.h>
    21 #include <s32std.h>
    22 #include <displaymode.h>
    23 
    24 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS	
    25 #include <graphics/gdi/glyphsample.h>
    26 #include <graphics/gdi/gdiconsts.h>
    27 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS	
    28 
    29 class TOpenFontCharMetrics;
    30 class RShapeInfo;
    31 class CGraphicsContext;
    32 class TTextParameters;
    33 
    34 /**
    35 Number of twips per inch. 
    36 @publishedAll
    37 @released
    38 */
    39 const TInt KTwipsPerInch=1440;
    40 
    41 /**
    42 Number of twips per point.
    43 @publishedAll
    44 @released
    45 */
    46 const TInt KTwipsPerPoint=20;
    47 
    48 /**
    49 Number of points per inch. 
    50 @publishedAll
    51 @released
    52 */
    53 const TInt KPointsPerInch=72;
    54 
    55 /**
    56 Number of twips per cm.
    57 @publishedAll
    58 @released
    59 */
    60 const TInt KTwipsPerCm=567;
    61 #if defined(__NO_CLASS_CONSTS__)
    62 /**
    63 A4 paper size in twips. 
    64 @publishedAll
    65 @released
    66 */
    67 #define KA4PaperSizeInTwips TSize(11906,16838)
    68 
    69 /** Legal paper size in twips.
    70 @publishedAll
    71 @released
    72 */
    73 #define KLegalPaperSizeInTwips TSize(12240,20160)
    74 
    75 /**
    76 Executive paper size in twips. 
    77 @publishedAll
    78 @released
    79 */
    80 #define KExecutivePaperSizeInTwips TSize(10440,15120)
    81 /** 
    82 Letter paper size in twips. 
    83 @publishedAll
    84 @released
    85 */
    86 #define KLetterPaperSizeInTwips TSize(12240,15840)
    87 
    88 /**
    89 Com-10 paper size in twips. 
    90 @publishedAll
    91 @released
    92 */
    93 #define KCom_10PaperSizeInTwips TSize(5940,13680)
    94 
    95 /**
    96 Monarch paper size in twips. 
    97 @publishedAll
    98 @released
    99 */
   100 #define KMonarchPaperSizeInTwips TSize(5580,10800)
   101 
   102 /**
   103 DL paper size in twips. 
   104 @publishedAll
   105 @released
   106 */
   107 #define KDLPaperSizeInTwips TSize(6236,12472)
   108 
   109 /**
   110 C5 paper size in twips. 
   111 @publishedAll
   112 @released
   113 */
   114 #define KC5PaperSizeInTwips TSize(9184,12983)
   115 #else
   116 /**
   117 @publishedAll
   118 @released
   119 */
   120 const TSize KA4PaperSizeInTwips(11906,16838);
   121 const TSize KLegalPaperSizeInTwips(12240,20160);
   122 const TSize KExecutivePaperSizeInTwips(10440,15120);
   123 const TSize KLetterPaperSizeInTwips(12240,15840);
   124 const TSize KCom_10PaperSizeInTwips(5940,13680);
   125 const TSize KMonarchPaperSizeInTwips(5580,10800);
   126 const TSize KDLPaperSizeInTwips(6236,12472);
   127 const TSize KC5PaperSizeInTwips(9184,12983);
   128 #endif
   129 
   130 
   131 /**
   132 This enumeration holds the possible panic codes that may be raised 
   133 by the GDI API on detecting an unrecoverable error. */
   134 enum TGdiPanic
   135 	{
   136 	/** Not used */
   137 	EGdiPanic_Unknown				= 0,
   138 	/** One or more of the input parameters to the interface were invalid */
   139 	EGdiPanic_InvalidInputParam		= 1,
   140 	/** Insufficient text for successful completion of the method */
   141 	EGdiPanic_OutOfText				= 2,
   142 	/** Internal failure. */
   143 	EGdiPanic_Invariant				= 3,
   144 	/** Unused panic codes. Can be reused if needed. */
   145 	EGdiPanic_Unused1				= 4,
   146 	EGdiPanic_Unused2				= 5,
   147 	/** Setting a typeface name that is too long */
   148 	EGdiPanic_TypefaceNameOverflow	= 6,
   149 	};
   150 
   151 
   152 /** 24-bit RGB colour value with 8 bits each for red, green and blue.
   153 
   154 All Graphics drawing functions are specified in terms of a 32-bit TRgb colour 
   155 containing the three colour values plus 8 bits for alpha channel. For hardware which 
   156 does not support 24-bit colour, a mapping from TRgb to display colours is 
   157 performed. 
   158 
   159 Generally, the convention for the alpha blending fact is 0 = transparent, 
   160 255 = opaque, unless otherwise stated.  The exception to this are the TRgb constructor 
   161 taking a single value, where the top byte of the passed in parameter is used for 
   162 alpha information and the function Value(), which returns alpha information in the top byte.
   163 In both these cases, 0 means opaque, 255 means transparent.
   164 
   165 The supported display modes are enumerated in the TDisplayMode type. In each 
   166 display mode a unique index can represent each physical colours supported, 
   167 and which can be mapped onto a full RGB value. The mappings are as follows: 
   168 
   169 16-colour displays use the EGA colour set: black, white, and then both light 
   170 and dark versions of grey, red, green, blue, cyan, magenta and yellow
   171 
   172 256-colour displays support 216 colours made up of 6x6x6 RGB values, each 
   173 containing all possible multiples of 51 for R,G,B values. Additionally, all 
   174 remaining 10 shades of pure red, green, blue and grey are represented, by 
   175 adding all remaining multiples of 17. This use of 256 colours is sometimes 
   176 known as the Netscape colour cube.
   177 
   178 4096-colour displays effectively support RGB values with 4 bits per primary 
   179 colour
   180 
   181 64k-colour displays effectively support RGB values with 5 bits allocated to 
   182 red, 6 to green and 5 to blue
   183 
   184 16 million-colour displays support true colour with 8 bits allocated to each 
   185 primary colour
   186 
   187 @publishedAll
   188 @released
   189 @see TDisplayMode
   190 @see DynamicPalette */
   191 class TRgb
   192 	{
   193 public:
   194 	inline TRgb();
   195 	inline TRgb(TUint32 aValue);
   196 	inline TRgb(TUint32 aInternalValue, TInt aAlpha);
   197 	inline TRgb(TInt aRed,TInt aGreen,TInt aBlue);
   198 	inline TRgb(TInt aRed, TInt aGreen, TInt aBlue, TInt aAlpha);
   199 	inline TInt Red() const;
   200 	inline TInt Green() const;
   201 	inline TInt Blue() const;
   202 	inline TInt Alpha() const;
   203 	IMPORT_C void SetRed(TInt aRed);
   204 	IMPORT_C void SetGreen(TInt aGreen);
   205 	IMPORT_C void SetBlue(TInt aBlue);
   206 	IMPORT_C void SetAlpha(TInt aAlpha);
   207 	IMPORT_C static TRgb Gray2(TInt aGray2);
   208 	IMPORT_C static TRgb Gray4(TInt aGray4);
   209 	IMPORT_C static TRgb Gray16(TInt aGray16);
   210 	IMPORT_C static TRgb Gray256(TInt aGray256);
   211 	IMPORT_C static TRgb Color16(TInt aColor16);
   212 	IMPORT_C static TRgb Color256(TInt aColor256);
   213 	IMPORT_C static TRgb Color4K(TInt aColor4K);
   214 	IMPORT_C static TRgb Color64K(TInt aColor64K);
   215 	IMPORT_C static TRgb Color16M(TInt aColor16M);
   216 	IMPORT_C TInt Gray2() const;
   217 	IMPORT_C TInt Gray4() const;
   218 	IMPORT_C TInt Gray16() const;
   219 	IMPORT_C TInt Gray256() const;
   220 	IMPORT_C TInt Color16() const;
   221 	IMPORT_C TInt Color256() const;
   222 	IMPORT_C TInt Color4K() const;
   223 	IMPORT_C TInt Color64K() const;
   224 	IMPORT_C TInt Color16M() const;
   225 	inline TBool operator==(const TRgb& aColor) const;
   226 	inline TBool operator!=(const TRgb& aColor) const;
   227 	inline TRgb operator~() const;
   228 	inline TRgb operator&(const TRgb& aColor);
   229 	inline TRgb operator|(const TRgb& aColor);
   230 	inline TRgb operator^(const TRgb& aColor);
   231 	inline TRgb& operator&=(const TRgb& aColor);
   232 	inline TRgb& operator|=(const TRgb& aColor);
   233 	inline TRgb& operator^=(const TRgb& aColor);
   234 	inline TUint32 Value() const;
   235 	inline TUint32 Internal() const;
   236 	inline void SetInternal(TUint32 aInternal);
   237 	IMPORT_C TInt Difference(const TRgb& aColor) const;
   238 	IMPORT_C void InternalizeL(RReadStream& aStream);
   239 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   240 	IMPORT_C static TRgb Color16MU(TInt a0RGB);
   241 	IMPORT_C TInt Color16MU() const;
   242 	IMPORT_C static TRgb Color16MA(TUint aARGB);
   243 	IMPORT_C TUint Color16MA() const;
   244 	IMPORT_C static TRgb Color16MAP(TUint aARGB);
   245 	IMPORT_C TUint Color16MAP() const;
   246 	IMPORT_C TUint _Color16MAP() const;
   247 	IMPORT_C static TRgb _Color16MAP(TUint aARGB);
   248 	inline TInt _Gray2() const;
   249 	inline TInt _Gray4() const;
   250 	inline TInt _Gray16() const;
   251 	inline TInt _Gray256() const;
   252 	inline TInt _Color4K() const;
   253 	inline TInt _Color64K() const;
   254 	inline TInt _Color16M() const;
   255 	inline TInt _Color16MU() const;
   256 	inline TUint _Color16MA() const;
   257 	inline static TRgb _Gray2(TInt aGray2);
   258 	inline static TRgb _Gray4(TInt aGray4);
   259 	inline static TRgb _Gray16(TInt aGray16);
   260 	inline static TRgb _Gray256(TInt aGray256);
   261 	inline static TRgb _Color4K(TInt aColor4K);
   262 	inline static TRgb _Color64K(TInt aColor64K);
   263 	inline static TRgb _Color16M(TInt aColor16M);
   264 	inline static TRgb _Color16MU(TInt a0RGB);
   265 	inline static TRgb _Color16MA(TUint aARGB);
   266 private:
   267 	TUint32 iValue;
   268 	};
   269 
   270 
   271 /**
   272 @publishedAll
   273 @released
   274 */
   275 #define KRgbBlack		TRgb(0x000000)
   276 #define KRgbDarkGray	TRgb(0x555555)
   277 #define KRgbDarkRed		TRgb(0x000080)
   278 #define KRgbDarkGreen	TRgb(0x008000)
   279 #define KRgbDarkYellow	TRgb(0x008080)
   280 #define KRgbDarkBlue	TRgb(0x800000)
   281 #define KRgbDarkMagenta	TRgb(0x800080)
   282 #define KRgbDarkCyan	TRgb(0x808000)
   283 #define KRgbRed			TRgb(0x0000ff)
   284 #define KRgbGreen		TRgb(0x00ff00)
   285 #define KRgbYellow		TRgb(0x00ffff)
   286 #define KRgbBlue		TRgb(0xff0000)
   287 #define KRgbMagenta		TRgb(0xff00ff)
   288 #define KRgbCyan		TRgb(0xffff00)
   289 #define KRgbGray		TRgb(0xaaaaaa)
   290 #define KRgbWhite		TRgb(0xffffff)
   291 #define KRgbTransparent	TRgb(0x000000,0x00)
   292 
   293 /** A set of static utility functions to get information about a display mode. 
   294 @publishedAll 
   295 @released
   296 */
   297 class TDisplayModeUtils
   298 	{
   299 public:
   300 	IMPORT_C static TBool IsDisplayModeColor(TDisplayMode aDispMode);
   301 	IMPORT_C static TBool IsDisplayModeValid(TDisplayMode aDispMode);
   302 	IMPORT_C static TInt NumDisplayModeColors(TDisplayMode aDispMode);
   303 	IMPORT_C static TInt NumDisplayModeBitsPerPixel(TDisplayMode aDispMode);
   304 	};
   305 
   306 /** Provides user-definable palette support to the GDI.
   307 
   308 A palette is a user-defined set of colours, which is a subset of the full 
   309 range of 24-bit colours. This allows users the advantages of having a low 
   310 bpp colour mode whilst being able to specify the colours available in that 
   311 mode. To give an example, the EColor16 mode provides a palette of 16 colours 
   312 as it provides a mapping between an integer index and a TRgb colour (see the 
   313 table EGA Low-colour constants). Only a palette of 16 colour enables you to 
   314 change the palette. Palettes are also used to allow 24-bit bitmaps to be stored 
   315 in a more compressed form by finding the actual number of different colours 
   316 used in the bitmap, creating a palette to allow the mapping of these colours 
   317 to a smaller index space, and encoding the bitmaps pixels using indexes 
   318 to this new index space. 
   319 
   320 A palette has a size which is set at its creation and cannot be altered 
   321 the number of entries in the palette. Each entry in a palette is a mapping 
   322 between that entrys index and a TRgb value. Palette entries can be got 
   323 and set at any time between the palettes creation and destruction. The 
   324 GDIs palette support also provides functions to find the nearest palette 
   325 colour to a requested TRgb colour. 
   326 @publishedAll
   327 @released
   328 */
   329 class CPalette : public CBase
   330 	{
   331 public:
   332 	IMPORT_C static CPalette* NewL(TInt aNumberOfEntries);
   333 	IMPORT_C static CPalette* NewDefaultL(TDisplayMode aDispMode);
   334 	IMPORT_C ~CPalette();
   335 	IMPORT_C void Clear();
   336 	inline TInt Entries() const;
   337 	IMPORT_C TRgb GetEntry(TInt aPaletteIndex) const;
   338 	IMPORT_C TRgb NearestEntry(const TRgb& aColor) const;
   339 	IMPORT_C TInt NearestIndex(const TRgb& aColor) const;
   340 	IMPORT_C void SetEntry(TInt aPaletteIndex,const TRgb& aPaletteEntry);
   341 	IMPORT_C void GetDataPtr(TInt aFirstColor,TInt aNumColors,TPtr8& aPtr);
   342 protected:
   343 	IMPORT_C CPalette();
   344 	void ConstructL(TInt aNumberOfEntries);
   345 protected:
   346 	TRgb* iArray;
   347 	TInt iNumEntries;
   348 	};
   349 
   350 
   351 /** Enables conversion, in both directions, between a TRgb object and an index 
   352 into an arbitrary 256 colour palette. 
   353 @publishedAll 
   354 @released
   355 */
   356 class TColor256Util
   357 	{
   358 public:
   359 	IMPORT_C void Construct(const CPalette& aPalette);
   360 	IMPORT_C TInt Color256(TRgb aRgb) const;
   361 	IMPORT_C void Color256(TUint8* aDestination,const TRgb* aSource,TInt aNumPixels) const;
   362 	inline TRgb Color256(TInt aColor256) const;
   363 	IMPORT_C static const TColor256Util* Default();
   364 public:
   365 	/** 256 colour lookup table.
   366 	
   367 	Each entry is a 32 bit value which corresponds to a TRgb value in the 
   368 	palette passed to Construct(). If there are more than 256 colours in the 
   369 	palette, the first 256 colours are used in this table. If there are fewer 
   370 	than 256 entries, the remaining entries in the table are set to zero. */
   371 	TUint32	iColorTable[256];
   372 
   373 	/** Inverse colour lookup table.
   374 	
   375 	It has 4096 entries. Each entry is the index of a colour in the palette 
   376 	that the object was created with (see Construct()) that most closely 
   377 	matches the 4096 degrees of intensity of red, green and blue on a uniform 
   378 	16x16x16 colour cube.
   379 	
   380 	It is called "inverse" because iColorTable maps indices (0..255) to TRgb 
   381 	values, but this table maps TRgb values to palette indices. */
   382 	TUint8	iInverseColorTable[0x1000];
   383 	};
   384 
   385 
   386 /** Linear digital differential analyser.
   387 
   388 This is used to calculate the pixels which most closely approximate a specified 
   389 straight line, or when scaling a bitmap. Note that a line is infinitely thin, 
   390 and can only be approximated by pixels with real width and height.
   391 
   392 Functions are provided for: pixel line traversing; jumping to a rectangle or 
   393 co-ordinate 
   394 @publishedAll 
   395 @released
   396 */
   397 class TLinearDDA
   398 	{
   399 public:
   400 	/** LDDA Line mode. */
   401 	enum TLineMode
   402 		{
   403 		/** Centres scan-lines in the pixel line */
   404 		ECenter,
   405 		/** Starts at the beginning of a complete scan line. Used for bitmap 
   406 		scaling. */
   407 		ELeft
   408 		};
   409 public:
   410 	IMPORT_C TLinearDDA();
   411 	IMPORT_C TLinearDDA(const TLinearDDA& aLine);
   412 	IMPORT_C void Construct(const TPoint& aStart,const TPoint& aFinish,TLineMode aMode=ECenter);
   413 	IMPORT_C TBool SingleStep(TPoint& aPosition);
   414 	IMPORT_C TBool SingleScanline(TPoint& aStartPosition,TPoint& aEndPosition);
   415 	IMPORT_C TBool NextStep(TPoint& aPosition);
   416 	IMPORT_C void JumpToRect(const TRect& aRect);
   417 	IMPORT_C void JumpToXCoord(const TInt aXCoord,TInt& aYCoord);
   418 	IMPORT_C void JumpToYCoord(TInt& aXCoord,const TInt aYCoord);
   419 	IMPORT_C void JumpToXCoord2(TInt aXCoord,TInt& aYCoord);
   420 	IMPORT_C void JumpToYCoord2(TInt& aXCoord,TInt aYCoord);
   421 private:
   422 	void UpdatePosition();
   423 private:
   424 	enum TLineStatus
   425 		{
   426 		EInitialised,
   427 		ECurrent,
   428 		EComplete
   429 		};
   430 private:
   431 	TInt iCount;
   432 	TSize iDifference;
   433 	TPoint iFinish;
   434 	TInt iGradient;
   435 	TPoint iInc;
   436 	TPoint iPos;
   437 	TPoint iStart;
   438 	TRect iBoundingRect;
   439 	TBool iBoundingRectSet;
   440 	TInt16 iInsideX; // boolean, defined as TInt16 to maintain binary compatibility
   441 	TInt16 iInsideY; // boolean, defined as TInt16 to maintain binary compatibility
   442 	TLineStatus iStatus;
   443 	};
   444 
   445 
   446 /**
   447 Font posture flags.
   448 Fonts can be either upright or italic. 
   449 @publishedAll	
   450 @released
   451 */
   452 enum TFontPosture
   453 	{
   454 	/** Font posture is normal (upright). */
   455 	EPostureUpright,
   456 	/** Font posture is italic. */
   457 	EPostureItalic
   458 	};
   459 
   460 /**
   461 Font stroke weight flags. 
   462 @publishedAll	
   463 @released
   464 */
   465 enum TFontStrokeWeight
   466 	{
   467 	/** Font stroke weight is normal. */
   468 	EStrokeWeightNormal,
   469 	/** Font stroke weight is bold. */
   470 	EStrokeWeightBold
   471 	};
   472 
   473 /**
   474 Font print position flags.
   475 Fonts can be normal, superscript or subscript. 
   476 @publishedAll	
   477 @released
   478 */
   479 enum TFontPrintPosition
   480 	{
   481 	/** Font is normal. */
   482 	EPrintPosNormal,
   483 	/** Font is superscript. */
   484 	EPrintPosSuperscript,
   485 	/** Font is subscript. */
   486 	EPrintPosSubscript
   487 	};
   488 
   489 /**
   490 Font underline flags. 
   491 @publishedAll	
   492 @released
   493 */
   494 enum TFontUnderline
   495 	{
   496 	/** Font is not underlined. */
   497 	EUnderlineOff,
   498 	/** Font is underlined. */
   499 	EUnderlineOn
   500 	};
   501 
   502 /**
   503 Font strike-through flags. 
   504 @publishedAll	
   505 @released
   506 */
   507 enum TFontStrikethrough
   508 	{
   509 	/** Font is not struck-through. */
   510 	EStrikethroughOff,
   511 	/** Font is struck-through. */
   512 	EStrikethroughOn
   513 	};
   514 
   515 /**
   516 The maximum length of a typeface name (in characters). 
   517 @publishedAll	
   518 @released
   519 */
   520 const TInt KMaxTypefaceNameLength=0x18;
   521 
   522 
   523 /** Typeface name and attributes.
   524 
   525 This class identifies a typeface by name, and contains the combination of 
   526 attributes of the typeface. These attributes define whether it is a symbol 
   527 typeface, whether the typeface is proportional, and whether it is serif or 
   528 sans-serif. 
   529 
   530 The combination of attributes for a typeface are stored in a bitmask, with 
   531 the various bits indicating different attributes. The bitmask is calculated 
   532 for any particular attribute combination by ORing the enumerated value for 
   533 each individual attribute. 
   534 @publishedAll 
   535 @released
   536 */
   537 class TTypeface
   538     {
   539 public:
   540 	enum
   541 		{
   542 		/** Typeface is a proportional typeface (e.g. Swiss)
   543 		*/
   544 		EProportional = 1,
   545 		/** Typeface is a serif typeface (e.g. Times)
   546 		*/
   547 		ESerif = 2,
   548 		/** Typeface is a symbol typeface (e.g. Symbol)
   549 		*/
   550 		ESymbol = 4,
   551 		};
   552 public:
   553 	IMPORT_C TTypeface();
   554 	IMPORT_C TBool operator==(const TTypeface& aTypeface) const;
   555 	IMPORT_C void InternalizeL(RReadStream& aStream);
   556 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   557 	IMPORT_C void SetAttributes(TInt aAttributes);
   558 	IMPORT_C void SetIsProportional(TBool aIsProportional);
   559 	IMPORT_C void SetIsSerif(TBool aIsSerif);
   560 	IMPORT_C void SetIsSymbol(TBool aIsSymbol);
   561 	IMPORT_C TInt Attributes() const;
   562 	IMPORT_C TBool IsProportional() const;
   563 	IMPORT_C TBool IsSerif() const;
   564 	IMPORT_C TBool IsSymbol() const;
   565 	IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
   566 	IMPORT_C void SetScriptTypeForMetrics(TInt aScript);
   567 	IMPORT_C TInt ScriptTypeForMetrics() const;
   568 	IMPORT_C void SetName(const TDesC& aName);
   569 	IMPORT_C const TDesC& Name() const;
   570 private:
   571 	void ResetAttributes();
   572 	void ResetScriptType();
   573 public:
   574 	/** The typeface name. */
   575     TBufC<KMaxTypefaceNameLength> iName;
   576 private:
   577     TUint32 iFlags;
   578     };
   579 
   580 
   581 /**
   582 An enumerated type for the format of a glyph bitmap. This type is currently 
   583 used to indicate whether glyph bitmaps for scalable fonts are drawn anti-aliased. 
   584 Additional values may be defined in the future.
   585 
   586 @see TFontStyle::SetBitmapType()
   587 @see CFbsTypefaceStore::SetDefaultBitmapType() 
   588 @publishedAll
   589 @released	
   590 */
   591 enum TGlyphBitmapType
   592 	{
   593 	/** The font store's default glyph bitmap format is used. */
   594 	EDefaultGlyphBitmap = 0,
   595 	/** The standard monochrome format: no anti-aliasing, 1 bit per pixel, 
   596 	run-length encoded. */
   597 	EMonochromeGlyphBitmap,
   598 	/** Standard 8-bits-per-pixel with anti-aliasing. */
   599 	EAntiAliasedGlyphBitmap,
   600 	/** The format used when sub-pixel font rendering is used. */
   601 	ESubPixelGlyphBitmap,
   602 	/** The format used when outline and shadow font rendering is used. 
   603 
   604 	If the raterizer supports the outline and shadow fonts, it will set the bitmaptype as 
   605 	EFourColourBlendGlyphBitmap but only when glyph bitmap type is set as EAntiAliasedGlyphBitmap and 
   606 	when any of the EDropShadow or EOutline effect is on. Only rasterizer providers can use this enum.
   607 	*/
   608 	EFourColourBlendGlyphBitmap,
   609 	/**
   610 	This is used for glyphs, and not fonts, and is needed to inform the font drawing routines
   611 	that the character should be drawn using the overall font setting. 
   612 	For Internal Use Only.
   613 	*/
   614 	EGlyphBitmapTypeNotDefined,
   615 	/**
   616 	This is used to inform the rasterizer that the best match should be
   617 	found for the bitmap type based upon its knowledge.
   618 	For Internal Use Only.
   619 	*/
   620 	EAntiAliasedOrMonochromeGlyphBitmap,
   621 	};
   622 
   623 /**
   624 Defines a set of font effects flags.
   625 
   626 @publishedAll 
   627 @released
   628 WARNING: This Class is for use by system/UI software ONLY.
   629 */
   630 NONSHARABLE_CLASS(FontEffect)
   631 	{
   632 public:
   633 	enum TEffect
   634 		{
   635 		ENone			= 0x0,		// No effects.
   636 		EAlgorithmicBold= 0x10,		// Font is algorithmic bold (a.k.a pseudo bold.)
   637 		EDropShadow		= 0x20,		// Font has a drop shadow.
   638 		EOutline		= 0x40,		// Font is an outline font.
   639 		EEmbossed		= 0x80,		// Font is embossed.
   640 		EEngraved		= 0x100,	// Font is engraved.
   641 		ESoftEdge		= 0x200,	// Font is soft edged.
   642 		EReserved1		= 0x400,	// Reserved for Symbian use.
   643 		EReserved2		= 0x800,	// Reserved for Symbian use.
   644 		EReserved3		= 0x1000,	// Reserved for Symbian use.
   645 		EReserved4		= 0x2000,	// Reserved for Symbian use.
   646 		EReserved5		= 0x4000,	// Reserved for Symbian use.
   647 		EReserved6		= 0x8000,	// Reserved for Symbian use.
   648 		};
   649 public:
   650 	IMPORT_C static TBool IsEffectOn(TEffect aEffect, TUint32 aFontEffect);
   651 	IMPORT_C static void SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect);
   652 	};
   653 
   654 /** Encapsulates a font style. 
   655 
   656 The font style information is comprised of:
   657 
   658 the posture of the font upright or italic
   659 
   660 the stroke weight of the font  normal or bold
   661 
   662 the print position of the font normal, subscript or superscript
   663 
   664 Note that the underline and strike-through attributes are not included in 
   665 this class, but are set in the graphics context.
   666 
   667 @see CGraphicsContext::SetUnderlineStyle()
   668 @see CGraphicsContext::SetStrikethroughStyle() 
   669 @publishedAll
   670 @released
   671 */
   672 class TFontStyle
   673 	{
   674 public:
   675 	IMPORT_C TFontStyle();
   676 	IMPORT_C TFontStyle(TFontPosture aPost,TFontStrokeWeight aStrWgt,TFontPrintPosition aPrintPos);
   677 	IMPORT_C void InternalizeL(RReadStream& aStream);
   678 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   679 	IMPORT_C TFontPosture Posture() const;
   680 	IMPORT_C TFontStrokeWeight StrokeWeight() const;
   681 	IMPORT_C TFontPrintPosition PrintPosition() const;
   682 	IMPORT_C void SetPosture(TFontPosture aPosture);
   683 	IMPORT_C void SetStrokeWeight(TFontStrokeWeight aStrokeWeight);
   684 	IMPORT_C void SetPrintPosition(TFontPrintPosition aPrintPosition);
   685 	inline TGlyphBitmapType BitmapType() const;
   686 	inline void SetBitmapType(TGlyphBitmapType aBitmapType);
   687 	IMPORT_C TBool operator==(const TFontStyle& aFontStyle) const;
   688 	IMPORT_C TUint32 Effects() const;
   689 	IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const;
   690 	IMPORT_C void SetEffects(TUint32 aEffects);
   691 	IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn);
   692 private:
   693 	enum
   694 		{
   695 		EItalic=0x1,
   696 		EBold=0x2,
   697 		ESuper=0x4,
   698 		ESub=0x8
   699 		};
   700 private:
   701 	TUint32 iFlags; // bitmap type - 16 bits (high), font effects - 12 bits (middle), style - 4 bits (low)
   702 	TAny* iReserved1;
   703 	TAny* iReserved2;
   704 	};
   705 
   706 
   707 
   708 /**
   709 Specifies the font specification in device independent terms.
   710 @publishedAll 
   711 @released
   712 */
   713 class TFontSpec
   714 	{
   715 public:
   716 	IMPORT_C TFontSpec();
   717 	IMPORT_C TFontSpec(const TDesC& aTypefaceName,TInt aHeight);
   718 	IMPORT_C TBool operator==(const TFontSpec& aFontSpec) const;
   719 	IMPORT_C void InternalizeL(RReadStream& aStream);
   720 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   721 	IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage);
   722 	IMPORT_C TInt ScriptTypeForMetrics() const;
   723 public:
   724 	/** The typeface. */
   725 	TTypeface iTypeface;
   726 	/** The height of the typeface (in twips). */
   727 	TInt iHeight;
   728 	/** The font style of the typeface. */
   729 	TFontStyle iFontStyle;
   730 	};
   731 
   732 
   733 
   734 /** Typeface family support information.
   735 
   736 This data-only class includes the name and attributes of a typeface, how many 
   737 font heights are available, its minimum and maximum heights, and whether or 
   738 not it is scaleable  a typeface is scaleable if it supports heights at 
   739 fixed intervals between the minimum and maximum heights. 
   740 @publishedAll 
   741 @released
   742 */
   743 class TTypefaceSupport
   744     {
   745 public:
   746 	/** The name and attributes of the typeface. */
   747     TTypeface iTypeface;
   748 	/** The number of distinct font heights available in the typeface. */
   749     TInt iNumHeights;
   750 	/** The typeface's minimum font height, in twips. */
   751     TInt iMinHeightInTwips;
   752 	/** The typeface's maximum font height, in twips. */
   753     TInt iMaxHeightInTwips;
   754 	/** Whether the typeface is scaleable. ETrue if it is scaleable, otherwise 
   755 	EFalse. */
   756     TBool iIsScalable; // supports heights from min to max at fixed interval
   757     };
   758 
   759 /**
   760 The percentage used to multiply a normal font height when calculating its 
   761 superscript or subscript height. 
   762 @publishedAll	
   763 @released
   764 */
   765 const TInt KSuperSubScalingPercentage=67;
   766 
   767 /**
   768 The percentage of a font height used to calculate its baseline offset for a 
   769 superscript print position. 
   770 @publishedAll	
   771 @released
   772 */
   773 const TInt KSuperscriptOffsetPercentage=-28;
   774 
   775 /**
   776 The percentage of a font height used to calculate its baseline offset for a 
   777 subscript print position. 
   778 @publishedAll	
   779 @released
   780 */
   781 const TInt KSubscriptOffsetPercentage=14;
   782 
   783 class CFont;
   784 
   785 /** Typeface store abstract base interface.
   786 
   787 This class provides the interface to a store for typefaces.
   788 
   789 See also CFontStore. 
   790 @publishedAll
   791 @released
   792 */
   793 class CTypefaceStore : public CBase
   794 	{
   795 public:
   796 	IMPORT_C ~CTypefaceStore();
   797 
   798 	/**
   799 	Gets the font which is the nearest to the given font specification.
   800 
   801 	When the font is no longer needed, call @c ReleaseFont().
   802 
   803 	Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips() 
   804 	yielding (virtually) the same result. However clients are strongly encouraged to use the new
   805 	@c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every 
   806 	character within any given text string will fit within the given amount of twips, whereas the design 
   807 	height is an aesthetic unit decided by the font designer without strict physical meaning, which 
   808 	may result in cropped characters.
   809 
   810 	@param aFont On return, contains a pointer to the nearest font.
   811 	@param aFontSpec The specification of the font to be matched.
   812 	@return KErrNone if successful; a system-wide error code otherwise.
   813 	@publishedAll
   814 	@deprecated Use GetNearestFontToDesignHeightInTwips
   815 	*/
   816 	virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
   817 
   818 	/**
   819 	Gets the font which is the nearest to the given font specification.
   820 	
   821 	When the font is no longer needed, call @c ReleaseFont().
   822 
   823 	This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the 
   824 	same result. However clients are strongly encouraged to use the new
   825 	@c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every 
   826 	character within any given text string will fit within the given amount of twips, whereas the design 
   827 	height is an aesthetic unit decided by the font designer without strict physical meaning, which 
   828 	may result in cropped characters.
   829 
   830 	@param aFont On return, contains a pointer to the nearest font.
   831 	@param aFontSpec The specification of the font to be matched.
   832 	@return KErrNone if successful; a system-wide error code otherwise.
   833 	@publishedAll
   834 	@released
   835 	*/
   836 	virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
   837 	
   838 	/**
   839 	Gets the font which is the nearest to the given font specification.
   840 	
   841 	When the font is no longer needed, call @c ReleaseFont().
   842 
   843 	The font and bitmap server returns a pointer to the nearest matching font 
   844 	from those available. Matches to max height of font - this does its best 
   845 	to return a font that will fit within the maximum height specified (but 
   846 	note that variations due to hinting algorithms may rarely result in this 
   847 	height being exceeded by up to one pixel). Problems can also be 
   848 	encountered with bitmap fonts where the typeface exists but doesn't have 
   849 	a font small enough.
   850 
   851 	@param aFont On return, contains a pointer to the nearest font.
   852 	@param aFontSpec The specification of the font to be matched.
   853 	@param aMaxHeight The maximum height within which the font must fit.
   854 	@return KErrNone if successful; a system-wide error code otherwise.
   855 	@publishedAll
   856 	@released
   857 	*/
   858 	virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) = 0;
   859 
   860 	/** Gets the number of typefaces supported by the typeface store.
   861 	
   862 	@return The number of supported typefaces. */
   863 	virtual TInt NumTypefaces() const=0;
   864 
   865 	/** Gets typeface information for a specified typeface index.
   866  
   867  	This information is returned in aTypefaceSupport, and
   868 	includes the typeface name and typeface attributes, the number of font
   869  	heights, the maximum and minimum font heights, and whether it is a
   870 	scaleable typeface.
   871  
   872  	@param aTypefaceSupport On return, if the function executed successfully, 
   873  	this object contains the typeface information.
   874   	@param aTypefaceIndex A typeface index number, in the range: zero to
   875              (NumTypefaces() - 1). */
   876 	virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
   877 
   878 	/** Gets the height of the font with specified height and typeface indices, 
   879 	in twips.
   880 	
   881 	The value returned is rounded up or down to the nearest font height in twips.
   882 	
   883 	@param aTypefaceIndex A typeface index number, in the range: 0 to 
   884 	(NumTypefaces() - 1). 
   885 	@param aHeightIndex A font height index number.
   886 	@return The height of the font, in twips. */
   887 	virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
   888 	IMPORT_C void ReleaseFont(CFont* aFont);
   889 	IMPORT_C static TInt BaselineOffset(TInt aHeight,TFontPrintPosition aPos);
   890 	IMPORT_C static TInt SuperSubHeight(TInt aHeight,TFontPrintPosition aPos);
   891 protected:
   892 	IMPORT_C CTypefaceStore();
   893 	IMPORT_C void ConstructL();
   894 	IMPORT_C void AddFontL(CFont* aFont);
   895 	IMPORT_C TBool IncrementFontCount(const CFont* aFont);
   896 private:
   897 	TBool FindFont(const CFont* aFont, TInt& aIdx) const;
   898 	NONSHARABLE_CLASS(TFontAccess)
   899 	/**
   900 	Pairs a font with a count of how many clients of the typeface store 
   901 	are accessing that font. 
   902     */
   903 		{
   904 	public:
   905 		/** A device specific font. */
   906 		CFont* iFont;
   907 		/** The number of clients accessing the font. */
   908 		TInt iAccessCount;
   909 		};
   910 protected:
   911 	/** A list of fonts accessed by clients of the typeface store, which pairs 
   912 	a font with a count of the number of clients accessing the font.
   913 	
   914 	Implemented as an array of TFontAccess objects.
   915 	
   916 	An object is added to this array for every font accessed. If the font is 
   917 	released by all clients, and the access count drops to zero, the font is 
   918 	removed from the list. */
   919 	CArrayFixFlat<TFontAccess>* iFontAccess;
   920 	};
   921 
   922 /** The maximum number of entries in the font cache.
   923 
   924 @see CFontCache */
   925 const TInt KMaxFontCacheEntries=32;
   926 
   927 /** Font cache. 
   928 
   929 When a CFont* needs to be found for a particular TFontSpec, the cache can 
   930 be searched to see if the TFontSpec is already in the cache. If the TFontSpec 
   931 is in the cache, its corresponding CFont* can be returned. Otherwise 
   932 GetNearestFontInTwips() must be used to search all of the available fonts for 
   933 the nearest CFont- a procedure which takes much longer than a simple cache
   934 search.
   935 
   936 The current font cache should be destroyed and a new cache created whenever 
   937 the zoom factor or device map changes, as these changes break the relation 
   938 between CFont and TFontSpec. 
   939 @publishedAll
   940 @released
   941 */
   942 class CFontCache : public CBase
   943 	{
   944 public:
   945 	IMPORT_C CFontCache();
   946 	IMPORT_C CFontCache(TInt aMaxEntries);
   947 	IMPORT_C ~CFontCache();
   948 	IMPORT_C CFont* Search(const TFontSpec& aFontSpec);
   949 	IMPORT_C CFont* AddEntryL(CFont* aFont,const TFontSpec& aFontSpec);
   950 	IMPORT_C CFont* RemoveFirstEntry();
   951 public:
   952 	/** The number of cache hits since the font cache was created i.e. 
   953 	successful results from CFontCache::Search(). */
   954 	TInt iNumHits;
   955 	/** The number of cache misses since the font cache was created i.e. 
   956 	unsuccessful results from CFontCache::Search(). */
   957 	TInt iNumMisses;
   958 private:
   959 	class CFontCacheEntry : public CBase
   960 		{
   961 	public:
   962 		CFontCacheEntry(CFont* aFont,const TFontSpec& aFontSpec,CFontCacheEntry* aNext);
   963 	public:
   964 		CFont* iFont;
   965 		TFontSpec iSpec;
   966 		CFontCacheEntry* iNext;
   967 		};
   968 private:
   969 	TInt iNumEntries;
   970 	TInt iMaxEntries;
   971 	CFontCacheEntry* iFirst;
   972 	};
   973 
   974 /** Interface class for mapping between twips and device-specific units (pixels).
   975 
   976 TZoomFactor is derived from MGraphicsDeviceMap.
   977 
   978 @see CGraphicsDevice
   979 @see TZoomFactor 
   980 @publishedAll
   981 @released
   982 */
   983 class MGraphicsDeviceMap
   984     {
   985 public:
   986 	IMPORT_C MGraphicsDeviceMap();
   987 	IMPORT_C virtual ~MGraphicsDeviceMap();
   988 	IMPORT_C TPoint TwipsToPixels(const TPoint& aTwipPoint) const;
   989 	IMPORT_C TRect TwipsToPixels(const TRect& aTwipRect) const;
   990 	IMPORT_C TPoint PixelsToTwips(const TPoint& aPixelPoint) const;
   991 	IMPORT_C TRect PixelsToTwips(const TRect& aPixelRect) const;
   992 
   993 	/** Converts a horizontal dimension from twips to pixels.
   994 	
   995 	An implementation is supplied by a derived class.
   996 	
   997 	@param aTwips A horizontal dimension of a device in twips. 
   998 	@return A horizontal dimension of a device in pixels. */
   999 	virtual TInt HorizontalTwipsToPixels(TInt aTwips) const=0;
  1000 
  1001 	/** Converts a vertical dimension from twips to pixels.
  1002 	
  1003 	An implementation is supplied by a derived class.
  1004 	
  1005 	@param aTwips A vertical dimension of a device in twips. 
  1006 	@return A vertical dimension of a device in pixels. */
  1007 	virtual TInt VerticalTwipsToPixels(TInt aTwips) const=0;
  1008 
  1009 	/** Converts a horizontal dimension from pixels to twips.
  1010 	
  1011 	An implementation is supplied by a derived class.
  1012 	
  1013 	@param aPixels A horizontal dimension of a device in pixels. 
  1014 	@return A horizontal dimension of a device in twips. */
  1015 	virtual TInt HorizontalPixelsToTwips(TInt aPixels) const=0;
  1016 
  1017 	/** Converts a vertical dimension from pixels to twips.
  1018 	
  1019 	An implementation is supplied by a derived class.
  1020 	
  1021 	@param aPixels A vertical dimension of a device in pixels. 
  1022 	@return A vertical dimension of a device in twips. */
  1023 	virtual TInt VerticalPixelsToTwips(TInt aPixels) const=0;
  1024 
  1025 	/**
  1026 	Gets the font which is the nearest to the given font specification.
  1027 
  1028 	When the font is no longer needed, call @c ReleaseFont().
  1029 
  1030 	Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips() 
  1031 	yielding (virtually) the same result. However clients are strongly encouraged to use the new
  1032 	@c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every 
  1033 	character within any given text string will fit within the given amount of twips, whereas the design 
  1034 	height is an aesthetic unit decided by the font designer without strict physical meaning, which 
  1035 	may result in cropped characters.
  1036 
  1037 	@param aFont On return, contains a pointer to the nearest font.
  1038 	@param aFontSpec The specification of the font to be matched.
  1039 	@return KErrNone if successful; a system-wide error code otherwise.
  1040 	@publishedAll
  1041 	@deprecated Use GetNearestFontToDesignHeightInTwips
  1042 	*/
  1043 	virtual TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)=0;
  1044 
  1045 	/**
  1046 	Gets the font which is the nearest to the given font specification.
  1047 	
  1048 	When the font is no longer needed, call @c ReleaseFont().
  1049 
  1050 	This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the 
  1051 	same result. However clients are strongly encouraged to use the new
  1052 	@c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every 
  1053 	character within any given text string will fit within the given amount of twips, whereas the design 
  1054 	height is an aesthetic unit decided by the font designer without strict physical meaning, which 
  1055 	may result in cropped characters.
  1056 
  1057 	@param aFont On return, contains a pointer to the nearest font.
  1058 	@param aFontSpec The specification of the font to be matched.
  1059 	@return KErrNone if successful; a system-wide error code otherwise.
  1060 	@publishedAll
  1061 	@released
  1062 	*/
  1063 	virtual TInt GetNearestFontToDesignHeightInTwips(
  1064 		CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; }
  1065 
  1066 	/**
  1067 	Gets the font which is the nearest to the given font specification.
  1068 
  1069 	When the font is no longer needed, call @c ReleaseFont().
  1070 
  1071 	The font and bitmap server returns a pointer to the nearest matching font 
  1072 	from those available. Matches to max height of font - this does its best 
  1073 	to return a font that will fit within the maximum height specified (but 
  1074 	note that variations due to hinting algorithms may rarely result in this 
  1075 	height being exceeded by up to one pixel). Problems can also be 
  1076 	encountered with bitmap fonts where the typeface exists but doesn't have 
  1077 	a font small enough.
  1078 
  1079 	@param aFont On return, contains a pointer to the nearest font.
  1080 	@param aFontSpec The specification of the font to be matched.
  1081 	@param aMaxHeight The maximum height within which the font must fit.
  1082 	This overrides the height specified in aFontSpec.
  1083 	@return KErrNone if successful; a system-wide error code otherwise.
  1084 	@publishedAll
  1085 	@released
  1086 	*/
  1087 	virtual TInt GetNearestFontToMaxHeightInTwips(
  1088 		CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; }
  1089 
  1090 	/** Releases the specified font.
  1091 	
  1092 	It is used to indicate that the specified font is no longer needed for use 
  1093 	by the device map. As fonts can be shared between applications, this 
  1094 	function does not delete the copy of the font from RAM unless the font was 
  1095 	only being used by this particular device map.
  1096 	
  1097 	An implementation is supplied by a derived class.
  1098 	
  1099 	@param aFont A pointer to the font to be released. */
  1100 	virtual void ReleaseFont(CFont* aFont)=0;
  1101     };
  1102 
  1103 class CGraphicsContext;
  1104 
  1105 /** Specifies the interface for concrete device classes.
  1106 
  1107 It holds information on the capabilities and attributes of a graphics device. 
  1108 The CBitmapDevice and CPrinterDevice classes are derived from CGraphicsDevice.
  1109 
  1110 @see CGraphicsDevice
  1111 @see CPrinterDevice 
  1112 @publishedAll
  1113 @released
  1114 */
  1115 class CGraphicsDevice : public CBase , public MGraphicsDeviceMap
  1116     {
  1117 public:
  1118 	/** Gets the display mode of the device.
  1119 	
  1120 	@return The display mode of the device. */
  1121 	virtual TDisplayMode DisplayMode() const=0;
  1122 
  1123 	/** Gets the size of the device area in pixels.
  1124 	
  1125 	@return The width and height of the device area, in pixels */
  1126 	virtual TSize SizeInPixels() const=0;
  1127 
  1128 	/** Gets the size of the device area in twips.
  1129 	
  1130 	@return The width and height of the device area, in twips */
  1131 	virtual TSize SizeInTwips() const=0;
  1132 
  1133  	/** Creates a graphics context for the device.
  1134 	
  1135 	@param aGC On return, contains a pointer to the created graphics context. 
  1136 	@return KErrNone, if successful; otherwise, another of the system-wide error 
  1137 	codes. */
  1138     virtual TInt CreateContext(CGraphicsContext*& aGC)=0;
  1139 
  1140 	/** Gets the number of typefaces supported by the graphics device.
  1141 	
  1142 	@return The number of typefaces supported. */
  1143     virtual TInt NumTypefaces() const=0;
  1144 
  1145  	/** Gets typeface information for a specified typeface.
  1146 	
  1147 	This information is returned in aTypefaceSupport, and includes:
  1148 	
  1149 	the typeface name and typeface attributes
  1150 	
  1151 	the number of font heights
  1152 	
  1153 	the maximum and minimum font heights
  1154 	
  1155 	whether it is a scalable typeface
  1156 	
  1157 	@param aTypefaceSupport On return, contains the typeface information. 
  1158 	@param aTypefaceIndex A typeface index number, in the range: zero to 
  1159 	(NumTypefaces() - 1). 
  1160 	@see NumTypefaces() */
  1161     virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0;
  1162 
  1163 	/** Get the height of a font in twips.
  1164 	
  1165 	The font is identified by typeface and height.
  1166 	
  1167 	The value returned is rounded up or down to the nearest font height in twips.
  1168 	
  1169 	@param aTypefaceIndex An index identifying the typeface, in the range: 0 
  1170 	to (NumTypefaces() - 1). 
  1171 	@param aHeightIndex An index identifying the font height, in the range: 0 
  1172 	to (iNumHeights - 1). Note that iNumHeights is in the TTypefaceSupport 
  1173 	object returned by TypefaceSupport(). 
  1174 	@return The height of the font, in twips. */
  1175 	virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
  1176 
  1177 	/** Gets the palette attributes of the device.
  1178 	
  1179 	@param aModifiable On return, holds information on whether or not the device's 
  1180 	palette is modifiable (ETrue) or fixed (EFalse). 
  1181 	@param aNumEntries On return, holds the number of entries in the device's 
  1182 	palette. */
  1183 	virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const=0;
  1184 
  1185 	/** Sets the device's palette.
  1186 	
  1187 	Setting the palette is only possible if the device has a modifiable palette, 
  1188 	which can be determined by calling PaletteAttributes().
  1189 	
  1190 	@param aPalette The new palette for the device. */
  1191 	virtual void SetPalette(CPalette* aPalette)=0;
  1192 
  1193 	/** Gets the device's current palette.
  1194 	
  1195 	This function is only supported if the device has a modifiable palette, 
  1196 	which can be determined by calling PaletteAttributes().
  1197 	
  1198 	@param aPalette On return, holds the device's current palette.
  1199 	@return KErrNone, if successful; otherwise, another of the system-wide error 
  1200 	codes. */
  1201 	virtual TInt GetPalette(CPalette*& aPalette) const=0;
  1202     };
  1203 
  1204 
  1205 /** 
  1206 Code section range information. 
  1207 
  1208 A code section defines the bitmaps for characters in a specified range -
  1209 the range is stored in objects of this type. 
  1210 @publishedAll
  1211 @deprecated 	This is not used anywhere in version 6.0.
  1212 */
  1213 class TCodeSection
  1214 	{
  1215 public:
  1216 	/** The beginning of the range. */
  1217 	TInt iStart;
  1218 	/** The end of the range. */
  1219 	TInt iEnd;
  1220 	};
  1221 
  1222 /**
  1223 WARNING: this Class is for internal use ONLY.  Compatibility is not guaranteed in future releases.
  1224 UIDs corresponding to the CFont API extension functions
  1225 @internalTechnology
  1226 */
  1227 const TUid KFontCapitalAscent	= {0x1020498E};
  1228 const TUid KFontMaxAscent		= {0x10204B10};
  1229 const TUid KFontStandardDescent	= {0x10204B11};
  1230 const TUid KFontMaxDescent		= {0x10205AFC};
  1231 const TUid KFontLineGap			= {0x10204B12};
  1232 const TUid KFontGetFontTable    = {0x102872C1};
  1233 const TUid KFontGetGlyphOutline = {0x102872C2};
  1234 const TUid KFontReleaseGlyphOutline = {0x2002A1FD};
  1235 const TUid KFontReleaseFontTable = {0x2002AC24};
  1236 
  1237 
  1238 /** Abstract font interface.
  1239 
  1240 The CFont class provides a device-independent interface to a device-dependent 
  1241 font usually obtained from a call to GetNearestFont...() on a graphics device. 
  1242 It is used as a handle in CGraphicsContext::UseFont() and to obtain 
  1243 device-dependent information about the font - notably the pixel width of a text 
  1244 string.
  1245 
  1246 @see CFbsFont
  1247 @see CGraphicsContext::UseFont() 
  1248 @publishedAll 
  1249 @released
  1250 */
  1251 class CFont : public CBase
  1252 	{
  1253 	friend class CTypefaceStore;
  1254 public:
  1255 
  1256 	/** Text direction flags.
  1257 
  1258 	This enum is used in TMeasureTextInput and determines whether the text is 
  1259 	drawn horizontally or vertically. Note: text is drawn vertically in some 
  1260 	styles of Japanese, etc.
  1261 
  1262 	@see TMeasureTextInput */
  1263 	enum TTextDirection
  1264 		{
  1265 	/** Text is drawn horizontally. */
  1266  		/** Text is drawn horizontally. */
  1267    		EHorizontal,
  1268  		/** Text is drawn vertically. */
  1269 		EVertical
  1270 		};
  1271 
  1272 	/** Complicated parameter block used for contextual glyph selection, 
  1273 	ligature creation and diacritic placement when drawing text in complex 
  1274 	scripts
  1275 
  1276 	This class declares a constructor, another scoped class, and several other 
  1277 	enums. However this class is unlikely to be useful to third party developers.
  1278 
  1279 	@see CFont::GetCharacterPosition()
  1280 	@see CFont::GetCharacterPosition2()
  1281 	@publishedAll
  1282 	@released
  1283 	*/
  1284 	class TPositionParam
  1285 		{
  1286 	public:
  1287 		/** Standard constructor. */
  1288 		TPositionParam():
  1289 			iDirection(EHorizontal),
  1290 			iFlags(0),
  1291 			iPosInText(0),
  1292 			iOutputGlyphs(0)
  1293 			{
  1294 			}
  1295 
  1296 		enum
  1297 			{
  1298 			EMaxInputChars = 18,	// ligatures cannot be made from more than 18 components
  1299 			EMaxOutputGlyphs = 8	// output can consist of up to 8 characters (one base and 7 combining characters)
  1300 			};
  1301 
  1302 		/**Flags for TPositionParam::iFlags. */
  1303 		enum TFlags
  1304 			{
  1305 			/** Input text is logically ordered not visually ordered. */
  1306 			EFLogicalOrder = 1
  1307 			};
  1308 
  1309 		/** Input: Orientation (EHorizontal or EVertical) in which to draw
  1310 		the text. */
  1311 		TInt16 iDirection;
  1312 		/** Input: Flags from TFlags. */
  1313 		TUint16 iFlags;
  1314 		/** Input: Text containing the characters to be positioned. */
  1315 		TPtrC iText;
  1316 
  1317 		/** Input and output: Position within iText to shape. On exit
  1318 		it will index the first character not positioned */
  1319 		TInt iPosInText;
  1320 		/** Input and output: Pen position. */
  1321 		TPoint iPen;			
  1322 
  1323 		/** Output of GetCharacterPosition and GetCharacterPosition2.
  1324 		@see CFont::GetCharacterPosition
  1325 		@see CFont::GetCharacterPosition2
  1326 		@publishedAll
  1327 		@released */
  1328 		class TOutput
  1329 			{
  1330 		public:
  1331 			/** Standard constructor. */
  1332 			TOutput() : iBitmapSize(TSize::EUninitialized),
  1333 				iBounds(TRect::EUninitialized) {}
  1334 			/** Character or glyph code. */
  1335 			TUint iCode;			
  1336 			/** Bitmap data for the glyph, if available */
  1337 			const TUint8* iBitmap;	
  1338 			/** Size of the bitmap before algorithmic bolding, size 
  1339 			multiplication, etc. */
  1340 			TSize iBitmapSize;		
  1341 			/** Bitmap bounds relative to the original pen position. */
  1342 			TRect iBounds;			
  1343 			};
  1344 
  1345 		/** Information about the glyphs that were output. */
  1346 		TOutput iOutput[EMaxOutputGlyphs];	
  1347 		/** Number of glyphs actually output. */
  1348 		TInt iOutputGlyphs;					
  1349 		};	
  1350 
  1351 
  1352 	/** Input parameter block.
  1353 
  1354 	This is optionally used by CFont::MeasureText(), which is the powerful text 
  1355 	measurement function underlying all the other text measurement functions.
  1356 
  1357 	@see CFont::MeasureText() 
  1358 	@publishedAll
  1359 	@released
  1360 	*/
  1361 	class TMeasureTextInput
  1362 		{
  1363 	public:
  1364 		TMeasureTextInput():
  1365 			iStartInputChar(0),
  1366 			iEndInputChar(KMaxTInt),
  1367 			iDirection(EHorizontal),
  1368 			iFlags(0),
  1369 			iMaxAdvance(KMaxTInt),
  1370 			iMaxBounds(KMaxTInt),
  1371 			iCharJustNum(0),
  1372 			iCharJustExcess(0),
  1373 			iWordJustNum(0),
  1374 			iWordJustExcess(0)
  1375 			{
  1376 			}
  1377 
  1378 		/**Flags for TMeasureTextInput::iFlags. */
  1379 		enum TFlags
  1380 			{
  1381  			/** Input text is visually ordered left-to-right. */
  1382  			EFVisualOrder = 1,
  1383  			/** Input text is visually ordered right-to-left.
  1384  			Overrides EFVisualOrder. */
  1385  			EFVisualOrderRightToLeft = 2,
  1386  			/** Flag to consider side bearings when checking bounds for line-break */
  1387  			EFIncludePenPositionInBoundsCheck = 4
  1388 			};
  1389 
  1390 		/** Starting index specifying first input character in iText.
  1391 	
  1392 		Together with iEndInputChar, this allows some context before and 
  1393 		after the measured text to be supplied so that shaping can work 
  1394 		properly. */
  1395 		TInt iStartInputChar;	
  1396 	
  1397 		/** Index specifying the final input character.
  1398 	
  1399 		Together with iStartInputChar, this allows some context before and 
  1400 		after the measured text to be supplied so that shaping can work 
  1401 		properly. */
  1402 		TInt iEndInputChar;		
  1403 	
  1404 		/** The direction in which to draw the text. */
  1405 		TUint16 iDirection;
  1406 	
  1407 		/** Flags from TFlags. */
  1408 		TUint16 iFlags;
  1409 	
  1410 		/** The maximum advance. */
  1411 		TInt iMaxAdvance;		
  1412 		
  1413 		/** The maximum width (or height if drawing vertically) of bounds. */
  1414 		TInt iMaxBounds;		
  1415 	
  1416 		/** The number of glyph groups to be letter-spaced. */
  1417 		TInt iCharJustNum;		
  1418 	
  1419 		/** The amount of space to be used for letter spacing. */
  1420 		TInt iCharJustExcess;	
  1421 		
  1422 		/** The number of spaces to be used for word spacing. */
  1423 		TInt iWordJustNum;		
  1424 	
  1425 		/** The amount of space to be used for word spacing. */
  1426 		TInt iWordJustExcess;	
  1427 		};
  1428 
  1429 	/** Output parameter block.
  1430 
  1431 	This is optionally used by CFont::MeasureText(), which is the powerful text 
  1432 	measurement function underlying all the other text measurement functions.
  1433 
  1434 	@see CFont::MeasureText() 
  1435 	@publishedAll
  1436 	@released
  1437 	*/
  1438 	class TMeasureTextOutput
  1439 		{
  1440 		public:
  1441 		/** The number of input characters that would be drawn.
  1442 	
  1443 		This may be less than the length of the text if a maximum advance or bounding 
  1444 		box size is specified. */
  1445 		TInt iChars;			
  1446 		/** The number of glyphs that would be drawn. */
  1447 		TInt iGlyphs;			
  1448 		/** The number of groups that would be drawn.
  1449 	
  1450 		A group is a base glyph plus one or more combining characters. */
  1451 		TInt iGroups;			
  1452 		/** The number of word spaces (U+0020) that would be drawn. */
  1453 		TInt iSpaces;			
  1454 		/** The bounding box of all the glyphs that would be drawn. */
  1455 		TRect iBounds;			
  1456 		/** The maximum width and height of any glyph. */
  1457 		TSize iMaxGlyphSize;	
  1458 		};
  1459 
  1460 	/**
  1461 	Data availability flags.
  1462 
  1463 	Some fonts like printer fonts may only have width information and can return 
  1464 	ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize 
  1465 	the rest of the data if necessary.
  1466 
  1467 	@see GetCharacterData() 
  1468 	@publishedAll	
  1469 	@released
  1470 	*/
  1471 	enum TCharacterDataAvailability
  1472 		{
  1473 		/** No font information available. */
  1474 		ENoCharacterData,
  1475 		/** Width information only is available. */
  1476 		ECharacterWidthOnly,
  1477 		/** All character data is available. */
  1478 		EAllCharacterData
  1479 		};
  1480 
  1481 private:
  1482 	// virtual functions have been made protected and public non-virtual ones
  1483 	// added to convert CFont to a handle-body pattern. SC is kept throught the
  1484 	// new functions and BC is kept by keeping the protected functions in the
  1485 	// same place in the class, and therefore in the same place in the vtable
  1486 	/**
  1487 	@publishedAll
  1488 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1489 	*/
  1490 	virtual TUid DoTypeUid() const=0;
  1491 	/**
  1492 	@publishedAll
  1493 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1494 	*/
  1495 	virtual TInt DoHeightInPixels() const=0;
  1496 	/**
  1497 	@publishedAll
  1498 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1499 	*/
  1500 	virtual TInt DoAscentInPixels() const=0;
  1501 	IMPORT_C virtual TInt DoDescentInPixels() const;
  1502 	/**
  1503 	@publishedAll
  1504 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1505 	*/
  1506 	virtual TInt DoCharWidthInPixels(TChar aChar) const=0;
  1507 	/**
  1508 	@publishedAll
  1509 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1510 	*/
  1511 	virtual TInt DoTextWidthInPixels(const TDesC& aText) const=0;
  1512 	/**
  1513 	@publishedAll
  1514 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1515 	*/
  1516 	virtual TInt DoBaselineOffsetInPixels() const=0;
  1517 	/**
  1518 	@publishedAll
  1519 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1520 	*/
  1521 	virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const=0;
  1522 	/**
  1523 	@publishedAll
  1524 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1525 	*/
  1526 	virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0;
  1527 	/**
  1528 	@publishedAll
  1529 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1530 	*/
  1531 	virtual TInt DoMaxCharWidthInPixels() const=0;
  1532 	/**
  1533 	@publishedAll
  1534 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1535 	*/
  1536 	virtual TInt DoMaxNormalCharWidthInPixels() const=0;
  1537 	/**
  1538 	@publishedAll
  1539 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases. Please see derived class for implementation.
  1540 	*/
  1541 	virtual TFontSpec DoFontSpecInTwips() const=0;
  1542 
  1543 protected:	
  1544 	IMPORT_C virtual TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
  1545 	IMPORT_C virtual TBool DoGetCharacterPosition(TPositionParam& aParam) const;
  1546 	IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
  1547 
  1548 protected:
  1549 	IMPORT_C virtual ~CFont();
  1550 
  1551 public:
  1552 	inline TInt FontCapitalAscent() const;
  1553 	inline TInt FontMaxAscent() const;
  1554 	inline TInt FontStandardDescent() const;
  1555 	inline TInt FontMaxDescent() const;
  1556 	inline TInt FontLineGap() const;
  1557 	inline TInt FontMaxHeight() const;
  1558 
  1559 public:
  1560 	/** Gets run-time identity of the actual font type. This enables safe casting to 
  1561 	a derived type.
  1562 	
  1563 	For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid. 
  1564 	You would need to cast to a CFbsFont to get a character bounding box. Similarly, 
  1565 	a CBitmapFont returns KCBitmapFontUidVal.
  1566 	
  1567 	@return The font-type identifier. */
  1568 	IMPORT_C TUid TypeUid() const;
  1569 
  1570 	/** Gets the font height in pixels.
  1571 	Note that this deprecated function is replaced by the new @c FontMaxHeight().
  1572 
  1573 	@return The font height in pixels.
  1574 	@see FontMaxHeight()
  1575 	@deprecated */
  1576 	IMPORT_C TInt HeightInPixels() const;
  1577 
  1578 	/** Gets the font ascent in pixels.
  1579 	Note that this deprecated function is replaced by the new @c FontMaxAscent()
  1580 	or in some cases @c FontCapitalAscent().	
  1581 	
  1582 	@return The font ascent in pixels.
  1583 	@see FontCapitalAscent()
  1584 	@see FontMaxAscent()
  1585 	@deprecated */
  1586 	IMPORT_C TInt AscentInPixels() const;
  1587 	
  1588 	/** Gets the font descent in pixels.
  1589 	Note that this deprecated function is replaced by the new @c FontMaxDescent()
  1590 	or in some cases @c FontStandardDescent().	
  1591 	
  1592 	@return The font descent in pixels.
  1593 	@see FontStandardDescent() 
  1594 	@see FontMaxDescent()
  1595 	@deprecated */
  1596 	IMPORT_C TInt DescentInPixels() const;
  1597 
  1598 	/** Gets the width in pixels in this font of the specified character.
  1599 	
  1600 	Note: For OpenType fonts this function returns the horizontal advance of
  1601 	the character, which may be different from the actual width.
  1602 	
  1603 	@param aChar The character whose width should be determined. 
  1604 	@return The width in pixels of the specified character in this font. */
  1605 	IMPORT_C TInt CharWidthInPixels(TChar aChar) const;
  1606 
  1607 	/** Gets the width in pixels of the specified descriptor when displayed in this 
  1608 	font.
  1609 	
  1610 	@param aText The descriptor whose width should be determined. 
  1611 	@return The width of the specified descriptor when displayed in this font, 
  1612 	in pixels. */
  1613 	IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const;
  1614 
  1615 	/** Gets the baseline offset in pixels. 
  1616 	
  1617 	The baseline offset is how far a font is raised or lowered from its normal 
  1618 	baseline.
  1619 	
  1620 	@return Offset from normal baseline, in pixels. */
  1621 	IMPORT_C TInt BaselineOffsetInPixels() const;
  1622 
  1623 	/** Gets how much of the specified descriptor can be displayed in this font without 
  1624 	exceeding the specified width.
  1625 	
  1626 	Note:
  1627 	
  1628 	This function does not display any of the descriptor itself - it is used 
  1629 	before display, to test whether the whole descriptor can be displayed.
  1630 	
  1631 	@param aText The descriptor. 
  1632 	@param aWidthInPixels The available width for character display. 
  1633 	@return The number of characters which will be able to be displayed without 
  1634 	exceeding the specified width. The count starts from the beginning of the 
  1635 	descriptor. */
  1636 	IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const;
  1637 
  1638 	/** Gets how much of the specified descriptor can be displayed in this font without 
  1639 	exceeding the specified width. 
  1640 	
  1641 	It also returns the excess width - defined as the specified available width 
  1642 	minus the width of the portion of the descriptor which can be displayed without 
  1643 	exceeding the available width.
  1644 	
  1645 	@param aText The descriptor. 
  1646 	@param aWidthInPixels The available width for character display. 
  1647 	@param aExcessWidthInPixels The excess width after displaying the portion of 
  1648 	the descriptor, in pixels. 
  1649 	@return The number of characters which will be able to be displayed without 
  1650 	exceeding the specified width. The count starts from the beginning of the 
  1651 	descriptor. */
  1652 	IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
  1653 
  1654 	/** Gets the width in pixels of the widest character in this font.
  1655 	
  1656 	@return The width of the maximum width character, in pixels. */
  1657 	IMPORT_C TInt MaxCharWidthInPixels() const;
  1658 
  1659 	/** Gets the width in pixels of the widest normal character in this font.
  1660 	
  1661 	Normal characters include all character in a character set except non-alphabetic 
  1662 	characters (e.g. the copyright symbol, or a block graphics symbol, for example).
  1663 	
  1664 	@return The width of the maximum width normal character, in pixels. */
  1665 	IMPORT_C TInt MaxNormalCharWidthInPixels() const;
  1666 
  1667 	/** Gets the font specification of this font in twips.
  1668 	
  1669 	@return The font specification of this font (in twips). */
  1670 	IMPORT_C TFontSpec FontSpecInTwips() const;
  1671 	IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
  1672 	IMPORT_C TBool GetCharacterPosition(TPositionParam& aParam) const;
  1673 	IMPORT_C TInt WidthZeroInPixels() const;
  1674 	IMPORT_C TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL, TMeasureTextOutput* aOutput = NULL) const;
  1675 	IMPORT_C static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter);
  1676 	IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
  1677 	IMPORT_C TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const;
  1678 
  1679 	/** Gets the width in pixels of the specified descriptor when displayed in this 
  1680 	font.
  1681 	
  1682 	@param aText The descriptor whose width should be determined.
  1683 	@param aParam Parameter block that controls how much of aText is measured
  1684 	@return The width of the specified descriptor when displayed in this font, 
  1685 	in pixels. */
  1686 	IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const;
  1687 	};
  1688 
  1689 class CFbsBitmap;
  1690 class CWsBitmap;
  1691 /** Abstract base class for all graphics contexts.
  1692 
  1693 Created by a CGraphicsDevice.
  1694 
  1695 Provides the 'context' in which you are drawing to an associated device, in 
  1696 the sense that it holds the settings for drawing, such as the pen and brush 
  1697 settings (e.g. color, line styles) and the font settings (e.g. bold, underline, 
  1698 italic). These settings are device-independent.
  1699 
  1700 Also provides the clipping region (the visible drawing area).
  1701 
  1702 The settings and clipping area can be updated while drawing.
  1703 
  1704 This class also contains the main drawing functions, and all drawing is done 
  1705 through a CGraphicsContext.
  1706 
  1707 The graphics context deals with pixels of device-dependent size and uses fonts 
  1708 with device-dependent size and representation. The sizes and fonts to be passed 
  1709 to the class functions therefore need to be converted from size-independent 
  1710 units to size-dependent units first. This is done by an MGraphicsDeviceMap 
  1711 derived class. This may be a TZoomFactor or the CGraphicsDevice.
  1712 
  1713 See CGraphicsContext::Reset() for the default graphics context settings immediately 
  1714 after construction.
  1715 
  1716 @see CBitmapContext 
  1717 @publishedAll
  1718 @released
  1719 */
  1720 class CGraphicsContext : public CBase
  1721 	{
  1722 public:
  1723 
  1724 
  1725 	/** Text alignment.
  1726 	@publishedAll
  1727 	@released
  1728 	*/
  1729 	enum TTextAlign
  1730 		{
  1731 		/** Text is left-aligned. */
  1732 		ELeft,
  1733 		/** Text is centred. */
  1734 		ECenter,
  1735 		/** Text is right-aligned. */
  1736 		ERight
  1737 		};
  1738 
  1739 	/** 
  1740 	Drawing mode components.
  1741 	This enum is not intended to be used directly, but provides components for 
  1742 	the easy specification of drawing modes in the TDrawMode enum. 
  1743 	@publishedAll
  1744 	@released
  1745 	*/
  1746 	enum TDrawModeComponents
  1747 		{
  1748 		/** 1 */
  1749 		EInvertScreen=1,
  1750 		/** 2 */
  1751 		EXor=2,
  1752 		/** 4 */
  1753 		EOr=4,
  1754 		/** 8 */
  1755 		EAnd=8,
  1756 		/** 14 */
  1757 		ELogicalOp=14,
  1758 		/** 16 */
  1759 		EInvertPen=16,
  1760 		/** 32 */
  1761 		EPenmode=32,
  1762 		/** 64 */
  1763 		EWriteAlpha=64,
  1764 		};
  1765 
  1766 
  1767 	/** 
  1768 	Drawing modes.
  1769 
  1770 	This enum builds on the drawing mode components in the TDrawModeComponents 
  1771 	enum.
  1772 
  1773 	If the pen colour is p, brush colour is b and screen colour is s, the effect 
  1774 	of TDrawMode::EDrawModeAND is P=p&s and B=b&s. In other words, the effective 
  1775 	colour of the pen on the screen, P, is that produced by the bitwise ANDing 
  1776 	of the current screen colour and the current pen colour. The effect is similar 
  1777 	for the effective brush colour, B.
  1778 
  1779 	The effective pen and brush colour are given in the table using the key
  1780 	Inputs: pen colour is p, brush colour is b and screen colour is s
  1781 	Outputs: effective brush colour is B, effective pen colour is P. 
  1782 
  1783 	Some notes on using EDrawModeWriteAlpha:-
  1784 
  1785 	- It is rare for client code to need to use this draw mode: see the documentation
  1786 	of SetDrawMode() for more information.
  1787 	- EDrawModeWriteAlpha should only be used with DrawRect(), Clear(), BitBlt(), and BitBltMasked() 
  1788 	with EGray2 mask (and DrawBitmap() and DrawBitmapMasked()). For other draw operations, it is not 
  1789 	supported, and may have unintended effects.
  1790 	- EDrawModeWriteAlpha has the same effect as EDrawModePEN, unless the brush colour has transparency 
  1791 	(DrawRect(), Clear()), or the source bitmap is EColor16MA (and has transparency) (BitBlt(), BitBltMasked())
  1792 	- EDrawModeWriteAlpha has the same effect as EDrawModePEN if the draw mode of the destination does not 
  1793 	support alpha blending. (Blending is only supported in 24bpp and 32bpp colour i.e. EColor16M, EColor16MU, EColor16MA)
  1794 	- In these cases, EDrawModePEN does alpha blending, whereas EDrawModeWriteAlpha means don't do alpha blending.
  1795 
  1796 	@see SetDrawMode()
  1797 	@publishedAll
  1798 	@released
  1799 	*/
  1800 	enum TDrawMode
  1801 		{
  1802 		/** Bitwise ANDs the pen and brush colours with the screen colour. 
  1803 		P=p&s, B=b&s */
  1804 		EDrawModeAND=EAnd,
  1805 		/** Inverts the pen and brush colours before ANDing. P=(~p)&s, 
  1806 		B=(~b)&s */
  1807 		EDrawModeNOTAND=EInvertScreen|EAnd,
  1808 		/** Uses both pen and brush colour as they are. P=p, B=b */
  1809 		EDrawModePEN=EPenmode,
  1810 		/** Inverts the screen colour before ANDing. P=p&(~s), B=b&(~s) */
  1811 		EDrawModeANDNOT=EAnd|EInvertPen,
  1812 		/** Bitwise XORs the pen and brush colours with the screen colour. 
  1813 		P=p^s, B=b^s */
  1814 		EDrawModeXOR=EXor,
  1815 		/** Bitwise ORs the pen and brush colours with the screen colour. 
  1816 		P=p|s, B=b|s */
  1817 		EDrawModeOR=EOr,
  1818 		/** Inverts the screen and pen and brush colours before ANDing. 
  1819 		P=(~p)&(~s), B=(~b)&(~s) */
  1820 		EDrawModeNOTANDNOT=EInvertScreen|EAnd|EInvertPen,
  1821 		/** Inverts the pen and brush colours before XORing. P=(~p)^s, 
  1822 		B=(~b)^s */
  1823 		EDrawModeNOTXOR=EInvertScreen|EXor,
  1824 		/** Inverts the colour of each pixel that is drawn over, (pen and 
  1825 		brush attributes are ignored). P=~s, B=~s */
  1826 		EDrawModeNOTSCREEN=EInvertScreen,
  1827 		/** Inverts the screen colour before ORing. P=p|(~s), 
  1828 		B=b|(~s) */
  1829 		EDrawModeNOTOR=EInvertScreen|EOr,
  1830 		/** Inverts the pen and brush colours. P=~p, B=~b */
  1831 		EDrawModeNOTPEN=EInvertPen|EPenmode,
  1832 		/** Inverts the pen and brush colours before ORing. P=(~p)|s, 
  1833 		B=(~b)|s */
  1834 		EDrawModeORNOT=EOr|EInvertPen,
  1835 		/** Inverts the screen and pen and brush colours before ORing.
  1836 		P=(~p)|(~s), B=(~b)|(~s) */
  1837 		EDrawModeNOTORNOT=EInvertScreen|EOr|EInvertPen,
  1838 		/** Writes alpha information in the source directly into the destination, rather than blending. */
  1839 		EDrawModeWriteAlpha=EWriteAlpha,
  1840 		};
  1841 
  1842 	/** 
  1843 	Pen styles. The screen pattern unit in each definition below describes the 
  1844 	pattern drawn by the line 1 represents a pixel drawn, 0 represents a 
  1845 	pixel that is not affected. 
  1846 	@publishedAll
  1847 	@released
  1848 	*/
  1849 	enum TPenStyle
  1850 		{
  1851 		/** The pen does not draw. Screen pattern unit = 00... */
  1852 		ENullPen,
  1853 		/** A solid line (default). Screen pattern unit = 11... */
  1854 		ESolidPen,
  1855 		/** A dotted line. Screen pattern unit = 1000... */
  1856 		EDottedPen,
  1857 		/** A dashed line. Screen pattern unit = 111000... */
  1858 		EDashedPen,
  1859 		/** A line of alternating dashes and dots. Screen pattern unit = 
  1860 		1111001100... */
  1861 		EDotDashPen,
  1862 		/** A line of alternating single dashes and pairs of dots. Screen 
  1863 		pattern unit = 11110011001100... */
  1864 		EDotDotDashPen
  1865 		};
  1866 
  1867 	/** 
  1868 	Brush styles. 
  1869 	@publishedAll
  1870 	@released
  1871 	*/
  1872 	enum TBrushStyle
  1873 		{
  1874 		/** The brush fill has no effect (default). */
  1875 		ENullBrush,
  1876 		/** The brush fills with a solid single colour, determined by 
  1877 		SetBrushColor() and the drawing mode. */
  1878 		ESolidBrush,
  1879 		/** The brush fills with a selected bitmap pattern, set by 
  1880 		UseBrushPattern(). */
  1881 		EPatternedBrush,
  1882 		/** The brush fills with vertical hatching  lines going from top to 
  1883 		bottom. */
  1884 		EVerticalHatchBrush,
  1885 		/** The brush fills with diagonal hatching lines going from bottom 
  1886 		left to top right. */
  1887 		EForwardDiagonalHatchBrush,
  1888 		/** The brush fills with horizontal hatching  lines going from left 
  1889 		to right. */
  1890 		EHorizontalHatchBrush,
  1891 		/** The brush fills with rearward diagonal hatching lines going from top 
  1892 		left to bottom right. */
  1893 		ERearwardDiagonalHatchBrush,
  1894 		/** The brush fills with horizontal and vertical hatching  lines going 
  1895 		from left to right plus lines going from top to bottom  giving the 
  1896 		effect of a grid of small squares */
  1897 		ESquareCrossHatchBrush,
  1898 		/** The brush fills with forward diagonal and rearward diagonal hatching 
  1899 		lines going from bottom left to top right plus lines going from top left 
  1900 		to bottom right giving the effect of a grid of small diamonds. */
  1901 		EDiamondCrossHatchBrush
  1902 		};
  1903 
  1904 	/** 
  1905 	Rules used to fill self crossing polygons. 
  1906 
  1907 	The filling of a polygon proceeds as follows: for a given point in the 
  1908 	polygon, then
  1909 
  1910 	if the rule is TFillRule::EAlternate (default) and it has an odd winding 
  1911 	number, then fill the surrounding area.
  1912 
  1913 	if the rule is TFillRule::EWinding and it has a winding number greater than 
  1914 	zero, then fill the surrounding area. 
  1915 	@publishedAll
  1916 	@released
  1917 	*/
  1918 	enum TFillRule
  1919 		{
  1920 		/** Only fill areas with odd winding numbers. */
  1921 		EAlternate,
  1922 		/** Fill areas with winding numbers greater than zero. */
  1923 		EWinding
  1924 		};
  1925 
  1926 	/** Parameters to control the drawing of text. */
  1927 	struct TDrawTextParam
  1928 		{
  1929 	public:
  1930 		TDrawTextParam():
  1931 			iDirection(CFont::EHorizontal),
  1932 			iCharJustNum(0),
  1933 			iCharJustExcess(0),
  1934 			iWordJustNum(0),
  1935 			iWordJustExcess(0)
  1936 	/** Reserved for future use. */
  1937 			{}
  1938 	public:
  1939 		/** the direction in which to draw the text. */
  1940 		CFont::TTextDirection iDirection;	
  1941 		/** number of glyph groups to be letterspaced */
  1942 		TInt iCharJustNum;					
  1943 		/** amount of space to be used for letterspacing */
  1944 		TInt iCharJustExcess;				
  1945 		/** number of spaces to be used for wordspacing*/
  1946 		TInt iWordJustNum;					
  1947 		/**  amount of space to be used for wordspacing*/
  1948 		TInt iWordJustExcess;				
  1949 		};
  1950 
  1951 
  1952 	/** Parameters for extended text drawing and measuring. It is used by 
  1953 	CGraphicsContext::DrawTextExtended() to indicate whether text should be 
  1954 	drawn from right-to-left or left-to-right. */
  1955 	struct TDrawTextExtendedParam : public TDrawTextParam
  1956 		{
  1957 	public:
  1958 		/** Constructor. Initialises iParRightToLeft to EFalse. */
  1959 		TDrawTextExtendedParam():
  1960 			iParRightToLeft(EFalse)
  1961 			{}
  1962 	public:
  1963 		/** ETrue if the text direction is right-to-left (for scripts like 
  1964 		Arabic and Hebrew). EFalse if left-to-right. */
  1965 		TBool iParRightToLeft;	
  1966 		};
  1967 	
  1968 	/**
  1969 	Parameters used in drawing text within supplied context.
  1970 	It is used by CGraphicsContext::DrawText() and CGraphicsContext::DrawTextVertical() family of API's
  1971 	to draw text from iStart to iEnd withing the supplied text descriptor.
  1972 	*/
  1973 	class TTextParameters
  1974 		{
  1975 	public:
  1976 		TTextParameters():
  1977 			iStart(0),
  1978 			iEnd(KMaxTInt),
  1979 			iFlags(0)
  1980 				{
  1981 				}
  1982 		TInt iStart;
  1983 		TInt iEnd;
  1984 		TUint16 iFlags;
  1985 		/* Reserved for future use */
  1986 		TAny* iReserved1;
  1987 		TAny* iReserved2;
  1988 		TAny* iReserved3;
  1989 		TAny* iReserved4;
  1990 		};
  1991 public:
  1992 	/** Gets a pointer to the graphics context's graphics device.
  1993 	
  1994 	@return A pointer to the graphics device. */
  1995 	virtual CGraphicsDevice* Device() const=0;
  1996 
  1997 	/** Sets the position of the co-ordinate origin.
  1998 	
  1999 	All subsequent drawing operations are done relative to this origin.
  2000 	
  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;
  2004 
  2005 	/** Sets the drawing mode. 
  2006 	
  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.
  2013 	
  2014 	The three most important modes are TDrawMode::EDrawModePEN, TDrawMode::EDrawModeNOTSCREEN 
  2015 	and TDrawMode::EDrawModeXOR. The default drawing mode is TDrawMode::EDrawModePEN.
  2016 	
  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).
  2020 	
  2021 	Notes:
  2022 	
  2023 	TDrawMode::EDrawModeAND gives a "colour filter" effect. For example:
  2024 	
  2025 	- ANDing with white gives the original colour
  2026 	- ANDing with black gives black
  2027 	
  2028 	TDrawMode::EDrawModeOR gives a "colour boost" effect. For example:
  2029 	
  2030 	- ORing with black gives the original colour
  2031 	- ORing with white gives white
  2032 	
  2033 	TDrawMode::EDrawModeXOR gives an "Exclusive OR" effect. For example:
  2034 	
  2035 	- white XOR black gives white
  2036 	- white XOR white gives black
  2037 	- black XOR black gives black
  2038 	
  2039 	TDrawMode::EDrawModeWriteAlpha should not normally need to be used by client code. 
  2040 	The following are exceptions:-
  2041 
  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. 
  2048 
  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.
  2051 
  2052 	@param aDrawingMode The drawing mode.
  2053 	@see CGraphicsContext::TDrawMode
  2054 	@see CGraphicsContext::TDrawModeComponents */
  2055 	virtual void SetDrawMode(TDrawMode aDrawingMode)=0;
  2056 
  2057 	/** Sets the clipping rectangle.	 
  2058 	
  2059 	The area of visible drawing depends on the clipping rectangle, any items 
  2060 	that fall outside the extent of the clipping rectangle will not be drawn. 
  2061 	The default clipping rectangle is the full device area.
  2062 	
  2063 	Note that clipping is additive. If a clipping region has been set using SetClippingRegion() 
  2064 	then clipping will be to the intersection of that region and this rectangle.
  2065 		
  2066 	@param aRect The rectangle to be used as the clipping rectangle. Note that 
  2067 	this rectangle is tranformed by the current co-ordinate origin before it is used. 
  2068 	The co-ordinate origin is set using SetOrigin().
  2069 	
  2070 	@see CGraphicsContext::SetClippingRegion() 
  2071 	@see CGraphicsContext::SetOrigin() */
  2072 	virtual void SetClippingRect(const TRect& aRect)=0;
  2073 
  2074 	/** Cancels any clipping rectangle.
  2075 	
  2076 	Clipping thus reverts to the full device area, the default.
  2077 	
  2078 	@see SetClippingRect() */
  2079 	virtual void CancelClippingRect()=0;
  2080 
  2081 	/** Resets the graphics context to its default settings:
  2082 	
  2083 	the drawing mode is TDrawMode::EDrawModePen (pen and brush colours used as 
  2084 	they are)
  2085 	
  2086 	there is no clipping rectangle
  2087 	
  2088 	the pen settings are: black, solid, single pixel size
  2089 	
  2090 	the brush style is null
  2091 	
  2092 	no text font is selected */
  2093 	virtual void Reset()=0;
  2094 
  2095    /** Sets the device font to be used for text drawing.
  2096 	
  2097 	If the font is already in memory, then that copy is shared.
  2098 	
  2099 	Notes:
  2100 	
  2101 	The CFont* argument must have been previously initialised by calling 
  2102 	MGraphicsDeviceMap::GetNearestFontInTwips() with the required 
  2103 	font-specification. If the CFont* has not been initialised 
  2104 	correctly, and therefore does not point to an available font-bitmap, 
  2105 	then a panic is raised.
  2106 	
  2107 	When the font is no longer required, use DiscardFont() to free up the 
  2108 	memory used. If UseFont() is used again without using DiscardFont() then 
  2109 	the previous font is discarded automatically.
  2110 	
  2111 	If no font has been selected, and an attempt is made to draw text with 
  2112 	DrawText(), then a panic is raised.
  2113 	
  2114 	@param aFont A device font 
  2115 	@see MGraphicsDeviceMap::GetNearestFontInTwips() */
  2116 	virtual void UseFont(const CFont* aFont)=0;
  2117 
  2118 	/** Discards a font.
  2119 	
  2120 	This frees up the memory used, if the font is not being shared.
  2121 	
  2122 	The function can be called when no font is in use. */
  2123 	virtual void DiscardFont()=0;
  2124 
  2125 	/** Sets the underline style.
  2126 	
  2127 	This is applied to all subsequently drawn text.
  2128 	
  2129 	@param aUnderlineStyle The underline style on or off. */
  2130 	virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle)=0;
  2131 
  2132 	/** Sets the strikethrough style.
  2133 	
  2134 	This is applied to all subsequently drawn text.
  2135 	
  2136 	@param aStrikethroughStyle The strikethrough style on or off. */
  2137 	virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)=0;
  2138 	IMPORT_C static TInt JustificationInPixels(TInt aExcessPixels,TInt aTotalUnits,TInt aFirstUnit,TInt aNumUnits);
  2139 	IMPORT_C static TInt JustificationInPixels(TInt& aExcessPixels,TInt& aTotalUnits);
  2140 
  2141 	/** Adjusts the spaces between words to stretch or squeeze to a certain 
  2142 	width.
  2143 	
  2144 	The function is required by the Text Views API, and is not intended for 
  2145 	regular use by developers.
  2146 	
  2147 	The text line that is to be justified has a certain number of gaps (spaces) 
  2148 	between the words. It also has a distance (in pixels) between the end of 
  2149 	the last word and the actual end of the line (right hand margin, usually). 
  2150 	These excess width pixels are distributed amongst the gaps between the words 
  2151 	to achieve full justification of the text line. Spaces become fat spaces to 
  2152 	keep underlining/strikethrough consistent. Pixels are distributed to the 
  2153 	inter-word gaps starting from the left end of the string. The spacing 
  2154 	between characters in each word remains unchanged.
  2155 	
  2156 	After a call to SetWordJustification(), subsequent calls to either of the 
  2157 	two DrawText() functions are affected until the number of spaces specified 
  2158 	by aNumSpaces is used up.
  2159 	
  2160 	The easiest way to find out the excess width and number of spaces is to call 
  2161 	CFont::MeasureText(). This function can also perform counting, which is 
  2162 	finding how much of some text will fit into a given width.
  2163 	
  2164 	Use CFont::TextCount() to return the excess width.
  2165 	
  2166 	For example, in the string "To be, or not to be", there are five inter-word 
  2167 	gaps. If there are six excess pixels they will be distributed in the 
  2168 	proportion 	2, 1, 1, 1, 1 between the words. If there are nine excess pixels 
  2169 	they will be distributed in the proportion 2, 2, 2, 2, 1 between the words.
  2170 	
  2171 	Notes:
  2172 	
  2173 	If the excess width is zero, then calling SetWordJustification() has no 
  2174 	effect.
  2175 	
  2176 	At first sight it may appear that SetWordJustification() is not required 
  2177 	because you can simply call DrawText() for each word. However, underlined 
  2178 	justified text does not work using this strategy  you get a non-underlined 
  2179 	gap between the space and the beginning of the next word.
  2180 	
  2181 	@param aExcessWidth The width (in pixels) to be distributed between the 
  2182 	specified number of spaces. 
  2183 	@param aNumGaps The number of word spaces (characters with the code U+0020) 
  2184 	over which the change in width is distributed. */
  2185 	virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps)=0;
  2186 
  2187 	/** Sets character justification.
  2188 	
  2189 	This function is required by the Text Views API, and is not intended for 
  2190 	regular use by developers.
  2191 	
  2192 	It affects the strings of text used in the calls to DrawText() that follow, 
  2193 	until the number of characters drawn equals aNumChars.
  2194 	
  2195 	The text line that is to be justified has a certain number of characters
  2196 	this includes the spaces between the words. It also has a distance (in 
  2197 	pixels) between the end of the last word and the actual end of the line 
  2198 	(right hand margin, usually). These excess width pixels are distributed 
  2199 	amongst all the characters, increasing the gaps between them, to achieve 
  2200 	full justification of the text line.
  2201 	
  2202 	Use CFont::TextCount() to return the excess width.
  2203 	
  2204 	Notes:
  2205 	
  2206 	This function is provided to allow simulation of printer fonts on screen. 
  2207 	Due to the fact that fully-scalable fonts are not used before v5, large 
  2208 	printer fonts can be simulated by using the nearest smaller font and 
  2209 	widening it slightly.
  2210 	
  2211 	If the excess width is zero, then calling SetCharJustification() has no 
  2212 	effect.
  2213 	
  2214 	SetCharJustification() is required for WYSIWYG where the layout uses 
  2215 	printer font metrics but screen fonts have to be drawn on the screen. 
  2216 	Because continuously scalable typefaces (c.f. TrueType) are not used 
  2217 	before v5 and because screen fonts are coarser and less numerous in 
  2218 	their variety than the printer fonts, the best matching smaller screen 
  2219 	font must be used with character justification to simulate the printer 
  2220 	font on the screen.
  2221 	
  2222 	There is also a situation where the gaps between characters on screen have 
  2223 	to be reduced with character clipping. The screen font that best matches 
  2224 	the printer font may have the required height, but has characters that are 
  2225 	too wide. A line of text that works on the printer will then be too long 
  2226 	on the screen, unless it is squashed horizontally. The number of pixels 
  2227 	that overlap the end of the screen line must now be removed from the gaps 
  2228 	between the characters, i.e. there is a negative excess width. This 
  2229 	situation is especially important where adding a TAB on screen gives 
  2230 	perfectly acceptable printout, but would push the last character of the 
  2231 	line off the right hand side of the screen.
  2232 	
  2233 	In practice what you do in printer layout mode is:
  2234 	
  2235 	Calculate where the line breaks will come on the printer. To do this you 
  2236 	use a printer font (which in practice means a table of character widths 
  2237 	of the font that the printer will use).
  2238 	
  2239 	Now change to use a screen font that is the closest font which is no taller 
  2240 	that the printer font. In practice it will often be fatter maybe only for 
  2241 	certain characters such as 'i'.
  2242 	
  2243 	You have to recalculate the width of the characters using the screen fonts. 
  2244 	You can do this using CFont::TextWidth() as you have already determined how 
  2245 	many characters will fit on the line.
  2246 	
  2247 	If, in the screen font, the characters are not as wide as the line then you 
  2248 	can just use word justification to expand the line. You would only do this 
  2249 	if the text is to be justified.
  2250 	
  2251 	If, however, the characters are wider than the line then you would use 
  2252 	character justification to clip each character. You would need to do this 
  2253 	even if the line is not justified.
  2254 	
  2255 	Thus, in practice, character justification will only very rarely be used to 
  2256 	expand a line of characters.
  2257 	
  2258 	@param aExcessWidth The excess width (in pixels) to be distributed between 
  2259 	the specified number of characters. It may be positive, in which case the text is 
  2260 	stretched, or negative, in which case it is shrunk.
  2261 	@param aNumChars The number of characters involved. */
  2262 	virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars)=0;
  2263 
  2264 	/** Sets the pen colour.
  2265 	
  2266 	The effective pen colour depends on the drawing mode. The default pen colour 
  2267 	is black.
  2268 	
  2269 	Note:
  2270 	
  2271 	The pen is used to draw lines, the outlines of filled shapes, and text. In case
  2272 	of outlined text, the pen is used to draw the outline of the font.
  2273 	
  2274 	The	class provides member functions to set the colour of the pen, the style of 
  2275 	line and the line size drawn.
  2276 	
  2277 	@param aColor An RGB colour for the pen. 
  2278 	@see CGraphicsContext::SetDrawMode() */
  2279 	virtual void SetPenColor(const TRgb& aColor)=0;
  2280  
  2281 	/** Sets the line drawing style for the pen. 
  2282 	
  2283 	There are 6 pen styles. If no pen style is set, then the default is 
  2284 	TPenStyle::ESolidPen. To use a pen style, its full context must be given, 
  2285 	e.g. for a null pen:
  2286 	
  2287 	CGraphicsContext::TPenStyle::ENullPen
  2288 	Notes:
  2289 	
  2290 	The pen is used to draw lines, the outlines of filled shapes, and text. 
  2291 	CGraphicsContext member functions are provided to set the colour of the 
  2292 	pen, the style of line and the line size drawn.
  2293 	
  2294 	The TPenStyle::ENullPen style should be used if a border is not required 
  2295 	around a filled shape.
  2296 	
  2297 	Dotted and dashed pen styles have a device dependant implementation, always 
  2298 	give single-pixel size lines on the screen whatever the pen size set 
  2299 	by SetPenSize() and can only be used for straight lines, polylines, 
  2300 	non-rounded rectangles and polygons.
  2301 	
  2302 	The dotted/dashed pattern is continued, without re-starting, for all 
  2303 	consecutively drawn straight lines, i.e.
  2304 	
  2305 	the outlines of rectangles the pattern starts in the top left corner. 
  2306 	It is reset at the end of the function call.
  2307 	
  2308 	the outlines of polygons the pattern starts at the first point. It is 
  2309 	reset at the end of the function call.
  2310 	
  2311 	polylines and straight lines the pattern starts at the first point 
  2312 	initially. Consecutive calls to DrawLine() and/or DrawPolyLine(), whether 
  2313 	the lines are concatenated or not, continue the pattern. It can be reset 
  2314 	by a further call to SetPenStyle() using the same dotted/dashed style 
  2315 	parameter.
  2316 	
  2317 	@param aPenStyle A pen style. 
  2318 	@see CGraphicsContext::TPenStyle */
  2319 	virtual void SetPenStyle(TPenStyle aPenStyle)=0;
  2320 
  2321 	/** Sets the line drawing size for the pen.
  2322 	
  2323 	Lines of size greater than one pixel:
  2324 	
  2325 	are drawn with rounded ends that extend beyond the end points, (as if the 
  2326 	line is drawn using a circular pen tip of the specified size).
  2327 	
  2328 	are always drawn in TDrawMode::EDrawModePEN mode, overriding whatever mode 
  2329 	has been set using SetDrawMode().
  2330 	
  2331 	Notes:
  2332 	
  2333 	The pen is used to draw lines, the outlines of filled shapes, and text. The 
  2334 	class provides member functions to set the colour of the pen, the style of 
  2335 	line and the line size drawn.
  2336 	
  2337 	Wide straight lines and arcs have rounded ends so that concatenated wide 
  2338 	lines have smoothly rounded corners at the vertexes.
  2339 	
  2340 	When lines are made wide, the extra strips of pixels are added equally to 
  2341 	both sides of the line. This works precisely for lines of odd pixel size 
  2342 	(3, 5, 7, etc.). Wide lines of even pixel size, (2, 4, 6, etc.), 
  2343 	have the extra strip of pixels added to the right and/or below the line.
  2344 	
  2345 	Wide outlines of ellipses and wide line arcs are drawn with the pixels 
  2346 	distributed either side of a thin (single pixel wide) true ellipse 
  2347 	constructed in the normal manner. Wide ellipses and arcs of even pixel 
  2348 	size have the extra strip of pixels added to the right and/or below the 
  2349 	curved line. This gives a slight asymmetry to ellipses.
  2350 	
  2351 	If the pen style is dotted or dashed, the size specification is ignored: a 
  2352 	single-pixel wide primitive is drawn, (this is device dependant).
  2353 	
  2354 	A line size of zero is handled as if the pen style had been set to 
  2355 	TPenStyle::ENullPen.
  2356 	
  2357 	@param aSize A line size. The default is 1 pixel. */
  2358 	virtual void SetPenSize(const TSize& aSize)=0;
  2359 
  2360 	/** Sets the brush colour.
  2361 	
  2362 	The effective brush colour depends on the drawing mode.
  2363 	
  2364 	Notes:
  2365 	
  2366 	The brush is used for filling shapes and the background of text boxes. In 
  2367 	case of outlined text, the brush is used for filling the font. The brush 
  2368 	has colour, style, pattern and pattern origin parameters.
  2369 	
  2370 	If no brush colour has been set, it defaults to white. However the default 
  2371 	brush style is null, so when drawing to a window the default appears to be 
  2372 	the window's background colour.
  2373 	
  2374 	@param aColor An RGB colour for the brush. 
  2375 	@see SetDrawMode() */
  2376 	virtual void SetBrushColor(const TRgb& aColor)=0;
  2377 
  2378 	/**	Sets the brush style.
  2379 
  2380 	Ten brush styles are provided, including six built-in hatching patterns.
  2381 	Note: The brush is used for filling shapes and the background of text boxes.
  2382 	The brush has colour, style, pattern and pattern origin parameters.
  2383 	Note: Use TBrushStyle::ENullBrush to draw the outline of a fillable
  2384 	shape on its own, without filling.
  2385 	Note: If the TBrushStyle::EPatternedBrush style is set, but no bitmap 
  2386 	pattern has been selected using UseBrushPattern(), then the function panics.
  2387 	Note: Hatching lines are done in the current pen colour, set using SetPenColor(). 
  2388 	The hatching pattern starts at the brush origin, set using SetBrushOrigin().
  2389 	@see TBrushStyle::ENullBrush
  2390 	@see TBrushStyle::EPatternedBrush
  2391 	@see UseBrushPattern()
  2392 	@see SetPenColor()
  2393 	@see SetBrushOrigin()
  2394 	@publishedAll
  2395 	@released
  2396 	@param aBrushStyle A brush style. */
  2397 	virtual void SetBrushStyle(TBrushStyle aBrushStyle)=0;
  2398 
  2399 	/** Sets the brush pattern origin.
  2400 	
  2401 	This specifies the top left-hand corner position for the pattern tile around 
  2402 	which copies of the pattern are tiled.
  2403 	
  2404 	The brush pattern may be a built-in style, or a bitmap. To use a bitmap, the 
  2405 	brush must have a pattern set and the brush style must be set to 
  2406 	TBrushStyle::EPatternedBrush.
  2407 	
  2408 	Notes
  2409 	
  2410 	The brush is used for filling shapes and the background of text boxes. The 
  2411 	brush has colour, style, pattern and pattern origin parameters.
  2412 	
  2413 	If SetBrushOrigin() is not used, then the origin defaults to (0,0).
  2414 	
  2415 	This brush origin remains in effect for all fillable shapes drawn 
  2416 	subsequently, until a new brush origin is set. Shapes can thus be 
  2417 	considered as windows onto a continuous pattern field (covering the whole 
  2418 	clipping region of a screen device, or the whole device area of a printer).
  2419 	
  2420 	@param aOrigin An origin point for the brush. The coordinates are relative 
  2421 	to the rectangle to fill, i.e. specify 0,0 to align the pattern flush with 
  2422 	the top and left hand sides of the rectangle.
  2423 	@see SetBrushStyle()
  2424 	@see UseBrushPattern() */
  2425 	virtual void SetBrushOrigin(const TPoint& aOrigin)=0;
  2426 
  2427 	/** Sets the brush pattern to the specified bitmap.
  2428 	
  2429 	For the brush to actually use the bitmap, TBrushStyle::EPatternedBrush must 
  2430 	be used to set the brush style.
  2431 	
  2432 	When the brush pattern is no longer required, use DiscardBrushPattern() to 
  2433 	free up the memory used, if the bitmap is not being shared. 
  2434 	If UseBrushPattern() is used again without using DiscardBrushPattern() 
  2435 	then the previous pattern is discarded automatically.
  2436 	
  2437 	Notes:
  2438 	
  2439 	The brush is used for filling shapes and the background of text boxes. The 
  2440 	brush has colour, style, pattern and pattern origin parameters.
  2441 	
  2442 	When loading a bitmap, the bitmap is checked to see if it is already in 
  2443 	memory. If the bitmap is already there, then that copy is shared.
  2444 	
  2445 	The brush does not need to have a pattern set at all. There are several 
  2446 	built-in hatching patterns which can be selected using SetBrushStyle().
  2447 	
  2448 	@param aBitmap A bitmap pattern for the brush. 
  2449 	@see SetBrushStyle() */
  2450 	virtual void UseBrushPattern(const CFbsBitmap* aBitmap)=0;
  2451 
  2452 	/** Discards a non-built-in brush pattern.
  2453 	
  2454 	This frees up the memory used by the bitmap, if it is not being shared by 
  2455 	another process.
  2456 	
  2457 	Notes:
  2458 	
  2459 	The brush is used for filling shapes and the background of text boxes. The 
  2460 	brush has colour, style, pattern and pattern origin parameters.
  2461 	
  2462 	If DiscardBrushPattern() is used, with no brush pattern set, then there is 
  2463 	no effect. */
  2464 	virtual void DiscardBrushPattern()=0;
  2465 
  2466 
  2467 	/** Sets the drawing point relative to the co-ordinate origin. 
  2468 	
  2469 	A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing 
  2470 	point as the start point for the line drawn.
  2471 	
  2472 	Notes
  2473 	
  2474 	The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline() 
  2475 	also change the internal drawing position to the last point of the drawn 
  2476 	line(s). 
  2477 	
  2478 	The internal drawing position is set to the co-ordinate origin if no drawing 
  2479 	or moving operations have yet taken place.
  2480 	
  2481 	@param aPoint The new internal drawing position. */
  2482 	virtual void MoveTo(const TPoint& aPoint)=0;
  2483 
  2484 	/** Sets the drawing point relative to the current co-ordinates.
  2485 	
  2486 	A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing point 
  2487 	as the start point for the line drawn.
  2488 	
  2489 	Notes
  2490 	
  2491 	The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline() 
  2492 	also change the internal drawing position to the last point of the drawn 
  2493 	line(s). 
  2494 	
  2495 	The internal drawing position is set to the co-ordinate origin if no drawing 
  2496 	or moving operations have yet taken place.
  2497 	
  2498 	@param aVector The amount by which the internal drawing position is to move. */
  2499 	virtual void MoveBy(const TPoint& aVector)=0;
  2500 
  2501 	/** Draws a single point. The point is drawn with the current pen settings 
  2502 	using the current drawing mode.
  2503 	
  2504 	Note:
  2505 	
  2506 	If the pen size is greater than one pixel, a filled circle of the current 
  2507 	pen colour is drawn, with the pen size as the diameter and the plotted point 
  2508 	as the centre. If the pen size is an even number of pixels, the extra pixels 
  2509 	are drawn below and to the right of the centre.
  2510 	
  2511 	@param aPoint The point to be drawn.
  2512 	@see SetPenSize() */
  2513 	virtual void Plot(const TPoint& aPoint)=0;
  2514 
  2515 	/** Draws an arc.
  2516 	
  2517 	The arc is considered a portion of an ellipse. The ellipse is defined by the 
  2518 	TRect argument.
  2519 	
  2520 	The pixels at both the start point and the end point are drawn.
  2521 	
  2522 	The arc itself is the segment of the ellipse drawn in an anti-clockwise 
  2523 	direction from the start point to the end point.
  2524 	
  2525 	Notes:
  2526 	
  2527 	A rectangle is used in the construction of the ellipse of which the arc is 
  2528 	a segment. This rectangle is passed as an argument of type TRect.
  2529 	
  2530 	A wide line arc is drawn with the pixels distributed either side of a true 
  2531 	ellipse, in such a way that the outer edge of the line would touch the edge 
  2532 	of the construction rectangle. In other words, the ellipse used to 
  2533 	construct it is slightly smaller than that for a single pixel line size.
  2534 	
  2535 	If the specified start or end point is at the centre of the ellipse, then 
  2536 	the line that defines the start or end of the arc defaults to one extending 
  2537 	vertically above the centre point.
  2538 	
  2539 	If the start and end point are the same point or are points on the same line 
  2540 	through the ellipse centre then a complete unfilled ellipse is drawn.
  2541 	
  2542 	@param aRect A rectangle in which to draw the ellipse, of which the arc is 
  2543 	a segment. 
  2544 	@param aStart The point defining the start of the arc. It defines one end of 
  2545 	a line from the geometric centre of the ellipse. The point of intersection 
  2546 	between this line and the ellipse defines the start point of the arc.
  2547 	@param aEnd The point defining the end of the arc. It defines one end of a 
  2548 	second line from the geometric centre of the ellipse. The point of 
  2549 	intersection between this line and the ellipse defines the end point of the 
  2550 	arc.
  2551 	@see DrawEllipse() */
  2552 	virtual void DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0;
  2553 
  2554 	/** Draws a straight line between two points.
  2555 	
  2556 	@param aPoint1 The point at the start of the line. 
  2557 	@param aPoint2 The point at the end of the line. */
  2558 	virtual void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)=0;
  2559 
  2560 	/** Draws a straight line from the current drawing point to a specified 
  2561 	point.
  2562 	
  2563 	@param aPoint The point at the end of the line. 
  2564 	@see MoveTo()
  2565 	@see MoveBy() */
  2566 	virtual void DrawLineTo(const TPoint& aPoint)=0;
  2567 
  2568 	/** Draws a straight line relative to the current drawing point, using a 
  2569 	vector.
  2570 	
  2571 	The start point of the line is the current drawing point. The specified 
  2572 	vector 
  2573 	is added to the drawing point to give the end point of the line
  2574 	
  2575 	@param aVector The vector to add to the current internal drawing position, 
  2576 	giving the end point of the line. 
  2577 	@see MoveTo()
  2578 	@see MoveBy() */
  2579 	virtual void DrawLineBy(const TPoint& aVector)=0;
  2580 
  2581 	/** Draws a polyline from a set of points in an array.
  2582 	
  2583 	A polyline is a series of concatenated straight lines joining a set of 
  2584 	points.
  2585 	
  2586 	@param aPointList An array containing the points on the polyline. */
  2587 	virtual void DrawPolyLine(const CArrayFix<TPoint>* aPointList)=0;
  2588 
  2589 	/** Draws a polyline from a set of points in a list.
  2590 	
  2591 	A polyline is a series of concatenated straight lines joining a set of 
  2592 	points.
  2593 	
  2594 	@param aPointList Pointer to a set of points on the polyline.
  2595 	@param aNumPoints Number of points in the list. */
  2596 	virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)=0;
  2597 
  2598 	/** Draws and fills a pie slice.
  2599 	
  2600 	The pie slice is an area bounded by:
  2601 	
  2602 	the arc of an ellipse drawn in an anticlockwise direction from the start 
  2603 	point to the end point
  2604 	
  2605 	the straight line drawn to the start point from the geometric centre of the 
  2606 	ellipse.
  2607 	
  2608 	the straight line to the end point from the geometric centre of the ellipse.
  2609 	
  2610 	Notes:
  2611 	
  2612 	A rectangle is used in the construction of the pie slice. This rectangle is 
  2613 	passed as an argument of type TRect. The curved edge of the pie slice is an 
  2614 	arc of an ellipse constructed within the rectangle.
  2615 	
  2616 	The line drawn by the pen goes inside the specified rectangle.
  2617 	
  2618 	The pixels at the end point of the arc are not drawn.
  2619 	
  2620 	A wide line edged pie slice has the arc drawn with the pixels distributed 
  2621 	either side of a true ellipse. This is done in such a way that the outer 
  2622 	edge of the line touches the edge of the construction rectangle. In other 
  2623 	words, the ellipse used to construct it is slightly smaller than that for 
  2624 	a single pixel line size.
  2625 	
  2626 	If the specified start or end point is at the centre of the ellipse, then 
  2627 	the line that defines the start or end of the arc defaults to one extending 
  2628 	vertically above the centre point.
  2629 	
  2630 	If the start and end point are the same point or are points on the same line 
  2631 	through the ellipse centre then a complete filled ellipse is drawn. A line 
  2632 	is also drawn from the edge to the ellipse centre.
  2633 	
  2634 	@param aRect A rectangle in which to draw the ellipse bounding the pie slice. 
  2635 	@param aStart A point defining the start of the arc bounding the pie slice. 
  2636 	It defines one end of a line from the geometrical centre of the ellipse. The 
  2637 	point of intersection between this line and the ellipse defines the start 
  2638 	point of the arc.
  2639 	@param aEnd A point to define the end of the arc bounding the pie slice. It 
  2640 	defines one end of a second line from the geometrical centre of the ellipse. 
  2641 	The point of intersection between this line and the ellipse defines the end 
  2642 	point of the arc. */
  2643 	virtual void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0;
  2644 
  2645 	/** Draws and fills an ellipse.
  2646 	
  2647 	The ellipse is drawn inside the rectangle defined by the TRect argument. Any 
  2648 	rectangle that has odd pixel dimensions, has the bottom right corner trimmed 
  2649 	to give even pixel dimensions before the ellipse is constructed.
  2650 	
  2651 	Note:
  2652 	
  2653 	A wide outline ellipse is drawn with the pixels distributed either side of 
  2654 	a true ellipse, in such a way that the outer edge of the line touches the 
  2655 	edge of the construction rectangle. In other words, the ellipse used to 
  2656 	construct it is smaller than that for a single pixel line size.
  2657 	
  2658 	@param aRect The rectangle in which the ellipse is drawn. */
  2659 	virtual void DrawEllipse(const TRect& aRect)=0;
  2660 
  2661 	/** Draws and fills a rectangle.
  2662 	
  2663 	@param aRect The rectangle to be drawn. */
  2664 	virtual void DrawRect(const TRect& aRect)=0;
  2665 
  2666 	/** Draws and fills a rectangle with rounded corners.
  2667 	
  2668 	The rounded corners are each constructed as an arc of an ellipse.
  2669 	
  2670 	The line drawn by the pen, if any, goes inside the specified rectangle.
  2671 	
  2672 	Notes:
  2673 	
  2674 	Dotted and dashed pen styles cannot be used for the outline of a rounded 
  2675 	rectangle.
  2676 	
  2677 	If either corner size dimension is greater than half the corresponding 
  2678 	rectangle length, the corner size dimension is reduced to half the 
  2679 	rectangle size.
  2680 	
  2681 	@param aRect The rectangle to be drawn. 
  2682 	@param aCornerSize The dimensions of each corner. 
  2683 	@see DrawArc() */
  2684 	virtual void DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)=0;
  2685 
  2686 	/** Draws and fills a polygon defined using an array of points.
  2687 	
  2688 	The first point in the array defines the start of the first side of the 
  2689 	polygon. The second point defines the second vertex (the end point of the 
  2690 	first side and the start point of the second side).
  2691 	
  2692 	The final side of the polygon is drawn using the last point from the array, 
  2693 	and the line is drawn to the start point of the first side.
  2694 	
  2695 	Self-crossing polygons are filled according to the specified fill rule.
  2696 	
  2697 	@param aPointList An array of points, specifying the vertices of the polygon.
  2698 	@param aFillRule The fill rule. By default, this is TFillRule::EAlternate. 
  2699 	@return KErrNone, if successful; otherwise, another of the system-wide error 
  2700 	codes. */
  2701 	virtual TInt DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule=EAlternate)=0;
  2702 
  2703 	/** Draws and fills a polygon defined using a list of points.
  2704 	
  2705 	The first point in the list defines the start of the first side of the 
  2706 	polygon. The second point defines the second vertex (the end point of the 
  2707 	first side and the start point of the second side).
  2708 	
  2709 	The final side of the polygon is drawn using the last point from the list, 
  2710 	and the line is drawn to the start point of the first side.
  2711 	
  2712 	Self-crossing polygons are filled according to the specified fill rule.
  2713 	
  2714 	@param aPointList Pointer to list of points, specifying the vertices of the 
  2715 	polygon.
  2716 	@param aNumPoints The number of points in the list.
  2717 	@param aFillRule The fill rule. By default this is TFillRule::EAlternate. 
  2718 	@return KErrNone, if successful; otherwise, another of the system-wide error 
  2719 	codes. */
  2720 	virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate)=0;
  2721 
  2722 	/** Draws a bitmap at the specified point.
  2723 	
  2724 	The point specifies the top left hand corner of the bitmap. The bitmap is 
  2725 	compressed or stretched based on its internally stored size in twips.
  2726 	
  2727 	Notes:
  2728 	
  2729 	This member function uses the bitmap's size in twips and does a 
  2730 	stretch/compress blit using a linear DDA.
  2731 	
  2732 	As this function scales the bitmap, it is unavoidably slow. Therefore, where 
  2733 	possible, use CBitmapContext::BitBlt() instead. If the bitmap has to be 
  2734 	scaled, consider creating another bitmap along with an CFbsBitmapDevice etc, 
  2735 	doing DrawBitmap() once and using BitBlt() subsequently.
  2736 	
  2737 	Note that all bitmaps are clipped to the device boundaries.
  2738 	
  2739 	@param aTopLeft The point where the top left pixel of the bitmap is to be 
  2740 	drawn 
  2741 	@param aSource A source bitmap 
  2742 	@see TLinearDDA */
  2743 	virtual void DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource)=0;
  2744 
  2745 	/** Draws a bitmap to fit a given rectangle. 
  2746 	
  2747 	The bitmap is compressed or stretched based on its internally stored size 
  2748 	in pixels.
  2749 	
  2750 	Notes:
  2751 	
  2752 	This member function uses the bitmap's size in pixels and does a 
  2753 	stretch/compress blit using a linear DDA.
  2754 	
  2755 	As this function scales the bitmap, it is unavoidably slow. Therefore, 
  2756 	where possible, use CBitmapContext::BitBlt() instead. If the bitmap has 
  2757 	to be scaled, consider creating another bitmap along with an 
  2758 	CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt() 
  2759 	subsequently.
  2760 	
  2761 	Note that all bitmaps are clipped to the device boundaries.
  2762 	
  2763 	@param aDestRect The rectangle within which the bitmap is to be drawn. 
  2764 	@param aSource A source bitmap. 
  2765 	@see TLinearDDA */
  2766 	virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)=0;
  2767 
  2768 	/** Draws a specified rectangle of a source bitmap to fit into a given 
  2769 	destination rectangle.
  2770 	
  2771 	Notes:
  2772 	
  2773 	This member function uses rectangle sizes in pixels and does a 
  2774 	stretch/compress blit using a linear DDA.
  2775 	
  2776 	As this function scales the bitmap, it is unavoidably slow. Therefore, 
  2777 	where possible, use CBitmapContext::BitBlt() instead. If the bitmap has 
  2778 	to be scaled, consider creating another bitmap along with an 
  2779 	CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt() 
  2780 	subsequently.
  2781 	
  2782 	Note that all bitmaps are clipped to the device boundaries.
  2783 	
  2784 	@param aDestRect The rectangle within which the bitmap is to be drawn. 
  2785 	@param aSource A source bitmap. 
  2786 	@param aSourceRect The rectangle in the source bitmap that is copied to the 
  2787 	destination rectangle. 
  2788 	@see TLinearDDA */
  2789 	virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect)=0;
  2790 
  2791 	/** Draws a specified rectangle of a source bitmap to fit into a given rectangle using a given mask.
  2792 
  2793 	Notes:
  2794 	
  2795 	  This member function uses rectangle sizes in pixels and does a 
  2796 	stretch/compress blit using a linear DDA.
  2797 	
  2798 	
  2799 	@param aDestRect The rectangle within which the bitmap is to be drawn. 
  2800 	@param aBitmap The source bitmap
  2801 	@param aSourceRect The rectangle in the source bitmap that is to be drawn
  2802 	@param aMaskBitmap The mask to be applied to the source bitmap while drawing
  2803 	@param aInvertMask Flag to indicate if the mask should be inverted.
  2804 	*/
  2805 	virtual void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0;
  2806 
  2807 	/** Draws a specified rectangle from a wserv bitmap and its mask into 
  2808 	another rectangle.
  2809 
  2810 	The function compresses/stretches the specified rectangle from the bitmap 
  2811 	to fit the destination rectangle. 
  2812 	The mask bitmap can be used as either a positive or negative mask. Masked 
  2813 	pixels are not mapped to the destination rectangle.
  2814 
  2815 	A black and white (binary) mask bitmap is used. With aInvertMask=EFalse, black 
  2816 	pixels in the mask bitmap stop corresponding pixels in the source bitmap from 
  2817 	being transferred to the destination rectangle. With aInvertMask=ETrue, white 
  2818 	pixels in the mask bitmap stop corresponding pixels in the source bitmap from 
  2819 	being transferred to the destination rectangle.
  2820 
  2821 	Note: this member function uses rectangle sizes in pixels and does a stretch/compress 
  2822 	blit using a linear DDA.
  2823 
  2824 	@param aDestRect The rectangle within which the masked bitmap is to be drawn. 
  2825 	@param aBitmap A source wserv bitmap. 
  2826 	@param aSourceRect The rectangle in the source bitmap that is copied to the 
  2827 	destination rectangle.
  2828 	@param aMaskBitmap A mask wserv bitmap. 
  2829 	@param aInvertMask If false, a source pixel that is masked by a black pixel 
  2830 	is not transferred to the destination rectangle. If true, then a source pixel 
  2831 	that is masked by a white pixel is not transferred to the destination rectangle. */
  2832 	virtual void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask)=0;
  2833 
  2834 	/** Draws text without a surrounding box. 
  2835 	
  2836 	The text baseline is aligned with the y co-ordinate of the specified point, 
  2837 	and the left end of the text is aligned with the x co-ordinate of the 
  2838 	specified point.
  2839 	
  2840 	Note:
  2841 	
  2842 	Text drawing is done with the pen, and is subject to the pen colour. The 
  2843 	effective text colour also depends on the drawing mode. The size and style 
  2844 	of the text depends on the font used. The layout of the text depends on the 
  2845 	justification mode set.
  2846 	
  2847 	@param aText The text string to be drawn. 
  2848 	@param aPosition A point specifying the position of the left end of the text. */
  2849 	virtual void DrawText(const TDesC& aText,const TPoint& aPosition) = 0;
  2850 
  2851 	/** Draws text inside a box.
  2852 	
  2853 	The surrounding box is filled with the current brush colour (not a pattern) 
  2854 	and is drawn without any outline. The effective box colour depends on the 
  2855 	drawing mode - if a brush colour has not been set then the brush defaults 
  2856 	to white. The brush may be set to TBrushStyle::ENullBrush if text 
  2857 	positioning relative to a box is required, but the box should not be filled.
  2858 	
  2859 	The font used is that set by UseFont(). If no font is in use then a panic 
  2860 	occurs.
  2861 	
  2862 	The alignment of the text within the box can be specified.
  2863 	
  2864 	Text drawn within a box is also clipped to that box. Unless you intend to 
  2865 	clip the top off the text, aBaselineOffset should be greater than or equal 
  2866 	to the ascent of the current font.
  2867 	
  2868 	Offsets:
  2869 	
  2870 	If the offset is negative, zero, or less than font height this is handled 
  2871 	as would be expected, i.e. no text will be seen in the box in the first two 
  2872 	instances, and the top of the text will be clipped in the latter case.
  2873 	
  2874 	Margins:
  2875 	
  2876 	For the drawing of right-aligned text, aLeftMargin indicates the margin from 
  2877 	the right of aBox - where a positive value results in a leftwards offset. 
  2878 	
  2879 	Negative margins can be used to display portions of the text string clipped 
  2880 	by the box. A negative margin for left aligned text would clip the start of 
  2881 	the text string. Similarly, a negative margin for right aligned text would 
  2882 	clip the end of the text string.
  2883 	
  2884 	If the margin is greater than the width of the box then no text will be 
  2885 	visible.
  2886 	
  2887 	The margin is still honoured for centred text - centred text will not be 
  2888 	centred in the box, unless the margin is zero.
  2889 	
  2890 	Note:
  2891 	
  2892 	Text drawing is done with the pen, and is thus subject to the pen colour. 
  2893 	The effective text colour also depends on the drawing mode. The size and 
  2894 	style of the text depends on the used font. The layout of the text depends 
  2895 	on the justification mode set.
  2896 	
  2897 	@param aText The text string to be drawn. 
  2898 	@param aBox The box to draw the text in. 
  2899 	@param aBaselineOffset An offset from the top of the box to the text 
  2900 	baseline. 
  2901 	@param aAlignment The text alignment mode default is left aligned. 
  2902 	@param aLeftMargin The left margin for left-aligned text, or the right 
  2903 	margin 
  2904 	for right-aligned text default is zero. */
  2905 	virtual void DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TTextAlign aAlignment = ELeft,
  2906 		TInt aLeftMargin = 0) = 0;
  2907 	IMPORT_C virtual void DrawText(const TDesC& aText,const TPoint& aPosition,const TDrawTextParam& aParam);
  2908 	IMPORT_C virtual void Reserved();
  2909 	IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TPoint& aPosition,const TDrawTextExtendedParam& aParam);
  2910 							
  2911 	/** Maps pixels in the specified rectangle.
  2912 	The function tries to match the colour of a pixel with one of the RGB values 
  2913 	in an array of RGB pairs. If there is a match, the colour is changed to the 
  2914 	value specified in the other RGB in the RGB pair.
  2915 	@param aRect The rectangle in which pixels are to be mapped.
  2916 	@param aColors A pointer to a set of RGB pairs. 
  2917 	@param aNumPairs The number of pairs 
  2918 	@param aMapForwards ETrue, mapping is done from the first RGB to the second 
  2919 	RGB in the pair; EFalse, mapping is done from the second RGB to the first 
  2920 	RGB in the pair. */	
  2921 	virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards) = 0;
  2922 	
  2923 	/** Sets the clipping region, any items that fall outside the extent of the clipping 
  2924 	region will not be drawn.
  2925 	
  2926 	Note that clipping is additive. If a clipping rectangle has been set using SetClippingRect() 
  2927 	then clipping will be to the intersection of that rectangle and this region.
  2928 	
  2929 	@param aRegion The new clipping region. Note that clipping region co-ordinates are
  2930 	used as absolute co-ordinates, they are not transformed by the current co-ordinate 
  2931 	origin before use (as occurs in SetClippingRect()).
  2932 	 
  2933 	@return KErrNone if successful; KErrArgument if the TRegion is not valid; KErrNoMemory if there is insufficient memory.
  2934 	
  2935 	@see CGraphicsContext::CancelClippingRegion() 
  2936 	@see CGraphicsContext::SetClippingRect() */		
  2937 	virtual TInt SetClippingRegion(const TRegion &aRegion) = 0;
  2938 	
  2939 	/** Cancels the current clipping region. 
  2940 	@see CGraphicsContext::SetClippingRegion()*/
  2941 	virtual void CancelClippingRegion() = 0;
  2942 	
  2943 	/** Draws vertical text in the specified direction.
  2944 	@param aText The text to be drawn. 
  2945 	@param aPos Point of origin of the text baseline. 
  2946 	@param aUp Direction. ETrue for up, EFalse for down. */
  2947 	virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp) = 0;
  2948 	
  2949 	/** Draws text vertically in the specified direction, within a box of the specified size.
  2950 	@param aText The text to be drawn. 
  2951 	@param aBox The bounding box within which the text should be drawn, and which it is clipped to.
  2952 	@param aBaselineOffset The height of the top of the characters from their text baseline. 
  2953 	@param aUp The direction. ETrue for up, EFalse for down.
  2954 	@param aVert The text alignment. 
  2955 	@param aMargin The margin. */	
  2956 	virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0) = 0;
  2957 	
  2958 	IMPORT_C TInt GetUnderlineMetrics(TInt& aTop,TInt& aBottom);
  2959 
  2960 	/** Set the font's shadow colour
  2961 	@param aShadowColor Shadow colour to be set.
  2962 	@return KErrNone, if successful; otherwise, another of the system-wide errors. */
  2963 	IMPORT_C TInt SetShadowColor(const TRgb& aShadowColor);
  2964 
  2965 	/** Get the font's shadow colour
  2966 	@param aShadowColor Shadow colour of the font returned by the funtion.
  2967 	@return KErrNone, if successful; otherwise, another of the system-wide errors. */
  2968 	IMPORT_C TInt GetShadowColor(TRgb& aShadowColor);
  2969 
  2970 	/** Determine if the Gc is a CFbsBitGc
  2971 	@return ETrue, if the Gc is a CFbsBitGc, EFalse otherwise 
  2972 	@publishedAll
  2973 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases.
  2974 	*/
  2975 	IMPORT_C TBool IsFbsBitGc() const;
  2976 
  2977 	IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition);
  2978 	IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0);
  2979 	IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextParam& aParam);
  2980 
  2981 	IMPORT_C void DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPos,TBool aUp);
  2982 	IMPORT_C void DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
  2983 	
  2984 	IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextExtendedParam& aParam);
  2985 	
  2986 protected:
  2987 
  2988 	/**
  2989 	An APIExtension method to allow the addition of new APIs to retain compatibility 
  2990 	with previous versions of gdi.dll
  2991 	@param aOutput is for output
  2992 	@param aInput is for input
  2993 	@see CGraphicsContext
  2994 	@publishedAll
  2995 	WARNING: Function for internal use ONLY.  Compatibility is not guaranteed in future releases.
  2996 	*/
  2997 	IMPORT_C virtual TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput);	
  2998 	
  2999 	/**
  3000 	A reserved virtual function for future use.
  3001 	*/
  3002 	IMPORT_C virtual void Reserved_CGraphicsContext_2();		
  3003 	};
  3004 
  3005 
  3006 /** An abstract, device-independent, interface to bitmapped graphics contexts.
  3007 
  3008 This holds the setting used to draw to a CBitmapDevice.
  3009 
  3010 The default settings of a CBitmapContext object immediately after construction 
  3011 are:
  3012 
  3013 drawing mode is EDrawModePen (pen and brush colours used as they are)
  3014 
  3015 no clipping rectangle
  3016 
  3017 pen settings are: black, solid, single pixel width
  3018 
  3019 brush style is null
  3020 
  3021 no text font selected
  3022 
  3023 The classes CFbsBitGc and CWindowGc are derived from this class.
  3024 
  3025 @see CFbsBitGc 
  3026 @publishedAll
  3027 @released
  3028 */
  3029 class CBitmapContext : public CGraphicsContext
  3030 	{
  3031 public:
  3032 	/** Clears the whole bitmap.
  3033 	
  3034 	The cleared area is filled with the current brush colour.
  3035 	
  3036 	This pure virtual function is implemented in derived classes. */
  3037 	virtual void Clear()=0;
  3038 
  3039 	/** Clears a rectangular area of a bitmap.
  3040 	
  3041 	The cleared area is filled with the current brush colour.
  3042 	
  3043 	This pure virtual function is implemented in derived classes.
  3044 	
  3045 	@param aRect The rectangle to clear. */
  3046 	virtual void Clear(const TRect& aRect)=0;
  3047 
  3048 	/** Copies a rectangle.
  3049 	
  3050 	This pure virtual function is implemented in derived classes.
  3051 	
  3052 	@param aOffset The offset from the top left corner of the rectangle to be 
  3053 	copied to the top left corner of the copy.
  3054 	@param aRect The rectangular area to be copied. */
  3055 	virtual void CopyRect(const TPoint& aOffset,const TRect& aRect)=0;
  3056 
  3057 	/** Performs a bitmap block transfer.
  3058 	
  3059 	This pure virtual function is implemented in derived classes.
  3060 	
  3061 	@param aPoint The destination for the top left corner of the transferred bitmap. 
  3062 	It is relative to the top left corner of the destination bitmap, which may be the screen.
  3063 	@param aBitmap A memory-resident bitmap. */
  3064 	virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap)=0;
  3065 
  3066 	/** Performs a bitmap block transfer of a rectangular piece of a bitmap.
  3067 	
  3068 	If the specified rectangle is larger than the bitmap then the bitmap is 
  3069 	padded with white.
  3070 	
  3071 	This pure virtual function is implemented in derived classes.
  3072 	
  3073 	@param aPoint The destination for the top left corner of the transferred bitmap.
  3074 	It is relative to the top left corner of the destination bitmap, which may be the screen.
  3075 	
  3076 	@param aBitmap A memory-resident bitmap 
  3077 	@param aRect A rectangle defining the portion of the bitmap to transfer. 
  3078 	Its coordinates are relative to the top left corner of the source bitmap.   */
  3079 	virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aRect)=0;
  3080 
  3081 	/** Performs a masked bitmap block transfer.
  3082 	
  3083 	The mask bitmap can be used as either a positive or negative mask. Masked 
  3084 	pixels are not mapped to the destination rectangle.
  3085 	
  3086 	This function uses either a black and white (binary) mask bitmap, or if 
  3087 	aMaskBitmap's display mode is EGray256, alpha blending is used. Use of 
  3088 	any other mode may result in unpredictable results
  3089 	
  3090 	With aInvertMask=EFalse, black pixels in the mask bitmap stop corresponding 
  3091 	pixels in the source bitmap from being transferred to the destination rectangle. 
  3092 	With aInvertMask=ETrue, white pixels in the mask bitmap stop corresponding 
  3093 	pixels in the source bitmap from being transferred to the destination 
  3094 	rectangle.
  3095 	
  3096 	Note that if the mask bitmap is smaller than the source bitmap, then it is 
  3097 	tiled across the bitmap. Note that the mask is applied before the piece of 
  3098 	the bitmap is defined - the mask is tiled relative to the top left of the 
  3099 	original source bitmap rather than the top left of the bitmap piece.
  3100 	
  3101 	This pure virtual function is implemented in derived classes.
  3102 	
  3103 	@param aPoint The destination for the top left corner of the transferred bitmap. 
  3104 	It is relative to the top left corner of the destination bitmap, which may be the screen. 
  3105 	@param aBitmap A memory-resident source bitmap. 
  3106 	@param aSourceRect A rectangle defining the piece of the bitmap to be drawn, 
  3107 	with co-ordinates relative to the top left corner of the bitmap. 
  3108 	@param aMaskBitmap A mask bitmap 
  3109 	@param aInvertMask If  EFalse, a source pixel that is masked by a black pixel 
  3110 	is not transferred to the destination rectangle. If ETrue, then a source 
  3111 	pixel that is masked by a white pixel is not transferred to the destination 
  3112 	rectangle. */
  3113 	virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0;
  3114 
  3115 	/** Sets whether the graphics context is faded.
  3116 	
  3117 	@param aFaded ETrue to fade the GC; EFalse to unfade it. */
  3118 	virtual void SetFaded(TBool aFaded)=0;
  3119 
  3120 	/** Sets the fading parameters.
  3121 	
  3122 	This function allows you to override the map used when drawing with a faded 
  3123 	graphics context (GC). However if you draw to a faded window with a faded 
  3124 	GC, then fading on the GC is ignored and the fading of the window is used.
  3125 	
  3126 	Fading is used to change the colour of a window to make other windows stand 
  3127 	out. Fading can either make a faded window closer to white or closer to 
  3128 	black.
  3129 	
  3130 	Fading re-maps colours in the faded GC to fall between the specified black 
  3131 	and white map values. If aBlackMap=0 and aWhiteMap=255 then the colours are 
  3132 	mapped unchanged. As the values converge the colours are mapped to a smaller 
  3133 	range - so the differences between colours in the faded GC decrease. If 
  3134 	the values are reversed then the colours are inverted (i.e. where the GC 
  3135 	would be black, it is now white). 
  3136 	
  3137 	@param aBlackMap Black map fading parameter. Unfaded this is 0. 
  3138 	@param aWhiteMap White map fading parameter. Unfaded this is 255. */
  3139 	virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)=0;
  3140 
  3141 	/**
  3142 	Performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using
  3143 	the data from aAlphaBmp as an alpha blending factor.
  3144 	The formula used is:
  3145 	(S * A + W * (255 - A)) / 255, where:
  3146 	- S - a pixel from aSrcBmp;
  3147 	- W - a pixel from the window;
  3148 	- A - a pixel from aAlphaBmp;
  3149 	The contents of source and alpha bitmap are preserved.
  3150 	The calculated alpha blended pixels are written to the destination CBitmapContext.
  3151 	@param aDestPt Position in the target the result should be drawn to.
  3152 	@param aSrcBmp A pointer to the source bitmap.
  3153 	@param aSrcRect The part of the source bitmap that should be used.
  3154 	@param aAlphaBmp A pointer to the bitmap used as an alpha blending factor.
  3155 	@param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source 
  3156 	                for the alpha blending. The size of the area is the same as the 
  3157 	                source bitmap area - aSrcRect parameter.*/	
  3158 	
  3159 	virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0;	
  3160 	
  3161 	/**
  3162 	The method performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using
  3163 	the data from aAlphaBmp as an alpha blending factor.
  3164 	For information on how this function works, see the other overload.
  3165 	@param aDestPt Position in the target the result should be drawn to.
  3166 	@param aSrcBmp A pointer to the source bitmap.
  3167 	@param aSrcRect The part of the source bitmap that should be used.
  3168 	@param aAlphaBmp A pointer to the bitmap used as an alpha blending factor.
  3169 	@param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source 
  3170 	                for the alpha blending. The size of the area is the same as the 
  3171 	                source bitmap area - aSrcRect parameter.*/
  3172 	virtual	TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp,	const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0;
  3173 	
  3174 protected:
  3175 
  3176 	/*
  3177 	Implementations from CGraphicsContext
  3178 	@see CGraphicsContext::APIExtension(TUid, TAny*&, TAny*)
  3179 	*/
  3180 	IMPORT_C TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput);	
  3181 	/*
  3182 	Implementations from CGraphicsContext
  3183 	@see CGraphicsContext::Reserved_CGraphicsContext_2()
  3184 	*/
  3185 	IMPORT_C void Reserved_CGraphicsContext_2();
  3186 
  3187 	IMPORT_C virtual void Reserved_CBitmapContext_1();
  3188 	IMPORT_C virtual void Reserved_CBitmapContext_2();
  3189 	IMPORT_C virtual void Reserved_CBitmapContext_3();
  3190 	};
  3191 
  3192 /** Defines an abstract interface for the capabilities and attributes of a 
  3193 bitmapped graphics device.
  3194 
  3195 The class specialises the graphics device interface CGraphicsDevice for bitmaps 
  3196 graphics. The Window Server Client-Side API provides one implementation of 
  3197 the interface, CWsScreenDevice, for screen drawing. Another implementation, 
  3198 CFbsBitmapDevice, is used for drawing to in-memory bitmaps. A third, 
  3199 CFbsScreenDevice, is used (rarely) to access the screen directly, without the 
  3200 mediation of the window server. 
  3201 @publishedAll
  3202 @released
  3203 */
  3204 class CBitmapDevice : public CGraphicsDevice
  3205 	{
  3206 public:
  3207 	/** Gets the RGB colour of an individual pixel on a bitmapped graphics 
  3208 	device. 
  3209 	
  3210 	This pure virtual function is implemented in derived classes.
  3211 	
  3212 	@param aColor On return, should contain the RGB colour of the pixel. 
  3213 	@param aPixel The (x,y) co-ordinates of the pixel. The top left pixel is 
  3214 	(0,0). */
  3215 	virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const=0;
  3216 
  3217 	/** Copies a scanline into a buffer.
  3218 	
  3219 	The pixels are converted from the display mode format on the bitmapped 
  3220 	graphics device to the format of the specified device display mode.
  3221 	
  3222 	By specifying the start pixel and the number of pixels, either the whole or 
  3223 	a portion of a bitmapped graphics device pixel row may be copied.
  3224 	
  3225 	This pure virtual function is implemented in derived classes.
  3226 	
  3227 	@param aBuf An 8 bit modifiable descriptor buffer into which pixels are 
  3228 	copied; it must be sufficiently large to store all the scanline pixels. 
  3229 	@param aStartPixel The (x,y) co-ordinates of the first pixel of the bitmap 
  3230 	scanline to be put into the buffer. 
  3231 	@param aLength The number of pixels to put into the buffer. 
  3232 	@param aDispMode The display mode into which to convert the pixels. */
  3233 	virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const=0;
  3234 
  3235 	/** Adds a font file to the device's typeface store. The specified font
  3236 	file must be accessible to any process, i.e. not located inside an
  3237 	application's private directory.
  3238 	
  3239 	This pure virtual function is implemented in derived classes.
  3240 	
  3241 	@param aName The name of the font file. 
  3242 	@param aId On return, contains an ID for the font file. 
  3243 	@return KErrNone, if successful; otherwise, another of the system-wide error 
  3244 	codes. */
  3245 	virtual TInt AddFile(const TDesC& aName,TInt& aId)=0;
  3246 
  3247 	/** Removes a font file from the font store.
  3248 	
  3249 	This pure virtual function is implemented in derived classes.
  3250 	
  3251 	@param aId The ID of the font file to be removed. The default is 0. */
  3252 	virtual void RemoveFile(TInt aId=0)=0;
  3253 
  3254 	/**
  3255 	Gets the font which is the nearest to the given font specification.
  3256 	
  3257 	When the font is no longer needed, call @c ReleaseFont().
  3258 	
  3259 	Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInPixels() 
  3260 	yielding (virtually) the same result. However clients are strongly encouraged to use the new
  3261 	@c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every 
  3262 	character within any given text string will fit within the given amount of pixels, whereas the design 
  3263 	height is an aesthetic unit decided by the font designer without strict physical meaning, which 
  3264 	may result in cropped characters.
  3265 	
  3266 	@param aFont On return, contains a pointer to the nearest font.
  3267 	@param aFontSpec The specification of the font to be matched.
  3268 	@return KErrNone if successful; a system-wide error code otherwise.
  3269 	@publishedAll
  3270 	@deprecated Use GetNearestFontToDesignHeightInPixels
  3271 	*/
  3272 	virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec) = 0;
  3273 
  3274 	/**
  3275 	Gets the font which is the nearest to the given font specification.
  3276 	
  3277 	When the font is no longer needed, call @c ReleaseFont().
  3278 	
  3279 	This new function replaces the deprecated @c GetNearestFontInPixels() yielding (virtually) the 
  3280 	same result. However clients are strongly encouraged to use the new
  3281 	@c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every 
  3282 	character within any given text string will fit within the given amount of pixels, whereas the design 
  3283 	height is an aesthetic unit decided by the font designer without strict physical meaning, which 
  3284 	may result in cropped characters.
  3285 
  3286 	@param aFont On return, contains a pointer to the nearest font.
  3287 	@param aFontSpec The specification of the font to be matched.
  3288 	@return KErrNone if successful; a system-wide error code otherwise.
  3289 	@publishedAll
  3290 	@released
  3291 	*/
  3292 	virtual TInt GetNearestFontToDesignHeightInPixels(
  3293 		CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; }
  3294 
  3295 	/**
  3296 	Gets the font which is the nearest to the given font specification.
  3297 	
  3298 	When the font is no longer needed, call @c ReleaseFont().
  3299 	
  3300 	The font and bitmap server returns a pointer to the nearest matching font 
  3301 	from those available. Matches to max height of font - this does its best 
  3302 	to return a font that will fit within the maximum height specified (but 
  3303 	note that variations due to hinting algorithms may rarely result in this 
  3304 	height being exceeded by up to one pixel). Problems can also be 
  3305 	encountered with bitmap fonts where the typeface exists but doesn't have 
  3306 	a font small enough.
  3307 
  3308 	@param aFont On return, contains a pointer to the nearest font.
  3309 	@param aFontSpec The specification of the font to be matched.
  3310 	@param aMaxHeight The maximum height within which the font must fit.
  3311 	This overrides the height specified in aFontSpec.
  3312 	@return KErrNone if successful; a system-wide error code otherwise.
  3313 	@publishedAll
  3314 	@released
  3315 	*/
  3316 	virtual TInt GetNearestFontToMaxHeightInPixels(
  3317 		CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; }
  3318 
  3319 	/** Gets the height, in pixels, of the specified typeface at one of its 
  3320 	defined heights.
  3321 	
  3322 	The typeface is identified by by an index. For a given typeface, there are 
  3323 	a discrete number of heights; the specific height is also identified by an 
  3324 	index.
  3325 	
  3326 	The value returned is rounded up or down to the nearest font height in 
  3327 	pixels.
  3328 	
  3329 	This pure virtual function is implemented in derived classes.
  3330 	
  3331 	@param aTypefaceIndex A typeface index number, in the range: 0 to 
  3332 	(NumTypefaces() - 1). 
  3333 	@param aHeightIndex A font height index number, in the range: 0 to 
  3334 	(iNumHeights - 1) where iNumHeights is a public data member of the 
  3335 	TTypefaceSupport object returned by TypefaceSupport(). 
  3336 	@return The height of the font, in pixels.
  3337 	@see TTypefaceSupport
  3338 	@see CGraphicsDevice::NumTypefaces()
  3339 	@see CGraphicsDevice::TypefaceSupport() */
  3340 	virtual TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const=0;
  3341     inline TInt CreateBitmapContext(CBitmapContext*& aGC);
  3342 	};
  3343 
  3344 /** A set of margins used for cropping a picture. 
  3345 
  3346 Margins are specified in twips or pixels. 
  3347 @publishedAll
  3348 @released
  3349 */
  3350 class TMargins
  3351     {
  3352 public:
  3353 	IMPORT_C void InternalizeL(RReadStream& aStream);
  3354 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
  3355 	IMPORT_C TBool operator==(const TMargins& aMargins) const;
  3356 	IMPORT_C TBool operator!=(const TMargins& aMargins) const;
  3357 public:
  3358 	/** Left margin, (in twips or pixels). */
  3359 	TInt iLeft;
  3360 	/** Right margin, (in twips or pixels). */
  3361 	TInt iRight;
  3362 	/** Top margin, (in twips or pixels). */
  3363     TInt iTop;
  3364 	/** Bottom margin, (in twips or pixels). */
  3365 	TInt iBottom;
  3366 	};
  3367 
  3368 /** Picture capabilities.
  3369 
  3370 These include the types of scaling that can be applied to a picture, and whether 
  3371 or not it is croppable. 
  3372 @publishedAll
  3373 @released
  3374 */
  3375 class TPictureCapability
  3376 	{
  3377 public:
  3378 	/** Scaling types. */
  3379 	enum TScalingType
  3380 		{
  3381 		/** The picture is not scalable. */
  3382 		ENotScaleable,
  3383 		/** The picture is fully scalable. */
  3384 		EFullyScaleable,
  3385 		/** The picture is scalable to any size, as long as its aspect ratio 
  3386 		(the ratio of its height to its width) remains constant. */
  3387 		EScaleableMaintainingAspectRatio
  3388 		};
  3389 public:
  3390 	inline TPictureCapability(TScalingType aScalingType,TBool aCroppable);
  3391 public:
  3392 	/** Whether or not the picture is croppable. */
  3393 	TScalingType iScalingType;
  3394 	/** Scaling type. */
  3395 	TBool iIsCroppable;
  3396 	};
  3397 
  3398 /** Abstract base class for: drawing a picture to a graphics context, storing 
  3399 and restoring the picture. 
  3400 
  3401 The class defines the protocol for a number of concrete picture classes. Its 
  3402 main role is to support glass doors used in object embedding.
  3403 
  3404 The class provides a protocol for the provision of scaling and cropping 
  3405 functions by derived classes, together with default implementations.
  3406 
  3407 Its main function is Draw(), which draws the picture onto the graphics context 
  3408 at a particular point. It also has two important pure virtual functions: 
  3409 ExternalizeL() and GetOriginalSizeInTwips().
  3410 
  3411 A picture has both an original representation and an on-screen representation. 
  3412 The original representation has a size in twips, and can somehow be drawn. 
  3413 The on-screen representation is assumed to be drawn under the control of an 
  3414 application which may wish to re-size or scale the original in some way, to 
  3415 crop it at the edges, and/or to ensure it fits within a particular defined 
  3416 area on the screen.
  3417 
  3418 The class provides several functions that allow an application to set scaling 
  3419 and cropping before invoking the Draw() function to draw the picture on-screen. 
  3420 It is up to the internal workings of the function to determine the order of 
  3421 application cropping and scaling. 
  3422 @publishedAll
  3423 @released
  3424 */
  3425 class CPicture : public CBase
  3426     {
  3427 public:
  3428 	/** Options for detaching pictures from stores. Used by DetachFromStoreL(). */
  3429 	enum TDetach
  3430 		{
  3431 		/** Internalise all data that is required to fully store the picture 
  3432 		later; null any references to containing stores. */
  3433 		EDetachFull,
  3434 		/** Internalise enough information to draw the picture (and no more); 
  3435 		null any references to containing stores. */
  3436 		EDetachDraw
  3437 		};
  3438 public:
  3439 	IMPORT_C virtual ~CPicture();
  3440 	/** Draws a picture.
  3441 	
  3442 	@param aGc The graphics context. 
  3443 	@param aTopLeft The co-ordinates where the top left corner pixel of the 
  3444 	picture should be placed. Note that whether this is actually drawn depends 
  3445 	on the clipping area defined.
  3446 	@param aClipRect A clipping rectangle that defines the area to which the 
  3447 	function should draw. An implementation should never draw outside this 
  3448 	rectangle. Note that the graphics context may also have a clipping rectangle 
  3449 	set on it. 
  3450 	@param aMap The device map for the graphics device. The implementation 
  3451 	should use this to find the scaling to apply to the picture. */
  3452 	virtual void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap) const=0;
  3453 	IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore) const; // assumes no sub streams
  3454 	virtual void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull) {}
  3455 
  3456 	/** Externalises the picture to a stream.
  3457 	
  3458 	The presence of this function means that the standard templated stream 
  3459 	operator<<() is available to externalise objects of this class.
  3460 	
  3461 	A derived class must supply an implementation of this function.
  3462 	
  3463 	@param aStream The write stream. */
  3464 	virtual void ExternalizeL(RWriteStream& aStream) const =0;
  3465 
  3466 	/** Gets the pictur's original size, in twips.
  3467 	
  3468 	@param aSize The size of the picture, in twips */
  3469 	virtual void GetOriginalSizeInTwips(TSize& aSize) const =0;
  3470 	IMPORT_C virtual void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); // does nothing
  3471 	IMPORT_C virtual void SetCropInTwips(const TMargins& aMargins); // does nothing
  3472 	IMPORT_C virtual TPictureCapability Capability() const; // no scale, no crop
  3473 	IMPORT_C virtual void GetCropInTwips(TMargins& aMargins) const; // returns no crop
  3474 	IMPORT_C virtual TInt ScaleFactorWidth() const; // returns no scaling
  3475 	IMPORT_C virtual TInt ScaleFactorHeight() const; // returns no scaling
  3476 	IMPORT_C virtual TBool LineBreakPossible(TUint aClass,TBool aBeforePicture,TBool aHaveSpaces) const;
  3477 	IMPORT_C virtual TBool NativePixelSize(TSize& aPixelSize);
  3478 
  3479 	IMPORT_C void GetSizeInPixels(MGraphicsDeviceMap* aMap, TSize& aSize) const;
  3480 	IMPORT_C void SetSizeInPixels(MGraphicsDeviceMap* aMap, const TSize& aSize);
  3481 	IMPORT_C void AddCropInPixels(MGraphicsDeviceMap* aMap, const TMargins& aMargins);
  3482 	IMPORT_C void GetSizeInTwips(TSize& aSize) const;
  3483 	IMPORT_C void SetSizeInTwips(const TSize& aSize);
  3484 	IMPORT_C void ResetToOriginal();
  3485 protected:
  3486 	IMPORT_C CPicture();
  3487 	};
  3488 
  3489 
  3490 /** Picture header providing an interface to a stored picture. The header holds:
  3491 
  3492 the picture's type, encoded as a UID, which ensures that it will be restored 
  3493 to the correct picture type
  3494 
  3495 the picture's size, which facilitates deferred loading
  3496 
  3497 the stream ID of the picture body, which is replaced by a pointer to the picture 
  3498 object when it has been restored. 
  3499 @publishedAll
  3500 @released
  3501 */
  3502 class TPictureHeader
  3503 	{
  3504 public:
  3505 	IMPORT_C TPictureHeader();
  3506 	IMPORT_C void InternalizeL(RReadStream& aStream);
  3507 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
  3508 	IMPORT_C void DeletePicture();
  3509 public:
  3510 	/** A swizzle storing either the ID of the stream in which the picture is 
  3511 	stored, or a pointer to the internalised picture. */
  3512 	TSwizzle<CPicture> iPicture;
  3513 	/** A UID specifying the type of the picture. */
  3514 	TUid iPictureType;
  3515 	/** The original size of the picture. */
  3516 	TSize iSize;
  3517 	};
  3518 
  3519 
  3520 /** Abstract interface for instantiating and restoring new CPicture derived 
  3521 objects.
  3522 
  3523 A concrete derived class creates pictures of one or more specific types. The 
  3524 class has no member data and just one function, NewPictureL, that needs to 
  3525 be provided by derived classes. 
  3526 @publishedAll
  3527 @released
  3528 */
  3529 class MPictureFactory
  3530 	{
  3531 public:
  3532 	/** Interface to the picture restoration process that ensures that a 
  3533 	picture of the correct type is restored.
  3534 	
  3535 	The class of the object to be restored is determined by the UID of the 
  3536 	stored picture, contained in the specified picture header.
  3537 	
  3538 	The function can allow the restoration of:
  3539 	
  3540 	just one CPicture-derived class, returning an error if the UID indicates 
  3541 	that the stored picture is not of the required type
  3542 	
  3543 	many different CPicture-derived classes, using the UID to choose which of 
  3544 	the possible CPicture-derived classes should be instantiated
  3545 	
  3546 	@param aHeader The picture header that should be restored. 
  3547 	@param aDeferredPictureStore The store in which both the header and picture 
  3548 	reside. */
  3549 	virtual void NewPictureL(TPictureHeader& aHeader,const CStreamStore& aDeferredPictureStore)const=0;
  3550 	};
  3551 
  3552 // printing classes
  3553 
  3554 /**
  3555 The maximum length of a printer model name.
  3556 @see TPrinterModelName 
  3557 @publishedAll
  3558 @released
  3559 */
  3560 const TInt KMaxPrinterModelNameLength=0x20;
  3561 
  3562 /**
  3563 Defines a modifiable buffer descriptor that can contain the name of a
  3564 printer model. The maximum length of the buffer is 32.
  3565 @since 5.0 
  3566 @publishedAll
  3567 @released
  3568 */
  3569 typedef TBuf<KMaxPrinterModelNameLength> TPrinterModelName;
  3570 
  3571 /** Page specification for a print operation.
  3572 
  3573   The page specification consists of the page orientation and the page
  3574 size in twips or pixels. By default, the page orientation is portrait.
  3575 When using landscape orientation, the left hand side of the page
  3576 becomes the top. 
  3577 "gdi.lib"
  3578 @since 5.0
  3579 @publishedAll
  3580 @released
  3581 */	
  3582 class TPageSpec
  3583 	{
  3584 public:
  3585 	/**The available page orientations. */
  3586 	enum TPageOrientation
  3587 		{
  3588 		/** Portrait page orientation */
  3589 		EPortrait,
  3590 		/** Landscape page orientation */
  3591 		ELandscape
  3592 		};
  3593 public:
  3594 	IMPORT_C TPageSpec();
  3595 	IMPORT_C TPageSpec(TPageOrientation aOrientation,const TSize& aSize);
  3596 	IMPORT_C void InternalizeL(RReadStream& aStream);
  3597 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
  3598 	IMPORT_C TSize OrientedPageSize() const;
  3599 	IMPORT_C TBool operator==(const TPageSpec& aPageSpec) const;
  3600 	IMPORT_C TBool operator!=(const TPageSpec& aPageSpec) const;
  3601 public:
  3602 	/** The width and height of the page in portrait orientation in twips or 
  3603 	pixels.
  3604 	
  3605 	Note that OrientedPageSize() returns the width and height in reverse order 
  3606 	for a landscape portrait. */
  3607 	TSize iPortraitPageSize;
  3608 	/** The page orientation. */
  3609 	TPageOrientation iOrientation;
  3610 	};
  3611 
  3612 
  3613 /**  Controls the attributes of the band to be printed.
  3614 
  3615 An object of this type is passed as a parameter to functions.
  3616 MPageRegionPrinter::PrintBandL() and CPrinterControl::QueueGetBand().
  3617 @see MPageRegionPrinter::PrintBandL()
  3618 @see CPrinterControl::QueueGetBand() 
  3619 @since 5.0
  3620 @publishedAll
  3621 @released
  3622 */	
  3623 class TBandAttributes
  3624     {
  3625 public:
  3626 	/** The width and height of the band in twips or pixels. */
  3627 	TRect iRect;
  3628 	/** ETrue to draw no text to the band; EFalse to draw text. */
  3629 	TBool iTextIsIgnored; // any text drawing to this band is ignored
  3630 	/** ETrue to draw no graphics to the band; EFalse to draw graphics. */
  3631 	TBool iGraphicsIsIgnored; // any graphics drawing to this band is ignored
  3632 	/** ETrue if band is the first band on the page; EFalse if not. */
  3633 	TBool iFirstBandOnPage;
  3634 	};
  3635 
  3636 /**  Printer port interface.
  3637 
  3638 This interface is used as the base class for the various types of
  3639 printer port. New printer port classes should be derived from this
  3640 class.After allocation and construction, a pointer to a concrete
  3641 printer port should be passed to
  3642 CPrintSetup::StartPrintL().
  3643 @see CPrintSetup::StartPrintL() 
  3644 @since 5.0
  3645 @publishedAll
  3646 @released
  3647 */
  3648 class CPrinterPort : public CBase
  3649 	{
  3650 public:
  3651 	/** Writes data asynchronously to the printer port.
  3652 	
  3653 	@param aBuf Data to be written to the port 
  3654 	@param aRequestStatus A reference to the request status object. If the 
  3655 	request is cancelled, this should be set to KErrCancel; if the request 
  3656 	completes normally, this should be set to KErrNone. */
  3657 	virtual void WriteRequest(const TDesC8& aBuf,TRequestStatus& aRequestStatus)=0;
  3658  
  3659 	/** Cancels an outstanding WriteRequest() operation. */
  3660 	virtual void Cancel()=0;
  3661 	};
  3662 
  3663 
  3664 /** Detailed information about a printer model. 
  3665 "gdi.lib" 
  3666 @since 5.0
  3667 @publishedAll
  3668 @released
  3669 */
  3670 class TPrinterModelEntry
  3671   	{
  3672 public:
  3673 	/** The name of the printer model. */
  3674 	TPrinterModelName iModelName;
  3675 	/** If ETrue, then a printer port is required. */
  3676 	TBool iRequiresPrinterPort;
  3677 	/** The UID associated with this printer model. */
  3678 	TUid iUid;
  3679 public:
  3680 	IMPORT_C void InternalizeL(RReadStream& aStream);
  3681 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
  3682 	};
  3683 
  3684 
  3685 /** Information about a printer model.
  3686 
  3687 An instance of this class consists of a TPrinterModelEntry and a stream ID, 
  3688 and is passed to CPrinterDevice::SetModel().
  3689 
  3690 @see CPrinterDevice 
  3691 @publishedAll
  3692 @released
  3693 */
  3694 class TPrinterModelHeader
  3695     {
  3696 public:
  3697 	/** The printer model. */
  3698 	TPrinterModelEntry iEntry;
  3699 	/** The stream ID for model data. */
  3700 	TStreamId iModelDataStreamId;
  3701 public:
  3702 	IMPORT_C void InternalizeL(RReadStream& aStream);
  3703 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
  3704 	};
  3705 
  3706 
  3707 /** Printer control interface.
  3708 
  3709 This abstract base class acts as the interface between a CPrinterDevice object 
  3710 and the printer. It creates the context for, and controls the progress and 
  3711 termination of the print job.
  3712 
  3713 Only those who need to add new printer drivers should write derived classes. 
  3714 After instantiation of such a class, using CPrinterDevice::CreateControlL(), 
  3715 the object can be accessed via the iControl member of CPrinterDevice.
  3716 
  3717 @see CPrinterDevice 
  3718 @publishedAll
  3719 @released
  3720 */
  3721 class CPrinterControl : public CBase
  3722     {
  3723 public:
  3724 	/** Flags indicating whether there is more on the page to print. */
  3725 	enum TMoreOnPage
  3726 		{
  3727 		/** Indicates there is more to print on the current page. */
  3728 		EMoreOnPage,
  3729 		/** Indicates there is no more to print on the current page. */
  3730 		ENoMoreOnPage
  3731 		};
  3732 public:
  3733 	IMPORT_C ~CPrinterControl();
  3734 
  3735 	/** Gets the number of bands per page.
  3736  
  3737  	@return The number of bands on each page. */
  3738 	virtual TInt BandsPerPage()=0;
  3739 
  3740 	/**  Prints the next band on the page.
  3741  
  3742  	This is an asynchronous function.
  3743  	@param  aStatus Request status object. On successful completion
  3744     contains KErrNone, otherwise another of the system-wide 
  3745     error codes.
  3746  	@param aBand  On return, indicates the attributes of the band, including 
  3747  	its height and width and whether or not the device will ignore one or 
  3748  	other of graphics or text output. This information may be used by 
  3749  	applications to draw more efficiently, or may be ignored
  3750  	@return EMoreOnPage, if any unprinted bands remain on the 
  3751  	current page. ENoMoreOnPage, if the current band is last on 
  3752  	page. */
  3753 	virtual TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand)=0; // returns affirmative if more to print on current page
  3754 
  3755 	/** Terminates the print process.
  3756 
  3757 	This is an asynchronous function and is called when no more bands in
  3758 	the document remain to be printed.Note that all bands have been
  3759 	printed when no more pages or copies remain to be printed, and
  3760 	QueueGetBand() returns ENoMoreToPrint.
  3761 
  3762 	@param aStatus Request status object. On successful completion contains 
  3763 	KErrNone, otherwise another of the system-wide error codes. */
  3764 	virtual void QueueEndPrint(TRequestStatus& aStatus)=0; 
  3765 
  3766 	/** Aborts the print process before it has completed.
  3767 	
  3768 	This function should be called if QueueGetBand() reports an error. */
  3769 	virtual void AbortPrint()=0; // tidy up synchronously in a short time, return success code
  3770 protected:
  3771 	IMPORT_C CPrinterControl(CPrinterPort* aPrinterPort);
  3772 protected:
  3773 	/** State flags. */
  3774 	enum TState 
  3775 		{
  3776 		/** Not printing. */
  3777 		ENotPrinting, 
  3778 		/** Printing. */
  3779 		EPrinting
  3780 		};
  3781 	/** Printing state. */
  3782 	TState iState;
  3783 	/** Printer port. */
  3784 	CPrinterPort* iPrinterPort;
  3785 	};
  3786 
  3787 class CDictionaryStore;
  3788 class RFs;
  3789 
  3790 /** Printer graphics device interface.
  3791 
  3792 This abstract class represents a physical graphics device that is used for 
  3793 printing.
  3794 
  3795 This class is used to:
  3796 
  3797 set and get the page specification
  3798 
  3799 map between the co-ordinates of the printed page (in twips) and the co-ordinates 
  3800 of the image device (in pixels)
  3801 
  3802 get and set the printer model entry
  3803 
  3804 create and delete a printer control.
  3805 
  3806 A printer driver is defined in terms of a printer device and a printer control. 
  3807 A printer device can own either a single or no printer control. The control 
  3808 determines the progress and termination of the print job and is responsible 
  3809 for producing output.
  3810 
  3811 @see CPrinterControl 
  3812 @publishedAll
  3813 @released
  3814 */
  3815 class CPrinterDevice : public CGraphicsDevice
  3816 	{
  3817 public:
  3818 	IMPORT_C ~CPrinterDevice();
  3819 
  3820 	/** Gets the current page specification in twips.
  3821 	
  3822 	@return The current page specification, in twips. */
  3823 	inline TPageSpec CurrentPageSpecInTwips() const {return(iCurrentPageSpecInTwips);}
  3824 
  3825 	/** Sets the page specification in twips.
  3826 	
  3827 	@param aPageSpec The page specification in twips. */
  3828 	IMPORT_C virtual void SelectPageSpecInTwips(const TPageSpec& aPageSpec);
  3829 	IMPORT_C virtual TRect PrintablePageInPixels() const;
  3830 
  3831 	/** Gets the printer model entry.
  3832 	
  3833 	@return The printer model entry. */
  3834 	virtual TPrinterModelEntry Model()const =0;
  3835 
  3836 	/** Sets the printer model header and the store.
  3837 	
  3838 	@param aModel The printer model header.
  3839 	@param aStore  The store.
  3840 	@return KErrNone if successful; otherwise, another of the system-wide 
  3841 	error codes.*/
  3842 	virtual TInt SetModel(const TPrinterModelHeader& aModel,CStreamStore& aStore)=0;
  3843 
  3844 	/** Creates a printer control.
  3845 	
  3846 	The printer control is an instance of a CPrinterControl derived class; it 
  3847 	is assigned to this printer device's iControl member.
  3848 	
  3849 	Note that this function is called by CPrintSetup::StartPrintL().
  3850 	
  3851 	@param aPrinterPort Pointer to an instance of a printer port. */
  3852 	virtual void CreateControlL(CPrinterPort* aPrinterPort)=0;
  3853 	IMPORT_C virtual void DeleteControl();
  3854 
  3855 	/**  Externalizes printer properties to the store.
  3856 
  3857 	The default implementation is empty.
  3858 
  3859 	@param  aStream  The read stream. */
  3860 	virtual void InternalizePropertiesL(RReadStream& /*aStream*/) {}
  3861 
  3862 	/**  Externalizes printer properties to the store.
  3863 	
  3864 	The default implementation is empty.
  3865 	
  3866 	@param  aStream  The write stream. */
  3867 	virtual void ExternalizePropertiesL(RWriteStream& /*aStream*/) const {}
  3868 	IMPORT_C void RestorePropertiesL();
  3869 	IMPORT_C void StorePropertiesL() const;
  3870 protected:
  3871 	IMPORT_C CPrinterDevice();
  3872 public:
  3873 	/** The printer control.
  3874 	
  3875 	This may be NULL. If implemented, it provides control over the print 
  3876 	operation. */
  3877 	CPrinterControl* iControl;
  3878 protected:
  3879 	/** Current page specification in twips. */
  3880 	TPageSpec iCurrentPageSpecInTwips;
  3881 	};
  3882 
  3883 
  3884 /** Printer model list interface.
  3885 
  3886 Functions provided by this abstract base class can be used to extract printer 
  3887 model information from the list of printer models. This class would typically 
  3888 be used to implement printer selection in a dialog box.
  3889 
  3890 @see CPdrModelList 
  3891 @publishedAll
  3892 @released
  3893 */
  3894 class CPrinterModelList : public CBase
  3895      {
  3896 public:
  3897 	/** Gets the number of printer models in the printer model list.
  3898  
  3899  	@return The number of printer models. */
  3900     virtual TInt ModelCount() const=0;
  3901 
  3902 	/**Gets printer model name.
  3903  
  3904 	This is the name of the printer model at the specified index within
  3905 	the list of printer models.
  3906  
  3907 	@param  anIndex The index of the printer model within the array of
  3908     printer models. Note that this number must be between zero and 
  3909     ModelCount().
  3910     @return Name of printer model, up to 32 characters long */
  3911     virtual const TPrinterModelEntry operator[](TInt anIndex)=0;
  3912 
  3913 	/** Gets a printer models index within the model list from its UID.
  3914 
  3915 	@param aModelUid The UID of the printer model.
  3916 	@return  The index of the printer model within the array of printer models.*/
  3917 	virtual TInt UidToNum(TUid aModelUid) const=0;
  3918     };
  3919 
  3920 
  3921 /** Interface for printing in bands.
  3922 
  3923 This class provides a single PrintBandL() function that prints 
  3924 the body of each page band by band. Classes derived from this interface must 
  3925 provide an implementation of the PrintBandL() function. 
  3926 @since 5.0 
  3927 @publishedAll
  3928 @released
  3929 */
  3930 class MPageRegionPrinter
  3931 	{
  3932 public:
  3933 	/** Prints a band.
  3934 	
  3935 	Implementations should set up a graphics context to which all drawing should 
  3936 	take place using CGraphicsDevice::CreateContext(). All co-ordinate 
  3937 	calculations should be done in twips, and converted into pixels before 
  3938 	starting the print job.
  3939 	
  3940 	@param aDevice Pointer to the graphics device representing the printer.
  3941 	@param aPageNo The number of the page containing the band to be printed.
  3942 	@param aBandInPixels Attributes of the band to be printed. */
  3943 	virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBandInPixels)=0;
  3944 	};
  3945 
  3946 /**
  3947 The UID value of a printer specification data store. 
  3948 @publishedAll
  3949 @released
  3950 */
  3951 const TInt KPdrStoreFileUidVal=268435514;
  3952 
  3953 const TInt KPdlUidVal=268450588;
  3954 const TInt KUdlUidVal=268450589;
  3955 
  3956 
  3957 /** Printer specific user interface.
  3958 
  3959 The class is used to implement a printer specific setup dialog. A concrete 
  3960 implementation of the class is supplied in a UDL (i.e. a UI DLL).
  3961 
  3962 CPrinterDriver::CreatePrinterDriverUIL() is used to construct a CPrinterDriverUI 
  3963 object for a specific printer. (This function calls the ordinal 1 exported 
  3964 function of the UDL that performs the construction of the CPrinterDriverUI 
  3965 object).
  3966 
  3967 @see CPrinterDriver::CreatePrinterDriverUIL() 
  3968 @publishedAll
  3969 @released
  3970 */
  3971 class CPrinterDriverUI : public CBase
  3972     {
  3973 protected:
  3974 	IMPORT_C CPrinterDriverUI();
  3975 public:
  3976 	IMPORT_C virtual TBool BeforePrintL();
  3977 	IMPORT_C virtual void AfterPrintL();
  3978 	IMPORT_C virtual void SetPropertiesL();
  3979 	IMPORT_C virtual TBool CanSetProperties();
  3980 
  3981 	/** Sets the printer device.
  3982 	
  3983 	@param aPrinterDevice The printer device. */
  3984 	virtual TInt SetPrinterDevice(CPrinterDevice* aPrinterDevice)=0;
  3985 	};
  3986 								   
  3987 class CFileStore;
  3988 
  3989 
  3990 /** Provides access to a store containing printer specification data.
  3991 
  3992 Printer specification data is held as a direct file store, and usually has 
  3993 a .pdr file type.
  3994 
  3995 A printer driver is implemented as two files: a PDR file containing the printer 
  3996 specification data and a PDL file containing the code to link the printer 
  3997 with the graphics printing system.
  3998 
  3999 The printer specification data is generated by compiling a text file (a .pd 
  4000 file type) using the pdrtran tool. Printer specification data defines:
  4001 
  4002 the name of the associated PDL
  4003 
  4004 a list of one or more models supported by this driver, identified by name 
  4005 and UID
  4006 
  4007 device information such as the size of the device, typeface information for 
  4008 each model, including which typefaces are supported, the heights available 
  4009 in each typeface and the width of each character in a font.
  4010 
  4011 @see CPrinterDriverUI 
  4012 @publishedAll
  4013 @released
  4014 */
  4015 class CPrinterDriver : public CBase
  4016      {
  4017 public:
  4018 	IMPORT_C static CPrinterDriver* NewL();
  4019 	IMPORT_C ~CPrinterDriver();
  4020 	IMPORT_C void OpenPdrL(const TDesC &aName);
  4021 	IMPORT_C void Close();
  4022 	IMPORT_C TInt NumModels() const;
  4023 	IMPORT_C TPrinterModelEntry Model(TInt aNum) const;
  4024 
  4025 	/** Gets the associated graphics printer device.
  4026 	
  4027 	@return The physical graphics device used for printing. */
  4028 	inline CPrinterDevice* PrinterDevice() {return iPrinterDevice;}
  4029 	IMPORT_C CPrinterDevice* CreatePrinterDeviceL(TUid aModelUid);
  4030 	IMPORT_C CPrinterDriverUI* CreatePrinterDriverUIL();
  4031 private:
  4032 	CPrinterDriver();
  4033 	void DeletePrinterDevice();
  4034 	void DoOpenPdrL(const TDesC &aName);
  4035 	void DoCreatePrinterDeviceL(TUid aModelUid);
  4036 	void LoadLibraryL(RLibrary& aLibrary,const TDesC& aExt,TUid aUid2);
  4037 private:
  4038 	RFs iFs;
  4039 	CFileStore *iPdrStore;
  4040 	TInt iNumModels;
  4041 	TPrinterModelHeader* iModelList;
  4042 	TFileName iPdlName;
  4043 	TUid iPdlUid;
  4044 	RLibrary iPdlLibrary;
  4045 	CPrinterDevice* iPrinterDevice;
  4046 	RLibrary iUdlLibrary;
  4047 	};
  4048 
  4049 class RResourceFile;
  4050 
  4051 
  4052 /** Implements a printer model list interface for a collection of PDR files. 
  4053 @publishedAll
  4054 @released
  4055 */
  4056 class CPdrModelList : public CPrinterModelList
  4057     {
  4058 public:
  4059 	IMPORT_C static CPdrModelList* NewL();
  4060 	IMPORT_C virtual ~CPdrModelList();
  4061     IMPORT_C TInt ModelCount() const;
  4062     IMPORT_C const TPrinterModelEntry operator [] (TInt anIndex);
  4063 	IMPORT_C TInt UidToNum(TUid aModelUid) const;  // returns KErrNotFound the model uid is not matched
  4064 	IMPORT_C void AddDirectoryL(const TDesC& aDir);
  4065 	IMPORT_C CPrinterModelList* ScanForModelsL();
  4066 	IMPORT_C CPrinterDriver* CreatePrinterDriverL(TInt anIndex);
  4067 private:
  4068 	CPdrModelList();
  4069 	void ConstructL();
  4070 private:
  4071 	class TFileEntry
  4072 		{
  4073 	public:
  4074 		TFileName iFileName;
  4075 		TDesC* iDirectory;
  4076 		};
  4077 	class TModelEntry
  4078 		{
  4079 	public:
  4080 		TPrinterModelEntry iEntry;
  4081 		TFileEntry* iFile; 
  4082 		};
  4083 private:
  4084 	void ScanDirectoryL(TInt aDirIndex);
  4085 	void ListModelsL(TInt aFileIndex, TParse& aParser, TFileName& aNameOfLoadedResourceFile, TFileName& aTempFileName, RResourceFile& aResourceFile, HBufC8*& aResource);
  4086 	HBufC* NewPathBufL(const TFileEntry& aFileEntry);
  4087 private:
  4088 	CArrayFixSeg<TModelEntry>* iModelArray;
  4089 	CArrayFixFlat<TFileEntry>* iFileArray;
  4090 	CArrayFixFlat<HBufC*>* iDirectoryArray;
  4091 	RFs iFileServer;
  4092 	};
  4093 
  4094  
  4095 /** The interface for mapping between twips and device-specific units enriched 
  4096 with facilities to allow zooming. 
  4097 
  4098 The class is recursive, because a TZoomFactor object can have a 
  4099 MGraphicsDeviceMap (which could itself be a TZoomFactor) in its member data. 
  4100 This allows a zoom factor object to contain another zoom factor object, and 
  4101 is used to allow objects with different zoom factors to be embedded in each 
  4102 other to an arbitrary depth by the application architecture. 
  4103 @publishedAll
  4104 @released
  4105 */
  4106 class TZoomFactor : public MGraphicsDeviceMap
  4107 	{
  4108 public:
  4109 	IMPORT_C TZoomFactor();
  4110 	IMPORT_C ~TZoomFactor();
  4111 	inline TZoomFactor(const MGraphicsDeviceMap* aDevice);
  4112 	inline TZoomFactor(const TZoomFactor* aDevice);
  4113 	IMPORT_C TInt ZoomFactor() const;
  4114 	IMPORT_C void SetZoomFactor(TInt aZoomFactor);
  4115 	inline void SetGraphicsDeviceMap(const MGraphicsDeviceMap* aDevice);
  4116 	inline const MGraphicsDeviceMap* GraphicsDeviceMap() const;
  4117 	IMPORT_C void SetTwipToPixelMapping(const TSize& aSizeInPixels,const TSize& aSizeInTwips);
  4118 	IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwipWidth) const;
  4119 	IMPORT_C TInt VerticalTwipsToPixels(TInt aTwipHeight) const;
  4120 	IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixelWidth) const;
  4121 	IMPORT_C TInt VerticalPixelsToTwips(TInt aPixelHeight) const;
  4122 	IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
  4123 	IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
  4124 	IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
  4125 	IMPORT_C void ReleaseFont(CFont* aFont);
  4126 public:
  4127 
  4128 	/**  One to one zoom factor.  */
  4129 	enum {EZoomOneToOne=1000};
  4130 private:
  4131 	TInt iZoomFactor;
  4132 	const MGraphicsDeviceMap* iDevice;
  4133 	};
  4134 
  4135 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS	
  4136 #include <graphics/gdi/gdistructs.h>
  4137 #include <graphics/gdi/gdiinline.inl>
  4138 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS	
  4139 
  4140 #include <gdi.inl>
  4141 
  4142 #endif // __GDI_H__