[2/3] comctl32/listview: Fix item bounds calculation for LVS_REPORT style

Nikolay Sivov bunglehead at gmail.com
Mon Jun 1 04:22:51 CDT 2009


Changelog:
    - Fix item bounds calculation for LVS_REPORT style

>From cdbf10438b61dd5bf5c074206718380cb12ec1e3 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sat, 30 May 2009 20:11:00 +0400
Subject: Fix item bounds calculation for LVS_REPORT style

---
 dlls/comctl32/listview.c       |   16 +++----
 dlls/comctl32/tests/listview.c |   86 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 9 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 7c1aee2..a1aa250 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -2045,7 +2045,11 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW
 	    Icon.left   = Box.left + state_width;
 
 	    if (uView == LVS_REPORT && lpLVItem->iSubItem == 0)
-		Icon.left += REPORT_MARGINX;
+	    {
+		/* we need the indent in report mode */
+		assert(lpLVItem->mask & LVIF_INDENT);
+		Icon.left += infoPtr->iconSize.cx * lpLVItem->iIndent + REPORT_MARGINX;
+	    }
 
 	    Icon.top    = Box.top;
 	    Icon.right  = Icon.left;
@@ -2164,16 +2168,10 @@ calc_label:
     {
 	if (uView == LVS_REPORT)
 	{
-	    SelectBox.left = Icon.right; /* FIXME: should be Icon.left */
+	    SelectBox.left = Icon.left;
 	    SelectBox.top = Box.top;
 	    SelectBox.bottom = Box.bottom;
-	    if (lpLVItem->iSubItem == 0)
-	    {
-		/* we need the indent in report mode */
-		assert(lpLVItem->mask & LVIF_INDENT);
-		SelectBox.left += infoPtr->iconSize.cx * lpLVItem->iIndent;
-	    }
-	    SelectBox.right = min(SelectBox.left + labelSize.cx, Label.right);
+	    SelectBox.right = min(Label.left + labelSize.cx, Label.right);
 	}
 	else
 	{
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index b6a44c8..42b9df6 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2741,6 +2741,92 @@ static void test_getitemrect(void)
     expect(18, rect.left);
     expect(50, rect.right);
 
+    r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL);
+    ok(r != 0, "should return current list handle\n");
+
+    r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
+    ok(r == 0, "should return zero\n");
+
+    item.mask = LVIF_STATE | LVIF_IMAGE;
+    item.iImage = 1;
+    item.state = 0;
+    item.stateMask = ~0;
+    item.iItem = 0;
+    item.iSubItem = 0;
+    r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
+    expect(TRUE, r);
+
+    /* icon bounds */
+    rect.left = LVIR_ICON;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding, icon width */
+    expect(2, rect.left);
+    expect(18, rect.right);
+    /* label bounds */
+    rect.left = LVIR_LABEL;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding + icon width -> column width */
+    expect(18, rect.left);
+    expect(50, rect.right);
+
+    /* select bounds */
+    rect.left = LVIR_SELECTBOUNDS;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding, column width */
+    expect(2, rect.left);
+    todo_wine expect(50, rect.right);
+
+    /* try with indentation */
+    item.mask = LVIF_INDENT;
+    item.iIndent = 1;
+    item.iItem = 0;
+    item.iSubItem = 0;
+    r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
+    expect(TRUE, r);
+
+    /* bounds */
+    rect.left = LVIR_BOUNDS;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding + 1 icon width, column width */
+    expect(0, rect.left);
+    expect(150, rect.right);
+
+    /* select bounds */
+    rect.left = LVIR_SELECTBOUNDS;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding + 1 icon width, column width */
+    expect(2 + 16, rect.left);
+    todo_wine expect(50, rect.right);
+
+    /* label bounds */
+    rect.left = LVIR_LABEL;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding + 2 icon widths, column width */
+    expect(2 + 16*2, rect.left);
+    expect(50, rect.right);
+
+    /* icon bounds */
+    rect.left = LVIR_ICON;
+    rect.right = rect.top = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
+    expect(TRUE, r);
+    /* padding + 1 icon width indentation, icon width */
+    expect(2 + 16, rect.left);
+    expect(34, rect.right);
+
+
     DestroyWindow(hwnd);
 }
 
-- 
1.5.6.5







More information about the wine-patches mailing list