gdi32: Use ntgdi interface for SetMapMode implementation.
[wine.git] / dlls / gdi32 / gdidc.c
blobadef8f45aeb46ad13d0c1f5d904fd4cd5058d630
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 * SetMapMode (GDI32.@)
295 INT WINAPI SetMapMode( HDC hdc, INT mode )
297 DC_ATTR *dc_attr;
298 DWORD ret;
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 )
322 DC_ATTR *dc_attr;
323 INT ret;
325 if (mode <= 0 || mode > POLYFILL_LAST)
327 SetLastError(ERROR_INVALID_PARAMETER);
328 return 0;
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;
337 return ret;
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 )
354 DC_ATTR *dc_attr;
355 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
356 *point = dc_attr->brush_org;
357 return TRUE;
360 /***********************************************************************
361 * SetBrushOrgEx (GDI32.@)
363 BOOL WINAPI SetBrushOrgEx( HDC hdc, INT x, INT y, POINT *oldorg )
365 DC_ATTR *dc_attr;
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;
370 return TRUE;
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 )
386 DC_ATTR *dc_attr;
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;
390 return TRUE;
393 /***********************************************************************
394 * GetWindowExtEx (GDI32.@)
396 BOOL WINAPI GetWindowExtEx( HDC hdc, SIZE *size )
398 DC_ATTR *dc_attr;
399 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
400 *size = dc_attr->wnd_ext;
401 return TRUE;
404 /***********************************************************************
405 * GetWindowOrgEx (GDI32.@)
407 BOOL WINAPI GetWindowOrgEx( HDC hdc, POINT *point )
409 DC_ATTR *dc_attr;
410 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
411 *point = dc_attr->wnd_org;
412 return TRUE;
415 /***********************************************************************
416 * GetViewportExtEx (GDI32.@)
418 BOOL WINAPI GetViewportExtEx( HDC hdc, SIZE *size )
420 DC_ATTR *dc_attr;
421 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
422 *size = dc_attr->vport_ext;
423 return TRUE;
426 /***********************************************************************
427 * GetViewportOrgEx (GDI32.@)
429 BOOL WINAPI GetViewportOrgEx( HDC hdc, POINT *point )
431 DC_ATTR *dc_attr;
432 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
433 *point = dc_attr->vport_org;
434 return TRUE;
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 )
450 DC_ATTR *dc_attr;
451 INT ret;
453 if (mode <= 0 || mode > MAXSTRETCHBLTMODE)
455 SetLastError(ERROR_INVALID_PARAMETER);
456 return 0;
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;
465 return ret;
468 /***********************************************************************
469 * GetCurrentPositionEx (GDI32.@)
471 BOOL WINAPI GetCurrentPositionEx( HDC hdc, POINT *point )
473 DC_ATTR *dc_attr;
474 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
475 *point = dc_attr->cur_pos;
476 return TRUE;
479 /***********************************************************************
480 * GetROP2 (GDI32.@)
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 )
502 DC_ATTR *dc_attr;
503 INT ret;
505 if (mode != ABSOLUTE && mode != RELATIVE)
507 SetLastError(ERROR_INVALID_PARAMETER);
508 return 0;
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;
515 return ret;
518 /***********************************************************************
519 * SetROP2 (GDI32.@)
521 INT WINAPI SetROP2( HDC hdc, INT mode )
523 DC_ATTR *dc_attr;
524 INT ret;
526 if ((mode < R2_BLACK) || (mode > R2_WHITE))
528 SetLastError(ERROR_INVALID_PARAMETER);
529 return 0;
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;
538 return ret;
541 /***********************************************************************
542 * GetMiterLimit (GDI32.@)
544 BOOL WINAPI GetMiterLimit( HDC hdc, FLOAT *limit )
546 DC_ATTR *dc_attr;
547 if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
548 if (limit) *limit = dc_attr->miter_limit;
549 return TRUE;
552 /*******************************************************************
553 * SetMiterLimit (GDI32.@)
555 BOOL WINAPI SetMiterLimit( HDC hdc, FLOAT limit, FLOAT *old_limit )
557 DC_ATTR *dc_attr;
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;
562 return TRUE;
565 /***********************************************************************
566 * SetPixel (GDI32.@)
568 COLORREF WINAPI SetPixel( HDC hdc, INT x, INT y, COLORREF color )
570 DC_ATTR *dc_attr;
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 /***********************************************************************
587 * LineTo (GDI32.@)
589 BOOL WINAPI LineTo( HDC hdc, INT x, INT y )
591 DC_ATTR *dc_attr;
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 /***********************************************************************
602 * MoveToEx (GDI32.@)
604 BOOL WINAPI MoveToEx( HDC hdc, INT x, INT y, POINT *pt )
606 DC_ATTR *dc_attr;
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 /***********************************************************************
617 * Arc (GDI32.@)
619 BOOL WINAPI Arc( 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 (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 ))
634 return FALSE;
636 return NtGdiArcInternal( NtGdiArc, hdc, left, top, right, bottom,
637 xstart, ystart, xend, yend );
640 /***********************************************************************
641 * ArcTo (GDI32.@)
643 BOOL WINAPI ArcTo( HDC hdc, INT left, INT top, INT right, INT bottom,
644 INT xstart, INT ystart, INT xend, INT yend )
646 DC_ATTR *dc_attr;
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 ))
654 return FALSE;
656 return NtGdiArcInternal( NtGdiArcTo, hdc, left, top, right, bottom,
657 xstart, ystart, xend, yend );
660 /***********************************************************************
661 * Chord (GDI32.@)
663 BOOL WINAPI Chord( 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_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 ))
678 return FALSE;
680 return NtGdiArcInternal( NtGdiChord, hdc, left, top, right, bottom,
681 xstart, ystart, xend, yend );
684 /***********************************************************************
685 * Pie (GDI32.@)
687 BOOL WINAPI Pie( HDC hdc, INT left, INT top, INT right, INT bottom,
688 INT xstart, INT ystart, INT xend, INT yend )
690 DC_ATTR *dc_attr;
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 ))
702 return FALSE;
704 return NtGdiArcInternal( NtGdiPie, hdc, left, top, right, bottom,
705 xstart, ystart, xend, yend );
708 /***********************************************************************
709 * AngleArc (GDI32.@)
711 BOOL WINAPI AngleArc( HDC hdc, INT x, INT y, DWORD radius, FLOAT start_angle, FLOAT sweep_angle )
713 DC_ATTR *dc_attr;
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 ))
719 return FALSE;
720 return NtGdiAngleArc( hdc, x, y, radius, start_angle, sweep_angle );
723 /***********************************************************************
724 * Ellipse (GDI32.@)
726 BOOL WINAPI Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom )
728 DC_ATTR *dc_attr;
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 )
743 DC_ATTR *dc_attr;
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 )
759 DC_ATTR *dc_attr;
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 ))
770 return FALSE;
772 return NtGdiRoundRect( hdc, left, top, right, bottom, ell_width, ell_height );
775 /**********************************************************************
776 * Polygon (GDI32.@)
778 BOOL WINAPI Polygon( HDC hdc, const POINT *points, INT count )
780 DC_ATTR *dc_attr;
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 )
795 DC_ATTR *dc_attr;
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 /**********************************************************************
806 * Polyline (GDI32.@)
808 BOOL WINAPI Polyline( HDC hdc, const POINT *points, INT count )
810 DC_ATTR *dc_attr;
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 )
825 DC_ATTR *dc_attr;
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 )
839 DC_ATTR *dc_attr;
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 )
853 DC_ATTR *dc_attr;
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 )
867 DC_ATTR *dc_attr;
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 /***********************************************************************
877 * PolyDraw (GDI32.@)
879 BOOL WINAPI PolyDraw( HDC hdc, const POINT *points, const BYTE *types, DWORD count )
881 DC_ATTR *dc_attr;
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 /***********************************************************************
891 * FillRgn (GDI32.@)
893 BOOL WINAPI FillRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush )
895 DC_ATTR *dc_attr;
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 /***********************************************************************
906 * PaintRgn (GDI32.@)
908 BOOL WINAPI PaintRgn( HDC hdc, HRGN hrgn )
910 DC_ATTR *dc_attr;
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 /***********************************************************************
921 * FrameRgn (GDI32.@)
923 BOOL WINAPI FrameRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush, INT width, INT height )
925 DC_ATTR *dc_attr;
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 ))
932 return FALSE;
933 return NtGdiFrameRgn( hdc, hrgn, hbrush, width, height );
936 /***********************************************************************
937 * InvertRgn (GDI32.@)
939 BOOL WINAPI InvertRgn( HDC hdc, HRGN hrgn )
941 DC_ATTR *dc_attr;
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 )
956 DC_ATTR *dc_attr;
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 )
980 DC_ATTR *dc_attr;
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 );
988 return FALSE;
990 if (dc_attr->emf &&
991 !EMFDC_GradientFill( dc_attr, vert_array, nvert, grad_array, ngrad, mode ))
992 return FALSE;
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 )
1002 DC_ATTR *dc_attr;
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 ))
1007 return FALSE;
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 )
1016 DC_ATTR *dc_attr;
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 ))
1021 return FALSE;
1022 return NtGdiSetTextJustification( hdc, extra, breaks );
1025 /***********************************************************************
1026 * PatBlt (GDI32.@)
1028 BOOL WINAPI PatBlt( HDC hdc, INT left, INT top, INT width, INT height, DWORD rop )
1030 DC_ATTR *dc_attr;
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 ))
1035 return FALSE;
1036 return NtGdiPatBlt( hdc, left, top, width, height, rop );
1039 /***********************************************************************
1040 * BeginPath (GDI32.@)
1042 BOOL WINAPI BeginPath(HDC hdc)
1044 DC_ATTR *dc_attr;
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 /***********************************************************************
1052 * EndPath (GDI32.@)
1054 BOOL WINAPI EndPath(HDC hdc)
1056 DC_ATTR *dc_attr;
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 )
1068 DC_ATTR *dc_attr;
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 )
1080 DC_ATTR *dc_attr;
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 )
1092 DC_ATTR *dc_attr;
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 ))
1099 return FALSE;
1100 return NtGdiIntersectClipRect( hdc, left, top, right, bottom );
1103 /***********************************************************************
1104 * OffsetClipRgn (GDI32.@)
1106 INT WINAPI OffsetClipRgn( HDC hdc, INT x, INT y )
1108 DC_ATTR *dc_attr;
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 )
1121 DC_ATTR *dc_attr;
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 ))
1126 return FALSE;
1127 return NtGdiExcludeClipRect( hdc, left, top, right, bottom );
1130 /******************************************************************************
1131 * ExtSelectClipRgn (GDI32.@)
1133 INT WINAPI ExtSelectClipRgn( HDC hdc, HRGN hrgn, INT mode )
1135 DC_ATTR *dc_attr;
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 ))
1142 return FALSE;
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 )
1159 DC_ATTR *dc_attr;
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 /***********************************************************************
1167 * DPtoLP (GDI32.@)
1169 BOOL WINAPI DPtoLP( HDC hdc, POINT *points, INT count )
1171 return NtGdiTransformPoints( hdc, points, points, count, NtGdiDPtoLP );
1174 /***********************************************************************
1175 * LPtoDP (GDI32.@)
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)
1197 FIXME( "stub\n" );
1198 return TRUE;
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 */
1207 switch (mode)
1209 case ICM_OFF: return ICM_OFF;
1210 case ICM_ON: return 0;
1211 case ICM_QUERY: return ICM_OFF;
1213 return 0;
1216 /***********************************************************************
1217 * GdiIsMetaPrintDC (GDI32.@)
1219 BOOL WINAPI GdiIsMetaPrintDC( HDC hdc )
1221 FIXME( "%p\n", hdc );
1222 return FALSE;
1225 /***********************************************************************
1226 * GdiIsMetaFileDC (GDI32.@)
1228 BOOL WINAPI GdiIsMetaFileDC( HDC hdc )
1230 TRACE( "%p\n", hdc );
1232 switch (GetObjectType( hdc ))
1234 case OBJ_METADC:
1235 case OBJ_ENHMETADC:
1236 return TRUE;
1238 return FALSE;
1241 /***********************************************************************
1242 * GdiIsPlayMetafileDC (GDI32.@)
1244 BOOL WINAPI GdiIsPlayMetafileDC( HDC hdc )
1246 FIXME( "%p\n", hdc );
1247 return FALSE;