KiCad PCB EDA Suite
PGM_TEST_FRAME Struct Reference
Inheritance diagram for PGM_TEST_FRAME:
PGM_BASE PGM_BASE PGM_BASE

Public Member Functions

void MacOpenFile (const wxString &aFileName) override
 Function MacOpenFile is specific to MacOSX (not used under Linux or Windows). More...
 
bool OnPgmInit ()
 
void OnPgmExit ()
 
void MacOpenFile (const wxString &aFileName) override
 Function MacOpenFile is specific to MacOSX (not used under Linux or Windows). More...
 
bool OnPgmInit ()
 
void OnPgmExit ()
 
void MacOpenFile (const wxString &aFileName) override
 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 (wxString &aErrMsg, bool first_time=false)
 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

Definition at line 33 of file common_mocks.cpp.

Member Function Documentation

◆ App()

wxApp & PGM_BASE::App ( )
inherited

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 129 of file pgm_base.cpp.

130 {
131  wxASSERT( wxTheApp );
132  return *wxTheApp;
133 }

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

◆ AskUserForPreferredEditor()

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

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 181 of file pgm_base.cpp.

182 {
183  // Create a mask representing the executable files in the current platform
184 #ifdef __WINDOWS__
185  wxString mask( _( "Executable file (*.exe)|*.exe" ) );
186 #else
187  wxString mask( _( "Executable file (*)|*" ) );
188 #endif
189 
190  // Extract the path, name and extension from the default editor (even if the editor's
191  // name was empty, this method will succeed and return empty strings).
192  wxString path, name, ext;
193  wxFileName::SplitPath( aDefaultEditor, &path, &name, &ext );
194 
195  // Show the modal editor and return the file chosen (may be empty if the user cancels
196  // the dialog).
197  return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path,
198  name, ext, mask,
199  NULL, wxFD_OPEN | wxFD_FILE_MUST_EXIST,
200  true );
201 }
#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:50
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
LanguagesList Note: because this list is not created on the fly, wxTranslation must be called when a ...
Definition: pgm_base.cpp:95

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

Referenced by PGM_BASE::GetEditorName().

◆ Destroy()

void PGM_BASE::Destroy ( )
inherited

Definition at line 118 of file pgm_base.cpp.

119 {
120  // unlike a normal destructor, this is designed to be called more than once safely:
121  delete m_pgm_checker;
122  m_pgm_checker = 0;
123 
124  delete m_locale;
125  m_locale = 0;
126 }
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 PGM_BASE::m_locale, and PGM_BASE::m_pgm_checker.

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

◆ ForceSystemPdfBrowser()

VTBL_ENTRY void PGM_BASE::ForceSystemPdfBrowser ( bool  aFlg)
inlineinherited

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 PGM_BASE::m_use_system_pdf_browser.

Referenced by PGM_BASE::PGM_BASE().

◆ GetCommonSettings()

COMMON_SETTINGS * PGM_BASE::GetCommonSettings ( ) const
inherited

Definition at line 570 of file pgm_base.cpp.

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

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

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

◆ GetEditorName()

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

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 144 of file pgm_base.cpp.

145 {
146  wxString editorname = m_editor_name;
147 
148  if( !editorname )
149  {
150  if( !wxGetEnv( "EDITOR", &editorname ) )
151  {
152  // If there is no EDITOR variable set, try the desktop default
153 #ifdef __WXMAC__
154  editorname = "/usr/bin/open";
155 #elif __WXX11__
156  editorname = "/usr/bin/xdg-open";
157 #endif
158  }
159  }
160 
161  // If we still don't have an editor name show a dialog asking the user to select one
162  if( !editorname && aCanShowFileChooser )
163  {
165  _( "No default editor found, you must choose it" ) );
166 
167  editorname = AskUserForPreferredEditor();
168  }
169 
170  // If we finally have a new editor name request it to be copied to m_editor_name and
171  // saved to the preferences file.
172  if( !editorname.IsEmpty() )
173  SetEditorName( editorname );
174 
175  // m_editor_name already has the same value that editorname, or empty if no editor was
176  // found/chosen.
177  return m_editor_name;
178 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:136
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:181
#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:95
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:268

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

