[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Mon Jun 20 03:55:20 CEST 2005


SVN commit 427238 by staikos:

Somewhat closer to keeping the curve inside the bounding box on resize and move


 M  +24 -0     kstviewbezier.cpp  
 M  +3 -0      kstviewbezier.h  


--- trunk/extragear/graphics/kst/kst/kstviewbezier.cpp #427237:427238
@@ -156,5 +156,29 @@
 }
 
 
+void KstViewBezier::resize(const QSize& sz) {
+  QSize oldSize = size();
+  QPoint pos = position();
+  double dxF = double(sz.width() - oldSize.width()) / oldSize.width();
+  double dyF = double(sz.height() - oldSize.height()) / oldSize.height();
+  _points[0].setX(int(_points[0].x() * (1 + dxF) - pos.x() * dxF));
+  _points[0].setY(int(_points[0].y() * (1 + dyF) - pos.y() * dyF));
+  _points[1].setX(int(_points[1].x() * (1 + dxF) - pos.x() * dxF));
+  _points[1].setY(int(_points[1].y() * (1 + dyF) - pos.y() * dyF));
+  _points[2].setX(int(_points[2].x() * (1 + dxF) - pos.x() * dxF));
+  _points[2].setY(int(_points[2].y() * (1 + dyF) - pos.y() * dyF));
+  _points[3].setX(int(_points[3].x() * (1 + dxF) - pos.x() * dxF));
+  _points[3].setY(int(_points[3].y() * (1 + dyF) - pos.y() * dyF));
+  KstViewObject::resize(sz);
+}
+
+
+void KstViewBezier::move(const QPoint& pt) {
+  QPoint offset = pt - position();
+  _points.translate(offset.x(), offset.y());
+  KstViewObject::move(pt);
+}
+
+
 #include "kstviewbezier.moc"
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstviewbezier.h #427237:427238
@@ -47,6 +47,9 @@
     virtual void setPenStyle(Qt::PenStyle style);
     virtual Qt::PenStyle penStyle() const;
 
+    virtual void resize(const QSize&);
+    virtual void move(const QPoint&);
+
   public slots:
     virtual void paint(KstPaintType type, QPainter& p);
 


More information about the Kst mailing list