]> icculus.org git repositories - mikachu/openbox.git/blob - otk/widget.hh
initial commit
[mikachu/openbox.git] / otk / widget.hh
1 #include <string>
2 #include <list>
3
4 #include "rect.hh"
5 #include "point.hh"
6 #include "texture.hh"
7
8 namespace otk {
9
10 class OtkWidget {
11
12 public:
13
14   typedef std::list<OtkWidget *> OtkWidgetList;
15
16   OtkWidget(OtkWidget *parent);
17   OtkWidget(unsigned int screen, Cursor);
18
19   virtual ~OtkWidget();
20
21   inline Window getWindow(void) const { return _window; }
22   inline const OtkWidget *getParent(void) const { return _parent; }
23   inline const OtkWidgetList &getChildren(void) const { return _children; }
24   inline unsigned int getScreen(void) const { return _screen; }
25   inline const Rect &getRect(void) const { return _rect; }
26
27   void move(const Point &to);
28   void move(int x, int y);
29
30   virtual void resize(const Point &to);
31   virtual void resize(int x, int y);
32
33   virtual void setGeometry(const Rect &new_geom);
34   virtual void setGeometry(const Point &topleft, int width, int height);
35   virtual void setGeometry(int x, int y, int width, int height);
36
37   inline bool isVisible(void) const { return _visible; };
38   virtual void show(void);
39   virtual void hide(void);
40
41   inline bool isFocused(void) const { return _focused; };
42   virtual void focus(void);
43   virtual void blur(void);
44
45   inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
46   bool grabMouse(void);
47   void ungrabMouse(void);
48
49   inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard; }
50   bool grabKeyboard(void);
51   void ungrabKeyboard(void);
52
53   inline const BTexture *getTexture(void) const { return _texture; }
54   virtual void setTexture(BTexture *texture);
55
56   virtual void addChild(OtkWidget *child);
57   virtual void removeChild(OtkWidget *child);
58
59   inline bool getStretchableHorz(void) const { return _stretchable_horz; }
60   void setStretchableHorz(bool s_horz) { _stretchable_horz = s_horz; }
61
62   inline bool getStretchableVert(void) const { return _stretchable_vert; }
63   void setStretchableVert(bool s_vert)  { _stretchable_vert = s_vert; }
64
65   inline Cursor getCursor(void) const { return _cursor; }
66
67 private:
68
69   void create(void);
70
71   Window _window;
72
73   OtkWidget *_parent;
74   OtkWidgetList _children;
75  
76   bool _visible;
77   bool _focused;
78
79   bool _grabbed_mouse;
80   bool _grabbed_keyboard;
81
82   bool _stretchable_vert;
83   bool _stretchable_horz;
84
85   BTexture *_texture;
86
87   Rect _rect;
88   unsigned int _screen;
89
90   Cursor _cursor;
91 };
92
93 }