Skip to content

Commit 347afae

Browse files
René HoffmannRené Hoffmann
authored andcommitted
add a method to determine the top node of an thereby invisible subtree
- added method 'TBaseVirtualTree.GetTopInvisibleParent' to retrieve the topmost node of an effectively invisible subtree - the resulting node can be invisible by lacking the 'vsVisible'-flag on its own or having its parent lacking the 'vsExpanded' flag - all of its sub-nodes can be considered effectively invisible - all of its ancestor-nodes can be considered to be effectively visible - 'nil' is returned if all nodes from 'Node' up to 'FRoot' are effectively visible
1 parent e2d5373 commit 347afae

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Source/VirtualTrees.pas

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,6 +3138,7 @@ TBaseVirtualTree = class(TCustomControl)
31383138
var Text: string); virtual;
31393139
function GetTreeRect: TRect;
31403140
function GetVisibleParent(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode;
3141+
function GetTopInvisibleParent(Node: PVirtualNode): PVirtualNode;
31413142
function HasAsParent(Node, PotentialParent: PVirtualNode): Boolean;
31423143
function InsertNode(Node: PVirtualNode; Mode: TVTNodeAttachMode; UserData: Pointer = nil): PVirtualNode;
31433144
procedure InvalidateChildren(Node: PVirtualNode; Recursive: Boolean);
@@ -29908,6 +29909,31 @@ function TBaseVirtualTree.GetVisibleParent(Node: PVirtualNode; IncludeFiltered:
2990829909

2990929910
//----------------------------------------------------------------------------------------------------------------------
2991029911

29912+
function TBaseVirtualTree.GetTopInvisibleParent(Node: PVirtualNode): PVirtualNode;
29913+
29914+
// Returns the last (furthest) parent node of Node which is invisible.
29915+
29916+
var
29917+
Run: PVirtualNode;
29918+
29919+
begin
29920+
Assert(Assigned(Node), 'Node must not be nil.');
29921+
Assert(Node <> FRoot, 'Node must not be the hidden root node.');
29922+
29923+
Result := nil;
29924+
29925+
Run := Node.Parent;
29926+
while (Run <> FRoot) do
29927+
begin
29928+
if not ( (vsVisible in Run.States) and (vsExpanded in Run.Parent.States) ) then
29929+
Result := Run;
29930+
Run := Run.Parent;
29931+
end;
29932+
29933+
end;
29934+
29935+
//----------------------------------------------------------------------------------------------------------------------
29936+
2991129937
function TBaseVirtualTree.HasAsParent(Node, PotentialParent: PVirtualNode): Boolean;
2991229938

2991329939
// Determines whether Node has got PotentialParent as one of its parents.

0 commit comments

Comments
 (0)