TextServices.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:17k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       TextServices.h
  3.  
  4.      Contains:   Text Services Manager Interfaces.
  5.  
  6.      Version:    Technology: System 8.2
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1991-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __TEXTSERVICES__
  18. #define __TEXTSERVICES__
  19. #ifndef __CONDITIONALMACROS__
  20. #include "ConditionalMacros.h"
  21. #endif
  22. #ifndef __MACTYPES__
  23. #include "MacTypes.h"
  24. #endif
  25. #ifndef __EVENTS__
  26. #include "Events.h"
  27. #endif
  28. #ifndef __MENUS__
  29. #include "Menus.h"
  30. #endif
  31. #ifndef __AEDATAMODEL__
  32. #include "AEDataModel.h"
  33. #endif
  34. #ifndef __AEREGISTRY__
  35. #include "AERegistry.h"
  36. #endif
  37. #ifndef __COMPONENTS__
  38. #include "Components.h"
  39. #endif
  40. #if PRAGMA_ONCE
  41. #pragma once
  42. #endif
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. #if PRAGMA_IMPORT
  47. #pragma import on
  48. #endif
  49. #if PRAGMA_STRUCT_ALIGN
  50.     #pragma options align=mac68k
  51. #elif PRAGMA_STRUCT_PACKPUSH
  52.     #pragma pack(push, 2)
  53. #elif PRAGMA_STRUCT_PACK
  54.     #pragma pack(2)
  55. #endif
  56. enum {
  57.     kTextService                = FOUR_CHAR_CODE('tsvc'),       /* component type for the component description */
  58.     kInputMethodService         = FOUR_CHAR_CODE('inpm'),       /* component subtype for the component description */
  59.     kTSMVersion                 = 0x0150                        /* Version of the Text Services Manager is 1.5 */
  60. };
  61. enum {
  62.     kUnicodeDocument            = FOUR_CHAR_CODE('udoc'),       /* TSM Document type for Unicode-savvy application */
  63.     kUnicodeTextService         = FOUR_CHAR_CODE('utsv')        /* Component type for Unicode Text Service */
  64. };
  65. /* Language and Script constants*/
  66. enum {
  67.     kUnknownLanguage            = 0xFFFF,
  68.     kUnknownScript              = 0xFFFF,
  69.     kNeutralScript              = 0xFFFF
  70. };
  71. enum {
  72.                                                                 /* Component Flags in ComponentDescription */
  73.     bTakeActiveEvent            = 15,                           /* bit set if the component takes active event */
  74.     bHandleAERecording          = 16,                           /* bit set if the component takes care of recording Apple Events <new in vers2.0> */
  75.     bScriptMask                 = 0x00007F00,                   /* bit 8 - 14 */
  76.     bLanguageMask               = 0x000000FF,                   /* bit 0 - 7  */
  77.     bScriptLanguageMask         = bScriptMask + bLanguageMask   /* bit 0 - 14  */
  78. };
  79. enum {
  80.                                                                 /* Typing method property constants for Input Methods */
  81.     kIMJaTypingMethodProperty   = FOUR_CHAR_CODE('jtyp'),       /* Typing method property for Japanese input methods*/
  82.     kIMJaTypingMethodRoman      = FOUR_CHAR_CODE('roma'),       /* Roman typing*/
  83.     kIMJaTypingMethodKana       = FOUR_CHAR_CODE('kana')        /* Kana typing*/
  84. };
  85. enum {
  86.                                                                 /* Low level routines which are dispatched directly to the Component Manager */
  87.     kCMGetScriptLangSupport     = 0x0001,                       /* Component Manager call selector 1 */
  88.     kCMInitiateTextService      = 0x0002,                       /* Component Manager call selector 2 */
  89.     kCMTerminateTextService     = 0x0003,                       /* Component Manager call selector 3 */
  90.     kCMActivateTextService      = 0x0004,                       /* Component Manager call selector 4 */
  91.     kCMDeactivateTextService    = 0x0005,                       /* Component Manager call selector 5 */
  92.     kCMTextServiceEvent         = 0x0006,                       /* Component Manager call selector 6 */
  93.     kCMGetTextServiceMenu       = 0x0007,                       /* Component Manager call selector 7 */
  94.     kCMTextServiceMenuSelect    = 0x0008,                       /* Component Manager call selector 8 */
  95.     kCMFixTextService           = 0x0009,                       /* Component Manager call selector 9 */
  96.     kCMSetTextServiceCursor     = 0x000A,                       /* Component Manager call selector 10 */
  97.     kCMHidePaletteWindows       = 0x000B,                       /* Component Manager call selector 11 */
  98.     kCMGetTextServiceProperty   = 0x000C,                       /* Component Manager call selector 12 */
  99.     kCMSetTextServiceProperty   = 0x000D                        /* Component Manager call selector 13 */
  100. };
  101. enum {
  102.                                                                 /* New low level routines which are dispatched directly to the Component Manager */
  103.     kCMUCTextServiceEvent       = 0x000E                        /* Component Manager call selector 14 */
  104. };
  105. /* extract Script/Language code from Component flag ... */
  106. #define     mGetScriptCode(cdRec)       ((ScriptCode)   ((cdRec.componentFlags & bScriptMask) >> 8))
  107. #define     mGetLanguageCode(cdRec)     ((LangCode)     cdRec.componentFlags & bLanguageMask)
  108. /* New opaque definitions for types */
  109. typedef struct OpaqueTSMDocumentID*     TSMDocumentID;
  110. typedef OSType                          InterfaceTypeList[1];
  111. /* Text Service Info List */
  112. struct TextServiceInfo {
  113.     Component                       fComponent;
  114.     Str255                          fItemName;
  115. };
  116. typedef struct TextServiceInfo          TextServiceInfo;
  117. typedef TextServiceInfo *               TextServiceInfoPtr;
  118. struct TextServiceList {
  119.     short                           fTextServiceCount;          /* number of entries in the 'fServices' array */
  120.     TextServiceInfo                 fServices[1];               /* Note: array of 'TextServiceInfo' records follows */
  121. };
  122. typedef struct TextServiceList          TextServiceList;
  123. typedef TextServiceList *               TextServiceListPtr;
  124. typedef TextServiceListPtr *            TextServiceListHandle;
  125. struct ScriptLanguageRecord {
  126.     ScriptCode                      fScript;
  127.     LangCode                        fLanguage;
  128. };
  129. typedef struct ScriptLanguageRecord     ScriptLanguageRecord;
  130. struct ScriptLanguageSupport {
  131.     short                           fScriptLanguageCount;       /* number of entries in the 'fScriptLanguageArray' array */
  132.     ScriptLanguageRecord            fScriptLanguageArray[1];    /* Note: array of 'ScriptLanguageRecord' records follows */
  133. };
  134. typedef struct ScriptLanguageSupport    ScriptLanguageSupport;
  135. typedef ScriptLanguageSupport *         ScriptLanguageSupportPtr;
  136. typedef ScriptLanguageSupportPtr *      ScriptLanguageSupportHandle;
  137. /* High level TSM Doucment routines */
  138. EXTERN_API( OSErr )
  139. NewTSMDocument                  (short                  numOfInterface,
  140.                                  InterfaceTypeList      supportedInterfaceTypes,
  141.                                  TSMDocumentID *        idocID,
  142.                                  long                   refcon)                             TWOWORDINLINE(0x7000, 0xAA54);
  143. EXTERN_API( OSErr )
  144. DeleteTSMDocument               (TSMDocumentID          idocID)                             TWOWORDINLINE(0x7001, 0xAA54);
  145. EXTERN_API( OSErr )
  146. ActivateTSMDocument             (TSMDocumentID          idocID)                             TWOWORDINLINE(0x7002, 0xAA54);
  147. EXTERN_API( OSErr )
  148. DeactivateTSMDocument           (TSMDocumentID          idocID)                             TWOWORDINLINE(0x7003, 0xAA54);
  149. EXTERN_API( OSErr )
  150. FixTSMDocument                  (TSMDocumentID          idocID)                             TWOWORDINLINE(0x7007, 0xAA54);
  151. EXTERN_API( OSErr )
  152. GetServiceList                  (short                  numOfInterface,
  153.                                  OSType *               supportedInterfaceTypes,
  154.                                  TextServiceListHandle * serviceInfo,
  155.                                  long *                 seedValue)                          TWOWORDINLINE(0x7008, 0xAA54);
  156. EXTERN_API( OSErr )
  157. OpenTextService                 (TSMDocumentID          idocID,
  158.                                  Component              aComponent,
  159.                                  ComponentInstance *    aComponentInstance)                 TWOWORDINLINE(0x7009, 0xAA54);
  160. EXTERN_API( OSErr )
  161. CloseTextService                (TSMDocumentID          idocID,
  162.                                  ComponentInstance      aComponentInstance)                 TWOWORDINLINE(0x700A, 0xAA54);
  163. EXTERN_API( OSErr )
  164. SendAEFromTSMComponent          (const AppleEvent *     theAppleEvent,
  165.                                  AppleEvent *           reply,
  166.                                  AESendMode             sendMode,
  167.                                  AESendPriority         sendPriority,
  168.                                  long                   timeOutInTicks,
  169.                                  AEIdleUPP              idleProc,
  170.                                  AEFilterUPP            filterProc)                         TWOWORDINLINE(0x700B, 0xAA54);
  171. EXTERN_API( OSErr )
  172. SetDefaultInputMethod           (Component              ts,
  173.                                  ScriptLanguageRecord * slRecordPtr)                        TWOWORDINLINE(0x700C, 0xAA54);
  174. EXTERN_API( OSErr )
  175. GetDefaultInputMethod           (Component *            ts,
  176.                                  ScriptLanguageRecord * slRecordPtr)                        TWOWORDINLINE(0x700D, 0xAA54);
  177. EXTERN_API( OSErr )
  178. SetTextServiceLanguage          (ScriptLanguageRecord * slRecordPtr)                        TWOWORDINLINE(0x700E, 0xAA54);
  179. EXTERN_API( OSErr )
  180. GetTextServiceLanguage          (ScriptLanguageRecord * slRecordPtr)                        TWOWORDINLINE(0x700F, 0xAA54);
  181. EXTERN_API( OSErr )
  182. UseInputWindow                  (TSMDocumentID          idocID,
  183.                                  Boolean                useWindow)                          TWOWORDINLINE(0x7010, 0xAA54);
  184. #if CALL_NOT_IN_CARBON
  185. /* Following calls from Classic event loops not needed for Carbon clients. */
  186. #if CALL_NOT_IN_CARBON
  187. EXTERN_API( Boolean )
  188. TSMEvent                        (EventRecord *          event)                              TWOWORDINLINE(0x7004, 0xAA54);
  189. EXTERN_API( Boolean )
  190. TSMMenuSelect                   (long                   menuResult)                         TWOWORDINLINE(0x7005, 0xAA54);
  191. EXTERN_API( Boolean )
  192. SetTSMCursor                    (Point                  mousePos)                           TWOWORDINLINE(0x7006, 0xAA54);
  193. /* Following ServiceWindow API replaced by Window Manager API in Carbon. */
  194. EXTERN_API( OSErr )
  195. NewServiceWindow                (void *                 wStorage,
  196.                                  const Rect *           boundsRect,
  197.                                  ConstStr255Param       title,
  198.                                  Boolean                visible,
  199.                                  short                  theProc,
  200.                                  WindowPtr              behind,
  201.                                  Boolean                goAwayFlag,
  202.                                  ComponentInstance      ts,
  203.                                  WindowPtr *            window)                             TWOWORDINLINE(0x7011, 0xAA54);
  204. EXTERN_API( OSErr )
  205. CloseServiceWindow              (WindowPtr              window)                             TWOWORDINLINE(0x7012, 0xAA54);
  206. EXTERN_API( OSErr )
  207. GetFrontServiceWindow           (WindowPtr *            window)                             TWOWORDINLINE(0x7013, 0xAA54);
  208. EXTERN_API( short )
  209. FindServiceWindow               (Point                  thePoint,
  210.                                  WindowPtr *            theWindow)                          TWOWORDINLINE(0x7017, 0xAA54);
  211. EXTERN_API( OSErr )
  212. NewCServiceWindow               (void *                 wStorage,
  213.                                  const Rect *           boundsRect,
  214.                                  ConstStr255Param       title,
  215.                                  Boolean                visible,
  216.                                  short                  theProc,
  217.                                  WindowPtr              behind,
  218.                                  Boolean                goAwayFlag,
  219.                                  ComponentInstance      ts,
  220.                                  WindowPtr *            window)                             TWOWORDINLINE(0x701A, 0xAA54);
  221. /* Explicit initialization not needed for Carbon clients, since TSM is */
  222. /* instanciated per-context. */
  223. EXTERN_API( OSErr )
  224. InitTSMAwareApplication         (void)                                                      TWOWORDINLINE(0x7014, 0xAA54);
  225. EXTERN_API( OSErr )
  226. CloseTSMAwareApplication        (void)                                                      TWOWORDINLINE(0x7015, 0xAA54);
  227. #endif  /* CALL_NOT_IN_CARBON */
  228. #endif  /* CALL_NOT_IN_CARBON */
  229. /* Component Manager Interfaces to Input Methods */
  230. EXTERN_API( ComponentResult )
  231. GetScriptLanguageSupport        (ComponentInstance      ts,
  232.                                  ScriptLanguageSupportHandle * scriptHdl)                   FIVEWORDINLINE(0x2F3C, 0x0004, 0x0001, 0x7000, 0xA82A);
  233. EXTERN_API( ComponentResult )
  234. InitiateTextService             (ComponentInstance      ts)                                 FIVEWORDINLINE(0x2F3C, 0x0000, 0x0002, 0x7000, 0xA82A);
  235. EXTERN_API( ComponentResult )
  236. TerminateTextService            (ComponentInstance      ts)                                 FIVEWORDINLINE(0x2F3C, 0x0000, 0x0003, 0x7000, 0xA82A);
  237. EXTERN_API( ComponentResult )
  238. ActivateTextService             (ComponentInstance      ts)                                 FIVEWORDINLINE(0x2F3C, 0x0000, 0x0004, 0x7000, 0xA82A);
  239. EXTERN_API( ComponentResult )
  240. DeactivateTextService           (ComponentInstance      ts)                                 FIVEWORDINLINE(0x2F3C, 0x0000, 0x0005, 0x7000, 0xA82A);
  241. EXTERN_API( ComponentResult )
  242. GetTextServiceMenu              (ComponentInstance      ts,
  243.                                  MenuRef *              serviceMenu)                        FIVEWORDINLINE(0x2F3C, 0x0004, 0x0007, 0x7000, 0xA82A);
  244. #if CALL_NOT_IN_CARBON
  245. #if CALL_NOT_IN_CARBON
  246. EXTERN_API( ComponentResult )
  247. TextServiceEvent                (ComponentInstance      ts,
  248.                                  short                  numOfEvents,
  249.                                  EventRecord *          event)                              FIVEWORDINLINE(0x2F3C, 0x0006, 0x0006, 0x7000, 0xA82A);
  250. EXTERN_API( ComponentResult )
  251. UCTextServiceEvent              (ComponentInstance      ts,
  252.                                  short                  numOfEvents,
  253.                                  EventRecord *          event,
  254.                                  UniChar                unicodeString[],
  255.                                  UniCharCount           unicodeStrLength)                   FIVEWORDINLINE(0x2F3C, 0x000E, 0x000E, 0x7000, 0xA82A);
  256. EXTERN_API( ComponentResult )
  257. TextServiceMenuSelect           (ComponentInstance      ts,
  258.                                  MenuRef                serviceMenu,
  259.                                  short                  item)                               FIVEWORDINLINE(0x2F3C, 0x0006, 0x0008, 0x7000, 0xA82A);
  260. EXTERN_API( ComponentResult )
  261. SetTextServiceCursor            (ComponentInstance      ts,
  262.                                  Point                  mousePos)                           FIVEWORDINLINE(0x2F3C, 0x0004, 0x000A, 0x7000, 0xA82A);
  263. #endif  /* CALL_NOT_IN_CARBON */
  264. #endif  /* CALL_NOT_IN_CARBON */
  265. EXTERN_API( ComponentResult )
  266. FixTextService                  (ComponentInstance      ts)                                 FIVEWORDINLINE(0x2F3C, 0x0000, 0x0009, 0x7000, 0xA82A);
  267. EXTERN_API( ComponentResult )
  268. HidePaletteWindows              (ComponentInstance      ts)                                 FIVEWORDINLINE(0x2F3C, 0x0000, 0x000B, 0x7000, 0xA82A);
  269. EXTERN_API( ComponentResult )
  270. GetTextServiceProperty          (ComponentInstance      ts,
  271.                                  OSType                 propertySelector,
  272.                                  SInt32 *               result)                             FIVEWORDINLINE(0x2F3C, 0x0008, 0x000C, 0x7000, 0xA82A);
  273. EXTERN_API( ComponentResult )
  274. SetTextServiceProperty          (ComponentInstance      ts,
  275.                                  OSType                 propertySelector,
  276.                                  SInt32                 value)                              FIVEWORDINLINE(0x2F3C, 0x0008, 0x000D, 0x7000, 0xA82A);
  277. #if PRAGMA_STRUCT_ALIGN
  278.     #pragma options align=reset
  279. #elif PRAGMA_STRUCT_PACKPUSH
  280.     #pragma pack(pop)
  281. #elif PRAGMA_STRUCT_PACK
  282.     #pragma pack()
  283. #endif
  284. #ifdef PRAGMA_IMPORT_OFF
  285. #pragma import off
  286. #elif PRAGMA_IMPORT
  287. #pragma import reset
  288. #endif
  289. #ifdef __cplusplus
  290. }
  291. #endif
  292. #endif /* __TEXTSERVICES__ */