[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Wed Jun 9 20:08:12 CEST 2004


CVS commit by arwalker: 

When dragging a label make its background transparent.


  M +41 -28    kst2dplot.cpp   1.72


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.71:1.72
@@ -26,4 +26,5 @@
 #include <qnamespace.h>
 #include <qpainter.h>
+#include <qbitmap.h>
 #include <qrect.h>
 #include <qstring.h>
@@ -1828,12 +1829,19 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
     // Start a drag
     KstLabel *label = labelList.at(i_label);
+    if (label) {
     QRegion oldExtents = label->extents;
+      QBitmap bm(GetWinRegion().width(), GetWinRegion().height(), TRUE);
     QPixmap pm(GetWinRegion().width(), GetWinRegion().height());
-    pm.fill(KstSettings::globalSettings()->backgroundColor);
     QRect rectBounding = oldExtents.boundingRect();
 
+      pm.fill(KstSettings::globalSettings()->backgroundColor);
+
+      { // Scope is needed to kill off painter before we resize
+        QPainter p(&bm);
+        label->draw(p, 0, label->v_offset, false);
+      }
+
     { // Scope is needed to kill off painter before we resize
       QPainter p(&pm);
-      p.setBackgroundColor(KstSettings::globalSettings()->backgroundColor);
       label->draw(p, 0, label->v_offset, false);
     }
@@ -1853,8 +1861,13 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
 
     pm.resize(iWidth, iHeight);
+      bm.resize(iWidth, iHeight);
+      pm.setMask(bm);
     label->extents = oldExtents; // restore them in case the drag is canceled
     QDragObject *d = new KstLabelDrag(view, static_cast<KstViewWindow*>(view->parent())->caption(), this, i_label, _draggablePoint - GetWinRegion().topLeft() - rectBounding.topLeft(), pm);
+      if (d) {
     d->dragMove();
     _draggableLabel = -1;
+      }
+    }
     return;
   } else if (e->state() & Qt::LeftButton && _mouse.mode == LABEL_TOOL && legendUnder(e)) {





More information about the Kst mailing list