home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / point.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  2KB  |  101 lines

  1.  
  2.  
  3. #ifndef _point_h_
  4. #define _point_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34.  
  35.  
  36.  
  37. #if defined(__GNUC__)
  38. #pragma interface
  39. #endif
  40.  
  41.  
  42. #include "base/map.h"
  43. #include "base/binding.h"
  44.  
  45.  
  46.  
  47. //  This is a class representing a point in the X-Y coordinate system.
  48.  
  49.  
  50.  
  51. class CL_EXPORT UI_Point: public CL_Object {
  52.  
  53. public:
  54.    
  55.     UI_Point (long px = 0,long py = 0);
  56.     
  57.     UI_Point (const UI_Point& );
  58.  
  59.     ~UI_Point () {};
  60.     
  61.     long  XCoord() const {return x;};
  62.  
  63.     long  YCoord() const {return y;};
  64.  
  65.     void  AddToX (long value);
  66.  
  67.     void  AddToY (long value);
  68.  
  69.     UI_Point operator+ (const UI_Point&) const;
  70.  
  71.     void operator+=    (const UI_Point& p) {*this = *this + p;};
  72.     
  73.     UI_Point operator- (const UI_Point&) const;
  74.  
  75.     void operator-=    (const UI_Point& p) {*this = *this - p;};
  76.  
  77.     long operator* (const UI_Point& p) const;
  78.     // Cross product: see Cormen, Leiserson and Rivest, p 888, for
  79.     // definition. This is  $x_1*y_2 - x_2*y_1$.
  80.     
  81.     void operator= (const CL_Object&);
  82.  
  83.     void operator= (const UI_Point&);
  84.  
  85.     bool operator== (const CL_Object& p) const;
  86.  
  87.     bool operator== (const UI_Point& p) const;
  88.  
  89.     CL_String AsString() const;
  90.     // Return a string that looks like \verb|"(23, 15)"|.
  91.     
  92.  
  93.  
  94.  
  95. protected:
  96.    
  97.     long x,y;
  98. };
  99.  
  100. #endif
  101.