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