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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "wine/winuser16.h"
35 #include "wine/unicode.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dc
);
40 static BOOL
DC_DeleteObject( HGDIOBJ handle
, void *obj
);
42 static const struct gdi_obj_funcs dc_funcs
=
44 NULL
, /* pSelectObject */
45 NULL
, /* pGetObject16 */
46 NULL
, /* pGetObjectA */
47 NULL
, /* pGetObjectW */
48 NULL
, /* pUnrealizeObject */
49 DC_DeleteObject
/* pDeleteObject */
52 /***********************************************************************
55 DC
*DC_AllocDC( const DC_FUNCTIONS
*funcs
, WORD magic
)
60 if (!(dc
= GDI_AllocObject( sizeof(*dc
), magic
, (HGDIOBJ
*)&hdc
, &dc_funcs
))) return NULL
;
81 dc
->hPen
= GetStockObject( BLACK_PEN
);
82 dc
->hBrush
= GetStockObject( WHITE_BRUSH
);
83 dc
->hFont
= GetStockObject( SYSTEM_FONT
);
86 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
88 dc
->ROPmode
= R2_COPYPEN
;
89 dc
->polyFillMode
= ALTERNATE
;
90 dc
->stretchBltMode
= BLACKONWHITE
;
91 dc
->relAbsMode
= ABSOLUTE
;
92 dc
->backgroundMode
= OPAQUE
;
93 dc
->backgroundColor
= RGB( 255, 255, 255 );
94 dc
->dcBrushColor
= RGB( 255, 255, 255 );
95 dc
->dcPenColor
= RGB( 0, 0, 0 );
96 dc
->textColor
= RGB( 0, 0, 0 );
99 dc
->textAlign
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
101 dc
->breakTotalExtra
= 0;
105 dc
->totalExtent
.left
= 0;
106 dc
->totalExtent
.top
= 0;
107 dc
->totalExtent
.right
= 0;
108 dc
->totalExtent
.bottom
= 0;
109 dc
->bitsPerPixel
= 1;
110 dc
->MapMode
= MM_TEXT
;
111 dc
->GraphicsMode
= GM_COMPATIBLE
;
112 dc
->pAbortProc
= NULL
;
115 dc
->ArcDirection
= AD_COUNTERCLOCKWISE
;
116 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
117 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
118 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
119 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
120 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
121 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
122 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
123 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
124 dc
->vport2WorldValid
= TRUE
;
125 PATH_InitGdiPath(&dc
->path
);
131 /***********************************************************************
134 DC
*DC_GetDCPtr( HDC hdc
)
136 GDIOBJHDR
*ptr
= GDI_GetObjPtr( hdc
, MAGIC_DONTCARE
);
137 if (!ptr
) return NULL
;
138 if ((GDIMAGIC(ptr
->wMagic
) == DC_MAGIC
) ||
139 (GDIMAGIC(ptr
->wMagic
) == MEMORY_DC_MAGIC
) ||
140 (GDIMAGIC(ptr
->wMagic
) == METAFILE_DC_MAGIC
) ||
141 (GDIMAGIC(ptr
->wMagic
) == ENHMETAFILE_DC_MAGIC
))
143 GDI_ReleaseObj( hdc
);
144 SetLastError( ERROR_INVALID_HANDLE
);
148 /***********************************************************************
151 * Retrieve a DC ptr while making sure the visRgn is updated.
152 * This function may call up to USER so the GDI lock should _not_
153 * be held when calling it.
155 DC
*DC_GetDCUpdate( HDC hdc
)
157 DC
*dc
= DC_GetDCPtr( hdc
);
158 if (!dc
) return NULL
;
159 while (dc
->flags
& DC_DIRTY
)
161 DCHOOKPROC proc
= dc
->hookThunk
;
162 dc
->flags
&= ~DC_DIRTY
;
165 DWORD data
= dc
->dwHookData
;
166 GDI_ReleaseObj( hdc
);
167 proc( HDC_16(hdc
), DCHC_INVALIDVISRGN
, data
, 0 );
168 if (!(dc
= DC_GetDCPtr( hdc
))) break;
169 /* otherwise restart the loop in case it became dirty again in the meantime */
176 /***********************************************************************
179 static BOOL
DC_DeleteObject( HGDIOBJ handle
, void *obj
)
181 GDI_ReleaseObj( handle
);
182 return DeleteDC( handle
);
186 /***********************************************************************
189 * Setup device-specific DC values for a newly created DC.
191 void DC_InitDC( DC
* dc
)
193 if (dc
->funcs
->pRealizeDefaultPalette
) dc
->funcs
->pRealizeDefaultPalette( dc
->physDev
);
194 SetTextColor( dc
->hSelf
, dc
->textColor
);
195 SetBkColor( dc
->hSelf
, dc
->backgroundColor
);
196 SelectObject( dc
->hSelf
, dc
->hPen
);
197 SelectObject( dc
->hSelf
, dc
->hBrush
);
198 SelectObject( dc
->hSelf
, dc
->hFont
);
199 CLIPPING_UpdateGCRegion( dc
);
203 /***********************************************************************
206 * Computes the inverse of the transformation xformSrc and stores it to
207 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
210 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
214 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
215 xformSrc
->eM12
*xformSrc
->eM21
;
216 if (determinant
> -1e-12 && determinant
< 1e-12)
219 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
220 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
221 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
222 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
223 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
224 xformSrc
->eDy
* xformDest
->eM21
;
225 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
226 xformSrc
->eDy
* xformDest
->eM22
;
232 /***********************************************************************
235 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
236 * fields of the specified DC by creating a transformation that
237 * represents the current mapping mode and combining it with the DC's
238 * world transform. This function should be called whenever the
239 * parameters associated with the mapping mode (window and viewport
240 * extents and origins) or the world transform change.
242 void DC_UpdateXforms( DC
*dc
)
244 XFORM xformWnd2Vport
, oldworld2vport
;
245 FLOAT scaleX
, scaleY
;
247 /* Construct a transformation to do the window-to-viewport conversion */
248 scaleX
= (FLOAT
)dc
->vportExtX
/ (FLOAT
)dc
->wndExtX
;
249 scaleY
= (FLOAT
)dc
->vportExtY
/ (FLOAT
)dc
->wndExtY
;
250 xformWnd2Vport
.eM11
= scaleX
;
251 xformWnd2Vport
.eM12
= 0.0;
252 xformWnd2Vport
.eM21
= 0.0;
253 xformWnd2Vport
.eM22
= scaleY
;
254 xformWnd2Vport
.eDx
= (FLOAT
)dc
->vportOrgX
-
255 scaleX
* (FLOAT
)dc
->wndOrgX
;
256 xformWnd2Vport
.eDy
= (FLOAT
)dc
->vportOrgY
-
257 scaleY
* (FLOAT
)dc
->wndOrgY
;
259 oldworld2vport
= dc
->xformWorld2Vport
;
260 /* Combine with the world transformation */
261 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
264 /* Create inverse of world-to-viewport transformation */
265 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
266 &dc
->xformVport2World
);
268 /* Reselect the font back into the dc so that the font size
270 if(memcmp(&oldworld2vport
, &dc
->xformWorld2Vport
, sizeof(oldworld2vport
)))
271 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_FONT
));
275 /***********************************************************************
276 * GetDCState (Not a Windows API)
278 HDC WINAPI
GetDCState( HDC hdc
)
283 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
284 if (!(newdc
= GDI_AllocObject( sizeof(DC
), GDIMAGIC(dc
->header
.wMagic
), &handle
, &dc_funcs
)))
286 GDI_ReleaseObj( hdc
);
289 TRACE("(%p): returning %p\n", hdc
, handle
);
291 newdc
->flags
= dc
->flags
| DC_SAVED
;
292 newdc
->hPen
= dc
->hPen
;
293 newdc
->hBrush
= dc
->hBrush
;
294 newdc
->hFont
= dc
->hFont
;
295 newdc
->hBitmap
= dc
->hBitmap
;
296 newdc
->hDevice
= dc
->hDevice
;
297 newdc
->hPalette
= dc
->hPalette
;
298 newdc
->totalExtent
= dc
->totalExtent
;
299 newdc
->bitsPerPixel
= dc
->bitsPerPixel
;
300 newdc
->ROPmode
= dc
->ROPmode
;
301 newdc
->polyFillMode
= dc
->polyFillMode
;
302 newdc
->stretchBltMode
= dc
->stretchBltMode
;
303 newdc
->relAbsMode
= dc
->relAbsMode
;
304 newdc
->backgroundMode
= dc
->backgroundMode
;
305 newdc
->backgroundColor
= dc
->backgroundColor
;
306 newdc
->textColor
= dc
->textColor
;
307 newdc
->dcBrushColor
= dc
->dcBrushColor
;
308 newdc
->dcPenColor
= dc
->dcPenColor
;
309 newdc
->brushOrgX
= dc
->brushOrgX
;
310 newdc
->brushOrgY
= dc
->brushOrgY
;
311 newdc
->textAlign
= dc
->textAlign
;
312 newdc
->charExtra
= dc
->charExtra
;
313 newdc
->breakTotalExtra
= dc
->breakTotalExtra
;
314 newdc
->breakCount
= dc
->breakCount
;
315 newdc
->breakExtra
= dc
->breakExtra
;
316 newdc
->breakRem
= dc
->breakRem
;
317 newdc
->MapMode
= dc
->MapMode
;
318 newdc
->GraphicsMode
= dc
->GraphicsMode
;
319 newdc
->CursPosX
= dc
->CursPosX
;
320 newdc
->CursPosY
= dc
->CursPosY
;
321 newdc
->ArcDirection
= dc
->ArcDirection
;
322 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
323 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
324 newdc
->xformVport2World
= dc
->xformVport2World
;
325 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
326 newdc
->wndOrgX
= dc
->wndOrgX
;
327 newdc
->wndOrgY
= dc
->wndOrgY
;
328 newdc
->wndExtX
= dc
->wndExtX
;
329 newdc
->wndExtY
= dc
->wndExtY
;
330 newdc
->vportOrgX
= dc
->vportOrgX
;
331 newdc
->vportOrgY
= dc
->vportOrgY
;
332 newdc
->vportExtX
= dc
->vportExtX
;
333 newdc
->vportExtY
= dc
->vportExtY
;
335 newdc
->hSelf
= (HDC
)handle
;
336 newdc
->saveLevel
= 0;
338 PATH_InitGdiPath( &newdc
->path
);
340 newdc
->pAbortProc
= NULL
;
341 newdc
->hookThunk
= NULL
;
344 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
346 newdc
->hGCClipRgn
= newdc
->hVisRgn
= 0;
349 newdc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
350 CombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
356 newdc
->gdiFont
= dc
->gdiFont
;
360 GDI_ReleaseObj( handle
);
361 GDI_ReleaseObj( hdc
);
366 /***********************************************************************
367 * SetDCState (Not a Windows API)
369 void WINAPI
SetDCState( HDC hdc
, HDC hdcs
)
373 if (!(dc
= DC_GetDCUpdate( hdc
))) return;
374 if (!(dcs
= DC_GetDCPtr( hdcs
)))
376 GDI_ReleaseObj( hdc
);
379 if (!dcs
->flags
& DC_SAVED
)
381 GDI_ReleaseObj( hdc
);
382 GDI_ReleaseObj( hdcs
);
385 TRACE("%p %p\n", hdc
, hdcs
);
387 dc
->flags
= dcs
->flags
& ~(DC_SAVED
| DC_DIRTY
);
388 dc
->hDevice
= dcs
->hDevice
;
389 dc
->totalExtent
= dcs
->totalExtent
;
390 dc
->ROPmode
= dcs
->ROPmode
;
391 dc
->polyFillMode
= dcs
->polyFillMode
;
392 dc
->stretchBltMode
= dcs
->stretchBltMode
;
393 dc
->relAbsMode
= dcs
->relAbsMode
;
394 dc
->backgroundMode
= dcs
->backgroundMode
;
395 dc
->backgroundColor
= dcs
->backgroundColor
;
396 dc
->textColor
= dcs
->textColor
;
397 dc
->dcBrushColor
= dcs
->dcBrushColor
;
398 dc
->dcPenColor
= dcs
->dcPenColor
;
399 dc
->brushOrgX
= dcs
->brushOrgX
;
400 dc
->brushOrgY
= dcs
->brushOrgY
;
401 dc
->textAlign
= dcs
->textAlign
;
402 dc
->charExtra
= dcs
->charExtra
;
403 dc
->breakTotalExtra
= dcs
->breakTotalExtra
;
404 dc
->breakCount
= dcs
->breakCount
;
405 dc
->breakExtra
= dcs
->breakExtra
;
406 dc
->breakRem
= dcs
->breakRem
;
407 dc
->MapMode
= dcs
->MapMode
;
408 dc
->GraphicsMode
= dcs
->GraphicsMode
;
409 dc
->CursPosX
= dcs
->CursPosX
;
410 dc
->CursPosY
= dcs
->CursPosY
;
411 dc
->ArcDirection
= dcs
->ArcDirection
;
412 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
413 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
414 dc
->xformVport2World
= dcs
->xformVport2World
;
415 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
417 dc
->wndOrgX
= dcs
->wndOrgX
;
418 dc
->wndOrgY
= dcs
->wndOrgY
;
419 dc
->wndExtX
= dcs
->wndExtX
;
420 dc
->wndExtY
= dcs
->wndExtY
;
421 dc
->vportOrgX
= dcs
->vportOrgX
;
422 dc
->vportOrgY
= dcs
->vportOrgY
;
423 dc
->vportExtX
= dcs
->vportExtX
;
424 dc
->vportExtY
= dcs
->vportExtY
;
426 if (GDIMAGIC(dc
->header
.wMagic
) != MEMORY_DC_MAGIC
) dc
->bitsPerPixel
= dcs
->bitsPerPixel
;
430 if (!dc
->hClipRgn
) dc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
431 CombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
435 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
438 CLIPPING_UpdateGCRegion( dc
);
440 SelectObject( hdc
, dcs
->hBitmap
);
441 SelectObject( hdc
, dcs
->hBrush
);
442 SelectObject( hdc
, dcs
->hFont
);
443 SelectObject( hdc
, dcs
->hPen
);
444 SetBkColor( hdc
, dcs
->backgroundColor
);
445 SetTextColor( hdc
, dcs
->textColor
);
446 GDISelectPalette( hdc
, dcs
->hPalette
, FALSE
);
447 GDI_ReleaseObj( hdcs
);
448 GDI_ReleaseObj( hdc
);
452 /***********************************************************************
453 * GetDCState (GDI.179)
455 HDC16 WINAPI
GetDCState16( HDC16 hdc
)
457 return HDC_16( GetDCState( HDC_32(hdc
) ));
461 /***********************************************************************
462 * SetDCState (GDI.180)
464 void WINAPI
SetDCState16( HDC16 hdc
, HDC16 hdcs
)
466 SetDCState( HDC_32(hdc
), HDC_32(hdcs
) );
470 /***********************************************************************
473 INT WINAPI
SaveDC( HDC hdc
)
479 dc
= DC_GetDCPtr( hdc
);
482 if(dc
->funcs
->pSaveDC
)
484 ret
= dc
->funcs
->pSaveDC( dc
->physDev
);
485 GDI_ReleaseObj( hdc
);
489 if (!(hdcs
= GetDCState( hdc
)))
491 GDI_ReleaseObj( hdc
);
494 dcs
= DC_GetDCPtr( hdcs
);
496 /* Copy path. The reason why path saving / restoring is in SaveDC/
497 * RestoreDC and not in GetDCState/SetDCState is that the ...DCState
498 * functions are only in Win16 (which doesn't have paths) and that
499 * SetDCState doesn't allow us to signal an error (which can happen
500 * when copying paths).
502 if (!PATH_AssignGdiPath( &dcs
->path
, &dc
->path
))
504 GDI_ReleaseObj( hdc
);
505 GDI_ReleaseObj( hdcs
);
510 dcs
->header
.hNext
= dc
->header
.hNext
;
511 dc
->header
.hNext
= HDC_16(hdcs
);
512 TRACE("(%p): returning %d\n", hdc
, dc
->saveLevel
+1 );
513 ret
= ++dc
->saveLevel
;
514 GDI_ReleaseObj( hdcs
);
515 GDI_ReleaseObj( hdc
);
520 /***********************************************************************
521 * RestoreDC (GDI32.@)
523 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
528 TRACE("%p %d\n", hdc
, level
);
529 dc
= DC_GetDCUpdate( hdc
);
530 if(!dc
) return FALSE
;
531 if(dc
->funcs
->pRestoreDC
)
533 success
= dc
->funcs
->pRestoreDC( dc
->physDev
, level
);
534 GDI_ReleaseObj( hdc
);
538 if (level
== -1) level
= dc
->saveLevel
;
540 /* This pair of checks disagrees with MSDN "Platform SDK:
541 Windows GDI" July 2000 which says all negative values
542 for level will be interpreted as an instance relative
543 to the current state. Restricting it to just -1 does
545 || (level
> dc
->saveLevel
))
547 GDI_ReleaseObj( hdc
);
552 while (dc
->saveLevel
>= level
)
554 HDC hdcs
= HDC_32(dc
->header
.hNext
);
555 if (!(dcs
= DC_GetDCPtr( hdcs
)))
557 GDI_ReleaseObj( hdc
);
560 dc
->header
.hNext
= dcs
->header
.hNext
;
561 if (--dc
->saveLevel
< level
)
563 SetDCState( hdc
, hdcs
);
564 if (!PATH_AssignGdiPath( &dc
->path
, &dcs
->path
))
565 /* FIXME: This might not be quite right, since we're
566 * returning FALSE but still destroying the saved DC state */
569 GDI_ReleaseObj( hdcs
);
570 GDI_ReleaseObj( hdc
);
572 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
574 GDI_ReleaseObj( hdc
);
579 /***********************************************************************
580 * CreateDCW (GDI32.@)
582 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
583 const DEVMODEW
*initData
)
587 const DC_FUNCTIONS
*funcs
;
592 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
594 if (!driver
) return 0;
595 strcpyW(buf
, driver
);
598 if (!(funcs
= DRIVER_load_driver( buf
)))
600 ERR( "no driver found for %s\n", debugstr_w(buf
) );
603 if (!(dc
= DC_AllocDC( funcs
, DC_MAGIC
)))
605 DRIVER_release_driver( funcs
);
609 dc
->hBitmap
= GetStockObject( DEFAULT_BITMAP
);
611 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
612 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
614 if (dc
->funcs
->pCreateDC
&&
615 !dc
->funcs
->pCreateDC( dc
, &dc
->physDev
, buf
, device
, output
, initData
))
617 WARN("creation aborted by device\n" );
618 GDI_FreeObject( dc
->hSelf
, dc
);
619 DRIVER_release_driver( funcs
);
623 dc
->totalExtent
.left
= 0;
624 dc
->totalExtent
.top
= 0;
625 dc
->totalExtent
.right
= GetDeviceCaps( dc
->hSelf
, HORZRES
);
626 dc
->totalExtent
.bottom
= GetDeviceCaps( dc
->hSelf
, VERTRES
);
627 dc
->hVisRgn
= CreateRectRgnIndirect( &dc
->totalExtent
);
631 GDI_ReleaseObj( hdc
);
636 /***********************************************************************
637 * CreateDCA (GDI32.@)
639 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
640 const DEVMODEA
*initData
)
642 UNICODE_STRING driverW
, deviceW
, outputW
;
646 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
647 else driverW
.Buffer
= NULL
;
649 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
650 else deviceW
.Buffer
= NULL
;
652 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
653 else outputW
.Buffer
= NULL
;
655 if (initData
) initDataW
= GdiConvertToDevmodeW(initData
);
656 else initDataW
= NULL
;
658 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
660 RtlFreeUnicodeString(&driverW
);
661 RtlFreeUnicodeString(&deviceW
);
662 RtlFreeUnicodeString(&outputW
);
663 if (initDataW
) HeapFree(GetProcessHeap(), 0, initDataW
);
668 /***********************************************************************
669 * CreateICA (GDI32.@)
671 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
672 const DEVMODEA
* initData
)
674 /* Nothing special yet for ICs */
675 return CreateDCA( driver
, device
, output
, initData
);
679 /***********************************************************************
680 * CreateICW (GDI32.@)
682 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
683 const DEVMODEW
* initData
)
685 /* Nothing special yet for ICs */
686 return CreateDCW( driver
, device
, output
, initData
);
690 /***********************************************************************
691 * CreateCompatibleDC (GDI32.@)
693 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
696 const DC_FUNCTIONS
*funcs
;
701 if ((origDC
= GDI_GetObjPtr( hdc
, DC_MAGIC
)))
703 funcs
= origDC
->funcs
;
704 physDev
= origDC
->physDev
;
705 GDI_ReleaseObj( hdc
); /* can't hold the lock while loading the driver */
706 funcs
= DRIVER_get_driver( funcs
);
710 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
711 funcs
= DRIVER_load_driver( displayW
);
715 if (!funcs
) return 0;
717 if (!(dc
= DC_AllocDC( funcs
, MEMORY_DC_MAGIC
)))
719 DRIVER_release_driver( funcs
);
723 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
725 dc
->bitsPerPixel
= 1;
726 dc
->hBitmap
= GetStockObject( DEFAULT_BITMAP
);
728 /* Copy the driver-specific physical device info into
729 * the new DC. The driver may use this read-only info
730 * while creating the compatible DC below. */
731 dc
->physDev
= physDev
;
733 if (dc
->funcs
->pCreateDC
&&
734 !dc
->funcs
->pCreateDC( dc
, &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
736 WARN("creation aborted by device\n");
737 GDI_FreeObject( dc
->hSelf
, dc
);
738 DRIVER_release_driver( funcs
);
742 dc
->totalExtent
.left
= 0;
743 dc
->totalExtent
.top
= 0;
744 dc
->totalExtent
.right
= 1; /* default bitmap is 1x1 */
745 dc
->totalExtent
.bottom
= 1;
746 dc
->hVisRgn
= CreateRectRgnIndirect( &dc
->totalExtent
);
749 GDI_ReleaseObj( dc
->hSelf
);
754 /***********************************************************************
757 BOOL WINAPI
DeleteDC( HDC hdc
)
759 const DC_FUNCTIONS
*funcs
= NULL
;
766 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
768 /* Call hook procedure to check whether is it OK to delete this DC */
771 DCHOOKPROC proc
= dc
->hookThunk
;
772 DWORD data
= dc
->dwHookData
;
773 GDI_ReleaseObj( hdc
);
774 if (!proc( HDC_16(hdc
), DCHC_DELETEDC
, data
, 0 )) return FALSE
;
775 if (!(dc
= DC_GetDCPtr( hdc
))) return TRUE
; /* deleted by the hook */
778 while (dc
->saveLevel
)
781 HDC hdcs
= HDC_32(dc
->header
.hNext
);
782 if (!(dcs
= DC_GetDCPtr( hdcs
))) break;
783 dc
->header
.hNext
= dcs
->header
.hNext
;
785 if (dcs
->hClipRgn
) DeleteObject( dcs
->hClipRgn
);
786 if (dcs
->hVisRgn
) DeleteObject( dcs
->hVisRgn
);
787 if (dcs
->hGCClipRgn
) DeleteObject( dcs
->hGCClipRgn
);
788 PATH_DestroyGdiPath(&dcs
->path
);
789 GDI_FreeObject( hdcs
, dcs
);
792 if (!(dc
->flags
& DC_SAVED
))
794 SelectObject( hdc
, GetStockObject(BLACK_PEN
) );
795 SelectObject( hdc
, GetStockObject(WHITE_BRUSH
) );
796 SelectObject( hdc
, GetStockObject(SYSTEM_FONT
) );
797 SelectObject( hdc
, GetStockObject(DEFAULT_BITMAP
) );
799 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
->physDev
);
803 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
804 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
805 if (dc
->hGCClipRgn
) DeleteObject( dc
->hGCClipRgn
);
806 PATH_DestroyGdiPath(&dc
->path
);
808 GDI_FreeObject( hdc
, dc
);
809 if (funcs
) DRIVER_release_driver( funcs
); /* do that after releasing the GDI lock */
814 /***********************************************************************
817 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
822 if ((dc
= DC_GetDCPtr( hdc
)))
824 if (dc
->funcs
->pResetDC
) ret
= dc
->funcs
->pResetDC( dc
->physDev
, devmode
);
825 GDI_ReleaseObj( hdc
);
831 /***********************************************************************
834 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
836 return ResetDCA(hdc
, (const DEVMODEA
*)devmode
); /* FIXME */
840 /***********************************************************************
841 * GetDeviceCaps (GDI32.@)
843 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
848 if ((dc
= DC_GetDCPtr( hdc
)))
850 if (dc
->funcs
->pGetDeviceCaps
) ret
= dc
->funcs
->pGetDeviceCaps( dc
->physDev
, cap
);
851 GDI_ReleaseObj( hdc
);
857 /***********************************************************************
858 * SetBkColor (GDI32.@)
860 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
863 DC
* dc
= DC_GetDCPtr( hdc
);
865 TRACE("hdc=%p color=0x%08lx\n", hdc
, color
);
867 if (!dc
) return CLR_INVALID
;
868 oldColor
= dc
->backgroundColor
;
869 if (dc
->funcs
->pSetBkColor
)
871 color
= dc
->funcs
->pSetBkColor(dc
->physDev
, color
);
872 if (color
== CLR_INVALID
) /* don't change it */
875 oldColor
= CLR_INVALID
;
878 dc
->backgroundColor
= color
;
879 GDI_ReleaseObj( hdc
);
884 /***********************************************************************
885 * SetTextColor (GDI32.@)
887 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
890 DC
* dc
= DC_GetDCPtr( hdc
);
892 TRACE(" hdc=%p color=0x%08lx\n", hdc
, color
);
894 if (!dc
) return CLR_INVALID
;
895 oldColor
= dc
->textColor
;
896 if (dc
->funcs
->pSetTextColor
)
898 color
= dc
->funcs
->pSetTextColor(dc
->physDev
, color
);
899 if (color
== CLR_INVALID
) /* don't change it */
902 oldColor
= CLR_INVALID
;
905 dc
->textColor
= color
;
906 GDI_ReleaseObj( hdc
);
911 /***********************************************************************
912 * SetTextAlign (GDI32.@)
914 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
917 DC
*dc
= DC_GetDCPtr( hdc
);
919 TRACE("hdc=%p align=%d\n", hdc
, align
);
922 if (dc
->funcs
->pSetTextAlign
)
923 prevAlign
= dc
->funcs
->pSetTextAlign(dc
->physDev
, align
);
925 prevAlign
= dc
->textAlign
;
926 dc
->textAlign
= align
;
928 GDI_ReleaseObj( hdc
);
932 /***********************************************************************
933 * GetDCOrgEx (GDI32.@)
935 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
939 if (!lpp
) return FALSE
;
940 if (!(dc
= DC_GetDCPtr( hDC
))) return FALSE
;
943 if (dc
->funcs
->pGetDCOrgEx
) dc
->funcs
->pGetDCOrgEx( dc
->physDev
, lpp
);
944 GDI_ReleaseObj( hDC
);
949 /***********************************************************************
952 DWORD WINAPI
SetDCOrg16( HDC16 hdc16
, INT16 x
, INT16 y
)
955 HDC hdc
= HDC_32( hdc16
);
956 DC
*dc
= DC_GetDCPtr( hdc
);
958 if (dc
->funcs
->pSetDCOrg
) prevOrg
= dc
->funcs
->pSetDCOrg( dc
->physDev
, x
, y
);
959 GDI_ReleaseObj( hdc
);
964 /***********************************************************************
965 * SetGraphicsMode (GDI32.@)
967 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
970 DC
*dc
= DC_GetDCPtr( hdc
);
972 /* One would think that setting the graphics mode to GM_COMPATIBLE
973 * would also reset the world transformation matrix to the unity
974 * matrix. However, in Windows, this is not the case. This doesn't
975 * make a lot of sense to me, but that's the way it is.
978 if ((mode
> 0) && (mode
<= GM_LAST
))
980 ret
= dc
->GraphicsMode
;
981 dc
->GraphicsMode
= mode
;
983 GDI_ReleaseObj( hdc
);
988 /***********************************************************************
989 * SetArcDirection (GDI32.@)
991 INT WINAPI
SetArcDirection( HDC hdc
, INT nDirection
)
994 INT nOldDirection
= 0;
996 if (nDirection
!=AD_COUNTERCLOCKWISE
&& nDirection
!=AD_CLOCKWISE
)
998 SetLastError(ERROR_INVALID_PARAMETER
);
1002 if ((dc
= DC_GetDCPtr( hdc
)))
1004 if (dc
->funcs
->pSetArcDirection
)
1006 dc
->funcs
->pSetArcDirection(dc
->physDev
, nDirection
);
1008 nOldDirection
= dc
->ArcDirection
;
1009 dc
->ArcDirection
= nDirection
;
1010 GDI_ReleaseObj( hdc
);
1012 return nOldDirection
;
1016 /***********************************************************************
1017 * GetWorldTransform (GDI32.@)
1019 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
1022 if (!xform
) return FALSE
;
1023 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
1024 *xform
= dc
->xformWorld2Wnd
;
1025 GDI_ReleaseObj( hdc
);
1030 /***********************************************************************
1031 * GetTransform (GDI32.@)
1033 BOOL WINAPI
GetTransform( HDC hdc
, DWORD unknown
, LPXFORM xform
)
1035 if (unknown
== 0x0203) return GetWorldTransform( hdc
, xform
);
1036 ERR("stub: don't know what to do for code %lx\n", unknown
);
1041 /***********************************************************************
1042 * SetWorldTransform (GDI32.@)
1044 BOOL WINAPI
SetWorldTransform( HDC hdc
, const XFORM
*xform
)
1047 DC
*dc
= DC_GetDCPtr( hdc
);
1049 if (!dc
) return FALSE
;
1050 if (!xform
) goto done
;
1052 /* Check that graphics mode is GM_ADVANCED */
1053 if (dc
->GraphicsMode
!=GM_ADVANCED
) goto done
;
1055 if (dc
->funcs
->pSetWorldTransform
)
1057 ret
= dc
->funcs
->pSetWorldTransform(dc
->physDev
, xform
);
1058 if (!ret
) goto done
;
1061 dc
->xformWorld2Wnd
= *xform
;
1062 DC_UpdateXforms( dc
);
1065 GDI_ReleaseObj( hdc
);
1070 /****************************************************************************
1071 * ModifyWorldTransform [GDI32.@]
1072 * Modifies the world transformation for a device context.
1075 * hdc [I] Handle to device context
1076 * xform [I] XFORM structure that will be used to modify the world
1078 * iMode [I] Specifies in what way to modify the world transformation
1081 * Resets the world transformation to the identity matrix.
1082 * The parameter xform is ignored.
1084 * Multiplies xform into the world transformation matrix from
1087 * Multiplies xform into the world transformation matrix from
1092 BOOL WINAPI
ModifyWorldTransform( HDC hdc
, const XFORM
*xform
,
1096 DC
*dc
= DC_GetDCPtr( hdc
);
1098 /* Check for illegal parameters */
1099 if (!dc
) return FALSE
;
1100 if (!xform
) goto done
;
1102 /* Check that graphics mode is GM_ADVANCED */
1103 if (dc
->GraphicsMode
!=GM_ADVANCED
) goto done
;
1105 if (dc
->funcs
->pModifyWorldTransform
)
1107 ret
= dc
->funcs
->pModifyWorldTransform(dc
->physDev
, xform
, iMode
);
1108 if (!ret
) goto done
;
1114 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
1115 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
1116 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
1117 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
1118 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
1119 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
1121 case MWT_LEFTMULTIPLY
:
1122 CombineTransform( &dc
->xformWorld2Wnd
, xform
,
1123 &dc
->xformWorld2Wnd
);
1125 case MWT_RIGHTMULTIPLY
:
1126 CombineTransform( &dc
->xformWorld2Wnd
, &dc
->xformWorld2Wnd
,
1133 DC_UpdateXforms( dc
);
1136 GDI_ReleaseObj( hdc
);
1141 /****************************************************************************
1142 * CombineTransform [GDI32.@]
1143 * Combines two transformation matrices.
1146 * xformResult [O] Stores the result of combining the two matrices
1147 * xform1 [I] Specifies the first matrix to apply
1148 * xform2 [I] Specifies the second matrix to apply
1151 * The same matrix can be passed in for more than one of the parameters.
1155 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1156 const XFORM
*xform2
)
1160 /* Check for illegal parameters */
1161 if (!xformResult
|| !xform1
|| !xform2
)
1164 /* Create the result in a temporary XFORM, since xformResult may be
1165 * equal to xform1 or xform2 */
1166 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1167 xform1
->eM12
* xform2
->eM21
;
1168 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1169 xform1
->eM12
* xform2
->eM22
;
1170 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1171 xform1
->eM22
* xform2
->eM21
;
1172 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1173 xform1
->eM22
* xform2
->eM22
;
1174 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1175 xform1
->eDy
* xform2
->eM21
+
1177 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1178 xform1
->eDy
* xform2
->eM22
+
1181 /* Copy the result to xformResult */
1182 *xformResult
= xformTemp
;
1188 /***********************************************************************
1189 * SetDCHook (GDI32.@)
1191 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1193 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD dwHookData
)
1195 DC
*dc
= GDI_GetObjPtr( hdc
, DC_MAGIC
);
1197 if (!dc
) return FALSE
;
1199 if (!(dc
->flags
& DC_SAVED
))
1201 dc
->dwHookData
= dwHookData
;
1202 dc
->hookThunk
= hookProc
;
1204 GDI_ReleaseObj( hdc
);
1209 /* relay function to call the 16-bit DC hook proc */
1210 static BOOL16 WINAPI
call_dc_hook16( HDC16 hdc16
, WORD code
, DWORD data
, LPARAM lParam
)
1214 FARPROC16 proc
= NULL
;
1215 HDC hdc
= HDC_32( hdc16
);
1216 DC
*dc
= DC_GetDCPtr( hdc
);
1218 if (!dc
) return FALSE
;
1219 proc
= dc
->hookProc
;
1220 GDI_ReleaseObj( hdc
);
1221 if (!proc
) return FALSE
;
1224 args
[3] = HIWORD(data
);
1225 args
[2] = LOWORD(data
);
1226 args
[1] = HIWORD(lParam
);
1227 args
[0] = LOWORD(lParam
);
1228 WOWCallback16Ex( (DWORD
)proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
1232 /***********************************************************************
1233 * SetDCHook (GDI.190)
1235 BOOL16 WINAPI
SetDCHook16( HDC16 hdc16
, FARPROC16 hookProc
, DWORD dwHookData
)
1237 HDC hdc
= HDC_32( hdc16
);
1238 DC
*dc
= DC_GetDCPtr( hdc
);
1239 if (!dc
) return FALSE
;
1241 dc
->hookProc
= hookProc
;
1242 GDI_ReleaseObj( hdc
);
1243 return SetDCHook( hdc
, call_dc_hook16
, dwHookData
);
1247 /***********************************************************************
1248 * GetDCHook (GDI.191)
1250 DWORD WINAPI
GetDCHook16( HDC16 hdc16
, FARPROC16
*phookProc
)
1252 HDC hdc
= HDC_32( hdc16
);
1253 DC
*dc
= DC_GetDCPtr( hdc
);
1257 *phookProc
= dc
->hookProc
;
1258 ret
= dc
->dwHookData
;
1259 GDI_ReleaseObj( hdc
);
1264 /***********************************************************************
1265 * SetHookFlags (GDI.192)
1267 WORD WINAPI
SetHookFlags16(HDC16 hdc16
, WORD flags
)
1269 HDC hdc
= HDC_32( hdc16
);
1270 DC
*dc
= DC_GetDCPtr( hdc
);
1274 WORD wRet
= dc
->flags
& DC_DIRTY
;
1276 /* "Undocumented Windows" info is slightly confusing.
1279 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1281 if( flags
& DCHF_INVALIDATEVISRGN
)
1282 dc
->flags
|= DC_DIRTY
;
1283 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1284 dc
->flags
&= ~DC_DIRTY
;
1285 GDI_ReleaseObj( hdc
);
1291 /***********************************************************************
1292 * SetICMMode (GDI32.@)
1294 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1296 /*FIXME Asuming that ICM is always off, and cannot be turned on */
1297 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1298 if (iEnableICM
== ICM_ON
) return 0;
1299 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1303 /***********************************************************************
1304 * GetDeviceGammaRamp (GDI32.@)
1306 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1309 DC
*dc
= DC_GetDCPtr( hDC
);
1313 if (dc
->funcs
->pGetDeviceGammaRamp
)
1314 ret
= dc
->funcs
->pGetDeviceGammaRamp(dc
->physDev
, ptr
);
1315 GDI_ReleaseObj( hDC
);
1320 /***********************************************************************
1321 * SetDeviceGammaRamp (GDI32.@)
1323 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1326 DC
*dc
= DC_GetDCPtr( hDC
);
1330 if (dc
->funcs
->pSetDeviceGammaRamp
)
1331 ret
= dc
->funcs
->pSetDeviceGammaRamp(dc
->physDev
, ptr
);
1332 GDI_ReleaseObj( hDC
);
1337 /***********************************************************************
1338 * GetColorSpace (GDI32.@)
1340 HCOLORSPACE WINAPI
GetColorSpace(HDC hdc
)
1342 /*FIXME Need to to whatever GetColorSpace actually does */
1346 /***********************************************************************
1347 * CreateColorSpaceA (GDI32.@)
1349 HCOLORSPACE WINAPI
CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace
)
1355 /***********************************************************************
1356 * CreateColorSpaceW (GDI32.@)
1358 HCOLORSPACE WINAPI
CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace
)
1364 /***********************************************************************
1365 * DeleteColorSpace (GDI32.@)
1367 BOOL WINAPI
DeleteColorSpace( HCOLORSPACE hColorSpace
)
1374 /***********************************************************************
1375 * SetColorSpace (GDI32.@)
1377 HCOLORSPACE WINAPI
SetColorSpace( HDC hDC
, HCOLORSPACE hColorSpace
)
1384 /***********************************************************************
1385 * GetBoundsRect (GDI.194)
1387 UINT16 WINAPI
GetBoundsRect16(HDC16 hdc
, LPRECT16 rect
, UINT16 flags
)
1389 return DCB_RESET
| DCB_DISABLE
; /* bounding rectangle always empty and disabled*/
1392 /***********************************************************************
1393 * GetBoundsRect (GDI32.@)
1395 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1397 FIXME("(): stub\n");
1398 return DCB_RESET
; /* bounding rectangle always empty */
1401 /***********************************************************************
1402 * SetBoundsRect (GDI.193)
1404 UINT16 WINAPI
SetBoundsRect16(HDC16 hdc
, const RECT16
* rect
, UINT16 flags
)
1406 if ( (flags
& DCB_ACCUMULATE
) || (flags
& DCB_ENABLE
) )
1407 FIXME("(%04x, %p, %04x): stub\n", hdc
, rect
, flags
);
1409 return DCB_RESET
| DCB_DISABLE
; /* bounding rectangle always empty and disabled*/
1412 /***********************************************************************
1413 * SetBoundsRect (GDI32.@)
1415 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1417 FIXME("(): stub\n");
1418 return DCB_DISABLE
; /* bounding rectangle always empty */
1422 /***********************************************************************
1423 * GetRelAbs (GDI32.@)
1425 INT WINAPI
GetRelAbs( HDC hdc
, DWORD dwIgnore
)
1428 DC
*dc
= DC_GetDCPtr( hdc
);
1429 if (dc
) ret
= dc
->relAbsMode
;
1430 GDI_ReleaseObj( hdc
);
1434 /***********************************************************************
1435 * GetLayout (GDI32.@)
1437 * Gets left->right or right->left text layout flags of a dc.
1438 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1441 DWORD WINAPI
GetLayout(HDC hdc
)
1443 FIXME("(%p): stub\n", hdc
);
1444 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1448 /***********************************************************************
1449 * SetLayout (GDI32.@)
1451 * Sets left->right or right->left text layout flags of a dc.
1452 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1455 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1457 FIXME("(%p,%08lx): stub\n", hdc
, layout
);
1458 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1462 /***********************************************************************
1463 * GetDCBrushColor (GDI32.@)
1465 * Retrieves the current brush color for the specified device
1469 COLORREF WINAPI
GetDCBrushColor(HDC hdc
)
1472 COLORREF dcBrushColor
= CLR_INVALID
;
1474 TRACE("hdc(%p)\n", hdc
);
1476 dc
= DC_GetDCPtr( hdc
);
1479 dcBrushColor
= dc
->dcBrushColor
;
1480 GDI_ReleaseObj( hdc
);
1483 return dcBrushColor
;
1486 /***********************************************************************
1487 * SetDCBrushColor (GDI32.@)
1489 * Sets the current device context (DC) brush color to the specified
1490 * color value. If the device cannot represent the specified color
1491 * value, the color is set to the nearest physical color.
1494 COLORREF WINAPI
SetDCBrushColor(HDC hdc
, COLORREF crColor
)
1497 COLORREF oldClr
= CLR_INVALID
;
1499 TRACE("hdc(%p) crColor(%08lx)\n", hdc
, crColor
);
1501 dc
= DC_GetDCPtr( hdc
);
1504 if (dc
->funcs
->pSetDCBrushColor
)
1505 crColor
= dc
->funcs
->pSetDCBrushColor( dc
->physDev
, crColor
);
1506 else if (dc
->hBrush
== GetStockObject( DC_BRUSH
))
1508 /* If DC_BRUSH is selected, update driver pen color */
1509 HBRUSH hBrush
= CreateSolidBrush( crColor
);
1510 dc
->funcs
->pSelectBrush( dc
->physDev
, hBrush
);
1511 DeleteObject( hBrush
);
1514 if (crColor
!= CLR_INVALID
)
1516 oldClr
= dc
->dcBrushColor
;
1517 dc
->dcBrushColor
= crColor
;
1520 GDI_ReleaseObj( hdc
);
1526 /***********************************************************************
1527 * GetDCPenColor (GDI32.@)
1529 * Retrieves the current pen color for the specified device
1533 COLORREF WINAPI
GetDCPenColor(HDC hdc
)
1536 COLORREF dcPenColor
= CLR_INVALID
;
1538 TRACE("hdc(%p)\n", hdc
);
1540 dc
= DC_GetDCPtr( hdc
);
1543 dcPenColor
= dc
->dcPenColor
;
1544 GDI_ReleaseObj( hdc
);
1550 /***********************************************************************
1551 * SetDCPenColor (GDI32.@)
1553 * Sets the current device context (DC) pen color to the specified
1554 * color value. If the device cannot represent the specified color
1555 * value, the color is set to the nearest physical color.
1558 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1561 COLORREF oldClr
= CLR_INVALID
;
1563 TRACE("hdc(%p) crColor(%08lx)\n", hdc
, crColor
);
1565 dc
= DC_GetDCPtr( hdc
);
1568 if (dc
->funcs
->pSetDCPenColor
)
1569 crColor
= dc
->funcs
->pSetDCPenColor( dc
->physDev
, crColor
);
1570 else if (dc
->hPen
== GetStockObject( DC_PEN
))
1572 /* If DC_PEN is selected, update the driver pen color */
1573 LOGPEN logpen
= { PS_SOLID
, { 0, 0 }, crColor
};
1574 HPEN hPen
= CreatePenIndirect( &logpen
);
1575 dc
->funcs
->pSelectPen( dc
->physDev
, hPen
);
1576 DeleteObject( hPen
);
1579 if (crColor
!= CLR_INVALID
)
1581 oldClr
= dc
->dcPenColor
;
1582 dc
->dcPenColor
= crColor
;
1585 GDI_ReleaseObj( hdc
);
1591 /***********************************************************************
1592 * SetVirtualResolution (GDI32.@)
1594 * Undocumented on msdn. Called when PowerPoint XP saves a file.
1596 DWORD WINAPI
SetVirtualResolution(HDC hdc
, DWORD dw2
, DWORD dw3
, DWORD dw4
, DWORD dw5
)
1598 FIXME("(%p %08lx %08lx %08lx %08lx): stub!\n", hdc
, dw2
, dw3
, dw4
, dw5
);