Commit d4a67c43 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

comctl32: toolbar: The default button size is 16x16.

parent 3487da71
/* Unit tests for treeview.
*
* Copyright 2005 Krzysztof Foltman
* Copyright 2007 Mikolaj Zalewski
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -185,7 +186,7 @@ static void rebuild_toolbar_with_buttons(HWND *hToolbar)
if (himl != NULL) {\
ok(ImageList_GetImageCount(himl) == count, "Images count mismatch - %d vs %d\n", count, ImageList_GetImageCount(himl)); \
ImageList_GetIconSize(himl, &cx, &cy); \
ok(cx == dx && cy == cy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
ok(cx == dx && cy == dy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
} \
}
......@@ -196,7 +197,7 @@ static void rebuild_toolbar_with_buttons(HWND *hToolbar)
if (himl != NULL) {\
todo_wine ok(ImageList_GetImageCount(himl) == count, "Images count mismatch - %d vs %d\n", count, ImageList_GetImageCount(himl)); \
ImageList_GetIconSize(himl, &cx, &cy); \
ok(cx == dx && cy == cy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
ok(cx == dx && cy == dy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
} \
}
......@@ -207,7 +208,7 @@ static void rebuild_toolbar_with_buttons(HWND *hToolbar)
if (himl != NULL) {\
todo_wine ok(ImageList_GetImageCount(himl) == count, "Images count mismatch - %d vs %d\n", count, ImageList_GetImageCount(himl)); \
ImageList_GetIconSize(himl, &cx, &cy); \
todo_wine ok(cx == dx && cy == cy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
todo_wine ok(cx == dx && cy == dy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
} \
}
......@@ -235,63 +236,63 @@ static void test_add_bitmap(void)
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 8, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(8, 16, 15);
CHECK_IMAGELIST(8, 16, 16);
/* adding more bitmaps */
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80) == 8, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
/* adding the same bitmap will simply return the index of the already loaded block */
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 8, (LPARAM)&bmp128);
ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80);
ok(ret == 8, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
/* even if we increase the wParam */
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 55, (LPARAM)&bmp80);
ok(ret == 8, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
/* when the wParam is smaller than the bitmaps count but non-zero, all the bitmaps will be added*/
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 3, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(8, 16, 15);
CHECK_IMAGELIST(8, 16, 16);
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80);
ok(ret == 3, "TB_ADDBITMAP - unexpected return %d\n", ret);
/* the returned value is misleading - id 8 is the id of the first icon from bmp80 */
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
/* the same for negative wParam */
rebuild_toolbar(&hToolbar);
ret = SendMessageA(hToolbar, TB_ADDBITMAP, -143, (LPARAM)&bmp128);
ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(8, 16, 15);
CHECK_IMAGELIST(8, 16, 16);
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&bmp80);
ok(ret == -143, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
/* for zero only one bitmap will be added */
rebuild_toolbar(&hToolbar);
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&bmp80);
ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(1, 16, 15);
CHECK_IMAGELIST(1, 16, 16);
/* if wParam is larger than the amount of icons, the list is grown */
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp80) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(100, 16, 15);
CHECK_IMAGELIST(100, 16, 16);
ret = SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp128);
ok(ret == 100, "TB_ADDBITMAP - unexpected return %d\n", ret);
CHECK_IMAGELIST(200, 16, 15);
CHECK_IMAGELIST(200, 16, 16);
/* adding built-in items - the wParam is ignored */
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(5, 16, 15);
CHECK_IMAGELIST(5, 16, 16);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&stdsmall) == 5, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(20, 16, 15);
CHECK_IMAGELIST(20, 16, 16);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp128) == 20, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(28, 16, 15);
CHECK_IMAGELIST(28, 16, 16);
/* when we increase the bitmap size, less icons will be created */
rebuild_toolbar(&hToolbar);
......@@ -308,14 +309,14 @@ static void test_add_bitmap(void)
/* loading a standard bitmaps automatically resizes the icons */
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&stdsmall) == 2, "TB_ADDBITMAP - unexpected return\n");
UpdateWindow(hToolbar);
CHECK_IMAGELIST(28, 16, 15);
CHECK_IMAGELIST(28, 16, 16);
/* two more SETBITMAPSIZE tests */
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(100, 16, 15);
CHECK_IMAGELIST(100, 16, 16);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp80) == 100, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(200, 16, 15);
CHECK_IMAGELIST(200, 16, 16);
ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(8, 8)) == TRUE, "TB_SETBITMAPSIZE failed\n");
UpdateWindow(hToolbar);
CHECK_IMAGELIST(200, 8, 8);
......@@ -324,9 +325,9 @@ static void test_add_bitmap(void)
CHECK_IMAGELIST(200, 30, 30);
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(8, 16, 15);
CHECK_IMAGELIST(8, 16, 16);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 3, (LPARAM)&bmp80) == 5, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(13, 16, 15);
CHECK_IMAGELIST(13, 16, 16);
ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(30, 30)) == TRUE, "TB_SETBITMAPSIZE failed\n");
UpdateWindow(hToolbar);
CHECK_IMAGELIST(8, 30, 30);
......@@ -362,7 +363,7 @@ static void test_add_bitmap(void)
addbmp.nID = IDB_STD_SMALL_COLOR;
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(15, 16, 15);
CHECK_IMAGELIST(15, 16, 16);
addbmp.nID = IDB_STD_LARGE_COLOR;
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
......@@ -371,7 +372,7 @@ static void test_add_bitmap(void)
addbmp.nID = IDB_VIEW_SMALL_COLOR;
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(12, 16, 15);
CHECK_IMAGELIST(12, 16, 16);
addbmp.nID = IDB_VIEW_LARGE_COLOR;
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
......@@ -380,7 +381,7 @@ static void test_add_bitmap(void)
addbmp.nID = IDB_HIST_SMALL_COLOR;
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
CHECK_IMAGELIST(5, 16, 15);
CHECK_IMAGELIST(5, 16, 16);
addbmp.nID = IDB_HIST_LARGE_COLOR;
rebuild_toolbar(&hToolbar);
ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
......
......@@ -125,7 +125,6 @@ typedef struct
INT nButtonHeight;
INT nButtonWidth;
INT nBitmapHeight;
INT nVBitmapHeight; /* see TOOLBAR_Create for an explanation */
INT nBitmapWidth;
INT nIndent;
INT nRows; /* number of button rows */
......@@ -1560,7 +1559,7 @@ static inline SIZE TOOLBAR_MeasureButton(TOOLBAR_INFO *infoPtr, SIZE sizeString,
if (infoPtr->dwStyle & TBSTYLE_LIST)
{
/* set button height from bitmap / text height... */
sizeButton.cy = max((bHasBitmap ? infoPtr->nVBitmapHeight : 0),
sizeButton.cy = max((bHasBitmap ? infoPtr->nBitmapHeight : 0),
sizeString.cy);
/* ... add on the necessary padding */
......@@ -1589,7 +1588,7 @@ static inline SIZE TOOLBAR_MeasureButton(TOOLBAR_INFO *infoPtr, SIZE sizeString,
{
if (bHasBitmap)
{
sizeButton.cy = infoPtr->nVBitmapHeight + DEFPAD_CY;
sizeButton.cy = infoPtr->nBitmapHeight + DEFPAD_CY;
if (sizeString.cy > 0)
sizeButton.cy += 1 + sizeString.cy;
sizeButton.cx = infoPtr->szPadding.cx +
......@@ -2777,9 +2776,6 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (lpAddBmp->nID & 1)
{
/* large icons */
/* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
* in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
*/
SendMessageW (hwnd, TB_SETBITMAPSIZE, 0,
MAKELPARAM((WORD)24, (WORD)24));
SendMessageW (hwnd, TB_SETBUTTONSIZE, 0,
......@@ -4442,7 +4438,7 @@ TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
LOWORD(lParam), HIWORD(lParam));
infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
infoPtr->nVBitmapHeight = infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
if ((himlDef == infoPtr->himlInt) &&
(ImageList_GetImageCount(infoPtr->himlInt) == 0))
......@@ -4593,7 +4589,7 @@ TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (cy == 0) cx = 22;
cx = max(cx, infoPtr->szPadding.cx + infoPtr->nBitmapWidth);
cy = max(cy, infoPtr->szPadding.cy + infoPtr->nVBitmapHeight);
cy = max(cy, infoPtr->szPadding.cy + infoPtr->nBitmapHeight);
infoPtr->nButtonWidth = cx;
infoPtr->nButtonHeight = cy;
......@@ -4852,7 +4848,6 @@ TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->nBitmapWidth = 1;
infoPtr->nBitmapHeight = 1;
}
infoPtr->nVBitmapHeight = infoPtr->nBitmapHeight;
TOOLBAR_CalcToolbar(hwnd);
TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n",
......@@ -5321,13 +5316,8 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
/* initialize info structure */
infoPtr->nButtonWidth = 23;
infoPtr->nButtonHeight = 22;
infoPtr->nBitmapHeight = 15;
infoPtr->nBitmapHeight = 16;
infoPtr->nBitmapWidth = 16;
/* By default Windows creates an image list with 16x15 icons but computes the button size as
* if the icons were 16x16. That's why we keep infoPtr->nVBitmapHeight. After a call to
* TB_SETBITMAPSIZE or TB_SETIMAGELIST the nVBitmapHeight = nBitmapHeight.
*/
infoPtr->nVBitmapHeight = 16;
infoPtr->nMaxTextRows = 1;
infoPtr->cxMin = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment