home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / RBUTTONS.H < prev    next >
C/C++ Source or Header  |  1994-01-05  |  3KB  |  115 lines

  1. /************************************************************************
  2. **
  3. ** @(#)rbuttons.h    01/03/94    Chris Ahlstrom
  4. **
  5. **    This module interfaces C++ with code for handling various kinds
  6. ** of button devices.
  7. **
  8. **    Also defines constants for the Turbo Vision implementation of
  9. ** response support.
  10. **
  11. *************************************************************************/
  12.  
  13. #if !defined(RBUTTONS_h)                // { RBUTTONS_h
  14. #define RBUTTONS_h
  15.  
  16.  
  17. /************************************************************************
  18. ** ResponseType
  19. **
  20. **    Simply selects the device to use.  We don't allow simultaneous
  21. ** interchangeable use of all devices.
  22. **
  23. **    MOUSE_POINT_RESPONSE is not yet supported.
  24. **
  25. *************************************************************************/
  26.  
  27. typedef enum
  28. {
  29.     MOUSE_RESPONSE    = 0,        // left or right buttons
  30.     KEYBOARD_RESPONSE,            // 1, 2, or E key
  31.     KOALA_RESPONSE,            // left or right buttons
  32.     MOUSE_POINT_RESPONSE        // click in 1st, 2nd, or 3rd section
  33.  
  34. } ResponseType;
  35.  
  36.  
  37. /************************************************************************
  38. ** Response
  39. **
  40. **    All responses are mapped onto a two-button response device.
  41. **
  42. **    BUTTON_3 and ALL_BUTTONS are not yet supported.
  43. **
  44. ** KeyResponse
  45. **
  46. **    The keys as mapped onto Response values.
  47. **
  48. *************************************************************************/
  49.  
  50. typedef enum
  51. {
  52.     NO_BUTTON        = 0x00,
  53.     BUTTON_1        = 0x01,
  54.     BUTTON_2        = 0x02,
  55.     BUTTON_3        = 0x04,
  56.     BOTH_BUTTONS    = (BUTTON_1+BUTTON_2),
  57.     ALL_BUTTONS        = (BOTH_BUTTONS+BUTTON_3)
  58.  
  59. } Response;
  60.  
  61. typedef enum
  62. {
  63.     KEY_NO_BUTTON    = 0,
  64.     KEY_BUTTON_1    = '1',
  65.     KEY_BUTTON_2    = '2',
  66.     KEY_BUTTON_3    = '3',
  67.     KEY_BOTH_BUTTONS    = 'B',
  68.     KEY_BOTH_ESCAPE    = '\x1B',
  69.     KEY_ALL_BUTTONS    = 'A'
  70.  
  71. } ResponseKey;
  72.  
  73.  
  74. /************************************************************************
  75. ** ResponseButton base class
  76. **
  77. **    The protected member responseDevice is of little use at the
  78. ** moment.
  79. **
  80. **    The protected member lastResponse is useful perhaps for
  81. ** doing tricky but too-tricky things (e.g. two-key double clicks),
  82. ** or for saving the status so that a Windows mouse-handler routine
  83. ** can decide what to do with it.
  84. **
  85. *************************************************************************/
  86.  
  87. class ResponseButton
  88. {
  89.  
  90. public:
  91.  
  92.     ResponseButton                // constructor
  93.     (
  94.     ResponseType device            // kind of device
  95.     );
  96.  
  97.     virtual ~ResponseButton ();            // destructor
  98.  
  99.     int checkAbort ();
  100.     int waitKey ();
  101.     int getLastResponse ();
  102.  
  103.     virtual int readKey ();            // default support is keyboard
  104.  
  105. protected:
  106.  
  107.     ResponseType responseDevice;        // default device is keyboard
  108.     Response lastResponse;            // previous response
  109.  
  110. };
  111.  
  112.  
  113. #endif                            // } RBUTTONS_h
  114.  
  115.