[PATCH 0/4] MR9433: comctl32/status: Refactor STATUSBAR_DrawSizeGrip() to take an HWND instead.
From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/status.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c index bd5fa040ecf..3243234ab38 100644 --- a/dlls/comctl32/status.c +++ b/dlls/comctl32/status.c @@ -113,15 +113,16 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr) } static void -STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect) +STATUSBAR_DrawSizeGrip (HWND hwnd, HDC hdc, LPRECT lpRect) { RECT rc = *lpRect; - - TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect)); + HTHEME theme = GetWindowTheme(hwnd); if (theme) { SIZE gripperSize; + + TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect)); if (SUCCEEDED (GetThemePartSize (theme, hdc, SP_GRIPPER, 0, lpRect, TS_DRAW, &gripperSize))) { @@ -132,6 +133,7 @@ STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect) } } + TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect)); rc.left = max( rc.left, rc.right - GetSystemMetrics(SM_CXVSCROLL) - 1 ); rc.top = max( rc.top, rc.bottom - GetSystemMetrics(SM_CYHSCROLL) - 1 ); DrawFrameControl( hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP ); @@ -250,7 +252,7 @@ STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc) if ((GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) && !(GetWindowLongW (infoPtr->Notify, GWL_STYLE) & WS_MAXIMIZE)) - STATUSBAR_DrawSizeGrip (theme, hdc, &rect); + STATUSBAR_DrawSizeGrip (infoPtr->Self, hdc, &rect); return 0; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9433
From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/status.c | 46 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c index 3243234ab38..ef6eefa56bd 100644 --- a/dlls/comctl32/status.c +++ b/dlls/comctl32/status.c @@ -140,33 +140,41 @@ STATUSBAR_DrawSizeGrip (HWND hwnd, HDC hdc, LPRECT lpRect) } static void -STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID) +STATUSBAR_DrawPartBackground (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, + int itemID, RECT *rect) { - RECT r = part->bound; UINT border; - HTHEME theme = GetWindowTheme (infoPtr->Self); - int themePart = SP_PANE; - int x = 0; - - TRACE("part bound %s\n", wine_dbgstr_rect(&r)); + HTHEME theme = GetWindowTheme(infoPtr->Self); if (theme) { - if ((GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) - && (infoPtr->simple || (itemID == (infoPtr->numParts-1)))) + int themePart = SP_PANE; + + if ((GetWindowLongW(infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) + && (infoPtr->simple || (itemID == (infoPtr->numParts - 1)))) themePart = SP_GRIPPERPANE; - DrawThemeBackground(theme, hdc, themePart, 0, &r, NULL); + DrawThemeBackground(theme, hdc, themePart, 0, rect, NULL); + return; } + + if (part->style & SBT_POPOUT) + border = BDR_RAISEDOUTER; + else if (part->style & SBT_NOBORDERS) + border = 0; else - { - if (part->style & SBT_POPOUT) - border = BDR_RAISEDOUTER; - else if (part->style & SBT_NOBORDERS) - border = 0; - else - border = BDR_SUNKENOUTER; - DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST); - } + border = BDR_SUNKENOUTER; + DrawEdge(hdc, rect, border, BF_RECT | BF_ADJUST); +} + +static void +STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID) +{ + RECT r = part->bound; + int x = 0; + + TRACE("part bound %s\n", wine_dbgstr_rect(&r)); + + STATUSBAR_DrawPartBackground(infoPtr, hdc, part, itemID, &r); if (part->hIcon) { INT cy = r.bottom - r.top; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9433
From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/status.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c index ef6eefa56bd..08dd44d2eaa 100644 --- a/dlls/comctl32/status.c +++ b/dlls/comctl32/status.c @@ -212,14 +212,32 @@ STATUSBAR_RefreshPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPA STATUSBAR_DrawPart (infoPtr, hdc, part, itemID); } +static void +STATUSBAR_DrawBackground (const STATUS_INFO *infoPtr, HDC hdc, const RECT *rect) +{ + HBRUSH brush; + HTHEME theme = GetWindowTheme (infoPtr->Self); + + if (theme) + { + DrawThemeBackground (theme, hdc, 0, 0, rect, NULL); + return; + } + + if (infoPtr->clrBk != CLR_DEFAULT) + brush = CreateSolidBrush (infoPtr->clrBk); + else + brush = GetSysColorBrush (COLOR_3DFACE); + FillRect (hdc, rect, brush); + if (infoPtr->clrBk != CLR_DEFAULT) + DeleteObject (brush); +} static LRESULT STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc) { RECT rect; - HBRUSH hbrBk; HFONT hOldFont; - HTHEME theme; TRACE("\n"); if (!IsWindowVisible(infoPtr->Self)) @@ -228,21 +246,7 @@ STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc) STATUSBAR_SetPartBounds(infoPtr); GetClientRect (infoPtr->Self, &rect); - - if ((theme = GetWindowTheme (infoPtr->Self))) - { - DrawThemeBackground(theme, hdc, 0, 0, &rect, NULL); - } - else - { - if (infoPtr->clrBk != CLR_DEFAULT) - hbrBk = CreateSolidBrush (infoPtr->clrBk); - else - hbrBk = GetSysColorBrush (COLOR_3DFACE); - FillRect(hdc, &rect, hbrBk); - if (infoPtr->clrBk != CLR_DEFAULT) - DeleteObject (hbrBk); - } + STATUSBAR_DrawBackground (infoPtr, hdc, &rect); hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9433
From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/status.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c index 08dd44d2eaa..ec68b8d3e0c 100644 --- a/dlls/comctl32/status.c +++ b/dlls/comctl32/status.c @@ -84,8 +84,6 @@ typedef struct #define VERT_BORDER 2 #define HORZ_GAP 2 -static const WCHAR themeClass[] = L"Status"; - /* prototype */ static void STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr); @@ -116,6 +114,7 @@ static void STATUSBAR_DrawSizeGrip (HWND hwnd, HDC hdc, LPRECT lpRect) { RECT rc = *lpRect; +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(hwnd); if (theme) @@ -132,6 +131,7 @@ STATUSBAR_DrawSizeGrip (HWND hwnd, HDC hdc, LPRECT lpRect) return; } } +#endif TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect)); rc.left = max( rc.left, rc.right - GetSystemMetrics(SM_CXVSCROLL) - 1 ); @@ -144,6 +144,7 @@ STATUSBAR_DrawPartBackground (const STATUS_INFO *infoPtr, HDC hdc, const STATUSW int itemID, RECT *rect) { UINT border; +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(infoPtr->Self); if (theme) @@ -156,6 +157,7 @@ STATUSBAR_DrawPartBackground (const STATUS_INFO *infoPtr, HDC hdc, const STATUSW DrawThemeBackground(theme, hdc, themePart, 0, rect, NULL); return; } +#endif if (part->style & SBT_POPOUT) border = BDR_RAISEDOUTER; @@ -216,6 +218,7 @@ static void STATUSBAR_DrawBackground (const STATUS_INFO *infoPtr, HDC hdc, const RECT *rect) { HBRUSH brush; +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme (infoPtr->Self); if (theme) @@ -223,6 +226,7 @@ STATUSBAR_DrawBackground (const STATUS_INFO *infoPtr, HDC hdc, const RECT *rect) DrawThemeBackground (theme, hdc, 0, 0, rect, NULL); return; } +#endif if (infoPtr->clrBk != CLR_DEFAULT) brush = CreateSolidBrush (infoPtr->clrBk); @@ -844,7 +848,7 @@ STATUSBAR_WMDestroy (STATUS_INFO *infoPtr) if (infoPtr->hwndToolTip) DestroyWindow (infoPtr->hwndToolTip); - CloseThemeData (GetWindowTheme (infoPtr->Self)); + COMCTL32_CloseThemeForWindow (infoPtr->Self); SetWindowLongPtrW(infoPtr->Self, 0, 0); Free (infoPtr); @@ -903,8 +907,8 @@ STATUSBAR_WMCreate (HWND hwnd, const CREATESTRUCTA *lpCreate) infoPtr->parts[0].x = -1; infoPtr->parts[0].style = 0; infoPtr->parts[0].hIcon = 0; - - OpenThemeData (hwnd, themeClass); + + COMCTL32_OpenThemeForWindow (hwnd, L"Status"); if (lpCreate->lpszName && (len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) { @@ -1087,17 +1091,6 @@ STATUSBAR_WMSize (STATUS_INFO *infoPtr, WORD flags) } -/* update theme after a WM_THEMECHANGED message */ -static LRESULT theme_changed (const STATUS_INFO* infoPtr) -{ - HTHEME theme = GetWindowTheme (infoPtr->Self); - CloseThemeData (theme); - OpenThemeData (infoPtr->Self, themeClass); - InvalidateRect (infoPtr->Self, NULL, TRUE); - return 0; -} - - static LRESULT STATUSBAR_NotifyFormat (STATUS_INFO *infoPtr, HWND from, INT cmd) { @@ -1282,7 +1275,7 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; case WM_THEMECHANGED: - return theme_changed (infoPtr); + return COMCTL32_ThemeChanged (infoPtr->Self, L"Status", TRUE, TRUE); default: if ((msg >= WM_USER) && (msg < WM_APP) && !COMCTL32_IsReflectedMessage(msg)) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9433
This merge request was approved by Nikolay Sivov. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9433
participants (3)
-
Nikolay Sivov (@nsivov) -
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)