![](../../../Home/Icons/Home.gif)
![](../icons/UpBook.gif)
![](../icons/BookContext.gif)
![](../../../Home/Icons/Search.gif)
![](../../../Home/Icons/Help.gif)
![](../../icons/button_contents.gif)
![](../../icons/button_previous.gif)
TTextLineLayout provides functions that calculate a highlight area for a specified region of text within a line. The highlighting functions take a TTextRange specifying the selected range of text to be highlighted, or a TTextRegion for discontiguous selections. Typically, you create the range based on a beginning and ending TInsertionOffset computed from the positions of mouse events (converting mouse events to TInsertionOffset instances is described in "Supporting discontiguous selections" on page 159).
To compute a highlight area, use one of the following:
- GetHighlightArea computes the highlight area for the range.
- AddToHighlightArea computes the highlight area for the range and adds it to another specified highlight area. You can use this, for example, to calculate the total highlight area for multiple lines of text.
These functions use two variables to determine the highlighting behavior. You can specify whether to use any fixed line-height values, which causes the highlight area to be limited to the specified line height. You can also specify whether to include the view margins in the highlight area. If the view margins are included, the highlight area includes the white space in the view before the first character on the line and after the last character on the line. The view margins are set in the TLinePlacement instance owned by the TTextLineLayout.
NOTE
When you implement highlighting functionality, you should recompute the highlight area for the whole line rather than for only newly selected characters. Highlighting only newly selected characters can result in white gaps between characters, because the highlight areas are sloped to match the slope of the selected text. The highlight areas of adjacent characters can overlap and may cause gaps when the overlapping areas are intersected
several times.
To control whether the highlight areas are sloped, use the following functions:
- SetAngledHighlight
- SetAverageAngleAtCaretSplits
When SetAngledHighlight is True and SetAverageAngleAtCaretSplits is False, TTextLineLayout slopes the highlight area to match the characters at the end points. When both are True, the slope of the highlight area is averaged at the end points.
You can also implement selection functionality that causes the selection cursor to assume the slope of the text currently under the cursor. For example, this can make it easier for the end user to select italic text. To do this, use the GetCursorSlope function to get the appropriate slope for the cursor. GetCursorSlope takes a position and returns the slope and the area for which that slope is valid. You can cache the returned area so that you don't need to make as many calls to this function while tracking the cursor.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker