]>
Dogcows Code - chaz/openbox/blob - src/buttonwidget.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
7 #include "buttonwidget.hh"
8 #include "otk/gccache.hh" // otk::BPen
12 ButtonWidget::ButtonWidget(otk::Widget
*parent
,
13 WidgetBase::WidgetType type
)
14 : otk::Widget(parent
),
22 ButtonWidget::~ButtonWidget()
27 void ButtonWidget::setTextures()
33 setTexture(_style
->getGripFocus());
35 setTexture(_style
->getGripUnfocus());
37 case Type_StickyButton
:
38 case Type_CloseButton
:
39 case Type_MaximizeButton
:
40 case Type_IconifyButton
:
43 setTexture(_style
->getButtonPressedFocus());
45 setTexture(_style
->getButtonPressedUnfocus());
48 setTexture(_style
->getButtonFocus());
50 setTexture(_style
->getButtonUnfocus());
54 assert(false); // there's no other button widgets!
59 void ButtonWidget::setStyle(otk::Style
*style
)
61 otk::Widget::setStyle(style
);
67 setBorderColor(_style
->getBorderColor());
69 case Type_StickyButton
:
70 case Type_CloseButton
:
71 case Type_MaximizeButton
:
72 case Type_IconifyButton
:
75 assert(false); // there's no other button widgets!
80 void ButtonWidget::update()
86 otk::Widget::update();
90 case Type_StickyButton
:
91 pm
= _style
->getStickyButtonMask();
93 case Type_CloseButton
:
94 pm
= _style
->getCloseButtonMask();
96 case Type_MaximizeButton
:
97 pm
= _style
->getMaximizeButtonMask();
99 case Type_IconifyButton
:
100 pm
= _style
->getIconifyButtonMask();
104 return; // no drawing
106 assert(false); // there's no other button widgets!
109 if (pm
->mask
== None
) return; // no mask for the button, leave it empty
111 width
= _rect
.width();
113 otk::Pen
pen(_focused
? *_style
->getButtonPicFocus() :
114 *_style
->getButtonPicUnfocus());
116 // set the clip region
117 XSetClipMask(**otk::display
, pen
.gc(), pm
->mask
);
118 XSetClipOrigin(**otk::display
, pen
.gc(),
119 (width
- pm
->w
)/2, (width
- pm
->h
)/2);
121 // fill in the clipped region
122 XFillRectangle(**otk::display
, _window
, pen
.gc(),
123 (width
- pm
->w
)/2, (width
- pm
->h
)/2,
124 (width
+ pm
->w
)/2, (width
+ pm
->h
)/2);
126 // unset the clip region
127 XSetClipMask(**otk::display
, pen
.gc(), None
);
128 XSetClipOrigin(**otk::display
, pen
.gc(), 0, 0);
133 void ButtonWidget::adjust()
135 // nothing to adjust. no children.
139 void ButtonWidget::focus()
141 otk::Widget::focus();
146 void ButtonWidget::unfocus()
148 otk::Widget::unfocus();
153 void ButtonWidget::buttonPressHandler(const XButtonEvent
&e
)
155 otk::Widget::buttonPressHandler(e
);
164 void ButtonWidget::buttonReleaseHandler(const XButtonEvent
&e
)
166 otk::Widget::buttonPressHandler(e
);
167 if (e
.button
!= _button
) return;
This page took 0.041593 seconds and 4 git commands to generate.