comctl32/treeview: Use additional helper for item invalidation.

This commit is contained in:
Nikolay Sivov 2009-12-09 23:06:08 +03:00 committed by Alexandre Julliard
parent f9a475c808
commit e3c34f2d29
1 changed files with 22 additions and 32 deletions

View File

@ -2858,10 +2858,16 @@ TREEVIEW_Refresh(TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc)
TREEVIEW_SendCustomDrawNotify(infoPtr, CDDS_POSTPAINT, hdc, rect); TREEVIEW_SendCustomDrawNotify(infoPtr, CDDS_POSTPAINT, hdc, rect);
} }
static inline void
TREEVIEW_InvalidateItem(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
{
if (item) InvalidateRect(infoPtr->hwnd, &item->rect, TRUE);
}
static void static void
TREEVIEW_Invalidate(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item) TREEVIEW_Invalidate(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
{ {
if (item != NULL) if (item)
InvalidateRect(infoPtr->hwnd, &item->rect, TRUE); InvalidateRect(infoPtr->hwnd, &item->rect, TRUE);
else else
InvalidateRect(infoPtr->hwnd, NULL, TRUE); InvalidateRect(infoPtr->hwnd, NULL, TRUE);
@ -4026,7 +4032,6 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
HWND hwnd = infoPtr->hwnd; HWND hwnd = infoPtr->hwnd;
TVHITTESTINFO ht; TVHITTESTINFO ht;
BOOL bTrack, bDoLabelEdit; BOOL bTrack, bDoLabelEdit;
HTREEITEM tempItem;
/* If Edit control is active - kill it and return. /* If Edit control is active - kill it and return.
* The best way to do it is to set focus to itself. * The best way to do it is to set focus to itself.
@ -4049,10 +4054,8 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
if(ht.hItem && (ht.flags & TVHT_ONITEM)) if(ht.hItem && (ht.flags & TVHT_ONITEM))
{ {
infoPtr->focusedItem = ht.hItem; infoPtr->focusedItem = ht.hItem;
InvalidateRect(hwnd, &ht.hItem->rect, TRUE); TREEVIEW_InvalidateItem(infoPtr, infoPtr->focusedItem);
TREEVIEW_InvalidateItem(infoPtr, infoPtr->selectedItem);
if(infoPtr->selectedItem)
InvalidateRect(hwnd, &(infoPtr->selectedItem->rect), TRUE);
} }
bTrack = (ht.flags & TVHT_ONITEM) bTrack = (ht.flags & TVHT_ONITEM)
@ -4086,13 +4089,11 @@ TREEVIEW_LButtonDown(TREEVIEW_INFO *infoPtr, LPARAM lParam)
if(infoPtr->focusedItem) if(infoPtr->focusedItem)
{ {
/* refresh the item that was focused */ /* refresh the item that was focused */
tempItem = infoPtr->focusedItem; TREEVIEW_InvalidateItem(infoPtr, infoPtr->focusedItem);
infoPtr->focusedItem = 0; infoPtr->focusedItem = NULL;
InvalidateRect(infoPtr->hwnd, &tempItem->rect, TRUE);
/* refresh the selected item to return the filled background */ /* refresh the selected item to return the filled background */
if (infoPtr->selectedItem) TREEVIEW_InvalidateItem(infoPtr, infoPtr->selectedItem);
InvalidateRect(infoPtr->hwnd, &(infoPtr->selectedItem->rect), TRUE);
} }
return 0; return 0;
@ -4312,7 +4313,6 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect,
INT cause) INT cause)
{ {
TREEVIEW_ITEM *prevSelect; TREEVIEW_ITEM *prevSelect;
RECT rcFocused;
assert(newSelect == NULL || TREEVIEW_ValidItem(infoPtr, newSelect)); assert(newSelect == NULL || TREEVIEW_ValidItem(infoPtr, newSelect));
@ -4322,12 +4322,8 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect,
/* reset and redraw focusedItem if focusedItem was set so we don't */ /* reset and redraw focusedItem if focusedItem was set so we don't */
/* have to worry about the previously focused item when we set a new one */ /* have to worry about the previously focused item when we set a new one */
if(infoPtr->focusedItem) TREEVIEW_InvalidateItem(infoPtr, infoPtr->focusedItem);
{ infoPtr->focusedItem = NULL;
rcFocused = (infoPtr->focusedItem)->rect;
infoPtr->focusedItem = 0;
InvalidateRect(infoPtr->hwnd, &rcFocused, TRUE);
}
switch (action) switch (action)
{ {
@ -4356,10 +4352,8 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect,
TREEVIEW_EnsureVisible(infoPtr, infoPtr->selectedItem, FALSE); TREEVIEW_EnsureVisible(infoPtr, infoPtr->selectedItem, FALSE);
if (prevSelect) TREEVIEW_InvalidateItem(infoPtr, prevSelect);
TREEVIEW_Invalidate(infoPtr, prevSelect); TREEVIEW_InvalidateItem(infoPtr, newSelect);
if (newSelect)
TREEVIEW_Invalidate(infoPtr, newSelect);
TREEVIEW_SendTreeviewNotify(infoPtr, TREEVIEW_SendTreeviewNotify(infoPtr,
TVN_SELCHANGEDW, TVN_SELCHANGEDW,
@ -5257,12 +5251,10 @@ TREEVIEW_KeyDown(TREEVIEW_INFO *infoPtr, WPARAM wParam)
static LRESULT static LRESULT
TREEVIEW_MouseLeave (TREEVIEW_INFO * infoPtr) TREEVIEW_MouseLeave (TREEVIEW_INFO * infoPtr)
{ {
if (infoPtr->hotItem) /* remove hot effect from item */
{ TREEVIEW_InvalidateItem(infoPtr, infoPtr->hotItem);
/* remove hot effect from item */ infoPtr->hotItem = NULL;
InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE);
infoPtr->hotItem = NULL;
}
return 0; return 0;
} }
@ -5302,12 +5294,10 @@ TREEVIEW_MouseMove (TREEVIEW_INFO * infoPtr, LPARAM lParam)
if (item != infoPtr->hotItem) if (item != infoPtr->hotItem)
{ {
/* redraw old hot item */ /* redraw old hot item */
if (infoPtr->hotItem) TREEVIEW_InvalidateItem(infoPtr, infoPtr->hotItem);
InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE);
infoPtr->hotItem = item; infoPtr->hotItem = item;
/* redraw new hot item */ /* redraw new hot item */
if (infoPtr->hotItem) TREEVIEW_InvalidateItem(infoPtr, infoPtr->hotItem);
InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE);
} }
return 0; return 0;