Zhiyi Zhang : comctl32/button: Simplify focus rectangle calculation for drawing themed push buttons.

Alexandre Julliard julliard at winehq.org
Thu Nov 4 17:04:21 CDT 2021


Module: wine
Branch: master
Commit: 3d3914bca0eb9d3646a6f9beb9fe20ec876dd230
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3d3914bca0eb9d3646a6f9beb9fe20ec876dd230

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Thu Nov  4 14:51:57 2021 +0800

comctl32/button: Simplify focus rectangle calculation for drawing themed push buttons.

The focus rectangle is the same as the result from GetThemeBackgroundContentRect(). So there is no
need to retrieve content margins and calculate it again.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/button.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index fbe060513d2..00f42322399 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -2651,7 +2651,7 @@ cleanup:
  */
 static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused)
 {
-    RECT bgRect, textRect;
+    RECT bgRect, textRect, focusRect;
     NMCUSTOMDRAW nmcd;
     LRESULT cdrf;
     HWND parent;
@@ -2661,6 +2661,8 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
 
     GetClientRect(infoPtr->hwnd, &bgRect);
     GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect);
+    focusRect = textRect;
+
     init_custom_draw(&nmcd, infoPtr, hDC, &bgRect);
 
     parent = GetParent(infoPtr->hwnd);
@@ -2698,20 +2700,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
     }
     if (cdrf & CDRF_SKIPPOSTPAINT) return;
 
-    if (focused)
-    {
-        MARGINS margins;
-        RECT focusRect = bgRect;
-
-        GetThemeMargins(theme, hDC, BP_PUSHBUTTON, state, TMT_CONTENTMARGINS, NULL, &margins);
-
-        focusRect.left += margins.cxLeftWidth;
-        focusRect.top += margins.cyTopHeight;
-        focusRect.right -= margins.cxRightWidth;
-        focusRect.bottom -= margins.cyBottomHeight;
-
-        DrawFocusRect( hDC, &focusRect );
-    }
+    if (focused) DrawFocusRect(hDC, &focusRect);
 }
 
 static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused)




More information about the wine-cvs mailing list