#include "ftpro.h"
BEGIN_EVENT_TABLE(SetupDialog,wxDialog)
EVT_BUTTON( ID_SETTINGS_REGULAR_FIND, SetupDialog::OnSettingsReditorFind )
EVT_BUTTON( ID_PREF_REGULAR_DEFAULT, SetupDialog::OnSettingsReditorDefault )
EVT_BUTTON( ID_SETTINGS_FIND_PROGRAMMERS, SetupDialog::OnSettingsPeditorFind )
EVT_BUTTON( ID_SETTINGS_PROGRAMMERS_DEFAULT, SetupDialog::OnSettingsPeditorDefault )
EVT_RADIOBUTTON( ID_SETUP_QUICK_CONNECT, SetupDialog::OnSettingsStartQC )
EVT_RADIOBUTTON( ID_SETUP_REGULAR_CONNECT, SetupDialog::OnSettingsStartRC )
EVT_BUTTON( ID_SETTINGS_OK, SetupDialog::OnSettingsOk )
EVT_BUTTON( ID_SETTINGS_CANCEL, SetupDialog::OnSettingsCancel )
EVT_BUTTON( ID_MANAGE_ADD, SetupDialog::OnManageAdd )
EVT_BUTTON(ID_SETTINGS_FIND_HOME,SetupDialog::OnSettingsHomeFind)
EVT_BUTTON(ID_SETTINGS_DEFAULT_HOME,SetupDialog::OnSettingsHomeDefault)
END_EVENT_TABLE()
SetupDialog::SetupDialog( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style ) :
wxDialog( parent, id, title, position, size, style )
{
start_style = 0;
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
wxStaticText *item1 = new wxStaticText( this, ID_TEXT, "Settings", wxDefaultPosition, wxDefaultSize, 0 );
item1->SetFont( wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ) );
#if defined(__WXMSW__) && !(wxCHECK_VERSION(2,3,0))
item1->SetSize( item1->GetBestSize() );
#endif
item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( 10, 10, 0, wxALIGN_CENTRE|wxALL, 0 );
wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *item3 = new wxStaticText( this, ID_TEXT, "Programmers Editor", wxDefaultPosition, wxDefaultSize, 0 );
item2->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
reditor_tc = new wxTextCtrl( this, ID_SETUP_PEDITOR_T, "", wxDefaultPosition, wxSize(150,-1), 0 );
item2->Add( reditor_tc, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item5 = new wxButton( this, ID_SETTINGS_FIND_PROGRAMMERS , "Find", wxDefaultPosition, wxDefaultSize, 0 );
item5->SetToolTip( "Find Programmers Editor" );
item2->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item6 = new wxButton( this, ID_SETTINGS_PROGRAMMERS_DEFAULT, "Default", wxDefaultPosition, wxDefaultSize, 0 );
item6->SetToolTip( "Use default editor" );
item2->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
wxBoxSizer *item7 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *item8 = new wxStaticText( this, ID_TEXT, "Regular Editor ", wxDefaultPosition, wxDefaultSize, 0 );
item7->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );
peditor_tc = new wxTextCtrl( this, ID_SETUP_REDITOR_T, "", wxDefaultPosition, wxSize(150,-1), 0 );
item7->Add( peditor_tc, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item10 = new wxButton( this,ID_SETTINGS_REGULAR_FIND, "Find", wxDefaultPosition, wxDefaultSize, 0 );
item7->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item11 = new wxButton( this,ID_PREF_REGULAR_DEFAULT, "Default", wxDefaultPosition, wxDefaultSize, 0 );
item7->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
wxBoxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *item13 = new wxStaticText( this, ID_TEXT, "Set Home", wxDefaultPosition, wxDefaultSize, 0 );
item12->Add( item13, 0, wxALIGN_CENTRE|wxALL, 5 );
item12->Add( 36, 20, 0, wxALIGN_CENTRE|wxALL, 5 );
home_tc = new wxTextCtrl( this, ID_TEXTCTRL, "", wxDefaultPosition, wxSize(150,-1), 0 );
item12->Add( home_tc, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item15 = new wxButton( this, ID_SETTINGS_FIND_HOME, "Find", wxDefaultPosition, wxDefaultSize, 0 );
item15->SetToolTip( "Find a new home, man thsi app does everything...." );
item12->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item16 = new wxButton( this, ID_SETTINGS_DEFAULT_HOME, "Default", wxDefaultPosition, wxDefaultSize, 0 );
item16->SetToolTip( "Use C:\\ for Home" );
item12->Add( item16, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxStaticLine *item20 = new wxStaticLine( this, ID_LINE, wxDefaultPosition, wxSize(430,-1), wxLI_HORIZONTAL );
item0->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 );
wxBoxSizer *item21 = new wxBoxSizer( wxHORIZONTAL );
wxButton *item22 = new wxButton( this, ID_SETTINGS_OK, "OK", wxDefaultPosition, wxDefaultSize, 0 );
item21->Add( item22, 0, wxALIGN_CENTRE|wxALL, 5 );
item21->Add( 110, 20, 0, wxALIGN_CENTRE|wxALL, 5 );
wxButton *item23 = new wxButton( this, ID_SETTINGS_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize, 0 );
item21->Add( item23, 0, wxALIGN_CENTRE|wxALL, 5 );
item0->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 );
if (true)
{
this->SetAutoLayout( TRUE );
this->SetSizer( item0 );
if (true)
{
item0->Fit( this );
item0->SetSizeHints( this );
}
}
// setup_dialog( this, TRUE );
}
// WDR: handler implementations for SetupDialog
void SetupDialog::OnManageAdd( )
{
}
void SetupDialog::OnSettingsCancel( )
{
EndModal(1);
}
void SetupDialog::OnSettingsOk( )
{
if (start_style == 1 || start_style == 2)
{
ofstream start("C:\\FTPro\\.startup");
start << start_style;
start.close();
}
if (!(s_peditor.IsEmpty()))
{
s_peditor += "%";
ofstream pedit("C:\\FTPro\\.peditor");
pedit.write(s_peditor.c_str(), s_peditor.Length());
pedit.close();
}
if (!(s_reditor.IsEmpty()))
{
s_reditor += "%";
ofstream redit("C:\\FTPro\\.reditor");
redit.write(s_reditor.c_str() , s_reditor.Length());
redit.close();
}
if (!(s_home.IsEmpty()))
{
s_home += "%";
ofstream home("C:\\FTPro\\.home");
home.write(s_home.c_str(), s_home.Length());
home.close();
}
EndModal(1);
wxMessageDialog dialog(this, "I need to restart for these settings to take affect\nshall i do that now ?","",wxYES_NO | wxICON_INFORMATION);
if (dialog.ShowModal() == wxID_YES)
{
wxExecute("C:\\Program Files\\Ftrpo\\ftppro.exe");
exit(0);
}
else
dialog.EndModal(1);
}
void SetupDialog::OnSettingsStartRC( )
{
start_style = 2;
}
void SetupDialog::OnSettingsStartQC( )
{
start_style = 1;
}
void SetupDialog::OnSettingsPeditorDefault( )
{
// these are reversed, ill fix it later
reditor_tc->SetValue("C:\\Program Files\\Accessories\\worpad.exe");
}
void SetupDialog::OnSettingsPeditorFind( )
{
wxFileDialog file(this, "Choose A File",wxGetCwd());
file.ShowModal();
s_peditor = file.GetPath();
//this is just lazy, they got switched somewhere, prolly kick your self in the ass later
reditor_tc->SetValue(s_peditor);
}
void SetupDialog::OnSettingsReditorDefault( )
{
peditor_tc->SetValue("C:\\Program Files\\Accessories\\worpad.exe");
}
void SetupDialog::OnSettingsReditorFind( )
{
wxFileDialog file(this, "Choose A File",wxGetCwd());
file.ShowModal();
s_reditor = file.GetPath();
peditor_tc->SetValue(s_reditor);
}
void SetupDialog::OnSettingsHomeFind()
{
wxDirDialog dir(this,"Choose A Directory",wxGetCwd());
dir.ShowModal();
s_home = dir.GetPath();
home_tc->SetValue(s_home);
}
void SetupDialog::OnSettingsHomeDefault()
{
home_tc->SetValue("C:\\Ftpro");
}