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

  1. /**************************************************************************
  2.     Listing 8 - LINE.HPP
  3.  
  4.     Written by Kevin D. Weeks, April 1990
  5.     Released to the Public Domain
  6. */
  7. #if !defined(LINE_HPP)
  8. #define LINE_HPP
  9.  
  10. #include "graphobj.hpp"
  11. #include "point.hpp"
  12.  
  13. class Line : virtual public Graphics_Object
  14. {
  15.   public:
  16. // Constructors and destructor.
  17.     Line(void);
  18.     Line(const Line &source)
  19.         { copy(source); };
  20.     Line(const Line *source);
  21.     Line(const Point begin, const Point finish,
  22.          const COLORS init_color = (COLORS)DEFAULT,
  23.          const line_styles init_style = (line_styles)DEFAULT,
  24.          const line_widths init_width = (line_widths)DEFAULT);
  25.     ~Line(void)
  26.         { if(visible) erase(); };
  27.  
  28. // Get attribute methods
  29.     virtual Point&  get_start(void)
  30.                     { return start; };
  31.     virtual Point&  get_end(void)
  32.                     { return end; };
  33.     virtual line_styles get_style(void)
  34.                     { return style; };
  35.     virtual line_widths get_width(void)
  36.                     { return width; };
  37.     virtual COLORS  get_color(void)
  38.                     { return color; };
  39.  
  40. // Set attribute methods.
  41.     // NOTE: if the object is visible the set_start() and set_end()
  42.     // methods will fail quietly.
  43.     virtual void    set_start(const Point new_start)
  44.                     { if (!visible) start = new_start; };
  45.     virtual void    set_end(const Point new_end)
  46.                     { if (!visible) end = new_end; };
  47.  
  48.     // color, style, and width can be changed whether the line is visible
  49.     // or not.
  50.     virtual void    set_style(line_styles new_style = (line_styles)DEFAULT);
  51.     virtual void    set_width(line_widths new_width = (line_widths)DEFAULT);
  52.     virtual void    set_color(const COLORS new_color = (COLORS)DEFAULT);
  53.  
  54. // Inherited methods.
  55.     virtual void    draw(void);
  56.     virtual void    erase(void);
  57.     virtual void    move_relative(Point &distance);
  58.     virtual void    move_absolute(Point &new_location, Point &reference);
  59.  
  60. // Operators.
  61.     Line            &operator=(const Line &source)
  62.                     { return copy(source); };
  63.  
  64.   private:
  65.     // this method is used by both the copy constructor and operator =
  66.     Line            ©(const Line &source);
  67.  
  68.     // these attributes should be obvious
  69.     Point           start;
  70.     Point           end;
  71.     COLORS          color;              // COLORS, line_styles, and
  72.     line_styles     style;              //    line_widths are defined in
  73.     line_widths     width;              //    include\graphics.h
  74. };
  75.  
  76. #endif
  77.