[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Sun Oct 30 02:01:59 CET 2005


SVN commit 475646 by netterfield:

legend names soon will not have to equal tag names. 



 M  +3 -0      kstbasecurve.h  
 M  +6 -6      kstlegend.cpp  


--- trunk/extragear/graphics/kst/kst/kstbasecurve.h #475645:475646
@@ -97,6 +97,9 @@
     
     // render the legend symbol for this curve
     virtual void paintLegendSymbol(QPainter *p, const QRect& bound) = 0;
+    
+    // Return a name suitible for a legend
+    virtual QString legendTag() { return tagName(); }
 
   protected:
  
--- trunk/extragear/graphics/kst/kst/kstlegend.cpp #475645:475646
@@ -151,7 +151,7 @@
   iCharWidth = p.fontMetrics().width("M");
 
   for(KstBaseCurveList::iterator it = pCurves->begin(); it != pCurves->end(); it++) {
-    iItemWidth  = p.fontMetrics().width((*it)->tagName()) + 4*iCharWidth;
+    iItemWidth  = p.fontMetrics().width((*it)->legendTag()) + 4*iCharWidth;
     iLineWidth += iItemWidth;
     if(iNumInLine > 0 && px + iLineWidth > rect.width()) {
       iNumInLine = 1;
@@ -198,7 +198,7 @@
   iY = iLineHeight;
   iX = 0;
   for(KstBaseCurveList::iterator it = pCurves->begin(); it != pCurves->end(); it++) {
-    iTextWidth = p.fontMetrics().width((*it)->tagName());
+    iTextWidth = p.fontMetrics().width((*it)->legendTag());
     int iTextHeight = iLineHeight - p.fontMetrics().descent();
     iItemWidth = iTextWidth + 4*iCharWidth;
     if(iNumInLine > 0 && px + iX + iItemWidth > rect.width()) {
@@ -211,7 +211,7 @@
     }
 
     p.setPen(_colorForeground);
-    p.drawText(px + iX + (iCharWidth/2), py + iY, (*it)->tagName());        
+    p.drawText(px + iX + (iCharWidth/2), py + iY, (*it)->legendTag());        
 
     // draw the symbol for this curve
     QRect symbolBound(QPoint(px+iX+(iCharWidth/2)+iTextWidth+(1*iCharWidth), py+iY-iTextHeight + 1), 
@@ -239,7 +239,7 @@
   iCharWidth = p.fontMetrics().width("M");
 
   for(KstBaseCurveList::iterator it = pCurves->begin(); it != pCurves->end(); it++) {
-    iLineWidth = p.fontMetrics().width((*it)->tagName());
+    iLineWidth = p.fontMetrics().width((*it)->legendTag());
     if( iLineWidth > iLineWidthMax ) {
       iLineWidthMax = iLineWidth;
     }
@@ -273,7 +273,7 @@
   }
 
   for(KstBaseCurveList::iterator it = pCurves->begin(); it != pCurves->end(); it++) {
-    iLineWidth = p.fontMetrics().width((*it)->tagName());
+    iLineWidth = p.fontMetrics().width((*it)->legendTag());
     int iTextHeight = iLineHeight - p.fontMetrics().descent();
     if(it == pCurves->begin()) {
       px += iCharWidth / 2;
@@ -293,7 +293,7 @@
         break;
     }
     
-    p.drawText( iX, py, (*it)->tagName());
+    p.drawText( iX, py, (*it)->legendTag());
 
     // draw the legend symbol
     QRect symbolBound(QPoint(iX + iLineWidth + iCharWidth, py-iTextHeight + 1), 


More information about the Kst mailing list