KiCad PCB EDA Suite
TEXT_BUTTON_FILE_BROWSER Class Reference
Inheritance diagram for TEXT_BUTTON_FILE_BROWSER:

Public Member Functions

 TEXT_BUTTON_FILE_BROWSER (wxWindow *aParent, DIALOG_SHIM *aParentDlg, wxString *aCurrentDir, wxString *aExt=nullptr)
 

Protected Member Functions

void DoSetPopupControl (wxComboPopup *popup) override
 
void OnButtonClick () override
 

Protected Attributes

DIALOG_SHIMm_dlg
 
wxString * m_currentDir
 
wxString * m_ext
 

Detailed Description

Definition at line 312 of file grid_text_button_helpers.cpp.

Constructor & Destructor Documentation

◆ TEXT_BUTTON_FILE_BROWSER()

TEXT_BUTTON_FILE_BROWSER::TEXT_BUTTON_FILE_BROWSER ( wxWindow *  aParent,
DIALOG_SHIM aParentDlg,
wxString *  aCurrentDir,
wxString *  aExt = nullptr 
)
inline

Definition at line 315 of file grid_text_button_helpers.cpp.

316  :
317  wxComboCtrl( aParent ),
318  m_dlg( aParentDlg ),
319  m_currentDir( aCurrentDir ),
320  m_ext( aExt )
321  {
322  SetButtonBitmaps( KiBitmap( folder_xpm ) );
323  }
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79

References KiBitmap().

Member Function Documentation

◆ DoSetPopupControl()

void TEXT_BUTTON_FILE_BROWSER::DoSetPopupControl ( wxComboPopup *  popup)
inlineoverrideprotected

Definition at line 326 of file grid_text_button_helpers.cpp.

327  {
328  m_popup = nullptr;
329  }

◆ OnButtonClick()

void TEXT_BUTTON_FILE_BROWSER::OnButtonClick ( )
inlineoverrideprotected

Definition at line 331 of file grid_text_button_helpers.cpp.

332  {
333  wxString path = GetValue();
334 
335  if( path.IsEmpty() )
336  path = *m_currentDir;
337  else
338  path = ExpandEnvVarSubstitutions( path );
339 
340  if( m_ext )
341  {
342  wxFileDialog dlg( nullptr, _( "Select a File" ), path, wxEmptyString, *m_ext,
343  wxFD_FILE_MUST_EXIST | wxFD_OPEN );
344 
345  if( dlg.ShowModal() == wxID_OK )
346  {
347  SetValue( dlg.GetPath() );
348  *m_currentDir = dlg.GetPath();
349  }
350  }
351  else
352  {
353  wxDirDialog dlg( nullptr, _( "Select Path" ), path,
354  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
355 
356  if( dlg.ShowModal() == wxID_OK )
357  {
358  SetValue( dlg.GetPath() );
359  *m_currentDir = dlg.GetPath();
360  }
361  }
362  }
const wxString ExpandEnvVarSubstitutions(const wxString &aString)
Replace any environment variable references with their values.
Definition: common.cpp:458
#define _(s)

References _, ExpandEnvVarSubstitutions(), m_currentDir, and m_ext.

Member Data Documentation

◆ m_currentDir

wxString* TEXT_BUTTON_FILE_BROWSER::m_currentDir
protected

Definition at line 365 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().

◆ m_dlg

DIALOG_SHIM* TEXT_BUTTON_FILE_BROWSER::m_dlg
protected

Definition at line 364 of file grid_text_button_helpers.cpp.

◆ m_ext

wxString* TEXT_BUTTON_FILE_BROWSER::m_ext
protected

Definition at line 366 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().


The documentation for this class was generated from the following file: