21#include "kowmfpaint.h"
30 if ( mPainter.isActive() )
return false;
32 mRelativeCoord = relativeCoord;
42bool KoWmfPaint::begin() {
43 bool ret = mPainter.begin( mTarget );
46 if ( mRelativeCoord ) {
47 mInternalWorldMatrix.reset();
52 mPainter.setWindow( rec.left(), rec.top(), rec.width(), rec.height() );
59bool KoWmfPaint::end() {
60 if ( mRelativeCoord ) {
70 return mPainter.end();
74void KoWmfPaint::save() {
79void KoWmfPaint::restore() {
84void KoWmfPaint::setFont(
const TQFont &font ) {
85 mPainter.setFont( font );
89void KoWmfPaint::setPen(
const TQPen &pen ) {
91 int width = pen.width();
93 if ( mTarget->isExtDev() ) {
99 TQRect devRec = mPainter.xForm( mPainter.window() );
100 TQRect rec = mPainter.window();
101 if ( rec.width() != 0 )
102 width = ( width * devRec.width() ) / rec.width() ;
108 mPainter.setPen( p );
112const TQPen &KoWmfPaint::pen()
const {
113 return mPainter.pen();
117void KoWmfPaint::setBrush(
const TQBrush &brush ) {
118 mPainter.setBrush( brush );
122void KoWmfPaint::setBackgroundColor(
const TQColor &c ) {
123 mPainter.setBackgroundColor( c );
127void KoWmfPaint::setBackgroundMode( TQt::BGMode mode ) {
128 mPainter.setBackgroundMode( mode );
132void KoWmfPaint::setRasterOp( TQt::RasterOp op ) {
133 mPainter.setRasterOp( op );
144void KoWmfPaint::setWindowOrg(
int left,
int top ) {
145 if ( mRelativeCoord ) {
146 double dx = mInternalWorldMatrix.dx();
147 double dy = mInternalWorldMatrix.dy();
150 mInternalWorldMatrix.translate( -dx, -dy );
151 mPainter.translate( -dx, -dy );
152 mInternalWorldMatrix.translate( -left, -top );
153 mPainter.translate( -left, -top );
156 TQRect rec = mPainter.window();
157 mPainter.setWindow( left, top, rec.width(), rec.height() );
162void KoWmfPaint::setWindowExt(
int w,
int h ) {
163 if ( mRelativeCoord ) {
164 TQRect r = mPainter.window();
165 double dx = mInternalWorldMatrix.dx();
166 double dy = mInternalWorldMatrix.dy();
167 double sx = mInternalWorldMatrix.m11();
168 double sy = mInternalWorldMatrix.m22();
171 mInternalWorldMatrix.translate( -dx, -dy );
172 mPainter.translate( -dx, -dy );
173 mInternalWorldMatrix.scale( 1/sx, 1/sy );
174 mPainter.scale( 1/sx, 1/sy );
176 sx = (double)r.width() / (double)w;
177 sy = (double)r.height() / (double)h;
179 mInternalWorldMatrix.scale( sx, sy );
180 mPainter.scale( sx, sy );
181 mInternalWorldMatrix.translate( dx, dy );
182 mPainter.translate( dx, dy );
185 TQRect rec = mPainter.window();
186 mPainter.setWindow( rec.left(), rec.top(), w, h );
191void KoWmfPaint::setWorldMatrix(
const TQWMatrix &wm,
bool combine ) {
192 mPainter.setWorldMatrix( wm, combine );
196void KoWmfPaint::setClipRegion(
const TQRegion &rec ) {
197 mPainter.setClipRegion( rec, TQPainter::CoordPainter );
201TQRegion KoWmfPaint::clipRegion() {
202 return mPainter.clipRegion( TQPainter::CoordPainter );
206void KoWmfPaint::moveTo(
int x,
int y ) {
207 mPainter.moveTo( x, y );
211void KoWmfPaint::lineTo(
int x,
int y ) {
212 mPainter.lineTo( x, y );
216void KoWmfPaint::drawRect(
int x,
int y,
int w,
int h ) {
217 mPainter.drawRect( x, y, w, h );
221void KoWmfPaint::drawRoundRect(
int x,
int y,
int w,
int h,
int roudw,
int roudh ) {
222 mPainter.drawRoundRect( x, y, w, h, roudw, roudh );
226void KoWmfPaint::drawEllipse(
int x,
int y,
int w,
int h ) {
227 mPainter.drawEllipse( x, y, w, h );
231void KoWmfPaint::drawArc(
int x,
int y,
int w,
int h,
int a,
int alen ) {
232 mPainter.drawArc( x, y, w, h, a, alen );
236void KoWmfPaint::drawPie(
int x,
int y,
int w,
int h,
int a,
int alen ) {
237 mPainter.drawPie( x, y, w, h, a, alen );
241void KoWmfPaint::drawChord(
int x,
int y,
int w,
int h,
int a,
int alen ) {
242 mPainter.drawChord( x, y, w, h, a, alen );
246void KoWmfPaint::drawPolyline(
const TQPointArray &pa ) {
247 mPainter.drawPolyline( pa );
251void KoWmfPaint::drawPolygon(
const TQPointArray &pa,
bool winding ) {
252 mPainter.drawPolygon( pa, winding );
256void KoWmfPaint::drawPolyPolygon( TQPtrList<TQPointArray>& listPa,
bool winding ) {
260 TQBrush brush = mPainter.brush();
264 for ( pa = listPa.first() ; pa ; pa = listPa.next() ) {
265 region = region.eor( *pa );
267 mPainter.setClipRegion( region, TQPainter::CoordPainter );
270 if ( brush != TQt::NoBrush ) {
271 mPainter.fillRect( region.boundingRect(), brush );
275 mPainter.setClipping(
false );
276 if ( mPainter.pen().style() != TQt::NoPen ) {
277 mPainter.setBrush( TQt::NoBrush );
278 for ( pa = listPa.first() ; pa ; pa = listPa.next() ) {
279 mPainter.drawPolygon( *pa, winding );
288void KoWmfPaint::drawImage(
int x,
int y,
const TQImage &img,
int sx,
int sy,
int sw,
int sh ) {
289 mPainter.drawImage( x, y, img, sx, sy, sw, sh );
293void KoWmfPaint::drawText(
int x,
int y,
int w,
int h,
int flags,
const TQString& s,
double ) {
294 mPainter.drawText( x, y, w, h, flags, s );
KoWmfRead allows the redirection of the actions stored in a WMF file.
virtual bool play()
play the WMF file => call virtuals functions
virtual TQRect boundingRect(void) const
Returns the bounding rectangle Standard Meta File : return the bounding box from setWindowOrg and set...