]>
Dogcows Code - chaz/openbox/blob - otk/button.cc
3f283b00085ac9869a7e0d3b661995a34ede48ff
6 OtkButton::OtkButton(OtkWidget
*parent
)
7 : OtkFocusWidget(parent
), _text(""), _pressed(false), _dirty(false),
8 _pressed_focus_tx(0), _pressed_unfocus_tx(0), _unpr_focus_tx(0),
11 setTexture(getStyle()->getButtonFocus());
12 setUnfocusTexture(getStyle()->getButtonUnfocus());
13 _pressed_focus_tx
= getStyle()->getButtonPressedFocus();
14 _pressed_unfocus_tx
= getStyle()->getButtonPressedUnfocus();
17 OtkButton::~OtkButton()
19 if (_pressed_focus_tx
) delete _pressed_focus_tx
;
20 if (_pressed_unfocus_tx
) delete _pressed_unfocus_tx
;
23 void OtkButton::press(void)
25 if (_pressed_focus_tx
)
26 OtkFocusWidget::setTexture(_pressed_focus_tx
);
27 if (_pressed_unfocus_tx
)
28 OtkFocusWidget::setUnfocusTexture(_pressed_unfocus_tx
);
32 void OtkButton::release(void)
34 OtkFocusWidget::setTexture(_unpr_focus_tx
);
35 OtkFocusWidget::setUnfocusTexture(_unpr_unfocus_tx
);
39 void OtkButton::setTexture(BTexture
*texture
)
41 OtkFocusWidget::setTexture(texture
);
42 _unpr_focus_tx
= texture
;
45 void OtkButton::setUnfocusTexture(BTexture
*texture
)
47 OtkFocusWidget::setUnfocusTexture(texture
);
48 _unpr_unfocus_tx
= texture
;
51 void OtkButton::update(void)
54 const BFont ft
= getStyle()->getFont();
55 BColor
*text_color
= (isFocused() ? getStyle()->getTextFocus()
56 : getStyle()->getTextUnfocus());
57 unsigned int bevel
= getStyle()->getBevelWidth();
59 OtkFocusWidget::resize(ft
.measureString(_text
) + bevel
* 2,
60 ft
.height() + bevel
* 2);
61 OtkFocusWidget::update();
63 ft
.drawString(getWindow(), bevel
, bevel
, *text_color
, _text
);
65 OtkFocusWidget::update();
70 int OtkButton::buttonPressHandler(const XButtonEvent
&e
)
75 return OtkFocusWidget::buttonPressHandler(e
);
78 int OtkButton::buttonReleaseHandler(const XButtonEvent
&e
)
83 return OtkFocusWidget::buttonReleaseHandler(e
);
86 int OtkButton::exposeHandler(const XExposeEvent
&e
)
89 return OtkFocusWidget::exposeHandler(e
);
92 int OtkButton::configureHandler(const XConfigureEvent
&e
)
94 if (!(e
.width
== width() && e
.height
== height()))
96 return OtkFocusWidget::configureHandler(e
);
This page took 0.040213 seconds and 4 git commands to generate.