comctl32: rebar[2/3]: WM_SETFONT should send a RBN_HEIGHTCHANGED if necessary (with testcase)

Mikołaj Zalewski mikolaj at zalewski.pl
Sun Feb 25 05:41:54 CST 2007


  This allows as to eliminate the third parameter of REBAR_Layout.
-------------- next part --------------
From 2edae3656159e84a0366b65e1bd1d13e3089dc97 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Mon, 19 Feb 2007 20:42:08 +0100
Subject: [PATCH] comctl32: rebar: WM_SETFONT should send a RBN_HEIGHTCHANGED if necessary (with testcase)

---
 dlls/comctl32/rebar.c       |   28 +++++++++++-----------------
 dlls/comctl32/tests/rebar.c |   28 +++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c
index 7db49f2..1fe16da 100644
--- a/dlls/comctl32/rebar.c
+++ b/dlls/comctl32/rebar.c
@@ -1299,7 +1299,7 @@ static void REBAR_LayoutRow(REBAR_INFO *infoPtr, int iBeginBand, int iEndBand, i
 }
 
 static VOID
-REBAR_Layout(REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify)
+REBAR_Layout(REBAR_INFO *infoPtr, LPRECT lpRect)
 {
     REBAR_BAND *lpBand;
     RECT rcAdj;
@@ -1378,7 +1378,7 @@ REBAR_Layout(REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify)
 
     infoPtr->calcSize.cx = adjcx;
     infoPtr->calcSize.cy = yPos;
-    TRACE("calcsize notify=%d, size=(%d, %d), origheight=(%d,%d)\n", notify,
+    TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
             infoPtr->calcSize.cx, infoPtr->calcSize.cy,
 	    oldSize.cx, oldSize.cy);
 
@@ -1388,7 +1388,7 @@ REBAR_Layout(REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify)
 
     /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
      * and does another ForceResize */
-    if (notify && (oldSize.cy != infoPtr->calcSize.cy))
+    if (oldSize.cy != infoPtr->calcSize.cy)
     {
         NMHDR heightchange;
         REBAR_Notify(&heightchange, infoPtr, RBN_HEIGHTCHANGE);
@@ -1942,7 +1942,7 @@ REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
     TRACE("setting NEEDS_LAYOUT\n");
     infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
-    REBAR_Layout(infoPtr, NULL, TRUE);
+    REBAR_Layout(infoPtr, NULL);
 
     return TRUE;
 }
@@ -2316,7 +2316,7 @@ REBAR_InsertBandT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnico
 
     REBAR_DumpBand (infoPtr);
 
-    REBAR_Layout(infoPtr, NULL, TRUE);
+    REBAR_Layout(infoPtr, NULL);
     InvalidateRect(infoPtr->hwndSelf, 0, TRUE);
 
     return TRUE;
@@ -2538,7 +2538,7 @@ REBAR_SetBandInfoT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnic
     REBAR_DumpBand (infoPtr);
 
     if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE))) {
-	  REBAR_Layout(infoPtr, NULL, TRUE);
+	  REBAR_Layout(infoPtr, NULL);
 	  InvalidateRect(infoPtr->hwndSelf, 0, 1);
     }
 
@@ -2688,7 +2688,7 @@ REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     }
 
     infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
-    REBAR_Layout(infoPtr, NULL, TRUE);
+    REBAR_Layout(infoPtr, NULL);
     InvalidateRect(infoPtr->hwndSelf, 0, 1);
 
     return TRUE;
@@ -2718,7 +2718,7 @@ REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     /* force full _Layout processing */
     TRACE("setting NEEDS_LAYOUT\n");
     infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
-    REBAR_Layout(infoPtr, lpRect, TRUE);
+    REBAR_Layout(infoPtr, lpRect);
     InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
     return TRUE;
 }
@@ -3286,7 +3286,6 @@ REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 static LRESULT
 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-    RECT rcClient;
     REBAR_BAND *lpBand;
     UINT i;
 
@@ -3298,12 +3297,7 @@ REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 	REBAR_ValidateBand (infoPtr, lpBand);
     }
 
