openbox/otk/focuswidget.cc

78 lines
1.5 KiB
C++
Raw Normal View History

// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif
2002-11-13 10:19:28 +00:00
#include "focuswidget.hh"
namespace otk {
OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
: OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
2002-11-13 10:19:28 +00:00
{
_focused = true;
2002-11-13 10:19:28 +00:00
_focus_texture = parent->getTexture();
_focus_bcolor = parent->getBorderColor();
2002-11-13 10:19:28 +00:00
}
OtkFocusWidget::~OtkFocusWidget()
{
}
#include <stdio.h>
2002-11-13 10:19:28 +00:00
void OtkFocusWidget::focus(void)
{
if (!isVisible() || _focused)
2002-11-13 10:19:28 +00:00
return;
printf("FOCUS\n");
OtkWidget::focus();
if (_focus_bcolor)
OtkWidget::setBorderColor(_focus_bcolor);
2002-11-14 11:43:39 +00:00
2002-11-13 10:19:28 +00:00
OtkWidget::setTexture(_focus_texture);
OtkWidget::update();
}
void OtkFocusWidget::unfocus(void)
{
if (!isVisible() || !_focused)
2002-11-13 10:19:28 +00:00
return;
printf("UNFOCUS\n");
OtkWidget::unfocus();
if (_unfocus_bcolor)
OtkWidget::setBorderColor(_unfocus_bcolor);
2002-11-13 10:19:28 +00:00
OtkWidget::setTexture(_unfocus_texture);
OtkWidget::update();
2002-12-11 00:50:26 +00:00
OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
OtkWidget::OtkWidgetList::iterator it = children.begin(),
end = children.end();
2002-11-13 10:19:28 +00:00
OtkFocusWidget *tmp = 0;
for (; it != end; ++it) {
tmp = dynamic_cast<OtkFocusWidget*>(*it);
if (tmp) tmp->unfocus();
}
}
void OtkFocusWidget::setTexture(BTexture *texture)
{
OtkWidget::setTexture(texture);
_focus_texture = texture;
}
void OtkFocusWidget::setBorderColor(const BColor *color)
{
OtkWidget::setBorderColor(color);
_focus_bcolor = color;
}
2002-11-13 10:19:28 +00:00
}