Main Page   Class Hierarchy   Compound List   File List   Compound Members  

wino.cpp

00001 /*
00002  * Purpose: Sample application for demonstrating and testing the wxWindows email support
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006 
00007 #include "wino.h"
00008 #include "snddlg.h"
00009 
00010 static const char sccsid[] = "%W% %G%";
00011 
00012 #include "wino.xpm"
00013 #include "snddlg.h"
00014 
00015 enum {
00016     ID_SEND_BUTTON = 1,
00017     ID_FILE_ADD_BUTTON,
00018     ID_FILE_REMOVE_BUTTON,
00019     ID_ADDRESS_ADD_BUTTON,
00020     ID_ADDRESS_REMOVE_BUTTON
00021 };
00022 
00023 
00024 BEGIN_EVENT_TABLE(WinoDialog, wxDialog)
00025 EVT_BUTTON(ID_SEND_BUTTON, WinoDialog::OnSendButton)
00026 EVT_BUTTON(ID_FILE_ADD_BUTTON, WinoDialog::OnFileAddButton)
00027 EVT_BUTTON(ID_FILE_REMOVE_BUTTON, WinoDialog::OnFileRemoveButton)
00028 EVT_BUTTON(ID_ADDRESS_ADD_BUTTON, WinoDialog::OnAddressAddButton)
00029 EVT_BUTTON(ID_ADDRESS_REMOVE_BUTTON, WinoDialog::OnAddressRemoveButton)
00030 END_EVENT_TABLE()
00031 
00032 
00033 IMPLEMENT_APP(WinoApp)
00034 
00035 
00036 bool WinoApp::OnInit(void)
00037 {
00038     WinoDialog dialog(NULL);
00039     dialog.ShowModal();
00040 
00041     return FALSE;
00042 }
00043 
00044 #include "base64.h"
00045 
00046 WinoDialog::WinoDialog(wxWindow *parent)
00047                : wxDialog(parent, -1,
00048                           _("Wino - Wino Is Not Outlook"),
00049                           wxDefaultPosition,
00050                           wxDefaultSize,
00051                           wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
00052 {
00053 
00054     // TODO: save pointers to member variables in delete it in destructor
00055     wxBoxSizer* pTopSizer = new wxBoxSizer(wxVERTICAL);
00056 
00057     wxBoxSizer* pServerSizer = new wxBoxSizer(wxHORIZONTAL);
00058     pServerSizer->Add(new wxStaticText(this, -1, "SMTP Server:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00059     m_pServerTextCtrl = new wxTextCtrl(this, -1);
00060     pServerSizer->Add(m_pServerTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10);
00061     pTopSizer->Add(pServerSizer, 0, wxEXPAND);
00062 
00063     wxBoxSizer* pFromSizer = new wxBoxSizer(wxHORIZONTAL);
00064     pFromSizer->Add(new wxStaticText(this, -1, "Absender:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00065     m_pFromTextCtrl = new wxTextCtrl(this, -1);
00066     pFromSizer->Add(m_pFromTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10);
00067     pTopSizer->Add(pFromSizer, 0, wxEXPAND);
00068 
00069     wxBoxSizer* pToSizer = new wxBoxSizer(wxHORIZONTAL);
00070     pToSizer->Add(new wxStaticText(this, -1, "An:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00071     m_pToTextCtrl = new wxTextCtrl(this, -1);
00072     pToSizer->Add(m_pToTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10);
00073     pTopSizer->Add(pToSizer, 0, wxEXPAND);
00074 
00075     wxBoxSizer* pSubjectSizer = new wxBoxSizer(wxHORIZONTAL);
00076     pSubjectSizer->Add(new wxStaticText(this, -1, "Betreff:"), 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00077     m_pSubjectTextCtrl = new wxTextCtrl(this, -1);
00078     pSubjectSizer->Add(m_pSubjectTextCtrl, 5, wxLEFT | wxTOP | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER | wxEXPAND, 10);
00079     pTopSizer->Add(pSubjectSizer, 0, wxEXPAND);
00080 
00081     m_pTextTextCtrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(100, 200), wxTE_MULTILINE);
00082     pTopSizer->Add(m_pTextTextCtrl, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10);
00083 
00084     // list ctrls
00085     wxBoxSizer* pListsSizer = new wxBoxSizer(wxHORIZONTAL);
00086     wxBoxSizer* pFilelistSizer = new wxStaticBoxSizer(new wxStaticBox(this, -1, "Dateianhänge"), wxVERTICAL);
00087     wxBoxSizer* pFilelistButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
00088     pFilelistButtonsSizer->Add(new wxButton(this, ID_FILE_ADD_BUTTON, "Datei hinzufügen"), 1, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 10);
00089     pFilelistButtonsSizer->Add(new wxButton(this, ID_FILE_REMOVE_BUTTON, "Markierte entfernen"), 1, wxEXPAND | wxALL, 10);
00090     m_pFilelist = new wxListBox(this, -1, wxDefaultPosition, wxSize(50, 50));
00091     pFilelistSizer->Add(m_pFilelist, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10);
00092     pFilelistSizer->Add(pFilelistButtonsSizer, 0, wxEXPAND);
00093     pListsSizer->Add(pFilelistSizer, 1, wxEXPAND | wxLEFT | wxTOP, 10);
00094     wxBoxSizer* pAddresslistSizer = new wxStaticBoxSizer(new wxStaticBox(this, -1, "Address Manager Dateien"), wxVERTICAL);
00095     wxBoxSizer* pAddresslistButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
00096     pAddresslistButtonsSizer->Add(new wxButton(this, ID_ADDRESS_ADD_BUTTON, "Datei hinzufügen"), 1, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 10);
00097     pAddresslistButtonsSizer->Add(new wxButton(this, ID_ADDRESS_REMOVE_BUTTON, "Markierte entfernen"), 1, wxEXPAND | wxALL, 10);
00098     m_pAddresslist = new wxListBox(this, -1, wxDefaultPosition, wxSize(50, 50));
00099     pAddresslistSizer->Add(m_pAddresslist, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10);
00100     pAddresslistSizer->Add(pAddresslistButtonsSizer, 0, wxEXPAND);
00101     pListsSizer->Add(pAddresslistSizer, 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10);
00102     pTopSizer->Add(pListsSizer, 0, wxEXPAND);
00103 
00104     // send close button
00105     wxBoxSizer* pSendCloseSizer = new wxBoxSizer(wxHORIZONTAL);
00106     pSendCloseSizer->Add(new wxButton(this, ID_SEND_BUTTON, "eMail verschicken"), 0, wxTOP | wxBOTTOM, 10);
00107     wxButton* pCloseButton = new wxButton(this, wxID_CANCEL, "Beenden");
00108     pCloseButton->SetDefault();
00109     pSendCloseSizer->Add(pCloseButton, 0, wxALL, 10);
00110     pTopSizer->Add(pSendCloseSizer, 0, wxALIGN_RIGHT);
00111 
00112     SetAutoLayout(true);
00113     SetSizer(pTopSizer);
00114     pTopSizer->Fit(this);
00115     pTopSizer->SetSizeHints(this);
00116 
00117     // set some default values for testing
00118     m_pServerTextCtrl->SetValue("merlin");  // my local unix server
00119     m_pSubjectTextCtrl->SetValue("");
00120     m_pTextTextCtrl->SetValue("");
00121     m_pFromTextCtrl->SetValue("fb@frank-buss.de");
00122     m_pToTextCtrl->SetValue("somebody@frank-buss.de");
00123 
00124     // show dialog
00125     Centre(wxBOTH | wxCENTRE_ON_SCREEN);
00126 }
00127 
00128 
00129 WinoDialog::~WinoDialog()
00130 {
00131 }
00132 
00133 
00134 void WinoDialog::OnSendButton(wxCommandEvent &event)
00135 {
00136     SendDialog dialog(*this);
00137     dialog.ShowModal();
00138 }
00139 
00140 
00141 void WinoDialog::OnFileAddButton(wxCommandEvent &event)
00142 {
00143     wxFileDialog dialog(this, "Datei Hinzufügen", "", "", "Alle Dateien (*)|*", wxOPEN);
00144     if (dialog.ShowModal() == wxID_OK) {
00145         wxFileName* pFilename = new wxFileName(dialog.GetPath());
00146         m_pFilelist->Append(pFilename->GetFullName(), pFilename);
00147     }
00148 }
00149 
00150 void WinoDialog::OnFileRemoveButton(wxCommandEvent &event)
00151 {
00152     int sel = m_pFilelist->GetSelection();
00153     if (sel != -1) {
00154         wxFileName* pFilename = (wxFileName*) m_pFilelist->GetClientData(sel);
00155         m_pFilelist->Delete(sel);
00156         delete pFilename;
00157     }
00158 }
00159 
00160 void WinoDialog::OnAddressAddButton(wxCommandEvent &event)
00161 {
00162     wxFileDialog dialog(this, "Address Manager Datei Empfängerliste Hinzufügen", "", "", "Address Manager Dateien (*.adm)|*.adm", wxOPEN);
00163     if (dialog.ShowModal() == wxID_OK) {
00164         wxFileName* pFilename = new wxFileName(dialog.GetPath());
00165         m_pAddresslist->Append(pFilename->GetFullName(), pFilename);
00166     }
00167 }
00168 
00169 void WinoDialog::OnAddressRemoveButton(wxCommandEvent &event)
00170 {
00171     int sel = m_pAddresslist->GetSelection();
00172     if (sel != -1) {
00173         wxFileName* pFilename = (wxFileName*) m_pAddresslist->GetClientData(sel);
00174         m_pAddresslist->Delete(sel);
00175         delete pFilename;
00176     }
00177 }
00178 

Generated on Mon May 6 01:14:20 2002 for Wino by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001