KiCad PCB EDA Suite
PGM_BASE Class Referenceabstract

PGM_BASE keeps program (whole process) data for KiCad programs. More...

#include <pgm_base.h>

Inheritance diagram for PGM_BASE:
PGM_KICAD PGM_MOCK_EESCHEMA_FRAME PGM_SINGLE_TOP PGM_TEST_FRAME PGM_TEST_FRAME PGM_TEST_FRAME

Public Member Functions

 PGM_BASE ()
 
virtual ~PGM_BASE ()
 
VTBL_ENTRY void MacOpenFile (const wxString &aFileName)=0
 Function MacOpenFile is specific to MacOSX (not used under Linux or Windows). More...
 
VTBL_ENTRY SETTINGS_MANAGERGetSettingsManager () const
 
VTBL_ENTRY COMMON_SETTINGSGetCommonSettings () const
 
VTBL_ENTRY void SetEditorName (const wxString &aFileName)
 
VTBL_ENTRY const wxString & GetEditorName (bool aCanShowFileChooser=true)
 Return the preferred editor name. More...
 
VTBL_ENTRY const wxString AskUserForPreferredEditor (const wxString &aDefaultEditor=wxEmptyString)
 Shows a dialog that instructs the user to select a new preferred editor. More...
 
VTBL_ENTRY bool IsKicadEnvVariableDefined () const
 
VTBL_ENTRY const wxString & GetKicadEnvVariable () const
 
VTBL_ENTRY const wxString & GetExecutablePath () const
 
VTBL_ENTRY wxLocale * GetLocale ()
 
VTBL_ENTRY const wxString & GetPdfBrowserName () const
 
VTBL_ENTRY void SetPdfBrowserName (const wxString &aFileName)
 
VTBL_ENTRY bool UseSystemPdfBrowser () const
 Function UseSystemPdfBrowser returns true if the PDF browser is the default (system) PDF browser and false if the PDF browser is the preferred (selected) browser, else returns false if there is no selected browser. More...
 
VTBL_ENTRY void ForceSystemPdfBrowser (bool aFlg)
 Function ForceSystemPdfBrowser forces the use of system PDF browser, even if a preferred PDF browser is set. More...
 
VTBL_ENTRY bool SetLanguage (bool first_time=false)
 Function SetLanguage sets the dictionary file name for internationalization. More...
 
VTBL_ENTRY void SetLanguageIdentifier (int menu_id)
 Function SetLanguageIdentifier sets in .m_language_id member the wxWidgets language identifier Id from the KiCad menu id (internal menu identifier). More...
 
VTBL_ENTRY int GetSelectedLanguageIdentifier () const
 
VTBL_ENTRY void SetLanguagePath ()
 
VTBL_ENTRY void ReadPdfBrowserInfos ()
 Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration. More...
 
VTBL_ENTRY void WritePdfBrowserInfos ()
 Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration. More...
 
VTBL_ENTRY bool SetLocalEnvVariable (const wxString &aName, const wxString &aValue)
 Function SetLocalEnvVariable. More...
 
VTBL_ENTRY void SetLocalEnvVariables (const ENV_VAR_MAP &aEnvVarMap)
 Function SetLocalEnvVariables. More...
 
VTBL_ENTRY const ENV_VAR_MAPGetLocalEnvVariables () const
 
VTBL_ENTRY wxApp & App ()
 Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe. More...
 
bool InitPgm ()
 Function initPgm initializes this program (process) in a KiCad standard way, using some generalized techniques. More...
 
void Destroy ()
 
void SaveCommonSettings ()
 Function saveCommonSettings saves the program (process) settings subset which are stored .kicad_common. More...
 

Public Attributes

bool m_Printing
 wxWidgets on MSW tends to crash if you spool up more than one print job at a time. More...
 

Static Public Attributes

static const wxChar workingDirKey []
 

Protected Member Functions

void loadCommonSettings ()
 Loads internal settings from COMMON_SETTINGS. More...
 
void setLanguageId (int aId)
 Trap all changes in here, simplifies debugging. More...
 
bool setExecutablePath ()
 Function setExecutablePath finds the path to the executable and stores it in PGM_BASE::m_bin_dir. More...
 

Protected Attributes

std::unique_ptr< SETTINGS_MANAGERm_settings_manager
 
wxSingleInstanceChecker * m_pgm_checker
 prevents multiple instances of a program from being run at the same time. More...
 
wxString m_bin_dir
 full path to this program More...
 
wxString m_kicad_env
 The KICAD system environment variable. More...
 
wxLocale * m_locale
 The current locale. More...
 
int m_language_id
 The current language setting. More...
 
bool m_use_system_pdf_browser
 true to use the selected PDF browser, if exists, or false to use the default More...
 
wxString m_pdf_browser
 The file name of the the program selected for browsing pdf files. More...
 
wxString m_editor_name
 
wxSize m_help_size
 
ENV_VAR_MAP m_local_env_vars
 Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD. More...
 
bool m_show_env_var_dialog
 Flag to indicate if the environment variable overwrite warning dialog should be shown. More...
 

Detailed Description

PGM_BASE keeps program (whole process) data for KiCad programs.

The VTBL_ENTRY functions are VTBL_ENTRY so we can do cross module calls without linking to them. This used to be a wxApp derivative, but that is difficult under wxPython which shapes the wxApp. So now this is a "side-car" (like a motorcycle side-car) object with a back pointer into the wxApp which initializes it.

OnPgmStart() is virtual, may be overridden, and parallels wxApp::OnInit(), from where it should called.

OnPgmEnd() is virtual, may be overridden, and parallels wxApp::OnExit(), from where it should be called.

Definition at line 137 of file pgm_base.h.

Constructor & Destructor Documentation

◆ PGM_BASE()

PGM_BASE::PGM_BASE ( )

Definition at line 107 of file pgm_base.cpp.

