1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include "new_php_workspace_dlg.h"
#include <windowattrmanager.h>
#include "php_strings.h"
#include "cl_standard_paths.h"
NewPHPWorkspaceDlg::NewPHPWorkspaceDlg(wxWindow* parent)
: NewPHPWorkspaceBaseDlg(parent)
{
m_textCtrlPath->ChangeValue(clStandardPaths::Get().GetDocumentsDir());
CenterOnParent();
SetName("NewPHPWorkspaceDlg");
WindowAttrManager::Load(this);
}
NewPHPWorkspaceDlg::~NewPHPWorkspaceDlg() {}
wxString NewPHPWorkspaceDlg::GetWorkspacePath() const
{
if(m_textCtrlPath->IsEmpty() || m_textCtrlName->IsEmpty()) {
return "";
}
wxFileName filepath(m_textCtrlPath->GetValue(), m_textCtrlName->GetValue());
filepath.SetExt(PHPStrings::PHP_WORKSPACE_EXT);
return filepath.GetFullPath();
}
void NewPHPWorkspaceDlg::OnNameUpdated(wxCommandEvent& event)
{
event.Skip();
m_textCtrlPreview->ChangeValue(GetWorkspacePath());
}
void NewPHPWorkspaceDlg::OnOK(wxCommandEvent& event)
{
EndModal(wxID_OK);
}
void NewPHPWorkspaceDlg::OnCheckMakeSeparateDir(wxCommandEvent& event)
{
m_textCtrlPreview->ChangeValue(GetWorkspacePath());
}
void NewPHPWorkspaceDlg::OnOKUI(wxUpdateUIEvent& event)
{
event.Enable(!m_textCtrlPath->GetValue().IsEmpty() && !m_textCtrlName->GetValue().IsEmpty());
}
void NewPHPWorkspaceDlg::OnBrowse(wxCommandEvent& event)
{
wxString path = ::wxDirSelector(_("select a folder"), m_textCtrlPath->GetValue());
if(!path.IsEmpty()) {
m_textCtrlPath->SetValue(path); // we want event here
m_textCtrlPreview->ChangeValue(GetWorkspacePath());
}
}
void NewPHPWorkspaceDlg::OnFolderSelected(wxCommandEvent& event)
{
wxUnusedVar(event);
wxFileName fn(m_textCtrlPath->GetValue());
// Use the last folder path as the project name
m_textCtrlName->ChangeValue(fn.GetName());
}
|