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 BOOL
_Success_(return != FALSE
)
360 NtGdiGetAndSetDCDword(
364 _Out_ DWORD
*pdwResult
)
370 DWORD SafeResult
= 0;
371 NTSTATUS Status
= STATUS_SUCCESS
;
375 EngSetLastError(ERROR_INVALID_PARAMETER
);
379 pdc
= DC_LockDc(hdc
);
382 EngSetLastError(ERROR_INVALID_HANDLE
);
385 pdcattr
= pdc
->pdcattr
;
389 case GdiGetSetCopyCount
:
390 SafeResult
= pdc
->ulCopyCount
;
391 pdc
->ulCopyCount
= dwIn
;
394 case GdiGetSetTextAlign
:
395 SafeResult
= pdcattr
->lTextAlign
;
396 pdcattr
->lTextAlign
= dwIn
;
397 // pdcattr->flTextAlign = dwIn; // Flags!
400 case GdiGetSetRelAbs
:
401 SafeResult
= pdcattr
->lRelAbs
;
402 pdcattr
->lRelAbs
= dwIn
;
405 case GdiGetSetTextCharExtra
:
406 SafeResult
= pdcattr
->lTextExtra
;
407 pdcattr
->lTextExtra
= dwIn
;
410 case GdiGetSetSelectFont
:
413 case GdiGetSetMapperFlagsInternal
:
416 EngSetLastError(ERROR_INVALID_PARAMETER
);
420 SafeResult
= pdcattr
->flFontMapper
;
421 pdcattr
->flFontMapper
= dwIn
;
424 case GdiGetSetMapMode
:
425 SafeResult
= IntGdiSetMapMode(pdc
, dwIn
);
428 case GdiGetSetArcDirection
:
429 if (dwIn
!= AD_COUNTERCLOCKWISE
&& dwIn
!= AD_CLOCKWISE
)
431 EngSetLastError(ERROR_INVALID_PARAMETER
);
435 if (pdcattr
->dwLayout
& LAYOUT_RTL
) // Right to Left
437 SafeResult
= AD_CLOCKWISE
- ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0);
438 if (dwIn
== AD_CLOCKWISE
)
440 pdc
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
443 pdc
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
445 else // Left to Right
447 SafeResult
= ((pdc
->dclevel
.flPath
& DCPATH_CLOCKWISE
) != 0) +
449 if (dwIn
== AD_COUNTERCLOCKWISE
)
451 pdc
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
454 pdc
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
459 EngSetLastError(ERROR_INVALID_PARAMETER
);
468 ProbeForWrite(pdwResult
, sizeof(DWORD
), 1);
469 *pdwResult
= SafeResult
;
471 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
473 Status
= _SEH2_GetExceptionCode();
477 if (!NT_SUCCESS(Status
))
479 SetLastNtError(Status
);
499 if (!(pdc
= DC_LockDc(hdc
))) return 0;
501 /* Get the return value */
502 ret
= pdc
->fs
& DC_ACCUM_APP
? DCB_ENABLE
: DCB_DISABLE
;
503 ret
|= RECTL_bIsEmptyRect(&pdc
->erclBoundsApp
) ? DCB_RESET
: DCB_SET
;
505 /* Copy the rect to the caller */
508 ProbeForWrite(prc
, sizeof(RECT
), 1);
509 *prc
= pdc
->erclBoundsApp
;
511 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
517 if (flags
& DCB_RESET
)
519 RECTL_vSetEmptyRect(&pdc
->erclBoundsApp
);
538 /* Verify arguments */
539 if ((flags
& DCB_ENABLE
) && (flags
& DCB_DISABLE
)) return 0;
542 if (!(pdc
= DC_LockDc(hdc
))) return 0;
544 /* Get the return value */
545 ret
= pdc
->fs
& DC_ACCUM_APP
? DCB_ENABLE
: DCB_DISABLE
;
546 ret
|= RECTL_bIsEmptyRect(&pdc
->erclBoundsApp
) ? DCB_RESET
: DCB_SET
;
548 if (flags
& DCB_RESET
)
550 RECTL_vSetEmptyRect(&pdc
->erclBoundsApp
);
553 if (flags
& DCB_ACCUMULATE
)
555 /* Capture the rect */
558 ProbeForRead(prc
, sizeof(RECT
), 1);
561 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
564 _SEH2_YIELD(return 0;)
568 RECTL_vMakeWellOrdered(&rcl
);
569 RECTL_bUnionRect(&pdc
->erclBoundsApp
, &pdc
->erclBoundsApp
, &rcl
);
572 if (flags
& DCB_ENABLE
) pdc
->fs
|= DC_ACCUM_APP
;
573 if (flags
& DCB_DISABLE
) pdc
->fs
&= ~DC_ACCUM_APP
;
578 /* Translates a COLORREF to the right color in the specified DC color space */
580 TranslateCOLORREF(PDC pdc
, COLORREF crColor
)
584 ULONG index
, ulColor
, iBitmapFormat
;
587 /* Get the DC surface */
588 psurfDC
= pdc
->dclevel
.pSurface
;
590 /* If no surface is selected, use the default bitmap */
592 psurfDC
= psurfDefaultBitmap
;
594 /* Check what color type this is */
595 switch (crColor
>> 24)
597 case 0x00: /* RGB color */
600 case 0x01: /* PALETTEINDEX */
601 index
= crColor
& 0xFFFFFF;
602 ppalDC
= pdc
->dclevel
.ppal
;
603 if (index
>= ppalDC
->NumColors
) index
= 0;
605 /* Get the RGB value */
606 crColor
= PALETTE_ulGetRGBColorFromIndex(ppalDC
, index
);
609 case 0x02: /* PALETTERGB */
611 if (pdc
->dclevel
.hpal
!= StockObjects
[DEFAULT_PALETTE
])
613 /* First find the nearest index in the dc palette */
614 ppalDC
= pdc
->dclevel
.ppal
;
615 index
= PALETTE_ulGetNearestIndex(ppalDC
, crColor
& 0xFFFFFF);
617 /* Get the RGB value */
618 crColor
= PALETTE_ulGetRGBColorFromIndex(ppalDC
, index
);
622 /* Use the pure color */
623 crColor
= crColor
& 0x00FFFFFF;
627 case 0x10: /* DIBINDEX */
628 /* Mask the value to match the target bpp */
629 iBitmapFormat
= psurfDC
->SurfObj
.iBitmapFormat
;
630 if (iBitmapFormat
== BMF_1BPP
) index
= crColor
& 0x1;
631 else if (iBitmapFormat
== BMF_4BPP
) index
= crColor
& 0xf;
632 else if (iBitmapFormat
== BMF_8BPP
) index
= crColor
& 0xFF;
633 else if (iBitmapFormat
== BMF_16BPP
) index
= crColor
& 0xFFFF;
634 else index
= crColor
& 0xFFFFFF;
638 DPRINT("Unsupported color type %u passed\n", crColor
>> 24);
642 /* Initialize an XLATEOBJ from RGB to the target surface */
643 EXLATEOBJ_vInitialize(&exlo
, &gpalRGB
, psurfDC
->ppal
, 0xFFFFFF, 0, 0);
645 /* Translate the color to the target format */
646 ulColor
= XLATEOBJ_iXlate(&exlo
.xlo
, crColor
);
648 /* Cleanup the XLATEOBJ */
649 EXLATEOBJ_vCleanup(&exlo
);