openbox/otk/focuswidget.cc

65 lines
1.1 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 {
FocusWidget::FocusWidget(Widget *parent, Direction direction)
: Widget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
2002-11-13 10:19:28 +00:00
{
_focused = true;
2002-12-20 15:26:34 +00:00
_focus_texture = parent->texture();
_focus_bcolor = parent->borderColor();
2002-11-13 10:19:28 +00:00
}
FocusWidget::~FocusWidget()
{
}
2003-01-27 19:05:33 +00:00
void FocusWidget::focus(void)
2002-11-13 10:19:28 +00:00
{
if (_focused)
2002-11-13 10:19:28 +00:00
return;
Widget::focus();
if (_focus_bcolor)
Widget::setBorderColor(_focus_bcolor);
2002-11-14 11:43:39 +00:00
Widget::setTexture(_focus_texture);
update();
2002-11-13 10:19:28 +00:00
}
void FocusWidget::unfocus(void)
2002-11-13 10:19:28 +00:00
{
if (!_focused)
2002-11-13 10:19:28 +00:00
return;
Widget::unfocus();
if (_unfocus_bcolor)
Widget::setBorderColor(_unfocus_bcolor);
Widget::setTexture(_unfocus_texture);
update();
2002-11-13 10:19:28 +00:00
}
2003-01-20 06:11:12 +00:00
void FocusWidget::setTexture(RenderTexture *texture)
2002-11-13 10:19:28 +00:00
{
Widget::setTexture(texture);
2002-11-13 10:19:28 +00:00
_focus_texture = texture;
}
2003-01-22 22:46:16 +00:00
void FocusWidget::setBorderColor(const RenderColor *color)
{
Widget::setBorderColor(color);
_focus_bcolor = color;
}
2002-11-13 10:19:28 +00:00
}