#include <WTreeNode>
Inherits Wt::WCompositeWidget.
Inherited by Wt::WTreeTableNode.
Inheritance diagram for Wt::WTreeNode:

Public Types | |
| LazyLoading | |
| Load-on-demand of child nodes. | |
| PreLoading | |
| Pre-load all child nodes. | |
| NextLevelLoading | |
| Pre-load one level of child nodes. | |
| enum | LoadPolicy { LazyLoading, PreLoading, NextLevelLoading } |
| Load policy. More... | |
Public Slots | |
| void | expand () |
| Expand this node. | |
| void | collapse () |
| Collapse this node. | |
Public Member Functions | |
| WTreeNode (const WString &labelText, WIconPair *labelIcon=0, WTreeNode *parentNode=0) | |
| Construct a tree node with the given label. | |
| ~WTreeNode () | |
| Destructor. | |
| WText * | label () const |
| Get a reference to the label. | |
| WIconPair * | labelIcon () const |
| Get a reference to the label icon. | |
| void | setLabelIcon (WIconPair *labelIcon) |
| Change the label icon. | |
| virtual void | addChildNode (WTreeNode *node) |
| Add a child node. | |
| void | removeChildNode (WTreeNode *node) |
| Remove a child node. | |
| const std::vector< WTreeNode * > & | childNodes () const |
| Get the list of children. | |
| void | setImagePack (const std::string url) |
| Set the image pack for this (sub)tree. | |
| void | setLoadPolicy (LoadPolicy loadPolicy) |
| Change the load policy for this tree. | |
| bool | expanded () const |
| Is this node expanded ? | |
Protected Slots | |
| virtual void | doExpand () |
| The actual expand. | |
| virtual void | doCollapse () |
| The actual collapse. | |
Protected Member Functions | |
| WTreeNode (WTreeNode *parentNode=0) | |
| Construct a tree node with empty labelArea(). | |
| WTableCell * | labelArea () |
| Access the container widget that holds the label area. | |
| virtual void | populate () |
| Populate the node dynamically on loading. | |
| std::string | imagePack () const |
| The image pack that is used for this tree node. | |
| virtual void | undoDoExpand () |
| Undo method for doCollapse() stateless implementation. | |
| virtual void | undoDoCollapse () |
| Undo method for doCollapse() stateless implementation. | |
A tree list is constructed by combining several tree node objects in a tree hierarchy, by passing the parent tree node as the last argument in the child node constructor, or by using addChildNode(), to add a child to its parent.
Each tree node has a label, and optionally a label icon pair. The icon pair offers the capability to show a different icon depending on the state of the node (expanded or collapsed). When the node has any children, the child count is indicated next to the label. When expanding a tree node it will collapse all its children.
The treenode provides several policies to communicate the current contents of the tree to the client (if possible):
The default policy is WTreeNode::LazyLoading. Another load policy may be specified using setLoadPolicy() on the root node and before adding any children. The load policy is inherited by all children in the tree.
There are a few scenarios where it makes sense to specialize the WTreeNode class. One scenario is create a tree that is populated dynamically while browsing. For this purpose you should reimplement the populate() method, whose default implementation does nothing. This method is called when 'loading' the node. The exact moment for loading a treenode depends on the LoadPolicy.
A second scenario that is if you want to customize the look of the tree label (see labelArea()) or if you want to modify or augment the event collapse/expand event handling (see doExpand() and doCollapse()).
Next to the icons, two style classes determine the look of a WTreeNode: the label has CSS style class "treenodelabel", and the child count has CSS style class "treenodechildcount".
For example, the following CSS stylesheet styles a tree for which the root has style class "mytree":
mytree * .treenodelabel {
font-size: smaller;
}
mytree * .treenodechildcount {
font-size: smaller;
color: blue;
}
The tree node uses an image-pack, which is a collection of images to render the expand/collapse icons and lines. Use setImagePack() to specify the location of these icons. This needs only be done on the root of the tree, as child nodes will query their ancestors for the location of these images, when they are not set explicitly.
| Wt::WTreeNode::WTreeNode | ( | const WString & | labelText, | |
| WIconPair * | labelIcon = 0, |
|||
| WTreeNode * | parentNode = 0 | |||
| ) |
Construct a tree node with the given label.
The labelIcon, if specified, will appear just before the label and its state reflect the expand/collapse state of the node.
The node is initialized to be collapsed.
| Wt::WTreeNode::WTreeNode | ( | WTreeNode * | parentNode = 0 |
) | [protected] |
Construct a tree node with empty labelArea().
This tree node has no label or labelicon, and is therefore ideally suited to provide a custom look.
| void Wt::WTreeNode::collapse | ( | ) | [slot] |
| void Wt::WTreeNode::doCollapse | ( | ) | [protected, virtual, slot] |
The actual collapse.
This method, which is implemented as a stateless slot, performs the actual collapse of the node.
You may want to reimplement this function (and undoDoCollapse()) if you wish to do additional things on node expansion.
| void Wt::WTreeNode::doExpand | ( | ) | [protected, virtual, slot] |
The actual expand.
This method, which is implemented as a stateless slot, performs the actual expansion of the node.
You may want to reimplement this function (and undoDoExpand()) if you wish to do additional things on node expansion.
| void Wt::WTreeNode::expand | ( | ) | [slot] |
Expand this node.
Besides the actual expansion of the node, this may also trigger the loading and population of the node children, or of the children's children.
| std::string Wt::WTreeNode::imagePack | ( | ) | const [protected] |
The image pack that is used for this tree node.
This is the imagepack that was set, or if not set, the image pack of its parent.
| WTableCell * Wt::WTreeNode::labelArea | ( | ) | [protected] |
Access the container widget that holds the label area.
Use this to customize how the label should look like.
| void Wt::WTreeNode::populate | ( | ) | [protected, virtual] |
Populate the node dynamically on loading.
Reimplement this method if you want to populate the widget dynamically, as the tree is being browsed and therefore loaded. This is only usefull with LazyLoading or NextLevelLoading strategies.
| void Wt::WTreeNode::setImagePack | ( | const std::string | url | ) |
Set the image pack for this (sub)tree.
You must specify a valid url for the directory that contains the icons.
| void Wt::WTreeNode::setLoadPolicy | ( | LoadPolicy | loadPolicy | ) |
Change the load policy for this tree.
This may only be set on the root of a tree, and before adding any children.
| void Wt::WTreeNode::undoDoCollapse | ( | ) | [protected, virtual] |
| void Wt::WTreeNode::undoDoExpand | ( | ) | [protected, virtual] |
1.4.7