![]() |
ATSUHighlightText |
||||
Header: | ATSUnicode.h | Carbon status: | Supported | |
Highlights a range of text.
OSStatus ATSUHighlightText ( ATSUTextLayout iTextLayout, ATSUTextMeasurement iTextBasePointX, ATSUTextMeasurement iTextBasePointY, UniCharArrayOffset iHighlightStart, UniCharCount iHighlightLength );
A reference to an initialized text layout object containing the range of text you wish to highlight. You cannot pass NULL for this parameter.
The x-coordinate of the origin (in the current graphics port) of the line containing the range of text you want to highlight. Pass the constant kATSUUseGrafPortPenLoc, described in
The y-coordinate of the origin (in the current graphics port) of the line containing the range of text you want to highlight. Pass the constant kATSUUseGrafPortPenLoc, described in
The edge offset that corresponds to the beginning of the range of text that you want to highlight. If the range of text spans multiple lines, you should call ATSUHighlightText for each line and pass the offset of the beginning of the new line you want to highlight. To specify the beginning of the text buffer, pass the constant kATSUFromTextBeginning, described in
The length of the range of text that you want to highlight. If you want the length to extend to the end of the text buffer, pass the constant kATSUToTextEnd, described in
A result code. The result code kATSUInvalidCacheErr indicates that an attempt was made to read in style data from an invalid cache. This may be because the format of the cached data does not match that used by ATSUI or the cached data is corrupt. The result code kATSUQuickDrawTextErr indicates that the QuickDraw function DrawText encountered an error while measuring a line of text.
The ATSUHighlightText function highlights a range of text using the highlight information in the graphics port.
Before calculating the highlighting dimensions, ATSUHighlightText turns off any previously set line justification, rotation, width alignment, descent, and ascent values and treats the text as a single line. It then examines the text layout object to make sure that the style runs cover the entire range of text. If there are gaps between style runs, ATSUHighlightText assigns the characters in the gap to the style run following the gap. If there is no style run at the beginning of the range of text, ATSUHighlightText assigns these characters to the first style run it can find. If there no style run at the end of the range of text, ATSUHighlightText assigns the remaining characters to the last style run it can find.
If you want to highlight a range of text that spans multiple lines, you should call ATSUHighlightText for each line of text that is being highlighted, even if all the lines are in the same text layout object. You should adjust the iHighlightStart parameter to reflect the beginning of each line to be highlighted.
You can extend highlighting across tab stops by setting the bits specified by the mask constants kATSLineFillOutToWidth and kATSLineImposeNoAngleForEnds, described in
ATSUHighlightText uses the previously set line ascent and descent values to calculate the height of the highlighted region. If these values have not been set for the line, ATSUHighlightText uses the line ascent and descent values set for the text layout object containing the line. If these are not set, it uses the default values.
ATSUHighlightText may allocate memory in your application heap, unless you designate a different heap by calling the function ATSUCreateMemorySetting.
Available beginning with ATSUI 1.0.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.5 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)