Location:
FRMTLAY.H
Link against: form.lib
class MFormCustomWrap;
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()
.
Defined in MFormCustomWrap
:
GetLineBreakInContext()
, IsHangingCharacter()
, LineBreakClass()
, LineBreakPossible()
virtual IMPORT_C TUint LineBreakClass(TUint aCode, TUint &aRangeStart, TUint &aRangeEnd) const;
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.
|
|
virtual IMPORT_C TBool LineBreakPossible(TUint aPrevClass, TUint aNextClass, TBool aHaveSpaces) const;
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.
|
|
virtual IMPORT_C TBool GetLineBreakInContext(const TDesC &aText, TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards, TInt
&aBreakPos) const;
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.
|
|
virtual IMPORT_C TBool IsHangingCharacter(TUint aChar) const;
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.
|
|