]>
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
->gripFocusBackground());
35 setTexture(_style
->gripUnfocusBackground());
37 case Type_StickyButton
:
38 case Type_CloseButton
:
39 case Type_MaximizeButton
:
40 case Type_IconifyButton
:
43 setTexture(_style
->buttonPressFocusBackground());
45 setTexture(_style
->buttonPressUnfocusBackground());
48 setTexture(_style
->buttonUnpressFocusBackground());
50 setTexture(_style
->buttonUnpressUnfocusBackground());
54 assert(false); // there's no other button widgets!
59 void ButtonWidget::setStyle(otk::RenderStyle
*style
)
61 otk::Widget::setStyle(style
);
67 setBorderColor(_style
->frameBorderColor());
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::renderForeground()
86 otk::Widget::renderForeground();
90 case Type_StickyButton
:
91 pm
= _style
->stickyMask();
93 case Type_CloseButton
:
94 pm
= _style
->closeMask();
96 case Type_MaximizeButton
:
97 pm
= _style
->maximizeMask();
99 case Type_IconifyButton
:
100 pm
= _style
->iconifyMask();
104 return; // no drawing
106 assert(false); // there's no other button widgets!
110 if (pm
->mask
== None
) return; // no mask for the button, leave it empty
112 width
= _rect
.width();
114 otk::RenderColor
*color
= (_focused
? _style
->buttonFocusColor() :
115 _style
->buttonUnfocusColor());
117 // set the clip region
118 int x
= (width
- pm
->w
) / 2, y
= (width
- pm
->h
) / 2;
119 XSetClipMask(**otk::display
, color
->gc(), pm
->mask
);
120 XSetClipOrigin(**otk::display
, color
->gc(), x
, y
);
122 // fill in the clipped region
123 XFillRectangle(**otk::display
, _surface
->pixmap(), color
->gc(), x
, y
,
124 x
+ pm
->w
, y
+ pm
->h
);
126 // unset the clip region
127 XSetClipMask(**otk::display
, color
->gc(), None
);
128 XSetClipOrigin(**otk::display
, color
->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.038717 seconds and 4 git commands to generate.