summaryrefslogtreecommitdiff
path: root/include/widgets.h
diff options
context:
space:
mode:
authorpixel <pixel>2004-07-15 13:41:31 +0000
committerpixel <pixel>2004-07-15 13:41:31 +0000
commit55524da6af5a98df4d9c38d8408cd65bd233ee57 (patch)
tree714838bc565d0ff0a77ded92ff2c5549b58e7c98 /include/widgets.h
parent652aa99bd5fddbb4ee878ddd65ac637a134dbcbc (diff)
Some more widgets introduced
Diffstat (limited to 'include/widgets.h')
-rw-r--r--include/widgets.h92
1 files changed, 87 insertions, 5 deletions
diff --git a/include/widgets.h b/include/widgets.h
index 116eef5..939c753 100644
--- a/include/widgets.h
+++ b/include/widgets.h
@@ -3,6 +3,7 @@
#include <Exceptions.h>
#include <shape.h>
+#include <base.h>
namespace mogltk {
enum event_t {
@@ -12,16 +13,18 @@ namespace mogltk {
E_MOUSE_END_DRAG,
E_MOUSE_END_DRAG_OVER,
E_MOUSE_MOVE,
+ E_MOUSE_OUT,
E_MOUSE_DOWN,
E_MOUSE_UP,
E_MOUSE_CLICK,
+ E_MOUSE_OUT_CLICK,
E_MOUSE_DBL_CLICK,
};
class widget : public Base {
public:
virtual ~widget();
- void move(int x, int y);
- void resize(int sx, int sy);
+ virtual void move(int x, int y);
+ virtual void resize(int sx, int sy);
int GetX();
int GetY();
int GetH();
@@ -30,6 +33,7 @@ namespace mogltk {
int GetAY();
int GetAX2();
int GetAY2();
+ virtual mogltk::rect GetDrawRect();
widget * Father();
widget * Child();
widget * Next();
@@ -39,15 +43,23 @@ namespace mogltk {
void mainloop();
void m_event(int x, int y, event_t event);
bool inside(int x, int y);
+ bool GetVisible();
+ virtual void SetVisible(bool);
+ bool GetEnabled();
+ virtual void SetEnabled(bool);
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);
+ virtual void resize_notify();
void set_exclusive(widget *);
void unset_exclusive(widget *);
+ void add_out_move();
+ void remove_out_move();
+ void add_out_click();
+ void remove_out_click();
+ String caption;
private:
- void computeabs();
int x, y, sx, sy, ax, ay, ax2, ay2;
widget * father, * next, * prev, * child, * root;
static widget * focused;
@@ -55,9 +67,14 @@ namespace mogltk {
String name;
shape * sh;
widget * exclusive;
- void idraw();
+ bool visible;
+ bool enabled;
+
+ void computeabs();
+ void idraw();
bool ievent(int x, int y, event_t event);
void icomputeabs();
+ void iresize_notify();
};
namespace widgets {
@@ -104,6 +121,7 @@ namespace mogltk {
class SmartBox : public widget {
public:
SmartBox(shape *, widget * father, int x, int y, int w, int h, const String & caption);
+ virtual rect GetDrawRect();
protected:
virtual void draw();
virtual bool process_event(int, int, event_t);
@@ -116,6 +134,70 @@ namespace mogltk {
MsgBox(shape *, widget * father, const String & caption, const String & text);
virtual ~MsgBox();
};
+
+ class Frame : public widget {
+ public:
+ Frame(shape *, widget * father, int x, int y, int w, int h);
+ virtual rect GetDrawRect();
+ protected:
+ virtual void draw();
+ };
+
+ class ContextMenu : public widget {
+ public:
+ ContextMenu(shape *, widget * father, int x, int y);
+ virtual ~ContextMenu();
+ void addnode(const String &, action *);
+ void addline();
+ void addsub(const String &, ContextMenu *);
+ ContextMenu * createsub(const String &);
+ virtual void move(int x, int y);
+ virtual void resize(int w, int h);
+ virtual void SetVisible(bool);
+ virtual void SetEnabled(int i, bool);
+ protected:
+ virtual void draw();
+ virtual bool process_event(int x, int y, event_t event);
+ class node : public Base {
+ public:
+ node(const String &, int x, int y, int w, int h, action * = 0, ContextMenu * sub = 0, ContextMenu * father = 0, bool = false);
+ String GetCaption();
+ action * GetAction();
+ ContextMenu * GetSub();
+ ContextMenu * GetFather();
+ bool GetLine();
+ bool GetEnabled();
+ void SetEnabled(bool);
+ int GetX();
+ int GetY();
+ int GetW();
+ int GetH();
+ private:
+ String caption;
+ int x, y, w, h;
+ action * a;
+ ContextMenu * sub, * father;
+ bool line, enabled;
+ };
+
+ std::vector<node> nodes;
+ int selected;
+ ContextMenu * subselected;
+ private:
+ bool in_click;
+
+ bool iin_click();
+ };
+
+ class Menu : public widget {
+ public:
+ Menu(shape *, widget * father);
+ virtual void resize_notify();
+ protected:
+ virtual void draw();
+ virtual bool process_event(int, int, event_t);
+ private:
+ };
};
};