home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef testprog_picture_H
- #define testprog_picture_H
-
- #include "window.h"
- #include "winhandlers.h"
- #include "menu.h"
- #include "saveas.h"
- #include "colourdbox.h"
- #include "button.h"
- #include "actionbutton.h"
- #include "windowcmds.h"
- #include "graphic.h"
-
- class Picture;
- ostream &operator<<(ostream &stream, const Picture &picture);
-
- class Picture: public WindowRedrawable, public ClickHandler,
- public GraphicLoader<istream &, WindowFileInfo> {
- Window window, &toolbar;
- void redraw(const RedrawInfo &info) const;
- bool single_click(const ClickInfo &click);
- void load(const WindowFileInfo &info, istream &stream);
-
- ColourDBox colour_dbox;
- ShowWindowCommand show_colour_dbox;
- ActionButton &colour_button;
-
- class Shape: public WindowRedrawable {
- protected:
- WinCoords pos;
- Colour colour;
- public:
- Shape(const WinCoords &p, Colour c): pos(p), colour(c) {}
- virtual ~Shape() {}
- };
- List<Shape *> shapes;
-
- friend ostream &operator<<(ostream &stream, const Picture &picture);
- SaveAsInserter<Picture> saver;
- SaveAs &save_as;
-
- class Square: public Shape {
- public:
- Square(const WinCoords &p, Colour c): Shape(p, c) {}
- virtual ~Square() {}
- void redraw(const RedrawInfo &info) const;
- };
- class Circle: public Shape {
- public:
- Circle(const WinCoords &p, Colour c): Shape(p, c) {}
- virtual ~Circle() {}
- void redraw(const RedrawInfo &info) const;
- };
- class GraphicObject: public Shape {
- public:
- GraphicObject(Graphic *g): Shape(WinCoords(), no_colour), graphic(g) {}
- virtual ~GraphicObject() { delete graphic; }
- void redraw(const RedrawInfo &info) const;
- Graphic *graphic;
- };
-
- class ShapeButton: public ClickHandler {
- Picture *picture;
- Button *button;
- public:
- ShapeButton(Picture *p, Button *b): picture(p), button(b)
- { button->set_handler(this); }
- virtual ~ShapeButton() {}
- bool single_click(const ClickInfo &click);
- virtual Shape *make_shape(const WinCoords &p, Colour c) const = 0;
- void set_selected(bool select) { button->set_selected(select); }
- bool get_selected() const { return button->get_selected(); }
- } *current;
- friend ShapeButton;
-
- class SquareButton: public ShapeButton {
- public:
- SquareButton(Picture *p, Button *n): ShapeButton(p, n) {}
- Shape *make_shape(const WinCoords &p, Colour c) const
- { return new Square(p, c); }
- } square;
- class CircleButton: public ShapeButton {
- public:
- CircleButton(Picture *p, Button *n): ShapeButton(p, n) {}
- Shape *make_shape(const WinCoords &p, Colour c) const
- { return new Circle(p, c); }
- } circle;
-
- DeleteObjectCommand<Picture> hide;
-
- public:
- Picture();
- ~Picture();
- };
-
- #endif
-