implemented gradient caption bars

svn path=/trunk/; revision=7210
This commit is contained in:
Thomas Bluemel 2003-12-24 01:26:10 +00:00
parent a52d82602e
commit b1e7c60fdd
4 changed files with 222 additions and 35 deletions

View file

@ -1781,6 +1781,10 @@ extern "C" {
#define COLOR_WINDOW (5)
#define COLOR_WINDOWFRAME (6)
#define COLOR_WINDOWTEXT (8)
#define COLOR_GRADIENTACTIVECAPTION (27)
#define COLOR_GRADIENTINACTIVECAPTION (28)
#define COLOR_MENUHILIGHT (29)
#define COLOR_MENUBAR (30)
/* GetSystemMetrics */
#define SM_CYMIN (29)
@ -2723,6 +2727,74 @@ extern "C" {
#define SPI_SETSTICKYKEYS (59)
#define SPI_SETTOGGLEKEYS (53)
#define SPI_SETWORKAREA (47)
#define SPI_GETACTIVEWINDOWTRACKING (4096)
#define SPI_SETACTIVEWINDOWTRACKING (4097)
#define SPI_GETMENUANIMATION (4098)
#define SPI_SETMENUANIMATION (4099)
#define SPI_GETCOMBOBOXANIMATION (4100)
#define SPI_SETCOMBOBOXANIMATION (4101)
#define SPI_GETLISTBOXSMOOTHSCROLLING (4102)
#define SPI_SETLISTBOXSMOOTHSCROLLING (4103)
#define SPI_GETGRADIENTCAPTIONS (4104)
#define SPI_SETGRADIENTCAPTIONS (4105)
#define SPI_GETKEYBOARDCUES (4106)
#define SPI_SETKEYBOARDCUES (4107)
#define SPI_GETMENUUNDERLINES (SPI_GETKEYBOARDCUES)
#define SPI_SETMENUUNDERLINES (SPI_SETKEYBOARDCUES)
#define SPI_GETACTIVEWNDTRKZORDER (4108)
#define SPI_SETACTIVEWNDTRKZORDER (4109)
#define SPI_GETHOTTRACKING (4110)
#define SPI_SETHOTTRACKING (4111)
#define SPI_GETMENUFADE (4114)
#define SPI_SETMENUFADE (4115)
#define SPI_GETSELECTIONFADE (4116)
#define SPI_SETSELECTIONFADE (4117)
#define SPI_GETTOOLTIPANIMATION (4118)
#define SPI_SETTOOLTIPANIMATION (4119)
#define SPI_GETTOOLTIPFADE (4120)
#define SPI_SETTOOLTIPFADE (4121)
#define SPI_GETCURSORSHADOW (4122)
#define SPI_SETCURSORSHADOW (4123)
#define SPI_GETMOUSESONAR (4124)
#define SPI_SETMOUSESONAR (4125)
#define SPI_GETMOUSECLICKLOCK (4126)
#define SPI_SETMOUSECLICKLOCK (4127)
#define SPI_GETMOUSEVANISH (4128)
#define SPI_SETMOUSEVANISH (4129)
#define SPI_GETFLATMENU (4130)
#define SPI_SETFLATMENU (4131)
#define SPI_GETDROPSHADOW (4132)
#define SPI_SETDROPSHADOW (4133)
#define SPI_GETBLOCKSENDINPUTRESETS (4134)
#define SPI_SETBLOCKSENDINPUTRESETS (4135)
#define SPI_GETUIEFFECTS (4158)
#define SPI_SETUIEFFECTS (4159)
#define SPI_GETFOREGROUNDLOCKTIMEOUT (8192)
#define SPI_SETFOREGROUNDLOCKTIMEOUT (8192)
#define SPI_GETACTIVEWNDTRKTIMEOUT (8193)
#define SPI_SETACTIVEWNDTRKTIMEOUT (8194)
#define SPI_GETFOREGROUNDFLASHCOUNT (8195)
#define SPI_SETFOREGROUNDFLASHCOUNT (8196)
#define SPI_GETCARETWIDTH (8197)
#define SPI_SETCARETWIDTH (8198)
#define SPI_GETMOUSECLICKLOCKTIME (8199)
#define SPI_SETMOUSECLICKLOCKTIME (8200)
#define SPI_GETFONTSMOOTHINGTYPE (8201)
#define SPI_SETFONTSMOOTHINGTYPE (8202)
#define FE_FONTSMOOTHINGSTANDARD (1) /* for SPI_GETFONTSMOOTHINGTYPE and SPI_SETFONTSMOOTHINGTYPE */
#define FE_FONTSMOOTHINGCLEARTYPE (2) /* for SPI_GETFONTSMOOTHINGTYPE and SPI_SETFONTSMOOTHINGTYPE */
#define FE_FONTSMOOTHINGDOCKING (32768) /* for SPI_GETFONTSMOOTHINGTYPE and SPI_SETFONTSMOOTHINGTYPE */
#define SPI_GETFONTSMOOTHINGCONTRAST (8204)
#define SPI_SETFONTSMOOTHINGCONTRAST (8205)
#define SPI_GETFOCUSBORDERWIDTH (8206)
#define SPI_SETFOCUSBORDERWIDTH (8207)
#define SPI_GETFOCUSBORDERHEIGHT (8208)
#define SPI_SETFOCUSBORDERHEIGHT (8209)
#define SPI_GETFONTSMOOTHINGORIENTATION (8210)
#define SPI_SETFONTSMOOTHINGORIENTATION (8211)
#define FE_FONTSMOOTHINGORIENTATIONBGR (0) /* for SPI_GETFONTSMOOTHINGORIENTATION and SPI_SETFONTSMOOTHINGORIENTATION */
#define FE_FONTSMOOTHINGORIENTATIONRGB (1) /* for SPI_GETFONTSMOOTHINGORIENTATION and SPI_SETFONTSMOOTHINGORIENTATION */
#define SPIF_UPDATEINIFILE (1)
#define SPIF_SENDWININICHANGE (2)
#define SPIF_SENDCHANGE (2)

View file

@ -1,4 +1,4 @@
/* $Id: defwnd.c,v 1.114 2003/12/23 08:48:59 navaraf Exp $
/* $Id: defwnd.c,v 1.115 2003/12/24 01:26:10 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@ -48,7 +48,7 @@ static HBITMAP hbScrRight;
*/
static COLORREF SysColours[] =
static COLORREF SysColors[] =
{
RGB(192, 192, 192) /* COLOR_SCROLLBAR */,
RGB(58, 110, 165) /* COLOR_BACKGROUND */,
@ -81,7 +81,7 @@ static COLORREF SysColours[] =
RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */,
};
#define NUM_SYSCOLORS (sizeof(SysColours) / sizeof(SysColours[0]))
#define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
ATOM AtomInternalPos;
@ -103,7 +103,7 @@ UserSetupInternalPos(VOID)
DWORD STDCALL
GetSysColor(int nIndex)
{
return SysColours[nIndex];
return SysColors[nIndex];
}
/*
@ -124,7 +124,7 @@ GetSysColorPen(int nIndex)
can't be deleted */
if (NULL == SysPens[nIndex])
{
SysPens[nIndex] = CreatePen(PS_SOLID, 1, SysColours[nIndex]);
SysPens[nIndex] = CreatePen(PS_SOLID, 1, SysColors[nIndex]);
}
return SysPens[nIndex];
@ -148,7 +148,7 @@ GetSysColorBrush(int nIndex)
can't be deleted */
if (NULL == SysBrushes[nIndex])
{
SysBrushes[nIndex] = (HBRUSH) ((DWORD) CreateSolidBrush(SysColours[nIndex]) | 0x00800000);
SysBrushes[nIndex] = (HBRUSH) ((DWORD) CreateSolidBrush(SysColors[nIndex]) | 0x00800000);
}
return SysBrushes[nIndex];

View file

@ -364,8 +364,14 @@ DefWndNCPaint(HWND hWnd, HRGN hRgn)
/* Draw caption */
if ((Style & WS_CAPTION) == WS_CAPTION)
{
DWORD CaptionFlags = DC_ICON | DC_TEXT | DC_GRADIENT | DC_BUTTONS;
DWORD CaptionFlags = DC_ICON | DC_TEXT | DC_BUTTONS;
HPEN PreviousPen;
BOOL Gradient = FALSE;
if(SystemParametersInfoW(SPI_GETGRADIENTCAPTIONS, 0, &Gradient, 0) && Gradient)
{
CaptionFlags |= DC_GRADIENT;
}
TempRect = CurrentRect;
@ -996,8 +1002,7 @@ AdjustWindowRect(LPRECT lpRect,
}
// Enabling this will cause captions to draw smoother, but slower:
// #define DOUBLE_BUFFER_CAPTION
// NOTE: Double buffering appears to be broken for this at the moment
#define DOUBLE_BUFFER_CAPTION
/*
* @implemented
@ -1033,27 +1038,6 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
OffsetViewportOrgEx(MemDC, lprc->left, lprc->top, NULL);
#endif
// If DC_GRADIENT is specified, a Win 98/2000 style caption gradient should
// be painted. For now, that flag is ignored:
// Windows 98/Me, Windows 2000/XP: When this flag is set, the function uses
// COLOR_GRADIENTACTIVECAPTION (if the DC_ACTIVE flag was set) or
// COLOR_GRADIENTINACTIVECAPTION for the title-bar color.
// Draw the caption background
if (uFlags & DC_INBUTTON)
{
OldBrush = SelectObject(MemDC, GetSysColorBrush(uFlags & DC_ACTIVE ? COLOR_BTNFACE : COLOR_BTNSHADOW) );
if (! OldBrush) goto cleanup;
if (! PatBlt(MemDC, 0, 0, lprc->right - lprc->left, lprc->bottom - lprc->top, PATCOPY )) goto cleanup;
}
else
{
// DC_GRADIENT check should go here somewhere
OldBrush = SelectObject(MemDC, GetSysColorBrush(uFlags & DC_ACTIVE ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
if (! OldBrush) goto cleanup;
if (! PatBlt(MemDC, 0, 0, lprc->right - lprc->left, lprc->bottom - lprc->top, PATCOPY )) goto cleanup;
}
Style = GetWindowLongW(hWnd, GWL_STYLE);
/* Windows behaves like this */
@ -1067,14 +1051,122 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
r.top = Padding;
r.bottom = r.top + (Height / 2);
if ((uFlags & DC_ICON) && (Style & WS_SYSMENU) && !(uFlags & DC_SMALLCAP))
// Draw the caption background
if (uFlags & DC_INBUTTON)
{
OldBrush = SelectObject(MemDC, GetSysColorBrush(uFlags & DC_ACTIVE ? COLOR_BTNFACE : COLOR_BTNSHADOW) );
if (! OldBrush) goto cleanup;
if (! PatBlt(MemDC, 0, 0, lprc->right - lprc->left, lprc->bottom - lprc->top, PATCOPY )) goto cleanup;
}
else
{
if (uFlags & DC_GRADIENT)
{
COLORREF Colors[2];
BYTE cr[3], cg[3], cb[3];
LONG xx, wd, wdh;
POINT OldPoint;
HPEN Pen;
HGDIOBJ OldObj;
r.right = (lprc->right - lprc->left);
if (uFlags & DC_SMALLCAP)
ButtonWidth = GetSystemMetrics(SM_CXSMSIZE) - 2;
else
ButtonWidth = GetSystemMetrics(SM_CXSIZE) - 2;
if (Style & WS_SYSMENU)
{
r.right -= 3 + ButtonWidth;
if (! (uFlags & DC_SMALLCAP))
{
if(Style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX))
r.right -= 2 + 2 * ButtonWidth;
else
r.right -= 2;
r.right -= 2;
}
}
Colors[0] = GetSysColor((uFlags & DC_ACTIVE) ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION);
Colors[1] = GetSysColor((uFlags & DC_ACTIVE) ? COLOR_GRADIENTACTIVECAPTION : COLOR_GRADIENTINACTIVECAPTION);
if ((uFlags & DC_ICON) && (Style & WS_SYSMENU) && !(uFlags & DC_SMALLCAP))
{
OldBrush = SelectObject(MemDC, GetSysColorBrush(uFlags & DC_ACTIVE ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
if (!OldBrush) goto cleanup;
xx = GetSystemMetrics(SM_CXSIZE) + Padding;
/* draw icon background */
PatBlt(MemDC, 0, 0, xx, lprc->bottom - lprc->top, PATCOPY);
// For some reason the icon isn't centered correctly...
r.top --;
UserDrawSysMenuButton(hWnd, MemDC, &r, FALSE);
r.top ++;
r.left += xx;
}
cr[1] = GetRValue(Colors[0]);
cg[1] = GetGValue(Colors[0]);
cb[1] = GetBValue(Colors[0]);
cr[2] = GetRValue(Colors[1]) - cr[1];
cg[2] = GetGValue(Colors[1]) - cg[1];
cb[2] = GetBValue(Colors[1]) - cb[1];
wd = r.right - r.left;
wdh = wd / 2;
if(wd > 0)
{
MoveToEx(MemDC, 0, 0, &OldPoint);
for(xx = 0; xx < wd; xx++)
{
cr[0] = (cr[1] + ((cr[2] * xx) + wdh) / wd);
cg[0] = (cg[1] + ((cg[2] * xx) + wdh) / wd);
cb[0] = (cb[1] + ((cb[2] * xx) + wdh) / wd);
Pen = CreatePen(PS_SOLID, 0, RGB(cr[0], cg[0], cb[0]));
if(!Pen)
{
break;
}
OldObj = SelectObject(MemDC, Pen);
MoveToEx(MemDC, r.left + xx, 0, NULL);
LineTo(MemDC, r.left + xx, lprc->bottom - lprc->top);
if(OldObj)
SelectObject(MemDC, OldObj);
DeleteObject(Pen);
}
MoveToEx(MemDC, OldPoint.x, OldPoint.y, NULL);
}
if(OldBrush)
{
SelectObject(MemDC, OldBrush);
OldBrush = NULL;
}
xx = lprc->right - lprc->left - r.right;
if(xx > 0)
{
OldBrush = SelectObject(MemDC, GetSysColorBrush(uFlags & DC_ACTIVE ? COLOR_GRADIENTACTIVECAPTION : COLOR_GRADIENTINACTIVECAPTION));
if (!OldBrush) goto cleanup;
PatBlt(MemDC, r.right, 0, xx, lprc->bottom - lprc->top, PATCOPY);
}
}
else
{
OldBrush = SelectObject(MemDC, GetSysColorBrush(uFlags & DC_ACTIVE ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
if (! OldBrush) goto cleanup;
if (! PatBlt(MemDC, 0, 0, lprc->right - lprc->left, lprc->bottom - lprc->top, PATCOPY )) goto cleanup;
}
}
if ((uFlags & DC_ICON) && !(uFlags & DC_GRADIENT) && (Style & WS_SYSMENU) && !(uFlags & DC_SMALLCAP))
{
// For some reason the icon isn't centered correctly...
r.top --;
UserDrawSysMenuButton(hWnd, MemDC, &r, FALSE);
r.top ++;
}
r.top ++;
r.left += 2;
@ -1082,6 +1174,8 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
if ((uFlags & DC_TEXT) && (GetWindowTextW( hWnd, buffer, sizeof(buffer)/sizeof(buffer[0]) )))
{
if(!(uFlags & DC_GRADIENT))
{
if (!(uFlags & DC_SMALLCAP) && ((uFlags & DC_ICON) || (uFlags & DC_INBUTTON)))
r.left += GetSystemMetrics(SM_CXSIZE) + Padding;
@ -1100,9 +1194,10 @@ DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
r.right -= 2 + 2 * ButtonWidth;
else
r.right -= 2;
r.right -= 2;
}
}
r.right -= 2;
}
nclm.cbSize = sizeof(nclm);
if (! SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &nclm, 0)) goto cleanup;

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.36 2003/12/20 15:42:47 weiden Exp $
/* $Id: misc.c,v 1.37 2003/12/24 01:26:10 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -381,6 +381,7 @@ NtUserSystemParametersInfo(
PVOID pvParam,
UINT fWinIni)
{
static BOOL GradientCaptions = TRUE;
/* FIXME: This should be obtained from the registry */
static LOGFONTW CaptionFont =
{ 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
@ -503,7 +504,26 @@ NtUserSystemParametersInfo(
memcpy((LPVOID)&(pMetrics->lfMessageFont), &CaptionFont, sizeof(CaptionFont));
return TRUE;
}
case SPI_GETGRADIENTCAPTIONS:
{
Status = MmCopyToCaller(pvParam, &GradientCaptions, sizeof(BOOL));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
case SPI_SETGRADIENTCAPTIONS:
{
Status = MmCopyFromCaller(&GradientCaptions, pvParam, sizeof(BOOL));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return TRUE;
}
}
return FALSE;
}