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"
36 #include "wine/unicode.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dc
);
41 static BOOL
DC_DeleteObject( HGDIOBJ handle
, void *obj
);
43 static const struct gdi_obj_funcs dc_funcs
=
45 NULL
, /* pSelectObject */
46 NULL
, /* pGetObject16 */
47 NULL
, /* pGetObjectA */
48 NULL
, /* pGetObjectW */
49 NULL
, /* pUnrealizeObject */
50 DC_DeleteObject
/* pDeleteObject */
53 /***********************************************************************
56 DC
*DC_AllocDC( const DC_FUNCTIONS
*funcs
, WORD magic
)
61 if (!(dc
= GDI_AllocObject( sizeof(*dc
), magic
, (HGDIOBJ
*)&hdc
, &dc_funcs
))) return NULL
;
82 dc
->hPen
= GetStockObject( BLACK_PEN
);
83 dc
->hBrush
= GetStockObject( WHITE_BRUSH
);
84 dc
->hFont
= GetStockObject( SYSTEM_FONT
);
87 dc
->hPalette
= GetStockObject( DEFAULT_PALETTE
);
89 dc
->ROPmode
= R2_COPYPEN
;
90 dc
->polyFillMode
= ALTERNATE
;
91 dc
->stretchBltMode
= BLACKONWHITE
;
92 dc
->relAbsMode
= ABSOLUTE
;
93 dc
->backgroundMode
= OPAQUE
;
94 dc
->backgroundColor
= RGB( 255, 255, 255 );
95 dc
->dcBrushColor
= RGB( 255, 255, 255 );
96 dc
->dcPenColor
= RGB( 0, 0, 0 );
97 dc
->textColor
= RGB( 0, 0, 0 );
100 dc
->textAlign
= TA_LEFT
| TA_TOP
| TA_NOUPDATECP
;
102 dc
->breakTotalExtra
= 0;
106 dc
->totalExtent
.left
= 0;
107 dc
->totalExtent
.top
= 0;
108 dc
->totalExtent
.right
= 0;
109 dc
->totalExtent
.bottom
= 0;
110 dc
->bitsPerPixel
= 1;
111 dc
->MapMode
= MM_TEXT
;
112 dc
->GraphicsMode
= GM_COMPATIBLE
;
113 dc
->pAbortProc
= NULL
;
116 dc
->ArcDirection
= AD_COUNTERCLOCKWISE
;
117 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
118 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
119 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
120 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
121 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
122 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
123 dc
->xformWorld2Vport
= dc
->xformWorld2Wnd
;
124 dc
->xformVport2World
= dc
->xformWorld2Wnd
;
125 dc
->vport2WorldValid
= TRUE
;
126 PATH_InitGdiPath(&dc
->path
);
132 /***********************************************************************
135 DC
*DC_GetDCPtr( HDC hdc
)
137 GDIOBJHDR
*ptr
= GDI_GetObjPtr( hdc
, MAGIC_DONTCARE
);
138 if (!ptr
) return NULL
;
139 if ((GDIMAGIC(ptr
->wMagic
) == DC_MAGIC
) ||
140 (GDIMAGIC(ptr
->wMagic
) == MEMORY_DC_MAGIC
) ||
141 (GDIMAGIC(ptr
->wMagic
) == METAFILE_DC_MAGIC
) ||
142 (GDIMAGIC(ptr
->wMagic
) == ENHMETAFILE_DC_MAGIC
))
144 GDI_ReleaseObj( hdc
);
145 SetLastError( ERROR_INVALID_HANDLE
);
149 /***********************************************************************
152 * Retrieve a DC ptr while making sure the visRgn is updated.
153 * This function may call up to USER so the GDI lock should _not_
154 * be held when calling it.
156 DC
*DC_GetDCUpdate( HDC hdc
)
158 DC
*dc
= DC_GetDCPtr( hdc
);
159 if (!dc
) return NULL
;
160 while (dc
->flags
& DC_DIRTY
)
162 DCHOOKPROC proc
= dc
->hookThunk
;
163 dc
->flags
&= ~DC_DIRTY
;
166 DWORD data
= dc
->dwHookData
;
167 GDI_ReleaseObj( hdc
);
168 proc( HDC_16(hdc
), DCHC_INVALIDVISRGN
, data
, 0 );
169 if (!(dc
= DC_GetDCPtr( hdc
))) break;
170 /* otherwise restart the loop in case it became dirty again in the meantime */
177 /***********************************************************************
180 static BOOL
DC_DeleteObject( HGDIOBJ handle
, void *obj
)
182 GDI_ReleaseObj( handle
);
183 return DeleteDC( handle
);
187 /***********************************************************************
190 * Setup device-specific DC values for a newly created DC.
192 void DC_InitDC( DC
* dc
)
194 if (dc
->funcs
->pRealizeDefaultPalette
) dc
->funcs
->pRealizeDefaultPalette( dc
->physDev
);
195 SetTextColor( dc
->hSelf
, dc
->textColor
);
196 SetBkColor( dc
->hSelf
, dc
->backgroundColor
);
197 SelectObject( dc
->hSelf
, dc
->hPen
);
198 SelectObject( dc
->hSelf
, dc
->hBrush
);
199 SelectObject( dc
->hSelf
, dc
->hFont
);
200 CLIPPING_UpdateGCRegion( dc
);
204 /***********************************************************************
207 * Computes the inverse of the transformation xformSrc and stores it to
208 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
211 static BOOL
DC_InvertXform( const XFORM
*xformSrc
, XFORM
*xformDest
)
215 determinant
= xformSrc
->eM11
*xformSrc
->eM22
-
216 xformSrc
->eM12
*xformSrc
->eM21
;
217 if (determinant
> -1e-12 && determinant
< 1e-12)
220 xformDest
->eM11
= xformSrc
->eM22
/ determinant
;
221 xformDest
->eM12
= -xformSrc
->eM12
/ determinant
;
222 xformDest
->eM21
= -xformSrc
->eM21
/ determinant
;
223 xformDest
->eM22
= xformSrc
->eM11
/ determinant
;
224 xformDest
->eDx
= -xformSrc
->eDx
* xformDest
->eM11
-
225 xformSrc
->eDy
* xformDest
->eM21
;
226 xformDest
->eDy
= -xformSrc
->eDx
* xformDest
->eM12
-
227 xformSrc
->eDy
* xformDest
->eM22
;
233 /***********************************************************************
236 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
237 * fields of the specified DC by creating a transformation that
238 * represents the current mapping mode and combining it with the DC's
239 * world transform. This function should be called whenever the
240 * parameters associated with the mapping mode (window and viewport
241 * extents and origins) or the world transform change.
243 void DC_UpdateXforms( DC
*dc
)
245 XFORM xformWnd2Vport
, oldworld2vport
;
246 FLOAT scaleX
, scaleY
;
248 /* Construct a transformation to do the window-to-viewport conversion */
249 scaleX
= (FLOAT
)dc
->vportExtX
/ (FLOAT
)dc
->wndExtX
;
250 scaleY
= (FLOAT
)dc
->vportExtY
/ (FLOAT
)dc
->wndExtY
;
251 xformWnd2Vport
.eM11
= scaleX
;
252 xformWnd2Vport
.eM12
= 0.0;
253 xformWnd2Vport
.eM21
= 0.0;
254 xformWnd2Vport
.eM22
= scaleY
;
255 xformWnd2Vport
.eDx
= (FLOAT
)dc
->vportOrgX
-
256 scaleX
* (FLOAT
)dc
->wndOrgX
;
257 xformWnd2Vport
.eDy
= (FLOAT
)dc
->vportOrgY
-
258 scaleY
* (FLOAT
)dc
->wndOrgY
;
260 oldworld2vport
= dc
->xformWorld2Vport
;
261 /* Combine with the world transformation */
262 CombineTransform( &dc
->xformWorld2Vport
, &dc
->xformWorld2Wnd
,
265 /* Create inverse of world-to-viewport transformation */
266 dc
->vport2WorldValid
= DC_InvertXform( &dc
->xformWorld2Vport
,
267 &dc
->xformVport2World
);
269 /* Reselect the font back into the dc so that the font size
271 if(memcmp(&oldworld2vport
, &dc
->xformWorld2Vport
, sizeof(oldworld2vport
)))
272 SelectObject(dc
->hSelf
, GetCurrentObject(dc
->hSelf
, OBJ_FONT
));
276 /***********************************************************************
277 * GetDCState (Not a Windows API)
279 HDC WINAPI
GetDCState( HDC hdc
)
284 if (!(dc
= DC_GetDCPtr( hdc
))) return 0;
285 if (!(newdc
= GDI_AllocObject( sizeof(DC
), GDIMAGIC(dc
->header
.wMagic
), &handle
, &dc_funcs
)))
287 GDI_ReleaseObj( hdc
);
290 TRACE("(%p): returning %p\n", hdc
, handle
);
292 newdc
->flags
= dc
->flags
| DC_SAVED
;
293 newdc
->hPen
= dc
->hPen
;
294 newdc
->hBrush
= dc
->hBrush
;
295 newdc
->hFont
= dc
->hFont
;
296 newdc
->hBitmap
= dc
->hBitmap
;
297 newdc
->hDevice
= dc
->hDevice
;
298 newdc
->hPalette
= dc
->hPalette
;
299 newdc
->totalExtent
= dc
->totalExtent
;
300 newdc
->bitsPerPixel
= dc
->bitsPerPixel
;
301 newdc
->ROPmode
= dc
->ROPmode
;
302 newdc
->polyFillMode
= dc
->polyFillMode
;
303 newdc
->stretchBltMode
= dc
->stretchBltMode
;
304 newdc
->relAbsMode
= dc
->relAbsMode
;
305 newdc
->backgroundMode
= dc
->backgroundMode
;
306 newdc
->backgroundColor
= dc
->backgroundColor
;
307 newdc
->textColor
= dc
->textColor
;
308 newdc
->dcBrushColor
= dc
->dcBrushColor
;
309 newdc
->dcPenColor
= dc
->dcPenColor
;
310 newdc
->brushOrgX
= dc
->brushOrgX
;
311 newdc
->brushOrgY
= dc
->brushOrgY
;
312 newdc
->textAlign
= dc
->textAlign
;
313 newdc
->charExtra
= dc
->charExtra
;
314 newdc
->breakTotalExtra
= dc
->breakTotalExtra
;
315 newdc
->breakCount
= dc
->breakCount
;
316 newdc
->breakExtra
= dc
->breakExtra
;
317 newdc
->breakRem
= dc
->breakRem
;
318 newdc
->MapMode
= dc
->MapMode
;
319 newdc
->GraphicsMode
= dc
->GraphicsMode
;
320 newdc
->CursPosX
= dc
->CursPosX
;
321 newdc
->CursPosY
= dc
->CursPosY
;
322 newdc
->ArcDirection
= dc
->ArcDirection
;
323 newdc
->xformWorld2Wnd
= dc
->xformWorld2Wnd
;
324 newdc
->xformWorld2Vport
= dc
->xformWorld2Vport
;
325 newdc
->xformVport2World
= dc
->xformVport2World
;
326 newdc
->vport2WorldValid
= dc
->vport2WorldValid
;
327 newdc
->wndOrgX
= dc
->wndOrgX
;
328 newdc
->wndOrgY
= dc
->wndOrgY
;
329 newdc
->wndExtX
= dc
->wndExtX
;
330 newdc
->wndExtY
= dc
->wndExtY
;
331 newdc
->vportOrgX
= dc
->vportOrgX
;
332 newdc
->vportOrgY
= dc
->vportOrgY
;
333 newdc
->vportExtX
= dc
->vportExtX
;
334 newdc
->vportExtY
= dc
->vportExtY
;
336 newdc
->hSelf
= (HDC
)handle
;
337 newdc
->saveLevel
= 0;
339 PATH_InitGdiPath( &newdc
->path
);
341 newdc
->pAbortProc
= NULL
;
342 newdc
->hookThunk
= NULL
;
345 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
347 newdc
->hGCClipRgn
= newdc
->hVisRgn
= 0;
350 newdc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
351 CombineRgn( newdc
->hClipRgn
, dc
->hClipRgn
, 0, RGN_COPY
);
357 newdc
->gdiFont
= dc
->gdiFont
;
361 GDI_ReleaseObj( handle
);
362 GDI_ReleaseObj( hdc
);
367 /***********************************************************************
368 * SetDCState (Not a Windows API)
370 void WINAPI
SetDCState( HDC hdc
, HDC hdcs
)
374 if (!(dc
= DC_GetDCUpdate( hdc
))) return;
375 if (!(dcs
= DC_GetDCPtr( hdcs
)))
377 GDI_ReleaseObj( hdc
);
380 if (!dcs
->flags
& DC_SAVED
)
382 GDI_ReleaseObj( hdc
);
383 GDI_ReleaseObj( hdcs
);
386 TRACE("%p %p\n", hdc
, hdcs
);
388 dc
->flags
= dcs
->flags
& ~(DC_SAVED
| DC_DIRTY
);
389 dc
->hDevice
= dcs
->hDevice
;
390 dc
->totalExtent
= dcs
->totalExtent
;
391 dc
->ROPmode
= dcs
->ROPmode
;
392 dc
->polyFillMode
= dcs
->polyFillMode
;
393 dc
->stretchBltMode
= dcs
->stretchBltMode
;
394 dc
->relAbsMode
= dcs
->relAbsMode
;
395 dc
->backgroundMode
= dcs
->backgroundMode
;
396 dc
->backgroundColor
= dcs
->backgroundColor
;
397 dc
->textColor
= dcs
->textColor
;
398 dc
->dcBrushColor
= dcs
->dcBrushColor
;
399 dc
->dcPenColor
= dcs
->dcPenColor
;
400 dc
->brushOrgX
= dcs
->brushOrgX
;
401 dc
->brushOrgY
= dcs
->brushOrgY
;
402 dc
->textAlign
= dcs
->textAlign
;
403 dc
->charExtra
= dcs
->charExtra
;
404 dc
->breakTotalExtra
= dcs
->breakTotalExtra
;
405 dc
->breakCount
= dcs
->breakCount
;
406 dc
->breakExtra
= dcs
->breakExtra
;
407 dc
->breakRem
= dcs
->breakRem
;
408 dc
->MapMode
= dcs
->MapMode
;
409 dc
->GraphicsMode
= dcs
->GraphicsMode
;
410 dc
->CursPosX
= dcs
->CursPosX
;
411 dc
->CursPosY
= dcs
->CursPosY
;
412 dc
->ArcDirection
= dcs
->ArcDirection
;
413 dc
->xformWorld2Wnd
= dcs
->xformWorld2Wnd
;
414 dc
->xformWorld2Vport
= dcs
->xformWorld2Vport
;
415 dc
->xformVport2World
= dcs
->xformVport2World
;
416 dc
->vport2WorldValid
= dcs
->vport2WorldValid
;
418 dc
->wndOrgX
= dcs
->wndOrgX
;
419 dc
->wndOrgY
= dcs
->wndOrgY
;
420 dc
->wndExtX
= dcs
->wndExtX
;
421 dc
->wndExtY
= dcs
->wndExtY
;
422 dc
->vportOrgX
= dcs
->vportOrgX
;
423 dc
->vportOrgY
= dcs
->vportOrgY
;
424 dc
->vportExtX
= dcs
->vportExtX
;
425 dc
->vportExtY
= dcs
->vportExtY
;
427 if (GDIMAGIC(dc
->header
.wMagic
) != MEMORY_DC_MAGIC
) dc
->bitsPerPixel
= dcs
->bitsPerPixel
;
431 if (!dc
->hClipRgn
) dc
->hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
432 CombineRgn( dc
->hClipRgn
, dcs
->hClipRgn
, 0, RGN_COPY
);
436 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
439 CLIPPING_UpdateGCRegion( dc
);
441 SelectObject( hdc
, dcs
->hBitmap
);
442 SelectObject( hdc
, dcs
->hBrush
);
443 SelectObject( hdc
, dcs
->hFont
);
444 SelectObject( hdc
, dcs
->hPen
);
445 SetBkColor( hdc
, dcs
->backgroundColor
);
446 SetTextColor( hdc
, dcs
->textColor
);
447 GDISelectPalette( hdc
, dcs
->hPalette
, FALSE
);
448 GDI_ReleaseObj( hdcs
);
449 GDI_ReleaseObj( hdc
);
453 /***********************************************************************
454 * GetDCState (GDI.179)
456 HDC16 WINAPI
GetDCState16( HDC16 hdc
)
458 return HDC_16( GetDCState( HDC_32(hdc
) ));
462 /***********************************************************************
463 * SetDCState (GDI.180)
465 void WINAPI
SetDCState16( HDC16 hdc
, HDC16 hdcs
)
467 SetDCState( HDC_32(hdc
), HDC_32(hdcs
) );
471 /***********************************************************************
474 INT WINAPI
SaveDC( HDC hdc
)
480 dc
= DC_GetDCPtr( hdc
);
483 if(dc
->funcs
->pSaveDC
)
485 ret
= dc
->funcs
->pSaveDC( dc
->physDev
);
486 GDI_ReleaseObj( hdc
);
490 if (!(hdcs
= GetDCState( hdc
)))
492 GDI_ReleaseObj( hdc
);
495 dcs
= DC_GetDCPtr( hdcs
);
497 /* Copy path. The reason why path saving / restoring is in SaveDC/
498 * RestoreDC and not in GetDCState/SetDCState is that the ...DCState
499 * functions are only in Win16 (which doesn't have paths) and that
500 * SetDCState doesn't allow us to signal an error (which can happen
501 * when copying paths).
503 if (!PATH_AssignGdiPath( &dcs
->path
, &dc
->path
))
505 GDI_ReleaseObj( hdc
);
506 GDI_ReleaseObj( hdcs
);
511 dcs
->header
.hNext
= dc
->header
.hNext
;
512 dc
->header
.hNext
= HDC_16(hdcs
);
513 TRACE("(%p): returning %d\n", hdc
, dc
->saveLevel
+1 );
514 ret
= ++dc
->saveLevel
;
515 GDI_ReleaseObj( hdcs
);
516 GDI_ReleaseObj( hdc
);
521 /***********************************************************************
522 * RestoreDC (GDI32.@)
524 BOOL WINAPI
RestoreDC( HDC hdc
, INT level
)
529 TRACE("%p %d\n", hdc
, level
);
530 dc
= DC_GetDCUpdate( hdc
);
531 if(!dc
) return FALSE
;
532 if(dc
->funcs
->pRestoreDC
)
534 success
= dc
->funcs
->pRestoreDC( dc
->physDev
, level
);
535 GDI_ReleaseObj( hdc
);
539 if (level
== -1) level
= dc
->saveLevel
;
541 /* This pair of checks disagrees with MSDN "Platform SDK:
542 Windows GDI" July 2000 which says all negative values
543 for level will be interpreted as an instance relative
544 to the current state. Restricting it to just -1 does
546 || (level
> dc
->saveLevel
))
548 GDI_ReleaseObj( hdc
);
553 while (dc
->saveLevel
>= level
)
555 HDC hdcs
= HDC_32(dc
->header
.hNext
);
556 if (!(dcs
= DC_GetDCPtr( hdcs
)))
558 GDI_ReleaseObj( hdc
);
561 dc
->header
.hNext
= dcs
->header
.hNext
;
562 if (--dc
->saveLevel
< level
)
564 SetDCState( hdc
, hdcs
);
565 if (!PATH_AssignGdiPath( &dc
->path
, &dcs
->path
))
566 /* FIXME: This might not be quite right, since we're
567 * returning FALSE but still destroying the saved DC state */
570 GDI_ReleaseObj( hdcs
);
571 GDI_ReleaseObj( hdc
);
573 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
575 GDI_ReleaseObj( hdc
);
580 /***********************************************************************
581 * CreateDCW (GDI32.@)
583 HDC WINAPI
CreateDCW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
584 const DEVMODEW
*initData
)
588 const DC_FUNCTIONS
*funcs
;
593 if (!device
|| !DRIVER_GetDriverName( device
, buf
, 300 ))
595 if (!driver
) return 0;
596 strcpyW(buf
, driver
);
599 if (!(funcs
= DRIVER_load_driver( buf
)))
601 ERR( "no driver found for %s\n", debugstr_w(buf
) );
604 if (!(dc
= DC_AllocDC( funcs
, DC_MAGIC
)))
606 DRIVER_release_driver( funcs
);
610 dc
->hBitmap
= GetStockObject( DEFAULT_BITMAP
);
612 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
613 debugstr_w(driver
), debugstr_w(device
), debugstr_w(output
), dc
->hSelf
);
615 if (dc
->funcs
->pCreateDC
&&
616 !dc
->funcs
->pCreateDC( dc
, &dc
->physDev
, buf
, device
, output
, initData
))
618 WARN("creation aborted by device\n" );
619 GDI_FreeObject( dc
->hSelf
, dc
);
620 DRIVER_release_driver( funcs
);
624 dc
->totalExtent
.left
= 0;
625 dc
->totalExtent
.top
= 0;
626 dc
->totalExtent
.right
= GetDeviceCaps( dc
->hSelf
, HORZRES
);
627 dc
->totalExtent
.bottom
= GetDeviceCaps( dc
->hSelf
, VERTRES
);
628 dc
->hVisRgn
= CreateRectRgnIndirect( &dc
->totalExtent
);
632 GDI_ReleaseObj( hdc
);
637 /***********************************************************************
638 * CreateDCA (GDI32.@)
640 HDC WINAPI
CreateDCA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
641 const DEVMODEA
*initData
)
643 UNICODE_STRING driverW
, deviceW
, outputW
;
647 if (driver
) RtlCreateUnicodeStringFromAsciiz(&driverW
, driver
);
648 else driverW
.Buffer
= NULL
;
650 if (device
) RtlCreateUnicodeStringFromAsciiz(&deviceW
, device
);
651 else deviceW
.Buffer
= NULL
;
653 if (output
) RtlCreateUnicodeStringFromAsciiz(&outputW
, output
);
654 else outputW
.Buffer
= NULL
;
656 if (initData
) initDataW
= GdiConvertToDevmodeW(initData
);
657 else initDataW
= NULL
;
659 ret
= CreateDCW( driverW
.Buffer
, deviceW
.Buffer
, outputW
.Buffer
, initDataW
);
661 RtlFreeUnicodeString(&driverW
);
662 RtlFreeUnicodeString(&deviceW
);
663 RtlFreeUnicodeString(&outputW
);
664 if (initDataW
) HeapFree(GetProcessHeap(), 0, initDataW
);
669 /***********************************************************************
670 * CreateICA (GDI32.@)
672 HDC WINAPI
CreateICA( LPCSTR driver
, LPCSTR device
, LPCSTR output
,
673 const DEVMODEA
* initData
)
675 /* Nothing special yet for ICs */
676 return CreateDCA( driver
, device
, output
, initData
);
680 /***********************************************************************
681 * CreateICW (GDI32.@)
683 HDC WINAPI
CreateICW( LPCWSTR driver
, LPCWSTR device
, LPCWSTR output
,
684 const DEVMODEW
* initData
)
686 /* Nothing special yet for ICs */
687 return CreateDCW( driver
, device
, output
, initData
);
691 /***********************************************************************
692 * CreateCompatibleDC (GDI32.@)
694 HDC WINAPI
CreateCompatibleDC( HDC hdc
)
697 const DC_FUNCTIONS
*funcs
;
702 if ((origDC
= GDI_GetObjPtr( hdc
, DC_MAGIC
)))
704 funcs
= origDC
->funcs
;
705 physDev
= origDC
->physDev
;
706 GDI_ReleaseObj( hdc
); /* can't hold the lock while loading the driver */
707 funcs
= DRIVER_get_driver( funcs
);
711 static const WCHAR displayW
[] = { 'd','i','s','p','l','a','y',0 };
712 funcs
= DRIVER_load_driver( displayW
);
716 if (!funcs
) return 0;
718 if (!(dc
= DC_AllocDC( funcs
, MEMORY_DC_MAGIC
)))
720 DRIVER_release_driver( funcs
);
724 TRACE("(%p): returning %p\n", hdc
, dc
->hSelf
);
726 dc
->bitsPerPixel
= 1;
727 dc
->hBitmap
= GetStockObject( DEFAULT_BITMAP
);
729 /* Copy the driver-specific physical device info into
730 * the new DC. The driver may use this read-only info
731 * while creating the compatible DC below. */
732 dc
->physDev
= physDev
;
734 if (dc
->funcs
->pCreateDC
&&
735 !dc
->funcs
->pCreateDC( dc
, &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
737 WARN("creation aborted by device\n");
738 GDI_FreeObject( dc
->hSelf
, dc
);
739 DRIVER_release_driver( funcs
);
743 dc
->totalExtent
.left
= 0;
744 dc
->totalExtent
.top
= 0;
745 dc
->totalExtent
.right
= 1; /* default bitmap is 1x1 */
746 dc
->totalExtent
.bottom
= 1;
747 dc
->hVisRgn
= CreateRectRgnIndirect( &dc
->totalExtent
);
750 GDI_ReleaseObj( dc
->hSelf
);
755 /***********************************************************************
758 BOOL WINAPI
DeleteDC( HDC hdc
)
760 const DC_FUNCTIONS
*funcs
= NULL
;
767 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
769 /* Call hook procedure to check whether is it OK to delete this DC */
772 DCHOOKPROC proc
= dc
->hookThunk
;
773 DWORD data
= dc
->dwHookData
;
774 GDI_ReleaseObj( hdc
);
775 if (!proc( HDC_16(hdc
), DCHC_DELETEDC
, data
, 0 )) return FALSE
;
776 if (!(dc
= DC_GetDCPtr( hdc
))) return TRUE
; /* deleted by the hook */
779 while (dc
->saveLevel
)
782 HDC hdcs
= HDC_32(dc
->header
.hNext
);
783 if (!(dcs
= DC_GetDCPtr( hdcs
))) break;
784 dc
->header
.hNext
= dcs
->header
.hNext
;
786 if (dcs
->hClipRgn
) DeleteObject( dcs
->hClipRgn
);
787 if (dcs
->hVisRgn
) DeleteObject( dcs
->hVisRgn
);
788 if (dcs
->hGCClipRgn
) DeleteObject( dcs
->hGCClipRgn
);
789 PATH_DestroyGdiPath(&dcs
->path
);
790 GDI_FreeObject( hdcs
, dcs
);
793 if (!(dc
->flags
& DC_SAVED
))
795 SelectObject( hdc
, GetStockObject(BLACK_PEN
) );
796 SelectObject( hdc
, GetStockObject(WHITE_BRUSH
) );
797 SelectObject( hdc
, GetStockObject(SYSTEM_FONT
) );
798 SelectObject( hdc
, GetStockObject(DEFAULT_BITMAP
) );
800 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
->physDev
);
804 if (dc
->hClipRgn
) DeleteObject( dc
->hClipRgn
);
805 if (dc
->hVisRgn
) DeleteObject( dc
->hVisRgn
);
806 if (dc
->hGCClipRgn
) DeleteObject( dc
->hGCClipRgn
);
807 PATH_DestroyGdiPath(&dc
->path
);
809 GDI_FreeObject( hdc
, dc
);
810 if (funcs
) DRIVER_release_driver( funcs
); /* do that after releasing the GDI lock */
815 /***********************************************************************
818 HDC WINAPI
ResetDCA( HDC hdc
, const DEVMODEA
*devmode
)
823 if ((dc
= DC_GetDCPtr( hdc
)))
825 if (dc
->funcs
->pResetDC
) ret
= dc
->funcs
->pResetDC( dc
->physDev
, devmode
);
826 GDI_ReleaseObj( hdc
);
832 /***********************************************************************
835 HDC WINAPI
ResetDCW( HDC hdc
, const DEVMODEW
*devmode
)
837 return ResetDCA(hdc
, (const DEVMODEA
*)devmode
); /* FIXME */
841 /***********************************************************************
842 * GetDeviceCaps (GDI32.@)
844 INT WINAPI
GetDeviceCaps( HDC hdc
, INT cap
)
849 if ((dc
= DC_GetDCPtr( hdc
)))
851 if (dc
->funcs
->pGetDeviceCaps
) ret
= dc
->funcs
->pGetDeviceCaps( dc
->physDev
, cap
);
852 GDI_ReleaseObj( hdc
);
858 /***********************************************************************
859 * SetBkColor (GDI32.@)
861 COLORREF WINAPI
SetBkColor( HDC hdc
, COLORREF color
)
864 DC
* dc
= DC_GetDCPtr( hdc
);
866 TRACE("hdc=%p color=0x%08lx\n", hdc
, color
);
868 if (!dc
) return CLR_INVALID
;
869 oldColor
= dc
->backgroundColor
;
870 if (dc
->funcs
->pSetBkColor
)
872 color
= dc
->funcs
->pSetBkColor(dc
->physDev
, color
);
873 if (color
== CLR_INVALID
) /* don't change it */
876 oldColor
= CLR_INVALID
;
879 dc
->backgroundColor
= color
;
880 GDI_ReleaseObj( hdc
);
885 /***********************************************************************
886 * SetTextColor (GDI32.@)
888 COLORREF WINAPI
SetTextColor( HDC hdc
, COLORREF color
)
891 DC
* dc
= DC_GetDCPtr( hdc
);
893 TRACE(" hdc=%p color=0x%08lx\n", hdc
, color
);
895 if (!dc
) return CLR_INVALID
;
896 oldColor
= dc
->textColor
;
897 if (dc
->funcs
->pSetTextColor
)
899 color
= dc
->funcs
->pSetTextColor(dc
->physDev
, color
);
900 if (color
== CLR_INVALID
) /* don't change it */
903 oldColor
= CLR_INVALID
;
906 dc
->textColor
= color
;
907 GDI_ReleaseObj( hdc
);
912 /***********************************************************************
913 * SetTextAlign (GDI32.@)
915 UINT WINAPI
SetTextAlign( HDC hdc
, UINT align
)
918 DC
*dc
= DC_GetDCPtr( hdc
);
920 TRACE("hdc=%p align=%d\n", hdc
, align
);
923 if (dc
->funcs
->pSetTextAlign
)
924 prevAlign
= dc
->funcs
->pSetTextAlign(dc
->physDev
, align
);
926 prevAlign
= dc
->textAlign
;
927 dc
->textAlign
= align
;
929 GDI_ReleaseObj( hdc
);
933 /***********************************************************************
934 * GetDCOrgEx (GDI32.@)
936 BOOL WINAPI
GetDCOrgEx( HDC hDC
, LPPOINT lpp
)
940 if (!lpp
) return FALSE
;
941 if (!(dc
= DC_GetDCPtr( hDC
))) return FALSE
;
944 if (dc
->funcs
->pGetDCOrgEx
) dc
->funcs
->pGetDCOrgEx( dc
->physDev
, lpp
);
945 GDI_ReleaseObj( hDC
);
950 /***********************************************************************
953 DWORD WINAPI
SetDCOrg16( HDC16 hdc16
, INT16 x
, INT16 y
)
956 HDC hdc
= HDC_32( hdc16
);
957 DC
*dc
= DC_GetDCPtr( hdc
);
959 if (dc
->funcs
->pSetDCOrg
) prevOrg
= dc
->funcs
->pSetDCOrg( dc
->physDev
, x
, y
);
960 GDI_ReleaseObj( hdc
);
965 /***********************************************************************
966 * SetGraphicsMode (GDI32.@)
968 INT WINAPI
SetGraphicsMode( HDC hdc
, INT mode
)
971 DC
*dc
= DC_GetDCPtr( hdc
);
973 /* One would think that setting the graphics mode to GM_COMPATIBLE
974 * would also reset the world transformation matrix to the unity
975 * matrix. However, in Windows, this is not the case. This doesn't
976 * make a lot of sense to me, but that's the way it is.
979 if ((mode
> 0) && (mode
<= GM_LAST
))
981 ret
= dc
->GraphicsMode
;
982 dc
->GraphicsMode
= mode
;
984 GDI_ReleaseObj( hdc
);
989 /***********************************************************************
990 * SetArcDirection (GDI32.@)
992 INT WINAPI
SetArcDirection( HDC hdc
, INT nDirection
)
995 INT nOldDirection
= 0;
997 if (nDirection
!=AD_COUNTERCLOCKWISE
&& nDirection
!=AD_CLOCKWISE
)
999 SetLastError(ERROR_INVALID_PARAMETER
);
1003 if ((dc
= DC_GetDCPtr( hdc
)))
1005 if (dc
->funcs
->pSetArcDirection
)
1007 dc
->funcs
->pSetArcDirection(dc
->physDev
, nDirection
);
1009 nOldDirection
= dc
->ArcDirection
;
1010 dc
->ArcDirection
= nDirection
;
1011 GDI_ReleaseObj( hdc
);
1013 return nOldDirection
;
1017 /***********************************************************************
1018 * GetWorldTransform (GDI32.@)
1020 BOOL WINAPI
GetWorldTransform( HDC hdc
, LPXFORM xform
)
1023 if (!xform
) return FALSE
;
1024 if (!(dc
= DC_GetDCPtr( hdc
))) return FALSE
;
1025 *xform
= dc
->xformWorld2Wnd
;
1026 GDI_ReleaseObj( hdc
);
1031 /***********************************************************************
1032 * GetTransform (GDI32.@)
1034 BOOL WINAPI
GetTransform( HDC hdc
, DWORD unknown
, LPXFORM xform
)
1036 if (unknown
== 0x0203) return GetWorldTransform( hdc
, xform
);
1037 ERR("stub: don't know what to do for code %lx\n", unknown
);
1042 /***********************************************************************
1043 * SetWorldTransform (GDI32.@)
1045 BOOL WINAPI
SetWorldTransform( HDC hdc
, const XFORM
*xform
)
1048 DC
*dc
= DC_GetDCPtr( hdc
);
1050 if (!dc
) return FALSE
;
1051 if (!xform
) goto done
;
1053 /* Check that graphics mode is GM_ADVANCED */
1054 if (dc
->GraphicsMode
!=GM_ADVANCED
) goto done
;
1056 if (dc
->funcs
->pSetWorldTransform
)
1058 ret
= dc
->funcs
->pSetWorldTransform(dc
->physDev
, xform
);
1059 if (!ret
) goto done
;
1062 dc
->xformWorld2Wnd
= *xform
;
1063 DC_UpdateXforms( dc
);
1066 GDI_ReleaseObj( hdc
);
1071 /****************************************************************************
1072 * ModifyWorldTransform [GDI32.@]
1073 * Modifies the world transformation for a device context.
1076 * hdc [I] Handle to device context
1077 * xform [I] XFORM structure that will be used to modify the world
1079 * iMode [I] Specifies in what way to modify the world transformation
1082 * Resets the world transformation to the identity matrix.
1083 * The parameter xform is ignored.
1085 * Multiplies xform into the world transformation matrix from
1088 * Multiplies xform into the world transformation matrix from
1093 BOOL WINAPI
ModifyWorldTransform( HDC hdc
, const XFORM
*xform
,
1097 DC
*dc
= DC_GetDCPtr( hdc
);
1099 /* Check for illegal parameters */
1100 if (!dc
) return FALSE
;
1101 if (!xform
) goto done
;
1103 /* Check that graphics mode is GM_ADVANCED */
1104 if (dc
->GraphicsMode
!=GM_ADVANCED
) goto done
;
1106 if (dc
->funcs
->pModifyWorldTransform
)
1108 ret
= dc
->funcs
->pModifyWorldTransform(dc
->physDev
, xform
, iMode
);
1109 if (!ret
) goto done
;
1115 dc
->xformWorld2Wnd
.eM11
= 1.0f
;
1116 dc
->xformWorld2Wnd
.eM12
= 0.0f
;
1117 dc
->xformWorld2Wnd
.eM21
= 0.0f
;
1118 dc
->xformWorld2Wnd
.eM22
= 1.0f
;
1119 dc
->xformWorld2Wnd
.eDx
= 0.0f
;
1120 dc
->xformWorld2Wnd
.eDy
= 0.0f
;
1122 case MWT_LEFTMULTIPLY
:
1123 CombineTransform( &dc
->xformWorld2Wnd
, xform
,
1124 &dc
->xformWorld2Wnd
);
1126 case MWT_RIGHTMULTIPLY
:
1127 CombineTransform( &dc
->xformWorld2Wnd
, &dc
->xformWorld2Wnd
,
1134 DC_UpdateXforms( dc
);
1137 GDI_ReleaseObj( hdc
);
1142 /****************************************************************************
1143 * CombineTransform [GDI32.@]
1144 * Combines two transformation matrices.
1147 * xformResult [O] Stores the result of combining the two matrices
1148 * xform1 [I] Specifies the first matrix to apply
1149 * xform2 [I] Specifies the second matrix to apply
1152 * The same matrix can be passed in for more than one of the parameters.
1156 BOOL WINAPI
CombineTransform( LPXFORM xformResult
, const XFORM
*xform1
,
1157 const XFORM
*xform2
)
1161 /* Check for illegal parameters */
1162 if (!xformResult
|| !xform1
|| !xform2
)
1165 /* Create the result in a temporary XFORM, since xformResult may be
1166 * equal to xform1 or xform2 */
1167 xformTemp
.eM11
= xform1
->eM11
* xform2
->eM11
+
1168 xform1
->eM12
* xform2
->eM21
;
1169 xformTemp
.eM12
= xform1
->eM11
* xform2
->eM12
+
1170 xform1
->eM12
* xform2
->eM22
;
1171 xformTemp
.eM21
= xform1
->eM21
* xform2
->eM11
+
1172 xform1
->eM22
* xform2
->eM21
;
1173 xformTemp
.eM22
= xform1
->eM21
* xform2
->eM12
+
1174 xform1
->eM22
* xform2
->eM22
;
1175 xformTemp
.eDx
= xform1
->eDx
* xform2
->eM11
+
1176 xform1
->eDy
* xform2
->eM21
+
1178 xformTemp
.eDy
= xform1
->eDx
* xform2
->eM12
+
1179 xform1
->eDy
* xform2
->eM22
+
1182 /* Copy the result to xformResult */
1183 *xformResult
= xformTemp
;
1189 /***********************************************************************
1190 * SetDCHook (GDI32.@)
1192 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1194 BOOL WINAPI
SetDCHook( HDC hdc
, DCHOOKPROC hookProc
, DWORD dwHookData
)
1196 DC
*dc
= GDI_GetObjPtr( hdc
, DC_MAGIC
);
1198 if (!dc
) return FALSE
;
1200 if (!(dc
->flags
& DC_SAVED
))
1202 dc
->dwHookData
= dwHookData
;
1203 dc
->hookThunk
= hookProc
;
1205 GDI_ReleaseObj( hdc
);
1210 /* relay function to call the 16-bit DC hook proc */
1211 static BOOL16 WINAPI
call_dc_hook16( HDC16 hdc16
, WORD code
, DWORD data
, LPARAM lParam
)
1215 FARPROC16 proc
= NULL
;
1216 HDC hdc
= HDC_32( hdc16
);
1217 DC
*dc
= DC_GetDCPtr( hdc
);
1219 if (!dc
) return FALSE
;
1220 proc
= dc
->hookProc
;
1221 GDI_ReleaseObj( hdc
);
1222 if (!proc
) return FALSE
;
1225 args
[3] = HIWORD(data
);
1226 args
[2] = LOWORD(data
);
1227 args
[1] = HIWORD(lParam
);
1228 args
[0] = LOWORD(lParam
);
1229 WOWCallback16Ex( (DWORD
)proc
, WCB16_PASCAL
, sizeof(args
), args
, &ret
);
1233 /***********************************************************************
1234 * SetDCHook (GDI.190)
1236 BOOL16 WINAPI
SetDCHook16( HDC16 hdc16
, FARPROC16 hookProc
, DWORD dwHookData
)
1238 HDC hdc
= HDC_32( hdc16
);
1239 DC
*dc
= DC_GetDCPtr( hdc
);
1240 if (!dc
) return FALSE
;
1242 dc
->hookProc
= hookProc
;
1243 GDI_ReleaseObj( hdc
);
1244 return SetDCHook( hdc
, call_dc_hook16
, dwHookData
);
1248 /***********************************************************************
1249 * GetDCHook (GDI.191)
1251 DWORD WINAPI
GetDCHook16( HDC16 hdc16
, FARPROC16
*phookProc
)
1253 HDC hdc
= HDC_32( hdc16
);
1254 DC
*dc
= DC_GetDCPtr( hdc
);
1258 *phookProc
= dc
->hookProc
;
1259 ret
= dc
->dwHookData
;
1260 GDI_ReleaseObj( hdc
);
1265 /***********************************************************************
1266 * SetHookFlags (GDI.192)
1268 WORD WINAPI
SetHookFlags16(HDC16 hdc16
, WORD flags
)
1270 HDC hdc
= HDC_32( hdc16
);
1271 DC
*dc
= DC_GetDCPtr( hdc
);
1275 WORD wRet
= dc
->flags
& DC_DIRTY
;
1277 /* "Undocumented Windows" info is slightly confusing.
1280 TRACE("hDC %p, flags %04x\n",hdc
,flags
);
1282 if( flags
& DCHF_INVALIDATEVISRGN
)
1283 dc
->flags
|= DC_DIRTY
;
1284 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
1285 dc
->flags
&= ~DC_DIRTY
;
1286 GDI_ReleaseObj( hdc
);
1292 /***********************************************************************
1293 * SetICMMode (GDI32.@)
1295 INT WINAPI
SetICMMode(HDC hdc
, INT iEnableICM
)
1297 /*FIXME Asuming that ICM is always off, and cannot be turned on */
1298 if (iEnableICM
== ICM_OFF
) return ICM_OFF
;
1299 if (iEnableICM
== ICM_ON
) return 0;
1300 if (iEnableICM
== ICM_QUERY
) return ICM_OFF
;
1304 /***********************************************************************
1305 * GetDeviceGammaRamp (GDI32.@)
1307 BOOL WINAPI
GetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1310 DC
*dc
= DC_GetDCPtr( hDC
);
1314 if (dc
->funcs
->pGetDeviceGammaRamp
)
1315 ret
= dc
->funcs
->pGetDeviceGammaRamp(dc
->physDev
, ptr
);
1316 GDI_ReleaseObj( hDC
);
1321 /***********************************************************************
1322 * SetDeviceGammaRamp (GDI32.@)
1324 BOOL WINAPI
SetDeviceGammaRamp(HDC hDC
, LPVOID ptr
)
1327 DC
*dc
= DC_GetDCPtr( hDC
);
1331 if (dc
->funcs
->pSetDeviceGammaRamp
)
1332 ret
= dc
->funcs
->pSetDeviceGammaRamp(dc
->physDev
, ptr
);
1333 GDI_ReleaseObj( hDC
);
1338 /***********************************************************************
1339 * GetColorSpace (GDI32.@)
1341 HCOLORSPACE WINAPI
GetColorSpace(HDC hdc
)
1343 /*FIXME Need to to whatever GetColorSpace actually does */
1347 /***********************************************************************
1348 * CreateColorSpaceA (GDI32.@)
1350 HCOLORSPACE WINAPI
CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace
)
1356 /***********************************************************************
1357 * CreateColorSpaceW (GDI32.@)
1359 HCOLORSPACE WINAPI
CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace
)
1365 /***********************************************************************
1366 * DeleteColorSpace (GDI32.@)
1368 BOOL WINAPI
DeleteColorSpace( HCOLORSPACE hColorSpace
)
1375 /***********************************************************************
1376 * SetColorSpace (GDI32.@)
1378 HCOLORSPACE WINAPI
SetColorSpace( HDC hDC
, HCOLORSPACE hColorSpace
)
1385 /***********************************************************************
1386 * GetBoundsRect (GDI.194)
1388 UINT16 WINAPI
GetBoundsRect16(HDC16 hdc
, LPRECT16 rect
, UINT16 flags
)
1390 return DCB_RESET
| DCB_DISABLE
; /* bounding rectangle always empty and disabled*/
1393 /***********************************************************************
1394 * GetBoundsRect (GDI32.@)
1396 UINT WINAPI
GetBoundsRect(HDC hdc
, LPRECT rect
, UINT flags
)
1398 FIXME("(): stub\n");
1399 return DCB_RESET
; /* bounding rectangle always empty */
1402 /***********************************************************************
1403 * SetBoundsRect (GDI.193)
1405 UINT16 WINAPI
SetBoundsRect16(HDC16 hdc
, const RECT16
* rect
, UINT16 flags
)
1407 if ( (flags
& DCB_ACCUMULATE
) || (flags
& DCB_ENABLE
) )
1408 FIXME("(%04x, %p, %04x): stub\n", hdc
, rect
, flags
);
1410 return DCB_RESET
| DCB_DISABLE
; /* bounding rectangle always empty and disabled*/
1413 /***********************************************************************
1414 * SetBoundsRect (GDI32.@)
1416 UINT WINAPI
SetBoundsRect(HDC hdc
, const RECT
* rect
, UINT flags
)
1418 FIXME("(): stub\n");
1419 return DCB_DISABLE
; /* bounding rectangle always empty */
1423 /***********************************************************************
1424 * GetRelAbs (GDI32.@)
1426 INT WINAPI
GetRelAbs( HDC hdc
, DWORD dwIgnore
)
1429 DC
*dc
= DC_GetDCPtr( hdc
);
1430 if (dc
) ret
= dc
->relAbsMode
;
1431 GDI_ReleaseObj( hdc
);
1435 /***********************************************************************
1436 * GetLayout (GDI32.@)
1438 * Gets left->right or right->left text layout flags of a dc.
1439 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1442 DWORD WINAPI
GetLayout(HDC hdc
)
1444 FIXME("(%p): stub\n", hdc
);
1445 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1449 /***********************************************************************
1450 * SetLayout (GDI32.@)
1452 * Sets left->right or right->left text layout flags of a dc.
1453 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1456 DWORD WINAPI
SetLayout(HDC hdc
, DWORD layout
)
1458 FIXME("(%p,%08lx): stub\n", hdc
, layout
);
1459 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1463 /***********************************************************************
1464 * GetDCBrushColor (GDI32.@)
1466 * Retrieves the current brush color for the specified device
1470 COLORREF WINAPI
GetDCBrushColor(HDC hdc
)
1473 COLORREF dcBrushColor
= CLR_INVALID
;
1475 TRACE("hdc(%p)\n", hdc
);
1477 dc
= DC_GetDCPtr( hdc
);
1480 dcBrushColor
= dc
->dcBrushColor
;
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
;
1549 /***********************************************************************
1550 * SetDCPenColor (GDI32.@)
1552 * Sets the current device context (DC) pen color to the specified
1553 * color value. If the device cannot represent the specified color
1554 * value, the color is set to the nearest physical color.
1557 COLORREF WINAPI
SetDCPenColor(HDC hdc
, COLORREF crColor
)
1560 COLORREF oldClr
= CLR_INVALID
;
1562 TRACE("hdc(%p) crColor(%08lx)\n", hdc
, crColor
);
1564 dc
= DC_GetDCPtr( hdc
);
1567 if (dc
->funcs
->pSetDCPenColor
)
1568 crColor
= dc
->funcs
->pSetDCPenColor( dc
->physDev
, crColor
);
1569 else if (dc
->hPen
== GetStockObject( DC_PEN
))
1571 /* If DC_PEN is selected, update the driver pen color */
1572 LOGPEN logpen
= { PS_SOLID
, { 0, 0 }, crColor
};
1573 HPEN hPen
= CreatePenIndirect( &logpen
);
1574 dc
->funcs
->pSelectPen( dc
->physDev
, hPen
);
1575 DeleteObject( hPen
);
1578 if (crColor
!= CLR_INVALID
)
1580 oldClr
= dc
->dcPenColor
;
1581 dc
->dcPenColor
= crColor
;
1584 GDI_ReleaseObj( hdc
);
1590 /***********************************************************************
1591 * SetVirtualResolution (GDI32.@)
1593 * Undocumented on msdn. Called when PowerPoint XP saves a file.
1595 DWORD WINAPI
SetVirtualResolution(HDC hdc
, DWORD dw2
, DWORD dw3
, DWORD dw4
, DWORD dw5
)
1597 FIXME("(%p %08lx %08lx %08lx %08lx): stub!\n", hdc
, dw2
, dw3
, dw4
, dw5
);