Wt examples  3.3.8
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
OptionList Class Reference

A list of options, separated by '|'. More...

#include <OptionList.h>

Inheritance diagram for OptionList:
Inheritance graph
[legend]

Public Member Functions

 OptionList (WContainerWidget *parent=0)
 Create an OptionList. More...
 
void add (Option *option)
 Add an Option to the list. More...
 
void update ()
 Updates the stateless implementations after an Option has been hidden or shown. More...
 
- 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(finaloverride)
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(finaloverride)
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(finaloverride)
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(finaloverride)
 
virtual bool isScrollVisible () const WT_CXX11ONLY(finaloverride)
 
virtual void setThemeStyleEnabled (bool enabled)
 
virtual bool isThemeStyleEnabled () const
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
virtual void removeChild (WObject *child)
 
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 optionVisibilityChanged (Option *opt, bool hidden)
 An option changed visibility: possibly update the separators inbetween. More...
 

Private Attributes

std::vector< Option * > options_
 The list of options. More...
 
OptionoptionNeedReset_
 The option that needs its stateless code updated. More...
 

Friends

class Option
 

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::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 list of options, separated by '|'.

This widget is part of the Wt composer example.

An OptionList displays a list of Option widgets, which are separated by a '|' separator.

For example, Foo | Bar | Huu

When Options are hidden, the separators are adjusted so that there is no separator after the last visible option. However, this requires a call of update() each time an option is hidden or shown. This is because the removing of separators is optimized in stateless implementations, and thus in client-side JavaScript code. Since the behaviour is not entirely stateless, the update() method resets stateless implementations if necessary.

See also
OptionList

Definition at line 40 of file OptionList.h.

Constructor & Destructor Documentation

OptionList::OptionList ( WContainerWidget parent = 0)

Create an OptionList.

Definition at line 11 of file OptionList.C.

12  : WContainerWidget(parent),
14 {
15  resize(WLength::Auto, WLength(2.5, WLength::FontEx));
16 }
virtual void resize(const WLength &width, const WLength &height)
Option * optionNeedReset_
The option that needs its stateless code updated.
Definition: OptionList.h:61
WContainerWidget(WContainerWidget *parent=0)

Member Function Documentation

void OptionList::add ( Option option)

Add an Option to the list.

Definition at line 18 of file OptionList.C.

19 {
20  addWidget(option);
21  option->setOptionList(this);
22 
23  if (!options_.empty()) {
24  options_.back()->addSeparator();
25  }
26 
27  options_.push_back(option);
28 }
void setOptionList(OptionList *l)
Definition: Option.C:28
std::vector< Option * > options_
The list of options.
Definition: OptionList.h:58
virtual void addWidget(WWidget *widget)
void OptionList::optionVisibilityChanged ( Option opt,
bool  hidden 
)
private

An option changed visibility: possibly update the separators inbetween.

Definition at line 38 of file OptionList.C.

39 {
40  /*
41  * Check if it was the last visible option, in that case the second last
42  * visible option loses its separator.
43  */
44  for (std::size_t i = options_.size() - 1; i > 0; --i) {
45  if (options_[i] == opt) {
46  for (int j = i - 1; j >= 0; --j) {
47  if (!options_[j]->isHidden()) {
48  if (hidden)
49  options_[j]->hideSeparator();
50  else
51  options_[j]->showSeparator();
52  break;
53  }
54  }
55  break;
56  } else
57  if (!options_[i]->isHidden())
58  break;
59  }
60 
61  /*
62  * The Option to the right needs to relearn its stateless
63  * slot code for hide() and show().
64  */
65  for (unsigned i = 0; i < options_.size(); ++i) {
66  if (options_[i] == opt) {
67  for (unsigned j = i + 1; j < options_.size(); ++j) {
68  if (!options_[j]->isHidden()) {
70  break;
71  }
72  }
73 
74  break;
75  }
76  }
77 }
std::vector< Option * > options_
The list of options.
Definition: OptionList.h:58
virtual bool isHidden() const
Option * optionNeedReset_
The option that needs its stateless code updated.
Definition: OptionList.h:61
void OptionList::update ( )

Updates the stateless implementations after an Option has been hidden or shown.

Definition at line 30 of file OptionList.C.

31 {
32  if (optionNeedReset_ != 0)
34 
35  optionNeedReset_ = 0;
36 }
void resetLearnedSlots()
Option * optionNeedReset_
The option that needs its stateless code updated.
Definition: OptionList.h:61

Friends And Related Function Documentation

friend class Option
friend

Definition at line 66 of file OptionList.h.

Member Data Documentation

Option* OptionList::optionNeedReset_
private

The option that needs its stateless code updated.

Definition at line 61 of file OptionList.h.

std::vector<Option *> OptionList::options_
private

The list of options.

Definition at line 58 of file OptionList.h.


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

Generated on Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11