108 {
110  m_locale = NULL;
111  m_Printing = false;
112 
113  m_show_env_var_dialog = true;
114 
115  setLanguageId( wxLANGUAGE_DEFAULT );
116 
117  ForceSystemPdfBrowser( false );
118 }
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:360
VTBL_ENTRY void ForceSystemPdfBrowser(bool aFlg)
Function ForceSystemPdfBrowser forces the use of system PDF browser, even if a preferred PDF browser ...
Definition: pgm_base.h:228
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:387
wxSingleInstanceChecker * m_pgm_checker
prevents multiple instances of a program from being run at the same time.
Definition: pgm_base.h:351
#define NULL
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:369
bool m_Printing
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
Definition: pgm_base.h:341

References ForceSystemPdfBrowser(), m_locale, m_pgm_checker, m_Printing, m_show_env_var_dialog, NULL, and setLanguageId().

◆ ~PGM_BASE()

PGM_BASE::~PGM_BASE ( )
virtual

Definition at line 121 of file pgm_base.cpp.

122 {
123  Destroy();
124 }
void Destroy()
Definition: pgm_base.cpp:127

References Destroy().

Member Function Documentation

◆ App()

wxApp & PGM_BASE::App ( )

Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.

Should return what wxGetApp() returns.

Definition at line 138 of file pgm_base.cpp.

139 {
140  wxASSERT( wxTheApp );
141  return *wxTheApp;
142 }

Referenced by InitPgm(), PGM_KICAD::MacOpenFile(), PGM_SINGLE_TOP::MacOpenFile(), PGM_TEST_FRAME::MacOpenFile(), PGM_MOCK_EESCHEMA_FRAME::MacOpenFile(), and PGM_KICAD::OnPgmInit().

◆ AskUserForPreferredEditor()

const wxString PGM_BASE::AskUserForPreferredEditor ( const wxString &  aDefaultEditor = wxEmptyString)

Shows a dialog that instructs the user to select a new preferred editor.

Parameters
aDefaultEditorDefault full path for the default editor this dialog should show by default.
Returns
Returns the full path of the editor, or an empty string if no editor was chosen.

Definition at line 190 of file pgm_base.cpp.

191 {
192  // Create a mask representing the executable files in the current platform
193 #ifdef __WINDOWS__
194  wxString mask( _( "Executable file (*.exe)|*.exe" ) );
195 #else
196  wxString mask( _( "Executable file (*)|*" ) );
197 #endif
198 
199  // Extract the path, name and extension from the default editor (even if the editor's
200  // name was empty, this method will succeed and return empty strings).
201  wxString path, name, ext;
202  wxFileName::SplitPath( aDefaultEditor, &path, &name, &ext );
203 
204  // Show the modal editor and return the file chosen (may be empty if the user cancels
205  // the dialog).
206  return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path,
207  name, ext, mask,
208  NULL, wxFD_OPEN | wxFD_FILE_MUST_EXIST,
209  true );
210 }
#define NULL
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:52
const char * name
Definition: DXF_plotter.cpp:60
#define _(s)
LanguagesList Note: because this list is not created on the fly, wxTranslation must be called when a ...
Definition: pgm_base.cpp:104

References _, EDA_FILE_SELECTOR(), name, and NULL.

Referenced by GetEditorName().

◆ Destroy()

void PGM_BASE::Destroy ( )

Definition at line 127 of file pgm_base.cpp.

128 {
129  // unlike a normal destructor, this is designed to be called more than once safely:
130  delete m_pgm_checker;
131  m_pgm_checker = 0;
132 
133  delete m_locale;
134  m_locale = 0;
135 }
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:360
wxSingleInstanceChecker * m_pgm_checker
prevents multiple instances of a program from being run at the same time.
Definition: pgm_base.h:351

References m_locale, and m_pgm_checker.

Referenced by PGM_KICAD::Destroy(), PGM_SINGLE_TOP::OnPgmExit(), PGM_MOCK_EESCHEMA_FRAME::OnPgmExit(), PGM_TEST_FRAME::OnPgmExit(), and ~PGM_BASE().

◆ ForceSystemPdfBrowser()

VTBL_ENTRY void PGM_BASE::ForceSystemPdfBrowser ( bool  aFlg)
inline

Function ForceSystemPdfBrowser forces the use of system PDF browser, even if a preferred PDF browser is set.

Definition at line 228 of file pgm_base.h.

228 { m_use_system_pdf_browser = aFlg; }
bool m_use_system_pdf_browser
true to use the selected PDF browser, if exists, or false to use the default
Definition: pgm_base.h:366

References m_use_system_pdf_browser.

Referenced by PGM_BASE().

◆ GetCommonSettings()

COMMON_SETTINGS * PGM_BASE::GetCommonSettings ( ) const

Definition at line 546 of file pgm_base.cpp.

547 {
549 }
VTBL_ENTRY SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:175
COMMON_SETTINGS * GetCommonSettings()
Retrieves the common settings shared by all applications.

References SETTINGS_MANAGER::GetCommonSettings(), and GetSettingsManager().

Referenced by InitPgm(), loadCommonSettings(), ReadPdfBrowserInfos(), SaveCommonSettings(), SetEditorName(), SetLanguage(), and WritePdfBrowserInfos().

◆ GetEditorName()

const wxString & PGM_BASE::GetEditorName ( bool  aCanShowFileChooser = true)

Return the preferred editor name.

Parameters
aCanShowFileChooserIf no editor is currently set and this argument is 'true' then this method will show a file chooser dialog asking for the editor's executable.
Returns
Returns the full path of the editor, or an empty string if no editor has been set.

Definition at line 153 of file pgm_base.cpp.

