📄 compileroptionsdlg.cpp
字号:
if (control)
control->Append(path);
}
}
void CompilerOptionsDlg::OnEditDirClick(wxCommandEvent& event)
{
wxListBox* control = GetDirsListBox();
if (!control || control->GetSelection() < 0)
return;
wxFileName dir(control->GetString(control->GetSelection()) + wxFileName::GetPathSeparator());
// if (m_pProject)
// dir.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, m_pProject->GetBasePath());
// Manager::Get()->GetMessageManager()->DebugLog(dir.GetFullPath());
wxString initial = _T("");
// This path may not exist, but if using EditPathDlg, you still want it
// displayed
initial = dir.GetPath(wxPATH_GET_VOLUME);
/*wxString path = ChooseDirectory(this,
_("Select directory"),
initial,
m_pProject ? m_pProject->GetBasePath() : "",
true,
true);*/
EditPathDlg dlg(this,
initial,
m_pProject ? m_pProject->GetBasePath() : _T(""),
_("Edit directory"));
if (dlg.ShowModal() == wxID_OK)
{
wxString path = dlg.GetPath();
control->SetString(control->GetSelection(), path);
}
}
void CompilerOptionsDlg::OnRemoveDirClick(wxCommandEvent& event)
{
wxListBox* control = GetDirsListBox();
if (!control || control->GetSelection() < 0)
return;
if (wxMessageBox(_("Remove '")+control->GetStringSelection()+_("' from the list?"),
_("Confirmation"),
wxOK | wxCANCEL | wxICON_QUESTION) == wxOK)
{
control->Delete(control->GetSelection());
}
}
void CompilerOptionsDlg::OnAddVarClick(wxCommandEvent& event)
{
const wxString title = _("Add variable");
wxString name = wxGetTextFromUser(_("Please enter the name for the new variable:"), title);
if (name.IsEmpty())
return;
wxString value = wxGetTextFromUser(_("Please enter value for the new variable:"), title);
CustomVars* vars = GetCustomVars();
if (vars)
{
vars->Add(name, value);
DoFillVars(vars);
}
}
void CompilerOptionsDlg::OnEditVarClick(wxCommandEvent& event)
{
const wxString title = _("Edit variable");
int sel = XRCCTRL(*this, "lstVars", wxListBox)->GetSelection();
if (sel == -1)
return;
Var* var = static_cast<Var*>(XRCCTRL(*this, "lstVars", wxListBox)->GetClientData(sel));
if (!var)
return;
wxString value = wxGetTextFromUser(_("Please edit the variable value:"), title, var->value);
if (!value.IsEmpty() && value != var->value)
{
var->value = value;
CustomVars* vars = GetCustomVars();
if (vars)
vars->SetModified(true);
XRCCTRL(*this, "lstVars", wxListBox)->SetString(sel, var->name + _T(" = ") + var->value);
}
}
void CompilerOptionsDlg::OnRemoveVarClick(wxCommandEvent& event)
{
int sel = XRCCTRL(*this, "lstVars", wxListBox)->GetSelection();
if (sel == -1)
return;
if (wxMessageBox(_("Are you sure you want to delete this variable?"),
_("Confirmation"),
wxOK | wxCANCEL | wxICON_QUESTION) == wxOK)
{
Var* var = static_cast<Var*>(XRCCTRL(*this, "lstVars", wxListBox)->GetClientData(sel));
if (var)
{
CustomVars* vars = GetCustomVars();
if (vars)
{
vars->DeleteVar(var);
DoFillVars(vars);
}
}
}
}
void CompilerOptionsDlg::OnSetDefaultCompilerClick(wxCommandEvent& event)
{
wxComboBox* cmb = XRCCTRL(*this, "cmbCompiler", wxComboBox);
int idx = cmb->GetSelection();
CompilerFactory::SetDefaultCompilerIndex(idx);
wxString msg;
msg.Printf(_("%s is now selected as the default compiler for new projects"), CompilerFactory::GetDefaultCompiler()->GetName().c_str());
wxMessageBox(msg);
}
void CompilerOptionsDlg::OnAddCompilerClick(wxCommandEvent& event)
{
wxComboBox* cmb = XRCCTRL(*this, "cmbCompiler", wxComboBox);
int idx = cmb->GetSelection();
wxString value = wxGetTextFromUser(_("Please enter the new compiler's name:"), _("Add new compiler"), _("Copy of ") + CompilerFactory::Compilers[idx]->GetName());
if (!value.IsEmpty())
{
// make a copy of current compiler
int newIdx = CompilerFactory::CreateCompilerCopy(CompilerFactory::Compilers[idx]);
Compiler* newC = CompilerFactory::Compilers[newIdx];
// and change its name
newC->SetName(value);
cmb->Append(value);
cmb->SetSelection(cmb->GetCount() - 1);
// refresh settings in dialog
DoFillCompilerPrograms();
DoFillCategories();
DoFillOptions();
DoLoadOptions(newIdx, 0);
m_LastCompilerIdx = newIdx;
wxMessageBox(_("The new compiler has been added! Don't forget to update the \"Programs\" page..."));
}
}
void CompilerOptionsDlg::OnEditCompilerClick(wxCommandEvent& event)
{
wxComboBox* cmb = XRCCTRL(*this, "cmbCompiler", wxComboBox);
wxString value = wxGetTextFromUser(_("Please edit the compiler's name:"), _("Rename compiler"), cmb->GetValue());
if (!value.IsEmpty())
{
int idx = cmb->GetSelection();
CompilerFactory::Compilers[idx]->SetName(value);
#ifndef __WXGTK__
cmb->SetString(idx, value);
#else
#warning wxComboBox::SetString() not implemented: CompilerOptionsDlg::OnEditCompilerClick() is not updating correctly...
#endif
cmb->SetSelection(idx);
}
}
void CompilerOptionsDlg::OnRemoveCompilerClick(wxCommandEvent& event)
{
if (wxMessageBox(_("Are you sure you want to remove this compiler?"),
_("Confirmation"),
wxOK | wxCANCEL | wxICON_QUESTION | wxNO_DEFAULT) == wxOK)
{
wxComboBox* cmb = XRCCTRL(*this, "cmbCompiler", wxComboBox);
int compilerIdx = cmb->GetSelection();
CompilerFactory::RemoveCompiler(CompilerFactory::Compilers[compilerIdx]);
cmb->Delete(compilerIdx);
while (compilerIdx >= cmb->GetCount())
--compilerIdx;
cmb->SetSelection(compilerIdx);
DoFillCompilerPrograms();
DoFillCategories();
DoFillOptions();
m_LastCompilerIdx = compilerIdx;
DoLoadOptions(compilerIdx, 0);
}
}
void CompilerOptionsDlg::OnResetCompilerClick(wxCommandEvent& event)
{
if (wxMessageBox(_("Reset this compiler's settings to the defaults?"),
_("Confirmation"),
wxOK | wxCANCEL | wxICON_QUESTION | wxNO_DEFAULT) == wxOK)
if (wxMessageBox(_("Reset this compiler's settings to the defaults?\n"
"\nAre you REALLY sure?"),
_("Confirmation"),
wxOK | wxCANCEL | wxICON_QUESTION | wxNO_DEFAULT) == wxOK)
{
wxComboBox* cmb = XRCCTRL(*this, "cmbCompiler", wxComboBox);
int compilerIdx = cmb->GetSelection();
CompilerFactory::Compilers[compilerIdx]->Reset();
// run auto-detection
AutoDetectCompiler();
CompilerFactory::SaveSettings();
// refresh settings in dialog
DoFillCompilerPrograms();
DoFillCategories();
DoFillOptions();
DoLoadOptions(compilerIdx, 0);
}
}
void CompilerOptionsDlg::OnAddLibClick(wxCommandEvent& event)
{
/*int compilerIdx = m_pTarget ? m_pTarget->GetCompilerIndex()
: (m_pProject ? m_pProject->GetCompilerIndex()
: XRCCTRL(*this, "cmbCompiler", wxComboBox)->GetSelection());*/
wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
/*LinkLibDlg dlg(this, m_pProject, m_pTarget, CompilerFactory::Compilers[compilerIdx], "");*/
EditPathDlg dlg(this,
_T(""),
m_pProject ? m_pProject->GetBasePath() : _T(""),
_("Add library"),
_("Choose library to link"),
false,
true,
_("Library files (*.a, *.lib)|*.a;*.lib|All files (*)|*"));
if (dlg.ShowModal() == wxID_OK)
{
wxArrayString paths = GetArrayFromString(dlg.GetPath());
for (unsigned int i = 0; i < paths.GetCount(); ++i)
lstLibs->Append(paths[i]);
}
}
void CompilerOptionsDlg::OnEditLibClick(wxCommandEvent& event)
{
/*int compilerIdx = m_pTarget ? m_pTarget->GetCompilerIndex()
: (m_pProject ? m_pProject->GetCompilerIndex()
: XRCCTRL(*this, "cmbCompiler", wxComboBox)->GetSelection());*/
wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
/*LinkLibDlg dlg(this, m_pProject, m_pTarget, CompilerFactory::Compilers[compilerIdx], lstLibs->GetStringSelection());*/
EditPathDlg dlg(this,
lstLibs->GetStringSelection(),
m_pProject ? m_pProject->GetBasePath() : _T(""),
_("Edit library"),
_("Choose library to link"),
false,
false,
_("Library files (*.a, *.lib)|*.a;*.lib|All files (*)|*"));
if (dlg.ShowModal() == wxID_OK)
{
/*lstLibs->SetString(lstLibs->GetSelection(), dlg.GetLib());*/
lstLibs->SetString(lstLibs->GetSelection(), dlg.GetPath());
}
}
void CompilerOptionsDlg::OnRemoveLibClick(wxCommandEvent& event)
{
wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
if (!lstLibs || lstLibs->GetSelection() < 0)
return;
if (wxMessageBox(_("Remove library '")+lstLibs->GetStringSelection()+_("' from the list?"), _("Confirmation"), wxICON_QUESTION | wxOK | wxCANCEL) == wxOK)
lstLibs->Delete(lstLibs->GetSelection());
}
void CompilerOptionsDlg::OnAddExtraPathClick(wxCommandEvent& event)
{
wxString path = ChooseDirectory(this,
_("Select directory"),
_T(""),
_T(""),
true,
true);
if (path.IsEmpty())
return;
wxListBox* control = XRCCTRL(*this, "lstExtraPaths", wxListBox);
if (control)
{
int compilerIdx = XRCCTRL(*this, "cmbCompiler", wxComboBox)->GetSelection();
Compiler* compiler = CompilerFactory::Compilers[compilerIdx];
wxArrayString extraPaths = CompilerFactory::Compilers[compilerIdx]->GetExtraPaths();
if (extraPaths.Index(path) != wxNOT_FOUND)
{
wxMessageBox(_("Path already in extra paths list!"), _("Warning"), wxICON_WARNING);
return;
}
extraPaths.Add(path);
compiler->SetExtraPaths(extraPaths);
control->Append(path);
}
}
void CompilerOptionsDlg::OnEditExtraPathClick(wxCommandEvent& event)
{
wxListBox* control = XRCCTRL(*this, "lstExtraPaths", wxListBox);
if (!control || control->GetSelection() < 0)
return;
wxFileName dir(control->GetString(control->GetSelection()) + wxFileName::GetPathSeparator());
wxString initial = _T("");
if (dir.DirExists())
initial = dir.GetPath(wxPATH_GET_VOLUME);
wxString path = ChooseDirectory(this,
_("Select directory"),
initial,
_T(""),
true,
true);
if (path.IsEmpty())
return;
int compilerIdx = XRCCTRL(*this, "cmbCompiler", wxComboBox)->GetSelection();
Compiler* compiler = CompilerFactory::Compilers[compilerIdx];
wxArrayString extraPaths = CompilerFactory::Compilers[compilerIdx]->GetExtraPaths();
if (extraPaths.Index(path) != wxNOT_FOUND)
{
wxMessageBox(_("Path already in extra paths list!"), _("Warning"), wxICON_WARNING);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -