#include <TreeNode.h>
Public Slots | |
void | collapse () |
Collapse this node. | |
void | expand () |
Expand this node. | |
Public Member Functions | |
TreeNode (const std::wstring labelText, Wt::WText::Formatting labelFormatting, IconPair *labelIcon, Wt::WContainerWidget *parent=0) | |
Construct a tree node with the given label. | |
void | addChildNode (TreeNode *node) |
Add a child node. | |
void | removeChildNode (TreeNode *node) |
Remove a child node. | |
const std::vector< TreeNode * > & | childNodes () const |
Get the list of children. | |
Private Types | |
enum | ImageIndex { Middle = 0, Last = 1 } |
Two sets of images, for a normal node, and for the last node. More... | |
Private Member Functions | |
void | adjustExpandIcon () |
Adjust the expand icon. | |
bool | isLastChildNode () const |
Returns if is the last child within its parent (is rendered differently). | |
void | childNodesChanged () |
Rerender when children have changed. | |
void | undoCollapse () |
Undo function for prelearning collapse(). | |
void | undoExpand () |
Undo function for prelearning expand(). | |
Private Attributes | |
std::vector< TreeNode * > | childNodes_ |
List of child nodes. | |
TreeNode * | parentNode_ |
The parent node. | |
Wt::WTable * | layout_ |
Layout (2x2 table). | |
IconPair * | expandIcon_ |
The icon for expanding or collapsing. | |
Wt::WImage * | noExpandIcon_ |
The single image shown instead of the expand/collapse icon when no children. | |
IconPair * | labelIcon_ |
The icon next to the label. | |
Wt::WText * | labelText_ |
The label. | |
Wt::WText * | childCountLabel_ |
The children count '(x)' for x children. | |
Wt::WContainerWidget * | expandedContent_ |
The container in which the children are managed. | |
bool | wasCollapsed_ |
Was collapsed (for undo of prelearned collapse() and expand() slots. | |
Static Private Attributes | |
static std::string | imageLine_ [] |
static std::string | imagePlus_ [] |
static std::string | imageMin_ [] |
This is an example of a basic treelist implementation. As of version 1.1.8, a more flexible treenode implementation is included as part of the library: WTreeNode.
A tree list is constructed by nesting TreeNode objects in a tree hierarchy.
A TreeNode has a label, and optionally a two-state label icon, which defines a different image depending on the state of the node (expanded or collapsed). When the node has any children, a child count is also indicated.
Next to the icons, two style classes determine the look of a TreeNode: the label has style "treenodelabel", and the child count has as style "treenodechildcount".
Use CSS nested selectors to apply different styles to different treenodes. For example, to style the treenode with style class "mynode":
The behaviour of the tree node is to collapse all children when the node is expanded (this is similar to how most tree node implementations work).
The widget uses a number of images which must be available in an "icons/" folder (see the Wt treelist examples).
This widget is part of the Wt treelist example.
Definition at line 55 of file TreeNode.h.
enum TreeNode::ImageIndex [private] |
Two sets of images, for a normal node, and for the last node.
Definition at line 140 of file TreeNode.h.
TreeNode::TreeNode | ( | const std::wstring | labelText, | |
Wt::WText::Formatting | labelFormatting, | |||
IconPair * | labelIcon, | |||
Wt::WContainerWidget * | parent = 0 | |||
) |
Construct a tree node with the given label.
The label is formatted in a WText with the given formatting. The labelIcon (if not 0) will appear next to the label and its state will reflect the expand/collapse state of the node.
Optionally, a userContent widget may be associated with the node. When expanded, this widget will be shown below the widget, but above any of the children nodes.
Definition at line 25 of file TreeNode.C.
void TreeNode::addChildNode | ( | TreeNode * | node | ) |
void TreeNode::removeChildNode | ( | TreeNode * | node | ) |
const std::vector<TreeNode *>& TreeNode::childNodes | ( | ) | const [inline] |
void TreeNode::collapse | ( | ) | [slot] |
void TreeNode::expand | ( | ) | [slot] |
void TreeNode::adjustExpandIcon | ( | ) | [private] |
bool TreeNode::isLastChildNode | ( | ) | const [private] |
Returns if is the last child within its parent (is rendered differently).
Definition at line 77 of file TreeNode.C.
void TreeNode::childNodesChanged | ( | ) | [private] |
void TreeNode::undoCollapse | ( | ) | [private] |
void TreeNode::undoExpand | ( | ) | [private] |
std::vector<TreeNode *> TreeNode::childNodes_ [private] |
TreeNode* TreeNode::parentNode_ [private] |
Wt::WTable* TreeNode::layout_ [private] |
IconPair* TreeNode::expandIcon_ [private] |
Wt::WImage* TreeNode::noExpandIcon_ [private] |
The single image shown instead of the expand/collapse icon when no children.
Definition at line 107 of file TreeNode.h.
IconPair* TreeNode::labelIcon_ [private] |
Wt::WText* TreeNode::labelText_ [private] |
Wt::WText* TreeNode::childCountLabel_ [private] |
Wt::WContainerWidget* TreeNode::expandedContent_ [private] |
bool TreeNode::wasCollapsed_ [private] |
Was collapsed (for undo of prelearned collapse() and expand() slots.
Definition at line 131 of file TreeNode.h.
std::string TreeNode::imageLine_ [static, private] |
Initial value:
{ "icons/line-middle.gif", "icons/line-last.gif" }
Definition at line 142 of file TreeNode.h.
std::string TreeNode::imagePlus_ [static, private] |
Initial value:
{ "icons/nav-plus-line-middle.gif", "icons/nav-plus-line-last.gif" }
Definition at line 143 of file TreeNode.h.
std::string TreeNode::imageMin_ [static, private] |
Initial value:
{ "icons/nav-minus-line-middle.gif", "icons/nav-minus-line-last.gif" }
Definition at line 144 of file TreeNode.h.