diff options
Diffstat (limited to 'libkdchart/KDChartCustomBox.cpp')
-rw-r--r-- | libkdchart/KDChartCustomBox.cpp | 150 |
1 files changed, 71 insertions, 79 deletions
diff --git a/libkdchart/KDChartCustomBox.cpp b/libkdchart/KDChartCustomBox.cpp index 4f765f0..d500356 100644 --- a/libkdchart/KDChartCustomBox.cpp +++ b/libkdchart/KDChartCustomBox.cpp @@ -26,12 +26,12 @@ ** licensing are not clear to you. ** **********************************************************************/ -#include <qpainter.h> -#include <qregion.h> -#include <qpalette.h> -#include <qpoint.h> -#include <qsimplerichtext.h> -#include <qpaintdevicemetrics.h> +#include <tqpainter.h> +#include <tqregion.h> +#include <tqpalette.h> +#include <tqpoint.h> +#include <tqsimplerichtext.h> +#include <tqpaintdevicemetrics.h> #include <KDChartCustomBox.h> #include <KDXMLTools.h> @@ -87,7 +87,7 @@ float KDChartCustomBox::trueFontSize( double areaWidthP1000, if( 0 > _fontSize ) { if( _fontScaleGlobal ) { - size = _fontSize * QMIN(areaWidthP1000, areaHeightP1000) * -1.0;//(areaWidthP1000 + areaHeightP1000) / -2.0; + size = _fontSize * TQMIN(areaWidthP1000, areaHeightP1000) * -1.0;//(areaWidthP1000 + areaHeightP1000) / -2.0; } else { @@ -95,25 +95,25 @@ float KDChartCustomBox::trueFontSize( double areaWidthP1000, float targetLineSpacing = (_fontSize * rectHeight)/ -1000; size = targetLineSpacing; // step #1 - try to make the right font size: - QFont font( content().font() ); + TQFont font( content().font() ); font.setPointSizeFloat( size ); - QFontMetrics fm( font ); - //qDebug(QString("\nsize : ")+QString::number(size)); - //qDebug(QString("(float)rectHeight : ")+QString::number((float)rectHeight)); - //qDebug(QString("(float)fm.lineSpacing(): ")+QString::number((float)fm.lineSpacing())); + TQFontMetrics fm( font ); + //qDebug(TQString("\nsize : ")+TQString::number(size)); + //qDebug(TQString("(float)rectHeight : ")+TQString::number((float)rectHeight)); + //qDebug(TQString("(float)fm.lineSpacing(): ")+TQString::number((float)fm.lineSpacing())); size *= targetLineSpacing / fm.lineSpacing(); - //qDebug(QString("size : ")+QString::number(size)); + //qDebug(TQString("size : ")+TQString::number(size)); // step #2 - make sure the font size is not too big: font.setPointSizeFloat( size ); - QFontMetrics fm2( font ); + TQFontMetrics fm2( font ); size *= targetLineSpacing / fm2.lineSpacing(); - //qDebug(QString("(float)rectHeight : ")+QString::number((float)rectHeight)); - //qDebug(QString("(float)fm.lineSpacing(): ")+QString::number((float)fm.lineSpacing())); - //qDebug(QString("size : ")+QString::number(size)); + //qDebug(TQString("(float)rectHeight : ")+TQString::number((float)rectHeight)); + //qDebug(TQString("(float)fm.lineSpacing(): ")+TQString::number((float)fm.lineSpacing())); + //qDebug(TQString("size : ")+TQString::number(size)); } } else { -//qDebug(QString("\n_fontsize: ")+QString::number(_fontSize)); +//qDebug(TQString("\n_fontsize: ")+TQString::number(_fontSize)); if( _fontSize ) size = _fontSize; else{ @@ -132,9 +132,9 @@ int KDChartCustomBox::trueFontLineSpacing( double areaWidthP1000, double areaHeightP1000, int rectHeight ) const { - QFont font( content().font() ); + TQFont font( content().font() ); font.setPointSizeFloat( trueFontSize( areaWidthP1000,areaHeightP1000, rectHeight ) ); - QFontMetrics fm( font ); + TQFontMetrics fm( font ); return fm.lineSpacing(); } @@ -157,33 +157,33 @@ void KDChartCustomBox::getTrueShift( double areaWidthP1000, //qDebug("y %i",y); } uint deltaAlign = (KDCHART_AlignAuto == _deltaAlign) ? _anchorAlign : _deltaAlign; - if ( Qt::AlignLeft == (Qt::AlignLeft & deltaAlign) ) + if ( TQt::AlignLeft == (TQt::AlignLeft & deltaAlign) ) dX = x; - else if ( Qt::AlignRight == (Qt::AlignRight & deltaAlign) ) + else if ( TQt::AlignRight == (TQt::AlignRight & deltaAlign) ) dX = -x; else dX = 0; // <-- so the _deltaX value becomes ineffective! - if ( Qt::AlignTop == (Qt::AlignTop & deltaAlign) ) + if ( TQt::AlignTop == (TQt::AlignTop & deltaAlign) ) dY = y; - else if ( Qt::AlignBottom == (Qt::AlignBottom & deltaAlign) ) + else if ( TQt::AlignBottom == (TQt::AlignBottom & deltaAlign) ) dY = -y; else dY = 0; // <-- so the _deltaY value becomes ineffective! } -QRect KDChartCustomBox::trueRect( QPainter * /*painter*/, QPoint /*anchor*/, double /*areaWidthP1000*/, double /*areaHeightP1000*/ ) const +TQRect KDChartCustomBox::trueRect( TQPainter * /*painter*/, TQPoint /*anchor*/, double /*areaWidthP1000*/, double /*areaHeightP1000*/ ) const { //temporary allow KDC_Presentation to compile qDebug( "Sorry, not implemented yet: KDChartCustomBox::trueRect()" ); - return QRect( 1, 1, 2, 2 ); + return TQRect( 1, 1, 2, 2 ); } -//static QPainter* pppainter=0; +//static TQPainter* pppainter=0; //static int pdWidth =1280; //static int pdHeight =1024; -QRect KDChartCustomBox::trueRect( QPoint anchor, double areaWidthP1000, double areaHeightP1000 ) const +TQRect KDChartCustomBox::trueRect( TQPoint anchor, double areaWidthP1000, double areaHeightP1000 ) const { int w = (0 > _width ) ? static_cast < int > ( -areaWidthP1000 * _width ) : _width; int h = (0 > _height) ? static_cast < int > ( -areaHeightP1000 * _height ) : _height; @@ -192,31 +192,23 @@ QRect KDChartCustomBox::trueRect( QPoint anchor, double areaWidthP1000, double a if( _fontScaleGlobal && 0 == w && 0 == h ){ //Now calculate the size of the box based upon the content! - QFont font( content().font() ); + TQFont font( content().font() ); if ( _fontSize ) { font.setPointSizeFloat( (0 > _fontSize) - ? (_fontSize * QMIN(areaWidthP1000, areaHeightP1000) * -1.0)//(areaWidthP1000 + areaHeightP1000) / -2.0 + ? (_fontSize * TQMIN(areaWidthP1000, areaHeightP1000) * -1.0)//(areaWidthP1000 + areaHeightP1000) / -2.0 : _fontSize ); - //qDebug("\n_fontSize * QMIN(areaWidthP1000, areaHeightP1000) %i * QMIN(%f, %f) text: %s", _fontSize , areaWidthP1000, areaHeightP1000, content().text().latin1()); + //qDebug("\n_fontSize * TQMIN(areaWidthP1000, areaHeightP1000) %i * TQMIN(%f, %f) text: %s", _fontSize , areaWidthP1000, areaHeightP1000, content().text().latin1()); } - QString txt( content().text() ); - QString txtTest( txt.stripWhiteSpace().lower() ); -#if QT_VERSION >= 200 && QT_VERSION < 300 -// version 2.x - if( !(txtTest.left(4) == "<qt>") ) - txt.prepend( "<qt>" ); - if( !(txtTest.right(5)== "</qt>")) - txt.append( "</qt>"); -#else + TQString txt( content().text() ); + TQString txtTest( txt.stripWhiteSpace().lower() ); if( !txtTest.startsWith("<qt>" ) ) txt.prepend( "<qt>" ); if( !txtTest.endsWith( "</qt>") ) txt.append( "</qt>"); -#endif //qDebug("\nw: %i h: %i", w,h ); - QSimpleRichText tmpContent( txt, font ); + TQSimpleRichText tmpContent( txt, font ); // tmpContent.setWidth(pdWidth); // tmpContent.setHeight(pdHeight); // tmpContent.adjustSize(); @@ -232,16 +224,16 @@ QRect KDChartCustomBox::trueRect( QPoint anchor, double areaWidthP1000, double a //qDebug("\nw: %i h: %i", w,h ); int x,y; - if ( Qt::AlignLeft == (Qt::AlignLeft & _anchorAlign) ) + if ( TQt::AlignLeft == (TQt::AlignLeft & _anchorAlign) ) x = 0; - else if ( Qt::AlignRight == (Qt::AlignRight & _anchorAlign) ) + else if ( TQt::AlignRight == (TQt::AlignRight & _anchorAlign) ) x = - w + 1; else x = - w / 2; - if ( Qt::AlignTop == (Qt::AlignTop & _anchorAlign) ) + if ( TQt::AlignTop == (TQt::AlignTop & _anchorAlign) ) y = 0; - else if ( Qt::AlignBottom == (Qt::AlignBottom & _anchorAlign) ) + else if ( TQt::AlignBottom == (TQt::AlignBottom & _anchorAlign) ) y = - h + 1; else y = - h / 2; @@ -250,55 +242,55 @@ QRect KDChartCustomBox::trueRect( QPoint anchor, double areaWidthP1000, double a dX, dY ); //qDebug("trueRect: x %i y %i w %i h %i text: %s", anchor.x()+x+dX, anchor.y()+y+dY, w,h, content().text().latin1()); - return QRect( anchor.x()+x+dX, anchor.y()+y+dY, w, h ); + return TQRect( anchor.x()+x+dX, anchor.y()+y+dY, w, h ); } -int KDChartCustomBox::trueRectAlignX(const QRect& rect) const +int KDChartCustomBox::trueRectAlignX(const TQRect& rect) const { int ret = rect.center().x(); - if ( Qt::AlignLeft == (Qt::AlignLeft & _anchorAlign) ) + if ( TQt::AlignLeft == (TQt::AlignLeft & _anchorAlign) ) ret -= rect.width(); - else if ( Qt::AlignRight == (Qt::AlignRight & _anchorAlign) ) + else if ( TQt::AlignRight == (TQt::AlignRight & _anchorAlign) ) ret += rect.width(); return ret; } -int KDChartCustomBox::trueRectAlignY(const QRect& rect) const +int KDChartCustomBox::trueRectAlignY(const TQRect& rect) const { int ret = rect.center().y(); - if ( Qt::AlignTop == (Qt::AlignTop & _anchorAlign) ) + if ( TQt::AlignTop == (TQt::AlignTop & _anchorAlign) ) ret -= rect.height(); - else if ( Qt::AlignBottom == (Qt::AlignBottom & _anchorAlign) ) + else if ( TQt::AlignBottom == (TQt::AlignBottom & _anchorAlign) ) ret += rect.height(); return ret; } -void KDChartCustomBox::paint( QPainter* painter, - QPoint anchor, +void KDChartCustomBox::paint( TQPainter* painter, + TQPoint anchor, double areaWidthP1000, double areaHeightP1000, const KDFrame* frame, - const QRect& frameRect, - const QColor * color, - const QBrush * paper ) const + const TQRect& frameRect, + const TQColor * color, + const TQBrush * paper ) const { painter->save(); int rotDX = 0; int rotDY = 0; /* //pppainter=painter; -const QPaintDeviceMetrics metrics(painter->device()); +const TQPaintDeviceMetrics metrics(painter->device()); pdWidth = metrics.width(); const int aWidthP1000 = metrics.width() /1000; const int aHeightP1000 = metrics.height()/1000; //pdHeight = metrics.height(); */ - QRect myRect( trueRect( anchor, areaWidthP1000, areaHeightP1000 ) ); + TQRect myRect( trueRect( anchor, areaWidthP1000, areaHeightP1000 ) ); /* -QPaintDeviceMetrics metrics(painter->device()); +TQPaintDeviceMetrics metrics(painter->device()); int pdWidth = metrics.width(); int dpiY = metrics.logicalDpiY(); int dpiX = metrics.logicalDpiX(); @@ -308,7 +300,7 @@ qDebug("pdWidth: %i box myRect w: %i h %i",pdWidth,myRect.width(),myRect.hei //myRect.setSize(myRect.size()*6); - QRect myFrameRect( frameRect ); + TQRect myFrameRect( frameRect ); if ( myRect.isValid() ) { //qDebug("box myRect center: x %i y %i",myRect.center().x(),myRect.center().y()); if( _rotation ){ @@ -319,10 +311,10 @@ qDebug("pdWidth: %i box myRect w: %i h %i",pdWidth,myRect.width(),myRect.hei myFrameRect.moveBy( -rotDX, -rotDY ); //qDebug("\nrotDelta: x %i y %i",rotDX,rotDY); //qDebug("\nbox myRect center: x %i y %i",myRect.center().x(),myRect.center().y()); - myRect.moveCenter( QPoint( anchor.x() - trueRectAlignX(myRect), + myRect.moveCenter( TQPoint( anchor.x() - trueRectAlignX(myRect), anchor.y() - trueRectAlignY(myRect) ) ); if( frame ) - myFrameRect.moveCenter( QPoint( anchor.x() - trueRectAlignX(myFrameRect), + myFrameRect.moveCenter( TQPoint( anchor.x() - trueRectAlignX(myFrameRect), anchor.y() - trueRectAlignY(myFrameRect) ) ); //qDebug("box myRect center: x %i y %i",myRect.center().x(),myRect.center().y()); painter->translate( anchor.x(), anchor.y() ); @@ -332,7 +324,7 @@ qDebug("pdWidth: %i box myRect w: %i h %i",pdWidth,myRect.width(),myRect.hei if( frame ) frame->paint( painter, KDFrame::PaintAll, myFrameRect ); if ( _fontSize ) { - QFont font( content().font() ); + TQFont font( content().font() ); float trueSize = trueFontSize(areaWidthP1000,areaHeightP1000, myRect.height() ); font.setPointSizeFloat( trueSize ); @@ -354,13 +346,13 @@ qDebug("pdWidth: %i box myRect w: %i h %i",pdWidth,myRect.width(),myRect.hei } -void KDChartCustomBox::createCustomBoxNode( QDomDocument& document, - QDomNode& parent, - const QString& elementName, +void KDChartCustomBox::createCustomBoxNode( TQDomDocument& document, + TQDomNode& tqparent, + const TQString& elementName, const KDChartCustomBox* custombox ) { - QDomElement customBoxElement = document.createElement( elementName ); - parent.appendChild( customBoxElement ); + TQDomElement customBoxElement = document.createElement( elementName ); + tqparent.appendChild( customBoxElement ); KDXML::createIntNode( document, customBoxElement, "Rotation", custombox->_rotation ); KDXML::createStringNode( document, customBoxElement, "ContentText", custombox->_content.text() ); @@ -396,12 +388,12 @@ void KDChartCustomBox::createCustomBoxNode( QDomDocument& document, } -bool KDChartCustomBox::readCustomBoxNode( const QDomElement& element, +bool KDChartCustomBox::readCustomBoxNode( const TQDomElement& element, KDChartCustomBox& custombox ) { bool ok = true; - QString tempContentText; - QFont tempContentFont; + TQString tempContentText; + TQFont tempContentFont; int tempRotation = 0; // must be initialized: new parameter, not present in old versions of KDChart int tempDeltaAlign = KDCHART_AlignAuto; // must be initialized too: new parameter bool tempDeltaScaleGlobal = true; // must be initialized too: new parameter @@ -409,14 +401,14 @@ bool KDChartCustomBox::readCustomBoxNode( const QDomElement& element, tempWidth, tempHeight, tempAnchorArea, tempParentAxisArea, tempAnchorAlign, tempDataRow, tempDataCol, tempData3rd; bool tempFontScaleGlobal; - QColor tempColor; - QBrush tempPaper; + TQColor tempColor; + TQBrush tempPaper; KDChartEnums::PositionFlag tempAnchorPos = KDChartEnums::PosTopLeft; - QDomNode node = element.firstChild(); + TQDomNode node = element.firstChild(); while( !node.isNull() ) { - QDomElement element = node.toElement(); + TQDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element - QString tagName = element.tagName(); + TQString tagName = element.tagName(); if( tagName == "Rotation" ) { ok = ok & KDXML::readIntNode( element, tempRotation ); } else if( tagName == "ContentText" ) { @@ -442,7 +434,7 @@ bool KDChartCustomBox::readCustomBoxNode( const QDomElement& element, } else if( tagName == "AnchorArea" ) { ok = ok & KDXML::readIntNode( element, tempAnchorArea ); } else if( tagName == "AnchorPos" ) { - QString value; + TQString value; ok = ok & KDXML::readStringNode( element, value ); tempAnchorPos = KDChartEnums::stringToPositionFlag( value ); } else if( tagName == "AnchorAlign" ) { |