home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / RECTANGL.H < prev    next >
C/C++ Source or Header  |  1993-03-15  |  817b  |  34 lines

  1. // -------- rectangl.h
  2.  
  3. #ifndef RECTANGL_H
  4. #define RECTANGL_H
  5.  
  6. #include "dflatdef.h"
  7.  
  8. class Rect    {
  9.     int left,top,right,bottom;
  10. public:
  11.     Rect() {};
  12.     Rect(int l, int t, int r, int b)
  13.         { left = l; top = t; right = r; bottom = b; }
  14.     int &Top()        { return top; }
  15.     int &Bottom()    { return bottom; }
  16.     int &Left()        { return left; }
  17.     int &Right()    { return right; }
  18.     int Height()    { return bottom-top+1; }
  19.     int Width()        { return right-left+1; }
  20.     Bool Inside(int x, int y)
  21.         { return (Bool)(x >= left && x <= right && y >= top && y <= bottom); }
  22.     Rect subRectangle(Rect &rc);
  23.     Bool ValidRectangle()
  24.         { return (Bool) (right != -1 && top != -1); }
  25.     Bool operator==(Rect rc)
  26.         { return (Bool) (right == rc.right && top == rc.top &&
  27.                          left == rc.left && bottom == rc.bottom); }
  28. };
  29.  
  30. #endif
  31.  
  32.  
  33.  
  34.