]>
Dogcows Code - chaz/openbox/blob - button.cc
98d5780504d8335eaecb40558dca4170c0fecf64
5 OtkButton::OtkButton(OtkWidget
*parent
)
6 : OtkFocusWidget(parent
), _text(""), _pressed(false), _dirty(false),
7 _pressed_focus_tx(0), _pressed_unfocus_tx(0), _unpr_focus_tx(0),
10 setTexture(getStyle()->getButtonFocus());
11 setUnfocusTexture(getStyle()->getButtonUnfocus());
12 _pressed_focus_tx
= getStyle()->getButtonPressedFocus();
13 _pressed_unfocus_tx
= getStyle()->getButtonPressedUnfocus();
16 OtkButton::~OtkButton()
18 if (_pressed_focus_tx
) delete _pressed_focus_tx
;
19 if (_pressed_unfocus_tx
) delete _pressed_unfocus_tx
;
22 void OtkButton::press(void)
24 if (_pressed_focus_tx
)
25 OtkFocusWidget::setTexture(_pressed_focus_tx
);
26 if (_pressed_unfocus_tx
)
27 OtkFocusWidget::setUnfocusTexture(_pressed_unfocus_tx
);
31 void OtkButton::release(void)
33 OtkFocusWidget::setTexture(_unpr_focus_tx
);
34 OtkFocusWidget::setUnfocusTexture(_unpr_unfocus_tx
);
38 void OtkButton::setTexture(BTexture
*texture
)
40 OtkFocusWidget::setTexture(texture
);
41 _unpr_focus_tx
= texture
;
44 void OtkButton::setUnfocusTexture(BTexture
*texture
)
46 OtkFocusWidget::setUnfocusTexture(texture
);
47 _unpr_unfocus_tx
= texture
;
50 void OtkButton::update(void)
53 const BFont ft
= getStyle()->getFont();
54 BColor
*text_color
= (isFocused() ? getStyle()->getTextFocus()
55 : getStyle()->getTextUnfocus());
56 unsigned int bevel
= getStyle()->getBevelWidth();
58 OtkFocusWidget::resize(ft
.measureString(_text
) + bevel
* 2,
59 ft
.height() + bevel
* 2);
60 ft
.drawString(getWindow(), bevel
, bevel
, *text_color
, _text
);
62 OtkFocusWidget::update();
This page took 0.034274 seconds and 3 git commands to generate.