]>
Dogcows Code - chaz/openbox/blob - otk/widget.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
7 #include "rendertexture.hh"
8 #include "renderstyle.hh"
9 #include "eventdispatcher.hh"
22 class Widget
: public EventHandler
{
26 enum Direction
{ Horizontal
, Vertical
};
28 typedef std::list
<Widget
*> WidgetList
;
30 Widget(Widget
*parent
, Direction
= Horizontal
);
31 Widget(EventDispatcher
*event_dispatcher
, RenderStyle
*style
,
32 Direction direction
= Horizontal
, Cursor cursor
= 0,
33 int bevel_width
= 1, bool override_redirect
= false);
37 virtual void update();
39 void exposeHandler(const XExposeEvent
&e
);
40 void configureHandler(const XConfigureEvent
&e
);
42 inline Window
window(void) const { return _window
; }
43 inline const Widget
*parent(void) const { return _parent
; }
44 inline const WidgetList
&children(void) const { return _children
; }
45 inline unsigned int screen(void) const { return _screen
; }
46 inline const Rect
&rect(void) const { return _rect
; }
48 void move(const Point
&to
);
49 void move(int x
, int y
);
51 virtual void setWidth(int);
52 virtual void setHeight(int);
54 virtual int width() const { return _rect
.width(); }
55 virtual int height() const { return _rect
.height(); }
57 virtual void resize(const Point
&to
);
58 virtual void resize(int x
, int y
);
60 virtual void setGeometry(const Rect
&new_geom
);
61 virtual void setGeometry(const Point
&topleft
, int width
, int height
);
62 virtual void setGeometry(int x
, int y
, int width
, int height
);
64 inline bool isVisible(void) const { return _visible
; };
65 virtual void show(bool recursive
= false);
66 virtual void hide(bool recursive
= false);
68 inline bool isFocused(void) const { return _focused
; };
69 virtual void focus(void);
70 virtual void unfocus(void);
72 inline bool hasGrabbedMouse(void) const { return _grabbed_mouse
; }
74 void ungrabMouse(void);
76 inline bool hasGrabbedKeyboard(void) const { return _grabbed_keyboard
; }
77 bool grabKeyboard(void);
78 void ungrabKeyboard(void);
80 inline RenderTexture
*texture(void) const { return _texture
; }
81 virtual void setTexture(RenderTexture
*texture
)
82 { _texture
= texture
; _dirty
= true; }
84 inline const RenderColor
*borderColor(void) const { return _bcolor
; }
85 virtual void setBorderColor(const RenderColor
*color
) {
86 assert(color
); _bcolor
= color
;
87 XSetWindowBorder(**display
, _window
, color
->pixel());
90 inline int borderWidth(void) const { return _bwidth
; }
91 void setBorderWidth(int width
) {
93 XSetWindowBorderWidth(**display
, _window
, width
);
96 virtual void addChild(Widget
*child
, bool front
= false);
97 virtual void removeChild(Widget
*child
);
99 inline bool isStretchableHorz(void) const { return _stretchable_horz
; }
100 void setStretchableHorz(bool s_horz
= true) { _stretchable_horz
= s_horz
; }
102 inline bool isStretchableVert(void) const { return _stretchable_vert
; }
103 void setStretchableVert(bool s_vert
= true) { _stretchable_vert
= s_vert
; }
105 inline Cursor
cursor(void) const { return _cursor
; }
106 void setCursor(Cursor cursor
) {
108 XDefineCursor(**display
, _window
, _cursor
);
111 inline int bevelWidth(void) const { return _bevel_width
; }
112 void setBevelWidth(int bevel_width
)
113 { assert(bevel_width
> 0); _bevel_width
= bevel_width
; }
115 inline Direction
direction(void) const { return _direction
; }
116 void setDirection(Direction dir
) { _direction
= dir
; }
118 inline RenderStyle
*style(void) const { return _style
; }
119 virtual void setStyle(RenderStyle
*style
);
121 inline EventDispatcher
*eventDispatcher(void)
122 { return _event_dispatcher
; }
123 void setEventDispatcher(EventDispatcher
*disp
);
130 virtual void adjust(void);
131 virtual void create(bool override_redirect
= false);
132 virtual void adjustHorz(void);
133 virtual void adjustVert(void);
134 virtual void internalResize(int width
, int height
);
135 virtual void render(void);
136 virtual void renderForeground() {} // for overriding
141 WidgetList _children
;
144 Direction _direction
;
152 bool _grabbed_keyboard
;
154 bool _stretchable_vert
;
155 bool _stretchable_horz
;
157 RenderTexture
*_texture
;
159 unsigned int _bg_pixel
;
161 const RenderColor
*_bcolor
;
162 unsigned int _bwidth
;
165 unsigned int _screen
;
172 EventDispatcher
*_event_dispatcher
;
177 #endif // __widget_hh
This page took 0.039849 seconds and 4 git commands to generate.