6 #include <boost/lexical_cast.hpp> 9 #include <Wt/WTableCell> 12 #include <Wt/WCssDecorationStyle> 20 "icons/line-last.gif" };
22 "icons/nav-plus-line-last.gif" };
24 "icons/nav-minus-line-last.gif" };
27 Wt::TextFormat labelFormat,
29 Wt::WContainerWidget *parent)
30 :
Wt::WCompositeWidget(parent),
43 setImplementation(
layout_ =
new Wt::WTable());
64 labelIcon_->setVerticalAlignment(Wt::AlignMiddle);
71 layout_->elementAt(0, 0)->setContentAlignment(Wt::AlignTop);
72 layout_->elementAt(0, 1)->setContentAlignment(Wt::AlignMiddle);
116 ->setText(
"(" + boost::lexical_cast<std::string>(
childNodes_.size())
191 ->decorationStyle().setBackgroundImage(
"");
193 ->decorationStyle().setBackgroundImage(
"");
196 ->decorationStyle().setBackgroundImage(
"icons/line-trunk.gif",
197 Wt::WCssDecorationStyle::RepeatY);
199 ->decorationStyle().setBackgroundImage(
"icons/line-trunk.gif",
200 Wt::WCssDecorationStyle::RepeatY);
An icon pair (identical to WIconPair)
void undoExpand()
Undo function for prelearning expand()
Wt::WImage * icon1() const
Get the first icon image.
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.
TreeNode * parentNode_
The parent node.
void setState(int num)
Set which icon should be visible.
Wt::WContainerWidget * expandedContent_
The container in which the children are managed.
Wt::WImage * icon2() const
Get the second icon image.
Wt::WImage * noExpandIcon_
The single image shown instead of the expand/collapse icon when no children.
Wt::EventSignal< Wt::WMouseEvent > & icon1Clicked
Signal emitted when clicked while in state 0 (icon 1 is shown).
Wt::WTable * layout_
Layout (2x2 table).
Wt::WText * childCountLabel_
The children count '(x)' for x children.
Wt::WText * labelText_
The label.
std::vector< TreeNode * > childNodes_
List of child nodes.
static std::string imageMin_[]
IconPair * labelIcon_
The icon next to the label.
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)
void addChildNode(TreeNode *node)
Adds a child node.
IconPair * expandIcon_
The icon for expanding or collapsing.
Wt::EventSignal< Wt::WMouseEvent > & icon2Clicked
Signal emitted when clicked while in state 1 (icon 2 is shown).
static std::string imageLine_[]
void childNodesChanged()
Rerender when children have changed.
static std::string imagePlus_[]
TreeNode(const std::string labelText, Wt::TextFormat labelFormat, IconPair *labelIcon, Wt::WContainerWidget *parent=0)
Construct a tree node with the given label.
void removeChildNode(TreeNode *node)
Removes a child node.
void adjustExpandIcon()
Adjust the expand icon.
Example implementation of a single tree list node.
void collapse()
Collapses this node.