diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kpresenter/KPrTextPreview.cpp | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpresenter/KPrTextPreview.cpp')
-rw-r--r-- | kpresenter/KPrTextPreview.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/kpresenter/KPrTextPreview.cpp b/kpresenter/KPrTextPreview.cpp new file mode 100644 index 00000000..b77e067e --- /dev/null +++ b/kpresenter/KPrTextPreview.cpp @@ -0,0 +1,101 @@ +#include "KPrTextPreview.h" + +#include <KoGlobal.h> + +#include <qpainter.h> +#include <qfont.h> + +KPrTextPreview::KPrTextPreview( QWidget* parent, const char* name ) + : QFrame( parent, name ), + shadowDirection( SD_LEFT_BOTTOM ), + shadowDistance( 0 ), + angle( 0 ) +{ + setBackgroundColor( white ); + setFrameStyle( NoFrame ); +} + +void KPrTextPreview::drawContents( QPainter* painter ) +{ + QFont font(KoGlobal::defaultFont().family(), 30, QFont::Bold); + QFontMetrics fm( font ); + + QRect br = fm.boundingRect( "KOffice" ); + int pw = br.width(); + int ph = br.height(); + QRect r = br; + int textYPos = -r.y(); + int textXPos = -r.x(); + br.moveTopLeft( QPoint( -br.width() / 2, -br.height() / 2 ) ); + r.moveTopLeft( QPoint( -r.width() / 2, -r.height() / 2 ) ); + + int x = r.left() + textXPos; + int y = r.top() + textYPos; + int sx = 0, sy = 0; + + switch ( shadowDirection ) + { + case SD_LEFT_UP: + { + sx = x - shadowDistance; + sy = y - shadowDistance; + } break; + case SD_UP: + { + sx = x; + sy = y - shadowDistance; + } break; + case SD_RIGHT_UP: + { + sx = x + shadowDistance; + sy = y - shadowDistance; + } break; + case SD_RIGHT: + { + sx = x + shadowDistance; + sy = y; + } break; + case SD_RIGHT_BOTTOM: + { + sx = x + shadowDistance; + sy = y + shadowDistance; + } break; + case SD_BOTTOM: + { + sx = x; + sy = y + shadowDistance; + } break; + case SD_LEFT_BOTTOM: + { + sx = x - shadowDistance; + sy = y + shadowDistance; + } break; + case SD_LEFT: + { + sx = x - shadowDistance; + sy = y; + } break; + } + + painter->save(); + + painter->setViewport( ( width() - pw ) / 2, ( height() - ph ) / 2, width(), height() ); + + QWMatrix m, mtx; + mtx.rotate( angle ); + m.translate( pw / 2, ph / 2 ); + m = mtx * m; + + painter->setWorldMatrix( m ); + painter->setFont( font ); + + if ( shadowDistance > 0 ) { + painter->setPen( shadowColor ); + painter->drawText( sx, sy, "KOffice" ); + } + painter->setPen( blue ); + painter->drawText( x, y, "KOffice" ); + + painter->restore(); +} +#include "KPrTextPreview.moc" |