gdi32: Use NtGdiIntersectClipRect for IntersectClipRect implementation.
[wine.git] / dlls / gdi32 / gdidc.c
blob72990ef18e360d516471c1082b50016d7a23365e
1 /*
2 * GDI Device Context functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
6 * 1999 Huw D M Davies
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"
24 #include "winternl.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 );
33 DC_ATTR *dc_attr;
34 if ((type & 0x1f) != NTGDI_OBJ_DC || !(dc_attr = get_gdi_client_ptr( hdc, 0 )))
36 SetLastError( ERROR_INVALID_HANDLE );
37 return NULL;
39 return dc_attr->disabled ? NULL : dc_attr;
42 /***********************************************************************
43 * CreateDCA (GDI32.@)
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;
50 HDC ret;
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;
61 if (init_data)
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 );
74 return ret;
77 /***********************************************************************
78 * CreateICA (GDI32.@)
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 /***********************************************************************
89 * CreateICW (GDI32.@)
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 /***********************************************************************
99 * ResetDCA (GDI32.@)
101 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
103 DEVMODEW *devmodeW;
104 HDC ret;
106 if (devmode) devmodeW = GdiConvertToDevmodeW( devmode );
107 else devmodeW = NULL;
109 ret = ResetDCW( hdc, devmodeW );
111 HeapFree( GetProcessHeap(), 0, devmodeW );
112 return ret;
115 /***********************************************************************
116 * SaveDC (GDI32.@)
118 INT WINAPI SaveDC( HDC hdc )
120 DC_ATTR *dc_attr;
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 )
152 DC_ATTR *dc_attr;
153 UINT ret;
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;
163 return ret;
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 )
216 DC_ATTR *dc_attr;
217 INT ret;
219 if (mode <= 0 || mode > BKMODE_LAST)
221 SetLastError(ERROR_INVALID_PARAMETER);
222 return 0;
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;
231 return ret;
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 )
257 DC_ATTR *dc_attr;
258 INT ret;
260 if (dir != AD_COUNTERCLOCKWISE && dir != AD_CLOCKWISE)
262 SetLastError(ERROR_INVALID_PARAMETER);
263 return 0;
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;
271 return ret;
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 )
306 DC_ATTR *dc_attr;
307 INT ret;
309 if (mode <= 0 || mode > POLYFILL_LAST)
311 SetLastError(ERROR_INVALID_PARAMETER);
312 return 0;
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;
321 return ret;
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 )
338 DC_ATTR *dc_attr;
339 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
340 *point = dc_attr->brush_org;
341 return TRUE;
344 /***********************************************************************
345 * SetBrushOrgEx (GDI32.@)
347 BOOL WINAPI SetBrushOrgEx( HDC hdc, INT x, INT y, POINT *oldorg )
349 DC_ATTR *dc_attr;
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;
354 return TRUE;
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 )
370 DC_ATTR *dc_attr;
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;
374 return TRUE;
377 /***********************************************************************
378 * GetWindowExtEx (GDI32.@)
380 BOOL WINAPI GetWindowExtEx( HDC hdc, SIZE *size )
382 DC_ATTR *dc_attr;
383 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
384 *size = dc_attr->wnd_ext;
385 return TRUE;
388 /***********************************************************************
389 * GetWindowOrgEx (GDI32.@)
391 BOOL WINAPI GetWindowOrgEx( HDC hdc, POINT *point )
393 DC_ATTR *dc_attr;
394 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
395 *point = dc_attr->wnd_org;
396 return TRUE;
399 /***********************************************************************
400 * GetViewportExtEx (GDI32.@)
402 BOOL WINAPI GetViewportExtEx( HDC hdc, SIZE *size )
404 DC_ATTR *dc_attr;
405 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
406 *size = dc_attr->vport_ext;
407 return TRUE;
410 /***********************************************************************
411 * GetViewportOrgEx (GDI32.@)
413 BOOL WINAPI GetViewportOrgEx( HDC hdc, POINT *point )
415 DC_ATTR *dc_attr;
416 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
417 *point = dc_attr->vport_org;
418 return TRUE;
421 /***********************************************************************
422 * SetStretchBltMode (GDI32.@)
424 INT WINAPI SetStretchBltMode( HDC hdc, INT mode )
426 DC_ATTR *dc_attr;
427 INT ret;
429 if (mode <= 0 || mode > MAXSTRETCHBLTMODE)
431 SetLastError(ERROR_INVALID_PARAMETER);
432 return 0;
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;
441 return ret;
444 /***********************************************************************
445 * GetCurrentPositionEx (GDI32.@)
447 BOOL WINAPI GetCurrentPositionEx( HDC hdc, POINT *point )
449 DC_ATTR *dc_attr;
450 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
451 *point = dc_attr->cur_pos;
452 return TRUE;
455 /***********************************************************************
456 * GetROP2 (GDI32.@)
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 )
478 DC_ATTR *dc_attr;
479 INT ret;
481 if (mode != ABSOLUTE && mode != RELATIVE)
483 SetLastError(ERROR_INVALID_PARAMETER);
484 return 0;
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;
491 return ret;
494 /***********************************************************************
495 * SetROP2 (GDI32.@)
497 INT WINAPI SetROP2( HDC hdc, INT mode )
499 DC_ATTR *dc_attr;
500 INT ret;
502 if ((mode < R2_BLACK) || (mode > R2_WHITE))
504 SetLastError(ERROR_INVALID_PARAMETER);
505 return 0;
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;
514 return ret;
517 /***********************************************************************
518 * GetMiterLimit (GDI32.@)
520 BOOL WINAPI GetMiterLimit( HDC hdc, FLOAT *limit )
522 DC_ATTR *dc_attr;
523 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
524 if (limit) *limit = dc_attr->miter_limit;
525 return TRUE;
528 /*******************************************************************
529 * SetMiterLimit (GDI32.@)
531 BOOL WINAPI SetMiterLimit( HDC hdc, FLOAT limit, FLOAT *old_limit )
533 DC_ATTR *dc_attr;
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;
538 return TRUE;
541 /***********************************************************************
542 * SetPixel (GDI32.@)
544 COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color )
546 DC_ATTR *dc_attr;
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 /***********************************************************************
563 * LineTo (GDI32.@)
565 BOOL WINAPI LineTo( HDC hdc, INT x, INT y )
567 DC_ATTR *dc_attr;
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 /***********************************************************************
578 * MoveToEx (GDI32.@)
580 BOOL WINAPI MoveToEx( HDC hdc, INT x, INT y, POINT *pt )
582 DC_ATTR *dc_attr;
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 /***********************************************************************
593 * Arc (GDI32.@)
595 BOOL WINAPI Arc( HDC hdc, INT left, INT top, INT right, INT bottom,
596 INT xstart, INT ystart, INT xend, INT yend )
598 DC_ATTR *dc_attr;
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 ))
610 return FALSE;
612 return NtGdiArcInternal( NtGdiArc, hdc, left, top, right, bottom,
613 xstart, ystart, xend, yend );
616 /***********************************************************************
617 * ArcTo (GDI32.@)
619 BOOL WINAPI ArcTo( HDC hdc, INT left, INT top, INT right, INT bottom,
620 INT xstart, INT ystart, INT xend, INT yend )
622 DC_ATTR *dc_attr;
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 ))
630 return FALSE;
632 return NtGdiArcInternal( NtGdiArcTo, hdc, left, top, right, bottom,
633 xstart, ystart, xend, yend );
636 /***********************************************************************
637 * Chord (GDI32.@)
639 BOOL WINAPI Chord( HDC hdc, INT left, INT top, INT right, INT bottom,
640 INT xstart, INT ystart, INT xend, INT yend )
642 DC_ATTR *dc_attr;
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 ))
654 return FALSE;
656 return NtGdiArcInternal( NtGdiChord, hdc, left, top, right, bottom,
657 xstart, ystart, xend, yend );
660 /***********************************************************************
661 * Pie (GDI32.@)
663 BOOL WINAPI Pie( HDC hdc, INT left, INT top, INT right, INT bottom,
664 INT xstart, INT ystart, INT xend, INT yend )
666 DC_ATTR *dc_attr;
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 ))
678 return FALSE;
680 return NtGdiArcInternal( NtGdiPie, hdc, left, top, right, bottom,
681 xstart, ystart, xend, yend );
684 /***********************************************************************
685 * AngleArc (GDI32.@)
687 BOOL WINAPI AngleArc( HDC hdc, INT x, INT y, DWORD radius, FLOAT start_angle, FLOAT sweep_angle )
689 DC_ATTR *dc_attr;
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 ))
695 return FALSE;
696 return NtGdiAngleArc( hdc, x, y, radius, start_angle, sweep_angle );
699 /***********************************************************************
700 * Ellipse (GDI32.@)
702 BOOL WINAPI Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom )
704 DC_ATTR *dc_attr;
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 )
719 DC_ATTR *dc_attr;
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 )
735 DC_ATTR *dc_attr;
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 ))
746 return FALSE;
748 return NtGdiRoundRect( hdc, left, top, right, bottom, ell_width, ell_height );
751 /**********************************************************************
752 * Polygon (GDI32.@)
754 BOOL WINAPI Polygon( HDC hdc, const POINT *points, INT count )
756 DC_ATTR *dc_attr;
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 )
771 DC_ATTR *dc_attr;
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 /**********************************************************************
782 * Polyline (GDI32.@)
784 BOOL WINAPI Polyline( HDC hdc, const POINT *points, INT count )
786 DC_ATTR *dc_attr;
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 )
801 DC_ATTR *dc_attr;
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 )
815 DC_ATTR *dc_attr;
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 )
829 DC_ATTR *dc_attr;
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 )
843 DC_ATTR *dc_attr;
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 /***********************************************************************
853 * PolyDraw (GDI32.@)
855 BOOL WINAPI PolyDraw( HDC hdc, const POINT *points, const BYTE *types, DWORD count )
857 DC_ATTR *dc_attr;
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 /***********************************************************************
867 * FillRgn (GDI32.@)
869 BOOL WINAPI FillRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush )
871 DC_ATTR *dc_attr;
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 /***********************************************************************
882 * PaintRgn (GDI32.@)
884 BOOL WINAPI PaintRgn( HDC hdc, HRGN hrgn )
886 DC_ATTR *dc_attr;
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 /***********************************************************************
897 * FrameRgn (GDI32.@)
899 BOOL WINAPI FrameRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush, INT width, INT height )
901 DC_ATTR *dc_attr;
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 ))
908 return FALSE;
909 return NtGdiFrameRgn( hdc, hrgn, hbrush, width, height );
912 /***********************************************************************
913 * InvertRgn (GDI32.@)
915 BOOL WINAPI InvertRgn( HDC hdc, HRGN hrgn )
917 DC_ATTR *dc_attr;
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 )
932 DC_ATTR *dc_attr;
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 )
956 DC_ATTR *dc_attr;
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 );
964 return FALSE;
966 if (dc_attr->emf &&
967 !EMFDC_GradientFill( dc_attr, vert_array, nvert, grad_array, ngrad, mode ))
968 return FALSE;
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 )
978 DC_ATTR *dc_attr;
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 ))
983 return FALSE;
984 return NtGdiExtTextOutW( hdc, x, y, flags, rect, str, count, dx, 0 );
987 /***********************************************************************
988 * PatBlt (GDI32.@)
990 BOOL WINAPI PatBlt( HDC hdc, INT left, INT top, INT width, INT height, DWORD rop )
992 DC_ATTR *dc_attr;
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 ))
997 return FALSE;
998 return NtGdiPatBlt( hdc, left, top, width, height, rop );
1001 /***********************************************************************
1002 * BeginPath (GDI32.@)
1004 BOOL WINAPI BeginPath(HDC hdc)
1006 DC_ATTR *dc_attr;
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 /***********************************************************************
1014 * EndPath (GDI32.@)
1016 BOOL WINAPI EndPath(HDC hdc)
1018 DC_ATTR *dc_attr;
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 )
1030 DC_ATTR *dc_attr;
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 )
1042 DC_ATTR *dc_attr;
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 )
1054 DC_ATTR *dc_attr;
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 ))
1061 return FALSE;
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)
1079 FIXME( "stub\n" );
1080 return TRUE;
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 */
1089 switch (mode)
1091 case ICM_OFF: return ICM_OFF;
1092 case ICM_ON: return 0;
1093 case ICM_QUERY: return ICM_OFF;
1095 return 0;
1098 /***********************************************************************
1099 * GdiIsMetaPrintDC (GDI32.@)
1101 BOOL WINAPI GdiIsMetaPrintDC( HDC hdc )
1103 FIXME( "%p\n", hdc );
1104 return FALSE;
1107 /***********************************************************************
1108 * GdiIsMetaFileDC (GDI32.@)
1110 BOOL WINAPI GdiIsMetaFileDC( HDC hdc )
1112 TRACE( "%p\n", hdc );
1114 switch (GetObjectType( hdc ))
1116 case OBJ_METADC:
1117 case OBJ_ENHMETADC:
1118 return TRUE;
1120 return FALSE;
1123 /***********************************************************************
1124 * GdiIsPlayMetafileDC (GDI32.@)
1126 BOOL WINAPI GdiIsPlayMetafileDC( HDC hdc )
1128 FIXME( "%p\n", hdc );
1129 return FALSE;