summaryrefslogtreecommitdiff
path: root/src/gui/fpg_tree.pas
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/fpg_tree.pas')
-rw-r--r--src/gui/fpg_tree.pas50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/gui/fpg_tree.pas b/src/gui/fpg_tree.pas
index 5f12ea1f..e38b32da 100644
--- a/src/gui/fpg_tree.pas
+++ b/src/gui/fpg_tree.pas
@@ -48,6 +48,8 @@ uses
type
+ TfpgNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);
+
PfpgTreeColumnWidth = ^TfpgTreeColumnWidth;
TfpgTreeColumnWidth = record
next: PfpgTreeColumnWidth;
@@ -107,6 +109,7 @@ type
procedure Collapse;
procedure Expand;
procedure Remove(var aNode: TfpgTreeNode);
+ procedure MoveTo(Destination: TfpgTreeNode; Mode: TfpgNodeAttachMode);
procedure UnregisterSubNode(aNode: TfpgTreeNode);
// parent color settings
function ParentInactSelColor: TfpgColor;
@@ -671,6 +674,53 @@ begin
aNode.parent := nil;
end;
+procedure TfpgTreeNode.MoveTo(Destination: TfpgTreeNode; Mode: TfpgNodeAttachMode);
+begin
+ if Destination = nil then
+ Exit;
+ DoTreeCheck(Destination);
+
+ Parent.Remove(self);
+ case Mode of
+ naAdd:
+ begin
+ Destination.Parent.Append(self);
+ end;
+ naAddFirst:
+ begin
+ Next := Destination.Parent.FirstSubNode;
+ Next.Prev := self;
+ Destination.Parent.FFirstSubNode := self;
+ Parent := Destination.Parent;
+ end;
+ naAddChild:
+ begin
+ Destination.Append(self);
+ end;
+ naAddChildFirst:
+ begin
+ Next := Destination.FirstSubNode;
+ if Assigned(Destination.FirstSubNode) then
+ Destination.FirstSubNode.Prev := self;
+ Destination.FFirstSubNode := self;
+ Parent := Destination;
+ if Destination.LastSubNode = nil then
+ Destination.FLastSubNode := self;
+ end;
+ naInsert:
+ begin
+ Prev := Destination.Prev;
+ Next := Destination;
+ Parent := Destination.Parent;
+ Destination.Prev := self;
+ if Prev = nil then
+ Parent.FFirstSubNode := self
+ else
+ Prev.Next := self;
+ end;
+ end; { case }
+end;
+
procedure TfpgTreeNode.Clear;
var
n: TfpgTreeNode;