#include <frmtlay.h>
class CTextLayout::TRangeChange |
Public Member Enumerations | |
---|---|
enum | TChangeType { ESet, EClear } |
Public Member Functions | |
---|---|
TRangeChange(TInt, TInt, TChangeType) | |
TRangeChange() | |
IMPORT_C TBool | Clip(TInt, TInt) |
IMPORT_C TChangeType | Get(TInt &, TInt &) |
TBool | IsJoinedTo(const TRangeChange) |
void | Join(const TRangeChange) |
IMPORT_C TBool | NonNull() |
IMPORT_C void | OptimizeWith(TRangeChange &) |
IMPORT_C void | Set(TInt, TInt, TChangeType) |
Specifies the range of characters involved when setting or clearing a text selection.
This class is used in the CTextLayout::Highlight() function. The following code demonstrates how it should be used to clear an existing highlight and set a new one:
CTextLayout::TRangeChange oldHighlight(anchorPos, old_cursorPos, CTextLayout::TRangeChange::EClear); // existing highlight CTextLayout::TRangeChange newHighlight(anchorPos, new_cursorPos, CTextLayout::TRangeChange::ESet); // new one newHighlight.OptimizeWith(oldHighlight); // doesn't matter which range is the parameter and which is the calling object layout.Highlight(oldHighlight,drawRect,context); // doesn't matter in which order this and following line occur layout.Highlight(newHighlight,drawRect,context);
See also: CTextLayout::Highlight()
IMPORT_C | TRangeChange | ( | TInt | aStart, |
TInt | aEnd, | |||
TChangeType | aChange | |||
) |
Constructor with a start and end position and whether the highlighting in the range should be set or cleared.
The start and end positions can be specified in any order.
Parameters | |
---|---|
aStart | The start position. |
aEnd | The end position. |
aChange | Specifies whether the highlighting should be set or cleared. |
IMPORT_C | TRangeChange | ( | ) |
Default constructor.
The start and end positions are set to zero - Set() should be called to initialise the object.
Clips the range so that its start and end positions are within the minimum and maximum positions specified.
Parameters | |
---|---|
aMin | The minimum value for the start and end of the range. |
aMax | The maximum value for the start and end of the range. |
IMPORT_C TChangeType | Get | ( | TInt & | aStart, |
TInt & | aEnd | |||
) | const |
Gets the start and end of the range and whether the highlighting should be set or cleared.
Parameters | |
---|---|
aStart | On return, the start of the range. This is always the lesser of the two positions. |
aEnd | On return, the end of the range. This is always the greater of the two positions. |
TBool | IsJoinedTo | ( | const TRangeChange | aRange | ) |
void | Join | ( | const TRangeChange | aRange | ) |
IMPORT_C TBool | NonNull | ( | ) | const |
Tests whether the range is not null.
IMPORT_C void | OptimizeWith | ( | TRangeChange & | aBuddy | ) |
Try to cancel out sections of the ranges that overlap Merges two ranges of characters.
Two successive calls to CTextLayout::Highlight() could cause unecessary flicker or redrawing if the arguments to each call overlap. For example, if extending a highlight involved removing the old highlight and then drawing the new one, this would cause visible flicker. This can be eliminated by calling this function to remove any overlap between the two ranges. If there is overlap, this range is set to the result of the merge, and the other range (aBuddy) is set to zero.
When calling this function, it does not matter whether or not the two ranges overlap. Also it does not matter which range is the parameter and which is the calling object. After calling OptimizeWith(), it is guaranteed that the resulting ranges will not overlap, and they will represent the same change to the highlight as the original two ranges.
See the code fragment in the class description for TRangeChange for an example of how this function is used.
Parameters | |
---|---|
aBuddy | The range of characters to combine with this range. |
IMPORT_C void | Set | ( | TInt | aStart, |
TInt | aEnd, | |||
TChangeType | aChange | |||
) |
Sets the start and end positions and whether the highlighting should be set or cleared.
Called by the non-default constructor. The start and end positions can be specified in any order.
Parameters | |
---|---|
aStart | The start of the range. |
aEnd | The end of the range. |
aChange | Whether the highlighting should be set or cleared. |