Wt examples 3.3.12
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DemoTreeList Class Reference

A demonstration of the treelist. More...

#include <DemoTreeList.h>

Inheritance diagram for DemoTreeList:
Inheritance graph
[legend]

Public Member Functions

 DemoTreeList (Wt::WContainerWidget *parent)
 Create a DemoTreeList.
 
- Public Member Functions inherited from Wt::WContainerWidget
 WContainerWidget (WContainerWidget *parent=0)
 
 ~WContainerWidget ()
 
void setLayout (WLayout *layout)
 
void setLayout (WLayout *layout, WFlags< AlignmentFlag > alignment)
 
WLayoutlayout ()
 
virtual void addWidget (WWidget *widget)
 
virtual void insertBefore (WWidget *widget, WWidget *before)
 
virtual void insertWidget (int index, WWidget *widget)
 
virtual void removeWidget (WWidget *widget)
 
virtual void clear ()
 
virtual int indexOf (WWidget *widget) const
 
virtual WWidgetwidget (int index) const
 
virtual int count () const
 
void setContentAlignment (WFlags< AlignmentFlag > contentAlignment)
 
void setPadding (const WLength &padding, WFlags< Side > sides=All)
 
WLength padding (Side side) const
 
WFlags< AlignmentFlagcontentAlignment () const
 
void setOverflow (Overflow overflow, WFlags< Orientation > orientation=(Horizontal|Vertical))
 
void setList (bool list, bool ordered=false)
 
bool isList () const
 
bool isUnorderedList () const
 
bool isOrderedList () const
 
EventSignal< WScrollEvent > & scrolled ()
 
int scrollTop () const
 
int scrollLeft () const
 
- Public Member Functions inherited from Wt::WInteractWidget
 WInteractWidget (WContainerWidget *parent=0)
 
EventSignal< WKeyEvent > & keyWentDown ()
 
EventSignal< WKeyEvent > & keyPressed ()
 
EventSignal< WKeyEvent > & keyWentUp ()
 
EventSignalenterPressed ()
 
EventSignalescapePressed ()
 
EventSignal< WMouseEvent > & clicked ()
 
EventSignal< WMouseEvent > & doubleClicked ()
 
EventSignal< WMouseEvent > & mouseWentDown ()
 
EventSignal< WMouseEvent > & mouseWentUp ()
 
EventSignal< WMouseEvent > & mouseWentOut ()
 
EventSignal< WMouseEvent > & mouseWentOver ()
 
EventSignal< WMouseEvent > & mouseMoved ()
 
EventSignal< WMouseEvent > & mouseDragged ()
 
EventSignal< WMouseEvent > & mouseWheel ()
 
EventSignal< WTouchEvent > & touchStarted ()
 
EventSignal< WTouchEvent > & touchEnded ()
 
EventSignal< WTouchEvent > & touchMoved ()
 
EventSignal< WGestureEvent > & gestureStarted ()
 
EventSignal< WGestureEvent > & gestureChanged ()
 
EventSignal< WGestureEvent > & gestureEnded ()
 
void setDraggable (const std::string &mimeType, WWidget *dragWidget=0, bool isDragWidgetOnly=false, WObject *sourceWidget=0)
 
void unsetDraggable ()
 
void setMouseOverDelay (int delay)
 
int mouseOverDelay () const
 
virtual void setPopup (bool popup)
 
virtual void load ()
 
virtual bool isEnabled () const
 
- Public Member Functions inherited from Wt::WWebWidget
 WWebWidget (WContainerWidget *parent=0)
 
virtual void setPositionScheme (PositionScheme scheme)
 
virtual PositionScheme positionScheme () const
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 
virtual WLength offset (Side s) const
 
virtual void resize (const WLength &width, const WLength &height)
 
virtual WLength width () const
 
virtual WLength height () const
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 
virtual WLength minimumWidth () const
 
virtual WLength minimumHeight () const
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 
virtual WLength maximumWidth () const
 
virtual WLength maximumHeight () const
 
virtual void setLineHeight (const WLength &height)
 
virtual WLength lineHeight () const
 
virtual void setFloatSide (Side s)
 
virtual Side floatSide () const
 
virtual void setClearSides (WFlags< Side > sides)
 
virtual WFlags< SideclearSides () const
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 
virtual WLength margin (Side side) const
 
virtual void setHiddenKeepsGeometry (bool enabled)
 
virtual bool hiddenKeepsGeometry () const
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 
virtual bool isHidden () const
 
virtual bool isVisible () const
 
virtual void setDisabled (bool disabled)
 
virtual bool isDisabled () const
 
virtual bool isPopup () const
 
virtual void setInline (bool isInline)
 
virtual bool isInline () const
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 
virtual WCssDecorationStyledecorationStyle ()
 
virtual void setStyleClass (const WString &styleClass)
 
virtual WString styleClass () const
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 
virtual bool hasStyleClass (const WString &styleClass) const
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength())
 
virtual AlignmentFlag verticalAlignment () const
 
virtual WLength verticalAlignmentLength () const
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 
virtual WString toolTip () const
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 
virtual WString attributeValue (const std::string &name) const
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 
virtual std::string javaScriptMember (const std::string &name) const
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 
virtual bool loaded () const
 
virtual void setId (const std::string &id)
 
virtual WWidgetfind (const std::string &name)
 
virtual WWidgetfindById (const std::string &id)
 
virtual void setSelectable (bool selectable)
 
virtual void doJavaScript (const std::string &javascript)
 
virtual const std::string id () const
 
void setLoadLaterWhenInvisible (bool)
 
std::string htmlTagName () const
 
void setHtmlTagName (const std::string &tag)
 
const std::vector< WWidget * > & children () const
 
SignalchildrenChanged ()
 
virtual void setCanReceiveFocus (bool enabled)
 
virtual bool canReceiveFocus () const
 
virtual bool setFirstFocus ()
 
virtual void setFocus (bool focus)
 
virtual bool hasFocus () const
 
virtual void setTabIndex (int index)
 
virtual int tabIndex () const
 
EventSignalblurred ()
 
EventSignalfocussed ()
 
virtual bool scrollVisibilityEnabled () const WT_CXX11ONLY(final override)
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(final override)
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(final override)
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(final override)
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(final override)
 
virtual bool isScrollVisible () const WT_CXX11ONLY(final override)
 
virtual void setThemeStyleEnabled (bool enabled)
 
virtual bool isThemeStyleEnabled () const
 
virtual void removeChild (WObject *child)
 
void setFocus ()
 
virtual void setFocus (bool focus)=0
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 
std::string jsRef () const
 
void setFocus ()
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 
virtual void stopAcceptDrops (const std::string &mimeType)
 
virtual void setObjectName (const std::string &name)
 
virtual void htmlText (std::ostream &out)
 
bool isRendered () const
 
void hide ()
 
void animateHide (const WAnimation &animation)
 
void show ()
 
void animateShow (const WAnimation &animation)
 
void enable ()
 
void disable ()
 
bool layoutSizeAware () const
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
virtual std::string objectName () const
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
void addChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

Private Member Functions

void addMap ()
 Add a map.
 
void removeMap ()
 Remove a map.
 
TreeNodemakeTreeMap (const std::string name, TreeNode *parent)
 Create a "map" node, and insert in the given parent.
 
TreeNodemakeTreeFile (const std::string name, TreeNode *parent)
 Create a "file" node, and insert in the given parent.
 

Private Attributes

TreeNodetree_
 
TreeNodetestMap_
 
int testCount_
 
Wt::WPushButtonaddMapButton_
 
Wt::WPushButtonremoveMapButton_
 

Additional Inherited Members

- Public Types inherited from Wt::WContainerWidget
enum  Overflow
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWebWidget
static WString escapeText (const WString &text, bool newlinesToo=false)
 
static std::string & escapeText (std::string &text, bool newlinestoo=false)
 
static bool removeScript (WString &text)
 
static std::string jsStringLiteral (const std::string &v, char delimiter='\'')
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 
- Public Attributes inherited from Wt::WContainerWidget
 OverflowVisible
 
 OverflowAuto
 
 OverflowHidden
 
 OverflowScroll
 
- Protected Member Functions inherited from Wt::WContainerWidget
virtual void removeChild (WObject *child)
 
