MFormCustomWrap Class Reference

#include <frmtlay.h>

class MFormCustomWrap
Public Member Functions
virtual IMPORT_C TBoolGetLineBreakInContext(const TDesC &, TInt, TInt, TBool, TInt &)
virtual IMPORT_C TBoolIsHangingCharacter(TUint)
virtual IMPORT_C TUintLineBreakClass(TUint, TUint &, TUint &)
virtual IMPORT_C TBoolLineBreakPossible(TUint, TUint, TBool)

Detailed Description

An interface class that can be derived from to implement custom line breaking.

Custom line breaking allows the Text Views line wrapping algorithm to break lines in any way. For instance, it may be used to avoid the jagged white space at the right edge of text windows caused by normal line wrapping on a small screen.

All of these functions have a default implementation. To change the default behaviour, a pointer to an object that overrides any or all of the functions in the interface needs to be passed to the function CTextLayout::SetCustomWrap().
Since
6.2

See also: CTextLayout::SetCustomWrap()

Member Function Documentation

GetLineBreakInContext ( const TDesC &, TInt, TInt, TBool, TInt & )

IMPORT_C TBoolGetLineBreakInContext(const TDesC &aText,
TIntaMinBreakPos,
TIntaMaxBreakPos,
TBoolaForwards,
TInt &aBreakPos
)const [virtual]

Gets the position of the first or last possible line break position in a text string.

This function is called instead of LineBreakPossible() for runs of characters of class ESaLineBreakClass. It is used for South Asian languages like Thai, Lao and Khmer that have no spaces between words, so that line breaks must be calculated using dictionary lookup or a linguistic algorithm.

The default implementation of this function just returns false.

Parameters
aTextA string containing characters of class ESaLineBreakClass.
aMinBreakPosA position within aText at which to begin searching for a possible line break position.
aMaxBreakPosA position within aText at which to stop searching for a possible line break position.
aForwardsIf ETrue, the function gets the first possible line break position (searches forwards from aMinBreakPos); if EFalse, gets the last one (searches backwards from aMaxBreakPos).
aBreakPosOn return, the position of the first or last possible line break within aText. This must be greater than zero and less than aText.Length()1, and must also be in the range aMinBreakPos to aMaxBreakPos.
Return Value
ETrue if a possible line break position is found, EFalse if not.

IsHangingCharacter ( TUint )

IMPORT_C TBoolIsHangingCharacter(TUintaChar)const [virtual]

Tests whether a character can overhang the right margin.

This function can be overridden to customise the line breaking behaviour for closing punctuation in Japanese. Any characters for which this function returns ETrue are allowed to overhang the right margin. The rest will be moved to the next line.

The default implementation of this function just returns false.

Parameters
aCharThe Unicode character code of interest.
Return Value
ETrue if the character specified can overhang the right margin, EFalse if not.

LineBreakClass ( TUint, TUint &, TUint & )

IMPORT_C TUintLineBreakClass(TUintaCode,
TUint &aRangeStart,
TUint &aRangeEnd
)const [virtual]

Returns the line break class for a Unicode character.

For convenience, it also gets the range of consecutive characters (if any) according to the Unicode standard, including aCode, that share the same line break class.

The Unicode line break classes are enumerated in class MTmCustom.

Each character's line break class is obtained using LineBreakClass(). To find out whether a line break is allowed between two adjacent characters, call LineBreakPossible() with the line break classes of the two characters as arguments. For example, the line break class EClLineBreakClass (closing punctuation) applies to characters such as ")", "]" and ";". Line breaks are typically allowed after these characters, but not before, so a call to LineBreakPossible() with the arguments (EAlLineBreakClass, EClLineBreakClass) would return EFalse in the default implementation, but a call with (EClLineBreakClass, EAlLineBreakClass) would return ETrue.

Parameters
aCodeThe Unicode character code of interest.
aRangeStartOn return, contains the Unicode character code at the start of the range including aCode that shares the same line break class as aCode.
aRangeEndOn return, contains the Unicode character code at the end of the range including aCode that shares the same line break class as aCode.
Return Value
The line break class assigned to the character. Line break classes are enumerated in class MTmCustom.

LineBreakPossible ( TUint, TUint, TBool )

IMPORT_C TBoolLineBreakPossible(TUintaPrevClass,
TUintaNextClass,
TBoolaHaveSpaces
)const [virtual]

Tests whether a line break is possible between two characters.

If aHaveSpaces is true, the characters are not adjacent one or more space characters (with a line break class of ESpLineBreakClass) occur between them.

The aPrevClass and aNextClass arguments never have the value ESpLineBreakClass. Instead, this function is called with the classes of the characters on either side of the space or run of spaces, (and if so, aHaveSpaces is true). This is so that line breaks can be prohibited between certain characters with intervening spaces, for instance an alphabetic character (EAlLineBreakClass, such as 'a') and a closing bracket, with a space inbetween.

Additionally, the arguments to this function never have a value of ESaLineBreakClass. For such characters, GetLineBreakInContext() is called instead.

Parameters
aPrevClassThe line break class of the previous non-space character.
aNextClassThe line break class of the next non-space character.
aHaveSpacesETrue if there are one or more space characters (with a line break class of ESpLineBreakClass) between aPrevClass and aNextClass. EFalse if not.
Return Value
ETrue if a line break is possible between characters with the two line break classes, EFalse if not.