TBidiText Class Reference

class TBidiText

This class works as a replacement for HBufC in those cases where a small amount of text is being formatted simply. The text must be all of one style and broken into lines of all the same length. The number of lines and the text itself is specified on construction, and the text may then be re-broken, re-truncated and re-drawn with non-leaving functions.

Public Member Functions
IMPORT_C TDirectionalityDirectionality()
IMPORT_C TPtrCDisplayText()
IMPORT_C voidDrawText(CGraphicsContext &, const TPoint &)
IMPORT_C voidDrawText(CGraphicsContext &, const TPoint &, TInt, CGraphicsContext::TTextAlign)
IMPORT_C voidDrawText(CGraphicsContext &, const TPoint &, TInt)
IMPORT_C TPtrCLineOfDisplayText(TInt, TInt &)
IMPORT_C TSizeMinimumSize(TInt, const CFont &, TInt, TInt, const MLineBreaker *)
IMPORT_C TBidiText *NewL(TInt, TInt)
IMPORT_C TBidiText *NewL(const TDesC &, TInt)
IMPORT_C TBidiText *NewL(const TDesC &, TInt, TDirectionality)
IMPORT_C TIntNumberOfLinesInDisplayText()
IMPORT_C TDirectionalityScriptDirectionality(TLanguage)
IMPORT_C TIntSetText(const TDesC &, RRunInfoArray &)
IMPORT_C TIntSetText(const TDesC &, TDirectionality, RRunInfoArray &)
IMPORT_C voidSetTruncationChar(TChar)
IMPORT_C TPtrCText()
IMPORT_C TDirectionalityTextDirectionality(const TDesC &, TBool *)
IMPORT_C TCharTruncationChar()
IMPORT_C voidWrapText(TInt, const CFont &, const MLineBreaker *, TInt)
IMPORT_C voidWrapText(TInt, const CFont &, const MLineBreaker *)
IMPORT_C TIntWrappingWidth()
Protected Member Functions
TBidiText()
Private Member Functions
TInt DoWrapText(TInt, const CFont &, const MLineBreaker *, TInt, TText *&, TInt &, TInt16 *)
Public Member Enumerations
enumTDirectionality { ELeftToRight = 0, ERightToLeft = 1 }
enumTPanicCodes { EPanicRunArrayNull }

Constructor & Destructor Documentation

TBidiText()

TBidiText()[protected]

Member Functions Documentation

Directionality()

IMPORT_C TDirectionalityDirectionality()const

Returns the directionality of the text.

DisplayText()

IMPORT_C TPtrCDisplayText()const

Returns the text as prepared for display, provided that WrapText has been called. If WrapText has not been called, a panic will result.

DoWrapText(TInt, const CFont &, const MLineBreaker *, TInt, TText *&, TInt &, TInt16 *)

TInt DoWrapText(TIntaWrappingWidth,
const CFont &aFont,
const MLineBreaker *aBreaker,
TIntaMaxLines,
TText *&aOutputText,
TInt &aNumLines,
TInt16 *aLineWidthArray
)const [private]

Parameters

TInt aWrappingWidth
const CFont & aFont
const MLineBreaker * aBreaker
TInt aMaxLines
TText *& aOutputText
TInt & aNumLines
TInt16 * aLineWidthArray

DrawText(CGraphicsContext &, const TPoint &)

IMPORT_C voidDrawText(CGraphicsContext &aGc,
const TPoint &aLeft
)const

Draws the first line of the text. WrapText must have been called already. Alignment is taken from the directionality of the text.

Parameters

CGraphicsContext & aGcThe graphics context to draw the text to. The graphics context's font is assumed to have been set to the same font that was passed to the previous call to WrapText.
const TPoint & aLeftThe left extreme of the baseline. Note that this should not be at the very edge of the available space, or characters such as "W" with left side bearings may be truncated.

DrawText(CGraphicsContext &, const TPoint &, TInt, CGraphicsContext::TTextAlign)

IMPORT_C voidDrawText(CGraphicsContext &aGc,
const TPoint &aLeft,
TIntaBaseLineSpacing,
CGraphicsContext::TTextAlignaAlignment
)const

Draws all of the text. WrapText must have been called already.

Parameters

