]> Dogcows Code - chaz/openbox/blob - otk/focuswidget.cc
it resizes now
[chaz/openbox] / otk / focuswidget.cc
1 #include "focuswidget.hh"
2
3 namespace otk {
4
5 OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
6 : OtkWidget(parent, direction), _unfocus_texture(0), _focused(true)
7 {
8 _focus_texture = parent->getTexture();
9 }
10
11 OtkFocusWidget::OtkFocusWidget(Style *style, Direction direction,
12 Cursor cursor, int bevel_width)
13 : OtkWidget(style, direction, cursor, bevel_width),
14 _unfocus_texture(0), _focused(true)
15 {
16 }
17
18 void OtkFocusWidget::focus(void)
19 {
20 if (_focused)
21 return;
22
23 // XXX: what about OtkWidget::focus()
24
25 assert(_focus_texture);
26 OtkWidget::setTexture(_focus_texture);
27 OtkWidget::update();
28
29 OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
30
31 OtkWidget::OtkWidgetList::iterator it = children.begin(),
32 end = children.end();
33
34 OtkFocusWidget *tmp = 0;
35 for (; it != end; ++it) {
36 tmp = dynamic_cast<OtkFocusWidget*>(*it);
37 if (tmp) tmp->focus();
38 }
39 }
40
41 void OtkFocusWidget::unfocus(void)
42 {
43 if (! _focused)
44 return;
45
46 assert(_unfocus_texture);
47 OtkWidget::setTexture(_unfocus_texture);
48 OtkWidget::update();
49
50 OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
51
52 OtkWidget::OtkWidgetList::iterator it = children.begin(),
53 end = children.end();
54
55 OtkFocusWidget *tmp = 0;
56 for (; it != end; ++it) {
57 tmp = dynamic_cast<OtkFocusWidget*>(*it);
58 if (tmp) tmp->unfocus();
59 }
60 }
61
62 void OtkFocusWidget::setTexture(BTexture *texture)
63 {
64 OtkWidget::setTexture(texture);
65 _focus_texture = texture;
66 }
67
68 }
This page took 0.03973 seconds and 4 git commands to generate.