]> icculus.org git repositories - mikachu/openbox.git/blob - otk/focuswidget.cc
add an OtkAppWidget which are "root windows", i.e. the managed child of root, to...
[mikachu/openbox.git] / 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()
12 {
13 }
14
15 void OtkFocusWidget::focus(void)
16 {
17   if (_focused)
18     return;
19
20   // XXX: what about OtkWidget::focus()
21
22   assert(_focus_texture);
23   OtkWidget::setTexture(_focus_texture);
24   OtkWidget::update();
25
26   OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
27
28   OtkWidget::OtkWidgetList::iterator it = children.begin(),
29     end = children.end();
30
31   OtkFocusWidget *tmp = 0;
32   for (; it != end; ++it) {
33     tmp = dynamic_cast<OtkFocusWidget*>(*it);
34     if (tmp) tmp->focus();
35   }
36 }
37
38 void OtkFocusWidget::unfocus(void)
39 {
40   if (! _focused)
41     return;
42
43   assert(_unfocus_texture);
44   OtkWidget::setTexture(_unfocus_texture);
45   OtkWidget::update();
46
47   OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
48
49   OtkWidget::OtkWidgetList::iterator it = children.begin(),
50     end = children.end();
51
52   OtkFocusWidget *tmp = 0;
53   for (; it != end; ++it) {
54     tmp = dynamic_cast<OtkFocusWidget*>(*it);
55     if (tmp) tmp->unfocus();
56   }
57 }
58
59 void OtkFocusWidget::setTexture(BTexture *texture)
60 {
61   OtkWidget::setTexture(texture);
62   _focus_texture = texture;
63 }
64
65 }