summaryrefslogtreecommitdiff
path: root/src/buttonwidget.cc
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-12-25 22:02:34 +0000
committerDana Jansens <danakj@orodu.net>2002-12-25 22:02:34 +0000
commit2ae2b257d39ea62640c2590f794e4275c6db1cd4 (patch)
treef26abe4a0601d263fbc460eddc012c1d674c868b /src/buttonwidget.cc
parent3c61812e588fb3c34d0713d7f82ccbf21091f032 (diff)
might not compile... ob uses its own widgets now, which subclass only the base otk widget. working on compressing focus events and handling them etc.
Diffstat (limited to 'src/buttonwidget.cc')
-rw-r--r--src/buttonwidget.cc94
1 files changed, 79 insertions, 15 deletions
diff --git a/src/buttonwidget.cc b/src/buttonwidget.cc
index 867cc5be..853b0339 100644
--- a/src/buttonwidget.cc
+++ b/src/buttonwidget.cc
@@ -10,8 +10,10 @@ namespace ob {
OBButtonWidget::OBButtonWidget(otk::OtkWidget *parent,
OBWidget::WidgetType type)
- : otk::OtkButton(parent),
- OBWidget(type)
+ : otk::OtkWidget(parent),
+ OBWidget(type),
+ _pressed(false),
+ _button(0)
{
}
@@ -21,36 +23,98 @@ OBButtonWidget::~OBButtonWidget()
}
+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!
+ }
+}
+
+
void OBButtonWidget::setStyle(otk::Style *style)
{
- otk::OtkButton::setStyle(style);
+ otk::OtkWidget::setStyle(style);
+ setTextures();
switch (type()) {
case Type_LeftGrip:
case Type_RightGrip:
- setTexture(style->getGripFocus());
- setUnfocusTexture(style->getGripUnfocus());
- setPressedFocusTexture(style->getGripFocus());
- setPressedUnfocusTexture(style->getGripUnfocus());
- setTexture(style->getGripFocus());
- setUnfocusTexture(style->getGripUnfocus());
- setPressedFocusTexture(style->getGripFocus());
- setPressedUnfocusTexture(style->getGripUnfocus());
setBorderColor(_style->getBorderColor());
- setUnfocusBorderColor(style->getBorderColor());
break;
- default:
+ case Type_StickyButton:
+ case Type_CloseButton:
+ case Type_MaximizeButton:
+ case Type_IconifyButton:
break;
+ default:
+ assert(false); // there's no other button widgets!
}
}
-void OBButtonWidget::adjust()
+void OBButtonWidget::focus()
{
- otk::OtkButton::adjust();
+ otk::OtkWidget::focus();
+ setTextures();
+}
+
+void OBButtonWidget::unfocus()
+{
+ otk::OtkWidget::unfocus();
+ setTextures();
+}
+
+
+void OBButtonWidget::adjust()
+{
// XXX: adjust shit
}
+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();
+}
+
}