00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <kdebug.h>
00020
00021 #include "kowmfpaint.h"
00022
00023 KoWmfPaint::KoWmfPaint() : KoWmfRead() {
00024 mTarget = 0;
00025 }
00026
00027
00028 bool KoWmfPaint::play( QPaintDevice& target, bool relativeCoord )
00029 {
00030 if ( mPainter.isActive() ) return false;
00031 mTarget = ⌖
00032 mRelativeCoord = relativeCoord;
00033
00034
00035 return KoWmfRead::play( );
00036 }
00037
00038
00039
00040
00041
00042 bool KoWmfPaint::begin() {
00043 bool ret = mPainter.begin( mTarget );
00044
00045 if ( ret ) {
00046 if ( mRelativeCoord ) {
00047 mInternalWorldMatrix.reset();
00048 }
00049 else {
00050
00051 QRect rec = boundingRect();
00052 mPainter.setWindow( rec.left(), rec.top(), rec.width(), rec.height() );
00053 }
00054 }
00055 return ret;
00056 }
00057
00058
00059 bool KoWmfPaint::end() {
00060 if ( mRelativeCoord ) {
00061 QRect rec = boundingRect();
00062
00063
00064
00065
00066
00067
00068
00069 }
00070 return mPainter.end();
00071 }
00072
00073
00074 void KoWmfPaint::save() {
00075 mPainter.save();
00076 }
00077
00078
00079 void KoWmfPaint::restore() {
00080 mPainter.restore();
00081 }
00082
00083
00084 void KoWmfPaint::setFont( const QFont &font ) {
00085 mPainter.setFont( font );
00086 }
00087
00088
00089 void KoWmfPaint::setPen( const QPen &pen ) {
00090 QPen p = pen;
00091 int width = pen.width();
00092
00093 if ( mTarget->isExtDev() ) {
00094 width = 0;
00095 }
00096 else {
00097
00098
00099 QRect devRec = mPainter.xForm( mPainter.window() );
00100 QRect rec = mPainter.window();
00101 if ( rec.width() != 0 )
00102 width = ( width * devRec.width() ) / rec.width() ;
00103 else
00104 width = 0;
00105 }
00106
00107 p.setWidth( width );
00108 mPainter.setPen( p );
00109 }
00110
00111
00112 const QPen &KoWmfPaint::pen() const {
00113 return mPainter.pen();
00114 }
00115
00116
00117 void KoWmfPaint::setBrush( const QBrush &brush ) {
00118 mPainter.setBrush( brush );
00119 }
00120
00121
00122 void KoWmfPaint::setBackgroundColor( const QColor &c ) {
00123 mPainter.setBackgroundColor( c );
00124 }
00125
00126
00127 void KoWmfPaint::setBackgroundMode( Qt::BGMode mode ) {
00128 mPainter.setBackgroundMode( mode );
00129 }
00130
00131
00132 void KoWmfPaint::setRasterOp( Qt::RasterOp op ) {
00133 mPainter.setRasterOp( op );
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 void KoWmfPaint::setWindowOrg( int left, int top ) {
00145 if ( mRelativeCoord ) {
00146 double dx = mInternalWorldMatrix.dx();
00147 double dy = mInternalWorldMatrix.dy();
00148
00149
00150 mInternalWorldMatrix.translate( -dx, -dy );
00151 mPainter.translate( -dx, -dy );
00152 mInternalWorldMatrix.translate( -left, -top );
00153 mPainter.translate( -left, -top );
00154 }
00155 else {
00156 QRect rec = mPainter.window();
00157 mPainter.setWindow( left, top, rec.width(), rec.height() );
00158 }
00159 }
00160
00161
00162 void KoWmfPaint::setWindowExt( int w, int h ) {
00163 if ( mRelativeCoord ) {
00164 QRect r = mPainter.window();
00165 double dx = mInternalWorldMatrix.dx();
00166 double dy = mInternalWorldMatrix.dy();
00167 double sx = mInternalWorldMatrix.m11();
00168 double sy = mInternalWorldMatrix.m22();
00169
00170
00171 mInternalWorldMatrix.translate( -dx, -dy );
00172 mPainter.translate( -dx, -dy );
00173 mInternalWorldMatrix.scale( 1/sx, 1/sy );
00174 mPainter.scale( 1/sx, 1/sy );
00175
00176 sx = (double)r.width() / (double)w;
00177 sy = (double)r.height() / (double)h;
00178
00179 mInternalWorldMatrix.scale( sx, sy );
00180 mPainter.scale( sx, sy );
00181 mInternalWorldMatrix.translate( dx, dy );
00182 mPainter.translate( dx, dy );
00183 }
00184 else {
00185 QRect rec = mPainter.window();
00186 mPainter.setWindow( rec.left(), rec.top(), w, h );
00187 }
00188 }
00189
00190
00191 void KoWmfPaint::setWorldMatrix( const QWMatrix &wm, bool combine ) {
00192 mPainter.setWorldMatrix( wm, combine );
00193 }
00194
00195
00196 void KoWmfPaint::setClipRegion( const QRegion &rec ) {
00197 mPainter.setClipRegion( rec, QPainter::CoordPainter );
00198 }
00199
00200
00201 QRegion KoWmfPaint::clipRegion() {
00202 return mPainter.clipRegion( QPainter::CoordPainter );
00203 }
00204
00205
00206 void KoWmfPaint::moveTo( int x, int y ) {
00207 mPainter.moveTo( x, y );
00208 }
00209
00210
00211 void KoWmfPaint::lineTo( int x, int y ) {
00212 mPainter.lineTo( x, y );
00213 }
00214
00215
00216 void KoWmfPaint::drawRect( int x, int y, int w, int h ) {
00217 mPainter.drawRect( x, y, w, h );
00218 }
00219
00220
00221 void KoWmfPaint::drawRoundRect( int x, int y, int w, int h, int roudw, int roudh ) {
00222 mPainter.drawRoundRect( x, y, w, h, roudw, roudh );
00223 }
00224
00225
00226 void KoWmfPaint::drawEllipse( int x, int y, int w, int h ) {
00227 mPainter.drawEllipse( x, y, w, h );
00228 }
00229
00230
00231 void KoWmfPaint::drawArc( int x, int y, int w, int h, int a, int alen ) {
00232 mPainter.drawArc( x, y, w, h, a, alen );
00233 }
00234
00235
00236 void KoWmfPaint::drawPie( int x, int y, int w, int h, int a, int alen ) {
00237 mPainter.drawPie( x, y, w, h, a, alen );
00238 }
00239
00240
00241 void KoWmfPaint::drawChord( int x, int y, int w, int h, int a, int alen ) {
00242 mPainter.drawChord( x, y, w, h, a, alen );
00243 }
00244
00245
00246 void KoWmfPaint::drawPolyline( const QPointArray &pa ) {
00247 mPainter.drawPolyline( pa );
00248 }
00249
00250
00251 void KoWmfPaint::drawPolygon( const QPointArray &pa, bool winding ) {
00252 mPainter.drawPolygon( pa, winding );
00253 }
00254
00255
00256 void KoWmfPaint::drawPolyPolygon( QPtrList<QPointArray>& listPa, bool winding ) {
00257 QPointArray *pa;
00258
00259 mPainter.save();
00260 QBrush brush = mPainter.brush();
00261
00262
00263 QRegion region;
00264 for ( pa = listPa.first() ; pa ; pa = listPa.next() ) {
00265 region = region.eor( *pa );
00266 }
00267 mPainter.setClipRegion( region, QPainter::CoordPainter );
00268
00269
00270 if ( brush != Qt::NoBrush ) {
00271 mPainter.fillRect( region.boundingRect(), brush );
00272 }
00273
00274
00275 mPainter.setClipping( false );
00276 if ( mPainter.pen().style() != Qt::NoPen ) {
00277 mPainter.setBrush( Qt::NoBrush );
00278 for ( pa = listPa.first() ; pa ; pa = listPa.next() ) {
00279 mPainter.drawPolygon( *pa, winding );
00280 }
00281 }
00282
00283
00284 mPainter.restore();
00285 }
00286
00287
00288 void KoWmfPaint::drawImage( int x, int y, const QImage &img, int sx, int sy, int sw, int sh ) {
00289 mPainter.drawImage( x, y, img, sx, sy, sw, sh );
00290 }
00291
00292
00293 void KoWmfPaint::drawText( int x, int y, int w, int h, int flags, const QString& s, double ) {
00294 mPainter.drawText( x, y, w, h, flags, s );
00295 }
00296
00297