Wt examples  4.10.4
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AddresseeEdit Class Reference

An edit field for an email addressee. More...

#include <AddresseeEdit.h>

Inheritance diagram for AddresseeEdit:
[legend]

Public Member Functions

 AddresseeEdit (const WString &label, WContainerWidget *labelParent)
 Create a new addressee edit with the given label. More...
 
void setAddressees (const std::vector< Contact > &contacts)
 Set a list of addressees. More...
 
std::vector< Contactaddressees () const
 Get a list of addressees. More...
 
virtual void setHidden (bool hidden, const WAnimation &animation)
 Reimplement hide() and show() to also hide() and show() the label. More...
 
- Public Member Functions inherited from Wt::WTextArea
 WTextArea ()
 
 WTextArea (const WString &content)
 
void setColumns (int cols)
 
void setRows (int rows)
 
int columns () const
 
int rows () const
 
const WStringtext () const
 
virtual void setText (const WString &text)
 
int selectionStart () const
 
WString selectedText () const
 
bool hasSelectedText () const
 
int cursorPosition () const
 
virtual WString valueText () const override
 
virtual void setValueText (const WString &text) override
 
EventSignaltextInput ()
 
- Public Member Functions inherited from Wt::WFormWidget
 WFormWidget ()
 
 ~WFormWidget ()
 
WLabellabel () const
 
void setValidator (const std::shared_ptr< WValidator > &validator)
 
virtual std::shared_ptr< WValidatorvalidator () const
 
virtual ValidationState validate ()
 
void setEnabled (bool enabled)
 
virtual void setReadOnly (bool readOnly)
 
bool isReadOnly () const
 
virtual void setPlaceholderText (const WString &placeholder)
 
const WStringplaceholderText () const
 
EventSignalchanged ()
 
Signal< WValidator::Result > & validated ()
 
virtual void refresh () override
 
virtual void setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
 
virtual bool canReceiveFocus () const override
 
virtual int tabIndex () const override
 
- Public Member Functions inherited from Wt::WInteractWidget
 WInteractWidget ()
 
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=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
 
SignalchildrenChanged ()
 
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
 
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< SideclearSides () 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 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
 
virtual void setInline (bool isInline) override
 
virtual bool isInline () const override
 
virtual void setDecorationStyle (const WCssDecorationStyle &style) override
 
virtual WCssDecorationStyledecorationStyle () 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 setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
 
virtual WString toolTip () const 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 WWidgetfind (const std::string &name) override
 
virtual WWidgetfindById (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)
 
virtual void setCanReceiveFocus (bool enabled) override
 
virtual bool setFirstFocus () override
 
virtual void setFocus (bool focus) override
 
virtual bool hasFocus () const override
 
virtual void setTabIndex (int index) override
 
EventSignalblurred ()
 
EventSignalfocussed ()
 
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 ()
 
virtual void setFocus (bool focus)=0
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget)
 
std::unique_ptr< Widget > removeWidget (Widget *widget)
 
std::unique_ptr< WWidgetremoveFromParent ()
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation 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 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
void addChild (std::unique_ptr< WObject > child)
 
Child * addChild (std::unique_ptr< Child > child)
 
std::unique_ptr< WObjectremoveChild (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

bool parse (std::vector< Contact > &contacts) const
 Parse the addressees into a list of contacts. More...
 

Private Attributes

Labellabel_
 The label associated with this edit. More...
 

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 Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 
- Protected Member Functions inherited from Wt::WTextArea
virtual int boxPadding (Orientation orientation) const override
 
virtual int boxBorder (Orientation orientation) const override
 
- Protected Member Functions inherited from Wt::WFormWidget
virtual void enableAjax () override
 
virtual void render (WFlags< RenderFlag > flags) override
 
virtual void propagateSetEnabled (bool enabled) override
 
- Protected Member Functions inherited from Wt::WWebWidget
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)
 
void scheduleRender (WFlags< RepaintFlag > flags=None)
 

Detailed Description

An edit field for an email addressee.

This widget is part of the Wt composer example.

Definition at line 31 of file AddresseeEdit.h.

