#include <buttonwidget.hh>
Inheritance diagram for ob::ButtonWidget:
Public Methods | |
ButtonWidget (otk::Widget *parent, WidgetBase::WidgetType type, Client *client) | |
virtual | ~ButtonWidget () |
virtual void | setStyle (otk::RenderStyle *style) |
virtual void | adjust () |
virtual void | update () |
virtual void | renderForeground () |
virtual void | focus () |
virtual void | unfocus () |
virtual void | buttonPressHandler (const XButtonEvent &e) |
Called whenever a button of the pointer is pressed. | |
virtual void | buttonReleaseHandler (const XButtonEvent &e) |
Called whenever a button of the pointer is released. | |
Private Methods | |
void | setTextures () |
Private Attributes | |
Client * | _client |
bool | _pressed |
unsigned int | _button |
bool | _state |
|
Definition at line 12 of file buttonwidget.cc.
00015 : otk::Widget(parent), 00016 WidgetBase(type), 00017 _client(client), 00018 _pressed(false), 00019 _button(0), 00020 _state(false) 00021 { 00022 } |
|
Definition at line 25 of file buttonwidget.cc.
00026 { 00027 } |
|
Reimplemented from otk::Widget. Definition at line 174 of file buttonwidget.cc.
00175 {
00176 // nothing to adjust. no children.
00177 }
|
|
Called whenever a button of the pointer is pressed.
Reimplemented from otk::EventHandler. Definition at line 194 of file buttonwidget.cc. References _button, _pressed, otk::EventHandler::buttonPressHandler(), setTextures(), and update().
00195 { 00196 otk::Widget::buttonPressHandler(e); 00197 if (_button) return; 00198 _button = e.button; 00199 _pressed = true; 00200 setTextures(); 00201 update(); 00202 } |
|
Called whenever a button of the pointer is released.
Reimplemented from otk::EventHandler. Definition at line 205 of file buttonwidget.cc. References _button, _pressed, otk::EventHandler::buttonPressHandler(), setTextures(), and update().
00206 { 00207 otk::Widget::buttonPressHandler(e); 00208 if (e.button != _button) return; 00209 _button = 0; 00210 _pressed = false; 00211 setTextures(); 00212 update(); 00213 } |
|
Reimplemented from otk::Widget. Definition at line 180 of file buttonwidget.cc. References otk::Widget::focus(), and setTextures().
00181 { 00182 otk::Widget::focus(); 00183 setTextures(); 00184 } |
|
Reimplemented from otk::Widget. Definition at line 121 of file buttonwidget.cc. References otk::Widget::_dirty, otk::Widget::_focused, otk::Widget::_rect, otk::Widget::_style, otk::Widget::_surface, otk::RenderColor::gc(), otk::PixmapMask::h, otk::PixmapMask::mask, otk::Widget::renderForeground(), ob::WidgetBase::type(), ob::WidgetBase::Type_AllDesktopsButton, ob::WidgetBase::Type_CloseButton, ob::WidgetBase::Type_IconifyButton, ob::WidgetBase::Type_LeftGrip, ob::WidgetBase::Type_MaximizeButton, ob::WidgetBase::Type_RightGrip, otk::PixmapMask::w, and otk::Widget::width().
00122 { 00123 otk::PixmapMask *pm; 00124 int width; 00125 bool draw = _dirty; 00126 00127 otk::Widget::renderForeground(); 00128 00129 if (draw) { 00130 switch (type()) { 00131 case Type_AllDesktopsButton: 00132 pm = _style->alldesktopsMask(); 00133 break; 00134 case Type_CloseButton: 00135 pm = _style->closeMask(); 00136 break; 00137 case Type_MaximizeButton: 00138 pm = _style->maximizeMask(); 00139 break; 00140 case Type_IconifyButton: 00141 pm = _style->iconifyMask(); 00142 break; 00143 case Type_LeftGrip: 00144 case Type_RightGrip: 00145 return; // no drawing 00146 default: 00147 assert(false); // there's no other button widgets! 00148 } 00149 00150 assert(pm->mask); 00151 if (pm->mask == None) return; // no mask for the button, leave it empty 00152 00153 width = _rect.width(); 00154 00155 otk::RenderColor *color = (_focused ? _style->buttonFocusColor() : 00156 _style->buttonUnfocusColor()); 00157 00158 // set the clip region 00159 int x = (width - pm->w) / 2, y = (width - pm->h) / 2; 00160 XSetClipMask(**otk::display, color->gc(), pm->mask); 00161 XSetClipOrigin(**otk::display, color->gc(), x, y); 00162 00163 // fill in the clipped region 00164 XFillRectangle(**otk::display, _surface->pixmap(), color->gc(), x, y, 00165 x + pm->w, y + pm->h); 00166 00167 // unset the clip region 00168 XSetClipMask(**otk::display, color->gc(), None); 00169 XSetClipOrigin(**otk::display, color->gc(), 0, 0); 00170 } 00171 } |
|
Reimplemented from otk::Widget. Definition at line 77 of file buttonwidget.cc. References otk::Widget::_style, otk::Widget::setBorderColor(), otk::Widget::setStyle(), setTextures(), ob::WidgetBase::type(), ob::WidgetBase::Type_AllDesktopsButton, ob::WidgetBase::Type_CloseButton, ob::WidgetBase::Type_IconifyButton, ob::WidgetBase::Type_LeftGrip, ob::WidgetBase::Type_MaximizeButton, and ob::WidgetBase::Type_RightGrip.
00078 { 00079 otk::Widget::setStyle(style); 00080 setTextures(); 00081 00082 switch (type()) { 00083 case Type_LeftGrip: 00084 case Type_RightGrip: 00085 setBorderColor(_style->frameBorderColor()); 00086 break; 00087 case Type_AllDesktopsButton: 00088 case Type_CloseButton: 00089 case Type_MaximizeButton: 00090 case Type_IconifyButton: 00091 break; 00092 default: 00093 assert(false); // there's no other button widgets! 00094 } 00095 } |
|
Definition at line 30 of file buttonwidget.cc. References _client, _pressed, otk::Widget::_style, ob::Client::desktop(), ob::Client::maxHorz(), ob::Client::maxVert(), otk::Widget::setTexture(), ob::WidgetBase::type(), ob::WidgetBase::Type_AllDesktopsButton, ob::WidgetBase::Type_CloseButton, ob::WidgetBase::Type_IconifyButton, ob::WidgetBase::Type_LeftGrip, ob::WidgetBase::Type_MaximizeButton, and ob::WidgetBase::Type_RightGrip. Referenced by buttonPressHandler(), buttonReleaseHandler(), focus(), setStyle(), unfocus(), and update().
00031 { 00032 bool p = _pressed; 00033 00034 switch (type()) { 00035 case Type_AllDesktopsButton: 00036 if (_client->desktop() == (signed)0xffffffff) 00037 p = true; 00038 break; 00039 case Type_MaximizeButton: 00040 if (_client->maxHorz() || _client->maxVert()) 00041 p = true; 00042 break; 00043 default: 00044 break; 00045 } 00046 00047 switch (type()) { 00048 case Type_LeftGrip: 00049 case Type_RightGrip: 00050 if (_focused) 00051 setTexture(_style->gripFocusBackground()); 00052 else 00053 setTexture(_style->gripUnfocusBackground()); 00054 break; 00055 case Type_AllDesktopsButton: 00056 case Type_MaximizeButton: 00057 case Type_CloseButton: 00058 case Type_IconifyButton: 00059 if (p) { 00060 if (_focused) 00061 setTexture(_style->buttonPressFocusBackground()); 00062 else 00063 setTexture(_style->buttonPressUnfocusBackground()); 00064 } else { 00065 if (_focused) 00066 setTexture(_style->buttonUnpressFocusBackground()); 00067 else 00068 setTexture(_style->buttonUnpressUnfocusBackground()); 00069 } 00070 break; 00071 default: 00072 assert(false); // there's no other button widgets! 00073 } 00074 } |
|
Reimplemented from otk::Widget. Definition at line 187 of file buttonwidget.cc. References setTextures(), and otk::Widget::unfocus().
00188 { 00189 otk::Widget::unfocus(); 00190 setTextures(); 00191 } |
|
Reimplemented from otk::Widget. Definition at line 98 of file buttonwidget.cc. References _client, _state, ob::Client::desktop(), ob::Client::maxHorz(), ob::Client::maxVert(), setTextures(), ob::WidgetBase::type(), ob::WidgetBase::Type_AllDesktopsButton, ob::WidgetBase::Type_MaximizeButton, and otk::Widget::update(). Referenced by ob::Frame::adjustState(), buttonPressHandler(), and buttonReleaseHandler().
00099 { 00100 switch (type()) { 00101 case Type_AllDesktopsButton: 00102 if ((_client->desktop() == (signed)0xffffffff) != _state) { 00103 _state = !_state; 00104 setTextures(); 00105 } 00106 break; 00107 case Type_MaximizeButton: 00108 if ((_client->maxHorz() || _client->maxVert()) != _state) { 00109 _state = !_state; 00110 setTextures(); 00111 } 00112 break; 00113 default: 00114 break; 00115 } 00116 00117 otk::Widget::update(); 00118 } |
|
Definition at line 18 of file buttonwidget.hh. Referenced by buttonPressHandler(), and buttonReleaseHandler(). |
|
Definition at line 16 of file buttonwidget.hh. Referenced by setTextures(), and update(). |
|
Definition at line 17 of file buttonwidget.hh. Referenced by buttonPressHandler(), buttonReleaseHandler(), and setTextures(). |
|
Definition at line 19 of file buttonwidget.hh. Referenced by update(). |