25#include <wx/checkbox.h>
27#include <wx/filedlg.h>
29#include <wx/textctrl.h>
59 return Combo()->GetValue();
68 wxGridCellEditor::SetSize( rect );
82 wxTextEntry* textEntry =
static_cast<wxTextEntry*
>(
Combo() );
88 ch =
event.GetUnicodeKey();
95 ch =
event.GetKeyCode();
96 isPrintable = ch >= WXK_SPACE && ch < WXK_START;
103 textEntry->Remove( 0, 1 );
109 const long pos = textEntry->GetLastPosition();
110 textEntry->Remove( pos - 1, pos );
116 textEntry->WriteText(
static_cast<wxChar
>( ch ) );
124 auto evtHandler =
static_cast< wxGridCellEditorEvtHandler*
>( m_control->GetEventHandler() );
127 evtHandler->SetInSetFocus(
true );
129 m_value = aGrid->GetTable()->GetValue( aRow, aCol );
138 const wxString value =
Combo()->GetValue();
154 aGrid->GetTable()->SetValue( aRow, aCol,
m_value );
165void GRID_CELL_TEXT_BUTTON::SetValidator(
const wxValidator& validator )
167 m_validator.reset(
static_cast< wxValidator*
>( validator.Clone() ) );
176 const wxString& aPreselect ) :
177 wxComboCtrl( aParent ),
184 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
196 wxString libName = aRawValue.BeforeFirst(
':', &itemName );
203 wxString rawValue = GetValue();
205 if( rawValue.IsEmpty() )
212 if( frame->ShowModal( &symbolId,
m_dlg ) )
225 wxEvtHandler* aEventHandler )
230 wxGridCellEditor::Create( aParent, aId, aEventHandler );
238 const wxString& aSymbolNetlist,
const wxString& aPreselect ) :
239 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
240 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
249 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
270 wxString fpid = GetValue();
280 frame->KiwayMailIn( event );
283 if( frame->ShowModal( &fpid,
m_dlg ) )
309 wxEvtHandler* aEventHandler )
318 Combo()->SetValidator( *m_validator );
322 wxGridCellEditor::Create( aParent, aId, aEventHandler );
330 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
331 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
339 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
358 wxString filename = GetValue();
360 if (filename.IsEmpty() || filename == wxT(
"~"))
363 wxFileDialog openFileDialog(
this,
_(
"Open file" ),
"",
"",
"All files (*.*)|*.*",
364 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
365 openFileDialog.SetCustomizeHook( customize );
367 if( openFileDialog.ShowModal() == wxID_OK )
369 filename = openFileDialog.GetPath();
370 wxFileName fn( filename );
379 SetValue(
"file://" + filename );
397 if (GetValue().IsEmpty())
410 wxEvtHandler* aEventHandler )
419 Combo()->SetValidator( *m_validator );
423 wxGridCellEditor::Create( aParent, aId, aEventHandler );
431 wxString* aCurrentDir,
const wxString& aFileFilter = wxEmptyString,
432 bool aNormalize =
false,
433 const wxString& aNormalizeBasePath = wxEmptyString ) :
434 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
435 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
446 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
450 wxString* aCurrentDir,
451 std::function<wxString(
WX_GRID*
grid,
int row )> aFileFilterFn,
452 bool aNormalize =
false,
453 const wxString& aNormalizeBasePath = wxEmptyString ) :
454 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
455 wxTE_PROCESS_ENTER | wxBORDER_NONE ),
466 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
481 wxFileName fn = GetValue();
490 wxFileDialog dlg(
m_dlg,
_(
"Select a File" ), fn.GetPath(), fn.GetFullName(),
493 if( dlg.ShowModal() == wxID_OK )
495 wxString filePath = dlg.GetPath();
496 wxString lastPath = dlg.GetDirectory();
497 wxString relPath = wxEmptyString;
503 lastPath =
NormalizePath( dlg.GetDirectory(), &
Pgm().GetLocalEnvVariables(),
522 wxDirDialog dlg(
m_dlg,
_(
"Select Path" ), fn.GetPath(),
523 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
525 if( dlg.ShowModal() == wxID_OK )
527 wxString filePath = dlg.GetPath();
528 wxString relPath = wxEmptyString;
562 wxEvtHandler* aEventHandler )
577 Combo()->SetValidator( *m_validator );
581 wxGridCellEditor::Create( aParent, aId, aEventHandler );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
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)
Loads a file from disk and adds it to the collection.
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
std::function< wxString(WX_GRID *aGrid, int aRow)> m_fileFilterFn
wxString m_normalizeBasePath
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
wxString GetValue() const override
wxComboCtrl * Combo() const
void StartingKey(wxKeyEvent &event) override
void BeginEdit(int aRow, int aCol, wxGrid *aGrid) override
bool EndEdit(int, int, const wxGrid *, const wxString &, wxString *aNewVal) override
void ApplyEdit(int aRow, int aCol, wxGrid *aGrid) override
void SetSize(const wxRect &aRect) override
SEARCH_STACK * m_searchStack
void Create(wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
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(WX_GRID *aGrid, int aRow)> m_fileFilterFn
wxString m_normalizeBasePath
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)
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::string m_symbolNetlist
void OnButtonClick() override
bool m_buttonFpChooserLock
void DoSetPopupControl(wxComboPopup *popup) override
TEXT_BUTTON_FP_CHOOSER(wxWindow *aParent, DIALOG_SHIM *aParentDlg, const wxString &aSymbolNetlist, const wxString &aPreselect)
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()
void OnButtonClick() override
TEXT_BUTTON_URL(wxWindow *aParent, DIALOG_SHIM *aParentDlg, SEARCH_STACK *aSearchStack, EMBEDDED_FILES *aFiles)
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.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
static void CellEditorTransformSizeRect(wxRect &aRect)
A helper function to tweak sizes of text-based cell editors depending on OS.
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, EMBEDDED_FILES *aFiles)
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.
@ FRAME_FOOTPRINT_CHOOSER
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:...