From e163b4a2dc94539d0cfb81f63568a96da3e238c0 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 7 Jan 2009 16:00:53 +0000 Subject: [PATCH] lcl: skip not expanded nodes when we count max right (bug #0012799) git-svn-id: trunk@18191 - --- lcl/include/treeview.inc | 51 ++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/lcl/include/treeview.inc b/lcl/include/treeview.inc index 7c6c51e861..51de205ffc 100644 --- a/lcl/include/treeview.inc +++ b/lcl/include/treeview.inc @@ -3105,39 +3105,50 @@ begin end; procedure TCustomTreeView.UpdateMaxRight; -var Node: TTreeNode; +var + Node: TTreeNode; i: integer; FMaxTextLen: Integer; Cnt: Integer; begin if not (tvsMaxRightNeedsUpdate in FStates) then exit; - FMaxRight:=0; - FMaxTextLen:=0; - Node:=Items.GetFirstNode; - Cnt:=0; - while Node<>nil do begin + FMaxRight := 0; + FMaxTextLen := 0; + Node := Items.GetFirstNode; + Cnt := 0; + while Node <> nil do + begin + if not Node.AreParentsExpanded then + begin + Node := Node.GetNext; + Continue; + end; inc(Cnt); - if (Cnt<100) then begin - i:=Node.DisplayTextRight; - end else begin + if (Cnt < 100) then + begin + i := Node.DisplayTextRight; + end else + begin // computing DisplayTextRight is too expensive when the tree // has hundreds of nodes // => use a heuristic - if Cnt=100 then - i:=Node.DisplayTextRight+100 - else if length(Node.Text)>FMaxTextLen then - i:=Node.DisplayTextRight+100 + if Cnt = 100 then + i := Node.DisplayTextRight + 100 else - i:=FMaxRight; + if length(Node.Text) > FMaxTextLen then + i := Node.DisplayTextRight + 100 + else + i := FMaxRight; end; - if FMaxRight