CGraphicsContext & aGcThe graphics context to draw the text to. The graphics context's font is assumed to have been set to the same font that was passed to the previous call to WrapText.
const TPoint & aLeftThe left extreme of the baseline. Note that this should not be at the very edge of the available space, or characters such as "W" with left side bearings may be truncated.
TInt aBaseLineSpacingThe spacing between each line. If 0, only the first line is drawn.
CGraphicsContext::TTextAlign aAlignmentHow to position the text horizontally.

DrawText(CGraphicsContext &, const TPoint &, TInt)

IMPORT_C voidDrawText(CGraphicsContext &aGc,
const TPoint &aLeft,
TIntaBaseLineSpacing
)const

Draws all of the text. Alignment is taken from the directionality of the text. WrapText must have been called already.

Parameters

CGraphicsContext & aGcThe graphics context to draw the text to. The graphics context's font is assumed to have been set to the same font that was passed to the previous call to WrapText.
const TPoint & aLeftThe left extreme of the baseline. Note that this should not be at the very edge of the available space, or characters such as "W" with left side bearings may be truncated.
TInt aBaseLineSpacingThe spacing between each line. If 0, only the first line is drawn.

LineOfDisplayText(TInt, TInt &)

IMPORT_C TPtrCLineOfDisplayText(TIntaLine,
TInt &aWidthInPixels
)const

Returns the text as prepared for display, provided that WrapText has been called. If WrapText has not been called, a panic will result.

Parameters

TInt aLineLine number to retrieve.
TInt & aWidthInPixels

MinimumSize(TInt, const CFont &, TInt, TInt, const MLineBreaker *)

IMPORT_C TSizeMinimumSize(TIntaWrappingWidth,
const CFont &aFont,
TIntaLineGap,
TIntaMaxLines = -1,
const MLineBreaker *aBreaker = NULL
)const

Calculate the minimum size needed to draw the current text, given the specified wrapping width, font, and line gap. Calling this method will not rewrap the object's text.

Parameters

TInt aWrappingWidthThe maximum width of the text in pixels. Note that this distance should be slightly less than the available width to allow for characters such as "W" which can have side-bearings that leak into the margins.
const CFont & aFontThe font that will provide the character metrics.
TInt aLineGapThe number of empty pixels between two lines of text. Note that this is not the same as the baseline spacing, which is the font height plus the line gap.
TInt aMaxLines = -1Number of lines to restrict wrapping to. The truncation character will be used if the text is too long for this number of lines. The number of lines wrapped to may be greater than the figure passed to NewL, and that figure will be used if the number of lines is specified as -1. If 0 (zero) is specified no limit is applied.
const MLineBreaker * aBreaker = NULLAn object for breaking the lines. May be NULL for default behaviour.

NewL(TInt, TInt)

IMPORT_C TBidiText *NewL(TIntaReservedMaxLength,
TIntaMaxLines
)[static]

Creates a bidirectional text object with enough room for up to aReservedMaxLength number of characters. The number of characters that will actually fit (when calling SetText()) might be slightly less than aReservedMaxLength, as each change between a left-to-right and a right-to-left sub-string (and the other way around) needs about two characters worth of memory.

Parameters

TInt aReservedMaxLengthThe maximum number of characters.
TInt aMaxLinesThe maximum number of lines that this text will need to be split into. Must be at least 1, but should not be too large, as each potential line takes an extra 8 bytes of memory.

NewL(const TDesC &, TInt)

IMPORT_C TBidiText *NewL(const TDesC &aText,
TIntaMaxLines
)[static]

Creates a bidirectional text object with directionality determined by the text itself. Use this for text that has been obtained from a resource file.

Parameters

const TDesC & aTextThe text in logical order.
TInt aMaxLinesThe maximum number of lines that this text will need to be split into. Must be at least 1, but should not be too large, as each potential line takes an extra 8 bytes of memory.

NewL(const TDesC &, TInt, TDirectionality)

IMPORT_C TBidiText *NewL(const TDesC &aText,
TIntaMaxLines,
TDirectionalityaDirectionality
)[static]

Creates a bidirectional text object with directionality determined by aDirectionality. Use this for text that has come from user input.

Parameters

const TDesC & aTextThe text in logical order.
TInt aMaxLinesThe maximum number of lines that this text will need to be split into. Must be at least 1, but should not be too large, as each potential line takes an extra 8 bytes of memory.
TDirectionality aDirectionalityDirection to use.

