8 #include <Wt/WTableCell.h>
11 #include <Wt/WCssDecorationStyle.h>
19 "icons/line-last.gif" };
21 "icons/nav-plus-line-last.gif" };
23 "icons/nav-minus-line-last.gif" };
27 std::unique_ptr<IconPair> labelIcon)
28 : parentNode_(nullptr),
29 labelIcon_(labelIcon.get())
40 layout_ = setNewImplementation<WTable>();
50 auto labelTextWidget = std::make_unique<WText>(labelText);
51 labelTextWidget->setTextFormat(labelFormat);
52 labelTextWidget->setStyleClass(
"treenodelabel");
54 auto childCountLabel = std::make_unique<WText>();
84 node->parentNode_ =
this;
105 node->adjustExpandIcon();
169 node->undoCollapse();
191 Orientation::Vertical);
194 Orientation::Vertical);
An icon pair (identical to WIconPair)
EventSignal< WMouseEvent > * icon2Clicked
Signal emitted when clicked while in state 1 (icon 2 is shown).
void setState(int num)
Set which icon should be visible.
WImage * icon1() const
Get the first icon image.
WImage * icon2() const
Get the second icon image.
EventSignal< WMouseEvent > * icon1Clicked
Signal emitted when clicked while in state 0 (icon 1 is shown).
Example implementation of a single tree list node.
void undoCollapse()
Undo function for prelearning collapse()
void removeChildNode(TreeNode *node, int index)
Removes a child node.
std::vector< TreeNode * > childNodes_
List of child nodes.
void undoExpand()
Undo function for prelearning expand()
void childNodesChanged()
Rerender when children have changed.
static std::string imageLine_[]
IconPair * expandIcon_
The icon for expanding or collapsing.
bool wasCollapsed_
Was collapsed (for undo of prelearned collapse() and expand() slots.
WTable * layout_
Layout (2x2 table).
static std::string imagePlus_[]
TreeNode(const std::string labelText, TextFormat labelFormat, std::unique_ptr< IconPair > labelIcon)
Construct a tree node with the given label.
void collapse()
Collapses this node.
bool isLastChildNode() const
Returns if is the last child within its parent (is rendered differently)
WContainerWidget * expandedContent_
The container in which the children are managed.
ImageIndex
Two sets of images, for a normal node, and for the last node.
WText * childCountLabel_
The children count '(x)' for x children.
static std::string imageMin_[]
void expand()
Expands this node.
void addChildNode(std::unique_ptr< TreeNode > node)
Adds a child node.
TreeNode * parentNode_
The parent node.
void adjustExpandIcon()
Adjust the expand icon.
IconPair * labelIcon_
The icon next to the label.
WImage * noExpandIcon_
The single image shown instead of the expand/collapse icon when no children.
Wt::Signals::connection connect(F function)
void setBackgroundImage(const WLink &link, WFlags< Orientation > repeat=Orientation::Horizontal|Orientation::Vertical, WFlags< Side > sides=None)
const WLink & imageLink() const
void setImageLink(const WLink &link)
WStatelessSlot * implementStateless(void(T::*method)())
WTableCell * elementAt(int row, int column)
bool setText(const WString &text)