// tools.h -- TGraphTool and derived tool classes header file

#ifndef __TOOLS_H
#define __TOOLS_H

#if !defined( __CLASSLIB_OBJSTRM_H )
  #include <classlib\objstrm.h>
#endif
#ifndef __POINT_H
  #include <owl\point.h>
#endif
#ifndef __DC_H
  #include <owl\dc.h>
#endif
#ifndef __GDIOBJEC_H
  #include <owl\gdiobjec.h>
#endif

// TGraphPen adds a default constructor to TPen,
// required for streaming TGraphTool objects
class TGraphPen: public TPen {
public:
  TGraphPen(): TPen(TColor::Black), color(TColor::Black) { }
  TGraphPen(TColor c): TPen(c), color(c) { }
  TColor GetColor() const { return color; }
private:
  TColor color;
};

// TGraphBrush adds a default constructor to TBrush,
// also required for streaming TGraphTool objects
class TGraphBrush: public TBrush {
public:
  TGraphBrush(): TBrush(TColor::White), color(TColor::White) { }
  TGraphBrush(TColor c): TBrush(c), color(c) { }
  TColor GetColor() const { return color; }
private:
  TColor color;
};

// Abstract base class for object-drawing tools
class TGraphTool: public virtual TStreamableBase {
public:
  TGraphTool();
  TGraphTool(TPoint p1, TPoint p2,
    TColor penColor, TColor brushColor);
  ~TGraphTool();
  void SetStartPt(TPoint p) { startPt = p; }
  void SetEndPt(TPoint p) { endPt = p; }
  void OffsetPoints(long xofs, long yofs);
  virtual TGraphTool * Clone() = 0;  // Pure virtual function
  virtual void Draw(TDC& dc) = 0;    // Pure virtual function
  void SelectAttributes(TDC& dc);
  void DeselectAttributes(TDC& dc);
  const TGraphPen* GetPen() const { return pen; }
  const TGraphBrush* GetBrush() const { return brush; }
  void SetPenColor(TColor color);
  void SetBrushColor(TColor color);
  int operator== (const TGraphTool& tool);
protected:
  TPoint startPt;
  TPoint endPt;
private:
  TGraphPen* pen;       // Pointer to tool's outline color
  TGraphBrush* brush;   // Pointer to tool's interor color
DECLARE_ABSTRACT_STREAMABLE( , TGraphTool, 1);
};

class TLine: public TGraphTool {
public:
  TLine(TPoint p1, TPoint p2,
    TColor penColor, TColor brushColor)
    : TGraphTool(p1, p2, penColor, brushColor) {};
  virtual TGraphTool * Clone();
  virtual void Draw(TDC& dc);
DECLARE_STREAMABLE( , TLine, 1);
};

class TEllipse: public TGraphTool {
public:
  TEllipse(TPoint p1, TPoint p2,
    TColor penColor, TColor brushColor)
    : TGraphTool(p1, p2, penColor, brushColor) {};
  virtual TGraphTool * Clone();
  virtual void Draw(TDC& dc);
DECLARE_STREAMABLE( , TEllipse, 1);
};

class TRectangle: public TGraphTool {
public:
  TRectangle(TPoint p1, TPoint p2,
    TColor penColor, TColor brushColor)
    : TGraphTool(p1, p2, penColor, brushColor) {};
  virtual TGraphTool * Clone();
  virtual void Draw(TDC& dc);
DECLARE_STREAMABLE( , TRectangle, 1);
};

#endif // __TOOLS_H

