1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
7 #include "focuswidget.hh"
11 OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
12 : OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
15 _focus_texture = parent->texture();
16 _focus_bcolor = parent->borderColor();
19 OtkFocusWidget::~OtkFocusWidget()
24 void OtkFocusWidget::focus(void)
26 if (!isVisible() || _focused)
33 OtkWidget::setBorderColor(_focus_bcolor);
35 OtkWidget::setTexture(_focus_texture);
39 void OtkFocusWidget::unfocus(void)
41 if (!isVisible() || !_focused)
48 OtkWidget::setBorderColor(_unfocus_bcolor);
50 OtkWidget::setTexture(_unfocus_texture);
53 OtkWidget::OtkWidgetList children = OtkWidget::children();
55 OtkWidget::OtkWidgetList::iterator it = children.begin(),
58 OtkFocusWidget *tmp = 0;
59 for (; it != end; ++it) {
60 tmp = dynamic_cast<OtkFocusWidget*>(*it);
61 if (tmp) tmp->unfocus();
65 void OtkFocusWidget::setTexture(BTexture *texture)
67 OtkWidget::setTexture(texture);
68 _focus_texture = texture;
71 void OtkFocusWidget::setBorderColor(const BColor *color)
73 OtkWidget::setBorderColor(color);
74 _focus_bcolor = color;