]> Dogcows Code - chaz/openbox/blob - otk/widget.hh
manage and unmanage windows in OBScreen
[chaz/openbox] / otk / widget.hh
1 #include <string>
2 #include <list>
3
4 #include "rect.hh"
5 #include "point.hh"
6 #include "texture.hh"
7 #include "style.hh"
8
9 namespace otk {
10
11 class OtkWidget {
12
13 public:
14
15 enum Direction { Horizontal, Vertical };
16
17 typedef std::list<OtkWidget *> OtkWidgetList;
18
19 OtkWidget(OtkWidget *parent, Direction = Horizontal);
20 OtkWidget(Style *style, Direction direction = Horizontal,
21 Cursor cursor = 0, int bevel_width = 1);
22
23 virtual ~OtkWidget();
24
25 inline Window getWindow(void) const { return _window; }
26 inline const OtkWidget *getParent(void) const { return _parent; }
27 inline const OtkWidgetList &getChildren(void) const { return _children; }
28 inline unsigned int getScreen(void) const { return _screen; }
29 inline const Rect &getRect(void) const { return _rect; }
30
31 void move(const Point &to);
32 void move(int x, int y);
33
34 virtual void resize(const Point &to);
35 virtual void resize(int x, int y);
36
37 virtual void setGeometry(const Rect &new_geom);
38 virtual void setGeometry(const Point &topleft, int width, int height);
39 virtual void setGeometry(int x, int y, int width, int height);
40
41 inline bool isVisible(void) const { return _visible; };
42 virtual void show(void);
43 virtual void hide(void);
44
45 inline bool isFocused(void) const { return _focused; };
46 virtual void focus(void);
47
48 inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
49 bool grabMouse(void);
50 void ungrabMouse(void);
51
52 inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard; }
53 bool grabKeyboard(void);
54 void ungrabKeyboard(void);
55
56 inline const BTexture *getTexture(void) const { return _texture; }
57 virtual void setTexture(BTexture *texture = 0);
58
59 virtual void addChild(OtkWidget *child, bool front = false);
60 virtual void removeChild(OtkWidget *child);
61
62 inline bool getStretchableHorz(void) const { return _stretchable_horz; }
63 void setStretchableHorz(bool s_horz) { _stretchable_horz = s_horz; }
64
65 inline bool getStretchableVert(void) const { return _stretchable_vert; }
66 void setStretchableVert(bool s_vert) { _stretchable_vert = s_vert; }
67
68 inline Cursor getCursor(void) const { return _cursor; }
69
70 inline int getBevelWidth(void) const { return _bevel_width; }
71 void setBevelWidth(int bevel_width)
72 { assert(bevel_width > 0); _bevel_width = bevel_width; }
73
74 inline Direction getDirection(void) const { return _direction; }
75 void setDirection(Direction dir) { _direction = dir; }
76
77 inline Style *getStyle(void) const { return _style; }
78 void setStyle(Style *style) { _style = style; }
79
80 private:
81
82 void create(void);
83
84 Window _window;
85
86 OtkWidget *_parent;
87 OtkWidgetList _children;
88
89 Style *_style;
90 Direction _direction;
91 Cursor _cursor;
92 int _bevel_width;
93
94 bool _visible;
95 bool _focused;
96
97 bool _grabbed_mouse;
98 bool _grabbed_keyboard;
99
100 bool _stretchable_vert;
101 bool _stretchable_horz;
102
103 BTexture *_texture;
104 Pixmap _bg_pixmap;
105
106 Rect _rect;
107 unsigned int _screen;
108 };
109
110 }
This page took 0.037849 seconds and 4 git commands to generate.