00001 // This may look like C code, but it's really -*- C++ -*- 00002 /* 00003 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium. 00004 * 00005 * See the LICENSE file for terms of use. 00006 */ 00007 #ifndef COMPOSER_H_ 00008 #define COMPOSER_H_ 00009 00010 #include <Wt/WCompositeWidget> 00011 00012 #include "Contact.h" 00013 #include "Attachment.h" 00014 00015 namespace Wt { 00016 class WLineEdit; 00017 class WPushButton; 00018 class WTable; 00019 class WText; 00020 class WTextArea; 00021 } 00022 00023 class AddresseeEdit; 00024 class AttachmentEdit; 00025 class ContactSuggestions; 00026 class OptionList; 00027 class Option; 00028 00029 using namespace Wt; 00030 00035 00040 class Composer : public WCompositeWidget 00041 { 00042 public: 00045 Composer(WContainerWidget *parent = 0); 00046 00049 void setTo(const std::vector<Contact>& to); 00050 00053 void setSubject(const WString& subject); 00054 00057 void setMessage(const WString& message); 00058 00061 void setAddressBook(const std::vector<Contact>& addressBook); 00062 00065 std::vector<Contact> to() const; 00066 00069 std::vector<Contact> cc() const; 00070 00073 std::vector<Contact> bcc() const; 00074 00077 const WString& subject() const; 00078 00084 std::vector<Attachment> attachments() const; 00085 00088 const WString& message() const; 00089 00090 public: 00093 Wt::Signal<void> send; 00094 00097 Wt::Signal<void> discard; 00098 00099 private: 00100 WContainerWidget *layout_; 00101 00102 WPushButton *topSendButton_, *topSaveNowButton_, *topDiscardButton_; 00103 WPushButton *botSendButton_, *botSaveNowButton_, *botDiscardButton_; 00104 WText *statusMsg_; 00105 00106 WTable *edits_; 00107 00109 AddresseeEdit *toEdit_; 00111 AddresseeEdit *ccEdit_; 00113 AddresseeEdit *bccEdit_; 00114 00116 ContactSuggestions *contactSuggestions_; 00117 00119 WLineEdit *subject_; 00120 00122 OptionList *options_; 00123 00125 Option *addcc_; 00127 Option *addbcc_; 00129 Option *attachFile_; 00131 Option *attachOtherFile_; 00132 00134 std::vector<AttachmentEdit *> attachments_; 00135 00137 WTextArea *message_; 00138 00140 bool saving_, sending_; 00141 00143 int attachmentsPending_; 00144 00147 void attachMore(); 00148 00151 void removeAttachment(AttachmentEdit *attachment); 00152 00157 void sendIt(); 00158 00164 void saveNow(); 00165 00170 void discardIt(); 00171 00179 void attachmentDone(); 00180 00181 private: 00182 // create the user-interface 00183 void createUi(); 00184 00188 void saved(); 00189 00192 void setStatus(const WString& text, const WString& style); 00193 00194 friend class AttachmentEdit; 00195 }; 00196 00199 #endif // COMPOSER_H_