◆ GetExecutablePath()

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

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 PGM_BASE::m_bin_dir.

Referenced by PGM_SINGLE_TOP::OnPgmInit().

◆ GetKicadEnvVariable()

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

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 PGM_BASE::m_kicad_env.

◆ GetLocale()

VTBL_ENTRY wxLocale* PGM_BASE::GetLocale ( )
inlineinherited

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 PGM_BASE::m_locale.

◆ GetLocalEnvVariables()

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

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 PGM_BASE::m_local_env_vars.

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

◆ GetPdfBrowserName()

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

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 PGM_BASE::m_pdf_browser.

Referenced by PGM_BASE::WritePdfBrowserInfos().

◆ GetSelectedLanguageIdentifier()

VTBL_ENTRY int PGM_BASE::GetSelectedLanguageIdentifier ( ) const
inlineinherited
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 PGM_BASE::m_language_id.

◆ GetSettingsManager()

◆ InitPgm()

bool PGM_BASE::InitPgm ( )
inherited

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 204 of file pgm_base.cpp.

205 {
206  wxFileName pgm_name( App().argv[0] );
207 
208  wxInitAllImageHandlers();
209 
210  m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) +
211  wxGetUserId(), GetKicadLockFilePath() );
212 
213  if( m_pgm_checker->IsAnotherRunning() )
214  {
215  wxString quiz =
216  wxString::Format( _( "%s is already running. Continue?" ), pgm_name.GetName() );
217 
218  if( !IsOK( NULL, quiz ) )
219  return false;
220  }
221 
222  m_settings_manager = std::unique_ptr<SETTINGS_MANAGER>( new SETTINGS_MANAGER );
223 
224  // Something got in the way of settings load: can't continue
225  if( !m_settings_manager->IsOK() )
226  return false;
227 
228  // Init KiCad environment
229  // the environment variable KICAD (if exists) gives the kicad path:
230  // something like set KICAD=d:\kicad
231  bool isDefined = wxGetEnv( "KICAD", &m_kicad_env );
232 
233  if( isDefined ) // ensure m_kicad_env ends by "/"
234  {
236 
237  if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
239  }
240 
241  // Init parameters for configuration
242  App().SetVendorName( "KiCad" );
243  App().SetAppName( pgm_name.GetName().Lower() );
244 
245  // Install some image handlers, mainly for help
246  if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL )
247  wxImage::AddHandler( new wxPNGHandler );
248 
249  if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL )
250  wxImage::AddHandler( new wxGIFHandler );
251 
252  if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL )
253  wxImage::AddHandler( new wxJPEGHandler );
254 
255  wxFileSystem::AddHandler( new wxZipFSHandler );
256 
257  // Analyze the command line & initialize the binary path
259 
260  SetLanguagePath();
261 
262  wxString envVarName = wxT( "KIGITHUB" );
263  ENV_VAR_ITEM envVarItem;
264  wxString envValue;
265  wxFileName tmpFileName;
266 
267  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
268  {
269  tmpFileName.AssignDir( envValue );
270  envVarItem.SetDefinedExternally( true );
271  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
272  }
273  else
274  {
275  envVarItem.SetValue( wxString( wxT( "https://github.com/KiCad" ) ) );
276  envVarItem.SetDefinedExternally( false );
277  }
278 
279  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
280  m_local_env_vars[ envVarName ] = envVarItem;
281 
282  wxFileName baseSharePath;
283 #if defined( __WXMSW__ )
284  // Make the paths relative to the executable dir as KiCad might be installed anywhere
285  // It follows the Windows installer paths scheme, where binaries are installed in
286  // PATH/bin and extra files in PATH/share/kicad
287  baseSharePath.AssignDir( m_bin_dir + "\\.." );
288  baseSharePath.Normalize();
289 #else
290  baseSharePath.AssignDir( wxString( wxT( DEFAULT_INSTALL_PATH ) ) );
291 #endif
292 
293 #if !defined( __WXMAC__ )
294  baseSharePath.AppendDir( "share" );
295  baseSharePath.AppendDir( "kicad" );
296 #endif
297 
298  // KISYSMOD
299  envVarName = wxT( "KISYSMOD" );
300 
301  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
302  {
303  tmpFileName.AssignDir( envValue );
304  envVarItem.SetDefinedExternally( true );
305  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
306  }
307  else
308  {
309  tmpFileName = baseSharePath;
310  tmpFileName.AppendDir( "modules" );
311  envVarItem.SetDefinedExternally( false );
312  }
313 
314  envVarItem.SetValue( tmpFileName.GetPath() );
315  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
316  m_local_env_vars[ envVarName ] = envVarItem;
317 
318  // KISYS3DMOD
319  envVarName = wxT( "KISYS3DMOD" );
320 
321  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
322  {
323  tmpFileName.AssignDir( envValue );
324  envVarItem.SetDefinedExternally( true );
325  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
326  }
327  else
328  {
329  tmpFileName = baseSharePath;
330  tmpFileName.AppendDir( "3dmodels" );
331  envVarItem.SetDefinedExternally( false );
332  }
333 
334  envVarItem.SetValue( tmpFileName.GetFullPath() );
335  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
336  m_local_env_vars[ envVarName ] = envVarItem;
337 
338  // KICAD_TEMPLATE_DIR
339  envVarName = "KICAD_TEMPLATE_DIR";
340 
341  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
342  {
343  tmpFileName.AssignDir( envValue );
344  envVarItem.SetDefinedExternally( true );
345  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
346  }
347  else
348  {
349  // Attempt to find the best default template path.
350  SEARCH_STACK bases;
351  SEARCH_STACK templatePaths;
352 
353  SystemDirsAppend( &bases );
354 
355  for( unsigned i = 0; i < bases.GetCount(); ++i )
356  {
357  wxFileName fn( bases[i], wxEmptyString );
358 
359  // Add KiCad template file path to search path list.
360  fn.AppendDir( "template" );
361 
362  // Only add path if exists and can be read by the user.
363  if( fn.DirExists() && fn.IsDirReadable() )
364  {
365  wxLogTrace( tracePathsAndFiles, "Checking template path '%s' exists",
366  fn.GetPath() );
367  templatePaths.AddPaths( fn.GetPath() );
368  }
369  }
370 
371  if( templatePaths.IsEmpty() )
372  {
373  tmpFileName = baseSharePath;
374  tmpFileName.AppendDir( "template" );
375  }
376  else
377  {
378  // Take the first one. There may be more but this will likely be the best option.
379  tmpFileName.AssignDir( templatePaths[0] );
380  }
381 
382  envVarItem.SetDefinedExternally( false );
383  }
384 
385  envVarItem.SetValue( tmpFileName.GetPath() );
386  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
387  m_local_env_vars[ envVarName ] = envVarItem;
388 
389  // KICAD_USER_TEMPLATE_DIR
390  envVarName = "KICAD_USER_TEMPLATE_DIR";
391 
392  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
393  {
394  tmpFileName.AssignDir( envValue );
395  envVarItem.SetDefinedExternally( true );
396  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
397  }
398  else
399  {
400  // Default user template path.
401  tmpFileName.AssignDir( wxStandardPaths::Get().GetDocumentsDir() );
402  tmpFileName.AppendDir( "kicad" );
403  tmpFileName.AppendDir( "template" );
404  envVarItem.SetDefinedExternally( false );
405  }
406 
407  envVarItem.SetValue( tmpFileName.GetPath() );
408  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
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  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
419  }
420  else
421  {
422  tmpFileName = baseSharePath;
423  tmpFileName.AppendDir( "library" );
424  envVarItem.SetDefinedExternally( false );
425  }
426 
427  envVarItem.SetValue( tmpFileName.GetPath() );
428  wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
429  m_local_env_vars[ envVarName ] = envVarItem;
430 
432 
433  // Init user language *before* calling loadCommonSettings, because
434  // env vars could be incorrectly initialized on Linux
435  // (if the value contains some non ASCII7 chars, the env var is not initialized)
436  wxString tmp;
437  SetLanguage( tmp, true );
438 
440 
441  ReadPdfBrowserInfos(); // needs GetCommonSettings()
442 
443 #ifdef __WXMAC__
444  // Always show filters on Open dialog to be able to choose plugin
445  wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
446 #endif
447 
448  // TODO(JE): Remove this if apps are refactored to not assume Prj() always works
449  // Need to create a project early for now (it can have an empty path for the moment)
451 
452  return true;
453 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
void loadCommonSettings()
Loads internal settings from COMMON_SETTINGS.
Definition: pgm_base.cpp:498
wxString GetKicadLockFilePath()
Function GetKicadLockFilePath.
Definition: lockfile.cpp:60
#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
const wxString & GetValue() const
Definition: pgm_base.h:105
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:129
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:456
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 bool SetLanguage(wxString &aErrMsg, bool first_time=false)
sets the dictionary file name for internationalization.
Definition: pgm_base.cpp:576
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
VTBL_ENTRY void SetLanguagePath()
Definition: pgm_base.cpp:698
wxString m_bin_dir
full path to this program
Definition: pgm_base.h:354
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:41
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:201
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:95
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:284
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)

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

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

