]> Dogcows Code - chaz/openbox/commitdiff
buttons have their pixmaps!
authorDana Jansens <danakj@orodu.net>
Fri, 27 Dec 2002 10:07:57 +0000 (10:07 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 27 Dec 2002 10:07:57 +0000 (10:07 +0000)
otk/otk_wrap.cc
otk/style.hh
otk/texture.cc
src/buttonwidget.cc
src/buttonwidget.hh
src/client.cc
src/labelwidget.cc

index c62d247175206f0f31fd9f12afa5577599ecab15..5ab614fb5baf751d7f4729ceab29cd662c22a8b3 100644 (file)
@@ -10927,6 +10927,74 @@ static PyObject *_wrap_Style_load(PyObject *self, PyObject *args) {
 }
 
 
+static PyObject *_wrap_Style_getCloseButtonMask(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    otk::Style *arg1 = (otk::Style *) 0 ;
+    otk::PixmapMask *result;
+    PyObject * obj0  = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:Style_getCloseButtonMask",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_otk__Style,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    result = (otk::PixmapMask *)(arg1)->getCloseButtonMask();
+    
+    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_otk__PixmapMask, 0);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_Style_getMaximizeButtonMask(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    otk::Style *arg1 = (otk::Style *) 0 ;
+    otk::PixmapMask *result;
+    PyObject * obj0  = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:Style_getMaximizeButtonMask",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_otk__Style,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    result = (otk::PixmapMask *)(arg1)->getMaximizeButtonMask();
+    
+    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_otk__PixmapMask, 0);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_Style_getIconifyButtonMask(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    otk::Style *arg1 = (otk::Style *) 0 ;
+    otk::PixmapMask *result;
+    PyObject * obj0  = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:Style_getIconifyButtonMask",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_otk__Style,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    result = (otk::PixmapMask *)(arg1)->getIconifyButtonMask();
+    
+    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_otk__PixmapMask, 0);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_Style_getStickyButtonMask(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    otk::Style *arg1 = (otk::Style *) 0 ;
+    otk::PixmapMask *result;
+    PyObject * obj0  = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:Style_getStickyButtonMask",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_otk__Style,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    result = (otk::PixmapMask *)(arg1)->getStickyButtonMask();
+    
+    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_otk__PixmapMask, 0);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
 static PyObject *_wrap_Style_getTextFocus(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     otk::Style *arg1 = (otk::Style *) 0 ;
@@ -13077,6 +13145,10 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"Style_readDatabaseColor", _wrap_Style_readDatabaseColor, METH_VARARGS },
         { (char *)"Style_readDatabaseFont", _wrap_Style_readDatabaseFont, METH_VARARGS },
         { (char *)"Style_load", _wrap_Style_load, METH_VARARGS },
+        { (char *)"Style_getCloseButtonMask", _wrap_Style_getCloseButtonMask, METH_VARARGS },
+        { (char *)"Style_getMaximizeButtonMask", _wrap_Style_getMaximizeButtonMask, METH_VARARGS },
+        { (char *)"Style_getIconifyButtonMask", _wrap_Style_getIconifyButtonMask, METH_VARARGS },
+        { (char *)"Style_getStickyButtonMask", _wrap_Style_getStickyButtonMask, METH_VARARGS },
         { (char *)"Style_getTextFocus", _wrap_Style_getTextFocus, METH_VARARGS },
         { (char *)"Style_getTextUnfocus", _wrap_Style_getTextUnfocus, METH_VARARGS },
         { (char *)"Style_getButtonPicFocus", _wrap_Style_getButtonPicFocus, METH_VARARGS },
index d3b5903e94222f3639459d45541a94e4a8fc4b5f..2944339dddcd4cdc11f74f79d369e0ec7447e652 100644 (file)
@@ -84,6 +84,11 @@ public:
 
   void load(const Configuration &style);
 
+  inline PixmapMask *getCloseButtonMask(void) { return &close_button; }
+  inline PixmapMask *getMaximizeButtonMask(void) { return &max_button; }
+  inline PixmapMask *getIconifyButtonMask(void) { return &icon_button; }
+  inline PixmapMask *getStickyButtonMask(void) { return &stick_button; }
+
   inline BColor *getTextFocus(void) { return &l_text_focus; }
   inline BColor *getTextUnfocus(void) { return &l_text_unfocus; }
 
index 7a651620057cde78c0d40c3faa3a4a1069f5a061..967878b7edc3cd474ff2f775566bf1acc0edf08f 100644 (file)
@@ -158,8 +158,8 @@ Pixmap BTexture::render(const unsigned int width, const unsigned int height,
                         const Pixmap old) {
   assert(texture() != BTexture::NoTexture);
 
-  if (texture() == (BTexture::Flat | BTexture::Solid))
-    return None;
+//  if (texture() == (BTexture::Flat | BTexture::Solid))
+//    return None;
   if (texture() == BTexture::Parent_Relative)
     return ParentRelative;
 
index 853b0339f448793948e60e93bb3ff7b9e6db6cbc..efb98e7652babc990da115232a9e60e44d9a7b3d 100644 (file)
@@ -5,6 +5,7 @@
 #endif
 
 #include "buttonwidget.hh"
+#include "otk/gccache.hh" // otk::BPen
 
 namespace ob {
 
@@ -76,6 +77,62 @@ void OBButtonWidget::setStyle(otk::Style *style)
 }
 
 
+void OBButtonWidget::update()
+{
+  otk::PixmapMask *pm;
+  int width;
+
+  otk::OtkWidget::update();
+
+  switch (type()) {
+  case Type_StickyButton:
+    pm = _style->getStickyButtonMask();
+    break;
+  case Type_CloseButton:
+    pm = _style->getCloseButtonMask();
+    break;
+  case Type_MaximizeButton:
+    pm = _style->getMaximizeButtonMask();
+    break;
+  case Type_IconifyButton:
+    pm = _style->getIconifyButtonMask();
+    break;
+  case Type_LeftGrip:
+  case Type_RightGrip:
+    return; // no drawing
+  default:
+    assert(false); // there's no other button widgets!
+  }
+
+  if (pm->mask == None) return; // no mask for the button, leave it empty
+
+  width = _rect.width();
+  
+  otk::BPen pen(_focused ? *_style->getButtonPicFocus() :
+                           *_style->getButtonPicUnfocus());
+
+  // set the clip region
+  XSetClipMask(otk::OBDisplay::display, pen.gc(), pm->mask);
+  XSetClipOrigin(otk::OBDisplay::display, pen.gc(),
+                 (width - pm->w)/2, (width - pm->h)/2);
+
+  // fill in the clipped region
+  XFillRectangle(otk::OBDisplay::display, _window, pen.gc(),
+                 (width - pm->w)/2, (width - pm->h)/2,
+                 (width + pm->w)/2, (width + pm->h)/2);
+
+  // unset the clip region
+  XSetClipMask(otk::OBDisplay::display, pen.gc(), None);
+  XSetClipOrigin(otk::OBDisplay::display, pen.gc(), 0, 0);
+}
+
+
+void OBButtonWidget::adjust()
+{
+  // XXX: adjust shit
+}
+
+
 void OBButtonWidget::focus()
 {
   otk::OtkWidget::focus();
@@ -90,12 +147,6 @@ void OBButtonWidget::unfocus()
 }
 
 
-void OBButtonWidget::adjust()
-{
-  // XXX: adjust shit
-}
-
-
 void OBButtonWidget::buttonPressHandler(const XButtonEvent &e)
 {
   OtkWidget::buttonPressHandler(e);
index 66a9cf3724f13b6a5de88ea04d1305723766309c..c2bb41f4ddba8ea6b1ccff177d40b7dc293e296f 100644 (file)
@@ -22,6 +22,8 @@ public:
 
   virtual void adjust();
 
+  virtual void update();
+  
   virtual void focus();
   virtual void unfocus();
 
index 243390a84ba78bf32e74cbc519f9a6f23eba5494..e626081ce19e871a2fe37e25653f5f257ee69ed0 100644 (file)
@@ -1009,15 +1009,15 @@ void OBClient::destroyHandler(const XDestroyWindowEvent &e)
 
 void OBClient::reparentHandler(const XReparentEvent &e)
 {
+  // this is when the client is first taken captive in the frame
+  if (e.parent == frame->plate()) return;
+
 #ifdef    DEBUG
   printf("ReparentNotify for 0x%lx\n", e.window);
 #endif // DEBUG
 
   OtkEventHandler::reparentHandler(e);
 
-  // this is when the client is first taken captive in the frame
-  if (e.parent == frame->plate()) return;
-
   /*
     This event is quite rare and is usually handled in unmapHandler.
     However, if the window is unmapped when the reparent event occurs,
index 5a33cf3dd0bfdf78e857d74ee587504b8c78ee76..491deadccdf75120f0c938b664acb3b7f4e1d94a 100644 (file)
@@ -72,41 +72,38 @@ void OBLabelWidget::unfocus()
 
 void OBLabelWidget::update()
 {
-  if (_dirty) {
-    std::string t = _text;
-    int x = _sidemargin;    // x coord for the text
-
-    // find a string that will fit inside the area for text
-    int max_length = width() - _sidemargin * 2;
-    if (max_length <= 0) {
-      t = ""; // can't fit anything
-    } else {
-      size_t text_len = t.size();
-      int length;
+  OtkWidget::update();
+
+  std::string t = _text;
+  int x = _sidemargin;    // x coord for the text
+
+  // find a string that will fit inside the area for text
+  int max_length = width() - _sidemargin * 2;
+  if (max_length <= 0) {
+    t = ""; // can't fit anything
+  } else {
+    size_t text_len = t.size();
+    int length;
       
-      do {
-        t.resize(text_len);
-        length = _font->measureString(t);
-      } while (length > max_length && text_len-- > 0);
-
-      // justify the text
-      switch (_justify) {
-      case otk::Style::RightJustify:
-        x += max_length - length;
-        break;
-      case otk::Style::CenterJustify:
-        x += (max_length - length) / 2;
-        break;
-      case otk::Style::LeftJustify:
-        break;
-      }
+    do {
+      t.resize(text_len);
+      length = _font->measureString(t);
+    } while (length > max_length && text_len-- > 0);
+
+    // justify the text
+    switch (_justify) {
+    case otk::Style::RightJustify:
+      x += max_length - length;
+      break;
+    case otk::Style::CenterJustify:
+      x += (max_length - length) / 2;
+      break;
+    case otk::Style::LeftJustify:
+      break;
     }
+  }
 
-    OtkWidget::update();
-
-    _font->drawString(_xftdraw, x, 0, *_text_color, t);
-  } else
-    OtkWidget::update();
+  _font->drawString(_xftdraw, x, 0, *_text_color, t);
 }
 
 
This page took 0.036157 seconds and 4 git commands to generate.