Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

414 lines
14 KiB

  1. /*
  2. File: AEInteraction.h
  3. Contains: AppleEvent functions that deal with Events and interacting with user
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 2000-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __AEINTERACTION__
  11. #define __AEINTERACTION__
  12. #ifndef __AEDATAMODEL__
  13. #include <AEDataModel.h>
  14. #endif
  15. #ifndef __NOTIFICATION__
  16. #include <Notification.h>
  17. #endif
  18. #ifndef __EVENTS__
  19. #include <Events.h>
  20. #endif
  21. #if PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if PRAGMA_IMPORT
  28. #pragma import on
  29. #endif
  30. #if PRAGMA_STRUCT_ALIGN
  31. #pragma options align=mac68k
  32. #elif PRAGMA_STRUCT_PACKPUSH
  33. #pragma pack(push, 2)
  34. #elif PRAGMA_STRUCT_PACK
  35. #pragma pack(2)
  36. #endif
  37. /**************************************************************************
  38. AppleEvent callbacks.
  39. **************************************************************************/
  40. typedef CALLBACK_API( Boolean , AEIdleProcPtr )(EventRecord *theEvent, long *sleepTime, RgnHandle *mouseRgn);
  41. typedef CALLBACK_API( Boolean , AEFilterProcPtr )(EventRecord *theEvent, long returnID, long transactionID, const AEAddressDesc *sender);
  42. typedef STACK_UPP_TYPE(AEIdleProcPtr) AEIdleUPP;
  43. typedef STACK_UPP_TYPE(AEFilterProcPtr) AEFilterUPP;
  44. /**************************************************************************
  45. The next couple of calls are basic routines used to create, send,
  46. and process AppleEvents.
  47. **************************************************************************/
  48. /*
  49. * AESend()
  50. *
  51. * Availability:
  52. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  53. * CarbonLib: in CarbonLib 1.0 and later
  54. * Mac OS X: in version 10.0 and later
  55. */
  56. EXTERN_API( OSErr )
  57. AESend(
  58. const AppleEvent * theAppleEvent,
  59. AppleEvent * reply,
  60. AESendMode sendMode,
  61. AESendPriority sendPriority,
  62. long timeOutInTicks,
  63. AEIdleUPP idleProc, /* can be NULL */
  64. AEFilterUPP filterProc) /* can be NULL */ THREEWORDINLINE(0x303C, 0x0D17, 0xA816);
  65. /*
  66. * AEProcessAppleEvent()
  67. *
  68. * Availability:
  69. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  70. * CarbonLib: in CarbonLib 1.0 and later
  71. * Mac OS X: in version 10.0 and later
  72. */
  73. EXTERN_API( OSErr )
  74. AEProcessAppleEvent(const EventRecord * theEventRecord) THREEWORDINLINE(0x303C, 0x021B, 0xA816);
  75. /*
  76. Note: during event processing, an event handler may realize that it is likely
  77. to exceed the client's timeout limit. Passing the reply to this
  78. routine causes a wait event to be generated that asks the client
  79. for more time.
  80. */
  81. /*
  82. * AEResetTimer()
  83. *
  84. * Availability:
  85. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  86. * CarbonLib: in CarbonLib 1.0 and later
  87. * Mac OS X: in version 10.0 and later
  88. */
  89. EXTERN_API( OSErr )
  90. AEResetTimer(const AppleEvent * reply) THREEWORDINLINE(0x303C, 0x0219, 0xA816);
  91. /**************************************************************************
  92. The following three calls are used to allow applications to behave
  93. courteously when a user interaction such as a dialog box is needed.
  94. **************************************************************************/
  95. typedef SInt8 AEInteractAllowed;
  96. enum {
  97. kAEInteractWithSelf = 0,
  98. kAEInteractWithLocal = 1,
  99. kAEInteractWithAll = 2
  100. };
  101. /*
  102. * AEGetInteractionAllowed()
  103. *
  104. * Availability:
  105. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  106. * CarbonLib: in CarbonLib 1.0 and later
  107. * Mac OS X: in version 10.0 and later
  108. */
  109. EXTERN_API( OSErr )
  110. AEGetInteractionAllowed(AEInteractAllowed * level) THREEWORDINLINE(0x303C, 0x021D, 0xA816);
  111. /*
  112. * AESetInteractionAllowed()
  113. *
  114. * Availability:
  115. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  116. * CarbonLib: in CarbonLib 1.0 and later
  117. * Mac OS X: in version 10.0 and later
  118. */
  119. EXTERN_API( OSErr )
  120. AESetInteractionAllowed(AEInteractAllowed level) THREEWORDINLINE(0x303C, 0x011E, 0xA816);
  121. /*
  122. * AEInteractWithUser()
  123. *
  124. * Availability:
  125. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  126. * CarbonLib: in CarbonLib 1.0 and later
  127. * Mac OS X: in version 10.0 and later
  128. */
  129. EXTERN_API( OSErr )
  130. AEInteractWithUser(
  131. long timeOutInTicks,
  132. NMRecPtr nmReqPtr,
  133. AEIdleUPP idleProc) THREEWORDINLINE(0x303C, 0x061C, 0xA816);
  134. /**************************************************************************
  135. The following four calls are available for applications which need more
  136. sophisticated control over when and how events are processed. Applications
  137. which implement multi-session servers or which implement their own
  138. internal event queueing will probably be the major clients of these
  139. routines. They can be called from within a handler to prevent the AEM from
  140. disposing of the AppleEvent when the handler returns. They can be used to
  141. asynchronously process the event (as MacApp does).
  142. **************************************************************************/
  143. /*
  144. * AESuspendTheCurrentEvent()
  145. *
  146. * Availability:
  147. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  148. * CarbonLib: in CarbonLib 1.0 and later
  149. * Mac OS X: in version 10.0 and later
  150. */
  151. EXTERN_API( OSErr )
  152. AESuspendTheCurrentEvent(const AppleEvent * theAppleEvent) THREEWORDINLINE(0x303C, 0x022B, 0xA816);
  153. /*
  154. Note: The following routine tells the AppleEvent manager that processing
  155. is either about to resume or has been completed on a previously suspended
  156. event. The procPtr passed in as the dispatcher parameter will be called to
  157. attempt to redispatch the event. Several constants for the dispatcher
  158. parameter allow special behavior. They are:
  159. - kAEUseStandardDispatch means redispatch as if the event was just
  160. received, using the standard AppleEvent dispatch mechanism.
  161. - kAENoDispatch means ignore the parameter.
  162. Use this in the case where the event has been handled and no
  163. redispatch is needed.
  164. - non nil means call the routine which the dispatcher points to.
  165. */
  166. /* Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch */
  167. enum {
  168. kAEDoNotIgnoreHandler = 0x00000000,
  169. kAEIgnoreAppPhacHandler = 0x00000001, /* available only in vers 1.0.1 and greater */
  170. kAEIgnoreAppEventHandler = 0x00000002, /* available only in vers 1.0.1 and greater */
  171. kAEIgnoreSysPhacHandler = 0x00000004, /* available only in vers 1.0.1 and greater */
  172. kAEIgnoreSysEventHandler = 0x00000008, /* available only in vers 1.0.1 and greater */
  173. kAEIngoreBuiltInEventHandler = 0x00000010, /* available only in vers 1.0.1 and greater */
  174. kAEDontDisposeOnResume = (long)0x80000000 /* available only in vers 1.0.1 and greater */
  175. };
  176. /* Constants for AEResumeTheCurrentEvent */
  177. enum {
  178. kAENoDispatch = 0, /* dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch */
  179. kAEUseStandardDispatch = (long)0xFFFFFFFF /* table, or one of these two constants */
  180. };
  181. /*
  182. * AEResumeTheCurrentEvent()
  183. *
  184. * Availability:
  185. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  186. * CarbonLib: in CarbonLib 1.0 and later
  187. * Mac OS X: in version 10.0 and later
  188. */
  189. EXTERN_API( OSErr )
  190. AEResumeTheCurrentEvent(
  191. const AppleEvent * theAppleEvent,
  192. const AppleEvent * reply,
  193. AEEventHandlerUPP dispatcher, /* can be NULL */
  194. long handlerRefcon) THREEWORDINLINE(0x303C, 0x0818, 0xA816);
  195. /*
  196. * AEGetTheCurrentEvent()
  197. *
  198. * Availability:
  199. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  200. * CarbonLib: in CarbonLib 1.0 and later
  201. * Mac OS X: in version 10.0 and later
  202. */
  203. EXTERN_API( OSErr )
  204. AEGetTheCurrentEvent(AppleEvent * theAppleEvent) THREEWORDINLINE(0x303C, 0x021A, 0xA816);
  205. /*
  206. * AESetTheCurrentEvent()
  207. *
  208. * Availability:
  209. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  210. * CarbonLib: in CarbonLib 1.0 and later
  211. * Mac OS X: in version 10.0 and later
  212. */
  213. EXTERN_API( OSErr )
  214. AESetTheCurrentEvent(const AppleEvent * theAppleEvent) THREEWORDINLINE(0x303C, 0x022C, 0xA816);
  215. /**************************************************************************
  216. AppleEvent callbacks.
  217. **************************************************************************/
  218. /*
  219. * NewAEIdleUPP()
  220. *
  221. * Availability:
  222. * Non-Carbon CFM: available as macro/inline
  223. * CarbonLib: in CarbonLib 1.0 and later
  224. * Mac OS X: in version 10.0 and later
  225. */
  226. EXTERN_API_C( AEIdleUPP )
  227. NewAEIdleUPP(AEIdleProcPtr userRoutine);
  228. #if !OPAQUE_UPP_TYPES
  229. enum { uppAEIdleProcInfo = 0x00000FD0 }; /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes) */
  230. #ifdef __cplusplus
  231. inline DEFINE_API_C(AEIdleUPP) NewAEIdleUPP(AEIdleProcPtr userRoutine) { return (AEIdleUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEIdleProcInfo, GetCurrentArchitecture()); }
  232. #else
  233. #define NewAEIdleUPP(userRoutine) (AEIdleUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEIdleProcInfo, GetCurrentArchitecture())
  234. #endif
  235. #endif
  236. /*
  237. * NewAEFilterUPP()
  238. *
  239. * Availability:
  240. * Non-Carbon CFM: available as macro/inline
  241. * CarbonLib: in CarbonLib 1.0 and later
  242. * Mac OS X: in version 10.0 and later
  243. */
  244. EXTERN_API_C( AEFilterUPP )
  245. NewAEFilterUPP(AEFilterProcPtr userRoutine);
  246. #if !OPAQUE_UPP_TYPES
  247. enum { uppAEFilterProcInfo = 0x00003FD0 }; /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  248. #ifdef __cplusplus
  249. inline DEFINE_API_C(AEFilterUPP) NewAEFilterUPP(AEFilterProcPtr userRoutine) { return (AEFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEFilterProcInfo, GetCurrentArchitecture()); }
  250. #else
  251. #define NewAEFilterUPP(userRoutine) (AEFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEFilterProcInfo, GetCurrentArchitecture())
  252. #endif
  253. #endif
  254. /*
  255. * DisposeAEIdleUPP()
  256. *
  257. * Availability:
  258. * Non-Carbon CFM: available as macro/inline
  259. * CarbonLib: in CarbonLib 1.0 and later
  260. * Mac OS X: in version 10.0 and later
  261. */
  262. EXTERN_API_C( void )
  263. DisposeAEIdleUPP(AEIdleUPP userUPP);
  264. #if !OPAQUE_UPP_TYPES
  265. #ifdef __cplusplus
  266. inline DEFINE_API_C(void) DisposeAEIdleUPP(AEIdleUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  267. #else
  268. #define DisposeAEIdleUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  269. #endif
  270. #endif
  271. /*
  272. * DisposeAEFilterUPP()
  273. *
  274. * Availability:
  275. * Non-Carbon CFM: available as macro/inline
  276. * CarbonLib: in CarbonLib 1.0 and later
  277. * Mac OS X: in version 10.0 and later
  278. */
  279. EXTERN_API_C( void )
  280. DisposeAEFilterUPP(AEFilterUPP userUPP);
  281. #if !OPAQUE_UPP_TYPES
  282. #ifdef __cplusplus
  283. inline DEFINE_API_C(void) DisposeAEFilterUPP(AEFilterUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  284. #else
  285. #define DisposeAEFilterUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  286. #endif
  287. #endif
  288. /*
  289. * InvokeAEIdleUPP()
  290. *
  291. * Availability:
  292. * Non-Carbon CFM: available as macro/inline
  293. * CarbonLib: in CarbonLib 1.0 and later
  294. * Mac OS X: in version 10.0 and later
  295. */
  296. EXTERN_API_C( Boolean )
  297. InvokeAEIdleUPP(
  298. EventRecord * theEvent,
  299. long * sleepTime,
  300. RgnHandle * mouseRgn,
  301. AEIdleUPP userUPP);
  302. #if !OPAQUE_UPP_TYPES
  303. #ifdef __cplusplus
  304. inline DEFINE_API_C(Boolean) InvokeAEIdleUPP(EventRecord * theEvent, long * sleepTime, RgnHandle * mouseRgn, AEIdleUPP userUPP) { return (Boolean)CALL_THREE_PARAMETER_UPP(userUPP, uppAEIdleProcInfo, theEvent, sleepTime, mouseRgn); }
  305. #else
  306. #define InvokeAEIdleUPP(theEvent, sleepTime, mouseRgn, userUPP) (Boolean)CALL_THREE_PARAMETER_UPP((userUPP), uppAEIdleProcInfo, (theEvent), (sleepTime), (mouseRgn))
  307. #endif
  308. #endif
  309. /*
  310. * InvokeAEFilterUPP()
  311. *
  312. * Availability:
  313. * Non-Carbon CFM: available as macro/inline
  314. * CarbonLib: in CarbonLib 1.0 and later
  315. * Mac OS X: in version 10.0 and later
  316. */
  317. EXTERN_API_C( Boolean )
  318. InvokeAEFilterUPP(
  319. EventRecord * theEvent,
  320. long returnID,
  321. long transactionID,
  322. const AEAddressDesc * sender,
  323. AEFilterUPP userUPP);
  324. #if !OPAQUE_UPP_TYPES
  325. #ifdef __cplusplus
  326. inline DEFINE_API_C(Boolean) InvokeAEFilterUPP(EventRecord * theEvent, long returnID, long transactionID, const AEAddressDesc * sender, AEFilterUPP userUPP) { return (Boolean)CALL_FOUR_PARAMETER_UPP(userUPP, uppAEFilterProcInfo, theEvent, returnID, transactionID, sender); }
  327. #else
  328. #define InvokeAEFilterUPP(theEvent, returnID, transactionID, sender, userUPP) (Boolean)CALL_FOUR_PARAMETER_UPP((userUPP), uppAEFilterProcInfo, (theEvent), (returnID), (transactionID), (sender))
  329. #endif
  330. #endif
  331. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  332. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  333. #define NewAEIdleProc(userRoutine) NewAEIdleUPP(userRoutine)
  334. #define NewAEFilterProc(userRoutine) NewAEFilterUPP(userRoutine)
  335. #define CallAEIdleProc(userRoutine, theEvent, sleepTime, mouseRgn) InvokeAEIdleUPP(theEvent, sleepTime, mouseRgn, userRoutine)
  336. #define CallAEFilterProc(userRoutine, theEvent, returnID, transactionID, sender) InvokeAEFilterUPP(theEvent, returnID, transactionID, sender, userRoutine)
  337. #endif /* CALL_NOT_IN_CARBON */
  338. #if PRAGMA_STRUCT_ALIGN
  339. #pragma options align=reset
  340. #elif PRAGMA_STRUCT_PACKPUSH
  341. #pragma pack(pop)
  342. #elif PRAGMA_STRUCT_PACK
  343. #pragma pack()
  344. #endif
  345. #ifdef PRAGMA_IMPORT_OFF
  346. #pragma import off
  347. #elif PRAGMA_IMPORT
  348. #pragma import reset
  349. #endif
  350. #ifdef __cplusplus
  351. }
  352. #endif
  353. #endif /* __AEINTERACTION__ */