Wt examples  3.3.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FormExample Class Reference

Main widget for the Form example. More...

#include <FormExample.h>

Inheritance diagram for FormExample:
Inheritance graph
[legend]

Public Member Functions

 FormExample (WContainerWidget *parent=0)
 Instantiate a new form example. 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 changeLanguage ()
 Change the language. More...
 
void setLanguage (const std::string lang)
 

Private Attributes

std::vector< WText * > languageSelects_
 

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

Main widget for the Form example.

This class demonstrates, next instantiating the form itself, handling of different languages.

Definition at line 29 of file FormExample.h.

Constructor & Destructor Documentation

FormExample::FormExample ( WContainerWidget parent = 0)

Instantiate a new form example.

Definition at line 14 of file FormExample.C.

15  : WContainerWidget(parent)
16 {
17  WContainerWidget *langLayout = new WContainerWidget(this);
18  langLayout->setContentAlignment(AlignRight);
19  new WText(tr("language"), langLayout);
20 
21  const char *lang[] = { "en", "nl" };
22 
23  for (int i = 0; i < 2; ++i) {
24  WText *t = new WText(widen(lang[i]), langLayout);
25  t->setMargin(5);
26  t->clicked().connect(this, &FormExample::changeLanguage);
27 
28  languageSelects_.push_back(t);
29  }
30 
31  /*
32  * Start with the reported locale, if available
33  */
34  setLanguage(wApp->locale().name());
35 
36  Form *form = new Form(this);
37  form->setMargin(20);
38 }
A simple Form.
Definition: Form.h:35
std::vector< WText * > languageSelects_
Definition: FormExample.h:37
void setLanguage(const std::string lang)
Definition: FormExample.C:40
void changeLanguage()
Change the language.
Definition: FormExample.C:62
virtual void setMargin(const WLength &margin, WFlags< Side > sides=All)=0

Member Function Documentation

void FormExample::changeLanguage ( )
private

Change the language.

Definition at line 62 of file FormExample.C.

63 {
64  WText *t = (WText *)sender();
65  setLanguage(narrow(t->text().value()));
66 }
void setLanguage(const std::string lang)
Definition: FormExample.C:40
void FormExample::setLanguage ( const std::string  lang)
private

Definition at line 40 of file FormExample.C.

41 {
42  bool haveLang = false;
43 
44  for (unsigned i = 0; i < languageSelects_.size(); ++i) {
45  WText *t = languageSelects_[i];
46 
47  // prefix match, e.g. en matches en-us.
48  bool isLang = lang.find(narrow(t->text().value())) == 0;
49  t->setStyleClass(isLang ? L"langcurrent" : L"lang");
50 
51  haveLang = haveLang || isLang;
52  }
53 
54  if (!haveLang) {
55  languageSelects_[0]->setStyleClass(L"langcurrent");
56  WApplication::instance()
57  ->setLocale(narrow(languageSelects_[0]->text().value()));
58  } else
59  WApplication::instance()->setLocale(lang);
60 }
std::vector< WText * > languageSelects_
Definition: FormExample.h:37
virtual void setStyleClass(const WString &styleClass)=0

Member Data Documentation

std::vector<WText *> FormExample::languageSelects_
private

Definition at line 37 of file FormExample.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