lib

qwmf.cpp
1/* Windows Meta File Loader/Painter Class Implementation
2 *
3 * Copyright ( C ) 1998 Stefan Taferner
4 * Modified 2002 thierry lorthiois
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or ( at your
9 * option ) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details. You should have received a copy
15 * of the GNU General Public License along with this program; if not, write
16 * to the Free Software Foundation, Inc, 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include "config.h"
21
22#include <math.h>
23#include <assert.h>
24#include <tqfileinfo.h>
25#include <tqpixmap.h>
26#include <tqpainter.h>
27#include <tqdatastream.h>
28#include <tqapplication.h>
29#include <tqbuffer.h>
30#include <kdebug.h>
31
32bool qwmfDebug = false;
33
34#include "qwmf.h"
35#include "wmfstruct.h"
36#include "metafuncs.h"
37
38#define TQWMF_DEBUG 0
39
40
41class WmfCmd
42{
43public:
44 ~WmfCmd() { if ( next ) delete next; }
45 WmfCmd* next;
46 unsigned short funcIndex;
47 long numParm;
48 short* parm;
49};
50
51
52class WinObjHandle
53{
54public:
55 virtual void apply( TQPainter& p ) = 0;
56};
57
58class WinObjBrushHandle: public WinObjHandle
59{
60public:
61 virtual void apply( TQPainter& p );
62 TQBrush brush;
63 virtual ~WinObjBrushHandle() {};
64};
65
66class WinObjPenHandle: public WinObjHandle
67{
68public:
69 virtual void apply( TQPainter& p );
70 TQPen pen;
71 virtual ~WinObjPenHandle() {};
72};
73
74class WinObjPatternBrushHandle: public WinObjHandle
75{
76public:
77 virtual void apply( TQPainter& p );
78 TQBrush brush;
79 TQPixmap image;
80 virtual ~WinObjPatternBrushHandle() {};
81};
82
83class WinObjFontHandle: public WinObjHandle
84{
85public:
86 virtual void apply( TQPainter& p );
87 TQFont font;
88 int rotation;
89 virtual ~WinObjFontHandle() {};
90};
91
92void WinObjBrushHandle::apply( TQPainter& p )
93{
94 p.setBrush( brush );
95}
96
97void WinObjPenHandle::apply( TQPainter& p )
98{
99 p.setPen( pen );
100}
101
102void WinObjPatternBrushHandle::apply( TQPainter& p )
103{
104 p.setBrush( brush );
105}
106
107void WinObjFontHandle::apply( TQPainter& p )
108{
109 p.setFont( font );
110}
111
112#define MAX_OBJHANDLE 64
113
114
115
116//-----------------------------------------------------------------------------
117QWinMetaFile::QWinMetaFile()
118{
119 mValid = false;
120 mFirstCmd = NULL;
121 mObjHandleTab = NULL;
122 mDpi = 1000;
123}
124
125
126//-----------------------------------------------------------------------------
127QWinMetaFile::~QWinMetaFile()
128{
129 if ( mFirstCmd ) delete mFirstCmd;
130 if ( mObjHandleTab ) delete[] mObjHandleTab;
131}
132
133
134//-----------------------------------------------------------------------------
135bool QWinMetaFile::load( const TQString &filename )
136{
137 TQFile file( filename );
138
139 if ( !file.exists() )
140 {
141 kdDebug() << "File " << TQString(TQFile::encodeName(filename)) << " does not exist" << endl;
142 return false;
143 }
144
145 if ( !file.open( IO_ReadOnly ) )
146 {
147 kdDebug() << "Cannot open file " << TQString(TQFile::encodeName(filename)) << endl;
148 return false;
149 }
150
151 TQByteArray ba = file.readAll();
152 file.close();
153
154 TQBuffer buffer( ba );
155 buffer.open( IO_ReadOnly );
156 return load( buffer );
157}
158
159//-----------------------------------------------------------------------------
160bool QWinMetaFile::load( TQBuffer &buffer )
161{
162 TQDataStream st;
163 WmfEnhMetaHeader eheader;
164 WmfMetaHeader header;
165 WmfPlaceableHeader pheader;
166 WORD checksum;
167 int filePos, idx, i;
168 WmfCmd *cmd, *last;
169 DWORD rdSize;
170 WORD rdFunc;
171
172 mTextAlign = 0;
173 mRotation = 0;
174 mTextColor = TQt::black;
175 if ( mFirstCmd ) delete mFirstCmd;
176 mFirstCmd = NULL;
177
178 st.setDevice( &buffer );
179 st.setByteOrder( TQDataStream::LittleEndian ); // Great, I love TQt !
180
181 //----- Read placeable metafile header
182 st >> pheader.key;
183 mIsPlaceable = ( pheader.key==( DWORD )APMHEADER_KEY );
184 if ( mIsPlaceable )
185 {
186 st >> pheader.hmf;
187 st >> pheader.bbox.left;
188 st >> pheader.bbox.top;
189 st >> pheader.bbox.right;
190 st >> pheader.bbox.bottom;
191 st >> pheader.inch;
192 st >> pheader.reserved;
193 st >> pheader.checksum;
194 checksum = calcCheckSum( &pheader );
195 if ( pheader.checksum!=checksum ) mIsPlaceable = false;
196
197 mDpi = pheader.inch;
198 mBBox.setLeft( pheader.bbox.left );
199 mBBox.setTop( pheader.bbox.top );
200 mBBox.setRight( pheader.bbox.right );
201 mBBox.setBottom( pheader.bbox.bottom );
202 mHeaderBoundingBox = mBBox;
203 if ( TQWMF_DEBUG )
204 {
205 kdDebug() << endl << "-------------------------------------------------" << endl;
206 kdDebug() << "WMF Placeable Header ( " << static_cast<int>(sizeof( pheader ) ) << "):" << endl;
207 kdDebug() << " bbox=( " << mBBox.left() << "; " << mBBox.top() << "; " << mBBox.width()
208 << "; " << mBBox.height() << ")" << endl;
209 kdDebug() << " inch=" << pheader.inch << endl;
210 kdDebug() << " checksum=" << pheader.checksum << "( "
211 << (pheader.checksum==checksum?"ok":"wrong") << " )" << endl;
212 }
213 }
214 else buffer.at( 0 );
215
216 //----- Read as enhanced metafile header
217 filePos = buffer.at();
218 st >> eheader.iType;
219 st >> eheader.nSize;
220 st >> eheader.rclBounds.left;
221 st >> eheader.rclBounds.top;
222 st >> eheader.rclBounds.right;
223 st >> eheader.rclBounds.bottom;
224 st >> eheader.rclFrame.left;
225 st >> eheader.rclFrame.top;
226 st >> eheader.rclFrame.right;
227 st >> eheader.rclFrame.bottom;
228 st >> eheader.dSignature;
229 mIsEnhanced = ( eheader.dSignature==ENHMETA_SIGNATURE );
230 if ( mIsEnhanced ) // is it really enhanced ?
231 {
232 st >> eheader.nVersion;
233 st >> eheader.nBytes;
234 st >> eheader.nRecords;
235 st >> eheader.nHandles;
236 st >> eheader.sReserved;
237 st >> eheader.nDescription;
238 st >> eheader.offDescription;
239 st >> eheader.nPalEntries;
240 st >> eheader.szlDevice.width;
241 st >> eheader.szlDevice.height;
242 st >> eheader.szlMillimeters.width;
243 st >> eheader.szlMillimeters.height;
244
245 if ( TQWMF_DEBUG )
246 {
247 kdDebug() << endl << "-------------------------------------------------" << endl;
248 kdDebug() << "WMF Extended Header:" << endl;
249 kdDebug() << " iType=" << eheader.iType << endl;
250 kdDebug() << " nSize=" << eheader.nSize << endl;
251 kdDebug() << " rclBounds=( " << eheader.rclBounds.left << "; " << eheader.rclBounds.top << "; "
252 << eheader.rclBounds.right << "; " << eheader.rclBounds.bottom << ")" << endl;
253 kdDebug() << " rclFrame=( " << eheader.rclFrame.left << "; " << eheader.rclFrame.top << "; "
254 << eheader.rclFrame.right << "; " << eheader.rclFrame.bottom << ")" << endl;
255 kdDebug() << " nBytes=" << eheader.nBytes << endl;
256 kdDebug() << "\nNOT YET IMPLEMENTED, SORRY." << endl;
257 }
258 }
259 else // no, not enhanced
260 {
261 //----- Read as standard metafile header
262 buffer.at( filePos );
263 st >> header.mtType;
264 st >> header.mtHeaderSize;
265 st >> header.mtVersion;
266 st >> header.mtSize;
267 st >> header.mtNoObjects;
268 st >> header.mtMaxRecord;
269 st >> header.mtNoParameters;
270 if ( TQWMF_DEBUG ) {
271 kdDebug() << "WMF Header: " << "mtSize=" << header.mtSize << endl;
272 }
273 }
274
275 //----- Test header validity
276 mValid = ((header.mtHeaderSize == 9) && (header.mtNoParameters == 0)) || mIsEnhanced || mIsPlaceable;
277 if ( mValid )
278 {
279 //----- Read Metafile Records
280 last = NULL;
281 rdFunc = -1;
282 while ( !st.eof() && (rdFunc != 0) )
283 {
284 st >> rdSize;
285 st >> rdFunc;
286 idx = findFunc( rdFunc );
287 rdSize -= 3;
288
289 cmd = new WmfCmd;
290 cmd->next = NULL;
291 if ( last ) last->next = cmd;
292 else mFirstCmd = cmd;
293
294 cmd->funcIndex = idx;
295 cmd->numParm = rdSize;
296 cmd->parm = new WORD[ rdSize ];
297 last = cmd;
298
299 for ( i=0; i<rdSize && !st.eof(); i++ )
300 st >> cmd->parm[ i ];
301
302
303 if ( rdFunc == 0x020B ) { // SETWINDOWORG: dimensions
304 mBBox.setLeft( cmd->parm[ 1 ] );
305 mBBox.setTop( cmd->parm[ 0 ] );
306 }
307 if ( rdFunc == 0x020C ) { // SETWINDOWEXT: dimensions
308 mBBox.setWidth( cmd->parm[ 1 ] );
309 mBBox.setHeight( cmd->parm[ 0 ] );
310 }
311
312 if ( i<rdSize )
313 {
314 kdDebug() << "WMF : file truncated !" << endl;
315 return false;
316 }
317 }
318 //----- Test records validities
319 mValid = (rdFunc == 0) && (mBBox.width() != 0) && (mBBox.height() != 0);
320 if ( !mValid ) {
321 kdDebug() << "WMF : incorrect file format !" << endl;
322 }
323 }
324 else {
325 kdDebug() << "WMF Header : incorrect header !" << endl;
326 }
327
328 buffer.close();
329 return mValid;
330}
331
332
333//-----------------------------------------------------------------------------
334bool QWinMetaFile::paint( const TQPaintDevice* aTarget, bool absolute )
335{
336 int idx, i;
337 WmfCmd* cmd;
338
339 if ( !mValid ) return false;
340
341 assert( aTarget!=NULL );
342 if ( mPainter.isActive() ) return false;
343
344 if ( mObjHandleTab ) delete[] mObjHandleTab;
345 mObjHandleTab = new WinObjHandle* [ MAX_OBJHANDLE ];
346 for ( i=MAX_OBJHANDLE-1; i>=0; i-- )
347 mObjHandleTab[ i ] = NULL;
348
349 mPainter.resetXForm();
350 mWinding = false;
351 mAbsoluteCoord = absolute;
352
353 mPainter.begin( const_cast<TQPaintDevice*>(aTarget) );
354 if ( TQWMF_DEBUG ) {
355 kdDebug() << "Bounding box : " << mBBox.left()
356 << " " << mBBox.top() << " " << mBBox.right() << " " << mBBox.bottom() << endl;
357 }
358
359 if ( mAbsoluteCoord ) {
360 mPainter.setWindow( mBBox.top(), mBBox.left(), mBBox.width(), mBBox.height() );
361 }
362 mInternalWorldMatrix.reset();
363
364 for ( cmd=mFirstCmd; cmd; cmd=cmd->next )
365 {
366 idx = cmd->funcIndex;
367 ( this->*metaFuncTab[ idx ].method )( cmd->numParm, cmd->parm );
368
369 if ( TQWMF_DEBUG ) {
370 TQString str = "", param;
371 if ( metaFuncTab[ idx ].name == NULL ) {
372 str += "UNKNOWN ";
373 }
374 if ( metaFuncTab[ idx ].method == &QWinMetaFile::noop ) {
375 str += "UNIMPLEMENTED ";
376 }
377 str += metaFuncTab[ idx ].name;
378 str += " : ";
379
380 for ( i=0 ; i < cmd->numParm ; i++ ) {
381 param.setNum( cmd->parm[ i ] );
382 str += param;
383 str += " ";
384 }
385 kdDebug() << str << endl;
386 }
387 }
388/*
389 // TODO: cleanup this code when TQPicture::setBoundingBox() is possible in KOClipart (QT31)
390 // because actually TQPicture::boundingBox() != mBBox()
391 mWindowsCoord += 1;
392 if ( mWindowsCoord == 2 ) {
393 kdDebug() << "DRAW ANGLES " << endl;
394 mPainter.setPen( TQt::white );
395 mPainter.drawPoint( mBBox.left(), mBBox.top() );
396 mPainter.drawPoint( mBBox.right(), mBBox.bottom() );
397 }
398*/
399 mPainter.end();
400 return true;
401}
402
403
404//----------------s-------------------------------------------------------------
405// Metafile painter methods
406//-----------------------------------------------------------------------------
407void QWinMetaFile::setWindowOrg( long, short* parm )
408{
409 if ( mAbsoluteCoord ) {
410 TQRect r = mPainter.window();
411 mPainter.setWindow( parm[ 1 ], parm[ 0 ], r.width(), r.height() );
412 }
413 else {
414 double dx = mInternalWorldMatrix.dx();
415 double dy = mInternalWorldMatrix.dy();
416
417 mInternalWorldMatrix.translate( -dx, -dy );
418 mInternalWorldMatrix.translate( -parm[ 1 ], -parm[ 0 ] );
419 mPainter.translate( -dx, -dy );
420 mPainter.translate( -parm[ 1 ], -parm[ 0 ] );
421 }
422}
423
424
425//-----------------------------------------------------------------------------
426void QWinMetaFile::setWindowExt( long, short* parm )
427{
428 // negative value allowed for width and height : TQABS() forbidden
429 if ( mAbsoluteCoord ) {
430 TQRect r = mPainter.window();
431 mPainter.setWindow( r.left(), r.top(), parm[ 1 ], parm[ 0 ] );
432 }
433 else {
434 if ( (parm[ 0 ] != 0) && (parm[ 1 ] != 0) ) {
435 TQRect r = mPainter.window();
436 double dx = mInternalWorldMatrix.dx();
437 double dy = mInternalWorldMatrix.dy();
438 double sx = mInternalWorldMatrix.m11();
439 double sy = mInternalWorldMatrix.m22();
440
441 mInternalWorldMatrix.translate( -dx, -dy );
442 mInternalWorldMatrix.scale( 1/sx, 1/sy );
443 mPainter.translate( -dx, -dy );
444 mPainter.scale( 1/sx, 1/sy );
445
446 sx = (double)r.width() / (double)parm[ 1 ];
447 sy = (double)r.height() / (double)parm[ 0 ];
448
449 mInternalWorldMatrix.scale( sx, sy );
450 mInternalWorldMatrix.translate( dx, dy );
451 mPainter.scale( sx, sy );
452 mPainter.translate( dx, dy );
453 }
454 }
455}
456
457
458//-----------------------------------------------------------------------------
459// Drawing
460//-----------------------------------------------------------------------------
461void QWinMetaFile::lineTo( long, short* parm )
462{
463 mPainter.lineTo( parm[ 1 ], parm[ 0 ] );
464}
465
466
467//-----------------------------------------------------------------------------
468void QWinMetaFile::moveTo( long, short* parm )
469{
470 mPainter.moveTo( parm[ 1 ], parm[ 0 ] );
471}
472
473
474//-----------------------------------------------------------------------------
475void QWinMetaFile::ellipse( long, short* parm )
476{
477 mPainter.drawEllipse( parm[ 3 ], parm[ 2 ], parm[ 1 ]-parm[ 3 ], parm[ 0 ]-parm[ 2 ] );
478}
479
480
481//-----------------------------------------------------------------------------
482void QWinMetaFile::polygon( long, short* parm )
483{
484 TQPointArray* pa;
485
486 pa = pointArray( parm[ 0 ], &parm[ 1 ] );
487 mPainter.drawPolygon( *pa, mWinding );
488}
489
490
491//-----------------------------------------------------------------------------
492void QWinMetaFile::polyPolygon( long, short* parm )
493{
494 TQRegion region;
495 int i, j, startPolygon;
496
497 mPainter.save();
498
499 // define clipping region
500 TQRect win = bbox();
501 startPolygon = 1+parm[ 0 ];
502 for ( i=0 ; i < parm[ 0 ] ; i++ ) {
503 TQPointArray pa1( parm[ 1+i ] );
504 for ( j=0 ; j < parm[ 1+i ] ; j++) {
505 pa1.setPoint ( j, parm[ startPolygon ], parm[ startPolygon+1 ] );
506 startPolygon += 2;
507 }
508 TQRegion r( pa1 );
509 region = region.eor( r );
510 }
511 mPainter.setClipRegion( region, TQPainter::CoordPainter );
512
513 // fill polygons
514 mPainter.fillRect( win.left(), win.top(), win.width(), win.height(), mPainter.brush() );
515
516 // draw polygon's border if necessary
517 if ( mPainter.pen().style() != TQt::NoPen ) {
518 mPainter.setClipping( false );
519 mPainter.setBrush( TQt::NoBrush );
520
521 TQPointArray* pa;
522 int idxPolygon = 1 + parm[ 0 ];
523 for ( i=0 ; i < parm[ 0 ] ; i++ ) {
524 pa = pointArray( parm[ 1+i ], &parm[ idxPolygon ] );
525 mPainter.drawPolygon( *pa );
526 idxPolygon += parm[ 1+i ] * 2;
527 }
528 }
529
530 mPainter.restore();
531}
532
533
534//-----------------------------------------------------------------------------
535void QWinMetaFile::polyline( long, short* parm )
536{
537 TQPointArray* pa;
538
539 pa = pointArray( parm[ 0 ], &parm[ 1 ] );
540 mPainter.drawPolyline( *pa );
541}
542
543
544//-----------------------------------------------------------------------------
545void QWinMetaFile::rectangle( long, short* parm )
546{
547 mPainter.drawRect( parm[ 3 ], parm[ 2 ], parm[ 1 ]-parm[ 3 ], parm[ 0 ]-parm[ 2 ] );
548}
549
550
551//-----------------------------------------------------------------------------
552void QWinMetaFile::roundRect( long, short* parm )
553{
554 int xRnd = 0, yRnd = 0;
555
556 // convert (xRound, yRound) in percentage
557 if ( (parm[ 3 ] - parm[ 5 ]) != 0 )
558 xRnd = (parm[ 1 ] * 100) / (parm[ 3 ] - parm[ 5 ]) ;
559 if ( (parm[ 2 ] - parm[ 4 ]) != 0 )
560 yRnd = (parm[ 0 ] * 100) / (parm[ 2 ] - parm[ 4 ]) ;
561
562 mPainter.drawRoundRect( parm[ 5 ], parm[ 4 ], parm[ 3 ]-parm[ 5 ], parm[ 2 ]-parm[ 4 ], xRnd, yRnd );
563}
564
565
566//-----------------------------------------------------------------------------
567void QWinMetaFile::arc( long, short* parm )
568{
569 int xCenter, yCenter, angleStart, aLength;
570
571 xCenter = parm[ 7 ] + ((parm[ 5 ] - parm[ 7 ]) / 2);
572 yCenter = parm[ 6 ] + ((parm[ 4 ] - parm[ 6 ]) / 2);
573
574 xyToAngle ( parm[ 3 ] - xCenter, yCenter - parm[ 2 ], parm[ 1 ] - xCenter, yCenter - parm[ 0 ], angleStart, aLength );
575
576 mPainter.drawArc( parm[ 7 ], parm[ 6 ], parm[ 5 ]-parm[ 7 ], parm[ 4 ]-parm[ 6 ], angleStart, aLength);
577}
578
579
580//-----------------------------------------------------------------------------
581void QWinMetaFile::chord( long, short* parm )
582{
583 int xCenter, yCenter, angleStart, aLength;
584
585 xCenter = parm[ 7 ] + ((parm[ 5 ] - parm[ 7 ]) / 2);
586 yCenter = parm[ 6 ] + ((parm[ 4 ] - parm[ 6 ]) / 2);
587
588 xyToAngle ( parm[ 3 ] - xCenter, yCenter - parm[ 2 ], parm[ 1 ] - xCenter, yCenter - parm[ 0 ], angleStart, aLength );
589
590 mPainter.drawChord( parm[ 7 ], parm[ 6 ], parm[ 5 ]-parm[ 7 ], parm[ 4 ]-parm[ 6 ], angleStart, aLength);
591}
592
593
594//-----------------------------------------------------------------------------
595void QWinMetaFile::pie( long, short* parm )
596{
597 int xCenter, yCenter, angleStart, aLength;
598
599 xCenter = parm[ 7 ] + ((parm[ 5 ] - parm[ 7 ]) / 2);
600 yCenter = parm[ 6 ] + ((parm[ 4 ] - parm[ 6 ]) / 2);
601
602 xyToAngle ( parm[ 3 ] - xCenter, yCenter - parm[ 2 ], parm[ 1 ] - xCenter, yCenter - parm[ 0 ], angleStart, aLength );
603
604 mPainter.drawPie( parm[ 7 ], parm[ 6 ], parm[ 5 ]-parm[ 7 ], parm[ 4 ]-parm[ 6 ], angleStart, aLength);
605}
606
607
608//-----------------------------------------------------------------------------
609void QWinMetaFile::setPolyFillMode( long, short* parm )
610{
611 mWinding = parm[ 0 ];
612}
613
614
615//-----------------------------------------------------------------------------
616void QWinMetaFile::setBkColor( long, short* parm )
617{
618 mPainter.setBackgroundColor( color( parm ) );
619}
620
621
622//-----------------------------------------------------------------------------
623void QWinMetaFile::setBkMode( long, short* parm )
624{
625 if ( parm[ 0 ]==1 ) mPainter.setBackgroundMode( TQt::TransparentMode );
626 else mPainter.setBackgroundMode( TQt::OpaqueMode );
627}
628
629
630//-----------------------------------------------------------------------------
631void QWinMetaFile::setPixel( long, short* parm )
632{
633 TQPen pen = mPainter.pen();
634 mPainter.setPen( color( parm ) );
635 mPainter.drawPoint( parm[ 3 ], parm[ 2 ] );
636 mPainter.setPen( pen );
637}
638
639
640//-----------------------------------------------------------------------------
641void QWinMetaFile::setRop( long, short* parm )
642{
643 mPainter.setRasterOp( winToTQtRaster( parm[ 0 ] ) );
644}
645
646
647//-----------------------------------------------------------------------------
648void QWinMetaFile::saveDC( long, short* )
649{
650 mPainter.save();
651}
652
653
654//-----------------------------------------------------------------------------
655void QWinMetaFile::restoreDC( long, short *parm )
656{
657 for ( int i=0; i > parm[ 0 ] ; i-- )
658 mPainter.restore();
659}
660
661
662//-----------------------------------------------------------------------------
663void QWinMetaFile::intersectClipRect( long, short* parm )
664{
665/* TODO: better implementation : need QT 3.0.2
666 TQRegion region = mPainter.clipRegion();
667 if ( region.isEmpty() )
668 region = bbox();
669*/
670 TQRegion region( bbox() );
671
672 TQRegion newRegion( parm[ 3 ], parm[ 2 ], parm[ 1 ] - parm[ 3 ], parm[ 0 ] - parm[ 2 ] );
673 region = region.intersect( newRegion );
674
675 mPainter.setClipRegion( region, TQPainter::CoordPainter );
676}
677
678
679//-----------------------------------------------------------------------------
680void QWinMetaFile::excludeClipRect( long, short* parm )
681{
682/* TODO: better implementation : need QT 3.0.2
683 TQRegion region = mPainter.clipRegion();
684 if ( region.isEmpty() )
685 region = bbox();
686*/
687 TQRegion region( bbox() );
688
689 TQRegion newRegion( parm[ 3 ], parm[ 2 ], parm[ 1 ] - parm[ 3 ], parm[ 0 ] - parm[ 2 ] );
690 region = region.subtract( newRegion );
691
692 mPainter.setClipRegion( region, TQPainter::CoordPainter );
693}
694
695
696//-----------------------------------------------------------------------------
697// Text
698//-----------------------------------------------------------------------------
699void QWinMetaFile::setTextColor( long, short* parm )
700{
701 mTextColor = color( parm );
702}
703
704
705//-----------------------------------------------------------------------------
706void QWinMetaFile::setTextAlign( long, short* parm )
707{
708 mTextAlign = parm[ 0 ];
709}
710
711
712//-----------------------------------------------------------------------------
713void QWinMetaFile::textOut( long num, short* parm )
714{
715
716 short *copyParm = new short[ num + 1 ];
717
718 // re-order parameters
719 int idxOffset = (parm[ 0 ] / 2) + 1 + (parm[ 0 ] & 1);
720 copyParm[ 0 ] = parm[ idxOffset ];
721 copyParm[ 1 ] = parm[ idxOffset + 1 ];
722 copyParm[ 2 ] = parm[ 0 ];
723 copyParm[ 3 ] = 0;
724 memcpy( &copyParm[ 4 ], &parm[ 1 ], parm[ 0 ] );
725
726 extTextOut( num + 1, copyParm );
727 delete [] copyParm;
728}
729
730
731//-----------------------------------------------------------------------------
732void QWinMetaFile::extTextOut( long num, short* parm )
733{
734 char* ptStr;
735 int x, y, width, height;
736 int idxOffset;
737
738 if ( parm[ 3 ] != 0 ) // ETO_CLIPPED flag add 4 parameters
739 ptStr = (char*)&parm[ 8 ];
740 else
741 ptStr = (char*)&parm[ 4 ];
742
743 TQCString text( ptStr, parm[ 2 ] + 1 );
744
745 TQFontMetrics fm( mPainter.font() );
746 width = fm.width( text ) + fm.descent(); // because fm.width(text) isn't rigth with Italic text
747 height = fm.height();
748
749 mPainter.save();
750
751 if ( mTextAlign & 0x01 ) { // (left, top) position = current logical position
752 TQPoint pos = mPainter.pos();
753 x = pos.x();
754 y = pos.y();
755 }
756 else { // (left, top) position = parameters
757 x = parm[ 1 ];
758 y = parm[ 0 ];
759 }
760
761 if ( mRotation ) {
762 mPainter.translate( parm[ 1 ], parm[ 0 ]);
763 mPainter.rotate ( mRotation );
764 mPainter.translate( -parm[ 1 ], -parm[ 0 ] );
765 }
766
767 // alignment
768 if ( mTextAlign & 0x06 )
769 x -= ( width / 2 );
770 if ( mTextAlign & 0x08 )
771 y -= (height - fm.descent());
772
773 mPainter.setPen( mTextColor );
774 idxOffset = (parm[ 2 ] / 2) + 4 + (parm[ 2 ] & 1);
775 if ( ( parm[ 2 ] > 1 ) && ( num >= (idxOffset + parm[ 2 ]) ) && ( parm[ 3 ] == 0 ) ) {
776 // offset for each char
777 int left = x;
778 mPainter.drawText( left, y, width, height, TQt::AlignLeft | TQt::AlignTop, text.mid(0, 1) );
779 for ( int i = 1; i < parm[ 2 ] ; i++ ) {
780 left += parm[ idxOffset + i - 1 ];
781 mPainter.drawText( left, y, width, height, TQt::AlignLeft | TQt::AlignTop, text.mid(i, 1) );
782 }
783 }
784 else {
785 mPainter.drawText( x, y, width, height, TQt::AlignLeft | TQt::AlignTop, text );
786 }
787
788 mPainter.restore();
789
790}
791
792
793
794//-----------------------------------------------------------------------------
795// Bitmap
796//-----------------------------------------------------------------------------
797void QWinMetaFile::dibBitBlt( long num, short* parm )
798{
799 if ( num > 9 ) { // DIB image
800 TQImage bmpSrc;
801
802 if ( dibToBmp( bmpSrc, (char*)&parm[ 8 ], (num - 8) * 2 ) ) {
803 long raster = toDWord( parm );
804
805 mPainter.setRasterOp( winToTQtRaster( raster ) );
806
807 // wmf file allow negative width or height
808 mPainter.save();
809 if ( parm[ 5 ] < 0 ) { // width < 0 => horizontal flip
810 TQWMatrix m( -1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F );
811 mPainter.setWorldMatrix( m, true );
812 }
813 if ( parm[ 4 ] < 0 ) { // height < 0 => vertical flip
814 TQWMatrix m( 1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F );
815 mPainter.setWorldMatrix( m, true );
816 }
817 mPainter.drawImage( parm[ 7 ], parm[ 6 ], bmpSrc, parm[ 3 ], parm[ 2 ], parm[ 5 ], parm[ 4 ] );
818 mPainter.restore();
819 }
820 }
821 else {
822 kdDebug() << "QWinMetaFile::dibBitBlt without image: not implemented " << endl;
823 }
824}
825
826
827//-----------------------------------------------------------------------------
828void QWinMetaFile::dibStretchBlt( long num, short* parm )
829{
830 TQImage bmpSrc;
831
832 if ( dibToBmp( bmpSrc, (char*)&parm[ 10 ], (num - 10) * 2 ) ) {
833 long raster = toDWord( parm );
834
835 mPainter.setRasterOp( winToTQtRaster( raster ) );
836
837 // wmf file allow negative width or height
838 mPainter.save();
839 if ( parm[ 7 ] < 0 ) { // width < 0 => horizontal flip
840 TQWMatrix m( -1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F );
841 mPainter.setWorldMatrix( m, true );
842 }
843 if ( parm[ 6 ] < 0 ) { // height < 0 => vertical flip
844 TQWMatrix m( 1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F );
845 mPainter.setWorldMatrix( m, true );
846 }
847 bmpSrc = bmpSrc.copy( parm[ 5 ], parm[ 4 ], parm[ 3 ], parm[ 2 ] );
848 // TODO: scale the bitmap ( TQImage::scale(parm[ 7 ], parm[ 6 ]) is actually too slow )
849
850 mPainter.drawImage( parm[ 9 ], parm[ 8 ], bmpSrc );
851 mPainter.restore();
852 }
853}
854
855
856//-----------------------------------------------------------------------------
857void QWinMetaFile::stretchDib( long num, short* parm )
858{
859 TQImage bmpSrc;
860
861 if ( dibToBmp( bmpSrc, (char*)&parm[ 11 ], (num - 11) * 2 ) ) {
862 long raster = toDWord( parm );
863
864 mPainter.setRasterOp( winToTQtRaster( raster ) );
865
866 // wmf file allow negative width or height
867 mPainter.save();
868 if ( parm[ 8 ] < 0 ) { // width < 0 => horizontal flip
869 TQWMatrix m( -1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F );
870 mPainter.setWorldMatrix( m, true );
871 }
872 if ( parm[ 7 ] < 0 ) { // height < 0 => vertical flip
873 TQWMatrix m( 1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F );
874 mPainter.setWorldMatrix( m, true );
875 }
876 bmpSrc = bmpSrc.copy( parm[ 6 ], parm[ 5 ], parm[ 4 ], parm[ 3 ] );
877 // TODO: scale the bitmap ( TQImage::scale(parm[ 8 ], parm[ 7 ]) is actually too slow )
878
879 mPainter.drawImage( parm[ 10 ], parm[ 9 ], bmpSrc );
880 mPainter.restore();
881 }
882}
883
884
885//-----------------------------------------------------------------------------
886void QWinMetaFile::dibCreatePatternBrush( long num, short* parm )
887{
888 WinObjPatternBrushHandle* handle = new WinObjPatternBrushHandle;
889 addHandle( handle );
890 TQImage bmpSrc;
891
892 if ( dibToBmp( bmpSrc, (char*)&parm[ 2 ], (num - 2) * 2 ) ) {
893 handle->image = bmpSrc;
894 handle->brush.setPixmap( handle->image );
895 }
896}
897
898
899//-----------------------------------------------------------------------------
900// Object handle
901//-----------------------------------------------------------------------------
902void QWinMetaFile::selectObject( long, short* parm )
903{
904 int idx = parm[ 0 ];
905 if ( idx>=0 && idx < MAX_OBJHANDLE && mObjHandleTab[ idx ] )
906 mObjHandleTab[ idx ]->apply( mPainter );
907}
908
909
910//-----------------------------------------------------------------------------
911void QWinMetaFile::deleteObject( long, short* parm )
912{
913 deleteHandle( parm[ 0 ] );
914}
915
916
917//-----------------------------------------------------------------------------
919{
920 // allocation of an empty object (to keep object counting in sync)
921 WinObjPenHandle* handle = new WinObjPenHandle;
922 addHandle( handle );
923 kdDebug() << "QWinMetaFile: unimplemented createObject " << endl;
924}
925
926
927//-----------------------------------------------------------------------------
928void QWinMetaFile::createBrushIndirect( long, short* parm )
929{
930 static TQt::BrushStyle hatchedStyleTab[] =
931 {
932 TQt::HorPattern,
933 TQt::FDiagPattern,
934 TQt::BDiagPattern,
935 TQt::CrossPattern,
936 TQt::DiagCrossPattern
937 };
938 static TQt::BrushStyle styleTab[] =
939 { TQt::SolidPattern,
940 TQt::NoBrush,
941 TQt::FDiagPattern, /* hatched */
942 TQt::Dense4Pattern, /* should be custom bitmap pattern */
943 TQt::HorPattern, /* should be BS_INDEXED (?) */
944 TQt::VerPattern, /* should be device-independent bitmap */
945 TQt::Dense6Pattern, /* should be device-independent packed-bitmap */
946 TQt::Dense2Pattern, /* should be BS_PATTERN8x8 */
947 TQt::Dense3Pattern /* should be device-independent BS_DIBPATTERN8x8 */
948 };
949 TQt::BrushStyle style;
950 short arg;
951 WinObjBrushHandle* handle = new WinObjBrushHandle;
952 addHandle( handle );
953
954 arg = parm[ 0 ];
955 if ( arg==2 )
956 {
957 arg = parm[ 3 ];
958 if ( arg>=0 && arg<5 ) style = hatchedStyleTab[ arg ];
959 else
960 {
961 kdDebug() << "QWinMetaFile::createBrushIndirect: invalid hatched brush " << arg << endl;
962 style = TQt::SolidPattern;
963 }
964 }
965 else if ( arg>=0 && arg<9 )
966 style = styleTab[ arg ];
967 else
968 {
969 kdDebug() << "QWinMetaFile::createBrushIndirect: invalid brush " << arg << endl;
970 style = TQt::SolidPattern;
971 }
972 handle->brush.setStyle( style );
973 handle->brush.setColor( color( parm+1 ) );
974}
975
976
977//-----------------------------------------------------------------------------
978void QWinMetaFile::createPenIndirect( long, short* parm )
979{
980 static TQt::PenStyle styleTab[] =
981 { TQt::SolidLine, TQt::DashLine, TQt::DotLine, TQt::DashDotLine, TQt::DashDotDotLine,
982 TQt::NoPen, TQt::SolidLine };
983 TQt::PenStyle style;
984 WinObjPenHandle* handle = new WinObjPenHandle;
985 addHandle( handle );
986
987 if ( parm[ 0 ]>=0 && parm[ 0 ]<6 ) style=styleTab[ parm[ 0 ] ];
988 else
989 {
990 kdDebug() << "QWinMetaFile::createPenIndirect: invalid pen " << parm[ 0 ] << endl;
991 style = TQt::SolidLine;
992 }
993
994 handle->pen.setStyle( style );
995 handle->pen.setColor( color( parm+3 ) );
996 handle->pen.setCapStyle( TQt::RoundCap );
997
998 //int width = 0;
999 // TODO : width of pen proportional to device context width
1000 // DOESN'T WORK
1001/*
1002 TQRect devRec;
1003 devRec = mPainter.xForm( mBBox );
1004 width = ( parm[ 0 ] * devRec.width() ) / mBBox.width() ;
1005 kdDebug() << "CreatePenIndirect: " << endl;
1006 kdDebug() << " log coord. : " << mBBox.width() << " " << mBBox.height() << endl;
1007 kdDebug() << " log. pen : " << parm[ 1 ] << " " << parm[ 2 ] << endl;
1008 kdDebug() << " dev. pen : " << width << endl;
1009 handle->pen.setWidth( width );
1010*/
1011}
1012
1013
1014//-----------------------------------------------------------------------------
1015void QWinMetaFile::createFontIndirect( long , short* parm)
1016{
1017 WinObjFontHandle* handle = new WinObjFontHandle;
1018 addHandle( handle );
1019
1020 TQString family( (const char*)&parm[ 9 ] );
1021
1022 mRotation = -parm[ 2 ] / 10; // text rotation (in 1/10 degree)
1023 // TODO: memorisation of rotation in object Font
1024 handle->font.setFamily( family );
1025 handle->font.setFixedPitch( ((parm[ 8 ] & 0x01) == 0) );
1026 // TODO: investigation why some test case need -2. (size of font in logical point)
1027 handle->font.setPointSize( TQABS(parm[ 0 ]) - 2 );
1028 handle->font.setWeight( (parm[ 4 ] >> 3) );
1029 handle->font.setItalic( (parm[ 5 ] & 0x01) );
1030 handle->font.setUnderline( (parm[ 5 ] & 0x100) );
1031}
1032
1033
1034//-----------------------------------------------------------------------------
1035// Misc
1036//-----------------------------------------------------------------------------
1037void QWinMetaFile::noop( long, short* )
1038{
1039}
1040
1041
1042void QWinMetaFile::end( long, short* )
1043{
1044 // end of file :
1045// kdDebug() << "END bbox=( " << mBBox.left() << "; " << mBBox.top() << "; " << mBBox.width() << "; " << mBBox.height() << ")" << endl;
1046}
1047
1048
1049//-----------------------------------------------------------------------------
1050unsigned short QWinMetaFile::calcCheckSum( WmfPlaceableHeader* apmfh )
1051{
1052 WORD* lpWord;
1053 WORD wResult, i;
1054
1055 // Start with the first word
1056 wResult = *( lpWord = ( WORD* )( apmfh ) );
1057 // XOR in each of the other 9 words
1058 for( i=1; i<=9; i++ )
1059 {
1060 wResult ^= lpWord[ i ];
1061 }
1062 return wResult;
1063}
1064
1065
1066//-----------------------------------------------------------------------------
1067int QWinMetaFile::findFunc( unsigned short aFunc ) const
1068{
1069 int i;
1070
1071 for ( i=0; metaFuncTab[ i ].name; i++ )
1072 if ( metaFuncTab[ i ].func == aFunc ) return i;
1073
1074 // here : unknown function
1075 return i;
1076}
1077
1078//-----------------------------------------------------------------------------
1079TQPointArray* QWinMetaFile::pointArray( short num, short* parm )
1080{
1081 int i;
1082
1083 mPoints.resize( num );
1084
1085 for ( i=0; i<num; i++, parm+=2 )
1086 mPoints.setPoint( i, parm[ 0 ], parm[ 1 ] );
1087
1088 return &mPoints;
1089}
1090
1091//-----------------------------------------------------------------------------
1092unsigned int QWinMetaFile::toDWord( short* parm )
1093{
1094 unsigned int l;
1095
1096#if !defined( WORDS_BIGENDIAN )
1097 l = *( unsigned int* )( parm );
1098#else
1099 char *bytes;
1100 char swap[ 4 ];
1101 bytes = ( char* )parm;
1102 swap[ 0 ] = bytes[ 2 ];
1103 swap[ 1 ] = bytes[ 3 ];
1104 swap[ 2 ] = bytes[ 0 ];
1105 swap[ 3 ] = bytes[ 1 ];
1106 l = *( unsigned int* )( swap );
1107#endif
1108
1109 return l;
1110}
1111
1112
1113//-----------------------------------------------------------------------------
1114TQColor QWinMetaFile::color( short* parm )
1115{
1116 unsigned int colorRef;
1117 int red, green, blue;
1118
1119 colorRef = toDWord( parm ) & 0xffffff;
1120 red = colorRef & 255;
1121 green = ( colorRef>>8 ) & 255;
1122 blue = ( colorRef>>16 ) & 255;
1123
1124 return TQColor( red, green, blue );
1125}
1126
1127
1128//-----------------------------------------------------------------------------
1129void QWinMetaFile::xyToAngle( int xStart, int yStart, int xEnd, int yEnd, int& angleStart, int& angleLength )
1130{
1131 float aStart, aLength;
1132
1133 aStart = atan2( yStart, xStart );
1134 aLength = atan2( yEnd, xEnd ) - aStart;
1135
1136 angleStart = (int)(aStart * 2880 / 3.14166);
1137 angleLength = (int)(aLength * 2880 / 3.14166);
1138 if ( angleLength < 0 ) angleLength = 5760 + angleLength;
1139}
1140
1141
1142//-----------------------------------------------------------------------------
1143void QWinMetaFile::addHandle( WinObjHandle* handle )
1144{
1145 int idx;
1146
1147 for ( idx=0; idx < MAX_OBJHANDLE ; idx++ )
1148 if ( mObjHandleTab[ idx ] == NULL ) break;
1149
1150 if ( idx < MAX_OBJHANDLE )
1151 mObjHandleTab[ idx ] = handle;
1152 else
1153 kdDebug() << "QWinMetaFile error: handle table full !" << endl;
1154}
1155
1156//-----------------------------------------------------------------------------
1157void QWinMetaFile::deleteHandle( int idx )
1158{
1159 if ( idx >= 0 && idx < MAX_OBJHANDLE && mObjHandleTab[ idx ] )
1160 {
1161 delete mObjHandleTab[ idx ];
1162 mObjHandleTab[ idx ] = NULL;
1163 }
1164}
1165
1166//-----------------------------------------------------------------------------
1167TQt::RasterOp QWinMetaFile::winToTQtRaster( short parm ) const
1168{
1169 static const TQt::RasterOp opTab[] =
1170 {
1171 TQt::CopyROP,
1172 TQt::ClearROP, TQt::NandROP, TQt::NotAndROP, TQt::NotCopyROP,
1173 TQt::AndNotROP, TQt::NotROP, TQt::XorROP, TQt::NorROP,
1174 TQt::AndROP, TQt::NotXorROP, TQt::NopROP, TQt::NotOrROP,
1175 TQt::CopyROP, TQt::OrNotROP, TQt::OrROP, TQt::SetROP
1176 };
1177
1178 if ( parm > 0 && parm <= 16 )
1179 return opTab[ parm ];
1180 else
1181 return TQt::CopyROP;
1182}
1183
1184//-----------------------------------------------------------------------------
1185TQt::RasterOp QWinMetaFile::winToTQtRaster( long parm ) const
1186{
1187 /* TODO: Ternary raster operations
1188 0x00C000CA dest = (source AND pattern)
1189 0x00F00021 dest = pattern
1190 0x00FB0A09 dest = DPSnoo
1191 0x005A0049 dest = pattern XOR dest */
1192 static const struct OpTab
1193 {
1194 long winRasterOp;
1195 TQt::RasterOp qtRasterOp;
1196 } opTab[] =
1197 {
1198 { 0x00CC0020, TQt::CopyROP },
1199 { 0x00EE0086, TQt::OrROP },
1200 { 0x008800C6, TQt::AndROP },
1201 { 0x00660046, TQt::XorROP },
1202 { 0x00440328, TQt::AndNotROP },
1203 { 0x00330008, TQt::NotCopyROP },
1204 { 0x001100A6, TQt::NandROP },
1205 { 0x00C000CA, TQt::CopyROP },
1206 { 0x00BB0226, TQt::NotOrROP },
1207 { 0x00F00021, TQt::CopyROP },
1208 { 0x00FB0A09, TQt::CopyROP },
1209 { 0x005A0049, TQt::CopyROP },
1210 { 0x00550009, TQt::NotROP },
1211 { 0x00000042, TQt::ClearROP },
1212 { 0x00FF0062, TQt::SetROP }
1213 };
1214
1215 int i;
1216 for ( i=0 ; i < 15 ; i++ )
1217 if ( opTab[ i ].winRasterOp == parm )
1218 break;
1219
1220 if ( i < 15 )
1221 return opTab[ i ].qtRasterOp;
1222 else
1223 return TQt::CopyROP;
1224}
1225
1226//-----------------------------------------------------------------------------
1227bool QWinMetaFile::dibToBmp( TQImage& bmp, const char* dib, long size )
1228{
1229 typedef struct _BMPFILEHEADER {
1230 WORD bmType;
1231 DWORD bmSize;
1232 WORD bmReserved1;
1233 WORD bmReserved2;
1234 DWORD bmOffBits;
1235 } BMPFILEHEADER;
1236
1237 int sizeBmp = size + 14;
1238
1239 TQByteArray pattern( sizeBmp ); // BMP header and DIB data
1240 pattern.fill(0);
1241 memcpy( &pattern[ 14 ], dib, size );
1242
1243 // add BMP header
1244 BMPFILEHEADER* bmpHeader;
1245 bmpHeader = (BMPFILEHEADER*)((const char*)pattern);
1246 bmpHeader->bmType = 0x4D42;
1247 bmpHeader->bmSize = sizeBmp;
1248
1249 if ( !bmp.loadFromData( (const uchar*)bmpHeader, pattern.size(), "BMP" ) ) {
1250 kdDebug() << "QWinMetaFile::dibToBmp: invalid bitmap " << endl;
1251 return false;
1252 }
1253 return true;
1254}
1255
void polygon(long num, short *parms)
draw polygon
Definition qwmf.cpp:482
void chord(long num, short *parms)
draw chord
Definition qwmf.cpp:581
TQRect bbox(void) const
Definition qwmf.h:87
void setRop(long num, short *parms)
Set raster operation mode.
Definition qwmf.cpp:641
void polyPolygon(long num, short *parms)
draw a list of polygons
Definition qwmf.cpp:492
void setBkColor(long num, short *parms)
set background pen color
Definition qwmf.cpp:616
void saveDC(long num, short *parms)
save device context
Definition qwmf.cpp:648
void createEmptyObject(long num, short *parms)
create an empty object in the object list
Definition qwmf.cpp:918
void dibBitBlt(long num, short *parms)
copies a DIB into a dest location
Definition qwmf.cpp:797
void end(long, short *)
end of meta file
Definition qwmf.cpp:1042
void restoreDC(long num, short *parms)
restore device context
Definition qwmf.cpp:655
void textOut(long num, short *parms)
draw text
Definition qwmf.cpp:713
void setWindowExt(long num, short *parms)
set window extents
Definition qwmf.cpp:426
bool dibToBmp(TQImage &bmp, const char *dib, long size)
Converts DIB to BMP.
Definition qwmf.cpp:1227
void createBrushIndirect(long num, short *parms)
create a logical brush
Definition qwmf.cpp:928
void setTextColor(long num, short *parms)
set text color
Definition qwmf.cpp:699
TQColor color(short *parm)
Returns color given by the two parameters.
Definition qwmf.cpp:1114
void createPenIndirect(long num, short *parms)
create a logical pen
Definition qwmf.cpp:978
void setPolyFillMode(long num, short *parms)
set polygon fill mode
Definition qwmf.cpp:609
void createFontIndirect(long num, short *parms)
create a logical font
Definition qwmf.cpp:1015
void dibCreatePatternBrush(long num, short *parms)
create a pattern brush
Definition qwmf.cpp:886
void setBkMode(long num, short *parms)
set background pen mode
Definition qwmf.cpp:623
void setPixel(long num, short *parms)
set a pixel
Definition qwmf.cpp:631
void setWindowOrg(long num, short *parms)
set window origin
Definition qwmf.cpp:407
void addHandle(WinObjHandle *)
Handle win-object-handles.
Definition qwmf.cpp:1143
virtual int findFunc(unsigned short aFunc) const
Find function in metafunc table by metafile-function.
Definition qwmf.cpp:1067
void excludeClipRect(long num, short *parms)
delete a clipping rectangle of the original region
Definition qwmf.cpp:680
void dibStretchBlt(long num, short *parms)
stretches a DIB into a dest location
Definition qwmf.cpp:828
void setTextAlign(long num, short *parms)
set text alignment
Definition qwmf.cpp:706
TQt::RasterOp winToTQtRaster(short parm) const
Convert windows rasterOp in TQt rasterOp.
Definition qwmf.cpp:1167
void ellipse(long num, short *parms)
draw ellipse
Definition qwmf.cpp:475
void arc(long num, short *parms)
draw arc
Definition qwmf.cpp:567
virtual bool paint(const TQPaintDevice *target, bool absolute=false)
Paint metafile to given paint-device using absolute or relative coordinate.
Definition qwmf.cpp:334
void xyToAngle(int xStart, int yStart, int xEnd, int yEnd, int &angle, int &aLength)
Convert (x1,y1) and (x2, y2) positions in angle and angleLength.
Definition qwmf.cpp:1129
unsigned int toDWord(short *parm)
Converts two parameters to long.
Definition qwmf.cpp:1092
TQPointArray * pointArray(short num, short *parms)
Fills given parms into mPoints.
Definition qwmf.cpp:1079
void polyline(long num, short *parms)
draw series of lines
Definition qwmf.cpp:535
void lineTo(long num, short *parms)
draw line to coord
Definition qwmf.cpp:461
virtual bool load(const TQString &fileName)
Load WMF file.
Definition qwmf.cpp:135
void deleteObject(long num, short *parms)
Free object handle.
Definition qwmf.cpp:911
void roundRect(long num, short *parms)
draw round rectangle
Definition qwmf.cpp:552
void moveTo(long num, short *parms)
move pen to coord
Definition qwmf.cpp:468
void selectObject(long num, short *parms)
Activate object handle.
Definition qwmf.cpp:902
void intersectClipRect(long num, short *parms)
clipping region is the intersection of this region and the original region
Definition qwmf.cpp:663
void pie(long num, short *parms)
draw pie
Definition qwmf.cpp:595
unsigned short calcCheckSum(WmfPlaceableHeader *)
Calculate header checksum.
Definition qwmf.cpp:1050
void noop(long, short *)
nothing to do
Definition qwmf.cpp:1037
void rectangle(long num, short *parms)
draw a rectangle
Definition qwmf.cpp:545