NumberOfLinesInDisplayText()

IMPORT_C TIntNumberOfLinesInDisplayText()const

Reports the number of lines in the text to be drawn.

WrapText must have been called already.

ScriptDirectionality(TLanguage)

IMPORT_C TDirectionalityScriptDirectionality(TLanguageaLanguage)[static]

Returns the directionality of a given language.

Parameters

TLanguage aLanguageLanguage.

SetText(const TDesC &, RRunInfoArray &)

IMPORT_C TIntSetText(const TDesC &aText,
RRunInfoArray &aRunInfoArray
)

Sets the text of the bidirectional text object with directionality determined by the text itself. Use this for text that has been obtained from a resource file.

Parameters

const TDesC & aTextThe text in logical order.
RRunInfoArray & aRunInfoArray

SetText(const TDesC &, TDirectionality, RRunInfoArray &)

IMPORT_C TIntSetText(const TDesC &aText,
TDirectionalityaDirectionality,
RRunInfoArray &aRunInfoArray
)

Sets the text of the bidirectional text with directionality determined by aDirectionality. Use this for text that has come from user input.

panic
Bidi EBidiPanic_RunArrayNull The call to RRunInfoArray::OpenL() has not been made prior to this call to TBidiText::SetText()

Parameters

const TDesC & aTextThe text in logical order.
TDirectionality aDirectionalityDirection to use.
RRunInfoArray & aRunInfoArray

SetTruncationChar(TChar)

IMPORT_C voidSetTruncationChar(TCharaTruncateWith)

Sets the character that will be added at the end of the text if the whole text cannot fit into the space specified.

Parameters

TChar aTruncateWithThe truncation char.

Text()

IMPORT_C TPtrCText()const

Returns the original logically-ordered text supplied in the constructor.

TextDirectionality(const TDesC &, TBool *)

IMPORT_C TDirectionalityTextDirectionality(const TDesC &aText,
TBool *aFound = 0
)[static]

Reports the implicit directionality of a piece of text.

Parameters

const TDesC & aTextThe text to be examined.
TBool * aFound = 0If non-null, returns ETrue if there were any strongly directional characters and EFalse if there were none. If a piece of text is spread over several descriptors, They need to be queried in sequence until one returns ETrue in aFound.

TruncationChar()

IMPORT_C TCharTruncationChar()const

Returns the truncation character used.

WrapText(TInt, const CFont &, const MLineBreaker *, TInt)

IMPORT_C voidWrapText(TIntaWrappingWidth,
const CFont &aFont,
const MLineBreaker *aBreaker,
TIntaMaxLines
)

Prepares the visually-ordered text according to the wrapping width and font specified. Text cannot be drawn until this has been done.

Parameters

TInt aWrappingWidthThe maximum width of the text in pixels. Note that this distance should be slightly less than the available width to allow for characters such as "W" which can have side-bearings that leak into the margins.
const CFont & aFontThe font that will provide the character metrics.
const MLineBreaker * aBreakerAn object for breaking the lines. May be NULL for default behaviour.
TInt aMaxLinesNumber of lines to restrict wrapping to. The truncation character will be used if the text is too long for this number of lines. The number of lines wrapped to may not be greater than the figure passed to NewL.

WrapText(TInt, const CFont &, const MLineBreaker *)

IMPORT_C voidWrapText(TIntaWrappingWidth,
const CFont &aFont,
const MLineBreaker *aBreaker = NULL
)

Prepares the visually-ordered text according to the wrapping width and font specified. Text cannot be drawn until this has been done.

Parameters

TInt aWrappingWidthThe maximum width of the text in pixels. Note that this distance should be slightly less than the available width to allow for characters such as "W" which can have side-bearings that leak into the margins.
const CFont & aFontThe font that will provide the character metrics.
const MLineBreaker * aBreaker = NULLAn object for breaking the lines. May be NULL for default behaviour.

WrappingWidth()

IMPORT_C TIntWrappingWidth()const

Returns the wrapping width previously supplied to WrapText.

Member Enumerations Documentation

Enum TDirectionality

Overall directionality of the text.

Enumerators

ELeftToRight = 0

Text reading begins on the left.

ERightToLeft = 1

Text reading begins on the right.

Enum TPanicCodes

Class specific panic codes This enum has been replaced by TBidiPanic.

Enumerators

EPanicRunArrayNull