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

  1. /**************************************************************************
  2.     Listing 6   -   DOT.HPP
  3.  
  4.     Written by Kevin D. Weeks, April 1990
  5.     Released to the Public Domain
  6. */
  7. #if !defined(DOT_HPP)
  8. #define DOT_HPP
  9.  
  10. #include "graphobj.hpp"
  11. #include "point.hpp"
  12.  
  13. class Dot : virtual public Graphics_Object
  14. {
  15.   public:
  16. // Constructors and destructor.
  17.             Dot(void);
  18.             Dot(const Dot &source)
  19.             { copy(source); };
  20.             Dot(const Dot *source);
  21.             Dot(const Point &init_location,
  22.                 COLORS init_color = (COLORS)DEFAULT);
  23.             ~Dot(void)
  24.             { if (visible) erase(); };
  25.  
  26. // Get attribute methods.
  27.     virtual Point   &get_location(void)
  28.                     { return location; };
  29.     virtual int     get_x(void)
  30.                     { return location.get_x(); };
  31.     virtual int     get_y(void)
  32.                     { return location.get_y(); };
  33.     virtual COLORS  get_color(void)
  34.                     { return color; };
  35.  
  36. // Set attribute methods.
  37.     // NOTE: if the object is visible then attempts to modify its position
  38.     // attributes will fail quietly.
  39.     virtual void    set_location(const Point &new_location)
  40.                      { if (!visible) location = new_location; };
  41.     virtual void    set_x(const int new_x)
  42.                      { if (!visible) location.set_x(new_x); };
  43.     virtual void    set_y(const int new_y)
  44.                      { if (!visible) location.set_y(new_y); };
  45.     virtual void    set_color(COLORS new_color = (COLORS)DEFAULT);
  46.  
  47. // Inherited methods.
  48.     virtual void    draw(void);
  49.     virtual void    erase(void);
  50.     virtual void    move_relative(Point &distance);
  51.     virtual void    move_absolute(Point &new_location, Point &reference);
  52.  
  53. // Operators.
  54.     Dot     &operator=(const Dot &source)
  55.             { return copy(source); };
  56.  
  57.   private:
  58.     // this method is used by both the copy constructor and oprator=
  59.     Dot            ©(const Dot &source);
  60.  
  61.     // the attributes should be self-evident
  62.     Point           location;
  63.     COLORS          color;
  64. };
  65.  
  66. #endif
  67.