FLTK Utility Library and Widget Collection (FLU): Flu_Tree_Browser::Node class Reference

Main Page | Class Hierarchy | Class List | File List | Class Members

# Flu_Tree_Browser::Node Class Reference

This class holds a single entry in the tree. More...

`#include <Flu_Tree_Browser.h>`

List of all members.

## Public Member Functions
bool | active () const
| Is this node currently active?
void | active (bool b)
| Activate or deactivate this node.
void | activate ()
| Activate this node.
Node * | add (const char *fullpath, Fl_Widget *w=0, bool showLabel=true)
| Add the entry specified by fullpath to this node. If w is not `NULL` then that widget is the entry and the label (as specified in fullPath) is visible depending on the value of showLabel. Note that the widget is destroyed by the tree/node on clear() or the destructor.
Node * | add_branch (const char *fullpath, Fl_Widget *w=0, bool showLabel=true)
| Convenience function that is the same as add() except it appends a '/' to fullpath if one does not exist.
Node * | add_leaf (const char *fullpath, Fl_Widget *w=0, bool showLabel=true)
| Convenience function that is the same as add() except it removes any '/' at the end of fullpath.
Node * | add (const char *path, const char *name, Fl_Widget *w=0, bool showLabel=true)
| Convenience function that is the same as add() except path and name are concatenated (with a '/' added if necessary) to create the full path.
Node * | add_branch (const char *path, const char *name, Fl_Widget *w=0, bool showLabel=true)
| Convenience function that is the same as add_branch() except path and name are concatenated (with a '/' added if necessary) to create the full path.
Node * | add_leaf (const char *path, const char *name, Fl_Widget *w=0, bool showLabel=true)
| Convenience function that is the same as add_leaf() except path and name are concatenated (with a '/' added if necessary) to create the full path.
void | always_open (bool b)
| Set whether a branch node is always open (only for branch nodes). Default is `false`.
bool | always_open () const
| Get whether this branch node is always open (only for branches).
void | auto_color (bool b)
| Set whether the color of the widget in this node tracks the color of the node itself. This is useful for changing the color of the widget when the node is selected. Default is `false`.
bool | auto_color ()
| Get whether the color of the widget in this node tracks the color of the node itself.
void | auto_label (bool b)
| Set whether the label of the widget in this node tracks the label of the node itself. This is useful for when the label of the node changes and you want the widget to reflect the change.
bool | auto_label ()
| Set whether the label of the widget in this node tracks the label of the node itself.
void | auto_label_color (bool b)
| Set whether the label color of the widget in this node tracks the label color of the node itself. This is useful for changing the label color of the widget when the node is selected. Default is `false`.
bool | auto_label_color ()
| Get whether the label color of the widget in this node tracks the label color of the node itself.
void | branch_icons (Fl_Image *closed, Fl_Image *open)
| Set the branch icons to use for this node (only for branch nodes).
void | branch_icon (Fl_Image *icon)
| Convenience routine to set both branch icons at once.
Node * | child (int i) const
| child i of this node (base 0). Bounds checking is performed and NULL is returned if the child cannot be found
int | children () const
| the number of child nodes beneath this node
void | clear ()
| Clear all child entries from this node (does not change the entry of this node).
void | close ()
| Close this node (only for branches).
bool | closed ()
| Is this node closed? (only for branches).
void | collapse_icons (Fl_Image *closed, Fl_Image *open)
| Set the collapse icons to use for this node (only for branch nodes).
void | deactivate ()
| Deactivate this node.
unsigned short | depth () const
| Get the depth of this node in the tree.
void | do_callback (int reason)
| Do the tree browser callback. reason should be one of FLU_HILIGHTED, FLU_UNHILIGHTED, FLU_SELECTED, FLU_UNSELECTED, FLU_OPENED, FLU_CLOSED, FLU_DOUBLE_CLICK, FLU_WIDGET_CALLBACK.
void | droppable (bool b)
| Set whether this node can receive new nodes as a result of dragging-and-dropping (only for branch nodes). Default is `true`.
bool | droppable ()
| Get whether this node can receive new nodes as a result of dragging-and-dropping (only for branch nodes).
void | expand_to_width (bool b)
| Set whether to force the size of the embedded widget to expand to fill the visible width of the browser. Default is `false`.
bool | expand_to_width () const
| Get whether to force the size of the embedded widget to expand to fill the visible width of the browser.
Node * | find (const char *fullpath)
| Find the entry identified by fullpath.
Node * | find (unsigned int id)
| Find the entry identified by unique id id.
Node * | find (Fl_Widget *w)
| Find the entry containing the widget w.
Node * | find (Node *n)
| Search for Node n.
const char * | find_path ()
| the full path of this node
Node * | first ()
| the first node in this hierarchy (i.e. this node)
Node * | first_branch ()
| the first branch encountered in a depth-first traversal (or this node if it is a branch). NULL means there are no branches
Node * | first_leaf ()
| the first leaf encountered in a depth-first traversal (or this node if it is a leaf). NULL means there are no leaves
void | swap_label_and_widget (bool b)
| Set whether this node draws the label to the left of the widget (`false`, default) or to the right of the widget (`true`).
bool | swap_label_and_widget ()
| Get whether this node draws the label to the left of the widget (`false`, default) or to the right of the widget (`true`).
Node * | get_selected (int index)
| the selected Node that is at index among all selected nodes, or `NULL` if no Node is selected
void | icon_at_end (bool b)
| Set whether the icon for this node is drawn after the label and widget (`true`) or before (`false`, default) (only for leaf nodes).
bool | icon_at_end ()
| Get whether the icon for this node is drawn after the label and widget (`true`) or before (`false`, default) (only for leaf nodes).
unsigned int | id () const
| Get the unique ID of this node.
int | index () const
| Get the index this node is (as a child) in its parent's list.
Node * | insert (const char *fullpath, int pos)
| Insert a new node at position pos.
Node * | insert_branch (const char *fullpath, int pos)
| Insert a new branch at position pos.
Node * | insert_leaf (const char *fullpath, int pos)
| Insert a new leaf at position pos.
bool | is_ancestor (Node *n)
| Is node n an ancestor of this node?
bool | is_branch () const
| Is this node a branch node?
bool | is_descendent (Node *n)
| Is node n a descendent of this node?
bool | is_leaf () const
| Is this node a leaf node?
bool | is_root () const
| Is this node the root node?
void | label (const char *l)
| Set the label for this node. Note that setting the label may invalidate a sorted tree. Fix by calling Flu_Tree_Browser::sort().
const char * | label () const
| Get the label for this node.
void | label_color (Fl_Color c)
| Set the label color for this node.
Fl_Color | label_color () const
| Get the label color for this node.
void | label_font (Fl_Font f)
| Set the label font for this node.
Fl_Font | label_font () const
| Get the label font for this node.
void | label_size (unsigned char s)
| Set the label size for this node.
unsigned char | label_size () const
| Get the label size for this node.
bool | label_visible () const
| Is the label for this node visible?
void | label_visible (bool b)
| Set whether the label for this node is visible.
Node * | last ()
| the last node in this hierarchy
Node * | last_branch ()
| the last branch encountered in a depth-first traversal (or this node if it is a branch and has no children). NULL means there are no branches
Node * | last_leaf ()
| the last leaf encountered in a depth-first traversal (or this node if it is a leaf). NULL means there are no leaves
void | leaf_icon (Fl_Image *icon)
| Set the leaf icon to use for this node (only for leaf nodes).
void | movable (bool b)
| Set whether this node can be moved (either via move() or by dragging with the mouse). Default is `true`.
bool | movable ()
| Get whether this node can be moved (either via move() or by dragging with the mouse).
bool | move (int pos)
| Move this node to absolute position pos within its parent.
bool | move (int where, Node *n)
| Move this node to a position before, after, or inside node n.
Node * | next ()
| the next node (after this node) in this hierarchy (depth-first traversal)
Node * | next_branch ()
| the next branch (after this node) encountered in a depth-first traversal. NULL means there are no more branches
Node * | next_leaf ()
| the next leaf (after this node) encountered in a depth-first traversal. NULL means there are no more leaves
Node * | next_sibling ()
| the next sibling (after this node) encountered in a depth-first traversal. NULL means this node is the last child w.r.t. its parent
int | num_selected ()
| the number of selected entries
bool | open () const
| Is this node currently open? (only for branch nodes).
void | open (bool b)
| Open or close this node (only for branch nodes).
Node * | parent () const
| Get the node that is the parent of this node, or NULL if there is no parent.
Node * | previous ()
| the previous node (before this node) in this hierarchy (depth-first traversal)
Node * | previous_branch ()
| the previous branch (before this node) encountered in a depth-first traversal. NULL means there are no more branches
Node * | previous_leaf ()
| the previous leaf (before this node) encountered in a depth-first traversal. NULL means there are no more leaves
Node * | previous_sibling ()
| the previous sibling (before this node) encountered in a depth-first traversal. NULL means this node is the first child w.r.t. its parent
void | print (int spaces=0)
| Print this node and its children to stdout.
unsigned int | remove (const char *fullpath)
| Remove the entry identified by path fullpath from this node.
unsigned int | remove (unsigned int id)
| Remove the entry identified by unique id id from this node.
unsigned int | remove (Fl_Widget *w)
| Remove the node containing the widget w from this node. Note that the widget is automatically destroyed.
unsigned int | remove (Node *n)
| Remove Node n.
void | select_all ()
| Select this entry and all child entries.
bool | selected () const
| Is this node currently selected?
void | select (bool b)
| Select or unselect this node.
void | select_only ()
| Select only this node.
void | sort_children ()
| Sort this node's children according to Flu_Tree_Browser::insertion_mode().
bool | swap (Node *n)
| Swap this node and node n in their respective trees.
void | unselect_all (Node *except=NULL)
| Unselect this entry and all child entries (except for Node except ).
void * | user_data ()
| Get the user-specific data stored in this node.
void | user_data (void *d)
| Set the user-specific data stored in this node.
Fl_Widget * | widget () const
| Get the widget in this node, or NULL if there is no widget. Note that the widget is destroyed by the tree/node on clear() or the destructor.
void | widget (Fl_Widget *w)
| Set the widget in this node. Note that the widget is destroyed by the tree/node on clear() or the destructor.
## Static Public Member Functions
bool | move (Node *n1, int where, Node *n2)
| Move node n1 to a position before, after, or inside node n2.
bool | swap (Node *n1, Node *n2)
| Swap nodes n1 and n2 in their respective trees.
## Protected Types
enum | { ADD, REMOVE, FIND, FIND_NUMBER, GET_SELECTED }
enum | { DRAW, MEASURE, MEASURE_THIS_OPEN, HANDLE, COUNT_SELECTED }
enum | { SELECTED = 0x0001, COLLAPSED = 0x0002, LEAF = 0x0004, SHOW_LABEL = 0x0008, ACTIVE = 0x0010, EXPAND_TO_WIDTH = 0x0020, ALWAYS_OPEN = 0x0040, SOME_VISIBLE_CHILDREN = 0x0080, MOVABLE = 0x0100, DROPPABLE = 0x0200, AUTO_LABEL_COLOR = 0x0400, AUTO_COLOR = 0x0800, AUTO_LABEL = 0x1000, SWAP_LABEL_AND_WIDGET = 0x2000, ICON_AT_END = 0x4000 }
## Protected Member Functions
bool | CHECK (unsigned short flag) const
void | SET (unsigned short flag)
void | SET (unsigned short flag, bool b)
void | CLEAR (unsigned short flag)
| Node (const char *lbl=0)
| Node (bool l, const char *n, Node *p, RData &rdata, Fl_Widget *w, bool showLabel)
Node * | modify (const char *path, int what, RData &rdata, Fl_Widget *w=0, bool showLabel=true)
void | initType ()
void | sort ()
void | determineVisibility (bool parentVisible=true)
int | recurse (RData &rdata, int type, int event=0)
void | draw (RData &rdata, bool measure)
bool | findPath (unsigned int id, RData &rdata)
bool | findPath (Fl_Widget *w, RData &rdata)
void | widgetCB ()
## Static Protected Member Functions
bool | isMoveValid (Node *&n1, int &where, Node *&n2)
void | _widgetCB (Fl_Widget *w, void *arg)
## Protected Attributes
unsigned int | _id
unsigned short | flags
NodeList | _children
Node * | _parent
Flu_Tree_Browser * | tree
FluSimpleString | text
WidgetInfo * | _widget
Fl_Group * | _group
void * | userData
int | totalChildH
Fl_Image * | cIcon [2]
Fl_Image * | bIcon [2]
Fl_Image * | lIcon
Fl_Color | textColor
Fl_Font | textFont
unsigned char | textSize
unsigned short | textW
unsigned short | textH
int | currentY
unsigned short | currentH
## Friends
class | Flu_Tree_Browser
class | NodeList

