11 #include "eventdispatcher.hh"
12 #include "application.hh"
16 class OtkWidget : public OtkEventHandler {
20 enum Direction { Horizontal, Vertical };
22 typedef std::list<OtkWidget *> OtkWidgetList;
24 OtkWidget(OtkWidget *parent, Direction = Horizontal);
25 OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
26 Direction direction = Horizontal, Cursor cursor = 0,
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 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; }
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(void);
60 virtual void hide(void);
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(OtkWidget *child, bool front = false);
78 virtual void removeChild(OtkWidget *child);
80 inline bool isStretchableHorz(void) const { return _stretchable_horz; }
81 void setStretchableHorz(bool s_horz) { _stretchable_horz = s_horz; }
83 inline bool isStretchableVert(void) const { return _stretchable_vert; }
84 void setStretchableVert(bool s_vert) { _stretchable_vert = s_vert; }
86 inline Cursor getCursor(void) const { return _cursor; }
88 inline int getBevelWidth(void) const { return _bevel_width; }
89 void setBevelWidth(int bevel_width)
90 { assert(bevel_width > 0); _bevel_width = bevel_width; }
92 inline Direction getDirection(void) const { return _direction; }
93 void setDirection(Direction dir) { _direction = dir; }
95 inline Style *getStyle(void) const { return _style; }
96 void setStyle(Style *style) { _style = style; }
98 inline OtkEventDispatcher *getEventDispatcher(void)
99 { return _event_dispatcher; }
100 void setEventDispatcher(OtkEventDispatcher *disp);
110 void adjustHorz(void);
111 void adjustVert(void);
112 void internalResize(int width, int height);
118 OtkWidgetList _children;
121 Direction _direction;
130 bool _grabbed_keyboard;
132 bool _stretchable_vert;
133 bool _stretchable_horz;
137 unsigned int _bg_pixel;
140 unsigned int _screen;
145 OtkEventDispatcher *_event_dispatcher;
146 OtkApplication *_application;
151 #endif // __widget_hh