1 #ifndef __basewidget_hh
2 #define __basewidget_hh
9 #include "eventdispatcher.hh"
19 class OtkBaseWidget : public OtkEventHandler {
23 typedef std::list<OtkBaseWidget *> OtkBaseWidgetList;
25 OtkBaseWidget(OtkBaseWidget *parent);
26 OtkBaseWidget(Style *style, Cursor cursor = 0, int bevel_width = 1);
28 virtual ~OtkBaseWidget();
30 //! Redraw the widget and all of its children
31 virtual void update(void);
33 void exposeHandler(const XExposeEvent &e);
34 void configureHandler(const XConfigureEvent &e);
36 inline Window getWindow(void) const { return _window; }
37 inline const OtkBaseWidget *getParent(void) const { return _parent; }
38 inline const OtkBaseWidgetList &getChildren(void) const { return _children; }
39 inline unsigned int getScreen(void) const { return _screen; }
40 inline const Rect &getRect(void) const { return _rect; }
42 void move(const Point &to);
43 void move(int x, int y);
45 virtual void setWidth(int);
46 virtual void setHeight(int);
48 virtual int width() const { return _rect.width(); }
49 virtual int height() const { return _rect.height(); }
51 virtual void resize(const Point &to);
52 virtual void resize(int x, int y);
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);
58 inline bool isVisible(void) const { return _visible; };
59 virtual void show(bool recursive = false);
60 virtual void hide(bool recursive = false);
62 inline bool isFocused(void) const { return _focused; };
63 virtual void focus(void);
65 inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
67 void ungrabMouse(void);
69 inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard; }
70 bool grabKeyboard(void);
71 void ungrabKeyboard(void);
73 inline BTexture *getTexture(void) const { return _texture; }
74 virtual void setTexture(BTexture *texture)
75 { _texture = texture; _dirty = true; }
77 virtual void addChild(OtkBaseWidget *child, bool front = false);
78 virtual void removeChild(OtkBaseWidget *child);
80 inline Cursor getCursor(void) const { return _cursor; }
81 void setCursor(Cursor cursor) {
83 XDefineCursor(OBDisplay::display, _window, _cursor);
86 inline int getBevelWidth(void) const { return _bevel_width; }
87 void setBevelWidth(int bevel_width)
88 { assert(bevel_width > 0); _bevel_width = bevel_width; }
90 inline Style *getStyle(void) const { return _style; }
91 virtual void setStyle(Style *style);
95 //! If the widget needs to redraw itself. Watched by all subclasses too!
100 OtkBaseWidget *_parent;
101 OtkBaseWidgetList _children;
112 bool _grabbed_keyboard;
116 unsigned int _bg_pixel;
119 unsigned int _screen;
129 #endif // __basewidget_hh