class Fl_Tree


Class Hierarchy

Include Files

Description

This is the base class for Fl_Toggle_Tree. It could conceivably be used to create other tree-like widgets.

This class has been designed to maintain a doubly linked tree list, and defers data storage and management to subclasses of Fl_Tree and Fl_Node. This class also maintains wether it's branches are visible or not (i.e. "opened" or "closed").

Methods

  • Fl_Tree
  • add_next
  • add_sub
  • clear
  • close
  • draw
  • remove
  • first
  • open
  • traverse_start
  • traverse_forward
  • traverse_up
  • update_height
  • Fl_Tree::Fl_Tree(int x, int y, int w, int h)

    The constructor makes an empty Fl_Tree.

    void Fl_Tree::add_next(Fl_Node *n)

    Insert n as the next item after current node.

    void Fl_Tree::add_sub(Fl_Node *n)

    Insert n as the next sub item after the current node.

    void Fl_Tree::clear()

    Clear the tree.

    void Fl_Tree::close(Fl_Node *n)

    Set node n as "closed".

    virtual void Fl_Tree::draw()

    Virtual method that draws the tree.

    int Fl_Tree::remove(Fl_Node *n)

    Remove n (and all of it's sub nodes) from the tree. If successful returns 1, else returns 0.

    Fl_Node* Fl_Tree::first()

    Returns the first (top) Fl_Node in the widget tree.

    void Fl_Tree::open(Fl_Node *n)

    Set node n as "open".

    void Fl_Tree::traverse_start(Fl_Node* t)
    Fl_Node* Fl_Tree::traverse_start()

    The first form of this method sets the current pointer to t. The second form of this method, sets the traversal pointer to first() and then returns first(). The second form is provided for convenience.

    Fl_Node* Fl_Tree::traverse_forward(int visible, int &depth)
    Fl_Node* Fl_Tree::traverse_forward()

    This method traverses forward through the tree. Traversal through the node tree is done by a depth first traversal that updates the current node pointer. If traverse_forward returns 0, then the current node pointer has reached the end of the tree. Otherwise, traverse_forward returns the next node in the tree.

    The visible flag should be set to 1 if you want to restrict traversal to the visible tree (the Fl_Nodes that are not closed). The depth variable is updated with the new node depth, if the old node depth is passed to traverse_forward.

    The second form of the method is the same as traverse_forward(0, temp).

    Fl_Node* Fl_Tree::traverse_up()

    If the current node has an up pointer, traverse_up returns this pointer and sets it as the current node.

    void Fl_Tree::update_height()

    Update the height of the tree.