lcl: skip not expanded nodes when we count max right (bug #0012799)

git-svn-id: trunk@18191 -
This commit is contained in:
paul 2009-01-07 16:00:53 +00:00
parent 12e937579c
commit e163b4a2dc

View File

@ -3105,7 +3105,8 @@ begin
end;
procedure TCustomTreeView.UpdateMaxRight;
var Node: TTreeNode;
var
Node: TTreeNode;
i: integer;
FMaxTextLen: Integer;
Cnt: Integer;
@ -3115,22 +3116,32 @@ begin
FMaxTextLen := 0;
Node := Items.GetFirstNode;
Cnt := 0;
while Node<>nil do begin
while Node <> nil do
begin
if not Node.AreParentsExpanded then
begin
Node := Node.GetNext;
Continue;
end;
inc(Cnt);
if (Cnt<100) then begin
if (Cnt < 100) then
begin
i := Node.DisplayTextRight;
end else begin
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
else
if length(Node.Text) > FMaxTextLen then
i := Node.DisplayTextRight + 100
else
i := FMaxRight;
end;
if FMaxRight<i then begin
if FMaxRight < i then
begin
FMaxRight := i;
FMaxTextLen := length(Node.Text);
end;