dlls/comctl32/treeview.c: remove repainting, try 2
yuxdwa702 at sneakemail.com
yuxdwa702 at sneakemail.com
Thu Feb 10 17:26:04 CST 2005
Changelog:
tinus <yuxdwa702 at sneakemail.com>
Scroll instead of repainting when expanding/collapsing trees
Don't repaint on hover if 'hot tracking' isn't on
Index: dlls/comctl32/treeview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/treeview.c,v
retrieving revision 1.164
diff -p -u -r1.164 treeview.c
--- dlls/comctl32/treeview.c 14 Jan 2005 15:13:24 -0000 1.164
+++ dlls/comctl32/treeview.c 10 Feb 2005 22:10:31 -0000
@@ -2386,7 +2386,9 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr
/* The custom draw handler can query the text rectangle,
* so get ready. */
- TREEVIEW_ComputeTextWidth(infoPtr, wineItem, hdc);
+ /* should already be known, set to 0 when changed */
+ if (!wineItem->textWidth)
+ TREEVIEW_ComputeTextWidth(infoPtr, wineItem, hdc);
cditem = 0;
@@ -3084,6 +3086,9 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr
{
UINT action = TVE_COLLAPSE | (bRemoveChildren ? TVE_COLLAPSERESET : 0);
BOOL bSetSelection, bSetFirstVisible;
+ RECT scrollRect;
+ LONG scrollDist;
+ TREEVIEW_ITEM *nextItem = NULL, *tmpItem;
TRACE("TVE_COLLAPSE %p %s\n", wineItem, TREEVIEW_ItemName(wineItem));
@@ -3107,6 +3112,20 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr
bSetFirstVisible = (infoPtr->firstVisible != NULL
&& TREEVIEW_IsChildOf(wineItem, infoPtr->firstVisible));
+ tmpItem = wineItem;
+ while (tmpItem)
+ {
+ if (tmpItem->nextSibling)
+ {
+ nextItem = tmpItem->nextSibling;
+ break;
+ }
+ tmpItem = tmpItem->parent;
+ }
+
+ if (nextItem)
+ scrollDist = nextItem->rect.top;
+
if (bRemoveChildren)
{
INT old_cChildren = wineItem->cChildren;
@@ -3131,8 +3150,8 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr
TREEVIEW_RecalculateVisibleOrder(infoPtr, wineItem);
- TREEVIEW_SetFirstVisible(infoPtr, bSetFirstVisible ? wineItem
- : infoPtr->firstVisible, TRUE);
+ if (nextItem)
+ scrollDist = -(scrollDist - nextItem->rect.top);
if (bSetSelection)
{
@@ -3141,12 +3160,29 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr
infoPtr->selectedItem->state &= ~TVIS_SELECTED;
wineItem->state |= TVIS_SELECTED;
infoPtr->selectedItem = wineItem;
-
- TREEVIEW_EnsureVisible(infoPtr, wineItem, FALSE);
}
TREEVIEW_UpdateScrollBars(infoPtr);
- TREEVIEW_Invalidate(infoPtr, NULL);
+
+ scrollRect.left = 0;
+ scrollRect.right = infoPtr->clientWidth;
+ scrollRect.bottom = infoPtr->clientHeight;
+
+ if (nextItem)
+ {
+ scrollRect.top = nextItem->rect.top;
+
+ ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL,
+ NULL, NULL, SW_ERASE | SW_INVALIDATE);
+ TREEVIEW_Invalidate(infoPtr, wineItem);
+ } else {
+ scrollRect.top = wineItem->rect.top;
+ InvalidateRect(infoPtr->hwnd, &scrollRect, TRUE);
+ }
+
+ TREEVIEW_SetFirstVisible(infoPtr,
+ bSetFirstVisible ? wineItem : infoPtr->firstVisible,
+ TRUE);
return TRUE;
}
@@ -3155,11 +3191,30 @@ static BOOL
TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
BOOL bExpandPartial, BOOL bUser)
{
+ LONG scrollDist;
+ LONG orgNextTop;
+ RECT scrollRect;
+ TREEVIEW_ITEM *nextItem, *tmpItem;
+
TRACE("\n");
if (wineItem->state & TVIS_EXPANDED)
return TRUE;
+ tmpItem = wineItem; nextItem = NULL;
+ while (tmpItem)
+ {
+ if (tmpItem->nextSibling)
+ {
+ nextItem = tmpItem->nextSibling;
+ break;
+ }
+ tmpItem = tmpItem->parent;
+ }
+
+ if (nextItem)
+ orgNextTop = nextItem->rect.top;
+
TRACE("TVE_EXPAND %p %s\n", wineItem, TREEVIEW_ItemName(wineItem));
if (bUser || ((wineItem->cChildren != 0) &&
@@ -3194,6 +3249,22 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr,
TREEVIEW_UpdateSubTree(infoPtr, wineItem);
TREEVIEW_UpdateScrollBars(infoPtr);
+ scrollRect.left = 0;
+ scrollRect.bottom = infoPtr->treeHeight;
+ scrollRect.right = infoPtr->clientWidth;
+ if (nextItem)
+ {
+ scrollDist = nextItem->rect.top - orgNextTop;
+ scrollRect.top = orgNextTop;
+
+ ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL,
+ NULL, NULL, SW_ERASE | SW_INVALIDATE);
+ TREEVIEW_Invalidate (infoPtr, wineItem);
+ } else {
+ scrollRect.top = wineItem->rect.top;
+ InvalidateRect(infoPtr->hwnd, &scrollRect, FALSE);
+ }
+
/* Scroll up so that as many children as possible are visible.
* This fails when expanding causes an HScroll bar to appear, but we
* don't know that yet, so the last item is obscured. */
@@ -3226,8 +3297,6 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr,
}
}
- TREEVIEW_Invalidate(infoPtr, NULL);
-
return TRUE;
}
@@ -4735,7 +4804,7 @@ TREEVIEW_Create(HWND hwnd, const CREATES
infoPtr->uIndent = MINIMUM_INDENT;
infoPtr->selectedItem = 0;
infoPtr->focusedItem = 0;
- /* hotItem? */
+ infoPtr->hotItem = 0;
infoPtr->firstVisible = 0;
infoPtr->maxVisibleOrder = 0;
infoPtr->dropItem = 0;
@@ -5435,7 +5504,10 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg
return TREEVIEW_MouseLeave(infoPtr);
case WM_MOUSEMOVE:
- return TREEVIEW_MouseMove(infoPtr, wParam, lParam);
+ if (infoPtr->dwStyle & TVS_TRACKSELECT)
+ return TREEVIEW_MouseMove(infoPtr, wParam, lParam);
+ else
+ return 0;
case WM_NOTIFY:
return TREEVIEW_Notify(infoPtr, wParam, lParam);
More information about the wine-patches
mailing list