diff options
Diffstat (limited to 'lib/kotext/KoFontDiaPreview.cpp')
-rw-r--r-- | lib/kotext/KoFontDiaPreview.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/lib/kotext/KoFontDiaPreview.cpp b/lib/kotext/KoFontDiaPreview.cpp index 32473e43..04d56e4c 100644 --- a/lib/kotext/KoFontDiaPreview.cpp +++ b/lib/kotext/KoFontDiaPreview.cpp @@ -23,31 +23,31 @@ #include <klocale.h> -#include <qfontmetrics.h> -#include <qrect.h> -#include <qpainter.h> -#include <qfont.h> -#include <qstringlist.h> -#include <qstring.h> -#include <qregexp.h> +#include <tqfontmetrics.h> +#include <tqrect.h> +#include <tqpainter.h> +#include <tqfont.h> +#include <tqstringlist.h> +#include <tqstring.h> +#include <tqregexp.h> #include <math.h> #include "KoFontDiaPreview.moc" -KoFontDiaPreview::KoFontDiaPreview( QWidget* parent, const char* name , WFlags fl ) - : QFrame( parent, name, fl ) +KoFontDiaPreview::KoFontDiaPreview( TQWidget* tqparent, const char* name , WFlags fl ) + : TQFrame( tqparent, name, fl ) ,m_text( i18n( "The quick brown dog jumps over the lazy cat." ) ) ,displayText( i18n( "The quick brown dog jumps over the lazy cat." ) ) ,m_font( KoGlobal::defaultFont() ) - ,m_textColor( Qt::black ) - ,m_backgroundColor( Qt::white ) + ,m_textColor( TQt::black ) + ,m_backgroundColor( TQt::white ) ,m_shadowDistanceX( 0 ) ,m_shadowDistanceY( 0 ) - ,m_shadowColor( Qt::black ) + ,m_shadowColor( TQt::black ) ,m_underlining( 0 ) ,m_underliningStyle( 0 ) - ,m_underliningColor( Qt::black ) + ,m_underliningColor( TQt::black ) ,m_wordByWord( false ) ,m_strikethrough( 0 ) ,m_strikethroughStyle( 0 ) @@ -57,9 +57,9 @@ KoFontDiaPreview::KoFontDiaPreview( QWidget* parent, const char* name , WFlags f ,m_relativeSize( 1 ) { - setFrameStyle( QFrame::WinPanel | QFrame::Plain ); + setFrameStyle( TQFrame::WinPanel | TQFrame::Plain ); setBackgroundMode( PaletteBase ); - setBackgroundColor( Qt::white ); + setBackgroundColor( TQt::white ); setMinimumSize( 400, 100 ); } @@ -67,32 +67,32 @@ KoFontDiaPreview::~KoFontDiaPreview() { } -void KoFontDiaPreview::setText( const QString &text ) +void KoFontDiaPreview::setText( const TQString &text ) { m_text = text; update(); } -void KoFontDiaPreview::setFont( const QFont &font ) +void KoFontDiaPreview::setFont( const TQFont &font ) { m_font = font; m_fontSize = m_font.pointSize(); update(); } -void KoFontDiaPreview::setFontColor( const QColor &textColor ) +void KoFontDiaPreview::setFontColor( const TQColor &textColor ) { m_textColor = textColor; update(); } -void KoFontDiaPreview::setBackgroundColor( const QColor &backgroundColor ) +void KoFontDiaPreview::setBackgroundColor( const TQColor &backgroundColor ) { m_backgroundColor = backgroundColor; update(); } -void KoFontDiaPreview::setShadow( double sdx, double sdy, QColor shadowColor ) +void KoFontDiaPreview::setShadow( double sdx, double sdy, TQColor shadowColor ) { m_shadowDistanceX = sdx; m_shadowDistanceY = sdy; @@ -100,7 +100,7 @@ void KoFontDiaPreview::setShadow( double sdx, double sdy, QColor shadowColor ) update(); } -void KoFontDiaPreview::setUnderlining( int underlining, int underliningStyle, const QColor underliningColor, bool wordByWord ) +void KoFontDiaPreview::setUnderlining( int underlining, int underliningStyle, const TQColor underliningColor, bool wordByWord ) { m_underlining = underlining; m_underliningStyle = underliningStyle; @@ -137,7 +137,7 @@ void KoFontDiaPreview::setSubSuperscript( int subSuper, int offset, double relat update(); } -QString KoFontDiaPreview::formatCapitalisation( const QString &string ) +TQString KoFontDiaPreview::formatCapitalisation( const TQString &string ) { switch ( m_capitalisation ) { @@ -154,7 +154,7 @@ QString KoFontDiaPreview::formatCapitalisation( const QString &string ) } } -void KoFontDiaPreview::drawContents( QPainter* p ) +void KoFontDiaPreview::drawContents( TQPainter* p ) { p->save(); @@ -162,7 +162,7 @@ void KoFontDiaPreview::drawContents( QPainter* p ) //Capitalisation double capitalisationCoeff; - QFontMetrics fmCapitalisation( m_font ); + TQFontMetrics fmCapitalisation( m_font ); switch ( m_capitalisation ) { @@ -190,18 +190,18 @@ void KoFontDiaPreview::drawContents( QPainter* p ) displayText = formatCapitalisation( m_text ); // draw the stuff - QFontMetrics fm( displayFont ); - QRect br = fm.boundingRect( contentsRect().x(), contentsRect().y(), contentsRect().width(), contentsRect().height(), Qt::AlignCenter | Qt::WordBreak, displayText ); + TQFontMetrics fm( displayFont ); + TQRect br = fm.boundingRect( contentsRect().x(), contentsRect().y(), contentsRect().width(), contentsRect().height(), TQt::AlignCenter | TQt::WordBreak, displayText ); if ( br.width() > contentsRect().width() || br.height() > contentsRect().height() ) { displayText = formatCapitalisation( i18n( "Font too large for the preview pane" ) ); displayFont.setPointSizeFloat( 14 * capitalisationCoeff ); } - QFontMetrics fm1( displayFont ); - br = fm1.boundingRect( contentsRect().x(), contentsRect().y(), contentsRect().width(), contentsRect().height(), Qt::AlignCenter | Qt::WordBreak, displayText ); + TQFontMetrics fm1( displayFont ); + br = fm1.boundingRect( contentsRect().x(), contentsRect().y(), contentsRect().width(), contentsRect().height(), TQt::AlignCenter | TQt::WordBreak, displayText ); - int xorg = qRound( ( contentsRect().width() - br.width() ) / 2 ) + contentsRect().x() - fm1.leftBearing( displayText.at( 0 ) ); + int xorg = tqRound( ( contentsRect().width() - br.width() ) / 2 ) + contentsRect().x() - fm1.leftBearing( displayText.at( 0 ) ); // sub / superscript modifications int subSuperOffset = 0; @@ -224,17 +224,17 @@ void KoFontDiaPreview::drawContents( QPainter* p ) break; } - QFontMetrics fm2( displayFont ); - br = fm2.boundingRect( contentsRect().x(), contentsRect().y(), contentsRect().width(), contentsRect().height(), Qt::AlignCenter | Qt::WordBreak, displayText ); - int yorg = qRound( ( contentsRect().height() - br.height() ) / 2 ) + fm1.ascent() + subSuperOffset; + TQFontMetrics fm2( displayFont ); + br = fm2.boundingRect( contentsRect().x(), contentsRect().y(), contentsRect().width(), contentsRect().height(), TQt::AlignCenter | TQt::WordBreak, displayText ); + int yorg = tqRound( ( contentsRect().height() - br.height() ) / 2 ) + fm1.ascent() + subSuperOffset; int sxorg = xorg + int( m_shadowDistanceX ); int syorg = yorg + int( m_shadowDistanceY ); - QStringList textWords = QStringList::split( " ", displayText ); + TQStringList textWords = TQStringList::split( " ", displayText ); int x = xorg; int y = yorg; int sx = sxorg; int sy = syorg; - int bx= QMIN( x, sx ); + int bx= TQMIN( x, sx ); int xend = bx; int yUnderline; int widthUnderline; @@ -247,7 +247,7 @@ void KoFontDiaPreview::drawContents( QPainter* p ) p->setPen( m_textColor ); int count = 1; - for ( QStringList::iterator it = textWords.begin(); it != textWords.end(); ++it ) { + for ( TQStringList::iterator it = textWords.begin(); it != textWords.end(); ++it ) { int boffset = 0; if ( x + fm2.width( (*it) ) > contentsRect().width() ) { y += fm1.lineSpacing(); @@ -255,10 +255,10 @@ void KoFontDiaPreview::drawContents( QPainter* p ) xend = x; x = xorg; sx = sxorg; - bx= QMIN( x, sx ); + bx= TQMIN( x, sx ); count = 1; } - QString textDraw; + TQString textDraw; if ( (*it) == textWords.last() ) { textDraw = (*it); } @@ -266,23 +266,23 @@ void KoFontDiaPreview::drawContents( QPainter* p ) textDraw = (*it) + " "; } /*background*/ - if ( count == 1 ) boffset = QABS( int( m_shadowDistanceX ) ); + if ( count == 1 ) boffset = TQABS( int( m_shadowDistanceX ) ); else boffset = 0; - if ( bx < xend && (bx + fm2.width( textDraw ) + boffset ) < xend && ( QMIN( y, sy ) - fm2.ascent() ) < ( QMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + QABS( m_shadowDistanceY ) ) ) { - p->fillRect( bx, QMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + QABS( int( m_shadowDistanceY ) ), fm2.width( textDraw ) + boffset , fm2.height() + QABS( int( m_shadowDistanceY ) ) - ( QMIN( yorg, syorg ) - QMIN( y, sy ) + fm2.height() + QABS( int( m_shadowDistanceY ) ) ), m_backgroundColor ); + if ( bx < xend && (bx + fm2.width( textDraw ) + boffset ) < xend && ( TQMIN( y, sy ) - fm2.ascent() ) < ( TQMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + TQABS( m_shadowDistanceY ) ) ) { + p->fillRect( bx, TQMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + TQABS( int( m_shadowDistanceY ) ), fm2.width( textDraw ) + boffset , fm2.height() + TQABS( int( m_shadowDistanceY ) ) - ( TQMIN( yorg, syorg ) - TQMIN( y, sy ) + fm2.height() + TQABS( int( m_shadowDistanceY ) ) ), m_backgroundColor ); } - else if ( bx < xend && (bx + fm2.width( textDraw ) + boffset ) >= xend && ( QMIN( y, sy ) - fm2.ascent() ) < ( QMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + QABS( m_shadowDistanceY ) ) ) { - p->fillRect( bx, QMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + QABS( int( m_shadowDistanceY ) ), xend - bx , fm2.height() + QABS( int( m_shadowDistanceY ) ) - ( QMIN( yorg, syorg ) - QMIN( y, sy ) + fm2.height() + QABS( int( m_shadowDistanceY ) ) ), m_backgroundColor ); - p->fillRect( xend, QMIN( y, sy ) - fm2.ascent(), fm2.width( textDraw ) + boffset - xend + bx, fm2.height() + QABS( int( m_shadowDistanceY ) ), m_backgroundColor ); + else if ( bx < xend && (bx + fm2.width( textDraw ) + boffset ) >= xend && ( TQMIN( y, sy ) - fm2.ascent() ) < ( TQMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + TQABS( m_shadowDistanceY ) ) ) { + p->fillRect( bx, TQMIN( yorg, syorg ) - fm2.ascent() + fm2.height() + TQABS( int( m_shadowDistanceY ) ), xend - bx , fm2.height() + TQABS( int( m_shadowDistanceY ) ) - ( TQMIN( yorg, syorg ) - TQMIN( y, sy ) + fm2.height() + TQABS( int( m_shadowDistanceY ) ) ), m_backgroundColor ); + p->fillRect( xend, TQMIN( y, sy ) - fm2.ascent(), fm2.width( textDraw ) + boffset - xend + bx, fm2.height() + TQABS( int( m_shadowDistanceY ) ), m_backgroundColor ); } else { - p->fillRect( bx, QMIN( y, sy ) - fm2.ascent(), fm2.width( textDraw ) + boffset , fm2.height() + QABS( int( m_shadowDistanceY ) ), m_backgroundColor ); + p->fillRect( bx, TQMIN( y, sy ) - fm2.ascent(), fm2.width( textDraw ) + boffset , fm2.height() + TQABS( int( m_shadowDistanceY ) ), m_backgroundColor ); } - if ( count == 1 ) boffset = QABS( int( m_shadowDistanceX ) ); + if ( count == 1 ) boffset = TQABS( int( m_shadowDistanceX ) ); else boffset = 0; - bx += fm2.width( textDraw ) + boffset;//( count == 1 )?0:0;//QABS( m_shadowDistanceX ):0; + bx += fm2.width( textDraw ) + boffset;//( count == 1 )?0:0;//TQABS( m_shadowDistanceX ):0; /*shadow*/ if ( m_shadowDistanceX || m_shadowDistanceY ) { @@ -308,13 +308,13 @@ void KoFontDiaPreview::drawContents( QPainter* p ) ( m_wordByWord )? widthUnderline = fm2.width( (*it) ): widthUnderline = fm2.width( textDraw ); thicknessUnderline = 1; drawUnderline( x, yUnderline, widthUnderline, thicknessUnderline, m_underliningColor, p ); - yUnderline = y + qRound( fm2.descent() / 2 ); + yUnderline = y + tqRound( fm2.descent() / 2 ); drawUnderline( x, yUnderline, widthUnderline, thicknessUnderline, m_underliningColor, p ); break; case KoTextFormat::U_SIMPLE_BOLD: yUnderline = y + fm2.descent(); ( m_wordByWord )? widthUnderline = fm2.width( (*it) ): widthUnderline = fm2.width( textDraw ); - thicknessUnderline = qRound( displayFont.pointSize() / 10 ) + 1; + thicknessUnderline = tqRound( displayFont.pointSize() / 10 ) + 1; drawUnderline( x, yUnderline, widthUnderline, thicknessUnderline, m_underliningColor, p ); break; case KoTextFormat::U_WAVE: @@ -331,23 +331,23 @@ void KoFontDiaPreview::drawContents( QPainter* p ) case KoTextFormat::S_NONE: break; case KoTextFormat::S_SIMPLE: - yStrikethrough = y - qRound( fm2.ascent() / 3 ); + yStrikethrough = y - tqRound( fm2.ascent() / 3 ); ( m_wordByWord )? widthStrikethrough = fm2.width( (*it) ): widthStrikethrough = fm2.width( textDraw ); thicknessStrikethrough = 1; drawStrikethrough( x, yStrikethrough, widthStrikethrough, thicknessStrikethrough, p ); break; case KoTextFormat::S_DOUBLE: - yStrikethrough = y - qRound( fm2.ascent() / 4 ); + yStrikethrough = y - tqRound( fm2.ascent() / 4 ); ( m_wordByWord )? widthStrikethrough = fm2.width( (*it) ): widthStrikethrough = fm2.width( textDraw ); thicknessStrikethrough = 1; drawStrikethrough( x, yStrikethrough, widthStrikethrough, thicknessStrikethrough, p ); - yStrikethrough = y - 2 * qRound( fm2.ascent() / 4 ); + yStrikethrough = y - 2 * tqRound( fm2.ascent() / 4 ); drawStrikethrough( x, yStrikethrough, widthStrikethrough, thicknessStrikethrough, p ); break; case KoTextFormat::S_SIMPLE_BOLD: - yStrikethrough = y - qRound( fm2.ascent() / 3 ); + yStrikethrough = y - tqRound( fm2.ascent() / 3 ); ( m_wordByWord )? widthStrikethrough = fm2.width( (*it) ): widthStrikethrough = fm2.width( textDraw ); - thicknessStrikethrough = qRound( displayFont.pointSize() / 10 ) + 1; + thicknessStrikethrough = tqRound( displayFont.pointSize() / 10 ) + 1; drawStrikethrough( x, yStrikethrough, widthStrikethrough, thicknessStrikethrough, p ); break; default: @@ -361,37 +361,37 @@ void KoFontDiaPreview::drawContents( QPainter* p ) p->restore(); } -void KoFontDiaPreview::drawUnderline( int x, int y, int width, int thickness, QColor & color, QPainter *p ) +void KoFontDiaPreview::drawUnderline( int x, int y, int width, int thickness, TQColor & color, TQPainter *p ) { p->save(); switch ( m_underliningStyle ) { case KoTextFormat::U_SOLID: - p->setPen( QPen( color, thickness, Qt::SolidLine ) ); + p->setPen( TQPen( color, thickness, TQt::SolidLine ) ); break; case KoTextFormat::U_DASH: - p->setPen( QPen( color, thickness, Qt::DashLine ) ); + p->setPen( TQPen( color, thickness, TQt::DashLine ) ); break; case KoTextFormat::U_DOT: - p->setPen( QPen( color, thickness, Qt::DotLine ) ); + p->setPen( TQPen( color, thickness, TQt::DotLine ) ); break; case KoTextFormat::U_DASH_DOT: - p->setPen( QPen( color, thickness, Qt::DashDotLine ) ); + p->setPen( TQPen( color, thickness, TQt::DashDotLine ) ); break; case KoTextFormat::U_DASH_DOT_DOT: - p->setPen( QPen( color, thickness, Qt::DashDotDotLine ) ); + p->setPen( TQPen( color, thickness, TQt::DashDotDotLine ) ); break; default: - p->setPen( QPen( color, thickness, Qt::SolidLine ) ); + p->setPen( TQPen( color, thickness, TQt::SolidLine ) ); } p->drawLine( x, y, x+ width, y ); p->restore(); } -void KoFontDiaPreview::drawUnderlineWave( int x, int y, int width, int thickness, QColor & color, QPainter *p ) +void KoFontDiaPreview::drawUnderlineWave( int x, int y, int width, int thickness, TQColor & color, TQPainter *p ) { p->save(); int offset = 2 * thickness; - QPen pen(color, thickness, Qt::SolidLine); + TQPen pen(color, thickness, TQt::SolidLine); pen.setCapStyle(Qt::RoundCap); p->setPen(pen); double anc=acos(1.0-2*(static_cast<double>(offset-(x)%offset)/static_cast<double>(offset)))/3.1415*180; @@ -400,7 +400,7 @@ void KoFontDiaPreview::drawUnderlineWave( int x, int y, int width, int thickness if(2*((x/offset)/2)==x/offset) pos*=-1; //draw first part of wave - p->drawArc( (x/offset)*offset, y, offset, offset, 0, -qRound(pos*anc*16) ); + p->drawArc( (x/offset)*offset, y, offset, offset, 0, -tqRound(pos*anc*16) ); //now the main part int zigzag_x = (x/offset+1)*offset; for ( ; zigzag_x + offset <= width+x; zigzag_x += offset) @@ -410,31 +410,31 @@ void KoFontDiaPreview::drawUnderlineWave( int x, int y, int width, int thickness } //and here we finish anc=acos(1.0-2*(static_cast<double>((x+width)%offset)/static_cast<double>(offset)))/3.1415*180; - p->drawArc( zigzag_x, y, offset, offset, 180*16, -qRound(pos*anc*16) ); + p->drawArc( zigzag_x, y, offset, offset, 180*16, -tqRound(pos*anc*16) ); p->restore(); } -void KoFontDiaPreview::drawStrikethrough( int x, int y, int width, int thickness, QPainter *p ) +void KoFontDiaPreview::drawStrikethrough( int x, int y, int width, int thickness, TQPainter *p ) { p->save(); switch ( m_strikethroughStyle ) { case KoTextFormat::S_SOLID: - p->setPen( QPen( Qt::black, thickness, Qt::SolidLine ) ); + p->setPen( TQPen( TQt::black, thickness, TQt::SolidLine ) ); break; case KoTextFormat::S_DASH: - p->setPen( QPen( Qt::black, thickness, Qt::DashLine ) ); + p->setPen( TQPen( TQt::black, thickness, TQt::DashLine ) ); break; case KoTextFormat::S_DOT: - p->setPen( QPen( Qt::black, thickness, Qt::DotLine ) ); + p->setPen( TQPen( TQt::black, thickness, TQt::DotLine ) ); break; case KoTextFormat::S_DASH_DOT: - p->setPen( QPen( Qt::black, thickness, Qt::DashDotLine ) ); + p->setPen( TQPen( TQt::black, thickness, TQt::DashDotLine ) ); break; case KoTextFormat::S_DASH_DOT_DOT: - p->setPen( QPen( Qt::black, thickness, Qt::DashDotDotLine ) ); + p->setPen( TQPen( TQt::black, thickness, TQt::DashDotDotLine ) ); break; default: - p->setPen( QPen( Qt::black, thickness, Qt::SolidLine ) ); + p->setPen( TQPen( TQt::black, thickness, TQt::SolidLine ) ); } p->drawLine( x, y, x+ width, y ); p->restore(); |