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