HITextViews.pas 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. {
  2. File: HIToolbox/HITextViews.h
  3. Contains: Definitions of text-display and text-editing views provided by HIToolbox.
  4. Version: HIToolbox-624~3
  5. Copyright: © 2006-2008 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://bugs.freepascal.org
  9. }
  10. { Initial Pascal Translation: Jonas Maebe, <[email protected]>, October 2009 }
  11. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  12. {
  13. Modified for use with Free Pascal
  14. Version 308
  15. Please report any bugs to <[email protected]>
  16. }
  17. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  18. {$mode macpas}
  19. {$modeswitch cblocks}
  20. {$packenum 1}
  21. {$macro on}
  22. {$inline on}
  23. {$calling mwpascal}
  24. {$IFNDEF FPC_DOTTEDUNITS}
  25. unit HITextViews;
  26. {$ENDIF FPC_DOTTEDUNITS}
  27. interface
  28. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  29. {$setc GAP_INTERFACES_VERSION := $0308}
  30. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  31. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  32. {$endc}
  33. {$ifc defined CPUPOWERPC and defined CPUI386}
  34. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  35. {$endc}
  36. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  37. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  38. {$endc}
  39. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  40. {$setc __ppc__ := 1}
  41. {$elsec}
  42. {$setc __ppc__ := 0}
  43. {$endc}
  44. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  45. {$setc __ppc64__ := 1}
  46. {$elsec}
  47. {$setc __ppc64__ := 0}
  48. {$endc}
  49. {$ifc not defined __i386__ and defined CPUI386}
  50. {$setc __i386__ := 1}
  51. {$elsec}
  52. {$setc __i386__ := 0}
  53. {$endc}
  54. {$ifc not defined __x86_64__ and defined CPUX86_64}
  55. {$setc __x86_64__ := 1}
  56. {$elsec}
  57. {$setc __x86_64__ := 0}
  58. {$endc}
  59. {$ifc not defined __arm__ and defined CPUARM}
  60. {$setc __arm__ := 1}
  61. {$elsec}
  62. {$setc __arm__ := 0}
  63. {$endc}
  64. {$ifc not defined __arm64__ and defined CPUAARCH64}
  65. {$setc __arm64__ := 1}
  66. {$elsec}
  67. {$setc __arm64__ := 0}
  68. {$endc}
  69. {$ifc defined cpu64}
  70. {$setc __LP64__ := 1}
  71. {$elsec}
  72. {$setc __LP64__ := 0}
  73. {$endc}
  74. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  75. {$error Conflicting definitions for __ppc__ and __i386__}
  76. {$endc}
  77. {$ifc defined __ppc__ and __ppc__}
  78. {$setc TARGET_CPU_PPC := TRUE}
  79. {$setc TARGET_CPU_PPC64 := FALSE}
  80. {$setc TARGET_CPU_X86 := FALSE}
  81. {$setc TARGET_CPU_X86_64 := FALSE}
  82. {$setc TARGET_CPU_ARM := FALSE}
  83. {$setc TARGET_CPU_ARM64 := FALSE}
  84. {$setc TARGET_OS_MAC := TRUE}
  85. {$setc TARGET_OS_IPHONE := FALSE}
  86. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  87. {$setc TARGET_OS_EMBEDDED := FALSE}
  88. {$elifc defined __ppc64__ and __ppc64__}
  89. {$setc TARGET_CPU_PPC := FALSE}
  90. {$setc TARGET_CPU_PPC64 := TRUE}
  91. {$setc TARGET_CPU_X86 := FALSE}
  92. {$setc TARGET_CPU_X86_64 := FALSE}
  93. {$setc TARGET_CPU_ARM := FALSE}
  94. {$setc TARGET_CPU_ARM64 := FALSE}
  95. {$setc TARGET_OS_MAC := TRUE}
  96. {$setc TARGET_OS_IPHONE := FALSE}
  97. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  98. {$setc TARGET_OS_EMBEDDED := FALSE}
  99. {$elifc defined __i386__ and __i386__}
  100. {$setc TARGET_CPU_PPC := FALSE}
  101. {$setc TARGET_CPU_PPC64 := FALSE}
  102. {$setc TARGET_CPU_X86 := TRUE}
  103. {$setc TARGET_CPU_X86_64 := FALSE}
  104. {$setc TARGET_CPU_ARM := FALSE}
  105. {$setc TARGET_CPU_ARM64 := FALSE}
  106. {$ifc defined iphonesim}
  107. {$setc TARGET_OS_MAC := FALSE}
  108. {$setc TARGET_OS_IPHONE := TRUE}
  109. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  110. {$elsec}
  111. {$setc TARGET_OS_MAC := TRUE}
  112. {$setc TARGET_OS_IPHONE := FALSE}
  113. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  114. {$endc}
  115. {$setc TARGET_OS_EMBEDDED := FALSE}
  116. {$elifc defined __x86_64__ and __x86_64__}
  117. {$setc TARGET_CPU_PPC := FALSE}
  118. {$setc TARGET_CPU_PPC64 := FALSE}
  119. {$setc TARGET_CPU_X86 := FALSE}
  120. {$setc TARGET_CPU_X86_64 := TRUE}
  121. {$setc TARGET_CPU_ARM := FALSE}
  122. {$setc TARGET_CPU_ARM64 := FALSE}
  123. {$ifc defined iphonesim}
  124. {$setc TARGET_OS_MAC := FALSE}
  125. {$setc TARGET_OS_IPHONE := TRUE}
  126. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  127. {$elsec}
  128. {$setc TARGET_OS_MAC := TRUE}
  129. {$setc TARGET_OS_IPHONE := FALSE}
  130. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  131. {$endc}
  132. {$setc TARGET_OS_EMBEDDED := FALSE}
  133. {$elifc defined __arm__ and __arm__}
  134. {$setc TARGET_CPU_PPC := FALSE}
  135. {$setc TARGET_CPU_PPC64 := FALSE}
  136. {$setc TARGET_CPU_X86 := FALSE}
  137. {$setc TARGET_CPU_X86_64 := FALSE}
  138. {$setc TARGET_CPU_ARM := TRUE}
  139. {$setc TARGET_CPU_ARM64 := FALSE}
  140. {$setc TARGET_OS_MAC := FALSE}
  141. {$setc TARGET_OS_IPHONE := TRUE}
  142. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  143. {$setc TARGET_OS_EMBEDDED := TRUE}
  144. {$elifc defined __arm64__ and __arm64__}
  145. {$setc TARGET_CPU_PPC := FALSE}
  146. {$setc TARGET_CPU_PPC64 := FALSE}
  147. {$setc TARGET_CPU_X86 := FALSE}
  148. {$setc TARGET_CPU_X86_64 := FALSE}
  149. {$setc TARGET_CPU_ARM := FALSE}
  150. {$setc TARGET_CPU_ARM64 := TRUE}
  151. {$ifc defined ios}
  152. {$setc TARGET_OS_MAC := FALSE}
  153. {$setc TARGET_OS_IPHONE := TRUE}
  154. {$setc TARGET_OS_EMBEDDED := TRUE}
  155. {$elsec}
  156. {$setc TARGET_OS_MAC := TRUE}
  157. {$setc TARGET_OS_IPHONE := FALSE}
  158. {$setc TARGET_OS_EMBEDDED := FALSE}
  159. {$endc}
  160. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  161. {$elsec}
  162. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  163. {$endc}
  164. {$ifc defined __LP64__ and __LP64__ }
  165. {$setc TARGET_CPU_64 := TRUE}
  166. {$elsec}
  167. {$setc TARGET_CPU_64 := FALSE}
  168. {$endc}
  169. {$ifc defined FPC_BIG_ENDIAN}
  170. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  171. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  172. {$elifc defined FPC_LITTLE_ENDIAN}
  173. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  174. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  175. {$elsec}
  176. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  177. {$endc}
  178. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  179. {$setc CALL_NOT_IN_CARBON := FALSE}
  180. {$setc OLDROUTINENAMES := FALSE}
  181. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  182. {$setc OPAQUE_UPP_TYPES := TRUE}
  183. {$setc OTCARBONAPPLICATION := TRUE}
  184. {$setc OTKERNEL := FALSE}
  185. {$setc PM_USE_SESSION_APIS := TRUE}
  186. {$setc TARGET_API_MAC_CARBON := TRUE}
  187. {$setc TARGET_API_MAC_OS8 := FALSE}
  188. {$setc TARGET_API_MAC_OSX := TRUE}
  189. {$setc TARGET_CARBON := TRUE}
  190. {$setc TARGET_CPU_68K := FALSE}
  191. {$setc TARGET_CPU_MIPS := FALSE}
  192. {$setc TARGET_CPU_SPARC := FALSE}
  193. {$setc TARGET_OS_UNIX := FALSE}
  194. {$setc TARGET_OS_WIN32 := FALSE}
  195. {$setc TARGET_RT_MAC_68881 := FALSE}
  196. {$setc TARGET_RT_MAC_CFM := FALSE}
  197. {$setc TARGET_RT_MAC_MACHO := TRUE}
  198. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  199. {$setc TYPE_BOOL := FALSE}
  200. {$setc TYPE_EXTENDED := FALSE}
  201. {$setc TYPE_LONGLONG := TRUE}
  202. {$IFDEF FPC_DOTTEDUNITS}
  203. uses MacOsApi.MacTypes,MacOsApi.Appearance,MacOsApi.CarbonEvents,MacOsApi.Controls,MacOsApi.MacTextEditor,MacOsApi.QuickdrawTypes,MacOsApi.TextCommon, MacOsApi.CFBase,MacOsApi.CGBase,MacOsApi.HIGeometry,MacOsApi.HIObject,MacOsApi.HIView;
  204. {$ELSE FPC_DOTTEDUNITS}
  205. uses MacTypes,Appearance,CarbonEvents,Controls,MacTextEditor,QuickdrawTypes,TextCommon, CFBase,CGBase,HIGeometry,HIObject,HIView;
  206. {$ENDIF FPC_DOTTEDUNITS}
  207. {$endc} {not MACOSALLINCLUDE}
  208. {$ifc TARGET_OS_MAC}
  209. {$ALIGN MAC68K}
  210. {
  211. * HITextViews.h
  212. *
  213. * Discussion:
  214. * API definitions for the standard text-display and text-editing
  215. * views: Static text view, HITextView, EditUnicodeText view, and
  216. * (deprecated) classic EditText view.
  217. }
  218. {ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ}
  219. { ¥ Static Text (CDEF 18) }
  220. {ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ}
  221. { Static Text proc IDs }
  222. const
  223. kControlStaticTextProc = 288;
  224. { Control Kind Tag }
  225. const
  226. kControlKindStaticText = FourCharCode('stxt');
  227. { The HIObject class ID for the HIStaticTextView class. }
  228. {$ifc USE_CFSTR_CONSTANT_MACROS}
  229. {$definec kHIStaticTextViewClassID CFSTRP('com.apple.HIStaticTextView')}
  230. {$endc}
  231. { Creation API: Carbon only }
  232. {$ifc not TARGET_CPU_64}
  233. {
  234. * CreateStaticTextControl()
  235. *
  236. * Summary:
  237. * Creates a new static text control.
  238. *
  239. * Mac OS X threading:
  240. * Not thread safe
  241. *
  242. * Parameters:
  243. *
  244. * window:
  245. * The window in which the control should be placed. May be NULL
  246. * in 10.3 and later.
  247. *
  248. * boundsRect:
  249. * The bounds of the control, in local coordinates of the window.
  250. *
  251. * text:
  252. * The text of the control. May be NULL.
  253. *
  254. * style:
  255. * The control's font style, size, color, and so on. May be NULL.
  256. *
  257. * outControl:
  258. * On exit, contains the new control.
  259. *
  260. * Result:
  261. * An operating system result code.
  262. *
  263. * Availability:
  264. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  265. * CarbonLib: in CarbonLib 1.1 and later
  266. * Non-Carbon CFM: not available
  267. }
  268. function CreateStaticTextControl( window: WindowRef { can be NULL }; const (*var*) boundsRect: Rect; text: CFStringRef { can be NULL }; {const} style: ControlFontStyleRecPtr { can be NULL }; var outControl: ControlRef ): OSStatus; external name '_CreateStaticTextControl';
  269. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  270. {$endc} {not TARGET_CPU_64}
  271. {
  272. * Summary:
  273. * Tagged data supported by the static text control
  274. }
  275. const
  276. {
  277. * Used to get or set the control's current text style. Data is of
  278. * type ControlFontStyleRec. Available with Appearance Manager 1.0
  279. * (Mac OS 8.0) and later.
  280. }
  281. kControlStaticTextStyleTag = kControlFontStyleTag;
  282. {
  283. * Used to get or set the control's current text. Data is an array of
  284. * chars. Generally you should used GetControlDataSize to determine
  285. * the length of the text, and allocate a buffer of that length,
  286. * before calling GetControlData with this selector. Deprecated in
  287. * Carbon in favor of kControlStaticTextCFStringTag. Available with
  288. * Appearance Manager 1.0 (Mac OS 8.0) and later.
  289. }
  290. kControlStaticTextTextTag = FourCharCode('text');
  291. {
  292. * Used to get the height of the control's text. May not be used with
  293. * SetControlData. Data is of type SInt16. Available with Appearance
  294. * Manager 1.0 (Mac OS 8.0) and later.
  295. }
  296. kControlStaticTextTextHeightTag = FourCharCode('thei');
  297. {
  298. * Used to get or set the control's text truncation style. Data is of
  299. * type TruncCode; pass a truncation code of -1 to indication no
  300. * truncation. Available with Appearance Manager 1.1 (Mac OS 8.5) and
  301. * later. Truncation will not occur unless
  302. * kControlStaticTextIsMultilineTag is set to false.
  303. }
  304. kControlStaticTextTruncTag = FourCharCode('trun');
  305. {
  306. * Used to get or set the control's current text. Data is of type
  307. * CFStringRef. When setting the text, the control will retain the
  308. * string, so you may release the string after calling
  309. * SetControlData; if the string is mutable, the control will make a
  310. * copy of the string, so any changes to the string after calling
  311. * SetControlData will not affect the control. When getting the text,
  312. * the control retains the string before returning it to you, so you
  313. * must release the string after you are done with it. Available in
  314. * CarbonLib 1.5 and Mac OS X 10.0 and later.
  315. }
  316. kControlStaticTextCFStringTag = FourCharCode('cfst');
  317. {
  318. * Used to get or set whether the control draws its text in multiple
  319. * lines if the text is too wide for the control bounds. If false,
  320. * then the control always draws the text in a single line. Data is
  321. * of type Boolean. Default is true. Available in Mac OS X 10.1 and
  322. * later.
  323. }
  324. kControlStaticTextIsMultilineTag = FourCharCode('stim');
  325. {==============================================================================}
  326. { Text field events }
  327. { A text field is the part of some views that you can enter text into. }
  328. { A text field is common to the EditText, EditUnicodeText, ComboBox, }
  329. { HISearchField, and HITextView views. The kEventClassTextField event allows }
  330. { you to receive notifications when the text has been accepted by the user. }
  331. { For example, you can install a handler for a kEventClassTextField / }
  332. { kEventTextAccepted event on a HISearchField view to receive a notification }
  333. { that the user has initiated a search by hitting the return or enter key. }
  334. { You can also filter the text that will replace a selection before the }
  335. { change has been made to either accept or reject the replacement. }
  336. {==============================================================================}
  337. {
  338. kEventClassTextField quick reference:
  339. kEventTextAccepted = 1,
  340. kEventTextShouldChangeInRange = 2,
  341. kEventTextDidChange = 3
  342. }
  343. const
  344. kEventClassTextField = FourCharCode('txfd');
  345. const
  346. kEventParamTextSelection = FourCharCode('txsl'); { typeCFRange}
  347. kEventParamCandidateText = FourCharCode('tstx'); { typeCFStringRef}
  348. kEventParamReplacementText = FourCharCode('trtx'); { typeCFStringRef}
  349. kEventParamUnconfirmedRange = FourCharCode('tunr'); { typeCFRange}
  350. kEventParamUnconfirmedText = FourCharCode('txun'); { typeCFStringRef}
  351. {
  352. * kEventClassTextField / kEventTextAccepted
  353. *
  354. * Summary:
  355. * Notification that the text in a view's editable text field has
  356. * been accepted.
  357. *
  358. * Discussion:
  359. * This event is sent as a notification when the text contained in a
  360. * view's editable text field has been accepted by the user. Text is
  361. * accepted when the user presses return or enter on the keyboard
  362. * for the EditUnicodeText, HIComboBox, and HISearchField views, or
  363. * when the text has changed in the field and the field loses focus
  364. * for the EditUnicodeText, HIComboBox, HISearchField and HITextView
  365. * views.
  366. *
  367. * This event is sent to the view containing the text field only, it
  368. * will not propagate. It is sent to all handlers installed on the
  369. * view containing the text field.
  370. *
  371. * Mac OS X threading:
  372. * Not thread safe
  373. *
  374. * Parameters:
  375. *
  376. * --> kEventParamDirectObject (in, typeControlRef)
  377. * The editable text field that has sent the notification.
  378. *
  379. * Availability:
  380. * Mac OS X: in version 10.3 and later in Carbon.framework
  381. * CarbonLib: not available
  382. }
  383. const
  384. kEventTextAccepted = 1;
  385. {
  386. * kEventClassTextField / kEventTextShouldChangeInRange
  387. *
  388. * Summary:
  389. * Returns whether the text should be changed in editable text
  390. * fields.
  391. *
  392. * Discussion:
  393. * There are several editable text field views, such as the
  394. * HIComboBox, HISearchField, HITextView, and EditUnicodeText views.
  395. * There are times when you may require fine-grained control over
  396. * what text is inserted into the text field and either accept the
  397. * changes, reject them or modify what is to be entered. This event
  398. * is sent whenever the text is about to be modified in a text
  399. * field, either by user input or in other scenarios such as a paste
  400. * from the clipboard, spell-checking word correction, or Mac OS X
  401. * Service operation. You can change what text is inserted by
  402. * providing a replacement string as a parameter to this event. This
  403. * event is only sent for Unicode text views; it is not sent for the
  404. * classic non-Unicode EditText control.
  405. *
  406. * This event is not sent prior to programmatic modification of the
  407. * text field contents using SetControlData.
  408. *
  409. * This event is not sent while an active inline editing session is
  410. * in progress. Once the inline text has been confirmed, this event
  411. * will be sent prior to the confirmed text being inserted into the
  412. * text field. If you need control over keystrokes during an inline
  413. * editing session, you can use the kEventTextInputFilterText event.
  414. *
  415. *
  416. * This event is sent to the view containing the text field only; it
  417. * will not propagate.
  418. *
  419. * Mac OS X threading:
  420. * Not thread safe
  421. *
  422. * Parameters:
  423. *
  424. * --> kEventParamDirectObject (in, typeControlRef)
  425. * The editable text field that has sent the notification.
  426. * Available in Mac OS X 10.5 and later.
  427. *
  428. * --> kEventParamTextSelection (in, typeCFRange)
  429. * The range of the selection that is about to be changed. The
  430. * units of the selection are in the same units that are
  431. * returned in a EditTextSelectionRec, when called with
  432. * GetControlData using kControlEditTextSelectionTag.
  433. *
  434. * --> kEventParamCandidateText (in, typeCFStringRef)
  435. * The text that is going to replace the selection. Note that
  436. * this string was originally created with
  437. * CFStringCreateWithCharactersNoCopy, and the original text
  438. * has a limited lifespan. If for some reason you need to
  439. * retain the text past the end of your event handler, you
  440. * should extract the characters from the string with
  441. * CFStringGetCharacters, and then store those characters or
  442. * create a new CFString from them.
  443. *
  444. * <-- kEventParamReplacementText (out, typeCFStringRef)
  445. * On output, can contain optional replacement text.
  446. *
  447. * Result:
  448. * If noErr is returned from your handler and the
  449. * kEventParamReplacementText parameter is added to the event, then
  450. * the contents of that parameter, rather than the candidate text,
  451. * will be added to the text field.
  452. *
  453. * If noErr is returned from your handler and the
  454. * kEventParamReplacementText parameter is _not_ added to the event,
  455. * then the candidate text will be filtered out and no text will be
  456. * entered in the text field. The current selection will be deleted,
  457. * however.
  458. *
  459. * If userCanceledErr is returned from your handler, then no text
  460. * will be entered in the text field and the current selection will
  461. * remain unchanged. Effectively, the editing operation will be
  462. * ignored. Note that when an inline text editing session is active,
  463. * you will only receive this event when the user attempts to
  464. * confirm the inline input. You should not return userCanceledErr
  465. * at this point; doing so will not really prevent the text from
  466. * being committed.
  467. *
  468. * If eventNotHandledErr is returned from your handler, the contents
  469. * of the kEventParamReplacementText parameter are ignored, and the
  470. * candidate text will replace the selection.
  471. *
  472. * Any other return value will result in the default behavior, as if
  473. * eventNotHandledErr had been returned.
  474. *
  475. * Availability:
  476. * Mac OS X: in version 10.4 and later in Carbon.framework
  477. * CarbonLib: not available
  478. }
  479. const
  480. kEventTextShouldChangeInRange = 2;
  481. {
  482. * kEventClassTextField / kEventTextDidChange
  483. *
  484. * Summary:
  485. * Indicates that the contents of an editable text field have
  486. * changed.
  487. *
  488. * Discussion:
  489. * This event is sent by all of the Unicode-based editable text
  490. * views: HIComboBox, HISearchField, HITextView and EditUnicodeText.
  491. * This event is not sent for the classic non-Unicode EditText view.
  492. *
  493. *
  494. * Note that this event is sent after inline editing operations,
  495. * such as pressing a dead key, or using a input method that creates
  496. * an inline editing hole. Most clients of this event should ignore
  497. * the event during inline editing, and only respond to changes to
  498. * the text after inline editing completes. A client can check for
  499. * the presence of the kEventParamUnconfirmedRange parameter to
  500. * determine whether inline editing is currently active; if this
  501. * parameter is present, the client may wish to ignore the event.
  502. *
  503. *
  504. * This event is not sent after programmatic modification of the
  505. * text field contents using SetControlData.
  506. *
  507. * This event is sent only to the view containing the text field; it
  508. * will not propagate. It is sent to all handlers registered for it.
  509. *
  510. * Mac OS X threading:
  511. * Not thread safe
  512. *
  513. * Parameters:
  514. *
  515. * --> kEventParamDirectObject (in, typeControlRef)
  516. * The editable text field that has sent the notification.
  517. * Available in Mac OS X 10.5 and later.
  518. *
  519. * --> kEventParamUnconfirmedRange (in, typeCFRange)
  520. * If the text field currently has an open inline hole, this
  521. * parameter contains the range of text inside the hole. This
  522. * parameter is optional and is only present during inline
  523. * editing.
  524. *
  525. * --> kEventParamUnconfirmedText (in, typeCFStringRef)
  526. * If the text field currently has an open inline hole, this
  527. * parameter contains the non-confirmed text currently being
  528. * edited inside the hole. This parameter is optional and is
  529. * only present during inline editing. Note that this string
  530. * was originally created with
  531. * CFStringCreateWithCharactersNoCopy, and the original text
  532. * has a limited lifespan. If for some reason you need to
  533. * retain the text past the end of your event handler, you
  534. * should extract the characters from the string with
  535. * CFStringGetCharacters, and then store those characters or
  536. * create a new CFString from them.
  537. *
  538. * Availability:
  539. * Mac OS X: in version 10.4 and later in Carbon.framework
  540. * CarbonLib: not available
  541. }
  542. const
  543. kEventTextDidChange = 3;
  544. {ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ}
  545. { ¥ HITextView }
  546. {ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ}
  547. {==============================================================================}
  548. { HITextView is a MLTE view that can be embedded in the HIView hierarchy. The }
  549. { view can be embedded in an HIScrollView if scroll bars are desired and can }
  550. { be used in a composited window. On creation, a TXNObject is created to back }
  551. { the view. You can extract the TXNObject at any time and use a subset of the }
  552. { MLTE API with that object as an argument. }
  553. {==============================================================================}
  554. {
  555. In Mac OS X 10.4 and later, HITextView supports these tags previously defined for the EditUnicodeText control:
  556. kControlEditTextCharCount
  557. kControlEditTextSelectionTag
  558. kControlEditTextCFStringTag
  559. kControlEditTextInsertCFStringRefTag
  560. }
  561. { The HIObject class ID for the HITextView class. }
  562. {
  563. * kHITextViewClassID
  564. *
  565. * Mac OS X threading:
  566. * Not thread safe
  567. *
  568. * Availability:
  569. * Mac OS X: in version 10.3 and later in Carbon.framework [32-bit only]
  570. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  571. * Non-Carbon CFM: not available
  572. }
  573. var kHITextViewClassID: CFStringRef; external name '_kHITextViewClassID'; (* attribute const *)
  574. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  575. { ControlKind}
  576. const
  577. kControlKindHITextView = FourCharCode('hitx');
  578. {$ifc not TARGET_CPU_64}
  579. {
  580. * HITextViewCreate()
  581. *
  582. * Summary:
  583. * Creates a text view. The new view is initially invisible.
  584. *
  585. * Mac OS X threading:
  586. * Not thread safe
  587. *
  588. * Parameters:
  589. *
  590. * inBoundsRect:
  591. * The bounding box of the view. If NULL, the bounds of the view
  592. * will be initialized to 0.
  593. *
  594. * inOptions:
  595. * There are currently no options. This must be 0.
  596. *
  597. * inTXNFrameOptions:
  598. * Any frame options desired for the TXN object creation.
  599. *
  600. * outTextView:
  601. * On exit, contains the new view.
  602. *
  603. * Availability:
  604. * Mac OS X: in version 10.3 and later in Carbon.framework [32-bit only]
  605. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  606. * Non-Carbon CFM: not available
  607. }
  608. function HITextViewCreate( {const} inBoundsRect: HIRectPtr { can be NULL }; inOptions: OptionBits; inTXNFrameOptions: TXNFrameOptions; var outTextView: HIViewRef ): OSStatus; external name '_HITextViewCreate';
  609. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  610. {
  611. * HITextViewGetTXNObject()
  612. *
  613. * Summary:
  614. * Obtains the TXNObject that backs the text view.
  615. *
  616. * Mac OS X threading:
  617. * Not thread safe
  618. *
  619. * Parameters:
  620. *
  621. * inTextView:
  622. * The text view that contains the TXNObject you wish to retrieve.
  623. *
  624. * Result:
  625. * The TXNObject backing the given view.
  626. *
  627. * Availability:
  628. * Mac OS X: in version 10.3 and later in Carbon.framework [32-bit only]
  629. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  630. * Non-Carbon CFM: not available
  631. }
  632. function HITextViewGetTXNObject( inTextView: HIViewRef ): TXNObject; external name '_HITextViewGetTXNObject';
  633. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  634. {
  635. * HITextViewSetBackgroundColor()
  636. *
  637. * Summary:
  638. * Sets the background color of the view. This allows you to provide
  639. * alpha as well. If inColor is NULL, the background of the text
  640. * view will not draw.
  641. *
  642. * Mac OS X threading:
  643. * Not thread safe
  644. *
  645. * Parameters:
  646. *
  647. * inTextView:
  648. * The text view that you are modifying the background color of.
  649. *
  650. * inColor:
  651. * A CGColorRef representing the color or pattern that will fill
  652. * the background of the text view. The CGColorRef will be
  653. * retained by this API. If the text view already contains a
  654. * background color, it will be released prior to the new color
  655. * being retained. If inColor is NULL, the background of the text
  656. * view will not draw.
  657. *
  658. * Result:
  659. * An operating system status code.
  660. *
  661. * Availability:
  662. * Mac OS X: in version 10.3 and later in Carbon.framework [32-bit only]
  663. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  664. * Non-Carbon CFM: not available
  665. }
  666. function HITextViewSetBackgroundColor( inTextView: HIViewRef; inColor: CGColorRef { can be NULL } ): OSStatus; external name '_HITextViewSetBackgroundColor';
  667. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  668. {
  669. * HITextViewCopyBackgroundColor()
  670. *
  671. * Summary:
  672. * Gets the background color of the view. If the background color
  673. * returned is NULL, the background does not draw.
  674. *
  675. * Mac OS X threading:
  676. * Not thread safe
  677. *
  678. * Parameters:
  679. *
  680. * inTextView:
  681. * The text view from which you want to obtain the background
  682. * color.
  683. *
  684. * outColor:
  685. * A CGColorRef representing the color or pattern that is used for
  686. * drawing the background of the text view. If the returned value
  687. * is NULL, the background does not draw. If the returned
  688. * CGColorRef is not NULL, it will be retained on return. You are
  689. * responsible for releasing this CGColorRef when you are no
  690. * longer referencing it.
  691. *
  692. * Result:
  693. * An operating system status code.
  694. *
  695. * Availability:
  696. * Mac OS X: in version 10.3 and later in Carbon.framework [32-bit only]
  697. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.3 and later
  698. * Non-Carbon CFM: not available
  699. }
  700. function HITextViewCopyBackgroundColor( inTextView: HIViewRef; var outColor: CGColorRef ): OSStatus; external name '_HITextViewCopyBackgroundColor';
  701. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  702. {---------------------------------------------------------------------------------------}
  703. { EditUnicodeText }
  704. {---------------------------------------------------------------------------------------}
  705. { This view is only available in Mac OS X. It is super similar to Edit Text control }
  706. { Use all the same Get/Set tags. But don't ask for the TEHandle. }
  707. {---------------------------------------------------------------------------------------}
  708. {$endc} {not TARGET_CPU_64}
  709. const
  710. kControlEditUnicodeTextProc = 912;
  711. kControlEditUnicodeTextPasswordProc = 914;
  712. { Control Kind Tag }
  713. const
  714. kControlKindEditUnicodeText = FourCharCode('eutx');
  715. { The HIObject class ID for the HITextField class. }
  716. {$ifc USE_CFSTR_CONSTANT_MACROS}
  717. {$definec kHITextFieldClassID CFSTRP('com.apple.HITextField')}
  718. {$endc}
  719. {$ifc not TARGET_CPU_64}
  720. {
  721. * CreateEditUnicodeTextControl()
  722. *
  723. * Summary:
  724. * Creates a new edit text control.
  725. *
  726. * Discussion:
  727. * This is the preferred edit text control. Use it instead of the
  728. * EditText control. This control handles Unicode and draws its text
  729. * using antialiasing, which the other control does not.
  730. *
  731. * Mac OS X threading:
  732. * Not thread safe
  733. *
  734. * Parameters:
  735. *
  736. * window:
  737. * The window in which the control should be placed. May be NULL
  738. * in 10.3 and later.
  739. *
  740. * boundsRect:
  741. * The bounds of the control, in local coordinates of the window.
  742. *
  743. * text:
  744. * The text of the control. May be NULL.
  745. *
  746. * isPassword:
  747. * A Boolean indicating whether the field is to be used as a
  748. * password field. Passing false indicates that the field is to
  749. * display entered text normally. True means that the field will
  750. * be used as a password field and any text typed into the field
  751. * will be displayed only as bullets.
  752. *
  753. * style:
  754. * The control's font style, size, color, and so on. May be NULL.
  755. *
  756. * outControl:
  757. * On exit, contains the new control (if noErr is returned as the
  758. * result code).
  759. *
  760. * Result:
  761. * An operating system result code.
  762. *
  763. * Availability:
  764. * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
  765. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  766. * Non-Carbon CFM: not available
  767. }
  768. function CreateEditUnicodeTextControl( window: WindowRef; const (*var*) boundsRect: Rect; text: CFStringRef { can be NULL }; isPassword: Boolean; {const} style: ControlFontStyleRecPtr { can be NULL }; var outControl: ControlRef ): OSStatus; external name '_CreateEditUnicodeTextControl';
  769. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  770. { Tagged data supported by edit text }
  771. {$endc} {not TARGET_CPU_64}
  772. const
  773. kControlEditTextStyleTag = kControlFontStyleTag; { ControlFontStyleRec}
  774. kControlEditTextTextTag = FourCharCode('text'); { Buffer of chars - you supply the buffer}
  775. kControlEditTextKeyFilterTag = kControlKeyFilterTag;
  776. kControlEditTextSelectionTag = FourCharCode('sele'); { ControlEditTextSelectionRec}
  777. kControlEditTextPasswordTag = FourCharCode('pass'); { The clear text password text}
  778. kControlEditTextCharCount = FourCharCode('chrc'); { [UInt32] Count of characters in the control's text}
  779. { tags available with Appearance 1.1 or later }
  780. const
  781. kControlEditTextKeyScriptBehaviorTag = FourCharCode('kscr'); { ControlKeyScriptBehavior. Defaults to "PrefersRoman" for password fields,}
  782. { or "AllowAnyScript" for non-password fields.}
  783. kControlEditTextLockedTag = FourCharCode('lock'); { Boolean. Locking disables editability.}
  784. kControlEditTextFixedTextTag = FourCharCode('ftxt'); { Like the normal text tag, but fixes inline input first}
  785. kControlEditTextValidationProcTag = FourCharCode('vali'); { ControlEditTextValidationUPP. Called when a key filter can't be: after cut, paste, etc.}
  786. {
  787. * Discussion:
  788. * EditText ControlData tags available with Mac OS X and later.
  789. }
  790. const
  791. {
  792. * Extract the content of the edit text field as a CFString. Don't
  793. * forget that you own the returned CFStringRef and are responsible
  794. * for CFReleasing it.
  795. }
  796. kControlEditTextCFStringTag = FourCharCode('cfst'); { CFStringRef (Also available on CarbonLib 1.5)}
  797. {
  798. * Extract the content of the edit text field as a CFString, if it is
  799. * a password field. Don't forget that you own the returned
  800. * CFStringRef and are responsible for CFReleasing it.
  801. }
  802. kControlEditTextPasswordCFStringTag = FourCharCode('pwcf'); { CFStringRef}
  803. const
  804. kControlEditTextSingleLineTag = FourCharCode('sglc'); { data is a Boolean; indicates whether the control should always be single-line}
  805. kControlEditTextInsertTextBufferTag = FourCharCode('intx'); { data is an array of AnsiChar; get or set the control's text as WorldScript-encoded text}
  806. kControlEditTextInsertCFStringRefTag = FourCharCode('incf'); { data is a CFStringRef; get or set the control's text as a CFStringRef. Caller should release CFString if getting.}
  807. kControlEditUnicodeTextPostUpdateProcTag = FourCharCode('upup'); { data is a UnicodePostUpdateUPP; get or set the post-update proc}
  808. kControlEditTextSpellCheckingTag = FourCharCode('spck'); { data is a Boolean; indicates whether the control wants to have spell checking support. Available in Leopard and later.}
  809. kControlEditTextSpellCheckAsYouTypeTag = FourCharCode('scat'); { data is a Boolean; indicates whether you want to support spell-checking-as-you-type. Available in Leopard and later.}
  810. { Structure for getting the edit text selection. Used with kControlEditTextSelectionTag. }
  811. type
  812. ControlEditTextSelectionRec = record
  813. selStart: SInt16;
  814. selEnd: SInt16;
  815. end;
  816. type
  817. ControlEditTextSelectionPtr = ^ControlEditTextSelectionRec;
  818. ControlEditTextValidationProcPtr = procedure( control: ControlRef );
  819. { This callback supplies the functionality of the TSMTEPostUpdateProcPtr that is used }
  820. { in the EditText control. A client should supply this call if they want to look at }
  821. { inline text that has been fixed before it is included in the actual body text }
  822. { if the new text (i.e. the text in the handle) should be included in the body text }
  823. { the client should return true. If the client wants to block the inclusion of the }
  824. { text they should return false. }
  825. type
  826. EditUnicodePostUpdateProcPtr = function( uniText: UniCharArrayHandle; uniTextLength: UniCharCount; iStartOffset: UniCharArrayOffset; iEndOffset: UniCharArrayOffset; refcon: UnivPtr ): Boolean;
  827. ControlEditTextValidationUPP = ControlEditTextValidationProcPtr;
  828. EditUnicodePostUpdateUPP = EditUnicodePostUpdateProcPtr;
  829. {
  830. * NewControlEditTextValidationUPP()
  831. *
  832. * Availability:
  833. * Mac OS X: in version 10.0 and later in Carbon.framework
  834. * CarbonLib: in CarbonLib 1.0 and later
  835. * Non-Carbon CFM: available as macro/inline
  836. }
  837. function NewControlEditTextValidationUPP( userRoutine: ControlEditTextValidationProcPtr ): ControlEditTextValidationUPP; external name '_NewControlEditTextValidationUPP';
  838. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  839. {
  840. * NewEditUnicodePostUpdateUPP()
  841. *
  842. * Availability:
  843. * Mac OS X: in version 10.0 and later in Carbon.framework
  844. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  845. * Non-Carbon CFM: not available
  846. }
  847. function NewEditUnicodePostUpdateUPP( userRoutine: EditUnicodePostUpdateProcPtr ): EditUnicodePostUpdateUPP; external name '_NewEditUnicodePostUpdateUPP';
  848. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  849. {
  850. * DisposeControlEditTextValidationUPP()
  851. *
  852. * Availability:
  853. * Mac OS X: in version 10.0 and later in Carbon.framework
  854. * CarbonLib: in CarbonLib 1.0 and later
  855. * Non-Carbon CFM: available as macro/inline
  856. }
  857. procedure DisposeControlEditTextValidationUPP( userUPP: ControlEditTextValidationUPP ); external name '_DisposeControlEditTextValidationUPP';
  858. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  859. {
  860. * DisposeEditUnicodePostUpdateUPP()
  861. *
  862. * Availability:
  863. * Mac OS X: in version 10.0 and later in Carbon.framework
  864. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  865. * Non-Carbon CFM: not available
  866. }
  867. procedure DisposeEditUnicodePostUpdateUPP( userUPP: EditUnicodePostUpdateUPP ); external name '_DisposeEditUnicodePostUpdateUPP';
  868. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  869. {
  870. * InvokeControlEditTextValidationUPP()
  871. *
  872. * Availability:
  873. * Mac OS X: in version 10.0 and later in Carbon.framework
  874. * CarbonLib: in CarbonLib 1.0 and later
  875. * Non-Carbon CFM: available as macro/inline
  876. }
  877. procedure InvokeControlEditTextValidationUPP( control: ControlRef; userUPP: ControlEditTextValidationUPP ); external name '_InvokeControlEditTextValidationUPP';
  878. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  879. {
  880. * InvokeEditUnicodePostUpdateUPP()
  881. *
  882. * Availability:
  883. * Mac OS X: in version 10.0 and later in Carbon.framework
  884. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  885. * Non-Carbon CFM: not available
  886. }
  887. function InvokeEditUnicodePostUpdateUPP( uniText: UniCharArrayHandle; uniTextLength: UniCharCount; iStartOffset: UniCharArrayOffset; iEndOffset: UniCharArrayOffset; refcon: UnivPtr; userUPP: EditUnicodePostUpdateUPP ): Boolean; external name '_InvokeEditUnicodePostUpdateUPP';
  888. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  889. {$endc} {TARGET_OS_MAC}
  890. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  891. end.
  892. {$endc} {not MACOSALLINCLUDE}