Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: FRMTLAY.H
Link against: form.lib

Class MFormCustomDraw

class MFormCustomDraw;

Description

An abstract class which specifies the protocol for customising the way text and its background are drawn.

Common uses for this are to implement custom highlighting or to draw a background bitmap. You must create an object of a class derived from this class and call CTextLayout::SetCustomDraw(), passing a pointer to the object. All of these functions have default implementations. Your class can override any of the virtual functions listed below.

Members

Defined in MFormCustomDraw:
DrawBackground(), DrawLineGraphics(), DrawText(), SystemColor(), TLineInfo, TParam


Member functions


DrawBackground()

virtual IMPORT_C void DrawBackground(const TParam &aParam, const TRgb &aBackground, TRect &aDrawn) const;

Description

This function is called whenever part of the background of a CTextLayout or CTextView object needs to be drawn. The default implementation fills aParam.iDrawRect with the colour specified in aBackground.

The default background colour is contained in aBackground. This is the background colour of the paragraph if drawing text, or the background colour specified in the TDrawTextLayoutContext object passed to CTextLayout::DrawL() if drawing outside the text area.

The rectangle which is drawn by this function, (this may not be the whole of aParam.iDrawRect) must be returned in aDrawn; areas not drawn by you are automatically filled using the colour aBackground.

Parameters

const TParam &aParam

Contains the drawing parameters: aParam.iGc is the graphics context to use. aParam.iMap is the graphics device map, which allows you to convert between pixels and twips and create fonts. aParam.iTextLayoutTopLeft is the origin of the text; bitmaps and other graphics must be drawn relative to this position. aParam.iDrawRect is the area to be drawn; do not draw outside this rectangle.

const TRgb &aBackground

The default background colour. This is the background colour of the paragraph if drawing text, or the background colour specified in the TDrawTextLayoutContext object passed to CTextLayout::DrawL() if drawing outside the text area.

TRect &aDrawn

Must return the rectangle you actually draw. This may not be the whole of aParam.iDrawRect (for instance, if you are drawing a non-tiled bitmap that occupies only part of aRect).


DrawLineGraphics()

virtual IMPORT_C void DrawLineGraphics(const TParam &aParam, const TLineInfo &aLineInfo) const;

Description

This function is called after the background has been drawn by DrawBackground(), and before drawing the text. This function might be used to draw a ruled line under each line of text.

The default implementation of this function does nothing.

Parameters

const TParam &aParam

Contains the drawing parameters. You should only draw to aParam.iDrawRect. There is no need to fill aParam.iDrawRect or to indicate the rectangle drawn.

const TLineInfo &aLineInfo

Contains the line metrics: aLineInfo.iOuterLineRect specifies the bounding rectangle of the line, including margins, indents and automatic space above and below paragraphs, aLineInfo.iInnerLineRect specifies the bounds of the text only, aLineInfo.iBaseline specifies the baseline of the text.


DrawText()

virtual IMPORT_C void DrawText(const TParam &aParam, const TLineInfo &aLineInfo, const TCharFormat &aFormat, const TDesC &aText, const TPoint &aTextOrigin, TInt aExtraPixels) const;

Description

This function is called to draw the text and its highlighted background, if any, after bidirectional reordering and other character mappings have taken place.

The default implementation of this function draws the text with no special effects and supports standard, round-cornered and shadowed highlighting only. The text is drawn with the left end of its baseline located at aTextOrigin after drawing the background, if any, in aParam.iDrawRect.

The main reason to override this function is to apply custom text highlighting, (for this, aFormat.iFontPresentation.iHighlightStyle should be in the range EFontHighlightFirstCustomStyle to EFontHighlightLastCustomStyle).

The horizontal spacing between the characters in the text string is increased by the number of pixels specified in aExtraPixels. The standard way to do this is by calling CGraphicsContext::SetCharJustification().

The font and other graphics parameters (e.g. pen colour, font style), are specified in aParam.iGc but a character format container (aFormat) is supplied so that a different font can be used. Note that any graphics drawn cannot exceed the bounds of aParam.iDrawRect, so changes are usually restricted to drawing shadows, outlines, etc. if custom highlighting is in use.

Parameters

const TParam &aParam

Contains the drawing parameters. Drawing can only occur within aParam.iDrawRect.

const TLineInfo &aLineInfo

Contains the line metrics.

const TCharFormat &aFormat

Specifies the character formatting to apply to the text, including the type of text highlighting.

const TDesC &aText

The text string to be drawn.

const TPoint &aTextOrigin

The point at which the left end of the baseline of the text should be drawn.

TInt aExtraPixels

The number of additional pixels to insert between the characters in the text string, in order to increase its length.


SystemColor()

virtual IMPORT_C TRgb SystemColor(TUint aColorIndex, TRgb aDefaultColor) const;

Description

This function translates logical colours specified in FORM objects into real colours. The default implementation just returns the default colour that is passed in and ignores aColorIndex.

Overriding implementations may use aColorIndex in any desired way, either to replace or modify aDefaultColor. The values used in aColorIndex are taken from the top byte of a TLogicalRgb object and are thus in the range 0...255. The TLogicalRgb class defines two reserved values: TLogicalRgb::ESystemForegroundIndex = 254 and TLogicalRgb::ESystemBackgroundIndex = 255.

Parameters

TUint aColorIndex

TRgb aDefaultColor

Return value

TRgb

[Top]


Member classes


Class TParam

class TParam;

Description

Parameters used by several custom draw functions

Members

Defined in MFormCustomDraw::TParam:
TParam(), iDrawRect, iGc, iMap, iTextLayoutTopLeft

Construction and destruction


TParam()

inline TParam(CGraphicsContext &aGc, MGraphicsDeviceMap &aMap, const TPoint &aTextLayoutTopLeft, const TRect &aDrawRect);

Description

Parameters

CGraphicsContext &aGc

MGraphicsDeviceMap &aMap

const TPoint &aTextLayoutTopLeft

const TRect &aDrawRect

Member data


iGc

CGraphicsContext & iGc;

Description


iMap

MGraphicsDeviceMap & iMap;

Description


iTextLayoutTopLeft

const TPoint & iTextLayoutTopLeft;

Description


iDrawRect

const TRect & iDrawRect;

Description


Class TLineInfo

class TLineInfo;

Description

Contains the line metrics.

Members

Defined in MFormCustomDraw::TLineInfo:
TLineInfo(), iBaseline, iInnerRect, iOuterRect

Construction and destruction


TLineInfo()

inline TLineInfo(const TRect &aOuterRect, const TRect &aInnerRect, TInt aBaseline);

Description

Parameters

const TRect &aOuterRect

const TRect &aInnerRect

TInt aBaseline

Member data


iOuterRect

const TRect & iOuterRect;

Description


iInnerRect

const TRect & iInnerRect;

Description


iBaseline

TInt iBaseline;

Description