home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / include / mousepos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-25  |  2.1 KB  |  77 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknowledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef _MousePosition_h
  13. #define _MousePosition_h
  14.  
  15. //
  16. //  Support for the Atari Mouse - directly.  Do not use with AES.
  17. //
  18.  
  19. #include <values.h>
  20. #include <shape.h>
  21. #include <bool.h>
  22.  
  23. class MousePosition;
  24. extern MousePosition Mouse;
  25.  
  26.  
  27. // **** Only one MousePosition may be declared (ie. Mouse above) ****
  28.  
  29.  
  30.  
  31. class MousePosition
  32. {
  33. public:
  34.     MousePosition();
  35.     ~MousePosition();
  36.  
  37.     int X();
  38.     int Y();
  39.     bool LeftButton();
  40.     bool RightButton();
  41.     int MoveTo(int,int);
  42.     int MoveBy(int,int);
  43.     void Speed(short x,short y); // Thresholds
  44.  
  45.     void Unbound(); // Default
  46.     void Bound(Rectangle);
  47.     /* Old */ void Bound(int MinX=0, int MinY=0,
  48.         int Width=MAXINT, int Height=MAXINT);
  49.     void SetLeft(int);
  50.     void SetRight(int);
  51.  
  52. private:
  53.     void Bind();
  54.     bool Bounded;
  55.     int minx,miny,maxx,maxy;
  56.     void* OldVec;
  57.     volatile int x,y;
  58.     volatile bool Left,Right;
  59. };
  60.  
  61. inline bool MousePosition::LeftButton() { return Left; }
  62. inline bool MousePosition::RightButton() { return Right; }
  63. inline int MousePosition::X() { return x; }
  64. inline int MousePosition::Y() { return y; }
  65. inline int MousePosition::MoveTo(int X,int Y) { x=X; y=Y; if (Bounded) Bind(); }
  66. inline int MousePosition::MoveBy(int X,int Y) { x+=X; y+=Y; if (Bounded) Bind(); }
  67. inline void MousePosition::Unbound() { Bounded=0; }
  68. inline void MousePosition::Bound(Rectangle R)
  69.         { Bounded=1; minx=R.x; miny=R.y; maxx=R.w+minx-1; maxy=R.h+miny-1; Bind(); }
  70. inline void MousePosition::Bound(int MinX=0, int MinY=0, int Width=MAXINT, int Height=MAXINT)
  71.         { Bounded=1; minx=MinX; miny=MinY; maxx=Width+minx-1; maxy=Height+miny-1; Bind(); }
  72. inline void MousePosition::SetLeft(int on) { Left=on; }
  73. inline void MousePosition::SetRight(int on) { Right=on; }
  74.  
  75.  
  76. #endif
  77.