]>
Dogcows Code - chaz/openbox/blob - buttonwidget.cc
efb98e7652babc990da115232a9e60e44d9a7b3d
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()
85 otk::OtkWidget::update();
88 case Type_StickyButton
:
89 pm
= _style
->getStickyButtonMask();
91 case Type_CloseButton
:
92 pm
= _style
->getCloseButtonMask();
94 case Type_MaximizeButton
:
95 pm
= _style
->getMaximizeButtonMask();
97 case Type_IconifyButton
:
98 pm
= _style
->getIconifyButtonMask();
102 return; // no drawing
104 assert(false); // there's no other button widgets!
107 if (pm
->mask
== None
) return; // no mask for the button, leave it empty
109 width
= _rect
.width();
111 otk::BPen
pen(_focused
? *_style
->getButtonPicFocus() :
112 *_style
->getButtonPicUnfocus());
114 // set the clip region
115 XSetClipMask(otk::OBDisplay::display
, pen
.gc(), pm
->mask
);
116 XSetClipOrigin(otk::OBDisplay::display
, pen
.gc(),
117 (width
- pm
->w
)/2, (width
- pm
->h
)/2);
119 // fill in the clipped region
120 XFillRectangle(otk::OBDisplay::display
, _window
, pen
.gc(),
121 (width
- pm
->w
)/2, (width
- pm
->h
)/2,
122 (width
+ pm
->w
)/2, (width
+ pm
->h
)/2);
124 // unset the clip region
125 XSetClipMask(otk::OBDisplay::display
, pen
.gc(), None
);
126 XSetClipOrigin(otk::OBDisplay::display
, pen
.gc(), 0, 0);
130 void OBButtonWidget::adjust()
136 void OBButtonWidget::focus()
138 otk::OtkWidget::focus();
143 void OBButtonWidget::unfocus()
145 otk::OtkWidget::unfocus();
150 void OBButtonWidget::buttonPressHandler(const XButtonEvent
&e
)
152 OtkWidget::buttonPressHandler(e
);
161 void OBButtonWidget::buttonReleaseHandler(const XButtonEvent
&e
)
163 OtkWidget::buttonPressHandler(e
);
164 if (e
.button
!= _button
) return;
This page took 0.038442 seconds and 3 git commands to generate.