comctl32/listview: Fix vertical position offset for subitem rectangle.

This commit is contained in:
Nikolay Sivov 2010-05-24 12:08:29 +04:00 committed by Alexandre Julliard
parent 3f1d3e0ea1
commit 61c8a30574
2 changed files with 49 additions and 14 deletions

View file

@ -6953,7 +6953,7 @@ static BOOL LISTVIEW_GetItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPRECT
*/
static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPRECT lprc)
{
POINT Position;
POINT Position, Origin;
LVITEMW lvItem;
INT nColumn;
@ -6986,7 +6986,8 @@ static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPR
}
}
LISTVIEW_GetOrigin(infoPtr, &Position);
if (!LISTVIEW_GetItemPosition(infoPtr, nItem, &Position)) return FALSE;
LISTVIEW_GetOrigin(infoPtr, &Origin);
if (nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
@ -6994,7 +6995,6 @@ static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPR
lvItem.iItem = nItem;
lvItem.iSubItem = nColumn;
if (lvItem.mask && !LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
switch(lprc->left)
{
case LVIR_ICON:
@ -7011,7 +7011,9 @@ static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPR
return FALSE;
}
OffsetRect(lprc, Position.x, Position.y);
OffsetRect(lprc, Origin.x, Position.y);
TRACE("return rect %s\n", wine_dbgstr_rect(lprc));
return TRUE;
}

View file

@ -2089,7 +2089,7 @@ static void test_subitem_rect(void)
HWND hwnd;
DWORD r;
LVCOLUMN col;
RECT rect;
RECT rect, rect2;
INT arr[3];
/* test LVM_GETSUBITEMRECT for header */
@ -2099,15 +2099,12 @@ static void test_subitem_rect(void)
memset(&col, 0, sizeof(LVCOLUMN));
col.mask = LVCF_WIDTH;
col.cx = 100;
r = -1;
r = SendMessage(hwnd, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
expect(0, r);
col.cx = 150;
r = -1;
r = SendMessage(hwnd, LVM_INSERTCOLUMN, 1, (LPARAM)&col);
expect(1, r);
col.cx = 200;
r = -1;
r = SendMessage(hwnd, LVM_INSERTCOLUMN, 2, (LPARAM)&col);
expect(2, r);
/* item = -1 means header, subitem index is 1 based */
@ -2189,21 +2186,45 @@ todo_wine
col.mask = LVCF_WIDTH;
col.cx = 100;
r = -1;
r = SendMessage(hwnd, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
expect(0, r);
col.cx = 200;
r = -1;
r = SendMessage(hwnd, LVM_INSERTCOLUMN, 1, (LPARAM)&col);
expect(1, r);
col.cx = 300;
r = -1;
r = SendMessage(hwnd, LVM_INSERTCOLUMN, 2, (LPARAM)&col);
expect(2, r);
insert_item(hwnd, 0);
insert_item(hwnd, 1);
/* wrong item is refused for main item */
rect.left = LVIR_BOUNDS;
rect.top = 0;
rect.right = rect.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 2, (LPARAM)&rect);
ok(r == FALSE, "got %d\n", r);
/* for subitems rectangle is calculated even if there's no item added */
rect.left = LVIR_BOUNDS;
rect.top = 1;
rect.right = rect.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 1, (LPARAM)&rect);
ok(r == TRUE, "got %d\n", r);
rect2.left = LVIR_BOUNDS;
rect2.top = 1;
rect2.right = rect2.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 2, (LPARAM)&rect2);
todo_wine {
ok(r == TRUE, "got %d\n", r);
expect(rect.right, rect2.right);
expect(rect.left, rect2.left);
expect(rect.bottom, rect2.top);
ok(rect2.bottom > rect2.top, "expected not zero height\n");
}
arr[0] = 1; arr[1] = 0; arr[2] = 2;
r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 3, (LPARAM)arr);
@ -2213,7 +2234,7 @@ todo_wine
rect.top = 0;
rect.right = rect.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
ok(r != 0, "Expected not-null LRESULT\n");
ok(r == TRUE, "got %d\n", r);
expect(0, rect.left);
expect(600, rect.right);
@ -2221,15 +2242,27 @@ todo_wine
rect.top = 1;
rect.right = rect.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
ok(r != 0, "Expected not-null LRESULT\n");
ok(r == TRUE, "got %d\n", r);
expect(0, rect.left);
expect(200, rect.right);
rect2.left = LVIR_BOUNDS;
rect2.top = 1;
rect2.right = rect2.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 1, (LPARAM)&rect2);
ok(r == TRUE, "got %d\n", r);
expect(0, rect2.left);
expect(200, rect2.right);
/* items are of the same height */
ok(rect2.top > 0, "expected positive item height\n");
expect(rect.bottom, rect2.top);
expect(rect.bottom * 2 - rect.top, rect2.bottom);
rect.left = LVIR_BOUNDS;
rect.top = 2;
rect.right = rect.bottom = -1;
r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
ok(r != 0, "Expected not-null LRESULT\n");
ok(r == TRUE, "got %d\n", r);
expect(300, rect.left);
expect(600, rect.right);