Sergey Khodych : comctl32: toolbar: Improve text layout in TBSTYLE_LIST toolbars.

Alexandre Julliard julliard at winehq.org
Thu Nov 6 08:26:09 CST 2008


Module: wine
Branch: master
Commit: 65e9a6e02e16d6c98721984a64c1ca7d64fd0a5b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=65e9a6e02e16d6c98721984a64c1ca7d64fd0a5b

Author: Sergey Khodych <khodych at gmail.com>
Date:   Tue Nov  4 21:22:18 2008 +0200

comctl32: toolbar: Improve text layout in TBSTYLE_LIST toolbars.

---

 dlls/comctl32/tests/toolbar.c |   24 ++++++++++++++++++++++++
 dlls/comctl32/toolbar.c       |   17 ++++++-----------
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 94ee0d3..aebf8e5 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -721,6 +721,12 @@ static tbsize_result_t tbsize_results[] =
   { {0, 0, 672, 100}, {239, 102}, 3, {
     {  0,   2, 100,  102}, {100,   2, 139,  102}, {139, 2, 239,  102},
   }, },
+  { {0, 0, 672, 42}, {183, 40}, 3, {
+      {  0,   2,  75,  40}, {75,   2, 118, 40}, {118, 2, 183, 40},
+  }, },
+  { {0, 0, 672, 42}, {67, 40}, 1, {
+      {  0,   2,  67,  40},
+  }, },
 };
 
 static int tbsize_numtests = 0;
@@ -956,6 +962,24 @@ static void test_sizes(void)
     SendMessageA(hToolbar, TB_AUTOSIZE, (WPARAM)0, (LPARAM)0 );
     check_sizes();
 
+    rebuild_toolbar(&hToolbar);
+    SetWindowLong(hToolbar, GWL_STYLE, TBSTYLE_LIST | GetWindowLong(hToolbar, GWL_STYLE));
+    ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, (WPARAM)0, (LPARAM) MAKELONG (32, 32) ) == 1, "TB_SETBITMAPSIZE failed\n");
+    ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, (WPARAM)0, (LPARAM)MAKELONG(100, 100)) == 1, "TB_SETBUTTONSIZE failed\n");
+    ok(SendMessageA(hToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&buttons2[0]) == 1, "TB_ADDBUTTONS failed\n");
+    ok(SendMessageA(hToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&buttons3[2]) == 1, "TB_ADDBUTTONS failed\n");
+    ok(SendMessageA(hToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&buttons3[3]) == 1, "TB_ADDBUTTONS failed\n");
+    SendMessageA(hToolbar, TB_AUTOSIZE, (WPARAM)0, (LPARAM)0 );
+    check_sizes_todo(0xff);
+
+    rebuild_toolbar(&hToolbar);
+    SetWindowLong(hToolbar, GWL_STYLE, TBSTYLE_LIST | GetWindowLong(hToolbar, GWL_STYLE));
+    ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, (WPARAM)0, (LPARAM) MAKELONG (32, 32) ) == 1, "TB_SETBITMAPSIZE failed\n");
+    ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, (WPARAM)0, (LPARAM)MAKELONG(100, 100)) == 1, "TB_SETBUTTONSIZE failed\n");
+    ok(SendMessageA(hToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&buttons3[3]) == 1, "TB_ADDBUTTONS failed\n");
+    SendMessageA(hToolbar, TB_AUTOSIZE, (WPARAM)0, (LPARAM)0 );
+    check_sizes();
+
     DestroyWindow(hToolbar);
 }
 
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 397843f..317b21c 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -912,8 +912,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc, DWORD dwBaseCustDr
         rcText.right -= GetSystemMetrics(SM_CXEDGE);
         if (dwStyle & TBSTYLE_LIST)
         {
-            if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
-                rcText.left += infoPtr->nBitmapWidth + infoPtr->iListGap + 2;
+            rcText.left += infoPtr->nBitmapWidth + infoPtr->iListGap + 2;
         }
         else
         {
@@ -1574,15 +1573,11 @@ static inline SIZE TOOLBAR_MeasureButton(const TOOLBAR_INFO *infoPtr, SIZE sizeS
             sizeButton.cy += infoPtr->szPadding.cy;
 
         /* calculate button width */
-        if (bHasBitmap)
-        {
-            sizeButton.cx = 2*GetSystemMetrics(SM_CXEDGE) +
-                infoPtr->nBitmapWidth + infoPtr->iListGap;
-            if (sizeString.cx > 0)
-                sizeButton.cx += sizeString.cx + infoPtr->szPadding.cx;
-        }
-        else
-            sizeButton.cx = sizeString.cx + infoPtr->szPadding.cx;
+        sizeButton.cx = 2*GetSystemMetrics(SM_CXEDGE) +
+            infoPtr->nBitmapWidth + infoPtr->iListGap;
+        if (sizeString.cx > 0)
+            sizeButton.cx += sizeString.cx + infoPtr->szPadding.cx;
+
     }
     else
     {




More information about the wine-cvs mailing list