## Detailed Description

This class holds a single entry in the tree.

## Member Function Documentation

Node* Flu_Tree_Browser::Node::add | ( | const char * | fullpath,
|  | Fl_Widget * | w = 0,
|  | bool | showLabel = true
| ) | `[inline]`

| Add the entry specified by fullpath to this node. If w is not `NULL` then that widget is the entry and the label (as specified in fullPath) is visible depending on the value of showLabel. Note that the widget is destroyed by the tree/node on clear() or the destructor. Returns: a pointer to the Node of the added entry or NULL if the add failed

void Flu_Tree_Browser::Node::collapse_icons | ( | Fl_Image * | closed,
|  | Fl_Image * | open
| ) |

| Set the collapse icons to use for this node (only for branch nodes). Note: if a NULL icon is passed, the default plus/minus icons are chosen

Node* Flu_Tree_Browser::Node::find | ( | Node * | n | ) | `[inline]`

| Search for Node n. Returns: a pointer to n if it is found, or NULL if it is not present

Node* Flu_Tree_Browser::Node::find | ( | Fl_Widget * | w | ) |

| Find the entry containing the widget w. Returns: a pointer to the Node of the found entry, or NULL if no matching entry was found

Node* Flu_Tree_Browser::Node::find | ( | unsigned int | id | ) |

