mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 03:19:17 +02:00
lcl: skip not expanded nodes when we count max right (bug #0012799)
git-svn-id: trunk@18191 -
This commit is contained in:
parent
12e937579c
commit
e163b4a2dc
@ -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<i then begin
|
||||
FMaxRight:=i;
|
||||
FMaxTextLen:=length(Node.Text);
|
||||
if FMaxRight < i then
|
||||
begin
|
||||
FMaxRight := i;
|
||||
FMaxTextLen := length(Node.Text);
|
||||
end;
|
||||
Node:=Node.GetNext;
|
||||
Node := Node.GetNext;
|
||||
end;
|
||||
Exclude(FStates,tvsMaxRightNeedsUpdate);
|
||||
Include(FStates,tvsScrollbarChanged);
|
||||
Exclude(FStates, tvsMaxRightNeedsUpdate);
|
||||
Include(FStates, tvsScrollbarChanged);
|
||||
end;
|
||||
|
||||
procedure TCustomTreeView.UpdateTopItem;
|
||||
|
Loading…
Reference in New Issue
Block a user