https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ac0a0adc5144e5ce8683b…
commit ac0a0adc5144e5ce8683b8428d74adba317cc80a
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Oct 17 13:28:56 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Oct 17 13:28:56 2022 +0900
[NTUSER][USER32] Improve DrawFrameControl:DFC_MENU and DFC_BUTTON (#4783)
A retrial of 13868ee (#4779).
- Fill the background if necessary, and set the text color and the back mode in
DrawFrameControl:DFC_MENU.
- Use UITOOLS95_DrawFrameMenu in menu drawing instead of DrawFrameControl.
CORE-18515, CORE-18417
---
win32ss/user/ntuser/draw.c | 34 ++++++++++++++++++++++++++++++----
win32ss/user/ntuser/menu.c | 16 +++++++++-------
win32ss/user/user32/windows/draw.c | 37 +++++++++++++++++++++++++++++++------
3 files changed, 70 insertions(+), 17 deletions(-)
diff --git a/win32ss/user/ntuser/draw.c b/win32ss/user/ntuser/draw.c
index dd4a0ff4a62..9e382b50290 100644
--- a/win32ss/user/ntuser/draw.c
+++ b/win32ss/user/ntuser/draw.c
@@ -769,13 +769,18 @@ BOOL FASTCALL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT
uState)
case DFCS_BUTTONRADIOIMAGE:
case DFCS_BUTTONRADIOMASK:
- case DFCS_BUTTONRADIO:
+ if (uState & DFCS_BUTTONRADIOIMAGE)
+ FillRect(hdc, rc, (HBRUSH)NtGdiGetStockObject(BLACK_BRUSH)); /* Fill by
black */
+ else
+ FillRect(hdc, rc, (HBRUSH)NtGdiGetStockObject(WHITE_BRUSH)); /* Fill by
white */
+
return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, TRUE);
+ case DFCS_BUTTONRADIO:
+ return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, TRUE);
default:
ERR("Invalid button state=0x%04x\n", uState);
-
}
return FALSE;
}
@@ -953,7 +958,6 @@ BOOL FASTCALL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT
uFlags)
BOOL FASTCALL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
{
- // TODO: DFCS_TRANSPARENT upon DFCS_MENUARROWUP or DFCS_MENUARROWDOWN
LOGFONTW lf;
HFONT hFont, hOldFont;
WCHAR Symbol;
@@ -983,6 +987,7 @@ BOOL FASTCALL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
break;
case DFCS_MENUCHECK:
+ case DFCS_MENUCHECK | DFCS_MENUBULLET:
Symbol = 'a';
break;
@@ -1098,7 +1103,28 @@ DrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState)
case DFC_CAPTION:
return UITOOLS95_DrawFrameCaption(hDC, rc, uState);
case DFC_MENU:
- return UITOOLS95_DrawFrameMenu(hDC, rc, uState);
+ {
+ BOOL ret;
+ COLORREF rgbOldText;
+ INT iOldBackMode;
+
+ if (uState & (DFCS_MENUARROWUP | DFCS_MENUARROWDOWN))
+ {
+ if (!(uState & DFCS_TRANSPARENT))
+ FillRect(hDC, rc, IntGetSysColorBrush(COLOR_MENU)); /* Fill by menu
color */
+ }
+ else
+ {
+ FillRect(hDC, rc, (HBRUSH)NtGdiGetStockObject(WHITE_BRUSH)); /* Fill by
white */
+ }
+
+ rgbOldText = IntGdiSetTextColor(hDC, RGB(0, 0, 0)); /* Draw by black */
+ iOldBackMode = IntGdiSetBkMode(hDC, TRANSPARENT);
+ ret = UITOOLS95_DrawFrameMenu(hDC, rc, uState);
+ IntGdiSetBkMode(hDC, iOldBackMode);
+ IntGdiSetTextColor(hDC, rgbOldText);
+ return ret;
+ }
#if 0
case DFC_POPUPMENU:
UNIMPLEMENTED;
diff --git a/win32ss/user/ntuser/menu.c b/win32ss/user/ntuser/menu.c
index fb169b6e472..01740c9c23e 100644
--- a/win32ss/user/ntuser/menu.c
+++ b/win32ss/user/ntuser/menu.c
@@ -11,6 +11,8 @@ DBG_DEFAULT_CHANNEL(UserMenu);
/* INTERNAL ******************************************************************/
+BOOL FASTCALL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags); /* draw.c */
+
HFONT ghMenuFont = NULL;
HFONT ghMenuFontBold = NULL;
static SIZE MenuCharSize;
@@ -2186,14 +2188,14 @@ static void MENU_DrawScrollArrows(PMENU lppop, HDC hdc)
rect.right = lppop->cxMenu;
rect.bottom = arrow_bitmap_height;
FillRect(hdc, &rect, IntGetSysColorBrush(COLOR_MENU));
- DrawFrameControl(hdc, &rect, DFC_MENU, (lppop->iTop ? 0 :
DFCS_INACTIVE)|DFCS_MENUARROWUP);
+ UITOOLS95_DrawFrameMenu(hdc, &rect, (lppop->iTop ? 0 : DFCS_INACTIVE) |
DFCS_MENUARROWUP);
rect.top = lppop->cyMenu - arrow_bitmap_height;
rect.bottom = lppop->cyMenu;
FillRect(hdc, &rect, IntGetSysColorBrush(COLOR_MENU));
if (!(lppop->iTop < lppop->iMaxTop - (MENU_GetMaxPopupHeight(lppop) - 2 *
arrow_bitmap_height)))
Flags = DFCS_INACTIVE;
- DrawFrameControl(hdc, &rect, DFC_MENU, Flags|DFCS_MENUARROWDOWN);
+ UITOOLS95_DrawFrameMenu(hdc, &rect, Flags | DFCS_MENUARROWDOWN);
}
/***********************************************************************
@@ -2308,7 +2310,7 @@ static void FASTCALL MENU_DrawMenuItem(PWND Wnd, PMENU Menu, PWND
WndOwner, HDC
RECT rectTemp;
RtlCopyMemory(&rectTemp, &rect, sizeof(RECT));
rectTemp.left = rectTemp.right - UserGetSystemMetrics(SM_CXMENUCHECK);
- DrawFrameControl(hdc, &rectTemp, DFC_MENU, DFCS_MENUARROW);
+ UITOOLS95_DrawFrameMenu(hdc, &rectTemp, DFCS_MENUARROW);
}
return;
}
@@ -2452,9 +2454,9 @@ static void FASTCALL MENU_DrawMenuItem(PWND Wnd, PMENU Menu, PWND
WndOwner, HDC
RECT r;
r = rect;
r.right = r.left + check_bitmap_width;
- DrawFrameControl( hdc, &r, DFC_MENU,
- (lpitem->fType & MFT_RADIOCHECK) ?
- DFCS_MENUBULLET : DFCS_MENUCHECK);
+ UITOOLS95_DrawFrameMenu(hdc, &r,
+ (lpitem->fType & MFT_RADIOCHECK) ?
+ DFCS_MENUBULLET : DFCS_MENUCHECK);
checked = TRUE;
}
}
@@ -2475,7 +2477,7 @@ static void FASTCALL MENU_DrawMenuItem(PWND Wnd, PMENU Menu, PWND
WndOwner, HDC
RECT rectTemp;
RtlCopyMemory(&rectTemp, &rect, sizeof(RECT));
rectTemp.left = rectTemp.right - check_bitmap_width;
- DrawFrameControl(hdc, &rectTemp, DFC_MENU, DFCS_MENUARROW);
+ UITOOLS95_DrawFrameMenu(hdc, &rectTemp, DFCS_MENUARROW);
}
rect.left += 4;
if( !((Menu->fFlags & MNS_STYLE_MASK) & MNS_NOCHECK))
diff --git a/win32ss/user/user32/windows/draw.c b/win32ss/user/user32/windows/draw.c
index ff0fb72bff4..310f31493e5 100644
--- a/win32ss/user/user32/windows/draw.c
+++ b/win32ss/user/user32/windows/draw.c
@@ -6,7 +6,7 @@
* Copyright 2003 Andrew Greenwood
* Copyright 2003 Filip Navara
* Copyright 2009 Matthias Kupfer
- * Copyright 2017 Katayama Hirofumi MZ
+ * Copyright 2017-2022 Katayama Hirofumi MZ
*
* Based on Wine code.
*
@@ -704,7 +704,6 @@ static BOOL UITOOLS95_DFC_ButtonCheckRadio(HDC dc, LPRECT r, UINT
uFlags, BOOL R
// FIXME: improve font rendering
RECT Rect;
HGDIOBJ hbrOld, hpenOld;
- FillRect(dc, r, (HBRUSH)GetStockObject(WHITE_BRUSH));
SetRect(&Rect, X, Y, X + Shorter, Y + Shorter);
InflateRect(&Rect, -(Shorter * 8) / 54, -(Shorter * 8) / 54);
hbrOld = SelectObject(dc, GetStockObject(BLACK_BRUSH));
@@ -788,13 +787,18 @@ static BOOL UITOOLS95_DrawFrameButton(HDC hdc, LPRECT rc, UINT
uState)
case DFCS_BUTTONRADIOIMAGE:
case DFCS_BUTTONRADIOMASK:
- case DFCS_BUTTONRADIO:
+ if (uState & DFCS_BUTTONRADIOIMAGE)
+ FillRect(hdc, rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); /* Fill by black
*/
+ else
+ FillRect(hdc, rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); /* Fill by white
*/
+
return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, TRUE);
+ case DFCS_BUTTONRADIO:
+ return UITOOLS95_DFC_ButtonCheckRadio(hdc, rc, uState, TRUE);
default:
ERR("Invalid button state=0x%04x\n", uState);
-
}
return FALSE;
@@ -972,7 +976,6 @@ static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags)
static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
{
- // TODO: DFCS_TRANSPARENT upon DFCS_MENUARROWUP or DFCS_MENUARROWDOWN
LOGFONTW lf;
HFONT hFont, hOldFont;
TCHAR Symbol;
@@ -1002,6 +1005,7 @@ static BOOL UITOOLS95_DrawFrameMenu(HDC dc, LPRECT r, UINT uFlags)
break;
case DFCS_MENUCHECK:
+ case DFCS_MENUCHECK | DFCS_MENUBULLET:
Symbol = 'a';
break;
@@ -1428,7 +1432,28 @@ RealDrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState)
case DFC_CAPTION:
return UITOOLS95_DrawFrameCaption(hDC, rc, uState);
case DFC_MENU:
- return UITOOLS95_DrawFrameMenu(hDC, rc, uState);
+ {
+ BOOL ret;
+ COLORREF rgbOldText;
+ INT iOldBackMode;
+
+ if (uState & (DFCS_MENUARROWUP | DFCS_MENUARROWDOWN))
+ {
+ if (!(uState & DFCS_TRANSPARENT))
+ FillRect(hDC, rc, (HBRUSH)(COLOR_MENU + 1)); /* Fill by menu color
*/
+ }
+ else
+ {
+ FillRect(hDC, rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); /* Fill by white
*/
+ }
+
+ rgbOldText = SetTextColor(hDC, RGB(0, 0, 0)); /* Draw by black */
+ iOldBackMode = SetBkMode(hDC, TRANSPARENT);
+ ret = UITOOLS95_DrawFrameMenu(hDC, rc, uState);
+ SetBkMode(hDC, iOldBackMode);
+ SetTextColor(hDC, rgbOldText);
+ return ret;
+ }
#if 0
case DFC_POPUPMENU:
UNIMPLEMENTED;