Nikolay Sivov : comctl32/listview: Don't use special value (1) for item width to represent both zero and one pixel width.

Alexandre Julliard julliard at winehq.org
Thu Jun 11 10:54:26 CDT 2009


Module: wine
Branch: master
Commit: f2f444a230ba69ae6fabe28e8c0c1b95484a9362
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f2f444a230ba69ae6fabe28e8c0c1b95484a9362

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Thu Jun 11 00:32:46 2009 +0400

comctl32/listview: Don't use special value (1) for item width to represent both zero and one pixel width.

---

 dlls/comctl32/listview.c       |   26 ++++++++++++++++++++------
 dlls/comctl32/tests/listview.c |    2 +-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index c210bf5..8ef516a 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -1239,12 +1239,25 @@ static BOOL iterator_frameditems(ITERATOR* i, const LISTVIEW_INFO* infoPtr, cons
 	INT nPerCol = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / infoPtr->nItemHeight, 1);
 	INT nFirstRow = max(frame.top / infoPtr->nItemHeight, 0);
 	INT nLastRow = min((frame.bottom - 1) / infoPtr->nItemHeight, nPerCol - 1);
-	INT nFirstCol = max(frame.left / infoPtr->nItemWidth, 0);
-	INT nLastCol = min((frame.right - 1) / infoPtr->nItemWidth, (infoPtr->nItemCount + nPerCol - 1) / nPerCol);
-	INT lower = nFirstCol * nPerCol + nFirstRow;
+	INT nFirstCol;
+	INT nLastCol;
+	INT lower;
 	RANGE item_range;
 	INT nCol;
 
+	if (infoPtr->nItemWidth)
+	{
+	    nFirstCol = max(frame.left / infoPtr->nItemWidth, 0);
+            nLastCol  = min((frame.right - 1) / infoPtr->nItemWidth, (infoPtr->nItemCount + nPerCol - 1) / nPerCol);
+	}
+	else
+	{
+	    nFirstCol = max(frame.left, 0);
+            nLastCol  = min(frame.right - 1, (infoPtr->nItemCount + nPerCol - 1) / nPerCol);
+	}
+
+	lower = nFirstCol * nPerCol + nFirstRow;
+
 	TRACE("nPerCol=%d, nFirstRow=%d, nLastRow=%d, nFirstCol=%d, nLastCol=%d, lower=%d\n",
 	      nPerCol, nFirstRow, nLastRow, nFirstCol, nLastCol, lower);
 	
@@ -1493,7 +1506,7 @@ static inline INT LISTVIEW_GetCountPerRow(const LISTVIEW_INFO *infoPtr)
 {
     INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
 
-    return max(nListWidth/infoPtr->nItemWidth, 1);
+    return max(nListWidth/(infoPtr->nItemWidth ? infoPtr->nItemWidth : 1), 1);
 }
 
 /***
@@ -1736,7 +1749,8 @@ static void LISTVIEW_UpdateScroll(const LISTVIEW_INFO *infoPtr)
 	if(horzInfo.nPage < infoPtr->nItemWidth)
 		horzInfo.nPage = infoPtr->nItemWidth;
 
-	horzInfo.nPage /= infoPtr->nItemWidth;
+	if (infoPtr->nItemWidth)
+	    horzInfo.nPage /= infoPtr->nItemWidth;
     }
     else if (infoPtr->uView == LV_VIEW_DETAILS)
     {
@@ -2530,7 +2544,7 @@ static INT LISTVIEW_CalculateItemWidth(const LISTVIEW_INFO *infoPtr)
 	nItemWidth = max(DEFAULT_COLUMN_WIDTH, nItemWidth + WIDTH_PADDING);
     }
 
-    return max(nItemWidth, 1);
+    return nItemWidth;
 }
 
 /***
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 2dce945..3895bea 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2829,7 +2829,7 @@ static void test_getitemrect(void)
 
     /* zero width rectangle with no padding */
     expect(0, rect.left);
-    todo_wine expect(0, rect.right);
+    expect(0, rect.right);
 
     insert_column(hwnd, 0);
     insert_column(hwnd, 1);




More information about the wine-cvs mailing list