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.

2174 lines
70 KiB

  1. /*
  2. File: CarbonEventsCore.h
  3. Contains: Carbon Event Manager
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1999-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 __CARBONEVENTSCORE__
  11. #define __CARBONEVENTSCORE__
  12. #ifndef __CFSTRING__
  13. #include <CFString.h>
  14. #endif
  15. #ifndef __AEREGISTRY__
  16. #include <AERegistry.h>
  17. #endif
  18. #ifndef __AEDATAMODEL__
  19. #include <AEDataModel.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. /* The core data structure of the Carbon Event system */
  39. /*======================================================================================*/
  40. typedef struct OpaqueEventRef* EventRef;
  41. /*======================================================================================*/
  42. /* EVENT COMMON */
  43. /*======================================================================================*/
  44. /*
  45. * Discussion:
  46. * The following are all errors which can be returned from the
  47. * routines contained in this file.
  48. */
  49. enum {
  50. /*
  51. * This is returned from PostEventToQueue if the event in question is
  52. * already in the queue you are posting it to (or any other queue).
  53. */
  54. eventAlreadyPostedErr = -9860,
  55. /*
  56. * You are attemtping to modify a target that is currently in use,
  57. * such as when dispatching.
  58. */
  59. eventTargetBusyErr = -9861,
  60. /*
  61. * This is obsolete and will be removed.
  62. */
  63. eventClassInvalidErr = -9862,
  64. /*
  65. * This is obsolete and will be removed.
  66. */
  67. eventClassIncorrectErr = -9864,
  68. /*
  69. * Returned from InstallEventHandler if the handler proc you pass is
  70. * already installed for a given event type you are trying to
  71. * register.
  72. */
  73. eventHandlerAlreadyInstalledErr = -9866,
  74. /*
  75. * A generic error.
  76. */
  77. eventInternalErr = -9868,
  78. /*
  79. * This is obsolete and will be removed.
  80. */
  81. eventKindIncorrectErr = -9869,
  82. /*
  83. * The piece of data you are requesting from an event is not present.
  84. */
  85. eventParameterNotFoundErr = -9870,
  86. /*
  87. * This is what you should return from an event handler when your
  88. * handler has received an event it doesn't currently want to (or
  89. * isn't able to) handle. If you handle an event, you should return
  90. * noErr from your event handler. Any return value other than
  91. * eventNotHandledErr will cause event handling to stop; the event
  92. * will not be sent to any other event handler, and the return value
  93. * will be provided to the original caller of SendEventToTarget.
  94. */
  95. eventNotHandledErr = -9874,
  96. /*
  97. * The event loop has timed out. This can be returned from calls to
  98. * ReceiveNextEvent or RunCurrentEventLoop.
  99. */
  100. eventLoopTimedOutErr = -9875,
  101. /*
  102. * The event loop was quit, probably by a call to QuitEventLoop. This
  103. * can be returned from ReceiveNextEvent or RunCurrentEventLoop.
  104. */
  105. eventLoopQuitErr = -9876,
  106. /*
  107. * Returned from RemoveEventFromQueue when trying to remove an event
  108. * that's not in any queue.
  109. */
  110. eventNotInQueueErr = -9877,
  111. eventHotKeyExistsErr = -9878,
  112. eventHotKeyInvalidErr = -9879
  113. };
  114. /*======================================================================================*/
  115. /* EVENT CORE */
  116. /*======================================================================================*/
  117. /*--------------------------------------------------------------------------------------*/
  118. /* o Event Flags, options */
  119. /*--------------------------------------------------------------------------------------*/
  120. /*
  121. * EventPriority
  122. *
  123. * Discussion:
  124. * These values define the relative priority of an event, and are
  125. * used when posting events with PostEventToQueue. In general events
  126. * are pulled from the queue in order of first posted to last
  127. * posted. These priorities are a way to alter that when posting
  128. * events. You can post a standard priority event and then a high
  129. * priority event and the high priority event will be pulled from
  130. * the queue first.
  131. */
  132. typedef SInt16 EventPriority;
  133. enum {
  134. /*
  135. * Lowest priority. Currently only window update events are posted at
  136. * this priority.
  137. */
  138. kEventPriorityLow = 0,
  139. /*
  140. * Normal priority of events. Most events are standard priority.
  141. */
  142. kEventPriorityStandard = 1,
  143. /*
  144. * Highest priority.
  145. */
  146. kEventPriorityHigh = 2
  147. };
  148. enum {
  149. kEventLeaveInQueue = false,
  150. kEventRemoveFromQueue = true
  151. };
  152. /*--------------------------------------------------------------------------------------*/
  153. /* o Event Times */
  154. /* */
  155. /* EventTime is in seconds since boot. Use the constants to make life easy. */
  156. /*--------------------------------------------------------------------------------------*/
  157. typedef double EventTime;
  158. typedef EventTime EventTimeout;
  159. typedef EventTime EventTimerInterval;
  160. #define kEventDurationSecond ((EventTime)1.0)
  161. #define kEventDurationMillisecond ((EventTime)(kEventDurationSecond/1000))
  162. #define kEventDurationMicrosecond ((EventTime)(kEventDurationSecond/1000000))
  163. #define kEventDurationNanosecond ((EventTime)(kEventDurationSecond/1000000000))
  164. #define kEventDurationMinute ((EventTime)(kEventDurationSecond*60))
  165. #define kEventDurationHour ((EventTime)(kEventDurationMinute*60))
  166. #define kEventDurationDay ((EventTime)(kEventDurationHour*24))
  167. #define kEventDurationNoWait ((EventTime)0.0)
  168. #define kEventDurationForever ((EventTime)(-1.0))
  169. /* Helpful doodads to convert to and from ticks and event times*/
  170. #ifdef __cplusplus
  171. inline EventTime TicksToEventTime( UInt32 t ) { return ( (t) / 60.0 ); }
  172. inline UInt32 EventTimeToTicks( EventTime t ) { return (UInt32)( ((t) * 60) + 0.5 ); }
  173. #else
  174. #define TicksToEventTime( t ) ((EventTime)( (t) / 60.0 ))
  175. #define EventTimeToTicks( t ) ((UInt32)( ((t) * 60) + 0.5 ))
  176. #endif /* defined(__cplusplus) */
  177. /*--------------------------------------------------------------------------------------*/
  178. /* EventTypeSpec structure */
  179. /* */
  180. /* This structure is used in many routines to pass a list of event types to a function. */
  181. /* You typically would declare a const array of these types to pass in. */
  182. /*--------------------------------------------------------------------------------------*/
  183. /*
  184. * EventTypeSpec
  185. *
  186. * Discussion:
  187. * This structure is used to specify an event. Typically, a static
  188. * array of EventTypeSpecs are passed into functions such as
  189. * InstallEventHandler, as well as routines such as
  190. * FlushEventsMatchingListFromQueue.
  191. */
  192. struct EventTypeSpec {
  193. UInt32 eventClass;
  194. UInt32 eventKind;
  195. };
  196. typedef struct EventTypeSpec EventTypeSpec;
  197. /*A helpful macro for dealing with EventTypeSpecs */
  198. #define GetEventTypeCount( t ) (sizeof( (t) ) / sizeof( EventTypeSpec ))
  199. typedef OSType EventParamName;
  200. typedef OSType EventParamType;
  201. /*--------------------------------------------------------------------------------------*/
  202. /* o EventLoop */
  203. /*--------------------------------------------------------------------------------------*/
  204. /*
  205. * EventLoopRef
  206. *
  207. * Discussion:
  208. * An EventLoopRef represents an 'event loop', which is the
  209. * conceptual entity that you 'run' to fetch events from hardware
  210. * and other sources and also fires timers that might be installed
  211. * with InstallEventLoopTimer. The term 'run' is a bit of a
  212. * misnomer, as the event loop's goal is to stay as blocked as
  213. * possible to minimize CPU usage for the current application. The
  214. * event loop is run implicitly thru APIs like ReceiveNextEvent,
  215. * RunApplicationEventLoop, or even WaitNextEvent. It can also be
  216. * run explicitly thru a call to RunCurrentEventLoop. Each
  217. * preemptive thread can have an event loop. Cooperative threads
  218. * share the main thread's event loop.
  219. */
  220. typedef struct OpaqueEventLoopRef* EventLoopRef;
  221. /*
  222. * GetCurrentEventLoop()
  223. *
  224. * Discussion:
  225. * Returns the current event loop for the current thread. If the
  226. * current thread is a cooperative thread, the main event loop is
  227. * returned.
  228. *
  229. * Result:
  230. * An event loop reference.
  231. *
  232. * Availability:
  233. * Non-Carbon CFM: not available
  234. * CarbonLib: in CarbonLib 1.1 and later
  235. * Mac OS X: in version 10.0 and later
  236. */
  237. EXTERN_API( EventLoopRef )
  238. GetCurrentEventLoop(void);
  239. /*
  240. * GetMainEventLoop()
  241. *
  242. * Discussion:
  243. * Returns the event loop object for the main application thread.
  244. *
  245. * Result:
  246. * An event loop reference.
  247. *
  248. * Availability:
  249. * Non-Carbon CFM: not available
  250. * CarbonLib: in CarbonLib 1.1 and later
  251. * Mac OS X: in version 10.0 and later
  252. */
  253. EXTERN_API( EventLoopRef )
  254. GetMainEventLoop(void);
  255. /*
  256. * RunCurrentEventLoop()
  257. *
  258. * Discussion:
  259. * This routine 'runs' the event loop, returning only if aborted or
  260. * the timeout specified is reached. The event loop is mostly
  261. * blocked while in this function, occasionally waking up to fire
  262. * timers or pick up events. The typical use of this function is to
  263. * cause the current thread to wait for some operation to complete,
  264. * most likely on another thread of execution.
  265. *
  266. * Parameters:
  267. *
  268. * inTimeout:
  269. * The time to wait until returning (can be kEventDurationForever).
  270. *
  271. * Availability:
  272. * Non-Carbon CFM: not available
  273. * CarbonLib: in CarbonLib 1.1 and later
  274. * Mac OS X: in version 10.0 and later
  275. */
  276. EXTERN_API( OSStatus )
  277. RunCurrentEventLoop(EventTimeout inTimeout);
  278. /*
  279. * QuitEventLoop()
  280. *
  281. * Discussion:
  282. * Causes a specific event loop to terminate. Usage of this is
  283. * similar to WakeUpProcess, in that it causes the eventloop
  284. * specified to return immediately (as opposed to timing out).
  285. * Typically this call is used in conjunction with
  286. * RunCurrentEventLoop.
  287. *
  288. * Parameters:
  289. *
  290. * inEventLoop:
  291. * The event loop to terminate.
  292. *
  293. * Result:
  294. * An operating system result code.
  295. *
  296. * Availability:
  297. * Non-Carbon CFM: not available
  298. * CarbonLib: in CarbonLib 1.1 and later
  299. * Mac OS X: in version 10.0 and later
  300. */
  301. EXTERN_API( OSStatus )
  302. QuitEventLoop(EventLoopRef inEventLoop);
  303. /*
  304. * GetCFRunLoopFromEventLoop()
  305. *
  306. * Discussion:
  307. * Returns the corresponding CFRunLoopRef for the given EventLoop.
  308. * This is not necessarily a one-to-one mapping, hence the need for
  309. * this function. In Carbon, all cooperative threads use the same
  310. * run loop under the covers, so using CFRunLoopGetCurrent might
  311. * yield the wrong result. In general, you would only need to use
  312. * this function if you wished to add your own sources to the run
  313. * loop. If you don't know what I'm talking about, then you probably
  314. * don't need to use this.
  315. *
  316. * Parameters:
  317. *
  318. * inEventLoop:
  319. * The event loop to get the CFRunLoop for.
  320. *
  321. * Result:
  322. * The CFRunLoopRef for inEventLoop.
  323. *
  324. * Availability:
  325. * Non-Carbon CFM: not available
  326. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.1 and later
  327. * Mac OS X: in version 10.1 and later
  328. */
  329. EXTERN_API_C( CFTypeRef )
  330. GetCFRunLoopFromEventLoop(EventLoopRef inEventLoop);
  331. /*--------------------------------------------------------------------------------------*/
  332. /* o Low-level event fetching */
  333. /*--------------------------------------------------------------------------------------*/
  334. /*
  335. * ReceiveNextEvent()
  336. *
  337. * Discussion:
  338. * This routine tries to fetch the next event of a specified type.
  339. * If no events in the event queue match, this routine will run the
  340. * current event loop until an event that matches arrives, or the
  341. * timeout expires. Except for timers firing, your application is
  342. * blocked waiting for events to arrive when inside this function.
  343. *
  344. * Parameters:
  345. *
  346. * inNumTypes:
  347. * The number of event types we are waiting for (0 if any event
  348. * should cause this routine to return).
  349. *
  350. * inList:
  351. * The list of event types we are waiting for (pass NULL if any
  352. * event should cause this routine to return).
  353. *
  354. * inTimeout:
  355. * The time to wait (passing kEventDurationForever is preferred).
  356. *
  357. * inPullEvent:
  358. * Pass true for this parameter to actually remove the next
  359. * matching event from the queue.
  360. *
  361. * outEvent:
  362. * The next event that matches the list passed in. If inPullEvent
  363. * is true, the event is owned by you, and you will need to
  364. * release it when done.
  365. *
  366. * Result:
  367. * A result indicating whether an event was received, the timeout
  368. * expired, or the current event loop was quit.
  369. *
  370. * Availability:
  371. * Non-Carbon CFM: not available
  372. * CarbonLib: in CarbonLib 1.1 and later
  373. * Mac OS X: in version 10.0 and later
  374. */
  375. EXTERN_API( OSStatus )
  376. ReceiveNextEvent(
  377. UInt32 inNumTypes,
  378. const EventTypeSpec * inList,
  379. EventTimeout inTimeout,
  380. Boolean inPullEvent,
  381. EventRef * outEvent);
  382. /*--------------------------------------------------------------------------------------*/
  383. /* o Core event lifetime APIs */
  384. /*--------------------------------------------------------------------------------------*/
  385. typedef UInt32 EventAttributes;
  386. enum {
  387. kEventAttributeNone = 0,
  388. kEventAttributeUserEvent = (1 << 0)
  389. };
  390. /*
  391. * [Mac]CreateEvent()
  392. *
  393. * Availability:
  394. * Non-Carbon CFM: not available
  395. * CarbonLib: in CarbonLib 1.1 and later
  396. * Mac OS X: in version 10.0 and later
  397. */
  398. #if TARGET_OS_MAC
  399. #define MacCreateEvent CreateEvent
  400. #endif
  401. EXTERN_API( OSStatus )
  402. MacCreateEvent(
  403. CFAllocatorRef inAllocator, /* can be NULL */
  404. UInt32 inClassID,
  405. UInt32 kind,
  406. EventTime when,
  407. EventAttributes flags,
  408. EventRef * outEvent);
  409. /*
  410. * CopyEvent()
  411. *
  412. * Availability:
  413. * Non-Carbon CFM: not available
  414. * CarbonLib: in CarbonLib 1.1 and later
  415. * Mac OS X: in version 10.0 and later
  416. */
  417. EXTERN_API( EventRef )
  418. CopyEvent(EventRef inOther);
  419. /*
  420. * RetainEvent()
  421. *
  422. * Availability:
  423. * Non-Carbon CFM: not available
  424. * CarbonLib: in CarbonLib 1.1 and later
  425. * Mac OS X: in version 10.0 and later
  426. */
  427. EXTERN_API( EventRef )
  428. RetainEvent(EventRef inEvent);
  429. /*
  430. * GetEventRetainCount()
  431. *
  432. * Availability:
  433. * Non-Carbon CFM: not available
  434. * CarbonLib: in CarbonLib 1.1 and later
  435. * Mac OS X: in version 10.0 and later
  436. */
  437. EXTERN_API( UInt32 )
  438. GetEventRetainCount(EventRef inEvent);
  439. /*
  440. * ReleaseEvent()
  441. *
  442. * Availability:
  443. * Non-Carbon CFM: not available
  444. * CarbonLib: in CarbonLib 1.1 and later
  445. * Mac OS X: in version 10.0 and later
  446. */
  447. EXTERN_API( void )
  448. ReleaseEvent(EventRef inEvent);
  449. /*
  450. * SetEventParameter()
  451. *
  452. * Discussion:
  453. * Sets a piece of data for the given event.
  454. *
  455. * Parameters:
  456. *
  457. * inEvent:
  458. * The event to set the data for.
  459. *
  460. * inName:
  461. * The symbolic name of the parameter.
  462. *
  463. * inType:
  464. * The symbolic type of the parameter.
  465. *
  466. * inSize:
  467. * The size of the parameter data.
  468. *
  469. * inDataPtr:
  470. * The pointer to the parameter data.
  471. *
  472. * Result:
  473. * An operating system result code.
  474. *
  475. * Availability:
  476. * Non-Carbon CFM: not available
  477. * CarbonLib: in CarbonLib 1.1 and later
  478. * Mac OS X: in version 10.0 and later
  479. */
  480. EXTERN_API( OSStatus )
  481. SetEventParameter(
  482. EventRef inEvent,
  483. EventParamName inName,
  484. EventParamType inType,
  485. UInt32 inSize,
  486. const void * inDataPtr);
  487. /*
  488. * GetEventParameter()
  489. *
  490. * Discussion:
  491. * Gets a piece of data from the given event, if it exists.
  492. *
  493. * Parameters:
  494. *
  495. * inEvent:
  496. * The event to get the parameter from.
  497. *
  498. * inName:
  499. * The symbolic name of the parameter.
  500. *
  501. * inDesiredType:
  502. * The desired type of the parameter. At present we do not support
  503. * coercion, so this parameter must be the actual type of data
  504. * stored in the event, or an error will be returned.
  505. *
  506. * outActualType:
  507. * The actual type of the parameter, can be NULL if you are not
  508. * interested in receiving this information.
  509. *
  510. * inBufferSize:
  511. * The size of the output buffer specified by ioBuffer.
  512. *
  513. * outActualSize:
  514. * The actual size of the data, or NULL if you don't want this
  515. * information.
  516. *
  517. * outData:
  518. * The pointer to the buffer which will receive the parameter data.
  519. *
  520. * Result:
  521. * An operating system result code.
  522. *
  523. * Availability:
  524. * Non-Carbon CFM: not available
  525. * CarbonLib: in CarbonLib 1.1 and later
  526. * Mac OS X: in version 10.0 and later
  527. */
  528. EXTERN_API( OSStatus )
  529. GetEventParameter(
  530. EventRef inEvent,
  531. EventParamName inName,
  532. EventParamType inDesiredType,
  533. EventParamType * outActualType, /* can be NULL */
  534. UInt32 inBufferSize,
  535. UInt32 * outActualSize, /* can be NULL */
  536. void * outData);
  537. /*--------------------------------------------------------------------------------------*/
  538. /* o Getters for 'base-class' event info */
  539. /*--------------------------------------------------------------------------------------*/
  540. /*
  541. * GetEventClass()
  542. *
  543. * Discussion:
  544. * Returns the class of the given event, such as mouse, keyboard,
  545. * etc.
  546. *
  547. * Parameters:
  548. *
  549. * inEvent:
  550. * The event in question.
  551. *
  552. * Result:
  553. * The class ID of the event.
  554. *
  555. * Availability:
  556. * Non-Carbon CFM: not available
  557. * CarbonLib: in CarbonLib 1.1 and later
  558. * Mac OS X: in version 10.0 and later
  559. */
  560. EXTERN_API( UInt32 )
  561. GetEventClass(EventRef inEvent);
  562. /*
  563. * GetEventKind()
  564. *
  565. * Discussion:
  566. * Returns the kind of the given event (mousedown, etc.). Event
  567. * kinds overlap between event classes, e.g. kEventMouseDown and
  568. * kEventAppActivated have the same value (1). The combination of
  569. * class and kind is what determines an event signature.
  570. *
  571. * Parameters:
  572. *
  573. * inEvent:
  574. * The event in question.
  575. *
  576. * Result:
  577. * The kind of the event.
  578. *
  579. * Availability:
  580. * Non-Carbon CFM: not available
  581. * CarbonLib: in CarbonLib 1.1 and later
  582. * Mac OS X: in version 10.0 and later
  583. */
  584. EXTERN_API( UInt32 )
  585. GetEventKind(EventRef inEvent);
  586. /*
  587. * GetEventTime()
  588. *
  589. * Discussion:
  590. * Returns the time the event specified occurred, specified in
  591. * EventTime, which is a floating point number representing seconds
  592. * since the last system startup.
  593. *
  594. * Parameters:
  595. *
  596. * inEvent:
  597. * The event in question.
  598. *
  599. * Result:
  600. * The time the event occurred.
  601. *
  602. * Availability:
  603. * Non-Carbon CFM: not available
  604. * CarbonLib: in CarbonLib 1.1 and later
  605. * Mac OS X: in version 10.0 and later
  606. */
  607. EXTERN_API( EventTime )
  608. GetEventTime(EventRef inEvent);
  609. /*--------------------------------------------------------------------------------------*/
  610. /* o Setters for 'base-class' event info */
  611. /*--------------------------------------------------------------------------------------*/
  612. /*
  613. * SetEventTime()
  614. *
  615. * Discussion:
  616. * This routine allows you to set the time of a given event, if you
  617. * so desire. In general, you would never use this routine, except
  618. * for those special cases where you reuse an event from time to
  619. * time instead of creating a new event each time.
  620. *
  621. * Parameters:
  622. *
  623. * inEvent:
  624. * The event in question.
  625. *
  626. * inTime:
  627. * The new time.
  628. *
  629. * Result:
  630. * An operating system result code.
  631. *
  632. * Availability:
  633. * Non-Carbon CFM: not available
  634. * CarbonLib: in CarbonLib 1.1 and later
  635. * Mac OS X: in version 10.0 and later
  636. */
  637. EXTERN_API( OSStatus )
  638. SetEventTime(
  639. EventRef inEvent,
  640. EventTime inTime);
  641. /*--------------------------------------------------------------------------------------*/
  642. /* o Event Queue routines (posting, finding, flushing) */
  643. /*--------------------------------------------------------------------------------------*/
  644. typedef struct OpaqueEventQueueRef* EventQueueRef;
  645. /*
  646. * GetCurrentEventQueue()
  647. *
  648. * Discussion:
  649. * Returns the current event queue for the current thread. If the
  650. * current thread is a cooperative thread, the main event queue is
  651. * returned.
  652. *
  653. * Result:
  654. * An event queue reference.
  655. *
  656. * Availability:
  657. * Non-Carbon CFM: not available
  658. * CarbonLib: in CarbonLib 1.1 and later
  659. * Mac OS X: in version 10.0 and later
  660. */
  661. EXTERN_API( EventQueueRef )
  662. GetCurrentEventQueue(void);
  663. /*
  664. * GetMainEventQueue()
  665. *
  666. * Discussion:
  667. * Returns the event queue object for the main application thread.
  668. *
  669. * Result:
  670. * An event queue reference.
  671. *
  672. * Availability:
  673. * Non-Carbon CFM: not available
  674. * CarbonLib: in CarbonLib 1.1 and later
  675. * Mac OS X: in version 10.0 and later
  676. */
  677. EXTERN_API( EventQueueRef )
  678. GetMainEventQueue(void);
  679. /*
  680. * EventComparatorProcPtr
  681. *
  682. * Discussion:
  683. * Type of a callback function used by queue searches.
  684. *
  685. * Parameters:
  686. *
  687. * inEvent:
  688. * The event to compare.
  689. *
  690. * inCompareData:
  691. * The data used to compare the event.
  692. *
  693. * Result:
  694. * A boolean value indicating whether the event matches (true) or
  695. * not (false).
  696. */
  697. typedef CALLBACK_API( Boolean , EventComparatorProcPtr )(EventRef inEvent, void *inCompareData);
  698. typedef STACK_UPP_TYPE(EventComparatorProcPtr) EventComparatorUPP;
  699. /*
  700. * NewEventComparatorUPP()
  701. *
  702. * Availability:
  703. * Non-Carbon CFM: available as macro/inline
  704. * CarbonLib: in CarbonLib 1.1 and later
  705. * Mac OS X: in version 10.0 and later
  706. */
  707. EXTERN_API_C( EventComparatorUPP )
  708. NewEventComparatorUPP(EventComparatorProcPtr userRoutine);
  709. #if !OPAQUE_UPP_TYPES
  710. enum { uppEventComparatorProcInfo = 0x000003D0 }; /* pascal 1_byte Func(4_bytes, 4_bytes) */
  711. #ifdef __cplusplus
  712. inline DEFINE_API_C(EventComparatorUPP) NewEventComparatorUPP(EventComparatorProcPtr userRoutine) { return (EventComparatorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventComparatorProcInfo, GetCurrentArchitecture()); }
  713. #else
  714. #define NewEventComparatorUPP(userRoutine) (EventComparatorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventComparatorProcInfo, GetCurrentArchitecture())
  715. #endif
  716. #endif
  717. /*
  718. * DisposeEventComparatorUPP()
  719. *
  720. * Availability:
  721. * Non-Carbon CFM: available as macro/inline
  722. * CarbonLib: in CarbonLib 1.1 and later
  723. * Mac OS X: in version 10.0 and later
  724. */
  725. EXTERN_API_C( void )
  726. DisposeEventComparatorUPP(EventComparatorUPP userUPP);
  727. #if !OPAQUE_UPP_TYPES
  728. #ifdef __cplusplus
  729. inline DEFINE_API_C(void) DisposeEventComparatorUPP(EventComparatorUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  730. #else
  731. #define DisposeEventComparatorUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  732. #endif
  733. #endif
  734. /*
  735. * InvokeEventComparatorUPP()
  736. *
  737. * Availability:
  738. * Non-Carbon CFM: available as macro/inline
  739. * CarbonLib: in CarbonLib 1.1 and later
  740. * Mac OS X: in version 10.0 and later
  741. */
  742. EXTERN_API_C( Boolean )
  743. InvokeEventComparatorUPP(
  744. EventRef inEvent,
  745. void * inCompareData,
  746. EventComparatorUPP userUPP);
  747. #if !OPAQUE_UPP_TYPES
  748. #ifdef __cplusplus
  749. inline DEFINE_API_C(Boolean) InvokeEventComparatorUPP(EventRef inEvent, void * inCompareData, EventComparatorUPP userUPP) { return (Boolean)CALL_TWO_PARAMETER_UPP(userUPP, uppEventComparatorProcInfo, inEvent, inCompareData); }
  750. #else
  751. #define InvokeEventComparatorUPP(inEvent, inCompareData, userUPP) (Boolean)CALL_TWO_PARAMETER_UPP((userUPP), uppEventComparatorProcInfo, (inEvent), (inCompareData))
  752. #endif
  753. #endif
  754. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  755. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  756. #define NewEventComparatorProc(userRoutine) NewEventComparatorUPP(userRoutine)
  757. #define CallEventComparatorProc(userRoutine, inEvent, inCompareData) InvokeEventComparatorUPP(inEvent, inCompareData, userRoutine)
  758. #endif /* CALL_NOT_IN_CARBON */
  759. /*
  760. * PostEventToQueue()
  761. *
  762. * Discussion:
  763. * Posts an event to the queue specified. This automatically wakes
  764. * up the event loop of the thread the queue belongs to. After
  765. * posting the event, you should release the event. The event queue
  766. * retains it.
  767. *
  768. * Parameters:
  769. *
  770. * inQueue:
  771. * The event queue to post the event onto.
  772. *
  773. * inEvent:
  774. * The event to post.
  775. *
  776. * inPriority:
  777. * The priority of the event.
  778. *
  779. * Result:
  780. * An operating system result code.
  781. *
  782. * Availability:
  783. * Non-Carbon CFM: not available
  784. * CarbonLib: in CarbonLib 1.1 and later
  785. * Mac OS X: in version 10.0 and later
  786. */
  787. EXTERN_API( OSStatus )
  788. PostEventToQueue(
  789. EventQueueRef inQueue,
  790. EventRef inEvent,
  791. EventPriority inPriority);
  792. /*
  793. * FlushEventsMatchingListFromQueue()
  794. *
  795. * Discussion:
  796. * Flushes events matching a specified list of classes and kinds
  797. * from an event queue.
  798. *
  799. * Parameters:
  800. *
  801. * inQueue:
  802. * The event queue to flush events from.
  803. *
  804. * inNumTypes:
  805. * The number of event kinds to flush.
  806. *
  807. * inList:
  808. * The list of event classes and kinds to flush from the queue.
  809. *
  810. * Result:
  811. * An operating system result code.
  812. *
  813. * Availability:
  814. * Non-Carbon CFM: not available
  815. * CarbonLib: in CarbonLib 1.1 and later
  816. * Mac OS X: in version 10.0 and later
  817. */
  818. EXTERN_API( OSStatus )
  819. FlushEventsMatchingListFromQueue(
  820. EventQueueRef inQueue,
  821. UInt32 inNumTypes,
  822. const EventTypeSpec * inList);
  823. /*
  824. * FlushSpecificEventsFromQueue()
  825. *
  826. * Discussion:
  827. * Flushes events that match a comparator function.
  828. *
  829. * Parameters:
  830. *
  831. * inQueue:
  832. * The event queue to flush events from.
  833. *
  834. * inComparator:
  835. * The comparison function to invoke for each event in the queue.
  836. *
  837. * inCompareData:
  838. * The data you wish to pass to your comparison function.
  839. *
  840. * Result:
  841. * An operating system result code.
  842. *
  843. * Availability:
  844. * Non-Carbon CFM: not available
  845. * CarbonLib: in CarbonLib 1.1 and later
  846. * Mac OS X: in version 10.0 and later
  847. */
  848. EXTERN_API( OSStatus )
  849. FlushSpecificEventsFromQueue(
  850. EventQueueRef inQueue,
  851. EventComparatorUPP inComparator,
  852. void * inCompareData);
  853. /*
  854. * FlushEventQueue()
  855. *
  856. * Discussion:
  857. * Flushes all events from an event queue.
  858. *
  859. * Parameters:
  860. *
  861. * inQueue:
  862. * The event queue to flush.
  863. *
  864. * Result:
  865. * An operating system result code.
  866. *
  867. * Availability:
  868. * Non-Carbon CFM: not available
  869. * CarbonLib: in CarbonLib 1.1 and later
  870. * Mac OS X: in version 10.0 and later
  871. */
  872. EXTERN_API( OSStatus )
  873. FlushEventQueue(EventQueueRef inQueue);
  874. /*
  875. * FindSpecificEventInQueue()
  876. *
  877. * Discussion:
  878. * Returns the first event that matches a comparator function, or
  879. * NULL if no events match.
  880. *
  881. * Parameters:
  882. *
  883. * inQueue:
  884. * The event queue to search.
  885. *
  886. * inComparator:
  887. * The comparison function to invoke for each event in the queue.
  888. *
  889. * inCompareData:
  890. * The data you wish to pass to your comparison function.
  891. *
  892. * Result:
  893. * An event reference. The event is still in the queue when
  894. * FindSpecificEventInQueue returns; you can remove it from the
  895. * queue with RemoveEventFromQueue. The returned event does not need
  896. * to be released by the caller.
  897. *
  898. * Availability:
  899. * Non-Carbon CFM: not available
  900. * CarbonLib: in CarbonLib 1.1 and later
  901. * Mac OS X: in version 10.0 and later
  902. */
  903. EXTERN_API( EventRef )
  904. FindSpecificEventInQueue(
  905. EventQueueRef inQueue,
  906. EventComparatorUPP inComparator,
  907. void * inCompareData);
  908. /*
  909. * GetNumEventsInQueue()
  910. *
  911. * Discussion:
  912. * Returns the number of events in an event queue.
  913. *
  914. * Parameters:
  915. *
  916. * inQueue:
  917. * The event queue to query.
  918. *
  919. * Result:
  920. * The number of items in the queue.
  921. *
  922. * Availability:
  923. * Non-Carbon CFM: not available
  924. * CarbonLib: in CarbonLib 1.1 and later
  925. * Mac OS X: in version 10.0 and later
  926. */
  927. EXTERN_API( UInt32 )
  928. GetNumEventsInQueue(EventQueueRef inQueue);
  929. /*
  930. * RemoveEventFromQueue()
  931. *
  932. * Discussion:
  933. * Removes the given event from the queue which it was posted. When
  934. * you call this function, the event ownership is transferred to
  935. * you, the caller, at no charge. You must release the event when
  936. * you are through with it.
  937. *
  938. * Parameters:
  939. *
  940. * inQueue:
  941. * The queue to remove the event from.
  942. *
  943. * inEvent:
  944. * The event to remove.
  945. *
  946. * Result:
  947. * An operating system result code.
  948. *
  949. * Availability:
  950. * Non-Carbon CFM: not available
  951. * CarbonLib: in CarbonLib 1.1 and later
  952. * Mac OS X: in version 10.0 and later
  953. */
  954. EXTERN_API( OSStatus )
  955. RemoveEventFromQueue(
  956. EventQueueRef inQueue,
  957. EventRef inEvent);
  958. /*
  959. * IsEventInQueue()
  960. *
  961. * Discussion:
  962. * Returns true if the specified event is posted to a queue.
  963. *
  964. * Parameters:
  965. *
  966. * inQueue:
  967. * The queue to check.
  968. *
  969. * inEvent:
  970. * The event in question.
  971. *
  972. * Result:
  973. * A boolean value.
  974. *
  975. * Availability:
  976. * Non-Carbon CFM: not available
  977. * CarbonLib: in CarbonLib 1.1 and later
  978. * Mac OS X: in version 10.0 and later
  979. */
  980. EXTERN_API( Boolean )
  981. IsEventInQueue(
  982. EventQueueRef inQueue,
  983. EventRef inEvent);
  984. /*--------------------------------------------------------------------------------------*/
  985. /* Queue-synchronized event state */
  986. /*--------------------------------------------------------------------------------------*/
  987. /*
  988. * GetCurrentEvent()
  989. *
  990. * Summary:
  991. * Returns the user input event currently being handled.
  992. *
  993. * Discussion:
  994. * When an event with kEventAttributeUserEvent is dispatched by the
  995. * event dispatcher target, it is recorded internally by the Event
  996. * Manager. At any time during the handling of that event,
  997. * GetCurrentEvent may be used to retrieve the original EventRef.
  998. *
  999. * Result:
  1000. * The user input (mouse or keyboard) event currently being handled.
  1001. * May be NULL if no event is currently being handled, or if the
  1002. * current event was not a user input event. The returned event is
  1003. * not retained, and its lifetime should be considered to be no
  1004. * longer than the current function; if you need to keep the event
  1005. * alive past that time, you should retain it.
  1006. *
  1007. * Availability:
  1008. * Non-Carbon CFM: not available
  1009. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1010. * Mac OS X: in version 10.2 and later
  1011. */
  1012. EXTERN_API_C( EventRef )
  1013. GetCurrentEvent(void);
  1014. /*
  1015. * GetCurrentEventButtonState()
  1016. *
  1017. * Summary:
  1018. * Returns the current queue-synchronized mouse button state on the
  1019. * primary input device.
  1020. *
  1021. * Discussion:
  1022. * At any point in the handling of user input, there are two
  1023. * different mouse button states: the queue-synchronized state and
  1024. * the hardware state. The hardware state reflects the actual
  1025. * current state of the mouse attached to the user's machine. The
  1026. * queue-synchronized state reflects the state according to the
  1027. * events that have been processed at that point by the application.
  1028. * These two states may be different if there are unprocessed events
  1029. * in the event queue, or if events are being artificially
  1030. * introduced into the event queue from an outside source.
  1031. * GetCurrentEventButtonState returns the queue-synchronized button
  1032. * state. It is generally better to use this API than to use the
  1033. * Button function or the GetCurrentButtonState function (which
  1034. * return the hardware state). This gives a more consistent user
  1035. * experience when the user input queue is being remoted controlled
  1036. * or manipulated via non-hardware event sources such as speech or
  1037. * AppleEvents; using GetCurrentEventButtonState is also much faster
  1038. * than using Button or GetCurrentButtonState.
  1039. *
  1040. * Note that GetCurrentEventButtonState only returns a valid button
  1041. * state if your application is the active application. If your
  1042. * application is not active, then user input events are not flowing
  1043. * through the event dispatcher and the queue-synchronized state is
  1044. * not updated.
  1045. *
  1046. * Result:
  1047. * The queue-synchronized state of the mouse buttons. Bit zero
  1048. * indicates the state of the primary button, bit one the state of
  1049. * the secondary button, and so on.
  1050. *
  1051. * Availability:
  1052. * Non-Carbon CFM: not available
  1053. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1054. * Mac OS X: in version 10.2 and later
  1055. */
  1056. EXTERN_API_C( UInt32 )
  1057. GetCurrentEventButtonState(void);
  1058. /*
  1059. * GetCurrentEventKeyModifiers()
  1060. *
  1061. * Summary:
  1062. * Returns the current queue-synchronized keyboard modifier state.
  1063. *
  1064. * Discussion:
  1065. * At any point in the handling of user input, there are two
  1066. * different keyboard modifier states: the queue-synchronized state
  1067. * and the hardware state. The hardware state reflects the actual
  1068. * current state of the keyboard attached to the user's machine. The
  1069. * queue-synchronized state reflects the state according to the
  1070. * events that have been processed at that point by the application.
  1071. * These two states may be different if there are unprocessed events
  1072. * in the event queue, or if events are being artificially
  1073. * introduced into the event queue from an outside source.
  1074. * GetCurrentEventKeyModifiers returns the queue-synchronized
  1075. * modifier state. It is generally better to use this API than to
  1076. * use the GetCurrentKeyModifiers API (which returns the hardware
  1077. * state). This gives a more consistent user experience when the
  1078. * user input queue is being remoted controlled or manipulated via
  1079. * non-hardware event sources such as speech or AppleEvents; using
  1080. * GetCurrentEventKeyModifiers is also much faster than using
  1081. * EventAvail(0, &eventRecord) or GetCurrentKeyModifiers.
  1082. *
  1083. * Note that GetCurrentEventKeyModifiers only returns a valid
  1084. * modifier state if your application is the active application. If
  1085. * your application is not active, then user input events are not
  1086. * flowing through the event dispatcher and the queue-synchronized
  1087. * state is not updated.
  1088. *
  1089. * Result:
  1090. * The queue-synchronized state of the keyboard modifiers. The
  1091. * format of the return value is the same as the modifiers field of
  1092. * an EventRecord (but only includes keyboard modifiers and not the
  1093. * other modifier flags included in an EventRecord).
  1094. *
  1095. * Availability:
  1096. * Non-Carbon CFM: not available
  1097. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1098. * Mac OS X: in version 10.2 and later
  1099. */
  1100. EXTERN_API_C( UInt32 )
  1101. GetCurrentEventKeyModifiers(void);
  1102. /*--------------------------------------------------------------------------------------*/
  1103. /* Multiple-button support */
  1104. /*--------------------------------------------------------------------------------------*/
  1105. /*
  1106. * GetCurrentButtonState()
  1107. *
  1108. * Summary:
  1109. * Returns the current hardware mouse button state on the primary
  1110. * input device.
  1111. *
  1112. * Discussion:
  1113. * In most cases, you should not use GetCurrentButtonState, but
  1114. * should use the GetCurrentEventButtonState function instead.
  1115. * GetCurrentEventButtonState is much faster than
  1116. * GetCurrentButtonState because it returns the locally cached
  1117. * button state; GetCurrentButtonState must get the mouse button
  1118. * state from the window server, which is slower. Using
  1119. * GetCurrentButtonState also can prevent your application from
  1120. * being operated by remote posting of events, since the hardware
  1121. * input device is not actually changing state in that case. Most
  1122. * commonly, you might need to use GetCurrentButtonState when your
  1123. * application is not the active application (as determined by the
  1124. * Process Manager function GetFrontProcess). In that case, the
  1125. * cached button state returned by GetCurrentEventButtonState is not
  1126. * valid because mouse button events are not flowing to your
  1127. * application, and you must use GetCurrentButtonState to determine
  1128. * the current hardware state.
  1129. *
  1130. * Result:
  1131. * The state of the mouse buttons on the mouse hardware. Bit zero
  1132. * indicates the state of the primary button, bit one the state of
  1133. * the secondary button, and so on.
  1134. *
  1135. * Availability:
  1136. * Non-Carbon CFM: not available
  1137. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1138. * Mac OS X: in version 10.2 and later
  1139. */
  1140. EXTERN_API_C( UInt32 )
  1141. GetCurrentButtonState(void);
  1142. /*--------------------------------------------------------------------------------------*/
  1143. /* o Helpful utilities */
  1144. /*--------------------------------------------------------------------------------------*/
  1145. /*
  1146. * GetCurrentEventTime()
  1147. *
  1148. * Discussion:
  1149. * Returns the current time since last system startup in seconds.
  1150. *
  1151. * Result:
  1152. * EventTime.
  1153. *
  1154. * Availability:
  1155. * Non-Carbon CFM: not available
  1156. * CarbonLib: in CarbonLib 1.1 and later
  1157. * Mac OS X: in version 10.0 and later
  1158. */
  1159. EXTERN_API( EventTime )
  1160. GetCurrentEventTime(void);
  1161. /*--------------------------------------------------------------------------------------*/
  1162. /* o Timers */
  1163. /*--------------------------------------------------------------------------------------*/
  1164. /*
  1165. * EventLoopTimerRef
  1166. *
  1167. * Discussion:
  1168. * An EventLoopTimerRef represents what we term a 'timer'. A timer
  1169. * is a function that is called either once or at regular intervals.
  1170. * It executes at task level and should not be confused with Time
  1171. * Manager Tasks or any other interrupt-level callback. This means
  1172. * you can call Toolbox routines, allocate memory and draw. When a
  1173. * timer 'fires', it calls a callback that you specify when the
  1174. * timer is installed. Timers in general have two uses - as a
  1175. * timeout mechanism and as a periodic task. An everyday example of
  1176. * using a timer for a timeout might be a light that goes out if no
  1177. * motion is detected in a room for 5 minutes. For this, you might
  1178. * install a timer which will fire in 5 minutes. If motion is
  1179. * detected, you would reset the timer fire time and let the clock
  1180. * start over. If no motion is detected for the full 5 minutes, the
  1181. * timer will fire and you could power off the light. A periodic
  1182. * timer is one that fires at regular intervals (say every second or
  1183. * so). You might use such a timer to blink the insertion point in
  1184. * your editor, etc. One advantage of timers is that you can install
  1185. * the timer right from the code that wants the time. For example,
  1186. * the standard Toolbox Edit Text control can install a timer to
  1187. * blink the cursor when it's active, meaning that IdleControls is a
  1188. * no-op for that control and doesn't need to be called. When the
  1189. * control is inactive, it removes its timer and doesn't waste CPU
  1190. * time in that state. NOTE: Currently, if you do decide to draw
  1191. * when your timer is called, be sure to save and restore the
  1192. * current port so that calling your timer doesn't inadvertently
  1193. * change the port out from under someone.
  1194. */
  1195. typedef struct __EventLoopTimer* EventLoopTimerRef;
  1196. /*
  1197. * EventLoopTimerProcPtr
  1198. *
  1199. * Discussion:
  1200. * Called when a timer fires.
  1201. *
  1202. * Parameters:
  1203. *
  1204. * inTimer:
  1205. * The timer that fired.
  1206. *
  1207. * inUserData:
  1208. * The data passed into InstallEventLoopTimer.
  1209. */
  1210. typedef CALLBACK_API( void , EventLoopTimerProcPtr )(EventLoopTimerRef inTimer, void *inUserData);
  1211. /*
  1212. * Discussion:
  1213. * Event Loop Idle Timer Messages
  1214. */
  1215. enum {
  1216. /*
  1217. * The user has gone idle (not touched an input device) for the
  1218. * duration specified in your idle timer. This is the first message
  1219. * you will receive. Start your engines!
  1220. */
  1221. kEventLoopIdleTimerStarted = 1,
  1222. /*
  1223. * If you specified an interval on your idle timer, your idle timer
  1224. * proc will be called with this message, letting you know it is
  1225. * merely firing at the interval specified. If you did not specify an
  1226. * interval, this message is not sent.
  1227. */
  1228. kEventLoopIdleTimerIdling = 2,
  1229. /*
  1230. * The user is back! Stop everything! This is your cue to stop any
  1231. * processing if you need to.
  1232. */
  1233. kEventLoopIdleTimerStopped = 3
  1234. };
  1235. typedef UInt16 EventLoopIdleTimerMessage;
  1236. /*
  1237. * EventLoopIdleTimerProcPtr
  1238. *
  1239. * Discussion:
  1240. * Called when an idle timer fires.
  1241. *
  1242. * Parameters:
  1243. *
  1244. * inTimer:
  1245. * The timer that fired.
  1246. *
  1247. * inState:
  1248. * The current state of the timer.
  1249. *
  1250. * inUserData:
  1251. * The data passed into InstallEventLoopTimer.
  1252. */
  1253. typedef CALLBACK_API( void , EventLoopIdleTimerProcPtr )(EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void *inUserData);
  1254. typedef STACK_UPP_TYPE(EventLoopTimerProcPtr) EventLoopTimerUPP;
  1255. typedef STACK_UPP_TYPE(EventLoopIdleTimerProcPtr) EventLoopIdleTimerUPP;
  1256. /*
  1257. * NewEventLoopTimerUPP()
  1258. *
  1259. * Availability:
  1260. * Non-Carbon CFM: available as macro/inline
  1261. * CarbonLib: in CarbonLib 1.1 and later
  1262. * Mac OS X: in version 10.0 and later
  1263. */
  1264. EXTERN_API_C( EventLoopTimerUPP )
  1265. NewEventLoopTimerUPP(EventLoopTimerProcPtr userRoutine);
  1266. #if !OPAQUE_UPP_TYPES
  1267. enum { uppEventLoopTimerProcInfo = 0x000003C0 }; /* pascal no_return_value Func(4_bytes, 4_bytes) */
  1268. #ifdef __cplusplus
  1269. inline DEFINE_API_C(EventLoopTimerUPP) NewEventLoopTimerUPP(EventLoopTimerProcPtr userRoutine) { return (EventLoopTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopTimerProcInfo, GetCurrentArchitecture()); }
  1270. #else
  1271. #define NewEventLoopTimerUPP(userRoutine) (EventLoopTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopTimerProcInfo, GetCurrentArchitecture())
  1272. #endif
  1273. #endif
  1274. #if CALL_NOT_IN_CARBON
  1275. /*
  1276. * NewEventLoopIdleTimerUPP()
  1277. *
  1278. * Availability:
  1279. * Non-Carbon CFM: available as macro/inline
  1280. * CarbonLib: not available
  1281. * Mac OS X: in version 10.0 and later
  1282. */
  1283. EXTERN_API_C( EventLoopIdleTimerUPP )
  1284. NewEventLoopIdleTimerUPP(EventLoopIdleTimerProcPtr userRoutine);
  1285. #if !OPAQUE_UPP_TYPES
  1286. enum { uppEventLoopIdleTimerProcInfo = 0x00000EC0 }; /* pascal no_return_value Func(4_bytes, 2_bytes, 4_bytes) */
  1287. #ifdef __cplusplus
  1288. inline DEFINE_API_C(EventLoopIdleTimerUPP) NewEventLoopIdleTimerUPP(EventLoopIdleTimerProcPtr userRoutine) { return (EventLoopIdleTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopIdleTimerProcInfo, GetCurrentArchitecture()); }
  1289. #else
  1290. #define NewEventLoopIdleTimerUPP(userRoutine) (EventLoopIdleTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopIdleTimerProcInfo, GetCurrentArchitecture())
  1291. #endif
  1292. #endif
  1293. #endif /* CALL_NOT_IN_CARBON */
  1294. /*
  1295. * DisposeEventLoopTimerUPP()
  1296. *
  1297. * Availability:
  1298. * Non-Carbon CFM: available as macro/inline
  1299. * CarbonLib: in CarbonLib 1.1 and later
  1300. * Mac OS X: in version 10.0 and later
  1301. */
  1302. EXTERN_API_C( void )
  1303. DisposeEventLoopTimerUPP(EventLoopTimerUPP userUPP);
  1304. #if !OPAQUE_UPP_TYPES
  1305. #ifdef __cplusplus
  1306. inline DEFINE_API_C(void) DisposeEventLoopTimerUPP(EventLoopTimerUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  1307. #else
  1308. #define DisposeEventLoopTimerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  1309. #endif
  1310. #endif
  1311. #if CALL_NOT_IN_CARBON
  1312. /*
  1313. * DisposeEventLoopIdleTimerUPP()
  1314. *
  1315. * Availability:
  1316. * Non-Carbon CFM: available as macro/inline
  1317. * CarbonLib: not available
  1318. * Mac OS X: in version 10.0 and later
  1319. */
  1320. EXTERN_API_C( void )
  1321. DisposeEventLoopIdleTimerUPP(EventLoopIdleTimerUPP userUPP);
  1322. #if !OPAQUE_UPP_TYPES
  1323. #ifdef __cplusplus
  1324. inline DEFINE_API_C(void) DisposeEventLoopIdleTimerUPP(EventLoopIdleTimerUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  1325. #else
  1326. #define DisposeEventLoopIdleTimerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  1327. #endif
  1328. #endif
  1329. #endif /* CALL_NOT_IN_CARBON */
  1330. /*
  1331. * InvokeEventLoopTimerUPP()
  1332. *
  1333. * Availability:
  1334. * Non-Carbon CFM: available as macro/inline
  1335. * CarbonLib: in CarbonLib 1.1 and later
  1336. * Mac OS X: in version 10.0 and later
  1337. */
  1338. EXTERN_API_C( void )
  1339. InvokeEventLoopTimerUPP(
  1340. EventLoopTimerRef inTimer,
  1341. void * inUserData,
  1342. EventLoopTimerUPP userUPP);
  1343. #if !OPAQUE_UPP_TYPES
  1344. #ifdef __cplusplus
  1345. inline DEFINE_API_C(void) InvokeEventLoopTimerUPP(EventLoopTimerRef inTimer, void * inUserData, EventLoopTimerUPP userUPP) { CALL_TWO_PARAMETER_UPP(userUPP, uppEventLoopTimerProcInfo, inTimer, inUserData); }
  1346. #else
  1347. #define InvokeEventLoopTimerUPP(inTimer, inUserData, userUPP) CALL_TWO_PARAMETER_UPP((userUPP), uppEventLoopTimerProcInfo, (inTimer), (inUserData))
  1348. #endif
  1349. #endif
  1350. #if CALL_NOT_IN_CARBON
  1351. /*
  1352. * InvokeEventLoopIdleTimerUPP()
  1353. *
  1354. * Availability:
  1355. * Non-Carbon CFM: available as macro/inline
  1356. * CarbonLib: not available
  1357. * Mac OS X: in version 10.0 and later
  1358. */
  1359. EXTERN_API_C( void )
  1360. InvokeEventLoopIdleTimerUPP(
  1361. EventLoopTimerRef inTimer,
  1362. EventLoopIdleTimerMessage inState,
  1363. void * inUserData,
  1364. EventLoopIdleTimerUPP userUPP);
  1365. #if !OPAQUE_UPP_TYPES
  1366. #ifdef __cplusplus
  1367. inline DEFINE_API_C(void) InvokeEventLoopIdleTimerUPP(EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void * inUserData, EventLoopIdleTimerUPP userUPP) { CALL_THREE_PARAMETER_UPP(userUPP, uppEventLoopIdleTimerProcInfo, inTimer, inState, inUserData); }
  1368. #else
  1369. #define InvokeEventLoopIdleTimerUPP(inTimer, inState, inUserData, userUPP) CALL_THREE_PARAMETER_UPP((userUPP), uppEventLoopIdleTimerProcInfo, (inTimer), (inState), (inUserData))
  1370. #endif
  1371. #endif
  1372. #endif /* CALL_NOT_IN_CARBON */
  1373. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  1374. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  1375. #define NewEventLoopTimerProc(userRoutine) NewEventLoopTimerUPP(userRoutine)
  1376. #define NewEventLoopIdleTimerProc(userRoutine) NewEventLoopIdleTimerUPP(userRoutine)
  1377. #define CallEventLoopTimerProc(userRoutine, inTimer, inUserData) InvokeEventLoopTimerUPP(inTimer, inUserData, userRoutine)
  1378. #define CallEventLoopIdleTimerProc(userRoutine, inTimer, inState, inUserData) InvokeEventLoopIdleTimerUPP(inTimer, inState, inUserData, userRoutine)
  1379. #endif /* CALL_NOT_IN_CARBON */
  1380. /*
  1381. * InstallEventLoopTimer()
  1382. *
  1383. * Discussion:
  1384. * Installs a timer onto the event loop specified. The timer can
  1385. * either fire once or repeatedly at a specified interval depending
  1386. * on the parameters passed to this function.
  1387. *
  1388. * Parameters:
  1389. *
  1390. * inEventLoop:
  1391. * The event loop to add the timer.
  1392. *
  1393. * inFireDelay:
  1394. * The delay before first firing this timer (can be 0, to request
  1395. * that the timer be fired as soon as control returns to your
  1396. * event loop). In Mac OS X and CarbonLib 1.5 and later, you may
  1397. * pass kEventDurationForever to stop the timer from firing at all
  1398. * until SetEventLoopTimerNextFireTime is used to start it; in
  1399. * earlier CarbonLibs, to achieve the same effect, just pass zero
  1400. * and then immediately call SetEventLoopTimerNextFireTime( timer,
  1401. * kEventDurationForever ) before returning control to your event
  1402. * loop.
  1403. *
  1404. * inInterval:
  1405. * The timer interval (pass 0 for a one-shot timer, which executes
  1406. * once but does not repeat). In Mac OS X and CarbonLib 1.5 and
  1407. * later, you may also pass kEventDurationForever to create a
  1408. * one-shot timer.
  1409. *
  1410. * inTimerProc:
  1411. * The routine to call when the timer fires.
  1412. *
  1413. * inTimerData:
  1414. * Data to pass to the timer proc when called.
  1415. *
  1416. * outTimer:
  1417. * A reference to the newly installed timer.
  1418. *
  1419. * Result:
  1420. * An operating system status code.
  1421. *
  1422. * Availability:
  1423. * Non-Carbon CFM: not available
  1424. * CarbonLib: in CarbonLib 1.1 and later
  1425. * Mac OS X: in version 10.0 and later
  1426. */
  1427. EXTERN_API( OSStatus )
  1428. InstallEventLoopTimer(
  1429. EventLoopRef inEventLoop,
  1430. EventTimerInterval inFireDelay,
  1431. EventTimerInterval inInterval,
  1432. EventLoopTimerUPP inTimerProc,
  1433. void * inTimerData,
  1434. EventLoopTimerRef * outTimer);
  1435. /*
  1436. * InstallEventLoopIdleTimer()
  1437. *
  1438. * Discussion:
  1439. * Installs a timer onto the event loop specified. Idle timers are
  1440. * only called when there is no user activity occuring in the
  1441. * application. This means that the user is not actively
  1442. * clicking/typing, and is also not in the middle of tracking a
  1443. * control, menu, or window. TrackMouseLocation actually disables
  1444. * all idle timers automatically for you.
  1445. *
  1446. * Parameters:
  1447. *
  1448. * inEventLoop:
  1449. * The event loop to add the timer.
  1450. *
  1451. * inDelay:
  1452. * The delay before firing this timer after a user input event has
  1453. * come in. For example, if you want to start your timer 2 seconds
  1454. * after the user stops typing, etc. you would pass 2.0 into this
  1455. * parameter. Each time the user types a key (or whatever), this
  1456. * timer is reset. If we are considered to be idle when an idle
  1457. * timer is installed, the first time it fires will be inDelay
  1458. * seconds from the time it is installed. So if you installed it
  1459. * in the middle of control tracking, say, it wouldn't fire until
  1460. * the user stopped tracking. But if you installed it at app
  1461. * startup and the user hasn't typed/clicked, it would fire in
  1462. * inDelay seconds.
  1463. *
  1464. * inInterval:
  1465. * The timer interval (pass 0 for a one-shot timer, which executes
  1466. * once but does not repeat). You may also pass
  1467. * kEventDurationForever to create a one-shot timer.
  1468. *
  1469. * inTimerProc:
  1470. * The routine to call when the timer fires.
  1471. *
  1472. * inTimerData:
  1473. * Data to pass to the timer proc when called.
  1474. *
  1475. * outTimer:
  1476. * A reference to the newly installed timer.
  1477. *
  1478. * Result:
  1479. * An operating system status code.
  1480. *
  1481. * Availability:
  1482. * Non-Carbon CFM: not available
  1483. * CarbonLib: in CarbonLib 1.1 and later
  1484. * Mac OS X: in version 10.0 and later
  1485. */
  1486. EXTERN_API( OSStatus )
  1487. InstallEventLoopIdleTimer(
  1488. EventLoopRef inEventLoop,
  1489. EventTimerInterval inDelay,
  1490. EventTimerInterval inInterval,
  1491. EventLoopIdleTimerUPP inTimerProc,
  1492. void * inTimerData,
  1493. EventLoopTimerRef * outTimer);
  1494. /* GOING AWAY!!!! DO NOT CALL THIS API!!!!! USE INSTALLEVENTLOOPIDLETIMER ABOVE!!!! */
  1495. /*
  1496. * InstallIdleTimer()
  1497. *
  1498. * Availability:
  1499. * Non-Carbon CFM: not available
  1500. * CarbonLib: in CarbonLib 1.1 and later
  1501. * Mac OS X: in version 10.0 and later
  1502. */
  1503. EXTERN_API( OSStatus )
  1504. InstallIdleTimer(
  1505. EventLoopRef inEventLoop,
  1506. EventTimerInterval inDelay,
  1507. EventTimerInterval inInterval,
  1508. EventLoopTimerUPP inTimerProc,
  1509. void * inTimerData,
  1510. EventLoopTimerRef * outTimer);
  1511. /*
  1512. * RemoveEventLoopTimer()
  1513. *
  1514. * Discussion:
  1515. * Removes a timer that was previously installed by a call to
  1516. * InstallEventLoopTimer. You call this function when you are done
  1517. * using a timer.
  1518. *
  1519. * Parameters:
  1520. *
  1521. * inTimer:
  1522. * The timer to remove.
  1523. *
  1524. * Result:
  1525. * An operating system status code.
  1526. *
  1527. * Availability:
  1528. * Non-Carbon CFM: not available
  1529. * CarbonLib: in CarbonLib 1.1 and later
  1530. * Mac OS X: in version 10.0 and later
  1531. */
  1532. EXTERN_API( OSStatus )
  1533. RemoveEventLoopTimer(EventLoopTimerRef inTimer);
  1534. /*
  1535. * SetEventLoopTimerNextFireTime()
  1536. *
  1537. * Discussion:
  1538. * This routine is used to 'reset' a timer. It controls the next
  1539. * time the timer fires. This will override any interval you might
  1540. * have set. For example, if you have a timer that fires every
  1541. * second, and you call this function setting the next time to five
  1542. * seconds from now, the timer will sleep for five seconds, then
  1543. * fire. It will then resume its one-second interval after that. It
  1544. * is as if you removed the timer and reinstalled it with a new
  1545. * first-fire delay.
  1546. *
  1547. * Parameters:
  1548. *
  1549. * inTimer:
  1550. * The timer to adjust
  1551. *
  1552. * inNextFire:
  1553. * The interval from the current time to wait until firing the
  1554. * timer again. You may pass kEventDurationForever to stop the
  1555. * timer from firing at all.
  1556. *
  1557. * Result:
  1558. * An operating system status code.
  1559. *
  1560. * Availability:
  1561. * Non-Carbon CFM: not available
  1562. * CarbonLib: in CarbonLib 1.1 and later
  1563. * Mac OS X: in version 10.0 and later
  1564. */
  1565. EXTERN_API( OSStatus )
  1566. SetEventLoopTimerNextFireTime(
  1567. EventLoopTimerRef inTimer,
  1568. EventTimerInterval inNextFire);
  1569. /*======================================================================================*/
  1570. /* EVENT HANDLERS */
  1571. /*======================================================================================*/
  1572. typedef struct OpaqueEventHandlerRef* EventHandlerRef;
  1573. typedef struct OpaqueEventHandlerCallRef* EventHandlerCallRef;
  1574. /*--------------------------------------------------------------------------------------*/
  1575. /* o EventHandler specification */
  1576. /*--------------------------------------------------------------------------------------*/
  1577. /*
  1578. * EventHandlerProcPtr
  1579. *
  1580. * Discussion:
  1581. * Callback for receiving events sent to a target this callback is
  1582. * installed on.
  1583. *
  1584. * Parameters:
  1585. *
  1586. * inHandlerCallRef:
  1587. * A reference to the current handler call chain. This is sent to
  1588. * your handler so that you can call CallNextEventHandler if you
  1589. * need to.
  1590. *
  1591. * inEvent:
  1592. * The Event.
  1593. *
  1594. * inUserData:
  1595. * The app-specified data you passed in a call to
  1596. * InstallEventHandler.
  1597. *
  1598. * Result:
  1599. * An operating system result code. Returning noErr indicates you
  1600. * handled the event. Returning eventNotHandledErr indicates you did
  1601. * not handle the event and perhaps the toolbox should take other
  1602. * action.
  1603. */
  1604. typedef CALLBACK_API( OSStatus , EventHandlerProcPtr )(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
  1605. typedef STACK_UPP_TYPE(EventHandlerProcPtr) EventHandlerUPP;
  1606. /*
  1607. * NewEventHandlerUPP()
  1608. *
  1609. * Availability:
  1610. * Non-Carbon CFM: available as macro/inline
  1611. * CarbonLib: in CarbonLib 1.1 and later
  1612. * Mac OS X: in version 10.0 and later
  1613. */
  1614. EXTERN_API_C( EventHandlerUPP )
  1615. NewEventHandlerUPP(EventHandlerProcPtr userRoutine);
  1616. #if !OPAQUE_UPP_TYPES
  1617. enum { uppEventHandlerProcInfo = 0x00000FF0 }; /* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  1618. #ifdef __cplusplus
  1619. inline DEFINE_API_C(EventHandlerUPP) NewEventHandlerUPP(EventHandlerProcPtr userRoutine) { return (EventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventHandlerProcInfo, GetCurrentArchitecture()); }
  1620. #else
  1621. #define NewEventHandlerUPP(userRoutine) (EventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventHandlerProcInfo, GetCurrentArchitecture())
  1622. #endif
  1623. #endif
  1624. /*
  1625. * DisposeEventHandlerUPP()
  1626. *
  1627. * Availability:
  1628. * Non-Carbon CFM: available as macro/inline
  1629. * CarbonLib: in CarbonLib 1.1 and later
  1630. * Mac OS X: in version 10.0 and later
  1631. */
  1632. EXTERN_API_C( void )
  1633. DisposeEventHandlerUPP(EventHandlerUPP userUPP);
  1634. #if !OPAQUE_UPP_TYPES
  1635. #ifdef __cplusplus
  1636. inline DEFINE_API_C(void) DisposeEventHandlerUPP(EventHandlerUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
  1637. #else
  1638. #define DisposeEventHandlerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
  1639. #endif
  1640. #endif
  1641. /*
  1642. * InvokeEventHandlerUPP()
  1643. *
  1644. * Availability:
  1645. * Non-Carbon CFM: available as macro/inline
  1646. * CarbonLib: in CarbonLib 1.1 and later
  1647. * Mac OS X: in version 10.0 and later
  1648. */
  1649. EXTERN_API_C( OSStatus )
  1650. InvokeEventHandlerUPP(
  1651. EventHandlerCallRef inHandlerCallRef,
  1652. EventRef inEvent,
  1653. void * inUserData,
  1654. EventHandlerUPP userUPP);
  1655. #if !OPAQUE_UPP_TYPES
  1656. #ifdef __cplusplus
  1657. inline DEFINE_API_C(OSStatus) InvokeEventHandlerUPP(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData, EventHandlerUPP userUPP) { return (OSStatus)CALL_THREE_PARAMETER_UPP(userUPP, uppEventHandlerProcInfo, inHandlerCallRef, inEvent, inUserData); }
  1658. #else
  1659. #define InvokeEventHandlerUPP(inHandlerCallRef, inEvent, inUserData, userUPP) (OSStatus)CALL_THREE_PARAMETER_UPP((userUPP), uppEventHandlerProcInfo, (inHandlerCallRef), (inEvent), (inUserData))
  1660. #endif
  1661. #endif
  1662. #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
  1663. /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
  1664. #define NewEventHandlerProc(userRoutine) NewEventHandlerUPP(userRoutine)
  1665. #define CallEventHandlerProc(userRoutine, inHandlerCallRef, inEvent, inUserData) InvokeEventHandlerUPP(inHandlerCallRef, inEvent, inUserData, userRoutine)
  1666. #endif /* CALL_NOT_IN_CARBON */
  1667. typedef struct OpaqueEventTargetRef* EventTargetRef;
  1668. /*--------------------------------------------------------------------------------------*/
  1669. /* o Installing Event Handlers */
  1670. /* */
  1671. /* Use these routines to install event handlers for a specific toolbox object. You may */
  1672. /* pass zero for inNumTypes and NULL for inList if you need to be in a situation where */
  1673. /* you know you will be receiving events, but not exactly which ones at the time you */
  1674. /* are installing the handler. Later, your application can call the Add/Remove routines */
  1675. /* listed below this section. */
  1676. /* */
  1677. /* You can only install a specific handler once. The combination of inHandler and */
  1678. /* inUserData is considered the 'signature' of a handler. Any attempt to install a new */
  1679. /* handler with the same proc and user data as an already-installed handler will result */
  1680. /* in eventHandlerAlreadyInstalledErr. Installing the same proc and user data on a */
  1681. /* different object is legal. */
  1682. /* */
  1683. /* Upon successful completion of this routine, you are returned an EventHandlerRef, */
  1684. /* which you can use in various other calls, and is passed to your event handler. You */
  1685. /* use it to extract information about the handler, such as the target (window, etc.) */
  1686. /* if you have the same handler installed for different objects and need to perform */
  1687. /* actions on the current target (say, call a window manager function). */
  1688. /*--------------------------------------------------------------------------------------*/
  1689. /*
  1690. * InstallEventHandler()
  1691. *
  1692. * Discussion:
  1693. * Installs an event handler on a specified target. Your handler
  1694. * proc will be called with the events you registered with when an
  1695. * event of the corresponding type and class are send to the target
  1696. * you are installing your handler on.
  1697. *
  1698. * Parameters:
  1699. *
  1700. * inTarget:
  1701. * The target to register your handler with.
  1702. *
  1703. * inHandler:
  1704. * A pointer to your handler function.
  1705. *
  1706. * inNumTypes:
  1707. * The number of events you are registering for.
  1708. *
  1709. * inList:
  1710. * A pointer to an array of EventTypeSpec entries representing the
  1711. * events you are interested in.
  1712. *
  1713. * inUserData:
  1714. * The value passed in this parameter is passed on to your event
  1715. * handler proc when it is called.
  1716. *
  1717. * outRef:
  1718. * Receives an EventHandlerRef, which you can use later to remove
  1719. * the handler. You can pass null if you don't want the reference
  1720. * - when the target is disposed, the handler will be disposed as
  1721. * well.
  1722. *
  1723. * Result:
  1724. * An operating system result code.
  1725. *
  1726. * Availability:
  1727. * Non-Carbon CFM: not available
  1728. * CarbonLib: in CarbonLib 1.1 and later
  1729. * Mac OS X: in version 10.0 and later
  1730. */
  1731. EXTERN_API( OSStatus )
  1732. InstallEventHandler(
  1733. EventTargetRef inTarget,
  1734. EventHandlerUPP inHandler,
  1735. UInt32 inNumTypes,
  1736. const EventTypeSpec * inList,
  1737. void * inUserData,
  1738. EventHandlerRef * outRef); /* can be NULL */
  1739. /*
  1740. * InstallStandardEventHandler()
  1741. *
  1742. * Availability:
  1743. * Non-Carbon CFM: not available
  1744. * CarbonLib: in CarbonLib 1.1 and later
  1745. * Mac OS X: in version 10.0 and later
  1746. */
  1747. EXTERN_API( OSStatus )
  1748. InstallStandardEventHandler(EventTargetRef inTarget);
  1749. /*
  1750. * RemoveEventHandler()
  1751. *
  1752. * Discussion:
  1753. * Removes an event handler from the target it was bound to.
  1754. *
  1755. * Parameters:
  1756. *
  1757. * inHandlerRef:
  1758. * The handler ref to remove (returned in a call to
  1759. * InstallEventHandler). After you call this function, the handler
  1760. * ref is considered to be invalid and can no longer be used.
  1761. *
  1762. * Result:
  1763. * An operating system result code.
  1764. *
  1765. * Availability:
  1766. * Non-Carbon CFM: not available
  1767. * CarbonLib: in CarbonLib 1.1 and later
  1768. * Mac OS X: in version 10.0 and later
  1769. */
  1770. EXTERN_API( OSStatus )
  1771. RemoveEventHandler(EventHandlerRef inHandlerRef);
  1772. /*--------------------------------------------------------------------------------------*/
  1773. /* o Adjusting set of event types after a handler is created */
  1774. /* */
  1775. /* After installing a handler with the routine above, you can adjust the event type */
  1776. /* list telling the toolbox what events to send to that handler by calling the two */
  1777. /* routines below. If you add an event type twice for the same handler, your handler */
  1778. /* will only be called once, but it will take two RemoveEventType calls to stop your */
  1779. /* handler from being called with that event type. In other words, the install count */
  1780. /* for each event type is maintained by the toolbox. This might allow you, for example */
  1781. /* to have subclasses of a window object register for types without caring if the base */
  1782. /* class has already registered for that type. When the subclass removes its types, it */
  1783. /* can successfully do so without affecting the base class's reception of its event */
  1784. /* types, yielding eternal bliss. */
  1785. /*--------------------------------------------------------------------------------------*/
  1786. /*
  1787. * AddEventTypesToHandler()
  1788. *
  1789. * Discussion:
  1790. * Adds additional events to an event handler that has already been
  1791. * installed.
  1792. *
  1793. * Parameters:
  1794. *
  1795. * inHandlerRef:
  1796. * The event handler to add the additional events to.
  1797. *
  1798. * inNumTypes:
  1799. * The number of events to add.
  1800. *
  1801. * inList:
  1802. * A pointer to an array of EventTypeSpec entries.
  1803. *
  1804. * Result:
  1805. * An operating system result code.
  1806. *
  1807. * Availability:
  1808. * Non-Carbon CFM: not available
  1809. * CarbonLib: in CarbonLib 1.1 and later
  1810. * Mac OS X: in version 10.0 and later
  1811. */
  1812. EXTERN_API( OSStatus )
  1813. AddEventTypesToHandler(
  1814. EventHandlerRef inHandlerRef,
  1815. UInt32 inNumTypes,
  1816. const EventTypeSpec * inList);
  1817. /*
  1818. * RemoveEventTypesFromHandler()
  1819. *
  1820. * Discussion:
  1821. * Removes events from an event handler that has already been
  1822. * installed.
  1823. *
  1824. * Parameters:
  1825. *
  1826. * inHandlerRef:
  1827. * The event handler to remove the events from.
  1828. *
  1829. * inNumTypes:
  1830. * The number of events to remove.
  1831. *
  1832. * inList:
  1833. * A pointer to an array of EventTypeSpec entries.
  1834. *
  1835. * Result:
  1836. * An operating system status code.
  1837. *
  1838. * Availability:
  1839. * Non-Carbon CFM: not available
  1840. * CarbonLib: in CarbonLib 1.1 and later
  1841. * Mac OS X: in version 10.0 and later
  1842. */
  1843. EXTERN_API( OSStatus )
  1844. RemoveEventTypesFromHandler(
  1845. EventHandlerRef inHandlerRef,
  1846. UInt32 inNumTypes,
  1847. const EventTypeSpec * inList);
  1848. /*--------------------------------------------------------------------------------------*/
  1849. /* o Explicit Propogation */
  1850. /* */
  1851. /* CallNextEventHandler can be used to call thru to all handlers below the current */
  1852. /* handler being called. You pass the EventHandlerCallRef passed to your EventHandler */
  1853. /* into this call so that we know how to properly forward the event. The result of */
  1854. /* this function should normally be the result of your own handler that you called */
  1855. /* this API from. The typical use of this routine would be to allow the toolbox to do */
  1856. /* its standard processing and then follow up with some type of embellishment. */
  1857. /*--------------------------------------------------------------------------------------*/
  1858. /*
  1859. * CallNextEventHandler()
  1860. *
  1861. * Discussion:
  1862. * Calls thru to the event handlers below you in the event handler
  1863. * stack of the target to which your handler is bound. You might use
  1864. * this to call thru to the default toolbox handling in order to
  1865. * post-process the event. You can only call this routine from
  1866. * within an event handler.
  1867. *
  1868. * Parameters:
  1869. *
  1870. * inCallRef:
  1871. * The event handler call ref passed into your event handler.
  1872. *
  1873. * inEvent:
  1874. * The event to pass thru.
  1875. *
  1876. * Result:
  1877. * An operating system result code.
  1878. *
  1879. * Availability:
  1880. * Non-Carbon CFM: not available
  1881. * CarbonLib: in CarbonLib 1.1 and later
  1882. * Mac OS X: in version 10.0 and later
  1883. */
  1884. EXTERN_API( OSStatus )
  1885. CallNextEventHandler(
  1886. EventHandlerCallRef inCallRef,
  1887. EventRef inEvent);
  1888. /*--------------------------------------------------------------------------------------*/
  1889. /* o Sending Events */
  1890. /*--------------------------------------------------------------------------------------*/
  1891. /*
  1892. * Discussion:
  1893. * EventTarget Send Options
  1894. */
  1895. enum {
  1896. /*
  1897. * The event should be sent to the target given only, and should not
  1898. * propagate to any other target. CallNextEventHandler will do
  1899. * nothing in a handler which has received an event sent in this
  1900. * manner.
  1901. */
  1902. kEventTargetDontPropagate = (1 << 0),
  1903. /*
  1904. * The event is a notification-style event, and should be received by
  1905. * all handlers. The result is usually meaningless when sent in this
  1906. * manner, though we do maintain the strongest result code while the
  1907. * event falls through each handler. This means that if the first
  1908. * handler to receive the event returned noErr, and the next returned
  1909. * eventNotHandledErr, the result returned would actually be noErr.
  1910. * No handler can stop this event from propagating, i.e. the result
  1911. * code does not alter event flow.
  1912. */
  1913. kEventTargetSendToAllHandlers = (1 << 1)
  1914. };
  1915. /*
  1916. * SendEventToEventTarget()
  1917. *
  1918. * Discussion:
  1919. * Sends an event to the specified event target.
  1920. *
  1921. * Parameters:
  1922. *
  1923. * inEvent:
  1924. * The event to send.
  1925. *
  1926. * inTarget:
  1927. * The target to send it to.
  1928. *
  1929. * Result:
  1930. * An operating system result code.
  1931. *
  1932. * Availability:
  1933. * Non-Carbon CFM: not available
  1934. * CarbonLib: in CarbonLib 1.1 and later
  1935. * Mac OS X: in version 10.0 and later
  1936. */
  1937. EXTERN_API( OSStatus )
  1938. SendEventToEventTarget(
  1939. EventRef inEvent,
  1940. EventTargetRef inTarget);
  1941. /*
  1942. * SendEventToEventTargetWithOptions()
  1943. *
  1944. * Discussion:
  1945. * Sends an event to the specified event target, optionally
  1946. * controlling how the event propagates. See the discussion of the
  1947. * event send options above for more detail.
  1948. *
  1949. * Parameters:
  1950. *
  1951. * inEvent:
  1952. * The event to send.
  1953. *
  1954. * inTarget:
  1955. * The target to send it to.
  1956. *
  1957. * inOptions:
  1958. * The options to modify the send behavior. Passing zero for this
  1959. * makes it behave just like SendEventToEventTarget.
  1960. *
  1961. * Result:
  1962. * An operating system result code.
  1963. *
  1964. * Availability:
  1965. * Non-Carbon CFM: not available
  1966. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  1967. * Mac OS X: in version 10.2 and later
  1968. */
  1969. EXTERN_API_C( OSStatus )
  1970. SendEventToEventTargetWithOptions(
  1971. EventRef inEvent,
  1972. EventTargetRef inTarget,
  1973. OptionBits inOptions);
  1974. #if PRAGMA_STRUCT_ALIGN
  1975. #pragma options align=reset
  1976. #elif PRAGMA_STRUCT_PACKPUSH
  1977. #pragma pack(pop)
  1978. #elif PRAGMA_STRUCT_PACK
  1979. #pragma pack()
  1980. #endif
  1981. #ifdef PRAGMA_IMPORT_OFF
  1982. #pragma import off
  1983. #elif PRAGMA_IMPORT
  1984. #pragma import reset
  1985. #endif
  1986. #ifdef __cplusplus
  1987. }
  1988. #endif
  1989. #endif /* __CARBONEVENTSCORE__ */