From baac659433417ee555e3e04a28ea6c06fa23d588 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 12 Jul 2004 15:08:14 +0000 Subject: Widget slowly working... --- include/widgets.h | 96 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 13 deletions(-) (limited to 'include/widgets.h') diff --git a/include/widgets.h b/include/widgets.h index bef2682..116eef5 100644 --- a/include/widgets.h +++ b/include/widgets.h @@ -5,6 +5,18 @@ #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(); @@ -18,34 +30,92 @@ namespace mogltk { 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() = 0; + 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, caption; + String name; shape * sh; + widget * exclusive; void idraw(); + bool ievent(int x, int y, event_t event); + void icomputeabs(); }; - class drawer : public Base { - public: - virtual void draw(widget *) = 0; - }; + namespace widgets { + class drawer : public Base { + public: + virtual void draw(widget *) = 0; + }; - class Root : public widget { - public: - Root(shape *, drawer * = 0); - void setdrawer(drawer *); - protected: - virtual void draw(); - drawer * dr; + 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(); + }; }; }; -- cgit v1.2.3