2 * GDI Device Context functions
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "gdi_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dc
);
39 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
41 static BOOL
DC_DeleteObject( HGDIOBJ handle
);
43 static const struct gdi_obj_funcs dc_funcs
=
45 NULL
, /* pSelectObject */
46 NULL
, /* pGetObjectA */
47 NULL
, /* pGetObjectW */
48 NULL
, /* pUnrealizeObject */
49 DC_DeleteObject
/* pDeleteObject */
53 static inline DC
*get_dc_obj( HDC hdc
)
55 DC
*dc
= GDI_GetObjPtr( hdc
, 0 );
58 if ((dc
->header
.type
!= OBJ_DC
) &&
59 (dc
->header
.type
!= OBJ_MEMDC
) &&
60 (dc
->header
.type
!= OBJ_METADC
) &&
61 (dc
->header
.type
!= OBJ_ENHMETADC
))
63 GDI_ReleaseObj( hdc
);
64 SetLastError( ERROR_INVALID_HANDLE
);
71 /***********************************************************************
74 DC
*alloc_dc_ptr( WORD magic
)
78 if (!(dc
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*dc
) ))) return NULL
;
80 dc
->nulldrv
.funcs
= &null_driver
;
81 dc
->physDev
= &dc
->nulldrv
;
82 dc
->thread
= GetCurrentThreadId();
88 dc
->miterLimit
= 10.0f
; /* 10.0 is the default, from MSDN */
89 dc
->hPen
= GDI_inc_ref_count( GetStockObject( BLACK_PEN
));
90 dc
->hBrush
= GDI_inc_ref_count( GetStockObject( WHITE_BRUSH
));
91 dc
->hFont
= GDI_inc_ref_count( GetStockObject( SYSTEM_FONT
));
92 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
93 dc
->font_code_page
= CP_ACP
;
94 dc
->ROPmode
= R2_COPYPEN
;
95 dc
->polyFillMode
= ALTERNATE
;
96 dc
->stretchBltMode
= BLACKONWHITE
;
97 dc
->relAbsMode
= ABSOLUTE
;
98 dc
->backgroundMode
= OPAQUE
;
99 dc
->backgroundColor
= RGB( 255, 255, 255 );
100 dc
->dcBrushColor
= RGB( 255, 255, 255 );
101 dc
->dcPenColor
= RGB( 0, 0, 0 );
102 dc
->textColor
= RGB( 0, 0, 0 );
103 dc
->textAlign
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
104 dc
->MapMode
= MM_TEXT
;
105 dc
->GraphicsMode
= GM_COMPATIBLE
;
106 dc
->ArcDirection
= AD_COUNTERCLOCKWISE
;
107 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
108 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
109 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
110 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
111 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
112 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
113 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
114 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
115 dc
->vport2WorldValid
= TRUE
;
117 if (!(dc
->hSelf
= alloc_gdi_handle( &dc
->header
, magic
, &dc_funcs
)))
119 HeapFree( GetProcessHeap(), 0, dc
);
122 dc
->nulldrv
.hdc
= dc
->hSelf
;
124 if (font_driver
&& !font_driver
->pCreateDC( &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
134 /***********************************************************************
137 static void free_dc_state( DC
*dc
)
139 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
140 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
141 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
142 if (dc
->region
) DeleteObject( dc
->region
);
143 if (dc
->path
) free_gdi_path( dc
->path
);
144 HeapFree( GetProcessHeap(), 0, dc
);
148 /***********************************************************************
151 void free_dc_ptr( DC
*dc
)
153 assert( dc
->refcount
== 1 );
155 while (dc
->physDev
!= &dc
->nulldrv
)
157 PHYSDEV physdev
= pop_dc_driver( &dc
->physDev
);
158 physdev
->funcs
->pDeleteDC( physdev
);
159 if (physdev
== dc
->dibdrv
) dc
->dibdrv
= NULL
;
161 if (dc
->dibdrv
) dc
->dibdrv
->funcs
->pDeleteDC( dc
->dibdrv
);
162 free_gdi_handle( dc
->hSelf
);
167 /***********************************************************************
170 * Retrieve a DC pointer but release the GDI lock.
172 DC
*get_dc_ptr( HDC hdc
)
174 DC
*dc
= get_dc_obj( hdc
);
175 if (!dc
) return NULL
;
177 if (!InterlockedCompareExchange( &dc
->refcount
, 1, 0 ))
179 dc
->thread
= GetCurrentThreadId();
181 else if (dc
->thread
!= GetCurrentThreadId())
183 WARN( "dc %p belongs to thread %04x\n", hdc
, dc
->thread
);
184 GDI_ReleaseObj( hdc
);
187 else InterlockedIncrement( &dc
->refcount
);
189 GDI_ReleaseObj( hdc
);
194 /***********************************************************************
197 void release_dc_ptr( DC
*dc
)
202 ref
= InterlockedDecrement( &dc
->refcount
);
204 if (ref
) dc
->thread
= GetCurrentThreadId(); /* we still own it */
208 /***********************************************************************
211 * Make sure the DC vis region is up to date.
212 * This function may call up to USER so the GDI lock should _not_
213 * be held when calling it.
215 void update_dc( DC
*dc
)
217 if (InterlockedExchange( &dc
->dirty
, 0 ) && dc
->hookProc
)
218 dc
->hookProc( dc
->hSelf
, DCHC_INVALIDVISRGN
, dc
->dwHookData
, 0 );
222 /***********************************************************************
225 static BOOL
DC_DeleteObject( HGDIOBJ handle
)
227 return DeleteDC( handle
);
231 /***********************************************************************
234 * Setup device-specific DC values for a newly created DC.
236 void DC_InitDC( DC
* dc
)
238 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRealizeDefaultPalette
);
239 physdev
->funcs
->pRealizeDefaultPalette( physdev
);
240 SetTextColor( dc
->hSelf
, dc
->textColor
);
241 SetBkColor( dc
->hSelf
, dc
->backgroundColor
);
242 SelectObject( dc
->hSelf
, dc
->hPen
);
243 SelectObject( dc
->hSelf
, dc
->hBrush
);
244 SelectObject( dc
->hSelf
, dc
->hFont
);
245 update_dc_clipping( dc
);
246 SetVirtualResolution( dc
->hSelf
, 0, 0, 0, 0 );
250 /***********************************************************************
253 * Computes the inverse of the transformation xformSrc and stores it to
254 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
257 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
261 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
262 xformSrc
->eM12
*xformSrc
->eM21
;
263 if (determinant
> -1e-12 && determinant
< 1e-12)
266 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
267 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
268 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
269 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
270 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
271 xformSrc
->eDy
* xformDest
->eM21
;
272 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
273 xformSrc
->eDy
* xformDest
->eM22
;
278 /* Construct a transformation to do the window-to-viewport conversion */
279 static void construct_window_to_viewport(DC
*dc
, XFORM
*xform
)
281 double scaleX
, scaleY
;
282 scaleX
= (double)dc
->vportExtX
/ (double)dc
->wndExtX
;
283 scaleY
= (double)dc
->vportExtY
/ (double)dc
->wndExtY
;
285 if (dc
->layout
& LAYOUT_RTL
) scaleX
= -scaleX
;
286 xform
->eM11
= scaleX
;
289 xform
->eM22
= scaleY
;
290 xform
->eDx
= (double)dc
->vportOrgX
- scaleX
* (double)dc
->wndOrgX
;
291 xform
->eDy
= (double)dc
->vportOrgY
- scaleY
* (double)dc
->wndOrgY
;
292 if (dc
->layout
& LAYOUT_RTL
) xform
->eDx
= dc
->vis_rect
.right
- dc
->vis_rect
.left
- 1 - xform
->eDx
;
295 /***********************************************************************
298 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
299 * fields of the specified DC by creating a transformation that
300 * represents the current mapping mode and combining it with the DC's
301 * world transform. This function should be called whenever the
302 * parameters associated with the mapping mode (window and viewport
303 * extents and origins) or the world transform change.
305 void DC_UpdateXforms( DC
*dc
)
307 XFORM xformWnd2Vport
, oldworld2vport
;
309 construct_window_to_viewport(dc
, &xformWnd2Vport
);
311 oldworld2vport
= dc
->xformWorld2Vport
;
312 /* Combine with the world transformation */
313 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
316 /* Create inverse of world-to-viewport transformation */
317 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
318 &dc
->xformVport2World
);
320 /* Reselect the font and pen back into the dc so that the size
322 if (memcmp(&oldworld2vport
, &dc
->xformWorld2Vport
, sizeof(oldworld2vport
)) &&
323 !GdiIsMetaFileDC(dc
->hSelf
))
325 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_FONT
));
326 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_PEN
));
331 /***********************************************************************
334 INT
nulldrv_SaveDC( PHYSDEV dev
)
336 DC
*newdc
, *dc
= get_nulldrv_dc( dev
);
338 if (!(newdc
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*newdc
)))) return 0;
339 newdc
->flags
= dc
->flags
;
340 newdc
->layout
= dc
->layout
;
341 newdc
->hPen
= dc
->hPen
;
342 newdc
->hBrush
= dc
->hBrush
;
343 newdc
->hFont
= dc
->hFont
;
344 newdc
->hBitmap
= dc
->hBitmap
;
345 newdc
->hDevice
= dc
->hDevice
;
346 newdc
->hPalette
= dc
->hPalette
;
347 newdc
->ROPmode
= dc
->ROPmode
;
348 newdc
->polyFillMode
= dc
->polyFillMode
;
349 newdc
->stretchBltMode
= dc
->stretchBltMode
;
350 newdc
->relAbsMode
= dc
->relAbsMode
;
351 newdc
->backgroundMode
= dc
->backgroundMode
;
352 newdc
->backgroundColor
= dc
->backgroundColor
;
353 newdc
->textColor
= dc
->textColor
;
354 newdc
->dcBrushColor
= dc
->dcBrushColor
;
355 newdc
->dcPenColor
= dc
->dcPenColor
;
356 newdc
->brushOrgX
= dc
->brushOrgX
;
357 newdc
->brushOrgY
= dc
->brushOrgY
;
358 newdc
->mapperFlags
= dc
->mapperFlags
;
359 newdc
->textAlign
= dc
->textAlign
;
360 newdc
->charExtra
= dc
->charExtra
;
361 newdc
->breakExtra
= dc
->breakExtra
;
362 newdc
->breakRem
= dc
->breakRem
;
363 newdc
->MapMode
= dc
->MapMode
;
364 newdc
->GraphicsMode
= dc
->GraphicsMode
;
365 newdc
->CursPosX
= dc
->CursPosX
;
366 newdc
->CursPosY
= dc
->CursPosY
;
367 newdc
->ArcDirection
= dc
->ArcDirection
;
368 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
369 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
370 newdc
->xformVport2World
= dc
->xformVport2World
;
371 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
372 newdc
->wndOrgX
= dc
->wndOrgX
;
373 newdc
->wndOrgY
= dc
->wndOrgY
;
374 newdc
->wndExtX
= dc
->wndExtX
;
375 newdc
->wndExtY
= dc
->wndExtY
;
376 newdc
->vportOrgX
= dc
->vportOrgX
;
377 newdc
->vportOrgY
= dc
->vportOrgY
;
378 newdc
->vportExtX
= dc
->vportExtX
;
379 newdc
->vportExtY
= dc
->vportExtY
;
380 newdc
->virtual_res
= dc
->virtual_res
;
381 newdc
->virtual_size
= dc
->virtual_size
;
382 newdc
->BoundsRect
= dc
->BoundsRect
;
383 newdc
->gdiFont
= dc
->gdiFont
;
385 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
389 newdc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
390 CombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
394 newdc
->hMetaRgn
= CreateRectRgn( 0, 0, 0, 0 );
395 CombineRgn( newdc
->hMetaRgn
, dc
->hMetaRgn
, 0, RGN_COPY
);
398 if (!PATH_SavePath( newdc
, dc
))
400 release_dc_ptr( dc
);
401 free_dc_state( newdc
);
405 newdc
->saved_dc
= dc
->saved_dc
;
406 dc
->saved_dc
= newdc
;
407 return ++dc
->saveLevel
;
411 /***********************************************************************
414 BOOL
nulldrv_RestoreDC( PHYSDEV dev
, INT level
)
416 DC
*dcs
, *first_dcs
, *dc
= get_nulldrv_dc( dev
);
419 /* find the state level to restore */
421 if (abs(level
) > dc
->saveLevel
|| level
== 0) return FALSE
;
422 if (level
< 0) level
= dc
->saveLevel
+ level
+ 1;
423 first_dcs
= dc
->saved_dc
;
424 for (dcs
= first_dcs
, save_level
= dc
->saveLevel
; save_level
> level
; save_level
--)
427 /* restore the state */
429 if (!PATH_RestorePath( dc
, dcs
)) return FALSE
;
431 dc
->flags
= dcs
->flags
;
432 dc
->layout
= dcs
->layout
;
433 dc
->hDevice
= dcs
->hDevice
;
434 dc
->ROPmode
= dcs
->ROPmode
;
435 dc
->polyFillMode
= dcs
->polyFillMode
;
436 dc
->stretchBltMode
= dcs
->stretchBltMode
;
437 dc
->relAbsMode
= dcs
->relAbsMode
;
438 dc
->backgroundMode
= dcs
->backgroundMode
;
439 dc
->backgroundColor
= dcs
->backgroundColor
;
440 dc
->textColor
= dcs
->textColor
;
441 dc
->dcBrushColor
= dcs
->dcBrushColor
;
442 dc
->dcPenColor
= dcs
->dcPenColor
;
443 dc
->brushOrgX
= dcs
->brushOrgX
;
444 dc
->brushOrgY
= dcs
->brushOrgY
;
445 dc
->mapperFlags
= dcs
->mapperFlags
;
446 dc
->textAlign
= dcs
->textAlign
;
447 dc
->charExtra
= dcs
->charExtra
;
448 dc
->breakExtra
= dcs
->breakExtra
;
449 dc
->breakRem
= dcs
->breakRem
;
450 dc
->MapMode
= dcs
->MapMode
;
451 dc
->GraphicsMode
= dcs
->GraphicsMode
;
452 dc
->CursPosX
= dcs
->CursPosX
;
453 dc
->CursPosY
= dcs
->CursPosY
;
454 dc
->ArcDirection
= dcs
->ArcDirection
;
455 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
456 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
457 dc
->xformVport2World
= dcs
->xformVport2World
;
458 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
459 dc
->BoundsRect
= dcs
->BoundsRect
;
461 dc
->wndOrgX
= dcs
->wndOrgX
;
462 dc
->wndOrgY
= dcs
->wndOrgY
;
463 dc
->wndExtX
= dcs
->wndExtX
;
464 dc
->wndExtY
= dcs
->wndExtY
;
465 dc
->vportOrgX
= dcs
->vportOrgX
;
466 dc
->vportOrgY
= dcs
->vportOrgY
;
467 dc
->vportExtX
= dcs
->vportExtX
;
468 dc
->vportExtY
= dcs
->vportExtY
;
469 dc
->virtual_res
= dcs
->virtual_res
;
470 dc
->virtual_size
= dcs
->virtual_size
;
474 if (!dc
->hClipRgn
) dc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
475 CombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
479 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
484 if (!dc
->hMetaRgn
) dc
->hMetaRgn
= CreateRectRgn( 0, 0, 0, 0 );
485 CombineRgn( dc
->hMetaRgn
, dcs
->hMetaRgn
, 0, RGN_COPY
);
489 if (dc
->hMetaRgn
) DeleteObject( dc
->hMetaRgn
);
492 DC_UpdateXforms( dc
);
493 update_dc_clipping( dc
);
495 SelectObject( dev
->hdc
, dcs
->hBitmap
);
496 SelectObject( dev
->hdc
, dcs
->hBrush
);
497 SelectObject( dev
->hdc
, dcs
->hFont
);
498 SelectObject( dev
->hdc
, dcs
->hPen
);
499 SetBkColor( dev
->hdc
, dcs
->backgroundColor
);
500 SetTextColor( dev
->hdc
, dcs
->textColor
);
501 GDISelectPalette( dev
->hdc
, dcs
->hPalette
, FALSE
);
503 dc
->saved_dc
= dcs
->saved_dc
;
505 dc
->saveLevel
= save_level
- 1;
507 /* now destroy all the saved DCs */
511 DC
*next
= first_dcs
->saved_dc
;
512 free_dc_state( first_dcs
);
519 /***********************************************************************
522 INT WINAPI
SaveDC( HDC hdc
)
527 if ((dc
= get_dc_ptr( hdc
)))
529 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSaveDC
);
530 ret
= physdev
->funcs
->pSaveDC( physdev
);
531 release_dc_ptr( dc
);
537 /***********************************************************************
538 * RestoreDC (GDI32.@)
540 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
543 BOOL success
= FALSE
;
545 TRACE("%p %d\n", hdc
, level
);
546 if ((dc
= get_dc_ptr( hdc
)))
548 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pRestoreDC
);
550 success
= physdev
->funcs
->pRestoreDC( physdev
, level
);
551 release_dc_ptr( dc
);
557 /***********************************************************************
558 * CreateDCW (GDI32.@)
560 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
561 const DEVMODEW
*initData
)
565 const struct gdi_dc_funcs
*funcs
;
570 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
574 ERR( "no device found for %s\n", debugstr_w(device
) );
577 strcpyW(buf
, driver
);
580 if (!(funcs
= DRIVER_load_driver( buf
)))
582 ERR( "no driver found for %s\n", debugstr_w(buf
) );
585 if (!(dc
= alloc_dc_ptr( OBJ_DC
))) return 0;
588 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
590 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
591 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
593 if (funcs
->pCreateDC
)
595 if (!funcs
->pCreateDC( &dc
->physDev
, buf
, device
, output
, initData
))
597 WARN("creation aborted by device\n" );
603 dc
->vis_rect
.left
= 0;
604 dc
->vis_rect
.top
= 0;
605 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
606 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
609 release_dc_ptr( dc
);
614 /***********************************************************************
615 * CreateDCA (GDI32.@)
617 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
618 const DEVMODEA
*initData
)
620 UNICODE_STRING driverW
, deviceW
, outputW
;
624 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
625 else driverW
.Buffer
= NULL
;
627 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
628 else deviceW
.Buffer
= NULL
;
630 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
631 else outputW
.Buffer
= NULL
;
636 /* don't convert initData for DISPLAY driver, it's not used */
637 if (!driverW
.Buffer
|| strcmpiW( driverW
.Buffer
, displayW
))
638 initDataW
= GdiConvertToDevmodeW(initData
);
641 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
643 RtlFreeUnicodeString(&driverW
);
644 RtlFreeUnicodeString(&deviceW
);
645 RtlFreeUnicodeString(&outputW
);
646 HeapFree(GetProcessHeap(), 0, initDataW
);
651 /***********************************************************************
652 * CreateICA (GDI32.@)
654 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
655 const DEVMODEA
* initData
)
657 /* Nothing special yet for ICs */
658 return CreateDCA( driver
, device
, output
, initData
);
662 /***********************************************************************
663 * CreateICW (GDI32.@)
665 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
666 const DEVMODEW
* initData
)
668 /* Nothing special yet for ICs */
669 return CreateDCW( driver
, device
, output
, initData
);
673 /***********************************************************************
674 * CreateCompatibleDC (GDI32.@)
676 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
680 const struct gdi_dc_funcs
*funcs
= &null_driver
;
681 PHYSDEV physDev
= NULL
;
687 if (!(origDC
= get_dc_ptr( hdc
))) return 0;
688 physDev
= GET_DC_PHYSDEV( origDC
, pCreateCompatibleDC
);
689 funcs
= physDev
->funcs
;
690 release_dc_ptr( origDC
);
693 if (!(dc
= alloc_dc_ptr( OBJ_MEMDC
))) return 0;
695 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
697 dc
->hBitmap
= GDI_inc_ref_count( GetStockObject( DEFAULT_BITMAP
));
698 dc
->vis_rect
.left
= 0;
699 dc
->vis_rect
.top
= 0;
700 dc
->vis_rect
.right
= 1;
701 dc
->vis_rect
.bottom
= 1;
705 if (!funcs
->pCreateCompatibleDC( physDev
, &dc
->physDev
))
707 WARN("creation aborted by device\n");
712 release_dc_ptr( dc
);
717 /***********************************************************************
720 BOOL WINAPI
DeleteDC( HDC hdc
)
728 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
729 if (dc
->refcount
!= 1)
731 FIXME( "not deleting busy DC %p refcount %u\n", dc
->hSelf
, dc
->refcount
);
732 release_dc_ptr( dc
);
736 /* Call hook procedure to check whether is it OK to delete this DC */
737 if (dc
->hookProc
&& !dc
->hookProc( hdc
, DCHC_DELETEDC
, dc
->dwHookData
, 0 ))
739 release_dc_ptr( dc
);
743 while (dc
->saveLevel
)
745 DC
*dcs
= dc
->saved_dc
;
746 dc
->saved_dc
= dcs
->saved_dc
;
748 free_dc_state( dcs
);
752 SelectObject( hdc
, GetStockObject(BLACK_PEN
) );
753 SelectObject( hdc
, GetStockObject(WHITE_BRUSH
) );
754 SelectObject( hdc
, GetStockObject(SYSTEM_FONT
) );
755 SelectObject( hdc
, GetStockObject(DEFAULT_BITMAP
) );
762 /***********************************************************************
765 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
770 if ((dc
= get_dc_ptr( hdc
)))
772 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pResetDC
);
773 ret
= physdev
->funcs
->pResetDC( physdev
, devmode
);
774 if (ret
) /* reset the visible region */
777 dc
->vis_rect
.left
= 0;
778 dc
->vis_rect
.top
= 0;
779 dc
->vis_rect
.right
= GetDeviceCaps( hdc
, DESKTOPHORZRES
);
780 dc
->vis_rect
.bottom
= GetDeviceCaps( hdc
, DESKTOPVERTRES
);
781 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
783 update_dc_clipping( dc
);
785 release_dc_ptr( dc
);
791 /***********************************************************************
794 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
799 if (devmode
) devmodeW
= GdiConvertToDevmodeW(devmode
);
800 else devmodeW
= NULL
;
802 ret
= ResetDCW(hdc
, devmodeW
);
804 HeapFree(GetProcessHeap(), 0, devmodeW
);
809 /***********************************************************************
810 * GetDeviceCaps (GDI32.@)
812 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
817 if ((dc
= get_dc_ptr( hdc
)))
819 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceCaps
);
820 ret
= physdev
->funcs
->pGetDeviceCaps( physdev
, cap
);
821 release_dc_ptr( dc
);
827 /***********************************************************************
828 * GetBkColor (GDI32.@)
830 COLORREF WINAPI
GetBkColor( HDC hdc
)
833 DC
* dc
= get_dc_ptr( hdc
);
836 ret
= dc
->backgroundColor
;
837 release_dc_ptr( dc
);
843 /***********************************************************************
844 * SetBkColor (GDI32.@)
846 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
848 COLORREF ret
= CLR_INVALID
;
849 DC
* dc
= get_dc_ptr( hdc
);
851 TRACE("hdc=%p color=0x%08x\n", hdc
, color
);
855 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkColor
);
856 color
= physdev
->funcs
->pSetBkColor( physdev
, color
);
857 if (color
!= CLR_INVALID
)
859 ret
= dc
->backgroundColor
;
860 dc
->backgroundColor
= color
;
862 release_dc_ptr( dc
);
868 /***********************************************************************
869 * GetTextColor (GDI32.@)
871 COLORREF WINAPI
GetTextColor( HDC hdc
)
874 DC
* dc
= get_dc_ptr( hdc
);
878 release_dc_ptr( dc
);
884 /***********************************************************************
885 * SetTextColor (GDI32.@)
887 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
889 COLORREF ret
= CLR_INVALID
;
890 DC
* dc
= get_dc_ptr( hdc
);
892 TRACE(" hdc=%p color=0x%08x\n", hdc
, color
);
896 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextColor
);
897 color
= physdev
->funcs
->pSetTextColor( physdev
, color
);
898 if (color
!= CLR_INVALID
)
901 dc
->textColor
= color
;
903 release_dc_ptr( dc
);
909 /***********************************************************************
910 * GetTextAlign (GDI32.@)
912 UINT WINAPI
GetTextAlign( HDC hdc
)
915 DC
* dc
= get_dc_ptr( hdc
);
919 release_dc_ptr( dc
);
925 /***********************************************************************
926 * SetTextAlign (GDI32.@)
928 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
930 UINT ret
= GDI_ERROR
;
931 DC
*dc
= get_dc_ptr( hdc
);
933 TRACE("hdc=%p align=%d\n", hdc
, align
);
937 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetTextAlign
);
938 align
= physdev
->funcs
->pSetTextAlign( physdev
, align
);
939 if (align
!= GDI_ERROR
)
942 dc
->textAlign
= align
;
944 release_dc_ptr( dc
);
949 /***********************************************************************
950 * GetDCOrgEx (GDI32.@)
952 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
956 if (!lpp
) return FALSE
;
957 if (!(dc
= get_dc_ptr( hDC
))) return FALSE
;
958 lpp
->x
= dc
->vis_rect
.left
;
959 lpp
->y
= dc
->vis_rect
.top
;
960 release_dc_ptr( dc
);
965 /***********************************************************************
966 * GetGraphicsMode (GDI32.@)
968 INT WINAPI
GetGraphicsMode( HDC hdc
)
971 DC
* dc
= get_dc_ptr( hdc
);
974 ret
= dc
->GraphicsMode
;
975 release_dc_ptr( dc
);
981 /***********************************************************************
982 * SetGraphicsMode (GDI32.@)
984 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
987 DC
*dc
= get_dc_ptr( hdc
);
989 /* One would think that setting the graphics mode to GM_COMPATIBLE
990 * would also reset the world transformation matrix to the unity
991 * matrix. However, in Windows, this is not the case. This doesn't
992 * make a lot of sense to me, but that's the way it is.
995 if ((mode
> 0) && (mode
<= GM_LAST
))
997 ret
= dc
->GraphicsMode
;
998 dc
->GraphicsMode
= mode
;
1000 release_dc_ptr( dc
);
1005 /***********************************************************************
1006 * GetArcDirection (GDI32.@)
1008 INT WINAPI
GetArcDirection( HDC hdc
)
1011 DC
* dc
= get_dc_ptr( hdc
);
1014 ret
= dc
->ArcDirection
;
1015 release_dc_ptr( dc
);
1021 /***********************************************************************
1022 * SetArcDirection (GDI32.@)
1024 INT WINAPI
SetArcDirection( HDC hdc
, INT dir
)
1029 if (dir
!= AD_COUNTERCLOCKWISE
&& dir
!= AD_CLOCKWISE
)
1031 SetLastError(ERROR_INVALID_PARAMETER
);
1035 if ((dc
= get_dc_ptr( hdc
)))
1037 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetArcDirection
);
1038 dir
= physdev
->funcs
->pSetArcDirection( physdev
, dir
);
1041 ret
= dc
->ArcDirection
;
1042 dc
->ArcDirection
= dir
;
1044 release_dc_ptr( dc
);
1050 /***********************************************************************
1051 * GetWorldTransform (GDI32.@)
1053 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
1056 if (!xform
) return FALSE
;
1057 if (!(dc
= get_dc_ptr( hdc
))) return FALSE
;
1058 *xform
= dc
->xformWorld2Wnd
;
1059 release_dc_ptr( dc
);
1064 /***********************************************************************
1065 * GetTransform (GDI32.@)
1069 * Returns one of the co-ordinate space transforms
1072 * hdc [I] Device context.
1073 * which [I] Which xform to return:
1074 * 0x203 World -> Page transform (that set by SetWorldTransform).
1075 * 0x304 Page -> Device transform (the mapping mode transform).
1076 * 0x204 World -> Device transform (the combination of the above two).
1077 * 0x402 Device -> World transform (the inversion of the above).
1078 * xform [O] The xform.
1081 BOOL WINAPI
GetTransform( HDC hdc
, DWORD which
, XFORM
*xform
)
1084 DC
*dc
= get_dc_ptr( hdc
);
1085 if (!dc
) return FALSE
;
1090 *xform
= dc
->xformWorld2Wnd
;
1094 construct_window_to_viewport(dc
, xform
);
1098 *xform
= dc
->xformWorld2Vport
;
1102 *xform
= dc
->xformVport2World
;
1106 FIXME("Unknown code %x\n", which
);
1110 release_dc_ptr( dc
);
1115 /****************************************************************************
1116 * CombineTransform [GDI32.@]
1117 * Combines two transformation matrices.
1120 * xformResult [O] Stores the result of combining the two matrices
1121 * xform1 [I] Specifies the first matrix to apply
1122 * xform2 [I] Specifies the second matrix to apply
1125 * The same matrix can be passed in for more than one of the parameters.
1129 * Failure: FALSE. Use GetLastError() to determine the cause.
1131 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1132 const XFORM
*xform2
)
1136 /* Check for illegal parameters */
1137 if (!xformResult
|| !xform1
|| !xform2
)
1140 /* Create the result in a temporary XFORM, since xformResult may be
1141 * equal to xform1 or xform2 */
1142 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1143 xform1
->eM12
* xform2
->eM21
;
1144 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1145 xform1
->eM12
* xform2
->eM22
;
1146 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1147 xform1
->eM22
* xform2
->eM21
;
1148 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1149 xform1
->eM22
* xform2
->eM22
;
1150 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1151 xform1
->eDy
* xform2
->eM21
+
1153 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1154 xform1
->eDy
* xform2
->eM22
+
1157 /* Copy the result to xformResult */
1158 *xformResult
= xformTemp
;
1164 /***********************************************************************
1165 * SetDCHook (GDI32.@)
1167 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1169 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD_PTR dwHookData
)
1171 DC
*dc
= get_dc_ptr( hdc
);
1173 if (!dc
) return FALSE
;
1175 dc
->dwHookData
= dwHookData
;
1176 dc
->hookProc
= hookProc
;
1177 release_dc_ptr( dc
);
1182 /***********************************************************************
1183 * GetDCHook (GDI32.@)
1185 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1187 DWORD_PTR WINAPI
GetDCHook( HDC hdc
, DCHOOKPROC
*proc
)
1189 DC
*dc
= get_dc_ptr( hdc
);
1193 if (proc
) *proc
= dc
->hookProc
;
1194 ret
= dc
->dwHookData
;
1195 release_dc_ptr( dc
);
1200 /***********************************************************************
1201 * SetHookFlags (GDI32.@)
1203 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1205 WORD WINAPI
SetHookFlags( HDC hdc
, WORD flags
)
1207 DC
*dc
= get_dc_obj( hdc
); /* not get_dc_ptr, this needs to work from any thread */
1212 /* "Undocumented Windows" info is slightly confusing. */
1214 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1216 if (flags
& DCHF_INVALIDATEVISRGN
)
1217 ret
= InterlockedExchange( &dc
->dirty
, 1 );
1218 else if (flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1219 ret
= InterlockedExchange( &dc
->dirty
, 0 );
1221 GDI_ReleaseObj( hdc
);
1225 /***********************************************************************
1226 * SetICMMode (GDI32.@)
1228 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1230 /*FIXME: Assume that ICM is always off, and cannot be turned on */
1231 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1232 if (iEnableICM
== ICM_ON
) return 0;
1233 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1237 /***********************************************************************
1238 * GetDeviceGammaRamp (GDI32.@)
1240 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1243 DC
*dc
= get_dc_ptr( hDC
);
1245 TRACE("%p, %p\n", hDC
, ptr
);
1248 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pGetDeviceGammaRamp
);
1249 ret
= physdev
->funcs
->pGetDeviceGammaRamp( physdev
, ptr
);
1250 release_dc_ptr( dc
);
1255 /***********************************************************************
1256 * SetDeviceGammaRamp (GDI32.@)
1258 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1261 DC
*dc
= get_dc_ptr( hDC
);
1263 TRACE("%p, %p\n", hDC
, ptr
);
1266 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDeviceGammaRamp
);
1267 ret
= physdev
->funcs
->pSetDeviceGammaRamp( physdev
, ptr
);
1268 release_dc_ptr( dc
);
1273 /***********************************************************************
1274 * GetColorSpace (GDI32.@)
1276 HCOLORSPACE WINAPI
GetColorSpace(HDC hdc
)
1278 /*FIXME Need to do whatever GetColorSpace actually does */
1282 /***********************************************************************
1283 * CreateColorSpaceA (GDI32.@)
1285 HCOLORSPACE WINAPI
CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace
)
1291 /***********************************************************************
1292 * CreateColorSpaceW (GDI32.@)
1294 HCOLORSPACE WINAPI
CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace
)
1300 /***********************************************************************
1301 * DeleteColorSpace (GDI32.@)
1303 BOOL WINAPI
DeleteColorSpace( HCOLORSPACE hColorSpace
)
1310 /***********************************************************************
1311 * SetColorSpace (GDI32.@)
1313 HCOLORSPACE WINAPI
SetColorSpace( HDC hDC
, HCOLORSPACE hColorSpace
)
1320 /***********************************************************************
1321 * GetBoundsRect (GDI32.@)
1323 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1326 DC
*dc
= get_dc_ptr( hdc
);
1328 if ( !dc
) return 0;
1332 *rect
= dc
->BoundsRect
;
1333 ret
= is_rect_empty( rect
) ? DCB_RESET
: DCB_SET
;
1334 DPtoLP( hdc
, (POINT
*)rect
, 2 );
1336 if (flags
& DCB_RESET
)
1338 dc
->BoundsRect
.left
= 0;
1339 dc
->BoundsRect
.top
= 0;
1340 dc
->BoundsRect
.right
= 0;
1341 dc
->BoundsRect
.bottom
= 0;
1343 release_dc_ptr( dc
);
1348 /***********************************************************************
1349 * SetBoundsRect (GDI32.@)
1351 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1356 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
1357 if (!(dc
= get_dc_ptr( hdc
))) return 0;
1359 ret
= ((dc
->flags
& DC_BOUNDS_ENABLE
) ? DCB_ENABLE
: DCB_DISABLE
) |
1360 (is_rect_empty( &dc
->BoundsRect
) ? DCB_RESET
: DCB_SET
);
1362 if (flags
& DCB_RESET
)
1364 dc
->BoundsRect
.left
= 0;
1365 dc
->BoundsRect
.top
= 0;
1366 dc
->BoundsRect
.right
= 0;
1367 dc
->BoundsRect
.bottom
= 0;
1370 if ((flags
& DCB_ACCUMULATE
) && rect
)
1374 LPtoDP( hdc
, (POINT
*)&rc
, 2 );
1375 if (!is_rect_empty( &rc
))
1377 if (!is_rect_empty( &dc
->BoundsRect
))
1379 dc
->BoundsRect
.left
= min( dc
->BoundsRect
.left
, rc
.left
);
1380 dc
->BoundsRect
.top
= min( dc
->BoundsRect
.top
, rc
.top
);
1381 dc
->BoundsRect
.right
= max( dc
->BoundsRect
.right
, rc
.right
);
1382 dc
->BoundsRect
.bottom
= max( dc
->BoundsRect
.bottom
, rc
.bottom
);
1384 else dc
->BoundsRect
= rc
;
1388 if (flags
& DCB_ENABLE
) dc
->flags
|= DC_BOUNDS_ENABLE
;
1389 if (flags
& DCB_DISABLE
) dc
->flags
&= ~DC_BOUNDS_ENABLE
;
1391 release_dc_ptr( dc
);
1396 /***********************************************************************
1397 * GetRelAbs (GDI32.@)
1399 INT WINAPI
GetRelAbs( HDC hdc
, DWORD dwIgnore
)
1402 DC
*dc
= get_dc_ptr( hdc
);
1405 ret
= dc
->relAbsMode
;
1406 release_dc_ptr( dc
);
1414 /***********************************************************************
1415 * GetBkMode (GDI32.@)
1417 INT WINAPI
GetBkMode( HDC hdc
)
1420 DC
* dc
= get_dc_ptr( hdc
);
1423 ret
= dc
->backgroundMode
;
1424 release_dc_ptr( dc
);
1430 /***********************************************************************
1431 * SetBkMode (GDI32.@)
1433 INT WINAPI
SetBkMode( HDC hdc
, INT mode
)
1438 if ((mode
<= 0) || (mode
> BKMODE_LAST
))
1440 SetLastError(ERROR_INVALID_PARAMETER
);
1443 if ((dc
= get_dc_ptr( hdc
)))
1445 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetBkMode
);
1446 mode
= physdev
->funcs
->pSetBkMode( physdev
, mode
);
1449 ret
= dc
->backgroundMode
;
1450 dc
->backgroundMode
= mode
;
1452 release_dc_ptr( dc
);
1458 /***********************************************************************
1461 INT WINAPI
GetROP2( HDC hdc
)
1464 DC
* dc
= get_dc_ptr( hdc
);
1468 release_dc_ptr( dc
);
1474 /***********************************************************************
1477 INT WINAPI
SetROP2( HDC hdc
, INT mode
)
1482 if ((mode
< R2_BLACK
) || (mode
> R2_WHITE
))
1484 SetLastError(ERROR_INVALID_PARAMETER
);
1487 if ((dc
= get_dc_ptr( hdc
)))
1489 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetROP2
);
1490 mode
= physdev
->funcs
->pSetROP2( physdev
, mode
);
1496 release_dc_ptr( dc
);
1502 /***********************************************************************
1503 * SetRelAbs (GDI32.@)
1505 INT WINAPI
SetRelAbs( HDC hdc
, INT mode
)
1510 if ((mode
!= ABSOLUTE
) && (mode
!= RELATIVE
))
1512 SetLastError(ERROR_INVALID_PARAMETER
);
1515 if ((dc
= get_dc_ptr( hdc
)))
1517 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetRelAbs
);
1518 mode
= physdev
->funcs
->pSetRelAbs( physdev
, mode
);
1521 ret
= dc
->relAbsMode
;
1522 dc
->relAbsMode
= mode
;
1524 release_dc_ptr( dc
);
1530 /***********************************************************************
1531 * GetPolyFillMode (GDI32.@)
1533 INT WINAPI
GetPolyFillMode( HDC hdc
)
1536 DC
* dc
= get_dc_ptr( hdc
);
1539 ret
= dc
->polyFillMode
;
1540 release_dc_ptr( dc
);
1546 /***********************************************************************
1547 * SetPolyFillMode (GDI32.@)
1549 INT WINAPI
SetPolyFillMode( HDC hdc
, INT mode
)
1554 if ((mode
<= 0) || (mode
> POLYFILL_LAST
))
1556 SetLastError(ERROR_INVALID_PARAMETER
);
1559 if ((dc
= get_dc_ptr( hdc
)))
1561 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetPolyFillMode
);
1562 mode
= physdev
->funcs
->pSetPolyFillMode( physdev
, mode
);
1565 ret
= dc
->polyFillMode
;
1566 dc
->polyFillMode
= mode
;
1568 release_dc_ptr( dc
);
1574 /***********************************************************************
1575 * GetStretchBltMode (GDI32.@)
1577 INT WINAPI
GetStretchBltMode( HDC hdc
)
1580 DC
* dc
= get_dc_ptr( hdc
);
1583 ret
= dc
->stretchBltMode
;
1584 release_dc_ptr( dc
);
1590 /***********************************************************************
1591 * SetStretchBltMode (GDI32.@)
1593 INT WINAPI
SetStretchBltMode( HDC hdc
, INT mode
)
1598 if ((mode
<= 0) || (mode
> MAXSTRETCHBLTMODE
))
1600 SetLastError(ERROR_INVALID_PARAMETER
);
1603 if ((dc
= get_dc_ptr( hdc
)))
1605 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetStretchBltMode
);
1606 mode
= physdev
->funcs
->pSetStretchBltMode( physdev
, mode
);
1609 ret
= dc
->stretchBltMode
;
1610 dc
->stretchBltMode
= mode
;
1612 release_dc_ptr( dc
);
1618 /***********************************************************************
1619 * GetMapMode (GDI32.@)
1621 INT WINAPI
GetMapMode( HDC hdc
)
1624 DC
* dc
= get_dc_ptr( hdc
);
1628 release_dc_ptr( dc
);
1634 /***********************************************************************
1635 * GetBrushOrgEx (GDI32.@)
1637 BOOL WINAPI
GetBrushOrgEx( HDC hdc
, LPPOINT pt
)
1639 DC
* dc
= get_dc_ptr( hdc
);
1640 if (!dc
) return FALSE
;
1641 pt
->x
= dc
->brushOrgX
;
1642 pt
->y
= dc
->brushOrgY
;
1643 release_dc_ptr( dc
);
1648 /***********************************************************************
1649 * GetCurrentPositionEx (GDI32.@)
1651 BOOL WINAPI
GetCurrentPositionEx( HDC hdc
, LPPOINT pt
)
1653 DC
* dc
= get_dc_ptr( hdc
);
1654 if (!dc
) return FALSE
;
1655 pt
->x
= dc
->CursPosX
;
1656 pt
->y
= dc
->CursPosY
;
1657 release_dc_ptr( dc
);
1662 /***********************************************************************
1663 * GetViewportExtEx (GDI32.@)
1665 BOOL WINAPI
GetViewportExtEx( HDC hdc
, LPSIZE size
)
1667 DC
* dc
= get_dc_ptr( hdc
);
1668 if (!dc
) return FALSE
;
1669 size
->cx
= dc
->vportExtX
;
1670 size
->cy
= dc
->vportExtY
;
1671 release_dc_ptr( dc
);
1676 /***********************************************************************
1677 * GetViewportOrgEx (GDI32.@)
1679 BOOL WINAPI
GetViewportOrgEx( HDC hdc
, LPPOINT pt
)
1681 DC
* dc
= get_dc_ptr( hdc
);
1682 if (!dc
) return FALSE
;
1683 pt
->x
= dc
->vportOrgX
;
1684 pt
->y
= dc
->vportOrgY
;
1685 release_dc_ptr( dc
);
1690 /***********************************************************************
1691 * GetWindowExtEx (GDI32.@)
1693 BOOL WINAPI
GetWindowExtEx( HDC hdc
, LPSIZE size
)
1695 DC
* dc
= get_dc_ptr( hdc
);
1696 if (!dc
) return FALSE
;
1697 size
->cx
= dc
->wndExtX
;
1698 size
->cy
= dc
->wndExtY
;
1699 release_dc_ptr( dc
);
1704 /***********************************************************************
1705 * GetWindowOrgEx (GDI32.@)
1707 BOOL WINAPI
GetWindowOrgEx( HDC hdc
, LPPOINT pt
)
1709 DC
* dc
= get_dc_ptr( hdc
);
1710 if (!dc
) return FALSE
;
1711 pt
->x
= dc
->wndOrgX
;
1712 pt
->y
= dc
->wndOrgY
;
1713 release_dc_ptr( dc
);
1718 /***********************************************************************
1719 * GetLayout (GDI32.@)
1721 * Gets left->right or right->left text layout flags of a dc.
1724 DWORD WINAPI
GetLayout(HDC hdc
)
1726 DWORD layout
= GDI_ERROR
;
1728 DC
* dc
= get_dc_ptr( hdc
);
1731 layout
= dc
->layout
;
1732 release_dc_ptr( dc
);
1735 TRACE("hdc : %p, layout : %08x\n", hdc
, layout
);
1740 /***********************************************************************
1741 * SetLayout (GDI32.@)
1743 * Sets left->right or right->left text layout flags of a dc.
1746 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1748 DWORD oldlayout
= GDI_ERROR
;
1750 DC
* dc
= get_dc_ptr( hdc
);
1753 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetLayout
);
1754 layout
= physdev
->funcs
->pSetLayout( physdev
, layout
);
1755 if (layout
!= GDI_ERROR
)
1757 oldlayout
= dc
->layout
;
1758 dc
->layout
= layout
;
1759 if (layout
!= oldlayout
)
1761 if (layout
& LAYOUT_RTL
) dc
->MapMode
= MM_ANISOTROPIC
;
1762 DC_UpdateXforms( dc
);
1765 release_dc_ptr( dc
);
1768 TRACE("hdc : %p, old layout : %08x, new layout : %08x\n", hdc
, oldlayout
, layout
);
1773 /***********************************************************************
1774 * GetDCBrushColor (GDI32.@)
1776 COLORREF WINAPI
GetDCBrushColor(HDC hdc
)
1779 COLORREF dcBrushColor
= CLR_INVALID
;
1781 TRACE("hdc(%p)\n", hdc
);
1783 dc
= get_dc_ptr( hdc
);
1786 dcBrushColor
= dc
->dcBrushColor
;
1787 release_dc_ptr( dc
);
1790 return dcBrushColor
;
1793 /***********************************************************************
1794 * SetDCBrushColor (GDI32.@)
1796 COLORREF WINAPI
SetDCBrushColor(HDC hdc
, COLORREF crColor
)
1799 COLORREF oldClr
= CLR_INVALID
;
1801 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1803 dc
= get_dc_ptr( hdc
);
1806 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCBrushColor
);
1807 crColor
= physdev
->funcs
->pSetDCBrushColor( physdev
, crColor
);
1808 if (crColor
!= CLR_INVALID
)
1810 oldClr
= dc
->dcBrushColor
;
1811 dc
->dcBrushColor
= crColor
;
1813 release_dc_ptr( dc
);
1819 /***********************************************************************
1820 * GetDCPenColor (GDI32.@)
1822 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
1825 COLORREF dcPenColor
= CLR_INVALID
;
1827 TRACE("hdc(%p)\n", hdc
);
1829 dc
= get_dc_ptr( hdc
);
1832 dcPenColor
= dc
->dcPenColor
;
1833 release_dc_ptr( dc
);
1839 /***********************************************************************
1840 * SetDCPenColor (GDI32.@)
1842 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1845 COLORREF oldClr
= CLR_INVALID
;
1847 TRACE("hdc(%p) crColor(%08x)\n", hdc
, crColor
);
1849 dc
= get_dc_ptr( hdc
);
1852 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSetDCPenColor
);
1853 crColor
= physdev
->funcs
->pSetDCPenColor( physdev
, crColor
);
1854 if (crColor
!= CLR_INVALID
)
1856 oldClr
= dc
->dcPenColor
;
1857 dc
->dcPenColor
= crColor
;
1859 release_dc_ptr( dc
);
1865 /***********************************************************************
1866 * CancelDC (GDI32.@)
1868 BOOL WINAPI
CancelDC(HDC hdc
)
1874 /*******************************************************************
1875 * GetMiterLimit [GDI32.@]
1879 BOOL WINAPI
GetMiterLimit(HDC hdc
, PFLOAT peLimit
)
1884 TRACE("(%p,%p)\n", hdc
, peLimit
);
1886 dc
= get_dc_ptr( hdc
);
1890 *peLimit
= dc
->miterLimit
;
1892 release_dc_ptr( dc
);
1898 /*******************************************************************
1899 * SetMiterLimit [GDI32.@]
1903 BOOL WINAPI
SetMiterLimit(HDC hdc
, FLOAT eNewLimit
, PFLOAT peOldLimit
)
1908 TRACE("(%p,%f,%p)\n", hdc
, eNewLimit
, peOldLimit
);
1910 dc
= get_dc_ptr( hdc
);
1914 *peOldLimit
= dc
->miterLimit
;
1915 dc
->miterLimit
= eNewLimit
;
1916 release_dc_ptr( dc
);
1922 /*******************************************************************
1923 * GdiIsMetaPrintDC [GDI32.@]
1925 BOOL WINAPI
GdiIsMetaPrintDC(HDC hdc
)
1931 /*******************************************************************
1932 * GdiIsMetaFileDC [GDI32.@]
1934 BOOL WINAPI
GdiIsMetaFileDC(HDC hdc
)
1938 switch( GetObjectType( hdc
) )
1947 /*******************************************************************
1948 * GdiIsPlayMetafileDC [GDI32.@]
1950 BOOL WINAPI
GdiIsPlayMetafileDC(HDC hdc
)