Constructor & Destructor Documentation

◆ AddresseeEdit()

AddresseeEdit::AddresseeEdit ( const WString label,
WContainerWidget labelParent 
)

Create a new addressee edit with the given label.

Constructs also a widget to hold the label in the labelParent. The label will be hidden and shown together with this field.

Definition at line 16 of file AddresseeEdit.C.

17  : WTextArea()
18 {
19  label_ = labelParent->addWidget(std::make_unique<Label>(label, labelParent));
20 
21  setRows(3); setColumns(55);
22  resize(WLength(99, LengthUnit::Percentage), WLength::Auto);
23 
24  setInline(false); // for IE to position the suggestions well
25 }
Label * label_
The label associated with this edit.
Definition: AddresseeEdit.h:54
virtual void addWidget(std::unique_ptr< WWidget > widget)
WLabel * label() const
void setRows(int rows)
void setColumns(int cols)
virtual void resize(const WLength &width, const WLength &height) override
virtual void setInline(bool isInline) override

Member Function Documentation

◆ addressees()

std::vector< Contact > AddresseeEdit::addressees ( ) const

Get a list of addressees.

Definition at line 74 of file AddresseeEdit.C.

75 {
76  std::vector<Contact> result;
77  parse(result);
78 
79  return result;
80 }
bool parse(std::vector< Contact > &contacts) const
Parse the addressees into a list of contacts.
Definition: AddresseeEdit.C:40

◆ parse()

bool AddresseeEdit::parse ( std::vector< Contact > &  contacts) const
private

Parse the addressees into a list of contacts.

Definition at line 40 of file AddresseeEdit.C.

41 {
42  typedef boost::tokenizer<boost::escaped_list_separator<char32_t>,
43  std::wstring::const_iterator, std::wstring>
44  CsvTokenizer;
45 
46  std::wstring t = text();
47  CsvTokenizer tok(t);
48 
49  for (CsvTokenizer::iterator i = tok.begin(); i != tok.end(); ++i) {
50  std::wstring addressee = *i;
51 
52  boost::trim(addressee);
53  std::wstring::size_type pos = addressee.find_last_of(' ');
54  if (pos != std::string::npos) {
55  std::wstring email = addressee.substr(pos + 1);
56  std::wstring name = addressee.substr(0, pos);
57 
58  boost::trim(email);
59  boost::trim(name);
60  if (email[0] == '<')
61  email = email.substr(1);
62  if (email[email.length() - 1] == '>')
63  email = email.substr(0, email.length() - 1);
64 
65  if (!email.empty())
66  contacts.push_back(Contact(Wt::toUTF32(name), Wt::toUTF32(email)));
67  } else
68  if (!addressee.empty())
69  contacts.push_back(Contact(U"", Wt::toUTF32(addressee)));
70  }
71  return true;
72 }
const WString & text() const
std::u32string toUTF32(const std::u16string &s)
An email contact.
Definition: Contact.h:20

◆ setAddressees()

void AddresseeEdit::setAddressees ( const std::vector< Contact > &  contacts)

Set a list of addressees.

Definition at line 27 of file AddresseeEdit.C.

28 {
29  std::u32string text;
30 
31  for (unsigned i = 0; i < contacts.size(); ++i) {
32  if (i != 0)
33  text += U", ";
34  text += contacts[i].formatted();
35  }
36 
37  setText(text);
38 }
virtual void setText(const WString &text)

◆ setHidden()

void AddresseeEdit::setHidden ( bool  hidden,
const WAnimation animation 
)
virtual

Reimplement hide() and show() to also hide() and show() the label.

Reimplemented from Wt::WFormWidget.

Definition at line 82 of file AddresseeEdit.C.

83 {
84  WTextArea::setHidden(hidden, animation);
85  label_->setHidden(hidden, animation);
86 }
virtual void setHidden(bool hidden, const WAnimation &animation=WAnimation()) override

Member Data Documentation

◆ label_

Label* AddresseeEdit::label_
private

The label associated with this edit.

Definition at line 54 of file AddresseeEdit.h.


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