EZwgl (11.1 Trees)

## 11.1 Trees

Trees are built from the special data structure `EZ_TreeNode`. A tree node is created by the procedure

`EZ_TreeNode *EZ_CreateTreeNode(EZ_TreeNode *parent, EZ_Item *item);`

The tree object is used only in the `Tree` widget.

EZwgl includes commands for manipulating trees as well as special commands for manipulating directory trees.

### 11.1.1 Interface Routines

`EZ_TreeNode *EZ_TreeNodeGetParent(EZ_TreeNode *node);`

return the parent node.

`EZ_TreeNode *EZ_TreeNodeGetChildren(EZ_TreeNode *node);`

return the first child.

`EZ_TreeNode *EZ_TreeNodeGetSibling(EZ_TreeNode *node);`

return the sibling node.

`EZ_TreeNode *EZ_TreeFindNode(EZ_TreeNode *root, EZ_TreeNode *node);`

find a node in a tree.

`EZ_TreeNode *EZ_TreeFindNodeUsingItem(EZ_TreeNode *root, EZ_Item *item);`

find a node using display item as the search key.

    EZ_TreeNode  *EZ_TreeFindNodeUsingProcedure(EZ_TreeNode *root,
    	 EZ_TreeNode *(*f)(EZ_TreeNode *node, void *data), void *cdata );

search for a tree node using the specified procedure.

`void EZ_TreeDestroySubtree(EZ_TreeNode *node);`

destruct a subtree.

`void EZ_TreeDestroyNodeDescendants(EZ_TreeNode *node);`

destroy all descendants of a tree node.

`void EZ_TreeAttachSubtree(EZ_TreeNode *node, EZ_TreeNode *subtree);`

append a subtree to a tree node.

`void EZ_TreeDetachSubtree(EZ_TreeNode *node);`

detach a node and its descendants from a tree.

    void EZ_TreeSetCharacter(EZ_TreeNode *node,
    	 int type, int indent, int spacing, int drawBranch);

set the display characteristics for a tree.

    void EZ_TreeTraverseTree(EZ_TreeNode *node,
            void (*preF)(EZ_TreeNode *node)),
            void (*postF)(EZ_TreeNode *node) );

traverse a tree and execute the supplied procedures on each node.

`void EZ_TreeSetFGColor(EZ_TreeNode *node, unsigned long pv);`

`void EZ_TreeSetFGColorName (EZ_TreeNode *node, char *name);`

set the foreground color for all nodes.

`void EZ_TreeSetBGColor(EZ_TreeNode *node, unsigned long pv);`

`void EZ_TreeSetBGColorName(EZ_TreeNode *node, char *name);`

set the background color for all nodes.

`void EZ_ComputeSubtreeSize(EZ_TreeNode *node, int *w, int *h, int *parity);`

compute the minimal rectangle needed to hold a subtree.

    void EZ_DisplayTreeInDrawable(EZ_Widget *widget, Drawable drawable,
              int x0, int y0, EZ_TreeNode *node,
              int Rx, int Ry, int Rw, int Rh);

display a subtree.

`EZ_Item *EZ_TreeNodeGetItem(EZ_TreeNode *node);`

return the item assigned to a tree node.

HTML Documentation Maintainance:`Arturo Espinosa <arturo@nuclecu.unam.mx>`