Wt examples 3.3.12
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 bvba, Kessel-Lo, 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>
11#include <Wt/WText>
12
13class IconPair;
14
15namespace Wt {
16 class WTable;
17 class WImage;
18}
24
56{
57public:
68 TreeNode(const std::string labelText,
69 Wt::TextFormat labelFormat,
70 IconPair *labelIcon, Wt::WContainerWidget *parent = 0);
71
74 void addChildNode(TreeNode *node);
75
78 void removeChildNode(TreeNode *node);
79
82 const std::vector<TreeNode *>& childNodes() const { return childNodes_; }
83
86 void collapse();
87
90 void expand();
91
92private:
94 std::vector<TreeNode *> childNodes_;
95
98
101
104
107
110
113
116
119
121 void adjustExpandIcon();
122
124 bool isLastChildNode() const;
125
127 void childNodesChanged();
128
131
133 void undoCollapse();
134
136 void undoExpand();
137
139 enum ImageIndex { Middle = 0, Last = 1 };
140
141 static std::string imageLine_[];
142 static std::string imagePlus_[];
143 static std::string imageMin_[];
144}; //
145
148#endif // WTREENODE_H_
An icon pair (identical to WIconPair)
Definition IconPair.h:35
Example implementation of a single tree list node.
Definition TreeNode.h:56
void undoCollapse()
Undo function for prelearning collapse()
Definition TreeNode.C:150
Wt::WContainerWidget * expandedContent_
The container in which the children are managed.
Definition TreeNode.h:118
std::vector< TreeNode * > childNodes_
List of child nodes.
Definition TreeNode.h:94
void undoExpand()
Undo function for prelearning expand()
Definition TreeNode.C:161
Wt::WTable * layout_
Layout (2x2 table).
Definition TreeNode.h:100
void childNodesChanged()
Rerender when children have changed.
Definition TreeNode.C:107
static std::string imageLine_[]
Definition TreeNode.h:19
IconPair * expandIcon_
The icon for expanding or collapsing.
Definition TreeNode.h:103
bool wasCollapsed_
Was collapsed (for undo of prelearned collapse() and expand() slots.
Definition TreeNode.h:130
Wt::WText * childCountLabel_
The children count '(x)' for x children.
Definition TreeNode.h:115
static std::string imagePlus_[]
Definition TreeNode.h:21
void collapse()
Collapses this node.
Definition TreeNode.C:124
bool isLastChildNode() const
Returns if is the last child within its parent (is rendered differently)
Definition TreeNode.C:78
const std::vector< TreeNode * > & childNodes() const
Returns the list of children.
Definition TreeNode.h:82
ImageIndex
Two sets of images, for a normal node, and for the last node.
Definition TreeNode.h:139
Wt::WText * labelText_
The label.
Definition TreeNode.h:112
Wt::WImage * noExpandIcon_
The single image shown instead of the expand/collapse icon when no children.
Definition TreeNode.h:106
void addChildNode(TreeNode *node)
Adds a child node.
Definition TreeNode.C:86
void removeChildNode(TreeNode *node)
Removes a child node.
Definition TreeNode.C:96
static std::string imageMin_[]
Definition TreeNode.h:23
void expand()
Expands this node.
Definition TreeNode.C:134
TreeNode * parentNode_
The parent node.
Definition TreeNode.h:97
void adjustExpandIcon()
Adjust the expand icon.
Definition TreeNode.C:178
IconPair * labelIcon_
The icon next to the label.
Definition TreeNode.h:109
WWidget * parent() const
TextFormat

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8