Location:
frmtlay.h
MFormCustomDraw
Supported from 6.0
An abstract class which specifies the protocol for customising the way the 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.
Defined in MFormCustomDraw
:
DrawBackground()
, DrawLineGraphics()
, DrawText()
, TLineInfo
, TParam
virtual void DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const;
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
.
|
virtual void DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const;
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.
|
virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat, const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const;
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.
|
MFormCustomDraw::TParam
Contains the drawing parameters used by all custom draw functions.
Defined in MFormCustomDraw::TParam
:
iDrawRect
, iGc
, iMap
, iTextLayoutTopLeft
MGraphicsDeviceMap& iMap
The graphics device map, which allows you to convert between pixels and twips and create fonts.
const TPoint& iTextLayoutTopLeft
The origin for the coordinates at which the text, bitmaps and other graphics are drawn.
MFormCustomDraw::TLineInfo
Contains the line metrics.
Defined in MFormCustomDraw::TLineInfo
:
iBaseline
, iInnerRect
, iOuterRect
const TRect& iOuterRect
The bounding rectangle of the line, including margins, indents and automatic space above and below paragraphs.
TInt iBaseline
The baseline of the text.