Wt examples  4.15.0
Loading...
Searching...
No Matches
OptionList Class Reference

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

#include <OptionList.h>

Inheritance diagram for OptionList:
[legend]

Public Member Functions

 OptionList ()
 Create an OptionList.
void add (std::unique_ptr< Option > option)
 Add an Option to the list.
void update ()
 Updates the stateless implementations after an Option has been hidden or shown.
Public Member Functions inherited from Wt::WContainerWidget
 WContainerWidget ()
 ~WContainerWidget ()
void setLayout (std::unique_ptr< WLayout > layout)
Layout * setLayout (std::unique_ptr< Layout > layout)
WLayout * layout () const
virtual void addWidget (std::unique_ptr< WWidget > widget)
Widget * addWidget (std::unique_ptr< Widget > widget)
Widget * addNew (Args &&...args)
virtual void insertBefore (std::unique_ptr< WWidget > widget, WWidget *before)
Widget * insertBefore (std::unique_ptr< Widget > widget, WWidget *before)
virtual void insertWidget (int index, std::unique_ptr< WWidget > widget)
Widget * insertWidget (int index, std::unique_ptr< Widget > widget)
Widget * insertNew (int index, Args &&...args)
virtual std::unique_ptr< WWidget > removeWidget (WWidget *widget) override
virtual void clear ()
virtual int indexOf (WWidget *widget) const
virtual WWidget * widget (int index) const
virtual int count () const
void setContentAlignment (WFlags< AlignmentFlag > contentAlignment)
void setPadding (const WLength &padding, WFlags< Side > sides=AllSides)
WLength padding (Side side) const
WFlags< AlignmentFlag > contentAlignment () const
void setOverflow (Overflow overflow, WFlags< Orientation > orientation=(Orientation::Horizontal|Orientation::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
std::unique_ptr< Widget > removeWidget (Widget *widget)
Public Member Functions inherited from Wt::WInteractWidget
 WInteractWidget ()
EventSignal< WKeyEvent > & keyWentDown ()
EventSignal< WKeyEvent > & keyPressed ()
EventSignal< WKeyEvent > & keyWentUp ()
EventSignal & enterPressed ()
EventSignal & escapePressed ()
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=nullptr, bool isDragWidgetOnly=false, WObject *sourceWidget=nullptr)
void unsetDraggable ()
void setMouseOverDelay (int delay)
int mouseOverDelay () const
virtual void setPopup (bool popup) override
virtual void load () override
virtual bool isEnabled () const override
Public Member Functions inherited from Wt::WWebWidget
 WWebWidget ()
virtual std::vector< WWidget * > children () const override
Signal & childrenChanged ()
virtual void setPositionScheme (PositionScheme scheme) override
virtual PositionScheme positionScheme () const override
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override
virtual WLength offset (Side s) const override
virtual void resize (const WLength &width, const WLength &height) override
virtual WLength width () const override
virtual WLength height () const override
virtual void setMinimumSize (const WLength &width, const WLength &height) override
virtual WLength minimumWidth () const override
virtual WLength minimumHeight () const override
virtual void setMaximumSize (const WLength &width, const WLength &height) override
virtual WLength maximumWidth () const override
virtual WLength maximumHeight () const override
void anchorAt (WWidget *widget, Orientation orientation=Orientation::Vertical) override
virtual void setLineHeight (const WLength &height) override
virtual WLength lineHeight () const override
virtual void setFloatSide (Side s) override
virtual Side floatSide () const override
virtual void setClearSides (WFlags< Side > sides) override
virtual WFlags< Side > clearSides () const override
virtual void setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override
virtual WLength margin (Side side) const override
virtual void setHiddenKeepsGeometry (bool enabled) override
virtual bool hiddenKeepsGeometry () const override
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation()) override
virtual bool isHidden () const override
virtual bool isVisible () const override
virtual void setDisabled (bool disabled) override
virtual bool isDisabled () const override
virtual bool isPopup () const override
std::string positionAnchorName () const override
void becomePositionAnchor () override
void setPositionAnchor (const std::string &anchorName) override
void setPositionAnchor (WWidget *anchor) override
std::string positionAnchor () const override
virtual void setInline (bool isInline) override
virtual bool isInline () const override
virtual void setDecorationStyle (const WCssDecorationStyle &style) override
virtual WCssDecorationStyle & decorationStyle () override
virtual void setStyleClass (const WString &styleClass) override
virtual WString styleClass () const override
virtual void addStyleClass (const WString &styleClass, bool force=false) override
virtual void removeStyleClass (const WString &styleClass, bool force=false) override
virtual bool hasStyleClass (const WString &styleClass) const override
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) override
virtual AlignmentFlag verticalAlignment () const override
virtual WLength verticalAlignmentLength () const override
virtual void setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
virtual WString toolTip () const override
void showToolTipOnHover (bool enable)
void showToolTip ()
void hideToolTip ()
virtual void refresh () override
virtual void setAttributeValue (const std::string &name, const WString &value) override
virtual WString attributeValue (const std::string &name) const override
virtual void setJavaScriptMember (const std::string &name, const std::string &value) override
virtual std::string javaScriptMember (const std::string &name) const override
virtual void callJavaScriptMember (const std::string &name, const std::string &args) override
virtual bool loaded () const override
virtual void setId (const std::string &id) override
virtual WWidget * find (const std::string &name) override
virtual WWidget * findById (const std::string &id) override
virtual void setSelectable (bool selectable) override
virtual void doJavaScript (const std::string &javascript) override
virtual const std::string id () const override
void setLoadLaterWhenInvisible (bool)
std::string htmlTagName () const
void setHtmlTagName (const std::string &tag)
bool resendFormData () override
virtual void setCanReceiveFocus (bool enabled) override
virtual bool canReceiveFocus () const override
virtual bool setFirstFocus () override
virtual void setFocus (bool focus) override
virtual bool hasFocus () const override
virtual void setTabIndex (int index) override
virtual int tabIndex () const override
EventSignal & blurred ()
EventSignal & focussed ()
virtual bool scrollVisibilityEnabled () const final override
virtual void setScrollVisibilityEnabled (bool enabled) final override
virtual int scrollVisibilityMargin () const final override
virtual void setScrollVisibilityMargin (int margin) final override
virtual Signal< bool > & scrollVisibilityChanged () final override
virtual bool isScrollVisible () const final override
virtual void setThemeStyleEnabled (bool enabled) final override
virtual bool isThemeStyleEnabled () const final override
virtual void setObjectName (const std::string &name) override
void setFocus ()
Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
WWidget * parent () const
std::unique_ptr< Widget > removeWidget (Widget *widget)
std::unique_ptr< WWidget > removeFromParent ()
void setWidth (const WLength &width)
void setHeight (const WLength &height)
virtual void positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical, WFlags< Orientation > adjustOrientations=AllOrientations)
bool isPositionAnchor () const
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 htmlText (std::ostream &out)
virtual void htmlText (std::ostream &out, WStringStream &js)
bool isRendered () const
void hide ()
void animateHide (const WAnimation &animation)
void show ()
void animateShow (const WAnimation &animation)
void enable ()
void disable ()
bool layoutSizeAware () const
virtual void scheduleThemeStyleApply (std::shared_ptr< Wt::WTheme > theme, WWidget *child, int role)
virtual void applyThemeStyles ()
Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
Child * addChild (std::unique_ptr< Child > child)
std::unique_ptr< WObject > removeChild (WObject *child)
std::unique_ptr< Child > removeChild (Child *child)
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)
Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
virtual ~observable ()
auto bindSafe (void(C::*method)(Args...)) noexcept
auto bindSafe (void(C::*method)(Args...) const) const noexcept
auto bindSafe (const Function &function) noexcept

