Wt examples  3.7.1
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>
11 #include <Wt/WText>
12 
13 class IconPair;
14 
15 namespace Wt {
16  class WTable;
17  class WImage;
18 }
19 
24 
56 {
57 public:
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 
92 private:
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:34
ImageIndex
Two sets of images, for a normal node, and for the last node.
Definition: TreeNode.h:139
TreeNode * parentNode_
The parent node.
Definition: TreeNode.h:97
Wt::WContainerWidget * expandedContent_
The container in which the children are managed.
Definition: TreeNode.h:118
Wt::WImage * noExpandIcon_
The single image shown instead of the expand/collapse icon when no children.
Definition: TreeNode.h:106
Wt::WTable * layout_
Layout (2x2 table).
Definition: TreeNode.h:100
Wt::WText * childCountLabel_
The children count &#39;(x)&#39; for x children.
Definition: TreeNode.h:115
Wt::WText * labelText_
The label.
Definition: TreeNode.h:112
std::vector< TreeNode * > childNodes_
List of child nodes.
Definition: TreeNode.h:94
IconPair * labelIcon_
The icon next to the label.
Definition: TreeNode.h:109
bool wasCollapsed_
Was collapsed (for undo of prelearned collapse() and expand() slots.
Definition: TreeNode.h:130
IconPair * expandIcon_
The icon for expanding or collapsing.
Definition: TreeNode.h:103
TextFormat
const std::vector< TreeNode * > & childNodes() const
Returns the list of children.
Definition: TreeNode.h:82
Example implementation of a single tree list node.
Definition: TreeNode.h:55

Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13