154 {
155  wxString editorname = m_editor_name;
156 
157  if( !editorname )
158  {
159  if( !wxGetEnv( "EDITOR", &editorname ) )
160  {
161  // If there is no EDITOR variable set, try the desktop default
162 #ifdef __WXMAC__
163  editorname = "/usr/bin/open";
164 #elif __WXX11__
165  editorname = "/usr/bin/xdg-open";
166 #endif
167  }
168  }
169 
170  // If we still don't have an editor name show a dialog asking the user to select one
171  if( !editorname && aCanShowFileChooser )
172  {
174  _( "No default editor found, you must choose it" ) );
175 
176  editorname = AskUserForPreferredEditor();
177  }
178 
179  // If we finally have a new editor name request it to be copied to m_editor_name and
180  // saved to the preferences file.
181  if( !editorname.IsEmpty() )
182  SetEditorName( editorname );
183 
184  // m_editor_name already has the same value that editorname, or empty if no editor was
185  // found/chosen.
186  return m_editor_name;
187 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:145
VTBL_ENTRY const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Shows a dialog that instructs the user to select a new preferred editor.
Definition: pgm_base.cpp:190
#define NULL
#define _(s)
LanguagesList Note: because this list is not created on the fly, wxTranslation must be called when a ...
Definition: pgm_base.cpp:104
wxString m_editor_name
Definition: pgm_base.h:380
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267

References _, AskUserForPreferredEditor(), DisplayInfoMessage(), m_editor_name, NULL, and SetEditorName().

◆ GetExecutablePath()

VTBL_ENTRY const wxString& PGM_BASE::GetExecutablePath ( ) const
inline

Definition at line 205 of file pgm_base.h.

205 { return m_bin_dir; }
wxString m_bin_dir
full path to this program
Definition: pgm_base.h:354

References m_bin_dir.

Referenced by PGM_SINGLE_TOP::OnPgmInit().

◆ GetKicadEnvVariable()

VTBL_ENTRY const wxString& PGM_BASE::GetKicadEnvVariable ( ) const
inline

Definition at line 203 of file pgm_base.h.

203 { return m_kicad_env; }
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:357

References m_kicad_env.

◆ GetLocale()

VTBL_ENTRY wxLocale* PGM_BASE::GetLocale ( )
inline

Definition at line 207 of file pgm_base.h.

207 { return m_locale; }
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:360

References m_locale.

◆ GetLocalEnvVariables()

VTBL_ENTRY const ENV_VAR_MAP& PGM_BASE::GetLocalEnvVariables ( ) const
inline

Definition at line 298 of file pgm_base.h.

299  {
300  return m_local_env_vars;
301  }
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:384

References m_local_env_vars.

Referenced by FILENAME_RESOLVER::GetKicadPaths(), and PGM_KICAD::OnPgmInit().

◆ GetPdfBrowserName()

VTBL_ENTRY const wxString& PGM_BASE::GetPdfBrowserName ( ) const
inline

Definition at line 209 of file pgm_base.h.

209 { return m_pdf_browser; }
wxString m_pdf_browser
The file name of the the program selected for browsing pdf files.
Definition: pgm_base.h:379

References m_pdf_browser.

Referenced by WritePdfBrowserInfos().

◆ GetSelectedLanguageIdentifier()

VTBL_ENTRY int PGM_BASE::GetSelectedLanguageIdentifier ( ) const
inline
Returns
the wxWidgets language identifier Id of the language currently selected

Definition at line 255 of file pgm_base.h.

255 { return m_language_id; }
int m_language_id
The current language setting.
Definition: pgm_base.h:363

References m_language_id.

◆ GetSettingsManager()

◆ InitPgm()

bool PGM_BASE::InitPgm ( )

Function initPgm initializes this program (process) in a KiCad standard way, using some generalized techniques.

  • Default paths (help, libs, bin) and configuration file names
  • Language and locale
  • fonts

But nothing relating to DSOs or projects.

Returns
bool - true if success, false if failure and program is to terminate.

Definition at line 213 of file pgm_base.cpp.

