Wt examples  3.3.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ComposeExample Class Reference

Main widget of the Composer example. More...

#include <ComposeExample.h>

Inheritance diagram for ComposeExample:
Inheritance graph
[legend]

Public Member Functions

 ComposeExample (WContainerWidget *parent=0)
 create a new Composer example. More...
 

Private Member Functions

void send ()
 
void discard ()
 

Private Attributes

Composercomposer_
 
WContainerWidget * details_
 

Detailed Description

Main widget of the Composer example.

Definition at line 25 of file ComposeExample.h.

Constructor & Destructor Documentation

ComposeExample::ComposeExample ( WContainerWidget parent = 0)

create a new Composer example.

Definition at line 21 of file ComposeExample.C.

22  : WContainerWidget(parent)
23 {
24  composer_ = new Composer(this);
25 
26  std::vector<Contact> addressBook;
27  addressBook.push_back(Contact(L"Koen Deforche",
28  L"koen.deforche@gmail.com"));
29  addressBook.push_back(Contact(L"Koen alias1",
30  L"koen.alias1@yahoo.com"));
31  addressBook.push_back(Contact(L"Koen alias2",
32  L"koen.alias2@yahoo.com"));
33  addressBook.push_back(Contact(L"Koen alias3",
34  L"koen.alias3@yahoo.com"));
35  addressBook.push_back(Contact(L"Bartje",
36  L"jafar@hotmail.com"));
37  composer_->setAddressBook(addressBook);
38 
39  std::vector<Contact> contacts;
40  contacts.push_back(Contact(L"Koen Deforche", L"koen.deforche@gmail.com"));
41 
42  composer_->setTo(contacts);
43  composer_->setSubject("That's cool! Want to start your own google?");
44 
47 
48  details_ = new WContainerWidget(this);
49 
50  new WText(tr("example.info"), details_);
51 }

Member Function Documentation

void ComposeExample::discard ( )
private

Definition at line 126 of file ComposeExample.C.

127 {
128  WContainerWidget *feedback = new WContainerWidget(this);
129  feedback->setStyleClass("feedback");
130 
131  WContainerWidget *horiz = new WContainerWidget(feedback);
132  new WText("<p>Wise decision! Everyone's mailbox is already full anyway.</p>",
133  horiz);
134 
135  delete composer_;
136  delete details_;
137 
138  wApp->quit();
139 }
void ComposeExample::send ( )
private

Definition at line 53 of file ComposeExample.C.

54 {
55  WContainerWidget *feedback = new WContainerWidget(this);
56  feedback->setStyleClass(L"feedback");
57 
58  WContainerWidget *horiz = new WContainerWidget(feedback);
59  new WText(L"<p>We could have, but did not send the following email:</p>",
60  horiz);
61 
62  std::vector<Contact> contacts = composer_->to();
63  if (!contacts.empty())
64  horiz = new WContainerWidget(feedback);
65  for (unsigned i = 0; i < contacts.size(); ++i) {
66  new WText(L"To: \"" + contacts[i].name + L"\" <"
67  + contacts[i].email + L">", PlainText, horiz);
68  new WBreak(horiz);
69  }
70 
71  contacts = composer_->cc();
72  if (!contacts.empty())
73  horiz = new WContainerWidget(feedback);
74  for (unsigned i = 0; i < contacts.size(); ++i) {
75  new WText(L"Cc: \"" + contacts[i].name + L"\" <"
76  + contacts[i].email + L">", PlainText, horiz);
77  new WBreak(horiz);
78  }
79 
80  contacts = composer_->bcc();
81  if (!contacts.empty())
82  horiz = new WContainerWidget(feedback);
83  for (unsigned i = 0; i < contacts.size(); ++i) {
84  new WText(L"Bcc: \"" + contacts[i].name + L"\" <"
85  + contacts[i].email + L">", PlainText, horiz);
86  new WBreak(horiz);
87  }
88 
89  horiz = new WContainerWidget(feedback);
90  WText *t = new WText("Subject: \"" + composer_->subject() + "\"",
91  PlainText, horiz);
92 
93  std::vector<Attachment> attachments = composer_->attachments();
94  if (!attachments.empty())
95  horiz = new WContainerWidget(feedback);
96  for (unsigned i = 0; i < attachments.size(); ++i) {
97  new WText(L"Attachment: \""
98  + attachments[i].fileName
99  + L"\" (" + attachments[i].contentDescription
100  + L")", PlainText, horiz);
101 
102  unlink(attachments[i].spoolFileName.c_str());
103 
104  new WText(", was in spool file: "
105  + attachments[i].spoolFileName, horiz);
106  new WBreak(horiz);
107  }
108 
109  std::wstring message = composer_->message();
110 
111  horiz = new WContainerWidget(feedback);
112  t = new WText("Message body: ", horiz);
113  new WBreak(horiz);
114 
115  if (!message.empty()) {
116  t = new WText(message, PlainText, horiz);
117  } else
118  t = new WText("<i>(empty)</i>", horiz);
119 
120  delete composer_;
121  delete details_;
122 
123  wApp->quit();
124 }

Member Data Documentation

Composer* ComposeExample::composer_
private

Definition at line 33 of file ComposeExample.h.

WContainerWidget* ComposeExample::details_
private

Definition at line 34 of file ComposeExample.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