1#include "KPrTextPreview.h"
8KPrTextPreview::KPrTextPreview( TQWidget* parent, const char* name )
9 : TQFrame( parent, name ),
10 shadowDirection( SD_LEFT_BOTTOM ),
14 setBackgroundColor( white );
15 setFrameStyle( NoFrame );
18void KPrTextPreview::drawContents( TQPainter* painter )
20 TQFont font(KoGlobal::defaultFont().family(), 30, TQFont::Bold);
21 TQFontMetrics fm( font );
23 TQRect br = fm.boundingRect( "KOffice" );
27 int textYPos = -r.y();
28 int textXPos = -r.x();
29 br.moveTopLeft( TQPoint( -br.width() / 2, -br.height() / 2 ) );
30 r.moveTopLeft( TQPoint( -r.width() / 2, -r.height() / 2 ) );
32 int x = r.left() + textXPos;
33 int y = r.top() + textYPos;
36 switch ( shadowDirection )
40 sx = x - shadowDistance;
41 sy = y - shadowDistance;
46 sy = y - shadowDistance;
50 sx = x + shadowDistance;
51 sy = y - shadowDistance;
55 sx = x + shadowDistance;
60 sx = x + shadowDistance;
61 sy = y + shadowDistance;
66 sy = y + shadowDistance;
70 sx = x - shadowDistance;
71 sy = y + shadowDistance;
75 sx = x - shadowDistance;
82 painter->setViewport( ( width() - pw ) / 2, ( height() - ph ) / 2, width(), height() );
86 m.translate( pw / 2, ph / 2 );
89 painter->setWorldMatrix( m );
90 painter->setFont( font );
92 if ( shadowDistance > 0 ) {
93 painter->setPen( shadowColor );
94 painter->drawText( sx, sy, TQString( "KOffice") );
96 painter->setPen( blue );
97 painter->drawText( x, y, TQString( "KOffice") );
101#include "KPrTextPreview.moc"
|