X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Ffocuswidget.cc;h=a5d2696d6036dd1caeb4c7ed1a685da33fbcba66;hb=5a139f7263e33b499836f5df9ac37400e02c32f9;hp=e956561e2224fc94a78eb38f5754e23b86dbfe78;hpb=301adc8bc20dff10093f3c0df44e30acbbddab67;p=chaz%2Fopenbox diff --git a/otk/focuswidget.cc b/otk/focuswidget.cc index e956561e..a5d2696d 100644 --- a/otk/focuswidget.cc +++ b/otk/focuswidget.cc @@ -9,44 +9,52 @@ namespace otk { OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction) - : OtkWidget(parent, direction), _unfocus_texture(0), _focused(true) + : OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0) { - _focus_texture = parent->getTexture(); + _focused = true; + _focus_texture = parent->texture(); + _focus_bcolor = parent->borderColor(); } OtkFocusWidget::~OtkFocusWidget() { } +#include void OtkFocusWidget::focus(void) { - if (_focused) + if (!isVisible() || _focused) return; - // XXX: what about OtkWidget::focus() + printf("FOCUS\n"); + OtkWidget::focus(); + + if (_focus_bcolor) + OtkWidget::setBorderColor(_focus_bcolor); - assert(_focus_texture); OtkWidget::setTexture(_focus_texture); OtkWidget::update(); - - OtkBaseWidgetList::iterator it = _children.begin(), end = _children.end(); - OtkFocusWidget *tmp = 0; - for (; it != end; ++it) { - tmp = dynamic_cast(*it); - if (tmp) tmp->focus(); - } } void OtkFocusWidget::unfocus(void) { - if (! _focused) + if (!isVisible() || !_focused) return; - assert(_unfocus_texture); + printf("UNFOCUS\n"); + OtkWidget::unfocus(); + + if (_unfocus_bcolor) + OtkWidget::setBorderColor(_unfocus_bcolor); + OtkWidget::setTexture(_unfocus_texture); OtkWidget::update(); - OtkBaseWidgetList::iterator it = _children.begin(), end = _children.end(); + OtkWidget::OtkWidgetList children = OtkWidget::children(); + + OtkWidget::OtkWidgetList::iterator it = children.begin(), + end = children.end(); + OtkFocusWidget *tmp = 0; for (; it != end; ++it) { tmp = dynamic_cast(*it); @@ -60,4 +68,10 @@ void OtkFocusWidget::setTexture(BTexture *texture) _focus_texture = texture; } +void OtkFocusWidget::setBorderColor(const BColor *color) +{ + OtkWidget::setBorderColor(color); + _focus_bcolor = color; +} + }