summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorpixel <pixel>2004-07-12 15:08:14 +0000
committerpixel <pixel>2004-07-12 15:08:14 +0000
commitbaac659433417ee555e3e04a28ea6c06fa23d588 (patch)
tree0bff5e30087de61b6dddbb3de30174e3222bcde2 /include
parent5cc874802b0b8c4462e7e873654e6daa54be00de (diff)
Widget slowly working...
Diffstat (limited to 'include')
-rw-r--r--include/glwidgets.h32
-rw-r--r--include/widgets.h96
2 files changed, 100 insertions, 28 deletions
diff --git a/include/glwidgets.h b/include/glwidgets.h
index b606a14..241dd55 100644
--- a/include/glwidgets.h
+++ b/include/glwidgets.h
@@ -1,15 +1,17 @@
-#ifndef __GLWIDGETS_H__
-#define __GLWIDGETS_H__
-
-#include <widgets.h>
-
-namespace mogltk {
- class glRoot : public Root {
- public:
- glRoot(shape *);
- protected:
- virtual void draw();
- };
-};
-
-#endif
+#ifndef __GLWIDGETS_H__
+#define __GLWIDGETS_H__
+
+#include <widgets.h>
+
+namespace mogltk {
+ namespace widgets {
+ class glRoot : public Root {
+ public:
+ glRoot(shape *);
+ protected:
+ virtual void draw();
+ };
+ };
+};
+
+#endif
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 <shape.h>
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();
+ };
};
};