InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TreeNodeTraverser Class Reference

#include <TreeNodeTraverser.h>

Public Types

enum  Direction { eForward, eReverse }
 

Public Member Functions

 TreeNodeTraverser (const NodeID &from, const ITreeViewMgr *treeMgr, bool16 expandedNodesOnly, Direction direction=eForward)
 
virtual ~TreeNodeTraverser ()
 
virtual NodeID Next ()
 
virtual bool16 Completed () const
 

Detailed Description

TreeNodeTraverser is a class that helps a client walk thru the tree hierarchy of a TreeView Widget.

It uses the ITreeViewHierarchyAdapter on the kTreeViewWidgetBoss to traverse the tree from a given

node in the tree.  You choose a node in the tree and then can go from that node to the next node

in the tree, either going up or down the tree hierarchy.  You can also decide whether to go into unexpanded

nodes or to just visit the "visible" nodes.



An example usage is shown below...


    TreeNodeTraverser   traverse(startNode, treeMgr, kTrue, TreeNodeTraverser::eForward );

    NodeID  next;

    while (!traverse.Completed())

    {

        next = traverse.Next();
        // Do your stuff here

    }

Constructor & Destructor Documentation

TreeNodeTraverser::TreeNodeTraverser (const NodeIDfrom,
const ITreeViewMgrtreeMgr,
bool16 expandedNodesOnly,
Direction direction = eForward 
)

Create a TreeNodeTraverser for traversing the nodes in the specified tree

Parameters
fromwhich node in th etree you would like to start your traversal from. You can start from any node in the tree
treeMgrthe ITreeViewMgr interface of the TreeView widget you are traversing
expandedNodesOnlyif kTrue, only visible nodes are returned. if kFalse, all nodes in the tree are returned, even those not visible because their parent is closed
directioneForward will go forward(or down) the tree hierarchy. eReverse will go backwards(or up) the hierarchy
virtual TreeNodeTraverser::~TreeNodeTraverser ()
virtual

Destructor. Nothing special to note

Member Function Documentation

virtual bool16 TreeNodeTraverser::Completed () const
virtual

Determine whether or not the traversal has reached the last node in the tree. For a reverse traversal, last node would be the root node. This is typically used in a loop, for example...

while (!traverse.Completed()) { // your code here }

Returns
kTrue if traversal has completed, kFalse if there are mmore nodes to traverse
virtual NodeID TreeNodeTraverser::Next ()
virtual

Move to the next node in the tree. Calling this the first time will move from the start node to the next node above or below the start node. i.e. If you had a root element called 'Root' and 3 child elements, 'A', 'B', and 'C' and you were starting with 'A', calling Next() would return 'B' if going forward and it would return 'Root' if going backward.

Returns
NodeID of the next node