Module: wine Branch: master Commit: abd673bde93b76a361ddf7342c538c2dd99af2bd URL: http://source.winehq.org/git/wine.git/?a=commit;h=abd673bde93b76a361ddf7342c...
Author: Huw Davies huw@codeweavers.com Date: Tue Apr 28 11:32:01 2015 +0100
comctl32: A change in TBSTYLE_WRAPABLE should produce a recalc.
---
dlls/comctl32/tests/toolbar.c | 46 +++++++++++++++++++++++++++++++++++++++++-- dlls/comctl32/toolbar.c | 4 +++- 2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index d3088f9..365bfe2 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -1388,12 +1388,12 @@ static void restore_recalc_state(HWND hToolbar) RECT rect; /* return to style with a 2px top margin */ SetWindowLongA(hToolbar, GWL_STYLE, - GetWindowLongA(hToolbar, GWL_STYLE) & ~TBSTYLE_FLAT); + SendMessageA(hToolbar, TB_GETSTYLE, 0, 0) & ~TBSTYLE_FLAT); /* recalc */ SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)&buttons3[3]); /* top margin will be 0px if a recalc occurs */ SetWindowLongA(hToolbar, GWL_STYLE, - GetWindowLongA(hToolbar, GWL_STYLE) | TBSTYLE_FLAT); + SendMessageA(hToolbar, TB_GETSTYLE, 0, 0) | TBSTYLE_FLAT); /* safety check */ SendMessageA(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect); ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n", @@ -1408,6 +1408,7 @@ static void test_recalc(void) const int EX_STYLES_COUNT = 5; int i; BOOL recalc; + DWORD style;
/* Like TB_ADDBUTTONSA tested in test_sized, inserting a button without text * results in a relayout, while adding one with text forces a recalc */ @@ -1468,6 +1469,47 @@ static void test_recalc(void) /* undocumented exstyle 0x2 seems to change the top margin, which * interferes with these tests */
+ /* Show that a change in TBSTYLE_WRAPABLE causes a recalc */ + prepare_recalc_test(&hToolbar); + style = SendMessageA(hToolbar, TB_GETSTYLE, 0, 0); + SendMessageA(hToolbar, TB_SETSTYLE, 0, style); + recalc = did_recalc(hToolbar); + ok(!recalc, "recalc %d\n", recalc); + + SendMessageA(hToolbar, TB_SETSTYLE, 0, style | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | CCS_BOTTOM); + recalc = did_recalc(hToolbar); + ok(!recalc, "recalc %d\n", recalc); + + SendMessageA(hToolbar, TB_SETSTYLE, 0, style | TBSTYLE_WRAPABLE); + recalc = did_recalc(hToolbar); + ok(recalc, "recalc %d\n", recalc); + restore_recalc_state(hToolbar); + + SendMessageA(hToolbar, TB_SETSTYLE, 0, style | TBSTYLE_WRAPABLE); + recalc = did_recalc(hToolbar); + ok(!recalc, "recalc %d\n", recalc); + + SendMessageA(hToolbar, TB_SETSTYLE, 0, style); + recalc = did_recalc(hToolbar); + ok(recalc, "recalc %d\n", recalc); + restore_recalc_state(hToolbar); + + /* Changing CCS_VERT does not recalc */ + SendMessageA(hToolbar, TB_SETSTYLE, 0, style | CCS_VERT); + recalc = did_recalc(hToolbar); + ok(!recalc, "recalc %d\n", recalc); + restore_recalc_state(hToolbar); + + SendMessageA(hToolbar, TB_SETSTYLE, 0, style); + recalc = did_recalc(hToolbar); + ok(!recalc, "recalc %d\n", recalc); + restore_recalc_state(hToolbar); + + /* Setting the window's style directly also causes recalc */ + SetWindowLongA(hToolbar, GWL_STYLE, style | TBSTYLE_WRAPABLE); + recalc = did_recalc(hToolbar); + ok(recalc, "recalc %d\n", recalc); + DestroyWindow(hToolbar); }
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 695e450..b2f13c5 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -4934,7 +4934,9 @@ TOOLBAR_SetStyle (TOOLBAR_INFO *infoPtr, DWORD style) infoPtr->dwStyle = style; TOOLBAR_CheckStyle(infoPtr);
- if ((dwOldStyle ^ style) & (TBSTYLE_WRAPABLE | CCS_VERT)) + if ((dwOldStyle ^ style) & TBSTYLE_WRAPABLE) + TOOLBAR_CalcToolbar(infoPtr); + else if ((dwOldStyle ^ style) & CCS_VERT) TOOLBAR_LayoutToolbar(infoPtr);
/* only resize if one of the CCS_* styles was changed */