| Find the entry identified by unique id id. Returns: a pointer to the Node of the found entry, or NULL if no matching entry was found

Node* Flu_Tree_Browser::Node::find | ( | const char * | fullpath | ) | `[inline]`

| Find the entry identified by fullpath. Returns: a pointer to the Node of the found entry, or NULL if no matching entry was found

const char* Flu_Tree_Browser::Node::find_path | ( |  | ) | `[inline]`

| the full path of this node Note: the returned value is only valid until the next time find_path() is called

Node* Flu_Tree_Browser::Node::get_selected | ( | int | index | ) |

| the selected Node that is at index among all selected nodes, or `NULL` if no Node is selected For example, `get_selected(1)` will return the first selected node.

int Flu_Tree_Browser::Node::index | ( |  | ) | const

| Get the index this node is (as a child) in its parent's list. Returns: -1 if this node has no parent, else its index in its parent's list of children

bool Flu_Tree_Browser::Node::move | ( | Node * | n1,
|  | int | where,
|  | Node * | n2
| ) | `[static]`

  | Move node n1 to a position before, after, or inside node n2. Parameters:
  where | can be one of MOVE_BEFORE, MOVE_AFTER, or MOVE_INSIDE
Returns: `true` if the move was successful, or `false` if the move is not allowed

