mousesystem.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. // *****************************************************************************
  2. //
  3. // Filename : MouseSystem.h
  4. //
  5. // Purpose : Defines and typedefs for the "mousesystem" mouse region handler
  6. //
  7. // Modification history :
  8. //
  9. // 30jan97:Bret -> Creation
  10. //
  11. // *****************************************************************************
  12. // *****************************************************************************
  13. //
  14. // Includes
  15. //
  16. // *****************************************************************************
  17. #include "mousesystem_macros.h"
  18. #ifndef _MOUSE_SYSTEM_H_
  19. #define _MOUSE_SYSTEM_H_
  20. // *****************************************************************************
  21. //
  22. // Typedefs
  23. //
  24. // *****************************************************************************
  25. #ifdef JA2
  26. #define _JA2_RENDER_DIRTY // Undef this if not using the JA2 Dirty Rectangle System.
  27. #endif
  28. typedef void (*MOUSE_CALLBACK)(struct _MOUSE_REGION *,INT32); // Define MOUSE_CALLBACK type as pointer to void
  29. typedef void (*MOUSE_HELPTEXT_DONE_CALLBACK)( ); // the help is done callback
  30. typedef struct _MOUSE_REGION {
  31. UINT16 IDNumber; // Region's ID number, set by mouse system
  32. INT8 PriorityLevel; // Region's Priority, set by system and/or caller
  33. UINT32 uiFlags; // Region's state flags
  34. INT16 RegionTopLeftX; // Screen area affected by this region (absolute coordinates)
  35. INT16 RegionTopLeftY;
  36. INT16 RegionBottomRightX;
  37. INT16 RegionBottomRightY;
  38. INT16 MouseXPos; // Mouse's Coordinates in absolute screen coordinates
  39. INT16 MouseYPos;
  40. INT16 RelativeXPos; // Mouse's Coordinates relative to the Top-Left corner of the region
  41. INT16 RelativeYPos;
  42. UINT16 ButtonState; // Current state of the mouse buttons
  43. UINT16 Cursor; // Cursor to use when mouse in this region (see flags)
  44. MOUSE_CALLBACK MovementCallback; // Pointer to callback function if movement occured in this region
  45. MOUSE_CALLBACK ButtonCallback; // Pointer to callback function if button action occured in this region
  46. INT32 UserData[4]; // User Data, can be set to anything!
  47. //Fast help vars.
  48. INT16 FastHelpTimer; // Countdown timer for FastHelp text
  49. UINT16 *FastHelpText; // Text string for the FastHelp (describes buttons if left there a while)
  50. INT32 FastHelpRect;
  51. MOUSE_HELPTEXT_DONE_CALLBACK HelpDoneCallback;
  52. struct _MOUSE_REGION *next; // List maintenance, do NOT touch these entries
  53. struct _MOUSE_REGION *prev;
  54. } MOUSE_REGION;
  55. // *****************************************************************************
  56. //
  57. // Defines
  58. //
  59. // *****************************************************************************
  60. // Mouse Region Flags
  61. #define MSYS_NO_FLAGS 0x00000000
  62. #define MSYS_MOUSE_IN_AREA 0x00000001
  63. #define MSYS_SET_CURSOR 0x00000002
  64. #define MSYS_MOVE_CALLBACK 0x00000004
  65. #define MSYS_BUTTON_CALLBACK 0x00000008
  66. #define MSYS_REGION_EXISTS 0x00000010
  67. #define MSYS_SYSTEM_INIT 0x00000020
  68. #define MSYS_REGION_ENABLED 0x00000040
  69. #define MSYS_FASTHELP 0x00000080
  70. #define MSYS_GOT_BACKGROUND 0x00000100
  71. #define MSYS_HAS_BACKRECT 0x00000200
  72. #define MSYS_FASTHELP_RESET 0x00000400
  73. #define MSYS_ALLOW_DISABLED_FASTHELP 0x00000800
  74. // Mouse region IDs
  75. #define MSYS_ID_BASE 1
  76. #define MSYS_ID_MAX 0xfffffff // ( INT32 max )
  77. #define MSYS_ID_SYSTEM 0
  78. // Mouse region priorities
  79. #define MSYS_PRIORITY_LOWEST 0
  80. #define MSYS_PRIORITY_LOW 15
  81. #define MSYS_PRIORITY_BASE 31
  82. #define MSYS_PRIORITY_NORMAL 31
  83. #define MSYS_PRIORITY_HIGH 63
  84. #define MSYS_PRIORITY_HIGHEST 127
  85. #define MSYS_PRIORITY_SYSTEM -1
  86. #define MSYS_PRIORITY_AUTO -1
  87. // Mouse system defines used during updates
  88. #define MSYS_NO_ACTION 0
  89. #define MSYS_DO_MOVE 1
  90. #define MSYS_DO_LBUTTON_DWN 2
  91. #define MSYS_DO_LBUTTON_UP 4
  92. #define MSYS_DO_RBUTTON_DWN 8
  93. #define MSYS_DO_RBUTTON_UP 16
  94. #define MSYS_DO_LBUTTON_REPEAT 32
  95. #define MSYS_DO_RBUTTON_REPEAT 64
  96. #define MSYS_DO_BUTTONS (MSYS_DO_LBUTTON_DWN|MSYS_DO_LBUTTON_UP|MSYS_DO_RBUTTON_DWN|MSYS_DO_RBUTTON_UP|MSYS_DO_RBUTTON_REPEAT|MSYS_DO_LBUTTON_REPEAT)
  97. // Mouse system button masks
  98. #define MSYS_LEFT_BUTTON 1
  99. #define MSYS_RIGHT_BUTTON 2
  100. // Mouse system special values
  101. #define MSYS_NO_CALLBACK NULL
  102. #define MSYS_NO_CURSOR 65534
  103. // Mouse system callback reasons
  104. #define MSYS_CALLBACK_REASON_NONE 0
  105. #define MSYS_CALLBACK_REASON_INIT 1
  106. #define MSYS_CALLBACK_REASON_MOVE 2
  107. #define MSYS_CALLBACK_REASON_LBUTTON_DWN 4
  108. #define MSYS_CALLBACK_REASON_LBUTTON_UP 8
  109. #define MSYS_CALLBACK_REASON_RBUTTON_DWN 16
  110. #define MSYS_CALLBACK_REASON_RBUTTON_UP 32
  111. #define MSYS_CALLBACK_REASON_BUTTONS (MSYS_CALLBACK_REASON_LBUTTON_DWN|MSYS_CALLBACK_REASON_LBUTTON_UP| \
  112. MSYS_CALLBACK_REASON_RBUTTON_DWN|MSYS_CALLBACK_REASON_RBUTTON_UP)
  113. #define MSYS_CALLBACK_REASON_LOST_MOUSE 64
  114. #define MSYS_CALLBACK_REASON_GAIN_MOUSE 128
  115. #define MSYS_CALLBACK_REASON_LBUTTON_REPEAT 256
  116. #define MSYS_CALLBACK_REASON_RBUTTON_REPEAT 512
  117. //Kris: Nov 31, 1999
  118. //Added support for double clicks. The DOUBLECLICK event is passed combined with
  119. //the LBUTTON_DWN event if two LBUTTON_DWN events are detected on the same button/region
  120. //within the delay defined by MSYS_DOUBLECLICK_DELAY (in milliseconds). If your button/region
  121. //supports double clicks and single clicks, make sure the DOUBLECLICK event is checked first (rejecting
  122. //the LBUTTON_DWN event if detected)
  123. #define MSYS_CALLBACK_REASON_LBUTTON_DOUBLECLICK 1024
  124. // Mouse grabbing return codes
  125. #define MSYS_GRABBED_OK 0
  126. #define MSYS_ALREADY_GRABBED 1
  127. #define MSYS_REGION_NOT_IN_LIST 2
  128. // *****************************************************************************
  129. //
  130. // Prototypes
  131. //
  132. // *****************************************************************************
  133. #ifdef __cplusplus
  134. extern "C" {
  135. #endif
  136. // *****************************************************************************
  137. // Note:
  138. // The prototype for MSYS_SGP_Mouse_Handler_Hook() is defined in mousesystem_macros.h
  139. // Internal Functions
  140. INT32 MSYS_GetNewID(void);
  141. void MSYS_TrashRegList(void);
  142. void MSYS_AddRegionToList(MOUSE_REGION *region);
  143. INT32 MSYS_RegionInList(MOUSE_REGION *region);
  144. void MSYS_DeleteRegionFromList(MOUSE_REGION *region);
  145. void MSYS_UpdateMouseRegion(void);
  146. void MSYS_SetCurrentCursor(UINT16 Cursor);
  147. // External
  148. INT32 MSYS_Init(void);
  149. void MSYS_Shutdown(void);
  150. void MSYS_DefineRegion(MOUSE_REGION *region,UINT16 tlx,UINT16 tly,UINT16 brx,UINT16 bry,INT8 priority,
  151. UINT16 crsr,MOUSE_CALLBACK movecallback,MOUSE_CALLBACK buttoncallback);
  152. void MSYS_ChangeRegionCursor(MOUSE_REGION *region,UINT16 crsr);
  153. INT32 MSYS_AddRegion(MOUSE_REGION *region);
  154. void MSYS_RemoveRegion(MOUSE_REGION *region);
  155. void MSYS_EnableRegion(MOUSE_REGION *region);
  156. void MSYS_DisableRegion(MOUSE_REGION *region);
  157. void MSYS_ChangeRegionPriority(MOUSE_REGION *region,INT8 priority);
  158. void MSYS_SetRegionUserData(MOUSE_REGION *region,INT32 index,INT32 userdata);
  159. INT32 MSYS_GetRegionUserData(MOUSE_REGION *region,INT32 index);
  160. INT32 MSYS_GrabMouse(MOUSE_REGION *region);
  161. void MSYS_ReleaseMouse(MOUSE_REGION *region);
  162. void MSYS_MoveMouseRegionBy( MOUSE_REGION *region, INT16 sDeltaX, INT16 sDeltaY);
  163. void MSYS_MoveMouseRegionTo( MOUSE_REGION *region, INT16 sX, INT16 sY);
  164. void MSYS_AllowDisabledRegionFastHelp( MOUSE_REGION *region, BOOLEAN fAllow );
  165. // This function will force a re-evaluation of mous regions
  166. // Usually used to force change of mouse cursor if panels switch, etc
  167. void RefreshMouseRegions( );
  168. void SetRegionFastHelpText( MOUSE_REGION *region, UINT16 *szText );
  169. void SetRegionHelpEndCallback( MOUSE_REGION *region, MOUSE_HELPTEXT_DONE_CALLBACK CallbackFxn );
  170. // Now also used by Wizardry -- DB
  171. void DisplayFastHelp( MOUSE_REGION *region );
  172. void RenderFastHelp();
  173. void SetFastHelpDelay( INT16 sFastHelpDelay );
  174. void EnableMouseFastHelp( void );
  175. void DisableMouseFastHelp( void );
  176. void ResetClickedMode(void);
  177. #ifdef _JA2_RENDER_DIRTY
  178. BOOLEAN SetRegionSavedRect( MOUSE_REGION *region);
  179. void FreeRegionSavedRect( MOUSE_REGION *region );
  180. #endif
  181. // *****************************************************************************
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif
  186. // EOF *************************************************************************