[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Tue Nov 22 19:12:00 CET 2005


SVN commit 482354 by netterfield:

View Labels now play nice with borders:
	-The geometry is from the outside of the border 
		(borders don't get clipped)
	-Room is made inside the border for the text in autoResize mode
	-Left/right/top/bottom justification leaves room for the border



 M  +4 -4      kstborderedviewobject.cpp  
 M  +10 -10    kstviewlabel.cpp  


--- trunk/extragear/graphics/kst/kst/kstborderedviewobject.cpp #482353:482354
@@ -77,10 +77,10 @@
     QPen pen(_borderColor, _borderWidth);
     p.setBrush(Qt::NoBrush);
     p.setPen(pen);
-    r.setX(_geom.left() + _margin);
-    r.setY(_geom.top() + _margin);
-    r.setWidth(_geom.width() - 2 * _margin);
-    r.setHeight(_geom.height() - 2 * _margin);
+    r.setX(_geom.left() + _margin + _borderWidth/2);
+    r.setY(_geom.top() + _margin + _borderWidth/2);
+    r.setWidth(_geom.width() - 2 * _margin - _borderWidth + 1);
+    r.setHeight(_geom.height() - 2 * _margin - _borderWidth + 1);
     p.drawRect(r);
   }
   KstViewObject::paint(type, p, bounds);
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #482353:482354
@@ -245,7 +245,7 @@
   switch (hJust) {
     case KST_JUSTIFY_H_RIGHT:
       rc.x = -_textWidth / 2;
-      tx = size().width() - int(_textWidth * abcos + _textHeight * absin) / 2;
+      tx = size().width() - int(_textWidth * abcos + _textHeight * absin) / 2  - borderWidth();
       break;
     case KST_JUSTIFY_H_CENTER:
       rc.x = -_textWidth / 2;
@@ -256,14 +256,14 @@
     case KST_JUSTIFY_H_LEFT:
     default:
       rc.x = -_textWidth / 2;
-      tx = int(_textWidth * abcos + _textHeight * absin) / 2;
+      tx = int(_textWidth * abcos + _textHeight * absin) / 2  + borderWidth();
       break;
   }
 
   switch (KST_JUSTIFY_V(_justify)) {
     case KST_JUSTIFY_V_BOTTOM:
       rc.y = _ascent - _textHeight / 2;
-      ty = size().height() - int(_textHeight * abcos + _textWidth * absin) / 2;
+      ty = size().height() - int(_textHeight * abcos + _textWidth * absin) / 2  - borderWidth();
       break;
     case KST_JUSTIFY_V_CENTER:
       rc.y = _ascent - _textHeight / 2;
@@ -273,7 +273,7 @@
     case KST_JUSTIFY_V_TOP:
     default:
       rc.y = _ascent - _textHeight / 2;
-      ty = int(_textHeight * abcos + _textWidth * absin) / 2;
+      ty = int(_textHeight * abcos + _textWidth * absin) / 2  + borderWidth();
       break;
   }
 
@@ -424,6 +424,7 @@
     computeTextSize(_parsed);
   }
   
+  QSize sz(_textWidth, _textHeight);
   if (_rotation != 0 && _rotation != 180) {
     QPointArray pts(4);
     pts[0] = QPoint(0, 0);
@@ -444,19 +445,18 @@
 
     if (_parent) {
       QRect r(position(), pts.boundingRect().size());
-      resize(r.intersect(_parent->geometry()).size());
+      sz = r.intersect(_parent->geometry()).size();
     } else {
-      resize(pts.boundingRect().size());
+      sz = pts.boundingRect().size();
     }
   } else {
-    QSize sz(_textWidth, _textHeight);
     if (_parent) {
       QRect r(position(), sz);
-      resize(r.intersect(_parent->geometry()).size());
-    } else {
-      resize(sz);
+      sz = r.intersect(_parent->geometry()).size();
     }
   }
+
+  resize(sz + QSize(borderWidth()*2, borderWidth()*2));
 }
 
 


More information about the Kst mailing list