Wt examples  3.3.0
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:
Inheritance graph
[legend]

Public Member Functions

 AddresseeEdit (const WString &label, WContainerWidget *parent, 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 (WContainerWidget *parent=0)
 
 WTextArea (const WString &content, WContainerWidget *parent=0)
 
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
 
virtual void setValueText (const WString &text)
 

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

- Protected Member Functions inherited from Wt::WTextArea
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 

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 ( const WString label,
WContainerWidget parent,
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 15 of file AddresseeEdit.C.

17  : WTextArea(parent)
18 {
19  label_ = new Label(label, labelParent);
20 
21  setRows(3); setColumns(55);
22  resize(WLength(99, WLength::Percentage), WLength::Auto);
23 
24  setInline(false); // for IE to position the suggestions well
25 }

Member Function Documentation

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 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<wchar_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(name, email));
67  } else
68  if (!addressee.empty())
69  contacts.push_back(Contact(L"", addressee));
70  }
71  return true;
72 }
void AddresseeEdit::setAddressees ( const std::vector< Contact > &  contacts)

Set a list of addressees.

Definition at line 27 of file AddresseeEdit.C.

28 {
29  std::wstring text;
30 
31  for (unsigned i = 0; i < contacts.size(); ++i) {
32  if (i != 0)
33  text += L", ";
34  text += contacts[i].formatted();
35  }
36 
37  setText(text);
38 }
void AddresseeEdit::setHidden ( bool  hidden,
const WAnimation animation 
)
virtual

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

Implements Wt::WWidget.

Definition at line 82 of file AddresseeEdit.C.

83 {
84  WTextArea::setHidden(hidden, animation);
85  label_->setHidden(hidden, animation);
86 }

Member Data Documentation

Label* AddresseeEdit::label_
private

The label associated with this edit.

Definition at line 55 of file AddresseeEdit.h.


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

Generated on Fri May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1