-
-    if (LOWORD(lParam)) {
-        GetClientRect (infoPtr->hwndSelf, &rcClient);
-        REBAR_Layout(infoPtr, &rcClient, FALSE);
-    }
-
+    REBAR_Layout(infoPtr, NULL);
     return 0;
 }
 
@@ -3365,7 +3359,7 @@ REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     }
 
     infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
-    REBAR_Layout(infoPtr, NULL, TRUE);
+    REBAR_Layout(infoPtr, NULL);
 
     return 0;
 }
@@ -3385,7 +3379,7 @@ REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     if ((ss->styleNew ^ ss->styleOld) & CCS_VERT)
     {
         infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
-        REBAR_Layout(infoPtr, NULL, TRUE);
+        REBAR_Layout(infoPtr, NULL);
     }
 
     return FALSE;
diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c
index 640091a..e2e726a 100644
--- a/dlls/comctl32/tests/rebar.c
+++ b/dlls/comctl32/tests/rebar.c
@@ -598,21 +598,27 @@ rbresize_test_result_t resize_results[] = {
     {{-2, 0, 674, 24}, 1, FALSE},
     {{-2, 0, 674, 24}, 1, FALSE},
     {{-2, 0, 674, 24}, 0, FALSE},
+/* WM_SETFONT */
+    {{0, 2, 672, 22}, 1, TRUE},
+    {{0, 2, 672, 610}, 2, TRUE},
 };
 
 static int resize_numtests = 0;
 
 #define comment(fmt, arg1)
-#define check_client() { \
+#define check_client_todo(mask) { \
         RECT r; \
         rbresize_test_result_t *res = &resize_results[resize_numtests++]; \
         assert(resize_numtests <= sizeof(resize_results)/sizeof(resize_results[0])); \
         GetWindowRect(hRebar, &r); \
         MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); \
-        if ((dwStyles[i] & (CCS_NOPARENTALIGN|CCS_NODIVIDER)) == CCS_NOPARENTALIGN) {\
+        if (i < sizeof(dwStyles)/sizeof(dwStyles[0]) && (dwStyles[i] & (CCS_NOPARENTALIGN|CCS_NODIVIDER)) == CCS_NOPARENTALIGN) {\
             check_rect_no_top("client", r, res->rc); /* the top coordinate changes after every layout and is very implementation-dependent */ \
         } else { \
-            check_rect("client", r, res->rc); \
+	    if (mask & 1) { \
+                todo_wine check_rect("client", r, res->rc); \
+            } else \
+                check_rect("client", r, res->rc); \
         } \
         expect_eq((int)SendMessage(hRebar, RB_GETROWCOUNT, 0, 0), res->iNumRows, int, "%d"); \
         if (res->heightNotify) { \
@@ -623,6 +629,8 @@ static int resize_numtests = 0;
         SetRect(&height_change_notify_rect, -1, -1, -1, -1); \
     }
 
+#define check_client() check_client_todo(0)
+
 #endif
 
 static void resize_test()
@@ -633,6 +641,7 @@ static void resize_test()
         CCS_NOMOVEY | WS_BORDER};
 
     const int styles_count = sizeof(dwStyles) / sizeof(dwStyles[0]);
+    HFONT hFont;
     int i;
 
     for (i = 0; i < styles_count; i++)
@@ -674,6 +683,19 @@ static void resize_test()
         check_client();
         DestroyWindow(hRebar);
     }
+
+    /* WM_SETFONT forces a relayout */
+    comment("WM_SETFONT", 0);
+    rebuild_rebar(&hRebar);
+    add_band_w(hRebar, "abc", 30, 70, 100);
+    add_band_w(hRebar, "def", 50, 50, 100);
+    check_client();
+    hFont = CreateFont(300, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
+        DEFAULT_PITCH|FF_DONTCARE, "Courier New");
+    SendMessage(hRebar, WM_SETFONT, (WPARAM)hFont, FALSE);
+    check_client_todo(1);       /* the height is by 10 pixel too small in wine (598 vs 608) */
+    DestroyWindow(hRebar);
+    DeleteObject(hFont);
 }
 
 static void expect_band_content(UINT uBand, UINT fStyle, COLORREF clrFore,
-- 
1.4.4.2


More information about the wine-patches mailing list