XCoeTextDrawer Class Reference

class XCoeTextDrawer

This class serves as a smart-pointer handle to a CCoeTextDrawerBase-derived object, used for drawing user interface text. Through the use of the CCoeControl's TextDrawer() and GetTextDrawer() methods, a container control can control the text style and color used by its child controls. For example, a button class can override its GetTextDrawer() method to set the text color used by its text label child control depending on the buttons state (e.g. unpressed, pressed, or dimmed).

The XCoeTextDrawer object manages the life of the heap allocated CCoeTextDrawerBase (deleting it or resetting it depending on whether the object is reusable or not).

XCoeTextDrawer objects shall be allocated on the stack in the control's Draw() method and initialized with a heap allocated CCoeTextDrawerBase object fetched from the control's skin, or from its parent or background through the CCoeControl::TextDrawer() method.

Never create a CCoeTextDrawer-derived object inside your CCoeControl::Draw() method, as this is not guaranteed to work in low-memory situations. Non-reusable text drawers must only be created in your control's GetTextDrawer() method, as this provides error handling in case the text drawer could not be created.

Hence, typical use from inside a CCoeControl's Draw() method: XCoeTextDrawer textDrawer(TextDrawer()); textDrawer.SetAlignment(EHLeftVCenter); textDrawer.SetMargins(iTextMargins); textDrawer.DrawText(SystemGc(), *iText, iTextRect, ScreenFont(TCoeFont::NormalFont()));

Public Member Functions
XCoeTextDrawer(CCoeTextDrawerBase &)
~XCoeTextDrawer()
TGulAlignment Alignment()
IMPORT_C TRectClipRect()
IMPORT_C voidDrawDisplayOrderedText(CGraphicsContext &, const TDesC &, const TRect &, const CFont &)
IMPORT_C voidDrawDisplayOrderedTextVertical(CGraphicsContext &, const TDesC &, const TRect &, const CFont &, TBool)
IMPORT_C voidDrawText(CGraphicsContext &, const TBidiText &, const TRect &, const CFont &)
IMPORT_C voidDrawTextVertical(CGraphicsContext &, const TBidiText &, const TRect &, const CFont &, TBool)
TInt LineGapInPixels()
TMargins8 Margins()
voidSetAlignment(const TGulAlignment &)
IMPORT_C voidSetClipRect(const TRect &)
voidSetLineGapInPixels(TInt)
voidSetMargins(const TMargins8 &)
voidSetTextColor(TRgb)
TRgb TextColor()
IMPORT_C CCoeTextDrawerBase *operator->()
IMPORT_C voidoperator=(CCoeTextDrawerBase &)
Private Member Functions
XCoeTextDrawer(const XCoeTextDrawer &)
Private Attributes
TRect iClipRect
CCoeTextDrawerBase *iTextDrawer

Constructor & Destructor Documentation

XCoeTextDrawer(CCoeTextDrawerBase &)

IMPORT_CXCoeTextDrawer(CCoeTextDrawerBase &aTextDrawer)

Parameters

CCoeTextDrawerBase & aTextDrawer

XCoeTextDrawer(const XCoeTextDrawer &)

XCoeTextDrawer(const XCoeTextDrawer &aTextDrawer)[private]

Parameters

const XCoeTextDrawer & aTextDrawer

~XCoeTextDrawer()

IMPORT_C~XCoeTextDrawer()

Member Functions Documentation

Alignment()

TGulAlignment Alignment()const [inline]

Returns the text alignment that will be used by DrawText() and DrawDisplayOrderedText(). Note that left and right alignment will be swapped for right-to-left scripts, unless the alignment has been set to be absolute (see TGulAlignment).

TGulAlignment value of iAlignment data member

ClipRect()

IMPORT_C TRectClipRect()const

DrawDisplayOrderedText(CGraphicsContext &, const TDesC &, const TRect &, const CFont &)

IMPORT_C voidDrawDisplayOrderedText(CGraphicsContext &aGc,
const TDesC &aText,
const TRect &aTextRect,
const CFont &aFont
)const

