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

  1. /**************************************************************************
  2.     Listing 5 - GRAPHOBJ.HPP
  3.  
  4.     Written by Kevin D. Weeks, April 1990
  5.     Released to the Public Domain
  6.  
  7.         This is an abstract base class. All methods are declared as pure
  8.     virtual functions. I considered adding references to COLOR but decided
  9.     against it since Polygons and Circles may have both a fill_color and
  10.     line_color(s).
  11.  
  12.     General rules for descendants of this class:
  13.         Attempts to set the co-ordinates of "visible" objects will fail
  14.             quietly.
  15.         A "copy constructor" and an operator=() method should always be
  16.             defined. Their primary purpose is to ensure that the "visible"
  17.             attribute is always set to FALSE until the specific object is
  18.             explicitly draw()n.
  19. */
  20. #if !defined(GRAPHOBJ_HPP)
  21. #define GRAPHOBJ_HPP
  22.  
  23. #include <graphics.h>
  24. #include "point.hpp"
  25.  
  26. // DEFAULT is used by descendant classes to indicate that default para-
  27. // meters should be used.
  28. #define DEFAULT     -1
  29.  
  30. class Graphics_Object
  31. {
  32.   public:
  33.     // the methods followed by " = 0;" are 'pure' methods
  34.     virtual void    draw(void) = 0;
  35.     virtual void    erase(void) = 0;
  36.     virtual void    move_relative(Point &distance) = 0;
  37.     virtual void    move_absolute(Point &new_location, Point &reference) = 0;
  38.     virtual Bool    is_visible(void)
  39.                     { return visible; };
  40.   protected:
  41.     Bool    visible;
  42. };
  43.  
  44. #endif
  45.