2002-12-18 11:35:26 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "buttonwidget.hh"
|
|
|
|
|
|
|
|
namespace ob {
|
|
|
|
|
|
|
|
OBButtonWidget::OBButtonWidget(otk::OtkWidget *parent,
|
|
|
|
OBWidget::WidgetType type)
|
2002-12-25 22:02:34 +00:00
|
|
|
: otk::OtkWidget(parent),
|
|
|
|
OBWidget(type),
|
|
|
|
_pressed(false),
|
|
|
|
_button(0)
|
2002-12-18 11:35:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OBButtonWidget::~OBButtonWidget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-25 22:02:34 +00:00
|
|
|
void OBButtonWidget::setTextures()
|
|
|
|
{
|
|
|
|
switch (type()) {
|
|
|
|
case Type_LeftGrip:
|
|
|
|
case Type_RightGrip:
|
|
|
|
if (_focused)
|
|
|
|
setTexture(_style->getGripFocus());
|
|
|
|
else
|
|
|
|
setTexture(_style->getGripUnfocus());
|
|
|
|
break;
|
|
|
|
case Type_StickyButton:
|
|
|
|
case Type_CloseButton:
|
|
|
|
case Type_MaximizeButton:
|
|
|
|
case Type_IconifyButton:
|
|
|
|
if (_pressed) {
|
|
|
|
if (_focused)
|
|
|
|
setTexture(_style->getButtonPressedFocus());
|
|
|
|
else
|
|
|
|
setTexture(_style->getButtonPressedUnfocus());
|
|
|
|
} else {
|
|
|
|
if (_focused)
|
|
|
|
setTexture(_style->getButtonFocus());
|
|
|
|
else
|
|
|
|
setTexture(_style->getButtonUnfocus());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(false); // there's no other button widgets!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-18 11:35:26 +00:00
|
|
|
void OBButtonWidget::setStyle(otk::Style *style)
|
|
|
|
{
|
2002-12-25 22:02:34 +00:00
|
|
|
otk::OtkWidget::setStyle(style);
|
|
|
|
setTextures();
|
2002-12-18 11:35:26 +00:00
|
|
|
|
|
|
|
switch (type()) {
|
|
|
|
case Type_LeftGrip:
|
|
|
|
case Type_RightGrip:
|
|
|
|
setBorderColor(_style->getBorderColor());
|
|
|
|
break;
|
2002-12-25 22:02:34 +00:00
|
|
|
case Type_StickyButton:
|
|
|
|
case Type_CloseButton:
|
|
|
|
case Type_MaximizeButton:
|
|
|
|
case Type_IconifyButton:
|
2002-12-18 11:35:26 +00:00
|
|
|
break;
|
2002-12-25 22:02:34 +00:00
|
|
|
default:
|
|
|
|
assert(false); // there's no other button widgets!
|
2002-12-18 11:35:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-25 22:02:34 +00:00
|
|
|
void OBButtonWidget::focus()
|
2002-12-18 11:35:26 +00:00
|
|
|
{
|
2002-12-25 22:02:34 +00:00
|
|
|
otk::OtkWidget::focus();
|
|
|
|
setTextures();
|
|
|
|
}
|
2002-12-18 11:35:26 +00:00
|
|
|
|
2002-12-25 22:02:34 +00:00
|
|
|
|
|
|
|
void OBButtonWidget::unfocus()
|
|
|
|
{
|
|
|
|
otk::OtkWidget::unfocus();
|
|
|
|
setTextures();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OBButtonWidget::adjust()
|
|
|
|
{
|
2002-12-18 11:35:26 +00:00
|
|
|
// XXX: adjust shit
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-25 22:02:34 +00:00
|
|
|
void OBButtonWidget::buttonPressHandler(const XButtonEvent &e)
|
|
|
|
{
|
|
|
|
OtkWidget::buttonPressHandler(e);
|
|
|
|
if (_button) return;
|
|
|
|
_button = e.button;
|
|
|
|
_pressed = true;
|
|
|
|
setTextures();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OBButtonWidget::buttonReleaseHandler(const XButtonEvent &e)
|
|
|
|
{
|
|
|
|
OtkWidget::buttonPressHandler(e);
|
|
|
|
if (e.button != _button) return;
|
|
|
|
_button = 0;
|
|
|
|
_pressed = false;
|
|
|
|
setTextures();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2002-12-18 11:35:26 +00:00
|
|
|
}
|