214 {
215  wxFileName pgm_name( App().argv[0] );
216 
217  wxInitAllImageHandlers();
218 
219  m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) +
220  wxGetUserId(), GetKicadLockFilePath() );
221 
222  if( m_pgm_checker->IsAnotherRunning() )
223  {
224  wxString quiz = wxString::Format(
225  _( "%s is already running. Continue?" ),
226  GetChars( pgm_name.GetName() )
227  );
228 
229  if( !IsOK( NULL, quiz ) )
230  return false;
231  }
232 
233  m_settings_manager = std::unique_ptr<SETTINGS_MANAGER>( new SETTINGS_MANAGER );
234 
235  // Something got in the way of settings load: can't continue
236  if( !m_settings_manager->IsOK() )
237  return false;
238 
239  // Init KiCad environment
240  // the environment variable KICAD (if exists) gives the kicad path:
241  // something like set KICAD=d:\kicad
242  bool isDefined = wxGetEnv( "KICAD", &m_kicad_env );
243 
244  if( isDefined ) // ensure m_kicad_env ends by "/"
245  {
247 
248  if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
250  }
251 
252  // Init parameters for configuration
253  App().SetVendorName( "KiCad" );
254  App().SetAppName( pgm_name.GetName().Lower() );
255 
256  // Install some image handlers, mainly for help
257  if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL )
258  wxImage::AddHandler( new wxPNGHandler );
259 
260  if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL )
261  wxImage::AddHandler( new wxGIFHandler );
262 
263  if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL )
264  wxImage::AddHandler( new wxJPEGHandler );
265 
266  wxFileSystem::AddHandler( new wxZipFSHandler );
267 
268  // Analyze the command line & initialize the binary path
270 
271  SetLanguagePath();
272 
273  wxString envVarName = wxT( "KIGITHUB" );
274  ENV_VAR_ITEM envVarItem;
275  wxString envValue;
276  wxFileName tmpFileName;
277 
278  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
279  {
280  tmpFileName.AssignDir( envValue );
281  envVarItem.SetDefinedExternally( true );
282  }
283  else
284  {
285  envVarItem.SetValue( wxString( wxT( "https://github.com/KiCad" ) ) );
286  envVarItem.SetDefinedExternally( false );
287  }
288 
289  m_local_env_vars[ envVarName ] = envVarItem;
290 
291  wxFileName baseSharePath;
292 #if defined( __WXMSW__ )
293  // Make the paths relative to the executable dir as KiCad might be installed anywhere
294  // It follows the Windows installer paths scheme, where binaries are installed in
295  // PATH/bin and extra files in PATH/share/kicad
296  baseSharePath.AssignDir( m_bin_dir + "\\.." );
297  baseSharePath.Normalize();
298 #else
299  baseSharePath.AssignDir( wxString( wxT( DEFAULT_INSTALL_PATH ) ) );
300 #endif
301 
302 #if !defined( __WXMAC__ )
303  baseSharePath.AppendDir( "share" );
304  baseSharePath.AppendDir( "kicad" );
305 #endif
306 
307  // KISYSMOD
308  envVarName = wxT( "KISYSMOD" );
309 
310  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
311  {
312  tmpFileName.AssignDir( envValue );
313  envVarItem.SetDefinedExternally( true );
314  }
315  else
316  {
317  tmpFileName = baseSharePath;
318  tmpFileName.AppendDir( "modules" );
319  envVarItem.SetDefinedExternally( false );
320  }
321 
322  envVarItem.SetValue( tmpFileName.GetPath() );
323  m_local_env_vars[ envVarName ] = envVarItem;
324 
325  // KISYS3DMOD
326  envVarName = wxT( "KISYS3DMOD" );
327 
328  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
329  {
330  tmpFileName.AssignDir( envValue );
331  envVarItem.SetDefinedExternally( true );
332  }
333  else
334  {
335  tmpFileName.AppendDir( "packages3d" );
336  envVarItem.SetDefinedExternally( false );
337  }
338 
339  envVarItem.SetValue( tmpFileName.GetFullPath() );
340  m_local_env_vars[ envVarName ] = envVarItem;
341 
342  // KICAD_TEMPLATE_DIR
343  envVarName = "KICAD_TEMPLATE_DIR";
344 
345  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
346  {
347  tmpFileName.AssignDir( envValue );
348  envVarItem.SetDefinedExternally( true );
349  }
350  else
351  {
352  // Attempt to find the best default template path.
353  SEARCH_STACK bases;
354  SEARCH_STACK templatePaths;
355 
356  SystemDirsAppend( &bases );
357 
358  for( unsigned i = 0; i < bases.GetCount(); ++i )
359  {
360  wxFileName fn( bases[i], wxEmptyString );
361 
362  // Add KiCad template file path to search path list.
363  fn.AppendDir( "template" );
364 
365  // Only add path if exists and can be read by the user.
366  if( fn.DirExists() && fn.IsDirReadable() )
367  {
368  wxLogTrace( tracePathsAndFiles, "Checking template path '%s' exists",
369  fn.GetPath() );
370  templatePaths.AddPaths( fn.GetPath() );
371  }
372  }
373 
374  if( templatePaths.IsEmpty() )
375  {
376  tmpFileName = baseSharePath;
377  tmpFileName.AppendDir( "template" );
378  }
379  else
380  {
381  // Take the first one. There may be more but this will likely be the best option.
382  tmpFileName.AssignDir( templatePaths[0] );
383  }
384 
385  envVarItem.SetDefinedExternally( false );
386  }
387 
388  envVarItem.SetValue( tmpFileName.GetPath() );
389  m_local_env_vars[ envVarName ] = envVarItem;
390 
391  // KICAD_USER_TEMPLATE_DIR
392  envVarName = "KICAD_USER_TEMPLATE_DIR";
393 
394  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
395  {
396  tmpFileName.AssignDir( envValue );
397  envVarItem.SetDefinedExternally( true );
398  }
399  else
400  {
401  // Default user template path.
402  tmpFileName.AssignDir( wxStandardPaths::Get().GetDocumentsDir() );
403  tmpFileName.AppendDir( "kicad" );
404  tmpFileName.AppendDir( "template" );
405  envVarItem.SetDefinedExternally( false );
406  }
407 
408  envVarItem.SetValue( tmpFileName.GetPath() );
409  m_local_env_vars[ envVarName ] = envVarItem;
410 
411  // KICAD_SYMBOLS
412  envVarName = wxT( "KICAD_SYMBOL_DIR" );
413 
414  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
415  {
416  tmpFileName.AssignDir( envValue );
417  envVarItem.SetDefinedExternally( true );
418  }
419  else
420  {
421  tmpFileName = baseSharePath;
422  tmpFileName.AppendDir( "library" );
423  envVarItem.SetDefinedExternally( false );
424  }
425 
426  envVarItem.SetValue( tmpFileName.GetPath() );
427  m_local_env_vars[ envVarName ] = envVarItem;
428 
430 
431  // Init user language *before* calling loadCommonSettings, because
432  // env vars could be incorrectly initialized on Linux
433  // (if the value contains some non ASCII7 chars, the env var is not initialized)
434  SetLanguage( true );
435 
437 
438  ReadPdfBrowserInfos(); // needs GetCommonSettings()
439 
440 #ifdef __WXMAC__
441  // Always show filters on Open dialog to be able to choose plugin
442  wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
443 #endif
444 
445  return true;
446 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
void loadCommonSettings()
Loads internal settings from COMMON_SETTINGS.
Definition: pgm_base.cpp:491
wxString GetKicadLockFilePath()
Function GetKicadLockFilePath.
Definition: lockfile.cpp:59
#define WIN_STRING_DIR_SEP
Definition: gestfich.h:44
VTBL_ENTRY SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:175
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:384
#define UNIX_STRING_DIR_SEP
Definition: gestfich.h:43
ENV_VAR_ITEM.
Definition: pgm_base.h:88
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:138
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
bool setExecutablePath()
Function setExecutablePath finds the path to the executable and stores it in PGM_BASE::m_bin_dir.
Definition: pgm_base.cpp:449
wxSingleInstanceChecker * m_pgm_checker
prevents multiple instances of a program from being run at the same time.
Definition: pgm_base.h:351
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
Definition: pgm_base.h:348
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:357
#define NULL
void SetDefinedExternally(bool aIsDefinedExternally)
Definition: pgm_base.h:100
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Function SystemDirsAppend appends system places to aSearchStack in a platform specific way,...
VTBL_ENTRY void SetLanguagePath()
Definition: pgm_base.cpp:658
VTBL_ENTRY bool SetLanguage(bool first_time=false)
Function SetLanguage sets the dictionary file name for internationalization.
Definition: pgm_base.cpp:552
wxString m_bin_dir
full path to this program
Definition: pgm_base.h:354
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:43
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetValue(const wxString &aValue)
Definition: pgm_base.h:106
#define _(s)
LanguagesList Note: because this list is not created on the fly, wxTranslation must be called when a ...
Definition: pgm_base.cpp:104
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)

