]>
Dogcows Code - chaz/openbox/blob - widget.hh
7f2d926c4cf579941a44c67e941913bc50c5c81c
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
9 #include "eventdispatcher.hh"
21 class Widget
: public EventHandler
{
25 enum Direction
{ Horizontal
, Vertical
};
27 typedef std::list
<Widget
*> WidgetList
;
29 Widget(Widget
*parent
, Direction
= Horizontal
);
30 Widget(EventDispatcher
*event_dispatcher
, Style
*style
,
31 Direction direction
= Horizontal
, Cursor cursor
= 0,
32 int bevel_width
= 1, bool override_redirect
= false);
36 virtual void update(void);
38 void exposeHandler(const XExposeEvent
&e
);
39 void configureHandler(const XConfigureEvent
&e
);
41 inline Window
window(void) const { return _window
; }
42 inline const Widget
*parent(void) const { return _parent
; }
43 inline const WidgetList
&children(void) const { return _children
; }
44 inline unsigned int screen(void) const { return _screen
; }
45 inline const Rect
&rect(void) const { return _rect
; }
47 void move(const Point
&to
);
48 void move(int x
, int y
);
50 virtual void setWidth(int);
51 virtual void setHeight(int);
53 virtual int width() const { return _rect
.width(); }
54 virtual int height() const { return _rect
.height(); }
56 virtual void resize(const Point
&to
);
57 virtual void resize(int x
, int y
);
59 virtual void setGeometry(const Rect
&new_geom
);
60 virtual void setGeometry(const Point
&topleft
, int width
, int height
);
61 virtual void setGeometry(int x
, int y
, int width
, int height
);
63 inline bool isVisible(void) const { return _visible
; };
64 virtual void show(bool recursive
= false);
65 virtual void hide(bool recursive
= false);
67 inline bool isFocused(void) const { return _focused
; };
68 virtual void focus(void);
69 virtual void unfocus(void);
71 inline bool hasGrabbedMouse(void) const { return _grabbed_mouse
; }
73 void ungrabMouse(void);
75 inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard
; }
76 bool grabKeyboard(void);
77 void ungrabKeyboard(void);
79 inline Texture
*texture(void) const { return _texture
; }
80 virtual void setTexture(Texture
*texture
)
81 { _texture
= texture
; _dirty
= true; }
83 inline const Color
*borderColor(void) const { return _bcolor
; }
84 virtual void setBorderColor(const Color
*color
) {
85 assert(color
); _bcolor
= color
;
86 XSetWindowBorder(**display
, _window
, color
->pixel());
89 inline int borderWidth(void) const { return _bwidth
; }
90 void setBorderWidth(int width
) {
92 XSetWindowBorderWidth(**display
, _window
, width
);
95 virtual void addChild(Widget
*child
, bool front
= false);
96 virtual void removeChild(Widget
*child
);
98 inline bool isStretchableHorz(void) const { return _stretchable_horz
; }
99 void setStretchableHorz(bool s_horz
= true) { _stretchable_horz
= s_horz
; }
101 inline bool isStretchableVert(void) const { return _stretchable_vert
; }
102 void setStretchableVert(bool s_vert
= true) { _stretchable_vert
= s_vert
; }
104 inline Cursor
cursor(void) const { return _cursor
; }
105 void setCursor(Cursor cursor
) {
107 XDefineCursor(**display
, _window
, _cursor
);
110 inline int bevelWidth(void) const { return _bevel_width
; }
111 void setBevelWidth(int bevel_width
)
112 { assert(bevel_width
> 0); _bevel_width
= bevel_width
; }
114 inline Direction
direction(void) const { return _direction
; }
115 void setDirection(Direction dir
) { _direction
= dir
; }
117 inline Style
*style(void) const { return _style
; }
118 virtual void setStyle(Style
*style
);
120 inline EventDispatcher
*eventDispatcher(void)
121 { return _event_dispatcher
; }
122 void setEventDispatcher(EventDispatcher
*disp
);
129 virtual void adjust(void);
130 virtual void create(bool override_redirect
= false);
131 virtual void adjustHorz(void);
132 virtual void adjustVert(void);
133 virtual void internalResize(int width
, int height
);
134 virtual void render(void);
139 WidgetList _children
;
142 Direction _direction
;
150 bool _grabbed_keyboard
;
152 bool _stretchable_vert
;
153 bool _stretchable_horz
;
157 unsigned int _bg_pixel
;
159 const Color
*_bcolor
;
160 unsigned int _bwidth
;
163 unsigned int _screen
;
168 EventDispatcher
*_event_dispatcher
;
173 #endif // __widget_hh
This page took 0.038598 seconds and 3 git commands to generate.