home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / examples / Dreamscape / Examples / TestProg / h / picture next >
Encoding:
Text File  |  1996-07-29  |  2.6 KB  |  98 lines

  1.  
  2. #ifndef testprog_picture_H
  3. #define testprog_picture_H
  4.  
  5. #include "window.h"
  6. #include "winhandlers.h"
  7. #include "menu.h"
  8. #include "saveas.h"
  9. #include "colourdbox.h"
  10. #include "button.h"
  11. #include "actionbutton.h"
  12. #include "windowcmds.h"
  13. #include "graphic.h"
  14.  
  15. class Picture;
  16. ostream &operator<<(ostream &stream, const Picture &picture);
  17.  
  18. class Picture: public WindowRedrawable, public ClickHandler,
  19. public GraphicLoader<istream &, WindowFileInfo> {
  20.   Window window, &toolbar;
  21.   void redraw(const RedrawInfo &info) const;
  22.   bool single_click(const ClickInfo &click);
  23.   void load(const WindowFileInfo &info, istream &stream);
  24.  
  25.   ColourDBox colour_dbox;
  26.   ShowWindowCommand show_colour_dbox;
  27.   ActionButton &colour_button;
  28.  
  29.   class Shape: public WindowRedrawable {
  30.   protected:
  31.     WinCoords pos;
  32.     Colour colour;
  33.   public:
  34.     Shape(const WinCoords &p, Colour c): pos(p), colour(c) {}
  35.     virtual ~Shape() {}
  36.   };
  37.   List<Shape *> shapes;
  38.  
  39.   friend ostream &operator<<(ostream &stream, const Picture &picture);
  40.   SaveAsInserter<Picture> saver;
  41.   SaveAs &save_as;
  42.  
  43.   class Square: public Shape {
  44.   public:
  45.     Square(const WinCoords &p, Colour c): Shape(p, c) {}
  46.     virtual ~Square() {}
  47.     void redraw(const RedrawInfo &info) const;
  48.   };
  49.   class Circle: public Shape {
  50.   public:
  51.     Circle(const WinCoords &p, Colour c): Shape(p, c) {}
  52.     virtual ~Circle() {}
  53.     void redraw(const RedrawInfo &info) const;
  54.   };
  55.   class GraphicObject: public Shape {
  56.   public:
  57.     GraphicObject(Graphic *g): Shape(WinCoords(), no_colour), graphic(g) {}
  58.     virtual ~GraphicObject() { delete graphic; }
  59.     void redraw(const RedrawInfo &info) const;
  60.     Graphic *graphic;
  61.   };
  62.  
  63.   class ShapeButton: public ClickHandler {
  64.     Picture *picture;
  65.     Button *button;
  66.   public:
  67.     ShapeButton(Picture *p, Button *b): picture(p), button(b)
  68.       { button->set_handler(this); }
  69.     virtual ~ShapeButton() {}
  70.     bool single_click(const ClickInfo &click);
  71.     virtual Shape *make_shape(const WinCoords &p, Colour c) const = 0;
  72.     void set_selected(bool select) { button->set_selected(select); }
  73.     bool get_selected() const { return button->get_selected(); }
  74.   } *current;
  75.   friend ShapeButton;
  76.  
  77.   class SquareButton: public ShapeButton {
  78.   public:
  79.     SquareButton(Picture *p, Button *n): ShapeButton(p, n) {}
  80.     Shape *make_shape(const WinCoords &p, Colour c) const
  81.       { return new Square(p, c); }
  82.   } square;
  83.   class CircleButton: public ShapeButton {
  84.   public:
  85.     CircleButton(Picture *p, Button *n): ShapeButton(p, n) {}
  86.     Shape *make_shape(const WinCoords &p, Colour c) const
  87.       { return new Circle(p, c); }
  88.   } circle;
  89.  
  90.   DeleteObjectCommand<Picture> hide;
  91.  
  92. public:
  93.   Picture();
  94.   ~Picture();
  95. };
  96.  
  97. #endif
  98.