]> Dogcows Code - chaz/openbox/blob - otk/widget.hh
add an OtkAppWidget which are "root windows", i.e. the managed child of root, to...
[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 "eventdispatcher.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(OtkEventDispatcher *event_dispatcher, Style *style,
26 Direction direction = Horizontal, Cursor cursor = 0,
27 int bevel_width = 1);
28
29 virtual ~OtkWidget();
30
31 virtual void update(void);
32
33 void exposeHandler(const XExposeEvent &e);
34 void configureHandler(const XConfigureEvent &e);
35
36 inline Window getWindow(void) const { return _window; }
37 inline const OtkWidget *getParent(void) const { return _parent; }
38 inline const OtkWidgetList &getChildren(void) const { return _children; }
39 inline unsigned int getScreen(void) const { return _screen; }
40 inline const Rect &getRect(void) const { return _rect; }
41
42 void move(const Point &to);
43 void move(int x, int y);
44
45 virtual void setWidth(int);
46 virtual void setHeight(int);
47
48 virtual int width() const { return _rect.width(); }
49 virtual int height() const { return _rect.height(); }
50
51 virtual void resize(const Point &to);
52 virtual void resize(int x, int y);
53
54 virtual void setGeometry(const Rect &new_geom);
55 virtual void setGeometry(const Point &topleft, int width, int height);
56 virtual void setGeometry(int x, int y, int width, int height);
57
58 inline bool isVisible(void) const { return _visible; };
59 virtual void show(void);
60 virtual void hide(void);
61
62 inline bool isFocused(void) const { return _focused; };
63 virtual void focus(void);
64
65 inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
66 bool grabMouse(void);
67 void ungrabMouse(void);
68
69 inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard; }
70 bool grabKeyboard(void);
71 void ungrabKeyboard(void);
72
73 inline BTexture *getTexture(void) const { return _texture; }
74 virtual void setTexture(BTexture *texture)
75 { _texture = texture; _dirty = true; }
76
77 virtual void addChild(OtkWidget *child, bool front = false);
78 virtual void removeChild(OtkWidget *child);
79
80 inline bool isStretchableHorz(void) const { return _stretchable_horz; }
81 void setStretchableHorz(bool s_horz) { _stretchable_horz = s_horz; }
82
83 inline bool isStretchableVert(void) const { return _stretchable_vert; }
84 void setStretchableVert(bool s_vert) { _stretchable_vert = s_vert; }
85
86 inline Cursor getCursor(void) const { return _cursor; }
87
88 inline int getBevelWidth(void) const { return _bevel_width; }
89 void setBevelWidth(int bevel_width)
90 { assert(bevel_width > 0); _bevel_width = bevel_width; }
91
92 inline Direction getDirection(void) const { return _direction; }
93 void setDirection(Direction dir) { _direction = dir; }
94
95 inline Style *getStyle(void) const { return _style; }
96 void setStyle(Style *style) { _style = style; }
97
98 inline OtkEventDispatcher *getEventDispatcher(void)
99 { return _event_dispatcher; }
100 void setEventDispatcher(OtkEventDispatcher *disp);
101
102 protected:
103
104 bool _dirty;
105
106 private:
107
108 void create(void);
109 void adjust(void);
110 void adjustHorz(void);
111 void adjustVert(void);
112 void internalResize(int width, int height);
113 void render(void);
114
115 Window _window;
116
117 OtkWidget *_parent;
118 OtkWidgetList _children;
119
120 Style *_style;
121 Direction _direction;
122 Cursor _cursor;
123 int _bevel_width;
124 int _ignore_config;
125
126 bool _visible;
127 bool _focused;
128
129 bool _grabbed_mouse;
130 bool _grabbed_keyboard;
131
132 bool _stretchable_vert;
133 bool _stretchable_horz;
134
135 BTexture *_texture;
136 Pixmap _bg_pixmap;
137 unsigned int _bg_pixel;
138
139 Rect _rect;
140 unsigned int _screen;
141
142 bool _fixed_width;
143 bool _fixed_height;
144
145 OtkEventDispatcher *_event_dispatcher;
146 OtkApplication *_application;
147 };
148
149 }
150
151 #endif // __widget_hh
This page took 0.051655 seconds and 5 git commands to generate.