sl@0: // Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __GDI_H__ sl@0: #define __GDI_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #include sl@0: #endif //SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: sl@0: class TOpenFontCharMetrics; sl@0: class RShapeInfo; sl@0: class CGraphicsContext; sl@0: class TTextParameters; sl@0: sl@0: /** sl@0: Number of twips per inch. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KTwipsPerInch=1440; sl@0: sl@0: /** sl@0: Number of twips per point. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KTwipsPerPoint=20; sl@0: sl@0: /** sl@0: Number of points per inch. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KPointsPerInch=72; sl@0: sl@0: /** sl@0: Number of twips per cm. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KTwipsPerCm=567; sl@0: #if defined(__NO_CLASS_CONSTS__) sl@0: /** sl@0: A4 paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KA4PaperSizeInTwips TSize(11906,16838) sl@0: sl@0: /** Legal paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KLegalPaperSizeInTwips TSize(12240,20160) sl@0: sl@0: /** sl@0: Executive paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KExecutivePaperSizeInTwips TSize(10440,15120) sl@0: /** sl@0: Letter paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KLetterPaperSizeInTwips TSize(12240,15840) sl@0: sl@0: /** sl@0: Com-10 paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KCom_10PaperSizeInTwips TSize(5940,13680) sl@0: sl@0: /** sl@0: Monarch paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KMonarchPaperSizeInTwips TSize(5580,10800) sl@0: sl@0: /** sl@0: DL paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KDLPaperSizeInTwips TSize(6236,12472) sl@0: sl@0: /** sl@0: C5 paper size in twips. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KC5PaperSizeInTwips TSize(9184,12983) sl@0: #else sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TSize KA4PaperSizeInTwips(11906,16838); sl@0: const TSize KLegalPaperSizeInTwips(12240,20160); sl@0: const TSize KExecutivePaperSizeInTwips(10440,15120); sl@0: const TSize KLetterPaperSizeInTwips(12240,15840); sl@0: const TSize KCom_10PaperSizeInTwips(5940,13680); sl@0: const TSize KMonarchPaperSizeInTwips(5580,10800); sl@0: const TSize KDLPaperSizeInTwips(6236,12472); sl@0: const TSize KC5PaperSizeInTwips(9184,12983); sl@0: #endif sl@0: sl@0: sl@0: /** sl@0: This enumeration holds the possible panic codes that may be raised sl@0: by the GDI API on detecting an unrecoverable error. */ sl@0: enum TGdiPanic sl@0: { sl@0: /** Not used */ sl@0: EGdiPanic_Unknown = 0, sl@0: /** One or more of the input parameters to the interface were invalid */ sl@0: EGdiPanic_InvalidInputParam = 1, sl@0: /** Insufficient text for successful completion of the method */ sl@0: EGdiPanic_OutOfText = 2, sl@0: /** Internal failure. */ sl@0: EGdiPanic_Invariant = 3, sl@0: /** Unused panic codes. Can be reused if needed. */ sl@0: EGdiPanic_Unused1 = 4, sl@0: EGdiPanic_Unused2 = 5, sl@0: /** Setting a typeface name that is too long */ sl@0: EGdiPanic_TypefaceNameOverflow = 6, sl@0: }; sl@0: sl@0: sl@0: /** 24-bit RGB colour value with 8 bits each for red, green and blue. sl@0: sl@0: All Graphics drawing functions are specified in terms of a 32-bit TRgb colour sl@0: containing the three colour values plus 8 bits for alpha channel. For hardware which sl@0: does not support 24-bit colour, a mapping from TRgb to display colours is sl@0: performed. sl@0: sl@0: Generally, the convention for the alpha blending fact is 0 = transparent, sl@0: 255 = opaque, unless otherwise stated. The exception to this are the TRgb constructor sl@0: taking a single value, where the top byte of the passed in parameter is used for sl@0: alpha information and the function Value(), which returns alpha information in the top byte. sl@0: In both these cases, 0 means opaque, 255 means transparent. sl@0: sl@0: The supported display modes are enumerated in the TDisplayMode type. In each sl@0: display mode a unique index can represent each physical colours supported, sl@0: and which can be mapped onto a full RGB value. The mappings are as follows: sl@0: sl@0: 16-colour displays use the EGA colour set: black, white, and then both light sl@0: and dark versions of grey, red, green, blue, cyan, magenta and yellow sl@0: sl@0: 256-colour displays support 216 colours made up of 6x6x6 RGB values, each sl@0: containing all possible multiples of 51 for R,G,B values. Additionally, all sl@0: remaining 10 shades of pure red, green, blue and grey are represented, by sl@0: adding all remaining multiples of 17. This use of 256 colours is sometimes sl@0: known as the Netscape colour cube. sl@0: sl@0: 4096-colour displays effectively support RGB values with 4 bits per primary sl@0: colour sl@0: sl@0: 64k-colour displays effectively support RGB values with 5 bits allocated to sl@0: red, 6 to green and 5 to blue sl@0: sl@0: 16 million-colour displays support true colour with 8 bits allocated to each sl@0: primary colour sl@0: sl@0: @publishedAll sl@0: @released sl@0: @see TDisplayMode sl@0: @see DynamicPalette */ sl@0: class TRgb sl@0: { sl@0: public: sl@0: inline TRgb(); sl@0: inline TRgb(TUint32 aValue); sl@0: inline TRgb(TUint32 aInternalValue, TInt aAlpha); sl@0: inline TRgb(TInt aRed,TInt aGreen,TInt aBlue); sl@0: inline TRgb(TInt aRed, TInt aGreen, TInt aBlue, TInt aAlpha); sl@0: inline TInt Red() const; sl@0: inline TInt Green() const; sl@0: inline TInt Blue() const; sl@0: inline TInt Alpha() const; sl@0: IMPORT_C void SetRed(TInt aRed); sl@0: IMPORT_C void SetGreen(TInt aGreen); sl@0: IMPORT_C void SetBlue(TInt aBlue); sl@0: IMPORT_C void SetAlpha(TInt aAlpha); sl@0: IMPORT_C static TRgb Gray2(TInt aGray2); sl@0: IMPORT_C static TRgb Gray4(TInt aGray4); sl@0: IMPORT_C static TRgb Gray16(TInt aGray16); sl@0: IMPORT_C static TRgb Gray256(TInt aGray256); sl@0: IMPORT_C static TRgb Color16(TInt aColor16); sl@0: IMPORT_C static TRgb Color256(TInt aColor256); sl@0: IMPORT_C static TRgb Color4K(TInt aColor4K); sl@0: IMPORT_C static TRgb Color64K(TInt aColor64K); sl@0: IMPORT_C static TRgb Color16M(TInt aColor16M); sl@0: IMPORT_C TInt Gray2() const; sl@0: IMPORT_C TInt Gray4() const; sl@0: IMPORT_C TInt Gray16() const; sl@0: IMPORT_C TInt Gray256() const; sl@0: IMPORT_C TInt Color16() const; sl@0: IMPORT_C TInt Color256() const; sl@0: IMPORT_C TInt Color4K() const; sl@0: IMPORT_C TInt Color64K() const; sl@0: IMPORT_C TInt Color16M() const; sl@0: inline TBool operator==(const TRgb& aColor) const; sl@0: inline TBool operator!=(const TRgb& aColor) const; sl@0: inline TRgb operator~() const; sl@0: inline TRgb operator&(const TRgb& aColor); sl@0: inline TRgb operator|(const TRgb& aColor); sl@0: inline TRgb operator^(const TRgb& aColor); sl@0: inline TRgb& operator&=(const TRgb& aColor); sl@0: inline TRgb& operator|=(const TRgb& aColor); sl@0: inline TRgb& operator^=(const TRgb& aColor); sl@0: inline TUint32 Value() const; sl@0: inline TUint32 Internal() const; sl@0: inline void SetInternal(TUint32 aInternal); sl@0: IMPORT_C TInt Difference(const TRgb& aColor) const; sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C static TRgb Color16MU(TInt a0RGB); sl@0: IMPORT_C TInt Color16MU() const; sl@0: IMPORT_C static TRgb Color16MA(TUint aARGB); sl@0: IMPORT_C TUint Color16MA() const; sl@0: IMPORT_C static TRgb Color16MAP(TUint aARGB); sl@0: IMPORT_C TUint Color16MAP() const; sl@0: IMPORT_C TUint _Color16MAP() const; sl@0: IMPORT_C static TRgb _Color16MAP(TUint aARGB); sl@0: inline TInt _Gray2() const; sl@0: inline TInt _Gray4() const; sl@0: inline TInt _Gray16() const; sl@0: inline TInt _Gray256() const; sl@0: inline TInt _Color4K() const; sl@0: inline TInt _Color64K() const; sl@0: inline TInt _Color16M() const; sl@0: inline TInt _Color16MU() const; sl@0: inline TUint _Color16MA() const; sl@0: inline static TRgb _Gray2(TInt aGray2); sl@0: inline static TRgb _Gray4(TInt aGray4); sl@0: inline static TRgb _Gray16(TInt aGray16); sl@0: inline static TRgb _Gray256(TInt aGray256); sl@0: inline static TRgb _Color4K(TInt aColor4K); sl@0: inline static TRgb _Color64K(TInt aColor64K); sl@0: inline static TRgb _Color16M(TInt aColor16M); sl@0: inline static TRgb _Color16MU(TInt a0RGB); sl@0: inline static TRgb _Color16MA(TUint aARGB); sl@0: private: sl@0: TUint32 iValue; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define KRgbBlack TRgb(0x000000) sl@0: #define KRgbDarkGray TRgb(0x555555) sl@0: #define KRgbDarkRed TRgb(0x000080) sl@0: #define KRgbDarkGreen TRgb(0x008000) sl@0: #define KRgbDarkYellow TRgb(0x008080) sl@0: #define KRgbDarkBlue TRgb(0x800000) sl@0: #define KRgbDarkMagenta TRgb(0x800080) sl@0: #define KRgbDarkCyan TRgb(0x808000) sl@0: #define KRgbRed TRgb(0x0000ff) sl@0: #define KRgbGreen TRgb(0x00ff00) sl@0: #define KRgbYellow TRgb(0x00ffff) sl@0: #define KRgbBlue TRgb(0xff0000) sl@0: #define KRgbMagenta TRgb(0xff00ff) sl@0: #define KRgbCyan TRgb(0xffff00) sl@0: #define KRgbGray TRgb(0xaaaaaa) sl@0: #define KRgbWhite TRgb(0xffffff) sl@0: #define KRgbTransparent TRgb(0x000000,0x00) sl@0: sl@0: /** A set of static utility functions to get information about a display mode. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TDisplayModeUtils sl@0: { sl@0: public: sl@0: IMPORT_C static TBool IsDisplayModeColor(TDisplayMode aDispMode); sl@0: IMPORT_C static TBool IsDisplayModeValid(TDisplayMode aDispMode); sl@0: IMPORT_C static TInt NumDisplayModeColors(TDisplayMode aDispMode); sl@0: IMPORT_C static TInt NumDisplayModeBitsPerPixel(TDisplayMode aDispMode); sl@0: }; sl@0: sl@0: /** Provides user-definable palette support to the GDI. sl@0: sl@0: A palette is a user-defined set of colours, which is a subset of the full sl@0: range of 24-bit colours. This allows users the advantages of having a low sl@0: bpp colour mode whilst being able to specify the colours available in that sl@0: mode. To give an example, the EColor16 mode provides a palette of 16 colours sl@0: as it provides a mapping between an integer index and a TRgb colour (see the sl@0: table EGA Low-colour constants). Only a palette of 16 colour enables you to sl@0: change the palette. Palettes are also used to allow 24-bit bitmaps to be stored sl@0: in a more compressed form by finding the actual number of different colours sl@0: used in the bitmap, creating a palette to allow the mapping of these colours sl@0: to a smaller index space, and encoding the bitmaps pixels using indexes sl@0: to this new index space. sl@0: sl@0: A palette has a size which is set at its creation and cannot be altered sl@0: the number of entries in the palette. Each entry in a palette is a mapping sl@0: between that entrys index and a TRgb value. Palette entries can be got sl@0: and set at any time between the palettes creation and destruction. The sl@0: GDIs palette support also provides functions to find the nearest palette sl@0: colour to a requested TRgb colour. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPalette : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CPalette* NewL(TInt aNumberOfEntries); sl@0: IMPORT_C static CPalette* NewDefaultL(TDisplayMode aDispMode); sl@0: IMPORT_C ~CPalette(); sl@0: IMPORT_C void Clear(); sl@0: inline TInt Entries() const; sl@0: IMPORT_C TRgb GetEntry(TInt aPaletteIndex) const; sl@0: IMPORT_C TRgb NearestEntry(const TRgb& aColor) const; sl@0: IMPORT_C TInt NearestIndex(const TRgb& aColor) const; sl@0: IMPORT_C void SetEntry(TInt aPaletteIndex,const TRgb& aPaletteEntry); sl@0: IMPORT_C void GetDataPtr(TInt aFirstColor,TInt aNumColors,TPtr8& aPtr); sl@0: protected: sl@0: IMPORT_C CPalette(); sl@0: void ConstructL(TInt aNumberOfEntries); sl@0: protected: sl@0: TRgb* iArray; sl@0: TInt iNumEntries; sl@0: }; sl@0: sl@0: sl@0: /** Enables conversion, in both directions, between a TRgb object and an index sl@0: into an arbitrary 256 colour palette. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TColor256Util sl@0: { sl@0: public: sl@0: IMPORT_C void Construct(const CPalette& aPalette); sl@0: IMPORT_C TInt Color256(TRgb aRgb) const; sl@0: IMPORT_C void Color256(TUint8* aDestination,const TRgb* aSource,TInt aNumPixels) const; sl@0: inline TRgb Color256(TInt aColor256) const; sl@0: IMPORT_C static const TColor256Util* Default(); sl@0: public: sl@0: /** 256 colour lookup table. sl@0: sl@0: Each entry is a 32 bit value which corresponds to a TRgb value in the sl@0: palette passed to Construct(). If there are more than 256 colours in the sl@0: palette, the first 256 colours are used in this table. If there are fewer sl@0: than 256 entries, the remaining entries in the table are set to zero. */ sl@0: TUint32 iColorTable[256]; sl@0: sl@0: /** Inverse colour lookup table. sl@0: sl@0: It has 4096 entries. Each entry is the index of a colour in the palette sl@0: that the object was created with (see Construct()) that most closely sl@0: matches the 4096 degrees of intensity of red, green and blue on a uniform sl@0: 16x16x16 colour cube. sl@0: sl@0: It is called "inverse" because iColorTable maps indices (0..255) to TRgb sl@0: values, but this table maps TRgb values to palette indices. */ sl@0: TUint8 iInverseColorTable[0x1000]; sl@0: }; sl@0: sl@0: sl@0: /** Linear digital differential analyser. sl@0: sl@0: This is used to calculate the pixels which most closely approximate a specified sl@0: straight line, or when scaling a bitmap. Note that a line is infinitely thin, sl@0: and can only be approximated by pixels with real width and height. sl@0: sl@0: Functions are provided for: pixel line traversing; jumping to a rectangle or sl@0: co-ordinate sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TLinearDDA sl@0: { sl@0: public: sl@0: /** LDDA Line mode. */ sl@0: enum TLineMode sl@0: { sl@0: /** Centres scan-lines in the pixel line */ sl@0: ECenter, sl@0: /** Starts at the beginning of a complete scan line. Used for bitmap sl@0: scaling. */ sl@0: ELeft sl@0: }; sl@0: public: sl@0: IMPORT_C TLinearDDA(); sl@0: IMPORT_C TLinearDDA(const TLinearDDA& aLine); sl@0: IMPORT_C void Construct(const TPoint& aStart,const TPoint& aFinish,TLineMode aMode=ECenter); sl@0: IMPORT_C TBool SingleStep(TPoint& aPosition); sl@0: IMPORT_C TBool SingleScanline(TPoint& aStartPosition,TPoint& aEndPosition); sl@0: IMPORT_C TBool NextStep(TPoint& aPosition); sl@0: IMPORT_C void JumpToRect(const TRect& aRect); sl@0: IMPORT_C void JumpToXCoord(const TInt aXCoord,TInt& aYCoord); sl@0: IMPORT_C void JumpToYCoord(TInt& aXCoord,const TInt aYCoord); sl@0: IMPORT_C void JumpToXCoord2(TInt aXCoord,TInt& aYCoord); sl@0: IMPORT_C void JumpToYCoord2(TInt& aXCoord,TInt aYCoord); sl@0: private: sl@0: void UpdatePosition(); sl@0: private: sl@0: enum TLineStatus sl@0: { sl@0: EInitialised, sl@0: ECurrent, sl@0: EComplete sl@0: }; sl@0: private: sl@0: TInt iCount; sl@0: TSize iDifference; sl@0: TPoint iFinish; sl@0: TInt iGradient; sl@0: TPoint iInc; sl@0: TPoint iPos; sl@0: TPoint iStart; sl@0: TRect iBoundingRect; sl@0: TBool iBoundingRectSet; sl@0: TInt16 iInsideX; // boolean, defined as TInt16 to maintain binary compatibility sl@0: TInt16 iInsideY; // boolean, defined as TInt16 to maintain binary compatibility sl@0: TLineStatus iStatus; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Font posture flags. sl@0: Fonts can be either upright or italic. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TFontPosture sl@0: { sl@0: /** Font posture is normal (upright). */ sl@0: EPostureUpright, sl@0: /** Font posture is italic. */ sl@0: EPostureItalic sl@0: }; sl@0: sl@0: /** sl@0: Font stroke weight flags. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TFontStrokeWeight sl@0: { sl@0: /** Font stroke weight is normal. */ sl@0: EStrokeWeightNormal, sl@0: /** Font stroke weight is bold. */ sl@0: EStrokeWeightBold sl@0: }; sl@0: sl@0: /** sl@0: Font print position flags. sl@0: Fonts can be normal, superscript or subscript. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TFontPrintPosition sl@0: { sl@0: /** Font is normal. */ sl@0: EPrintPosNormal, sl@0: /** Font is superscript. */ sl@0: EPrintPosSuperscript, sl@0: /** Font is subscript. */ sl@0: EPrintPosSubscript sl@0: }; sl@0: sl@0: /** sl@0: Font underline flags. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TFontUnderline sl@0: { sl@0: /** Font is not underlined. */ sl@0: EUnderlineOff, sl@0: /** Font is underlined. */ sl@0: EUnderlineOn sl@0: }; sl@0: sl@0: /** sl@0: Font strike-through flags. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TFontStrikethrough sl@0: { sl@0: /** Font is not struck-through. */ sl@0: EStrikethroughOff, sl@0: /** Font is struck-through. */ sl@0: EStrikethroughOn sl@0: }; sl@0: sl@0: /** sl@0: The maximum length of a typeface name (in characters). sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KMaxTypefaceNameLength=0x18; sl@0: sl@0: sl@0: /** Typeface name and attributes. sl@0: sl@0: This class identifies a typeface by name, and contains the combination of sl@0: attributes of the typeface. These attributes define whether it is a symbol sl@0: typeface, whether the typeface is proportional, and whether it is serif or sl@0: sans-serif. sl@0: sl@0: The combination of attributes for a typeface are stored in a bitmask, with sl@0: the various bits indicating different attributes. The bitmask is calculated sl@0: for any particular attribute combination by ORing the enumerated value for sl@0: each individual attribute. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TTypeface sl@0: { sl@0: public: sl@0: enum sl@0: { sl@0: /** Typeface is a proportional typeface (e.g. Swiss) sl@0: */ sl@0: EProportional = 1, sl@0: /** Typeface is a serif typeface (e.g. Times) sl@0: */ sl@0: ESerif = 2, sl@0: /** Typeface is a symbol typeface (e.g. Symbol) sl@0: */ sl@0: ESymbol = 4, sl@0: }; sl@0: public: sl@0: IMPORT_C TTypeface(); sl@0: IMPORT_C TBool operator==(const TTypeface& aTypeface) const; sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C void SetAttributes(TInt aAttributes); sl@0: IMPORT_C void SetIsProportional(TBool aIsProportional); sl@0: IMPORT_C void SetIsSerif(TBool aIsSerif); sl@0: IMPORT_C void SetIsSymbol(TBool aIsSymbol); sl@0: IMPORT_C TInt Attributes() const; sl@0: IMPORT_C TBool IsProportional() const; sl@0: IMPORT_C TBool IsSerif() const; sl@0: IMPORT_C TBool IsSymbol() const; sl@0: IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage); sl@0: IMPORT_C void SetScriptTypeForMetrics(TInt aScript); sl@0: IMPORT_C TInt ScriptTypeForMetrics() const; sl@0: IMPORT_C void SetName(const TDesC& aName); sl@0: IMPORT_C const TDesC& Name() const; sl@0: private: sl@0: void ResetAttributes(); sl@0: void ResetScriptType(); sl@0: public: sl@0: /** The typeface name. */ sl@0: TBufC iName; sl@0: private: sl@0: TUint32 iFlags; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: An enumerated type for the format of a glyph bitmap. This type is currently sl@0: used to indicate whether glyph bitmaps for scalable fonts are drawn anti-aliased. sl@0: Additional values may be defined in the future. sl@0: sl@0: @see TFontStyle::SetBitmapType() sl@0: @see CFbsTypefaceStore::SetDefaultBitmapType() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TGlyphBitmapType sl@0: { sl@0: /** The font store's default glyph bitmap format is used. */ sl@0: EDefaultGlyphBitmap = 0, sl@0: /** The standard monochrome format: no anti-aliasing, 1 bit per pixel, sl@0: run-length encoded. */ sl@0: EMonochromeGlyphBitmap, sl@0: /** Standard 8-bits-per-pixel with anti-aliasing. */ sl@0: EAntiAliasedGlyphBitmap, sl@0: /** The format used when sub-pixel font rendering is used. */ sl@0: ESubPixelGlyphBitmap, sl@0: /** The format used when outline and shadow font rendering is used. sl@0: sl@0: If the raterizer supports the outline and shadow fonts, it will set the bitmaptype as sl@0: EFourColourBlendGlyphBitmap but only when glyph bitmap type is set as EAntiAliasedGlyphBitmap and sl@0: when any of the EDropShadow or EOutline effect is on. Only rasterizer providers can use this enum. sl@0: */ sl@0: EFourColourBlendGlyphBitmap, sl@0: /** sl@0: This is used for glyphs, and not fonts, and is needed to inform the font drawing routines sl@0: that the character should be drawn using the overall font setting. sl@0: For Internal Use Only. sl@0: */ sl@0: EGlyphBitmapTypeNotDefined, sl@0: /** sl@0: This is used to inform the rasterizer that the best match should be sl@0: found for the bitmap type based upon its knowledge. sl@0: For Internal Use Only. sl@0: */ sl@0: EAntiAliasedOrMonochromeGlyphBitmap, sl@0: }; sl@0: sl@0: /** sl@0: Defines a set of font effects flags. sl@0: sl@0: @publishedAll sl@0: @released sl@0: WARNING: This Class is for use by system/UI software ONLY. sl@0: */ sl@0: NONSHARABLE_CLASS(FontEffect) sl@0: { sl@0: public: sl@0: enum TEffect sl@0: { sl@0: ENone = 0x0, // No effects. sl@0: EAlgorithmicBold= 0x10, // Font is algorithmic bold (a.k.a pseudo bold.) sl@0: EDropShadow = 0x20, // Font has a drop shadow. sl@0: EOutline = 0x40, // Font is an outline font. sl@0: EEmbossed = 0x80, // Font is embossed. sl@0: EEngraved = 0x100, // Font is engraved. sl@0: ESoftEdge = 0x200, // Font is soft edged. sl@0: EReserved1 = 0x400, // Reserved for Symbian use. sl@0: EReserved2 = 0x800, // Reserved for Symbian use. sl@0: EReserved3 = 0x1000, // Reserved for Symbian use. sl@0: EReserved4 = 0x2000, // Reserved for Symbian use. sl@0: EReserved5 = 0x4000, // Reserved for Symbian use. sl@0: EReserved6 = 0x8000, // Reserved for Symbian use. sl@0: }; sl@0: public: sl@0: IMPORT_C static TBool IsEffectOn(TEffect aEffect, TUint32 aFontEffect); sl@0: IMPORT_C static void SetEffect(TEffect aEffect, TBool aOn, TUint32& aFontEffect); sl@0: }; sl@0: sl@0: /** Encapsulates a font style. sl@0: sl@0: The font style information is comprised of: sl@0: sl@0: the posture of the font upright or italic sl@0: sl@0: the stroke weight of the font normal or bold sl@0: sl@0: the print position of the font normal, subscript or superscript sl@0: sl@0: Note that the underline and strike-through attributes are not included in sl@0: this class, but are set in the graphics context. sl@0: sl@0: @see CGraphicsContext::SetUnderlineStyle() sl@0: @see CGraphicsContext::SetStrikethroughStyle() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TFontStyle sl@0: { sl@0: public: sl@0: IMPORT_C TFontStyle(); sl@0: IMPORT_C TFontStyle(TFontPosture aPost,TFontStrokeWeight aStrWgt,TFontPrintPosition aPrintPos); sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C TFontPosture Posture() const; sl@0: IMPORT_C TFontStrokeWeight StrokeWeight() const; sl@0: IMPORT_C TFontPrintPosition PrintPosition() const; sl@0: IMPORT_C void SetPosture(TFontPosture aPosture); sl@0: IMPORT_C void SetStrokeWeight(TFontStrokeWeight aStrokeWeight); sl@0: IMPORT_C void SetPrintPosition(TFontPrintPosition aPrintPosition); sl@0: inline TGlyphBitmapType BitmapType() const; sl@0: inline void SetBitmapType(TGlyphBitmapType aBitmapType); sl@0: IMPORT_C TBool operator==(const TFontStyle& aFontStyle) const; sl@0: IMPORT_C TUint32 Effects() const; sl@0: IMPORT_C TBool IsEffectOn(FontEffect::TEffect aEffect) const; sl@0: IMPORT_C void SetEffects(TUint32 aEffects); sl@0: IMPORT_C void SetEffects(FontEffect::TEffect aEffect, TBool aOn); sl@0: private: sl@0: enum sl@0: { sl@0: EItalic=0x1, sl@0: EBold=0x2, sl@0: ESuper=0x4, sl@0: ESub=0x8 sl@0: }; sl@0: private: sl@0: TUint32 iFlags; // bitmap type - 16 bits (high), font effects - 12 bits (middle), style - 4 bits (low) sl@0: TAny* iReserved1; sl@0: TAny* iReserved2; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: Specifies the font specification in device independent terms. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TFontSpec sl@0: { sl@0: public: sl@0: IMPORT_C TFontSpec(); sl@0: IMPORT_C TFontSpec(const TDesC& aTypefaceName,TInt aHeight); sl@0: IMPORT_C TBool operator==(const TFontSpec& aFontSpec) const; sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C void SetScriptTypeForMetrics(TLanguage aLanguage); sl@0: IMPORT_C TInt ScriptTypeForMetrics() const; sl@0: public: sl@0: /** The typeface. */ sl@0: TTypeface iTypeface; sl@0: /** The height of the typeface (in twips). */ sl@0: TInt iHeight; sl@0: /** The font style of the typeface. */ sl@0: TFontStyle iFontStyle; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** Typeface family support information. sl@0: sl@0: This data-only class includes the name and attributes of a typeface, how many sl@0: font heights are available, its minimum and maximum heights, and whether or sl@0: not it is scaleable a typeface is scaleable if it supports heights at sl@0: fixed intervals between the minimum and maximum heights. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TTypefaceSupport sl@0: { sl@0: public: sl@0: /** The name and attributes of the typeface. */ sl@0: TTypeface iTypeface; sl@0: /** The number of distinct font heights available in the typeface. */ sl@0: TInt iNumHeights; sl@0: /** The typeface's minimum font height, in twips. */ sl@0: TInt iMinHeightInTwips; sl@0: /** The typeface's maximum font height, in twips. */ sl@0: TInt iMaxHeightInTwips; sl@0: /** Whether the typeface is scaleable. ETrue if it is scaleable, otherwise sl@0: EFalse. */ sl@0: TBool iIsScalable; // supports heights from min to max at fixed interval sl@0: }; sl@0: sl@0: /** sl@0: The percentage used to multiply a normal font height when calculating its sl@0: superscript or subscript height. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KSuperSubScalingPercentage=67; sl@0: sl@0: /** sl@0: The percentage of a font height used to calculate its baseline offset for a sl@0: superscript print position. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KSuperscriptOffsetPercentage=-28; sl@0: sl@0: /** sl@0: The percentage of a font height used to calculate its baseline offset for a sl@0: subscript print position. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KSubscriptOffsetPercentage=14; sl@0: sl@0: class CFont; sl@0: sl@0: /** Typeface store abstract base interface. sl@0: sl@0: This class provides the interface to a store for typefaces. sl@0: sl@0: See also CFontStore. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CTypefaceStore : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C ~CTypefaceStore(); sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips() sl@0: yielding (virtually) the same result. However clients are strongly encouraged to use the new sl@0: @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every sl@0: character within any given text string will fit within the given amount of twips, whereas the design sl@0: height is an aesthetic unit decided by the font designer without strict physical meaning, which sl@0: may result in cropped characters. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @deprecated Use GetNearestFontToDesignHeightInTwips sl@0: */ sl@0: virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the sl@0: same result. However clients are strongly encouraged to use the new sl@0: @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every sl@0: character within any given text string will fit within the given amount of twips, whereas the design sl@0: height is an aesthetic unit decided by the font designer without strict physical meaning, which sl@0: may result in cropped characters. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec) = 0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: The font and bitmap server returns a pointer to the nearest matching font sl@0: from those available. Matches to max height of font - this does its best sl@0: to return a font that will fit within the maximum height specified (but sl@0: note that variations due to hinting algorithms may rarely result in this sl@0: height being exceeded by up to one pixel). Problems can also be sl@0: encountered with bitmap fonts where the typeface exists but doesn't have sl@0: a font small enough. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @param aMaxHeight The maximum height within which the font must fit. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight) = 0; sl@0: sl@0: /** Gets the number of typefaces supported by the typeface store. sl@0: sl@0: @return The number of supported typefaces. */ sl@0: virtual TInt NumTypefaces() const=0; sl@0: sl@0: /** Gets typeface information for a specified typeface index. sl@0: sl@0: This information is returned in aTypefaceSupport, and sl@0: includes the typeface name and typeface attributes, the number of font sl@0: heights, the maximum and minimum font heights, and whether it is a sl@0: scaleable typeface. sl@0: sl@0: @param aTypefaceSupport On return, if the function executed successfully, sl@0: this object contains the typeface information. sl@0: @param aTypefaceIndex A typeface index number, in the range: zero to sl@0: (NumTypefaces() - 1). */ sl@0: virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0; sl@0: sl@0: /** Gets the height of the font with specified height and typeface indices, sl@0: in twips. sl@0: sl@0: The value returned is rounded up or down to the nearest font height in twips. sl@0: sl@0: @param aTypefaceIndex A typeface index number, in the range: 0 to sl@0: (NumTypefaces() - 1). sl@0: @param aHeightIndex A font height index number. sl@0: @return The height of the font, in twips. */ sl@0: virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0; sl@0: IMPORT_C void ReleaseFont(CFont* aFont); sl@0: IMPORT_C static TInt BaselineOffset(TInt aHeight,TFontPrintPosition aPos); sl@0: IMPORT_C static TInt SuperSubHeight(TInt aHeight,TFontPrintPosition aPos); sl@0: protected: sl@0: IMPORT_C CTypefaceStore(); sl@0: IMPORT_C void ConstructL(); sl@0: IMPORT_C void AddFontL(CFont* aFont); sl@0: IMPORT_C TBool IncrementFontCount(const CFont* aFont); sl@0: private: sl@0: TBool FindFont(const CFont* aFont, TInt& aIdx) const; sl@0: NONSHARABLE_CLASS(TFontAccess) sl@0: /** sl@0: Pairs a font with a count of how many clients of the typeface store sl@0: are accessing that font. sl@0: */ sl@0: { sl@0: public: sl@0: /** A device specific font. */ sl@0: CFont* iFont; sl@0: /** The number of clients accessing the font. */ sl@0: TInt iAccessCount; sl@0: }; sl@0: protected: sl@0: /** A list of fonts accessed by clients of the typeface store, which pairs sl@0: a font with a count of the number of clients accessing the font. sl@0: sl@0: Implemented as an array of TFontAccess objects. sl@0: sl@0: An object is added to this array for every font accessed. If the font is sl@0: released by all clients, and the access count drops to zero, the font is sl@0: removed from the list. */ sl@0: CArrayFixFlat* iFontAccess; sl@0: }; sl@0: sl@0: /** The maximum number of entries in the font cache. sl@0: sl@0: @see CFontCache */ sl@0: const TInt KMaxFontCacheEntries=32; sl@0: sl@0: /** Font cache. sl@0: sl@0: When a CFont* needs to be found for a particular TFontSpec, the cache can sl@0: be searched to see if the TFontSpec is already in the cache. If the TFontSpec sl@0: is in the cache, its corresponding CFont* can be returned. Otherwise sl@0: GetNearestFontInTwips() must be used to search all of the available fonts for sl@0: the nearest CFont- a procedure which takes much longer than a simple cache sl@0: search. sl@0: sl@0: The current font cache should be destroyed and a new cache created whenever sl@0: the zoom factor or device map changes, as these changes break the relation sl@0: between CFont and TFontSpec. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFontCache : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C CFontCache(); sl@0: IMPORT_C CFontCache(TInt aMaxEntries); sl@0: IMPORT_C ~CFontCache(); sl@0: IMPORT_C CFont* Search(const TFontSpec& aFontSpec); sl@0: IMPORT_C CFont* AddEntryL(CFont* aFont,const TFontSpec& aFontSpec); sl@0: IMPORT_C CFont* RemoveFirstEntry(); sl@0: public: sl@0: /** The number of cache hits since the font cache was created i.e. sl@0: successful results from CFontCache::Search(). */ sl@0: TInt iNumHits; sl@0: /** The number of cache misses since the font cache was created i.e. sl@0: unsuccessful results from CFontCache::Search(). */ sl@0: TInt iNumMisses; sl@0: private: sl@0: class CFontCacheEntry : public CBase sl@0: { sl@0: public: sl@0: CFontCacheEntry(CFont* aFont,const TFontSpec& aFontSpec,CFontCacheEntry* aNext); sl@0: public: sl@0: CFont* iFont; sl@0: TFontSpec iSpec; sl@0: CFontCacheEntry* iNext; sl@0: }; sl@0: private: sl@0: TInt iNumEntries; sl@0: TInt iMaxEntries; sl@0: CFontCacheEntry* iFirst; sl@0: }; sl@0: sl@0: /** Interface class for mapping between twips and device-specific units (pixels). sl@0: sl@0: TZoomFactor is derived from MGraphicsDeviceMap. sl@0: sl@0: @see CGraphicsDevice sl@0: @see TZoomFactor sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MGraphicsDeviceMap sl@0: { sl@0: public: sl@0: IMPORT_C MGraphicsDeviceMap(); sl@0: IMPORT_C virtual ~MGraphicsDeviceMap(); sl@0: IMPORT_C TPoint TwipsToPixels(const TPoint& aTwipPoint) const; sl@0: IMPORT_C TRect TwipsToPixels(const TRect& aTwipRect) const; sl@0: IMPORT_C TPoint PixelsToTwips(const TPoint& aPixelPoint) const; sl@0: IMPORT_C TRect PixelsToTwips(const TRect& aPixelRect) const; sl@0: sl@0: /** Converts a horizontal dimension from twips to pixels. sl@0: sl@0: An implementation is supplied by a derived class. sl@0: sl@0: @param aTwips A horizontal dimension of a device in twips. sl@0: @return A horizontal dimension of a device in pixels. */ sl@0: virtual TInt HorizontalTwipsToPixels(TInt aTwips) const=0; sl@0: sl@0: /** Converts a vertical dimension from twips to pixels. sl@0: sl@0: An implementation is supplied by a derived class. sl@0: sl@0: @param aTwips A vertical dimension of a device in twips. sl@0: @return A vertical dimension of a device in pixels. */ sl@0: virtual TInt VerticalTwipsToPixels(TInt aTwips) const=0; sl@0: sl@0: /** Converts a horizontal dimension from pixels to twips. sl@0: sl@0: An implementation is supplied by a derived class. sl@0: sl@0: @param aPixels A horizontal dimension of a device in pixels. sl@0: @return A horizontal dimension of a device in twips. */ sl@0: virtual TInt HorizontalPixelsToTwips(TInt aPixels) const=0; sl@0: sl@0: /** Converts a vertical dimension from pixels to twips. sl@0: sl@0: An implementation is supplied by a derived class. sl@0: sl@0: @param aPixels A vertical dimension of a device in pixels. sl@0: @return A vertical dimension of a device in twips. */ sl@0: virtual TInt VerticalPixelsToTwips(TInt aPixels) const=0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInTwips() sl@0: yielding (virtually) the same result. However clients are strongly encouraged to use the new sl@0: @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every sl@0: character within any given text string will fit within the given amount of twips, whereas the design sl@0: height is an aesthetic unit decided by the font designer without strict physical meaning, which sl@0: may result in cropped characters. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @deprecated Use GetNearestFontToDesignHeightInTwips sl@0: */ sl@0: virtual TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)=0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: This new function replaces the deprecated @c GetNearestFontInTwips() yielding (virtually) the sl@0: same result. However clients are strongly encouraged to use the new sl@0: @c GetNearestFontToMaxHeightInTwips() function instead. This will guarantee that every sl@0: character within any given text string will fit within the given amount of twips, whereas the design sl@0: height is an aesthetic unit decided by the font designer without strict physical meaning, which sl@0: may result in cropped characters. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: virtual TInt GetNearestFontToDesignHeightInTwips( sl@0: CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; } sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: The font and bitmap server returns a pointer to the nearest matching font sl@0: from those available. Matches to max height of font - this does its best sl@0: to return a font that will fit within the maximum height specified (but sl@0: note that variations due to hinting algorithms may rarely result in this sl@0: height being exceeded by up to one pixel). Problems can also be sl@0: encountered with bitmap fonts where the typeface exists but doesn't have sl@0: a font small enough. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @param aMaxHeight The maximum height within which the font must fit. sl@0: This overrides the height specified in aFontSpec. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: virtual TInt GetNearestFontToMaxHeightInTwips( sl@0: CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; } sl@0: sl@0: /** Releases the specified font. sl@0: sl@0: It is used to indicate that the specified font is no longer needed for use sl@0: by the device map. As fonts can be shared between applications, this sl@0: function does not delete the copy of the font from RAM unless the font was sl@0: only being used by this particular device map. sl@0: sl@0: An implementation is supplied by a derived class. sl@0: sl@0: @param aFont A pointer to the font to be released. */ sl@0: virtual void ReleaseFont(CFont* aFont)=0; sl@0: }; sl@0: sl@0: class CGraphicsContext; sl@0: sl@0: /** Specifies the interface for concrete device classes. sl@0: sl@0: It holds information on the capabilities and attributes of a graphics device. sl@0: The CBitmapDevice and CPrinterDevice classes are derived from CGraphicsDevice. sl@0: sl@0: @see CGraphicsDevice sl@0: @see CPrinterDevice sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CGraphicsDevice : public CBase , public MGraphicsDeviceMap sl@0: { sl@0: public: sl@0: /** Gets the display mode of the device. sl@0: sl@0: @return The display mode of the device. */ sl@0: virtual TDisplayMode DisplayMode() const=0; sl@0: sl@0: /** Gets the size of the device area in pixels. sl@0: sl@0: @return The width and height of the device area, in pixels */ sl@0: virtual TSize SizeInPixels() const=0; sl@0: sl@0: /** Gets the size of the device area in twips. sl@0: sl@0: @return The width and height of the device area, in twips */ sl@0: virtual TSize SizeInTwips() const=0; sl@0: sl@0: /** Creates a graphics context for the device. sl@0: sl@0: @param aGC On return, contains a pointer to the created graphics context. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide error sl@0: codes. */ sl@0: virtual TInt CreateContext(CGraphicsContext*& aGC)=0; sl@0: sl@0: /** Gets the number of typefaces supported by the graphics device. sl@0: sl@0: @return The number of typefaces supported. */ sl@0: virtual TInt NumTypefaces() const=0; sl@0: sl@0: /** Gets typeface information for a specified typeface. sl@0: sl@0: This information is returned in aTypefaceSupport, and includes: sl@0: sl@0: the typeface name and typeface attributes sl@0: sl@0: the number of font heights sl@0: sl@0: the maximum and minimum font heights sl@0: sl@0: whether it is a scalable typeface sl@0: sl@0: @param aTypefaceSupport On return, contains the typeface information. sl@0: @param aTypefaceIndex A typeface index number, in the range: zero to sl@0: (NumTypefaces() - 1). sl@0: @see NumTypefaces() */ sl@0: virtual void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const=0; sl@0: sl@0: /** Get the height of a font in twips. sl@0: sl@0: The font is identified by typeface and height. sl@0: sl@0: The value returned is rounded up or down to the nearest font height in twips. sl@0: sl@0: @param aTypefaceIndex An index identifying the typeface, in the range: 0 sl@0: to (NumTypefaces() - 1). sl@0: @param aHeightIndex An index identifying the font height, in the range: 0 sl@0: to (iNumHeights - 1). Note that iNumHeights is in the TTypefaceSupport sl@0: object returned by TypefaceSupport(). sl@0: @return The height of the font, in twips. */ sl@0: virtual TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const=0; sl@0: sl@0: /** Gets the palette attributes of the device. sl@0: sl@0: @param aModifiable On return, holds information on whether or not the device's sl@0: palette is modifiable (ETrue) or fixed (EFalse). sl@0: @param aNumEntries On return, holds the number of entries in the device's sl@0: palette. */ sl@0: virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const=0; sl@0: sl@0: /** Sets the device's palette. sl@0: sl@0: Setting the palette is only possible if the device has a modifiable palette, sl@0: which can be determined by calling PaletteAttributes(). sl@0: sl@0: @param aPalette The new palette for the device. */ sl@0: virtual void SetPalette(CPalette* aPalette)=0; sl@0: sl@0: /** Gets the device's current palette. sl@0: sl@0: This function is only supported if the device has a modifiable palette, sl@0: which can be determined by calling PaletteAttributes(). sl@0: sl@0: @param aPalette On return, holds the device's current palette. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide error sl@0: codes. */ sl@0: virtual TInt GetPalette(CPalette*& aPalette) const=0; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Code section range information. sl@0: sl@0: A code section defines the bitmaps for characters in a specified range - sl@0: the range is stored in objects of this type. sl@0: @publishedAll sl@0: @deprecated This is not used anywhere in version 6.0. sl@0: */ sl@0: class TCodeSection sl@0: { sl@0: public: sl@0: /** The beginning of the range. */ sl@0: TInt iStart; sl@0: /** The end of the range. */ sl@0: TInt iEnd; sl@0: }; sl@0: sl@0: /** sl@0: WARNING: this Class is for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: UIDs corresponding to the CFont API extension functions sl@0: @internalTechnology sl@0: */ sl@0: const TUid KFontCapitalAscent = {0x1020498E}; sl@0: const TUid KFontMaxAscent = {0x10204B10}; sl@0: const TUid KFontStandardDescent = {0x10204B11}; sl@0: const TUid KFontMaxDescent = {0x10205AFC}; sl@0: const TUid KFontLineGap = {0x10204B12}; sl@0: const TUid KFontGetFontTable = {0x102872C1}; sl@0: const TUid KFontGetGlyphOutline = {0x102872C2}; sl@0: const TUid KFontReleaseGlyphOutline = {0x2002A1FD}; sl@0: const TUid KFontReleaseFontTable = {0x2002AC24}; sl@0: sl@0: sl@0: /** Abstract font interface. sl@0: sl@0: The CFont class provides a device-independent interface to a device-dependent sl@0: font usually obtained from a call to GetNearestFont...() on a graphics device. sl@0: It is used as a handle in CGraphicsContext::UseFont() and to obtain sl@0: device-dependent information about the font - notably the pixel width of a text sl@0: string. sl@0: sl@0: @see CFbsFont sl@0: @see CGraphicsContext::UseFont() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFont : public CBase sl@0: { sl@0: friend class CTypefaceStore; sl@0: public: sl@0: sl@0: /** Text direction flags. sl@0: sl@0: This enum is used in TMeasureTextInput and determines whether the text is sl@0: drawn horizontally or vertically. Note: text is drawn vertically in some sl@0: styles of Japanese, etc. sl@0: sl@0: @see TMeasureTextInput */ sl@0: enum TTextDirection sl@0: { sl@0: /** Text is drawn horizontally. */ sl@0: /** Text is drawn horizontally. */ sl@0: EHorizontal, sl@0: /** Text is drawn vertically. */ sl@0: EVertical sl@0: }; sl@0: sl@0: /** Complicated parameter block used for contextual glyph selection, sl@0: ligature creation and diacritic placement when drawing text in complex sl@0: scripts sl@0: sl@0: This class declares a constructor, another scoped class, and several other sl@0: enums. However this class is unlikely to be useful to third party developers. sl@0: sl@0: @see CFont::GetCharacterPosition() sl@0: @see CFont::GetCharacterPosition2() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TPositionParam sl@0: { sl@0: public: sl@0: /** Standard constructor. */ sl@0: TPositionParam(): sl@0: iDirection(EHorizontal), sl@0: iFlags(0), sl@0: iPosInText(0), sl@0: iOutputGlyphs(0) sl@0: { sl@0: } sl@0: sl@0: enum sl@0: { sl@0: EMaxInputChars = 18, // ligatures cannot be made from more than 18 components sl@0: EMaxOutputGlyphs = 8 // output can consist of up to 8 characters (one base and 7 combining characters) sl@0: }; sl@0: sl@0: /**Flags for TPositionParam::iFlags. */ sl@0: enum TFlags sl@0: { sl@0: /** Input text is logically ordered not visually ordered. */ sl@0: EFLogicalOrder = 1 sl@0: }; sl@0: sl@0: /** Input: Orientation (EHorizontal or EVertical) in which to draw sl@0: the text. */ sl@0: TInt16 iDirection; sl@0: /** Input: Flags from TFlags. */ sl@0: TUint16 iFlags; sl@0: /** Input: Text containing the characters to be positioned. */ sl@0: TPtrC iText; sl@0: sl@0: /** Input and output: Position within iText to shape. On exit sl@0: it will index the first character not positioned */ sl@0: TInt iPosInText; sl@0: /** Input and output: Pen position. */ sl@0: TPoint iPen; sl@0: sl@0: /** Output of GetCharacterPosition and GetCharacterPosition2. sl@0: @see CFont::GetCharacterPosition sl@0: @see CFont::GetCharacterPosition2 sl@0: @publishedAll sl@0: @released */ sl@0: class TOutput sl@0: { sl@0: public: sl@0: /** Standard constructor. */ sl@0: TOutput() : iBitmapSize(TSize::EUninitialized), sl@0: iBounds(TRect::EUninitialized) {} sl@0: /** Character or glyph code. */ sl@0: TUint iCode; sl@0: /** Bitmap data for the glyph, if available */ sl@0: const TUint8* iBitmap; sl@0: /** Size of the bitmap before algorithmic bolding, size sl@0: multiplication, etc. */ sl@0: TSize iBitmapSize; sl@0: /** Bitmap bounds relative to the original pen position. */ sl@0: TRect iBounds; sl@0: }; sl@0: sl@0: /** Information about the glyphs that were output. */ sl@0: TOutput iOutput[EMaxOutputGlyphs]; sl@0: /** Number of glyphs actually output. */ sl@0: TInt iOutputGlyphs; sl@0: }; sl@0: sl@0: sl@0: /** Input parameter block. sl@0: sl@0: This is optionally used by CFont::MeasureText(), which is the powerful text sl@0: measurement function underlying all the other text measurement functions. sl@0: sl@0: @see CFont::MeasureText() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TMeasureTextInput sl@0: { sl@0: public: sl@0: TMeasureTextInput(): sl@0: iStartInputChar(0), sl@0: iEndInputChar(KMaxTInt), sl@0: iDirection(EHorizontal), sl@0: iFlags(0), sl@0: iMaxAdvance(KMaxTInt), sl@0: iMaxBounds(KMaxTInt), sl@0: iCharJustNum(0), sl@0: iCharJustExcess(0), sl@0: iWordJustNum(0), sl@0: iWordJustExcess(0) sl@0: { sl@0: } sl@0: sl@0: /**Flags for TMeasureTextInput::iFlags. */ sl@0: enum TFlags sl@0: { sl@0: /** Input text is visually ordered left-to-right. */ sl@0: EFVisualOrder = 1, sl@0: /** Input text is visually ordered right-to-left. sl@0: Overrides EFVisualOrder. */ sl@0: EFVisualOrderRightToLeft = 2, sl@0: /** Flag to consider side bearings when checking bounds for line-break */ sl@0: EFIncludePenPositionInBoundsCheck = 4 sl@0: }; sl@0: sl@0: /** Starting index specifying first input character in iText. sl@0: sl@0: Together with iEndInputChar, this allows some context before and sl@0: after the measured text to be supplied so that shaping can work sl@0: properly. */ sl@0: TInt iStartInputChar; sl@0: sl@0: /** Index specifying the final input character. sl@0: sl@0: Together with iStartInputChar, this allows some context before and sl@0: after the measured text to be supplied so that shaping can work sl@0: properly. */ sl@0: TInt iEndInputChar; sl@0: sl@0: /** The direction in which to draw the text. */ sl@0: TUint16 iDirection; sl@0: sl@0: /** Flags from TFlags. */ sl@0: TUint16 iFlags; sl@0: sl@0: /** The maximum advance. */ sl@0: TInt iMaxAdvance; sl@0: sl@0: /** The maximum width (or height if drawing vertically) of bounds. */ sl@0: TInt iMaxBounds; sl@0: sl@0: /** The number of glyph groups to be letter-spaced. */ sl@0: TInt iCharJustNum; sl@0: sl@0: /** The amount of space to be used for letter spacing. */ sl@0: TInt iCharJustExcess; sl@0: sl@0: /** The number of spaces to be used for word spacing. */ sl@0: TInt iWordJustNum; sl@0: sl@0: /** The amount of space to be used for word spacing. */ sl@0: TInt iWordJustExcess; sl@0: }; sl@0: sl@0: /** Output parameter block. sl@0: sl@0: This is optionally used by CFont::MeasureText(), which is the powerful text sl@0: measurement function underlying all the other text measurement functions. sl@0: sl@0: @see CFont::MeasureText() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TMeasureTextOutput sl@0: { sl@0: public: sl@0: /** The number of input characters that would be drawn. sl@0: sl@0: This may be less than the length of the text if a maximum advance or bounding sl@0: box size is specified. */ sl@0: TInt iChars; sl@0: /** The number of glyphs that would be drawn. */ sl@0: TInt iGlyphs; sl@0: /** The number of groups that would be drawn. sl@0: sl@0: A group is a base glyph plus one or more combining characters. */ sl@0: TInt iGroups; sl@0: /** The number of word spaces (U+0020) that would be drawn. */ sl@0: TInt iSpaces; sl@0: /** The bounding box of all the glyphs that would be drawn. */ sl@0: TRect iBounds; sl@0: /** The maximum width and height of any glyph. */ sl@0: TSize iMaxGlyphSize; sl@0: }; sl@0: sl@0: /** sl@0: Data availability flags. sl@0: sl@0: Some fonts like printer fonts may only have width information and can return sl@0: ECharacterWidthOnly to show this: the text drawing routines in CFont synthesize sl@0: the rest of the data if necessary. sl@0: sl@0: @see GetCharacterData() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TCharacterDataAvailability sl@0: { sl@0: /** No font information available. */ sl@0: ENoCharacterData, sl@0: /** Width information only is available. */ sl@0: ECharacterWidthOnly, sl@0: /** All character data is available. */ sl@0: EAllCharacterData sl@0: }; sl@0: sl@0: private: sl@0: // virtual functions have been made protected and public non-virtual ones sl@0: // added to convert CFont to a handle-body pattern. SC is kept throught the sl@0: // new functions and BC is kept by keeping the protected functions in the sl@0: // same place in the class, and therefore in the same place in the vtable sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TUid DoTypeUid() const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoHeightInPixels() const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoAscentInPixels() const=0; sl@0: IMPORT_C virtual TInt DoDescentInPixels() const; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoCharWidthInPixels(TChar aChar) const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoTextWidthInPixels(const TDesC& aText) const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoBaselineOffsetInPixels() const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoMaxCharWidthInPixels() const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TInt DoMaxNormalCharWidthInPixels() const=0; sl@0: /** sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. Please see derived class for implementation. sl@0: */ sl@0: virtual TFontSpec DoFontSpecInTwips() const=0; sl@0: sl@0: protected: sl@0: IMPORT_C virtual TCharacterDataAvailability DoGetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const; sl@0: IMPORT_C virtual TBool DoGetCharacterPosition(TPositionParam& aParam) const; sl@0: IMPORT_C virtual TInt DoExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const; sl@0: sl@0: protected: sl@0: IMPORT_C virtual ~CFont(); sl@0: sl@0: public: sl@0: inline TInt FontCapitalAscent() const; sl@0: inline TInt FontMaxAscent() const; sl@0: inline TInt FontStandardDescent() const; sl@0: inline TInt FontMaxDescent() const; sl@0: inline TInt FontLineGap() const; sl@0: inline TInt FontMaxHeight() const; sl@0: sl@0: public: sl@0: /** Gets run-time identity of the actual font type. This enables safe casting to sl@0: a derived type. sl@0: sl@0: For example, if the derived type is a CFbsFont, the return value is KCFbsFontUid. sl@0: You would need to cast to a CFbsFont to get a character bounding box. Similarly, sl@0: a CBitmapFont returns KCBitmapFontUidVal. sl@0: sl@0: @return The font-type identifier. */ sl@0: IMPORT_C TUid TypeUid() const; sl@0: sl@0: /** Gets the font height in pixels. sl@0: Note that this deprecated function is replaced by the new @c FontMaxHeight(). sl@0: sl@0: @return The font height in pixels. sl@0: @see FontMaxHeight() sl@0: @deprecated */ sl@0: IMPORT_C TInt HeightInPixels() const; sl@0: sl@0: /** Gets the font ascent in pixels. sl@0: Note that this deprecated function is replaced by the new @c FontMaxAscent() sl@0: or in some cases @c FontCapitalAscent(). sl@0: sl@0: @return The font ascent in pixels. sl@0: @see FontCapitalAscent() sl@0: @see FontMaxAscent() sl@0: @deprecated */ sl@0: IMPORT_C TInt AscentInPixels() const; sl@0: sl@0: /** Gets the font descent in pixels. sl@0: Note that this deprecated function is replaced by the new @c FontMaxDescent() sl@0: or in some cases @c FontStandardDescent(). sl@0: sl@0: @return The font descent in pixels. sl@0: @see FontStandardDescent() sl@0: @see FontMaxDescent() sl@0: @deprecated */ sl@0: IMPORT_C TInt DescentInPixels() const; sl@0: sl@0: /** Gets the width in pixels in this font of the specified character. sl@0: sl@0: Note: For OpenType fonts this function returns the horizontal advance of sl@0: the character, which may be different from the actual width. sl@0: sl@0: @param aChar The character whose width should be determined. sl@0: @return The width in pixels of the specified character in this font. */ sl@0: IMPORT_C TInt CharWidthInPixels(TChar aChar) const; sl@0: sl@0: /** Gets the width in pixels of the specified descriptor when displayed in this sl@0: font. sl@0: sl@0: @param aText The descriptor whose width should be determined. sl@0: @return The width of the specified descriptor when displayed in this font, sl@0: in pixels. */ sl@0: IMPORT_C TInt TextWidthInPixels(const TDesC& aText) const; sl@0: sl@0: /** Gets the baseline offset in pixels. sl@0: sl@0: The baseline offset is how far a font is raised or lowered from its normal sl@0: baseline. sl@0: sl@0: @return Offset from normal baseline, in pixels. */ sl@0: IMPORT_C TInt BaselineOffsetInPixels() const; sl@0: sl@0: /** Gets how much of the specified descriptor can be displayed in this font without sl@0: exceeding the specified width. sl@0: sl@0: Note: sl@0: sl@0: This function does not display any of the descriptor itself - it is used sl@0: before display, to test whether the whole descriptor can be displayed. sl@0: sl@0: @param aText The descriptor. sl@0: @param aWidthInPixels The available width for character display. sl@0: @return The number of characters which will be able to be displayed without sl@0: exceeding the specified width. The count starts from the beginning of the sl@0: descriptor. */ sl@0: IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const; sl@0: sl@0: /** Gets how much of the specified descriptor can be displayed in this font without sl@0: exceeding the specified width. sl@0: sl@0: It also returns the excess width - defined as the specified available width sl@0: minus the width of the portion of the descriptor which can be displayed without sl@0: exceeding the available width. sl@0: sl@0: @param aText The descriptor. sl@0: @param aWidthInPixels The available width for character display. sl@0: @param aExcessWidthInPixels The excess width after displaying the portion of sl@0: the descriptor, in pixels. sl@0: @return The number of characters which will be able to be displayed without sl@0: exceeding the specified width. The count starts from the beginning of the sl@0: descriptor. */ sl@0: IMPORT_C TInt TextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const; sl@0: sl@0: /** Gets the width in pixels of the widest character in this font. sl@0: sl@0: @return The width of the maximum width character, in pixels. */ sl@0: IMPORT_C TInt MaxCharWidthInPixels() const; sl@0: sl@0: /** Gets the width in pixels of the widest normal character in this font. sl@0: sl@0: Normal characters include all character in a character set except non-alphabetic sl@0: characters (e.g. the copyright symbol, or a block graphics symbol, for example). sl@0: sl@0: @return The width of the maximum width normal character, in pixels. */ sl@0: IMPORT_C TInt MaxNormalCharWidthInPixels() const; sl@0: sl@0: /** Gets the font specification of this font in twips. sl@0: sl@0: @return The font specification of this font (in twips). */ sl@0: IMPORT_C TFontSpec FontSpecInTwips() const; sl@0: IMPORT_C TCharacterDataAvailability GetCharacterData(TUint aCode, TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const; sl@0: IMPORT_C TBool GetCharacterPosition(TPositionParam& aParam) const; sl@0: IMPORT_C TInt WidthZeroInPixels() const; sl@0: IMPORT_C TInt MeasureText(const TDesC& aText, const TMeasureTextInput* aInput = NULL, TMeasureTextOutput* aOutput = NULL) const; sl@0: IMPORT_C static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter); sl@0: IMPORT_C TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const; sl@0: IMPORT_C TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const; sl@0: sl@0: /** Gets the width in pixels of the specified descriptor when displayed in this sl@0: font. sl@0: sl@0: @param aText The descriptor whose width should be determined. sl@0: @param aParam Parameter block that controls how much of aText is measured sl@0: @return The width of the specified descriptor when displayed in this font, sl@0: in pixels. */ sl@0: IMPORT_C TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const; sl@0: }; sl@0: sl@0: class CFbsBitmap; sl@0: class CWsBitmap; sl@0: /** Abstract base class for all graphics contexts. sl@0: sl@0: Created by a CGraphicsDevice. sl@0: sl@0: Provides the 'context' in which you are drawing to an associated device, in sl@0: the sense that it holds the settings for drawing, such as the pen and brush sl@0: settings (e.g. color, line styles) and the font settings (e.g. bold, underline, sl@0: italic). These settings are device-independent. sl@0: sl@0: Also provides the clipping region (the visible drawing area). sl@0: sl@0: The settings and clipping area can be updated while drawing. sl@0: sl@0: This class also contains the main drawing functions, and all drawing is done sl@0: through a CGraphicsContext. sl@0: sl@0: The graphics context deals with pixels of device-dependent size and uses fonts sl@0: with device-dependent size and representation. The sizes and fonts to be passed sl@0: to the class functions therefore need to be converted from size-independent sl@0: units to size-dependent units first. This is done by an MGraphicsDeviceMap sl@0: derived class. This may be a TZoomFactor or the CGraphicsDevice. sl@0: sl@0: See CGraphicsContext::Reset() for the default graphics context settings immediately sl@0: after construction. sl@0: sl@0: @see CBitmapContext sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CGraphicsContext : public CBase sl@0: { sl@0: public: sl@0: sl@0: sl@0: /** Text alignment. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TTextAlign sl@0: { sl@0: /** Text is left-aligned. */ sl@0: ELeft, sl@0: /** Text is centred. */ sl@0: ECenter, sl@0: /** Text is right-aligned. */ sl@0: ERight sl@0: }; sl@0: sl@0: /** sl@0: Drawing mode components. sl@0: This enum is not intended to be used directly, but provides components for sl@0: the easy specification of drawing modes in the TDrawMode enum. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TDrawModeComponents sl@0: { sl@0: /** 1 */ sl@0: EInvertScreen=1, sl@0: /** 2 */ sl@0: EXor=2, sl@0: /** 4 */ sl@0: EOr=4, sl@0: /** 8 */ sl@0: EAnd=8, sl@0: /** 14 */ sl@0: ELogicalOp=14, sl@0: /** 16 */ sl@0: EInvertPen=16, sl@0: /** 32 */ sl@0: EPenmode=32, sl@0: /** 64 */ sl@0: EWriteAlpha=64, sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Drawing modes. sl@0: sl@0: This enum builds on the drawing mode components in the TDrawModeComponents sl@0: enum. sl@0: sl@0: If the pen colour is p, brush colour is b and screen colour is s, the effect sl@0: of TDrawMode::EDrawModeAND is P=p&s and B=b&s. In other words, the effective sl@0: colour of the pen on the screen, P, is that produced by the bitwise ANDing sl@0: of the current screen colour and the current pen colour. The effect is similar sl@0: for the effective brush colour, B. sl@0: sl@0: The effective pen and brush colour are given in the table using the key sl@0: Inputs: pen colour is p, brush colour is b and screen colour is s sl@0: Outputs: effective brush colour is B, effective pen colour is P. sl@0: sl@0: Some notes on using EDrawModeWriteAlpha:- sl@0: sl@0: - It is rare for client code to need to use this draw mode: see the documentation sl@0: of SetDrawMode() for more information. sl@0: - EDrawModeWriteAlpha should only be used with DrawRect(), Clear(), BitBlt(), and BitBltMasked() sl@0: with EGray2 mask (and DrawBitmap() and DrawBitmapMasked()). For other draw operations, it is not sl@0: supported, and may have unintended effects. sl@0: - EDrawModeWriteAlpha has the same effect as EDrawModePEN, unless the brush colour has transparency sl@0: (DrawRect(), Clear()), or the source bitmap is EColor16MA (and has transparency) (BitBlt(), BitBltMasked()) sl@0: - EDrawModeWriteAlpha has the same effect as EDrawModePEN if the draw mode of the destination does not sl@0: support alpha blending. (Blending is only supported in 24bpp and 32bpp colour i.e. EColor16M, EColor16MU, EColor16MA) sl@0: - In these cases, EDrawModePEN does alpha blending, whereas EDrawModeWriteAlpha means don't do alpha blending. sl@0: sl@0: @see SetDrawMode() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TDrawMode sl@0: { sl@0: /** Bitwise ANDs the pen and brush colours with the screen colour. sl@0: P=p&s, B=b&s */ sl@0: EDrawModeAND=EAnd, sl@0: /** Inverts the pen and brush colours before ANDing. P=(~p)&s, sl@0: B=(~b)&s */ sl@0: EDrawModeNOTAND=EInvertScreen|EAnd, sl@0: /** Uses both pen and brush colour as they are. P=p, B=b */ sl@0: EDrawModePEN=EPenmode, sl@0: /** Inverts the screen colour before ANDing. P=p&(~s), B=b&(~s) */ sl@0: EDrawModeANDNOT=EAnd|EInvertPen, sl@0: /** Bitwise XORs the pen and brush colours with the screen colour. sl@0: P=p^s, B=b^s */ sl@0: EDrawModeXOR=EXor, sl@0: /** Bitwise ORs the pen and brush colours with the screen colour. sl@0: P=p|s, B=b|s */ sl@0: EDrawModeOR=EOr, sl@0: /** Inverts the screen and pen and brush colours before ANDing. sl@0: P=(~p)&(~s), B=(~b)&(~s) */ sl@0: EDrawModeNOTANDNOT=EInvertScreen|EAnd|EInvertPen, sl@0: /** Inverts the pen and brush colours before XORing. P=(~p)^s, sl@0: B=(~b)^s */ sl@0: EDrawModeNOTXOR=EInvertScreen|EXor, sl@0: /** Inverts the colour of each pixel that is drawn over, (pen and sl@0: brush attributes are ignored). P=~s, B=~s */ sl@0: EDrawModeNOTSCREEN=EInvertScreen, sl@0: /** Inverts the screen colour before ORing. P=p|(~s), sl@0: B=b|(~s) */ sl@0: EDrawModeNOTOR=EInvertScreen|EOr, sl@0: /** Inverts the pen and brush colours. P=~p, B=~b */ sl@0: EDrawModeNOTPEN=EInvertPen|EPenmode, sl@0: /** Inverts the pen and brush colours before ORing. P=(~p)|s, sl@0: B=(~b)|s */ sl@0: EDrawModeORNOT=EOr|EInvertPen, sl@0: /** Inverts the screen and pen and brush colours before ORing. sl@0: P=(~p)|(~s), B=(~b)|(~s) */ sl@0: EDrawModeNOTORNOT=EInvertScreen|EOr|EInvertPen, sl@0: /** Writes alpha information in the source directly into the destination, rather than blending. */ sl@0: EDrawModeWriteAlpha=EWriteAlpha, sl@0: }; sl@0: sl@0: /** sl@0: Pen styles. The screen pattern unit in each definition below describes the sl@0: pattern drawn by the line 1 represents a pixel drawn, 0 represents a sl@0: pixel that is not affected. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TPenStyle sl@0: { sl@0: /** The pen does not draw. Screen pattern unit = 00... */ sl@0: ENullPen, sl@0: /** A solid line (default). Screen pattern unit = 11... */ sl@0: ESolidPen, sl@0: /** A dotted line. Screen pattern unit = 1000... */ sl@0: EDottedPen, sl@0: /** A dashed line. Screen pattern unit = 111000... */ sl@0: EDashedPen, sl@0: /** A line of alternating dashes and dots. Screen pattern unit = sl@0: 1111001100... */ sl@0: EDotDashPen, sl@0: /** A line of alternating single dashes and pairs of dots. Screen sl@0: pattern unit = 11110011001100... */ sl@0: EDotDotDashPen sl@0: }; sl@0: sl@0: /** sl@0: Brush styles. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TBrushStyle sl@0: { sl@0: /** The brush fill has no effect (default). */ sl@0: ENullBrush, sl@0: /** The brush fills with a solid single colour, determined by sl@0: SetBrushColor() and the drawing mode. */ sl@0: ESolidBrush, sl@0: /** The brush fills with a selected bitmap pattern, set by sl@0: UseBrushPattern(). */ sl@0: EPatternedBrush, sl@0: /** The brush fills with vertical hatching lines going from top to sl@0: bottom. */ sl@0: EVerticalHatchBrush, sl@0: /** The brush fills with diagonal hatching lines going from bottom sl@0: left to top right. */ sl@0: EForwardDiagonalHatchBrush, sl@0: /** The brush fills with horizontal hatching lines going from left sl@0: to right. */ sl@0: EHorizontalHatchBrush, sl@0: /** The brush fills with rearward diagonal hatching lines going from top sl@0: left to bottom right. */ sl@0: ERearwardDiagonalHatchBrush, sl@0: /** The brush fills with horizontal and vertical hatching lines going sl@0: from left to right plus lines going from top to bottom giving the sl@0: effect of a grid of small squares */ sl@0: ESquareCrossHatchBrush, sl@0: /** The brush fills with forward diagonal and rearward diagonal hatching sl@0: lines going from bottom left to top right plus lines going from top left sl@0: to bottom right giving the effect of a grid of small diamonds. */ sl@0: EDiamondCrossHatchBrush sl@0: }; sl@0: sl@0: /** sl@0: Rules used to fill self crossing polygons. sl@0: sl@0: The filling of a polygon proceeds as follows: for a given point in the sl@0: polygon, then sl@0: sl@0: if the rule is TFillRule::EAlternate (default) and it has an odd winding sl@0: number, then fill the surrounding area. sl@0: sl@0: if the rule is TFillRule::EWinding and it has a winding number greater than sl@0: zero, then fill the surrounding area. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TFillRule sl@0: { sl@0: /** Only fill areas with odd winding numbers. */ sl@0: EAlternate, sl@0: /** Fill areas with winding numbers greater than zero. */ sl@0: EWinding sl@0: }; sl@0: sl@0: /** Parameters to control the drawing of text. */ sl@0: struct TDrawTextParam sl@0: { sl@0: public: sl@0: TDrawTextParam(): sl@0: iDirection(CFont::EHorizontal), sl@0: iCharJustNum(0), sl@0: iCharJustExcess(0), sl@0: iWordJustNum(0), sl@0: iWordJustExcess(0) sl@0: /** Reserved for future use. */ sl@0: {} sl@0: public: sl@0: /** the direction in which to draw the text. */ sl@0: CFont::TTextDirection iDirection; sl@0: /** number of glyph groups to be letterspaced */ sl@0: TInt iCharJustNum; sl@0: /** amount of space to be used for letterspacing */ sl@0: TInt iCharJustExcess; sl@0: /** number of spaces to be used for wordspacing*/ sl@0: TInt iWordJustNum; sl@0: /** amount of space to be used for wordspacing*/ sl@0: TInt iWordJustExcess; sl@0: }; sl@0: sl@0: sl@0: /** Parameters for extended text drawing and measuring. It is used by sl@0: CGraphicsContext::DrawTextExtended() to indicate whether text should be sl@0: drawn from right-to-left or left-to-right. */ sl@0: struct TDrawTextExtendedParam : public TDrawTextParam sl@0: { sl@0: public: sl@0: /** Constructor. Initialises iParRightToLeft to EFalse. */ sl@0: TDrawTextExtendedParam(): sl@0: iParRightToLeft(EFalse) sl@0: {} sl@0: public: sl@0: /** ETrue if the text direction is right-to-left (for scripts like sl@0: Arabic and Hebrew). EFalse if left-to-right. */ sl@0: TBool iParRightToLeft; sl@0: }; sl@0: sl@0: /** sl@0: Parameters used in drawing text within supplied context. sl@0: It is used by CGraphicsContext::DrawText() and CGraphicsContext::DrawTextVertical() family of API's sl@0: to draw text from iStart to iEnd withing the supplied text descriptor. sl@0: */ sl@0: class TTextParameters sl@0: { sl@0: public: sl@0: TTextParameters(): sl@0: iStart(0), sl@0: iEnd(KMaxTInt), sl@0: iFlags(0) sl@0: { sl@0: } sl@0: TInt iStart; sl@0: TInt iEnd; sl@0: TUint16 iFlags; sl@0: /* Reserved for future use */ sl@0: TAny* iReserved1; sl@0: TAny* iReserved2; sl@0: TAny* iReserved3; sl@0: TAny* iReserved4; sl@0: }; sl@0: public: sl@0: /** Gets a pointer to the graphics context's graphics device. sl@0: sl@0: @return A pointer to the graphics device. */ sl@0: virtual CGraphicsDevice* Device() const=0; sl@0: sl@0: /** Sets the position of the co-ordinate origin. sl@0: sl@0: All subsequent drawing operations are done relative to this origin. sl@0: sl@0: @param aPos The origin. The default origin is TPoint(0,0) the top left sl@0: corner of the screen. */ sl@0: virtual void SetOrigin(const TPoint& aPos=TPoint(0,0))=0; sl@0: sl@0: /** Sets the drawing mode. sl@0: sl@0: The way that the pen and brush draw depends on the drawing mode. The drawing sl@0: mode affects the colour that is actually drawn, because it defines the way sl@0: that the current screen colour logically combines with the current pen colour sl@0: and brush colour. There are many drawing modes, each giving different logical sl@0: combinations of pen, brush and screen colours. Each mode is produced by ORing sl@0: together different combinations of seven drawing mode components. sl@0: sl@0: The three most important modes are TDrawMode::EDrawModePEN, TDrawMode::EDrawModeNOTSCREEN sl@0: and TDrawMode::EDrawModeXOR. The default drawing mode is TDrawMode::EDrawModePEN. sl@0: sl@0: The drawing mode is over-ridden for line and shape drawing functions when sl@0: a wide pen line has been selected. It is forced to TDrawMode::EDrawModePEN. sl@0: This is to prevent undesired effects at line joins (vertexes). sl@0: sl@0: Notes: sl@0: sl@0: TDrawMode::EDrawModeAND gives a "colour filter" effect. For example: sl@0: sl@0: - ANDing with white gives the original colour sl@0: - ANDing with black gives black sl@0: sl@0: TDrawMode::EDrawModeOR gives a "colour boost" effect. For example: sl@0: sl@0: - ORing with black gives the original colour sl@0: - ORing with white gives white sl@0: sl@0: TDrawMode::EDrawModeXOR gives an "Exclusive OR" effect. For example: sl@0: sl@0: - white XOR black gives white sl@0: - white XOR white gives black sl@0: - black XOR black gives black sl@0: sl@0: TDrawMode::EDrawModeWriteAlpha should not normally need to be used by client code. sl@0: The following are exceptions:- sl@0: sl@0: - When a client side EColor16MA bitmap needs to have a transparent background sl@0: (because you are intending to blend it onto something else), then you need to set sl@0: EDrawModeWriteAlpha to Clear() it. sl@0: - When you want to BitBlt() with an EColor16MA source bitmap that is opaque everywhere, sl@0: then using EDrawModeWriteAlpha is more efficient than EDrawModePEN, because the bitmap sl@0: does not need to be blended. sl@0: sl@0: Note that if you have a transparent brush or source bitmap and you are drawing to a window, sl@0: then it is a defect to use EDrawModeWriteAlpha. sl@0: sl@0: @param aDrawingMode The drawing mode. sl@0: @see CGraphicsContext::TDrawMode sl@0: @see CGraphicsContext::TDrawModeComponents */ sl@0: virtual void SetDrawMode(TDrawMode aDrawingMode)=0; sl@0: sl@0: /** Sets the clipping rectangle. sl@0: sl@0: The area of visible drawing depends on the clipping rectangle, any items sl@0: that fall outside the extent of the clipping rectangle will not be drawn. sl@0: The default clipping rectangle is the full device area. sl@0: sl@0: Note that clipping is additive. If a clipping region has been set using SetClippingRegion() sl@0: then clipping will be to the intersection of that region and this rectangle. sl@0: sl@0: @param aRect The rectangle to be used as the clipping rectangle. Note that sl@0: this rectangle is tranformed by the current co-ordinate origin before it is used. sl@0: The co-ordinate origin is set using SetOrigin(). sl@0: sl@0: @see CGraphicsContext::SetClippingRegion() sl@0: @see CGraphicsContext::SetOrigin() */ sl@0: virtual void SetClippingRect(const TRect& aRect)=0; sl@0: sl@0: /** Cancels any clipping rectangle. sl@0: sl@0: Clipping thus reverts to the full device area, the default. sl@0: sl@0: @see SetClippingRect() */ sl@0: virtual void CancelClippingRect()=0; sl@0: sl@0: /** Resets the graphics context to its default settings: sl@0: sl@0: the drawing mode is TDrawMode::EDrawModePen (pen and brush colours used as sl@0: they are) sl@0: sl@0: there is no clipping rectangle sl@0: sl@0: the pen settings are: black, solid, single pixel size sl@0: sl@0: the brush style is null sl@0: sl@0: no text font is selected */ sl@0: virtual void Reset()=0; sl@0: sl@0: /** Sets the device font to be used for text drawing. sl@0: sl@0: If the font is already in memory, then that copy is shared. sl@0: sl@0: Notes: sl@0: sl@0: The CFont* argument must have been previously initialised by calling sl@0: MGraphicsDeviceMap::GetNearestFontInTwips() with the required sl@0: font-specification. If the CFont* has not been initialised sl@0: correctly, and therefore does not point to an available font-bitmap, sl@0: then a panic is raised. sl@0: sl@0: When the font is no longer required, use DiscardFont() to free up the sl@0: memory used. If UseFont() is used again without using DiscardFont() then sl@0: the previous font is discarded automatically. sl@0: sl@0: If no font has been selected, and an attempt is made to draw text with sl@0: DrawText(), then a panic is raised. sl@0: sl@0: @param aFont A device font sl@0: @see MGraphicsDeviceMap::GetNearestFontInTwips() */ sl@0: virtual void UseFont(const CFont* aFont)=0; sl@0: sl@0: /** Discards a font. sl@0: sl@0: This frees up the memory used, if the font is not being shared. sl@0: sl@0: The function can be called when no font is in use. */ sl@0: virtual void DiscardFont()=0; sl@0: sl@0: /** Sets the underline style. sl@0: sl@0: This is applied to all subsequently drawn text. sl@0: sl@0: @param aUnderlineStyle The underline style on or off. */ sl@0: virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle)=0; sl@0: sl@0: /** Sets the strikethrough style. sl@0: sl@0: This is applied to all subsequently drawn text. sl@0: sl@0: @param aStrikethroughStyle The strikethrough style on or off. */ sl@0: virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)=0; sl@0: IMPORT_C static TInt JustificationInPixels(TInt aExcessPixels,TInt aTotalUnits,TInt aFirstUnit,TInt aNumUnits); sl@0: IMPORT_C static TInt JustificationInPixels(TInt& aExcessPixels,TInt& aTotalUnits); sl@0: sl@0: /** Adjusts the spaces between words to stretch or squeeze to a certain sl@0: width. sl@0: sl@0: The function is required by the Text Views API, and is not intended for sl@0: regular use by developers. sl@0: sl@0: The text line that is to be justified has a certain number of gaps (spaces) sl@0: between the words. It also has a distance (in pixels) between the end of sl@0: the last word and the actual end of the line (right hand margin, usually). sl@0: These excess width pixels are distributed amongst the gaps between the words sl@0: to achieve full justification of the text line. Spaces become fat spaces to sl@0: keep underlining/strikethrough consistent. Pixels are distributed to the sl@0: inter-word gaps starting from the left end of the string. The spacing sl@0: between characters in each word remains unchanged. sl@0: sl@0: After a call to SetWordJustification(), subsequent calls to either of the sl@0: two DrawText() functions are affected until the number of spaces specified sl@0: by aNumSpaces is used up. sl@0: sl@0: The easiest way to find out the excess width and number of spaces is to call sl@0: CFont::MeasureText(). This function can also perform counting, which is sl@0: finding how much of some text will fit into a given width. sl@0: sl@0: Use CFont::TextCount() to return the excess width. sl@0: sl@0: For example, in the string "To be, or not to be", there are five inter-word sl@0: gaps. If there are six excess pixels they will be distributed in the sl@0: proportion 2, 1, 1, 1, 1 between the words. If there are nine excess pixels sl@0: they will be distributed in the proportion 2, 2, 2, 2, 1 between the words. sl@0: sl@0: Notes: sl@0: sl@0: If the excess width is zero, then calling SetWordJustification() has no sl@0: effect. sl@0: sl@0: At first sight it may appear that SetWordJustification() is not required sl@0: because you can simply call DrawText() for each word. However, underlined sl@0: justified text does not work using this strategy you get a non-underlined sl@0: gap between the space and the beginning of the next word. sl@0: sl@0: @param aExcessWidth The width (in pixels) to be distributed between the sl@0: specified number of spaces. sl@0: @param aNumGaps The number of word spaces (characters with the code U+0020) sl@0: over which the change in width is distributed. */ sl@0: virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps)=0; sl@0: sl@0: /** Sets character justification. sl@0: sl@0: This function is required by the Text Views API, and is not intended for sl@0: regular use by developers. sl@0: sl@0: It affects the strings of text used in the calls to DrawText() that follow, sl@0: until the number of characters drawn equals aNumChars. sl@0: sl@0: The text line that is to be justified has a certain number of characters sl@0: this includes the spaces between the words. It also has a distance (in sl@0: pixels) between the end of the last word and the actual end of the line sl@0: (right hand margin, usually). These excess width pixels are distributed sl@0: amongst all the characters, increasing the gaps between them, to achieve sl@0: full justification of the text line. sl@0: sl@0: Use CFont::TextCount() to return the excess width. sl@0: sl@0: Notes: sl@0: sl@0: This function is provided to allow simulation of printer fonts on screen. sl@0: Due to the fact that fully-scalable fonts are not used before v5, large sl@0: printer fonts can be simulated by using the nearest smaller font and sl@0: widening it slightly. sl@0: sl@0: If the excess width is zero, then calling SetCharJustification() has no sl@0: effect. sl@0: sl@0: SetCharJustification() is required for WYSIWYG where the layout uses sl@0: printer font metrics but screen fonts have to be drawn on the screen. sl@0: Because continuously scalable typefaces (c.f. TrueType) are not used sl@0: before v5 and because screen fonts are coarser and less numerous in sl@0: their variety than the printer fonts, the best matching smaller screen sl@0: font must be used with character justification to simulate the printer sl@0: font on the screen. sl@0: sl@0: There is also a situation where the gaps between characters on screen have sl@0: to be reduced with character clipping. The screen font that best matches sl@0: the printer font may have the required height, but has characters that are sl@0: too wide. A line of text that works on the printer will then be too long sl@0: on the screen, unless it is squashed horizontally. The number of pixels sl@0: that overlap the end of the screen line must now be removed from the gaps sl@0: between the characters, i.e. there is a negative excess width. This sl@0: situation is especially important where adding a TAB on screen gives sl@0: perfectly acceptable printout, but would push the last character of the sl@0: line off the right hand side of the screen. sl@0: sl@0: In practice what you do in printer layout mode is: sl@0: sl@0: Calculate where the line breaks will come on the printer. To do this you sl@0: use a printer font (which in practice means a table of character widths sl@0: of the font that the printer will use). sl@0: sl@0: Now change to use a screen font that is the closest font which is no taller sl@0: that the printer font. In practice it will often be fatter maybe only for sl@0: certain characters such as 'i'. sl@0: sl@0: You have to recalculate the width of the characters using the screen fonts. sl@0: You can do this using CFont::TextWidth() as you have already determined how sl@0: many characters will fit on the line. sl@0: sl@0: If, in the screen font, the characters are not as wide as the line then you sl@0: can just use word justification to expand the line. You would only do this sl@0: if the text is to be justified. sl@0: sl@0: If, however, the characters are wider than the line then you would use sl@0: character justification to clip each character. You would need to do this sl@0: even if the line is not justified. sl@0: sl@0: Thus, in practice, character justification will only very rarely be used to sl@0: expand a line of characters. sl@0: sl@0: @param aExcessWidth The excess width (in pixels) to be distributed between sl@0: the specified number of characters. It may be positive, in which case the text is sl@0: stretched, or negative, in which case it is shrunk. sl@0: @param aNumChars The number of characters involved. */ sl@0: virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars)=0; sl@0: sl@0: /** Sets the pen colour. sl@0: sl@0: The effective pen colour depends on the drawing mode. The default pen colour sl@0: is black. sl@0: sl@0: Note: sl@0: sl@0: The pen is used to draw lines, the outlines of filled shapes, and text. In case sl@0: of outlined text, the pen is used to draw the outline of the font. sl@0: sl@0: The class provides member functions to set the colour of the pen, the style of sl@0: line and the line size drawn. sl@0: sl@0: @param aColor An RGB colour for the pen. sl@0: @see CGraphicsContext::SetDrawMode() */ sl@0: virtual void SetPenColor(const TRgb& aColor)=0; sl@0: sl@0: /** Sets the line drawing style for the pen. sl@0: sl@0: There are 6 pen styles. If no pen style is set, then the default is sl@0: TPenStyle::ESolidPen. To use a pen style, its full context must be given, sl@0: e.g. for a null pen: sl@0: sl@0: CGraphicsContext::TPenStyle::ENullPen sl@0: Notes: sl@0: sl@0: The pen is used to draw lines, the outlines of filled shapes, and text. sl@0: CGraphicsContext member functions are provided to set the colour of the sl@0: pen, the style of line and the line size drawn. sl@0: sl@0: The TPenStyle::ENullPen style should be used if a border is not required sl@0: around a filled shape. sl@0: sl@0: Dotted and dashed pen styles have a device dependant implementation, always sl@0: give single-pixel size lines on the screen whatever the pen size set sl@0: by SetPenSize() and can only be used for straight lines, polylines, sl@0: non-rounded rectangles and polygons. sl@0: sl@0: The dotted/dashed pattern is continued, without re-starting, for all sl@0: consecutively drawn straight lines, i.e. sl@0: sl@0: the outlines of rectangles the pattern starts in the top left corner. sl@0: It is reset at the end of the function call. sl@0: sl@0: the outlines of polygons the pattern starts at the first point. It is sl@0: reset at the end of the function call. sl@0: sl@0: polylines and straight lines the pattern starts at the first point sl@0: initially. Consecutive calls to DrawLine() and/or DrawPolyLine(), whether sl@0: the lines are concatenated or not, continue the pattern. It can be reset sl@0: by a further call to SetPenStyle() using the same dotted/dashed style sl@0: parameter. sl@0: sl@0: @param aPenStyle A pen style. sl@0: @see CGraphicsContext::TPenStyle */ sl@0: virtual void SetPenStyle(TPenStyle aPenStyle)=0; sl@0: sl@0: /** Sets the line drawing size for the pen. sl@0: sl@0: Lines of size greater than one pixel: sl@0: sl@0: are drawn with rounded ends that extend beyond the end points, (as if the sl@0: line is drawn using a circular pen tip of the specified size). sl@0: sl@0: are always drawn in TDrawMode::EDrawModePEN mode, overriding whatever mode sl@0: has been set using SetDrawMode(). sl@0: sl@0: Notes: sl@0: sl@0: The pen is used to draw lines, the outlines of filled shapes, and text. The sl@0: class provides member functions to set the colour of the pen, the style of sl@0: line and the line size drawn. sl@0: sl@0: Wide straight lines and arcs have rounded ends so that concatenated wide sl@0: lines have smoothly rounded corners at the vertexes. sl@0: sl@0: When lines are made wide, the extra strips of pixels are added equally to sl@0: both sides of the line. This works precisely for lines of odd pixel size sl@0: (3, 5, 7, etc.). Wide lines of even pixel size, (2, 4, 6, etc.), sl@0: have the extra strip of pixels added to the right and/or below the line. sl@0: sl@0: Wide outlines of ellipses and wide line arcs are drawn with the pixels sl@0: distributed either side of a thin (single pixel wide) true ellipse sl@0: constructed in the normal manner. Wide ellipses and arcs of even pixel sl@0: size have the extra strip of pixels added to the right and/or below the sl@0: curved line. This gives a slight asymmetry to ellipses. sl@0: sl@0: If the pen style is dotted or dashed, the size specification is ignored: a sl@0: single-pixel wide primitive is drawn, (this is device dependant). sl@0: sl@0: A line size of zero is handled as if the pen style had been set to sl@0: TPenStyle::ENullPen. sl@0: sl@0: @param aSize A line size. The default is 1 pixel. */ sl@0: virtual void SetPenSize(const TSize& aSize)=0; sl@0: sl@0: /** Sets the brush colour. sl@0: sl@0: The effective brush colour depends on the drawing mode. sl@0: sl@0: Notes: sl@0: sl@0: The brush is used for filling shapes and the background of text boxes. In sl@0: case of outlined text, the brush is used for filling the font. The brush sl@0: has colour, style, pattern and pattern origin parameters. sl@0: sl@0: If no brush colour has been set, it defaults to white. However the default sl@0: brush style is null, so when drawing to a window the default appears to be sl@0: the window's background colour. sl@0: sl@0: @param aColor An RGB colour for the brush. sl@0: @see SetDrawMode() */ sl@0: virtual void SetBrushColor(const TRgb& aColor)=0; sl@0: sl@0: /** Sets the brush style. sl@0: sl@0: Ten brush styles are provided, including six built-in hatching patterns. sl@0: Note: The brush is used for filling shapes and the background of text boxes. sl@0: The brush has colour, style, pattern and pattern origin parameters. sl@0: Note: Use TBrushStyle::ENullBrush to draw the outline of a fillable sl@0: shape on its own, without filling. sl@0: Note: If the TBrushStyle::EPatternedBrush style is set, but no bitmap sl@0: pattern has been selected using UseBrushPattern(), then the function panics. sl@0: Note: Hatching lines are done in the current pen colour, set using SetPenColor(). sl@0: The hatching pattern starts at the brush origin, set using SetBrushOrigin(). sl@0: @see TBrushStyle::ENullBrush sl@0: @see TBrushStyle::EPatternedBrush sl@0: @see UseBrushPattern() sl@0: @see SetPenColor() sl@0: @see SetBrushOrigin() sl@0: @publishedAll sl@0: @released sl@0: @param aBrushStyle A brush style. */ sl@0: virtual void SetBrushStyle(TBrushStyle aBrushStyle)=0; sl@0: sl@0: /** Sets the brush pattern origin. sl@0: sl@0: This specifies the top left-hand corner position for the pattern tile around sl@0: which copies of the pattern are tiled. sl@0: sl@0: The brush pattern may be a built-in style, or a bitmap. To use a bitmap, the sl@0: brush must have a pattern set and the brush style must be set to sl@0: TBrushStyle::EPatternedBrush. sl@0: sl@0: Notes sl@0: sl@0: The brush is used for filling shapes and the background of text boxes. The sl@0: brush has colour, style, pattern and pattern origin parameters. sl@0: sl@0: If SetBrushOrigin() is not used, then the origin defaults to (0,0). sl@0: sl@0: This brush origin remains in effect for all fillable shapes drawn sl@0: subsequently, until a new brush origin is set. Shapes can thus be sl@0: considered as windows onto a continuous pattern field (covering the whole sl@0: clipping region of a screen device, or the whole device area of a printer). sl@0: sl@0: @param aOrigin An origin point for the brush. The coordinates are relative sl@0: to the rectangle to fill, i.e. specify 0,0 to align the pattern flush with sl@0: the top and left hand sides of the rectangle. sl@0: @see SetBrushStyle() sl@0: @see UseBrushPattern() */ sl@0: virtual void SetBrushOrigin(const TPoint& aOrigin)=0; sl@0: sl@0: /** Sets the brush pattern to the specified bitmap. sl@0: sl@0: For the brush to actually use the bitmap, TBrushStyle::EPatternedBrush must sl@0: be used to set the brush style. sl@0: sl@0: When the brush pattern is no longer required, use DiscardBrushPattern() to sl@0: free up the memory used, if the bitmap is not being shared. sl@0: If UseBrushPattern() is used again without using DiscardBrushPattern() sl@0: then the previous pattern is discarded automatically. sl@0: sl@0: Notes: sl@0: sl@0: The brush is used for filling shapes and the background of text boxes. The sl@0: brush has colour, style, pattern and pattern origin parameters. sl@0: sl@0: When loading a bitmap, the bitmap is checked to see if it is already in sl@0: memory. If the bitmap is already there, then that copy is shared. sl@0: sl@0: The brush does not need to have a pattern set at all. There are several sl@0: built-in hatching patterns which can be selected using SetBrushStyle(). sl@0: sl@0: @param aBitmap A bitmap pattern for the brush. sl@0: @see SetBrushStyle() */ sl@0: virtual void UseBrushPattern(const CFbsBitmap* aBitmap)=0; sl@0: sl@0: /** Discards a non-built-in brush pattern. sl@0: sl@0: This frees up the memory used by the bitmap, if it is not being shared by sl@0: another process. sl@0: sl@0: Notes: sl@0: sl@0: The brush is used for filling shapes and the background of text boxes. The sl@0: brush has colour, style, pattern and pattern origin parameters. sl@0: sl@0: If DiscardBrushPattern() is used, with no brush pattern set, then there is sl@0: no effect. */ sl@0: virtual void DiscardBrushPattern()=0; sl@0: sl@0: sl@0: /** Sets the drawing point relative to the co-ordinate origin. sl@0: sl@0: A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing sl@0: point as the start point for the line drawn. sl@0: sl@0: Notes sl@0: sl@0: The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline() sl@0: also change the internal drawing position to the last point of the drawn sl@0: line(s). sl@0: sl@0: The internal drawing position is set to the co-ordinate origin if no drawing sl@0: or moving operations have yet taken place. sl@0: sl@0: @param aPoint The new internal drawing position. */ sl@0: virtual void MoveTo(const TPoint& aPoint)=0; sl@0: sl@0: /** Sets the drawing point relative to the current co-ordinates. sl@0: sl@0: A subsequent call to DrawLineTo() or DrawLineBy() uses the new drawing point sl@0: as the start point for the line drawn. sl@0: sl@0: Notes sl@0: sl@0: The operations DrawLine(), DrawLineTo(), DrawLineBy() and DrawPolyline() sl@0: also change the internal drawing position to the last point of the drawn sl@0: line(s). sl@0: sl@0: The internal drawing position is set to the co-ordinate origin if no drawing sl@0: or moving operations have yet taken place. sl@0: sl@0: @param aVector The amount by which the internal drawing position is to move. */ sl@0: virtual void MoveBy(const TPoint& aVector)=0; sl@0: sl@0: /** Draws a single point. The point is drawn with the current pen settings sl@0: using the current drawing mode. sl@0: sl@0: Note: sl@0: sl@0: If the pen size is greater than one pixel, a filled circle of the current sl@0: pen colour is drawn, with the pen size as the diameter and the plotted point sl@0: as the centre. If the pen size is an even number of pixels, the extra pixels sl@0: are drawn below and to the right of the centre. sl@0: sl@0: @param aPoint The point to be drawn. sl@0: @see SetPenSize() */ sl@0: virtual void Plot(const TPoint& aPoint)=0; sl@0: sl@0: /** Draws an arc. sl@0: sl@0: The arc is considered a portion of an ellipse. The ellipse is defined by the sl@0: TRect argument. sl@0: sl@0: The pixels at both the start point and the end point are drawn. sl@0: sl@0: The arc itself is the segment of the ellipse drawn in an anti-clockwise sl@0: direction from the start point to the end point. sl@0: sl@0: Notes: sl@0: sl@0: A rectangle is used in the construction of the ellipse of which the arc is sl@0: a segment. This rectangle is passed as an argument of type TRect. sl@0: sl@0: A wide line arc is drawn with the pixels distributed either side of a true sl@0: ellipse, in such a way that the outer edge of the line would touch the edge sl@0: of the construction rectangle. In other words, the ellipse used to sl@0: construct it is slightly smaller than that for a single pixel line size. sl@0: sl@0: If the specified start or end point is at the centre of the ellipse, then sl@0: the line that defines the start or end of the arc defaults to one extending sl@0: vertically above the centre point. sl@0: sl@0: If the start and end point are the same point or are points on the same line sl@0: through the ellipse centre then a complete unfilled ellipse is drawn. sl@0: sl@0: @param aRect A rectangle in which to draw the ellipse, of which the arc is sl@0: a segment. sl@0: @param aStart The point defining the start of the arc. It defines one end of sl@0: a line from the geometric centre of the ellipse. The point of intersection sl@0: between this line and the ellipse defines the start point of the arc. sl@0: @param aEnd The point defining the end of the arc. It defines one end of a sl@0: second line from the geometric centre of the ellipse. The point of sl@0: intersection between this line and the ellipse defines the end point of the sl@0: arc. sl@0: @see DrawEllipse() */ sl@0: virtual void DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0; sl@0: sl@0: /** Draws a straight line between two points. sl@0: sl@0: @param aPoint1 The point at the start of the line. sl@0: @param aPoint2 The point at the end of the line. */ sl@0: virtual void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)=0; sl@0: sl@0: /** Draws a straight line from the current drawing point to a specified sl@0: point. sl@0: sl@0: @param aPoint The point at the end of the line. sl@0: @see MoveTo() sl@0: @see MoveBy() */ sl@0: virtual void DrawLineTo(const TPoint& aPoint)=0; sl@0: sl@0: /** Draws a straight line relative to the current drawing point, using a sl@0: vector. sl@0: sl@0: The start point of the line is the current drawing point. The specified sl@0: vector sl@0: is added to the drawing point to give the end point of the line sl@0: sl@0: @param aVector The vector to add to the current internal drawing position, sl@0: giving the end point of the line. sl@0: @see MoveTo() sl@0: @see MoveBy() */ sl@0: virtual void DrawLineBy(const TPoint& aVector)=0; sl@0: sl@0: /** Draws a polyline from a set of points in an array. sl@0: sl@0: A polyline is a series of concatenated straight lines joining a set of sl@0: points. sl@0: sl@0: @param aPointList An array containing the points on the polyline. */ sl@0: virtual void DrawPolyLine(const CArrayFix* aPointList)=0; sl@0: sl@0: /** Draws a polyline from a set of points in a list. sl@0: sl@0: A polyline is a series of concatenated straight lines joining a set of sl@0: points. sl@0: sl@0: @param aPointList Pointer to a set of points on the polyline. sl@0: @param aNumPoints Number of points in the list. */ sl@0: virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)=0; sl@0: sl@0: /** Draws and fills a pie slice. sl@0: sl@0: The pie slice is an area bounded by: sl@0: sl@0: the arc of an ellipse drawn in an anticlockwise direction from the start sl@0: point to the end point sl@0: sl@0: the straight line drawn to the start point from the geometric centre of the sl@0: ellipse. sl@0: sl@0: the straight line to the end point from the geometric centre of the ellipse. sl@0: sl@0: Notes: sl@0: sl@0: A rectangle is used in the construction of the pie slice. This rectangle is sl@0: passed as an argument of type TRect. The curved edge of the pie slice is an sl@0: arc of an ellipse constructed within the rectangle. sl@0: sl@0: The line drawn by the pen goes inside the specified rectangle. sl@0: sl@0: The pixels at the end point of the arc are not drawn. sl@0: sl@0: A wide line edged pie slice has the arc drawn with the pixels distributed sl@0: either side of a true ellipse. This is done in such a way that the outer sl@0: edge of the line touches the edge of the construction rectangle. In other sl@0: words, the ellipse used to construct it is slightly smaller than that for sl@0: a single pixel line size. sl@0: sl@0: If the specified start or end point is at the centre of the ellipse, then sl@0: the line that defines the start or end of the arc defaults to one extending sl@0: vertically above the centre point. sl@0: sl@0: If the start and end point are the same point or are points on the same line sl@0: through the ellipse centre then a complete filled ellipse is drawn. A line sl@0: is also drawn from the edge to the ellipse centre. sl@0: sl@0: @param aRect A rectangle in which to draw the ellipse bounding the pie slice. sl@0: @param aStart A point defining the start of the arc bounding the pie slice. sl@0: It defines one end of a line from the geometrical centre of the ellipse. The sl@0: point of intersection between this line and the ellipse defines the start sl@0: point of the arc. sl@0: @param aEnd A point to define the end of the arc bounding the pie slice. It sl@0: defines one end of a second line from the geometrical centre of the ellipse. sl@0: The point of intersection between this line and the ellipse defines the end sl@0: point of the arc. */ sl@0: virtual void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)=0; sl@0: sl@0: /** Draws and fills an ellipse. sl@0: sl@0: The ellipse is drawn inside the rectangle defined by the TRect argument. Any sl@0: rectangle that has odd pixel dimensions, has the bottom right corner trimmed sl@0: to give even pixel dimensions before the ellipse is constructed. sl@0: sl@0: Note: sl@0: sl@0: A wide outline ellipse is drawn with the pixels distributed either side of sl@0: a true ellipse, in such a way that the outer edge of the line touches the sl@0: edge of the construction rectangle. In other words, the ellipse used to sl@0: construct it is smaller than that for a single pixel line size. sl@0: sl@0: @param aRect The rectangle in which the ellipse is drawn. */ sl@0: virtual void DrawEllipse(const TRect& aRect)=0; sl@0: sl@0: /** Draws and fills a rectangle. sl@0: sl@0: @param aRect The rectangle to be drawn. */ sl@0: virtual void DrawRect(const TRect& aRect)=0; sl@0: sl@0: /** Draws and fills a rectangle with rounded corners. sl@0: sl@0: The rounded corners are each constructed as an arc of an ellipse. sl@0: sl@0: The line drawn by the pen, if any, goes inside the specified rectangle. sl@0: sl@0: Notes: sl@0: sl@0: Dotted and dashed pen styles cannot be used for the outline of a rounded sl@0: rectangle. sl@0: sl@0: If either corner size dimension is greater than half the corresponding sl@0: rectangle length, the corner size dimension is reduced to half the sl@0: rectangle size. sl@0: sl@0: @param aRect The rectangle to be drawn. sl@0: @param aCornerSize The dimensions of each corner. sl@0: @see DrawArc() */ sl@0: virtual void DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)=0; sl@0: sl@0: /** Draws and fills a polygon defined using an array of points. sl@0: sl@0: The first point in the array defines the start of the first side of the sl@0: polygon. The second point defines the second vertex (the end point of the sl@0: first side and the start point of the second side). sl@0: sl@0: The final side of the polygon is drawn using the last point from the array, sl@0: and the line is drawn to the start point of the first side. sl@0: sl@0: Self-crossing polygons are filled according to the specified fill rule. sl@0: sl@0: @param aPointList An array of points, specifying the vertices of the polygon. sl@0: @param aFillRule The fill rule. By default, this is TFillRule::EAlternate. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide error sl@0: codes. */ sl@0: virtual TInt DrawPolygon(const CArrayFix* aPointList,TFillRule aFillRule=EAlternate)=0; sl@0: sl@0: /** Draws and fills a polygon defined using a list of points. sl@0: sl@0: The first point in the list defines the start of the first side of the sl@0: polygon. The second point defines the second vertex (the end point of the sl@0: first side and the start point of the second side). sl@0: sl@0: The final side of the polygon is drawn using the last point from the list, sl@0: and the line is drawn to the start point of the first side. sl@0: sl@0: Self-crossing polygons are filled according to the specified fill rule. sl@0: sl@0: @param aPointList Pointer to list of points, specifying the vertices of the sl@0: polygon. sl@0: @param aNumPoints The number of points in the list. sl@0: @param aFillRule The fill rule. By default this is TFillRule::EAlternate. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide error sl@0: codes. */ sl@0: virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate)=0; sl@0: sl@0: /** Draws a bitmap at the specified point. sl@0: sl@0: The point specifies the top left hand corner of the bitmap. The bitmap is sl@0: compressed or stretched based on its internally stored size in twips. sl@0: sl@0: Notes: sl@0: sl@0: This member function uses the bitmap's size in twips and does a sl@0: stretch/compress blit using a linear DDA. sl@0: sl@0: As this function scales the bitmap, it is unavoidably slow. Therefore, where sl@0: possible, use CBitmapContext::BitBlt() instead. If the bitmap has to be sl@0: scaled, consider creating another bitmap along with an CFbsBitmapDevice etc, sl@0: doing DrawBitmap() once and using BitBlt() subsequently. sl@0: sl@0: Note that all bitmaps are clipped to the device boundaries. sl@0: sl@0: @param aTopLeft The point where the top left pixel of the bitmap is to be sl@0: drawn sl@0: @param aSource A source bitmap sl@0: @see TLinearDDA */ sl@0: virtual void DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource)=0; sl@0: sl@0: /** Draws a bitmap to fit a given rectangle. sl@0: sl@0: The bitmap is compressed or stretched based on its internally stored size sl@0: in pixels. sl@0: sl@0: Notes: sl@0: sl@0: This member function uses the bitmap's size in pixels and does a sl@0: stretch/compress blit using a linear DDA. sl@0: sl@0: As this function scales the bitmap, it is unavoidably slow. Therefore, sl@0: where possible, use CBitmapContext::BitBlt() instead. If the bitmap has sl@0: to be scaled, consider creating another bitmap along with an sl@0: CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt() sl@0: subsequently. sl@0: sl@0: Note that all bitmaps are clipped to the device boundaries. sl@0: sl@0: @param aDestRect The rectangle within which the bitmap is to be drawn. sl@0: @param aSource A source bitmap. sl@0: @see TLinearDDA */ sl@0: virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)=0; sl@0: sl@0: /** Draws a specified rectangle of a source bitmap to fit into a given sl@0: destination rectangle. sl@0: sl@0: Notes: sl@0: sl@0: This member function uses rectangle sizes in pixels and does a sl@0: stretch/compress blit using a linear DDA. sl@0: sl@0: As this function scales the bitmap, it is unavoidably slow. Therefore, sl@0: where possible, use CBitmapContext::BitBlt() instead. If the bitmap has sl@0: to be scaled, consider creating another bitmap along with an sl@0: CFbsBitmapDevice etc., doing DrawBitmap() once and using BitBlt() sl@0: subsequently. sl@0: sl@0: Note that all bitmaps are clipped to the device boundaries. sl@0: sl@0: @param aDestRect The rectangle within which the bitmap is to be drawn. sl@0: @param aSource A source bitmap. sl@0: @param aSourceRect The rectangle in the source bitmap that is copied to the sl@0: destination rectangle. sl@0: @see TLinearDDA */ sl@0: virtual void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect)=0; sl@0: sl@0: /** Draws a specified rectangle of a source bitmap to fit into a given rectangle using a given mask. sl@0: sl@0: Notes: sl@0: sl@0: This member function uses rectangle sizes in pixels and does a sl@0: stretch/compress blit using a linear DDA. sl@0: sl@0: sl@0: @param aDestRect The rectangle within which the bitmap is to be drawn. sl@0: @param aBitmap The source bitmap sl@0: @param aSourceRect The rectangle in the source bitmap that is to be drawn sl@0: @param aMaskBitmap The mask to be applied to the source bitmap while drawing sl@0: @param aInvertMask Flag to indicate if the mask should be inverted. sl@0: */ sl@0: virtual void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0; sl@0: sl@0: /** Draws a specified rectangle from a wserv bitmap and its mask into sl@0: another rectangle. sl@0: sl@0: The function compresses/stretches the specified rectangle from the bitmap sl@0: to fit the destination rectangle. sl@0: The mask bitmap can be used as either a positive or negative mask. Masked sl@0: pixels are not mapped to the destination rectangle. sl@0: sl@0: A black and white (binary) mask bitmap is used. With aInvertMask=EFalse, black sl@0: pixels in the mask bitmap stop corresponding pixels in the source bitmap from sl@0: being transferred to the destination rectangle. With aInvertMask=ETrue, white sl@0: pixels in the mask bitmap stop corresponding pixels in the source bitmap from sl@0: being transferred to the destination rectangle. sl@0: sl@0: Note: this member function uses rectangle sizes in pixels and does a stretch/compress sl@0: blit using a linear DDA. sl@0: sl@0: @param aDestRect The rectangle within which the masked bitmap is to be drawn. sl@0: @param aBitmap A source wserv bitmap. sl@0: @param aSourceRect The rectangle in the source bitmap that is copied to the sl@0: destination rectangle. sl@0: @param aMaskBitmap A mask wserv bitmap. sl@0: @param aInvertMask If false, a source pixel that is masked by a black pixel sl@0: is not transferred to the destination rectangle. If true, then a source pixel sl@0: that is masked by a white pixel is not transferred to the destination rectangle. */ sl@0: virtual void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask)=0; sl@0: sl@0: /** Draws text without a surrounding box. sl@0: sl@0: The text baseline is aligned with the y co-ordinate of the specified point, sl@0: and the left end of the text is aligned with the x co-ordinate of the sl@0: specified point. sl@0: sl@0: Note: sl@0: sl@0: Text drawing is done with the pen, and is subject to the pen colour. The sl@0: effective text colour also depends on the drawing mode. The size and style sl@0: of the text depends on the font used. The layout of the text depends on the sl@0: justification mode set. sl@0: sl@0: @param aText The text string to be drawn. sl@0: @param aPosition A point specifying the position of the left end of the text. */ sl@0: virtual void DrawText(const TDesC& aText,const TPoint& aPosition) = 0; sl@0: sl@0: /** Draws text inside a box. sl@0: sl@0: The surrounding box is filled with the current brush colour (not a pattern) sl@0: and is drawn without any outline. The effective box colour depends on the sl@0: drawing mode - if a brush colour has not been set then the brush defaults sl@0: to white. The brush may be set to TBrushStyle::ENullBrush if text sl@0: positioning relative to a box is required, but the box should not be filled. sl@0: sl@0: The font used is that set by UseFont(). If no font is in use then a panic sl@0: occurs. sl@0: sl@0: The alignment of the text within the box can be specified. sl@0: sl@0: Text drawn within a box is also clipped to that box. Unless you intend to sl@0: clip the top off the text, aBaselineOffset should be greater than or equal sl@0: to the ascent of the current font. sl@0: sl@0: Offsets: sl@0: sl@0: If the offset is negative, zero, or less than font height this is handled sl@0: as would be expected, i.e. no text will be seen in the box in the first two sl@0: instances, and the top of the text will be clipped in the latter case. sl@0: sl@0: Margins: sl@0: sl@0: For the drawing of right-aligned text, aLeftMargin indicates the margin from sl@0: the right of aBox - where a positive value results in a leftwards offset. sl@0: sl@0: Negative margins can be used to display portions of the text string clipped sl@0: by the box. A negative margin for left aligned text would clip the start of sl@0: the text string. Similarly, a negative margin for right aligned text would sl@0: clip the end of the text string. sl@0: sl@0: If the margin is greater than the width of the box then no text will be sl@0: visible. sl@0: sl@0: The margin is still honoured for centred text - centred text will not be sl@0: centred in the box, unless the margin is zero. sl@0: sl@0: Note: sl@0: sl@0: Text drawing is done with the pen, and is thus subject to the pen colour. sl@0: The effective text colour also depends on the drawing mode. The size and sl@0: style of the text depends on the used font. The layout of the text depends sl@0: on the justification mode set. sl@0: sl@0: @param aText The text string to be drawn. sl@0: @param aBox The box to draw the text in. sl@0: @param aBaselineOffset An offset from the top of the box to the text sl@0: baseline. sl@0: @param aAlignment The text alignment mode default is left aligned. sl@0: @param aLeftMargin The left margin for left-aligned text, or the right sl@0: margin sl@0: for right-aligned text default is zero. */ sl@0: virtual void DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TTextAlign aAlignment = ELeft, sl@0: TInt aLeftMargin = 0) = 0; sl@0: IMPORT_C virtual void DrawText(const TDesC& aText,const TPoint& aPosition,const TDrawTextParam& aParam); sl@0: IMPORT_C virtual void Reserved(); sl@0: IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TPoint& aPosition,const TDrawTextExtendedParam& aParam); sl@0: sl@0: /** Maps pixels in the specified rectangle. sl@0: The function tries to match the colour of a pixel with one of the RGB values sl@0: in an array of RGB pairs. If there is a match, the colour is changed to the sl@0: value specified in the other RGB in the RGB pair. sl@0: @param aRect The rectangle in which pixels are to be mapped. sl@0: @param aColors A pointer to a set of RGB pairs. sl@0: @param aNumPairs The number of pairs sl@0: @param aMapForwards ETrue, mapping is done from the first RGB to the second sl@0: RGB in the pair; EFalse, mapping is done from the second RGB to the first sl@0: RGB in the pair. */ sl@0: virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards) = 0; sl@0: sl@0: /** Sets the clipping region, any items that fall outside the extent of the clipping sl@0: region will not be drawn. sl@0: sl@0: Note that clipping is additive. If a clipping rectangle has been set using SetClippingRect() sl@0: then clipping will be to the intersection of that rectangle and this region. sl@0: sl@0: @param aRegion The new clipping region. Note that clipping region co-ordinates are sl@0: used as absolute co-ordinates, they are not transformed by the current co-ordinate sl@0: origin before use (as occurs in SetClippingRect()). sl@0: sl@0: @return KErrNone if successful; KErrArgument if the TRegion is not valid; KErrNoMemory if there is insufficient memory. sl@0: sl@0: @see CGraphicsContext::CancelClippingRegion() sl@0: @see CGraphicsContext::SetClippingRect() */ sl@0: virtual TInt SetClippingRegion(const TRegion &aRegion) = 0; sl@0: sl@0: /** Cancels the current clipping region. sl@0: @see CGraphicsContext::SetClippingRegion()*/ sl@0: virtual void CancelClippingRegion() = 0; sl@0: sl@0: /** Draws vertical text in the specified direction. sl@0: @param aText The text to be drawn. sl@0: @param aPos Point of origin of the text baseline. sl@0: @param aUp Direction. ETrue for up, EFalse for down. */ sl@0: virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp) = 0; sl@0: sl@0: /** Draws text vertically in the specified direction, within a box of the specified size. sl@0: @param aText The text to be drawn. sl@0: @param aBox The bounding box within which the text should be drawn, and which it is clipped to. sl@0: @param aBaselineOffset The height of the top of the characters from their text baseline. sl@0: @param aUp The direction. ETrue for up, EFalse for down. sl@0: @param aVert The text alignment. sl@0: @param aMargin The margin. */ sl@0: virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0) = 0; sl@0: sl@0: IMPORT_C TInt GetUnderlineMetrics(TInt& aTop,TInt& aBottom); sl@0: sl@0: /** Set the font's shadow colour sl@0: @param aShadowColor Shadow colour to be set. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide errors. */ sl@0: IMPORT_C TInt SetShadowColor(const TRgb& aShadowColor); sl@0: sl@0: /** Get the font's shadow colour sl@0: @param aShadowColor Shadow colour of the font returned by the funtion. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide errors. */ sl@0: IMPORT_C TInt GetShadowColor(TRgb& aShadowColor); sl@0: sl@0: /** Determine if the Gc is a CFbsBitGc sl@0: @return ETrue, if the Gc is a CFbsBitGc, EFalse otherwise sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: */ sl@0: IMPORT_C TBool IsFbsBitGc() const; sl@0: sl@0: IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition); sl@0: IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0); sl@0: IMPORT_C void DrawText(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextParam& aParam); sl@0: sl@0: IMPORT_C void DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPos,TBool aUp); sl@0: IMPORT_C void DrawTextVertical(const TDesC& aText,const TTextParameters* iParam,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); sl@0: sl@0: IMPORT_C TInt DrawTextExtended(const TDesC& aText,const TTextParameters* iParam,const TPoint& aPosition,const TDrawTextExtendedParam& aParam); sl@0: sl@0: protected: sl@0: sl@0: /** sl@0: An APIExtension method to allow the addition of new APIs to retain compatibility sl@0: with previous versions of gdi.dll sl@0: @param aOutput is for output sl@0: @param aInput is for input sl@0: @see CGraphicsContext sl@0: @publishedAll sl@0: WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: */ sl@0: IMPORT_C virtual TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput); sl@0: sl@0: /** sl@0: A reserved virtual function for future use. sl@0: */ sl@0: IMPORT_C virtual void Reserved_CGraphicsContext_2(); sl@0: }; sl@0: sl@0: sl@0: /** An abstract, device-independent, interface to bitmapped graphics contexts. sl@0: sl@0: This holds the setting used to draw to a CBitmapDevice. sl@0: sl@0: The default settings of a CBitmapContext object immediately after construction sl@0: are: sl@0: sl@0: drawing mode is EDrawModePen (pen and brush colours used as they are) sl@0: sl@0: no clipping rectangle sl@0: sl@0: pen settings are: black, solid, single pixel width sl@0: sl@0: brush style is null sl@0: sl@0: no text font selected sl@0: sl@0: The classes CFbsBitGc and CWindowGc are derived from this class. sl@0: sl@0: @see CFbsBitGc sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CBitmapContext : public CGraphicsContext sl@0: { sl@0: public: sl@0: /** Clears the whole bitmap. sl@0: sl@0: The cleared area is filled with the current brush colour. sl@0: sl@0: This pure virtual function is implemented in derived classes. */ sl@0: virtual void Clear()=0; sl@0: sl@0: /** Clears a rectangular area of a bitmap. sl@0: sl@0: The cleared area is filled with the current brush colour. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aRect The rectangle to clear. */ sl@0: virtual void Clear(const TRect& aRect)=0; sl@0: sl@0: /** Copies a rectangle. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aOffset The offset from the top left corner of the rectangle to be sl@0: copied to the top left corner of the copy. sl@0: @param aRect The rectangular area to be copied. */ sl@0: virtual void CopyRect(const TPoint& aOffset,const TRect& aRect)=0; sl@0: sl@0: /** Performs a bitmap block transfer. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aPoint The destination for the top left corner of the transferred bitmap. sl@0: It is relative to the top left corner of the destination bitmap, which may be the screen. sl@0: @param aBitmap A memory-resident bitmap. */ sl@0: virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap)=0; sl@0: sl@0: /** Performs a bitmap block transfer of a rectangular piece of a bitmap. sl@0: sl@0: If the specified rectangle is larger than the bitmap then the bitmap is sl@0: padded with white. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aPoint The destination for the top left corner of the transferred bitmap. sl@0: It is relative to the top left corner of the destination bitmap, which may be the screen. sl@0: sl@0: @param aBitmap A memory-resident bitmap sl@0: @param aRect A rectangle defining the portion of the bitmap to transfer. sl@0: Its coordinates are relative to the top left corner of the source bitmap. */ sl@0: virtual void BitBlt(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aRect)=0; sl@0: sl@0: /** Performs a masked bitmap block transfer. sl@0: sl@0: The mask bitmap can be used as either a positive or negative mask. Masked sl@0: pixels are not mapped to the destination rectangle. sl@0: sl@0: This function uses either a black and white (binary) mask bitmap, or if sl@0: aMaskBitmap's display mode is EGray256, alpha blending is used. Use of sl@0: any other mode may result in unpredictable results sl@0: sl@0: With aInvertMask=EFalse, black pixels in the mask bitmap stop corresponding sl@0: pixels in the source bitmap from being transferred to the destination rectangle. sl@0: With aInvertMask=ETrue, white pixels in the mask bitmap stop corresponding sl@0: pixels in the source bitmap from being transferred to the destination sl@0: rectangle. sl@0: sl@0: Note that if the mask bitmap is smaller than the source bitmap, then it is sl@0: tiled across the bitmap. Note that the mask is applied before the piece of sl@0: the bitmap is defined - the mask is tiled relative to the top left of the sl@0: original source bitmap rather than the top left of the bitmap piece. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aPoint The destination for the top left corner of the transferred bitmap. sl@0: It is relative to the top left corner of the destination bitmap, which may be the screen. sl@0: @param aBitmap A memory-resident source bitmap. sl@0: @param aSourceRect A rectangle defining the piece of the bitmap to be drawn, sl@0: with co-ordinates relative to the top left corner of the bitmap. sl@0: @param aMaskBitmap A mask bitmap sl@0: @param aInvertMask If EFalse, a source pixel that is masked by a black pixel sl@0: is not transferred to the destination rectangle. If ETrue, then a source sl@0: pixel that is masked by a white pixel is not transferred to the destination sl@0: rectangle. */ sl@0: virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask)=0; sl@0: sl@0: /** Sets whether the graphics context is faded. sl@0: sl@0: @param aFaded ETrue to fade the GC; EFalse to unfade it. */ sl@0: virtual void SetFaded(TBool aFaded)=0; sl@0: sl@0: /** Sets the fading parameters. sl@0: sl@0: This function allows you to override the map used when drawing with a faded sl@0: graphics context (GC). However if you draw to a faded window with a faded sl@0: GC, then fading on the GC is ignored and the fading of the window is used. sl@0: sl@0: Fading is used to change the colour of a window to make other windows stand sl@0: out. Fading can either make a faded window closer to white or closer to sl@0: black. sl@0: sl@0: Fading re-maps colours in the faded GC to fall between the specified black sl@0: and white map values. If aBlackMap=0 and aWhiteMap=255 then the colours are sl@0: mapped unchanged. As the values converge the colours are mapped to a smaller sl@0: range - so the differences between colours in the faded GC decrease. If sl@0: the values are reversed then the colours are inverted (i.e. where the GC sl@0: would be black, it is now white). sl@0: sl@0: @param aBlackMap Black map fading parameter. Unfaded this is 0. sl@0: @param aWhiteMap White map fading parameter. Unfaded this is 255. */ sl@0: virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)=0; sl@0: sl@0: /** sl@0: Performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using sl@0: the data from aAlphaBmp as an alpha blending factor. sl@0: The formula used is: sl@0: (S * A + W * (255 - A)) / 255, where: sl@0: - S - a pixel from aSrcBmp; sl@0: - W - a pixel from the window; sl@0: - A - a pixel from aAlphaBmp; sl@0: The contents of source and alpha bitmap are preserved. sl@0: The calculated alpha blended pixels are written to the destination CBitmapContext. sl@0: @param aDestPt Position in the target the result should be drawn to. sl@0: @param aSrcBmp A pointer to the source bitmap. sl@0: @param aSrcRect The part of the source bitmap that should be used. sl@0: @param aAlphaBmp A pointer to the bitmap used as an alpha blending factor. sl@0: @param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source sl@0: for the alpha blending. The size of the area is the same as the sl@0: source bitmap area - aSrcRect parameter.*/ sl@0: sl@0: virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0; sl@0: sl@0: /** sl@0: The method performs an alpha blending of the source data, aSrcBmp, with the CBitmapContext, using sl@0: the data from aAlphaBmp as an alpha blending factor. sl@0: For information on how this function works, see the other overload. sl@0: @param aDestPt Position in the target the result should be drawn to. sl@0: @param aSrcBmp A pointer to the source bitmap. sl@0: @param aSrcRect The part of the source bitmap that should be used. sl@0: @param aAlphaBmp A pointer to the bitmap used as an alpha blending factor. sl@0: @param aAlphaPt Position of the first pixel in the alpha bitmap that should be used as a source sl@0: for the alpha blending. The size of the area is the same as the sl@0: source bitmap area - aSrcRect parameter.*/ sl@0: virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt) = 0; sl@0: sl@0: protected: sl@0: sl@0: /* sl@0: Implementations from CGraphicsContext sl@0: @see CGraphicsContext::APIExtension(TUid, TAny*&, TAny*) sl@0: */ sl@0: IMPORT_C TInt APIExtension(TUid aUid, TAny*& aOutput, TAny* aInput); sl@0: /* sl@0: Implementations from CGraphicsContext sl@0: @see CGraphicsContext::Reserved_CGraphicsContext_2() sl@0: */ sl@0: IMPORT_C void Reserved_CGraphicsContext_2(); sl@0: sl@0: IMPORT_C virtual void Reserved_CBitmapContext_1(); sl@0: IMPORT_C virtual void Reserved_CBitmapContext_2(); sl@0: IMPORT_C virtual void Reserved_CBitmapContext_3(); sl@0: }; sl@0: sl@0: /** Defines an abstract interface for the capabilities and attributes of a sl@0: bitmapped graphics device. sl@0: sl@0: The class specialises the graphics device interface CGraphicsDevice for bitmaps sl@0: graphics. The Window Server Client-Side API provides one implementation of sl@0: the interface, CWsScreenDevice, for screen drawing. Another implementation, sl@0: CFbsBitmapDevice, is used for drawing to in-memory bitmaps. A third, sl@0: CFbsScreenDevice, is used (rarely) to access the screen directly, without the sl@0: mediation of the window server. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CBitmapDevice : public CGraphicsDevice sl@0: { sl@0: public: sl@0: /** Gets the RGB colour of an individual pixel on a bitmapped graphics sl@0: device. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aColor On return, should contain the RGB colour of the pixel. sl@0: @param aPixel The (x,y) co-ordinates of the pixel. The top left pixel is sl@0: (0,0). */ sl@0: virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const=0; sl@0: sl@0: /** Copies a scanline into a buffer. sl@0: sl@0: The pixels are converted from the display mode format on the bitmapped sl@0: graphics device to the format of the specified device display mode. sl@0: sl@0: By specifying the start pixel and the number of pixels, either the whole or sl@0: a portion of a bitmapped graphics device pixel row may be copied. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aBuf An 8 bit modifiable descriptor buffer into which pixels are sl@0: copied; it must be sufficiently large to store all the scanline pixels. sl@0: @param aStartPixel The (x,y) co-ordinates of the first pixel of the bitmap sl@0: scanline to be put into the buffer. sl@0: @param aLength The number of pixels to put into the buffer. sl@0: @param aDispMode The display mode into which to convert the pixels. */ sl@0: virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const=0; sl@0: sl@0: /** Adds a font file to the device's typeface store. The specified font sl@0: file must be accessible to any process, i.e. not located inside an sl@0: application's private directory. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aName The name of the font file. sl@0: @param aId On return, contains an ID for the font file. sl@0: @return KErrNone, if successful; otherwise, another of the system-wide error sl@0: codes. */ sl@0: virtual TInt AddFile(const TDesC& aName,TInt& aId)=0; sl@0: sl@0: /** Removes a font file from the font store. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aId The ID of the font file to be removed. The default is 0. */ sl@0: virtual void RemoveFile(TInt aId=0)=0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: Note that this deprecated function is replaced by the new @c GetNearestFontToDesignHeightInPixels() sl@0: yielding (virtually) the same result. However clients are strongly encouraged to use the new sl@0: @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every sl@0: character within any given text string will fit within the given amount of pixels, whereas the design sl@0: height is an aesthetic unit decided by the font designer without strict physical meaning, which sl@0: may result in cropped characters. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @deprecated Use GetNearestFontToDesignHeightInPixels sl@0: */ sl@0: virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec) = 0; sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: This new function replaces the deprecated @c GetNearestFontInPixels() yielding (virtually) the sl@0: same result. However clients are strongly encouraged to use the new sl@0: @c GetNearestFontToMaxHeightInPixels() function instead. This will guarantee that every sl@0: character within any given text string will fit within the given amount of pixels, whereas the design sl@0: height is an aesthetic unit decided by the font designer without strict physical meaning, which sl@0: may result in cropped characters. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: virtual TInt GetNearestFontToDesignHeightInPixels( sl@0: CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/) { return KErrNotSupported; } sl@0: sl@0: /** sl@0: Gets the font which is the nearest to the given font specification. sl@0: sl@0: When the font is no longer needed, call @c ReleaseFont(). sl@0: sl@0: The font and bitmap server returns a pointer to the nearest matching font sl@0: from those available. Matches to max height of font - this does its best sl@0: to return a font that will fit within the maximum height specified (but sl@0: note that variations due to hinting algorithms may rarely result in this sl@0: height being exceeded by up to one pixel). Problems can also be sl@0: encountered with bitmap fonts where the typeface exists but doesn't have sl@0: a font small enough. sl@0: sl@0: @param aFont On return, contains a pointer to the nearest font. sl@0: @param aFontSpec The specification of the font to be matched. sl@0: @param aMaxHeight The maximum height within which the font must fit. sl@0: This overrides the height specified in aFontSpec. sl@0: @return KErrNone if successful; a system-wide error code otherwise. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: virtual TInt GetNearestFontToMaxHeightInPixels( sl@0: CFont*& /*aFont*/, const TFontSpec& /*aFontSpec*/, TInt /*aMaxHeight*/) { return KErrNotSupported; } sl@0: sl@0: /** Gets the height, in pixels, of the specified typeface at one of its sl@0: defined heights. sl@0: sl@0: The typeface is identified by by an index. For a given typeface, there are sl@0: a discrete number of heights; the specific height is also identified by an sl@0: index. sl@0: sl@0: The value returned is rounded up or down to the nearest font height in sl@0: pixels. sl@0: sl@0: This pure virtual function is implemented in derived classes. sl@0: sl@0: @param aTypefaceIndex A typeface index number, in the range: 0 to sl@0: (NumTypefaces() - 1). sl@0: @param aHeightIndex A font height index number, in the range: 0 to sl@0: (iNumHeights - 1) where iNumHeights is a public data member of the sl@0: TTypefaceSupport object returned by TypefaceSupport(). sl@0: @return The height of the font, in pixels. sl@0: @see TTypefaceSupport sl@0: @see CGraphicsDevice::NumTypefaces() sl@0: @see CGraphicsDevice::TypefaceSupport() */ sl@0: virtual TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const=0; sl@0: inline TInt CreateBitmapContext(CBitmapContext*& aGC); sl@0: }; sl@0: sl@0: /** A set of margins used for cropping a picture. sl@0: sl@0: Margins are specified in twips or pixels. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TMargins sl@0: { sl@0: public: sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C TBool operator==(const TMargins& aMargins) const; sl@0: IMPORT_C TBool operator!=(const TMargins& aMargins) const; sl@0: public: sl@0: /** Left margin, (in twips or pixels). */ sl@0: TInt iLeft; sl@0: /** Right margin, (in twips or pixels). */ sl@0: TInt iRight; sl@0: /** Top margin, (in twips or pixels). */ sl@0: TInt iTop; sl@0: /** Bottom margin, (in twips or pixels). */ sl@0: TInt iBottom; sl@0: }; sl@0: sl@0: /** Picture capabilities. sl@0: sl@0: These include the types of scaling that can be applied to a picture, and whether sl@0: or not it is croppable. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TPictureCapability sl@0: { sl@0: public: sl@0: /** Scaling types. */ sl@0: enum TScalingType sl@0: { sl@0: /** The picture is not scalable. */ sl@0: ENotScaleable, sl@0: /** The picture is fully scalable. */ sl@0: EFullyScaleable, sl@0: /** The picture is scalable to any size, as long as its aspect ratio sl@0: (the ratio of its height to its width) remains constant. */ sl@0: EScaleableMaintainingAspectRatio sl@0: }; sl@0: public: sl@0: inline TPictureCapability(TScalingType aScalingType,TBool aCroppable); sl@0: public: sl@0: /** Whether or not the picture is croppable. */ sl@0: TScalingType iScalingType; sl@0: /** Scaling type. */ sl@0: TBool iIsCroppable; sl@0: }; sl@0: sl@0: /** Abstract base class for: drawing a picture to a graphics context, storing sl@0: and restoring the picture. sl@0: sl@0: The class defines the protocol for a number of concrete picture classes. Its sl@0: main role is to support glass doors used in object embedding. sl@0: sl@0: The class provides a protocol for the provision of scaling and cropping sl@0: functions by derived classes, together with default implementations. sl@0: sl@0: Its main function is Draw(), which draws the picture onto the graphics context sl@0: at a particular point. It also has two important pure virtual functions: sl@0: ExternalizeL() and GetOriginalSizeInTwips(). sl@0: sl@0: A picture has both an original representation and an on-screen representation. sl@0: The original representation has a size in twips, and can somehow be drawn. sl@0: The on-screen representation is assumed to be drawn under the control of an sl@0: application which may wish to re-size or scale the original in some way, to sl@0: crop it at the edges, and/or to ensure it fits within a particular defined sl@0: area on the screen. sl@0: sl@0: The class provides several functions that allow an application to set scaling sl@0: and cropping before invoking the Draw() function to draw the picture on-screen. sl@0: It is up to the internal workings of the function to determine the order of sl@0: application cropping and scaling. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPicture : public CBase sl@0: { sl@0: public: sl@0: /** Options for detaching pictures from stores. Used by DetachFromStoreL(). */ sl@0: enum TDetach sl@0: { sl@0: /** Internalise all data that is required to fully store the picture sl@0: later; null any references to containing stores. */ sl@0: EDetachFull, sl@0: /** Internalise enough information to draw the picture (and no more); sl@0: null any references to containing stores. */ sl@0: EDetachDraw sl@0: }; sl@0: public: sl@0: IMPORT_C virtual ~CPicture(); sl@0: /** Draws a picture. sl@0: sl@0: @param aGc The graphics context. sl@0: @param aTopLeft The co-ordinates where the top left corner pixel of the sl@0: picture should be placed. Note that whether this is actually drawn depends sl@0: on the clipping area defined. sl@0: @param aClipRect A clipping rectangle that defines the area to which the sl@0: function should draw. An implementation should never draw outside this sl@0: rectangle. Note that the graphics context may also have a clipping rectangle sl@0: set on it. sl@0: @param aMap The device map for the graphics device. The implementation sl@0: should use this to find the scaling to apply to the picture. */ sl@0: virtual void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap) const=0; sl@0: IMPORT_C virtual TStreamId StoreL(CStreamStore& aStore) const; // assumes no sub streams sl@0: virtual void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull) {} sl@0: sl@0: /** Externalises the picture to a stream. sl@0: sl@0: The presence of this function means that the standard templated stream sl@0: operator<<() is available to externalise objects of this class. sl@0: sl@0: A derived class must supply an implementation of this function. sl@0: sl@0: @param aStream The write stream. */ sl@0: virtual void ExternalizeL(RWriteStream& aStream) const =0; sl@0: sl@0: /** Gets the pictur's original size, in twips. sl@0: sl@0: @param aSize The size of the picture, in twips */ sl@0: virtual void GetOriginalSizeInTwips(TSize& aSize) const =0; sl@0: IMPORT_C virtual void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); // does nothing sl@0: IMPORT_C virtual void SetCropInTwips(const TMargins& aMargins); // does nothing sl@0: IMPORT_C virtual TPictureCapability Capability() const; // no scale, no crop sl@0: IMPORT_C virtual void GetCropInTwips(TMargins& aMargins) const; // returns no crop sl@0: IMPORT_C virtual TInt ScaleFactorWidth() const; // returns no scaling sl@0: IMPORT_C virtual TInt ScaleFactorHeight() const; // returns no scaling sl@0: IMPORT_C virtual TBool LineBreakPossible(TUint aClass,TBool aBeforePicture,TBool aHaveSpaces) const; sl@0: IMPORT_C virtual TBool NativePixelSize(TSize& aPixelSize); sl@0: sl@0: IMPORT_C void GetSizeInPixels(MGraphicsDeviceMap* aMap, TSize& aSize) const; sl@0: IMPORT_C void SetSizeInPixels(MGraphicsDeviceMap* aMap, const TSize& aSize); sl@0: IMPORT_C void AddCropInPixels(MGraphicsDeviceMap* aMap, const TMargins& aMargins); sl@0: IMPORT_C void GetSizeInTwips(TSize& aSize) const; sl@0: IMPORT_C void SetSizeInTwips(const TSize& aSize); sl@0: IMPORT_C void ResetToOriginal(); sl@0: protected: sl@0: IMPORT_C CPicture(); sl@0: }; sl@0: sl@0: sl@0: /** Picture header providing an interface to a stored picture. The header holds: sl@0: sl@0: the picture's type, encoded as a UID, which ensures that it will be restored sl@0: to the correct picture type sl@0: sl@0: the picture's size, which facilitates deferred loading sl@0: sl@0: the stream ID of the picture body, which is replaced by a pointer to the picture sl@0: object when it has been restored. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TPictureHeader sl@0: { sl@0: public: sl@0: IMPORT_C TPictureHeader(); sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C void DeletePicture(); sl@0: public: sl@0: /** A swizzle storing either the ID of the stream in which the picture is sl@0: stored, or a pointer to the internalised picture. */ sl@0: TSwizzle iPicture; sl@0: /** A UID specifying the type of the picture. */ sl@0: TUid iPictureType; sl@0: /** The original size of the picture. */ sl@0: TSize iSize; sl@0: }; sl@0: sl@0: sl@0: /** Abstract interface for instantiating and restoring new CPicture derived sl@0: objects. sl@0: sl@0: A concrete derived class creates pictures of one or more specific types. The sl@0: class has no member data and just one function, NewPictureL, that needs to sl@0: be provided by derived classes. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MPictureFactory sl@0: { sl@0: public: sl@0: /** Interface to the picture restoration process that ensures that a sl@0: picture of the correct type is restored. sl@0: sl@0: The class of the object to be restored is determined by the UID of the sl@0: stored picture, contained in the specified picture header. sl@0: sl@0: The function can allow the restoration of: sl@0: sl@0: just one CPicture-derived class, returning an error if the UID indicates sl@0: that the stored picture is not of the required type sl@0: sl@0: many different CPicture-derived classes, using the UID to choose which of sl@0: the possible CPicture-derived classes should be instantiated sl@0: sl@0: @param aHeader The picture header that should be restored. sl@0: @param aDeferredPictureStore The store in which both the header and picture sl@0: reside. */ sl@0: virtual void NewPictureL(TPictureHeader& aHeader,const CStreamStore& aDeferredPictureStore)const=0; sl@0: }; sl@0: sl@0: // printing classes sl@0: sl@0: /** sl@0: The maximum length of a printer model name. sl@0: @see TPrinterModelName sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KMaxPrinterModelNameLength=0x20; sl@0: sl@0: /** sl@0: Defines a modifiable buffer descriptor that can contain the name of a sl@0: printer model. The maximum length of the buffer is 32. sl@0: @since 5.0 sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: typedef TBuf TPrinterModelName; sl@0: sl@0: /** Page specification for a print operation. sl@0: sl@0: The page specification consists of the page orientation and the page sl@0: size in twips or pixels. By default, the page orientation is portrait. sl@0: When using landscape orientation, the left hand side of the page sl@0: becomes the top. sl@0: "gdi.lib" sl@0: @since 5.0 sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TPageSpec sl@0: { sl@0: public: sl@0: /**The available page orientations. */ sl@0: enum TPageOrientation sl@0: { sl@0: /** Portrait page orientation */ sl@0: EPortrait, sl@0: /** Landscape page orientation */ sl@0: ELandscape sl@0: }; sl@0: public: sl@0: IMPORT_C TPageSpec(); sl@0: IMPORT_C TPageSpec(TPageOrientation aOrientation,const TSize& aSize); sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: IMPORT_C TSize OrientedPageSize() const; sl@0: IMPORT_C TBool operator==(const TPageSpec& aPageSpec) const; sl@0: IMPORT_C TBool operator!=(const TPageSpec& aPageSpec) const; sl@0: public: sl@0: /** The width and height of the page in portrait orientation in twips or sl@0: pixels. sl@0: sl@0: Note that OrientedPageSize() returns the width and height in reverse order sl@0: for a landscape portrait. */ sl@0: TSize iPortraitPageSize; sl@0: /** The page orientation. */ sl@0: TPageOrientation iOrientation; sl@0: }; sl@0: sl@0: sl@0: /** Controls the attributes of the band to be printed. sl@0: sl@0: An object of this type is passed as a parameter to functions. sl@0: MPageRegionPrinter::PrintBandL() and CPrinterControl::QueueGetBand(). sl@0: @see MPageRegionPrinter::PrintBandL() sl@0: @see CPrinterControl::QueueGetBand() sl@0: @since 5.0 sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TBandAttributes sl@0: { sl@0: public: sl@0: /** The width and height of the band in twips or pixels. */ sl@0: TRect iRect; sl@0: /** ETrue to draw no text to the band; EFalse to draw text. */ sl@0: TBool iTextIsIgnored; // any text drawing to this band is ignored sl@0: /** ETrue to draw no graphics to the band; EFalse to draw graphics. */ sl@0: TBool iGraphicsIsIgnored; // any graphics drawing to this band is ignored sl@0: /** ETrue if band is the first band on the page; EFalse if not. */ sl@0: TBool iFirstBandOnPage; sl@0: }; sl@0: sl@0: /** Printer port interface. sl@0: sl@0: This interface is used as the base class for the various types of sl@0: printer port. New printer port classes should be derived from this sl@0: class.After allocation and construction, a pointer to a concrete sl@0: printer port should be passed to sl@0: CPrintSetup::StartPrintL(). sl@0: @see CPrintSetup::StartPrintL() sl@0: @since 5.0 sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPrinterPort : public CBase sl@0: { sl@0: public: sl@0: /** Writes data asynchronously to the printer port. sl@0: sl@0: @param aBuf Data to be written to the port sl@0: @param aRequestStatus A reference to the request status object. If the sl@0: request is cancelled, this should be set to KErrCancel; if the request sl@0: completes normally, this should be set to KErrNone. */ sl@0: virtual void WriteRequest(const TDesC8& aBuf,TRequestStatus& aRequestStatus)=0; sl@0: sl@0: /** Cancels an outstanding WriteRequest() operation. */ sl@0: virtual void Cancel()=0; sl@0: }; sl@0: sl@0: sl@0: /** Detailed information about a printer model. sl@0: "gdi.lib" sl@0: @since 5.0 sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TPrinterModelEntry sl@0: { sl@0: public: sl@0: /** The name of the printer model. */ sl@0: TPrinterModelName iModelName; sl@0: /** If ETrue, then a printer port is required. */ sl@0: TBool iRequiresPrinterPort; sl@0: /** The UID associated with this printer model. */ sl@0: TUid iUid; sl@0: public: sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: }; sl@0: sl@0: sl@0: /** Information about a printer model. sl@0: sl@0: An instance of this class consists of a TPrinterModelEntry and a stream ID, sl@0: and is passed to CPrinterDevice::SetModel(). sl@0: sl@0: @see CPrinterDevice sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TPrinterModelHeader sl@0: { sl@0: public: sl@0: /** The printer model. */ sl@0: TPrinterModelEntry iEntry; sl@0: /** The stream ID for model data. */ sl@0: TStreamId iModelDataStreamId; sl@0: public: sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: }; sl@0: sl@0: sl@0: /** Printer control interface. sl@0: sl@0: This abstract base class acts as the interface between a CPrinterDevice object sl@0: and the printer. It creates the context for, and controls the progress and sl@0: termination of the print job. sl@0: sl@0: Only those who need to add new printer drivers should write derived classes. sl@0: After instantiation of such a class, using CPrinterDevice::CreateControlL(), sl@0: the object can be accessed via the iControl member of CPrinterDevice. sl@0: sl@0: @see CPrinterDevice sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPrinterControl : public CBase sl@0: { sl@0: public: sl@0: /** Flags indicating whether there is more on the page to print. */ sl@0: enum TMoreOnPage sl@0: { sl@0: /** Indicates there is more to print on the current page. */ sl@0: EMoreOnPage, sl@0: /** Indicates there is no more to print on the current page. */ sl@0: ENoMoreOnPage sl@0: }; sl@0: public: sl@0: IMPORT_C ~CPrinterControl(); sl@0: sl@0: /** Gets the number of bands per page. sl@0: sl@0: @return The number of bands on each page. */ sl@0: virtual TInt BandsPerPage()=0; sl@0: sl@0: /** Prints the next band on the page. sl@0: sl@0: This is an asynchronous function. sl@0: @param aStatus Request status object. On successful completion sl@0: contains KErrNone, otherwise another of the system-wide sl@0: error codes. sl@0: @param aBand On return, indicates the attributes of the band, including sl@0: its height and width and whether or not the device will ignore one or sl@0: other of graphics or text output. This information may be used by sl@0: applications to draw more efficiently, or may be ignored sl@0: @return EMoreOnPage, if any unprinted bands remain on the sl@0: current page. ENoMoreOnPage, if the current band is last on sl@0: page. */ sl@0: virtual TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand)=0; // returns affirmative if more to print on current page sl@0: sl@0: /** Terminates the print process. sl@0: sl@0: This is an asynchronous function and is called when no more bands in sl@0: the document remain to be printed.Note that all bands have been sl@0: printed when no more pages or copies remain to be printed, and sl@0: QueueGetBand() returns ENoMoreToPrint. sl@0: sl@0: @param aStatus Request status object. On successful completion contains sl@0: KErrNone, otherwise another of the system-wide error codes. */ sl@0: virtual void QueueEndPrint(TRequestStatus& aStatus)=0; sl@0: sl@0: /** Aborts the print process before it has completed. sl@0: sl@0: This function should be called if QueueGetBand() reports an error. */ sl@0: virtual void AbortPrint()=0; // tidy up synchronously in a short time, return success code sl@0: protected: sl@0: IMPORT_C CPrinterControl(CPrinterPort* aPrinterPort); sl@0: protected: sl@0: /** State flags. */ sl@0: enum TState sl@0: { sl@0: /** Not printing. */ sl@0: ENotPrinting, sl@0: /** Printing. */ sl@0: EPrinting sl@0: }; sl@0: /** Printing state. */ sl@0: TState iState; sl@0: /** Printer port. */ sl@0: CPrinterPort* iPrinterPort; sl@0: }; sl@0: sl@0: class CDictionaryStore; sl@0: class RFs; sl@0: sl@0: /** Printer graphics device interface. sl@0: sl@0: This abstract class represents a physical graphics device that is used for sl@0: printing. sl@0: sl@0: This class is used to: sl@0: sl@0: set and get the page specification sl@0: sl@0: map between the co-ordinates of the printed page (in twips) and the co-ordinates sl@0: of the image device (in pixels) sl@0: sl@0: get and set the printer model entry sl@0: sl@0: create and delete a printer control. sl@0: sl@0: A printer driver is defined in terms of a printer device and a printer control. sl@0: A printer device can own either a single or no printer control. The control sl@0: determines the progress and termination of the print job and is responsible sl@0: for producing output. sl@0: sl@0: @see CPrinterControl sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPrinterDevice : public CGraphicsDevice sl@0: { sl@0: public: sl@0: IMPORT_C ~CPrinterDevice(); sl@0: sl@0: /** Gets the current page specification in twips. sl@0: sl@0: @return The current page specification, in twips. */ sl@0: inline TPageSpec CurrentPageSpecInTwips() const {return(iCurrentPageSpecInTwips);} sl@0: sl@0: /** Sets the page specification in twips. sl@0: sl@0: @param aPageSpec The page specification in twips. */ sl@0: IMPORT_C virtual void SelectPageSpecInTwips(const TPageSpec& aPageSpec); sl@0: IMPORT_C virtual TRect PrintablePageInPixels() const; sl@0: sl@0: /** Gets the printer model entry. sl@0: sl@0: @return The printer model entry. */ sl@0: virtual TPrinterModelEntry Model()const =0; sl@0: sl@0: /** Sets the printer model header and the store. sl@0: sl@0: @param aModel The printer model header. sl@0: @param aStore The store. sl@0: @return KErrNone if successful; otherwise, another of the system-wide sl@0: error codes.*/ sl@0: virtual TInt SetModel(const TPrinterModelHeader& aModel,CStreamStore& aStore)=0; sl@0: sl@0: /** Creates a printer control. sl@0: sl@0: The printer control is an instance of a CPrinterControl derived class; it sl@0: is assigned to this printer device's iControl member. sl@0: sl@0: Note that this function is called by CPrintSetup::StartPrintL(). sl@0: sl@0: @param aPrinterPort Pointer to an instance of a printer port. */ sl@0: virtual void CreateControlL(CPrinterPort* aPrinterPort)=0; sl@0: IMPORT_C virtual void DeleteControl(); sl@0: sl@0: /** Externalizes printer properties to the store. sl@0: sl@0: The default implementation is empty. sl@0: sl@0: @param aStream The read stream. */ sl@0: virtual void InternalizePropertiesL(RReadStream& /*aStream*/) {} sl@0: sl@0: /** Externalizes printer properties to the store. sl@0: sl@0: The default implementation is empty. sl@0: sl@0: @param aStream The write stream. */ sl@0: virtual void ExternalizePropertiesL(RWriteStream& /*aStream*/) const {} sl@0: IMPORT_C void RestorePropertiesL(); sl@0: IMPORT_C void StorePropertiesL() const; sl@0: protected: sl@0: IMPORT_C CPrinterDevice(); sl@0: public: sl@0: /** The printer control. sl@0: sl@0: This may be NULL. If implemented, it provides control over the print sl@0: operation. */ sl@0: CPrinterControl* iControl; sl@0: protected: sl@0: /** Current page specification in twips. */ sl@0: TPageSpec iCurrentPageSpecInTwips; sl@0: }; sl@0: sl@0: sl@0: /** Printer model list interface. sl@0: sl@0: Functions provided by this abstract base class can be used to extract printer sl@0: model information from the list of printer models. This class would typically sl@0: be used to implement printer selection in a dialog box. sl@0: sl@0: @see CPdrModelList sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPrinterModelList : public CBase sl@0: { sl@0: public: sl@0: /** Gets the number of printer models in the printer model list. sl@0: sl@0: @return The number of printer models. */ sl@0: virtual TInt ModelCount() const=0; sl@0: sl@0: /**Gets printer model name. sl@0: sl@0: This is the name of the printer model at the specified index within sl@0: the list of printer models. sl@0: sl@0: @param anIndex The index of the printer model within the array of sl@0: printer models. Note that this number must be between zero and sl@0: ModelCount(). sl@0: @return Name of printer model, up to 32 characters long */ sl@0: virtual const TPrinterModelEntry operator[](TInt anIndex)=0; sl@0: sl@0: /** Gets a printer models index within the model list from its UID. sl@0: sl@0: @param aModelUid The UID of the printer model. sl@0: @return The index of the printer model within the array of printer models.*/ sl@0: virtual TInt UidToNum(TUid aModelUid) const=0; sl@0: }; sl@0: sl@0: sl@0: /** Interface for printing in bands. sl@0: sl@0: This class provides a single PrintBandL() function that prints sl@0: the body of each page band by band. Classes derived from this interface must sl@0: provide an implementation of the PrintBandL() function. sl@0: @since 5.0 sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MPageRegionPrinter sl@0: { sl@0: public: sl@0: /** Prints a band. sl@0: sl@0: Implementations should set up a graphics context to which all drawing should sl@0: take place using CGraphicsDevice::CreateContext(). All co-ordinate sl@0: calculations should be done in twips, and converted into pixels before sl@0: starting the print job. sl@0: sl@0: @param aDevice Pointer to the graphics device representing the printer. sl@0: @param aPageNo The number of the page containing the band to be printed. sl@0: @param aBandInPixels Attributes of the band to be printed. */ sl@0: virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBandInPixels)=0; sl@0: }; sl@0: sl@0: /** sl@0: The UID value of a printer specification data store. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: const TInt KPdrStoreFileUidVal=268435514; sl@0: sl@0: const TInt KPdlUidVal=268450588; sl@0: const TInt KUdlUidVal=268450589; sl@0: sl@0: sl@0: /** Printer specific user interface. sl@0: sl@0: The class is used to implement a printer specific setup dialog. A concrete sl@0: implementation of the class is supplied in a UDL (i.e. a UI DLL). sl@0: sl@0: CPrinterDriver::CreatePrinterDriverUIL() is used to construct a CPrinterDriverUI sl@0: object for a specific printer. (This function calls the ordinal 1 exported sl@0: function of the UDL that performs the construction of the CPrinterDriverUI sl@0: object). sl@0: sl@0: @see CPrinterDriver::CreatePrinterDriverUIL() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPrinterDriverUI : public CBase sl@0: { sl@0: protected: sl@0: IMPORT_C CPrinterDriverUI(); sl@0: public: sl@0: IMPORT_C virtual TBool BeforePrintL(); sl@0: IMPORT_C virtual void AfterPrintL(); sl@0: IMPORT_C virtual void SetPropertiesL(); sl@0: IMPORT_C virtual TBool CanSetProperties(); sl@0: sl@0: /** Sets the printer device. sl@0: sl@0: @param aPrinterDevice The printer device. */ sl@0: virtual TInt SetPrinterDevice(CPrinterDevice* aPrinterDevice)=0; sl@0: }; sl@0: sl@0: class CFileStore; sl@0: sl@0: sl@0: /** Provides access to a store containing printer specification data. sl@0: sl@0: Printer specification data is held as a direct file store, and usually has sl@0: a .pdr file type. sl@0: sl@0: A printer driver is implemented as two files: a PDR file containing the printer sl@0: specification data and a PDL file containing the code to link the printer sl@0: with the graphics printing system. sl@0: sl@0: The printer specification data is generated by compiling a text file (a .pd sl@0: file type) using the pdrtran tool. Printer specification data defines: sl@0: sl@0: the name of the associated PDL sl@0: sl@0: a list of one or more models supported by this driver, identified by name sl@0: and UID sl@0: sl@0: device information such as the size of the device, typeface information for sl@0: each model, including which typefaces are supported, the heights available sl@0: in each typeface and the width of each character in a font. sl@0: sl@0: @see CPrinterDriverUI sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPrinterDriver : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CPrinterDriver* NewL(); sl@0: IMPORT_C ~CPrinterDriver(); sl@0: IMPORT_C void OpenPdrL(const TDesC &aName); sl@0: IMPORT_C void Close(); sl@0: IMPORT_C TInt NumModels() const; sl@0: IMPORT_C TPrinterModelEntry Model(TInt aNum) const; sl@0: sl@0: /** Gets the associated graphics printer device. sl@0: sl@0: @return The physical graphics device used for printing. */ sl@0: inline CPrinterDevice* PrinterDevice() {return iPrinterDevice;} sl@0: IMPORT_C CPrinterDevice* CreatePrinterDeviceL(TUid aModelUid); sl@0: IMPORT_C CPrinterDriverUI* CreatePrinterDriverUIL(); sl@0: private: sl@0: CPrinterDriver(); sl@0: void DeletePrinterDevice(); sl@0: void DoOpenPdrL(const TDesC &aName); sl@0: void DoCreatePrinterDeviceL(TUid aModelUid); sl@0: void LoadLibraryL(RLibrary& aLibrary,const TDesC& aExt,TUid aUid2); sl@0: private: sl@0: RFs iFs; sl@0: CFileStore *iPdrStore; sl@0: TInt iNumModels; sl@0: TPrinterModelHeader* iModelList; sl@0: TFileName iPdlName; sl@0: TUid iPdlUid; sl@0: RLibrary iPdlLibrary; sl@0: CPrinterDevice* iPrinterDevice; sl@0: RLibrary iUdlLibrary; sl@0: }; sl@0: sl@0: class RResourceFile; sl@0: sl@0: sl@0: /** Implements a printer model list interface for a collection of PDR files. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CPdrModelList : public CPrinterModelList sl@0: { sl@0: public: sl@0: IMPORT_C static CPdrModelList* NewL(); sl@0: IMPORT_C virtual ~CPdrModelList(); sl@0: IMPORT_C TInt ModelCount() const; sl@0: IMPORT_C const TPrinterModelEntry operator [] (TInt anIndex); sl@0: IMPORT_C TInt UidToNum(TUid aModelUid) const; // returns KErrNotFound the model uid is not matched sl@0: IMPORT_C void AddDirectoryL(const TDesC& aDir); sl@0: IMPORT_C CPrinterModelList* ScanForModelsL(); sl@0: IMPORT_C CPrinterDriver* CreatePrinterDriverL(TInt anIndex); sl@0: private: sl@0: CPdrModelList(); sl@0: void ConstructL(); sl@0: private: sl@0: class TFileEntry sl@0: { sl@0: public: sl@0: TFileName iFileName; sl@0: TDesC* iDirectory; sl@0: }; sl@0: class TModelEntry sl@0: { sl@0: public: sl@0: TPrinterModelEntry iEntry; sl@0: TFileEntry* iFile; sl@0: }; sl@0: private: sl@0: void ScanDirectoryL(TInt aDirIndex); sl@0: void ListModelsL(TInt aFileIndex, TParse& aParser, TFileName& aNameOfLoadedResourceFile, TFileName& aTempFileName, RResourceFile& aResourceFile, HBufC8*& aResource); sl@0: HBufC* NewPathBufL(const TFileEntry& aFileEntry); sl@0: private: sl@0: CArrayFixSeg* iModelArray; sl@0: CArrayFixFlat* iFileArray; sl@0: CArrayFixFlat* iDirectoryArray; sl@0: RFs iFileServer; sl@0: }; sl@0: sl@0: sl@0: /** The interface for mapping between twips and device-specific units enriched sl@0: with facilities to allow zooming. sl@0: sl@0: The class is recursive, because a TZoomFactor object can have a sl@0: MGraphicsDeviceMap (which could itself be a TZoomFactor) in its member data. sl@0: This allows a zoom factor object to contain another zoom factor object, and sl@0: is used to allow objects with different zoom factors to be embedded in each sl@0: other to an arbitrary depth by the application architecture. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TZoomFactor : public MGraphicsDeviceMap sl@0: { sl@0: public: sl@0: IMPORT_C TZoomFactor(); sl@0: IMPORT_C ~TZoomFactor(); sl@0: inline TZoomFactor(const MGraphicsDeviceMap* aDevice); sl@0: inline TZoomFactor(const TZoomFactor* aDevice); sl@0: IMPORT_C TInt ZoomFactor() const; sl@0: IMPORT_C void SetZoomFactor(TInt aZoomFactor); sl@0: inline void SetGraphicsDeviceMap(const MGraphicsDeviceMap* aDevice); sl@0: inline const MGraphicsDeviceMap* GraphicsDeviceMap() const; sl@0: IMPORT_C void SetTwipToPixelMapping(const TSize& aSizeInPixels,const TSize& aSizeInTwips); sl@0: IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwipWidth) const; sl@0: IMPORT_C TInt VerticalTwipsToPixels(TInt aTwipHeight) const; sl@0: IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixelWidth) const; sl@0: IMPORT_C TInt VerticalPixelsToTwips(TInt aPixelHeight) const; sl@0: IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: IMPORT_C void ReleaseFont(CFont* aFont); sl@0: public: sl@0: sl@0: /** One to one zoom factor. */ sl@0: enum {EZoomOneToOne=1000}; sl@0: private: sl@0: TInt iZoomFactor; sl@0: const MGraphicsDeviceMap* iDevice; sl@0: }; sl@0: sl@0: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #include sl@0: #endif //SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: sl@0: #include sl@0: sl@0: #endif // __GDI_H__