]>
Dogcows Code - chaz/openbox/blob - otk/widget.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
5 #include "eventhandler.hh"
7 #include "renderstyle.hh"
18 class EventDispatcher
;
20 class Widget
: public EventHandler
, public StyleNotify
{
22 enum Direction
{ Horizontal
, Vertical
};
24 Widget(int screen
, EventDispatcher
*ed
, Direction direction
= Horizontal
,
25 int bevel
= 3, bool overrideredir
= false);
26 Widget(Widget
*parent
, Direction direction
= Horizontal
, int bevel
= 3);
29 inline int screen() const { return _screen
; }
30 inline Window
window() const { return _window
; }
31 inline Widget
*parent() const { return _parent
; }
32 inline Direction
direction() const { return _direction
; }
34 inline RenderStyle::Justify
alignment() const { return _alignment
; }
35 void setAlignment(RenderStyle::Justify a
);
37 inline long eventMask() const { return _event_mask
; }
38 virtual void setEventMask(long e
);
40 inline const Rect
& area() const { return _area
; }
41 inline Rect
usableArea() const { return Rect(_area
.position(),
46 inline const Size
& minSize() const { return _min_size
; }
47 inline const Size
& maxSize() const { return _max_size
; }
48 virtual void setMaxSize(const Size
&s
);
50 virtual void show(bool children
= false);
52 inline bool visible() const { return _visible
; }
54 virtual void update();
55 virtual void refresh() { _dirty
= true; render(); }
57 virtual void setBevel(int b
);
58 inline int bevel() const { return _bevel
; }
60 void move(const Point
&p
)
61 { moveresize(Rect(p
, _area
.size())); }
62 void resize(const Size
&s
)
63 { moveresize(Rect(_area
.position(), s
)); }
65 When a widget has a parent, this won't change the widget directly, but will
66 just cause the parent to re-layout all its children.
68 virtual void moveresize(const Rect
&r
);
70 inline const RenderColor
*borderColor() const { return _bordercolor
; }
71 virtual void setBorderColor(const RenderColor
*c
);
73 inline int borderWidth() const { return _borderwidth
; }
74 virtual void setBorderWidth(int w
);
76 const std::list
<Widget
*>& children() const { return _children
; }
78 virtual void exposeHandler(const XExposeEvent
&e
);
79 virtual void configureHandler(const XConfigureEvent
&e
);
80 virtual void styleChanged(const RenderStyle
&style
);
83 virtual void addChild(Widget
*w
) { assert(w
); _children
.push_back(w
); }
84 virtual void removeChild(Widget
*w
) { assert(w
); _children
.remove(w
); }
86 //! Find the default min/max sizes for the widget. Useful after the in-use
87 //! style has changed.
88 virtual void calcDefaultSizes();
90 virtual void setMinSize(const Size
&s
);
92 //! Arrange the widget's children
93 virtual void layout();
94 virtual void layoutHorz();
95 virtual void layoutVert();
96 virtual void render();
97 virtual void renderForeground(Surface
&) {};
98 virtual void renderChildren();
100 void createWindow(bool overrideredir
);
102 RenderTexture
*_texture
;
104 EventDispatcher
*dispatcher() const { return _dispatcher
; }
107 void internal_moveresize(int x
, int y
, int w
, int h
);
115 RenderStyle::Justify _alignment
;
116 Direction _direction
;
118 //! This size is the size *inside* the border, so they won't match the
119 //! actual size of the widget
121 //! This size is the size *inside* the border, so they won't match the
122 //! actual size of the widget
127 const RenderColor
*_bordercolor
;
132 std::list
<Widget
*> _children
;
134 EventDispatcher
*_dispatcher
;
141 #endif // __widget_hh
This page took 0.042368 seconds and 4 git commands to generate.