- Protected Member Functions inherited from Wt::WInteractWidget
virtual void propagateSetEnabled (bool enabled)
 
- Protected Member Functions inherited from Wt::WWebWidget
virtual void enableAjax ()
 
virtual WStatelessSlot * getStateless (Method method)
 
virtual void render (WFlags< RenderFlag > flags)
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
virtual void layoutSizeChanged (int width, int height)
 
 WWidget (WContainerWidget *parent=0)
 
virtual void dropEvent (WDropEvent dropEvent)
 
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 

Detailed Description

A demonstration of the treelist.

This is the main class for the treelist example.

Definition at line 27 of file DemoTreeList.h.

Constructor & Destructor Documentation

◆ DemoTreeList()

DemoTreeList::DemoTreeList ( Wt::WContainerWidget parent)

Create a DemoTreeList.

Definition at line 20 of file DemoTreeList.C.

22 testCount_(0)
23{
25 (new WText("<h2>Wt Tree List example</h2>"
26 "<p>This is a simple demo of a treelist, implemented using"
27 " <a href='http://witty.sourceforge.net/'>Wt</a>.</p>"
28 "<p>The leafs of the tree contain the source code of the "
29 "tree-list in the classes <b>TreeNode</b> and "
30 "<b>IconPair</b>, as well as the implementation of this "
31 "demo itself in the class <b>DemoTreeList</b>.</p>"));
32
33 tree_ = makeTreeMap("Examples", 0);
35
36 TreeNode *treelist = makeTreeMap("Tree List", tree_);
37 TreeNode *wstateicon = makeTreeMap("class IconPair", treelist);
38 makeTreeFile("<a href=\"IconPair.h\">IconPair.h</a>", wstateicon);
39 makeTreeFile("<a href=\"IconPair.C\">IconPair.C</a>", wstateicon);
40 TreeNode *wtreenode = makeTreeMap("class TreeNode", treelist);
41 makeTreeFile("<a href=\"TreeNode.h\">TreeNode.h</a>", wtreenode);
42 makeTreeFile("<a href=\"TreeNode.C\">TreeNode.C</a>", wtreenode);
43 TreeNode *demotreelist = makeTreeMap("class DemoTreeList", treelist);
44 makeTreeFile("<a href=\"DemoTreeList.h\">DemoTreeList.h</a>", demotreelist);
45 makeTreeFile("<a href=\"DemoTreeList.C\">DemoTreeList.C</a>", demotreelist);
46
47 testMap_ = makeTreeMap("Test map", tree_);
48
49 /*
50 * Buttons to dynamically demonstrate changing the tree contents.
51 */
53 (new WText("<p>Use the following buttons to change the tree "
54 "contents:</p>"));
55
57 = new WPushButton("Add map", this);
59
61 = new WPushButton("Remove map", this);
64
66 (new WText("<p>Remarks:"
67 "<ul>"
68 "<li><p>This is not the instantiation of a pre-defined "
69 "tree list component, but the full implementation of such "
70 "a component, in about 350 lines of C++ code !</p> "
71 "<p>In comparison, the <a href='http://myfaces.apache.org'> "
72 "Apache MyFaces</a> JSF implementation of tree2, with similar "
73 "functionality, uses about 2400 lines of Java, and 140 lines "
74 "of JavaScript code.</p></li>"
75 "<li><p>Once loaded, the tree list does not require any "
76 "interaction with the server for handling the click events on "
77 "the <img src='icons/nav-plus-line-middle.gif' /> and "
78 "<img src='icons/nav-minus-line-middle.gif' /> icons, "
79 "because these events have been connected to slots using "
80 "STATIC connections. Such connections are converted to the "
81 "appropriate JavaScript code that is inserted into the page. "
82 "Still, the events are signaled to the server to update the "
83 "application state.</p></li>"
84 "<li><p>In contrast, the buttons for manipulating the tree "
85 "contents use DYNAMIC connections, and thus the update "
86 "is computed at server-side, and communicated back to the "
87 "browser (by default using AJAX).</p></li>"
88 "<li><p>When loading a page, only visible widgets (that are not "
89 "<b>setHidden(true)</b>) are transmitted. "
90 "The remaining widgets are loaded in the background after "
91 "rendering the page. "
92 "As a result the application is loaded as fast as possible.</p>"
93 "</li>"
94 "<li><p>The browser reload button is supported and behaves as "
95 "expected: the page is reloaded from the server. Again, "
96 "only visible widgets are transmitted immediately.</p> "
97 "<p>(For the curious, this is the way to see the actual "
98 "HTML/JavaScript code !)</p></li>"
99 "</ul></p>"));
100}
void removeMap()
Remove a map.
Wt::WPushButton * addMapButton_
void addMap()
Add a map.
TreeNode * tree_
Wt::WPushButton * removeMapButton_
TreeNode * makeTreeMap(const std::string name, TreeNode *parent)
Create a "map" node, and insert in the given parent.
TreeNode * makeTreeFile(const std::string name, TreeNode *parent)
Create a "file" node, and insert in the given parent.
TreeNode * testMap_
Example implementation of a single tree list node.
Definition TreeNode.h:56
virtual void addWidget(WWidget *widget)
EventSignal< WMouseEvent > & clicked()
void disable()
WWidget * parent() const

