fixed DrawFocusRect() to use values from SPI_GETFOCUSBORDERWIDTH/HEIGHT

svn path=/trunk/; revision=9263
This commit is contained in:
Thomas Bluemel 2004-05-01 11:38:28 +00:00
parent 9900ed382e
commit 36599d2a2b
2 changed files with 290 additions and 156 deletions

View file

@ -37,7 +37,14 @@
#include <windows.h> #include <windows.h>
#include <string.h> #include <string.h>
#include <wine/unicode.h> #include <wine/unicode.h>
#include <wine/debug.h> #include <user32.h>
#include <debug.h>
/* FIXME - not yet defined in w32api :( */
#define SPI_GETFOCUSBORDERWIDTH (8206)
#define SPI_SETFOCUSBORDERWIDTH (8207)
#define SPI_GETFOCUSBORDERHEIGHT (8208)
#define SPI_SETFOCUSBORDERHEIGHT (8209)
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
@ -1845,6 +1852,7 @@ DrawFocusRect(HDC hdc, CONST RECT *rect)
{ {
static HBRUSH hFocusRectBrush = NULL; static HBRUSH hFocusRectBrush = NULL;
HGDIOBJ OldObj; HGDIOBJ OldObj;
UINT cx, cy;
if(!hFocusRectBrush) if(!hFocusRectBrush)
{ {
@ -1855,16 +1863,19 @@ DrawFocusRect(HDC hdc, CONST RECT *rect)
hFocusRectBrush = CreatePatternBrush(hFocusPattern); hFocusRectBrush = CreatePatternBrush(hFocusPattern);
} }
NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH, 0, &cx, 0);
NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, &cy, 0);
OldObj = SelectObject(hdc, hFocusRectBrush); OldObj = SelectObject(hdc, hFocusRectBrush);
PatBlt(hdc, rect->left, rect->top, /* top */
rect->right - rect->left - 1, 1, PATINVERT); PatBlt(hdc, rect->left, rect->top, rect->right - rect->left, cy, PATINVERT);
PatBlt(hdc, rect->left, rect->top + 1, 1, /* bottom */
rect->bottom - rect->top - 1, PATINVERT); PatBlt(hdc, rect->left, rect->bottom - cy, rect->right - rect->left, cy, PATINVERT);
PatBlt(hdc, rect->left + 1, rect->bottom - 1, /* left */
rect->right - rect->left - 1, -1, PATINVERT); PatBlt(hdc, rect->left, rect->top + cy, cx, rect->bottom - rect->top - (2 * cy), PATINVERT);
PatBlt(hdc, rect->right - 1, rect->top, -1, /* right */
rect->bottom - rect->top - 1, PATINVERT); PatBlt(hdc, rect->right - cx, rect->top + cy, cx, rect->bottom - rect->top - (2 * cy), PATINVERT);
SelectObject(hdc, OldObj); SelectObject(hdc, OldObj);
return TRUE; return TRUE;

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.65 2004/05/01 09:31:59 weiden Exp $ /* $Id: misc.c,v 1.66 2004/05/01 11:38:28 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -8,6 +8,7 @@
* REVISION HISTORY: * REVISION HISTORY:
* 2003/05/22 Created * 2003/05/22 Created
*/ */
#define __WIN32K__
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ddk/ntddmou.h> #include <ddk/ntddmou.h>
#include <win32k/win32k.h> #include <win32k/win32k.h>
@ -35,6 +36,12 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* FIXME - not yet defined in w32api :( */
#define SPI_GETFOCUSBORDERWIDTH (8206)
#define SPI_SETFOCUSBORDERWIDTH (8207)
#define SPI_GETFOCUSBORDERHEIGHT (8208)
#define SPI_SETFOCUSBORDERHEIGHT (8209)
void W32kRegisterPrimitiveMessageQueue() { void W32kRegisterPrimitiveMessageQueue() {
extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
if( !pmPrimitiveMessageQueue ) { if( !pmPrimitiveMessageQueue ) {
@ -507,24 +514,22 @@ IntGetFontMetricSetting(LPWSTR lpValueName, PLOGFONTW font)
} }
} }
/* ULONG FASTCALL
* @implemented IntSystemParametersInfo(
*/
DWORD
STDCALL
NtUserSystemParametersInfo(
UINT uiAction, UINT uiAction,
UINT uiParam, UINT uiParam,
PVOID pvParam, PVOID pvParam,
UINT fWinIni) UINT fWinIni)
{ {
static BOOL GradientCaptions = TRUE;
NTSTATUS Status;
PWINSTATION_OBJECT WinStaObject; PWINSTATION_OBJECT WinStaObject;
NTSTATUS Status;
static BOOL bInitialized = FALSE; static BOOL bInitialized = FALSE;
static LOGFONTW IconFont; static LOGFONTW IconFont;
static NONCLIENTMETRICSW pMetrics; static NONCLIENTMETRICSW pMetrics;
static BOOL GradientCaptions = TRUE;
static UINT FocusBorderHeight = 1;
static UINT FocusBorderWidth = 1;
if (!bInitialized) if (!bInitialized)
{ {
@ -557,155 +562,273 @@ NtUserSystemParametersInfo(
case SPI_SETDOUBLECLKWIDTH: case SPI_SETDOUBLECLKWIDTH:
case SPI_SETDOUBLECLKHEIGHT: case SPI_SETDOUBLECLKHEIGHT:
case SPI_SETDOUBLECLICKTIME: case SPI_SETDOUBLECLICKTIME:
{
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode,
0,
&WinStaObject);
if(!NT_SUCCESS(Status))
{ {
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(), SetLastNtError(Status);
KernelMode, return (DWORD)FALSE;
0,
&WinStaObject);
if (!NT_SUCCESS(Status))
return (DWORD)FALSE;
switch(uiAction)
{
case SPI_SETDOUBLECLKWIDTH:
/* FIXME limit the maximum value? */
WinStaObject->SystemCursor.DblClickWidth = uiParam;
break;
case SPI_SETDOUBLECLKHEIGHT:
/* FIXME limit the maximum value? */
WinStaObject->SystemCursor.DblClickHeight = uiParam;
break;
case SPI_SETDOUBLECLICKTIME:
/* FIXME limit the maximum time to 1000 ms? */
WinStaObject->SystemCursor.DblClickSpeed = uiParam;
break;
}
/* FIXME save the value to the registry */
ObDereferenceObject(WinStaObject);
return TRUE;
} }
switch(uiAction)
{
case SPI_SETDOUBLECLKWIDTH:
/* FIXME limit the maximum value? */
WinStaObject->SystemCursor.DblClickWidth = uiParam;
break;
case SPI_SETDOUBLECLKHEIGHT:
/* FIXME limit the maximum value? */
WinStaObject->SystemCursor.DblClickHeight = uiParam;
break;
case SPI_SETDOUBLECLICKTIME:
/* FIXME limit the maximum time to 1000 ms? */
WinStaObject->SystemCursor.DblClickSpeed = uiParam;
break;
}
/* FIXME save the value to the registry */
ObDereferenceObject(WinStaObject);
return TRUE;
}
case SPI_SETWORKAREA: case SPI_SETWORKAREA:
{
RECT *rc;
PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
if(!Desktop)
{ {
PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; /* FIXME - Set last error */
return FALSE;
if(!Desktop)
{
/* FIXME - Set last error */
return FALSE;
}
Status = MmCopyFromCaller(Desktop->WorkArea, (PRECT)pvParam, sizeof(RECT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
} }
ASSERT(pvParam);
rc = (RECT*)pvParam;
Desktop->WorkArea = *rc;
return TRUE;
}
case SPI_GETWORKAREA: case SPI_GETWORKAREA:
{
PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
if(!Desktop)
{ {
PRECT Rect; /* FIXME - Set last error */
PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; return FALSE;
if(!Desktop)
{
/* FIXME - Set last error */
return FALSE;
}
Rect = IntGetDesktopWorkArea(Desktop);
Status = MmCopyToCaller((PRECT)pvParam, Desktop->WorkArea, sizeof(RECT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
} }
case SPI_GETGRADIENTCAPTIONS:
{
HDC hDC;
PDC dc;
SURFOBJ *SurfObj;
BOOL Ret = GradientCaptions;
hDC = IntGetScreenDC(); ASSERT(pvParam);
if(hDC) *((PRECT)pvParam) = *(IntGetDesktopWorkArea(Desktop));
{
dc = DC_LockDc(hDC);
SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
if(SurfObj)
Ret = (SurfObj->iBitmapFormat > BMF_8BPP);
DC_UnlockDc(hDC);
}
Status = MmCopyToCaller(pvParam, &Ret, sizeof(BOOL)); return TRUE;
if(!NT_SUCCESS(Status)) }
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
case SPI_SETGRADIENTCAPTIONS: case SPI_SETGRADIENTCAPTIONS:
{
GradientCaptions = (pvParam != NULL);
/* FIXME - should be checked if the color depth is higher than 8bpp? */
return TRUE;
}
case SPI_GETGRADIENTCAPTIONS:
{
HDC hDC;
PDC dc;
SURFOBJ *SurfObj;
BOOL Ret = GradientCaptions;
hDC = IntGetScreenDC();
if(hDC)
{ {
Status = MmCopyFromCaller(&GradientCaptions, pvParam, sizeof(BOOL)); dc = DC_LockDc(hDC);
if(!NT_SUCCESS(Status)) SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface);
{ if(SurfObj)
SetLastNtError(Status); Ret = (SurfObj->iBitmapFormat > BMF_8BPP) && Ret;
return FALSE; DC_UnlockDc(hDC);
}
ASSERT(pvParam);
*((PBOOL)pvParam) = Ret;
return TRUE; return TRUE;
} }
return FALSE;
}
case SPI_SETFONTSMOOTHING: case SPI_SETFONTSMOOTHING:
{ {
BOOL Enable; IntEnableFontRendering(uiParam != 0);
return TRUE;
Status = MmCopyFromCaller(&Enable, pvParam, sizeof(BOOL)); }
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
IntEnableFontRendering(Enable);
return TRUE;
}
case SPI_GETFONTSMOOTHING: case SPI_GETFONTSMOOTHING:
{ {
BOOL Enabled = IntIsFontRenderingEnabled(); ASSERT(pvParam);
*((BOOL*)pvParam) = IntIsFontRenderingEnabled();
Status = MmCopyToCaller(pvParam, &Enabled, sizeof(BOOL)); return TRUE;
if(!NT_SUCCESS(Status)) }
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
case SPI_GETICONTITLELOGFONT: case SPI_GETICONTITLELOGFONT:
{ {
MmCopyToCaller(pvParam, (PVOID)&IconFont, sizeof(LOGFONTW)); ASSERT(pvParam);
return TRUE; *((LOGFONTW*)pvParam) = IconFont;
return TRUE;
} }
case SPI_GETNONCLIENTMETRICS: case SPI_GETNONCLIENTMETRICS:
{ {
/* FIXME: Is this windows default behavior? */ ASSERT(pvParam);
LPNONCLIENTMETRICSW lpMetrics = (LPNONCLIENTMETRICSW)pvParam; *((NONCLIENTMETRICSW*)pvParam) = pMetrics;
if ( lpMetrics->cbSize != sizeof(NONCLIENTMETRICSW) || return TRUE;
uiParam != sizeof(NONCLIENTMETRICSW )) }
{ case SPI_GETFOCUSBORDERHEIGHT:
return FALSE; {
} ASSERT(pvParam);
DPRINT("FontName: %S, Size: %i\n",pMetrics.lfMessageFont.lfFaceName, pMetrics.lfMessageFont.lfHeight); *((UINT*)pvParam) = FocusBorderHeight;
MmCopyToCaller(pvParam, (PVOID)&pMetrics, sizeof(NONCLIENTMETRICSW)); return TRUE;
return TRUE; }
case SPI_GETFOCUSBORDERWIDTH:
{
ASSERT(pvParam);
*((UINT*)pvParam) = FocusBorderWidth;
return TRUE;
}
case SPI_SETFOCUSBORDERHEIGHT:
{
FocusBorderHeight = (UINT)pvParam;
return TRUE;
}
case SPI_SETFOCUSBORDERWIDTH:
{
FocusBorderWidth = (UINT)pvParam;
return TRUE;
}
default:
{
DPRINT1("SystemParametersInfo: Unsupported Action 0x%x (uiParam: 0x%x, pvParam: 0x%x, fWinIni: 0x%x)\n",
uiAction, uiParam, pvParam, fWinIni);
return FALSE;
}
}
return FALSE;
}
/*
* @implemented
*/
DWORD
STDCALL
NtUserSystemParametersInfo(
UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni)
{
NTSTATUS Status;
switch(uiAction)
{
case SPI_SETDOUBLECLKWIDTH:
case SPI_SETDOUBLECLKHEIGHT:
case SPI_SETDOUBLECLICKTIME:
case SPI_SETGRADIENTCAPTIONS:
case SPI_SETFONTSMOOTHING:
case SPI_SETFOCUSBORDERHEIGHT:
case SPI_SETFOCUSBORDERWIDTH:
{
return (DWORD)IntSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
}
case SPI_SETWORKAREA:
{
RECT rc;
Status = MmCopyFromCaller(&rc, (PRECT)pvParam, sizeof(RECT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return (DWORD)IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni);
}
case SPI_GETWORKAREA:
{
RECT rc;
if(!IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni))
{
return FALSE;
}
Status = MmCopyToCaller((PRECT)pvParam, &rc, sizeof(RECT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
case SPI_GETFONTSMOOTHING:
case SPI_GETGRADIENTCAPTIONS:
case SPI_GETFOCUSBORDERHEIGHT:
case SPI_GETFOCUSBORDERWIDTH:
{
BOOL Ret;
if(!IntSystemParametersInfo(uiAction, uiParam, &Ret, fWinIni))
{
return FALSE;
}
Status = MmCopyToCaller(pvParam, &Ret, sizeof(BOOL));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
case SPI_GETICONTITLELOGFONT:
{
LOGFONTW IconFont;
if(!IntSystemParametersInfo(uiAction, uiParam, &IconFont, fWinIni))
{
return FALSE;
}
Status = MmCopyToCaller(pvParam, &IconFont, sizeof(LOGFONTW));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
case SPI_GETNONCLIENTMETRICS:
{
NONCLIENTMETRICSW metrics;
Status = MmCopyFromCaller(&metrics.cbSize, pvParam, sizeof(UINT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
if((metrics.cbSize != sizeof(NONCLIENTMETRICSW)) ||
(uiParam != sizeof(NONCLIENTMETRICSW)))
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
if(!IntSystemParametersInfo(uiAction, uiParam, &metrics, fWinIni))
{
return FALSE;
}
Status = MmCopyToCaller(pvParam, &metrics.cbSize, sizeof(NONCLIENTMETRICSW));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
} }
} }
return FALSE; return FALSE;