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.

228 lines
5.0 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. * Modified by Robert H�hne to be used for RHIDE.
  8. * SET: Hardware abstaction with ideas from JASC.
  9. *
  10. */
  11. #if defined( Uses_TEvent ) && !defined( __TEvent )
  12. #define __TEvent
  13. struct MouseEventType
  14. {
  15. uchar buttons;
  16. Boolean doubleClick;
  17. TPoint where;
  18. };
  19. // This class is the base hardware interface with the mouse and shouldn't
  20. // be used directly. You should use TMouse instead which is derived from
  21. // it. That's why most members are protected.
  22. // See thwmouse.cc
  23. class THWMouse
  24. {
  25. protected:
  26. THWMouse();
  27. THWMouse(const THWMouse&) {};
  28. virtual ~THWMouse();
  29. static void show();
  30. static void hide();
  31. // Needed by some drivers to communicate the size of the screen.
  32. static void (*setRange)(ushort, ushort);
  33. static void getEvent(MouseEventType &me);
  34. // This function could fail according to the hardware.
  35. // In TV 2.0 it just doesn't exist when you compile for 32 bits.
  36. static void (*registerHandler)(unsigned, void (*)());
  37. static void suspend();
  38. static void resume();
  39. // Inline members:
  40. // Disable mouse
  41. static void inhibit();
  42. // Is mouse installed?
  43. static Boolean present();
  44. // SET: To override just part of the behavior:
  45. static void (*Show)();
  46. static void (*Hide)();
  47. static void (*Suspend)();
  48. static void (*Resume)();
  49. static void (*GetEvent)(MouseEventType &me);
  50. // SET: This is optional, is only needed if the harware uses forceEvent.
  51. static int (*drawMouse)(int x, int y);
  52. // SET: Default behaviors
  53. static void defaultShow();
  54. static void defaultHide();
  55. static void defaultSetRange(ushort, ushort);
  56. static void defaultGetEvent(MouseEventType&);
  57. static void defaultRegisterHandler(unsigned, void (*)());
  58. static void defaultSuspend();
  59. static void defaultResume();
  60. static int defaultDrawMouse(int x, int y);
  61. public:
  62. // SET: Used to externally force a mouse event.
  63. // This is only used internally.
  64. static void forceEvent(int x, int y, int buttons);
  65. protected:
  66. // This indicates how many buttons have the mouse. Is also used to determine
  67. // if the mouse is present, a value of 0 is mouse not available. See the
  68. // present() member.
  69. static uchar buttonCount;
  70. // SET: Suspend sets buttonCount to 0 to disable the mouse. The default
  71. // resume behavior is to restore this value.
  72. static uchar oldButtonCount;
  73. // SET: Just to avoid redundant calls
  74. static char visible;
  75. // SET: Data used to force an event externally
  76. static MouseEventType forcedME;
  77. static char forced;
  78. static uchar btBeforeForce;
  79. // SET: Moved to the protected section
  80. static Boolean handlerInstalled;
  81. static Boolean noMouse;
  82. // The following counter is incremented when the mouse pointer is updated
  83. // by the driver. Only useful when done asynchronically.
  84. static volatile unsigned drawCounter;
  85. };
  86. inline Boolean THWMouse::present()
  87. {
  88. return Boolean(buttonCount!=0);
  89. }
  90. inline void THWMouse::inhibit()
  91. {
  92. noMouse=True;
  93. }
  94. // This class exposses the mouse interface.
  95. class TMouse : public THWMouse
  96. {
  97. public:
  98. TMouse();
  99. ~TMouse();
  100. static void show();
  101. static void hide();
  102. static void suspend();
  103. static void resume();
  104. static void setRange( ushort, ushort );
  105. static void getEvent( MouseEventType& );
  106. static void registerHandler( unsigned, void (*)() );
  107. static Boolean present();
  108. static void resetDrawCounter();
  109. static unsigned getDrawCounter();
  110. };
  111. inline void TMouse::show()
  112. {
  113. THWMouse::show();
  114. }
  115. inline void TMouse::hide()
  116. {
  117. THWMouse::hide();
  118. }
  119. inline void TMouse::suspend()
  120. {
  121. THWMouse::suspend();
  122. }
  123. inline void TMouse::resume()
  124. {
  125. THWMouse::resume();
  126. }
  127. inline void TMouse::setRange(ushort rx, ushort ry)
  128. {
  129. THWMouse::setRange(rx,ry);
  130. }
  131. inline void TMouse::getEvent(MouseEventType& me)
  132. {
  133. THWMouse::getEvent(me);
  134. }
  135. inline void TMouse::registerHandler(unsigned mask, void (*func)())
  136. {
  137. THWMouse::registerHandler(mask,func);
  138. }
  139. inline Boolean TMouse::present()
  140. {
  141. return THWMouse::present();
  142. }
  143. inline void TMouse::resetDrawCounter()
  144. {
  145. drawCounter=0;
  146. }
  147. inline unsigned TMouse::getDrawCounter()
  148. {
  149. return drawCounter;
  150. }
  151. /****************************************************************************************/
  152. struct CharScanType
  153. {
  154. uchar charCode; // The character encoded in the application code page
  155. uchar scanCode;
  156. };
  157. struct KeyDownEvent
  158. {
  159. CharScanType charScan;
  160. ushort keyCode; // Internal code, used for special keys (i.e. arrows)
  161. ushort shiftState;
  162. uchar raw_scanCode;
  163. uint32 charCode; // The Unicode16 of the key when the driver is in
  164. // Unicode16 mode. 0xFFFF if no character is associated.
  165. };
  166. struct MessageEvent
  167. {
  168. ushort command;
  169. union
  170. {
  171. void *infoPtr;
  172. long infoLong;
  173. ushort infoWord;
  174. short infoInt;
  175. uchar infoByte;
  176. char infoChar;
  177. };
  178. };
  179. struct TEvent
  180. {
  181. ushort what;
  182. union
  183. {
  184. MouseEventType mouse;
  185. KeyDownEvent keyDown;
  186. MessageEvent message;
  187. };
  188. void getMouseEvent();
  189. void getKeyEvent();
  190. };
  191. #endif // Uses_TEvent