Upstream tarball 20080414
[amule.git] / src / EditServerListDlg.cpp
blob109b2005f2ef96c9fc9cfebdf7064431ba83f886
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Drager
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include <wx/dialog.h> // Needed for wxDialog // Do_not_auto_remove
27 #include <wx/sizer.h> // Needed for wxBoxSizer
28 #include <wx/file.h> // Needed for wxFile
29 #include <wx/log.h> // Needed for wxLogSysError
30 #include <wx/textctrl.h>
32 #include "EditServerListDlg.h" // Interface declarations
34 BEGIN_EVENT_TABLE(EditServerListDlg, wxDialog)
35 EVT_BUTTON(wxID_OK, EditServerListDlg::OnOK)
36 END_EVENT_TABLE()
39 EditServerListDlg::EditServerListDlg(wxWindow *parent,
40 const wxString& caption,
41 const wxString& message,
42 const wxString& filename) : wxDialog(parent, -1, caption,
43 wxDefaultPosition, wxSize(400,200),
44 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
46 m_file = filename;
48 wxBeginBusyCursor();
50 wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
52 topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 );
54 m_textctrl = new wxTextCtrl(this, -1, wxEmptyString,
55 wxDefaultPosition,
56 wxDefaultSize,
57 wxTE_MULTILINE);
58 topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 );
60 topsizer->Add( CreateButtonSizer( wxOK | wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
62 SetAutoLayout( TRUE );
63 SetSizer( topsizer );
65 Centre( wxBOTH );
67 if (wxFile::Exists(filename))
68 m_textctrl->LoadFile(filename);
70 m_textctrl->SetFocus();
72 wxEndBusyCursor();
75 EditServerListDlg::~EditServerListDlg()
79 void EditServerListDlg::OnOK(wxCommandEvent& WXUNUSED(event) )
81 if (m_textctrl->SaveFile(m_file))
82 EndModal(1);
83 else
84 wxLogSysError(wxT("Can't write to file '") + m_file + wxT("'"));
86 // File_checked_for_headers