home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 3.ddi / BGICLA.ZIP / ARC.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-24  |  2.8 KB  |  83 lines

  1. /**************************************************************************
  2.     Listing 12  -   ARC.HPP
  3.  
  4.  
  5.     Written by Kevin D. Weeks, April 1990
  6.     Released to the Public Domain
  7. */
  8. #if !defined(ARC_HPP)
  9. #define ARC_HPP
  10.  
  11. #include "graphobj.hpp"
  12. #include "point.hpp"
  13.  
  14. class Arc : virtual public Graphics_Object
  15. {
  16.   public:
  17. // Constructors and destructor.
  18.     Arc(void);
  19.     Arc(const Arc &source)
  20.     { copy(source); };
  21.     Arc(const Arc *source);
  22.     Arc(const int starting_angle, const int ending_angle,
  23.                 const int init_radius, const Point ¢er,
  24.                 const COLORS init_color = (COLORS)DEFAULT,
  25.                 const line_widths init_width = (line_widths)DEFAULT);
  26.     ~Arc(void)
  27.             { if (visible) erase(); };
  28.  
  29. // Get attribute methods.
  30.     virtual COLORS  get_color(void)
  31.                     { return color; };
  32.     virtual int     get_start(void)
  33.                     { return start_angle; };
  34.     virtual int     get_end(void)
  35.                     { return end_angle; };
  36.     virtual int     get_radius(void)
  37.                     { return radius; };
  38.     virtual Point&  get_center(void)
  39.                     { return center; };
  40.     virtual line_widths get_width(void)
  41.                         { return width; };
  42.  
  43. // Set attribute methods.
  44.     // NOTE: attempting to change start, end, radius, or center
  45.     // of a visible object will fail quietly.
  46.     virtual void    set_start(const int new_start)
  47.                     { if (!visible) start_angle = new_start; };
  48.     virtual void    set_end(const int new_end)
  49.                     { if (!visible) end_angle = new_end; };
  50.     virtual void    set_radius(const int new_radius)
  51.                     { if (!visible) radius = new_radius; };
  52.     virtual void    set_center(const Point new_center)
  53.                     { if (!visible) center = new_center; };
  54.     // both color and width can be changed whether the arc is visible or not
  55.     virtual void    set_color(const COLORS new_color = (COLORS)DEFAULT);
  56.     virtual void    set_width(line_widths new_width = (line_widths)DEFAULT);
  57.  
  58. // Inherited methods.
  59.     virtual void    draw(void);
  60.     virtual void    erase(void);
  61.     virtual void    move_relative(Point &distance);
  62.     virtual void    move_absolute(Point &new_location, Point &reference);
  63.  
  64. // Operators.
  65.     Arc             &operator=(const Arc &source)
  66.                     { return copy(source); };
  67.  
  68.   protected:
  69.     // copy() is a private method used by both the copy constructor and the
  70.     // = operator.
  71.     Arc             ©(const Arc &source);
  72.  
  73.     // the attributes should be self-evident
  74.     COLORS          color;
  75.     int             start_angle;
  76.     int             end_angle;
  77.     int             radius;
  78.     Point           center;
  79.     line_widths     width;
  80. };
  81.  
  82. #endif
  83.