Commit fca20f65 authored by Chris Morgan's avatar Chris Morgan Committed by Alexandre Julliard

Paint background before drawing item and subitems. Paint any area of

the control not occupied by items. Early out of LISTVIEW_RefreshXXX if no items exist. InvalidateRect() on LBUTTONDOWN only if the control has items to draw.
parent c941effc
...@@ -119,6 +119,7 @@ typedef struct tagLISTVIEW_INFO ...@@ -119,6 +119,7 @@ typedef struct tagLISTVIEW_INFO
INT nEditLabelItem; INT nEditLabelItem;
EDITLABEL_ITEM *pedititem; EDITLABEL_ITEM *pedititem;
DWORD dwHoverTime; DWORD dwHoverTime;
INT nColumnCount; /* the number of columns in this control */
WPARAM charCode; /* Added */ WPARAM charCode; /* Added */
CHAR szSearchParam[ MAX_PATH ]; /* Added */ CHAR szSearchParam[ MAX_PATH ]; /* Added */
...@@ -2786,8 +2787,10 @@ static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, ...@@ -2786,8 +2787,10 @@ static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem,
CHAR szDispText[DISP_TEXT_SIZE]; CHAR szDispText[DISP_TEXT_SIZE];
LVITEMA lvItem; LVITEMA lvItem;
UINT textoutOptions = ETO_CLIPPED | ETO_OPAQUE; UINT textoutOptions = ETO_CLIPPED | ETO_OPAQUE;
HBRUSH hBrush;
RECT rcTemp;
TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d)\n", hwnd, hdc, TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d)\n", hwnd, hdc,
nItem, nSubItem); nItem, nSubItem);
/* get information needed for drawing the item */ /* get information needed for drawing the item */
...@@ -2799,6 +2802,17 @@ static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, ...@@ -2799,6 +2802,17 @@ static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem,
lvItem.pszText = szDispText; lvItem.pszText = szDispText;
LISTVIEW_GetItemA(hwnd, &lvItem, TRUE); LISTVIEW_GetItemA(hwnd, &lvItem, TRUE);
/* redraw the background of the item */
hBrush = CreateSolidBrush(infoPtr->clrBk);
rcTemp = rcItem;
if(infoPtr->nColumnCount == (nSubItem + 1))
rcTemp.right = infoPtr->rcList.right;
else
rcTemp.right+=WIDTH_PADDING;
FillRect(hdc, &rcTemp, hBrush);
DeleteObject(hBrush);
/* set item colors */ /* set item colors */
if (ListView_GetItemState(hwnd,nItem,LVIS_SELECTED) if (ListView_GetItemState(hwnd,nItem,LVIS_SELECTED)
&&(infoPtr->bFocus != FALSE) && Selected) &&(infoPtr->bFocus != FALSE) && Selected)
...@@ -2812,12 +2826,12 @@ static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, ...@@ -2812,12 +2826,12 @@ static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem,
{ {
SetBkMode(hdc, TRANSPARENT); SetBkMode(hdc, TRANSPARENT);
textoutOptions &= ~ETO_OPAQUE; textoutOptions &= ~ETO_OPAQUE;
} }
else else
{ {
SetBkMode(hdc, OPAQUE); SetBkMode(hdc, OPAQUE);
SetBkColor(hdc, infoPtr->clrTextBk); SetBkColor(hdc, infoPtr->clrTextBk);
} }
SetTextColor(hdc, infoPtr->clrText); SetTextColor(hdc, infoPtr->clrText);
} }
...@@ -2871,7 +2885,8 @@ static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, BOOL F ...@@ -2871,7 +2885,8 @@ static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, BOOL F
BOOL bImage = FALSE; BOOL bImage = FALSE;
INT iBkMode = -1; INT iBkMode = -1;
UINT textoutOptions = ETO_OPAQUE | ETO_CLIPPED; UINT textoutOptions = ETO_OPAQUE | ETO_CLIPPED;
HBRUSH hBrush;
RECT rcTemp;
TRACE("(hwnd=%x, hdc=%x, nItem=%d)\n", hwnd, hdc, nItem); TRACE("(hwnd=%x, hdc=%x, nItem=%d)\n", hwnd, hdc, nItem);
...@@ -2886,6 +2901,17 @@ static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, BOOL F ...@@ -2886,6 +2901,17 @@ static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, BOOL F
lvItem.pszText = szDispText; lvItem.pszText = szDispText;
LISTVIEW_GetItemA(hwnd, &lvItem, TRUE); LISTVIEW_GetItemA(hwnd, &lvItem, TRUE);
/* redraw the background of the item */
hBrush = CreateSolidBrush(infoPtr->clrBk);
rcTemp = rcItem;
if(infoPtr->nColumnCount == (nItem + 1))
rcTemp.right = infoPtr->rcList.right;
else
rcTemp.right+=WIDTH_PADDING;
FillRect(hdc, &rcTemp, hBrush);
DeleteObject(hBrush);
/* do indent */ /* do indent */
if (lvItem.iIndent>0 && infoPtr->iconSize.cx > 0) if (lvItem.iIndent>0 && infoPtr->iconSize.cx > 0)
{ {
...@@ -3040,6 +3066,8 @@ static VOID LISTVIEW_DrawLargeItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, ...@@ -3040,6 +3066,8 @@ static VOID LISTVIEW_DrawLargeItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem,
TEXTMETRICA tm; TEXTMETRICA tm;
LVITEMA lvItem; LVITEMA lvItem;
UINT textoutOptions = ETO_CLIPPED | ETO_OPAQUE; UINT textoutOptions = ETO_CLIPPED | ETO_OPAQUE;
HBRUSH hBrush;
RECT rcTemp;
TRACE("(hwnd=%x, hdc=%x, nItem=%d, left=%d, top=%d, right=%d, \ TRACE("(hwnd=%x, hdc=%x, nItem=%d, left=%d, top=%d, right=%d, \
bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right,
...@@ -3055,6 +3083,16 @@ bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, ...@@ -3055,6 +3083,16 @@ bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right,
lvItem.pszText = szDispText; lvItem.pszText = szDispText;
LISTVIEW_GetItemA(hwnd, &lvItem, TRUE); LISTVIEW_GetItemA(hwnd, &lvItem, TRUE);
/* redraw the background of the item */
hBrush = CreateSolidBrush(infoPtr->clrBk);
if(infoPtr->nColumnCount == (nItem + 1))
rcTemp.right = infoPtr->rcList.right;
else
rcTemp.right+=WIDTH_PADDING;
FillRect(hdc, &rcTemp, hBrush);
DeleteObject(hBrush);
if (lvItem.state & LVIS_SELECTED) if (lvItem.state & LVIS_SELECTED)
{ {
/* set item colors */ /* set item colors */
...@@ -3170,13 +3208,14 @@ static VOID LISTVIEW_RefreshReport(HWND hwnd, HDC hdc, DWORD cdmode) ...@@ -3170,13 +3208,14 @@ static VOID LISTVIEW_RefreshReport(HWND hwnd, HDC hdc, DWORD cdmode)
SCROLLINFO scrollInfo; SCROLLINFO scrollInfo;
INT nDrawPosY = infoPtr->rcList.top; INT nDrawPosY = infoPtr->rcList.top;
INT nColumnCount; INT nColumnCount;
RECT rcItem; RECT rcItem, rcTemp;
INT j; INT j;
INT nItem; INT nItem;
INT nLast; INT nLast;
BOOL FullSelected; BOOL FullSelected;
DWORD cditemmode = CDRF_DODEFAULT; DWORD cditemmode = CDRF_DODEFAULT;
LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
HBRUSH hBrush;
ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.cbSize = sizeof(SCROLLINFO);
...@@ -3204,8 +3243,19 @@ static VOID LISTVIEW_RefreshReport(HWND hwnd, HDC hdc, DWORD cdmode) ...@@ -3204,8 +3243,19 @@ static VOID LISTVIEW_RefreshReport(HWND hwnd, HDC hdc, DWORD cdmode)
} }
nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); nColumnCount = Header_GetItemCount(infoPtr->hwndHeader);
infoPtr->nColumnCount = nColumnCount; /* update nColumnCount */
FullSelected = infoPtr->dwExStyle & LVS_EX_FULLROWSELECT; FullSelected = infoPtr->dwExStyle & LVS_EX_FULLROWSELECT;
/* clear the background of any part of the control that doesn't contain items */
SubtractRect(&rcTemp, &infoPtr->rcList, &infoPtr->rcView);
hBrush = CreateSolidBrush(infoPtr->clrBk);
FillRect(hdc, &infoPtr->rcList, hBrush);
DeleteObject(hBrush);
/* nothing to draw */
if(GETITEMCOUNT(infoPtr) == 0)
return;
for (; nItem < nLast; nItem++) for (; nItem < nLast; nItem++)
{ {
RECT SuggestedFocusRect; RECT SuggestedFocusRect;
...@@ -3436,7 +3486,7 @@ static INT LISTVIEW_GetColumnCount(HWND hwnd) ...@@ -3436,7 +3486,7 @@ static INT LISTVIEW_GetColumnCount(HWND hwnd)
static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc, DWORD cdmode) static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc, DWORD cdmode)
{ {
LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
RECT rcItem,FocusRect; RECT rcItem, FocusRect, rcTemp;
INT i, j; INT i, j;
INT nItem; INT nItem;
INT nColumnCount; INT nColumnCount;
...@@ -3444,12 +3494,24 @@ static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc, DWORD cdmode) ...@@ -3444,12 +3494,24 @@ static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc, DWORD cdmode)
INT nItemWidth = infoPtr->nItemWidth; INT nItemWidth = infoPtr->nItemWidth;
INT nItemHeight = infoPtr->nItemHeight; INT nItemHeight = infoPtr->nItemHeight;
DWORD cditemmode = CDRF_DODEFAULT; DWORD cditemmode = CDRF_DODEFAULT;
HBRUSH hBrush;
/* get number of fully visible columns */ /* get number of fully visible columns */
nColumnCount = LISTVIEW_GetColumnCount(hwnd); nColumnCount = LISTVIEW_GetColumnCount(hwnd);
infoPtr->nColumnCount = nColumnCount;
nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd);
nItem = ListView_GetTopIndex(hwnd); nItem = ListView_GetTopIndex(hwnd);
/* paint the background of the control that doesn't contain any items */
SubtractRect(&rcTemp, &infoPtr->rcList, &infoPtr->rcView);
hBrush = CreateSolidBrush(infoPtr->clrBk);
FillRect(hdc, &infoPtr->rcList, hBrush);
DeleteObject(hBrush);
/* nothing to draw, return here */
if(GETITEMCOUNT(infoPtr) == 0)
return;
for (i = 0; i < nColumnCount; i++) for (i = 0; i < nColumnCount; i++)
{ {
for (j = 0; j < nCountPerColumn; j++, nItem++) for (j = 0; j < nCountPerColumn; j++, nItem++)
...@@ -3499,10 +3561,23 @@ static VOID LISTVIEW_RefreshIcon(HWND hwnd, HDC hdc, BOOL bSmall, DWORD cdmode) ...@@ -3499,10 +3561,23 @@ static VOID LISTVIEW_RefreshIcon(HWND hwnd, HDC hdc, BOOL bSmall, DWORD cdmode)
LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
POINT ptPosition; POINT ptPosition;
POINT ptOrigin; POINT ptOrigin;
RECT rcItem,SuggestedFocus; RECT rcItem, SuggestedFocus, rcTemp;
HBRUSH hBrush;
INT i; INT i;
DWORD cditemmode = CDRF_DODEFAULT; DWORD cditemmode = CDRF_DODEFAULT;
infoPtr->nColumnCount = 1; /* set this to an arbitrary value to prevent */
/* DrawItem from erasing the incorrect background area */
/* paint the background of the control that doesn't contain any items */
SubtractRect(&rcTemp, &infoPtr->rcList, &infoPtr->rcView);
hBrush = CreateSolidBrush(infoPtr->clrBk);
FillRect(hdc, &infoPtr->rcList, hBrush);
DeleteObject(hBrush);
/* nothing to draw, return here */
if(GETITEMCOUNT(infoPtr) == 0)
return;
LISTVIEW_GetOrigin(hwnd, &ptOrigin); LISTVIEW_GetOrigin(hwnd, &ptOrigin);
for (i = 0; i < GETITEMCOUNT(infoPtr); i++) for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
...@@ -8151,7 +8226,8 @@ static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX, ...@@ -8151,7 +8226,8 @@ static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX,
LISTVIEW_RemoveAllSelections(hwnd); LISTVIEW_RemoveAllSelections(hwnd);
} }
InvalidateRect(hwnd, NULL, TRUE); /* redraw if we could have possibly selected something */
if(!GETITEMCOUNT(infoPtr)) InvalidateRect(hwnd, NULL, TRUE);
return 0; return 0;
} }
......
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