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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       Events.h
  3.  
  4.      Contains:   Event Manager Interfaces.
  5.  
  6.      Version:    Technology: Mac OS 8
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1985-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 __EVENTS__
  18. #define __EVENTS__
  19. #ifndef __OSUTILS__
  20. #include "OSUtils.h"
  21. #endif
  22. #ifndef __QUICKDRAW__
  23. #include "Quickdraw.h"
  24. #endif
  25. #ifndef __MACTYPES__
  26. #include "MacTypes.h"
  27. #endif
  28. #if !TARGET_OS_MAC || !TARGET_API_MAC_OS8
  29. #ifndef __ENDIAN__
  30. #include "Endian.h"
  31. #endif
  32. #endif  /* !TARGET_OS_MAC || !TARGET_API_MAC_OS8 */
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49. typedef UInt16                          EventKind;
  50. typedef UInt16                          EventMask;
  51. enum {
  52.     nullEvent                   = 0,
  53.     mouseDown                   = 1,
  54.     mouseUp                     = 2,
  55.     keyDown                     = 3,
  56.     keyUp                       = 4,
  57.     autoKey                     = 5,
  58.     updateEvt                   = 6,
  59.     diskEvt                     = 7,
  60.     activateEvt                 = 8,
  61.     osEvt                       = 15,
  62.     kHighLevelEvent             = 23
  63. };
  64. enum {
  65.     mDownMask                   = 1 << mouseDown,               /* mouse button pressed*/
  66.     mUpMask                     = 1 << mouseUp,                 /* mouse button released*/
  67.     keyDownMask                 = 1 << keyDown,                 /* key pressed*/
  68.     keyUpMask                   = 1 << keyUp,                   /* key released*/
  69.     autoKeyMask                 = 1 << autoKey,                 /* key repeatedly held down*/
  70.     updateMask                  = 1 << updateEvt,               /* window needs updating*/
  71.     diskMask                    = 1 << diskEvt,                 /* disk inserted*/
  72.     activMask                   = 1 << activateEvt,             /* activate/deactivate window*/
  73.     highLevelEventMask          = 0x0400,                       /* high-level events (includes AppleEvents)*/
  74.     osMask                      = 1 << osEvt,                   /* operating system events (suspend, resume)*/
  75.     everyEvent                  = 0xFFFF                        /* all of the above*/
  76. };
  77. enum {
  78.     charCodeMask                = 0x000000FF,
  79.     keyCodeMask                 = 0x0000FF00,
  80.     adbAddrMask                 = 0x00FF0000,
  81.     osEvtMessageMask            = (unsigned long)0xFF000000
  82. };
  83. enum {
  84.                                                                 /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  85.     mouseMovedMessage           = 0x00FA,
  86.     suspendResumeMessage        = 0x0001
  87. };
  88. enum {
  89.     resumeFlag                  = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  90.     convertClipboardFlag        = 2                             /* Bit 1 in resume message indicates clipboard change*/
  91. };
  92. typedef UInt16                          EventModifiers;
  93. enum {
  94.                                                                 /* modifiers */
  95.     activeFlagBit               = 0,                            /* activate? (activateEvt and mouseDown)*/
  96.     btnStateBit                 = 7,                            /* state of button?*/
  97.     cmdKeyBit                   = 8,                            /* command key down?*/
  98.     shiftKeyBit                 = 9,                            /* shift key down?*/
  99.     alphaLockBit                = 10,                           /* alpha lock down?*/
  100.     optionKeyBit                = 11,                           /* option key down?*/
  101.     controlKeyBit               = 12,                           /* control key down?*/
  102.     rightShiftKeyBit            = 13,                           /* right shift key down?*/
  103.     rightOptionKeyBit           = 14,                           /* right Option key down?*/
  104.     rightControlKeyBit          = 15                            /* right Control key down?*/
  105. };
  106. enum {
  107.     activeFlag                  = 1 << activeFlagBit,
  108.     btnState                    = 1 << btnStateBit,
  109.     cmdKey                      = 1 << cmdKeyBit,
  110.     shiftKey                    = 1 << shiftKeyBit,
  111.     alphaLock                   = 1 << alphaLockBit,
  112.     optionKey                   = 1 << optionKeyBit,
  113.     controlKey                  = 1 << controlKeyBit,
  114.     rightShiftKey               = 1 << rightShiftKeyBit,
  115.     rightOptionKey              = 1 << rightOptionKeyBit,
  116.     rightControlKey             = 1 << rightControlKeyBit
  117. };
  118. enum {
  119.     kNullCharCode               = 0,
  120.     kHomeCharCode               = 1,
  121.     kEnterCharCode              = 3,
  122.     kEndCharCode                = 4,
  123.     kHelpCharCode               = 5,
  124.     kBellCharCode               = 7,
  125.     kBackspaceCharCode          = 8,
  126.     kTabCharCode                = 9,
  127.     kLineFeedCharCode           = 10,
  128.     kVerticalTabCharCode        = 11,
  129.     kPageUpCharCode             = 11,
  130.     kFormFeedCharCode           = 12,
  131.     kPageDownCharCode           = 12,
  132.     kReturnCharCode             = 13,
  133.     kFunctionKeyCharCode        = 16,
  134.     kEscapeCharCode             = 27,
  135.     kClearCharCode              = 27,
  136.     kLeftArrowCharCode          = 28,
  137.     kRightArrowCharCode         = 29,
  138.     kUpArrowCharCode            = 30,
  139.     kDownArrowCharCode          = 31,
  140.     kDeleteCharCode             = 127,
  141.     kNonBreakingSpaceCharCode   = 202
  142. };
  143. struct EventRecord {
  144.     EventKind                       what;
  145.     UInt32                          message;
  146.     UInt32                          when;
  147.     Point                           where;
  148.     EventModifiers                  modifiers;
  149. };
  150. typedef struct EventRecord              EventRecord;
  151. typedef CALLBACK_API( void , FKEYProcPtr )(void );
  152. typedef STACK_UPP_TYPE(FKEYProcPtr)                             FKEYUPP;
  153. #if OPAQUE_UPP_TYPES
  154. #if CALL_NOT_IN_CARBON
  155.     EXTERN_API(FKEYUPP)
  156.     NewFKEYUPP                     (FKEYProcPtr             userRoutine);
  157.     EXTERN_API(void)
  158.     DisposeFKEYUPP                 (FKEYUPP                 userUPP);
  159.     EXTERN_API(void)
  160.     InvokeFKEYUPP                  (FKEYUPP                 userUPP);
  161. #endif  /* CALL_NOT_IN_CARBON */
  162. #else
  163.     enum { uppFKEYProcInfo = 0x00000000 };                          /* pascal no_return_value Func() */
  164.     #define NewFKEYUPP(userRoutine)                                 (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  165.     #define DisposeFKEYUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  166.     #define InvokeFKEYUPP(userUPP)                                  CALL_ZERO_PARAMETER_UPP((userUPP), uppFKEYProcInfo)
  167. #endif
  168. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  169. #define NewFKEYProc(userRoutine)                                NewFKEYUPP(userRoutine)
  170. #define CallFKEYProc(userRoutine)                               InvokeFKEYUPP(userRoutine)
  171. EXTERN_API( void )
  172. GetMouse                        (Point *                mouseLoc)                           ONEWORDINLINE(0xA972);
  173. EXTERN_API( Boolean )
  174. Button                          (void)                                                      ONEWORDINLINE(0xA974);
  175. EXTERN_API( Boolean )
  176. StillDown                       (void)                                                      ONEWORDINLINE(0xA973);
  177. EXTERN_API( Boolean )
  178. WaitMouseUp                     (void)                                                      ONEWORDINLINE(0xA977);
  179. EXTERN_API( UInt32 )
  180. TickCount                       (void)                                                      ONEWORDINLINE(0xA975);
  181. EXTERN_API( UInt32 )
  182. KeyTranslate                    (const void *           transData,
  183.                                  UInt16                 keycode,
  184.                                  UInt32 *               state)                              ONEWORDINLINE(0xA9C3);
  185. EXTERN_API( UInt32 )
  186. GetCaretTime                    (void)                                                      TWOWORDINLINE(0x2EB8, 0x02F4);
  187. /* 
  188.     QuickTime 3.0 supports GetKeys() on unix and win32
  189.     But, on little endian machines you will have to be
  190.     careful about bit numberings and/or use a KeyMapByteArray
  191.     instead.
  192. */
  193. #if TARGET_OS_MAC && TARGET_API_MAC_OS8
  194. typedef UInt32                          KeyMap[4];
  195. #else
  196. typedef BigEndianLong                   KeyMap[4];
  197. #endif  /* TARGET_OS_MAC && TARGET_API_MAC_OS8 */
  198. typedef UInt8                           KeyMapByteArray[16];
  199. EXTERN_API( void )
  200. GetKeys                         (KeyMap                 theKeys)                            ONEWORDINLINE(0xA976);
  201. /* Obsolete event types & masks */
  202. enum {
  203.     networkEvt                  = 10,
  204.     driverEvt                   = 11,
  205.     app1Evt                     = 12,
  206.     app2Evt                     = 13,
  207.     app3Evt                     = 14,
  208.     app4Evt                     = 15,
  209.     networkMask                 = 0x0400,
  210.     driverMask                  = 0x0800,
  211.     app1Mask                    = 0x1000,
  212.     app2Mask                    = 0x2000,
  213.     app3Mask                    = 0x4000,
  214.     app4Mask                    = 0x8000
  215. };
  216. struct EvQEl {
  217.     QElemPtr                        qLink;
  218.     SInt16                          qType;
  219.     EventKind                       evtQWhat;                   /* this part is identical to the EventRecord as defined above */
  220.     UInt32                          evtQMessage;
  221.     UInt32                          evtQWhen;
  222.     Point                           evtQWhere;
  223.     EventModifiers                  evtQModifiers;
  224. };
  225. typedef struct EvQEl                    EvQEl;
  226. typedef EvQEl *                         EvQElPtr;
  227. typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
  228. typedef STACK_UPP_TYPE(GetNextEventFilterProcPtr)               GetNextEventFilterUPP;
  229. #if OPAQUE_UPP_TYPES
  230.     EXTERN_API(GetNextEventFilterUPP)
  231.     NewGetNextEventFilterUPP       (GetNextEventFilterProcPtr userRoutine);
  232.     EXTERN_API(void)
  233.     DisposeGetNextEventFilterUPP    (GetNextEventFilterUPP  userUPP);
  234.     EXTERN_API(void)
  235.     InvokeGetNextEventFilterUPP    (EventRecord *           theEvent,
  236.                                     Boolean *               result,
  237.                                     GetNextEventFilterUPP   userUPP);
  238. #else
  239.     enum { uppGetNextEventFilterProcInfo = 0x000000BF };            /* SPECIAL_CASE_PROCINFO(11) */
  240.     #define NewGetNextEventFilterUPP(userRoutine)                   (GetNextEventFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  241.     #define DisposeGetNextEventFilterUPP(userUPP)                   DisposeRoutineDescriptor(userUPP)
  242.     #define InvokeGetNextEventFilterUPP(theEvent, result, userUPP)  CALL_TWO_PARAMETER_UPP((userUPP), uppGetNextEventFilterProcInfo, (theEvent), (result))
  243. #endif
  244. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  245. #define NewGetNextEventFilterProc(userRoutine)                  NewGetNextEventFilterUPP(userRoutine)
  246. #define CallGetNextEventFilterProc(userRoutine, theEvent, result) InvokeGetNextEventFilterUPP(theEvent, result, userRoutine)
  247. typedef GetNextEventFilterUPP           GNEFilterUPP;
  248. EXTERN_API( UInt32 )
  249. GetDblTime                      (void)                                                      TWOWORDINLINE(0x2EB8, 0x02F0);
  250. EXTERN_API( void )
  251. SetEventMask                    (EventMask              value)                              TWOWORDINLINE(0x31DF, 0x0144);
  252. #if CALL_NOT_IN_CARBON
  253. #if CALL_NOT_IN_CARBON
  254. EXTERN_API( QHdrPtr )
  255. GetEvQHdr                       (void)                                                      THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  256. #endif  /* CALL_NOT_IN_CARBON */
  257. #if CALL_NOT_IN_CARBON
  258.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  259.                                                                                             #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  260.                                                                                             #endif
  261. EXTERN_API( OSErr )
  262. PPostEvent                      (EventKind              eventCode,
  263.                                  UInt32                 eventMsg,
  264.                                  EvQElPtr *             qEl)                                TWOWORDINLINE(0xA12F, 0x2288);
  265. #endif  /* CALL_NOT_IN_CARBON */
  266. #endif  /* CALL_NOT_IN_CARBON */
  267. EXTERN_API( Boolean )
  268. GetNextEvent                    (EventMask              eventMask,
  269.                                  EventRecord *          theEvent)                           ONEWORDINLINE(0xA970);
  270. EXTERN_API( Boolean )
  271. WaitNextEvent                   (EventMask              eventMask,
  272.                                  EventRecord *          theEvent,
  273.                                  UInt32                 sleep,
  274.                                  RgnHandle              mouseRgn) /* can be NULL */         ONEWORDINLINE(0xA860);
  275. EXTERN_API( Boolean )
  276. EventAvail                      (EventMask              eventMask,
  277.                                  EventRecord *          theEvent)                           ONEWORDINLINE(0xA971);
  278.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  279.                                                                                             #pragma parameter __D0 PostEvent(__A0, __D0)
  280.                                                                                             #endif
  281. EXTERN_API( OSErr )
  282. PostEvent                       (EventKind              eventNum,
  283.                                  UInt32                 eventMsg)                           ONEWORDINLINE(0xA02F);
  284. /*
  285.     For Carbon, use EventAvail, TickCount, GetGlobalMouse,
  286.     GetKeys, or GetCurrentKeyModifiers instead of
  287.     OSEventAvail, and use GetNextEvent or WaitNextEvent
  288.     instead of GetOSEvent.
  289. */
  290. #if CALL_NOT_IN_CARBON
  291. #if CALL_NOT_IN_CARBON
  292.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  293.                                                                                             #pragma parameter __D0 OSEventAvail(__D0, __A0)
  294.                                                                                             #endif
  295. EXTERN_API( Boolean )
  296. OSEventAvail                    (EventMask              mask,
  297.                                  EventRecord *          theEvent)                           TWOWORDINLINE(0xA030, 0x5240);
  298.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  299.                                                                                             #pragma parameter __D0 GetOSEvent(__D0, __A0)
  300.                                                                                             #endif
  301. EXTERN_API( Boolean )
  302. GetOSEvent                      (EventMask              mask,
  303.                                  EventRecord *          theEvent)                           TWOWORDINLINE(0xA031, 0x5240);
  304. #endif  /* CALL_NOT_IN_CARBON */
  305. #endif  /* CALL_NOT_IN_CARBON */
  306. EXTERN_API( void )
  307. FlushEvents                     (EventMask              whichMask,
  308.                                  EventMask              stopMask)                           TWOWORDINLINE(0x201F, 0xA032);
  309. #if CALL_NOT_IN_CARBON
  310. #if CALL_NOT_IN_CARBON
  311. EXTERN_API( void )
  312. SystemClick                     (const EventRecord *    theEvent,
  313.                                  WindowPtr              theWindow)                          ONEWORDINLINE(0xA9B3);
  314. EXTERN_API( void )
  315. SystemTask                      (void)                                                      ONEWORDINLINE(0xA9B4);
  316. EXTERN_API( Boolean )
  317. SystemEvent                     (const EventRecord *    theEvent)                           ONEWORDINLINE(0xA9B2);
  318. #endif  /* CALL_NOT_IN_CARBON */
  319. #endif  /* CALL_NOT_IN_CARBON */
  320. #if OLDROUTINENAMES
  321. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  322. #endif  /* OLDROUTINENAMES */
  323. /*
  324.     GetGlobalMouse and GetCurrentKeyModifiers
  325.     are only available as part of the Carbon API.
  326. */
  327. EXTERN_API( void )
  328. GetGlobalMouse                  (Point *                globalMouse);
  329. EXTERN_API( UInt32 )
  330. GetCurrentKeyModifiers          (void);
  331. #if CALL_NOT_IN_CARBON
  332. EXTERN_API( UInt32 )
  333. ParseTheCmdLine                 (void);
  334. #endif  /* CALL_NOT_IN_CARBON */
  335. #if PRAGMA_STRUCT_ALIGN
  336.     #pragma options align=reset
  337. #elif PRAGMA_STRUCT_PACKPUSH
  338.     #pragma pack(pop)
  339. #elif PRAGMA_STRUCT_PACK
  340.     #pragma pack()
  341. #endif
  342. #ifdef PRAGMA_IMPORT_OFF
  343. #pragma import off
  344. #elif PRAGMA_IMPORT
  345. #pragma import reset
  346. #endif
  347. #ifdef __cplusplus
  348. }
  349. #endif
  350. #endif /* __EVENTS__ */