Private Member Functions

void optionVisibilityChanged (Option *opt, bool hidden)
 An option changed visibility: possibly update the separators inbetween.

Private Attributes

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

Friends

class Option

Additional Inherited Members

Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
Static Public Member Functions inherited from Wt::WWebWidget
static std::string jsStringLiteral (const std::string &v, char delimiter='\'')
static void setDefaultNativeControl (bool enabled)
static bool defaultNativeControl ()
Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
Static Public Attributes inherited from Wt::WInteractWidget
static const std::string noDefault
Protected Member Functions inherited from Wt::WInteractWidget
void render (WFlags< RenderFlag > flags) override
virtual void propagateSetEnabled (bool enabled) override
Protected Member Functions inherited from Wt::WWebWidget
virtual void enableAjax () override
virtual WStatelessSlot * getStateless (Method method) override
Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
virtual void layoutSizeChanged (int width, int height)
 WWidget ()
virtual void dropEvent (WDropEvent dropEvent)
virtual int boxPadding (Orientation orientation) const
virtual int boxBorder (Orientation orientation) const
void scheduleRender (WFlags< RepaintFlag > flags=None)

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::OptionList ( )

Create an OptionList.

Definition at line 11 of file OptionList.C.

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

Member Function Documentation

◆ add()

void OptionList::add ( std::unique_ptr< Option > option)

Add an Option to the list.

Definition at line 18 of file OptionList.C.

19{
20 Option *optionPtr = option.get();
21 addWidget(std::move(option));
22 optionPtr->setOptionList(this);
23
24 if (!options_.empty()) {
25 options_.back()->addSeparator();
26 }
27
28 options_.push_back(optionPtr);
29}
std::vector< Option * > options_
The list of options.
Definition OptionList.h:58
friend class Option
Definition OptionList.h:66
void setOptionList(OptionList *l)
Definition Option.C:28
virtual void addWidget(std::unique_ptr< WWidget > widget)

◆ optionVisibilityChanged()

void OptionList::optionVisibilityChanged ( Option * opt,
bool hidden )
private

An option changed visibility: possibly update the separators inbetween.

Definition at line 39 of file OptionList.C.

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

◆ update()

void OptionList::update ( )

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

Definition at line 31 of file OptionList.C.

32{
33 if (optionNeedReset_ != 0)
34 optionNeedReset_->resetLearnedSlots();
35
37}

◆ Option

friend class Option
friend

Definition at line 66 of file OptionList.h.

Member Data Documentation

◆ optionNeedReset_

Option* OptionList::optionNeedReset_
private

The option that needs its stateless code updated.

Definition at line 61 of file OptionList.h.

◆ options_

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: