lib

qwmf.h
1/* Windows Meta File Loader
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#ifndef qwmf_h
20#define qwmf_h
21
22#include <tqstring.h>
23#include <tqpainter.h>
24#include <tqwmatrix.h>
25#include <tqpointarray.h>
26#include <tqpen.h>
27#include <tqcolor.h>
28#include <tqimage.h>
29#include <tqrect.h>
30
31class TQBuffer;
32class TQString;
33class WmfCmd;
34class WinObjHandle;
35class WinObjPenHandle;
36class WinObjBrushHandle;
37struct WmfPlaceableHeader;
38
50
51
52class QWinMetaFile
53{
54public:
55 QWinMetaFile();
56 virtual ~QWinMetaFile();
57
62 virtual bool load( const TQString &fileName );
63 virtual bool load( TQBuffer &buffer );
64
72 virtual bool paint( const TQPaintDevice* target, bool absolute=false );
73
77 bool isPlaceable( void ) const { return mIsPlaceable; }
78
82 bool isEnhanced( void ) const { return mIsEnhanced; }
83
87 TQRect bbox( void ) const { return mBBox; }
88
89public: // should be protected but cannot
90 /* Metafile painter methods */
91
93 void setWindowOrg( long num, short* parms );
95 void setWindowExt( long num, short* parms );
96
97 /****************** Drawing *******************/
99 void lineTo( long num, short* parms );
101 void moveTo( long num, short* parms );
103 void ellipse( long num, short* parms );
105 void polygon( long num, short* parms );
107 void polyPolygon( long num, short* parms );
109 void polyline( long num, short* parms );
111 void rectangle( long num, short* parms );
113 void roundRect( long num, short* parms );
115 void arc( long num, short* parms );
117 void chord( long num, short* parms );
119 void pie( long num, short* parms );
121 void setPolyFillMode( long num, short* parms );
123 void setBkColor( long num, short* parms );
125 void setBkMode( long num, short* parms );
127 void setPixel( long num, short* parms );
129 void setRop( long num, short* parms );
131 void saveDC( long num, short* parms );
133 void restoreDC( long num, short* parms );
135 void intersectClipRect( long num, short* parms );
137 void excludeClipRect( long num, short* parms );
138
139 /****************** Text *******************/
141 void setTextColor( long num, short* parms );
143 void setTextAlign( long num, short* parms );
145 void textOut( long num, short* parms );
146 void extTextOut( long num, short* parms );
147
148 /****************** Bitmap *******************/
150 void dibBitBlt( long num, short* parms );
152 void dibStretchBlt( long num, short* parms );
153 void stretchDib( long num, short* parms );
155 void dibCreatePatternBrush( long num, short* parms );
156
157 /****************** Object handle *******************/
159 void selectObject( long num, short* parms );
161 void deleteObject( long num, short* parms );
163 void createEmptyObject( long num, short* parms );
165 void createBrushIndirect( long num, short* parms );
167 void createPenIndirect( long num, short* parms );
169 void createFontIndirect( long num, short* parms );
170
171 /****************** misc *******************/
173 void noop( long , short* );
175 void end( long /*num*/, short* /*parms*/ );
177 int dpi( void ) const { return mDpi; }
178
179protected:
181 unsigned short calcCheckSum( WmfPlaceableHeader* );
182
185 virtual int findFunc( unsigned short aFunc ) const;
186
188 TQPointArray* pointArray( short num, short* parms );
189
191 TQColor color( short* parm );
192
194 unsigned int toDWord( short* parm );
195
197 void xyToAngle( int xStart, int yStart, int xEnd, int yEnd, int& angle, int& aLength );
198
200 void addHandle( WinObjHandle* );
201 void deleteHandle( int );
202
204 TQt::RasterOp winToTQtRaster( short parm ) const;
205 TQt::RasterOp winToTQtRaster( long parm ) const;
206
208 bool dibToBmp( TQImage& bmp, const char* dib, long size);
209
210protected:
211 TQPainter mPainter;
212 bool mIsPlaceable, mIsEnhanced, mValid;
213
214 // coordinate system
215 bool mAbsoluteCoord;
216 TQWMatrix mInternalWorldMatrix; // memorisation of WMF matrix transformation
217 TQRect mHeaderBoundingBox;
218 TQRect mBBox;
219
220 // information shared between Metafile Functions
221 TQColor mTextColor;
222 int mTextAlign, mRotation;
223 bool mWinding;
224
225 WmfCmd* mFirstCmd;
226 WinObjHandle** mObjHandleTab;
227 TQPointArray mPoints;
228 int mDpi;
229};
230
231#endif /*qwmf_h*/
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
bool isPlaceable(void) const
Definition qwmf.h:77
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
bool isEnhanced(void) const
Definition qwmf.h:82
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
int dpi(void) const
Resolution of the image in dots per inch.
Definition qwmf.h:177