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

  1. /**************************************************************************
  2.     Listing 10 - POLYGON.HPP
  3.  
  4.     Written by Kevin D. Weeks, April 1990
  5.     Released to the Public Domain
  6.  
  7.     This class varies rather sharply from the BGI polygon in that its
  8.     sides are composed of lines which can be manipulated individually.
  9.     In addition, fill() is a method of the standard polygon rather than
  10.     a separate filled polygon type.
  11. */
  12. #if !defined(POLYGON_HPP)
  13. #define POLYGON_HPP
  14.  
  15. #include "graphobj.hpp"
  16. #include "point.hpp"
  17. #include "line.hpp"
  18.  
  19. class Polygon : virtual public Graphics_Object
  20. {
  21.   public:
  22. // Constructors and destructor.
  23.     // notice that a polygon can be declared as either a set of
  24.     // Points or a set of Lines.
  25.     Polygon(void);
  26.     Polygon(const Polygon &source)
  27.     { copy(source); };
  28.     Polygon(const Polygon *source);
  29.     Polygon(const int num_vertices, const Point *vertex,
  30.             const COLORS side_color = (COLORS)DEFAULT,
  31.             const COLORS init_color = (COLORS)DEFAULT,
  32.             const line_styles side_style = (line_styles)DEFAULT,
  33.             const line_widths side_width = (line_widths)DEFAULT,
  34.             const fill_patterns init_pattern = (fill_patterns)DEFAULT);
  35.     Polygon(const int num_sides, const Line *init_side,
  36.             const COLORS side_color = (COLORS)DEFAULT,
  37.             const COLORS init_color = (COLORS)DEFAULT,
  38.             const line_styles side_style = (line_styles)DEFAULT,
  39.             const line_widths side_width = (line_widths)DEFAULT,
  40.             const fill_patterns init_pattern = (fill_patterns)DEFAULT);
  41.     ~Polygon(void);
  42.  
  43. // Get attribute methods.
  44.     virtual Line            &side(const int side_number);
  45.     virtual int             get_num_sides(void)
  46.                             { return num_sides; };
  47.     virtual fill_patterns   get_pattern(void)
  48.                             { return fill_pattern; };
  49.     virtual COLORS          get_color(void)
  50.                             { return fill_color; };
  51.  
  52. // Set attribute methods.
  53.     virtual void            set_side_color(COLORS new_color =
  54.                                           (COLORS)DEFAULT);
  55.     virtual void            set_side_style(line_styles new_style =
  56.                                            (line_styles)DEFAULT);
  57.     virtual void            set_side_width(line_widths new_width =
  58.                                            (line_widths)DEFAULT);
  59.     virtual void            set_color(const COLORS new_color);
  60.     virtual void            set_pattern(const fill_patterns new_pattern);
  61.  
  62.     virtual void            fill(void);     // fill the polygon
  63.     virtual void            empty(void);    // clear the polygon
  64.  
  65. // Inherited methods.
  66.     virtual void            draw(void);
  67.     virtual void            erase(void);
  68.     virtual void            move_relative(Point &distance);
  69.     virtual void            move_absolute(Point &new_location, Point &reference);
  70.  
  71. // Operators.
  72.     virtual Polygon         &operator=(const Polygon &source)
  73.                             { return copy(source); };
  74.  
  75.   protected:
  76.     // these attributes are declared as protected so that descendant
  77.     // classes such as Rectangle, Square, etc may access them directly.
  78.     Line            **sides;
  79.     int             num_sides;
  80.     COLORS          line_color;
  81.     COLORS          fill_color;
  82.     fill_patterns   fill_pattern;
  83.     int             filled;
  84.  
  85.   private:
  86.     Polygon         ©(const Polygon &source);
  87. };
  88.  
  89. #endif
  90.