Commit 8d8c87b8 authored by Susan Farley's avatar Susan Farley Committed by Alexandre Julliard

- When inserting an item, do not invalidate the area above the new

item. - The debug function that verifies the tree after each insertion should be disabled by default.
parent 49b3cec1
...@@ -160,8 +160,7 @@ DEFAULT_DEBUG_CHANNEL(treeview); ...@@ -160,8 +160,7 @@ DEFAULT_DEBUG_CHANNEL(treeview);
typedef VOID (*TREEVIEW_ItemEnumFunc)(TREEVIEW_INFO *, TREEVIEW_ITEM *,LPVOID); typedef VOID (*TREEVIEW_ItemEnumFunc)(TREEVIEW_INFO *, TREEVIEW_ITEM *,LPVOID);
static VOID TREEVIEW_QueueRefresh(TREEVIEW_INFO *); static VOID TREEVIEW_Invalidate(TREEVIEW_INFO *, TREEVIEW_ITEM *);
static VOID TREEVIEW_QueueItemRefresh(TREEVIEW_INFO *, TREEVIEW_ITEM *);
static LRESULT TREEVIEW_DoSelectItem(TREEVIEW_INFO *, INT, HTREEITEM, INT); static LRESULT TREEVIEW_DoSelectItem(TREEVIEW_INFO *, INT, HTREEITEM, INT);
static VOID TREEVIEW_SetFirstVisible(TREEVIEW_INFO *, TREEVIEW_ITEM *, BOOL); static VOID TREEVIEW_SetFirstVisible(TREEVIEW_INFO *, TREEVIEW_ITEM *, BOOL);
...@@ -174,7 +173,7 @@ static LRESULT TREEVIEW_HScroll(TREEVIEW_INFO *, WPARAM); ...@@ -174,7 +173,7 @@ static LRESULT TREEVIEW_HScroll(TREEVIEW_INFO *, WPARAM);
/* Random Utilities *****************************************************/ /* Random Utilities *****************************************************/
#ifdef NDEBUG #ifndef NDEBUG
static inline void static inline void
TREEVIEW_VerifyTree(TREEVIEW_INFO *infoPtr) TREEVIEW_VerifyTree(TREEVIEW_INFO *infoPtr)
{ {
...@@ -1150,6 +1149,7 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam) ...@@ -1150,6 +1149,7 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
if (parentItem == infoPtr->root || if (parentItem == infoPtr->root ||
(ISVISIBLE(parentItem) && parentItem->state & TVIS_EXPANDED)) (ISVISIBLE(parentItem) && parentItem->state & TVIS_EXPANDED))
{ {
TREEVIEW_ITEM *item;
TREEVIEW_ITEM *prev = TREEVIEW_GetPrevListItem(infoPtr, newItem); TREEVIEW_ITEM *prev = TREEVIEW_GetPrevListItem(infoPtr, newItem);
TREEVIEW_RecalculateVisibleOrder(infoPtr, prev); TREEVIEW_RecalculateVisibleOrder(infoPtr, prev);
...@@ -1160,7 +1160,14 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam) ...@@ -1160,7 +1160,14 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
TREEVIEW_ComputeTextWidth(infoPtr, newItem, 0); TREEVIEW_ComputeTextWidth(infoPtr, newItem, 0);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); /*
* if the item was inserted in a visible part of the tree,
* invalidate it, as well as those after it
*/
for (item = newItem;
item != NULL;
item = TREEVIEW_GetNextListItem(infoPtr, item))
TREEVIEW_Invalidate(infoPtr, item);
} }
else else
{ {
...@@ -1170,7 +1177,7 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam) ...@@ -1170,7 +1177,7 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
if (ISVISIBLE(parentItem) && newItem->prevSibling == newItem->nextSibling) if (ISVISIBLE(parentItem) && newItem->prevSibling == newItem->nextSibling)
{ {
/* parent got '+' - update it */ /* parent got '+' - update it */
TREEVIEW_QueueItemRefresh(infoPtr, parentItem); TREEVIEW_Invalidate(infoPtr, parentItem);
} }
} }
...@@ -1396,12 +1403,12 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem) ...@@ -1396,12 +1403,12 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem)
TREEVIEW_RecalculateVisibleOrder(infoPtr, prev); TREEVIEW_RecalculateVisibleOrder(infoPtr, prev);
TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE); TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
} }
else if (ISVISIBLE(parent) && !TREEVIEW_HasChildren(infoPtr, parent)) else if (ISVISIBLE(parent) && !TREEVIEW_HasChildren(infoPtr, parent))
{ {
/* parent lost '+/-' - update it */ /* parent lost '+/-' - update it */
TREEVIEW_QueueItemRefresh(infoPtr, parent); TREEVIEW_Invalidate(infoPtr, parent);
} }
return TRUE; return TRUE;
...@@ -1440,7 +1447,7 @@ TREEVIEW_SetIndent(TREEVIEW_INFO *infoPtr, UINT newIndent) ...@@ -1440,7 +1447,7 @@ TREEVIEW_SetIndent(TREEVIEW_INFO *infoPtr, UINT newIndent)
infoPtr->uIndent = newIndent; infoPtr->uIndent = newIndent;
TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root); TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
} }
return 0; return 0;
...@@ -1552,7 +1559,7 @@ TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam, HIMAGELIST himlNew) ...@@ -1552,7 +1559,7 @@ TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam, HIMAGELIST himlNew)
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
} }
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return (LRESULT)himlOld; return (LRESULT)himlOld;
} }
...@@ -1600,7 +1607,7 @@ TREEVIEW_SetItemHeight(TREEVIEW_INFO *infoPtr, INT newHeight) ...@@ -1600,7 +1607,7 @@ TREEVIEW_SetItemHeight(TREEVIEW_INFO *infoPtr, INT newHeight)
{ {
TREEVIEW_RecalculateVisibleOrder(infoPtr, NULL); TREEVIEW_RecalculateVisibleOrder(infoPtr, NULL);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
} }
return prevHeight; return prevHeight;
...@@ -1656,7 +1663,7 @@ TREEVIEW_SetFont(TREEVIEW_INFO *infoPtr, HFONT hFont, BOOL bRedraw) ...@@ -1656,7 +1663,7 @@ TREEVIEW_SetFont(TREEVIEW_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
if (bRedraw) if (bRedraw)
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return 0; return 0;
} }
...@@ -1696,7 +1703,7 @@ TREEVIEW_SetTextColor(TREEVIEW_INFO *infoPtr, COLORREF color) ...@@ -1696,7 +1703,7 @@ TREEVIEW_SetTextColor(TREEVIEW_INFO *infoPtr, COLORREF color)
infoPtr->clrText = color; infoPtr->clrText = color;
if (infoPtr->clrText != prevColor) if (infoPtr->clrText != prevColor)
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return (LRESULT)prevColor; return (LRESULT)prevColor;
} }
...@@ -1718,7 +1725,7 @@ TREEVIEW_SetBkColor(TREEVIEW_INFO *infoPtr, COLORREF newColor) ...@@ -1718,7 +1725,7 @@ TREEVIEW_SetBkColor(TREEVIEW_INFO *infoPtr, COLORREF newColor)
infoPtr->clrBk = newColor; infoPtr->clrBk = newColor;
if (newColor != prevColor) if (newColor != prevColor)
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return (LRESULT)prevColor; return (LRESULT)prevColor;
} }
...@@ -1754,7 +1761,7 @@ TREEVIEW_SetInsertMark(TREEVIEW_INFO *infoPtr, BOOL wParam, HTREEITEM item) ...@@ -1754,7 +1761,7 @@ TREEVIEW_SetInsertMark(TREEVIEW_INFO *infoPtr, BOOL wParam, HTREEITEM item)
infoPtr->insertBeforeorAfter = wParam; infoPtr->insertBeforeorAfter = wParam;
infoPtr->insertMarkItem = item; infoPtr->insertMarkItem = item;
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return 1; return 1;
} }
...@@ -1901,12 +1908,12 @@ TREEVIEW_SetItemA(TREEVIEW_INFO *infoPtr, LPTVITEMEXA tvItem) ...@@ -1901,12 +1908,12 @@ TREEVIEW_SetItemA(TREEVIEW_INFO *infoPtr, LPTVITEMEXA tvItem)
TREEVIEW_RecalculateVisibleOrder(infoPtr, wineItem); TREEVIEW_RecalculateVisibleOrder(infoPtr, wineItem);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
} }
else else
{ {
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueItemRefresh(infoPtr, wineItem); TREEVIEW_Invalidate(infoPtr, wineItem);
} }
} }
} }
...@@ -2079,7 +2086,7 @@ TREEVIEW_ToggleItemState(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item) ...@@ -2079,7 +2086,7 @@ TREEVIEW_ToggleItemState(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
item->state |= INDEXTOSTATEIMAGEMASK(state); item->state |= INDEXTOSTATEIMAGEMASK(state);
TRACE("state:%x\n", state); TRACE("state:%x\n", state);
TREEVIEW_QueueItemRefresh(infoPtr, item); TREEVIEW_Invalidate(infoPtr, item);
} }
} }
...@@ -2598,19 +2605,12 @@ TREEVIEW_Refresh(TREEVIEW_INFO *infoPtr, HDC hdc, RECT *rc) ...@@ -2598,19 +2605,12 @@ TREEVIEW_Refresh(TREEVIEW_INFO *infoPtr, HDC hdc, RECT *rc)
} }
static void static void
TREEVIEW_QueueRefresh(TREEVIEW_INFO *infoPtr) TREEVIEW_Invalidate(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
{
InvalidateRect(infoPtr->hwnd, NULL, TRUE);
}
/* It be that item->rect is out of date. If so, we invalidate the wrong area,
* but then whoever updates item->rect knows that they must invalidate after
* correcting it. */
static void
TREEVIEW_QueueItemRefresh(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
{ {
if (item != NULL) if (item != NULL)
InvalidateRect(infoPtr->hwnd, &item->rect, TRUE); InvalidateRect(infoPtr->hwnd, &item->rect, TRUE);
else
InvalidateRect(infoPtr->hwnd, NULL, TRUE);
} }
static LRESULT static LRESULT
...@@ -2820,7 +2820,7 @@ TREEVIEW_Sort(TREEVIEW_INFO *infoPtr, BOOL fRecurse, HTREEITEM parent, ...@@ -2820,7 +2820,7 @@ TREEVIEW_Sort(TREEVIEW_INFO *infoPtr, BOOL fRecurse, HTREEITEM parent,
TREEVIEW_SetFirstVisible(infoPtr, item, FALSE); TREEVIEW_SetFirstVisible(infoPtr, item, FALSE);
} }
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
} }
return TRUE; return TRUE;
...@@ -2938,7 +2938,7 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, ...@@ -2938,7 +2938,7 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
} }
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return TRUE; return TRUE;
} }
...@@ -3012,7 +3012,7 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, ...@@ -3012,7 +3012,7 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
} }
} }
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return TRUE; return TRUE;
} }
...@@ -3942,8 +3942,8 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect, ...@@ -3942,8 +3942,8 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect,
TVIF_HANDLE | TVIF_STATE | TVIF_PARAM, TVIF_HANDLE | TVIF_STATE | TVIF_PARAM,
prevSelect, prevSelect,
newSelect); newSelect);
TREEVIEW_QueueItemRefresh(infoPtr, prevSelect); TREEVIEW_Invalidate(infoPtr, prevSelect);
TREEVIEW_QueueItemRefresh(infoPtr, newSelect); TREEVIEW_Invalidate(infoPtr, newSelect);
break; break;
case TVGN_DROPHILITE: case TVGN_DROPHILITE:
...@@ -3957,14 +3957,14 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect, ...@@ -3957,14 +3957,14 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect,
if (newSelect) if (newSelect)
newSelect->state |= TVIS_DROPHILITED; newSelect->state |= TVIS_DROPHILITED;
TREEVIEW_QueueItemRefresh(infoPtr, prevSelect); TREEVIEW_Invalidate(infoPtr, prevSelect);
TREEVIEW_QueueItemRefresh(infoPtr, newSelect); TREEVIEW_Invalidate(infoPtr, newSelect);
break; break;
case TVGN_FIRSTVISIBLE: case TVGN_FIRSTVISIBLE:
TREEVIEW_EnsureVisible(infoPtr, newSelect, FALSE); TREEVIEW_EnsureVisible(infoPtr, newSelect, FALSE);
TREEVIEW_SetFirstVisible(infoPtr, newSelect, TRUE); TREEVIEW_SetFirstVisible(infoPtr, newSelect, TRUE);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
break; break;
} }
...@@ -4112,7 +4112,7 @@ TREEVIEW_SetFirstVisible(TREEVIEW_INFO *infoPtr, ...@@ -4112,7 +4112,7 @@ TREEVIEW_SetFirstVisible(TREEVIEW_INFO *infoPtr,
if (infoPtr->firstVisible == NULL || newFirstVisible == NULL) if (infoPtr->firstVisible == NULL || newFirstVisible == NULL)
{ {
infoPtr->firstVisible = newFirstVisible; infoPtr->firstVisible = newFirstVisible;
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
} }
else else
{ {
...@@ -4661,7 +4661,7 @@ TREEVIEW_Size(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -4661,7 +4661,7 @@ TREEVIEW_Size(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
FIXME("WM_SIZE flag %x %lx not handled\n", wParam, lParam); FIXME("WM_SIZE flag %x %lx not handled\n", wParam, lParam);
} }
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return 0; return 0;
} }
...@@ -4694,7 +4694,7 @@ TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -4694,7 +4694,7 @@ TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root); TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root);
TREEVIEW_UpdateScrollBars(infoPtr); TREEVIEW_UpdateScrollBars(infoPtr);
TREEVIEW_QueueRefresh(infoPtr); TREEVIEW_Invalidate(infoPtr, NULL);
return 0; return 0;
} }
...@@ -4711,7 +4711,7 @@ TREEVIEW_SetFocus(TREEVIEW_INFO *infoPtr) ...@@ -4711,7 +4711,7 @@ TREEVIEW_SetFocus(TREEVIEW_INFO *infoPtr)
} }
TREEVIEW_SendSimpleNotify(infoPtr, NM_SETFOCUS); TREEVIEW_SendSimpleNotify(infoPtr, NM_SETFOCUS);
TREEVIEW_QueueItemRefresh(infoPtr, infoPtr->selectedItem); TREEVIEW_Invalidate(infoPtr, infoPtr->selectedItem);
return 0; return 0;
} }
...@@ -4721,7 +4721,7 @@ TREEVIEW_KillFocus(TREEVIEW_INFO *infoPtr) ...@@ -4721,7 +4721,7 @@ TREEVIEW_KillFocus(TREEVIEW_INFO *infoPtr)
TRACE("\n"); TRACE("\n");
TREEVIEW_SendSimpleNotify(infoPtr, NM_KILLFOCUS); TREEVIEW_SendSimpleNotify(infoPtr, NM_KILLFOCUS);
TREEVIEW_QueueItemRefresh(infoPtr, infoPtr->selectedItem); TREEVIEW_Invalidate(infoPtr, infoPtr->selectedItem);
return 0; return 0;
} }
...@@ -5014,7 +5014,7 @@ TREEVIEW_Unregister(void) ...@@ -5014,7 +5014,7 @@ TREEVIEW_Unregister(void)
/* Tree Verification ****************************************************/ /* Tree Verification ****************************************************/
#ifndef NDEBUG #ifdef NDEBUG
static inline void static inline void
TREEVIEW_VerifyChildren(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item); TREEVIEW_VerifyChildren(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item);
......
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