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 * SetMapMode (GDI32.@)
295 INT WINAPI
SetMapMode( HDC hdc
, INT mode
)
300 TRACE("%p %d\n", hdc
, mode
);
302 if (is_meta_dc( hdc
)) return METADC_SetMapMode( hdc
, mode
);
303 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
304 if (dc_attr
->emf
&& !EMFDC_SetMapMode( dc_attr
, mode
)) return 0;
305 return NtGdiGetAndSetDCDword( hdc
, NtGdiSetMapMode
, mode
, &ret
) ? ret
: 0;
308 /***********************************************************************
309 * GetPolyFillMode (GDI32.@)
311 INT WINAPI
GetPolyFillMode( HDC hdc
)
313 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
314 return dc_attr
? dc_attr
->poly_fill_mode
: 0;
317 /***********************************************************************
318 * SetPolyFillMode (GDI32.@)
320 INT WINAPI
SetPolyFillMode( HDC hdc
, INT mode
)
325 if (mode
<= 0 || mode
> POLYFILL_LAST
)
327 SetLastError(ERROR_INVALID_PARAMETER
);
331 if (is_meta_dc( hdc
)) return METADC_SetPolyFillMode( hdc
, mode
);
332 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
333 if (dc_attr
->emf
&& !EMFDC_SetPolyFillMode( dc_attr
, mode
)) return 0;
335 ret
= dc_attr
->poly_fill_mode
;
336 dc_attr
->poly_fill_mode
= mode
;
340 /***********************************************************************
341 * GetStretchBltMode (GDI32.@)
343 INT WINAPI
GetStretchBltMode( HDC hdc
)
345 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
346 return dc_attr
? dc_attr
->stretch_blt_mode
: 0;
349 /***********************************************************************
350 * GetBrushOrgEx (GDI32.@)
352 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, POINT
*point
)
355 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
356 *point
= dc_attr
->brush_org
;
360 /***********************************************************************
361 * SetBrushOrgEx (GDI32.@)
363 BOOL WINAPI
SetBrushOrgEx( HDC hdc
, INT x
, INT y
, POINT
*oldorg
)
366 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
367 if (oldorg
) *oldorg
= dc_attr
->brush_org
;
368 dc_attr
->brush_org
.x
= x
;
369 dc_attr
->brush_org
.y
= y
;
373 /***********************************************************************
374 * FixBrushOrgEx (GDI32.@)
376 BOOL WINAPI
FixBrushOrgEx( HDC hdc
, INT x
, INT y
, POINT
*oldorg
)
378 return SetBrushOrgEx( hdc
, x
, y
, oldorg
);
381 /***********************************************************************
382 * GetDCOrgEx (GDI32.@)
384 BOOL WINAPI
GetDCOrgEx( HDC hdc
, POINT
*point
)
387 if (!point
|| !(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
388 point
->x
= dc_attr
->vis_rect
.left
;
389 point
->y
= dc_attr
->vis_rect
.top
;
393 /***********************************************************************
394 * GetWindowExtEx (GDI32.@)
396 BOOL WINAPI
GetWindowExtEx( HDC hdc
, SIZE
*size
)
399 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
400 *size
= dc_attr
->wnd_ext
;
404 /***********************************************************************
405 * GetWindowOrgEx (GDI32.@)
407 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, POINT
*point
)
410 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
411 *point
= dc_attr
->wnd_org
;
415 /***********************************************************************
416 * GetViewportExtEx (GDI32.@)
418 BOOL WINAPI
GetViewportExtEx( HDC hdc
, SIZE
*size
)
421 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
422 *size
= dc_attr
->vport_ext
;
426 /***********************************************************************
427 * GetViewportOrgEx (GDI32.@)
429 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, POINT
*point
)
432 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
433 *point
= dc_attr
->vport_org
;
437 /***********************************************************************
438 * GetWorldTransform (GDI32.@)
440 BOOL WINAPI
GetWorldTransform( HDC hdc
, XFORM
*xform
)
442 return NtGdiGetTransform( hdc
, 0x203, xform
);
445 /***********************************************************************
446 * SetStretchBltMode (GDI32.@)
448 INT WINAPI
SetStretchBltMode( HDC hdc
, INT mode
)
453 if (mode
<= 0 || mode
> MAXSTRETCHBLTMODE
)
455 SetLastError(ERROR_INVALID_PARAMETER
);
459 if (is_meta_dc( hdc
)) return METADC_SetStretchBltMode( hdc
, mode
);
460 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
461 if (dc_attr
->emf
&& !EMFDC_SetStretchBltMode( dc_attr
, mode
)) return 0;
463 ret
= dc_attr
->stretch_blt_mode
;
464 dc_attr
->stretch_blt_mode
= mode
;
468 /***********************************************************************
469 * GetCurrentPositionEx (GDI32.@)
471 BOOL WINAPI
GetCurrentPositionEx( HDC hdc
, POINT
*point
)
474 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
475 *point
= dc_attr
->cur_pos
;
479 /***********************************************************************
482 INT WINAPI
GetROP2( HDC hdc
)
484 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
485 return dc_attr
? dc_attr
->rop_mode
: 0;
488 /***********************************************************************
489 * GetRelAbs (GDI32.@)
491 INT WINAPI
GetRelAbs( HDC hdc
, DWORD ignore
)
493 DC_ATTR
*dc_attr
= get_dc_attr( hdc
);
494 return dc_attr
? dc_attr
->rel_abs_mode
: 0;
497 /***********************************************************************
498 * SetRelAbs (GDI32.@)
500 INT WINAPI
SetRelAbs( HDC hdc
, INT mode
)
505 if (mode
!= ABSOLUTE
&& mode
!= RELATIVE
)
507 SetLastError(ERROR_INVALID_PARAMETER
);
511 if (is_meta_dc( hdc
)) return METADC_SetRelAbs( hdc
, mode
);
512 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
513 ret
= dc_attr
->rel_abs_mode
;
514 dc_attr
->rel_abs_mode
= mode
;
518 /***********************************************************************
521 INT WINAPI
SetROP2( HDC hdc
, INT mode
)
526 if ((mode
< R2_BLACK
) || (mode
> R2_WHITE
))
528 SetLastError(ERROR_INVALID_PARAMETER
);
532 if (is_meta_dc( hdc
)) return METADC_SetROP2( hdc
, mode
);
533 if (!(dc_attr
= get_dc_attr( hdc
))) return 0;
534 if (dc_attr
->emf
&& !EMFDC_SetROP2( dc_attr
, mode
)) return 0;
536 ret
= dc_attr
->rop_mode
;
537 dc_attr
->rop_mode
= mode
;
541 /***********************************************************************
542 * GetMiterLimit (GDI32.@)
544 BOOL WINAPI
GetMiterLimit( HDC hdc
, FLOAT
*limit
)
547 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
548 if (limit
) *limit
= dc_attr
->miter_limit
;
552 /*******************************************************************
553 * SetMiterLimit (GDI32.@)
555 BOOL WINAPI
SetMiterLimit( HDC hdc
, FLOAT limit
, FLOAT
*old_limit
)
558 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
559 /* FIXME: record EMFs */
560 if (old_limit
) *old_limit
= dc_attr
->miter_limit
;
561 dc_attr
->miter_limit
= limit
;
565 /***********************************************************************
568 COLORREF WINAPI
SetPixel( HDC hdc
, INT x
, INT y
, COLORREF color
)
572 if (is_meta_dc( hdc
)) return METADC_SetPixel( hdc
, x
, y
, color
);
573 if (!(dc_attr
= get_dc_attr( hdc
))) return CLR_INVALID
;
574 if (dc_attr
->emf
&& !EMFDC_SetPixel( dc_attr
, x
, y
, color
)) return CLR_INVALID
;
575 return NtGdiSetPixel( hdc
, x
, y
, color
);
578 /***********************************************************************
579 * SetPixelV (GDI32.@)
581 BOOL WINAPI
SetPixelV( HDC hdc
, INT x
, INT y
, COLORREF color
)
583 return SetPixel( hdc
, x
, y
, color
) != CLR_INVALID
;
586 /***********************************************************************
589 BOOL WINAPI
LineTo( HDC hdc
, INT x
, INT y
)
593 TRACE( "%p, (%d, %d)\n", hdc
, x
, y
);
595 if (is_meta_dc( hdc
)) return METADC_LineTo( hdc
, x
, y
);
596 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
597 if (dc_attr
->emf
&& !EMFDC_LineTo( dc_attr
, x
, y
)) return FALSE
;
598 return NtGdiLineTo( hdc
, x
, y
);
601 /***********************************************************************
604 BOOL WINAPI
MoveToEx( HDC hdc
, INT x
, INT y
, POINT
*pt
)
608 TRACE( "%p, (%d, %d), %p\n", hdc
, x
, y
, pt
);
610 if (is_meta_dc( hdc
)) return METADC_MoveTo( hdc
, x
, y
);
611 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
612 if (dc_attr
->emf
&& !EMFDC_MoveTo( dc_attr
, x
, y
)) return FALSE
;
613 return NtGdiMoveTo( hdc
, x
, y
, pt
);
616 /***********************************************************************
619 BOOL WINAPI
Arc( 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 (is_meta_dc( hdc
))
628 return METADC_Arc( hdc
, left
, top
, right
, bottom
,
629 xstart
, ystart
, xend
, yend
);
631 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
632 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
633 xstart
, ystart
, xend
, yend
, EMR_ARC
))
636 return NtGdiArcInternal( NtGdiArc
, hdc
, left
, top
, right
, bottom
,
637 xstart
, ystart
, xend
, yend
);
640 /***********************************************************************
643 BOOL WINAPI
ArcTo( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
644 INT xstart
, INT ystart
, INT xend
, INT yend
)
648 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
649 right
, bottom
, 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_ARCTO
))
656 return NtGdiArcInternal( NtGdiArcTo
, hdc
, left
, top
, right
, bottom
,
657 xstart
, ystart
, xend
, yend
);
660 /***********************************************************************
663 BOOL WINAPI
Chord( 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_Chord( 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_CHORD
))
680 return NtGdiArcInternal( NtGdiChord
, hdc
, left
, top
, right
, bottom
,
681 xstart
, ystart
, xend
, yend
);
684 /***********************************************************************
687 BOOL WINAPI
Pie( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
688 INT xstart
, INT ystart
, INT xend
, INT yend
)
692 TRACE( "%p, (%d, %d)-(%d, %d), (%d, %d), (%d, %d)\n", hdc
, left
, top
,
693 right
, bottom
, xstart
, ystart
, xend
, yend
);
695 if (is_meta_dc( hdc
))
696 return METADC_Pie( hdc
, left
, top
, right
, bottom
,
697 xstart
, ystart
, xend
, yend
);
699 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
700 if (dc_attr
->emf
&& !EMFDC_ArcChordPie( dc_attr
, left
, top
, right
, bottom
,
701 xstart
, ystart
, xend
, yend
, EMR_PIE
))
704 return NtGdiArcInternal( NtGdiPie
, hdc
, left
, top
, right
, bottom
,
705 xstart
, ystart
, xend
, yend
);
708 /***********************************************************************
711 BOOL WINAPI
AngleArc( HDC hdc
, INT x
, INT y
, DWORD radius
, FLOAT start_angle
, FLOAT sweep_angle
)
715 TRACE( "%p, (%d, %d), %u, %f, %f\n", hdc
, x
, y
, radius
, start_angle
, sweep_angle
);
717 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
718 if (dc_attr
->emf
&& !EMFDC_AngleArc( dc_attr
, x
, y
, radius
, start_angle
, sweep_angle
))
720 return NtGdiAngleArc( hdc
, x
, y
, radius
, start_angle
, sweep_angle
);
723 /***********************************************************************
726 BOOL WINAPI
Ellipse( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
730 TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc
, left
, top
, right
, bottom
);
732 if (is_meta_dc( hdc
)) return METADC_Ellipse( hdc
, left
, top
, right
, bottom
);
733 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
734 if (dc_attr
->emf
&& !EMFDC_Ellipse( dc_attr
, left
, top
, right
, bottom
)) return FALSE
;
735 return NtGdiEllipse( hdc
, left
, top
, right
, bottom
);
738 /***********************************************************************
739 * Rectangle (GDI32.@)
741 BOOL WINAPI
Rectangle( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
745 TRACE( "%p, (%d, %d)-(%d, %d)\n", hdc
, left
, top
, right
, bottom
);
747 if (is_meta_dc( hdc
)) return METADC_Rectangle( hdc
, left
, top
, right
, bottom
);
748 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
749 if (dc_attr
->emf
&& !EMFDC_Rectangle( dc_attr
, left
, top
, right
, bottom
)) return FALSE
;
750 return NtGdiRectangle( hdc
, left
, top
, right
, bottom
);
753 /***********************************************************************
754 * RoundRect (GDI32.@)
756 BOOL WINAPI
RoundRect( HDC hdc
, INT left
, INT top
, INT right
,
757 INT bottom
, INT ell_width
, INT ell_height
)
761 TRACE( "%p, (%d, %d)-(%d, %d), %dx%d\n", hdc
, left
, top
, right
, bottom
,
762 ell_width
, ell_height
);
764 if (is_meta_dc( hdc
))
765 return METADC_RoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
767 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
768 if (dc_attr
->emf
&& !EMFDC_RoundRect( dc_attr
, left
, top
, right
, bottom
,
769 ell_width
, ell_height
))
772 return NtGdiRoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
775 /**********************************************************************
778 BOOL WINAPI
Polygon( HDC hdc
, const POINT
*points
, INT count
)
782 TRACE( "%p, %p, %d\n", hdc
, points
, count
);
784 if (is_meta_dc( hdc
)) return METADC_Polygon( hdc
, points
, count
);
785 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
786 if (dc_attr
->emf
&& !EMFDC_Polygon( dc_attr
, points
, count
)) return FALSE
;
787 return NtGdiPolyPolyDraw( hdc
, points
, (const UINT
*)&count
, 1, NtGdiPolyPolygon
);
790 /**********************************************************************
791 * PolyPolygon (GDI32.@)
793 BOOL WINAPI
PolyPolygon( HDC hdc
, const POINT
*points
, const INT
*counts
, UINT polygons
)
797 TRACE( "%p, %p, %p, %u\n", hdc
, points
, counts
, polygons
);
799 if (is_meta_dc( hdc
)) return METADC_PolyPolygon( hdc
, points
, counts
, polygons
);
800 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
801 if (dc_attr
->emf
&& !EMFDC_PolyPolygon( dc_attr
, points
, counts
, polygons
)) return FALSE
;
802 return NtGdiPolyPolyDraw( hdc
, points
, (const UINT
*)counts
, polygons
, NtGdiPolyPolygon
);
805 /**********************************************************************
808 BOOL WINAPI
Polyline( HDC hdc
, const POINT
*points
, INT count
)
812 TRACE( "%p, %p, %d\n", hdc
, points
, count
);
814 if (is_meta_dc( hdc
)) return METADC_Polyline( hdc
, points
, count
);
815 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
816 if (dc_attr
->emf
&& !EMFDC_Polyline( dc_attr
, points
, count
)) return FALSE
;
817 return NtGdiPolyPolyDraw( hdc
, points
, (const UINT
*)&count
, 1, NtGdiPolyPolyline
);
820 /**********************************************************************
821 * PolyPolyline (GDI32.@)
823 BOOL WINAPI
PolyPolyline( HDC hdc
, const POINT
*points
, const DWORD
*counts
, DWORD polylines
)
827 TRACE( "%p, %p, %p, %u\n", hdc
, points
, counts
, polylines
);
829 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
830 if (dc_attr
->emf
&& !EMFDC_PolyPolyline( dc_attr
, points
, counts
, polylines
)) return FALSE
;
831 return NtGdiPolyPolyDraw( hdc
, points
, counts
, polylines
, NtGdiPolyPolyline
);
834 /******************************************************************************
835 * PolyBezier (GDI32.@)
837 BOOL WINAPI
PolyBezier( HDC hdc
, const POINT
*points
, DWORD count
)
841 TRACE( "%p, %p, %u\n", hdc
, points
, count
);
843 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
844 if (dc_attr
->emf
&& !EMFDC_PolyBezier( dc_attr
, points
, count
)) return FALSE
;
845 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolyBezier
);
848 /******************************************************************************
849 * PolyBezierTo (GDI32.@)
851 BOOL WINAPI
PolyBezierTo( HDC hdc
, const POINT
*points
, DWORD count
)
855 TRACE( "%p, %p, %u\n", hdc
, points
, count
);
857 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
858 if (dc_attr
->emf
&& !EMFDC_PolyBezierTo( dc_attr
, points
, count
)) return FALSE
;
859 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolyBezierTo
);
862 /**********************************************************************
863 * PolylineTo (GDI32.@)
865 BOOL WINAPI
PolylineTo( HDC hdc
, const POINT
*points
, DWORD count
)
869 TRACE( "%p, %p, %u\n", hdc
, points
, count
);
871 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
872 if (dc_attr
->emf
&& !EMFDC_PolylineTo( dc_attr
, points
, count
)) return FALSE
;
873 return NtGdiPolyPolyDraw( hdc
, points
, &count
, 1, NtGdiPolylineTo
);
876 /***********************************************************************
879 BOOL WINAPI
PolyDraw( HDC hdc
, const POINT
*points
, const BYTE
*types
, DWORD count
)
883 TRACE( "%p, %p, %p, %u\n", hdc
, points
, types
, count
);
885 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
886 if (dc_attr
->emf
&& !EMFDC_PolyDraw( dc_attr
, points
, types
, count
)) return FALSE
;
887 return NtGdiPolyDraw( hdc
, points
, types
, count
);
890 /***********************************************************************
893 BOOL WINAPI
FillRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
)
897 TRACE( "%p, %p, %p\n", hdc
, hrgn
, hbrush
);
899 if (is_meta_dc( hdc
)) return METADC_FillRgn( hdc
, hrgn
, hbrush
);
900 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
901 if (dc_attr
->emf
&& !EMFDC_FillRgn( dc_attr
, hrgn
, hbrush
)) return FALSE
;
902 return NtGdiFillRgn( hdc
, hrgn
, hbrush
);
905 /***********************************************************************
908 BOOL WINAPI
PaintRgn( HDC hdc
, HRGN hrgn
)
912 TRACE( "%p, %p\n", hdc
, hrgn
);
914 if (is_meta_dc( hdc
)) return METADC_PaintRgn( hdc
, hrgn
);
915 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
916 if (dc_attr
->emf
&& !EMFDC_PaintRgn( dc_attr
, hrgn
)) return FALSE
;
917 return NtGdiFillRgn( hdc
, hrgn
, GetCurrentObject( hdc
, OBJ_BRUSH
));
920 /***********************************************************************
923 BOOL WINAPI
FrameRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
, INT width
, INT height
)
927 TRACE( "%p, %p, %p, %dx%d\n", hdc
, hrgn
, hbrush
, width
, height
);
929 if (is_meta_dc( hdc
)) return METADC_FrameRgn( hdc
, hrgn
, hbrush
, width
, height
);
930 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
931 if (dc_attr
->emf
&& !EMFDC_FrameRgn( dc_attr
, hrgn
, hbrush
, width
, height
))
933 return NtGdiFrameRgn( hdc
, hrgn
, hbrush
, width
, height
);
936 /***********************************************************************
937 * InvertRgn (GDI32.@)
939 BOOL WINAPI
InvertRgn( HDC hdc
, HRGN hrgn
)
943 TRACE( "%p, %p\n", hdc
, hrgn
);
945 if (is_meta_dc( hdc
)) return METADC_InvertRgn( hdc
, hrgn
);
946 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
947 if (dc_attr
->emf
&& !EMFDC_InvertRgn( dc_attr
, hrgn
)) return FALSE
;
948 return NtGdiInvertRgn( hdc
, hrgn
);
951 /***********************************************************************
952 * ExtFloodFill (GDI32.@)
954 BOOL WINAPI
ExtFloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
, UINT fill_type
)
958 TRACE( "%p, (%d, %d), %08x, %x\n", hdc
, x
, y
, color
, fill_type
);
960 if (is_meta_dc( hdc
)) return METADC_ExtFloodFill( hdc
, x
, y
, color
, fill_type
);
961 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
962 if (dc_attr
->emf
&& !EMFDC_ExtFloodFill( dc_attr
, x
, y
, color
, fill_type
)) return FALSE
;
963 return NtGdiExtFloodFill( hdc
, x
, y
, color
, fill_type
);
966 /***********************************************************************
967 * FloodFill (GDI32.@)
969 BOOL WINAPI
FloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
)
971 return ExtFloodFill( hdc
, x
, y
, color
, FLOODFILLBORDER
);
974 /******************************************************************************
975 * GdiGradientFill (GDI32.@)
977 BOOL WINAPI
GdiGradientFill( HDC hdc
, TRIVERTEX
*vert_array
, ULONG nvert
,
978 void *grad_array
, ULONG ngrad
, ULONG mode
)
982 TRACE( "%p vert_array:%p nvert:%d grad_array:%p ngrad:%d\n", hdc
, vert_array
,
983 nvert
, grad_array
, ngrad
);
985 if (!(dc_attr
= get_dc_attr( hdc
)))
987 SetLastError( ERROR_INVALID_PARAMETER
);
991 !EMFDC_GradientFill( dc_attr
, vert_array
, nvert
, grad_array
, ngrad
, mode
))
993 return NtGdiGradientFill( hdc
, vert_array
, nvert
, grad_array
, ngrad
, mode
);
996 /***********************************************************************
997 * ExtTextOutW (GDI32.@)
999 BOOL WINAPI
ExtTextOutW( HDC hdc
, INT x
, INT y
, UINT flags
, const RECT
*rect
,
1000 const WCHAR
*str
, UINT count
, const INT
*dx
)
1004 if (is_meta_dc( hdc
)) return METADC_ExtTextOut( hdc
, x
, y
, flags
, rect
, str
, count
, dx
);
1005 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1006 if (dc_attr
->emf
&& !EMFDC_ExtTextOut( dc_attr
, x
, y
, flags
, rect
, str
, count
, dx
))
1008 return NtGdiExtTextOutW( hdc
, x
, y
, flags
, rect
, str
, count
, dx
, 0 );
1011 /***********************************************************************
1012 * SetTextJustification (GDI32.@)
1014 BOOL WINAPI
SetTextJustification( HDC hdc
, INT extra
, INT breaks
)
1018 if (is_meta_dc( hdc
)) return METADC_SetTextJustification( hdc
, extra
, breaks
);
1019 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1020 if (dc_attr
->emf
&& !EMFDC_SetTextJustification( dc_attr
, extra
, breaks
))
1022 return NtGdiSetTextJustification( hdc
, extra
, breaks
);
1025 /***********************************************************************
1028 BOOL WINAPI
PatBlt( HDC hdc
, INT left
, INT top
, INT width
, INT height
, DWORD rop
)
1032 if (is_meta_dc( hdc
)) return METADC_PatBlt( hdc
, left
, top
, width
, height
, rop
);
1033 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1034 if (dc_attr
->emf
&& !EMFDC_PatBlt( dc_attr
, left
, top
, width
, height
, rop
))
1036 return NtGdiPatBlt( hdc
, left
, top
, width
, height
, rop
);
1039 /***********************************************************************
1040 * BeginPath (GDI32.@)
1042 BOOL WINAPI
BeginPath(HDC hdc
)
1046 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1047 if (dc_attr
->emf
&& !EMFDC_BeginPath( dc_attr
)) return FALSE
;
1048 return NtGdiBeginPath( hdc
);
1051 /***********************************************************************
1054 BOOL WINAPI
EndPath(HDC hdc
)
1058 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1059 if (dc_attr
->emf
&& !EMFDC_EndPath( dc_attr
)) return FALSE
;
1060 return NtGdiEndPath( hdc
);
1063 /***********************************************************************
1064 * AbortPath (GDI32.@)
1066 BOOL WINAPI
AbortPath( HDC hdc
)
1070 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1071 if (dc_attr
->emf
&& !EMFDC_AbortPath( dc_attr
)) return FALSE
;
1072 return NtGdiAbortPath( hdc
);
1075 /***********************************************************************
1076 * CloseFigure (GDI32.@)
1078 BOOL WINAPI
CloseFigure( HDC hdc
)
1082 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1083 if (dc_attr
->emf
&& !EMFDC_CloseFigure( dc_attr
)) return FALSE
;
1084 return NtGdiCloseFigure( hdc
);
1087 /***********************************************************************
1088 * IntersectClipRect (GDI32.@)
1090 INT WINAPI
IntersectClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
1094 TRACE("%p %d,%d - %d,%d\n", hdc
, left
, top
, right
, bottom
);
1096 if (is_meta_dc( hdc
)) return METADC_IntersectClipRect( hdc
, left
, top
, right
, bottom
);
1097 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1098 if (dc_attr
->emf
&& !EMFDC_IntersectClipRect( dc_attr
, left
, top
, right
, bottom
))
1100 return NtGdiIntersectClipRect( hdc
, left
, top
, right
, bottom
);
1103 /***********************************************************************
1104 * OffsetClipRgn (GDI32.@)
1106 INT WINAPI
OffsetClipRgn( HDC hdc
, INT x
, INT y
)
1110 if (is_meta_dc( hdc
)) return METADC_OffsetClipRgn( hdc
, x
, y
);
1111 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1112 if (dc_attr
->emf
&& !EMFDC_OffsetClipRgn( dc_attr
, x
, y
)) return FALSE
;
1113 return NtGdiOffsetClipRgn( hdc
, x
, y
);
1116 /***********************************************************************
1117 * ExcludeClipRect (GDI32.@)
1119 INT WINAPI
ExcludeClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
)
1123 if (is_meta_dc( hdc
)) return METADC_ExcludeClipRect( hdc
, left
, top
, right
, bottom
);
1124 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1125 if (dc_attr
->emf
&& !EMFDC_ExcludeClipRect( dc_attr
, left
, top
, right
, bottom
))
1127 return NtGdiExcludeClipRect( hdc
, left
, top
, right
, bottom
);
1130 /******************************************************************************
1131 * ExtSelectClipRgn (GDI32.@)
1133 INT WINAPI
ExtSelectClipRgn( HDC hdc
, HRGN hrgn
, INT mode
)
1137 TRACE("%p %p %d\n", hdc
, hrgn
, mode
);
1139 if (is_meta_dc( hdc
)) return METADC_ExtSelectClipRgn( hdc
, hrgn
, mode
);
1140 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1141 if (dc_attr
->emf
&& !EMFDC_ExtSelectClipRgn( dc_attr
, hrgn
, mode
))
1143 return NtGdiExtSelectClipRgn( hdc
, hrgn
, mode
);
1146 /***********************************************************************
1147 * SelectClipRgn (GDI32.@)
1149 INT WINAPI
SelectClipRgn( HDC hdc
, HRGN hrgn
)
1151 return ExtSelectClipRgn( hdc
, hrgn
, RGN_COPY
);
1154 /***********************************************************************
1155 * SetMetaRgn (GDI32.@)
1157 INT WINAPI
SetMetaRgn( HDC hdc
)
1161 if (!(dc_attr
= get_dc_attr( hdc
))) return FALSE
;
1162 if (dc_attr
->emf
) FIXME( "EMFs are not yet supported\n" );
1163 return NtGdiSetMetaRgn( hdc
);
1166 /***********************************************************************
1169 BOOL WINAPI
DPtoLP( HDC hdc
, POINT
*points
, INT count
)
1171 return NtGdiTransformPoints( hdc
, points
, points
, count
, NtGdiDPtoLP
);
1174 /***********************************************************************
1177 BOOL WINAPI
LPtoDP( HDC hdc
, POINT
*points
, INT count
)
1179 return NtGdiTransformPoints( hdc
, points
, points
, count
, NtGdiLPtoDP
);
1183 /***********************************************************************
1184 * GdiSetPixelFormat (GDI32.@)
1186 BOOL WINAPI
GdiSetPixelFormat( HDC hdc
, INT format
, const PIXELFORMATDESCRIPTOR
*descr
)
1188 TRACE( "(%p,%d,%p)\n", hdc
, format
, descr
);
1189 return NtGdiSetPixelFormat( hdc
, format
);
1192 /***********************************************************************
1193 * CancelDC (GDI32.@)
1195 BOOL WINAPI
CancelDC(HDC hdc
)
1201 /***********************************************************************
1202 * SetICMMode (GDI32.@)
1204 INT WINAPI
SetICMMode( HDC hdc
, INT mode
)
1206 /* FIXME: Assume that ICM is always off, and cannot be turned on */
1209 case ICM_OFF
: return ICM_OFF
;
1210 case ICM_ON
: return 0;
1211 case ICM_QUERY
: return ICM_OFF
;
1216 /***********************************************************************
1217 * GdiIsMetaPrintDC (GDI32.@)
1219 BOOL WINAPI
GdiIsMetaPrintDC( HDC hdc
)
1221 FIXME( "%p\n", hdc
);
1225 /***********************************************************************
1226 * GdiIsMetaFileDC (GDI32.@)
1228 BOOL WINAPI
GdiIsMetaFileDC( HDC hdc
)
1230 TRACE( "%p\n", hdc
);
1232 switch (GetObjectType( hdc
))
1241 /***********************************************************************
1242 * GdiIsPlayMetafileDC (GDI32.@)
1244 BOOL WINAPI
GdiIsPlayMetafileDC( HDC hdc
)
1246 FIXME( "%p\n", hdc
);