comctl32/listview: Default column width in LVS_LIST to better value.

This commit is contained in:
Nikolay Sivov 2009-11-26 22:42:33 +03:00 committed by Alexandre Julliard
parent dbbd2161ab
commit fc43895f49
2 changed files with 32 additions and 4 deletions

View File

@ -403,7 +403,7 @@ typedef struct tagLISTVIEW_INFO
#define MAX_EMPTYTEXT_SELECT_WIDTH 80
/* default column width for items in list display mode */
#define DEFAULT_COLUMN_WIDTH 128
#define DEFAULT_COLUMN_WIDTH 96
/* Size of "line" scroll for V & H scrolls */
#define LISTVIEW_SCROLL_ICON_LINE_SIZE 37
@ -2786,15 +2786,20 @@ static INT LISTVIEW_CalculateItemWidth(const LISTVIEW_INFO *infoPtr)
}
else /* LV_VIEW_SMALLICON, or LV_VIEW_LIST */
{
BOOL empty;
INT i;
for (i = 0; i < infoPtr->nItemCount; i++)
nItemWidth = max(LISTVIEW_GetLabelWidth(infoPtr, i), nItemWidth);
empty = nItemWidth == 0;
if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx;
if (infoPtr->himlState) nItemWidth += infoPtr->iconStateSize.cx;
nItemWidth = max(DEFAULT_COLUMN_WIDTH, nItemWidth + WIDTH_PADDING);
if (empty)
nItemWidth = max(nItemWidth, DEFAULT_COLUMN_WIDTH);
else
nItemWidth += WIDTH_PADDING;
}
return nItemWidth;
@ -7454,7 +7459,7 @@ static INT LISTVIEW_InsertItemT(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem,
TRACE(" inserting at %d, sorted=%d, count=%d, iItem=%d\n", nItem, is_sorted, infoPtr->nItemCount, lpLVItem->iItem);
nItem = DPA_InsertPtr( infoPtr->hdpaItems, nItem, hdpaSubItems );
if (nItem == -1) goto fail;
infoPtr->nItemCount++;
if (infoPtr->nItemCount++ == 0) LISTVIEW_UpdateItemSize(infoPtr);
/* shift indices first so they don't get tangled */
LISTVIEW_ShiftIndices(infoPtr, nItem, 1);

View File

@ -3124,6 +3124,20 @@ static void test_getitemrect(void)
INT order[2];
POINT pt;
/* rectangle isn't empty for empty text items */
hwnd = create_custom_listview_control(LVS_LIST);
memset(&item, 0, sizeof(item));
item.mask = 0;
item.iItem = 0;
r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
expect(0, r);
rect.left = LVIR_LABEL;
SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
expect(0, rect.left);
expect(0, rect.top);
todo_wine expect(96, rect.right);
DestroyWindow(hwnd);
hwnd = create_listview_control(0);
ok(hwnd != NULL, "failed to create a listview window\n");
@ -3921,6 +3935,7 @@ static void test_getcolumnwidth(void)
DWORD ret;
DWORD_PTR style;
LVCOLUMNA col;
LVITEMA itema;
/* default column width */
hwnd = create_custom_listview_control(0);
@ -3938,6 +3953,14 @@ static void test_getcolumnwidth(void)
ret = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
expect(10, ret);
DestroyWindow(hwnd);
/* default column width with item added */
hwnd = create_custom_listview_control(LVS_LIST);
memset(&itema, 0, sizeof(itema));
SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&itema);
ret = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
expect(96, ret);
DestroyWindow(hwnd);
}
static void test_scrollnotify(void)