[3/4] comctl32/listview: Don't use special value (1) for item width to represent both zero and one pixel width
Nikolay Sivov
bunglehead at gmail.com
Wed Jun 10 17:27:24 CDT 2009
Changelog:
- Don't use special value (1) for item width to represent both zero and one pixel width,
make zero a valid value too.
>From a682263cb34626966ae141bfeebbb88df6d4a5c8 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Thu, 11 Jun 2009 00:32:46 +0400
Subject: 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 214953a..8a038d6 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);
--
1.5.6.5
More information about the wine-patches
mailing list