2002-11-17 09:41:58 +00:00
|
|
|
// -*- 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 {
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
FocusWidget::FocusWidget(Widget *parent, Direction direction)
|
|
|
|
: Widget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
|
2002-11-13 10:19:28 +00:00
|
|
|
{
|
2002-12-18 02:28:44 +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
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
FocusWidget::~FocusWidget()
|
2002-11-16 02:15:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-01-27 19:05:33 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void FocusWidget::focus(void)
|
2002-11-13 10:19:28 +00:00
|
|
|
{
|
2002-12-25 22:02:34 +00:00
|
|
|
if (_focused)
|
2002-11-13 10:19:28 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::focus();
|
2002-12-18 02:28:44 +00:00
|
|
|
|
|
|
|
if (_focus_bcolor)
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::setBorderColor(_focus_bcolor);
|
2002-11-14 11:43:39 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::setTexture(_focus_texture);
|
2002-12-25 22:02:34 +00:00
|
|
|
update();
|
2002-11-13 10:19:28 +00:00
|
|
|
}
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
void FocusWidget::unfocus(void)
|
2002-11-13 10:19:28 +00:00
|
|
|
{
|
2002-12-25 22:02:34 +00:00
|
|
|
if (!_focused)
|
2002-11-13 10:19:28 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::unfocus();
|
2002-12-18 02:28:44 +00:00
|
|
|
|
|
|
|
if (_unfocus_bcolor)
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::setBorderColor(_unfocus_bcolor);
|
2002-12-18 02:28:44 +00:00
|
|
|
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::setTexture(_unfocus_texture);
|
2002-12-25 22:02:34 +00:00
|
|
|
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
|
|
|
{
|
2003-01-11 19:17:13 +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)
|
2002-12-18 02:28:44 +00:00
|
|
|
{
|
2003-01-11 19:17:13 +00:00
|
|
|
Widget::setBorderColor(color);
|
2002-12-18 02:28:44 +00:00
|
|
|
_focus_bcolor = color;
|
|
|
|
}
|
|
|
|
|
2002-11-13 10:19:28 +00:00
|
|
|
}
|