home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / MOUSE.H < prev    next >
C/C++ Source or Header  |  1993-10-11  |  2KB  |  83 lines

  1. // ---------- mouse.h
  2. //
  3. // modified for OS/2 operation - jw21sep93
  4.  
  5. #ifndef MOUSE_H
  6. #define MOUSE_H
  7.  
  8. #define INCL_SUB
  9. #define INCL_NOPMAPI
  10. #include <os2.h>
  11.  
  12. #include "dfwindow.h"
  13. #include "dtimer.h"      // name changed to avoid collision with Borland
  14.  
  15. class Mouse    
  16.     {
  17.     enum State
  18.         {
  19.         STATE_MOUSE_IDLE,
  20.         STATE_MOUSE_DEPRESSED,
  21.         STATE_MOUSE_RELEASED,
  22.         STATE_MOUSE_DWAIT,
  23.         STATE_MOUSE_REPEAT
  24.         };
  25.  
  26.     enum Event
  27.         {
  28.         EVENT_MOUSE_MOVED,
  29.         EVENT_MOUSE_DEPRESSED,
  30.         EVENT_MOUSE_RELEASED,
  31.         EVENT_MOUSE_TIMEREXPIRED
  32.         };
  33.  
  34.     HMOU         hMou;          // mouse device handle
  35.     MOUEVENTINFO previnfo;      // previous mouse info struct
  36.     MOUEVENTINFO currinfo;      // current mouse info struct
  37.     NOPTRRECT    inclRect;      // inclusion rectangle
  38.     Bool         installed;     // True = mouse is installed
  39.     Bool         timerRunning;  // True = timer was running when last checked
  40.     Timer        timer;         // mouse timer (used for double-clicks,
  41.                                 //   delays and repeats)
  42.  
  43.     int          delayticks;    // delay before mouse typematic activates
  44.     int          repeatticks;   // delay between mouse typematic repeats
  45.     int          doubleticks;   // double click period
  46.  
  47.     enum State   curState;      // current state of mouse
  48.  
  49.     DFWindow    *MouseWindow(int mx, int my);
  50.     void         HandleEvent(enum Event event);
  51.  
  52. public:
  53.     Mouse();
  54.     ~Mouse();
  55.     Bool Installed() { return installed; }
  56.     void GetPosition(int &x, int &y);   // get mouse position
  57.     void SetPosition(int x, int y);     // set mouse position
  58.     void Show();                        // show the mouse cursor
  59.     void Hide();                        // hide the mouse cursor
  60.     void SetTravel(int minx, int maxx, int miny, int maxy);
  61.     void DispatchEvent();               // process mouse events
  62.     };
  63.  
  64. // -------- timer delays for mouse repeat, double clicks
  65.  
  66. const int REPEAT    =  2;
  67. const int DELAY     =  20;
  68. const int DOUBLE    =  14;
  69.  
  70. // -------- event detection constants
  71.  
  72. const USHORT Movement = MOUSE_MOTION |
  73.                         MOUSE_MOTION_WITH_BN1_DOWN |
  74.                         MOUSE_MOTION_WITH_BN2_DOWN |
  75.                         MOUSE_MOTION_WITH_BN3_DOWN;
  76.  
  77. const USHORT Depression = MOUSE_BN1_DOWN |
  78.                           MOUSE_MOTION_WITH_BN1_DOWN;
  79.  
  80. #endif
  81.  
  82.  
  83.