blob: 21f60a85c3811d34dd0ce431d2e58ee8484fd1af [file] [log] [blame]
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001/*
2 * Metafile driver initialisation functions
3 *
4 * Copyright 1996 Alexandre Julliard
5 */
6
Marcus Meissner317af321999-02-17 13:51:06 +00007#include "windef.h"
8#include "wine/winbase16.h"
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00009#include "dc.h"
10#include "heap.h"
11#include "global.h"
12#include "metafile.h"
Marcus Meissner317af321999-02-17 13:51:06 +000013#include "metafiledrv.h"
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000014#include "debug.h"
15
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000016DEFAULT_DEBUG_CHANNEL(metafile)
17
Alexandre Julliard54c27111998-03-29 19:44:57 +000018#include <string.h>
19
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000020static const DC_FUNCTIONS MFDRV_Funcs =
21{
Huw D M Daviese39b6761999-05-17 16:20:51 +000022 NULL, /* pAbortDoc */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000023 MFDRV_Arc, /* pArc */
Alexandre Julliard75d86e11996-11-17 18:59:11 +000024 MFDRV_BitBlt, /* pBitBlt */
Huw D M Davies87f87bf1998-10-28 09:53:53 +000025 NULL, /* pBitmapBits */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000026 MFDRV_Chord, /* pChord */
Huw D M Davies87f87bf1998-10-28 09:53:53 +000027 NULL, /* pCreateBitmap */
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000028 NULL, /* no implementation */ /* pCreateDC */
Patrik Stridvallb87fe2e1999-04-01 08:16:08 +000029 NULL, /* pCreateDIBSection */
30 NULL, /* pCreateDIBSection16 */
Huw D M Daviese39b6761999-05-17 16:20:51 +000031 NULL, /* no implementation */ /* pDeleteDC */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000032 NULL, /* pDeleteObject */
Huw D M Daviese39b6761999-05-17 16:20:51 +000033 NULL, /* pDeviceCapabilities */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000034 MFDRV_Ellipse, /* pEllipse */
Huw D M Daviese39b6761999-05-17 16:20:51 +000035 NULL, /* pEndDoc */
36 NULL, /* pEndPage */
Alexandre Julliard889f7421997-04-15 17:19:52 +000037 NULL, /* pEnumDeviceFonts */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000038 NULL, /* pEscape */
Huw D M Davies7603dea1999-04-25 09:24:23 +000039 MFDRV_ExcludeClipRect, /* pExcludeClipRect */
Huw D M Daviese39b6761999-05-17 16:20:51 +000040 NULL, /* pExtDeviceMode */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000041 MFDRV_ExtFloodFill, /* pExtFloodFill */
42 MFDRV_ExtTextOut, /* pExtTextOut */
Huw D M Davies7603dea1999-04-25 09:24:23 +000043 MFDRV_FillRgn, /* pFillRgn */
44 MFDRV_FrameRgn, /* pFrameRgn */
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000045 NULL, /* pGetCharWidth */
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000046 NULL, /* no implementation */ /* pGetPixel */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000047 NULL, /* pGetTextExtentPoint */
48 NULL, /* pGetTextMetrics */
Huw D M Davies7603dea1999-04-25 09:24:23 +000049 MFDRV_IntersectClipRect, /* pIntersectClipRect */
50 MFDRV_InvertRgn, /* pInvertRgn */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000051 MFDRV_LineTo, /* pLineTo */
Huw D M Daviesd6a91b71998-12-02 10:29:04 +000052 NULL, /* pLoadOEMResource */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000053 MFDRV_MoveToEx, /* pMoveToEx */
Huw D M Davies7603dea1999-04-25 09:24:23 +000054 MFDRV_OffsetClipRgn, /* pOffsetClipRgn */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000055 MFDRV_OffsetViewportOrg, /* pOffsetViewportOrg */
56 MFDRV_OffsetWindowOrg, /* pOffsetWindowOrg */
Alexandre Julliard0623a6f1998-01-18 18:01:49 +000057 MFDRV_PaintRgn, /* pPaintRgn */
Alexandre Julliard75d86e11996-11-17 18:59:11 +000058 MFDRV_PatBlt, /* pPatBlt */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000059 MFDRV_Pie, /* pPie */
60 MFDRV_PolyPolygon, /* pPolyPolygon */
Alexandre Julliard46ea8b31998-05-03 19:01:20 +000061 NULL, /* pPolyPolyline */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000062 MFDRV_Polygon, /* pPolygon */
63 MFDRV_Polyline, /* pPolyline */
Alexandre Julliard642d3131998-07-12 19:29:36 +000064 NULL, /* pPolyBezier */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000065 NULL, /* pRealizePalette */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000066 MFDRV_Rectangle, /* pRectangle */
Huw D M Davies7603dea1999-04-25 09:24:23 +000067 MFDRV_RestoreDC, /* pRestoreDC */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000068 MFDRV_RoundRect, /* pRoundRect */
Huw D M Davies7603dea1999-04-25 09:24:23 +000069 MFDRV_SaveDC, /* pSaveDC */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000070 MFDRV_ScaleViewportExt, /* pScaleViewportExt */
71 MFDRV_ScaleWindowExt, /* pScaleWindowExt */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000072 NULL, /* pSelectClipRgn */
Alexandre Julliard349a9531997-02-02 19:01:52 +000073 MFDRV_SelectObject, /* pSelectObject */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000074 NULL, /* pSelectPalette */
Alexandre Julliarda0d77311998-09-13 16:32:00 +000075 MFDRV_SetBkColor, /* pSetBkColor */
Huw D M Davies7603dea1999-04-25 09:24:23 +000076 MFDRV_SetBkMode, /* pSetBkMode */
Alexandre Julliard530ee841996-10-23 16:59:13 +000077 NULL, /* pSetDeviceClipping */
Huw D M Davies56166a61999-04-19 16:45:24 +000078 MFDRV_SetDIBitsToDevice, /* pSetDIBitsToDevice */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000079 MFDRV_SetMapMode, /* pSetMapMode */
Huw D M Davies7603dea1999-04-25 09:24:23 +000080 MFDRV_SetMapperFlags, /* pSetMapperFlags */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000081 MFDRV_SetPixel, /* pSetPixel */
Huw D M Davies7603dea1999-04-25 09:24:23 +000082 MFDRV_SetPolyFillMode, /* pSetPolyFillMode */
83 MFDRV_SetROP2, /* pSetROP2 */
84 MFDRV_SetRelAbs, /* pSetRelAbs */
85 MFDRV_SetStretchBltMode, /* pSetStretchBltMode */
86 MFDRV_SetTextAlign, /* pSetTextAlign */
87 MFDRV_SetTextCharacterExtra, /* pSetTextCharacterExtra */
Alexandre Julliarda0d77311998-09-13 16:32:00 +000088 MFDRV_SetTextColor, /* pSetTextColor */
Huw D M Davies7603dea1999-04-25 09:24:23 +000089 MFDRV_SetTextJustification, /* pSetTextJustification */
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000090 MFDRV_SetViewportExt, /* pSetViewportExt */
91 MFDRV_SetViewportOrg, /* pSetViewportOrg */
92 MFDRV_SetWindowExt, /* pSetWindowExt */
93 MFDRV_SetWindowOrg, /* pSetWindowOrg */
Huw D M Daviese39b6761999-05-17 16:20:51 +000094 NULL, /* pStartDoc */
95 NULL, /* pStartPage */
Alexandre Julliard75d86e11996-11-17 18:59:11 +000096 MFDRV_StretchBlt, /* pStretchBlt */
Huw D M Davies56166a61999-04-19 16:45:24 +000097 MFDRV_StretchDIBits /* pStretchDIBits */
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000098};
99
100
101
102/**********************************************************************
103 * MFDRV_AllocMetaFile
104 */
105static DC *MFDRV_AllocMetaFile(void)
106{
107 DC *dc;
108 METAFILEDRV_PDEVICE *physDev;
109
110 if (!(dc = DC_AllocDC( &MFDRV_Funcs ))) return NULL;
111 dc->header.wMagic = METAFILE_DC_MAGIC;
112
113 physDev = (METAFILEDRV_PDEVICE *)HeapAlloc(SystemHeap,0,sizeof(*physDev));
114 if (!physDev)
115 {
116 GDI_HEAP_FREE( dc->hSelf );
117 return NULL;
118 }
119 dc->physDev = physDev;
120
121 if (!(physDev->mh = HeapAlloc( SystemHeap, 0, sizeof(*physDev->mh) )))
122 {
123 HeapFree( SystemHeap, 0, physDev );
124 GDI_HEAP_FREE( dc->hSelf );
125 return NULL;
126 }
127
128 physDev->nextHandle = 0;
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000129 physDev->hFile = 0;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000130
131 physDev->mh->mtHeaderSize = sizeof(METAHEADER) / sizeof(WORD);
132 physDev->mh->mtVersion = 0x0300;
133 physDev->mh->mtSize = physDev->mh->mtHeaderSize;
134 physDev->mh->mtNoObjects = 0;
135 physDev->mh->mtMaxRecord = 0;
136 physDev->mh->mtNoParameters = 0;
137
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000138 return dc;
139}
140
141
142/**********************************************************************
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000143 * MFDRV_DeleteDC
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000144 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000145static BOOL MFDRV_DeleteDC( DC *dc )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000146{
147 METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
148
149 if (physDev->mh) HeapFree( SystemHeap, 0, physDev->mh );
150 HeapFree( SystemHeap, 0, physDev );
151 dc->physDev = NULL;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000152 GDI_FreeObject(dc->hSelf);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000153 return TRUE;
154}
155
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000156/**********************************************************************
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000157 * CreateMetaFile16 (GDI.125)
158 *
159 * Create a new DC and associate it with a metafile. Pass a filename
160 * to create a disk-based metafile, NULL to create a memory metafile.
161 *
162 * RETURNS
163 * A handle to the metafile DC if successful, NULL on failure.
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000164 */
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000165HDC16 WINAPI CreateMetaFile16(
166 LPCSTR filename /* Filename of disk metafile */
167)
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000168{
169 DC *dc;
170 METAFILEDRV_PDEVICE *physDev;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000171 HFILE hFile;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000172
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000173 TRACE(metafile, "'%s'\n", filename );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000174
175 if (!(dc = MFDRV_AllocMetaFile())) return 0;
176 physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
177
178 if (filename) /* disk based metafile */
179 {
180 physDev->mh->mtType = METAFILE_DISK;
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000181 if ((hFile = CreateFileA(filename, GENERIC_WRITE, 0, NULL,
182 CREATE_ALWAYS, 0, -1)) == HFILE_ERROR) {
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000183 MFDRV_DeleteDC( dc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000184 return 0;
185 }
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000186 if (!WriteFile( hFile, (LPSTR)physDev->mh, sizeof(*physDev->mh), NULL,
187 NULL )) {
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000188 MFDRV_DeleteDC( dc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000189 return 0;
190 }
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000191 physDev->hFile = hFile;
192
193 /* Grow METAHEADER to include filename */
194 physDev->mh = MF_CreateMetaHeaderDisk(physDev->mh, filename);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000195 }
196 else /* memory based metafile */
197 physDev->mh->mtType = METAFILE_MEMORY;
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000198
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000199 TRACE(metafile, "returning %04x\n", dc->hSelf);
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000200 return dc->hSelf;
201}
202
Alexandre Julliard54c27111998-03-29 19:44:57 +0000203/**********************************************************************
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000204 * CreateMetaFileA (GDI32.51)
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000205 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000206HDC WINAPI CreateMetaFileA(
Alexandre Julliard54c27111998-03-29 19:44:57 +0000207 LPCSTR filename /* Filename of disk metafile */
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000208)
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000209{
Alexandre Julliard54c27111998-03-29 19:44:57 +0000210 return CreateMetaFile16( filename );
211}
212
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000213/**********************************************************************
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000214 * CreateMetaFileW (GDI32.52)
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000215 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000216HDC WINAPI CreateMetaFileW(LPCWSTR filename)
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000217{
218 LPSTR filenameA;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000219 HDC hReturnDC;
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000220
221 filenameA = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
222
Alexandre Julliarda3960291999-02-26 11:11:13 +0000223 hReturnDC = CreateMetaFileA(filenameA);
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +0000224
225 HeapFree( GetProcessHeap(), 0, filenameA );
226
227 return hReturnDC;
228}
229
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000230
231/**********************************************************************
232 * MFDRV_CloseMetaFile
233 */
234static DC *MFDRV_CloseMetaFile( HDC hdc )
Alexandre Julliard54c27111998-03-29 19:44:57 +0000235{
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000236 DC *dc;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000237 METAFILEDRV_PDEVICE *physDev;
238
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000239 TRACE(metafile, "(%04x)\n", hdc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000240
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000241 if (!(dc = (DC *) GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC ))) return 0;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000242 physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
243
244 /* Construct the end of metafile record - this is documented
245 * in SDK Knowledgebase Q99334.
246 */
247
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000248 if (!MFDRV_MetaParam0(dc, META_EOF))
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000249 {
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000250 MFDRV_DeleteDC( dc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000251 return 0;
252 }
253
254 if (physDev->mh->mtType == METAFILE_DISK) /* disk based metafile */
255 {
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000256 if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000257 MFDRV_DeleteDC( dc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000258 return 0;
259 }
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000260
261 physDev->mh->mtType = METAFILE_MEMORY; /* This is what windows does */
262 if (!WriteFile(physDev->hFile, (LPSTR)physDev->mh,
263 sizeof(*physDev->mh), NULL, NULL)) {
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000264 MFDRV_DeleteDC( dc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000265 return 0;
266 }
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000267 CloseHandle(physDev->hFile);
268 physDev->mh->mtType = METAFILE_DISK;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000269 }
270
Alexandre Julliard54c27111998-03-29 19:44:57 +0000271 return dc;
272}
273
274/******************************************************************
275 * CloseMetaFile16 (GDI.126)
276 */
277HMETAFILE16 WINAPI CloseMetaFile16(
278 HDC16 hdc /* Metafile DC to close */
279)
280{
281 HMETAFILE16 hmf;
282 METAFILEDRV_PDEVICE *physDev;
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000283 DC *dc = MFDRV_CloseMetaFile(hdc);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000284 if (!dc) return 0;
285 physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
286
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000287 /* Now allocate a global handle for the metafile */
288
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000289 hmf = MF_Create_HMETAFILE16( physDev->mh );
290
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000291 physDev->mh = NULL; /* So it won't be deleted */
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000292 MFDRV_DeleteDC( dc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000293 return hmf;
294}
295
Alexandre Julliard54c27111998-03-29 19:44:57 +0000296/******************************************************************
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000297 * CloseMetaFile (GDI32.17)
Alexandre Julliard54c27111998-03-29 19:44:57 +0000298 *
299 * Stop recording graphics operations in metafile associated with
300 * hdc and retrieve metafile.
301 *
302 * RETURNS
303 * Handle of newly created metafile on success, NULL on failure.
304 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000305HMETAFILE WINAPI CloseMetaFile(
306 HDC hdc /* Metafile DC to close */
Alexandre Julliard54c27111998-03-29 19:44:57 +0000307)
308{
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000309 HMETAFILE hmf;
310 METAFILEDRV_PDEVICE *physDev;
311 DC *dc = MFDRV_CloseMetaFile(hdc);
312 if (!dc) return 0;
313 physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
314
315 /* Now allocate a global handle for the metafile */
316
317 hmf = MF_Create_HMETAFILE( physDev->mh );
318
319 physDev->mh = NULL; /* So it won't be deleted */
320 MFDRV_DeleteDC( dc );
321 return hmf;
Alexandre Julliard54c27111998-03-29 19:44:57 +0000322}
323
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000324
325/******************************************************************
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000326 * MFDRV_WriteRecord
Alexandre Julliard54c27111998-03-29 19:44:57 +0000327 *
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000328 * Warning: this function can change the pointer to the metafile header.
329 */
330BOOL MFDRV_WriteRecord( DC *dc, METARECORD *mr, DWORD rlen)
331{
332 DWORD len;
333 METAHEADER *mh;
334 METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
335
336 switch(physDev->mh->mtType)
337 {
338 case METAFILE_MEMORY:
339 len = physDev->mh->mtSize * 2 + rlen;
340 mh = HeapReAlloc( SystemHeap, 0, physDev->mh, len );
341 if (!mh) return FALSE;
342 physDev->mh = mh;
343 memcpy((WORD *)physDev->mh + physDev->mh->mtSize, mr, rlen);
344 break;
345 case METAFILE_DISK:
346 TRACE(metafile,"Writing record to disk\n");
347 if (!WriteFile(physDev->hFile, (char *)mr, rlen, NULL, NULL))
348 return FALSE;
349 break;
350 default:
351 ERR(metafile, "Unknown metafile type %d\n", physDev->mh->mtType );
352 return FALSE;
353 }
354
355 physDev->mh->mtSize += rlen / 2;
356 physDev->mh->mtMaxRecord = MAX(physDev->mh->mtMaxRecord, rlen / 2);
357 return TRUE;
358}
359
360
361/******************************************************************
362 * MFDRV_MetaParam0
Alexandre Julliard54c27111998-03-29 19:44:57 +0000363 */
364
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000365BOOL MFDRV_MetaParam0(DC *dc, short func)
366{
367 char buffer[8];
368 METARECORD *mr = (METARECORD *)&buffer;
369
370 mr->rdSize = 3;
371 mr->rdFunction = func;
372 return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
Alexandre Julliard54c27111998-03-29 19:44:57 +0000373}
374
Huw D M Daviesb94e4331999-04-15 16:46:51 +0000375
376/******************************************************************
377 * MFDRV_MetaParam1
378 */
379BOOL MFDRV_MetaParam1(DC *dc, short func, short param1)
380{
381 char buffer[8];
382 METARECORD *mr = (METARECORD *)&buffer;
383
384 mr->rdSize = 4;
385 mr->rdFunction = func;
386 *(mr->rdParm) = param1;
387 return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
388}
389
390
391/******************************************************************
392 * MFDRV_MetaParam2
393 */
394BOOL MFDRV_MetaParam2(DC *dc, short func, short param1, short param2)
395{
396 char buffer[10];
397 METARECORD *mr = (METARECORD *)&buffer;
398
399 mr->rdSize = 5;
400 mr->rdFunction = func;
401 *(mr->rdParm) = param2;
402 *(mr->rdParm + 1) = param1;
403 return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
404}
405
406
407/******************************************************************
408 * MFDRV_MetaParam4
409 */
410
411BOOL MFDRV_MetaParam4(DC *dc, short func, short param1, short param2,
412 short param3, short param4)
413{
414 char buffer[14];
415 METARECORD *mr = (METARECORD *)&buffer;
416
417 mr->rdSize = 7;
418 mr->rdFunction = func;
419 *(mr->rdParm) = param4;
420 *(mr->rdParm + 1) = param3;
421 *(mr->rdParm + 2) = param2;
422 *(mr->rdParm + 3) = param1;
423 return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
424}
425
426
427/******************************************************************
428 * MFDRV_MetaParam6
429 */
430
431BOOL MFDRV_MetaParam6(DC *dc, short func, short param1, short param2,
432 short param3, short param4, short param5, short param6)
433{
434 char buffer[18];
435 METARECORD *mr = (METARECORD *)&buffer;
436
437 mr->rdSize = 9;
438 mr->rdFunction = func;
439 *(mr->rdParm) = param6;
440 *(mr->rdParm + 1) = param5;
441 *(mr->rdParm + 2) = param4;
442 *(mr->rdParm + 3) = param3;
443 *(mr->rdParm + 4) = param2;
444 *(mr->rdParm + 5) = param1;
445 return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
446}
447
448
449/******************************************************************
450 * MFDRV_MetaParam8
451 */
452BOOL MFDRV_MetaParam8(DC *dc, short func, short param1, short param2,
453 short param3, short param4, short param5,
454 short param6, short param7, short param8)
455{
456 char buffer[22];
457 METARECORD *mr = (METARECORD *)&buffer;
458
459 mr->rdSize = 11;
460 mr->rdFunction = func;
461 *(mr->rdParm) = param8;
462 *(mr->rdParm + 1) = param7;
463 *(mr->rdParm + 2) = param6;
464 *(mr->rdParm + 3) = param5;
465 *(mr->rdParm + 4) = param4;
466 *(mr->rdParm + 5) = param3;
467 *(mr->rdParm + 6) = param2;
468 *(mr->rdParm + 7) = param1;
469 return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
470}
471
472
473/******************************************************************
474 * MFDRV_AddHandleDC
475 *
476 * Note: this function assumes that we never delete objects.
477 * If we do someday, we'll need to maintain a table to re-use deleted
478 * handles.
479 */
480int MFDRV_AddHandleDC( DC *dc )
481{
482 METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
483 physDev->mh->mtNoObjects++;
484 return physDev->nextHandle++;
485}
486
487