]> Dogcows Code - chaz/openbox/blob - otk/widget.hh
fixed bugs, got otkapp to select on a fd, modded widget to make use of otkapp, press...
[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 inline OtkEventDispatcher *getEventDispatcher(void)
100 { return _event_dispatcher; }
101 void setEventDispatcher(OtkEventDispatcher *disp);
102
103 private:
104
105 void create(void);
106 void adjust(void);
107 void adjustHorz(void);
108 void adjustVert(void);
109 void internalResize(int width, int height);
110 void render(void);
111
112 Window _window;
113
114 OtkWidget *_parent;
115 OtkWidgetList _children;
116
117 Style *_style;
118 Direction _direction;
119 Cursor _cursor;
120 int _bevel_width;
121 int _ignore_config;
122
123 bool _visible;
124 bool _focused;
125
126 bool _grabbed_mouse;
127 bool _grabbed_keyboard;
128
129 bool _stretchable_vert;
130 bool _stretchable_horz;
131
132 BTexture *_texture;
133 Pixmap _bg_pixmap;
134 unsigned int _bg_pixel;
135
136 Rect _rect;
137 unsigned int _screen;
138
139 bool _fixed_width;
140 bool _fixed_height;
141
142 bool _dirty;
143
144 OtkEventDispatcher *_event_dispatcher;
145 };
146
147 }
148
149 #endif // __widget_hh
This page took 0.040646 seconds and 5 git commands to generate.