Commit f2f444a2 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Don't use special value (1) for item width to represent both…

comctl32/listview: Don't use special value (1) for item width to represent both zero and one pixel width.
parent a5c970de
...@@ -1239,12 +1239,25 @@ static BOOL iterator_frameditems(ITERATOR* i, const LISTVIEW_INFO* infoPtr, cons ...@@ -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 nPerCol = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / infoPtr->nItemHeight, 1);
INT nFirstRow = max(frame.top / infoPtr->nItemHeight, 0); INT nFirstRow = max(frame.top / infoPtr->nItemHeight, 0);
INT nLastRow = min((frame.bottom - 1) / infoPtr->nItemHeight, nPerCol - 1); INT nLastRow = min((frame.bottom - 1) / infoPtr->nItemHeight, nPerCol - 1);
INT nFirstCol = max(frame.left / infoPtr->nItemWidth, 0); INT nFirstCol;
INT nLastCol = min((frame.right - 1) / infoPtr->nItemWidth, (infoPtr->nItemCount + nPerCol - 1) / nPerCol); INT nLastCol;
INT lower = nFirstCol * nPerCol + nFirstRow; INT lower;
RANGE item_range; RANGE item_range;
INT nCol; 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", TRACE("nPerCol=%d, nFirstRow=%d, nLastRow=%d, nFirstCol=%d, nLastCol=%d, lower=%d\n",
nPerCol, nFirstRow, nLastRow, nFirstCol, nLastCol, lower); nPerCol, nFirstRow, nLastRow, nFirstCol, nLastCol, lower);
...@@ -1493,7 +1506,7 @@ static inline INT LISTVIEW_GetCountPerRow(const LISTVIEW_INFO *infoPtr) ...@@ -1493,7 +1506,7 @@ static inline INT LISTVIEW_GetCountPerRow(const LISTVIEW_INFO *infoPtr)
{ {
INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
return max(nListWidth/infoPtr->nItemWidth, 1); return max(nListWidth/(infoPtr->nItemWidth ? infoPtr->nItemWidth : 1), 1);
} }
/*** /***
...@@ -1736,6 +1749,7 @@ static void LISTVIEW_UpdateScroll(const LISTVIEW_INFO *infoPtr) ...@@ -1736,6 +1749,7 @@ static void LISTVIEW_UpdateScroll(const LISTVIEW_INFO *infoPtr)
if(horzInfo.nPage < infoPtr->nItemWidth) if(horzInfo.nPage < infoPtr->nItemWidth)
horzInfo.nPage = infoPtr->nItemWidth; horzInfo.nPage = infoPtr->nItemWidth;
if (infoPtr->nItemWidth)
horzInfo.nPage /= infoPtr->nItemWidth; horzInfo.nPage /= infoPtr->nItemWidth;
} }
else if (infoPtr->uView == LV_VIEW_DETAILS) else if (infoPtr->uView == LV_VIEW_DETAILS)
...@@ -2530,7 +2544,7 @@ static INT LISTVIEW_CalculateItemWidth(const LISTVIEW_INFO *infoPtr) ...@@ -2530,7 +2544,7 @@ static INT LISTVIEW_CalculateItemWidth(const LISTVIEW_INFO *infoPtr)
nItemWidth = max(DEFAULT_COLUMN_WIDTH, nItemWidth + WIDTH_PADDING); nItemWidth = max(DEFAULT_COLUMN_WIDTH, nItemWidth + WIDTH_PADDING);
} }
return max(nItemWidth, 1); return nItemWidth;
} }
/*** /***
......
...@@ -2829,7 +2829,7 @@ static void test_getitemrect(void) ...@@ -2829,7 +2829,7 @@ static void test_getitemrect(void)
/* zero width rectangle with no padding */ /* zero width rectangle with no padding */
expect(0, rect.left); expect(0, rect.left);
todo_wine expect(0, rect.right); expect(0, rect.right);
insert_column(hwnd, 0); insert_column(hwnd, 0);
insert_column(hwnd, 1); insert_column(hwnd, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment