SVN commit 600814 by khz: fixing KDE Bug #124601: Working around a bug in the KChartWizardLabelsLegendPage: The wizard does not have a checkbox [x] relative for the font sizes, so we now assume that font sizes are relative in all cases. We also have inclreased the default values for minimal font sizes, so that small, embedded charts will show small axis labels rather than 10 point size labels ... M +14 -8 kchartWizardLabelsLegendPage.cc M +7 -5 kchart_params.cc M +2 -0 kdchart/KDChartAxesPainter.cpp M +2 -2 kdchart/KDChartAxisParams.cpp M +17 -12 kdchart/KDChartPainter.cpp M +1 -0 kdchart/KDChartPainter.h M +4 -4 kdchart/KDChartParams.cpp --- branches/koffice/1.6/koffice/kchart/kchartWizardLabelsLegendPage.cc #600813:600814 @@ -301,16 +301,18 @@ // _chart->params()->YTitle2Color=y_color2; // _chart->params()->ytitle2=_ylabel2ED->text(); - _chart->params()->setHeaderFooterColor( KDChartParams::HdFtPosHeader,title_color); - _chart->params()->setHeader1Font(title); + _chart->params()->setHeaderFooterColor( KDChartParams::HdFtPosHeader, title_color ); + _chart->params()->setHeaderFooterFont( KDChartParams::HdFtPosHeader, title, true, title.pointSize()*4 ); _chart->params()->setAxisTitle( KDChartAxisParams::AxisPosBottom, _xlabelED->text() ); _chart->params()->setAxisTitle( KDChartAxisParams::AxisPosLeft, _ylabelED->text() ); _chart->params()->setLegendTitleText(_legendTitleText->text()); _chart->params()->setLegendTitleTextColor(_legendTitleColor); - _chart->params()->setLegendTitleFont(_legendTitleFont,true); + _chart->params()->setLegendTitleFont( _legendTitleFont,false); + _chart->params()->setLegendTitleFontRelSize( _legendTitleFont.pointSize()*4 ); _chart->params()->setLegendTextColor(_legendTextColor); - _chart->params()->setLegendFont( _legendTextFont,true); + _chart->params()->setLegendFont( _legendTextFont,false); + _chart->params()->setLegendFontRelSize( _legendTextFont.pointSize()*4 ); KDChartAxisParams leftparams; leftparams = _chart->params()->axisParams( KDChartAxisParams::AxisPosLeft ); @@ -320,10 +322,14 @@ bottomparams.setAxisLineColor( x_color ); if( y_color.isValid() ) leftparams.setAxisLineColor( y_color ); - if(bottomparams.axisLabelsFont()!=xlabel) - bottomparams.setAxisLabelsFont(xlabel,false); - if(leftparams.axisLabelsFont()!=ylabel) - leftparams.setAxisLabelsFont(ylabel,true); + if(bottomparams.axisLabelsFont()!=xlabel){ + bottomparams.setAxisLabelsFont( xlabel,false ); + bottomparams.setAxisLabelsFontRelSize( xlabel.pointSize()*4 ); + } + if(leftparams.axisLabelsFont()!=ylabel){ + leftparams.setAxisLabelsFont( ylabel,false ); + leftparams.setAxisLabelsFontRelSize( ylabel.pointSize()*4 ); + } _chart->params()->setAxisParams( KDChartAxisParams::AxisPosBottom, bottomparams ); _chart->params()->setAxisParams( KDChartAxisParams::AxisPosLeft, leftparams ); --- branches/koffice/1.6/koffice/kchart/kchart_params.cc #600813:600814 @@ -266,7 +266,7 @@ QFont font; QColor color; loadOasisFont( loadingContext, font, color ); - setHeaderFooterFont( KDChartParams::HdFtPosHeader, font, true, font.pointSize() ); + setHeaderFooterFont( KDChartParams::HdFtPosHeader, font, true, font.pointSize()*4 ); setHeaderFooterColor( KDChartParams::HdFtPosHeader, color ); loadingContext.styleStack().restore(); @@ -284,7 +284,7 @@ QFont font; QColor color; loadOasisFont( loadingContext, font, color ); - setHeaderFooterFont( KDChartParams::HdFtPosHeader2, font, true, font.pointSize() ); + setHeaderFooterFont( KDChartParams::HdFtPosHeader2, font, true, font.pointSize()*4 ); setHeaderFooterColor( KDChartParams::HdFtPosHeader2, color ); loadingContext.styleStack().restore(); @@ -302,7 +302,7 @@ QFont font; QColor color; loadOasisFont( loadingContext, font, color ); - setHeaderFooterFont( KDChartParams::HdFtPosFooter, font, true, font.pointSize() ); + setHeaderFooterFont( KDChartParams::HdFtPosFooter, font, true, font.pointSize()*4 ); setHeaderFooterColor( KDChartParams::HdFtPosFooter, color ); loadingContext.styleStack().restore(); @@ -322,8 +322,10 @@ QColor color; loadOasisFont( loadingContext, font, color ); //tz I didn't find that Oasis support seperate font/colors for the title and the rest of the legent - setLegendFont( font, true ); - setLegendTitleFont( font, true ); + setLegendFont( font, false ); + setLegendFontRelSize( font.pointSize()*4 ); + setLegendTitleFont( font, false); + setLegendTitleFontRelSize( font.pointSize()*4 ); setLegendTextColor( color ); setLegendTitleTextColor( color ); loadingContext.styleStack().restore(); --- branches/koffice/1.6/koffice/kchart/kdchart/KDChartAxesPainter.cpp #600813:600814 @@ -174,6 +174,7 @@ { uint iAxis; double averageValueP1000 = QMIN(areaWidthP1000, areaHeightP1000);//( areaWidthP1000 + areaHeightP1000 ) / 2.0; + //qDebug("KChart::KDChartAxesPainter::calculateAllAxesLabelTextsAndCalcValues() averageValueP1000: %f", averageValueP1000); // length of little delimiter-marks indicating axis scaling delimLen = 20.0 * averageValueP1000; // per mille of area @@ -538,6 +539,7 @@ // calculate font size const double minTextHeight = para.axisLabelsFontMinSize(); + //qDebug("KChart::KDChartAxesPainter::paintAxes() cv.nTxtHeight: %f minTextHeight: %f", cv.nTxtHeight, minTextHeight); if ( minTextHeight > cv.nTxtHeight ) cv.nTxtHeight = minTextHeight; QFont actFont( para.axisLabelsFont() ); --- branches/koffice/1.6/koffice/kchart/kdchart/KDChartAxisParams.cpp #600813:600814 @@ -171,8 +171,8 @@ _axisLabelsFont = QFont( "helvetica", 12, QFont::Normal, false ); _axisLabelsFontUseRelSize = true; - _axisLabelsFontRelSize = 17; - _axisLabelsFontMinSize = 10; + _axisLabelsFontRelSize = 32; + _axisLabelsFontMinSize = 6; _axisLabelsDontShrinkFont = false; _axisLabelsDontAutoRotate = false; _axisLabelsRotation = 0; --- branches/koffice/1.6/koffice/kchart/kdchart/KDChartPainter.cpp #600813:600814 @@ -1349,6 +1349,19 @@ params()->legendPosition() == KDChartParams::LegendBottomRightRight; } +QFont KDChartPainter::trueLegendTitleFont() const +{ + const double averageValueP1000 = QMIN(_areaWidthP1000, _areaHeightP1000);//( _areaWidthP1000 + _areaHeightP1000 ) / 2.0; + QFont font( params()->legendTitleFont() ); + if ( params()->legendTitleFontUseRelSize() ) { + int nTxtHeight = + static_cast < int > ( params()->legendTitleFontRelSize() + * averageValueP1000 ); + font.setPixelSize( nTxtHeight ); + // qDebug("l-t-height %i",nTxtHeight); + } + return font; +} /** Paints the legend for the chart. The implementation in KDChartPainter @@ -1399,7 +1412,7 @@ // first paint the title, if any if( _legendTitle ) { - painter->setFont( params()->legendTitleFont() ); + painter->setFont( trueLegendTitleFont() ); _legendTitle->draw( painter, xpos, ypos, @@ -2225,22 +2238,14 @@ delete _legendTitle; _legendTitle = 0; if ( hasLegendTitle ) { - QFont actLegendTitleFont = params()->legendTitleFont(); - if ( params()->legendTitleFontUseRelSize() ) { - int nTxtHeight = - static_cast < int > ( params()->legendTitleFontRelSize() - * averageValueP1000 ); - actLegendTitleFont.setPixelSize( nTxtHeight ); - // qDebug("l-t-height %i",nTxtHeight); - const_cast < KDChartParams* > ( params() )->setLegendTitleFont( actLegendTitleFont, false ); - } - painter->setFont( actLegendTitleFont ); + const QFont font( trueLegendTitleFont() ); + painter->setFont( font ); QFontMetrics legendTitleMetrics( painter->fontMetrics() ); _legendTitleMetricsHeight = legendTitleMetrics.height(); _legendTitle = new KDChartTextPiece( painter, params()->legendTitleText(), - actLegendTitleFont ); + font ); _legendTitleWidth = _legendTitle->width(); _legendTitleHeight = _legendTitle->height(); // qDebug("1. _legendTitleHeight %i",_legendTitleHeight); --- branches/koffice/1.6/koffice/kchart/kdchart/KDChartPainter.h #600813:600814 @@ -271,6 +271,7 @@ const KDChartParams::KDChartFrameSettings* settings ) const; int legendTitleVertGap() const; + QFont trueLegendTitleFont() const; QFont trueLegendFont() const; void calculateHorizontalLegendSize( QPainter* painter, QSize& size, --- branches/koffice/1.6/koffice/kchart/kdchart/KDChartParams.cpp #600813:600814 @@ -351,9 +351,9 @@ // legend font size is calculated dynamically, but ignore the font size setLegendFont( QFont( "helvetica", 10, QFont::Normal, false ), false ); // legend font size is calculated dynamically: - // 20 / 1000 of the average value of + // 40 / 1000 of the minimal value of // the printable area height and width - setLegendFontRelSize( 16 ); + setLegendFontRelSize( 40 ); // the default legend title is "Legend" setLegendTitleText( tr( "Legend" ) ); // legend title is drawn in black by default @@ -362,9 +362,9 @@ // the font size setLegendTitleFont( QFont( "helvetica", 12, QFont::Normal, false ), false ); // legend title font size is calculated dynamically: - // 25 / 1000 of the average value of + // 50 / 1000 of the minimal value of // the printable area height and width - setLegendTitleFontRelSize( 20 ); + setLegendTitleFontRelSize( 50 ); // END LEGEND