comctl32/listview: Fix select rectangle calculation for empty text items

Nikolay Sivov bunglehead at gmail.com
Wed Jul 1 17:50:55 CDT 2009


Selected rectangle has a separate calculation path
for empty text rectangle (some tests were present already).
It doesn't default to column width bound but has a maximum
width value (it needs some tests but it's still
close to native value now).

Only report mode behaviour affected by this.

Changelog:
    - Fix select rectangle calculation for empty text items

>From 04bc4216384d5e1da30e91801445843efbb189d1 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Thu, 2 Jul 2009 02:42:43 +0400
Subject: Fix select rectangle calculation for empty text items

---
 dlls/comctl32/listview.c       |   12 ++++++++++--
 dlls/comctl32/tests/listview.c |    4 ++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index d7a5f97..e5964fc 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -360,6 +360,8 @@ typedef struct tagLISTVIEW_INFO
 
 /* default label width for items in list and small icon display modes */
 #define DEFAULT_LABEL_WIDTH 40
+/* maximum select rectangle width for empty text item in LV_VIEW_DETAILS */
+#define MAX_EMPTYTEXT_SELECT_WIDTH 80
 
 /* default column width for items in list display mode */
 #define DEFAULT_COLUMN_WIDTH 128
@@ -2235,7 +2237,9 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW
 	    
     	    DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT);
 
-	    labelSize.cx = min(rcText.right - rcText.left + TRAILING_LABEL_PADDING, infoPtr->nItemWidth);
+	    if (rcText.right != rcText.left)
+	        labelSize.cx = min(rcText.right - rcText.left + TRAILING_LABEL_PADDING, infoPtr->nItemWidth);
+
 	    labelSize.cy = rcText.bottom - rcText.top;
 
     	    SelectObject(hdc, hOldFont);
@@ -2288,7 +2292,11 @@ calc_label:
 	    SelectBox.left = Icon.left;
 	    SelectBox.top = Box.top;
 	    SelectBox.bottom = Box.bottom;
-	    SelectBox.right = min(Label.left + labelSize.cx, Label.right);
+	    
+	    if (labelSize.cx)
+	        SelectBox.right = min(Label.left + labelSize.cx, Label.right);
+	    else
+	        SelectBox.right = min(Label.left + MAX_EMPTYTEXT_SELECT_WIDTH, Label.right);
 	}
 	else
 	{
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index d11d9de..d5bcbf5 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -3067,7 +3067,7 @@ static void test_getitemrect(void)
     expect(TRUE, r);
     /* padding, column width */
     expect(2, rect.left);
-    todo_wine expect(50, rect.right);
+    expect(50, rect.right);
 
     /* try with indentation */
     item.mask = LVIF_INDENT;
@@ -3093,7 +3093,7 @@ static void test_getitemrect(void)
     expect(TRUE, r);
     /* padding + 1 icon width, column width */
     expect(2 + 16, rect.left);
-    todo_wine expect(50, rect.right);
+    expect(50, rect.right);
 
     /* label bounds */
     rect.left = LVIR_LABEL;
-- 
1.5.6.5





More information about the wine-patches mailing list