◆ IsKicadEnvVariableDefined()

VTBL_ENTRY bool PGM_BASE::IsKicadEnvVariableDefined ( ) const
inlineinherited

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 PGM_BASE::m_kicad_env.

◆ loadCommonSettings()

void PGM_BASE::loadCommonSettings ( )
protectedinherited

Loads internal settings from COMMON_SETTINGS.

Definition at line 498 of file pgm_base.cpp.

499 {
500  m_help_size.x = 500;
501  m_help_size.y = 400;
502 
505 
506  for( const auto& it : GetCommonSettings()->m_Env.vars )
507  {
508  wxString key( it.first.c_str(), wxConvUTF8 );
509  wxLogTrace( traceEnvVars, "PGM_BASE::loadCommonSettings: Found entry %s = %s", key, it.second );
510 
511  // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason
512  // it is found in config. (It is reserved and defined as project path)
513  if( key == PROJECT_VAR_NAME )
514  continue;
515 
516  if( m_local_env_vars[ key ].GetDefinedExternally() )
517  continue;
518 
519  wxLogTrace( traceEnvVars, "PGM_BASE::loadCommonSettings: Updating entry %s = %s", key, it.second );
520 
521  m_local_env_vars[ key ] = ENV_VAR_ITEM( it.second, wxGetEnv( it.first, nullptr ) );
522  }
523 
524  for( auto& m_local_env_var : m_local_env_vars )
525  SetLocalEnvVariable( m_local_env_var.first, m_local_env_var.second.GetValue() );
526 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
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
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:733
ENVIRONMENT m_Env
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
wxSize m_help_size
Definition: pgm_base.h:381
wxString m_editor_name
Definition: pgm_base.h:380

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

Referenced by PGM_BASE::InitPgm().

◆ MacOpenFile() [1/3]

void PGM_TEST_FRAME::MacOpenFile ( const wxString &  aFileName)
inlineoverridevirtual

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

Implements PGM_BASE.

Definition at line 35 of file common_mocks.cpp.

36  {}

◆ MacOpenFile() [2/3]

void PGM_TEST_FRAME::MacOpenFile ( const wxString &  aFileName)
inlineoverridevirtual

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

Implements PGM_BASE.

Definition at line 84 of file mock_pgm.cpp.

85  {
86  wxFileName filename( aFileName );
87 
88  if( filename.FileExists() )
89  {
90 #if 0
91  // this pulls in EDA_DRAW_FRAME type info, which we don't want in
92  // the single_top link image.
93  KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
94 #else
95  KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
96 #endif
97 
98  if( frame )
99  frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
100  }
101  }
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:120
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:61
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:129

References PGM_BASE::App(), and KIWAY_PLAYER::OpenProjectFiles().

◆ MacOpenFile() [3/3]

void PGM_TEST_FRAME::MacOpenFile ( const wxString &  aFileName)
inlineoverridevirtual

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

Implements PGM_BASE.

Definition at line 110 of file test_app_main.cpp.

111  {
112  wxFileName filename( aFileName );
113 
114  if( filename.FileExists() )
115  {
116  #if 0
117  // this pulls in EDA_DRAW_FRAME type info, which we don't want in
118  // the single_top link image.
119  KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
120  #else
121  KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
122  #endif
123 
124  if( frame )
125  frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
126  }
127  }
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:120
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:61
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:129

◆ OnPgmExit() [1/2]

void PGM_TEST_FRAME::OnPgmExit ( )
inline

Definition at line 75 of file mock_pgm.cpp.

76  {
77  Kiway.OnKiwayEnd();
78 
79  // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
80  // earlier than wxApp and earlier than static destruction would.
82  }
void Destroy()
Definition: pgm_base.cpp:118
void OnKiwayEnd()
Definition: kiway.cpp:600
KIWAY Kiway

References Kiway, and KIWAY::OnKiwayEnd().

Referenced by APP_TEST::OnExit(), APP_TEST::OnInit(), and APP_TEST::OnRun().

◆ OnPgmExit() [2/2]

void PGM_TEST_FRAME::OnPgmExit ( )
inline

Definition at line 99 of file test_app_main.cpp.

100  {
101  printf("Destroy\n");
102  Kiway.OnKiwayEnd();
103 
104  // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
105  // earlier than wxApp and earlier than static destruction would.
107  }
void Destroy()
Definition: pgm_base.cpp:118
void OnKiwayEnd()
Definition: kiway.cpp:600
KIWAY Kiway

◆ OnPgmInit() [1/2]

bool PGM_TEST_FRAME::OnPgmInit ( )

Definition at line 238 of file test_app_main.cpp.

239 {
240  if( !InitPgm() )
241  return false;
242 
243  return true;
244 }
bool InitPgm()
Function initPgm initializes this program (process) in a KiCad standard way, using some generalized t...
Definition: pgm_base.cpp:204

References PGM_BASE::InitPgm().

Referenced by APP_TEST::OnInit().

◆ OnPgmInit() [2/2]

bool PGM_TEST_FRAME::OnPgmInit ( )

◆ ReadPdfBrowserInfos()

void PGM_BASE::ReadPdfBrowserInfos ( )
inherited

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

Definition at line 41 of file eda_doc.cpp.

42 {
43  SetPdfBrowserName( GetCommonSettings()->m_System.pdf_viewer_name );
45 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
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 PGM_BASE::GetCommonSettings(), COMMON_SETTINGS::m_System, PGM_BASE::m_use_system_pdf_browser, PGM_BASE::SetPdfBrowserName(), and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.

Referenced by PGM_BASE::InitPgm().

◆ SaveCommonSettings()

void PGM_BASE::SaveCommonSettings ( )
inherited

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

Definition at line 529 of file pgm_base.cpp.

530 {
531  // GetCommonSettings() is not initialized until fairly late in the
532  // process startup: InitPgm(), so test before using:
533  if( GetCommonSettings() )
534  {
535  GetCommonSettings()->m_System.working_dir = wxGetCwd();
537 
538  // remove only the old env vars that do not exist in list.
539  // We do not clear the full list because some are defined externally,
540  // and we cannot modify or delete them
541  std::map<std::string, wxString>& curr_vars = GetCommonSettings()->m_Env.vars;
542 
543  for( auto it = curr_vars.begin(); it != curr_vars.end(); )
544  {
545  const std::string& key = it->first;
546 
547  if( m_local_env_vars.find( key ) == m_local_env_vars.end() )
548  it = curr_vars.erase( it ); // This entry no longer exists in new list
549  else
550  it++;
551  }
552 
553  // Save the local environment variables.
554  for( auto& m_local_env_var : m_local_env_vars )
555  {
556  if( m_local_env_var.second.GetDefinedExternally() )
557  continue;
558 
559  wxLogTrace( traceEnvVars,
560  "PGM_BASE::SaveCommonSettings: Saving environment variable config entry %s as %s",
561  m_local_env_var.first, m_local_env_var.second.GetValue() );
562 
563  std::string key( m_local_env_var.first.ToUTF8() );
564  GetCommonSettings()->m_Env.vars[ key ] = m_local_env_var.second.GetValue();
565  }
566  }
567 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:384
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
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.

References PGM_BASE::GetCommonSettings(), COMMON_SETTINGS::m_Env, PGM_BASE::m_local_env_vars, PGM_BASE::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 PGM_BASE::SetLocalEnvVariables().

◆ SetEditorName()

void PGM_BASE::SetEditorName ( const wxString &  aFileName)
inherited

Definition at line 136 of file pgm_base.cpp.

137 {
138  m_editor_name = aFileName;
139  wxASSERT( GetCommonSettings() );
140  GetCommonSettings()->m_System.editor_name = aFileName;
141 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
wxString m_editor_name
Definition: pgm_base.h:380

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

Referenced by PGM_BASE::GetEditorName().

◆ setExecutablePath()

bool PGM_BASE::setExecutablePath ( )
protectedinherited

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 456 of file pgm_base.cpp.

457 {
458  m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
459 
460 #ifdef __WXMAC__
461  // On OSX Pgm().GetExecutablePath() will always point to main
462  // bundle directory, e.g., /Applications/kicad.app/
463 
464  wxFileName fn( m_bin_dir );
465 
466  if( fn.GetName() == wxT( "kicad" ) )
467  {
468  // kicad launcher, so just remove the Contents/MacOS part
469  fn.RemoveLastDir();
470  fn.RemoveLastDir();
471  }
472  else
473  {
474  // standalone binaries live in Contents/Applications/<standalone>.app/Contents/MacOS
475  fn.RemoveLastDir();
476  fn.RemoveLastDir();
477  fn.RemoveLastDir();
478  fn.RemoveLastDir();
479  fn.RemoveLastDir();
480  }
481 
482  m_bin_dir = fn.GetPath() + wxT( "/" );
483 #else
484  // Use unix notation for paths. I am not sure this is a good idea,
485  // but it simplifies compatibility between Windows and Unices.
486  // However it is a potential problem in path handling under Windows.
488 
489  // Remove file name form command line:
490  while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
491  m_bin_dir.RemoveLast();
492 #endif
493 
494  return true;
495 }
#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 PGM_BASE::m_bin_dir, UNIX_STRING_DIR_SEP, and WIN_STRING_DIR_SEP.

Referenced by PGM_BASE::InitPgm().

◆ SetLanguage()

bool PGM_BASE::SetLanguage ( wxString &  aErrMsg,
bool  first_time = false 
)
inherited

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
aErrMsgis the string to return the error message it
first_timemust be set to true the first time this function is called, false otherwise
Returns
false if there was an error setting the language

Definition at line 576 of file pgm_base.cpp.

577 {
578  if( first_time )
579  {
580  setLanguageId( wxLANGUAGE_DEFAULT );
581  // First time SetLanguage is called, the user selected language id is set
582  // from common user config settings
583  wxString languageSel = GetCommonSettings()->m_System.language;
584 
585  // Search for the current selection
586  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
587  {
588  if( LanguagesList[ii].m_Lang_Label == languageSel )
589  {
590  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
591  break;
592  }
593  }
594  }
595 
596  // dictionary file name without extend (full name is kicad.mo)
597  wxString dictionaryName( "kicad" );
598 
599  delete m_locale;
600  m_locale = new wxLocale;
601 
602  if( !m_locale->Init( m_language_id ) )
603  {
604  wxLogTrace( traceLocale, "This language is not supported by the system." );
605 
606  setLanguageId( wxLANGUAGE_DEFAULT );
607  delete m_locale;
608 
609  m_locale = new wxLocale;
610  m_locale->Init();
611 
612  aErrMsg = _( "This language is not supported by the operating system." );
613  return false;
614  }
615  else if( !first_time )
616  {
617  wxLogTrace( traceLocale, "Search for dictionary %s.mo in %s",
618  dictionaryName, m_locale->GetName() );
619  }
620 
621  if( !first_time )
622  {
623  // If we are here, the user has selected another language.
624  // Therefore the new prefered language name is stored in common config.
625  // Do NOT store the wxWidgets language Id, it can change between wxWidgets
626  // versions, for a given language
627  wxString languageSel;
628 
629  // Search for the current selection language name
630  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
631  {
632  if( LanguagesList[ii].m_WX_Lang_Identifier == m_language_id )
633  {
634  languageSel = LanguagesList[ii].m_Lang_Label;
635  break;
636  }
637  }
638 
640  cfg->m_System.language = languageSel;
641  cfg->SaveToFile( GetSettingsManager().GetPathForSettingsFile( cfg ) );
642  }
643 
644  // Test if floating point notation is working (bug encountered in cross compilation)
645  // Make a conversion double <=> string
646  double dtst = 0.5;
647  wxString msg;
648 
649  msg << dtst;
650  double result;
651  msg.ToDouble( &result );
652 
653  // string to double encode/decode does not work! Bug detected:
654  // Disable floating point localization:
655  if( result != dtst )
656  setlocale( LC_NUMERIC, "C" );
657 
658  // Try adding the dictionary if it is not currently loaded
659  if( !m_locale->IsLoaded( dictionaryName ) )
660  m_locale->AddCatalog( dictionaryName );
661 
662  // Verify the dictionary was loaded properly
663  if( !m_locale->IsLoaded( dictionaryName ) )
664  {
665  wxLogTrace( traceLocale, "Unable to load dictionary %s.mo in %s",
666  dictionaryName, m_locale->GetName() );
667 
668  setLanguageId( wxLANGUAGE_DEFAULT );
669  delete m_locale;
670 
671  m_locale = new wxLocale;
672  m_locale->Init();
673 
674  aErrMsg = _( "The KiCad language file for this language is not installed." );
675  return false;
676  }
677 
678  return true;
679 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:71
VTBL_ENTRY SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:175
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:63
int m_language_id
The current language setting.
Definition: pgm_base.h:363
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
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:66
#define _(s)
LanguagesList Note: because this list is not created on the fly, wxTranslation must be called when a ...
Definition: pgm_base.cpp:95

References _, PGM_BASE::GetCommonSettings(), PGM_BASE::GetSettingsManager(), COMMON_SETTINGS::SYSTEM::language, LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, LANGUAGE_DESCR::m_Lang_Label, PGM_BASE::m_language_id, PGM_BASE::m_locale, COMMON_SETTINGS::m_System, JSON_SETTINGS::SaveToFile(), PGM_BASE::setLanguageId(), and traceLocale.

Referenced by PGM_BASE::InitPgm().

◆ setLanguageId()

void PGM_BASE::setLanguageId ( int  aId)
inlineprotectedinherited

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 PGM_BASE::m_language_id.

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

◆ SetLanguageIdentifier()

void PGM_BASE::SetLanguageIdentifier ( int  menu_id)
inherited

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 682 of file pgm_base.cpp.

683 {
684  wxLogTrace( traceLocale, "Select language ID %d from %d possible languages.",
685  menu_id, (int)arrayDim( LanguagesList )-1 );
686 
687  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
688  {
689  if( menu_id == LanguagesList[ii].m_KI_Lang_Identifier )
690  {
691  setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
692  break;
693  }
694  }
695 }
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:71
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:63
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:127

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

◆ SetLanguagePath()

void PGM_BASE::SetLanguagePath ( )
inherited

Definition at line 698 of file pgm_base.cpp.

699 {
700  SEARCH_STACK guesses;
701 
702  SystemDirsAppend( &guesses );
703 
704  // Add our internat dir to the wxLocale catalog of paths
705  for( unsigned i = 0; i < guesses.GetCount(); i++ )
706  {
707  wxFileName fn( guesses[i], wxEmptyString );
708 
709  // Append path for Windows and unix KiCad package install
710  fn.AppendDir( "share" );
711  fn.AppendDir( "internat" );
712 
713  if( fn.IsDirReadable() )
714  {
715  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
716  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
717  }
718 
719  // Append path for unix standard install
720  fn.RemoveLastDir();
721  fn.AppendDir( "kicad" );
722  fn.AppendDir( "internat" );
723 
724  if( fn.IsDirReadable() )
725  {
726  wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
727  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
728  }
729  }
730 }
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 PGM_BASE::InitPgm().

◆ SetLocalEnvVariable()

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

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 733 of file pgm_base.cpp.

734 {
735  wxString env;
736 
737  // Check to see if the environment variable is already set.
738  if( wxGetEnv( aName, &env ) )
739  {
740  wxLogTrace( traceEnvVars,
741  "PGM_BASE::SetLocalEnvVariable: Environment variable %s already set to %s",
742  aName, env );
743  return env == aValue;
744  }
745 
746  wxLogTrace( traceEnvVars,
747  "PGM_BASE::SetLocalEnvVariable: Setting local environment variable %s to %s",
748  aName, aValue );
749 
750  return wxSetEnv( aName, aValue );
751 }
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.

References traceEnvVars.

Referenced by PGM_BASE::loadCommonSettings().

◆ SetLocalEnvVariables()

void PGM_BASE::SetLocalEnvVariables ( const ENV_VAR_MAP aEnvVarMap)
inherited

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 754 of file pgm_base.cpp.

755 {
756  m_local_env_vars.clear();
757  m_local_env_vars = aEnvVarMap;
758 
760 
761  // Overwrites externally defined environment variable until the next time the application
762  // is run.
763  for( auto& m_local_env_var : m_local_env_vars )
764  {
765  wxLogTrace( traceEnvVars,
766  "PGM_BASE::SetLocalEnvVariables: Setting local environment variable %s to %s",
767  m_local_env_var.first,
768  m_local_env_var.second.GetValue() );
769  wxSetEnv( m_local_env_var.first, m_local_env_var.second.GetValue() );
770  }
771 }
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:529
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.

References PGM_BASE::m_local_env_vars, PGM_BASE::SaveCommonSettings(), and traceEnvVars.

◆ SetPdfBrowserName()

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

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 PGM_BASE::m_pdf_browser.

Referenced by PGM_BASE::ReadPdfBrowserInfos().

◆ UseSystemPdfBrowser()

VTBL_ENTRY bool PGM_BASE::UseSystemPdfBrowser ( ) const
inlineinherited

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 PGM_BASE::m_pdf_browser, and PGM_BASE::m_use_system_pdf_browser.

◆ WritePdfBrowserInfos()

void PGM_BASE::WritePdfBrowserInfos ( )
inherited

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

Definition at line 48 of file eda_doc.cpp.

49 {
52 }
VTBL_ENTRY COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:570
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 PGM_BASE::GetCommonSettings(), PGM_BASE::GetPdfBrowserName(), COMMON_SETTINGS::m_System, PGM_BASE::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
protectedinherited

full path to this program

Definition at line 354 of file pgm_base.h.

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

◆ m_editor_name

wxString PGM_BASE::m_editor_name
protectedinherited

◆ m_help_size

wxSize PGM_BASE::m_help_size
protectedinherited

Definition at line 381 of file pgm_base.h.

Referenced by PGM_BASE::loadCommonSettings().

◆ m_kicad_env

wxString PGM_BASE::m_kicad_env
protectedinherited

The KICAD system environment variable.

Definition at line 357 of file pgm_base.h.

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

◆ m_language_id

int PGM_BASE::m_language_id
protectedinherited

The current language setting.

Definition at line 363 of file pgm_base.h.

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

◆ m_local_env_vars

ENV_VAR_MAP PGM_BASE::m_local_env_vars
protectedinherited

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

Definition at line 384 of file pgm_base.h.

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

◆ m_locale

wxLocale* PGM_BASE::m_locale
protectedinherited

The current locale.

Definition at line 360 of file pgm_base.h.

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

◆ m_pdf_browser

wxString PGM_BASE::m_pdf_browser
protectedinherited

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

Definition at line 379 of file pgm_base.h.

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

◆ m_pgm_checker

wxSingleInstanceChecker* PGM_BASE::m_pgm_checker
protectedinherited

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

Definition at line 351 of file pgm_base.h.

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

◆ m_Printing

bool PGM_BASE::m_Printing
inherited

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::PGM_BASE().

◆ m_settings_manager

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

◆ m_show_env_var_dialog

bool PGM_BASE::m_show_env_var_dialog
protectedinherited

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

Definition at line 387 of file pgm_base.h.

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

◆ m_use_system_pdf_browser

bool PGM_BASE::m_use_system_pdf_browser
protectedinherited

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 PGM_BASE::ForceSystemPdfBrowser(), PGM_BASE::ReadPdfBrowserInfos(), PGM_BASE::UseSystemPdfBrowser(), and PGM_BASE::WritePdfBrowserInfos().

◆ workingDirKey

const wxChar PGM_BASE::workingDirKey[]
staticinherited

Definition at line 312 of file pgm_base.h.


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