CCoeTextDrawerBase Class Reference

#include <mw/coetextdrawer.h>

class CCoeTextDrawerBase : public CBase, public MObjectProvider

Inherits from

Detailed Description

This is the base class for all text drawers implementing different text effects (for example shadow or glowing/outlined text). The object can be created and deleted each time it's used, or Reset() and reused if it IsReusable(). The latter is recommended.

Note that the pure virtual DrawText() method is private. This ensures that the object is used through the XCoeTextDrawer class (which manages its life).

Note also that the accessor and set methods should be used via the owning XCoeTextDrawer object, and that the MObjectProvider mechanism can be used to identify the actual text drawer implementation.

Constructor & Destructor Documentation

CCoeTextDrawerBase ( )

IMPORT_CCCoeTextDrawerBase()[protected]

Constructor.

~CCoeTextDrawerBase ( )

IMPORT_C~CCoeTextDrawerBase()

Destructor.

Member Function Documentation

ActualHorizontalAlignment ( const TCoeTextTypeAdaptor & )

IMPORT_C TGulHAlignmentActualHorizontalAlignment(const TCoeTextTypeAdaptor &aText)const [protected]

This method returns the actual (absolute) horizontal text alignment to be used when drawing text in any CCoeTextDrawerBase-derived DrawText() implementation. The actual alignment depends on the application language directionality if the application language has been set calling CCoeTextDrawerBase::SetAppLanguage(), or otherwise on the directionality of the actual text being printed. If the directionality is right-to-left (and the horizontal alignment has not been set to be absolute, using TGulAlignment::SetAbsoluteHAlignment()), left and right alignment (set using XCoeTextDrawer::SetAlignment()) will be swapped.

Alignment ( )

IMPORT_C TGulAlignmentAlignment()const

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).

A typical user of the text drawer mechanism will use the XCoeTextDrawer version of this API.

Return Value
TGulAlignment value of iAlignment data member

Construct ( )

IMPORT_C TIntConstruct()[protected]

Second phase object construction. Note that this method is non-leaving as it may be called indirectly from a Draw() method, which must not leave.

Return Value
returns KErrNone if successful, otherwise KErrNoMemory.

EffectMargins ( )

IMPORT_C TMargins8EffectMargins()[virtual]

Any text drawer implementation must override this method, returning the "margins" that the text effect will add to the text extent. I.e. a one-pixel drop-shadow to the lower right will add an effect margin of TMargins8(0,0,1,1), while a one-pixel all-around outline will add an effect margin of TMargins8(1,1,1,1).

IsReusable ( )

IMPORT_C TBoolIsReusable()const

Returns whether the CCoeTextDrawerBase-derived text drawer object has been set to be reusable or not. If reusable, the text drawer is assumed to have an owner that will delete it when appropriate. If not reusable, the XCoeTextDrawer will delete it in its destructor.

Return Value
bool value of iIsReusable data member

LineGapInPixels ( )

IMPORT_C TIntLineGapInPixels()const

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

A typical user of the text drawer mechanism will use the XCoeTextDrawer version of this API.

Return Value
The gap between lines of text, in pixels.

Margins ( )

IMPORT_C TMargins8Margins()const

Returns the text margins that will be used by DrawText() and DrawDisplayOrderedText().

A typical user of the text drawer mechanism will use the XCoeTextDrawer version of this API.

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

Reset ( )

IMPORT_C voidReset()[virtual]

This method is called from the destructor of the XCoeTextDrawer object managing the life of the CCoeTextDrawerBase object, if the CCoeTextDrawerBase object has been set to be reusable (by its owner calling SetReusable()).

Any derived class must override this method to reset its drawing parameters to their defaults, so that the object is ready to be used again. Any overriding implementation must call the base implementation as well.

SetAlignment ( const TGulAlignment & )

IMPORT_C voidSetAlignment(const TGulAlignment &aAlignment)

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).

A typical user of the text drawer mechanism will use the XCoeTextDrawer version of this API.

Parameters
aAlignmentTGulAlignment value.

SetAppLanguage ( TLanguage )

IMPORT_C voidSetAppLanguage(TLanguageaAppLang)

Unless absolute horizontal aligment has been selected (see TGulAlignment), the actual horizontal text alignment used when drawing text depends on whether the directionality of the scrip is left-to-right or right-to-left. In the latter case left and right is swapped. By default, the directionality of the actual text being drawn will define whether the horizontal alignment will be swapped or not. However, if (as recommended) the directionality of the application's main language shall be considered instead (rather than the directionality of the text being printed at the moment), then call this method.

If ELangNone is specified, the text drawer will be reset to swap horizontal alignment depending on the directionality of the text being printed.

Parameters
aAppLangThe application language (e.g. from CEikonEnv::ApplicationLanguage()).

SetLineGapInPixels ( TInt )

IMPORT_C voidSetLineGapInPixels(TIntaLineGapInPixels)

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

A typical user of the text drawer mechanism will use the XCoeTextDrawer version of this API.

Parameters
aLineGapInPixelsThe gap between lines of text, in pixels.

SetMargins ( const TMargins8 & )

IMPORT_C voidSetMargins(const TMargins8 &aMargins)

Set the text margins that will be used by DrawText() and DrawDisplayOrderedText().

A typical user of the text drawer mechanism will use the XCoeTextDrawer version of this API.

Parameters
aMarginsThe margins between the text rect and the actual text, in pixels.

SetReusable ( TBool )

IMPORT_C voidSetReusable(TBoolaIsReusable)

Set whether the text drawer is reusable or not. A reusable text drawer will be reset (through a call to Reset()) rather than deleted when the XCoeTextDrawer referring to it is deleted. This decision has to be made by the creator of the CCoeTextDrawerBase object. I.e. this method must not be called by a mere user of the XCoeTextDrawer.

Parameters
aIsReusableBoolean indicating whether the text drawer can be re-used.

SetTextColor ( TRgb )

voidSetTextColor(TRgbaColor)[pure virtual]

This method sets the main color to use to draw text.

Parameters
aColorThe color to use to draw text.

TextColor ( )

TRgb TextColor()const [pure virtual]

This method returns the main color used by the CCoeTextDrawer to draw text.

Return Value
The color used to draw text.