]> Dogcows Code - chaz/openbox/blob - otk/button.cc
04906fe517306f1e06baa4d5a0dbdf28c7934a2c
[chaz/openbox] / otk / button.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "button.hh"
8
9 namespace otk {
10
11 Button::Button(Widget *parent)
12 : FocusLabel(parent), _pressed(false), _pressed_focus_tx(0),
13 _pressed_unfocus_tx(0), _unpr_focus_tx(0), _unpr_unfocus_tx(0)
14 {
15 }
16
17 Button::~Button()
18 {
19 }
20
21
22 void Button::setStyle(Style *style)
23 {
24 FocusLabel::setStyle(style);
25
26 // XXX: do this again
27 //setTexture(style->getButtonFocus());
28 //setUnfocusTexture(style->getButtonUnfocus());
29 //_pressed_focus_tx = style->getButtonPressedFocus();
30 //_pressed_unfocus_tx = style->getButtonPressedUnfocus();
31 }
32
33
34 void Button::press(unsigned int mouse_button)
35 {
36 if (_pressed) return;
37
38 if (_pressed_focus_tx)
39 FocusWidget::setTexture(_pressed_focus_tx);
40 if (_pressed_unfocus_tx)
41 FocusWidget::setUnfocusTexture(_pressed_unfocus_tx);
42 _pressed = true;
43 _mouse_button = mouse_button;
44 }
45
46 void Button::release(unsigned int mouse_button)
47 {
48 if (_mouse_button != mouse_button) return; // wrong button
49
50 FocusWidget::setTexture(_unpr_focus_tx);
51 FocusWidget::setUnfocusTexture(_unpr_unfocus_tx);
52 _pressed = false;
53 }
54
55 void Button::setTexture(RenderTexture *texture)
56 {
57 FocusWidget::setTexture(texture);
58 _unpr_focus_tx = texture;
59 }
60
61 void Button::setUnfocusTexture(RenderTexture *texture)
62 {
63 FocusWidget::setUnfocusTexture(texture);
64 _unpr_unfocus_tx = texture;
65 }
66
67 void Button::buttonPressHandler(const XButtonEvent &e)
68 {
69 press(e.button);
70 update();
71 FocusWidget::buttonPressHandler(e);
72 }
73
74 void Button::buttonReleaseHandler(const XButtonEvent &e)
75 {
76 release(e.button);
77 update();
78 FocusWidget::buttonReleaseHandler(e);
79 }
80
81 }
This page took 0.037385 seconds and 4 git commands to generate.