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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       CarbonEvents.h
  3.  
  4.      Contains:   Carbon Event Manager
  5.  
  6.      Version:    Technology: Version 1.0
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1999-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 __CARBONEVENTS__
  18. #define __CARBONEVENTS__
  19. #ifndef __EVENTS__
  20. #include "Events.h"
  21. #endif
  22. #ifndef __MENUS__
  23. #include "Menus.h"
  24. #endif
  25. #ifndef __CONTROLS__
  26. #include "Controls.h"
  27. #endif
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37. #if PRAGMA_STRUCT_ALIGN
  38.     #pragma options align=mac68k
  39. #elif PRAGMA_STRUCT_PACKPUSH
  40.     #pragma pack(push, 2)
  41. #elif PRAGMA_STRUCT_PACK
  42.     #pragma pack(2)
  43. #endif
  44. /*======================================================================================*/
  45. /*  EVENT COMMON                                                                        */
  46. /*======================================================================================*/
  47. enum {
  48.     eventAlreadyPostedErr       = -9860,
  49.     eventClassInvalidErr        = -9862,
  50.     eventClassAlreadyExistsErr  = -9863,
  51.     eventClassIncorrectErr      = -9864,
  52.     eventClassInvalidVersionErr = -9865,
  53.     eventHandlerAlreadyInstalledErr = -9866,
  54.     eventCantInstallHandlerErr  = -9867,
  55.     eventInternalErr            = -9868,
  56.     eventKindIncorrectErr       = -9869,
  57.     eventDataTagNotSupportedErr = -9870,
  58.     eventDataSizeMismatchErr    = -9871
  59. };
  60. /*======================================================================================*/
  61. /*  EVENT CORE                                                                          */
  62. /*======================================================================================*/
  63. /*--------------------------------------------------------------------------------------*/
  64. /*  o Event Flags, options                                                              */
  65. /*--------------------------------------------------------------------------------------*/
  66. typedef SInt16 EventPriority;
  67. enum {
  68.     kEventPriorityLow           = 0,
  69.     kEventPriorityStandard      = 1,
  70.     kEventPriorityHigh          = 2
  71. };
  72. typedef UInt32 EventAttributes;
  73. enum {
  74.     kEventAttributeNone         = 0,
  75.     kEventAttributeUserEvent    = (1 << 0),
  76.     kEventAttributeRouteToUserFocus = (1 << 1)
  77. };
  78. enum {
  79.     kEventLeaveInQueue          = false,
  80.     kEventRemoveFromQueue       = true
  81. };
  82. /*--------------------------------------------------------------------------------------*/
  83. /* o Event Times                                                                        */
  84. /*                                                                                      */
  85. /* EventTime is in seconds since boot. Use the constants to make life easy.             */
  86. /*--------------------------------------------------------------------------------------*/
  87. typedef double                          EventTime;
  88. typedef EventTime                       EventTimeout;
  89. typedef EventTime                       EventTimerInterval;
  90. #define kEventDurationSecond            1.0
  91. #define kEventDurationMillisecond       kEventDurationSecond / 1000
  92. #define kEventDurationMicrosecond       kEventDurationSecond / 1000000
  93. #define kEventDurationNanosecond        kEventDurationSecond / 1000000000
  94. #define kEventDurationMinute            kEventDurationSecond * 60
  95. #define kEventDurationHour              kEventDurationMinute * 60
  96. #define kEventDurationDay               kEventDurationHour * 24
  97. #define kEventDurationNoWait            0.0
  98. #define kEventDurationForever           -1.0
  99. /* Helpful doodads to convert from and to ticks from event times*/
  100. #ifdef __cplusplus
  101.     inline EventTime TicksToEventTime( UInt32 t ) { return ( (t) / 60.0 ); }
  102.     inline UInt32 EventTimeToTicks( EventTime t ) { return (UInt32)( (t) * 60 ); }
  103. #else
  104.     #define TicksToEventTime( t )   (EventTime)( (t) / 60.0 )
  105.     #define EventTimeToTicks( t )   (UInt32)( (t) * 60 )
  106. #endif  /* defined(__cplusplus) */
  107. /*--------------------------------------------------------------------------------------*/
  108. /* EventTypeSpec structure                                                              */
  109. /*                                                                                      */
  110. /* This structure is used in many routines to pass a list of event types to a function. */
  111. /* You typically would declare a const array of these types to pass in.                 */
  112. /*--------------------------------------------------------------------------------------*/
  113. struct EventTypeSpec {
  114.     UInt32                          eventClass;
  115.     UInt32                          eventKind;
  116. };
  117. typedef struct EventTypeSpec            EventTypeSpec;
  118. /* MouseTrackingResults returned from TrackMouse*/
  119. typedef UInt16 MouseTrackingResult;
  120. enum {
  121.     kMouseTrackingMousePressed  = 1,
  122.     kMouseTrackingMouseReleased = 2,
  123.     kMouseTrackingMouseExited   = 3,
  124.     kMouseTrackingMouseEntered  = 4,
  125.     kMouseTrackingMouseMoved    = 5
  126. };
  127. typedef struct OpaqueEventRef*          EventRef;
  128. typedef UInt32                          EventClassID;
  129. typedef UInt32                          EventClass;
  130. typedef UInt32                          EventType;
  131. /*--------------------------------------------------------------------------------------*/
  132. /*    o EventLoop                                                 */
  133. /*--------------------------------------------------------------------------------------*/
  134. typedef struct OpaqueEventLoopRef*      EventLoopRef;
  135. EXTERN_API( EventLoopRef )
  136. GetCurrentEventLoop             (void);
  137. EXTERN_API( EventLoopRef )
  138. GetMainEventLoop                (void);
  139. /*--------------------------------------------------------------------------------------*/
  140. /*  o Low-level event blocking                                                          */
  141. /*--------------------------------------------------------------------------------------*/
  142. EXTERN_API( void )
  143. BlockEventLoop                  (EventTimeout           timeout);
  144. EXTERN_API( void )
  145. WakeEventLoop                   (void);
  146. EXTERN_API( Boolean )
  147. BlockUntilNextEvent             (EventTimeout           timeout,
  148.                                  Boolean                pullEvent,
  149.                                  EventRef *             outEvent);
  150. EXTERN_API( Boolean )
  151. BlockUntilNextEventMatchingList (UInt32                 numTypes,
  152.                                  const EventTypeSpec *  list,
  153.                                  EventTimeout           timeout,
  154.                                  Boolean                pullEvent,
  155.                                  EventRef *             outEvent);
  156. /*--------------------------------------------------------------------------------------*/
  157. /*  o Core event lifetime APIs                                                          */
  158. /*--------------------------------------------------------------------------------------*/
  159. EXTERN_API( EventRef )
  160. CopyEvent                       (EventRef               inOther);
  161. EXTERN_API( EventRef )
  162. RetainEvent                     (EventRef               inEvent);
  163. EXTERN_API( UInt32 )
  164. GetEventRetainCount             (EventRef               inEvent);
  165. EXTERN_API( void )
  166. ReleaseEvent                    (EventRef               inEvent);
  167. /*--------------------------------------------------------------------------------------*/
  168. /*  o Getters for 'base-class' event info                                               */
  169. /*--------------------------------------------------------------------------------------*/
  170. EXTERN_API( UInt32 )
  171. GetEventClass                   (EventRef               inEvent);
  172. EXTERN_API( UInt32 )
  173. GetEventKind                    (EventRef               inEvent);
  174. EXTERN_API( EventAttributes )
  175. GetEventAttributes              (EventRef               inEvent);
  176. EXTERN_API( EventTime )
  177. GetEventTime                    (EventRef               inEvent);
  178. EXTERN_API( UInt32 )
  179. GetEventPriority                (EventRef               inEvent);
  180. /*--------------------------------------------------------------------------------------*/
  181. /*  o Setters for 'base-class' event info                                               */
  182. /*--------------------------------------------------------------------------------------*/
  183. EXTERN_API( OSStatus )
  184. SetEventTime                    (EventRef               inEvent,
  185.                                  EventTime              inTime);
  186. /*--------------------------------------------------------------------------------------*/
  187. /*  o Getting/setting common event data via tags                                        */
  188. /*                                                                                      */
  189. /*  NOTE: THIS STUFF IS NOT YET ACTIVE. DO NOT ATTEMPT TO USE IT.                       */
  190. /*--------------------------------------------------------------------------------------*/
  191. enum {
  192.     kEventTagKeyModifiers       = FOUR_CHAR_CODE('mods'),       /* UInt32*/
  193.     kEventTagMouseLocation      = FOUR_CHAR_CODE('mloc')        /* Point*/
  194. };
  195. typedef UInt32                          EventDataTag;
  196. EXTERN_API( OSStatus )
  197. GetEventDataByTag               (EventRef               inEvent,
  198.                                  EventDataTag           inKey,
  199.                                  void *                 buffer,
  200.                                  Size                   bufferSize,
  201.                                  Size *                 actualSize) /* can be NULL */;
  202. EXTERN_API( OSStatus )
  203. SetEventDataByTag               (EventRef               inEvent,
  204.                                  EventDataTag           inKey,
  205.                                  void *                 buffer,
  206.                                  Size                   bufferSize);
  207. /* Common, type-safe wrappers for the above...*/
  208. EXTERN_API( OSStatus )
  209. GetEventKeyModifiers            (EventRef               inEvent,
  210.                                  UInt32 *               outModifiers);
  211. EXTERN_API( OSStatus )
  212. SetEventKeyModifiers            (EventRef               inEvent,
  213.                                  UInt32                 inModifiers);
  214. EXTERN_API( OSStatus )
  215. GetEventMouseLocation           (EventRef               inEvent,
  216.                                  Point *                outMouseLoc);
  217. EXTERN_API( OSStatus )
  218. SetEventMouseLocation           (EventRef               inEvent,
  219.                                  Point                  inMouseLoc);
  220. /*--------------------------------------------------------------------------------------*/
  221. /*  o Event Queue routines (posting, finding, flushing)                                 */
  222. /*--------------------------------------------------------------------------------------*/
  223. typedef CALLBACK_API( Boolean , EventComparatorProcPtr )(EventRef inEvent, void *inCompareData);
  224. typedef STACK_UPP_TYPE(EventComparatorProcPtr)                  EventComparatorUPP;
  225. #if OPAQUE_UPP_TYPES
  226.     EXTERN_API(EventComparatorUPP)
  227.     NewEventComparatorUPP          (EventComparatorProcPtr  userRoutine);
  228.     EXTERN_API(void)
  229.     DisposeEventComparatorUPP      (EventComparatorUPP      userUPP);
  230.     EXTERN_API(Boolean)
  231.     InvokeEventComparatorUPP       (EventRef                inEvent,
  232.                                     void *                  inCompareData,
  233.                                     EventComparatorUPP      userUPP);
  234. #else
  235.     enum { uppEventComparatorProcInfo = 0x000003D0 };               /* pascal 1_byte Func(4_bytes, 4_bytes) */
  236.     #define NewEventComparatorUPP(userRoutine)                      (EventComparatorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventComparatorProcInfo, GetCurrentArchitecture())
  237.     #define DisposeEventComparatorUPP(userUPP)                      DisposeRoutineDescriptor(userUPP)
  238.     #define InvokeEventComparatorUPP(inEvent, inCompareData, userUPP)  (Boolean)CALL_TWO_PARAMETER_UPP((userUPP), uppEventComparatorProcInfo, (inEvent), (inCompareData))
  239. #endif
  240. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  241. #define NewEventComparatorProc(userRoutine)                     NewEventComparatorUPP(userRoutine)
  242. #define CallEventComparatorProc(userRoutine, inEvent, inCompareData) InvokeEventComparatorUPP(inEvent, inCompareData, userRoutine)
  243. /*
  244.    PostEventToQueue retains the given event. You would normally release it after calling
  245.    this function.
  246. */
  247. EXTERN_API( OSStatus )
  248. PostEventToQueue                (EventRef               inEvent,
  249.                                  EventPriority          inPriority);
  250. EXTERN_API( Boolean )
  251. IsEventInQueue                  (EventRef               inEvent);
  252. EXTERN_API( OSStatus )
  253. FlushEventsMatchingListFromQueue (UInt32                inNumTypes,
  254.                                  const EventTypeSpec *  inList);
  255. EXTERN_API( OSStatus )
  256. FlushSpecificEventsFromQueue    (EventComparatorUPP     comparator,
  257.                                  void *                 compareData);
  258. EXTERN_API( void )
  259. FlushEventQueue                 (void);
  260. /*
  261.    Remove EventFromQueue removes the event from the event queue and releases it. If you
  262.    want to keep the event around, you should make sure to copy or retain it.
  263. */
  264. EXTERN_API( void )
  265. RemoveEventFromQueue            (EventRef               inEvent);
  266. EXTERN_API( EventRef )
  267. FindSpecificEventInQueue        (EventComparatorUPP     comparator,
  268.                                  void *                 compareData);
  269. EXTERN_API( UInt32 )
  270. GetNumEventsInQueue             (void);
  271. /*--------------------------------------------------------------------------------------*/
  272. /*  o Helpful utilities                                                                 */
  273. /*--------------------------------------------------------------------------------------*/
  274. EXTERN_API( EventTime )
  275. GetCurrentEventTime             (void);
  276. EXTERN_API( Boolean )
  277. IsUserCancelEventRef            (EventRef               event);
  278. EXTERN_API( Boolean )
  279. CheckEventQueueForUserCancel    (void);
  280. EXTERN_API( OSStatus )
  281. TrackMouseLocation              (GrafPtr                port, /* can be NULL */
  282.                                  Point *                outPt,
  283.                                  MouseTrackingResult *  result);
  284. EXTERN_API( OSStatus )
  285. TrackMouseRegion                (GrafPtr                port, /* can be NULL */
  286.                                  RgnHandle              region,
  287.                                  Boolean *              wasInRgn,
  288.                                  MouseTrackingResult *  result);
  289. EXTERN_API( Boolean )
  290. ConvertEventRefToEventRecord    (EventRef               inEvent,
  291.                                  EventRecord *          outEvent);
  292. EXTERN_API( Boolean )
  293. IsEventInMask                   (EventRef               inEvent,
  294.                                  EventMask              inMask);
  295. EXTERN_API( EventTime )
  296. GetLastUserEventTime            (void);
  297. /*--------------------------------------------------------------------------------------*/
  298. /*  o Timers                                                                            */
  299. /*--------------------------------------------------------------------------------------*/
  300. /* Timers, the new null processing mechanism.*/
  301. /* Not just good, but good for ya. */
  302. typedef struct OpaqueEventLoopTimerRef*  EventLoopTimerRef;
  303. typedef CALLBACK_API( void , EventLoopTimerProcPtr )(EventLoopTimerRef inTimer, void *inUserData);
  304. typedef STACK_UPP_TYPE(EventLoopTimerProcPtr)                   EventLoopTimerUPP;
  305. #if OPAQUE_UPP_TYPES
  306.     EXTERN_API(EventLoopTimerUPP)
  307.     NewEventLoopTimerUPP           (EventLoopTimerProcPtr   userRoutine);
  308.     EXTERN_API(void)
  309.     DisposeEventLoopTimerUPP       (EventLoopTimerUPP       userUPP);
  310.     EXTERN_API(void)
  311.     InvokeEventLoopTimerUPP        (EventLoopTimerRef       inTimer,
  312.                                     void *                  inUserData,
  313.                                     EventLoopTimerUPP       userUPP);
  314. #else
  315.     enum { uppEventLoopTimerProcInfo = 0x000003C0 };                /* pascal no_return_value Func(4_bytes, 4_bytes) */
  316.     #define NewEventLoopTimerUPP(userRoutine)                       (EventLoopTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopTimerProcInfo, GetCurrentArchitecture())
  317.     #define DisposeEventLoopTimerUPP(userUPP)                       DisposeRoutineDescriptor(userUPP)
  318.     #define InvokeEventLoopTimerUPP(inTimer, inUserData, userUPP)   CALL_TWO_PARAMETER_UPP((userUPP), uppEventLoopTimerProcInfo, (inTimer), (inUserData))
  319. #endif
  320. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  321. #define NewEventLoopTimerProc(userRoutine)                      NewEventLoopTimerUPP(userRoutine)
  322. #define CallEventLoopTimerProc(userRoutine, inTimer, inUserData) InvokeEventLoopTimerUPP(inTimer, inUserData, userRoutine)
  323. EXTERN_API( OSStatus )
  324. InstallEventLoopTimer           (EventLoopRef           inEventLoop,
  325.                                  EventTimerInterval     inFirstFire,
  326.                                  EventTimerInterval     inInterval,
  327.                                  EventLoopTimerUPP      inTimerProc,
  328.                                  void *                 inUserData,
  329.                                  EventLoopTimerRef *    outRef);
  330. EXTERN_API( OSStatus )
  331. RemoveEventLoopTimer            (EventLoopTimerRef      inTimer);
  332. EXTERN_API( OSStatus )
  333. SetEventLoopTimerNextFireTime   (EventLoopTimerRef      inTimer,
  334.                                  EventTimerInterval     nextFire);
  335. /*======================================================================================*/
  336. /*  EVENT CLASSES                                                                       */
  337. /*======================================================================================*/
  338. enum {
  339.     kEventClassMouse            = FOUR_CHAR_CODE('mous'),
  340.     kEventClassKeyboard         = FOUR_CHAR_CODE('keyb'),
  341.     kEventClassTextInput        = FOUR_CHAR_CODE('text'),
  342.     kEventClassApplication      = FOUR_CHAR_CODE('appl'),
  343.     kEventClassEPPC             = FOUR_CHAR_CODE('eppc'),
  344.     kEventClassMenu             = FOUR_CHAR_CODE('menu'),
  345.     kEventClassWindow           = FOUR_CHAR_CODE('wind'),
  346.     kEventClassControl          = FOUR_CHAR_CODE('cntl'),
  347.     kEventClassCommand          = FOUR_CHAR_CODE('cmds')
  348. };
  349. /* Mouse Events */
  350. enum {
  351.     kEventLeftMouseDown         = 1,
  352.     kEventLeftMouseUp           = 2,
  353.     kEventRightMouseDown        = 3,
  354.     kEventRightMouseUp          = 4,
  355.     kEventMouseMoved            = 5,
  356.     kEventLeftMouseDragged      = 6,                            /* mouse moved while button down*/
  357.     kEventRightMouseDragged     = 7,
  358.     kEventMouseEntered          = 8,
  359.     kEventMouseExited           = 9,
  360.     kEventMouseWheelMoved       = 10                            /* placeholder. Not yet operational, unlike the new Death Star.*/
  361. };
  362. enum {
  363.     kEventMouseButtonPrimary    = 0,                            /* only button for a one-button mouse (usually left button for multi-button mouse)*/
  364.     kEventMouseButtonSecondary  = 1,                            /* usually right button for a multi-button mouse*/
  365.     kEventMouseButtonTertiary   = 2                             /* usually middle button for a three-button mouse*/
  366. };
  367. typedef UInt16                          EventMouseButton;
  368. enum {
  369.     kEventMouseWheelDirectionUp = 0,
  370.     kEventMouseWheelDirectionDown = 1,
  371.     kEventMouseWheelDirectionLeft = 2,
  372.     kEventMouseWheelDirectionRight = 3
  373. };
  374. typedef UInt16                          EventMouseWheelDirection;
  375. /* Keyboard Events */
  376. enum {
  377.     kEventRawKeyDown            = 1,                            /* hardware-level events*/
  378.     kEventRawKeyRepeat          = 2,
  379.     kEventRawKeyUp              = 3,
  380.     kEventRawKeyModifiersChanged = 4
  381. };
  382. enum {
  383.     kEventTextInput             = 5                             /* high-level keyboard event (not available yet)*/
  384. };
  385. /* Application Events */
  386. enum {
  387.     kEventAppActivated          = 1,                            /* resume, in old parlance*/
  388.     kEventAppDeactivated        = 2,                            /* suspend, in old parlance*/
  389.     kEventAppQuit               = 3,                            /* this app is quitting.*/
  390.     kEventAppLaunchNotification = 4                             /* response to async application launch.*/
  391. };
  392. /* Apple Events */
  393. enum {
  394.     kEventHighLevelEvent        = 1
  395. };
  396. /*
  397.     Window Refresh Events
  398.     
  399.     o kEventWindowUpdate
  400.         low-level update event.  You must call BeginUpdate, call SetPort,
  401.         draw your window content, and then call EndUpdate.
  402.     
  403.     o kEventWindowDrawContent
  404.         sent when the standard window handler sees an update event. 
  405.         BeginUpdate, SetPort, and EndUpdate are called for you; all you do
  406.         is draw.
  407.     
  408.     o kEventWindowDrawStructure
  409.         sent after the window manager has drawn the window frame.  The
  410.         current port is a global port clipped to the window structure
  411.         region, not the window's port.
  412.         
  413.     o kEventWindowEraseContent
  414.         called when the window manager wishes to erase the window
  415.         background (In ShowWindow, for example).  The current port is set
  416.         to the window's port.
  417.         
  418.     o kEventWindowActivate
  419.         window is active now
  420.         
  421.     o kEventWindowDeactivate
  422.         window is inactive now
  423. */
  424. enum {
  425.     kEventWindowUpdate          = 1,
  426.     kEventWindowDrawContent     = 2,
  427.     kEventWindowDrawStructure   = 3,
  428.     kEventWindowEraseContent    = 4,
  429.     kEventWindowActivate        = 5,
  430.     kEventWindowDeactivate      = 6
  431. };
  432. /*
  433.     Window State Change Events
  434.     
  435.     o kEventWindowZOrderChanged
  436.         Sent after the window has changed position relative
  437.         to other windows in the application window list.
  438.     
  439.     o kEventWindowActivationChanged
  440.         Sent after the window has changed activation state
  441.     
  442.     o kEventWindowOriginChange
  443.       kEventWindowSizeChange
  444.         Sent during ResizeWindow/DragWindow, before the window is
  445.         actually modified.  Alter the current bounds in the event to
  446.         change the intended location of the window.  "Origin"
  447.         indicates that the window's place location onscreen is
  448.         different.  "Size" indicates that the window's size has
  449.         changed (the origin may also be different).
  450.     
  451.     o kEventWindowOriginChanged
  452.       kEventWindowSizeChanged
  453.         Sent after the window has been resized or moved.
  454. */
  455. enum {
  456.     kEventWindowZOrderChanged   = 16,
  457.     kEventWindowActivationChanged = 18,
  458.     kEventWindowOriginChange    = 20,
  459.     kEventWindowOriginChanged   = 21,
  460.     kEventWindowSizeChange      = 22,
  461.     kEventWindowSizeChanged     = 23
  462. };
  463. /*
  464.     Window Click Events
  465.     
  466.     Low-level events which generate higher-level "action" events.
  467.     Most clients should allow the standard window handler to implement
  468.     these events.
  469.     
  470.     o kEventWindowClickDragRgn
  471.         sent when the mouse is down in the drag region.  Calls DragWindow.
  472.     
  473.     o kEventWindowClickResizeRgn
  474.         sent when the mouse is down in the resize area.  Calls ResizeWindow.
  475.     
  476.     o kEventWindowClickCollapseRgn
  477.         sent when the mouse is down in the collapse widget.  Generates
  478.         kEventWindowExpand or kEventWindowCollapse (whichever is the opposite
  479.         of the window's current collapse state).
  480.     
  481.     o kEventWindowClickCloseRgn
  482.         sent when the mouse is down in the close widget.  Generates
  483.         kEventWindowClose.
  484.     
  485.     o kEventWindowClickZoomRgn
  486.         sent when the mouse is down in the zoom widget.  Generates
  487.         kEventWindowZoom.   
  488.         
  489.     o kEventWindowClickContentRgn
  490.         sent when the mouse is down in the content region.
  491.     
  492.     o kEventWindowClickProxyIconRgn
  493.         sent when the mouse is down in the proxy icon.  Generates proxy
  494.         icon events.
  495. */
  496. enum {
  497.     kEventWindowClickDragRgn    = 32,
  498.     kEventWindowClickResizeRgn  = 33,
  499.     kEventWindowClickCollapseRgn = 34,
  500.     kEventWindowClickCloseRgn   = 35,
  501.     kEventWindowClickZoomRgn    = 36,
  502.     kEventWindowClickContentRgn = 37,
  503.     kEventWindowClickProxyIconRgn = 38
  504. };
  505. /*
  506.     Window Action Events
  507.     
  508.     o kEventWindowCollapse
  509.         If the window is not collapsed, this event is sent by the standard
  510.         window handler after it has received kEventWindowClickCollapseRgn
  511.         and received true from a call to TrackBox.  Standard window handler
  512.         calls CollapseWindow and then sends kEventWindowCollapsed if no
  513.         error is received from CollapseWindow.
  514.     
  515.     o kEventWindowCollapsed
  516.         Notification that the object has successfully collapsed.
  517.     
  518.     o kEventWindowCollapseAll
  519.         Sent by the standard window handler (when the option key is down)
  520.         after it has received kEventWindowClickCollapseRgn and then
  521.         received true from a call to TrackBox.  The standard window
  522.         handler's response is to send each window of the same class as the
  523.         clicked window a kEventWindowCollapse event.
  524.     
  525.     o kEventWindowExpand
  526.         If the window is collapsed, this event is sent by the standard
  527.         window handler after it has received kEventWindowClickCollapseRgn
  528.         and received true from a call to TrackBox.  The standard window
  529.         handler's response is to call CollapseWindow, then send
  530.         kEventWindowExpanded.
  531.     
  532.     o kEventWindowExpanded
  533.         Sent by the standard window handler (when the option key is down)
  534.         after it has received kEventWindowClickCollapseRgn and then
  535.         received true from a call to TrackBox.  The standard window
  536.         handler's response is to send each window of the same class as the
  537.         clicked window a kEventWindowExpand event.
  538.     
  539.     o kEventWindowExpandAll
  540.         Notification that the window has successfully expanded.
  541.     
  542.     o kEventWindowClose
  543.         Sent by the standard window handler after it has received
  544.         kEventWindowClickCloseRgn and successfully called TrackBox.
  545.     
  546.     o kEventWindowClosed
  547.         Dispatched by DisposeWindow before the object is disposed.
  548.     
  549.     o kEventWindowCloseAll
  550.         Sent by the standard window handler (when the option key is down)
  551.         after it has received kEventWindowClickCloseRgn and received true
  552.         from a call to TrackGoAway.  The standard window handler's response
  553.         is to send each window with the same class as the clicked window a
  554.         kEventWindowClose event.
  555.     
  556.     o kEventWindowZoom
  557.         Sent by the standard window handler upon receiving
  558.         kEventWindowClickZoomRgn and then receiving true from a call to
  559.         TrackBox.  The standard window handler's response is to zoom the
  560.         window using the sample code taken from the 8.5 Window Manager
  561.         documentation. Upon successful zoom, kEventWindowZoomed is sent.
  562.     
  563.     o kEventWindowZoomed
  564.         Notification that object has been successfully zoomed.
  565.     
  566.     o kEventWindowZoomAll
  567.         Sent by the standard window handler (when the option key is down)
  568.         after it has received kEventObjectClickZoomRgn and received true
  569.         from a call to TrackBox.  The standard window handler's response is
  570.         to send each window with the same class as the clicked window a
  571.         kEventObjectZoom event and then to reposition all zoomed windows
  572.         using the kWindowCascadeOnParentWindowScreen positioning method.
  573.     
  574.     o kEventWindowContextualMenuSelect
  575.         Sent when either the right mouse button is pressed, or the control
  576.         key is held down and the left mouse button is pressed, or the left
  577.         mouse button is held down for more than 1/4th of a second (and
  578.         nothing else is handling the generated mouse tracking events).  
  579.         The standard window handler ignores this event.
  580.     
  581.     o kEventWindowPathSelect
  582.         Sent when IsWindowPathSelectClick would return true.  Set the
  583.         MenuRef in the event if you wish to customize the menu passed to
  584.         WindowPathSelect.
  585.     
  586.     o kEventWindowGetIdealSize
  587.         Sent by the standard window handler to determine the standard state
  588.         for zooming.
  589.     o kEventWindowGetMinimumSize
  590.         Sent by the standard window handler to determine the minimum size
  591.         of the window (used during window resizing).
  592.     
  593.     o kEventWindowProxyBeginDrag
  594.         Sent before a proxy icon drag; you can attach data to the DragRef
  595.         in the event.
  596.     
  597.     o kEventWindowProxyEndDrag
  598.         Sent after the proxy icon drag is complete, whether successful or
  599.         not.
  600. */
  601. enum {
  602.     kEventWindowCollapse        = 66,
  603.     kEventWindowCollapsed       = 67,
  604.     kEventWindowCollapseAll     = 68,
  605.     kEventWindowExpand          = 69,
  606.     kEventWindowExpanded        = 70,
  607.     kEventWindowExpandAll       = 71,
  608.     kEventWindowClose           = 72,
  609.     kEventWindowClosed          = 73,
  610.     kEventWindowCloseAll        = 74,
  611.     kEventWindowZoom            = 75,
  612.     kEventWindowZoomed          = 76,
  613.     kEventWindowZoomAll         = 77,
  614.     kEventWindowContextualMenuSelect = 78,
  615.     kEventWindowPathSelect      = 79,
  616.     kEventWindowGetIdealSize    = 80,
  617.     kEventWindowGetMinimumSize  = 81,
  618.     kEventWindowProxyBeginDrag  = 128,
  619.     kEventWindowProxyEndDrag    = 129
  620. };
  621. /* Menu Events */
  622. enum {
  623.     kEventMenuBeginTracking     = 1,
  624.     kEventMenuEndTracking       = 2,
  625.     kEventMenuChangeTrackingMode = 3,
  626.     kEventMenuOpening           = 4,
  627.     kEventMenuClosed            = 5,
  628.     kEventMenuTargetItem        = 6,
  629.     kEventMenuMatchKey          = 7
  630. };
  631. /* Command-related events */
  632. enum {
  633.     kEventProcessCommand        = 1
  634. };
  635. /* Control Events */
  636. enum {
  637.     kEventControlHit            = 1,
  638.     kEventControlSimulateHit    = 2
  639. };
  640. /* HI Commands */
  641. enum {
  642.     kHICommandCancel            = FOUR_CHAR_CODE('not!'),       /* the most important command: cancel the current operation!  sent when the user presses command-period*/
  643.     kHICommandQuit              = FOUR_CHAR_CODE('quit'),
  644.     kHICommandUndo              = FOUR_CHAR_CODE('undo'),
  645.     kHICommandRedo              = FOUR_CHAR_CODE('redo'),
  646.     kHICommandCut               = FOUR_CHAR_CODE('cut '),
  647.     kHICommandCopy              = FOUR_CHAR_CODE('copy'),
  648.     kHICommandPaste             = FOUR_CHAR_CODE('past'),
  649.     kHICommandClear             = FOUR_CHAR_CODE('clea'),
  650.     kHICommandSelectAll         = FOUR_CHAR_CODE('sall')
  651. };
  652. enum {
  653.     kHICommandFromMenu          = (1L << 0)
  654. };
  655. struct HICommand {
  656.     UInt32                          attributes;
  657.     UInt32                          commandID;
  658.     struct {
  659.         MenuRef                         menuRef;
  660.         UInt16                          menuItemIndex;
  661.     }                                 menu;
  662. };
  663. typedef struct HICommand                HICommand;
  664. /*--------------------------------------------------------------------------------------*/
  665. /* Mouse Events                                                                         */
  666. /*--------------------------------------------------------------------------------------*/
  667. EXTERN_API( OSStatus )
  668. CreateMouseEvent                (UInt32                 kind,
  669.                                  EventTime              when,
  670.                                  Point                  where,
  671.                                  UInt32                 modifiers,
  672.                                  EventRef *             outEvent);
  673. EXTERN_API( OSStatus )
  674. SetMouseEventMouseLocation      (EventRef               inEvent,
  675.                                  Point                  inPoint);
  676. EXTERN_API( OSStatus )
  677. SetMouseEventKeyModifiers       (EventRef               inEvent,
  678.                                  UInt32                 inModifiers);
  679. EXTERN_API( OSStatus )
  680. SetMouseEventClickCount         (EventRef               inEvent,
  681.                                  UInt32                 inCount);
  682. EXTERN_API( OSStatus )
  683. GetMouseEventMouseLocation      (EventRef               inEvent,
  684.                                  Point *                outPoint);
  685. EXTERN_API( OSStatus )
  686. GetMouseEventKeyModifiers       (EventRef               inEvent,
  687.                                  UInt32 *               outModifiers);
  688. EXTERN_API( OSStatus )
  689. GetMouseEventClickCount         (EventRef               inEvent,
  690.                                  UInt32 *               outCount);
  691. /*--------------------------------------------------------------------------------------*/
  692. /* Keyboard Events                                                                      */
  693. /*--------------------------------------------------------------------------------------*/
  694. EXTERN_API( OSStatus )
  695. CreateKeyboardEvent             (UInt32                 kind,
  696.                                  EventTime              when,
  697.                                  UInt32                 inKeyChar,
  698.                                  UInt32                 inKeyCode,
  699.                                  UInt32                 inKeyModifiers,
  700.                                  EventRef *             outEvent);
  701. EXTERN_API( OSStatus )
  702. SetKeyboardEventKeyCode         (EventRef               inEvent,
  703.                                  UInt32                 inKeyCode);
  704. EXTERN_API( OSStatus )
  705. SetKeyboardEventKeyChar         (EventRef               inEvent,
  706.                                  UInt32                 inKeyChar);
  707. EXTERN_API( OSStatus )
  708. SetKeyboardEventKeyModifiers    (EventRef               inEvent,
  709.                                  UInt32                 inModifiers);
  710. EXTERN_API( OSStatus )
  711. GetKeyboardEventKeyCode         (EventRef               inEvent,
  712.                                  UInt32 *               outKeyCode);
  713. EXTERN_API( OSStatus )
  714. GetKeyboardEventKeyChar         (EventRef               inEvent,
  715.                                  UInt32 *               outKeyChar);
  716. EXTERN_API( OSStatus )
  717. GetKeyboardEventKeyModifiers    (EventRef               inEvent,
  718.                                  UInt32 *               outModifiers);
  719. /*--------------------------------------------------------------------------------------*/
  720. /* Window Events                                                                        */
  721. /*--------------------------------------------------------------------------------------*/
  722. EXTERN_API( OSStatus )
  723. CreateWindowEvent               (UInt32                 kind,
  724.                                  EventTime              when,
  725.                                  WindowRef              window,
  726.                                  EventRef *             outEvent);
  727. EXTERN_API( OSStatus )
  728. SetWindowEventWindowRef         (EventRef               inEvent,
  729.                                  WindowRef              inWindow);
  730. EXTERN_API( OSStatus )
  731. SetWindowEventKeyModifiers      (EventRef               inEvent,
  732.                                  UInt32                 inModifiers);
  733. EXTERN_API( OSStatus )
  734. SetWindowEventMouseLocation     (EventRef               inEvent,
  735.                                  Point                  inWhere);
  736. EXTERN_API( OSStatus )
  737. SetWindowEventWindowSize        (EventRef               inEvent,
  738.                                  Point                  inSize);
  739. EXTERN_API( OSStatus )
  740. GetWindowEventWindowRef         (EventRef               inEvent,
  741.                                  WindowRef *            outWindow);
  742. EXTERN_API( OSStatus )
  743. GetWindowEventKeyModifiers      (EventRef               inEvent,
  744.                                  UInt32 *               outModifiers);
  745. EXTERN_API( OSStatus )
  746. GetWindowEventMouseLocation     (EventRef               inEvent,
  747.                                  Point *                outWhere);
  748. EXTERN_API( OSStatus )
  749. GetWindowEventWindowSize        (EventRef               inEvent,
  750.                                  Point *                outSize);
  751. /* window proxy events contain dragrefs*/
  752. EXTERN_API( OSStatus )
  753. GetWindowEventDragRef           (EventRef               eventRef,
  754.                                  DragRef *              outDrag);
  755. EXTERN_API( OSStatus )
  756. SetWindowEventDragRef           (EventRef               eventRef,
  757.                                  DragRef                inDrag);
  758. EXTERN_API( OSStatus )
  759. GetWindowEventMenuRef           (EventRef               eventRef,
  760.                                  MenuRef *              outMenu);
  761. EXTERN_API( OSStatus )
  762. SetWindowEventMenuRef           (EventRef               eventRef,
  763.                                  MenuRef                inMenu);
  764. /* window bounds-changed events*/
  765. EXTERN_API( OSStatus )
  766. GetWindowEventOriginalBounds    (EventRef               eventRef,
  767.                                  Rect *                 outBounds);
  768. EXTERN_API( OSStatus )
  769. SetWindowEventOriginalBounds    (EventRef               eventRef,
  770.                                  const Rect *           inBounds);
  771. EXTERN_API( OSStatus )
  772. GetWindowEventPreviousBounds    (EventRef               eventRef,
  773.                                  Rect *                 outBounds);
  774. EXTERN_API( OSStatus )
  775. SetWindowEventPreviousBounds    (EventRef               eventRef,
  776.                                  const Rect *           inBounds);
  777. EXTERN_API( OSStatus )
  778. GetWindowEventCurrentBounds     (EventRef               eventRef,
  779.                                  Rect *                 outBounds);
  780. EXTERN_API( OSStatus )
  781. SetWindowEventCurrentBounds     (EventRef               eventRef,
  782.                                  const Rect *           inBounds);
  783. EXTERN_API( OSStatus )
  784. GetWindowEventGrafPort          (EventRef               eventRef,
  785.                                  GrafPtr *              outPort);
  786. EXTERN_API( OSStatus )
  787. SetWindowEventGrafPort          (EventRef               eventRef,
  788.                                  GrafPtr                inPort);
  789. /* window click events each contain a reference to the original mouse down event*/
  790. EXTERN_API( OSStatus )
  791. GetWindowEventMouseEvent        (EventRef               eventRef,
  792.                                  EventRef *             outEvent);
  793. EXTERN_API( OSStatus )
  794. SetWindowEventMouseEvent        (EventRef               eventRef,
  795.                                  EventRef               inEvent);
  796. /*--------------------------------------------------------------------------------------*/
  797. /* Control Events                                                                       */
  798. /*--------------------------------------------------------------------------------------*/
  799. EXTERN_API( OSStatus )
  800. CreateControlEvent              (UInt32                 kind,
  801.                                  EventTime              when,
  802.                                  ControlRef             control,
  803.                                  EventRef *             outEvent);
  804. EXTERN_API( OSStatus )
  805. SetControlEventControlRef       (EventRef               inEvent,
  806.                                  ControlRef             inControl);
  807. EXTERN_API( OSStatus )
  808. SetControlEventControlPartCode  (EventRef               inEvent,
  809.                                  ControlPartCode        inPart);
  810. EXTERN_API( OSStatus )
  811. SetControlEventKeyModifiers     (EventRef               inEvent,
  812.                                  UInt32                 inModifiers);
  813. EXTERN_API( OSStatus )
  814. GetControlEventControlRef       (EventRef               inEvent,
  815.                                  ControlRef *           outControl);
  816. EXTERN_API( OSStatus )
  817. GetControlEventControlPartCode  (EventRef               inEvent,
  818.                                  ControlPartCode *      outPart);
  819. EXTERN_API( OSStatus )
  820. GetControlEventKeyModifiers     (EventRef               inEvent,
  821.                                  UInt32 *               outModifiers);
  822. /*--------------------------------------------------------------------------------------*/
  823. /* Menu Events                                                                          */
  824. /*--------------------------------------------------------------------------------------*/
  825. EXTERN_API( OSStatus )
  826. CreateMenuEvent                 (UInt32                 kind,
  827.                                  EventTime              when,
  828.                                  MenuRef                menu,
  829.                                  EventRef *             outEvent);
  830. EXTERN_API( OSStatus )
  831. SetMenuEventMenuRef             (EventRef               inEvent,
  832.                                  MenuRef                inMenu);
  833. EXTERN_API( OSStatus )
  834. SetMenuEventTrackingMode        (EventRef               inEvent,
  835.                                  MenuTrackingMode       inMode,
  836.                                  Boolean                setCurrent);
  837. EXTERN_API( OSStatus )
  838. SetMenuEventFirstTimeOpen       (EventRef               inEvent,
  839.                                  Boolean                inFirstTimeOpen);
  840. EXTERN_API( OSStatus )
  841. SetMenuEventItemIndex           (EventRef               inEvent,
  842.                                  MenuItemIndex          inItemIndex);
  843. EXTERN_API( OSStatus )
  844. SetMenuEventCommandID           (EventRef               inEvent,
  845.                                  MenuCommand            inCommand);
  846. EXTERN_API( OSStatus )
  847. SetMenuEventKeyEvent            (EventRef               inEvent,
  848.                                  EventRef               inKeyEvent);
  849. EXTERN_API( OSStatus )
  850. SetMenuEventHICommand           (EventRef               inEvent,
  851.                                  const HICommand *      inCommand);
  852. EXTERN_API( OSStatus )
  853. GetMenuEventMenuRef             (EventRef               inEvent,
  854.                                  MenuRef *              outMenu);
  855. EXTERN_API( OSStatus )
  856. GetMenuEventTrackingMode        (EventRef               inEvent,
  857.                                  Boolean                getCurrent,
  858.                                  MenuTrackingMode *     outMode);
  859. EXTERN_API( OSStatus )
  860. GetMenuEventFirstTimeOpen       (EventRef               inEvent,
  861.                                  Boolean *              outFirstTimeOpen);
  862. EXTERN_API( OSStatus )
  863. GetMenuEventItemIndex           (EventRef               inEvent,
  864.                                  MenuItemIndex *        outItemIndex);
  865. EXTERN_API( OSStatus )
  866. GetMenuEventCommandID           (EventRef               inEvent,
  867.                                  MenuCommand *          outCommand);
  868. EXTERN_API( OSStatus )
  869. GetMenuEventKeyEvent            (EventRef               inEvent,
  870.                                  EventRef *             outKeyEvent);
  871. EXTERN_API( OSStatus )
  872. GetMenuEventHICommand           (EventRef               inEvent,
  873.                                  HICommand *            outCommand);
  874. /*--------------------------------------------------------------------------------------*/
  875. /* Command Events                                                                       */
  876. /*--------------------------------------------------------------------------------------*/
  877. EXTERN_API( OSStatus )
  878. CreateCommandEvent              (UInt32                 kind,
  879.                                  EventTime              when,
  880.                                  const HICommand *      inCommand,
  881.                                  EventRef *             outEvent);
  882. EXTERN_API( OSStatus )
  883. GetCommandEventCommand          (EventRef               inEvent,
  884.                                  HICommand *            outCommand);
  885. /*--------------------------------------------------------------------------------------*/
  886. /* Miscellany                                                                           */
  887. /*--------------------------------------------------------------------------------------*/
  888. EXTERN_API( OSStatus )
  889. CreateApplicationEvent          (UInt32                 kind,
  890.                                  EventTime              when,
  891.                                  EventRef *             outEvent);
  892. /*
  893.    This routine is used to get information about an async application launch
  894.    It is only valid on Mac OS X.
  895. */
  896. EXTERN_API( OSStatus )
  897. GetApplicationEventLaunchData   (EventRef               event,
  898.                                  OSStatus *             outLaunchErr,
  899.                                  ProcessSerialNumber *  outProcess,
  900.                                  void **                outLaunchRefCon);
  901. /*======================================================================================*/
  902. /*  EVENT HANDLERS                                                                      */
  903. /*======================================================================================*/
  904. typedef UInt32 EventHandlerResult;
  905. enum {
  906.     kEventHandlerHandled        = 0,
  907.     kEventHandlerNotHandled     = 1,
  908.     kEventHandlerPassUpChain    = 2,
  909.     kEventHandlerStopProcessing = 3
  910. };
  911. enum {
  912.     kEventHandlerStandard       = -1L
  913. };
  914. typedef struct OpaqueEventHandlerRef*   EventHandlerRef;
  915. /*--------------------------------------------------------------------------------------*/
  916. /*  o EventHandler specification                                                        */
  917. /*--------------------------------------------------------------------------------------*/
  918. typedef CALLBACK_API( EventHandlerResult , EventHandlerProcPtr )(EventHandlerRef inHandlerRef, EventRef inEvent, void *userData);
  919. typedef STACK_UPP_TYPE(EventHandlerProcPtr)                     EventHandlerUPP;
  920. #if OPAQUE_UPP_TYPES
  921.     EXTERN_API(EventHandlerUPP)
  922.     NewEventHandlerUPP             (EventHandlerProcPtr     userRoutine);
  923.     EXTERN_API(void)
  924.     DisposeEventHandlerUPP         (EventHandlerUPP         userUPP);
  925.     EXTERN_API(EventHandlerResult)
  926.     InvokeEventHandlerUPP          (EventHandlerRef         inHandlerRef,
  927.                                     EventRef                inEvent,
  928.                                     void *                  userData,
  929.                                     EventHandlerUPP         userUPP);
  930. #else
  931.     enum { uppEventHandlerProcInfo = 0x00000FF0 };                  /* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  932.     #define NewEventHandlerUPP(userRoutine)                         (EventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventHandlerProcInfo, GetCurrentArchitecture())
  933.     #define DisposeEventHandlerUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  934.     #define InvokeEventHandlerUPP(inHandlerRef, inEvent, userData, userUPP)  (EventHandlerResult)CALL_THREE_PARAMETER_UPP((userUPP), uppEventHandlerProcInfo, (inHandlerRef), (inEvent), (userData))
  935. #endif
  936. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  937. #define NewEventHandlerProc(userRoutine)                        NewEventHandlerUPP(userRoutine)
  938. #define CallEventHandlerProc(userRoutine, inHandlerRef, inEvent, userData) InvokeEventHandlerUPP(inHandlerRef, inEvent, userData, userRoutine)
  939. /*--------------------------------------------------------------------------------------*/
  940. /*  o Installing Event Handlers                                                         */
  941. /*                                                                                      */
  942. /* Use these routines to install event handlers for a specific toolbox object. You may  */
  943. /* pass zero for inNumTypes and NULL for inList if you need to be in a situation where  */
  944. /* you know you will be receiving events, but not exactly which ones at the time you    */
  945. /* are installing the handler. Later, your application can call the Add/Remove routines */
  946. /* listed below this section.                                                           */
  947. /*                                                                                      */
  948. /* You can only install a specific handler once. The combination of inHandler and       */
  949. /* inUserData is considered the 'signature' of a handler. Any attempt to install a new  */
  950. /* handler with the same proc and user data as an already-installed handler will result */
  951. /* in eventHandlerAlreadyInstalledErr. Installing the same proc and user data on a      */
  952. /* different object is legal.                                                           */
  953. /*                                                                                      */
  954. /* Upon successful completion of this routine, you are returned an EventHandlerRef,     */
  955. /* which you can use in various other calls, and is passed to your event handler. You   */
  956. /* use it to extract information about the handler, such as the target (window, etc.)   */
  957. /* if you have the same handler installed for different objects and need to perform     */
  958. /* actions on the current target (say, call a window manager function).                 */
  959. /*--------------------------------------------------------------------------------------*/
  960. EXTERN_API( OSStatus )
  961. InstallApplicationEventHandler  (EventHandlerUPP        inHandler,
  962.                                  UInt32                 inNumTypes,
  963.                                  const EventTypeSpec *  inList,
  964.                                  void *                 inUserData,
  965.                                  EventHandlerRef *      outRef);
  966. EXTERN_API( OSStatus )
  967. InstallWindowEventHandler       (WindowRef              inWindowRef,
  968.                                  EventHandlerUPP        inHandler,
  969.                                  UInt32                 inNumTypes,
  970.                                  const EventTypeSpec *  inList,
  971.                                  void *                 inUserData,
  972.                                  EventHandlerRef *      outRef);
  973. EXTERN_API( OSStatus )
  974. InstallControlEventHandler      (ControlRef             inControlRef,
  975.                                  EventHandlerUPP        inHandler,
  976.                                  UInt32                 inNumTypes,
  977.                                  const EventTypeSpec *  inList,
  978.                                  void *                 inUserData,
  979.                                  EventHandlerRef *      outRef);
  980. EXTERN_API( OSStatus )
  981. InstallMenuEventHandler         (MenuRef                inMenuRef,
  982.                                  EventHandlerUPP        inHandler,
  983.                                  UInt32                 inNumTypes,
  984.                                  const EventTypeSpec *  inList,
  985.                                  void *                 inUserData,
  986.                                  EventHandlerRef *      outRef);
  987. EXTERN_API( OSStatus )
  988. RemoveEventHandler              (EventHandlerRef        inHandlerRef);
  989. /*--------------------------------------------------------------------------------------*/
  990. /*  o Adjusting set of event types after a handler is created                           */
  991. /*                                                                                      */
  992. /* After installing a handler with the routine above, you can adjust the event type     */
  993. /* list telling the toolbox what events to send to that handler by calling the two      */
  994. /* routines below. If you add an event type twice for the same handler, your handler    */
  995. /* will only be called once, but it will take two RemoveEventType calls to stop your    */
  996. /* handler from being called with that event type. In other words, the install count    */
  997. /* for each event type is maintained by the toolbox. This might allow you, for example  */
  998. /* to have subclasses of a window object register for types without caring if the base  */
  999. /* class has already registered for that type. When the subclass removes its types, it  */
  1000. /* can succesfully do so without affecting the base class' reception of its events      */
  1001. /* types, yielding eternal bliss.                                                       */
  1002. /*--------------------------------------------------------------------------------------*/
  1003. EXTERN_API( OSStatus )
  1004. AddEventTypesToHandler          (EventHandlerRef        inHandlerRef,
  1005.                                  UInt32                 inNumTypes,
  1006.                                  const EventTypeSpec *  inList);
  1007. EXTERN_API( OSStatus )
  1008. RemoveEventTypesFromHandler     (EventHandlerRef        inHandlerRef,
  1009.                                  UInt32                 inNumTypes,
  1010.                                  const EventTypeSpec *  inList);
  1011. /*--------------------------------------------------------------------------------------*/
  1012. /*  o Explicit Propogation                                                              */
  1013. /*--------------------------------------------------------------------------------------*/
  1014. EXTERN_API( EventHandlerResult )
  1015. CallNextEventHandler            (EventHandlerRef        inThisHandler,
  1016.                                  EventRef               inEvent);
  1017. /*--------------------------------------------------------------------------------------*/
  1018. /*  o Getting the target from a handler ref                                             */
  1019. /*--------------------------------------------------------------------------------------*/
  1020. EXTERN_API( ControlRef )
  1021. GetEventHandlerTargetControl    (EventHandlerRef        inHandler);
  1022. EXTERN_API( WindowRef )
  1023. GetEventHandlerTargetWindow     (EventHandlerRef        inHandler);
  1024. EXTERN_API( MenuRef )
  1025. GetEventHandlerTargetMenu       (EventHandlerRef        inHandler);
  1026. /*--------------------------------------------------------------------------------------*/
  1027. /*  o Sending Events                                                                    */
  1028. /*--------------------------------------------------------------------------------------*/
  1029. EXTERN_API( EventHandlerResult )
  1030. SendEventToApplication          (EventRef               inEvent);
  1031. EXTERN_API( EventHandlerResult )
  1032. SendEventToWindow               (EventRef               inEvent,
  1033.                                  WindowRef              inWindow);
  1034. EXTERN_API( EventHandlerResult )
  1035. SendEventToControl              (EventRef               inEvent,
  1036.                                  ControlRef             inControl);
  1037. EXTERN_API( EventHandlerResult )
  1038. SendEventToMenu                 (EventRef               inEvent,
  1039.                                  MenuRef                inMenu);
  1040. EXTERN_API( EventHandlerResult )
  1041. SendEventToUserFocus            (EventRef               inEvent);
  1042. /*--------------------------------------------------------------------------------------*/
  1043. /*  o Command Routines                                                                  */
  1044. /*--------------------------------------------------------------------------------------*/
  1045. EXTERN_API( EventHandlerResult )
  1046. ProcessHICommand                (const HICommand *      inCommand);
  1047. /*--------------------------------------------------------------------------------------*/
  1048. /*  o Event Loop Routines                                                               */
  1049. /*--------------------------------------------------------------------------------------*/
  1050. EXTERN_API( void )
  1051. RunApplicationEventLoop         (void);
  1052. EXTERN_API( void )
  1053. QuitApplicationEventLoop        (void);
  1054. /*--------------------------------------------------------------------------------------*/
  1055. /*  o User Focus                                                                        */
  1056. /*--------------------------------------------------------------------------------------*/
  1057. EXTERN_API( void )
  1058. SetUserFocusWindow              (WindowRef              inWindow);
  1059. EXTERN_API( WindowRef )
  1060. GetUserFocusWindow              (void);
  1061. /*--------------------------------------------------------------------------------------*/
  1062. /*  o Default/Cancel buttons                                                            */
  1063. /*--------------------------------------------------------------------------------------*/
  1064. EXTERN_API( OSStatus )
  1065. SetWindowDefaultButton          (WindowRef              inWindow,
  1066.                                  ControlRef             inControl) /* can be NULL */;
  1067. EXTERN_API( OSStatus )
  1068. SetWindowCancelButton           (WindowRef              inWindow,
  1069.                                  ControlRef             inControl) /* can be NULL */;
  1070. EXTERN_API( OSStatus )
  1071. GetWindowDefaultButton          (WindowRef              inWindow,
  1072.                                  ControlRef *           outControl);
  1073. EXTERN_API( OSStatus )
  1074. GetWindowCancelButton           (WindowRef              inWindow,
  1075.                                  ControlRef *           outControl);
  1076. /*--------------------------------------------------------------------------------------*/
  1077. /*  o Mouse Tracking Areas                                                              */
  1078. /*                                                                                      */
  1079. /*  Mouse tracking areas control the generation of mouse-enter and                      */
  1080. /*  mouse-exit events.  When the user moves the mouse into a tracking                   */
  1081. /*  area, kEventMouseEnter is sent to the window.  When the user moves                  */
  1082. /*  the mouse out of a tracking area, kEventMouseExit is sent.                          */
  1083. /*                                                                                      */
  1084. /*  Mouse tracking regions are uniquely identified within the scope of                  */
  1085. /*  a window by a client signature/MouseTrackingRef pair.  The client                   */
  1086. /*  signature is the usual DTS-registered creator OSType.                               */
  1087. /*                                                                                      */
  1088. /*  Mouse tracking areas can overlap, but are not exclusive.  Mouse                     */
  1089. /*  motion events are generated for each of the tracking areas                          */
  1090. /*  intersected by the mouse.                                                           */
  1091. /*                                                                                      */
  1092. /*  Mouse tracking areas are initially enabled.  You can explicitly                     */
  1093. /*  disable a mouse tracking area to prevent mouse-enter/exit events                    */
  1094. /*  from being generated.                                                               */
  1095. /*                                                                                      */
  1096. /*  Unlike global mouse-moved events, mouse-enter and mouse-exit are                    */
  1097. /*  generated while your app is in the background.  If this is not                      */
  1098. /*  considered desirable, disable the tracking areas while the                          */
  1099. /*  application is in the background.                                                   */
  1100. /*--------------------------------------------------------------------------------------*/
  1101. typedef struct OpaqueMouseTrackingRef*  MouseTrackingRef;
  1102. /*
  1103.     Tracking Options
  1104.     If locally clipped, the region is expected in local coordinates and
  1105.     mouse movement tracking is clipped to the window's content region.
  1106.     If globally clipped, the region is expected in global coordinates and
  1107.     the tracking area is clipped to  window's structure region.
  1108. */
  1109. typedef OptionBits                      MouseTrackingOptions;
  1110. enum {
  1111.     kMouseTrackingOptionLocalClip = 0,                          /* specify a region in local coordinates; it will be clipped to the window's content region*/
  1112.     kMouseTrackingOptionGlobalClip = 1,                         /* specify a region in global coordinates; it will be clipped to the window's structure region*/
  1113.     kMouseTrackingOptionsStandard = kMouseTrackingOptionLocalClip
  1114. };
  1115. /* Creation*/
  1116. EXTERN_API( OSStatus )
  1117. CreateMouseTrackingArea         (WindowRef              inWindow,
  1118.                                  OSType                 inCreator,
  1119.                                  MouseTrackingOptions   inOptions,
  1120.                                  RgnHandle              inRegion,
  1121.                                  MouseTrackingRef *     outMouseRef);
  1122. EXTERN_API( OSStatus )
  1123. RetainMouseTrackingArea         (MouseTrackingRef       inMouseRef);
  1124. EXTERN_API( OSStatus )
  1125. ReleaseMouseTrackingArea        (MouseTrackingRef       inMouseRef);
  1126. /* Accessors*/
  1127. EXTERN_API( OSStatus )
  1128. SetMouseTrackingAreaRefCon      (MouseTrackingRef       inMouseRef,
  1129.                                  UInt32                 refCon);
  1130. EXTERN_API( OSStatus )
  1131. GetMouseTrackingAreaRefCon      (MouseTrackingRef       inMouseRef,
  1132.                                  UInt32 *               outRefCon);
  1133. /* Geometry*/
  1134. EXTERN_API( OSStatus )
  1135. MoveMouseTrackingArea           (MouseTrackingRef       inMouseRef,
  1136.                                  SInt16                 deltaH,
  1137.                                  SInt16                 deltaV);
  1138. EXTERN_API( OSStatus )
  1139. SetMouseTrackingAreaRegion      (MouseTrackingRef       inMouseRef,
  1140.                                  RgnHandle              inRegion);
  1141. EXTERN_API( OSStatus )
  1142. GetMouseTrackingAreaRegion      (MouseTrackingRef       inMouseRef,
  1143.                                  RgnHandle              outRgn);
  1144. /* Enable/disable*/
  1145. EXTERN_API( OSStatus )
  1146. SetMouseTrackingAreaEnabled     (MouseTrackingRef       inMouseRef,
  1147.                                  Boolean                enabled);
  1148. /* Namespace-scoped operations*/
  1149. EXTERN_API( OSStatus )
  1150. ReleaseWindowMouseTrackingAreas (WindowRef              inWindow,
  1151.                                  OSType                 creator);
  1152. EXTERN_API( OSStatus )
  1153. MoveWindowMouseTrackingAreas    (WindowRef              inWindow,
  1154.                                  OSType                 creator,
  1155.                                  SInt16                 deltaH,
  1156.                                  SInt16                 deltaV);
  1157. EXTERN_API( OSStatus )
  1158. SetWindowMouseTrackingAreasEnabled (WindowRef           inWindow,
  1159.                                  OSType                 creator,
  1160.                                  Boolean                enabled);
  1161. /* Mouse event accessor additions*/
  1162. /* Mouse-enter and exit events contain the tracking ref for which they are generated.*/
  1163. EXTERN_API( OSStatus )
  1164. SetMouseEventTrackingArea       (EventRef               inEvent,
  1165.                                  MouseTrackingRef       inMouseRef);
  1166. EXTERN_API( OSStatus )
  1167. GetMouseEventTrackingArea       (EventRef               inEvent,
  1168.                                  MouseTrackingRef *     outMouseRef);
  1169. #if PRAGMA_STRUCT_ALIGN
  1170.     #pragma options align=reset
  1171. #elif PRAGMA_STRUCT_PACKPUSH
  1172.     #pragma pack(pop)
  1173. #elif PRAGMA_STRUCT_PACK
  1174.     #pragma pack()
  1175. #endif
  1176. #ifdef PRAGMA_IMPORT_OFF
  1177. #pragma import off
  1178. #elif PRAGMA_IMPORT
  1179. #pragma import reset
  1180. #endif
  1181. #ifdef __cplusplus
  1182. }
  1183. #endif
  1184. #endif /* __CARBONEVENTS__ */