#ifndef __WIDGETS_H__ #define __WIDGETS_H__ #include #include namespace mogltk { enum event_t { E_MOUSE_START_DRAG, E_MOUSE_DRAG, E_MOUSE_DRAG_OVER, E_MOUSE_END_DRAG, E_MOUSE_END_DRAG_OVER, E_MOUSE_MOVE, E_MOUSE_DOWN, E_MOUSE_UP, E_MOUSE_CLICK, E_MOUSE_DBL_CLICK, }; class widget : public Base { public: virtual ~widget(); void move(int x, int y); void resize(int sx, int sy); int GetX(); int GetY(); int GetH(); int GetW(); int GetAX(); int GetAY(); int GetAX2(); int GetAY2(); widget * Father(); widget * Child(); widget * Next(); widget * Prev(); void fulldraw(); shape * Shaper(); void mainloop(); void m_event(int x, int y, event_t event); bool inside(int x, int y); protected: widget(widget * father, int x, int y, int sx, int sy, int type, String name, shape *); virtual void draw(); String caption; virtual bool process_event(int x, int y, event_t event); void set_exclusive(widget *); void unset_exclusive(widget *); private: void computeabs(); int x, y, sx, sy, ax, ay, ax2, ay2; widget * father, * next, * prev, * child, * root; static widget * focused; int type; String name; shape * sh; widget * exclusive; void idraw(); bool ievent(int x, int y, event_t event); void icomputeabs(); }; namespace widgets { class drawer : public Base { public: virtual void draw(widget *) = 0; }; class action : public Base { public: virtual void do_action(widget *) = 0; }; class Root : public widget { public: Root(shape *, drawer * = 0); void setdrawer(drawer *); protected: virtual void draw(); drawer * dr; }; class Button : public widget { public: Button(action *, shape *, widget * father, int x, int y, int w, int h, const String & caption); protected: virtual void draw(); virtual bool process_event(int, int, event_t); bool bevel; private: bool dragging; action * a; }; class Label : public widget { public: Label(shape *, widget * father, int x, int y, int w, int h, const String & caption, const ColorP & color = BLACK); protected: virtual void draw(); private: ColorP color; }; class SmartBox : public widget { public: SmartBox(shape *, widget * father, int x, int y, int w, int h, const String & caption); protected: virtual void draw(); virtual bool process_event(int, int, event_t); private: int ox, oy, oax, oay; }; class MsgBox : public SmartBox { public: MsgBox(shape *, widget * father, const String & caption, const String & text); virtual ~MsgBox(); }; }; }; #endif