References _, SEARCH_STACK::AddPaths(), App(), Format(), GetChars(), GetCommonSettings(), GetKicadLockFilePath(), GetSettingsManager(), IsOK(), SETTINGS_MANAGER::Load(), loadCommonSettings(), m_bin_dir, m_kicad_env, m_local_env_vars, m_pgm_checker, m_settings_manager, NULL, ReadPdfBrowserInfos(), ENV_VAR_ITEM::SetDefinedExternally(), setExecutablePath(), SetLanguage(), SetLanguagePath(), ENV_VAR_ITEM::SetValue(), SystemDirsAppend(), tracePathsAndFiles, UNIX_STRING_DIR_SEP, and WIN_STRING_DIR_SEP.

Referenced by PGM_KICAD::OnPgmInit().

◆ IsKicadEnvVariableDefined()

VTBL_ENTRY bool PGM_BASE::IsKicadEnvVariableDefined ( ) const
inline

Definition at line 201 of file pgm_base.h.

201 { return !m_kicad_env.IsEmpty(); }
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:357

References m_kicad_env.

◆ loadCommonSettings()

void PGM_BASE::loadCommonSettings ( )
protected

Loads internal settings from COMMON_SETTINGS.

Definition at line 491 of file pgm_base.cpp.

492 {
493  m_help_size.x = 500;
494  m_help_size.y = 400;
495 
498 
499  for( const auto& it : GetCommonSettings()->m_Env.vars )
500  {
501  wxString key( it.first.c_str(), wxConvUTF8 );
502  wxLogTrace( traceEnvVars, "Enumerating over entry %s = %s.", key, it.second );
503 
504  // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason
505  // it is found in config. (It is reserved and defined as project path)
506  if( key == PROJECT_VAR_NAME )
507  continue;
508 
509  if( m_local_env_vars[ key ].GetDefinedExternally() )
510  continue;
511 
512  m_local_env_vars[ key ] = ENV_VAR_ITEM( it.second, wxGetEnv( it.first, nullptr ) );
513  }
514 
515  for( auto& m_local_env_var : m_local_env_vars )
516  SetLocalEnvVariable( m_local_env_var.first, m_local_env_var.second.GetValue() );
517 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:384
ENV_VAR_ITEM.
Definition: pgm_base.h:88
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:38
static const wxChar traceEnvVars[]
Definition: pgm_base.cpp:63
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:387
VTBL_ENTRY bool SetLocalEnvVariable(const wxString &aName, const wxString &aValue)
Function SetLocalEnvVariable.
Definition: pgm_base.cpp:693
ENVIRONMENT m_Env
wxSize m_help_size
Definition: pgm_base.h:381
wxString m_editor_name
Definition: pgm_base.h:380

References COMMON_SETTINGS::SYSTEM::editor_name, GetCommonSettings(), m_editor_name, COMMON_SETTINGS::m_Env, m_help_size, m_local_env_vars, m_show_env_var_dialog, COMMON_SETTINGS::m_System, PROJECT_VAR_NAME, SetLocalEnvVariable(), COMMON_SETTINGS::ENVIRONMENT::show_warning_dialog, and traceEnvVars.

Referenced by InitPgm().

◆ MacOpenFile()

VTBL_ENTRY void PGM_BASE::MacOpenFile ( const wxString &  aFileName)
pure virtual

Function MacOpenFile is specific to MacOSX (not used under Linux or Windows).

MacOSX requires it for file association.

See also
http://wiki.wxwidgets.org/WxMac-specific_topics

Implemented in PGM_TEST_FRAME, PGM_MOCK_EESCHEMA_FRAME, PGM_TEST_FRAME, PGM_SINGLE_TOP, PGM_KICAD, and PGM_TEST_FRAME.

◆ ReadPdfBrowserInfos()

void PGM_BASE::ReadPdfBrowserInfos ( )

Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.

Definition at line 43 of file eda_doc.cpp.

44 {
45  SetPdfBrowserName( GetCommonSettings()->m_System.pdf_viewer_name );
47 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
bool m_use_system_pdf_browser
true to use the selected PDF browser, if exists, or false to use the default
Definition: pgm_base.h:366
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
Definition: pgm_base.h:211

References GetCommonSettings(), COMMON_SETTINGS::m_System, m_use_system_pdf_browser, SetPdfBrowserName(), and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.

Referenced by InitPgm().

◆ SaveCommonSettings()

void PGM_BASE::SaveCommonSettings ( )

Function saveCommonSettings saves the program (process) settings subset which are stored .kicad_common.

Definition at line 520 of file pgm_base.cpp.

521 {
522  // GetCommonSettings() is not initialized until fairly late in the
523  // process startup: InitPgm(), so test before using:
524  if( GetCommonSettings() )
525  {
526  GetCommonSettings()->m_System.working_dir = wxGetCwd().ToStdString();
528 
529  // Save the local environment variables.
530  for( auto& m_local_env_var : m_local_env_vars )
531  {
532  if( m_local_env_var.second.GetDefinedExternally() )
533  continue;
534 
535  wxLogTrace( traceEnvVars, "Saving environment variable config entry %s as %s",
536  GetChars( m_local_env_var.first ),
537  GetChars( m_local_env_var.second.GetValue() ) );
538 
539  std::string key( m_local_env_var.first.ToUTF8() );
540  GetCommonSettings()->m_Env.vars[ key ] = m_local_env_var.second.GetValue();
541  }
542  }
543 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:384
static const wxChar traceEnvVars[]
Definition: pgm_base.cpp:63
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:387
std::map< std::string, wxString > vars
ENVIRONMENT m_Env
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101

References GetChars(), GetCommonSettings(), COMMON_SETTINGS::m_Env, m_local_env_vars, m_show_env_var_dialog, COMMON_SETTINGS::m_System, COMMON_SETTINGS::ENVIRONMENT::show_warning_dialog, traceEnvVars, COMMON_SETTINGS::ENVIRONMENT::vars, and COMMON_SETTINGS::SYSTEM::working_dir.

Referenced by PGM_KICAD::OnPgmExit(), PGM_SINGLE_TOP::OnPgmExit(), and SetLocalEnvVariables().

◆ SetEditorName()

void PGM_BASE::SetEditorName ( const wxString &  aFileName)

Definition at line 145 of file pgm_base.cpp.

146 {
147  m_editor_name = aFileName;
148  wxASSERT( GetCommonSettings() );
149  GetCommonSettings()->m_System.editor_name = aFileName;
150 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
wxString m_editor_name
Definition: pgm_base.h:380

References COMMON_SETTINGS::SYSTEM::editor_name, GetCommonSettings(), m_editor_name, and COMMON_SETTINGS::m_System.

Referenced by GetEditorName().

◆ setExecutablePath()

bool PGM_BASE::setExecutablePath ( )
protected

Function setExecutablePath finds the path to the executable and stores it in PGM_BASE::m_bin_dir.

Returns
bool - true if success, else false.

Definition at line 449 of file pgm_base.cpp.

450 {
451  m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
452 
453 #ifdef __WXMAC__
454  // On OSX Pgm().GetExecutablePath() will always point to main
455  // bundle directory, e.g., /Applications/kicad.app/
456 
457  wxFileName fn( m_bin_dir );
458 
459  if( fn.GetName() == wxT( "kicad" ) )
460  {
461  // kicad launcher, so just remove the Contents/MacOS part
462  fn.RemoveLastDir();
463  fn.RemoveLastDir();
464  }
465  else
466  {
467  // standalone binaries live in Contents/Applications/<standalone>.app/Contents/MacOS
468  fn.RemoveLastDir();
469  fn.RemoveLastDir();
470  fn.RemoveLastDir();
471  fn.RemoveLastDir();
472  fn.RemoveLastDir();
473  }
474 
475  m_bin_dir = fn.GetPath() + wxT( "/" );
476 #else
477  // Use unix notation for paths. I am not sure this is a good idea,
478  // but it simplifies compatibility between Windows and Unices.
479  // However it is a potential problem in path handling under Windows.
481 
482  // Remove file name form command line:
483  while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
484  m_bin_dir.RemoveLast();
485 #endif
486 
487  return true;
488 }
#define WIN_STRING_DIR_SEP
Definition: gestfich.h:44
#define UNIX_STRING_DIR_SEP
Definition: gestfich.h:43
wxString m_bin_dir
full path to this program
Definition: pgm_base.h:354

References m_bin_dir, UNIX_STRING_DIR_SEP, and WIN_STRING_DIR_SEP.

Referenced by InitPgm().

◆ SetLanguage()

bool PGM_BASE::SetLanguage ( bool  first_time = false)

Function SetLanguage sets the dictionary file name for internationalization.

The files are in kicad/internat/xx or kicad/internat/xx_XX and are named kicad.mo

Parameters
first_timemust be set to true the first time this funct is called, false otherwise
Returns
true if the language can be set (i.e. if the locale is available)

Definition at line 552 of file pgm_base.cpp.

553 {
554  bool retv = true;
555 
556  if( first_time )
557  {
558  setLanguageId( wxLANGUAGE_DEFAULT );
559  // First time SetLanguage is called, the user selected language id is set
560  // from common user config settings
561  wxString languageSel = GetCommonSettings()->m_System.language;
562 
563  // Search for the current selection
564  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
565  {
566  if( LanguagesList[ii].m_Lang_Label == languageSel )
567  {
568  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
569  break;
570  }
571  }
572  }
573 
574  // dictionary file name without extend (full name is kicad.mo)
575  wxString dictionaryName( "kicad" );
576 
577  delete m_locale;
578  m_locale = new wxLocale;
579 
580  if( !m_locale->Init( m_language_id ) )
581  {
582  wxLogTrace( traceLocale, "This language is not supported by the system." );
583 
584  setLanguageId( wxLANGUAGE_DEFAULT );
585  delete m_locale;
586 
587  m_locale = new wxLocale;
588  m_locale->Init();
589  retv = false;
590  }
591  else if( !first_time )
592  {
593  wxLogTrace( traceLocale, "Search for dictionary %s.mo in %s",
594  GetChars( dictionaryName ), GetChars( m_locale->GetName() ) );
595  }
596 
597  if( !first_time )
598  {
599  // If we are here, the user has selected another language.
600  // Therefore the new prefered language name is stored in common config.
601  // Do NOT store the wxWidgets language Id, it can change between wxWidgets
602  // versions, for a given language
603  wxString languageSel;
604 
605  // Search for the current selection language name
606  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
607  {
608  if( LanguagesList[ii].m_WX_Lang_Identifier == m_language_id )
609  {
610  languageSel = LanguagesList[ii].m_Lang_Label;
611  break;
612  }
613  }
614 
615  GetCommonSettings()->m_System.language = languageSel;
616  }
617 
618  // Test if floating point notation is working (bug encountered in cross compilation)
619  // Make a conversion double <=> string
620  double dtst = 0.5;
621  wxString msg;
622 
623  msg << dtst;
624  double result;
625  msg.ToDouble( &result );
626 
627  if( result != dtst )
628  // string to double encode/decode does not work! Bug detected:
629  // Disable floating point localization:
630  setlocale( LC_NUMERIC, "C" );
631 
632  if( !m_locale->IsLoaded( dictionaryName ) )
633  m_locale->AddCatalog( dictionaryName );
634 
635  if( !retv )
636  return retv;
637 
638  return m_locale->IsOk();
639 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
LANGUAGE_DESCR LanguagesList[]
Definition: pgm_base.cpp:74
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:360
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:64
int m_language_id
The current language setting.
Definition: pgm_base.h:363
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:369
const wxChar *const traceLocale
Flag to enable locale debug output.
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.h:70
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101

References GetChars(), GetCommonSettings(), COMMON_SETTINGS::SYSTEM::language, LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, LANGUAGE_DESCR::m_Lang_Label, m_language_id, m_locale, COMMON_SETTINGS::m_System, setLanguageId(), and traceLocale.

Referenced by InitPgm().

◆ setLanguageId()

void PGM_BASE::setLanguageId ( int  aId)
inlineprotected

Trap all changes in here, simplifies debugging.

Definition at line 369 of file pgm_base.h.

369 { m_language_id = aId; }
int m_language_id
The current language setting.
Definition: pgm_base.h:363

References m_language_id.

Referenced by PGM_BASE(), SetLanguage(), and SetLanguageIdentifier().

◆ SetLanguageIdentifier()

void PGM_BASE::SetLanguageIdentifier ( int  menu_id)

Function SetLanguageIdentifier sets in .m_language_id member the wxWidgets language identifier Id from the KiCad menu id (internal menu identifier).

Parameters
menu_idThe KiCad menuitem id (returned by Menu Event, when clicking on a menu item)

Definition at line 642 of file pgm_base.cpp.

643 {
644  wxLogTrace( traceLocale, "Select language ID %d from %d possible languages.",
645  menu_id, (int)arrayDim( LanguagesList )-1 );
646 
647  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
648  {
649  if( menu_id == LanguagesList[ii].m_KI_Lang_Identifier )
650  {
651  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
652  break;
653  }
654  }
655 }
LANGUAGE_DESCR LanguagesList[]
Definition: pgm_base.cpp:74
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:64
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:369
const wxChar *const traceLocale
Flag to enable locale debug output.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108

References arrayDim(), LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, setLanguageId(), and traceLocale.

◆ SetLanguagePath()

void PGM_BASE::SetLanguagePath ( )

Definition at line 658 of file pgm_base.cpp.

659 {
660  SEARCH_STACK guesses;
661 
662  SystemDirsAppend( &guesses );
663 
664  // Add our internat dir to the wxLocale catalog of paths
665  for( unsigned i = 0; i < guesses.GetCount(); i++ )
666  {
667  wxFileName fn( guesses[i], wxEmptyString );
668 
669  // Append path for Windows and unix KiCad package install
670  fn.AppendDir( "share" );
671  fn.AppendDir( "internat" );
672 
673  if( fn.IsDirReadable() )
674  {
675  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
676  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
677  }
678 
679  // Append path for unix standard install
680  fn.RemoveLastDir();
681  fn.AppendDir( "kicad" );
682  fn.AppendDir( "internat" );
683 
684  if( fn.IsDirReadable() )
685  {
686  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
687  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
688  }
689  }
690 }
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Function SystemDirsAppend appends system places to aSearchStack in a platform specific way,...
const wxChar *const traceLocale
Flag to enable locale debug output.

References SystemDirsAppend(), and traceLocale.

Referenced by InitPgm().

◆ SetLocalEnvVariable()

bool PGM_BASE::SetLocalEnvVariable ( const wxString &  aName,
const wxString &  aValue 
)

Function SetLocalEnvVariable.

Sets the environment variable aName to aValue.

This function first checks to see if the environment variable aName is already defined. If it is not defined, then the environment variable aName is set to a value. Otherwise, the environment variable is left unchanged. This allows the user to override environment variables for testing purposes.

Parameters
aNameis a wxString containing the environment variable name.
aValueis a wxString containing the environment variable value.
Returns
true if the environment variable Name was set to aValue.

Definition at line 693 of file pgm_base.cpp.

694 {
695  wxString env;
696 
697  // Check to see if the environment variable is already set.
698  if( wxGetEnv( aName, &env ) )
699  {
700  wxLogTrace( traceEnvVars, "Environment variable %s already set to %s.",
701  GetChars( aName ), GetChars( env ) );
702  return env == aValue;
703  }
704 
705  wxLogTrace( traceEnvVars, "Setting local environment variable %s to %s.",
706  GetChars( aName ), GetChars( aValue ) );
707 
708  return wxSetEnv( aName, aValue );
709 }
static const wxChar traceEnvVars[]
Definition: pgm_base.cpp:63
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101

References GetChars(), and traceEnvVars.

Referenced by loadCommonSettings().

◆ SetLocalEnvVariables()

void PGM_BASE::SetLocalEnvVariables ( const ENV_VAR_MAP aEnvVarMap)

Function SetLocalEnvVariables.

sets the internal local environment variable map to aEnvVarMap, updates the entries in the .kicad_common configuration file, and sets the environment variable to the new settings.

Parameters
aEnvVarMapis a ENV_VAR_MAP object containing the new environment variables.

Definition at line 712 of file pgm_base.cpp.

713 {
714  m_local_env_vars.clear();
715  m_local_env_vars = aEnvVarMap;
716 
718 
719  // Overwrites externally defined environment variable until the next time the application
720  // is run.
721  for( auto& m_local_env_var : m_local_env_vars )
722  {
723  wxLogTrace( traceEnvVars, "Setting local environment variable %s to %s.",
724  GetChars( m_local_env_var.first ),
725  GetChars( m_local_env_var.second.GetValue() ) );
726  wxSetEnv( m_local_env_var.first, m_local_env_var.second.GetValue() );
727  }
728 }
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:384
void SaveCommonSettings()
Function saveCommonSettings saves the program (process) settings subset which are stored ....
Definition: pgm_base.cpp:520
static const wxChar traceEnvVars[]
Definition: pgm_base.cpp:63
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101

References GetChars(), m_local_env_vars, SaveCommonSettings(), and traceEnvVars.

◆ SetPdfBrowserName()

VTBL_ENTRY void PGM_BASE::SetPdfBrowserName ( const wxString &  aFileName)
inline

Definition at line 211 of file pgm_base.h.

211 { m_pdf_browser = aFileName; }
wxString m_pdf_browser
The file name of the the program selected for browsing pdf files.
Definition: pgm_base.h:379

References m_pdf_browser.

Referenced by ReadPdfBrowserInfos().

◆ UseSystemPdfBrowser()

VTBL_ENTRY bool PGM_BASE::UseSystemPdfBrowser ( ) const
inline

Function UseSystemPdfBrowser returns true if the PDF browser is the default (system) PDF browser and false if the PDF browser is the preferred (selected) browser, else returns false if there is no selected browser.

Definition at line 219 of file pgm_base.h.

220  {
221  return m_use_system_pdf_browser || m_pdf_browser.IsEmpty();
222  }
bool m_use_system_pdf_browser
true to use the selected PDF browser, if exists, or false to use the default
Definition: pgm_base.h:366
wxString m_pdf_browser
The file name of the the program selected for browsing pdf files.
Definition: pgm_base.h:379

References m_pdf_browser, and m_use_system_pdf_browser.

◆ WritePdfBrowserInfos()

void PGM_BASE::WritePdfBrowserInfos ( )

Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.

Definition at line 50 of file eda_doc.cpp.

51 {
54 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:546
bool m_use_system_pdf_browser
true to use the selected PDF browser, if exists, or false to use the default
Definition: pgm_base.h:366
VTBL_ENTRY const wxString & GetPdfBrowserName() const
Definition: pgm_base.h:209

References GetCommonSettings(), GetPdfBrowserName(), COMMON_SETTINGS::m_System, m_use_system_pdf_browser, COMMON_SETTINGS::SYSTEM::pdf_viewer_name, and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.

Member Data Documentation

◆ m_bin_dir

wxString PGM_BASE::m_bin_dir
protected

full path to this program

Definition at line 354 of file pgm_base.h.

Referenced by GetExecutablePath(), InitPgm(), and setExecutablePath().

◆ m_editor_name

wxString PGM_BASE::m_editor_name
protected

Definition at line 380 of file pgm_base.h.

Referenced by GetEditorName(), loadCommonSettings(), and SetEditorName().

◆ m_help_size

wxSize PGM_BASE::m_help_size
protected

Definition at line 381 of file pgm_base.h.

Referenced by loadCommonSettings().

◆ m_kicad_env

wxString PGM_BASE::m_kicad_env
protected

The KICAD system environment variable.

Definition at line 357 of file pgm_base.h.

Referenced by GetKicadEnvVariable(), InitPgm(), and IsKicadEnvVariableDefined().

◆ m_language_id

int PGM_BASE::m_language_id
protected

The current language setting.

Definition at line 363 of file pgm_base.h.

Referenced by GetSelectedLanguageIdentifier(), SetLanguage(), and setLanguageId().

◆ m_local_env_vars

ENV_VAR_MAP PGM_BASE::m_local_env_vars
protected

Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.

Definition at line 384 of file pgm_base.h.

Referenced by GetLocalEnvVariables(), InitPgm(), loadCommonSettings(), SaveCommonSettings(), and SetLocalEnvVariables().

◆ m_locale

wxLocale* PGM_BASE::m_locale
protected

The current locale.

Definition at line 360 of file pgm_base.h.

Referenced by Destroy(), GetLocale(), PGM_BASE(), and SetLanguage().

◆ m_pdf_browser

wxString PGM_BASE::m_pdf_browser
protected

The file name of the the program selected for browsing pdf files.

Definition at line 379 of file pgm_base.h.

Referenced by GetPdfBrowserName(), SetPdfBrowserName(), and UseSystemPdfBrowser().

◆ m_pgm_checker

wxSingleInstanceChecker* PGM_BASE::m_pgm_checker
protected

prevents multiple instances of a program from being run at the same time.

Definition at line 351 of file pgm_base.h.

Referenced by Destroy(), InitPgm(), and PGM_BASE().

◆ m_Printing

bool PGM_BASE::m_Printing

wxWidgets on MSW tends to crash if you spool up more than one print job at a time.

Definition at line 341 of file pgm_base.h.

Referenced by BOARD::ComputeBoundingBox(), and PGM_BASE().

◆ m_settings_manager

std::unique_ptr<SETTINGS_MANAGER> PGM_BASE::m_settings_manager
protected

◆ m_show_env_var_dialog

bool PGM_BASE::m_show_env_var_dialog
protected

Flag to indicate if the environment variable overwrite warning dialog should be shown.

Definition at line 387 of file pgm_base.h.

Referenced by loadCommonSettings(), PGM_BASE(), and SaveCommonSettings().

◆ m_use_system_pdf_browser

bool PGM_BASE::m_use_system_pdf_browser
protected

true to use the selected PDF browser, if exists, or false to use the default

Definition at line 366 of file pgm_base.h.

Referenced by ForceSystemPdfBrowser(), ReadPdfBrowserInfos(), UseSystemPdfBrowser(), and WritePdfBrowserInfos().

◆ workingDirKey

const wxChar PGM_BASE::workingDirKey[]
static

Definition at line 312 of file pgm_base.h.


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