[gtkada] Ctree Collapse-Expand and resultant node list - & Tr averse Nodes

Wells, Larisa lwells at dcscorp.com
Wed Mar 21 20:00:40 CET 2001


Thank you for your help, Emmanuel.  I was not able to use your example
directly, as the Get_Sibling will only traverse one level and I have many.
But I was able to use your idea to create a new set of utilities that I have
included.  The package contains the following:

   function Get_First_Node (Ctree : Gtk.Ctree.Gtk_Ctree) 
      return Gtk.Ctree.Gtk_Ctree_Node;
   --  Returns the first node of the tree.  Using Get_Next_Node, each
   --  node of the tree can be traversed.

   function Get_Next_Node (Ctree : Gtk.Ctree.Gtk_Ctree;
                           Node  : Gtk.Ctree.Gtk_Ctree_Node) 
      return Gtk.Ctree.Gtk_Ctree_Node;
   --  Retrieves the node following the provided node in the tree.
   --  The pattern first traverses down a branch (to children), 
   --  then continues laterally (to siblings) where available. When
   --  the tree traversal is complete, Null_Ctree_Node is returned.

Then it can be used similarly to your suggestion:

  declare
     Node : Gtk_Ctree_Node;
  begin
     Node := Get_First_Node (Tree);
     while Node /= null loop
           ...;
           Node := Get_Next_Node (Ctree, Node);
     end loop;
  end;

By the way, I am very impressed with GVD.

-Larisa

-----Original Message-----
From: Emmanuel Briot [mailto:briot at act-europe.fr]
Sent: Wednesday, March 21, 2001 4:14 AM
To: gtkada at gtkada.eu.org
Subject: RE: [gtkada] Ctree Collapse-Expand and resultant node list


 > After filling the tree, I assembled a node list using my own list
utility.
 > I then used this list, instead of the query Gtk.Ctree.Get_Node_List, when
 > attempting to determine if each node is viewable.  So the fact that the
 > Gtk.Ctree.Node_List was dropping nodes, did not mean that the nodes
 > themselves were corrupt.


Larisa,

What we use in GVD (Gnu Visual Debugger) is:

  declare
     Nodes : Row_List.Glist := Get_Row_List (Tree);  --  not Get_Node_List
     Node : Gtk_Ctree_Node;
  begin
     Node := Find_Node_Ptr (Tree, Row_List.Get_Data (Nodes));
     while Node /= null loop
           ...;
           Node := Row_Get_Sibling (Node_Get_Row (Node));
     end loop;
  end;


Let us know if this works for you, and we'll add it to the documentation.

 > The second problem is still a strange one.  Replacing the use of
 > Gtk.Ctree.Is_Viewable with the following seems to work:

We don't have this problem in GVD, and we only use a direct call to
Is_Viewable.

  if not Is_Viewable (Tree, Node) then
      Expand (Tree, Row_Get_Parent (Node_Get_Row (Node)));
  end if;

 > That wouldn't be all so bad, except that the first time the tree is shown
 > (expanded), the Gtk.Ctree.Is_Viewable (rightly) returns true for all
 > nodes,instead of a reversal of logic for child nodes.  So I had to add a
 > "first time" attribute to check (and I must always initialize with the
tree
 > expanded -- no problem for me, but a limitation).

Again, we do not have this problem, but then we always create the tree not
expanded at first, and it is automatically expanded by the above code when a
node needs to be shown.
This might explain the difference we see, but somehow I doubt it :-)

Emmanuel

_______________________________________________
gtkada mailing list
gtkada at gtkada.eu.org
http://gtkada.eu.org/mailman/listinfo/gtkada

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gtk-ctree-traverse.adb
Type: application/octet-stream
Size: 2446 bytes
Desc: not available
Url : /pipermail/gtkada/attachments/20010321/84e60981/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gtk-ctree-traverse.ads
Type: application/octet-stream
Size: 960 bytes
Desc: not available
Url : /pipermail/gtkada/attachments/20010321/84e60981/attachment-0001.obj 


More information about the gtkada mailing list