~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gdi32/mfdrv/init.c

Version: ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Metafile driver initialisation functions
  3  *
  4  * Copyright 1996 Alexandre Julliard
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include <stdarg.h>
 22 #include <string.h>
 23 
 24 #include "windef.h"
 25 #include "winbase.h"
 26 #include "winnls.h"
 27 #include "gdi_private.h"
 28 #include "mfdrv/metafiledrv.h"
 29 #include "wine/debug.h"
 30 
 31 WINE_DEFAULT_DEBUG_CHANNEL(metafile);
 32 
 33 static BOOL MFDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev );
 34 static BOOL MFDRV_DeleteDC( PHYSDEV dev );
 35 
 36 
 37 /**********************************************************************
 38  *           MFDRV_ExtEscape
 39  */
 40 static INT MFDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_data,
 41                             INT cbOutput, LPVOID out_data )
 42 {
 43     METARECORD *mr;
 44     DWORD len;
 45     INT ret;
 46 
 47     if (cbOutput) return 0;  /* escapes that require output cannot work in metafiles */
 48 
 49     len = sizeof(*mr) + sizeof(WORD) + ((cbInput + 1) & ~1);
 50     mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
 51     mr->rdSize = len / 2;
 52     mr->rdFunction = META_ESCAPE;
 53     mr->rdParm[0] = nEscape;
 54     mr->rdParm[1] = cbInput;
 55     memcpy(&(mr->rdParm[2]), in_data, cbInput);
 56     ret = MFDRV_WriteRecord( dev, mr, len);
 57     HeapFree(GetProcessHeap(), 0, mr);
 58     return ret;
 59 }
 60 
 61 
 62 /******************************************************************
 63  *         MFDRV_GetBoundsRect
 64  */
 65 static UINT MFDRV_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
 66 {
 67     return 0;
 68 }
 69 
 70 
 71 /******************************************************************
 72  *         MFDRV_SetBoundsRect
 73  */
 74 static UINT MFDRV_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
 75 {
 76     return 0;
 77 }
 78 
 79 
 80 /******************************************************************
 81  *         MFDRV_GetDeviceCaps
 82  *
 83  *A very simple implementation that returns DT_METAFILE
 84  */
 85 static INT MFDRV_GetDeviceCaps(PHYSDEV dev, INT cap)
 86 {
 87     switch(cap)
 88     {
 89     case TECHNOLOGY:
 90         return DT_METAFILE;
 91     case TEXTCAPS:
 92         return 0;
 93     default:
 94         TRACE(" unsupported capability %d, will return 0\n", cap );
 95     }
 96     return 0;
 97 }
 98 
 99 
