Wt examples: treelist/TreeNode.h Source File

Wt examples 4.10.4

Loading...
Searching...
No Matches
TreeNode.h
Go to the documentation of this file.
1// This may look like C code, but it's really -*- C++ -*-
2/*
3 * Copyright (C) 2008 Emweb bv, Herent, Belgium.
4 *
5 * See the LICENSE file for terms of use.
6 */
7#ifndef TREENODE_H_
8#define TREENODE_H_
9
10#include <Wt/WCompositeWidget.h>
11#include <Wt/WText.h>
12
13class IconPair;
14
15using namespace Wt;
16
17namespace Wt {
18 class WTable;
19 class WImage;
20}
21
26
57 class TreeNode : public WCompositeWidget
58{
59public:
70 TreeNode(const std::string labelText,
71 TextFormat labelFormat,
72 std::unique_ptr<IconPair> labelIcon);
73
76 void addChildNode(std::unique_ptr<TreeNode> node);
77
80 void removeChildNode(TreeNode *node, int index);
81
84 const std::vector<TreeNode *>& childNodes() const { return childNodes_; }
85
88 void collapse();
89
92 void expand();
93
94private:
96 std::vector<TreeNode *> childNodes_;
97
99 TreeNode *parentNode_;
100
102 WTable *layout_;
103
105 IconPair *expandIcon_;
106
108 WImage *noExpandIcon_;
109
111 IconPair *labelIcon_;
112
114 WText *childCountLabel_;
115
117 WContainerWidget *expandedContent_;
118
120 void adjustExpandIcon();
121
123 bool isLastChildNode() const;
124
126 void childNodesChanged();
127
129 bool wasCollapsed_;
130
132 void undoCollapse();
133
135 void undoExpand();
136
138 enum ImageIndex { Middle = 0, Last = 1 };
139
140 static std::string imageLine_[];
141 static std::string imagePlus_[];
142 static std::string imageMin_[];
143}; //
144
147#endif // WTREENODE_H_
IconPair
An icon pair (identical to WIconPair)
Definition IconPair.h:37
TreeNode
Example implementation of a single tree list node.
Definition TreeNode.h:58
TreeNode::undoCollapse
void undoCollapse()
Undo function for prelearning collapse()
Definition TreeNode.C:144
TreeNode::removeChildNode
void removeChildNode(TreeNode *node, int index)
Removes a child node.
Definition TreeNode.C:91
TreeNode::childNodes_
std::vector< TreeNode * > childNodes_
List of child nodes.
Definition TreeNode.h:96
TreeNode::undoExpand
void undoExpand()
Undo function for prelearning expand()
Definition TreeNode.C:155
TreeNode::childNodesChanged
void childNodesChanged()
Rerender when children have changed.
Definition TreeNode.C:102
TreeNode::imageLine_
static std::string imageLine_[]
Definition TreeNode.h:18
TreeNode::expandIcon_
IconPair * expandIcon_
The icon for expanding or collapsing.
Definition TreeNode.h:105
TreeNode::wasCollapsed_
bool wasCollapsed_
Was collapsed (for undo of prelearned collapse() and expand() slots.
Definition TreeNode.h:129
TreeNode::layout_
WTable * layout_
Layout (2x2 table).
Definition TreeNode.h:102
TreeNode::imagePlus_
static std::string imagePlus_[]
Definition TreeNode.h:20
TreeNode::TreeNode
TreeNode(const std::string labelText, TextFormat labelFormat, std::unique_ptr< IconPair > labelIcon)
Construct a tree node with the given label.
Definition TreeNode.C:25
TreeNode::collapse
void collapse()
Collapses this node.
Definition TreeNode.C:118
TreeNode::isLastChildNode
bool isLastChildNode() const
Returns if is the last child within its parent (is rendered differently)
Definition TreeNode.C:73
TreeNode::expandedContent_
WContainerWidget * expandedContent_
The container in which the children are managed.
Definition TreeNode.h:117
TreeNode::childNodes
const std::vector< TreeNode * > & childNodes() const
Returns the list of children.
Definition TreeNode.h:84
TreeNode::ImageIndex
ImageIndex
Two sets of images, for a normal node, and for the last node.
Definition TreeNode.h:138
TreeNode::Last
@ Last
Definition TreeNode.h:138
TreeNode::Middle
@ Middle
Definition TreeNode.h:138
TreeNode::childCountLabel_
WText * childCountLabel_
The children count '(x)' for x children.
Definition TreeNode.h:114
TreeNode::imageMin_
static std::string imageMin_[]
Definition TreeNode.h:22
TreeNode::expand
void expand()
Expands this node.
Definition TreeNode.C:128
TreeNode::addChildNode
void addChildNode(std::unique_ptr< TreeNode > node)
Adds a child node.
Definition TreeNode.C:81
TreeNode::parentNode_
TreeNode * parentNode_
The parent node.
Definition TreeNode.h:99
TreeNode::adjustExpandIcon
void adjustExpandIcon()
Adjust the expand icon.
Definition TreeNode.C:172
TreeNode::labelIcon_
IconPair * labelIcon_
The icon next to the label.
Definition TreeNode.h:111
TreeNode::noExpandIcon_
WImage * noExpandIcon_
The single image shown instead of the expand/collapse icon when no children.
Definition TreeNode.h:108
Wt
Definition AddresseeEdit.h:16