home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n08 / sketchsc.exe / STROKE.H < prev    next >
C/C++ Source or Header  |  1995-08-01  |  4KB  |  102 lines

  1. //-----------------------------------------------------------------------
  2. // STROKE.H: Definitions for drawing_element, stroke, line
  3. //-----------------------------------------------------------------------
  4. #ifndef STROKE_H__
  5. #define STROKE_H__
  6.  
  7. #include "mywin.h"
  8.  
  9. // A drawing_element is not serializable because it's an abstract class.
  10. // Classes that derive from drawing_element must be serializeable, and
  11. // they should secify CObject (not drawing_element) in their 
  12. // IMPLEMENT_SERIAL macros.
  13.  
  14. class drawing_element : public CObject
  15. {
  16.  
  17.     unsigned short     width;    // actually a pen_width, but type-conversion problems
  18.                             // in Serialize preclude use of the enum.
  19. protected:
  20.     virtual void Serialize(CArchive& ar);
  21.  
  22.     void draw_line ( device *echo_dc, const CPoint &start, const CPoint &end ) const;
  23.     void erase_line( device *echo_dc, const CPoint &start, const CPoint &end ) const;
  24.  
  25.     void drawing_element::adjust_rect_for_pen_width( CRect *bound ) const;
  26.  
  27. public:
  28.     virtual void start_load        ( const CPoint &first_point, device *echo_to_here ) =0;
  29.     virtual void mouse_has_moved( const CPoint &new_point,     device *echo_to_here ) =0;
  30.     virtual int  end_load       ( const CPoint &end_point,     device *echo_to_here ) =0;
  31.  
  32.     virtual void     draw            ( device  *dc    ) const =0;
  33.     virtual void     render_as_text    ( device  *dc    ) const =0;
  34.     virtual void     invalidate        ( CWnd *p        ) const =0;
  35.     virtual unsigned is_in            ( CRect region    ) const =0;
  36.  
  37. public:
  38.     virtual ~drawing_element();
  39.     drawing_element( unsigned use_thick_line = 0 );
  40.  
  41. };
  42. //======================================================================/
  43. class stroke : public drawing_element
  44. {
  45.     enum serialize_schema { version = 1 };
  46.  
  47.     CRect                    bounding;    // bounding rectangle for the stroke
  48.     CArray<CPoint, CPoint>    points;        // connect these to form the stroke
  49.  
  50.     CPoint                    prev_point; // Used only for loading, but the
  51.                                         // size overhead is low in comparison
  52.                                         // to the points list.
  53. protected:
  54.     DECLARE_SERIAL( stroke );
  55.     virtual void Serialize    ( CArchive &ar );
  56.  
  57. public:
  58.     virtual ~stroke( void );
  59.     stroke( unsigned use_thick_lines = 0 );
  60.  
  61.     virtual void start_load        ( const CPoint &first_point,
  62.                                   device           *echo_to_here );
  63.     virtual void mouse_has_moved( const CPoint &new_point, 
  64.                                   device           *echo_to_here );
  65.     virtual int  end_load       ( const CPoint &end_point, 
  66.                                   device           *echo_to_here );
  67.  
  68.     virtual void     draw            ( device  *dc                 ) const;
  69.     virtual void     render_as_text    ( device  *dc    ) const;
  70.     virtual unsigned is_in            ( CRect region            ) const;
  71.     virtual void     invalidate        ( CWnd *p                ) const;
  72. };
  73. //======================================================================/
  74. class line : public drawing_element
  75. {
  76.     enum serialize_schema { version = 1 };
  77.  
  78.     CPoint    first, last;
  79.  
  80. protected:
  81.     DECLARE_SERIAL( line );
  82.     virtual void Serialize    ( CArchive &ar );
  83.  
  84. public:
  85.     virtual ~line( void );
  86.     line( unsigned use_thick_lines = 0 );
  87.  
  88.     virtual void start_load        ( const CPoint &first_point,
  89.                                   device           *echo_to_here );
  90.     virtual void mouse_has_moved( const CPoint &new_point, 
  91.                                   device           *echo_to_here );
  92.     virtual int  end_load       ( const CPoint &end_point, 
  93.                                   device           *echo_to_here );
  94.  
  95.     virtual void     draw            ( device  *dc                 ) const;
  96.     virtual void     render_as_text    ( device  *dc    ) const;
  97.     virtual unsigned is_in            ( CRect region            ) const;
  98.     virtual void     invalidate        ( CWnd *p                ) const;
  99. };
  100.  
  101. #endif // STROKE_H__
  102.