summaryrefslogtreecommitdiff
path: root/src/gui/fpg_tree.pas
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-21 10:24:08 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2009-10-21 10:24:08 +0200
commit99d341cd8b6ac2357a63f92cd115101c88722d43 (patch)
treec8b8a9b1e253ff1bdf486e980ee5e6b6409439a0 /src/gui/fpg_tree.pas
parent2c5b8e5babfd70919b1ea636c23d1a790b1df0e6 (diff)
downloadfpGUI-99d341cd8b6ac2357a63f92cd115101c88722d43.tar.xz
Treeview can now do a FindSubNode using the Node.Data property.
Signed-off-by: Graeme Geldenhuys <graeme@mastermaths.co.za>
Diffstat (limited to 'src/gui/fpg_tree.pas')
-rw-r--r--src/gui/fpg_tree.pas40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gui/fpg_tree.pas b/src/gui/fpg_tree.pas
index 351c9050..da3e2ddf 100644
--- a/src/gui/fpg_tree.pas
+++ b/src/gui/fpg_tree.pas
@@ -96,6 +96,7 @@ type
function CountRecursive: integer;
function FindSubNode(AText: string; ARecursive: Boolean): TfpgTreeNode; overload;
function FindSubNode(ATreeNodeFindMethod: TfpgTreeNodeFindMethod): TfpgTreeNode; overload;
+ function FindSubNode(AData: TObject; ARecursive: Boolean): TfpgTreeNode; overload;
function GetMaxDepth: integer;
function GetMaxVisibleDepth: integer;
procedure Append(var aValue: TfpgTreeNode);
@@ -479,6 +480,45 @@ begin
end;
end;
+function TfpgTreeNode.FindSubNode(AData: TObject; ARecursive: Boolean): TfpgTreeNode;
+var
+ h: TfpgTreeNode;
+begin
+ result := nil;
+ if ARecursive then
+ begin
+ h := FirstSubNode;
+ while h <> nil do
+ begin
+ if TObject(h.Data) = AData then
+ begin
+ result := h;
+ Exit; //==>
+ end;
+ if h.count > 0 then
+ begin
+ result := h.FindSubNode(AData, ARecursive);
+ if result <> nil then
+ Exit; //==>
+ end;
+ h := h.next;
+ end; { while }
+ end
+ else
+ begin
+ h := FirstSubNode;
+ while h <> nil do
+ begin
+ if TObject(h.Data) = AData then
+ begin
+ result := h;
+ break;
+ end;
+ h := h.next;
+ end;
+ end; { if/else }
+end;
+
function TfpgTreeNode.AppendText(AText: TfpgString): TfpgTreeNode;
var
h: TfpgTreeNode;