bool Flu_Tree_Browser::Node::move | ( | int | where,
|  | Node * | n
| ) | `[inline]`

  | Move this node to a position before, after, or inside node n. Parameters:
  where | can be one of MOVE_BEFORE, MOVE_AFTER, or MOVE_INSIDE
Returns: `true` if the move was successful, or `false` if the move is not allowed

bool Flu_Tree_Browser::Node::move | ( | int | pos | ) |

| Move this node to absolute position pos within its parent. Returns: `true` if the move was successful, or `false` if the move is not allowed

unsigned int Flu_Tree_Browser::Node::remove | ( | Node * | n | ) | `[inline]`

| Remove Node n. Returns: the id of n on successful removal, or `0` if n is present

unsigned int Flu_Tree_Browser::Node::remove | ( | Fl_Widget * | w | ) |

| Remove the node containing the widget w from this node. Note that the widget is automatically destroyed. Returns: the unique id of the removed entry, or `0` if no matching entry was found

unsigned int Flu_Tree_Browser::Node::remove | ( | unsigned int | id | ) |

| Remove the entry identified by unique id id from this node. Returns: the unique id of the removed entry, or `0` if no matching entry was found

unsigned int Flu_Tree_Browser::Node::remove | ( | const char * | fullpath | ) | `[inline]`

| Remove the entry identified by path fullpath from this node. Returns: the unique id of the removed entry, or `0` if no matching entry was found

bool Flu_Tree_Browser::Node::swap | ( | Node * | n1,
|  | Node * | n2
| ) | `[static]`

| Swap nodes n1 and n2 in their respective trees. Returns: `true` if the swap was successful, else `false`

bool Flu_Tree_Browser::Node::swap | ( | Node * | n | ) | `[inline]`

| Swap this node and node n in their respective trees. Returns: `true` if the swap was successful, else `false`

The documentation for this class was generated from the following file:

- Flu_Tree_Browser.h