1 /* Windows Meta File Loader
3 * Copyright ( C ) 1998 Stefan Taferner
4 * Modified 2002 thierry lorthiois
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.
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.
33 struct WmfPlaceableHeader
;
36 * QWinMetaFile is a WMF viewer based on Qt toolkit
37 * How to use QWinMetaFile :
40 * QPicture pic; // or QImage pic;
41 * if ( wmf.load( filename )
50 virtual ~QWinMetaFile();
54 * @return true on success.
56 virtual bool load(const QString
&fileName
);
57 virtual bool load(QBuffer
&buffer
);
60 * Paint metafile to given paint-device using absolute or relative coordinate.
61 * - absolute coord. Reset the world transfomation Matrix
62 * - relative coord. Use the existing world transfomation Matrix
64 * @return true on success.
66 virtual bool paint(QPaintDevice
*target
, bool absolute
= false);
69 * @return true if the metafile is placeable.
71 bool isPlaceable(void) const
77 * @return true if the metafile is enhanced.
79 bool isEnhanced(void) const
85 * @return bounding rectangle
87 QRect
bbox(void) const
92 public: // should be protected but cannot
93 /* Metafile painter methods */
95 /** set window origin */
96 void setWindowOrg(long num
, short *parms
);
97 /** set window extents */
98 void setWindowExt(long num
, short *parms
);
100 /****************** Drawing *******************/
101 /** draw line to coord */
102 void lineTo(long num
, short *parms
);
103 /** move pen to coord */
104 void moveTo(long num
, short *parms
);
106 void ellipse(long num
, short *parms
);
108 void polygon(long num
, short *parms
);
109 /** draw a list of polygons */
110 void polyPolygon(long num
, short *parms
);
111 /** draw series of lines */
112 void polyline(long num
, short *parms
);
113 /** draw a rectangle */
114 void rectangle(long num
, short *parms
);
115 /** draw round rectangle */
116 void roundRect(long num
, short *parms
);
118 void arc(long num
, short *parms
);
120 void chord(long num
, short *parms
);
122 void pie(long num
, short *parms
);
123 /** set polygon fill mode */
124 void setPolyFillMode(long num
, short *parms
);
125 /** set background pen color */
126 void setBkColor(long num
, short *parms
);
127 /** set background pen mode */
128 void setBkMode(long num
, short *parms
);
130 void setPixel(long num
, short *parms
);
131 /** Set raster operation mode */
132 void setRop(long num
, short *parms
);
133 /** save device context */
134 void saveDC(long num
, short *parms
);
135 /** restore device context */
136 void restoreDC(long num
, short *parms
);
137 /** clipping region is the intersection of this region and the original region */
138 void intersectClipRect(long num
, short *parms
);
139 /** delete a clipping rectangle of the original region */
140 void excludeClipRect(long num
, short *parms
);
142 /****************** Text *******************/
143 /** set text color */
144 void setTextColor(long num
, short *parms
);
145 /** set text alignment */
146 void setTextAlign(long num
, short *parms
);
148 void textOut(long num
, short *parms
);
149 void extTextOut(long num
, short *parms
);
151 /****************** Bitmap *******************/
152 /** copies a DIB into a dest location */
153 void dibBitBlt(long num
, short *parms
);
154 /** stretches a DIB into a dest location */
155 void dibStretchBlt(long num
, short *parms
);
156 void stretchDib(long num
, short *parms
);
157 /** create a pattern brush */
158 void dibCreatePatternBrush(long num
, short *parms
);
160 /****************** Object handle *******************/
161 /** Activate object handle */
162 void selectObject(long num
, short *parms
);
163 /** Free object handle */
164 void deleteObject(long num
, short *parms
);
165 /** create an empty object in the object list */
166 void createEmptyObject(long num
, short *parms
);
167 /** create a logical brush */
168 void createBrushIndirect(long num
, short *parms
);
169 /** create a logical pen */
170 void createPenIndirect(long num
, short *parms
);
171 /** create a logical font */
172 void createFontIndirect(long num
, short *parms
);
174 /****************** misc *******************/
176 void noop(long, short *);
177 /** end of meta file */
178 void end(long /*num*/, short * /*parms*/);
179 /** Resolution of the image in dots per inch */
186 /** Calculate header checksum */
187 unsigned short calcCheckSum(WmfPlaceableHeader
*);
189 /** Find function in metafunc table by metafile-function.
190 Returns index or -1 if not found. */
191 virtual int findFunc(unsigned short aFunc
) const;
193 /** Fills given parms into mPoints. */
194 QPolygon
*pointArray(short num
, short *parms
);
196 /** Returns color given by the two parameters */
197 QColor
color(short *parm
);
199 /** Converts two parameters to long */
200 unsigned int toDWord(short *parm
);
202 /** Convert (x1,y1) and (x2, y2) positions in angle and angleLength */
203 void xyToAngle(int xStart
, int yStart
, int xEnd
, int yEnd
, int &angle
, int &aLength
);
205 /** Handle win-object-handles */
206 void addHandle(WinObjHandle
*);
207 void deleteHandle(int);
209 /** Convert windows rasterOp in QT rasterOp */
210 QPainter::CompositionMode
winToQtComposition(short parm
) const;
211 QPainter::CompositionMode
winToQtComposition(long parm
) const;
213 /** Converts DIB to BMP */
214 bool dibToBmp(QImage
&bmp
, const char *dib
, long size
);
218 bool mIsPlaceable
, mIsEnhanced
, mValid
;
222 QMatrix mInternalWorldMatrix
; // memorisation of WMF matrix transformation
223 QRect mHeaderBoundingBox
;
226 // information shared between Metafile Functions
228 int mTextAlign
, mRotation
;
232 WinObjHandle
**mObjHandleTab
;