]> Dogcows Code - chaz/openbox/blob - otk/focuswidget.cc
fixed bugs, got otkapp to select on a fd, modded widget to make use of otkapp, press...
[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(OtkApplication *app, Direction direction,
12 Cursor cursor, int bevel_width)
13 : OtkWidget(app, direction, cursor, bevel_width),
14 _unfocus_texture(0), _focused(true)
15 {
16 }
17
18 OtkFocusWidget::OtkFocusWidget(Style *style, Direction direction,
19 Cursor cursor, int bevel_width)
20 : OtkWidget(style, direction, cursor, bevel_width),
21 _unfocus_texture(0), _focused(true)
22 {
23 }
24
25 OtkFocusWidget::~OtkFocusWidget()
26 {
27 }
28
29 void OtkFocusWidget::focus(void)
30 {
31 if (_focused)
32 return;
33
34 // XXX: what about OtkWidget::focus()
35
36 assert(_focus_texture);
37 OtkWidget::setTexture(_focus_texture);
38 OtkWidget::update();
39
40 OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
41
42 OtkWidget::OtkWidgetList::iterator it = children.begin(),
43 end = children.end();
44
45 OtkFocusWidget *tmp = 0;
46 for (; it != end; ++it) {
47 tmp = dynamic_cast<OtkFocusWidget*>(*it);
48 if (tmp) tmp->focus();
49 }
50 }
51
52 void OtkFocusWidget::unfocus(void)
53 {
54 if (! _focused)
55 return;
56
57 assert(_unfocus_texture);
58 OtkWidget::setTexture(_unfocus_texture);
59 OtkWidget::update();
60
61 OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
62
63 OtkWidget::OtkWidgetList::iterator it = children.begin(),
64 end = children.end();
65
66 OtkFocusWidget *tmp = 0;
67 for (; it != end; ++it) {
68 tmp = dynamic_cast<OtkFocusWidget*>(*it);
69 if (tmp) tmp->unfocus();
70 }
71 }
72
73 void OtkFocusWidget::setTexture(BTexture *texture)
74 {
75 OtkWidget::setTexture(texture);
76 _focus_texture = texture;
77 }
78
79 }
This page took 0.041379 seconds and 4 git commands to generate.