2 * Enhanced MetaFile driver dc value functions
4 * Copyright 1999 Huw D M Davies
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.
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.
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
21 #include "enhmfdrv/enhmetafiledrv.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile
);
26 INT
EMFDRV_SaveDC( PHYSDEV dev
)
28 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSaveDC
);
29 INT ret
= next
->funcs
->pSaveDC( next
);
34 emr
.emr
.iType
= EMR_SAVEDC
;
35 emr
.emr
.nSize
= sizeof(emr
);
36 EMFDRV_WriteRecord( dev
, &emr
.emr
);
41 BOOL
EMFDRV_RestoreDC( PHYSDEV dev
, INT level
)
43 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pRestoreDC
);
44 EMFDRV_PDEVICE
* physDev
= (EMFDRV_PDEVICE
*)dev
;
45 DC
*dc
= get_dc_ptr( dev
->hdc
);
49 emr
.emr
.iType
= EMR_RESTOREDC
;
50 emr
.emr
.nSize
= sizeof(emr
);
53 emr
.iRelative
= level
;
55 emr
.iRelative
= level
- dc
->saveLevel
- 1;
59 ret
= next
->funcs
->pRestoreDC( next
, level
);
62 if (ret
) EMFDRV_WriteRecord( dev
, &emr
.emr
);
66 UINT
EMFDRV_SetTextAlign( PHYSDEV dev
, UINT align
)
69 emr
.emr
.iType
= EMR_SETTEXTALIGN
;
70 emr
.emr
.nSize
= sizeof(emr
);
72 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? align
: GDI_ERROR
;
75 BOOL
EMFDRV_SetTextJustification(PHYSDEV dev
, INT nBreakExtra
, INT nBreakCount
)
77 EMRSETTEXTJUSTIFICATION emr
;
78 emr
.emr
.iType
= EMR_SETTEXTJUSTIFICATION
;
79 emr
.emr
.nSize
= sizeof(emr
);
80 emr
.nBreakExtra
= nBreakExtra
;
81 emr
.nBreakCount
= nBreakCount
;
82 return EMFDRV_WriteRecord(dev
, &emr
.emr
);
85 INT
EMFDRV_SetBkMode( PHYSDEV dev
, INT mode
)
88 emr
.emr
.iType
= EMR_SETBKMODE
;
89 emr
.emr
.nSize
= sizeof(emr
);
91 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? mode
: 0;
94 COLORREF
EMFDRV_SetBkColor( PHYSDEV dev
, COLORREF color
)
97 EMFDRV_PDEVICE
*physDev
= (EMFDRV_PDEVICE
*)dev
;
99 if (physDev
->restoring
) return color
; /* don't output records during RestoreDC */
101 emr
.emr
.iType
= EMR_SETBKCOLOR
;
102 emr
.emr
.nSize
= sizeof(emr
);
104 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? color
: CLR_INVALID
;
108 COLORREF
EMFDRV_SetTextColor( PHYSDEV dev
, COLORREF color
)
111 EMFDRV_PDEVICE
*physDev
= (EMFDRV_PDEVICE
*)dev
;
113 if (physDev
->restoring
) return color
; /* don't output records during RestoreDC */
115 emr
.emr
.iType
= EMR_SETTEXTCOLOR
;
116 emr
.emr
.nSize
= sizeof(emr
);
118 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? color
: CLR_INVALID
;
121 INT
EMFDRV_SetROP2( PHYSDEV dev
, INT rop
)
124 emr
.emr
.iType
= EMR_SETROP2
;
125 emr
.emr
.nSize
= sizeof(emr
);
127 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? rop
: 0;
130 INT
EMFDRV_SetPolyFillMode( PHYSDEV dev
, INT mode
)
132 EMRSETPOLYFILLMODE emr
;
133 emr
.emr
.iType
= EMR_SETPOLYFILLMODE
;
134 emr
.emr
.nSize
= sizeof(emr
);
136 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? mode
: 0;
139 INT
EMFDRV_SetStretchBltMode( PHYSDEV dev
, INT mode
)
141 EMRSETSTRETCHBLTMODE emr
;
142 emr
.emr
.iType
= EMR_SETSTRETCHBLTMODE
;
143 emr
.emr
.nSize
= sizeof(emr
);
145 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? mode
: 0;
148 INT
EMFDRV_SetArcDirection(PHYSDEV dev
, INT arcDirection
)
150 EMRSETARCDIRECTION emr
;
152 emr
.emr
.iType
= EMR_SETARCDIRECTION
;
153 emr
.emr
.nSize
= sizeof(emr
);
154 emr
.iArcDirection
= arcDirection
;
155 return EMFDRV_WriteRecord(dev
, &emr
.emr
) ? arcDirection
: 0;
158 INT
EMFDRV_ExcludeClipRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
160 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pExcludeClipRect
);
161 EMREXCLUDECLIPRECT emr
;
163 emr
.emr
.iType
= EMR_EXCLUDECLIPRECT
;
164 emr
.emr
.nSize
= sizeof(emr
);
165 emr
.rclClip
.left
= left
;
166 emr
.rclClip
.top
= top
;
167 emr
.rclClip
.right
= right
;
168 emr
.rclClip
.bottom
= bottom
;
169 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return ERROR
;
170 return next
->funcs
->pExcludeClipRect( next
, left
, top
, right
, bottom
);
173 INT
EMFDRV_IntersectClipRect( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
)
175 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pIntersectClipRect
);
176 EMRINTERSECTCLIPRECT emr
;
178 emr
.emr
.iType
= EMR_INTERSECTCLIPRECT
;
179 emr
.emr
.nSize
= sizeof(emr
);
180 emr
.rclClip
.left
= left
;
181 emr
.rclClip
.top
= top
;
182 emr
.rclClip
.right
= right
;
183 emr
.rclClip
.bottom
= bottom
;
184 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return ERROR
;
185 return next
->funcs
->pIntersectClipRect( next
, left
, top
, right
, bottom
);
188 INT
EMFDRV_OffsetClipRgn( PHYSDEV dev
, INT x
, INT y
)
190 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pOffsetClipRgn
);
191 EMROFFSETCLIPRGN emr
;
193 emr
.emr
.iType
= EMR_OFFSETCLIPRGN
;
194 emr
.emr
.nSize
= sizeof(emr
);
197 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return ERROR
;
198 return next
->funcs
->pOffsetClipRgn( next
, x
, y
);
201 INT
EMFDRV_ExtSelectClipRgn( PHYSDEV dev
, HRGN hrgn
, INT mode
)
203 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pExtSelectClipRgn
);
204 EMREXTSELECTCLIPRGN
*emr
;
210 if (mode
!= RGN_COPY
) return ERROR
;
213 else rgnsize
= GetRegionData( hrgn
, 0, NULL
);
215 size
= rgnsize
+ offsetof(EMREXTSELECTCLIPRGN
,RgnData
);
216 emr
= HeapAlloc( GetProcessHeap(), 0, size
);
217 if (rgnsize
) GetRegionData( hrgn
, rgnsize
, (RGNDATA
*)&emr
->RgnData
);
219 emr
->emr
.iType
= EMR_EXTSELECTCLIPRGN
;
220 emr
->emr
.nSize
= size
;
221 emr
->cbRgnData
= rgnsize
;
224 ret
= EMFDRV_WriteRecord( dev
, &emr
->emr
);
225 HeapFree( GetProcessHeap(), 0, emr
);
226 return ret
? next
->funcs
->pExtSelectClipRgn( next
, hrgn
, mode
) : ERROR
;
229 INT
EMFDRV_SetMapMode( PHYSDEV dev
, INT mode
)
231 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSetMapMode
);
233 emr
.emr
.iType
= EMR_SETMAPMODE
;
234 emr
.emr
.nSize
= sizeof(emr
);
237 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
238 return next
->funcs
->pSetMapMode( next
, mode
);
241 BOOL
EMFDRV_SetViewportExtEx( PHYSDEV dev
, INT cx
, INT cy
, SIZE
*size
)
243 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSetViewportExtEx
);
244 EMRSETVIEWPORTEXTEX emr
;
246 emr
.emr
.iType
= EMR_SETVIEWPORTEXTEX
;
247 emr
.emr
.nSize
= sizeof(emr
);
248 emr
.szlExtent
.cx
= cx
;
249 emr
.szlExtent
.cy
= cy
;
251 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return FALSE
;
252 return next
->funcs
->pSetViewportExtEx( next
, cx
, cy
, size
);
255 BOOL
EMFDRV_SetWindowExtEx( PHYSDEV dev
, INT cx
, INT cy
, SIZE
*size
)
257 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSetWindowExtEx
);
258 EMRSETWINDOWEXTEX emr
;
260 emr
.emr
.iType
= EMR_SETWINDOWEXTEX
;
261 emr
.emr
.nSize
= sizeof(emr
);
262 emr
.szlExtent
.cx
= cx
;
263 emr
.szlExtent
.cy
= cy
;
265 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
266 return next
->funcs
->pSetWindowExtEx( next
, cx
, cy
, size
);
269 BOOL
EMFDRV_SetViewportOrgEx( PHYSDEV dev
, INT x
, INT y
, POINT
*pt
)
271 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSetViewportOrgEx
);
272 EMRSETVIEWPORTORGEX emr
;
274 emr
.emr
.iType
= EMR_SETVIEWPORTORGEX
;
275 emr
.emr
.nSize
= sizeof(emr
);
279 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
280 return next
->funcs
->pSetViewportOrgEx( next
, x
, y
, pt
);
283 BOOL
EMFDRV_SetWindowOrgEx( PHYSDEV dev
, INT x
, INT y
, POINT
*pt
)
285 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSetWindowOrgEx
);
286 EMRSETWINDOWORGEX emr
;
288 emr
.emr
.iType
= EMR_SETWINDOWORGEX
;
289 emr
.emr
.nSize
= sizeof(emr
);
293 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
294 return next
->funcs
->pSetWindowOrgEx( next
, x
, y
, pt
);
297 BOOL
EMFDRV_ScaleViewportExtEx( PHYSDEV dev
, INT xNum
, INT xDenom
, INT yNum
, INT yDenom
, SIZE
*size
)
299 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pScaleViewportExtEx
);
300 EMRSCALEVIEWPORTEXTEX emr
;
302 emr
.emr
.iType
= EMR_SCALEVIEWPORTEXTEX
;
303 emr
.emr
.nSize
= sizeof(emr
);
309 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
310 return next
->funcs
->pScaleViewportExtEx( next
, xNum
, xDenom
, yNum
, yDenom
, size
);
313 BOOL
EMFDRV_ScaleWindowExtEx( PHYSDEV dev
, INT xNum
, INT xDenom
, INT yNum
, INT yDenom
, SIZE
*size
)
315 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pScaleWindowExtEx
);
316 EMRSCALEWINDOWEXTEX emr
;
318 emr
.emr
.iType
= EMR_SCALEWINDOWEXTEX
;
319 emr
.emr
.nSize
= sizeof(emr
);
325 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
326 return next
->funcs
->pScaleWindowExtEx( next
, xNum
, xDenom
, yNum
, yDenom
, size
);
329 DWORD
EMFDRV_SetLayout( PHYSDEV dev
, DWORD layout
)
333 emr
.emr
.iType
= EMR_SETLAYOUT
;
334 emr
.emr
.nSize
= sizeof(emr
);
336 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? layout
: GDI_ERROR
;
339 BOOL
EMFDRV_SetWorldTransform( PHYSDEV dev
, const XFORM
*xform
)
341 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSetWorldTransform
);
342 EMRSETWORLDTRANSFORM emr
;
344 emr
.emr
.iType
= EMR_SETWORLDTRANSFORM
;
345 emr
.emr
.nSize
= sizeof(emr
);
348 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return FALSE
;
349 return next
->funcs
->pSetWorldTransform( next
, xform
);
352 BOOL
EMFDRV_ModifyWorldTransform( PHYSDEV dev
, const XFORM
*xform
, DWORD mode
)
354 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pModifyWorldTransform
);
355 EMRMODIFYWORLDTRANSFORM emr
;
357 emr
.emr
.iType
= EMR_MODIFYWORLDTRANSFORM
;
358 emr
.emr
.nSize
= sizeof(emr
);
362 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return FALSE
;
363 return next
->funcs
->pModifyWorldTransform( next
, xform
, mode
);
366 BOOL
EMFDRV_OffsetViewportOrgEx( PHYSDEV dev
, INT x
, INT y
, POINT
*pt
)
368 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pOffsetViewportOrgEx
);
369 EMRSETVIEWPORTORGEX emr
;
372 GetViewportOrgEx( dev
->hdc
, &prev
);
374 emr
.emr
.iType
= EMR_SETVIEWPORTORGEX
;
375 emr
.emr
.nSize
= sizeof(emr
);
376 emr
.ptlOrigin
.x
= prev
.x
+ x
;
377 emr
.ptlOrigin
.y
= prev
.y
+ y
;
379 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
380 return next
->funcs
->pOffsetViewportOrgEx( next
, x
, y
, pt
);
383 BOOL
EMFDRV_OffsetWindowOrgEx( PHYSDEV dev
, INT x
, INT y
, POINT
*pt
)
385 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pOffsetWindowOrgEx
);
386 EMRSETWINDOWORGEX emr
;
389 GetWindowOrgEx( dev
->hdc
, &prev
);
391 emr
.emr
.iType
= EMR_SETWINDOWORGEX
;
392 emr
.emr
.nSize
= sizeof(emr
);
393 emr
.ptlOrigin
.x
= prev
.x
+ x
;
394 emr
.ptlOrigin
.y
= prev
.y
+ y
;
396 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return 0;
397 return next
->funcs
->pOffsetWindowOrgEx( next
, x
, y
, pt
);
400 DWORD
EMFDRV_SetMapperFlags( PHYSDEV dev
, DWORD flags
)
402 EMRSETMAPPERFLAGS emr
;
404 emr
.emr
.iType
= EMR_SETMAPPERFLAGS
;
405 emr
.emr
.nSize
= sizeof(emr
);
408 return EMFDRV_WriteRecord( dev
, &emr
.emr
) ? flags
: GDI_ERROR
;
411 BOOL
EMFDRV_AbortPath( PHYSDEV dev
)
415 emr
.emr
.iType
= EMR_ABORTPATH
;
416 emr
.emr
.nSize
= sizeof(emr
);
418 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
421 BOOL
EMFDRV_BeginPath( PHYSDEV dev
)
425 emr
.emr
.iType
= EMR_BEGINPATH
;
426 emr
.emr
.nSize
= sizeof(emr
);
428 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
431 BOOL
EMFDRV_CloseFigure( PHYSDEV dev
)
435 emr
.emr
.iType
= EMR_CLOSEFIGURE
;
436 emr
.emr
.nSize
= sizeof(emr
);
438 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
441 BOOL
EMFDRV_EndPath( PHYSDEV dev
)
445 emr
.emr
.iType
= EMR_ENDPATH
;
446 emr
.emr
.nSize
= sizeof(emr
);
448 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
451 BOOL
EMFDRV_FillPath( PHYSDEV dev
)
455 emr
.emr
.iType
= EMR_FILLPATH
;
456 emr
.emr
.nSize
= sizeof(emr
);
458 emr
.rclBounds
.left
= 0;
459 emr
.rclBounds
.top
= 0;
460 emr
.rclBounds
.right
= 0;
461 emr
.rclBounds
.bottom
= 0;
462 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
465 BOOL
EMFDRV_FlattenPath( PHYSDEV dev
)
469 emr
.emr
.iType
= EMR_FLATTENPATH
;
470 emr
.emr
.nSize
= sizeof(emr
);
472 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
475 BOOL
EMFDRV_SelectClipPath( PHYSDEV dev
, INT iMode
)
477 PHYSDEV next
= GET_NEXT_PHYSDEV( dev
, pSelectClipPath
);
478 EMRSELECTCLIPPATH emr
;
480 emr
.emr
.iType
= EMR_SELECTCLIPPATH
;
481 emr
.emr
.nSize
= sizeof(emr
);
484 if (!EMFDRV_WriteRecord( dev
, &emr
.emr
)) return FALSE
;
485 return next
->funcs
->pSelectClipPath( next
, iMode
);
488 BOOL
EMFDRV_StrokeAndFillPath( PHYSDEV dev
)
490 EMRSTROKEANDFILLPATH emr
;
492 emr
.emr
.iType
= EMR_STROKEANDFILLPATH
;
493 emr
.emr
.nSize
= sizeof(emr
);
495 emr
.rclBounds
.left
= 0;
496 emr
.rclBounds
.top
= 0;
497 emr
.rclBounds
.right
= 0;
498 emr
.rclBounds
.bottom
= 0;
499 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
502 BOOL
EMFDRV_StrokePath( PHYSDEV dev
)
506 emr
.emr
.iType
= EMR_STROKEPATH
;
507 emr
.emr
.nSize
= sizeof(emr
);
509 emr
.rclBounds
.left
= 0;
510 emr
.rclBounds
.top
= 0;
511 emr
.rclBounds
.right
= 0;
512 emr
.rclBounds
.bottom
= 0;
513 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
516 BOOL
EMFDRV_WidenPath( PHYSDEV dev
)
520 emr
.emr
.iType
= EMR_WIDENPATH
;
521 emr
.emr
.nSize
= sizeof(emr
);
523 return EMFDRV_WriteRecord( dev
, &emr
.emr
);
526 INT
EMFDRV_GetDeviceCaps(PHYSDEV dev
, INT cap
)
528 EMFDRV_PDEVICE
*physDev
= (EMFDRV_PDEVICE
*) dev
;
530 return GetDeviceCaps( physDev
->ref_dc
, cap
);