home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- Listing 12 - ARC.HPP
-
-
- Written by Kevin D. Weeks, April 1990
- Released to the Public Domain
- */
- #if !defined(ARC_HPP)
- #define ARC_HPP
-
- #include "graphobj.hpp"
- #include "point.hpp"
-
- class Arc : virtual public Graphics_Object
- {
- public:
- // Constructors and destructor.
- Arc(void);
- Arc(const Arc &source)
- { copy(source); };
- Arc(const Arc *source);
- Arc(const int starting_angle, const int ending_angle,
- const int init_radius, const Point ¢er,
- const COLORS init_color = (COLORS)DEFAULT,
- const line_widths init_width = (line_widths)DEFAULT);
- ~Arc(void)
- { if (visible) erase(); };
-
- // Get attribute methods.
- virtual COLORS get_color(void)
- { return color; };
- virtual int get_start(void)
- { return start_angle; };
- virtual int get_end(void)
- { return end_angle; };
- virtual int get_radius(void)
- { return radius; };
- virtual Point& get_center(void)
- { return center; };
- virtual line_widths get_width(void)
- { return width; };
-
- // Set attribute methods.
- // NOTE: attempting to change start, end, radius, or center
- // of a visible object will fail quietly.
- virtual void set_start(const int new_start)
- { if (!visible) start_angle = new_start; };
- virtual void set_end(const int new_end)
- { if (!visible) end_angle = new_end; };
- virtual void set_radius(const int new_radius)
- { if (!visible) radius = new_radius; };
- virtual void set_center(const Point new_center)
- { if (!visible) center = new_center; };
- // both color and width can be changed whether the arc is visible or not
- virtual void set_color(const COLORS new_color = (COLORS)DEFAULT);
- virtual void set_width(line_widths new_width = (line_widths)DEFAULT);
-
- // Inherited methods.
- virtual void draw(void);
- virtual void erase(void);
- virtual void move_relative(Point &distance);
- virtual void move_absolute(Point &new_location, Point &reference);
-
- // Operators.
- Arc &operator=(const Arc &source)
- { return copy(source); };
-
- protected:
- // copy() is a private method used by both the copy constructor and the
- // = operator.
- Arc ©(const Arc &source);
-
- // the attributes should be self-evident
- COLORS color;
- int start_angle;
- int end_angle;
- int radius;
- Point center;
- line_widths width;
- };
-
- #endif
-