]> Dogcows Code - chaz/openbox/blob - otk/widget.hh
added otkapplication and event stuff, changed other files to accomodate for this...
[chaz/openbox] / otk / widget.hh
1 #ifndef __widget_hh
2 #define __widget_hh
3
4 #include <string>
5 #include <list>
6
7 #include "rect.hh"
8 #include "point.hh"
9 #include "texture.hh"
10 #include "style.hh"
11 #include "eventhandler.hh"
12 #include "application.hh"
13
14 namespace otk {
15
16 class OtkWidget : public OtkEventHandler {
17
18 public:
19
20 enum Direction { Horizontal, Vertical };
21
22 typedef std::list<OtkWidget *> OtkWidgetList;
23
24 OtkWidget(OtkWidget *parent, Direction = Horizontal);
25 OtkWidget(OtkApplication *app, Direction direction = Horizontal,
26 Cursor cursor = 0, int bevel_width = 1);
27 OtkWidget(Style *style, Direction direction = Horizontal,
28 Cursor cursor = 0, int bevel_width = 1);
29
30 virtual ~OtkWidget();
31
32 virtual void update(void);
33
34 int exposeHandler(const XExposeEvent &e);
35 int configureHandler(const XConfigureEvent &e);
36
37 inline Window getWindow(void) const { return _window; }
38 inline const OtkWidget *getParent(void) const { return _parent; }
39 inline const OtkWidgetList &getChildren(void) const { return _children; }
40 inline unsigned int getScreen(void) const { return _screen; }
41 inline const Rect &getRect(void) const { return _rect; }
42
43 void move(const Point &to);
44 void move(int x, int y);
45
46 virtual void setWidth(int);
47 virtual void setHeight(int);
48
49 virtual int width() const { return _rect.width(); }
50 virtual int height() const { return _rect.height(); }
51
52 virtual void resize(const Point &to);
53 virtual void resize(int x, int y);
54
55 virtual void setGeometry(const Rect &new_geom);
56 virtual void setGeometry(const Point &topleft, int width, int height);
57 virtual void setGeometry(int x, int y, int width, int height);
58
59 inline bool isVisible(void) const { return _visible; };
60 virtual void show(void);
61 virtual void hide(void);
62
63 inline bool isFocused(void) const { return _focused; };
64 virtual void focus(void);
65
66 inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
67 bool grabMouse(void);
68 void ungrabMouse(void);
69
70 inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard; }
71 bool grabKeyboard(void);
72 void ungrabKeyboard(void);
73
74 inline BTexture *getTexture(void) const { return _texture; }
75 virtual void setTexture(BTexture *texture)
76 { _texture = texture; _dirty = true; }
77
78 virtual void addChild(OtkWidget *child, bool front = false);
79 virtual void removeChild(OtkWidget *child);
80
81 inline bool isStretchableHorz(void) const { return _stretchable_horz; }
82 void setStretchableHorz(bool s_horz) { _stretchable_horz = s_horz; }
83
84 inline bool isStretchableVert(void) const { return _stretchable_vert; }
85 void setStretchableVert(bool s_vert) { _stretchable_vert = s_vert; }
86
87 inline Cursor getCursor(void) const { return _cursor; }
88
89 inline int getBevelWidth(void) const { return _bevel_width; }
90 void setBevelWidth(int bevel_width)
91 { assert(bevel_width > 0); _bevel_width = bevel_width; }
92
93 inline Direction getDirection(void) const { return _direction; }
94 void setDirection(Direction dir) { _direction = dir; }
95
96 inline Style *getStyle(void) const { return _style; }
97 void setStyle(Style *style) { _style = style; }
98
99 private:
100
101 void create(void);
102 void adjust(void);
103 void adjustHorz(void);
104 void adjustVert(void);
105 void internalResize(int width, int height);
106 void render(void);
107
108 Window _window;
109
110 OtkWidget *_parent;
111 OtkWidgetList _children;
112
113 Style *_style;
114 Direction _direction;
115 Cursor _cursor;
116 int _bevel_width;
117 int _ignore_config;
118
119 bool _visible;
120 bool _focused;
121
122 bool _grabbed_mouse;
123 bool _grabbed_keyboard;
124
125 bool _stretchable_vert;
126 bool _stretchable_horz;
127
128 BTexture *_texture;
129 Pixmap _bg_pixmap;
130 unsigned int _bg_pixel;
131
132 Rect _rect;
133 unsigned int _screen;
134
135 bool _fixed_width;
136 bool _fixed_height;
137
138 bool _dirty;
139 };
140
141 }
142
143 #endif // __widget_hh
This page took 0.041295 seconds and 5 git commands to generate.