Parameters

CGraphicsContext & aGc
const TDesC & aText
const TRect & aTextRect
const CFont & aFont

DrawDisplayOrderedTextVertical(CGraphicsContext &, const TDesC &, const TRect &, const CFont &, TBool)

IMPORT_C voidDrawDisplayOrderedTextVertical(CGraphicsContext &aGc,
const TDesC &aText,
const TRect &aTextRect,
const CFont &aFont,
TBoolaUp = ETrue
)const

Parameters

CGraphicsContext & aGc
const TDesC & aText
const TRect & aTextRect
const CFont & aFont
TBool aUp = ETrue

DrawText(CGraphicsContext &, const TBidiText &, const TRect &, const CFont &)

IMPORT_C voidDrawText(CGraphicsContext &aGc,
const TBidiText &aText,
const TRect &aTextRect,
const CFont &aFont
)const

Parameters

CGraphicsContext & aGc
const TBidiText & aText
const TRect & aTextRect
const CFont & aFont

DrawTextVertical(CGraphicsContext &, const TBidiText &, const TRect &, const CFont &, TBool)

IMPORT_C voidDrawTextVertical(CGraphicsContext &aGc,
const TBidiText &aText,
const TRect &aTextRect,
const CFont &aFont,
TBoolaUp = ETrue
)const

Parameters

CGraphicsContext & aGc
const TBidiText & aText
const TRect & aTextRect
const CFont & aFont
TBool aUp = ETrue

LineGapInPixels()

TInt LineGapInPixels()const [inline]

Returns the gap (in pixels) between lines of text. Default gap is 1 (one) pixel. The gap between lines of text, in pixels.

Margins()

TMargins8 Margins()const [inline]

Returns the text margins that will be used by DrawText() and DrawDisplayOrderedText(). Note that text effects may intrude on the margin.

The margins between the text rect and the actual text, in pixels.

SetAlignment(const TGulAlignment &)

voidSetAlignment(const TGulAlignment &aAlignment)[inline]

Set the text alignment that will be used by DrawText() and DrawDisplayOrderedText(). Note that left and right alignment will be swapped for right-to-left scripts, unless the alignment has been set to be absolute (see TGulAlignment).

Parameters

const TGulAlignment & aAlignmentTGulAlignment value.

SetClipRect(const TRect &)

IMPORT_C voidSetClipRect(const TRect &aClipRect)

Parameters

const TRect & aClipRect

SetLineGapInPixels(TInt)

voidSetLineGapInPixels(TIntaLineGapInPixels)[inline]

Set the gap (in pixels) between lines of text. Default gap is 1 (one) pixel.

Parameters

TInt aLineGapInPixelsThe gap between lines of text, in pixels.

SetMargins(const TMargins8 &)

voidSetMargins(const TMargins8 &aMargins)[inline]

Set the text margins that will be used by DrawText() and DrawDisplayOrderedText(). Note that text effects may intrude on the margin, and that margins are always relative to the text orientation.

Parameters

const TMargins8 & aMarginsThe margins between the text rect and the actual text, in pixels.

SetTextColor(TRgb)

voidSetTextColor(TRgbaColor)[inline]

This method sets the main color to use by DrawText() and DrawDisplayOrderedText() to draw text.

Parameters

TRgb aColorThe color to use to draw text.

TextColor()

TRgb TextColor()const [inline]

This method returns the main color used by by DrawText() and DrawDisplayOrderedText(). The color used to draw text.

operator->()

IMPORT_C CCoeTextDrawerBase *operator->()

operator=(CCoeTextDrawerBase &)

IMPORT_C voidoperator=(CCoeTextDrawerBase &aTextDrawer)

Parameters

CCoeTextDrawerBase & aTextDrawer

Member Data Documentation

TRect iClipRect

TRect iClipRect[private]

CCoeTextDrawerBase * iTextDrawer

CCoeTextDrawerBase *iTextDrawer[private]