21#include <wx/checkbox.h>
23#include <wx/filedlg.h>
25#include <wx/textctrl.h>
52 const std::vector<EMBEDDED_FILES*>& aAdditionalLookupFiles )
55 std::set<EMBEDDED_FILES*> filesSeen;
59 if( !files || !filesSeen.insert( files ).second )
68 if( files && filesSeen.insert( files ).second )
77 const wxString& aSymbolNetlist )
84 if( !aSymbolNetlist.IsEmpty() )
86 std::string payload = aSymbolNetlist.ToStdString();
91 bool selected = frame->
ShowModal( &aFootprint, aDialog );
102 const wxString& aPreselect ) :
103 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ) ),
110 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
122 wxString libName = aRawValue.BeforeFirst(
':', &itemName );
129 wxString rawValue = GetValue();
131 if( rawValue.IsEmpty() )
138 if( frame->ShowModal( &symbolId,
m_dlg ) )
151 wxEvtHandler* aEventHandler )
156 wxGridCellEditor::Create( aParent, aId, aEventHandler );
164 const std::function<wxString(
int )>& aSymbolNetlistProvider,
165 wxGrid*& aGrid,
int& aRow ) :
166 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
167 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
177 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
198 wxString fpid = GetValue();
200 wxString symbolNetlist;
212 grid->CommitPendingChanges();
238 wxEvtHandler* aEventHandler )
247 Combo()->SetValidator( *m_validator );
251 wxGridCellEditor::Create( aParent, aId, aEventHandler );
260 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
261 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
270 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
288 m_dlg->PrepareForModalSubDialog();
295 wxString filename = GetValue();
297 if( filename.IsEmpty() || filename == wxT(
"~" ) )
301 wxFileDialog openFileDialog(
this,
_(
"Open file" ),
"",
"",
_(
"All Files" ) + wxT(
" (*.*)|*.*" ),
302 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
305 openFileDialog.SetCustomizeHook( customize );
309 if( openFileDialog.ShowModal() == wxID_OK )
311 filename = openFileDialog.GetPath();
312 wxFileName fn( filename );
330 if( !link.IsEmpty() )
335 SetValue(
"file://" + filename );
344 m_dlg->CleanupAfterModalSubDialog();
355 if( GetValue().IsEmpty() )
378 Combo()->SetValidator( *m_validator );
381 wxGridCellEditor::Create( aParent, aId, aEventHandler );
389 wxString* aCurrentDir,
const wxString& aFileFilter = wxEmptyString,
390 bool aNormalize =
false,
391 const wxString& aNormalizeBasePath = wxEmptyString,
392 std::function<wxString(
const wxString& )> aEmbedCallback =
nullptr ) :
393 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
394 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
406 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
410 wxString* aCurrentDir,
411 std::function<wxString(
WX_GRID*
grid,
int row )> aFileFilterFn,
412 bool aNormalize =
false,
413 const wxString& aNormalizeBasePath = wxEmptyString,
414 std::function<wxString(
const wxString& )> aEmbedCallback =
nullptr ) :
415 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
416 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
428 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
440 m_dlg->PrepareForModalSubDialog();
445 wxFileName fn = GetValue();
455 wxFileDialog dlg(
m_dlg,
_(
"Select a File" ), fn.GetPath(), fn.GetFullName(),
459 dlg.SetCustomizeHook( customize );
463 if( dlg.ShowModal() == wxID_OK )
465 wxString filePath = dlg.GetPath();
466 wxString lastPath = dlg.GetDirectory();
467 wxString relPath = wxEmptyString;
473 if( relPath.IsEmpty() )
475 m_dlg->CleanupAfterModalSubDialog();
483 lastPath =
NormalizePath( dlg.GetDirectory(), &
Pgm().GetLocalEnvVariables(),
493 if( !
m_grid->CommitPendingChanges() )
502 wxDirDialog dlg(
m_dlg,
_(
"Select Path" ), fn.GetPath(),
503 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
505 if( dlg.ShowModal() == wxID_OK )
507 wxString filePath = dlg.GetPath();
508 wxString relPath = wxEmptyString;
522 if( !
m_grid->CommitPendingChanges() )
530 m_dlg->CleanupAfterModalSubDialog();
547 wxEvtHandler* aEventHandler )
567 Combo()->SetValidator( *m_validator );
570 wxGridCellEditor::Create( aParent, aId, aEventHandler );
577 int& aRow,
int& aCol ) :
578 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
579 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
588 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
612 Combo()->SetValidator( *m_validator );
616 wxGridCellEditor::Create( aParent, aId, aEventHandler );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
std::function< wxString(int)> m_symbolNetlistProvider
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
std::function< wxString(WX_GRID *aGrid, int aRow)> m_fileFilterFn
wxString m_normalizeBasePath
std::function< wxString(const wxString &)> m_embedCallback
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
std::function< void(int, int)> m_function
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxComboCtrl * Combo() const
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
std::function< GRID_CELL_URL_EDITOR_CONTEXT(int)> m_contextProvider
SEARCH_STACK * m_searchStack
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
virtual void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent)
Receive KIWAY_MAIL_EVENT messages from other players.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Look for files in a number of paths.
void OnButtonClick() override
void DoSetPopupControl(wxComboPopup *popup) override
std::function< wxString(const wxString &)> m_embedCallback
TEXT_BUTTON_FILE_BROWSER(wxWindow *aParent, DIALOG_SHIM *aParentDlg, WX_GRID *aGrid, wxString *aCurrentDir, const wxString &aFileFilter=wxEmptyString, bool aNormalize=false, const wxString &aNormalizeBasePath=wxEmptyString, std::function< wxString(const wxString &)> aEmbedCallback=nullptr)
TEXT_BUTTON_FILE_BROWSER(wxWindow *aParent, DIALOG_SHIM *aParentDlg, WX_GRID *aGrid, wxString *aCurrentDir, std::function< wxString(WX_GRID *grid, int row)> aFileFilterFn, bool aNormalize=false, const wxString &aNormalizeBasePath=wxEmptyString, std::function< wxString(const wxString &)> aEmbedCallback=nullptr)
std::function< wxString(WX_GRID *aGrid, int aRow)> m_fileFilterFn
wxString m_normalizeBasePath
void OnButtonClick() override
bool m_buttonFpChooserLock
void DoSetPopupControl(wxComboPopup *popup) override
std::function< wxString(int)> m_symbolNetlistProvider
TEXT_BUTTON_FP_CHOOSER(wxWindow *aParent, DIALOG_SHIM *aParentDlg, const std::function< wxString(int)> &aSymbolNetlistProvider, wxGrid *&aGrid, int &aRow)
std::function< void(int, int)> & m_function
void DoSetPopupControl(wxComboPopup *popup) override
void OnButtonClick() override
TEXT_BUTTON_RUN_FUNCTION(wxWindow *aParent, DIALOG_SHIM *aParentDlg, std::function< void(int, int)> &aFunction, int &aRow, int &aCol)
void DoSetPopupControl(wxComboPopup *popup) override
wxString escapeLibId(const wxString &aRawValue)
void OnButtonClick() override
TEXT_BUTTON_SYMBOL_CHOOSER(wxWindow *aParent, DIALOG_SHIM *aParentDlg, const wxString &aPreselect)
void UpdateButtonBitmaps()
TEXT_BUTTON_URL(wxWindow *aParent, DIALOG_SHIM *aParentDlg, SEARCH_STACK *aSearchStack, const std::function< GRID_CELL_URL_EDITOR_CONTEXT(int)> &aContextProvider, int &aRow)
void OnButtonClick() override
std::function< GRID_CELL_URL_EDITOR_CONTEXT(int)> m_contextProvider
void DoSetPopupControl(wxComboPopup *popup) override
void OnTextChange(wxCommandEvent &event)
SEARCH_STACK * m_searchStack
static void CellEditorSetMargins(wxTextEntryBase *aEntry)
A helper function to set OS-specific margins for text-based cell editors.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
This file is part of the common library.
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Helper functions to substitute paths with environmental variables.
@ FRAME_FOOTPRINT_CHOOSER
bool SelectFootprintFromChooser(DIALOG_SHIM *aDialog, wxString &aFootprint, const wxString &aSymbolNetlist)
GRID_CELL_URL_EDITOR_CONTEXT MakeGridCellUrlEditorContext(const std::vector< EMBEDDED_FILES * > &aEmbedTargets, const std::vector< EMBEDDED_FILES * > &aAdditionalLookupFiles)
PGM_BASE & Pgm()
The global program "get" accessor.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
std::vector< EMBEDDED_FILES * > m_embedTargets
std::vector< EMBEDDED_FILES * > m_filesStack
wxString result
Test unit parsing edge cases and error handling.