]>
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 OBButtonWidget::OBButtonWidget(otk::OtkWidget
*parent
,
13 OBWidget::WidgetType type
)
14 : otk::OtkWidget(parent
),
22 OBButtonWidget::~OBButtonWidget()
27 void OBButtonWidget::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 OBButtonWidget::setStyle(otk::Style
*style
)
61 otk::OtkWidget::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 OBButtonWidget::update()
86 otk::OtkWidget::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::BPen
pen(_focused
? *_style
->getButtonPicFocus() :
114 *_style
->getButtonPicUnfocus());
116 // set the clip region
117 XSetClipMask(otk::OBDisplay::display
, pen
.gc(), pm
->mask
);
118 XSetClipOrigin(otk::OBDisplay::display
, pen
.gc(),
119 (width
- pm
->w
)/2, (width
- pm
->h
)/2);
121 // fill in the clipped region
122 XFillRectangle(otk::OBDisplay::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::OBDisplay::display
, pen
.gc(), None
);
128 XSetClipOrigin(otk::OBDisplay::display
, pen
.gc(), 0, 0);
133 void OBButtonWidget::adjust()
135 // nothing to adjust. no children.
139 void OBButtonWidget::focus()
141 otk::OtkWidget::focus();
146 void OBButtonWidget::unfocus()
148 otk::OtkWidget::unfocus();
153 void OBButtonWidget::buttonPressHandler(const XButtonEvent
&e
)
155 OtkWidget::buttonPressHandler(e
);
164 void OBButtonWidget::buttonReleaseHandler(const XButtonEvent
&e
)
166 OtkWidget::buttonPressHandler(e
);
167 if (e
.button
!= _button
) return;
This page took 0.038343 seconds and 4 git commands to generate.