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

  1.  
  2.  
  3. #ifndef _arc_h_ /* Thu Jan  5 09:27:04 1995 */
  4. #define _arc_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. // This is a GraphicObject representing an arc of an ellipse. This is not a
  37. // closed figure unless the subtended angle is 360 degrees.
  38.  
  39.  
  40. #if defined(__GNUC__)
  41. #pragma interface
  42. #endif
  43.  
  44. #include "ui/rectangl.h"
  45.  
  46. class CL_EXPORT UI_Rectangle;
  47. class CL_EXPORT UI_Point;
  48. class CL_EXPORT UI_Ellipse;
  49.  
  50. class CL_EXPORT UI_Arc: public UI_GraphicObject {
  51.  
  52. public:
  53.     UI_Arc (const UI_Rectangle& boundingRect, long startAngleDeg64, long
  54.             subtendedDeg64);
  55.     // Construct an arc of an ellipse. The arc is part of the ellipse whose
  56.     // bounding rectangle is {\tt boundingRect}. Its starting point is at an
  57.     // angle {$d$} degrees from the 3-o'clock position of {\tt boundingRect}
  58.     // where $d = {\tt startAngleDeg64} * 64$, and it subtends an angle $s$
  59.     // at the center of the ellipse, where $s = {\tt subtendedDeg64} * 64$,
  60.  
  61.     UI_Arc (const UI_Point &p1, const UI_Point &p2, const UI_Point& origin);
  62.     // Construct an arc of an ellipse with the points p1, p2 being the
  63.     // start point and the end point and the origin being the center of
  64.     // the ellipse.
  65.     
  66.     bool DrawOn (UI_DrawingSurface& sfc,
  67.                  const UI_Point& p = UI_Point (0,0)) const;
  68.     // Draw the ellipse on the surface {\tt sfc} (overrides inherited
  69.     // method).
  70.  
  71.     bool ReshapeTo (const UI_Point& p1, const UI_Point& p2);
  72.     // Override method inherited from GraphicObject. The implementation
  73.     // reshapes the ellipse so that its bounding rectangle is the rectangle
  74.     // whose diagonally opposite points are p1 and p2.
  75.  
  76.  
  77.     UI_Rectangle BoundingRectangle() const;
  78.     // Returns the bounding rectangle of the ellipse of which this arc is
  79.     // part.
  80.  
  81.     UI_PointPair EndPoints () const;
  82.  
  83.     bool IntersectsBoundary (const UI_Rectangle& r) const;
  84.  
  85.     UI_HitTest HitTest (const UI_Point& p) const;
  86.     // Hit testing: overrides method inherited from Graphic.  This method
  87.     // always returns either Outside or Boundary, never Inside, because
  88.     // there is no ``inside'' of an arc. The only exception is if this arc
  89.     // is really a complete ellipse.
  90.     
  91.     long StartAngle() const;
  92.     // Return the start angle in sixty-fourths of a degree.
  93.  
  94.     long SubtendedAngle() const;
  95.     // Return the subtended angle in sixty-fourths of a degree.
  96.  
  97.     UI_Ellipse Ellipse () const;
  98.  
  99.     void StartAngle (long startAngle64);
  100.  
  101.     void SubtendedAngle (long subtAngle64);
  102.  
  103.     void Origin (const UI_Point &origin);
  104.     
  105.     const char* ClassName() const {return "UI_Arc";};
  106.  
  107. protected:
  108.  
  109.     UI_Rectangle _boundingEllipse;
  110.     UI_Rectangle _boundingRect;
  111.     long         _startAngle  ;
  112.     long         _subtAngle   ;
  113. };
  114.  
  115.  
  116.  
  117.  
  118. inline long UI_Arc::StartAngle() const
  119. {
  120.     return _startAngle;
  121. }
  122.  
  123.  
  124. inline long UI_Arc::SubtendedAngle() const
  125. {
  126.     return _subtAngle;
  127. }
  128.  
  129.  
  130. #endif /* _arc_h_ */
  131.  
  132.