7 IntGdiSetBkColor(HDC hDC
, COLORREF color
)
14 if (!(dc
= DC_LockDc(hDC
)))
16 EngSetLastError(ERROR_INVALID_HANDLE
);
19 pdcattr
= dc
->pdcattr
;
20 oldColor
= pdcattr
->crBackgroundClr
;
21 pdcattr
->crBackgroundClr
= color
;
22 pdcattr
->ulBackgroundClr
= (ULONG
)color
;
23 pdcattr
->ulDirty_
|= DIRTY_BACKGROUND
|DIRTY_LINE
|DIRTY_FILL
; // Clear Flag if set.
24 hBrush
= pdcattr
->hbrush
;
26 NtGdiSelectBrush(hDC
, hBrush
);
31 IntGdiSetBkMode(HDC hDC
, INT Mode
)
37 if (!(dc
= DC_LockDc(hDC
)))
39 EngSetLastError(ERROR_INVALID_HANDLE
);
42 pdcattr
= dc
->pdcattr
;
43 oldMode
= pdcattr
->lBkMode
;
44 pdcattr
->jBkMode
= Mode
;
45 pdcattr
->lBkMode
= Mode
;
52 IntGdiSetTextAlign(HDC hDC
,
62 EngSetLastError(ERROR_INVALID_HANDLE
);
65 pdcattr
= dc
->pdcattr
;
66 prevAlign
= pdcattr
->lTextAlign
;
67 pdcattr
->lTextAlign
= Mode
;
74 IntGdiSetTextColor(HDC hDC
,
84 EngSetLastError(ERROR_INVALID_HANDLE
);
87 pdcattr
= pdc
->pdcattr
;
89 // What about ulForegroundClr, like in gdi32?
90 crOldColor
= pdcattr
->crForegroundClr
;
91 pdcattr
->crForegroundClr
= color
;
92 DC_vUpdateTextBrush(pdc
);
101 GreSetStretchBltMode(HDC hDC
, int iStretchMode
)
107 pdc
= DC_LockDc(hDC
);
110 pdcattr
= pdc
->pdcattr
;
111 oSMode
= pdcattr
->lStretchBltMode
;
112 pdcattr
->lStretchBltMode
= iStretchMode
;
114 // Wine returns an error here. We set the default.
115 if ((iStretchMode
<= 0) || (iStretchMode
> MAXSTRETCHBLTMODE
)) iStretchMode
= WHITEONBLACK
;
117 pdcattr
->jStretchBltMode
= iStretchMode
;
124 DCU_SetDcUndeletable(HDC hDC
)
126 PDC dc
= DC_LockDc(hDC
);
129 EngSetLastError(ERROR_INVALID_HANDLE
);
133 dc
->fs
|= DC_FLAG_PERMANENT
;
140 IntIsPrimarySurface(SURFOBJ
*SurfObj
)
142 if (PrimarySurface
.pSurface
== NULL
)
146 return SurfObj
->hsurf
== PrimarySurface
.pSurface
; // <- FIXME: WTF?
152 IntSetDefaultRegion(PDC pdc
)
156 RECTL rclWnd
, rclClip
;
158 IntGdiReleaseRaoRgn(pdc
);
162 rclWnd
.right
= pdc
->dclevel
.sizl
.cx
;
163 rclWnd
.bottom
= pdc
->dclevel
.sizl
.cy
;
166 //EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
167 if (pdc
->ppdev
->flFlags
& PDEV_META_DEVICE
)
169 pSurface
= pdc
->dclevel
.pSurface
;
170 if (pSurface
&& pSurface
->flags
& PDEV_SURFACE
)
172 rclClip
.left
+= pdc
->ppdev
->ptlOrigion
.x
;
173 rclClip
.top
+= pdc
->ppdev
->ptlOrigion
.y
;
174 rclClip
.right
+= pdc
->ppdev
->ptlOrigion
.x
;
175 rclClip
.bottom
+= pdc
->ppdev
->ptlOrigion
.y
;
178 //EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
182 if (prgn
&& prgn
!= prgnDefault
)
184 REGION_SetRectRgn( prgn
,
192 prgn
= IntSysCreateRectpRgn( rclClip
.left
,
201 pdc
->ptlDCOrig
.x
= 0;
202 pdc
->ptlDCOrig
.y
= 0;
203 pdc
->erclWindow
= rclWnd
;
204 pdc
->erclClip
= rclClip
;
205 /* Might be an InitDC or DCE... */
206 pdc
->ptlFillOrigin
.x
= pdc
->dcattr
.VisRectRegion
.Rect
.right
;
207 pdc
->ptlFillOrigin
.y
= pdc
->dcattr
.VisRectRegion
.Rect
.bottom
;
211 pdc
->prgnVis
= prgnDefault
;
217 NtGdiCancelDC(HDC hDC
)
225 IntGdiSetHookFlags(HDC hDC
, WORD Flags
)
228 DC
*dc
= DC_LockDc(hDC
);
232 EngSetLastError(ERROR_INVALID_HANDLE
);
236 wRet
= dc
->fs
& DC_FLAG_DIRTY_RAO
; // FIXME: Wrong flag!
238 /* Info in "Undocumented Windows" is slightly confusing. */
239 DPRINT("DC %p, Flags %04x\n", hDC
, Flags
);
241 if (Flags
& DCHF_INVALIDATEVISRGN
)
243 /* hVisRgn has to be updated */
244 dc
->fs
|= DC_FLAG_DIRTY_RAO
;
246 else if (Flags
& DCHF_VALIDATEVISRGN
|| 0 == Flags
)
248 dc
->fs
&= ~DC_FLAG_DIRTY_RAO
;
268 DWORD SafeResult
= 0;
269 NTSTATUS Status
= STATUS_SUCCESS
;
273 EngSetLastError(ERROR_INVALID_PARAMETER
);
277 pdc
= DC_LockDc(hDC
);
280 EngSetLastError(ERROR_INVALID_HANDLE
);
283 pdcattr
= pdc
->pdcattr
;
291 SafeResult
= pdcattr
->lRelAbs
;
294 case GdiGetBreakExtra
:
295 SafeResult
= pdcattr
->lBreakExtra
;
298 case GdiGerCharBreak
:
299 SafeResult
= pdcattr
->cBreak
;
302 case GdiGetArcDirection
:
303 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
304 SafeResult
= AD_CLOCKWISE
- ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0);
306 SafeResult
= ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0) + AD_COUNTERCLOCKWISE
;
309 case GdiGetEMFRestorDc
:
312 case GdiGetFontLanguageInfo
:
313 SafeResult
= IntGetFontLanguageInfo(pdc
);
317 SafeResult
= pdc
->dctype
;
321 SafeResult
= pdcattr
->iMapMode
;
324 case GdiGetTextCharExtra
:
325 SafeResult
= pdcattr
->lTextExtra
;
329 EngSetLastError(ERROR_INVALID_PARAMETER
);
338 ProbeForWrite(Result
, sizeof(DWORD
), 1);
339 *Result
= SafeResult
;
341 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
343 Status
= _SEH2_GetExceptionCode();
347 if (!NT_SUCCESS(Status
))
349 SetLastNtError(Status
);
358 _Success_(return != FALSE
)
361 NtGdiGetAndSetDCDword(
365 _Out_ DWORD
*pdwResult
)
371 DWORD SafeResult
= 0;
372 NTSTATUS Status
= STATUS_SUCCESS
;
376 EngSetLastError(ERROR_INVALID_PARAMETER
);
380 pdc
= DC_LockDc(hdc
);
383 EngSetLastError(ERROR_INVALID_HANDLE
);
386 pdcattr
= pdc
->pdcattr
;
390 case GdiGetSetCopyCount
:
391 SafeResult
= pdc
->ulCopyCount
;
392 pdc
->ulCopyCount
= dwIn
;
395 case GdiGetSetTextAlign
:
396 SafeResult
= pdcattr
->lTextAlign
;
397 pdcattr
->lTextAlign
= dwIn
;
398 // pdcattr->flTextAlign = dwIn; // Flags!
401 case GdiGetSetRelAbs
:
402 SafeResult
= pdcattr
->lRelAbs
;
403 pdcattr
->lRelAbs
= dwIn
;
406 case GdiGetSetTextCharExtra
:
407 SafeResult
= pdcattr
->lTextExtra
;
408 pdcattr
->lTextExtra
= dwIn
;
411 case GdiGetSetSelectFont
:
414 case GdiGetSetMapperFlagsInternal
:
417 EngSetLastError(ERROR_INVALID_PARAMETER
);
421 SafeResult
= pdcattr
->flFontMapper
;
422 pdcattr
->flFontMapper
= dwIn
;
425 case GdiGetSetMapMode
:
426 SafeResult
= IntGdiSetMapMode(pdc
, dwIn
);
429 case GdiGetSetArcDirection
:
430 if (dwIn
!= AD_COUNTERCLOCKWISE
&& dwIn
!= AD_CLOCKWISE
)
432 EngSetLastError(ERROR_INVALID_PARAMETER
);
436 if (pdcattr
->dwLayout
& LAYOUT_RTL
) // Right to Left
438 SafeResult
= AD_CLOCKWISE
- ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0);
439 if (dwIn
== AD_CLOCKWISE
)
441 pdc
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
444 pdc
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
446 else // Left to Right
448 SafeResult
= ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0) +
450 if (dwIn
== AD_COUNTERCLOCKWISE
)
452 pdc
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
455 pdc
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
460 EngSetLastError(ERROR_INVALID_PARAMETER
);
469 ProbeForWrite(pdwResult
, sizeof(DWORD
), 1);
470 *pdwResult
= SafeResult
;
472 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
474 Status
= _SEH2_GetExceptionCode();
478 if (!NT_SUCCESS(Status
))
480 SetLastNtError(Status
);
500 if (!(pdc
= DC_LockDc(hdc
))) return 0;
502 /* Get the return value */
503 ret
= pdc
->fs
& DC_ACCUM_APP
? DCB_ENABLE
: DCB_DISABLE
;
504 ret
|= RECTL_bIsEmptyRect(&pdc
->erclBoundsApp
) ? DCB_RESET
: DCB_SET
;
506 /* Copy the rect to the caller */
509 ProbeForWrite(prc
, sizeof(RECT
), 1);
510 *prc
= pdc
->erclBoundsApp
;
512 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
518 if (flags
& DCB_RESET
)
520 RECTL_vSetEmptyRect(&pdc
->erclBoundsApp
);
539 /* Verify arguments */
540 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
543 if (!(pdc
= DC_LockDc(hdc
))) return 0;
545 /* Get the return value */
546 ret
= pdc
->fs
& DC_ACCUM_APP
? DCB_ENABLE
: DCB_DISABLE
;
547 ret
|= RECTL_bIsEmptyRect(&pdc
->erclBoundsApp
) ? DCB_RESET
: DCB_SET
;
549 if (flags
& DCB_RESET
)
551 RECTL_vSetEmptyRect(&pdc
->erclBoundsApp
);
554 if (flags
& DCB_ACCUMULATE
)
556 /* Capture the rect */
559 ProbeForRead(prc
, sizeof(RECT
), 1);
562 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
565 _SEH2_YIELD(return 0;)
569 RECTL_vMakeWellOrdered(&rcl
);
570 RECTL_bUnionRect(&pdc
->erclBoundsApp
, &pdc
->erclBoundsApp
, &rcl
);
573 if (flags
& DCB_ENABLE
) pdc
->fs
|= DC_ACCUM_APP
;
574 if (flags
& DCB_DISABLE
) pdc
->fs
&= ~DC_ACCUM_APP
;
579 /* Translates a COLORREF to the right color in the specified DC color space */
581 TranslateCOLORREF(PDC pdc
, COLORREF crColor
)
585 ULONG index
, ulColor
, iBitmapFormat
;
588 /* Get the DC surface */
589 psurfDC
= pdc
->dclevel
.pSurface
;
591 /* If no surface is selected, use the default bitmap */
593 psurfDC
= psurfDefaultBitmap
;
595 /* Check what color type this is */
596 switch (crColor
>> 24)
598 case 0x00: /* RGB color */
601 case 0x01: /* PALETTEINDEX */
602 index
= crColor
& 0xFFFFFF;
603 ppalDC
= pdc
->dclevel
.ppal
;
604 if (index
>= ppalDC
->NumColors
) index
= 0;
606 /* Get the RGB value */
607 crColor
= PALETTE_ulGetRGBColorFromIndex(ppalDC
, index
);
610 case 0x02: /* PALETTERGB */
612 if (pdc
->dclevel
.hpal
!= StockObjects
[DEFAULT_PALETTE
])
614 /* First find the nearest index in the dc palette */
615 ppalDC
= pdc
->dclevel
.ppal
;
616 index
= PALETTE_ulGetNearestIndex(ppalDC
, crColor
& 0xFFFFFF);
618 /* Get the RGB value */
619 crColor
= PALETTE_ulGetRGBColorFromIndex(ppalDC
, index
);
623 /* Use the pure color */
624 crColor
= crColor
& 0x00FFFFFF;
628 case 0x10: /* DIBINDEX */
629 /* Mask the value to match the target bpp */
630 iBitmapFormat
= psurfDC
->SurfObj
.iBitmapFormat
;
631 if (iBitmapFormat
== BMF_1BPP
) index
= crColor
& 0x1;
632 else if (iBitmapFormat
== BMF_4BPP
) index
= crColor
& 0xf;
633 else if (iBitmapFormat
== BMF_8BPP
) index
= crColor
& 0xFF;
634 else if (iBitmapFormat
== BMF_16BPP
) index
= crColor
& 0xFFFF;
635 else index
= crColor
& 0xFFFFFF;
639 DPRINT("Unsupported color type %u passed\n", crColor
>> 24);
643 /* Initialize an XLATEOBJ from RGB to the target surface */
644 EXLATEOBJ_vInitialize(&exlo
, &gpalRGB
, psurfDC
->ppal
, 0xFFFFFF, 0, 0);
646 /* Translate the color to the target format */
647 ulColor
= XLATEOBJ_iXlate(&exlo
.xlo
, crColor
);
649 /* Cleanup the XLATEOBJ */
650 EXLATEOBJ_vCleanup(&exlo
);