TreeViewerNode Class Reference

A string object that is displayable in a tree structure. A node can have children, see methods children(), open(), and close(). More...

#include <treeviewer.h>

Collaboration diagram for TreeViewerNode:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list< TreeViewerNodeChildrenList
 Holds children.
typedef std::vector< std::pair
< TreeViewerNode *, int > > 
FlatForm
 Holds child*'s and depth.

Public Member Functions

TreeViewerNodeaddChild (std::string const &name)
 Take ownership of a new tree viewer node. Append it to the list of children.
void adoptInfo (TreeViewerNodeInfo *p)
 Take ownership of node info. Delete any previous node info.
ChildrenListchildren ()
 List of child nodes.
ChildrenList const & children () const
 List of child nodes.
void close (bool childrenToo=true)
 Mark this and optionally all child nodes as closed.
void flatten (FlatForm &output, int depth=0)
 Appends this node to a flattend version of the TreeViewerNode structure. A flat version does not contain the nested tree structure, per se, but does have an indication of the depth of the nodes in the tree to aid in the display thereof.
bool hasChildren () const
 Return true if this node has children.
virtual int height () const
 Get height of self plus children.
bool highlighted () const
TreeViewerNodeInfoinfo ()
 Return any user supplied information associated with this node.
std::string const & name () const
 Get this node's name.
void open (bool childrenToo=true)
 Mark this and optionally all child nodes as closed.
bool opened () const
 Return true if the children should be displayed.
void setHighlighted ()
 Force this node to be displayed in highlighted text.
void setName (std::string const &n)
 Set the node name.
 TreeViewerNode ()
 TreeViewerNode (std::string const &name)
virtual ~TreeViewerNode ()

Private Attributes

ChildrenList children_
bool highlighted_
TreeViewerNodeInfoinfo_
std::string name_
bool opened_

Detailed Description

A string object that is displayable in a tree structure. A node can have children, see methods children(), open(), and close().

There is no flag in the data that indicates what kind of tree viewer node you have, but you can use dynamic cast to see if a given node is a container or not.

Upon destruction, the children are also deleted.

Note that no child in the children list will be null (unless there is a major bug).

TreeViewerNodes are meant for raw data storage and do not have features needed to animate the nodes on the screen.

The nodes can have associated information that can be used to perform command handling. See adoptInfo() below and TreeViewerNodeInfo above.

Definition at line 69 of file treeviewer.h.


Member Typedef Documentation

typedef std::list<TreeViewerNode> ChildrenList

Holds children.

Definition at line 90 of file treeviewer.h.

typedef std::vector<std::pair<TreeViewerNode*, int> > FlatForm

Holds child*'s and depth.

Definition at line 91 of file treeviewer.h.


Constructor & Destructor Documentation

TreeViewerNode ( std::string const &  name  ) 

Definition at line 296 of file treeviewer.h.

TreeViewerNode (  ) 

Definition at line 307 of file treeviewer.h.

~TreeViewerNode (  )  [virtual]

Definition at line 429 of file treeviewer.h.


Member Function Documentation

TreeViewerNode & addChild ( std::string const &  name  ) 

Take ownership of a new tree viewer node. Append it to the list of children.

Definition at line 339 of file treeviewer.h.

Here is the caller graph for this function:

void adoptInfo ( TreeViewerNodeInfo p  ) 

Take ownership of node info. Delete any previous node info.

Definition at line 417 of file treeviewer.h.

Here is the caller graph for this function:

TreeViewerNode::ChildrenList & children (  ) 

List of child nodes.

Definition at line 357 of file treeviewer.h.

TreeViewerNode::ChildrenList const & children (  )  const

List of child nodes.

Definition at line 349 of file treeviewer.h.

void close ( bool  childrenToo = true  ) 

Mark this and optionally all child nodes as closed.

Definition at line 66 of file treeviewer.cxx.

Here is the caller graph for this function:

void flatten ( FlatForm output,
int  depth = 0 
)

Appends this node to a flattend version of the TreeViewerNode structure. A flat version does not contain the nested tree structure, per se, but does have an indication of the depth of the nodes in the tree to aid in the display thereof.

Definition at line 109 of file treeviewer.cxx.

Here is the caller graph for this function:

bool hasChildren (  )  const

Return true if this node has children.

Definition at line 367 of file treeviewer.h.

Here is the caller graph for this function:

int height (  )  const [virtual]

Get height of self plus children.

Definition at line 46 of file treeviewer.cxx.

bool highlighted (  )  const
Returns:
true if highlighted

Definition at line 145 of file treeviewer.h.

Here is the caller graph for this function:

TreeViewerNodeInfo * info (  ) 

Return any user supplied information associated with this node.

Definition at line 441 of file treeviewer.h.

std::string const & name (  )  const

Get this node's name.

Definition at line 329 of file treeviewer.h.

Here is the caller graph for this function:

void open ( bool  childrenToo = true  ) 

Mark this and optionally all child nodes as closed.

Definition at line 88 of file treeviewer.cxx.

Here is the caller graph for this function:

bool opened (  )  const

Return true if the children should be displayed.

Definition at line 377 of file treeviewer.h.

Here is the caller graph for this function:

void setHighlighted (  ) 

Force this node to be displayed in highlighted text.

Definition at line 470 of file treeviewer.h.

Here is the caller graph for this function:

void setName ( std::string const &  n  ) 

Set the node name.

Definition at line 319 of file treeviewer.h.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 95 of file treeviewer.h.

bool highlighted_ [private]

Definition at line 104 of file treeviewer.h.

Definition at line 102 of file treeviewer.h.

std::string name_ [private]

Definition at line 100 of file treeviewer.h.

bool opened_ [private]

Definition at line 97 of file treeviewer.h.


The documentation for this class was generated from the following files:
Generated on Wed Feb 29 22:57:42 2012 for CXXUtilities by  doxygen 1.6.3