CTextLayout::TRangeChange Class Reference

class CTextLayout::TRangeChange

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

CTextLayout::Highlight()

Public Member Functions
TRangeChange(TInt, TInt, TChangeType)
TRangeChange()
IMPORT_C TBoolClip(TInt, TInt)
TBool IsJoinedTo(const TRangeChange)
voidJoin(const TRangeChange)
IMPORT_C TBoolNonNull()
IMPORT_C voidOptimizeWith(TRangeChange &)
IMPORT_C voidSet(TInt, TInt, TChangeType)
Public Member Enumerations
enumTChangeType { ESet, EClear }
Private Attributes
TInt iA
TInt iB

Constructor & Destructor Documentation

TRangeChange(TInt, TInt, TChangeType)

IMPORT_CTRangeChange(TIntaStart,
TIntaEnd,
TChangeTypeaChange
)

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

TInt aStartThe start position.
TInt aEndThe end position.
TChangeType aChangeSpecifies whether the highlighting should be set or cleared.

TRangeChange()

IMPORT_CTRangeChange()

Member Functions Documentation

Clip(TInt, TInt)

IMPORT_C TBoolClip(TIntaMin,
TIntaMax
)

Parameters

TInt aMin
TInt aMax

IsJoinedTo(const TRangeChange)

TBool IsJoinedTo(const TRangeChangeaRange)

Parameters

const TRangeChange aRange

Join(const TRangeChange)

voidJoin(const TRangeChangeaRange)

Parameters

const TRangeChange aRange

NonNull()

IMPORT_C TBoolNonNull()const

OptimizeWith(TRangeChange &)

IMPORT_C voidOptimizeWith(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

TRangeChange & aBuddyThe range of characters to combine with this range.

Set(TInt, TInt, TChangeType)

IMPORT_C voidSet(TIntaStart,
TIntaEnd,
TChangeTypeaChange
)

Parameters

TInt aStart
TInt aEnd
TChangeType aChange

Member Enumerations Documentation

Enum TChangeType

Enumerates the possible change types.

Enumerators

ESet

The object is being used to set a range.

EClear

The object is being used to clear a range.

Member Data Documentation

TInt iA

TInt iA[private]

TInt iB

TInt iB[private]