/* * Purpose: Sample application for demonstrating and testing the wxWindows email support * Author: Frank Buß * Created: 2002 */ #include "wino.h" #include "snddlg.h" static const char sccsid[] = "%W% %G%"; #include "wino.xpm" #include "snddlg.h" enum { ID_SEND_BUTTON = 1, ID_FILE_ADD_BUTTON, ID_FILE_REMOVE_BUTTON, ID_ADDRESS_ADD_BUTTON, ID_ADDRESS_REMOVE_BUTTON }; BEGIN_EVENT_TABLE(WinoDialog, wxDialog) EVT_BUTTON(ID_SEND_BUTTON, WinoDialog::OnSendButton) EVT_BUTTON(ID_FILE_ADD_BUTTON, WinoDialog::OnFileAddButton) EVT_BUTTON(ID_FILE_REMOVE_BUTTON, WinoDialog::OnFileRemoveButton) EVT_BUTTON(ID_ADDRESS_ADD_BUTTON, WinoDialog::OnAddressAddButton) EVT_BUTTON(ID_ADDRESS_REMOVE_BUTTON, WinoDialog::OnAddressRemoveButton) END_EVENT_TABLE() IMPLEMENT_APP(WinoApp) bool WinoApp::OnInit(void) { WinoDialog dialog(NULL); dialog.ShowModal(); return FALSE; } #include "base64.h" WinoDialog::WinoDialog(wxWindow *parent) : wxDialog(parent, -1, _("Wino - Wino Is Not Outlook"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL) { // TODO: save pointers to member variables in delete it in destructor wxBoxSizer* pTopSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* pServerSizer = new wxBoxSizer(wxHORIZONTAL); pServerSizer->Add(new wxStaticText(this, -1, "SMTP Server:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10); m_pServerTextCtrl = new wxTextCtrl(this, -1); pServerSizer->Add(m_pServerTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10); pTopSizer->Add(pServerSizer, 0, wxEXPAND); wxBoxSizer* pFromSizer = new wxBoxSizer(wxHORIZONTAL); pFromSizer->Add(new wxStaticText(this, -1, "Absender:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10); m_pFromTextCtrl = new wxTextCtrl(this, -1); pFromSizer->Add(m_pFromTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10); pTopSizer->Add(pFromSizer, 0, wxEXPAND); wxBoxSizer* pToSizer = new wxBoxSizer(wxHORIZONTAL); pToSizer->Add(new wxStaticText(this, -1, "An:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10); m_pToTextCtrl = new wxTextCtrl(this, -1); pToSizer->Add(m_pToTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10); pTopSizer->Add(pToSizer, 0, wxEXPAND); wxBoxSizer* pSubjectSizer = new wxBoxSizer(wxHORIZONTAL); pSubjectSizer->Add(new wxStaticText(this, -1, "Betreff:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10); m_pSubjectTextCtrl = new wxTextCtrl(this, -1); pSubjectSizer->Add(m_pSubjectTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10); pTopSizer->Add(pSubjectSizer, 0, wxEXPAND); m_pTextTextCtrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(100, 200), wxTE_MULTILINE); pTopSizer->Add(m_pTextTextCtrl, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10); // list ctrls wxBoxSizer* pListsSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* pFilelistSizer = new wxStaticBoxSizer(new wxStaticBox(this, -1, "Dateianhänge"), wxVERTICAL); wxBoxSizer* pFilelistButtonsSizer = new wxBoxSizer(wxHORIZONTAL); pFilelistButtonsSizer->Add(new wxButton(this, ID_FILE_ADD_BUTTON, "Datei hinzufügen"), 1, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 10); pFilelistButtonsSizer->Add(new wxButton(this, ID_FILE_REMOVE_BUTTON, "Markierte entfernen"), 1, wxEXPAND | wxALL, 10); m_pFilelist = new wxListBox(this, -1, wxDefaultPosition, wxSize(50, 50)); pFilelistSizer->Add(m_pFilelist, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10); pFilelistSizer->Add(pFilelistButtonsSizer, 0, wxEXPAND); pListsSizer->Add(pFilelistSizer, 1, wxEXPAND | wxLEFT | wxTOP, 10); wxBoxSizer* pAddresslistSizer = new wxStaticBoxSizer(new wxStaticBox(this, -1, "Address Manager Dateien"), wxVERTICAL); wxBoxSizer* pAddresslistButtonsSizer = new wxBoxSizer(wxHORIZONTAL); pAddresslistButtonsSizer->Add(new wxButton(this, ID_ADDRESS_ADD_BUTTON, "Datei hinzufügen"), 1, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 10); pAddresslistButtonsSizer->Add(new wxButton(this, ID_ADDRESS_REMOVE_BUTTON, "Markierte entfernen"), 1, wxEXPAND | wxALL, 10); m_pAddresslist = new wxListBox(this, -1, wxDefaultPosition, wxSize(50, 50)); pAddresslistSizer->Add(m_pAddresslist, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10); pAddresslistSizer->Add(pAddresslistButtonsSizer, 0, wxEXPAND); pListsSizer->Add(pAddresslistSizer, 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10); pTopSizer->Add(pListsSizer, 0, wxEXPAND); // send close button wxBoxSizer* pSendCloseSizer = new wxBoxSizer(wxHORIZONTAL); pSendCloseSizer->Add(new wxButton(this, ID_SEND_BUTTON, "eMail verschicken"), 0, wxTOP | wxBOTTOM, 10); wxButton* pCloseButton = new wxButton(this, wxID_CANCEL, "Beenden"); pCloseButton->SetDefault(); pSendCloseSizer->Add(pCloseButton, 0, wxALL, 10); pTopSizer->Add(pSendCloseSizer, 0, wxALIGN_RIGHT); SetAutoLayout(true); SetSizer(pTopSizer); pTopSizer->Fit(this); pTopSizer->SetSizeHints(this); // set some default values for testing m_pServerTextCtrl->SetValue("merlin"); // my local unix server m_pSubjectTextCtrl->SetValue(""); m_pTextTextCtrl->SetValue(""); m_pFromTextCtrl->SetValue("fb@frank-buss.de"); m_pToTextCtrl->SetValue("somebody@frank-buss.de"); // show dialog Centre(wxBOTH | wxCENTRE_ON_SCREEN); } WinoDialog::~WinoDialog() { } void WinoDialog::OnSendButton(wxCommandEvent &event) { SendDialog dialog(*this); dialog.ShowModal(); } void WinoDialog::OnFileAddButton(wxCommandEvent &event) { wxFileDialog dialog(this, "Datei Hinzufügen", "", "", "Alle Dateien (*)|*", wxOPEN); if (dialog.ShowModal() == wxID_OK) { wxFileName* pFilename = new wxFileName(dialog.GetPath()); m_pFilelist->Append(pFilename->GetFullName(), pFilename); } } void WinoDialog::OnFileRemoveButton(wxCommandEvent &event) { int sel = m_pFilelist->GetSelection(); if (sel != -1) { wxFileName* pFilename = (wxFileName*) m_pFilelist->GetClientData(sel); m_pFilelist->Delete(sel); delete pFilename; } } void WinoDialog::OnAddressAddButton(wxCommandEvent &event) { wxFileDialog dialog(this, "Address Manager Datei Empfängerliste Hinzufügen", "", "", "Address Manager Dateien (*.adm)|*.adm", wxOPEN); if (dialog.ShowModal() == wxID_OK) { wxFileName* pFilename = new wxFileName(dialog.GetPath()); m_pAddresslist->Append(pFilename->GetFullName(), pFilename); } } void WinoDialog::OnAddressRemoveButton(wxCommandEvent &event) { int sel = m_pAddresslist->GetSelection(); if (sel != -1) { wxFileName* pFilename = (wxFileName*) m_pAddresslist->GetClientData(sel); m_pAddresslist->Delete(sel); delete pFilename; } }