]>
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::update()
82 printf("ButtonWidget::update()\n");
85 void ButtonWidget::renderForeground()
91 otk::Widget::renderForeground();
95 case Type_StickyButton
:
96 pm
= _style
->stickyMask();
98 case Type_CloseButton
:
99 pm
= _style
->closeMask();
101 case Type_MaximizeButton
:
102 pm
= _style
->maximizeMask();
104 case Type_IconifyButton
:
105 pm
= _style
->iconifyMask();
109 return; // no drawing
111 assert(false); // there's no other button widgets!
114 if (pm
->mask
== None
) return; // no mask for the button, leave it empty
116 width
= _rect
.width();
118 otk::RenderColor
*color
= (_focused
? _style
->buttonFocusColor() :
119 _style
->buttonUnfocusColor());
121 // set the clip region
122 XSetClipMask(**otk::display
, color
->gc(), pm
->mask
);
123 XSetClipOrigin(**otk::display
, color
->gc(),
124 (width
- pm
->w
)/2, (width
- pm
->h
)/2);
126 // fill in the clipped region
127 XFillRectangle(**otk::display
, _window
, color
->gc(),
128 (width
- pm
->w
)/2, (width
- pm
->h
)/2,
129 (width
+ pm
->w
)/2, (width
+ pm
->h
)/2);
131 // unset the clip region
132 XSetClipMask(**otk::display
, color
->gc(), None
);
133 XSetClipOrigin(**otk::display
, color
->gc(), 0, 0);
138 void ButtonWidget::adjust()
140 // nothing to adjust. no children.
144 void ButtonWidget::focus()
146 otk::Widget::focus();
151 void ButtonWidget::unfocus()
153 otk::Widget::unfocus();
158 void ButtonWidget::buttonPressHandler(const XButtonEvent
&e
)
160 otk::Widget::buttonPressHandler(e
);
169 void ButtonWidget::buttonReleaseHandler(const XButtonEvent
&e
)
171 otk::Widget::buttonPressHandler(e
);
172 if (e
.button
!= _button
) return;
This page took 0.040448 seconds and 4 git commands to generate.