39#include <wx/filedlg.h>
45 SetTitle( wxString::Format(
_(
"Project file: '%s'" ),
Prj().GetProjectFullName() ) );
55 if( !
project.m_EquivalenceFiles.empty() )
59 for(
const auto& entry :
project.m_EquivalenceFiles )
70 for(
int row = 0; row <
m_gridEnvVars->GetTable()->GetRowsCount(); row++ )
74 if( wxGetEnv(
m_gridEnvVars->GetCellValue( row, 0 ), &evValue ) )
82 GetSizer()->SetSizeHints(
this );
89 wxString editorname =
Pgm().GetTextEditor();
91 if( editorname.IsEmpty() )
93 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
97 wxArrayInt selections;
100 for(
unsigned ii = 0; ii < selections.GetCount(); ii++ )
110 project.m_EquivalenceFiles.clear();
115 Pgm().GetSettingsManager().SaveProject();
123 EndModal( wxID_CANCEL );
129 wxArrayInt selections;
132 if ( selections.GetCount() <= 0 )
135 if( selections[0] == 0 )
140 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
142 int jj = selections[ii];
143 std::swap( libnames[jj], libnames[jj-1] );
149 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
151 int jj = selections[ii];
159 wxArrayInt selections;
162 if ( selections.GetCount() <= 0 )
171 for(
int ii = selections.GetCount()-1; ii >= 0; ii-- )
173 int jj = selections[ii];
174 std::swap( libnames[jj], libnames[jj+1] );
180 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
182 int jj = selections[ii];
193 wxArrayInt selections;
196 std::sort( selections.begin(), selections.end() );
198 for(
int ii = selections.GetCount()-1; ii >= 0; ii-- )
207 int row = selectedRows.GetCount() ? selectedRows[0] :
m_gridEnvVars->GetGridCursorRow();
208 wxString libpath =
m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
210 wxFileDialog dlg(
this,
_(
"Footprint Association File" ), libpath, wxEmptyString,
213 if( dlg.ShowModal() != wxID_OK )
216 wxArrayString filenames;
217 dlg.GetPaths( filenames );
219 for(
unsigned jj = 0; jj < filenames.GetCount(); jj++ )
221 wxFileName fn = filenames[jj];
224 for( row = 0; row <
m_gridEnvVars->GetTable()->GetRowsCount(); row++ )
226 libpath =
m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
228 if( fn.MakeRelativeTo( libpath ) )
230 filepath.Printf( wxT(
"${%s}%c%s" ),
232 wxFileName::GetPathSeparator(),
238 if( filepath.IsEmpty() )
239 filepath = filenames[jj];
242 if(
m_filesListBox->FindString( filepath, wxFileName::IsCaseSensitive() ) == wxNOT_FOUND )
244 filepath.Replace( wxT(
"\\" ), wxT(
"/" ) );
249 DisplayError(
this, wxString::Format(
_(
"File '%s' already exists in list." ),
250 filepath.GetData() ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Class DIALOG_CONFIG_EQUFILES_BASE.
STD_BITMAP_BUTTON * m_bpMoveUp
STD_BITMAP_BUTTON * m_bpAdd
STD_BITMAP_BUTTON * m_bpMoveDown
wxListBox * m_filesListBox
STD_BITMAP_BUTTON * m_bpEdit
STD_BITMAP_BUTTON * m_bpDelete
DIALOG_CONFIG_EQUFILES(wxWindow *parent)
void OnCloseWindow(wxCloseEvent &event) override
void OnOkClick(wxCommandEvent &event) override
void OnButtonMoveDown(wxCommandEvent &event) override
void OnAddFiles(wxCommandEvent &event) override
void OnEditEquFile(wxCommandEvent &event) override
void OnRemoveFiles(wxCommandEvent &event) override
void OnButtonMoveUp(wxCommandEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
static const wxString GlobalPathEnvVariableName()
Return the name of the environment variable used to hold the directory of locally installed "KiCad sp...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback)
Call the executable file aEditorName with the parameter aFileName.
wxString EquFileWildcard()
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition of file extensions used in Kicad.