Wt examples  3.2.1
Public Member Functions | Private Member Functions | Private Attributes
DemoTreeList Class Reference

A demonstration of the treelist. More...

#include <DemoTreeList.h>

Inheritance diagram for DemoTreeList:
Inheritance graph
[legend]

List of all members.

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 ()
 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)
virtual void load ()
virtual bool isEnabled () const
 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 void setPopup (bool popup)
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 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 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 setTabIndex (int index)
virtual int tabIndex () const
virtual void setId (const std::string &id)
virtual WWidgetfind (const std::string &name)
virtual void setSelectable (bool selectable)
virtual void doJavaScript (const std::string &javascript)
virtual const std::string id () const
void setLoadLaterWhenInvisible (bool)
const std::vector< WWidget * > & children () const
SignalchildrenChanged ()
bool isRendered () const
virtual ~WWidget ()
WWidgetparent () const
void setWidth (const WLength &width)
void setHeight (const WLength &height)
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
std::string jsRef () const
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
virtual void stopAcceptDrops (const std::string &mimeType)
virtual void htmlText (std::ostream &out)
void hide ()
void animateHide (const WAnimation &animation)
void show ()
void animateShow (const WAnimation &animation)
void enable ()
void disable ()
bool layoutSizeAware () const
 WObject (WObject *parent=0)
virtual ~WObject ()
void setObjectName (const std::string &name)
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)())
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
void addChild (WObject *child)

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 Attributes inherited from Wt::WContainerWidget
 OverflowVisible
 OverflowAuto
 OverflowHidden
 OverflowScroll
- Protected Member Functions inherited from Wt::WContainerWidget
virtual void propagateSetEnabled (bool enabled)
virtual void enableAjax ()
virtual void removeChild (WObject *child)
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
virtual WStatelessSlot * getStateless (Method method)

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 ( Wt::WContainerWidget parent)

Create a DemoTreeList.

Definition at line 20 of file DemoTreeList.C.

: WContainerWidget(parent),
{
(new WText("<h2>Wt Tree List example</h2>"
"<p>This is a simple demo of a treelist, implemented using"
" <a href='http://witty.sourceforge.net/'>Wt</a>.</p>"
"<p>The leafs of the tree contain the source code of the "
"tree-list in the classes <b>TreeNode</b> and "
"<b>IconPair</b>, as well as the implementation of this "
"demo itself in the class <b>DemoTreeList</b>.</p>"));
tree_ = makeTreeMap("Examples", 0);
TreeNode *treelist = makeTreeMap("Tree List", tree_);
TreeNode *wstateicon = makeTreeMap("class IconPair", treelist);
makeTreeFile("<a href=\"IconPair.h\">IconPair.h</a>", wstateicon);
makeTreeFile("<a href=\"IconPair.C\">IconPair.C</a>", wstateicon);
TreeNode *wtreenode = makeTreeMap("class TreeNode", treelist);
makeTreeFile("<a href=\"TreeNode.h\">TreeNode.h</a>", wtreenode);
makeTreeFile("<a href=\"TreeNode.C\">TreeNode.C</a>", wtreenode);
TreeNode *demotreelist = makeTreeMap("class DemoTreeList", treelist);
makeTreeFile("<a href=\"DemoTreeList.h\">DemoTreeList.h</a>", demotreelist);
makeTreeFile("<a href=\"DemoTreeList.C\">DemoTreeList.C</a>", demotreelist);
testMap_ = makeTreeMap("Test map", tree_);
/*
* Buttons to dynamically demonstrate changing the tree contents.
*/
(new WText("<p>Use the following buttons to change the tree "
"contents:</p>"));
= new WPushButton("Add map", this);
= new WPushButton("Remove map", this);
(new WText("<p>Remarks:"
"<ul>"
"<li><p>This is not the instantiation of a pre-defined "
"tree list component, but the full implementation of such "
"a component, in about 350 lines of C++ code !</p> "
"<p>In comparison, the <a href='http://myfaces.apache.org'> "
"Apache MyFaces</a> JSF implementation of tree2, with similar "
"functionality, uses about 2400 lines of Java, and 140 lines "
"of JavaScript code.</p></li>"
"<li><p>Once loaded, the tree list does not require any "
"interaction with the server for handling the click events on "
"the <img src='icons/nav-plus-line-middle.gif' /> and "
"<img src='icons/nav-minus-line-middle.gif' /> icons, "
"because these events have been connected to slots using "
"STATIC connections. Such connections are converted to the "
"appropriate JavaScript code that is inserted into the page. "
"Still, the events are signaled to the server to update the "
"application state.</p></li>"
"<li><p>In contrast, the buttons for manipulating the tree "
"contents use DYNAMIC connections, and thus the update "
"is computed at server-side, and communicated back to the "
"browser (by default using AJAX).</p></li>"
"<li><p>When loading a page, only visible widgets (that are not "
"<b>setHidden(true)</b>) are transmitted. "
"The remaining widgets are loaded in the background after "
"rendering the page. "
"As a result the application is loaded as fast as possible.</p>"
"</li>"
"<li><p>The browser reload button is supported and behaves as "
"expected: the page is reloaded from the server. Again, "
"only visible widgets are transmitted immediately.</p> "
"<p>(For the curious, this is the way to see the actual "
"HTML/JavaScript code !)</p></li>"
"</ul></p>"));
}

Member Function Documentation

void DemoTreeList::addMap ( )
private

Add a map.

Definition at line 102 of file DemoTreeList.C.

{
TreeNode *node
= makeTreeMap("Map " + boost::lexical_cast<std::string>(++testCount_),
makeTreeFile("File " + boost::lexical_cast<std::string>(testCount_),
node);
}
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.

{
IconPair *labelIcon
= new IconPair("icons/document.png", "icons/yellow-folder-open.png",
false);
TreeNode *node = new TreeNode(name, XHTMLText, labelIcon, 0);
if (parent)
parent->addChildNode(node);
return node;
}
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.

{
IconPair *labelIcon
= new IconPair("icons/yellow-folder-closed.png",
"icons/yellow-folder-open.png",
false);
TreeNode *node = new TreeNode(name, PlainText, labelIcon, 0);
if (parent)
parent->addChildNode(node);
return node;
}
void DemoTreeList::removeMap ( )
private

Remove a map.

Definition at line 113 of file DemoTreeList.C.

{
int numMaps = testMap_->childNodes().size();
if (numMaps > 0) {
int c = rand() % numMaps;
TreeNode *child = testMap_->childNodes()[c];
delete child;
if (numMaps == 1)
}
}

Member Data Documentation

Wt::WPushButton* DemoTreeList::addMapButton_
private

Definition at line 39 of file DemoTreeList.h.

Wt::WPushButton* DemoTreeList::removeMapButton_
private

Definition at line 40 of file DemoTreeList.h.

int DemoTreeList::testCount_
private

Definition at line 37 of file DemoTreeList.h.

TreeNode* DemoTreeList::testMap_
private

Definition at line 36 of file DemoTreeList.h.

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 Tue Jun 19 2012 for the C++ Web Toolkit (Wt) by doxygen 1.8.1