Mac OS 9
Events.h
Go to the documentation of this file.
1 
19 #ifndef __EVENTS__
20 #define __EVENTS__
21 
22 #ifndef __OSUTILS__
23 #include <OSUtils.h>
24 #endif
25 
26 #ifndef __QUICKDRAW__
27 #include <Quickdraw.h>
28 #endif
29 
30 #ifndef __MACTYPES__
31 #include <MacTypes.h>
32 #endif
33 
34 #if !TARGET_OS_MAC || !TARGET_API_MAC_OS8
35 #ifndef __ENDIAN__
36 #include <Endian.h>
37 #endif
38 
39 #endif
41 #if PRAGMA_ONCE
42 #pragma once
43 #endif
44 
45 #ifdef __cplusplus
46 extern "C"
47 {
48 #endif
49 
50 #if PRAGMA_IMPORT
51 #pragma import on
52 #endif
53 
54 #if PRAGMA_STRUCT_ALIGN
55 #pragma options align = mac68k
56 #elif PRAGMA_STRUCT_PACKPUSH
57 #pragma pack(push, 2)
58 #elif PRAGMA_STRUCT_PACK
59 #pragma pack(2)
60 #endif
61 
62  typedef UInt16 EventKind;
63  typedef UInt16 EventMask;
64  enum
65  {
66  nullEvent = 0,
67  mouseDown = 1,
68  mouseUp = 2,
69  keyDown = 3,
70  keyUp = 4,
71  autoKey = 5,
72  updateEvt = 6,
73  diskEvt = 7,
75  osEvt = 15,
76  kHighLevelEvent = 23
77  };
78 
79  enum
80  {
81  mDownMask = 1 << mouseDown,
82  mUpMask = 1 << mouseUp,
83  keyDownMask = 1 << keyDown,
84  keyUpMask = 1 << keyUp,
85  autoKeyMask = 1 << autoKey,
86  updateMask = 1 << updateEvt,
87  diskMask = 1 << diskEvt,
89  highLevelEventMask = 0x0400,
90  osMask = 1 << osEvt,
91  everyEvent = 0xFFFF
92  };
93 
94  enum
95  {
96  charCodeMask = 0x000000FF,
97  keyCodeMask = 0x0000FF00,
98  adbAddrMask = 0x00FF0000,
99  osEvtMessageMask = (unsigned long)0xFF000000
100  };
101 
102  enum
103  {
107  suspendResumeMessage = 0x0001
108  };
109 
110  enum
111  {
112  resumeFlag = 1
113  };
114 
115 #if CALL_NOT_IN_CARBON
125  enum
126  {
127  convertClipboardFlag =
128  2
129  };
130 
131 #endif
145  typedef UInt16 EventModifiers;
146  enum
147  {
151  cmdKeyBit = 8,
158  rightControlKeyBit = 15
159  };
160 
161  enum
162  {
163  activeFlag = 1 << activeFlagBit,
164  btnState = 1 << btnStateBit,
165  cmdKey = 1 << cmdKeyBit,
166  shiftKey = 1 << shiftKeyBit,
167  alphaLock = 1 << alphaLockBit,
168  optionKey = 1 << optionKeyBit,
169  controlKey = 1 << controlKeyBit,
170  rightShiftKey = 1 << rightShiftKeyBit,
171  rightOptionKey = 1 << rightOptionKeyBit,
172  rightControlKey = 1 << rightControlKeyBit
173  };
174 
176  enum
177  {
178  kNullCharCode = 0,
179  kHomeCharCode = 1,
180  kEnterCharCode = 3,
181  kEndCharCode = 4,
182  kHelpCharCode = 5,
183  kBellCharCode = 7,
184  kBackspaceCharCode = 8,
185  kTabCharCode = 9,
186  kLineFeedCharCode = 10,
187  kVerticalTabCharCode = 11,
188  kPageUpCharCode = 11,
189  kFormFeedCharCode = 12,
190  kPageDownCharCode = 12,
191  kReturnCharCode = 13,
192  kFunctionKeyCharCode = 16,
193  kCommandCharCode = 17,
198  kClearCharCode = 27,
199  kLeftArrowCharCode = 28,
200  kRightArrowCharCode = 29,
201  kUpArrowCharCode = 30,
202  kDownArrowCharCode = 31,
203  kSpaceCharCode = 32,
204  kDeleteCharCode = 127,
205  kBulletCharCode = 165,
206  kNonBreakingSpaceCharCode = 202
207  };
208 
210  enum
211  {
212  kShiftUnicode = 0x21E7,
213  kControlUnicode = 0x2303,
214  kOptionUnicode = 0x2325,
215  kCommandUnicode = 0x2318,
216  kPencilUnicode = 0x270E,
217  kCheckUnicode = 0x2713,
218  kDiamondUnicode = 0x25C6,
219  kBulletUnicode = 0x2022,
220  kAppleLogoUnicode = 0xF8FF
221  };
222 
223  struct EventRecord
224  {
225  EventKind what;
226  UInt32 message;
227  UInt32 when;
228  Point where;
229  EventModifiers modifiers;
230  };
231  typedef struct EventRecord EventRecord;
232  typedef CALLBACK_API(void, FKEYProcPtr)(void);
233  typedef STACK_UPP_TYPE(FKEYProcPtr) FKEYUPP;
234 #if CALL_NOT_IN_CARBON
243  FKEYUPP
244  NewFKEYUPP(FKEYProcPtr userRoutine);
245 #if !OPAQUE_UPP_TYPES
246  enum
247  {
248  uppFKEYProcInfo = 0x00000000
249  };
250 #ifdef __cplusplus
251  inline FKEYUPP NewFKEYUPP(FKEYProcPtr userRoutine)
252  {
253  return (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo,
254  GetCurrentArchitecture());
255  }
256 #else
257 #define NewFKEYUPP(userRoutine) \
258  (FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, \
259  GetCurrentArchitecture())
260 #endif
261 #endif
262 
271  void
272  DisposeFKEYUPP(FKEYUPP userUPP);
273 #if !OPAQUE_UPP_TYPES
274 #ifdef __cplusplus
275  inline void DisposeFKEYUPP(FKEYUPP userUPP)
276  {
277  DisposeRoutineDescriptor((UniversalProcPtr)userUPP);
278  }
279 #else
280 #define DisposeFKEYUPP(userUPP) DisposeRoutineDescriptor(userUPP)
281 #endif
282 #endif
283 
292  void
293  InvokeFKEYUPP(FKEYUPP userUPP);
294 #if !OPAQUE_UPP_TYPES
295 #ifdef __cplusplus
296  inline void InvokeFKEYUPP(FKEYUPP userUPP)
297  {
298  CALL_ZERO_PARAMETER_UPP(userUPP, uppFKEYProcInfo);
299  }
300 #else
301 #define InvokeFKEYUPP(userUPP) \
302  CALL_ZERO_PARAMETER_UPP((userUPP), uppFKEYProcInfo)
303 #endif
304 #endif
305 
306 #endif
308 #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
310 #define NewFKEYProc(userRoutine) NewFKEYUPP(userRoutine)
311 #define CallFKEYProc(userRoutine) InvokeFKEYUPP(userRoutine)
312 #endif
322  void
323  GetMouse(Point *mouseLoc);
324 
333  Boolean
334  Button(void);
335 
344  Boolean
345  StillDown(void);
346 
355  Boolean
356  WaitMouseUp(void);
357 
366  UInt32
367  KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state);
368 
391  UInt32
393 
400 #if TARGET_OS_MAC && TARGET_API_MAC_OS8
401 
402  typedef UInt32 KeyMap[4];
403 #else
405 #endif
407  typedef UInt8 KeyMapByteArray[16];
416  void
417  GetKeys(KeyMap theKeys);
418 
420  enum
421  {
422  networkEvt = 10,
423  driverEvt = 11,
424  app1Evt = 12,
425  app2Evt = 13,
426  app3Evt = 14,
427  app4Evt = 15,
428  networkMask = 0x0400,
429  driverMask = 0x0800,
430  app1Mask = 0x1000,
431  app2Mask = 0x2000,
432  app3Mask = 0x4000,
433  app4Mask = 0x8000
434  };
435 
436  struct EvQEl
437  {
438  QElemPtr qLink;
439  SInt16 qType;
440  EventKind evtQWhat;
442  UInt32 evtQMessage;
443  UInt32 evtQWhen;
444  Point evtQWhere;
445  EventModifiers evtQModifiers;
446  };
447  typedef struct EvQEl EvQEl;
448  typedef EvQEl *EvQElPtr;
449  typedef CALLBACK_API_REGISTER68K(void, GetNextEventFilterProcPtr,
450  (EventRecord * theEvent, Boolean *result));
451  typedef REGISTER_UPP_TYPE(GetNextEventFilterProcPtr) GetNextEventFilterUPP;
452 #if CALL_NOT_IN_CARBON
461  GetNextEventFilterUPP
462  NewGetNextEventFilterUPP(GetNextEventFilterProcPtr userRoutine);
463 #if !OPAQUE_UPP_TYPES
464  enum
465  {
466  uppGetNextEventFilterProcInfo = 0x000000BF
467  };
468 #ifdef __cplusplus
469  inline GetNextEventFilterUPP
470  NewGetNextEventFilterUPP(GetNextEventFilterProcPtr userRoutine)
471  {
472  return (GetNextEventFilterUPP)NewRoutineDescriptor(
473  (ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo,
474  GetCurrentArchitecture());
475  }
476 #else
477 #define NewGetNextEventFilterUPP(userRoutine) \
478  (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), \
479  uppGetNextEventFilterProcInfo, \
480  GetCurrentArchitecture())
481 #endif
482 #endif
483 
492  void
493  DisposeGetNextEventFilterUPP(GetNextEventFilterUPP userUPP);
494 #if !OPAQUE_UPP_TYPES
495 #ifdef __cplusplus
496  inline void DisposeGetNextEventFilterUPP(GetNextEventFilterUPP userUPP)
497  {
498  DisposeRoutineDescriptor((UniversalProcPtr)userUPP);
499  }
500 #else
501 #define DisposeGetNextEventFilterUPP(userUPP) DisposeRoutineDescriptor(userUPP)
502 #endif
503 #endif
504 
513  void
515  GetNextEventFilterUPP userUPP);
516 #if !OPAQUE_UPP_TYPES && \
517  (!TARGET_OS_MAC || !TARGET_CPU_68K || TARGET_RT_MAC_CFM)
518 #ifdef __cplusplus
520  GetNextEventFilterUPP userUPP)
521  {
522  CALL_TWO_PARAMETER_UPP(userUPP, uppGetNextEventFilterProcInfo, theEvent,
523  result);
524  }
525 #else
526 #define InvokeGetNextEventFilterUPP(theEvent, result, userUPP) \
527  CALL_TWO_PARAMETER_UPP((userUPP), uppGetNextEventFilterProcInfo, (theEvent), \
528  (result))
529 #endif
530 #endif
531 
532 #endif
534 #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
536 #define NewGetNextEventFilterProc(userRoutine) \
537  NewGetNextEventFilterUPP(userRoutine)
538 #define CallGetNextEventFilterProc(userRoutine, theEvent, result) \
539  InvokeGetNextEventFilterUPP(theEvent, result, userRoutine)
540 #endif
542  typedef GetNextEventFilterUPP GNEFilterUPP;
543 
581 }
582 if (theEvent.what == keyDown)
583 {
584  </ pre>
585  * \copyright THINK Reference © 1991 - 1992 Symantec Corporation
586  * \non_carbon_cfm in InterfaceLib 7.1 and
587  later
588  * \carbon_lib in CarbonLib 1.0 and
589  later
590  * \mac_os_x in version 10.0 and
591  later
592  * /
593  UInt32
594  GetDblTime(void);
595 
629  void
630  SetEventMask(EventMask value);
631 
632 #if CALL_NOT_IN_CARBON
633 
654  QHdrPtr
655  GetEvQHdr(void);
656 
657 #endif
659 #if CALL_NOT_IN_CARBON
660 
699 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
700 #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
701 #endif
702  OSErr
703  PPostEvent(EventKind eventCode, UInt32 eventMsg, EvQElPtr * qEl);
704 
705 #endif
715  Boolean
716  GetNextEvent(EventMask eventMask, EventRecord * theEvent);
717 
726  Boolean
727  WaitNextEvent(EventMask eventMask, EventRecord * theEvent, UInt32 sleep,
728  RgnHandle mouseRgn) ;
729 
738  Boolean
739  EventAvail(EventMask eventMask, EventRecord * theEvent);
740 
781 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
782 #pragma parameter __D0 PostEvent(__A0, __D0)
783 #endif
784  OSErr
785  PostEvent(EventKind eventNum, UInt32 eventMsg);
786 
794 #if CALL_NOT_IN_CARBON
795 
825 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
826 #pragma parameter __D0 OSEventAvail(__D0, __A0)
827 #endif
828  Boolean
829  OSEventAvail(EventMask mask, EventRecord * theEvent);
830 
861 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
862 #pragma parameter __D0 GetOSEvent(__D0, __A0)
863 #endif
864  Boolean
865  GetOSEvent(EventMask mask, EventRecord * theEvent);
866 
867 #endif
895  void
896  FlushEvents(EventMask whichMask, EventMask stopMask);
897 
898 #if CALL_NOT_IN_CARBON
907  void
908  SystemClick(const EventRecord *theEvent, WindowRef theWindow);
909 
929  EventLoop(); /* ExitToShell elsewhere */
930 }
931 EventLoop()
932 {
933  MaintainCursor();
934  MaintainMenus();
935  SystemTask();
936  if (GetNextEvent(everyEvent, &theEvent))
937  {
938  .....process events...
939  .
940  }
941 }
942 DAs wanting a timeslice every so often should set bit 5 of the drvrFlags
943  word and a tick count in drvrDelay in the driver header.You should not depend on any particular accuracy,
944  since an application may fail to call
945  SystemTask often
946  enough(e.g., when saving a file)
947  .To receive periodic
948  timeslices with more accuracy,
949  install a vertical retrace task via VInstall
950  or a timer interrupt task via InsTime.</ pre>
951  * \copyright THINK Reference © 1991 -
952  1992 Symantec Corporation
953  * \non_carbon_cfm in InterfaceLib 7.1 and
954  later
955  * \carbon_lib not available
956  * \mac_os_x not available
957  * /
958  void
959  SystemTask(void);
960 
1006 Boolean
1008 
1009 #endif
1011 #if OLDROUTINENAMES
1012 #define KeyTrans(transData, keycode, state) \
1013  KeyTranslate(transData, keycode, state)
1014 #endif
1037 void
1038 GetGlobalMouse(Point *globalMouse);
1039 
1055 UInt32
1057 
1074 Boolean
1076 
1081 typedef struct OpaqueEventRef *EventRef;
1090 void
1091 KeyScript(short code);
1092 
1101 Boolean
1102 IsCmdChar(const EventRecord *event, short test);
1103 
1115 SInt16
1117 
1126 void
1127 LMSetKeyThresh(SInt16 value);
1128 
1137 SInt16
1139 
1148 void
1149 LMSetKeyRepThresh(SInt16 value);
1150 
1159 UInt8
1161 
1170 void
1171 LMSetKbdLast(UInt8 value);
1172 
1181 UInt8
1183 
1192 void
1193 LMSetKbdType(UInt8 value);
1194 
1195 #if PRAGMA_STRUCT_ALIGN
1196 #pragma options align = reset
1197 #elif PRAGMA_STRUCT_PACKPUSH
1198 #pragma pack(pop)
1199 #elif PRAGMA_STRUCT_PACK
1200 #pragma pack()
1201 #endif
1202 
1203 #ifdef PRAGMA_IMPORT_OFF
1204 #pragma import off
1205 #elif PRAGMA_IMPORT
1206 #pragma import reset
1207 #endif
1208 
1209 #ifdef __cplusplus
1210 }
1211 #endif
1212 
1213 #endif
1214 * /*/*/ * /*/*/ * /*/*/ */*/
QuickTime Interfaces.
long BigEndianLong
Definition: Endian.h:549
@ mouseMovedMessage
Definition: Events.h:106
void LMSetKeyRepThresh(SInt16 value)
void InvokeFKEYUPP(FKEYUPP userUPP)
UInt16 EventKind
Definition: Events.h:62
#define NewGetNextEventFilterUPP(userRoutine)
Definition: Events.h:477
UInt16 EventModifiers
Definition: Events.h:145
void GetMouse(Point *mouseLoc)
@ activateEvt
Definition: Events.h:74
void DisposeGetNextEventFilterUPP(GetNextEventFilterUPP userUPP)
GetNextEventFilterUPP GNEFilterUPP
Definition: Events.h:542
void LMSetKbdType(UInt8 value)
UInt32 GetCaretTime(void)
Obtain insertion-point cursor blink interval.
void DisposeFKEYUPP(FKEYUPP userUPP)
#define NewFKEYUPP(userRoutine)
Definition: Events.h:257
struct OpaqueEventRef * EventRef
Definition: Events.h:1081
Boolean WaitMouseUp(void)
BigEndianLong KeyMap[4]
Definition: Events.h:404
Boolean IsCmdChar(const EventRecord *event, short test)
Boolean StillDown(void)
void GetGlobalMouse(Point *globalMouse)
@ kControlUnicode
Definition: Events.h:213
@ kDiamondUnicode
Definition: Events.h:218
@ kBulletUnicode
Definition: Events.h:219
@ kCommandUnicode
Definition: Events.h:215
@ kCheckUnicode
Definition: Events.h:217
@ kAppleLogoUnicode
Definition: Events.h:220
@ kOptionUnicode
Definition: Events.h:214
@ kPencilUnicode
Definition: Events.h:216
Boolean Button(void)
UInt32 GetCurrentKeyModifiers(void)
@ rightOptionKeyBit
Definition: Events.h:157
@ alphaLockBit
Definition: Events.h:153
@ shiftKeyBit
Definition: Events.h:152
@ optionKeyBit
Definition: Events.h:154
@ rightControlKeyBit
Definition: Events.h:158
@ cmdKeyBit
Definition: Events.h:151
@ btnStateBit
Definition: Events.h:150
@ rightShiftKeyBit
Definition: Events.h:156
@ activeFlagBit
Definition: Events.h:149
@ controlKeyBit
Definition: Events.h:155
UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
void LMSetKbdLast(UInt8 value)
UInt8 KeyMapByteArray[16]
Definition: Events.h:407
void KeyScript(short code)
UInt8 LMGetKbdType(void)
Boolean SystemEvent(const EventRecord *theEvent)
Used internally by Event Manager.
@ kAppleLogoCharCode
Definition: Events.h:196
@ kCheckCharCode
Definition: Events.h:194
@ kDiamondCharCode
Definition: Events.h:195
@ kEscapeCharCode
Definition: Events.h:197
Boolean CheckEventQueueForUserCancel(void)
SInt16 LMGetKeyRepThresh(void)
UInt8 LMGetKbdLast(void)
void LMSetKeyThresh(SInt16 value)
void InvokeGetNextEventFilterUPP(EventRecord *theEvent, Boolean *result, GetNextEventFilterUPP userUPP)
void GetKeys(KeyMap theKeys)
SInt16 LMGetKeyThresh(void)
@ autoKeyMask
Definition: Events.h:85
@ updateMask
Definition: Events.h:86
@ diskMask
Definition: Events.h:87
@ keyUpMask
Definition: Events.h:84
@ osMask
Definition: Events.h:90
@ mUpMask
Definition: Events.h:82
@ keyDownMask
Definition: Events.h:83
@ highLevelEventMask
Definition: Events.h:89
@ activMask
Definition: Events.h:88
@ everyEvent
Definition: Events.h:91
Basic Macintosh data types.
unsigned char Boolean
Definition: MacTypes.h:318
#define CALL_ZERO_PARAMETER_UPP(upp, procInfo)
Definition: MixedMode.h:790
void DisposeRoutineDescriptor(UniversalProcPtr theUPP)
#define STACK_UPP_TYPE(name)
Definition: MixedMode.h:734
UniversalProcPtr NewRoutineDescriptor(ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA)
OS Utilities Interfaces.
Interface to Quickdraw Graphics.
OSErr VInstall(QElemPtr vblTaskPtr)
typedef CALLBACK_API_REGISTER68K(void, SIInterruptProcPtr,(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize))
typedef REGISTER_UPP_TYPE(HighHookProcPtr) HighHookUPP
void InsTime(QElemPtr tmTaskPtr)
Install timer task.
Definition: Components.h:266
Definition: Events.h:437
UInt32 evtQMessage
Definition: Events.h:442
Definition: Events.h:224
Definition: Quickdraw.h:1648
Definition: Quickdraw.h:306
Definition: MacTypes.h:520
Definition: OSUtils.h:131
Definition: OSUtils.h:154