src/backgroundwidget.cc (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- #ifdef HAVE_CONFIG_H # include "../config.h" #endif #include "backgroundwidget.hh" namespace ob { OBBackgroundWidget::OBBackgroundWidget(otk::OtkWidget *parent, OBWidget::WidgetType type) : otk::OtkWidget(parent), OBWidget(type) { } OBBackgroundWidget::~OBBackgroundWidget() { } void OBBackgroundWidget::setTextures() { switch (type()) { case Type_Titlebar: if (_focused) setTexture(_style->getTitleFocus()); else setTexture(_style->getTitleUnfocus()); break; case Type_Handle: if (_focused) setTexture(_style->getHandleFocus()); else setTexture(_style->getHandleUnfocus()); break; case Type_Plate: if (_focused) setBorderColor(&_style->getFrameFocus()->color()); else setBorderColor(&_style->getFrameUnfocus()->color()); break; default: assert(false); // there's no other background widgets! } } void OBBackgroundWidget::setStyle(otk::Style *style) { OtkWidget::setStyle(style); setTextures(); switch (type()) { case Type_Titlebar: case Type_Handle: setBorderColor(_style->getBorderColor()); break; case Type_Plate: break; default: assert(false); // there's no other background widgets! } } void OBBackgroundWidget::focus() { otk::OtkWidget::focus(); setTextures(); } void OBBackgroundWidget::unfocus() { otk::OtkWidget::unfocus(); setTextures(); } void OBBackgroundWidget::adjust() { // nothing to adjust here. its done in OBFrame::adjustSize } void OBBackgroundWidget::grabButtons(bool grab) { if (grab) { // grab simple button clicks on the client, but pass them through too otk::OBDisplay::grabButton(Button1, 0, _window, true, ButtonPressMask, GrabModeSync, GrabModeSync, _window, None, false); otk::OBDisplay::grabButton(Button2, 0, _window, true, ButtonPressMask, GrabModeSync, GrabModeSync, _window, None, false); otk::OBDisplay::grabButton(Button3, 0, _window, true, ButtonPressMask, GrabModeSync, GrabModeSync, _window, None, false); otk::OBDisplay::grabButton(Button4, 0, _window, true, ButtonPressMask, GrabModeSync, GrabModeSync, _window, None, false); otk::OBDisplay::grabButton(Button5, 0, _window, true, ButtonPressMask, GrabModeSync, GrabModeSync, _window, None, false); } else { otk::OBDisplay::ungrabButton(Button1, 0, _window); otk::OBDisplay::ungrabButton(Button2, 0, _window); otk::OBDisplay::ungrabButton(Button3, 0, _window); otk::OBDisplay::ungrabButton(Button4, 0, _window); otk::OBDisplay::ungrabButton(Button5, 0, _window); } } void OBBackgroundWidget::buttonPressHandler(const XButtonEvent &e) { if (type() == OBWidget::Type_Plate) XAllowEvents(otk::OBDisplay::display, ReplayPointer, e.time); } } |