ATSUnicodeDrawing.pas 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695
  1. {
  2. File: QD/ATSUnicodeDrawing.h
  3. Contains: ATSUI drawing, measuring, and highlighting functions.
  4. Version: Quickdraw-150~1
  5. Copyright: © 2003 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit ATSUnicodeDrawing;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,TextCommon,Quickdraw,ATSLayoutTypes,ATSUnicodeTypes;
  92. {$ALIGN MAC68K}
  93. { ---------------------------------------------------------------------------- }
  94. { ATSUI drawing and measuring }
  95. { ---------------------------------------------------------------------------- }
  96. {
  97. * ATSUDrawText()
  98. *
  99. * Summary:
  100. * Draws a specified range of text in a QuickDraw graphics port or
  101. * Quartz graphics context.
  102. *
  103. * Discussion:
  104. * Before calling ATSUDrawText, you will most likely want to call
  105. * ATSUSetLayoutControls to set a value for the kATSUCGContextTag
  106. * attribute in order to specify your current graphics context.
  107. * Otherwise, ATSUI will attempt to draw using Quickdraw style text
  108. * rendering in whatever Quickdraw GrafPort is currently active (use
  109. * SetPort to determine the currently active Quickdraw GrafPort, see
  110. * Quickdraw.h). Carbon applications can create a CGContext from a
  111. * Quickdraw GrafPort using the functions QDBeginCGContext and
  112. * QDEndCGContext (see Quickdraw.h). Cocoa applications can call the
  113. * method "graphicsPort" on the current NSGraphicsContext in order
  114. * to get a CGContextRef to pass into ATSUI (use the method
  115. * "currentContext" to obtain the current NSGraphicsContext, see
  116. * NSGraphicsContext.h for more information). ATSUDrawText examines
  117. * the text layout object to ensure that each of the characters in
  118. * the range is assigned to a style run. If there are gaps between
  119. * style runs, ATSUI assigns the characters in the gap to the style
  120. * run that precedes (in storage order) the gap. If there is no
  121. * style run at the beginning of the text range, ATSUI assigns these
  122. * characters to the first style run it finds. If there is no style
  123. * run at the end of the text range, ATSUI assigns the remaining
  124. * characters to the last style run it finds. If you want to draw a
  125. * range of text that spans multiple lines, you should call
  126. * ATSUDrawText for each line of text to draw, even if all the lines
  127. * are in the same text layout object. You should adjust the
  128. * iLineOffset parameter to reflect the beginning of each line to be
  129. * drawn. Please note that when drawing into a GrafPort, calls to
  130. * QDSwapTextFlags have no effect on ATSUI text rendering. The
  131. * proper way to achieve Quartz text rendering from ATSUI is to use
  132. * the kATSUCGContextTag attribute to specify a CGContextRef in each
  133. * ATSUTextLayout before calling ATSUDrawText.
  134. *
  135. * Parameters:
  136. *
  137. * iTextLayout:
  138. * A layout containing text to draw.
  139. *
  140. * iLineOffset:
  141. * The starting offset of the range of text to draw. To specify
  142. * the beginning of the text buffer, pass kATSUFromTextBeginning
  143. * for this parameter.
  144. *
  145. * iLineLength:
  146. * The length of the range of text to draw. To specify a range
  147. * that continues to the end of the text buffer, pass
  148. * kATSUToTextEnd for this parameter.
  149. *
  150. * iLocationX:
  151. * The x-coordinate of the origin (in either the current graphics
  152. * port or Quartz graphics context) of the line containing the
  153. * text range to render. Note that the ATSUTextMeasurement type is
  154. * defined as a Fixed value, so you must ensure that your
  155. * coordinates are converted to Fixed values before passing them
  156. * to this function (see FixMath.h for conversion functions). Pass
  157. * the constant kATSUUseGrafPortPenLoc to draw relative to the
  158. * current pen location in the current graphics port.
  159. *
  160. * iLocationY:
  161. * The y-coordinate of the origin (in either the current graphics
  162. * port or Quartz graphics context) of the line containing the
  163. * text range to render. Note that the ATSUTextMeasurement type is
  164. * defined as a Fixed value, so you must ensure that your
  165. * coordinates are converted to Fixed values before passing them
  166. * to this function (see FixMath.h for conversion functions). Pass
  167. * the constant kATSUUseGrafPortPenLoc to draw relative to the
  168. * current pen location in the current graphics port.
  169. *
  170. * Result:
  171. * On success, noErr is returned. See MacErrors.h for possible error
  172. * codes.
  173. *
  174. * Availability:
  175. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  176. * CarbonLib: in CarbonLib 1.0 and later
  177. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  178. }
  179. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  180. function ATSUDrawText( iTextLayout: ATSUTextLayout; iLineOffset: UniCharArrayOffset; iLineLength: UniCharCount; iLocationX: ATSUTextMeasurement; iLocationY: ATSUTextMeasurement ): OSStatus; external name '_ATSUDrawText';
  181. {
  182. * ATSUGetUnjustifiedBounds()
  183. *
  184. * Summary:
  185. * Obtains the typographic bounding rectangle for a line of text
  186. * prior to final layout.
  187. *
  188. * Discussion:
  189. * This function calculates the typographic bounds (in coordinates
  190. * independent of the rendering device) for a line of text. Note
  191. * that ATSUGetUnjustifiedBounds calculates these bounds prior to
  192. * the text's final layout, and therefore, the calculated bounds
  193. * might not reflect those of the final laid-out line.
  194. * Justification, truncation, and device level positioning are not
  195. * taken into account. To obtain the typographic bounds of a line
  196. * after it is laid out, you can call the function
  197. * ATSUGetGlyphBounds. For more infomration about the difference
  198. * between typographic and image bounds, please refer to the ATSUI
  199. * documentation. Note that ATSUGetUnjustifiedBounds treats the
  200. * specified text range as a single line. That is, if the range of
  201. * text you specify is less than a line, it nevertheless treats the
  202. * initial character in the range as the start of a line, for
  203. * measuring purposes. If the range of text extends beyond a line,
  204. * ATSUGetUnjustifiedBounds ignores soft line breaks, again,
  205. * treating the text as a single line.
  206. *
  207. * Parameters:
  208. *
  209. * iTextLayout:
  210. * The text layout object to obtain bounds information for.
  211. *
  212. * iLineStart:
  213. * The start of the line of text to obtain bounds information for.
  214. * To indicate that the line starts at the beginning of the text
  215. * buffer, you can pass the constant kATSUFromTextBeginning . To
  216. * specify the entire text buffer, pass kATSUFromTextBeginning in
  217. * this parameter and kATSUToTextEnd in the iLineLength parameter.
  218. *
  219. * iLineLength:
  220. * The length of the line to obtain bounds information for. If you
  221. * want the line to extend to the end of the text buffer, you can
  222. * pass the constant kATSUToTextEnd .
  223. *
  224. * oTextBefore:
  225. * On return, the value specifies the starting point of the
  226. * typographic bounds for the line, relative to the origin (0,0)
  227. * of the line and taking into account cross-stream shifting. Note
  228. * that the ATSUMeasureText function might produce negative values
  229. * for the typographic starting point of the line if, for example,
  230. * the initial character of the line is allowed to hang into the
  231. * margin. For horizontal text, this value corresponds to the left
  232. * side of the bounding rectangle.
  233. *
  234. * oTextAfter:
  235. * On return, the end point of the typographic bounds for the
  236. * line, relative to the origin (0,0) of the line and taking into
  237. * account cross-stream shifting. For horizontal text, this value
  238. * corresponds to the right side of the bounding rectangle.
  239. *
  240. * oAscent:
  241. * On return, the typographic bounds for the line, relative to the
  242. * origin (0,0) of the line and taking into account cross-stream
  243. * shifting. For horizontal text, this value corresponds to the
  244. * top side of the bounding rectangle.
  245. *
  246. * oDescent:
  247. * On return, the typographic bounds for the line, relative to the
  248. * origin (0,0) of the line and taking into account cross-stream
  249. * shifting. For horizontal text, this value corresponds to the
  250. * bottom side of the bounding rectangle.
  251. *
  252. * Result:
  253. * On success, noErr is returned. See MacErrors.h for possible error
  254. * codes.
  255. *
  256. * Availability:
  257. * Mac OS X: in version 10.2 and later in ApplicationServices.framework
  258. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  259. * Non-Carbon CFM: not available
  260. }
  261. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  262. function ATSUGetUnjustifiedBounds( iTextLayout: ATSUTextLayout; iLineStart: UniCharArrayOffset; iLineLength: UniCharCount; var oTextBefore: ATSUTextMeasurement; var oTextAfter: ATSUTextMeasurement; var oAscent: ATSUTextMeasurement; var oDescent: ATSUTextMeasurement ): OSStatus; external name '_ATSUGetUnjustifiedBounds';
  263. {
  264. * ATSUMeasureTextImage()
  265. *
  266. * Summary:
  267. * Obtains the image bounding rectangle for a line of text after
  268. * final layout.
  269. *
  270. * Discussion:
  271. * This function obtains the image bounds of a laid-out line of
  272. * text. These bounds are described by the smallest rectangle that
  273. * completely encloses the filled or framed parts of a block of
  274. * textÑthat is, the text's "inked" glyphs. In measuring the line,
  275. * the ATSUMeasureTextImage function takes into account line
  276. * rotation, alignment, and justification, as well as other
  277. * characteristics that affect layout, such as hanging punctuation.
  278. * (If the line is rotated, the sides of the rectangle are parallel
  279. * to the coordinate axes and encompass the rotated line.) If no
  280. * attributes are set for the line, ATSUMeasureTextImage uses the
  281. * global attributes set for the text layout object. Because the
  282. * height of the image bounding rectangle is determined by the
  283. * actual device metrics, ATSUMeasureTextImage ignores any
  284. * previously set line ascent and descent values for the line it is
  285. * measuring.
  286. *
  287. * Parameters:
  288. *
  289. * iTextLayout:
  290. * The text layout for which to obtain image bounds.
  291. *
  292. * iLineOffset:
  293. * The first character of the line to examine. To indicate that
  294. * the specified line starts at the beginning of the text buffer,
  295. * you can pass the constant kATSUFromTextBeginning . To specify
  296. * the entire text buffer, pass kATSUFromTextBeginning in this
  297. * parameter and kATSUToTextEnd in the iLineLength parameter.
  298. *
  299. * iLineLength:
  300. * The length of the text range. If you want the range of text to
  301. * extend to the end of the text buffer, you can pass the constant
  302. * kATSUToTextEnd . However, the image bounds is restricted to the
  303. * line in which iLineOffset resides.
  304. *
  305. * iLocationX:
  306. * The x-coordinate of the line's origin in the current graphics
  307. * port or Quartz graphics context. Pass the constant
  308. * kATSUUseGrafPortPenLoc for the dimensions of the bounds
  309. * relative to the current pen location in the current graphics
  310. * port or graphics context. You can pass 0to obtain only the
  311. * dimensions of the bounding rectangle relative to one another,
  312. * not their actual onscreen position.
  313. *
  314. * iLocationY:
  315. * The y-coordinate of the line's origin in the current graphics
  316. * port or Quartz graphics context. Pass the constant
  317. * kATSUUseGrafPortPenLoc for the dimensions of the bounds
  318. * relative to the current pen location in the current graphics
  319. * port or graphics context. You can pass 0to obtain only the
  320. * dimensions of the bounding rectangle relative to one another,
  321. * not their actual onscreen position.
  322. *
  323. * oTextImageRect:
  324. * On return, the dimensions of the image bounding rectangle for
  325. * the text, offset by the values specified in the iLocationX and
  326. * iLocationY parameters. If the line is rotated, the sides of the
  327. * rectangle are parallel to the coordinate axis.
  328. *
  329. * Result:
  330. * On success, noErr is returned. See MacErrors.h for possible error
  331. * codes.
  332. *
  333. * Availability:
  334. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  335. * CarbonLib: in CarbonLib 1.0 and later
  336. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  337. }
  338. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  339. function ATSUMeasureTextImage( iTextLayout: ATSUTextLayout; iLineOffset: UniCharArrayOffset; iLineLength: UniCharCount; iLocationX: ATSUTextMeasurement; iLocationY: ATSUTextMeasurement; var oTextImageRect: Rect ): OSStatus; external name '_ATSUMeasureTextImage';
  340. {
  341. * ATSUGetGlyphBounds()
  342. *
  343. * Summary:
  344. * Obtains the typographic bounds of a line of glyphs after final
  345. * layout.
  346. *
  347. * Discussion:
  348. * This function produces the enclosing trapezoid(s) that represent
  349. * the typographic bounds for glyphs in a final, laid-out range of
  350. * text. You typically call this function when you need to obtain an
  351. * enclosing trapezoid for a line, taking rotation and all other
  352. * layout attributes into account. ATSUI determines the height of
  353. * each trapezoid by examining any line ascent and descent attribute
  354. * values you may have set for the line. If you have not set these
  355. * attributes for the line, the ATSUGetGlyphBounds function uses any
  356. * line ascent and descent values you may have set for the text
  357. * layout object containing the line. If these are not set,
  358. * ATSUGetGlyphBounds uses the font's natural line ascent and
  359. * descent values for the line. If these are previously set,
  360. * ATSUGetGlyphBounds uses the ATSUStyle ascent and or
  361. * descent/leading values. Note that the coordinates produced for
  362. * the trapezoid(s) are offset by the amount specified in the
  363. * iTextBasePointX and iTextBasePointY parameters. If your goal in
  364. * calling the ATSUGetGlyphBounds function is to obtain metrics for
  365. * drawing the typographic bounds on the screen, pass the position
  366. * of the origin of the line in the current graphics port or
  367. * graphics context in these parameters. This enables
  368. * ATSUGetGlyphBounds to match the trapezoids to their onscreen
  369. * image. When the range specified by the iBoundsCharStart and
  370. * iBoundsCharLength parameters covers an entire line, you are
  371. * guaranteed to receive only one trapezoid on return. Otherwise,
  372. * multiple trapezoids may be returned to cover incomplete sections
  373. * of bidi runs. In such cases, you would typically call
  374. * ATSUGetGlyphBounds twice, as follows: (1) Pass NULL for the
  375. * oGlyphBounds parameter, 0 for the iMaxNumberOfBounds parameter,
  376. * and valid values for the other parameters. The ATSUGetGlyphBounds
  377. * function returns the actual number of trapezoids needed to
  378. * enclose the glyphs in the oActualNumberOfBounds parameter. (2)
  379. * Allocate enough space for a buffer of the returned size, then
  380. * call the function again, passing a valid pointer to the buffer in
  381. * the oGlyphBounds parameter. On return, the buffer contains the
  382. * trapezoids for the glyphs' typographic bounds. To obtain the
  383. * typographic bounds of a line of text prior to line layout, call
  384. * the function ATSUGetUnjustifiedBounds. To calculate the image
  385. * bounding rectangle for a final laid-out line, call the function
  386. * ATSUMeasureTextImage. For more infomration about the difference
  387. * between typographic and image bounds, please refer to the ATSUI
  388. * documentation.
  389. *
  390. * Parameters:
  391. *
  392. * iTextLayout:
  393. * The text layout object for which glyph bounds are to be
  394. * obtained.
  395. *
  396. * iTextBasePointX:
  397. * The x-coordinate of the origin of the line containing the
  398. * glyphs in the current graphics port or Quartz graphics context.
  399. * Pass the constant kATSUUseGrafPortPenLoc to obtain the glyph
  400. * bounds relative to the current pen location in the current
  401. * graphics port or graphics context. You may pass 0 to obtain
  402. * only the dimensions of the bounds relative to one another, not
  403. * their actual onscreen position.
  404. *
  405. * iTextBasePointY:
  406. * The y-coordinate of the origin of the line containing the
  407. * glyphs in the current graphics port or Quartz graphics context.
  408. * Pass the constant kATSUUseGrafPortPenLoc to obtain the glyph
  409. * bounds relative to the current pen location in the current
  410. * graphics port or graphics context. You may pass 0 to obtain
  411. * only the dimensions of the bounds relative to one another, not
  412. * their actual onscreen position.
  413. *
  414. * iBoundsCharStart:
  415. * The offset from the beginning of the text buffer to the
  416. * character corresponding to the first glyph to measure. To
  417. * indicate that the text range starts at the beginning of the
  418. * text buffer, you can pass the constant kATSUFromTextBeginning.
  419. *
  420. * iBoundsCharLength:
  421. * The length of text range to measure. If you want the range to
  422. * extend to the end of the text buffer, you can pass the constant
  423. * kATSUToTextEnd.
  424. *
  425. * iTypeOfBounds:
  426. * The type of bounds you wish to obtain. See ATSLayoutTypes.h for
  427. * a list of possible values to pass in here.
  428. *
  429. * iMaxNumberOfBounds:
  430. * The maximum number of bounding trapezoids to obtain. Typically,
  431. * this is equivalent to the number of bounds in the oGlyphBounds
  432. * array. To determine this value, see the Discussion.
  433. *
  434. * oGlyphBounds:
  435. * A pointer to memory you have allocated for an array of
  436. * ATSTrapezoid values. On return, the array contains a trapezoid
  437. * representing the typographic bounds for glyphs in the text
  438. * range. If the specified range of text encloses nested
  439. * bidirectional text, ATSUGetGlyphBounds produces multiple
  440. * trapezoids defining these regions.In ATSUI 1.1, the maximum
  441. * number of enclosing trapezoids that can be returned is 31; in
  442. * ATSUI 1.2, the maximum number is 127. If you pass a range that
  443. * covers an entire line, ATSUGetGlyphBounds always returns only 1
  444. * trapezoid. If you are uncertain of how much memory to allocate
  445. * for this array, see the Discussion. can be NULL
  446. *
  447. * oActualNumberOfBounds:
  448. * On return, the value specifies the actual number of enclosing
  449. * trapezoids bounding the specified characters. This may be
  450. * greater than the value you provide in the iMaxNumberOfBounds
  451. * parameter. can be NULL
  452. *
  453. * Result:
  454. * On success, noErr is returned. See MacErrors.h for possible error
  455. * codes.
  456. *
  457. * Availability:
  458. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  459. * CarbonLib: in CarbonLib 1.0 and later
  460. * Non-Carbon CFM: in ATSUnicodeLib 8.6 and later
  461. }
  462. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  463. function ATSUGetGlyphBounds( iTextLayout: ATSUTextLayout; iTextBasePointX: ATSUTextMeasurement; iTextBasePointY: ATSUTextMeasurement; iBoundsCharStart: UniCharArrayOffset; iBoundsCharLength: UniCharCount; iTypeOfBounds: UInt16; iMaxNumberOfBounds: ItemCount; oGlyphBounds: ATSTrapezoidPtr; var oActualNumberOfBounds: ItemCount ): OSStatus; external name '_ATSUGetGlyphBounds';
  464. { ---------------------------------------------------------------------------- }
  465. { ATSUI line breaking }
  466. { ---------------------------------------------------------------------------- }
  467. {
  468. * ATSUBatchBreakLines()
  469. *
  470. * Summary:
  471. * Soft wraps a range of text in a layout to a constant line width.
  472. *
  473. * Discussion:
  474. * Equivalent to repeatedly calling the ATSUBreakLine function with
  475. * the parameter iUseAsSoftLineBreak set to true. Use this function
  476. * to gain a substantial performance increase over the use of
  477. * ATSUBreakLine. It will set soft breaks in a layout for multiple
  478. * lines in a single call. It assumes constant line width. Soft line
  479. * breaks within a layout are what divide it into lines. You can
  480. * manipulate the soft breaks that are currently set within a layout
  481. * using the functions ATSUGetSoftLineBreaks, ATSUSetSoftLineBreak,
  482. * and ATSUClearSoftLineBreaks.
  483. *
  484. * Parameters:
  485. *
  486. * iTextLayout:
  487. * The layout containing text to be soft wrapped.
  488. *
  489. * iRangeStart:
  490. * Beginning offset for the rage of text to be soft wrapped.
  491. *
  492. * iRangeLength:
  493. * The length of the range of text to be soft wrapped.
  494. *
  495. * iLineWidth:
  496. * The line width at which to force soft wrapping of text. Note
  497. * that this parameter is of type ATSUTextMeasurement, which is
  498. * defined as Fixed. See FixMath.h for conversion routines for
  499. * fixed point values.
  500. *
  501. * oBreakCount:
  502. * On return, the number of soft breaks that were set in the
  503. * layout. Use this to determine how much memory to allocate when
  504. * calling ATSUGetSoftLineBreaks. can be NULL
  505. *
  506. * Result:
  507. * On success, noErr is returned. See MacErrors.h for possible error
  508. * codes.
  509. *
  510. * Availability:
  511. * Mac OS X: in version 10.2 and later in ApplicationServices.framework
  512. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  513. * Non-Carbon CFM: not available
  514. }
  515. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  516. function ATSUBatchBreakLines( iTextLayout: ATSUTextLayout; iRangeStart: UniCharArrayOffset; iRangeLength: UniCharCount; iLineWidth: ATSUTextMeasurement; oBreakCount: ItemCountPtr ): OSStatus; external name '_ATSUBatchBreakLines';
  517. {
  518. * ATSUBreakLine()
  519. *
  520. * Summary:
  521. * Soft wraps a single line of text within a layout.
  522. *
  523. * Discussion:
  524. * This function will automatically determine the optimal place to
  525. * set a soft break in a given range of text. It suggests a soft
  526. * line break each time it encounters a hard line break character
  527. * such as a carriage return, line feed, form feed, line separator,
  528. * or paragraph separator. If ATSUBreakLine does not encounter a
  529. * hard line break, it uses the line width you specify to determine
  530. * how many characters fit on a line and suggests soft line breaks
  531. * accordingly. You can loop over ATSUBreakLine, repeatedly calling
  532. * it on the same layout, until all the text in the entire layout
  533. * has been soft wrapped. However, for maximum efficiency, you
  534. * should use ATSUBatchBreakLines. ATSUBreakLine should only be used
  535. * if you have special needs, such as a non-constant line width.
  536. *
  537. * Parameters:
  538. *
  539. * iTextLayout:
  540. * The layout containing text to be soft wrapped.
  541. *
  542. * iLineStart:
  543. * The beginning of the line you wish to soft wrap. To specify the
  544. * beginning of the text buffer, pass the constant
  545. * kATSUFromTextBeginning.
  546. *
  547. * iLineWidth:
  548. * The line width at which to force soft wrapping of text. Note
  549. * that this parameter is of type ATSUTextMeasurement, which is
  550. * defined as Fixed. See FixMath.h for conversion routines for
  551. * fixed point values.
  552. *
  553. * iUseAsSoftLineBreak:
  554. * A Boolean value indicating whether ATSUBreakLine should
  555. * automatically set the line break produced in the oLineBreak
  556. * parameter. If true ,ATSUBreakLine sets the line break and
  557. * clears any previously-set soft line breaks that precede the new
  558. * break in the line but lie after the offset specified by
  559. * iLineStart. You should ususally pass true for this parameter,
  560. * unless you plan to use ATSUSetSoftLineBreak to set the soft
  561. * break somewhere other than what is suggested by ATSUBreakLine.
  562. *
  563. * oLineBreak:
  564. * On return, the value specifies the soft line break as
  565. * determined by ATSUBreakLine. If the value returned is the same
  566. * value as specified in iLineStart , you have made an input
  567. * parameter error. In this case, check to make sure that the line
  568. * width specified in iLineWidth is big enough for ATSUBreakLine
  569. * to perform line breaking. ATSUBreakLine does not return an
  570. * error in this case.
  571. *
  572. * Result:
  573. * On success, noErr is returned. TSUI usually calculates a soft
  574. * line break to be at the beginning of the first word that does ont
  575. * fit on the line. But if ATSUBreakLine calculates the most optimal
  576. * line break to be in the middle of a word, it returns the result
  577. * code kATSULineBreakInWord. Note that ATSUI produces a line break
  578. * in the middle of a word only as a last resort. See MacErrors.h
  579. * for other possible error codes. can be NULL
  580. *
  581. * Availability:
  582. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  583. * CarbonLib: in CarbonLib 1.0 and later
  584. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  585. }
  586. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  587. function ATSUBreakLine( iTextLayout: ATSUTextLayout; iLineStart: UniCharArrayOffset; iLineWidth: ATSUTextMeasurement; iUseAsSoftLineBreak: Boolean; oLineBreak: UniCharArrayOffsetPtr ): OSStatus; external name '_ATSUBreakLine';
  588. {
  589. * ATSUSetSoftLineBreak()
  590. *
  591. * Summary:
  592. * Sets a soft line break at the specified point in a text layout.
  593. *
  594. * Discussion:
  595. * You should typically only call ATSUSetSoftLineBreak to set line
  596. * breaks when you are using your own line-breaking algorithm to
  597. * calculate these breaks. For optimal performance, you should use
  598. * ATSUBatchBreakLines to both calculate and set soft line breaks in
  599. * your text. After calling ATSUSetSoftLineBreak , you should call
  600. * the function ATSUGetUnjustifiedBounds to determine whether the
  601. * characters still fit within the line, which is necessary due to
  602. * end-of-line effects such as swashes.
  603. *
  604. * Parameters:
  605. *
  606. * iTextLayout:
  607. * The layout in which to set the soft break.
  608. *
  609. * iLineBreak:
  610. * An offset into the text buffer specifying the location to set
  611. * the soft break at.
  612. *
  613. * Result:
  614. * On success, noErr is returned. See MacErrors.h for possible error
  615. * codes.
  616. *
  617. * Availability:
  618. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  619. * CarbonLib: in CarbonLib 1.0 and later
  620. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  621. }
  622. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  623. function ATSUSetSoftLineBreak( iTextLayout: ATSUTextLayout; iLineBreak: UniCharArrayOffset ): OSStatus; external name '_ATSUSetSoftLineBreak';
  624. {
  625. * ATSUGetSoftLineBreaks()
  626. *
  627. * Summary:
  628. * Obtains the soft line breaks that are currently set in a given
  629. * text range.
  630. *
  631. * Discussion:
  632. * Typically you use the function ATSUGetSoftLineBreaks by calling
  633. * it twice, as follows: (1) Pass valid values for the iTextLayout,
  634. * iRangeStart, iRangeLength, and oBreakCount parameters. Pass NULL
  635. * for the oBreaks parameter and 0 for the iMaximumBreaks parameter.
  636. * ATSUGetSoftLineBreaks returns the size of the font array in the
  637. * oBreakCount parameter. (2) Allocate enough space for an array of
  638. * the returned size, then call the function again, passing a valid
  639. * pointer in the oBreaks parameter. On return, the pointer refers
  640. * to an array containing the text range's soft line breaks. If you
  641. * have just called ATSUBatchBreakLines, the oBreakCount parameter
  642. * will give you the value you would normally obtain from step 1,
  643. * allowing you to skip this step in such cases.
  644. *
  645. * Parameters:
  646. *
  647. * iTextLayout:
  648. * A text layout to obtain a list of soft breaks from.
  649. *
  650. * iRangeStart:
  651. * The beginning of the range of text for which to obtain a list
  652. * of softbreaks. To indicate that the specified text range starts
  653. * at the beginning of the text buffer, you can pass the constant
  654. * kATSUFromTextBeginning, To specify the entire text buffer, pass
  655. * kATSUFromTextBeginning in this parameter and kATSUToTextEnd in
  656. * the iRangeLength parameter.
  657. *
  658. * iRangeLength:
  659. * The end of the range of text for which to obtain a list of
  660. * softbreaks. If you want the range of text to extend to the end
  661. * of the text buffer, you can pass the constant kATSUToTextEnd.
  662. *
  663. * iMaximumBreaks:
  664. * The maximum number of soft line breaks to obtain. Typically,
  665. * this is equivalent to the number of UniCharArrayOffset values
  666. * for which you have allocated memory in the oBreaks array. To
  667. * determine this value, see the Discussion.
  668. *
  669. * oBreaks:
  670. * On return, the array contains offsets from the beginning of the
  671. * text buffer to each of the soft line breaks in the text range.
  672. * If you are uncertain of how much memory to allocate for this
  673. * array, see the Discussion. can be NULL
  674. *
  675. * oBreakCount:
  676. * On return, the number of soft breaks set in iTextLayout. Note
  677. * that this value may be greater than what you pass in for
  678. * iMaximumBreaks. can be NULL
  679. *
  680. * Result:
  681. * On success, noErr is returned. See MacErrors.h for possible error
  682. * codes.
  683. *
  684. * Availability:
  685. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  686. * CarbonLib: in CarbonLib 1.0 and later
  687. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  688. }
  689. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  690. function ATSUGetSoftLineBreaks( iTextLayout: ATSUTextLayout; iRangeStart: UniCharArrayOffset; iRangeLength: UniCharCount; iMaximumBreaks: ItemCount; oBreaks: UniCharArrayOffsetPtr; oBreakCount: ItemCountPtr ): OSStatus; external name '_ATSUGetSoftLineBreaks';
  691. {
  692. * ATSUClearSoftLineBreaks()
  693. *
  694. * Summary:
  695. * Unsets any currently set soft breaks in a range of text.
  696. *
  697. * Discussion:
  698. * This function clears all previously set soft line breaks for the
  699. * specified text range and clears any associated layout caches as
  700. * well.
  701. *
  702. * Parameters:
  703. *
  704. * iTextLayout:
  705. * The text layout object for which to remove line breaks.
  706. *
  707. * iRangeStart:
  708. * The beginning of the text range over which to clear soft line
  709. * breaks. To indicate that the specified text range starts at the
  710. * beginning of the text buffer, you can pass the constant
  711. * kATSUFromTextBeginning . To specify the entire text buffer,
  712. * pass kATSUFromTextBeginning in this parameter and
  713. * kATSUToTextEnd in the iRangeLength parameter.
  714. *
  715. * iRangeLength:
  716. * The length of the text range over which to clear soft line
  717. * breaks. If you want the range of text to extend to the end of
  718. * the text buffer, you can pass the constant kATSUToTextEnd.
  719. *
  720. * Result:
  721. * On success, noErr is returned. See MacErrors.h for possible error
  722. * codes.
  723. *
  724. * Availability:
  725. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  726. * CarbonLib: in CarbonLib 1.0 and later
  727. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  728. }
  729. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  730. function ATSUClearSoftLineBreaks( iTextLayout: ATSUTextLayout; iRangeStart: UniCharArrayOffset; iRangeLength: UniCharCount ): OSStatus; external name '_ATSUClearSoftLineBreaks';
  731. { ---------------------------------------------------------------------------- }
  732. { ATSUI highlighting }
  733. { ---------------------------------------------------------------------------- }
  734. {
  735. * ATSUSetHighlightingMethod()
  736. *
  737. * Summary:
  738. * Specifies the methods ATSUI will use for highlighting and
  739. * unhighlighting text in a given layout.
  740. *
  741. * Discussion:
  742. * By default, ATSUI highlights text by "inverting" the region
  743. * containing the text, that is, its background color. Although
  744. * inversion provides satisfactory highlighting in most cases, it
  745. * does not always provide the best result for grayscale text. (Mac
  746. * OS X sets a lower threshold for antialiasing, while in Mac OS 9
  747. * grayscale text can be turned off by the user.) In Mac OS X, when
  748. * using a Quartz graphics context, you can instruct ATSUI to use
  749. * the redraw method of highlighting, rather than simple inversion.
  750. * (Note that Cocoa applications always use the redraw method of
  751. * highlighting.) The redraw method allows for accurate highlighting
  752. * of more complex backgrounds, such as those containing multiple
  753. * colors, patterns, or pictures. To set redrawing on, call the
  754. * ATSUSetHighlightingMethod function and specify that the redraw
  755. * method be used (by passing kRedrawHighlighting in the iMethod
  756. * parameter). If you specify the redraw method of highlighting when
  757. * you call ATSUSetHighlightingMethod, then you must also specify
  758. * how the background is to be redrawn when the function
  759. * ATSUUnhighlightText is called. ATSUI can restore the desired
  760. * background in one of two ways, depending on the background's
  761. * complexity: (1) When the background is a single color (such as
  762. * white), ATSUI can readily unhighlight the background. In such a
  763. * case, you specify the background color that ATSUI uses by calling
  764. * ATSUSetHighlightingMethod and setting iUnhighlightData.dataType
  765. * to kATSUBackgroundColor and providing the background color in
  766. * iUnhighlightData.unhighlightData. With these settings defined,
  767. * when you call ATSUUnhighlightText, ATSUI simply calculates the
  768. * previously highlighted area, repaints it with the specified
  769. * background color, and then redraws the text. (2) When the
  770. * background is more complex (containing, for example, multiple
  771. * colors, patterns, or pictures), you must provide a redraw
  772. * background callback function when you call
  773. * ATSUSetHighlightingMethod. You do this by setting
  774. * iUnhighlightData.dataType to kATSUBackgroundCallback and
  775. * providing a RedrawBackgroundUPP in
  776. * iUnhighlightData.unhighlightData . Then when you call
  777. * ATSUUnhighlightText and ATSUI calls your callback, you are
  778. * responsible for redrawing the background of the unhighlighted
  779. * area. If you choose to also redraw the text, then your callback
  780. * should return false as a function result. If your callback
  781. * returns true ATSUI redraws any text that needs to be redrawn. See
  782. * RedrawBackgroundProcPtr for additional information.
  783. *
  784. * Parameters:
  785. *
  786. * iTextLayout:
  787. * The layout to which this highlight method should be applied.
  788. *
  789. * iMethod:
  790. * The type of highlighting to use; inversion
  791. * (kInvertHighlighting) or redrawing (kRedrawHighlighting). The
  792. * default is inversion. If you are happy with that technique
  793. * there is no reason to call this function.
  794. *
  795. * iUnhighlightData:
  796. * Data needed to redraw the background or NULL if inversion is
  797. * being chosen. See the definition of ATSUUnhighlightData for
  798. * more information about the possible contents of this structure.
  799. * Also see the Discussion for this function. can be NULL
  800. *
  801. * Result:
  802. * On success, noErr is returned. See MacErrors.h for possible error
  803. * codes.
  804. *
  805. * Availability:
  806. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  807. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  808. * Non-Carbon CFM: not available
  809. }
  810. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  811. function ATSUSetHighlightingMethod( iTextLayout: ATSUTextLayout; iMethod: ATSUHighlightMethod; iUnhighlightData: ATSUUnhighlightDataPtr ): OSStatus; external name '_ATSUSetHighlightingMethod';
  812. {
  813. * ATSUHighlightText()
  814. *
  815. * Summary:
  816. * Renders a highlighted range of text at a specified location in a
  817. * QuickDraw graphics port or Quartz graphics context.
  818. *
  819. * Discussion:
  820. * When the user selects a series of glyphs, the characters in
  821. * memory corresponding to the glyphs make up the selection range
  822. * and should be highlighted to indicate where the next editing
  823. * operation is to occur. The characters in a selection range are
  824. * always contiguous in memory, but their corresponding glyphs are
  825. * not necessarily so onscreen. If the selection range crosses a
  826. * direction boundary, it is appropriate to display discontinuous
  827. * highlighting. The ATSUHighlightText function renders a
  828. * highlighted range of text at a specified location in a QuickDraw
  829. * graphics port or Quartz graphics context, using the highlight
  830. * information in the graphics port or context. ATSUHighlightText
  831. * automatically produces discontinuous highlighting, if needed. You
  832. * typically call the ATSUHighlightText function every time you need
  833. * to draw or redraw highlighted text.
  834. *
  835. * Parameters:
  836. *
  837. * iTextLayout:
  838. * A layout containing text to be highlighted.
  839. *
  840. * iTextBasePointX:
  841. * The x-coordinate of the origin (in either the current graphics
  842. * port or in a Quartz graphics context) of the line containing
  843. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  844. * draw relative to the current pen location in the current
  845. * graphics port.
  846. *
  847. * iTextBasePointY:
  848. * The y-coordinate of the origin (in either the current graphics
  849. * port or in a Quartz graphics context) of the line containing
  850. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  851. * draw relative to the current pen location in the current
  852. * graphics port.
  853. *
  854. * iHighlightStart:
  855. * The first character of the text range to be highlighted. If the
  856. * text range spans multiple lines, you should call
  857. * ATSUHighlightText for each line, passing the offset
  858. * corresponding to the beginning of the new line to draw with
  859. * each call. To indicate that the specified text range starts at
  860. * the beginning of the text buffer, you can pass the constant
  861. * kATSUFromTextBeginning. To specify the entire text buffer, pass
  862. * kATSUFromTextBeginning in this parameter and kATSUToTextEnd in
  863. * the iHighlightLength parameter.
  864. *
  865. * iHighlightLength:
  866. * The length of the text range to be highlighted. To indicate
  867. * that the text range extends to the end of the text buffer, pass
  868. * the constant kATSUToTextEnd.
  869. *
  870. * Result:
  871. * On success, noErr is returned. See MacErrors.h for possible error
  872. * codes.
  873. *
  874. * Availability:
  875. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  876. * CarbonLib: in CarbonLib 1.0 and later
  877. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  878. }
  879. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  880. function ATSUHighlightText( iTextLayout: ATSUTextLayout; iTextBasePointX: ATSUTextMeasurement; iTextBasePointY: ATSUTextMeasurement; iHighlightStart: UniCharArrayOffset; iHighlightLength: UniCharCount ): OSStatus; external name '_ATSUHighlightText';
  881. {
  882. * ATSUUnhighlightText()
  883. *
  884. * Summary:
  885. * Renders a previously highlighted range of text in an
  886. * unhighlighted state.
  887. *
  888. * Discussion:
  889. * This function renders a previously highlighted range of text in
  890. * an unhighlighted state. You should always call
  891. * ATSUUnhighlightText after calling the function ATSUHighlightText
  892. * to properly redraw the unhighlighted text and background. If the
  893. * inversion method of highlighting was used, when you call
  894. * ATSUUnhighlightText, it merely undoes the inversion and renders
  895. * the text. If the redraw method of highlighting was used,
  896. * ATSUUnhighlightText turns off the highlighting and restores the
  897. * desired background. Depending on the complexity of the
  898. * background, ATSUI restores the background in one of two ways:
  899. * filling in a solid color, or repainting the background using a
  900. * callback. See the function ATSUSetHighlightingMethod and the
  901. * definition ATSUUnhighlightData for more information.
  902. *
  903. * Parameters:
  904. *
  905. * iTextLayout:
  906. * A layout containing text to be unhighlighted.
  907. *
  908. * iTextBasePointX:
  909. * The x-coordinate of the origin (in either the current graphics
  910. * port or in a Quartz graphics context) of the line containing
  911. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  912. * draw relative to the current pen location in the current
  913. * graphics port.
  914. *
  915. * iTextBasePointY:
  916. * The y-coordinate of the origin (in either the current graphics
  917. * port or in a Quartz graphics context) of the line containing
  918. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  919. * draw relative to the current pen location in the current
  920. * graphics port.
  921. *
  922. * iHighlightStart:
  923. * The first character of the text range to be unhighlighted. If
  924. * the text range spans multiple lines, you should call
  925. * ATSUUnhighlightText for each line, passing the offset
  926. * corresponding to the beginning of the new line to draw with
  927. * each call. To indicate that the specified text range starts at
  928. * the beginning of the text buffer, you can pass the constant
  929. * kATSUFromTextBeginning. To specify the entire text buffer, pass
  930. * kATSUFromTextBeginning in this parameter and kATSUToTextEnd in
  931. * the iHighlightLength parameter.
  932. *
  933. * iHighlightLength:
  934. * The length of the text range to be unhighlighted. To indicate
  935. * that the text range extends to the end of the text buffer, pass
  936. * the constant kATSUToTextEnd.
  937. *
  938. * Result:
  939. * On success, noErr is returned. See MacErrors.h for possible error
  940. * codes.
  941. *
  942. * Availability:
  943. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  944. * CarbonLib: in CarbonLib 1.0 and later
  945. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  946. }
  947. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  948. function ATSUUnhighlightText( iTextLayout: ATSUTextLayout; iTextBasePointX: ATSUTextMeasurement; iTextBasePointY: ATSUTextMeasurement; iHighlightStart: UniCharArrayOffset; iHighlightLength: UniCharCount ): OSStatus; external name '_ATSUUnhighlightText';
  949. {
  950. * ATSUGetTextHighlight()
  951. *
  952. * Summary:
  953. * Obtains the highlight region for a range of text.
  954. *
  955. * Discussion:
  956. * Use this function to obtain the screen region that ATSUI would
  957. * normally highlight automatically when ATSUHighlightText is
  958. * called. This is useful if you wish to perform your own
  959. * highlighting.
  960. *
  961. * Parameters:
  962. *
  963. * iTextLayout:
  964. * A layout containing text to be highlighted.
  965. *
  966. * iTextBasePointX:
  967. * The x-coordinate of the origin (in either the current graphics
  968. * port or in a Quartz graphics context) of the line containing
  969. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  970. * draw relative to the current pen location in the current
  971. * graphics port.
  972. *
  973. * iTextBasePointY:
  974. * The y-coordinate of the origin (in either the current graphics
  975. * port or in a Quartz graphics context) of the line containing
  976. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  977. * draw relative to the current pen location in the current
  978. * graphics port.
  979. *
  980. * iHighlightStart:
  981. * The first character of the text range to be highlighted. If the
  982. * text range spans multiple lines, you should call
  983. * ATSUGetTextHighlight for each line, passing the offset
  984. * corresponding to the beginning of the new line to draw with
  985. * each call. To indicate that the specified text range starts at
  986. * the beginning of the text buffer, you can pass the constant
  987. * kATSUFromTextBeginning. To specify the entire text buffer, pass
  988. * kATSUFromTextBeginning in this parameter and kATSUToTextEnd in
  989. * the iHighlightLength parameter.
  990. *
  991. * iHighlightLength:
  992. * The length of the text range to be highlighted. To indicate
  993. * that the text range extends to the end of the text buffer, pass
  994. * the constant kATSUToTextEnd.
  995. *
  996. * oHighlightRegion:
  997. * On return, ATSUGetTextHighlight produces a MacRegion structure
  998. * containing the highlight region for the specified range of
  999. * text. In the case of discontinuous highlighting, the region
  1000. * consists of multiple components, with MacRegion.rgnBBox
  1001. * specifying the bounding box around the entire area of
  1002. * discontinuous highlighting.
  1003. *
  1004. * Result:
  1005. * On success, noErr is returned. See MacErrors.h for possible error
  1006. * codes.
  1007. *
  1008. * Availability:
  1009. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1010. * CarbonLib: in CarbonLib 1.0 and later
  1011. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1012. }
  1013. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1014. function ATSUGetTextHighlight( iTextLayout: ATSUTextLayout; iTextBasePointX: ATSUTextMeasurement; iTextBasePointY: ATSUTextMeasurement; iHighlightStart: UniCharArrayOffset; iHighlightLength: UniCharCount; oHighlightRegion: RgnHandle ): OSStatus; external name '_ATSUGetTextHighlight';
  1015. {
  1016. * ATSUHighlightInactiveText()
  1017. *
  1018. * Summary:
  1019. * Highlights text using the standard Mac OS X UI convention for an
  1020. * inactive window or UI pane.
  1021. *
  1022. * Discussion:
  1023. * Use this function to redraw text when a window or UI pane
  1024. * containing highlighted text becomes inactive. Once the window or
  1025. * UI pane becomes active again, call ATSUHighlightText to
  1026. * rehighlight the text in active mode.
  1027. *
  1028. * Parameters:
  1029. *
  1030. * iTextLayout:
  1031. * A layout containing text to be highlighted.
  1032. *
  1033. * iTextBasePointX:
  1034. * The x-coordinate of the origin (in either the current graphics
  1035. * port or in a Quartz graphics context) of the line containing
  1036. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  1037. * draw relative to the current pen location in the current
  1038. * graphics port.
  1039. *
  1040. * iTextBasePointY:
  1041. * The y-coordinate of the origin (in either the current graphics
  1042. * port or in a Quartz graphics context) of the line containing
  1043. * the text range. Pass the constant kATSUUseGrafPortPenLoc to
  1044. * draw relative to the current pen location in the current
  1045. * graphics port.
  1046. *
  1047. * iHighlightStart:
  1048. * The first character of the text range to be highlighted. If the
  1049. * text range spans multiple lines, you should call
  1050. * ATSUHighlightInactiveText for each line, passing the offset
  1051. * corresponding to the beginning of the new line to draw with
  1052. * each call. To indicate that the specified text range starts at
  1053. * the beginning of the text buffer, you can pass the constant
  1054. * kATSUFromTextBeginning. To specify the entire text buffer, pass
  1055. * kATSUFromTextBeginning in this parameter and kATSUToTextEnd in
  1056. * the iHighlightLength parameter.
  1057. *
  1058. * iHighlightLength:
  1059. * The length of the text range to be highlighted. To indicate
  1060. * that the text range extends to the end of the text buffer, pass
  1061. * the constant kATSUToTextEnd.
  1062. *
  1063. * Result:
  1064. * On success, noErr is returned. See MacErrors.h for possible error
  1065. * codes.
  1066. *
  1067. * Availability:
  1068. * Mac OS X: in version 10.2 and later in ApplicationServices.framework
  1069. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1070. * Non-Carbon CFM: not available
  1071. }
  1072. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  1073. function ATSUHighlightInactiveText( iTextLayout: ATSUTextLayout; iTextBasePointX: ATSUTextMeasurement; iTextBasePointY: ATSUTextMeasurement; iHighlightStart: UniCharArrayOffset; iHighlightLength: UniCharCount ): OSStatus; external name '_ATSUHighlightInactiveText';
  1074. { ---------------------------------------------------------------------------- }
  1075. { ATSUI hit-testing }
  1076. { ---------------------------------------------------------------------------- }
  1077. {
  1078. * ATSUPositionToOffset()
  1079. *
  1080. * Summary:
  1081. * Obtains the memory offset for the glyph edge nearest a mouse-down
  1082. * event.
  1083. *
  1084. * Discussion:
  1085. * The process of hit-testing text obtains the location of a
  1086. * mouse-down event relative both to the position of onscreen glyphs
  1087. * and to the corresponding offset between character codes in
  1088. * memory. You can then use the location information obtained by
  1089. * hit-testing to set the insertion point (that is, the caret) or
  1090. * selection range (for highlighting). Hit-testing text is
  1091. * complicated by the fact that a given line of text may be
  1092. * bidirectional. Therefore, the onscreen order of glyphs may not
  1093. * readily correspond to the storage order of the corresponding
  1094. * character codes. And the concept of which glyph comes "first" in
  1095. * a line of text cannot always be limited to the visual terms
  1096. * "left" and "right." Because of these complexities, it is more
  1097. * accurate to speak in terms of "leading" and "trailing" edges to
  1098. * glyphs. A "leading edge" is defined as the edge of a glyph that
  1099. * you first encounter when you read the text that includes that
  1100. * glyph. For example, when reading Roman text, you first encounter
  1101. * the left edge of a Roman glyph. Similarly, the "trailing edge" is
  1102. * defined as the edge of the glyph encountered last. This function
  1103. * produces the memory offset corresponding to the glyph edge
  1104. * nearest the event. If the mouse-down event occurs at a line
  1105. * direction boundary or within a glyph cluster,
  1106. * ATSUPositionToOffset produces two offsets. You can then provide
  1107. * the offset(s) to the ATSUOffsetToPosition function to obtain the
  1108. * actual caret position(s) for the event. When you call the
  1109. * ATSUPositionToOffset function, ATSUI examines the Unicode
  1110. * directionality of the character corresponding to the event
  1111. * location. The ATSUPositionToOffset function produces a value of
  1112. * true in the oIsLeading parameter if the offset is leading (that
  1113. * is, more closely associated with the subsequent character in
  1114. * memory and therefore indicative of a left-to-right line
  1115. * direction). It produces a value of false if the offset is
  1116. * trailing (that is, more closely associated with the preceding
  1117. * character in memory and indicative of a right-to-left line
  1118. * direction). Finally, note that when the event occurs beyond the
  1119. * leftmost or rightmost caret positions of the line (not taking
  1120. * into account line rotation), such that no glyph corresponds to
  1121. * the location of the hit, the ATSUPositionToOffset function
  1122. * produces the primary offset of the closest edge of the line to
  1123. * the input location. The oIsLeading flag depends on the
  1124. * directionality of the closest glyph and the side of the line to
  1125. * which the input location is closest. In this case, the secondary
  1126. * offset is equal to the primary offset, since no glyph was hit.
  1127. *
  1128. * Parameters:
  1129. *
  1130. * iTextLayout:
  1131. * The layout object in which the mouse-down event occurred.
  1132. *
  1133. * iLocationX:
  1134. * The x-coordinate of the event, in local coordinates, relative
  1135. * to the origin of the line where the event occurred. That is, to
  1136. * specify the x-coordinate value, you should subtract the
  1137. * x-coordinate of the line origin from the x-coordinate of the
  1138. * hit point (in local coordinates). You can pass the constant
  1139. * kATSUUseGrafPortPenLoc for the location of the mouse-down event
  1140. * relative to the current pen location in the current graphics
  1141. * port.
  1142. *
  1143. * iLocationY:
  1144. * The y-coordinate of the event, in local coordinates, relative
  1145. * to the origin of the line where the event occurred. That is, to
  1146. * specify the y-coordinate value, you should subtract the
  1147. * y-coordinate of the line origin from the y-coordinate of the
  1148. * hit point (in local coordinates). You can pass the constant
  1149. * kATSUUseGrafPortPenLoc for the location of the mouse-down event
  1150. * relative to the current pen location in the current graphics
  1151. * port.
  1152. *
  1153. * ioPrimaryOffset:
  1154. * On input, a pointer to a UniCharArrayOffset value specifying
  1155. * the offset corresponding to the beginning of the line where the
  1156. * event occurred. On return, the value specifies the offset
  1157. * corresponding to the glyph edge that is visually closest to the
  1158. * event. To determine whether this offset indicates the leading
  1159. * or trailing edge of the glyph, you can examine the value
  1160. * produced in the oIsLeading parameter.
  1161. *
  1162. * oIsLeading:
  1163. * On return, the value indicates whether the offset produced in
  1164. * the ioPrimaryOffset parameter is leading or trailing. The
  1165. * function ATSUPositionToOffset produces a value of true if the
  1166. * offset is leading (that is, more closely associated with the
  1167. * subsequent character in memory). It produces a value of false
  1168. * if the offset is trailing (that is, more closely associated
  1169. * with the preceding character in memory).
  1170. *
  1171. * oSecondaryOffset:
  1172. * On return, the value typically specifies the same offset as
  1173. * that produced in the ioPrimaryOffset parameter, unless the
  1174. * event occurred within a glyph cluster or at a line direction
  1175. * boundary. If so, the value specifies a secondary offset. The
  1176. * secondary offset is associated with the glyph that has a
  1177. * different direction from the primary line direction.
  1178. *
  1179. * Result:
  1180. * On success, noErr is returned. See MacErrors.h for possible error
  1181. * codes.
  1182. *
  1183. * Availability:
  1184. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1185. * CarbonLib: in CarbonLib 1.0 and later
  1186. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1187. }
  1188. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1189. function ATSUPositionToOffset( iTextLayout: ATSUTextLayout; iLocationX: ATSUTextMeasurement; iLocationY: ATSUTextMeasurement; var ioPrimaryOffset: UniCharArrayOffset; var oIsLeading: Boolean; var oSecondaryOffset: UniCharArrayOffset ): OSStatus; external name '_ATSUPositionToOffset';
  1190. {
  1191. * ATSUOffsetToPosition()
  1192. *
  1193. * Summary:
  1194. * Obtains the caret position(s) corresponding to a memory offset.
  1195. *
  1196. * Discussion:
  1197. * This function produces two structures of type ATSUCaret. These
  1198. * structures contain the pen positioning information needed to draw
  1199. * the caret(s) for the event, specified relative to the origin of
  1200. * the line in the current graphics port or graphics context.
  1201. * Specifically, the ATSUCaret structures contain x-y coordinates
  1202. * for both the caret's starting and ending pen positions (the
  1203. * latter taking into account line rotation, caret slanting, and
  1204. * split-caret appearances). If the offset you pass to
  1205. * ATSUOffsetToPosition is at a line boundary, the structure
  1206. * produced in the oMainCaret parameter contains the starting and
  1207. * ending pen locations for the high caret, while the oSecondCaret
  1208. * parameter contains the corresponding values for the low caret. If
  1209. * the offset is not at a line boundary, both parameters contain the
  1210. * starting and ending pen locations of the main caret. Because you
  1211. * provide the ATSUOffsetToPosition function an offset relative to
  1212. * the origin of the line where the hit occurred,
  1213. * ATSUOffsetToPosition produces positioning information that is
  1214. * also relative. Therefore, you must transform the positions
  1215. * produced by the ATSUOffsetToPosition function before drawing the
  1216. * caret(s). To transform the caret location(s), add the starting
  1217. * and ending caret coordinates to the coordinates of the origin of
  1218. * the line in which the hit occurred. For example, if
  1219. * ATSUOffsetToPosition produces starting and ending pen locations
  1220. * of (25,0), (25,25) in the oMainCaret parameter (and the
  1221. * oSecondCaret parameter contains the same coordinates, meaning
  1222. * that the caret was not split), you would add these to the
  1223. * position of the origin of the line in the graphics port or
  1224. * context. If the position of the line origin was at (50,50), then
  1225. * the starting and ending pen locations of the caret would be
  1226. * (75,50), (75,75).
  1227. *
  1228. * Parameters:
  1229. *
  1230. * iTextLayout:
  1231. * The layout containing the offset.
  1232. *
  1233. * iOffset:
  1234. * The offset into the text buffer for which you wish to obtain a
  1235. * caret position. To respond to a mouse-down event, pass the
  1236. * offset returned in the ioPrimaryOffset parameter from the
  1237. * function ATSUPositionToOffset. That is, the offset
  1238. * corresponding to the glyph edge closest to the event.
  1239. *
  1240. * iIsLeading:
  1241. * A Boolean value indicating whether the offset corresponds to
  1242. * the leading or trailing edge of the glyph. You can obtain this
  1243. * information from the function ATSUPositionToOffset. This value
  1244. * is relevant if the offset occurs at a line direction boundary
  1245. * or within a glyph cluster.
  1246. *
  1247. * oMainCaret:
  1248. * On return, contains the starting and ending pen locations of
  1249. * the high caret if the value produced in oCaretIsSplit is true.
  1250. * If the value is false, the structure contains the starting and
  1251. * ending pen locations of the main caret.
  1252. *
  1253. * oSecondCaret:
  1254. * On return, contains the starting and ending pen locations of
  1255. * the low caret if the value passed back in the oCaretIsSplit
  1256. * parameter is true. If the value is false, the structure
  1257. * contains the starting and ending pen locations of the main
  1258. * caret (that is, the same values as the oMainCaret parameter).
  1259. *
  1260. * oCaretIsSplit:
  1261. * On return, indicates whether the offset specified in the
  1262. * iOffset parameter occurs at a line direction boundary. If true,
  1263. * the offset occurs at a line direction boundary; otherwise,
  1264. * false.
  1265. *
  1266. * Result:
  1267. * On success, noErr is returned. See MacErrors.h for possible error
  1268. * codes.
  1269. *
  1270. * Availability:
  1271. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1272. * CarbonLib: in CarbonLib 1.0 and later
  1273. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1274. }
  1275. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1276. function ATSUOffsetToPosition( iTextLayout: ATSUTextLayout; iOffset: UniCharArrayOffset; iIsLeading: Boolean; var oMainCaret: ATSUCaret; var oSecondCaret: ATSUCaret; var oCaretIsSplit: Boolean ): OSStatus; external name '_ATSUOffsetToPosition';
  1277. {
  1278. * ATSUPositionToCursorOffset()
  1279. *
  1280. * Summary:
  1281. * Obtains the memory offset for the glyph edge nearest a mouse-down
  1282. * event, after a move of the specified length.
  1283. *
  1284. * Discussion:
  1285. * This function produces the memory offset for the glyph edge
  1286. * nearest a mouse-down event, after a move of the specified length.
  1287. * This offset corresponds to where an insertion point would be
  1288. * placed after the move.
  1289. *
  1290. * Parameters:
  1291. *
  1292. * iTextLayout:
  1293. * The layout in which the mouse down event occured.
  1294. *
  1295. * iLocationX:
  1296. * The x-coordinate of the event, in local coordinates, relative
  1297. * to the origin of the line where the event occurred. That is, to
  1298. * specify the x-coordinate value, you should subtract the
  1299. * x-coordinate of the line origin from the x-coordinate of the
  1300. * hit point (in local coordinates). You can pass the constant
  1301. * kATSUUseGrafPortPenLoc for the location of the mouse-down event
  1302. * relative to the current pen location in the current graphics
  1303. * port.
  1304. *
  1305. * iLocationY:
  1306. * The y-coordinate of the event, in local coordinates, relative
  1307. * to the origin of the line where the event occurred. That is, to
  1308. * specify the y-coordinate value, you should subtract the
  1309. * y-coordinate of the line origin from the y-coordinate of the
  1310. * hit point (in local coordinates). You can pass the constant
  1311. * kATSUUseGrafPortPenLoc for the location of the mouse-down event
  1312. * relative to the current pen location in the current graphics
  1313. * port.
  1314. *
  1315. * iMovementType:
  1316. * A constant specifying the type of cursor movement to use. See
  1317. * the definition of ATSUCursorMovementType for possible values to
  1318. * pass for this parameter.
  1319. *
  1320. * ioPrimaryOffset:
  1321. * On input, the offset corresponding to the beginning of the line
  1322. * where the event occurred. On return, the offset corresponding
  1323. * to the glyph edge nearest the event, after a movement of the
  1324. * specified type. This offset corresponds to where the insertion
  1325. * point would be placed after the move. To determine whether this
  1326. * offset indicates the leading or trailing edge of the glyph, you
  1327. * can examine the value produced in the oIsLeading parameter.
  1328. *
  1329. * oIsLeading:
  1330. * On return, the value indicates whether the offset produced in
  1331. * the ioPrimaryOffset parameter is leading or trailing. The
  1332. * ATSUPositionToOffset function produces a value of true if the
  1333. * offset is leading (that is, more closely associated with the
  1334. * subsequent character in memory). It produces a value of false
  1335. * if the offset is trailing (that is, more closely associated
  1336. * with the preceding character in memory).
  1337. *
  1338. * oSecondaryOffset:
  1339. * On return, the value typically specifies the same offset as
  1340. * that produced in the ioPrimaryOffset parameter, unless the
  1341. * event occurred within a glyph cluster or at a line direction
  1342. * boundary. If so, the value specifies the secondary offset, for
  1343. * the glyph edge furthest from the event.
  1344. *
  1345. * Result:
  1346. * On success, noErr is returned. See MacErrors.h for possible error
  1347. * codes.
  1348. *
  1349. * Availability:
  1350. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1351. * CarbonLib: in CarbonLib 1.5 and later
  1352. * Non-Carbon CFM: in ATSUnicodeLib 9.2.2 and later
  1353. }
  1354. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1355. function ATSUPositionToCursorOffset( iTextLayout: ATSUTextLayout; iLocationX: ATSUTextMeasurement; iLocationY: ATSUTextMeasurement; iMovementType: ATSUCursorMovementType; var ioPrimaryOffset: UniCharArrayOffset; var oIsLeading: Boolean; var oSecondaryOffset: UniCharArrayOffset ): OSStatus; external name '_ATSUPositionToCursorOffset';
  1356. {
  1357. * ATSUOffsetToCursorPosition()
  1358. *
  1359. * Summary:
  1360. * Obtains the caret position(s) corresponding to a memory offset,
  1361. * after a move of the specified length.
  1362. *
  1363. * Discussion:
  1364. * Use this function in conjunction with ATSUPositionToCursorOffset
  1365. * to determine where to draw the caret after a mouse-down event.
  1366. * The movement type parameter allows you to have the cursor "snap"
  1367. * to different parts of the text depending on the type of movement
  1368. * selected (i.e., words or characters). See the definition of
  1369. * ATSUCursorMovementType for more information on possible values.
  1370. *
  1371. * Parameters:
  1372. *
  1373. * iTextLayout:
  1374. * The text layout object in which the mouse-down event occurred.
  1375. *
  1376. * iOffset:
  1377. * The offset corresponding to the glyph edge nearest the event,
  1378. * after a movement of the specified type. You can obtain this
  1379. * value by examining the offset produced in the ioPrimaryOffset
  1380. * parameter of the function ATSUPositionToCursorOffset.
  1381. *
  1382. * iIsLeading:
  1383. * A Boolean value indicating whether the specified offset
  1384. * corresponds to the leading or trailing edge of the glyph. You
  1385. * can obtain this information from the function
  1386. * ATSUPositionToCursorOffset . This value is relevant if the
  1387. * offset occurs at a line direction boundary or within a glyph
  1388. * cluster.
  1389. *
  1390. * iMovementType:
  1391. * A constant specifying the unit of cursor movement. See the
  1392. * definition of ATSUCursorMovementType for possible values to
  1393. * pass for this parameter.
  1394. *
  1395. * oMainCaret:
  1396. * On return, the structure contains the starting and ending pen
  1397. * locations of the high caret if the value produced in the
  1398. * oCaretIsSplit parameter is true. If the value is false, the
  1399. * structure contains the starting and ending pen locations of the
  1400. * main caret.
  1401. *
  1402. * oSecondCaret:
  1403. * On return, the structure contains the starting and ending pen
  1404. * locations of the low caret if the value passed back in the
  1405. * oCaretIsSplit parameter is true. If the value is false, the
  1406. * structure contains the starting and ending pen locations of the
  1407. * main caret (that is, the same values as the oMainCaret
  1408. * parameter).
  1409. *
  1410. * oCaretIsSplit:
  1411. * On return, the value indicates whether the offset specified in
  1412. * the iOffset parameter occurs at a line direction boundary. If
  1413. * true, the offset occurs at a line direction boundary;
  1414. * otherwise, false.
  1415. *
  1416. * Result:
  1417. * On success, noErr is returned. See MacErrors.h for possible error
  1418. * codes.
  1419. *
  1420. * Availability:
  1421. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1422. * CarbonLib: in CarbonLib 1.5 and later
  1423. * Non-Carbon CFM: in ATSUnicodeLib 9.2.2 and later
  1424. }
  1425. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1426. function ATSUOffsetToCursorPosition( iTextLayout: ATSUTextLayout; iOffset: UniCharArrayOffset; iIsLeading: Boolean; iMovementType: ATSUCursorMovementType; var oMainCaret: ATSUCaret; var oSecondCaret: ATSUCaret; var oCaretIsSplit: Boolean ): OSStatus; external name '_ATSUOffsetToCursorPosition';
  1427. { ---------------------------------------------------------------------------- }
  1428. { ATSUI cursor movement }
  1429. { ---------------------------------------------------------------------------- }
  1430. {
  1431. * ATSUNextCursorPosition()
  1432. *
  1433. * Summary:
  1434. * Obtains the memory offset for the insertion point that follows
  1435. * the current insertion point in storage order, as determined by a
  1436. * move of the specified length and type.
  1437. *
  1438. * Discussion:
  1439. * Together with ATSUPreviousCursorPosition, this function allows an
  1440. * application to "walk" the text buffer in storage order, moving
  1441. * the cursor by a specified amount and movement type at each step.
  1442. * To move through the text buffer in screen order, use the
  1443. * functions ATSURightwardCursorPosition and
  1444. * ATSULeftwardCursorPosition.
  1445. *
  1446. * Parameters:
  1447. *
  1448. * iTextLayout:
  1449. * The layout in which to perform the cursor movement.
  1450. *
  1451. * iOldOffset:
  1452. * The previous cursor position.
  1453. *
  1454. * iMovementType:
  1455. * A constant specifying the unit of cursor movement. See the
  1456. * definition of ATSUCursorMovementType for possible values to
  1457. * pass for this parameter.
  1458. *
  1459. * oNewOffset:
  1460. * On return, the new cursor position.
  1461. *
  1462. * Result:
  1463. * On success, noErr is returned. See MacErrors.h for possible error
  1464. * codes.
  1465. *
  1466. * Availability:
  1467. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1468. * CarbonLib: in CarbonLib 1.0 and later
  1469. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1470. }
  1471. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1472. function ATSUNextCursorPosition( iTextLayout: ATSUTextLayout; iOldOffset: UniCharArrayOffset; iMovementType: ATSUCursorMovementType; var oNewOffset: UniCharArrayOffset ): OSStatus; external name '_ATSUNextCursorPosition';
  1473. {
  1474. * ATSUPreviousCursorPosition()
  1475. *
  1476. * Summary:
  1477. * Obtains the memory offset for the insertion point that preceeds
  1478. * the current insertion point in storage order, as determined by a
  1479. * move of the specified length and type.
  1480. *
  1481. * Discussion:
  1482. * Together with ATSUNextCursorPosition, this function allows an
  1483. * application to "walk" the text buffer in storage order, moving
  1484. * the cursor by a specified amount and movement type at each step.
  1485. * To move through the text buffer in screen order, use the
  1486. * functions ATSURightwardCursorPosition and
  1487. * ATSULeftwardCursorPosition.
  1488. *
  1489. * Parameters:
  1490. *
  1491. * iTextLayout:
  1492. * The layout in which to perform the cursor movement.
  1493. *
  1494. * iOldOffset:
  1495. * The previous cursor position.
  1496. *
  1497. * iMovementType:
  1498. * A constant specifying the unit of cursor movement. See the
  1499. * definition of ATSUCursorMovementType for possible values to
  1500. * pass for this parameter.
  1501. *
  1502. * oNewOffset:
  1503. * On return, the new cursor position.
  1504. *
  1505. * Result:
  1506. * On success, noErr is returned. See MacErrors.h for possible error
  1507. * codes.
  1508. *
  1509. * Availability:
  1510. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1511. * CarbonLib: in CarbonLib 1.0 and later
  1512. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1513. }
  1514. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1515. function ATSUPreviousCursorPosition( iTextLayout: ATSUTextLayout; iOldOffset: UniCharArrayOffset; iMovementType: ATSUCursorMovementType; var oNewOffset: UniCharArrayOffset ): OSStatus; external name '_ATSUPreviousCursorPosition';
  1516. {
  1517. * ATSURightwardCursorPosition()
  1518. *
  1519. * Summary:
  1520. * Obtains the memory offset for the insertion point that is to the
  1521. * right of the current insertion point, as determined by a move of
  1522. * the specified length and type.
  1523. *
  1524. * Discussion:
  1525. * Together with ATSULeftwardCursorPosition, this function allows an
  1526. * application to "walk" the text buffer in screen order, moving the
  1527. * cursor by a specified amount and movement type at each step. To
  1528. * move through the text buffer in storage order, use the functions
  1529. * ATSUNextCursorPosition and ATSUPreviousCursorPosition. Note that
  1530. * if you are drawing the cursor after a cursor move, you should use
  1531. * ATSUOffsetToPosition to obtain an ATSUCaret that determines the
  1532. * on screen location of the new cursor position. Always store the
  1533. * ATSUCaret from the previous cursor position as well, as this can
  1534. * help determine which caret to use in the case of a split caret.
  1535. * When performing leftward and rightward cursor movement, always
  1536. * use the caret closest to the previous caret. This maintains
  1537. * visual order when moving the cursor on screen.
  1538. *
  1539. * Parameters:
  1540. *
  1541. * iTextLayout:
  1542. * The layout in which to perform the cursor movement.
  1543. *
  1544. * iOldOffset:
  1545. * The previous cursor position.
  1546. *
  1547. * iMovementType:
  1548. * A constant specifying the unit of cursor movement. See the
  1549. * definition of ATSUCursorMovementType for possible values to
  1550. * pass for this parameter.
  1551. *
  1552. * oNewOffset:
  1553. * On return, the new cursor position.
  1554. *
  1555. * Result:
  1556. * On success, noErr is returned. See MacErrors.h for possible error
  1557. * codes.
  1558. *
  1559. * Availability:
  1560. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1561. * CarbonLib: in CarbonLib 1.0 and later
  1562. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1563. }
  1564. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1565. function ATSURightwardCursorPosition( iTextLayout: ATSUTextLayout; iOldOffset: UniCharArrayOffset; iMovementType: ATSUCursorMovementType; var oNewOffset: UniCharArrayOffset ): OSStatus; external name '_ATSURightwardCursorPosition';
  1566. {
  1567. * ATSULeftwardCursorPosition()
  1568. *
  1569. * Summary:
  1570. * Obtains the memory offset for the insertion point that is to the
  1571. * left of the current insertion point, as determined by a move of
  1572. * the specified length and type.
  1573. *
  1574. * Discussion:
  1575. * Together with ATSURightwardCursorPosition, this function allows
  1576. * an application to "walk" the text buffer in screen order, moving
  1577. * the cursor by a specified amount and movement type at each step.
  1578. * To move through the text buffer in storage order, use the
  1579. * functions ATSUNextCursorPosition and ATSUPreviousCursorPosition.
  1580. * Note that if you are drawing the cursor after a cursor move, you
  1581. * should use ATSUOffsetToPosition to obtain an ATSUCaret that
  1582. * determines the on screen location of the new cursor position.
  1583. * Always store the ATSUCaret from the previous cursor position as
  1584. * well, as this can help determine which caret to use in the case
  1585. * of a split caret. When performing leftward and rightward cursor
  1586. * movement, always use the caret closest to the previous caret.
  1587. * This maintains visual order when moving the cursor on screen.
  1588. *
  1589. * Parameters:
  1590. *
  1591. * iTextLayout:
  1592. * The layout in which to perform the cursor movement.
  1593. *
  1594. * iOldOffset:
  1595. * The previous cursor position.
  1596. *
  1597. * iMovementType:
  1598. * A constant specifying the unit of cursor movement. See the
  1599. * definition of ATSUCursorMovementType for possible values to
  1600. * pass for this parameter.
  1601. *
  1602. * oNewOffset:
  1603. * On return, the new cursor position.
  1604. *
  1605. * Result:
  1606. * On success, noErr is returned. See MacErrors.h for possible error
  1607. * codes.
  1608. *
  1609. * Availability:
  1610. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1611. * CarbonLib: in CarbonLib 1.0 and later
  1612. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1613. }
  1614. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1615. function ATSULeftwardCursorPosition( iTextLayout: ATSUTextLayout; iOldOffset: UniCharArrayOffset; iMovementType: ATSUCursorMovementType; var oNewOffset: UniCharArrayOffset ): OSStatus; external name '_ATSULeftwardCursorPosition';
  1616. { Functions listed beyond this point are either deprecated or not recommended }
  1617. {
  1618. * ATSUMeasureText()
  1619. *
  1620. * Discussion:
  1621. * This function is no longer recommended. Please use
  1622. * ATSUGetUnjustifiedBounds instead.
  1623. *
  1624. * Availability:
  1625. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  1626. * CarbonLib: in CarbonLib 1.0 and later
  1627. * Non-Carbon CFM: in ATSUnicodeLib 8.5 and later
  1628. }
  1629. // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER
  1630. function ATSUMeasureText( iTextLayout: ATSUTextLayout; iLineStart: UniCharArrayOffset; iLineLength: UniCharCount; var oTextBefore: ATSUTextMeasurement; var oTextAfter: ATSUTextMeasurement; var oAscent: ATSUTextMeasurement; var oDescent: ATSUTextMeasurement ): OSStatus; external name '_ATSUMeasureText';
  1631. end.