![]() | InDesign SDK 20.5 |
#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 |
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
}
| TreeNodeTraverser::TreeNodeTraverser | ( | const NodeID & | from, |
| const ITreeViewMgr * | treeMgr, | ||
| bool16 | expandedNodesOnly, | ||
| Direction | direction = eForward | ||
| ) |
Create a TreeNodeTraverser for traversing the nodes in the specified tree
| from | which node in th etree you would like to start your traversal from. You can start from any node in the tree |
| treeMgr | the ITreeViewMgr interface of the TreeView widget you are traversing |
| expandedNodesOnly | if kTrue, only visible nodes are returned. if kFalse, all nodes in the tree are returned, even those not visible because their parent is closed |
| direction | eForward will go forward(or down) the tree hierarchy. eReverse will go backwards(or up) the hierarchy |
| virtual |
Destructor. Nothing special to note
| 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 }
| 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.