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, WX_GRID *aGrid, wxString *aCurrentDir, wxString *aExt=nullptr, bool aNormalize=false, wxString aNormalizeBasePath=wxEmptyString)
 

Protected Member Functions

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

Protected Attributes

DIALOG_SHIMm_dlg
 
WX_GRIDm_grid
 
wxString * m_currentDir
 
wxString * m_ext
 
bool m_normalize
 
wxString m_normalizeBasePath
 

Detailed Description

Definition at line 368 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,
WX_GRID aGrid,
wxString *  aCurrentDir,
wxString *  aExt = nullptr,
bool  aNormalize = false,
wxString  aNormalizeBasePath = wxEmptyString 
)
inline

Definition at line 371 of file grid_text_button_helpers.cpp.

374 :
375 wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
376 wxTE_PROCESS_ENTER ),
377 m_dlg( aParentDlg ),
378 m_grid( aGrid ),
379 m_currentDir( aCurrentDir ),
380 m_ext( aExt ),
381 m_normalize( aNormalize ),
382 m_normalizeBasePath( aNormalizeBasePath )
383 {
384 SetButtonBitmaps( KiBitmap( BITMAPS::small_folder ) );
385
386 // win32 fix, avoids drawing the "native dropdown caret"
387 Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON );
388 }
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ small_folder

References KiBitmap(), and small_folder.

Member Function Documentation

◆ DoSetPopupControl()

void TEXT_BUTTON_FILE_BROWSER::DoSetPopupControl ( wxComboPopup *  popup)
inlineoverrideprotected

Definition at line 391 of file grid_text_button_helpers.cpp.

392 {
393 m_popup = nullptr;
394 }

◆ OnButtonClick()

void TEXT_BUTTON_FILE_BROWSER::OnButtonClick ( )
inlineoverrideprotected

Definition at line 396 of file grid_text_button_helpers.cpp.

397 {
398 wxFileName fn = GetValue();
399
400 if( fn.GetPath().IsEmpty() && m_currentDir )
401 fn.SetPath( *m_currentDir );
402 else
403 fn.SetPath( ExpandEnvVarSubstitutions( fn.GetPath(), &m_dlg->Prj() ) );
404
405 if( m_ext )
406 {
407 wxFileDialog dlg( m_dlg, _( "Select a File" ), fn.GetPath(), fn.GetFullName(), *m_ext,
408 wxFD_FILE_MUST_EXIST | wxFD_OPEN );
409
410 if( dlg.ShowModal() == wxID_OK )
411 {
412 wxString filePath = dlg.GetPath();
413 wxString lastPath = dlg.GetDirectory();
414 wxString relPath = wxEmptyString;
415
416 if( m_normalize )
417 {
418 relPath = NormalizePath( filePath, &Pgm().GetLocalEnvVariables(),
420 lastPath = NormalizePath( dlg.GetDirectory(), &Pgm().GetLocalEnvVariables(),
422 }
423 else
424 {
425 relPath = filePath;
426 }
427
428 SetValue( relPath );
429
431 {;} // shouldn't happen, but Coverity doesn't know that
432
433 if( m_currentDir )
434 *m_currentDir = lastPath;
435 }
436 }
437 else
438 {
439 wxDirDialog dlg( m_dlg, _( "Select Path" ), fn.GetPath(),
440 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
441
442 if( dlg.ShowModal() == wxID_OK )
443 {
444 wxString filePath = dlg.GetPath();
445 wxString relPath = wxEmptyString;
446
447 if ( m_normalize )
448 {
449 relPath = NormalizePath( filePath, &Pgm().GetLocalEnvVariables(),
451 }
452 else
453 {
454 relPath = filePath;
455 }
456
457 SetValue( relPath );
458
460 {;} // shouldn't happen, but Coverity doesn't know that
461
462 *m_currentDir = relPath;
463 }
464 }
465 }
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226
const wxString ExpandEnvVarSubstitutions(const wxString &aString, PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:267
#define _(s)
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References _, WX_GRID::CommitPendingChanges(), ExpandEnvVarSubstitutions(), m_currentDir, m_dlg, m_ext, m_grid, m_normalize, m_normalizeBasePath, NormalizePath(), Pgm(), and KIWAY_HOLDER::Prj().

Member Data Documentation

◆ m_currentDir

wxString* TEXT_BUTTON_FILE_BROWSER::m_currentDir
protected

Definition at line 469 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().

◆ m_dlg

DIALOG_SHIM* TEXT_BUTTON_FILE_BROWSER::m_dlg
protected

Definition at line 467 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().

◆ m_ext

wxString* TEXT_BUTTON_FILE_BROWSER::m_ext
protected

Definition at line 470 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().

◆ m_grid

WX_GRID* TEXT_BUTTON_FILE_BROWSER::m_grid
protected

Definition at line 468 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().

◆ m_normalize

bool TEXT_BUTTON_FILE_BROWSER::m_normalize
protected

Definition at line 471 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().

◆ m_normalizeBasePath

wxString TEXT_BUTTON_FILE_BROWSER::m_normalizeBasePath
protected

Definition at line 472 of file grid_text_button_helpers.cpp.

Referenced by OnButtonClick().


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