Member Function Documentation

◆ addMap()

void DemoTreeList::addMap ( )
private

Add a map.

Definition at line 102 of file DemoTreeList.C.

103{
104 TreeNode *node
105 = makeTreeMap("Map " + boost::lexical_cast<std::string>(++testCount_),
106 testMap_);
107 makeTreeFile("File " + boost::lexical_cast<std::string>(testCount_),
108 node);
109
111}
void enable()

◆ makeTreeFile()

TreeNode * DemoTreeList::makeTreeFile ( const std::string  name,
TreeNode parent 
)
private

Create a "file" node, and insert in the given parent.

Definition at line 143 of file DemoTreeList.C.

145{
146 IconPair *labelIcon
147 = new IconPair("icons/document.png", "icons/yellow-folder-open.png",
148 false);
149
150 TreeNode *node = new TreeNode(name, XHTMLText, labelIcon, 0);
151 if (parent)
152 parent->addChildNode(node);
153
154 return node;
155}
An icon pair (identical to WIconPair)
Definition IconPair.h:35
XHTMLText

◆ makeTreeMap()

TreeNode * DemoTreeList::makeTreeMap ( const std::string  name,
TreeNode parent 
)
private

Create a "map" node, and insert in the given parent.

Definition at line 129 of file DemoTreeList.C.

130{
131 IconPair *labelIcon
132 = new IconPair("icons/yellow-folder-closed.png",
133 "icons/yellow-folder-open.png",
134 false);
135
136 TreeNode *node = new TreeNode(name, PlainText, labelIcon, 0);
137 if (parent)
138 parent->addChildNode(node);
139
140 return node;
141}
PlainText

◆ removeMap()

void DemoTreeList::removeMap ( )
private

Remove a map.

Definition at line 113 of file DemoTreeList.C.

114{
115 int numMaps = testMap_->childNodes().size();
116
117 if (numMaps > 0) {
118 int c = rand() % numMaps;
119
120 TreeNode *child = testMap_->childNodes()[c];
122 delete child;
123
124 if (numMaps == 1)
126 }
127}
const std::vector< TreeNode * > & childNodes() const
Returns the list of children.
Definition TreeNode.h:82
void removeChildNode(TreeNode *node)
Removes a child node.
Definition TreeNode.C:96

Member Data Documentation

◆ addMapButton_

Wt::WPushButton* DemoTreeList::addMapButton_
private

Definition at line 39 of file DemoTreeList.h.

◆ removeMapButton_

Wt::WPushButton* DemoTreeList::removeMapButton_
private

Definition at line 40 of file DemoTreeList.h.

◆ testCount_

int DemoTreeList::testCount_
private

Definition at line 37 of file DemoTreeList.h.

◆ testMap_

TreeNode* DemoTreeList::testMap_
private

Definition at line 36 of file DemoTreeList.h.

◆ tree_

TreeNode* DemoTreeList::tree_
private

Definition at line 35 of file DemoTreeList.h.


The documentation for this class was generated from the following files:

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