- Removed NtGdiGetSysColorBrush and modified functions that used it.

- Modified desktop drawing to use PaintDesktop.

svn path=/trunk/; revision=7178
This commit is contained in:
Filip Navara 2003-12-22 15:30:21 +00:00
parent 13347b6918
commit 0ebaadbbae
9 changed files with 122 additions and 119 deletions

View file

@ -1,4 +1,4 @@
/* $Id: class.c,v 1.41 2003/12/07 22:25:34 weiden Exp $
/* $Id: class.c,v 1.42 2003/12/22 15:30:21 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@ -267,24 +267,31 @@ GetClassInfoW(
* @implemented
*/
DWORD STDCALL
GetClassLongA ( HWND hWnd, int nIndex )
GetClassLongA(HWND hWnd, int nIndex)
{
PUNICODE_STRING str;
switch (nIndex)
{
case GCL_HBRBACKGROUND:
{
DWORD hBrush = NtUserGetClassLong(hWnd, GCL_HBRBACKGROUND, TRUE);
if (hBrush != 0 && hBrush < 0x4000)
hBrush = (DWORD)GetSysColorBrush((ULONG)hBrush - 1);
return hBrush;
}
if ( nIndex != GCL_MENUNAME )
{
return NtUserGetClassLong ( hWnd, nIndex, TRUE );
}
case GCL_MENUNAME:
{
PUNICODE_STRING Name;
Name = (PUNICODE_STRING)NtUserGetClassLong(hWnd, nIndex, TRUE);
if (IS_INTRESOURCE(Name))
return (DWORD)Name;
else
return (DWORD)heap_string_poolA(Name->Buffer, Name->Length);
}
str = (PUNICODE_STRING)NtUserGetClassLong ( hWnd, nIndex, TRUE );
if ( IS_INTRESOURCE(str) )
{
return (DWORD)str;
}
else
{
return (DWORD)heap_string_poolA ( str->Buffer, str->Length );
}
default:
return NtUserGetClassLong(hWnd, nIndex, TRUE);
}
}
/*
@ -293,22 +300,29 @@ GetClassLongA ( HWND hWnd, int nIndex )
DWORD STDCALL
GetClassLongW ( HWND hWnd, int nIndex )
{
PUNICODE_STRING str;
switch (nIndex)
{
case GCL_HBRBACKGROUND:
{
DWORD hBrush = NtUserGetClassLong(hWnd, GCL_HBRBACKGROUND, TRUE);
if (hBrush != 0 && hBrush < 0x4000)
hBrush = (DWORD)GetSysColorBrush((ULONG)hBrush - 1);
return hBrush;
}
if ( nIndex != GCL_MENUNAME )
{
return NtUserGetClassLong ( hWnd, nIndex, FALSE );
}
case GCL_MENUNAME:
{
PUNICODE_STRING Name;
Name = (PUNICODE_STRING)NtUserGetClassLong(hWnd, nIndex, FALSE);
if (IS_INTRESOURCE(Name))
return (DWORD)Name;
else
return (DWORD)heap_string_poolW(Name->Buffer, Name->Length);
}
str = (PUNICODE_STRING)NtUserGetClassLong(hWnd, nIndex, TRUE);
if ( IS_INTRESOURCE(str) )
{
return (DWORD)str;
}
else
{
return (DWORD)heap_string_poolW ( str->Buffer, str->Length );
}
default:
return NtUserGetClassLong(hWnd, nIndex, FALSE);
}
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: draw.c,v 1.32 2003/12/21 16:49:41 navaraf Exp $
/* $Id: draw.c,v 1.33 2003/12/22 15:30:21 navaraf Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c
@ -47,13 +47,22 @@
/* INCLUDES ******************************************************************/
#ifndef __USE_W32API
#define __USE_W32API
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
#ifndef __USE_W32API
#include <user32.h>
#endif
// Needed for DrawState
#include <string.h>
#ifndef __USE_W32API
#include <unicode.h>
#include <draw.h>
#endif
#define NDEBUG
#include <debug.h>
@ -497,7 +506,7 @@ static BOOL UITOOLS95_DrawRectEdge(HDC hdc, LPRECT rc,
* otherwise.
* Dennis Björklund, 10 June, 99
*/
/* if( TWEAK_WineLook == WIN98_LOOK && LTInnerI != -1 ) */
if( LTInnerI != -1 )
LTInnerI = RBInnerI = COLOR_BTNFACE;
}
else if(uFlags & BF_SOFT)
@ -885,8 +894,10 @@ static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT uState)
case DFCS_BUTTONRADIO:
return UITOOLS95_DFC_ButtonRadio(hdc, rc, uState);
/*
default:
DbgPrint("Invalid button state=0x%04x\n", uState);
*/
}
return FALSE;
@ -1348,7 +1359,9 @@ static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
break;
default:
/*
DbgPrint("Invalid menu; flags=0x%04x\n", uFlags);
*/
retval = FALSE;
break;
}
@ -1380,8 +1393,10 @@ BOOL WINAPI DrawFrameControl( HDC hdc, LPRECT rc, UINT uType,
*/
case DFC_SCROLL:
return UITOOLS95_DrawFrameScroll(hdc, rc, uState);
/*
default:
DbgPrint("(%p,%p,%d,%x), bad type!\n", hdc,rc,uType,uState );
*/
}
return FALSE;
}
@ -1736,7 +1751,9 @@ WINBOOL INTERNAL_DrawStateDraw(HDC hdc, UINT type, DRAWSTATEPROC lpOutputFunc,
case DST_TEXT :
case DST_PREFIXTEXT :
{
/*
DbgPrint("Drawing DST_TEXT\n");
*/
if (unicode)
return DrawTextW(hdc, (LPWSTR)lData, (INT)wData, rc, dtflags);
else
@ -1746,26 +1763,34 @@ WINBOOL INTERNAL_DrawStateDraw(HDC hdc, UINT type, DRAWSTATEPROC lpOutputFunc,
case DST_ICON :
{
// TODO
/*
DbgPrint("Drawing DST_ICON\n");
*/
return retval;
}
case DST_BITMAP :
{
// TODO
/*
DbgPrint("Drawing DST_BITMAP\n");
*/
return retval;
}
case DST_COMPLEX :
{
/*
DbgPrint("Drawing DST_COMPLEX\n");
*/
// Call lpOutputFunc, if necessary
if (lpOutputFunc)
{
// Something seems to be wrong with OffsetViewportOrgEx:
OffsetViewportOrgEx(hdc, rc->left, rc->top, NULL);
/*
DbgPrint("Calling lpOutputFunc(0x%x, 0x%x, 0x%x, %d, %d)\n", hdc, lData, wData, cx, cy);
*/
retval = lpOutputFunc(hdc, lData, wData, cx, cy);
OffsetViewportOrgEx(hdc, -rc->left, -rc->top, NULL);
return retval;
@ -1820,7 +1845,9 @@ WINBOOL INTERNAL_DrawState(
state = fuFlags & 0x7ff0; // DSS_xxx
len = wData; // Data length
/*
DbgPrint("Entered DrawState, fuFlags %d, type %d, state %d\n", fuFlags, type, state);
*/
if ((type == DST_TEXT || type == DST_PREFIXTEXT) && ! len)
{
@ -1845,7 +1872,9 @@ WINBOOL INTERNAL_DrawState(
{
BOOL success;
/*
DbgPrint("Calculating rect of DST_TEXT / DST_PREFIXTEXT\n");
*/
if (unicode)
success = GetTextExtentPoint32W(hdc, (LPWSTR) lData, len, &s);
@ -1858,14 +1887,18 @@ WINBOOL INTERNAL_DrawState(
case DST_ICON :
{
/*
DbgPrint("Calculating rect of DST_ICON\n");
*/
// TODO
break;
}
case DST_BITMAP :
{
/*
DbgPrint("Calculating rect of DST_BITMAP\n");
*/
if (!GetObjectA((HBITMAP) lData, sizeof(bm), &bm))
return FALSE;
@ -1876,7 +1909,9 @@ WINBOOL INTERNAL_DrawState(
}
case DST_COMPLEX : // cx and cy must be set in this mode
/*
DbgPrint("Calculating rect of DST_COMPLEX - Not allowed!\n");
*/
return FALSE;
}
@ -1893,7 +1928,9 @@ WINBOOL INTERNAL_DrawState(
// No additional processing needed for DSS_NORMAL
if (state == DSS_NORMAL)
{
/*
DbgPrint("DSS_NORMAL (no additional processing necessary)\n");
*/
SetRect(&rect, x, y, x + cx, y + cy);
return INTERNAL_DrawStateDraw(hdc, type, lpOutputFunc, lData, wData, &rect, dtflags, unicode);
}
@ -1915,7 +1952,9 @@ WINBOOL INTERNAL_DrawState(
OldBMP = (HBITMAP) SelectObject(MemDC, MemBMP);
if (! OldBMP) goto cleanup;
/*
DbgPrint("Created and inited MemDC\n");
*/
// Set up the default colors and font
if (! FillRect(MemDC, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH))) goto cleanup;
@ -1923,7 +1962,9 @@ WINBOOL INTERNAL_DrawState(
SetTextColor(MemDC, RGB(0, 0, 0));
Font = (HFONT)SelectObject(MemDC, GetCurrentObject(hdc, OBJ_FONT));
/*
DbgPrint("Selected font and set colors\n");
*/
// Enable this line to use the current DC image to begin with (wrong?)
// if (! BitBlt(MemDC, 0, 0, cx, cy, hdc, x, y, SRCCOPY)) goto cleanup;
@ -1938,12 +1979,16 @@ WINBOOL INTERNAL_DrawState(
if (! TempResult) goto cleanup;
}
/*
DbgPrint("Done drawing\n");
*/
// Apply state(s?)
if (state & DSS_UNION)
{
/*
DbgPrint("DSS_UNION\n");
*/
// Dither the image (not implemented in ReactOS yet?)
// TODO
}
@ -1957,7 +2002,9 @@ WINBOOL INTERNAL_DrawState(
// Draw shadow
if (state & (DSS_DISABLED /*|DSS_DEFAULT*/))
{
/*
DbgPrint("DSS_DISABLED - Drawing shadow\n");
*/
if (! TempBrush) goto cleanup;
OldBrush = (HBRUSH)SelectObject(hdc, TempBrush);
if (! OldBrush) goto cleanup;
@ -1969,29 +2016,39 @@ WINBOOL INTERNAL_DrawState(
if (state & DSS_DISABLED)
{
/*
DbgPrint("DSS_DISABLED - Creating shadow brush 2\n");
*/
hbr = TempBrush = CreateSolidBrush(GetSysColor(COLOR_3DSHADOW));
if (! TempBrush) goto cleanup;
}
else if (! hbr)
{
/*
DbgPrint("Creating a brush\n");
*/
hbr = (HBRUSH) GetStockObject(BLACK_BRUSH);
}
/*
DbgPrint("Selecting new brush\n");
*/
OldBrush = (HBRUSH) SelectObject(hdc, hbr);
// Copy to hdc from MemDC
/*
DbgPrint("Blitting\n");
*/
if (! BitBlt(hdc, x, y, cx, cy, MemDC, 0, 0, 0x00B8074A)) goto cleanup;
retval = TRUE;
cleanup :
/*
DbgPrint("In cleanup : Font %x OldBrush %x OldBMP %x Tempbrush %x MemBMP %x MemDC %x\n",
Font, OldBrush, OldBMP, TempBrush, MemBMP, MemDC);
*/
SetTextColor(hdc, ForeColor);
SetBkColor(hdc, BackColor);
if (OldBrush) SelectObject(MemDC, OldBrush);
@ -2000,7 +2057,9 @@ WINBOOL INTERNAL_DrawState(
if (MemBMP) DeleteObject(MemBMP);
if (MemDC) DeleteDC(MemDC);
/*
DbgPrint("Leaving DrawState() with retval %d\n", retval);
*/
return retval;
}

View file

@ -1,4 +1,4 @@
/* $Id: desktopbg.c,v 1.2 2003/12/13 16:04:36 navaraf Exp $
/* $Id: desktopbg.c,v 1.3 2003/12/22 15:30:21 navaraf Exp $
*
* reactos/subsys/csrss/win32csr/desktopbg.c
*
@ -33,16 +33,6 @@ typedef struct tagDTBG_THREAD_DATA
static BOOL Initialized = FALSE;
static void FASTCALL
DtbgPaint(HDC hDC, LPRECT lpRect)
{
HBRUSH DesktopBrush;
DesktopBrush = CreateSolidBrush(RGB(58, 110, 165));
FillRect(hDC, lpRect, DesktopBrush);
DeleteObject(DesktopBrush);
}
static LRESULT CALLBACK
DtbgWindowProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
@ -59,18 +49,15 @@ DtbgWindowProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
case WM_PAINT:
{
PAINTSTRUCT PS;
BeginPaint(Wnd, &PS);
DtbgPaint(PS.hdc, &(PS.rcPaint));
PaintDesktop((HDC)PS.hdc);
EndPaint(Wnd, &PS);
Result = 0;
}
break;
case WM_ERASEBKGND:
{
RECT ClientRect;
GetClientRect(Wnd, &ClientRect);
DtbgPaint((HDC)wParam, &ClientRect);
PaintDesktop((HDC)wParam);
Result = 1;
}
break;
@ -128,7 +115,7 @@ DtbgInit()
Class.hInstance = (HINSTANCE) GetModuleHandleW(NULL);
Class.hIcon = NULL;
Class.hCursor = NULL;
Class.hbrBackground = NULL;
Class.hbrBackground = GetSysColorBrush(COLOR_BACKGROUND);
Class.lpszMenuName = NULL;
Class.lpszClassName = (LPCWSTR) DESKTOP_WINDOW_ATOM;
ClassAtom = RegisterClassExW(&Class);

View file

@ -5,6 +5,5 @@ const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate (VOID);
COLORREF STDCALL COLOR_LookupNearestColor (PALETTEENTRY* palPalEntry, INT size, COLORREF color);
INT STDCALL COLOR_PaletteLookupExactIndex (PALETTEENTRY* palPalEntry, INT size, COLORREF col);
INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, PXLATEOBJ XlateObj, COLORREF col, BOOL skipReserved);
HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex);
#endif /* _WIN32K_COLOR_H */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: class.c,v 1.44 2003/12/07 23:01:01 weiden Exp $
/* $Id: class.c,v 1.45 2003/12/22 15:30:21 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -451,10 +451,6 @@ IntGetClassLong(struct _WINDOW_OBJECT *WindowObject, ULONG Offset, BOOL Ansi)
break;
case GCL_HBRBACKGROUND:
Ret = (ULONG)WindowObject->Class->hbrBackground;
if (Ret != 0 && Ret < 0x4000)
{
Ret = (ULONG)NtGdiGetSysColorBrush(Ret - 1);
}
break;
case GCL_HCURSOR:
Ret = (ULONG)WindowObject->Class->hCursor;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: desktop.c,v 1.5 2003/12/13 18:40:34 gvg Exp $
* $Id: desktop.c,v 1.6 2003/12/22 15:30:21 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -644,15 +644,19 @@ BOOL STDCALL
NtUserPaintDesktop(HDC hDC)
{
RECT Rect;
HBRUSH PreviousBrush;
HBRUSH DesktopBrush, PreviousBrush;
HWND hWndDesktop;
IntGdiGetClipBox(hDC, &Rect);
hWndDesktop = IntGetDesktopWindow();
DesktopBrush = (HBRUSH)NtUserGetClassLong(hWndDesktop, GCL_HBRBACKGROUND, FALSE);
/*
* Paint desktop background
*/
PreviousBrush = NtGdiSelectObject(hDC, NtGdiGetSysColorBrush(COLOR_BACKGROUND));
PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);
NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
NtGdiSelectObject(hDC, PreviousBrush);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: menu.c,v 1.35 2003/12/21 22:09:07 weiden Exp $
/* $Id: menu.c,v 1.36 2003/12/22 15:30:21 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -271,7 +271,8 @@ IntCreateMenu(PHANDLE Handle)
MenuObject->MenuInfo.fMask = 0; /* not used */
MenuObject->MenuInfo.dwStyle = 0; /* FIXME */
MenuObject->MenuInfo.cyMax = 0; /* default */
MenuObject->MenuInfo.hbrBack = NtGdiGetSysColorBrush(COLOR_MENU); /*default background color */
MenuObject->MenuInfo.hbrBack =
NtGdiCreateSolidBrush(RGB(192, 192, 192)); /* FIXME: default background color */
MenuObject->MenuInfo.dwContextHelpID = 0; /* default */
MenuObject->MenuInfo.dwMenuData = 0; /* default */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: winpos.c,v 1.60 2003/12/22 11:37:32 navaraf Exp $
/* $Id: winpos.c,v 1.61 2003/12/22 15:30:21 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -577,7 +577,6 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
{
for (i = 0; List[i]; i++)
{
DPRINT1("%x\n", List[i]);
if (List[i] == hWnd)
break;
if ((NtUserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) &&

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: color.c,v 1.31 2003/12/20 10:31:32 navaraf Exp $ */
/* $Id: color.c,v 1.32 2003/12/22 15:30:21 navaraf Exp $ */
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
@ -78,62 +78,6 @@ const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
{ 0xff, 0xff, 0xff, PC_SYS_USED } // last 10
};
const COLORREF SysColours[] =
{
RGB(224, 224, 224) /* COLOR_SCROLLBAR */,
RGB(58, 110, 165) /* COLOR_BACKGROUND */,
RGB(0, 0, 128) /* COLOR_ACTIVECAPTION */,
RGB(128, 128, 128) /* COLOR_INACTIVECAPTION */,
RGB(192, 192, 192) /* COLOR_MENU */,
RGB(255, 255, 255) /* COLOR_WINDOW */,
RGB(0, 0, 0) /* COLOR_WINDOWFRAME */,
RGB(0, 0, 0) /* COLOR_MENUTEXT */,
RGB(0, 0, 0) /* COLOR_WINDOWTEXT */,
RGB(255, 255, 255) /* COLOR_CAPTIONTEXT */,
RGB(128, 128, 128) /* COLOR_ACTIVEBORDER */,
RGB(255, 255, 255) /* COLOR_INACTIVEBORDER */,
RGB(255, 255, 232) /* COLOR_APPWORKSPACE */,
RGB(224, 224, 224) /* COLOR_HILIGHT */,
RGB(0, 0, 128) /* COLOR_HILIGHTTEXT */,
RGB(192, 192, 192) /* COLOR_BTNFACE */,
RGB(128, 128, 128) /* COLOR_BTNSHADOW */,
RGB(192, 192, 192) /* COLOR_GRAYTEXT */,
RGB(0, 0, 0) /* COLOR_BTNTEXT */,
RGB(192, 192, 192) /* COLOR_INACTIVECAPTIONTEXT */,
RGB(255, 255, 255) /* COLOR_BTNHILIGHT */,
RGB(32, 32, 32) /* COLOR_3DDKSHADOW */,
RGB(192, 192, 192) /* COLOR_3DLIGHT */,
RGB(0, 0, 0) /* COLOR_INFOTEXT */,
RGB(255, 255, 192) /* COLOR_INFOBK */,
RGB(184, 180, 184) /* COLOR_ALTERNATEBTNFACE */,
RGB(0, 0, 255) /* COLOR_HOTLIGHT */,
RGB(16, 132, 208) /* COLOR_GRADIENTACTIVECAPTION */,
RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */,
};
HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex)
{
static HBRUSH SysBrushes[sizeof(SysColours) / sizeof(SysColours[0])];
if (nIndex < 0 || sizeof(SysColours) / sizeof(SysColours[0]) < nIndex)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return NULL;
}
/* FIXME Should be changed when a new user logs in? */
if (NULL == SysBrushes[nIndex])
{
SysBrushes[nIndex] = (HBRUSH) ((DWORD)NtGdiCreateSolidBrush(SysColours[nIndex]));
if (NULL != SysBrushes[nIndex])
{
GDIOBJ_SetOwnership(SysBrushes[nIndex], NULL);
}
}
return SysBrushes[nIndex];
}
const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void)
{
return (const PALETTEENTRY*)&COLOR_sysPalTemplate;