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.
34 struct WmfPlaceableHeader
;
37 * QWinMetaFile is a WMF viewer based on Qt toolkit
38 * How to use QWinMetaFile :
41 * QPicture pic; // or QImage pic;
42 * if ( wmf.load( filename )
52 virtual ~QWinMetaFile();
56 * @return true on success.
58 virtual bool load(const QString
&fileName
);
59 virtual bool load(QBuffer
&buffer
);
62 * Paint metafile to given paint-device using absolute or relative coordinate.
63 * - absolute coord. Reset the world transfomation Matrix
64 * - relative coord. Use the existing world transfomation Matrix
66 * @return true on success.
68 virtual bool paint(QPaintDevice
* target
, bool absolute
= false);
71 * @return true if the metafile is placeable.
73 bool isPlaceable(void) const {
78 * @return true if the metafile is enhanced.
80 bool isEnhanced(void) const {
85 * @return bounding rectangle
87 QRect
bbox(void) const {
91 public: // should be protected but cannot
92 /* Metafile painter methods */
94 /** set window origin */
95 void setWindowOrg(long num
, short* parms
);
96 /** set window extents */
97 void setWindowExt(long num
, short* parms
);
99 /****************** Drawing *******************/
100 /** draw line to coord */
101 void lineTo(long num
, short* parms
);
102 /** move pen to coord */
103 void moveTo(long num
, short* parms
);
105 void ellipse(long num
, short* parms
);
107 void polygon(long num
, short* parms
);
108 /** draw a list of polygons */
109 void polyPolygon(long num
, short* parms
);
110 /** draw series of lines */
111 void polyline(long num
, short* parms
);
112 /** draw a rectangle */
113 void rectangle(long num
, short* parms
);
114 /** draw round rectangle */
115 void roundRect(long num
, short* parms
);
117 void arc(long num
, short* parms
);
119 void chord(long num
, short* parms
);
121 void pie(long num
, short* parms
);
122 /** set polygon fill mode */
123 void setPolyFillMode(long num
, short* parms
);
124 /** set background pen color */
125 void setBkColor(long num
, short* parms
);
126 /** set background pen mode */
127 void setBkMode(long num
, short* parms
);
129 void setPixel(long num
, short* parms
);
130 /** Set raster operation mode */
131 void setRop(long num
, short* parms
);
132 /** save device context */
133 void saveDC(long num
, short* parms
);
134 /** restore device context */
135 void restoreDC(long num
, short* parms
);
136 /** clipping region is the intersection of this region and the original region */
137 void intersectClipRect(long num
, short* parms
);
138 /** delete a clipping rectangle of the original region */
139 void excludeClipRect(long num
, short* parms
);
141 /****************** Text *******************/
142 /** set text color */
143 void setTextColor(long num
, short* parms
);
144 /** set text alignment */
145 void setTextAlign(long num
, short* parms
);
147 void textOut(long num
, short* parms
);
148 void extTextOut(long num
, short* parms
);
150 /****************** Bitmap *******************/
151 /** copies a DIB into a dest location */
152 void dibBitBlt(long num
, short* parms
);
153 /** stretches a DIB into a dest location */
154 void dibStretchBlt(long num
, short* parms
);
155 void stretchDib(long num
, short* parms
);
156 /** create a pattern brush */
157 void dibCreatePatternBrush(long num
, short* parms
);
159 /****************** Object handle *******************/
160 /** Activate object handle */
161 void selectObject(long num
, short* parms
);
162 /** Free object handle */
163 void deleteObject(long num
, short* parms
);
164 /** create an empty object in the object list */
165 void createEmptyObject(long num
, short* parms
);
166 /** create a logical brush */
167 void createBrushIndirect(long num
, short* parms
);
168 /** create a logical pen */
169 void createPenIndirect(long num
, short* parms
);
170 /** create a logical font */
171 void createFontIndirect(long num
, short* parms
);
173 /****************** misc *******************/
175 void noop(long , short*);
176 /** end of meta file */
177 void end(long /*num*/, short* /*parms*/);
178 /** Resolution of the image in dots per inch */
179 int dpi(void) const {
184 /** Calculate header checksum */
185 unsigned short calcCheckSum(WmfPlaceableHeader
*);
187 /** Find function in metafunc table by metafile-function.
188 Returns index or -1 if not found. */
189 virtual int findFunc(unsigned short aFunc
) const;
191 /** Fills given parms into mPoints. */
192 QPolygon
* pointArray(short num
, short* parms
);
194 /** Returns color given by the two parameters */
195 QColor
color(short* parm
);
197 /** Converts two parameters to long */
198 unsigned int toDWord(short* parm
);
200 /** Convert (x1,y1) and (x2, y2) positions in angle and angleLength */
201 void xyToAngle(int xStart
, int yStart
, int xEnd
, int yEnd
, int& angle
, int& aLength
);
203 /** Handle win-object-handles */
204 void addHandle(WinObjHandle
*);
205 void deleteHandle(int);
207 /** Convert windows rasterOp in QT rasterOp */
208 QPainter::CompositionMode
winToQtComposition(short parm
) const;
209 QPainter::CompositionMode
winToQtComposition(long parm
) const;
211 /** Converts DIB to BMP */
212 bool dibToBmp(QImage
& bmp
, const char* dib
, long size
);
216 bool mIsPlaceable
, mIsEnhanced
, mValid
;
220 QMatrix mInternalWorldMatrix
; // memorisation of WMF matrix transformation
221 QRect mHeaderBoundingBox
;
224 // information shared between Metafile Functions
226 int mTextAlign
, mRotation
;
230 WinObjHandle
** mObjHandleTab
;