100 static const struct gdi_dc_funcs MFDRV_Funcs =
101 {
102     NULL,                            /* pAbortDoc */
103     MFDRV_AbortPath,                 /* pAbortPath */
104     NULL,                            /* pAlphaBlend */
105     NULL,                            /* pAngleArc */
106     MFDRV_Arc,                       /* pArc */
107     NULL,                            /* pArcTo */
108     MFDRV_BeginPath,                 /* pBeginPath */
109     NULL,                            /* pBlendImage */
110     NULL,                            /* pChoosePixelFormat */
111     MFDRV_Chord,                     /* pChord */
112     MFDRV_CloseFigure,               /* pCloseFigure */
113     NULL,                            /* pCopyBitmap */
114     NULL,                            /* pCreateBitmap */
115     MFDRV_CreateCompatibleDC,        /* pCreateCompatibleDC */
116     NULL,                            /* pCreateDC */
117     NULL,                            /* pDeleteBitmap */
118     MFDRV_DeleteDC,                  /* pDeleteDC */
119     MFDRV_DeleteObject,              /* pDeleteObject */
120     NULL,                            /* pDescribePixelFormat */
121     NULL,                            /* pDeviceCapabilities */
122     MFDRV_Ellipse,                   /* pEllipse */
123     NULL,                            /* pEndDoc */
124     NULL,                            /* pEndPage */
125     MFDRV_EndPath,                   /* pEndPath */
126     NULL,                            /* pEnumFonts */
127     NULL,                            /* pEnumICMProfiles */
128     MFDRV_ExcludeClipRect,           /* pExcludeClipRect */
129     NULL,                            /* pExtDeviceMode */
130     MFDRV_ExtEscape,                 /* pExtEscape */
131     MFDRV_ExtFloodFill,              /* pExtFloodFill */
132     MFDRV_ExtSelectClipRgn,          /* pExtSelectClipRgn */
133     MFDRV_ExtTextOut,                /* pExtTextOut */
134     MFDRV_FillPath,                  /* pFillPath */
135     MFDRV_FillRgn,                   /* pFillRgn */
136     MFDRV_FlattenPath,               /* pFlattenPath */
137     NULL,                            /* pFontIsLinked */
138     MFDRV_FrameRgn,                  /* pFrameRgn */
139     NULL,                            /* pGdiComment */
140     NULL,                            /* pGdiRealizationInfo */
141     MFDRV_GetBoundsRect,             /* pGetBoundsRect */
142     NULL,                            /* pGetCharABCWidths */
143     NULL,                            /* pGetCharABCWidthsI */
144     NULL,                            /* pGetCharWidth */
145     MFDRV_GetDeviceCaps,             /* pGetDeviceCaps */
146     NULL,                            /* pGetDeviceGammaRamp */
147     NULL,                            /* pGetFontData */
148     NULL,                            /* pGetFontUnicodeRanges */
149     NULL,                            /* pGetGlyphIndices */
150     NULL,                            /* pGetGlyphOutline */
151     NULL,                            /* pGetICMProfile */
152     NULL,                            /* pGetImage */
153     NULL,                            /* pGetKerningPairs */
154     NULL,                            /* pGetNearestColor */
155     NULL,                            /* pGetOutlineTextMetrics */
156     NULL,                            /* pGetPixel */
157     NULL,                            /* pGetPixelFormat */
158     NULL,                            /* pGetSystemPaletteEntries */
159     NULL,                            /* pGetTextCharsetInfo */
160     NULL,                            /* pGetTextExtentExPoint */
161     NULL,                            /* pGetTextExtentExPointI */
162     NULL,                            /* pGetTextFace */
163     NULL,                            /* pGetTextMetrics */
164     NULL,                            /* pGradientFill */
165     MFDRV_IntersectClipRect,         /* pIntersectClipRect */
166     MFDRV_InvertRgn,                 /* pInvertRgn */
167     MFDRV_LineTo,                    /* pLineTo */
168     NULL,                            /* pModifyWorldTransform */
169     MFDRV_MoveTo,                    /* pMoveTo */
170     MFDRV_OffsetClipRgn,             /* pOffsetClipRgn */
171     MFDRV_OffsetViewportOrgEx,       /* pOffsetViewportOrgEx */
172     MFDRV_OffsetWindowOrgEx,         /* pOffsetWindowOrgEx */
173     MFDRV_PaintRgn,                  /* pPaintRgn */
174     MFDRV_PatBlt,                    /* pPatBlt */
175     MFDRV_Pie,                       /* pPie */
176     MFDRV_PolyBezier,                /* pPolyBezier */
177     MFDRV_PolyBezierTo,              /* pPolyBezierTo */
178     NULL,                            /* pPolyDraw */
179     MFDRV_PolyPolygon,               /* pPolyPolygon */
180     NULL,                            /* pPolyPolyline */
181     MFDRV_Polygon,                   /* pPolygon */
182     MFDRV_Polyline,                  /* pPolyline */
183     NULL,                            /* pPolylineTo */
184     NULL,                            /* pPutImage */
185     NULL,                            /* pRealizeDefaultPalette */
186     MFDRV_RealizePalette,            /* pRealizePalette */
187     MFDRV_Rectangle,                 /* pRectangle */
188     NULL,                            /* pResetDC */
189     MFDRV_RestoreDC,                 /* pRestoreDC */
190     MFDRV_RoundRect,                 /* pRoundRect */
191     MFDRV_SaveDC,                    /* pSaveDC */
192     MFDRV_ScaleViewportExtEx,        /* pScaleViewportExtEx */
193     MFDRV_ScaleWindowExtEx,          /* pScaleWindowExtEx */
194     MFDRV_SelectBitmap,              /* pSelectBitmap */
195     MFDRV_SelectBrush,               /* pSelectBrush */
196     MFDRV_SelectClipPath,            /* pSelectClipPath */
197     MFDRV_SelectFont,                /* pSelectFont */
198     MFDRV_SelectPalette,             /* pSelectPalette */
199     MFDRV_SelectPen,                 /* pSelectPen */
200     NULL,                            /* pSetArcDirection */
201     MFDRV_SetBkColor,                /* pSetBkColor */
202     MFDRV_SetBkMode,                 /* pSetBkMode */
203     MFDRV_SetBoundsRect,             /* pSetBoundsRect */
204     MFDRV_SetDCBrushColor,           /* pSetDCBrushColor*/
205     MFDRV_SetDCPenColor,             /* pSetDCPenColor*/
206     MFDRV_SetDIBitsToDevice,         /* pSetDIBitsToDevice */
207     NULL,                            /* pSetDeviceClipping */
208     NULL,                            /* pSetDeviceGammaRamp */
209     NULL,                            /* pSetLayout */
210     MFDRV_SetMapMode,                /* pSetMapMode */
211     MFDRV_SetMapperFlags,            /* pSetMapperFlags */
212     MFDRV_SetPixel,                  /* pSetPixel */
213     NULL,                            /* pSetPixelFormat */
214     MFDRV_SetPolyFillMode,           /* pSetPolyFillMode */
215     MFDRV_SetROP2,                   /* pSetROP2 */
216     MFDRV_SetRelAbs,                 /* pSetRelAbs */
217     MFDRV_SetStretchBltMode,         /* pSetStretchBltMode */
218     MFDRV_SetTextAlign,              /* pSetTextAlign */
219     MFDRV_SetTextCharacterExtra,     /* pSetTextCharacterExtra */
220     MFDRV_SetTextColor,              /* pSetTextColor */
221     MFDRV_SetTextJustification,      /* pSetTextJustification */
222     MFDRV_SetViewportExtEx,          /* pSetViewportExtEx */
223     MFDRV_SetViewportOrgEx,          /* pSetViewportOrgEx */
224     MFDRV_SetWindowExtEx,            /* pSetWindowExtEx */
225     MFDRV_SetWindowOrgEx,            /* pSetWindowOrgEx */
226     NULL,                            /* pSetWorldTransform */
227     NULL,                            /* pStartDoc */
228     NULL,                            /* pStartPage */
229     MFDRV_StretchBlt,                /* pStretchBlt */
230     MFDRV_StretchDIBits,             /* pStretchDIBits */
231     MFDRV_StrokeAndFillPath,         /* pStrokeAndFillPath */
232     MFDRV_StrokePath,                /* pStrokePath */
233     NULL,                            /* pSwapBuffers */
234     NULL,                            /* pUnrealizePalette */
235     MFDRV_WidenPath,                 /* pWidenPath */
236     NULL,                            /* pwglCopyContext */
237     NULL,                            /* pwglCreateContext */
238     NULL,                            /* pwglCreateContextAttribsARB */
239     NULL,                            /* pwglDeleteContext */
240     NULL,                            /* pwglGetProcAddress */
241     NULL,                            /* pwglMakeContextCurrentARB */
242     NULL,                            /* pwglMakeCurrent */
243     NULL,                            /* pwglSetPixelFormatWINE */
244     NULL,                            /* pwglShareLists */
245     NULL,                            /* pwglUseFontBitmapsA */
246     NULL,                            /* pwglUseFontBitmapsW */
247     GDI_PRIORITY_GRAPHICS_DRV        /* priority */
248 };
249 
250 
251 
252 /**********************************************************************
253  *           MFDRV_AllocMetaFile
254  */
255 static DC *MFDRV_AllocMetaFile(void)
256 {
257     DC *dc;
258     METAFILEDRV_PDEVICE *physDev;
259 
260     if (!(dc = alloc_dc_ptr( OBJ_METADC ))) return NULL;
261 
262     physDev = HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
263     if (!physDev)
264     {
265         free_dc_ptr( dc );
266         return NULL;
267     }
268     if (!(physDev->mh = HeapAlloc( GetProcessHeap(), 0, sizeof(*physDev->mh) )))
269     {
270         HeapFree( GetProcessHeap(), 0, physDev );
271         free_dc_ptr( dc );
272         return NULL;
273     }
274 
275     push_dc_driver( &dc->physDev, &physDev->dev, &MFDRV_Funcs );
276 
277     physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
278     physDev->handles_size = HANDLE_LIST_INC;
279     physDev->cur_handles = 0;
280 
281     physDev->hFile = 0;
282 
283     physDev->mh->mtHeaderSize   = sizeof(METAHEADER) / sizeof(WORD);
284     physDev->mh->mtVersion      = 0x0300;
285     physDev->mh->mtSize         = physDev->mh->mtHeaderSize;
286     physDev->mh->mtNoObjects    = 0;
287     physDev->mh->mtMaxRecord    = 0;
288     physDev->mh->mtNoParameters = 0;
289 
290     SetVirtualResolution( physDev->dev.hdc, 0, 0, 0, 0);
291 
292     return dc;
293 }
294 
295 
296 /**********************************************************************
297  *           MFDRV_CreateCompatibleDC
298  */
299 static BOOL MFDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
300 {
301     /* not supported on metafile DCs */
302     return FALSE;
303 }
304 
305 
306 /**********************************************************************
307  *           MFDRV_DeleteDC
308  */
309 static BOOL MFDRV_DeleteDC( PHYSDEV dev )
310 {
311     METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev;
312     DWORD index;
313 
314     HeapFree( GetProcessHeap(), 0, physDev->mh );
315     for(index = 0; index < physDev->handles_size; index++)
316         if(physDev->handles[index])
317             GDI_hdc_not_using_object(physDev->handles[index], dev->hdc);
318     HeapFree( GetProcessHeap(), 0, physDev->handles );
319     HeapFree( GetProcessHeap(), 0, physDev );
320     return TRUE;
321 }
322 
323 
324 /**********************************************************************
325  *           CreateMetaFileW   (GDI32.@)
326  *
327  *  Create a new DC and associate it with a metafile. Pass a filename
328  *  to create a disk-based metafile, NULL to create a memory metafile.
329  *
330  * PARAMS
331  *  filename [I] Filename of disk metafile
332  *
333  * RETURNS
334  *  A handle to the metafile DC if successful, NULL on failure.
335  */
336 HDC WINAPI CreateMetaFileW( LPCWSTR filename )
337 {
338     HDC ret;
339     DC *dc;
340     METAFILEDRV_PDEVICE *physDev;
341     HANDLE hFile;
342 
343     TRACE("%s\n", debugstr_w(filename) );
344 
345     if (!(dc = MFDRV_AllocMetaFile())) return 0;
346     physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
347 
348     if (filename)  /* disk based metafile */
349     {
350         physDev->mh->mtType = METAFILE_DISK;
351         if ((hFile = CreateFileW(filename, GENERIC_WRITE, 0, NULL,
352                                 CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
353             free_dc_ptr( dc );
354             return 0;
355         }
356         if (!WriteFile( hFile, physDev->mh, sizeof(*physDev->mh), NULL,
357                         NULL )) {
358             free_dc_ptr( dc );
359             return 0;
360         }
361         physDev->hFile = hFile;
362 
363         /* Grow METAHEADER to include filename */
364         physDev->mh = MF_CreateMetaHeaderDisk(physDev->mh, filename, TRUE);
365     }
366     else  /* memory based metafile */
367         physDev->mh->mtType = METAFILE_MEMORY;
368 
369     TRACE("returning %p\n", physDev->dev.hdc);
370     ret = physDev->dev.hdc;
371     release_dc_ptr( dc );
372     return ret;
373 }
374 
375 /**********************************************************************
376  *          CreateMetaFileA   (GDI32.@)
377  *
378  * See CreateMetaFileW.
379  */
380 HDC WINAPI CreateMetaFileA(LPCSTR filename)
381 {
382     LPWSTR filenameW;
383     DWORD len;
384     HDC hReturnDC;
385 
386     if (!filename) return CreateMetaFileW(NULL);
387 
388     len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
389     filenameW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
390     MultiByteToWideChar( CP_ACP, 0, filename, -1, filenameW, len );
391 
392     hReturnDC = CreateMetaFileW(filenameW);
393 
394     HeapFree( GetProcessHeap(), 0, filenameW );
395 
396     return hReturnDC;
397 }
398 
399 
400 /**********************************************************************
401  *          MFDRV_CloseMetaFile
402  */
403 static DC *MFDRV_CloseMetaFile( HDC hdc )
404 {
405     DC *dc;
406     METAFILEDRV_PDEVICE *physDev;
407 
408     TRACE("(%p)\n", hdc );
409 
410     if (!(dc = get_dc_ptr( hdc ))) return NULL;
411     if (dc->header.type != OBJ_METADC)
412     {
413         release_dc_ptr( dc );
414         return NULL;
415     }
416     if (dc->refcount != 1)
417     {
418         FIXME( "not deleting busy DC %p refcount %u\n", hdc, dc->refcount );
419         release_dc_ptr( dc );
420         return NULL;
421     }
422     physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
423 
424     /* Construct the end of metafile record - this is documented
425      * in SDK Knowledgebase Q99334.
426      */
427 
428     if (!MFDRV_MetaParam0(dc->physDev, META_EOF))
429     {
430         free_dc_ptr( dc );
431         return 0;
432     }
433 
434     if (physDev->mh->mtType == METAFILE_DISK)  /* disk based metafile */
435     {
436         if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
437             free_dc_ptr( dc );
438             return 0;
439         }
440 
441         physDev->mh->mtType = METAFILE_MEMORY; /* This is what windows does */
442         if (!WriteFile(physDev->hFile, physDev->mh, sizeof(*physDev->mh),
443                        NULL, NULL)) {
444             free_dc_ptr( dc );
445             return 0;
446         }
447         CloseHandle(physDev->hFile);
448         physDev->mh->mtType = METAFILE_DISK;
449     }
450 
451     return dc;
452 }
453 
454 /******************************************************************
455  *           CloseMetaFile   (GDI32.@)
456  *
457  *  Stop recording graphics operations in metafile associated with
458  *  hdc and retrieve metafile.
459  *
460  * PARAMS
461  *  hdc [I] Metafile DC to close 
462  *
463  * RETURNS
464  *  Handle of newly created metafile on success, NULL on failure.
465  */
466 HMETAFILE WINAPI CloseMetaFile(HDC hdc)
467 {
468     HMETAFILE hmf;
469     METAFILEDRV_PDEVICE *physDev;
470     DC *dc = MFDRV_CloseMetaFile(hdc);
471     if (!dc) return 0;
472     physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
473 
474     /* Now allocate a global handle for the metafile */
475 
476     hmf = MF_Create_HMETAFILE( physDev->mh );
477 
478     physDev->mh = NULL;  /* So it won't be deleted */
479     free_dc_ptr( dc );
480     return hmf;
481 }
482 
483 
484 /******************************************************************
485  *         MFDRV_WriteRecord
486  *
487  * Warning: this function can change the pointer to the metafile header.
488  */
489 BOOL MFDRV_WriteRecord( PHYSDEV dev, METARECORD *mr, DWORD rlen)
490 {
491     DWORD len, size;
492     METAHEADER *mh;
493     METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev;
494 
495     switch(physDev->mh->mtType)
496     {
497     case METAFILE_MEMORY:
498         len = physDev->mh->mtSize * 2 + rlen;
499         /* reallocate memory if needed */
500         size = HeapSize( GetProcessHeap(), 0, physDev->mh );
501         if (len > size)
502         {
503             /*expand size*/
504             size += size / 2 + rlen;
505             mh = HeapReAlloc( GetProcessHeap(), 0, physDev->mh, size);
506             if (!mh) return FALSE;
507             physDev->mh = mh;
508             TRACE("Reallocated metafile: new size is %d\n",size);
509         }
510         memcpy((WORD *)physDev->mh + physDev->mh->mtSize, mr, rlen);
511         break;
512     case METAFILE_DISK:
513         TRACE("Writing record to disk\n");
514         if (!WriteFile(physDev->hFile, mr, rlen, NULL, NULL))
515             return FALSE;
516         break;
517     default:
518         ERR("Unknown metafile type %d\n", physDev->mh->mtType );
519         return FALSE;
520     }
521 
522     physDev->mh->mtSize += rlen / 2;
523     physDev->mh->mtMaxRecord = max(physDev->mh->mtMaxRecord, rlen / 2);
524     return TRUE;
525 }
526 
527 
528 /******************************************************************
529  *         MFDRV_MetaParam0
530  */
531 
532 BOOL MFDRV_MetaParam0(PHYSDEV dev, short func)
533 {
534     char buffer[8];
535     METARECORD *mr = (METARECORD *)&buffer;
536 
537     mr->rdSize = 3;
538     mr->rdFunction = func;
539     return MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
540 }
541 
542 
543 /******************************************************************
544  *         MFDRV_MetaParam1
545  */
546 BOOL MFDRV_MetaParam1(PHYSDEV dev, short func, short param1)
547 {
548     char buffer[8];
549     METARECORD *mr = (METARECORD *)&buffer;
550     WORD *params = mr->rdParm;
551 
552     mr->rdSize = 4;
553     mr->rdFunction = func;
554     params[0] = param1;
555     return MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
556 }
557 
558 
559 /******************************************************************
560  *         MFDRV_MetaParam2
561  */
562 BOOL MFDRV_MetaParam2(PHYSDEV dev, short func, short param1, short param2)
563 {
564     char buffer[10];
565     METARECORD *mr = (METARECORD *)&buffer;
566     WORD *params = mr->rdParm;
567 
568     mr->rdSize = 5;
569     mr->rdFunction = func;
570     params[0] = param2;
571     params[1] = param1;
572     return MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
573 }
574 
575 
576 /******************************************************************
577  *         MFDRV_MetaParam4
578  */
579 
580 BOOL MFDRV_MetaParam4(PHYSDEV dev, short func, short param1, short param2,
581                       short param3, short param4)
582 {
583     char buffer[14];
584     METARECORD *mr = (METARECORD *)&buffer;
585     WORD *params = mr->rdParm;
586 
587     mr->rdSize = 7;
588     mr->rdFunction = func;
589     params[0] = param4;
590     params[1] = param3;
591     params[2] = param2;
592     params[3] = param1;
593     return MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
594 }
595 
596 
597 /******************************************************************
598  *         MFDRV_MetaParam6
599  */
600 
601 BOOL MFDRV_MetaParam6(PHYSDEV dev, short func, short param1, short param2,
602                       short param3, short param4, short param5, short param6)
603 {
604     char buffer[18];
605     METARECORD *mr = (METARECORD *)&buffer;
606     WORD *params = mr->rdParm;
607 
608     mr->rdSize = 9;
609     mr->rdFunction = func;
610     params[0] = param6;
611     params[1] = param5;
612     params[2] = param4;
613     params[3] = param3;
614     params[4] = param2;
615     params[5] = param1;
616     return MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
617 }
618 
619 
620 /******************************************************************
621  *         MFDRV_MetaParam8
622  */
623 BOOL MFDRV_MetaParam8(PHYSDEV dev, short func, short param1, short param2,
624                       short param3, short param4, short param5,
625                       short param6, short param7, short param8)
626 {
627     char buffer[22];
628     METARECORD *mr = (METARECORD *)&buffer;
629     WORD *params = mr->rdParm;
630 
631     mr->rdSize = 11;
632     mr->rdFunction = func;
633     params[0] = param8;
634     params[1] = param7;
635     params[2] = param6;
636     params[3] = param5;
637     params[4] = param4;
638     params[5] = param3;
639     params[6] = param2;
640     params[7] = param1;
641     return MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
642 }
643 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.