RESEND: dlls/comctl32/treeview.c: remove repainting

yuxdwa702 at sneakemail.com yuxdwa702 at sneakemail.com
Thu Feb 10 11:08:17 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 -u -p -r1.164 treeview.c
--- dlls/comctl32/treeview.c	14 Jan 2005 15:13:24 -0000	1.164
+++ dlls/comctl32/treeview.c	31 Jan 2005 01:51:30 -0000
@@ -631,7 +631,8 @@ TREEVIEW_SendCustomDrawItemNotify(TREEVI
  	uItemState |= CDIS_SELECTED;
      if (wineItem == infoPtr->selectedItem)
  	uItemState |= CDIS_FOCUS;
-    if (wineItem == infoPtr->hotItem)
+    /* I'm not sure of this, needs to be compared to the real thing */
+    if ((infoPtr->dwStyle & TVS_TRACKSELECT) && wineItem == infoPtr->hotItem)
  	uItemState |= CDIS_HOT;

      nmcd = &nmcdhdr.nmcd;
@@ -2386,7 +2387,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; perhaps needs to test for LPSTR_TEXTCALLBACK */
+    if (!wineItem->textWidth)
+        TREEVIEW_ComputeTextWidth(infoPtr, wineItem, hdc);

      cditem = 0;

@@ -3084,6 +3087,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 +3113,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 +3151,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 +3161,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 +3192,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 +3250,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 +3298,6 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr,
  	}
      }

-    TREEVIEW_Invalidate(infoPtr, NULL);
-
      return TRUE;
  }

@@ -5037,11 +5107,13 @@ TREEVIEW_KeyDown(TREEVIEW_INFO *infoPtr,
  static LRESULT
  TREEVIEW_MouseLeave (TREEVIEW_INFO * infoPtr)
  {
-    if (infoPtr->hotItem)
+    HTREEITEM orgItem = infoPtr->hotItem;
+    infoPtr->hotItem = NULL;
+
+    /* remove hot effect from item */
+    if (infoPtr->dwStyle & TVS_TRACKSELECT)
      {
-        /* remove hot effect from item */
-        InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE);
-        infoPtr->hotItem = NULL;
+        InvalidateRect(infoPtr->hwnd, &orgItem->rect, TRUE);
      }
      return 0;
  }
@@ -5080,11 +5152,11 @@ TREEVIEW_MouseMove (TREEVIEW_INFO * info
      if (item != infoPtr->hotItem)
      {
          /* redraw old hot item */
-        if (infoPtr->hotItem)
+        if (infoPtr->hotItem && (infoPtr->dwStyle & TVS_TRACKSELECT) )
              InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE);
          infoPtr->hotItem = item;
          /* redraw new hot item */
-        if (infoPtr->hotItem)
+        if (infoPtr->hotItem && (infoPtr->dwStyle & TVS_TRACKSELECT) )
              InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE);
      }






More information about the wine-patches mailing list