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

Constructor & Destructor Documentation

TRangeChange(TInt, TInt, TChangeType)

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

TInt aStart The start position.
TInt aEnd The end position.
TChangeType aChange Specifies whether the highlighting should be set or cleared.

TRangeChange()

IMPORT_C TRangeChange ( )

Member Functions Documentation

Clip(TInt, TInt)

IMPORT_C TBool Clip ( TInt aMin,
TInt aMax
)

Parameters

TInt aMin
TInt aMax

IsJoinedTo(const TRangeChange)

TBool IsJoinedTo ( const TRangeChange aRange )

Parameters

const TRangeChange aRange

Join(const TRangeChange)

void Join ( const TRangeChange aRange )

Parameters

const TRangeChange aRange

NonNull()

IMPORT_C TBool NonNull ( ) const

OptimizeWith(TRangeChange &)

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

TRangeChange & aBuddy The range of characters to combine with this range.

Set(TInt, TInt, TChangeType)

IMPORT_C void Set ( TInt aStart,
TInt aEnd,
TChangeType aChange
)

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]