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,
int& aRow ) :
165 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
166 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
175 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
196 wxString fpid = GetValue();
198 wxString symbolNetlist;
228 wxEvtHandler* aEventHandler )
237 Combo()->SetValidator( *m_validator );
241 wxGridCellEditor::Create( aParent, aId, aEventHandler );
250 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
251 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
260 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
278 m_dlg->PrepareForModalSubDialog();
285 wxString filename = GetValue();
287 if( filename.IsEmpty() || filename == wxT(
"~" ) )
291 wxFileDialog openFileDialog(
this,
_(
"Open file" ),
"",
"",
_(
"All Files" ) + wxT(
" (*.*)|*.*" ),
292 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
295 openFileDialog.SetCustomizeHook( customize );
299 if( openFileDialog.ShowModal() == wxID_OK )
301 filename = openFileDialog.GetPath();
302 wxFileName fn( filename );
320 if( !link.IsEmpty() )
325 SetValue(
"file://" + filename );
334 m_dlg->CleanupAfterModalSubDialog();
345 if( GetValue().IsEmpty() )
368 Combo()->SetValidator( *m_validator );
371 wxGridCellEditor::Create( aParent, aId, aEventHandler );
379 wxString* aCurrentDir,
const wxString& aFileFilter = wxEmptyString,
380 bool aNormalize =
false,
381 const wxString& aNormalizeBasePath = wxEmptyString,
382 std::function<wxString(
const wxString& )> aEmbedCallback =
nullptr ) :
383 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
384 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
396 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
400 wxString* aCurrentDir,
401 std::function<wxString(
WX_GRID*
grid,
int row )> aFileFilterFn,
402 bool aNormalize =
false,
403 const wxString& aNormalizeBasePath = wxEmptyString,
404 std::function<wxString(
const wxString& )> aEmbedCallback =
nullptr ) :
405 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
406 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
418 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
430 m_dlg->PrepareForModalSubDialog();
435 wxFileName fn = GetValue();
445 wxFileDialog dlg(
m_dlg,
_(
"Select a File" ), fn.GetPath(), fn.GetFullName(),
449 dlg.SetCustomizeHook( customize );
453 if( dlg.ShowModal() == wxID_OK )
455 wxString filePath = dlg.GetPath();
456 wxString lastPath = dlg.GetDirectory();
457 wxString relPath = wxEmptyString;
463 if( relPath.IsEmpty() )
465 m_dlg->CleanupAfterModalSubDialog();
473 lastPath =
NormalizePath( dlg.GetDirectory(), &
Pgm().GetLocalEnvVariables(),
483 if( !
m_grid->CommitPendingChanges() )
492 wxDirDialog dlg(
m_dlg,
_(
"Select Path" ), fn.GetPath(),
493 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
495 if( dlg.ShowModal() == wxID_OK )
497 wxString filePath = dlg.GetPath();
498 wxString relPath = wxEmptyString;
512 if( !
m_grid->CommitPendingChanges() )
520 m_dlg->CleanupAfterModalSubDialog();
537 wxEvtHandler* aEventHandler )
557 Combo()->SetValidator( *m_validator );
560 wxGridCellEditor::Create( aParent, aId, aEventHandler );
567 int& aRow,
int& aCol ) :
568 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 0, 0 ),
569 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
578 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
602 Combo()->SetValidator( *m_validator );
606 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_ROUTED_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
TEXT_BUTTON_FP_CHOOSER(wxWindow *aParent, DIALOG_SHIM *aParentDlg, const std::function< wxString(int)> &aSymbolNetlistProvider, int &aRow)
bool m_buttonFpChooserLock
void DoSetPopupControl(wxComboPopup *popup) override
std::function< wxString(int)> m_symbolNetlistProvider
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.