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 TRect | ClipRect() |
IMPORT_C void | DrawDisplayOrderedText(CGraphicsContext &, const TDesC &, const TRect &, const CFont &) |
IMPORT_C void | DrawDisplayOrderedTextVertical(CGraphicsContext &, const TDesC &, const TRect &, const CFont &, TBool) |
IMPORT_C void | DrawText(CGraphicsContext &, const TBidiText &, const TRect &, const CFont &) |
IMPORT_C void | DrawTextVertical(CGraphicsContext &, const TBidiText &, const TRect &, const CFont &, TBool) |
TInt | LineGapInPixels() |
TMargins8 | Margins() |
void | SetAlignment(const TGulAlignment &) |
IMPORT_C void | SetClipRect(const TRect &) |
void | SetLineGapInPixels(TInt) |
void | SetMargins(const TMargins8 &) |
void | SetTextColor(TRgb) |
TRgb | TextColor() |
IMPORT_C CCoeTextDrawerBase * | operator->() |
IMPORT_C void | operator=(CCoeTextDrawerBase &) |
Private Member Functions | |
---|---|
XCoeTextDrawer(const XCoeTextDrawer &) |
Private Attributes | |
---|---|
TRect | iClipRect |
CCoeTextDrawerBase * | iTextDrawer |
IMPORT_C | XCoeTextDrawer | ( | CCoeTextDrawerBase & | aTextDrawer | ) |
CCoeTextDrawerBase & aTextDrawer |
XCoeTextDrawer | ( | const XCoeTextDrawer & | aTextDrawer | ) | [private] |
const XCoeTextDrawer & aTextDrawer |
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
IMPORT_C void | DrawDisplayOrderedText | ( | CGraphicsContext & | aGc, |
const TDesC & | aText, | |||
const TRect & | aTextRect, | |||
const CFont & | aFont | |||
) | const |
CGraphicsContext & aGc | |
const TDesC & aText | |
const TRect & aTextRect | |
const CFont & aFont |
IMPORT_C void | DrawDisplayOrderedTextVertical | ( | CGraphicsContext & | aGc, |
const TDesC & | aText, | |||
const TRect & | aTextRect, | |||
const CFont & | aFont, | |||
TBool | aUp = ETrue | |||
) | const |
CGraphicsContext & aGc | |
const TDesC & aText | |
const TRect & aTextRect | |
const CFont & aFont | |
TBool aUp = ETrue |
IMPORT_C void | DrawText | ( | CGraphicsContext & | aGc, |
const TBidiText & | aText, | |||
const TRect & | aTextRect, | |||
const CFont & | aFont | |||
) | const |
CGraphicsContext & aGc | |
const TBidiText & aText | |
const TRect & aTextRect | |
const CFont & aFont |
IMPORT_C void | DrawTextVertical | ( | CGraphicsContext & | aGc, |
const TBidiText & | aText, | |||
const TRect & | aTextRect, | |||
const CFont & | aFont, | |||
TBool | aUp = ETrue | |||
) | const |
CGraphicsContext & aGc | |
const TBidiText & aText | |
const TRect & aTextRect | |
const CFont & aFont | |
TBool aUp = ETrue |
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.
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.
void | SetAlignment | ( | 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).
const TGulAlignment & aAlignment | TGulAlignment value. |
IMPORT_C void | SetClipRect | ( | const TRect & | aClipRect | ) |
const TRect & aClipRect |
void | SetLineGapInPixels | ( | TInt | aLineGapInPixels | ) | [inline] |
Set the gap (in pixels) between lines of text. Default gap is 1 (one) pixel.
TInt aLineGapInPixels | The gap between lines of text, in pixels. |
void | SetMargins | ( | 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.
const TMargins8 & aMargins | The margins between the text rect and the actual text, in pixels. |
void | SetTextColor | ( | TRgb | aColor | ) | [inline] |
This method sets the main color to use by DrawText() and DrawDisplayOrderedText() to draw text.
TRgb aColor | The color to use to draw text. |
TRgb | TextColor | ( | ) | const [inline] |
This method returns the main color used by by DrawText() and DrawDisplayOrderedText(). The color used to draw text.
IMPORT_C void | operator= | ( | CCoeTextDrawerBase & | aTextDrawer | ) |
CCoeTextDrawerBase & aTextDrawer |