2 * GDI Device Context functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "gdi_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(gdi
);
30 static DC_ATTR
*get_dc_attr( HDC hdc
)
32 WORD type
= gdi_handle_type( hdc
);
34 if ((type
& 0x1f) != NTGDI_OBJ_DC
|| !(dc_attr
= get_gdi_client_ptr( hdc
, 0 )))
36 SetLastError( ERROR_INVALID_HANDLE
);
39 return dc_attr
->disabled
? NULL
: dc_attr
;
42 /***********************************************************************
45 HDC WINAPI
CreateDCA( const char *driver
, const char *device
, const char *output
,
46 const DEVMODEA
*init_data
)
48 UNICODE_STRING driverW
, deviceW
, outputW
;
49 DEVMODEW
*init_dataW
= NULL
;
52 if (driver
) RtlCreateUnicodeStringFromAsciiz( &driverW
, driver
);
53 else driverW
.Buffer
= NULL
;
55 if (device
) RtlCreateUnicodeStringFromAsciiz( &deviceW
, device
);
56 else deviceW
.Buffer
= NULL
;
58 if (output
) RtlCreateUnicodeStringFromAsciiz( &outputW
, output
);
59 else outputW
.Buffer
= NULL
;
63 /* don't convert init_data for DISPLAY driver, it's not used */
64 if (!driverW
.Buffer
|| wcsicmp( driverW
.Buffer
, L
"display" ))
65 init_dataW
= GdiConvertToDevmodeW( init_data
);
68 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, init_dataW
);
70 RtlFreeUnicodeString( &driverW
);
71 RtlFreeUnicodeString( &deviceW
);
72 RtlFreeUnicodeString( &outputW
);
73 HeapFree( GetProcessHeap(), 0, init_dataW
);
77 /***********************************************************************
80 HDC WINAPI
CreateICA( const char *driver
, const char *device
, const char *output
,
81 const DEVMODEA
*init_data
)
83 /* Nothing special yet for ICs */
84 return CreateDCA( driver
, device
, output
, init_data
);
88 /***********************************************************************
91 HDC WINAPI
CreateICW( const WCHAR
*driver
, const WCHAR
*device
, const WCHAR
*output
,
92 const DEVMODEW
*init_data
)
94 /* Nothing special yet for ICs */
95 return CreateDCW( driver
, device
, output
, init_data
);
98 /***********************************************************************
101 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
106 if (devmode
) devmodeW
= GdiConvertToDevmodeW( devmode
);
107 else devmodeW
= NULL
;
109 ret
= ResetDCW( hdc
, devmodeW
);
111 HeapFree( GetProcessHeap(), 0, devmodeW
);
115 /***********************************************************************
118 INT WINAPI
SaveDC( HDC hdc
)
122 if (is_meta_dc( hdc
)) return METADC_SaveDC( hdc
);
123 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
124 if (dc_attr
->emf
&& !EMFDC_SaveDC( dc_attr
)) return FALSE
;
125 return NtGdiSaveDC( hdc
);
128 /***********************************************************************
129 * GetDeviceCaps (GDI32.@)
131 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
133 if (is_meta_dc( hdc
)) return METADC_GetDeviceCaps( hdc
, cap
);
134 if (!get_dc_attr( hdc
)) return FALSE
;
135 return NtGdiGetDeviceCaps( hdc
, cap
);
138 /***********************************************************************
139 * GetTextAlign (GDI32.@)
141 UINT WINAPI
GetTextAlign( HDC hdc
)
143 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
144 return dc_attr
? dc_attr
->text_align
: 0;
147 /***********************************************************************
148 * SetTextAlign (GDI32.@)
150 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
155 TRACE("hdc=%p align=%d\n", hdc
, align
);
157 if (is_meta_dc( hdc
)) return METADC_SetTextAlign( hdc
, align
);
158 if (!(dc_attr
= get_dc_attr( hdc
))) return GDI_ERROR
;
159 if (dc_attr
->emf
&& !EMFDC_SetTextAlign( dc_attr
, align
)) return GDI_ERROR
;
161 ret
= dc_attr
->text_align
;
162 dc_attr
->text_align
= align
;
166 /***********************************************************************
167 * GetBkColor (GDI32.@)
169 COLORREF WINAPI
GetBkColor( HDC hdc
)
171 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
172 return dc_attr
? dc_attr
->background_color
: CLR_INVALID
;
175 /***********************************************************************
176 * GetDCBrushColor (GDI32.@)
178 COLORREF WINAPI
GetDCBrushColor( HDC hdc
)
180 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
181 return dc_attr
? dc_attr
->brush_color
: CLR_INVALID
;
184 /***********************************************************************
185 * GetDCPenColor (GDI32.@)
187 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
189 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
190 return dc_attr
? dc_attr
->pen_color
: CLR_INVALID
;
193 /***********************************************************************
194 * GetTextColor (GDI32.@)
196 COLORREF WINAPI
GetTextColor( HDC hdc
)
198 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
199 return dc_attr
? dc_attr
->text_color
: 0;
202 /***********************************************************************
203 * GetBkMode (GDI32.@)
205 INT WINAPI
GetBkMode( HDC hdc
)
207 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
208 return dc_attr
? dc_attr
->background_mode
: 0;
211 /***********************************************************************
212 * SetBkMode (GDI32.@)
214 INT WINAPI
SetBkMode( HDC hdc
, INT mode
)
219 if (mode
<= 0 || mode
> BKMODE_LAST
)
221 SetLastError(ERROR_INVALID_PARAMETER
);
225 if (is_meta_dc( hdc
)) return METADC_SetBkMode( hdc
, mode
);
226 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
227 if (dc_attr
->emf
&& !EMFDC_SetBkMode( dc_attr
, mode
)) return 0;
229 ret
= dc_attr
->background_mode
;
230 dc_attr
->background_mode
= mode
;
234 /***********************************************************************
235 * GetGraphicsMode (GDI32.@)
237 INT WINAPI
GetGraphicsMode( HDC hdc
)
239 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
240 return dc_attr
? dc_attr
->graphics_mode
: 0;
243 /***********************************************************************
244 * GetArcDirection (GDI32.@)
246 INT WINAPI
GetArcDirection( HDC hdc
)
248 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
249 return dc_attr
? dc_attr
->arc_direction
: 0;
252 /***********************************************************************
253 * SetArcDirection (GDI32.@)
255 INT WINAPI
SetArcDirection( HDC hdc
, INT dir
)
260 if (dir
!= AD_COUNTERCLOCKWISE
&& dir
!= AD_CLOCKWISE
)
262 SetLastError(ERROR_INVALID_PARAMETER
);
266 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
267 if (dc_attr
->emf
&& !EMFDC_SetArcDirection( dc_attr
, dir
)) return 0;
269 ret
= dc_attr
->arc_direction
;
270 dc_attr
->arc_direction
= dir
;
274 /***********************************************************************
275 * GetLayout (GDI32.@)
277 DWORD WINAPI
GetLayout( HDC hdc
)
279 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
280 return dc_attr
? dc_attr
->layout
: GDI_ERROR
;
283 /***********************************************************************
284 * GetMapMode (GDI32.@)
286 INT WINAPI
GetMapMode( HDC hdc
)
288 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
289 return dc_attr
? dc_attr
->map_mode
: 0;
292 /***********************************************************************
293 * GetPolyFillMode (GDI32.@)
295 INT WINAPI
GetPolyFillMode( HDC hdc
)
297 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
298 return dc_attr
? dc_attr
->poly_fill_mode
: 0;
301 /***********************************************************************
302 * SetPolyFillMode (GDI32.@)
304 INT WINAPI
SetPolyFillMode( HDC hdc
, INT mode
)
309 if (mode
<= 0 || mode
> POLYFILL_LAST
)
311 SetLastError(ERROR_INVALID_PARAMETER
);
315 if (is_meta_dc( hdc
)) return METADC_SetPolyFillMode( hdc
, mode
);
316 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
317 if (dc_attr
->emf
&& !EMFDC_SetPolyFillMode( dc_attr
, mode
)) return 0;
319 ret
= dc_attr
->poly_fill_mode
;
320 dc_attr
->poly_fill_mode
= mode
;
324 /***********************************************************************
325 * GetStretchBltMode (GDI32.@)
327 INT WINAPI
GetStretchBltMode( HDC hdc
)
329 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
330 return dc_attr
? dc_attr
->stretch_blt_mode
: 0;
333 /***********************************************************************
334 * GetBrushOrgEx (GDI32.@)
336 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, POINT
*point
)
339 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
340 *point
= dc_attr
->brush_org
;
344 /***********************************************************************
345 * SetBrushOrgEx (GDI32.@)
347 BOOL WINAPI
SetBrushOrgEx( HDC hdc
, INT x
, INT y
, POINT
*oldorg
)
350 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
351 if (oldorg
) *oldorg
= dc_attr
->brush_org
;
352 dc_attr
->brush_org
.x
= x
;
353 dc_attr
->brush_org
.y
= y
;
357 /***********************************************************************
358 * FixBrushOrgEx (GDI32.@)
360 BOOL WINAPI
FixBrushOrgEx( HDC hdc
, INT x
, INT y
, POINT
*oldorg
)
362 return SetBrushOrgEx( hdc
, x
, y
, oldorg
);
365 /***********************************************************************
366 * GetDCOrgEx (GDI32.@)
368 BOOL WINAPI
GetDCOrgEx( HDC hdc
, POINT
*point
)
371 if (!point
|| !(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
372 point
->x
= dc_attr
->vis_rect
.left
;
373 point
->y
= dc_attr
->vis_rect
.top
;
377 /***********************************************************************
378 * GetWindowExtEx (GDI32.@)
380 BOOL WINAPI
GetWindowExtEx( HDC hdc
, SIZE
*size
)
383 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
384 *size
= dc_attr
->wnd_ext
;
388 /***********************************************************************
389 * GetWindowOrgEx (GDI32.@)
391 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, POINT
*point
)
394 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
395 *point
= dc_attr
->wnd_org
;
399 /***********************************************************************
400 * GetViewportExtEx (GDI32.@)
402 BOOL WINAPI
GetViewportExtEx( HDC hdc
, SIZE
*size
)
405 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
406 *size
= dc_attr
->vport_ext
;
410 /***********************************************************************
411 * GetViewportOrgEx (GDI32.@)
413 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, POINT
*point
)
416 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
417 *point
= dc_attr
->vport_org
;
421 /***********************************************************************
422 * SetStretchBltMode (GDI32.@)
424 INT WINAPI
SetStretchBltMode( HDC hdc
, INT mode
)
429 if (mode
<= 0 || mode
> MAXSTRETCHBLTMODE
)
431 SetLastError(ERROR_INVALID_PARAMETER
);
435 if (is_meta_dc( hdc
)) return METADC_SetStretchBltMode( hdc
, mode
);
436 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
437 if (dc_attr
->emf
&& !EMFDC_SetStretchBltMode( dc_attr
, mode
)) return 0;
439 ret
= dc_attr
->stretch_blt_mode
;
440 dc_attr
->stretch_blt_mode
= mode
;
444 /***********************************************************************
445 * GetCurrentPositionEx (GDI32.@)
447 BOOL WINAPI
GetCurrentPositionEx( HDC hdc
, POINT
*point
)
450 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
451 *point
= dc_attr
->cur_pos
;
455 /***********************************************************************
458 INT WINAPI
GetROP2( HDC hdc
)
460 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
461 return dc_attr
? dc_attr
->rop_mode
: 0;
464 /***********************************************************************
465 * GetRelAbs (GDI32.@)
467 INT WINAPI
GetRelAbs( HDC hdc
, DWORD ignore
)
469 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
470 return dc_attr
? dc_attr
->rel_abs_mode
: 0;
473 /***********************************************************************
474 * SetRelAbs (GDI32.@)
476 INT WINAPI
SetRelAbs( HDC hdc
, INT mode
)
481 if (mode
!= ABSOLUTE
&& mode
!= RELATIVE
)
483 SetLastError(ERROR_INVALID_PARAMETER
);
487 if (is_meta_dc( hdc
)) return METADC_SetRelAbs( hdc
, mode
);
488 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
489 ret
= dc_attr
->rel_abs_mode
;
490 dc_attr
->rel_abs_mode
= mode
;
494 /***********************************************************************
497 INT WINAPI
SetROP2( HDC hdc
, INT mode
)
502 if ((mode
< R2_BLACK
) || (mode
> R2_WHITE
))
504 SetLastError(ERROR_INVALID_PARAMETER
);
508 if (is_meta_dc( hdc
)) return METADC_SetROP2( hdc
, mode
);
509 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
510 if (dc_attr
->emf
&& !EMFDC_SetROP2( dc_attr
, mode
)) return 0;
512 ret
= dc_attr
->rop_mode
;
513 dc_attr
->rop_mode
= mode
;
517 /***********************************************************************
518 * GetMiterLimit (GDI32.@)
520 BOOL WINAPI
GetMiterLimit( HDC hdc
, FLOAT
*limit
)
523 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
524 if (limit
) *limit
= dc_attr
->miter_limit
;
528 /*******************************************************************
529 * SetMiterLimit (GDI32.@)
531 BOOL WINAPI
SetMiterLimit( HDC hdc
, FLOAT limit
, FLOAT
*old_limit
)
534 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
535 /* FIXME: record EMFs */
536 if (old_limit
) *old_limit
= dc_attr
->miter_limit
;
537 dc_attr
->miter_limit
= limit
;
541 /***********************************************************************
544 COLORREF WINAPI
SetPixel( HDC hdc
, INT x
, INT y
, COLORREF color
)
548 if (is_meta_dc( hdc
)) return METADC_SetPixel( hdc
, x
, y
, color
);
549 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
550 if (dc_attr
->emf
&& !EMFDC_SetPixel( dc_attr
, x
, y
, color
)) return CLR_INVALID
;
551 return NtGdiSetPixel( hdc
, x
, y
, color
);
554 /***********************************************************************
555 * SetPixelV (GDI32.@)
557 BOOL WINAPI
SetPixelV( HDC hdc
, INT x
, INT y
, COLORREF color
)
559 return SetPixel( hdc
, x
, y
, color
) != CLR_INVALID
;
562 /***********************************************************************
565 BOOL WINAPI
LineTo( HDC hdc
, INT x
, INT y
)
569 TRACE( "%p, (%d, %d)\n", hdc
, x
, y
);
571 if (is_meta_dc( hdc
)) return METADC_LineTo( hdc
, x
, y
);
572 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
573 if (dc_attr
->emf
&& !EMFDC_LineTo( dc_attr
, x
, y
)) return FALSE
;
574 return NtGdiLineTo( hdc
, x
, y
);
577 /***********************************************************************
580 BOOL WINAPI
MoveToEx( HDC hdc
, INT x
, INT y
, POINT
*pt
)
584 TRACE( "%p, (%d, %d), %p\n", hdc
, x
, y
, pt
);
586 if (is_meta_dc( hdc
)) return METADC_MoveTo( hdc
, x
, y
);
587 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
588 if (dc_attr
->emf
&& !EMFDC_MoveTo( dc_attr
, x
, y
)) return FALSE
;
589 return NtGdiMoveTo( hdc
, x
, y
, pt
);
592 /***********************************************************************
595 BOOL WINAPI
Arc( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
596 INT xstart
, INT ystart
, INT xend
, INT yend
)
600 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
601 right
, bottom
, xstart
, ystart
, xend
, yend
);
603 if (is_meta_dc( hdc
))
604 return METADC_Arc( hdc
, left
, top
, right
, bottom
,
605 xstart
, ystart
, xend
, yend
);
607 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
608 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
609 xstart
, ystart
, xend
, yend
, EMR_ARC
))
612 return NtGdiArcInternal( NtGdiArc
, hdc
, left
, top
, right
, bottom
,
613 xstart
, ystart
, xend
, yend
);
616 /***********************************************************************
619 BOOL WINAPI
ArcTo( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
620 INT xstart
, INT ystart
, INT xend
, INT yend
)
624 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
625 right
, bottom
, xstart
, ystart
, xend
, yend
);
627 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
628 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
629 xstart
, ystart
, xend
, yend
, EMR_ARCTO
))
632 return NtGdiArcInternal( NtGdiArcTo
, hdc
, left
, top
, right
, bottom
,
633 xstart
, ystart
, xend
, yend
);
636 /***********************************************************************
639 BOOL WINAPI
Chord( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
640 INT xstart
, INT ystart
, INT xend
, INT yend
)
644 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
645 right
, bottom
, xstart
, ystart
, xend
, yend
);
647 if (is_meta_dc( hdc
))
648 return METADC_Chord( hdc
, left
, top
, right
, bottom
,
649 xstart
, ystart
, xend
, yend
);
651 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
652 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
653 xstart
, ystart
, xend
, yend
, EMR_CHORD
))
656 return NtGdiArcInternal( NtGdiChord
, hdc
, left
, top
, right
, bottom
,
657 xstart
, ystart
, xend
, yend
);
660 /***********************************************************************
663 BOOL WINAPI
Pie( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
664 INT xstart
, INT ystart
, INT xend
, INT yend
)
668 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
669 right
, bottom
, xstart
, ystart
, xend
, yend
);
671 if (is_meta_dc( hdc
))
672 return METADC_Pie( hdc
, left
, top
, right
, bottom
,
673 xstart
, ystart
, xend
, yend
);
675 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
676 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
677 xstart
, ystart
, xend
, yend
, EMR_PIE
))
680 return NtGdiArcInternal( NtGdiPie
, hdc
, left
, top
, right
, bottom
,
681 xstart
, ystart
, xend
, yend
);
684 /***********************************************************************
687 BOOL WINAPI
AngleArc( HDC hdc
, INT x
, INT y
, DWORD radius
, FLOAT start_angle
, FLOAT sweep_angle
)
691 TRACE( "%p, (%d, %d), %u, %f, %f\n", hdc
, x
, y
, radius
, start_angle
, sweep_angle
);
693 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
694 if (dc_attr
->emf
&& !EMFDC_AngleArc( dc_attr
, x
, y
, radius
, start_angle
, sweep_angle
))
696 return NtGdiAngleArc( hdc
, x
, y
, radius
, start_angle
, sweep_angle
);
699 /***********************************************************************
702 BOOL WINAPI
Ellipse( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
706 TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc
, left
, top
, right
, bottom
);
708 if (is_meta_dc( hdc
)) return METADC_Ellipse( hdc
, left
, top
, right
, bottom
);
709 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
710 if (dc_attr
->emf
&& !EMFDC_Ellipse( dc_attr
, left
, top
, right
, bottom
)) return FALSE
;
711 return NtGdiEllipse( hdc
, left
, top
, right
, bottom
);
714 /***********************************************************************
715 * Rectangle (GDI32.@)
717 BOOL WINAPI
Rectangle( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
721 TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc
, left
, top
, right
, bottom
);
723 if (is_meta_dc( hdc
)) return METADC_Rectangle( hdc
, left
, top
, right
, bottom
);
724 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
725 if (dc_attr
->emf
&& !EMFDC_Rectangle( dc_attr
, left
, top
, right
, bottom
)) return FALSE
;
726 return NtGdiRectangle( hdc
, left
, top
, right
, bottom
);
729 /***********************************************************************
730 * RoundRect (GDI32.@)
732 BOOL WINAPI
RoundRect( HDC hdc
, INT left
, INT top
, INT right
,
733 INT bottom
, INT ell_width
, INT ell_height
)
737 TRACE( "%p, (%d, %d)-(%d, %d), %dx%d\n", hdc
, left
, top
, right
, bottom
,
738 ell_width
, ell_height
);
740 if (is_meta_dc( hdc
))
741 return METADC_RoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
743 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
744 if (dc_attr
->emf
&& !EMFDC_RoundRect( dc_attr
, left
, top
, right
, bottom
,
745 ell_width
, ell_height
))
748 return NtGdiRoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
751 /**********************************************************************
754 BOOL WINAPI
Polygon( HDC hdc
, const POINT
*points
, INT count
)
758 TRACE( "%p, %p, %d\n", hdc
, points
, count
);
760 if (is_meta_dc( hdc
)) return METADC_Polygon( hdc
, points
, count
);
761 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
762 if (dc_attr
->emf
&& !EMFDC_Polygon( dc_attr
, points
, count
)) return FALSE
;
763 return NtGdiPolyPolyDraw( hdc
, points
, (const UINT
*)&count
, 1, NtGdiPolyPolygon
);
766 /**********************************************************************
767 * PolyPolygon (GDI32.@)
769 BOOL WINAPI
PolyPolygon( HDC hdc
, const POINT
*points
, const INT
*counts
, UINT polygons
)
773 TRACE( "%p, %p, %p, %u\n", hdc
, points
, counts
, polygons
);
775 if (is_meta_dc( hdc
)) return METADC_PolyPolygon( hdc
, points
, counts
, polygons
);
776 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
777 if (dc_attr
->emf
&& !EMFDC_PolyPolygon( dc_attr
, points
, counts
, polygons
)) return FALSE
;
778 return NtGdiPolyPolyDraw( hdc
, points
, (const UINT
*)counts
, polygons
, NtGdiPolyPolygon
);
781 /**********************************************************************
784 BOOL WINAPI
Polyline( HDC hdc
, const POINT
*points
, INT count
)
788 TRACE( "%p, %p, %d\n", hdc
, points
, count
);
790 if (is_meta_dc( hdc
)) return METADC_Polyline( hdc
, points
, count
);
791 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
792 if (dc_attr
->emf
&& !EMFDC_Polyline( dc_attr
, points
, count
)) return FALSE
;
793 return NtGdiPolyPolyDraw( hdc
, points
, (const UINT
*)&count
, 1, NtGdiPolyPolyline
);
796 /**********************************************************************
797 * PolyPolyline (GDI32.@)
799 BOOL WINAPI
PolyPolyline( HDC hdc
, const POINT
*points
, const DWORD
*counts
, DWORD polylines
)
803 TRACE( "%p, %p, %p, %u\n", hdc
, points
, counts
, polylines
);
805 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
806 if (dc_attr
->emf
&& !EMFDC_PolyPolyline( dc_attr
, points
, counts
, polylines
)) return FALSE
;
807 return NtGdiPolyPolyDraw( hdc
, points
, counts
, polylines
, NtGdiPolyPolyline
);
810 /******************************************************************************
811 * PolyBezier (GDI32.@)
813 BOOL WINAPI
PolyBezier( HDC hdc
, const POINT
*points
, DWORD count
)
817 TRACE( "%p, %p, %u\n", hdc
, points
, count
);
819 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
820 if (dc_attr
->emf
&& !EMFDC_PolyBezier( dc_attr
, points
, count
)) return FALSE
;
821 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolyBezier
);
824 /******************************************************************************
825 * PolyBezierTo (GDI32.@)
827 BOOL WINAPI
PolyBezierTo( HDC hdc
, const POINT
*points
, DWORD count
)
831 TRACE( "%p, %p, %u\n", hdc
, points
, count
);
833 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
834 if (dc_attr
->emf
&& !EMFDC_PolyBezierTo( dc_attr
, points
, count
)) return FALSE
;
835 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolyBezierTo
);
838 /**********************************************************************
839 * PolylineTo (GDI32.@)
841 BOOL WINAPI
PolylineTo( HDC hdc
, const POINT
*points
, DWORD count
)
845 TRACE( "%p, %p, %u\n", hdc
, points
, count
);
847 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
848 if (dc_attr
->emf
&& !EMFDC_PolylineTo( dc_attr
, points
, count
)) return FALSE
;
849 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolylineTo
);
852 /***********************************************************************
855 BOOL WINAPI
PolyDraw( HDC hdc
, const POINT
*points
, const BYTE
*types
, DWORD count
)
859 TRACE( "%p, %p, %p, %u\n", hdc
, points
, types
, count
);
861 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
862 if (dc_attr
->emf
&& !EMFDC_PolyDraw( dc_attr
, points
, types
, count
)) return FALSE
;
863 return NtGdiPolyDraw( hdc
, points
, types
, count
);
866 /***********************************************************************
869 BOOL WINAPI
FillRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
)
873 TRACE( "%p, %p, %p\n", hdc
, hrgn
, hbrush
);
875 if (is_meta_dc( hdc
)) return METADC_FillRgn( hdc
, hrgn
, hbrush
);
876 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
877 if (dc_attr
->emf
&& !EMFDC_FillRgn( dc_attr
, hrgn
, hbrush
)) return FALSE
;
878 return NtGdiFillRgn( hdc
, hrgn
, hbrush
);
881 /***********************************************************************
884 BOOL WINAPI
PaintRgn( HDC hdc
, HRGN hrgn
)
888 TRACE( "%p, %p\n", hdc
, hrgn
);
890 if (is_meta_dc( hdc
)) return METADC_PaintRgn( hdc
, hrgn
);
891 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
892 if (dc_attr
->emf
&& !EMFDC_PaintRgn( dc_attr
, hrgn
)) return FALSE
;
893 return NtGdiFillRgn( hdc
, hrgn
, GetCurrentObject( hdc
, OBJ_BRUSH
));
896 /***********************************************************************
899 BOOL WINAPI
FrameRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
, INT width
, INT height
)
903 TRACE( "%p, %p, %p, %dx%d\n", hdc
, hrgn
, hbrush
, width
, height
);
905 if (is_meta_dc( hdc
)) return METADC_FrameRgn( hdc
, hrgn
, hbrush
, width
, height
);
906 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
907 if (dc_attr
->emf
&& !EMFDC_FrameRgn( dc_attr
, hrgn
, hbrush
, width
, height
))
909 return NtGdiFrameRgn( hdc
, hrgn
, hbrush
, width
, height
);
912 /***********************************************************************
913 * InvertRgn (GDI32.@)
915 BOOL WINAPI
InvertRgn( HDC hdc
, HRGN hrgn
)
919 TRACE( "%p, %p\n", hdc
, hrgn
);
921 if (is_meta_dc( hdc
)) return METADC_InvertRgn( hdc
, hrgn
);
922 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
923 if (dc_attr
->emf
&& !EMFDC_InvertRgn( dc_attr
, hrgn
)) return FALSE
;
924 return NtGdiInvertRgn( hdc
, hrgn
);
927 /***********************************************************************
928 * ExtFloodFill (GDI32.@)
930 BOOL WINAPI
ExtFloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
, UINT fill_type
)
934 TRACE( "%p, (%d, %d), %08x, %x\n", hdc
, x
, y
, color
, fill_type
);
936 if (is_meta_dc( hdc
)) return METADC_ExtFloodFill( hdc
, x
, y
, color
, fill_type
);
937 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
938 if (dc_attr
->emf
&& !EMFDC_ExtFloodFill( dc_attr
, x
, y
, color
, fill_type
)) return FALSE
;
939 return NtGdiExtFloodFill( hdc
, x
, y
, color
, fill_type
);
942 /***********************************************************************
943 * FloodFill (GDI32.@)
945 BOOL WINAPI
FloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
)
947 return ExtFloodFill( hdc
, x
, y
, color
, FLOODFILLBORDER
);
950 /******************************************************************************
951 * GdiGradientFill (GDI32.@)
953 BOOL WINAPI
GdiGradientFill( HDC hdc
, TRIVERTEX
*vert_array
, ULONG nvert
,
954 void *grad_array
, ULONG ngrad
, ULONG mode
)
958 TRACE( "%p vert_array:%p nvert:%d grad_array:%p ngrad:%d\n", hdc
, vert_array
,
959 nvert
, grad_array
, ngrad
);
961 if (!(dc_attr
= get_dc_attr( hdc
)))
963 SetLastError( ERROR_INVALID_PARAMETER
);
967 !EMFDC_GradientFill( dc_attr
, vert_array
, nvert
, grad_array
, ngrad
, mode
))
969 return NtGdiGradientFill( hdc
, vert_array
, nvert
, grad_array
, ngrad
, mode
);
972 /***********************************************************************
973 * ExtTextOutW (GDI32.@)
975 BOOL WINAPI
ExtTextOutW( HDC hdc
, INT x
, INT y
, UINT flags
, const RECT
*rect
,
976 const WCHAR
*str
, UINT count
, const INT
*dx
)
980 if (is_meta_dc( hdc
)) return METADC_ExtTextOut( hdc
, x
, y
, flags
, rect
, str
, count
, dx
);
981 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
982 if (dc_attr
->emf
&& !EMFDC_ExtTextOut( dc_attr
, x
, y
, flags
, rect
, str
, count
, dx
))
984 return NtGdiExtTextOutW( hdc
, x
, y
, flags
, rect
, str
, count
, dx
, 0 );
987 /***********************************************************************
990 BOOL WINAPI
PatBlt( HDC hdc
, INT left
, INT top
, INT width
, INT height
, DWORD rop
)
994 if (is_meta_dc( hdc
)) return METADC_PatBlt( hdc
, left
, top
, width
, height
, rop
);
995 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
996 if (dc_attr
->emf
&& !EMFDC_PatBlt( dc_attr
, left
, top
, width
, height
, rop
))
998 return NtGdiPatBlt( hdc
, left
, top
, width
, height
, rop
);
1001 /***********************************************************************
1002 * BeginPath (GDI32.@)
1004 BOOL WINAPI
BeginPath(HDC hdc
)
1008 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1009 if (dc_attr
->emf
&& !EMFDC_BeginPath( dc_attr
)) return FALSE
;
1010 return NtGdiBeginPath( hdc
);
1013 /***********************************************************************
1016 BOOL WINAPI
EndPath(HDC hdc
)
1020 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1021 if (dc_attr
->emf
&& !EMFDC_EndPath( dc_attr
)) return FALSE
;
1022 return NtGdiEndPath( hdc
);
1025 /***********************************************************************
1026 * AbortPath (GDI32.@)
1028 BOOL WINAPI
AbortPath( HDC hdc
)
1032 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1033 if (dc_attr
->emf
&& !EMFDC_AbortPath( dc_attr
)) return FALSE
;
1034 return NtGdiAbortPath( hdc
);
1037 /***********************************************************************
1038 * CloseFigure (GDI32.@)
1040 BOOL WINAPI
CloseFigure( HDC hdc
)
1044 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1045 if (dc_attr
->emf
&& !EMFDC_CloseFigure( dc_attr
)) return FALSE
;
1046 return NtGdiCloseFigure( hdc
);
1049 /***********************************************************************
1050 * IntersectClipRect (GDI32.@)
1052 INT WINAPI
IntersectClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
1056 TRACE("%p %d,%d - %d,%d\n", hdc
, left
, top
, right
, bottom
);
1058 if (is_meta_dc( hdc
)) return METADC_IntersectClipRect( hdc
, left
, top
, right
, bottom
);
1059 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1060 if (dc_attr
->emf
&& !EMFDC_IntersectClipRect( dc_attr
, left
, top
, right
, bottom
))
1062 return NtGdiIntersectClipRect( hdc
, left
, top
, right
, bottom
);
1065 /***********************************************************************
1066 * GdiSetPixelFormat (GDI32.@)
1068 BOOL WINAPI
GdiSetPixelFormat( HDC hdc
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
1070 TRACE( "(%p,%d,%p)\n", hdc
, format
, descr
);
1071 return NtGdiSetPixelFormat( hdc
, format
);
1074 /***********************************************************************
1075 * CancelDC (GDI32.@)
1077 BOOL WINAPI
CancelDC(HDC hdc
)
1083 /***********************************************************************
1084 * SetICMMode (GDI32.@)
1086 INT WINAPI
SetICMMode( HDC hdc
, INT mode
)
1088 /* FIXME: Assume that ICM is always off, and cannot be turned on */
1091 case ICM_OFF
: return ICM_OFF
;
1092 case ICM_ON
: return 0;
1093 case ICM_QUERY
: return ICM_OFF
;
1098 /***********************************************************************
1099 * GdiIsMetaPrintDC (GDI32.@)
1101 BOOL WINAPI
GdiIsMetaPrintDC( HDC hdc
)
1103 FIXME( "%p\n", hdc
);
1107 /***********************************************************************
1108 * GdiIsMetaFileDC (GDI32.@)
1110 BOOL WINAPI
GdiIsMetaFileDC( HDC hdc
)
1112 TRACE( "%p\n", hdc
);
1114 switch (GetObjectType( hdc
))
1123 /***********************************************************************
1124 * GdiIsPlayMetafileDC (GDI32.@)
1126 BOOL WINAPI
GdiIsPlayMetafileDC( HDC hdc
)
1128 FIXME( "%p\n", hdc
);