Wt examples  3.3.1
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::WWidget
virtual void setPositionScheme (PositionScheme scheme)=0
 
virtual PositionScheme positionScheme () const =0
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)=0
 
virtual WLength offset (Side side) const =0
 
virtual void resize (const WLength &width, const WLength &height)
 
virtual WLength width () const =0
 
virtual WLength height () const =0
 
virtual void setMinimumSize (const WLength &width, const WLength &height)=0
 
virtual WLength minimumWidth () const =0
 
virtual WLength minimumHeight () const =0
 
virtual void setMaximumSize (const WLength &width, const WLength &height)=0
 
virtual WLength maximumWidth () const =0
 
virtual WLength maximumHeight () const =0
 
virtual void setLineHeight (const WLength &height)=0
 
virtual WLength lineHeight () const =0
 
virtual void setFloatSide (Side s)=0
 
virtual Side floatSide () const =0
 
virtual void setClearSides (WFlags< Side > sides)=0
 
virtual WFlags< SideclearSides () const =0
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)=0
 
virtual WLength margin (Side side) const =0
 
virtual void setHiddenKeepsGeometry (bool enabled)=0
 
virtual bool hiddenKeepsGeometry () const =0
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())=0
 
virtual bool isHidden () const =0
 
virtual bool isVisible () const =0
 
virtual void setDisabled (bool disabled)=0
 
virtual bool isDisabled () const =0
 
virtual bool isEnabled () const =0
 
virtual void setPopup (bool popup)=0
 
virtual bool isPopup () const =0
 
virtual void setInline (bool inlined)=0
 
virtual bool isInline () const =0
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)=0
 
virtual WCssDecorationStyledecorationStyle ()=0
 
virtual void setStyleClass (const WString &styleClass)=0
 
virtual WString styleClass () const =0
 
virtual void addStyleClass (const WString &styleClass, bool force=false)=0
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)=0
 
virtual bool hasStyleClass (const WString &styleClass) const =0
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)=0
 
virtual AlignmentFlag verticalAlignment () const =0
 
virtual WLength verticalAlignmentLength () const =0
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)=0
 
virtual const WStringtoolTip () const =0
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)=0
 
virtual WString attributeValue (const std::string &name) const =0
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)=0
 
virtual std::string javaScriptMember (const std::string &name) const =0
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)=0
 
virtual void load ()=0
 
virtual bool loaded () const =0
 
virtual void setTabIndex (int index)=0
 
virtual int tabIndex () const =0
 
virtual void setId (const std::string &id)=0
 
virtual WWidgetfind (const std::string &name)=0
 
virtual void setSelectable (bool selectable)=0
 
virtual void doJavaScript (const std::string &js)=0
 

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

- Protected Member Functions inherited from Wt::WWidget
virtual void enableAjax ()=0
 
virtual void propagateSetEnabled (bool enabled)=0
 
virtual void render (WFlags< RenderFlag > flags)
 

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

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
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 =0
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)
33  optionNeedReset_->resetLearnedSlots();
34 
35  optionNeedReset_ = 0;
36 }
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 Wed Jun 11 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.7