home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 0 Macintosh 29Sep94 / EventLoop.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  5.2 KB  |  135 lines  |  [TEXT/KAHL]

  1. /* EventLoop.h */
  2.  
  3. #ifndef Included_EventLoop_h
  4. #define Included_EventLoop_h
  5.  
  6. /* EventLoop module depends on: */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Menus */
  12. /* Screen */
  13. /* Memory */
  14. /* MyMalloc (for debugging) */
  15.  
  16. #include "Screen.h"
  17.  
  18. /* these are the possible events that can occur.  note that only some of the */
  19. /* parameters may be valid for certain events */
  20. typedef enum
  21.     {
  22.         eNoEvent EXECUTE(= -4412), /* Window, X, Y, Modifiers valid; Window == active or NIL */
  23.         eKeyPressed, /* Window, X, Y, Modifiers, KeyPressed valid */
  24.         eMouseDown, /* Window, X, Y, Modifiers valid */
  25.         eMouseUp, /* Window, X, Y, Modifiers valid */
  26.         eCheckCursor, /* Window, X, Y, Modifiers valid; Window == active window or NIL */
  27.         eMenuStarting, /* Window, Modifiers valid */
  28.         eMenuCommand, /* Window, Modifiers, MenuCommand valid */
  29.         eWindowClosing, /* Window valid */
  30.         eWindowResized, /* Window valid */
  31.         eActiveWindowChanged /* Window valid */
  32.     } EventType;
  33.  
  34. /* keyboard modifier bits */
  35. typedef enum
  36.     {
  37.         eNoModifiers = 0,
  38.         eShiftKey = 1,
  39.         eControlKey = 2,
  40.         eCommandKey = 4,
  41.         eOptionKey = 8,
  42.         eCapsLockKey = 16,
  43.         eMouseDownFlag = 32
  44.     } ModifierFlags;
  45.  
  46. /* special key return values.  these values must not change */
  47. #define eCancelKey (0x1b)
  48. #define eLeftArrow (0x1c)
  49. #define eRightArrow (0x1d)
  50. #define eUpArrow (0x1e)
  51. #define eDownArrow (0x1f)
  52.  
  53. /* forwards */
  54. struct MenuItemType;
  55.  
  56. /* initialize internal event loop data structures */
  57. MyBoolean                    Eep_InitEventLoop(void);
  58.  
  59. /* dispose of any internal event loop structures */
  60. void                            Eep_ShutdownEventLoop(void);
  61.  
  62. /* Fetch an event from the event queue and return it.  Only some of the parameters */
  63. /* returned may be valid; see the enumeration comments above for EventType to see */
  64. /* which.  Mouse coordinates are always local to the current window, or undefined */
  65. /* if there is no current window.  If there are no events, the routine will return */
  66. /* after some amount of time.  This routine may call the Menu manager, so menus */
  67. /* should be initialized before this routine is called.  Any parameter may be passed */
  68. /* as NIL if the user doesn't care about the result.  Window changes do not occur */
  69. /* if the mouse is down.  If the current window is a dialog box, then a window */
  70. /* change will never be returned for another window.  Mouse up events are always */
  71. /* returned with the same window as the mosue down event, even if the mouse is no */
  72. /* longer in the window. */
  73. EventType                    GetAnEvent(OrdType* Xloc, OrdType* Yloc, ModifierFlags* Modifiers,
  74.                                         WinType** Window, struct MenuItemType** MenuCommand, char* KeyPressed);
  75.  
  76. /* set the amount of time to wait for an event.  The default is 1/4 of a second */
  77. /* time units are in seconds. */
  78. double                        SetEventSleepTime(double TheSleepTime);
  79.  
  80. /* allow other processes to run in a cooperative environment and test for the */
  81. /* user cancel signal.  A return value of True means the user wants to cancel */
  82. MyBoolean                    RelinquishCPUCheckCancel(void);
  83.  
  84. /* allow other processes to run, but only a little bit.  Return value of True */
  85. /* means the user wants to cancel */
  86. MyBoolean                    RelinquishCPUJudiciouslyCheckCancel(void);
  87.  
  88. /* read the system timer (in seconds).  The timer returns real time (not process */
  89. /* time) but not relative to any known time.  The value may roll over from an */
  90. /* undefined large number to 0 */
  91. double                        ReadTimer(void);
  92.  
  93. /* find the true difference between two timer values even if one has rolled over */
  94. double                        TimerDifference(double Now, double Then);
  95.  
  96. /* get the current mouse position, relative to top-left of current window.  If there */
  97. /* is no current window, the results are undefined.  Either of the parameters can */
  98. /* be NIL if the user doesn't care about the result. */
  99. void                            GetMousePosition(OrdType* Xloc, OrdType* Yloc);
  100.  
  101. /* read the state of the modifier keys on the keyboard.  On systems that don't */
  102. /* allow this, the function may return the modifiers as they were at the last */
  103. /* known time */
  104. ModifierFlags            CheckModifiers(void);
  105.  
  106. /* set an implementation defined version of the specified cursor */
  107. void                            SetArrowCursor(void);
  108. void                            SetIBeamCursor(void);
  109. void                            SetWatchCursor(void);
  110. void                            SetCrossHairCursor(void);
  111.  
  112. /* set the cursor to the image and mask specified.  If the implementation's cursor */
  113. /* is larger than 16x16, then the adjustment is implementation defined.  On the */
  114. /* Macintosh, cursors are 16x16, so no adjustment is necessary */
  115. /* the most significant bit of the word is leftmost */
  116. void                            SetTheCursor(short HotPointX, short HotPointY,
  117.                                         unsigned short CursorImage[16], unsigned short CursorMask[16]);
  118.  
  119. /* get the number of seconds to wait before toggling an insertion point */
  120. double                        GetCursorBlinkRate(void);
  121.  
  122. /* get the maximum time between clicks for which they are considered a double click */
  123. double                        GetDoubleClickInterval(void);
  124.  
  125. /* emit a not too annoying beep to indicate an error occurred */
  126. void                            ErrorBeep(void);
  127.  
  128. /* enable or disable error beeping.  True enables it.  the old value is returned. */
  129. MyBoolean                    SetErrorBeepEnable(MyBoolean ShouldWeBeep);
  130.  
  131. /* this is an internal routine -- don't use */
  132. void                            Eep_WindowDying(WinType* Window);
  133.  
  134. #endif
  135.