KiCad PCB EDA Suite
PGM_KICAD Class Reference

Class PGM_KICAD extends PGM_BASE to bring in FileHistory() and PdfBrowser() which were moved from EDA_APP into KIFACE_I. More...

#include <pgm_kicad.h>

Inheritance diagram for PGM_KICAD:
PGM_BASE

Public Member Functions

 PGM_KICAD ()
 
 ~PGM_KICAD () throw ()
 
bool OnPgmInit ()
 
void OnPgmExit ()
 
void MacOpenFile (const wxString &aFileName) override
 Function MacOpenFile is specific to MacOSX (not used under Linux or Windows). More...
 
wxFileHistory & GetFileHistory ()
 
wxConfigBase * PgmSettings ()
 
SEARCH_STACKSysSearch ()
 
wxString GetHelpFileName ()
 
void Destroy ()
 
VTBL_ENTRY wxConfigBase * CommonSettings () 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 AddMenuLanguageList (wxMenu *MasterMenu)
 Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to MasterMenu. 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 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 void ConfigurePaths (wxWindow *aParent=NULL)
 Function ConfigurePaths. More...
 
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 SaveCommonSettings ()
 Function saveCommonSettings saves the program (process) settings subset which are stored .kicad_common. More...
 
void SetIconsScale (double aValue)
 Scaling factor for menus and tool icons. More...
 
double GetIconsScale ()
 
void SetUseIconsInMenus (bool aUseIcons)
 True to use menu icons. More...
 
bool GetUseIconsInMenus ()
 

Static Public Attributes

static const wxChar workingDirKey [] = wxT( "WorkingDir" )
 

Protected Member Functions

void loadCommonSettings ()
 Function loadCommonSettings loads the program (process) settings subset which are stored in .kicad_common. 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

BIN_MOD m_bm
 
wxSingleInstanceChecker * m_pgm_checker
 prevents multiple instances of a program from being run at the same time. More...
 
wxConfigBase * m_common_settings
 Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common. 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...
 
double m_iconsScale
 Scaling factor for menus and tool icons. More...
 
bool m_useIconsInMenus
 True to use menu icons. 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

Class PGM_KICAD extends PGM_BASE to bring in FileHistory() and PdfBrowser() which were moved from EDA_APP into KIFACE_I.

KIFACE_I is not applicable in the project manager since it is not a KIFACE. This header is in the kicad directory since nobody else needs to know about it.

Definition at line 40 of file pgm_kicad.h.

Constructor & Destructor Documentation

PGM_KICAD::PGM_KICAD ( )
inline

Definition at line 43 of file pgm_kicad.h.

43  :
44  m_bm( "kicad" ) // indicates a "$HOME/.kicad wxConfig like" config file.
45  {}
BIN_MOD m_bm
Definition: pgm_kicad.h:72
PGM_KICAD::~PGM_KICAD ( )
throw (
)
inline

Definition at line 47 of file pgm_kicad.h.

References Destroy(), MacOpenFile(), OnPgmExit(), and OnPgmInit().

48  {
49  Destroy();
50  }
void Destroy()
Definition: kicad.cpp:200

Member Function Documentation

void PGM_BASE::AddMenuLanguageList ( wxMenu *  MasterMenu)
inherited

Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to MasterMenu.

Parameters
MasterMenuThe main menu. The sub menu list will be accessible from the menu item with id ID_LANGUAGE_CHOICE

Definition at line 889 of file pgm_base.cpp.

References AddMenuItem(), DIM, ID_LANGUAGE_CHOICE, KiBitmap(), LANGUAGE_DESCR::m_DoNotTranslate, LANGUAGE_DESCR::m_KI_Lang_Identifier, LANGUAGE_DESCR::m_Lang_Icon, LANGUAGE_DESCR::m_Lang_Label, and LANGUAGE_DESCR::m_WX_Lang_Identifier.

Referenced by preparePreferencesMenu(), CVPCB_MAINFRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), and GERBVIEW_FRAME::ReCreateMenuBar().

890 {
891  wxMenu* menu = NULL;
892  wxMenuItem* item = MasterMenu->FindItem( ID_LANGUAGE_CHOICE );
893 
894  if( item ) // This menu exists, do nothing
895  return;
896 
897  menu = new wxMenu;
898 
899  for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
900  {
901  wxString label;
902 
903  if( s_Languages[ii].m_DoNotTranslate )
904  label = s_Languages[ii].m_Lang_Label;
905  else
906  label = wxGetTranslation( s_Languages[ii].m_Lang_Label );
907 
908  AddMenuItem( menu, s_Languages[ii].m_KI_Lang_Identifier,
909  label, KiBitmap(s_Languages[ii].m_Lang_Icon ),
910  wxITEM_CHECK );
911  }
912 
913  AddMenuItem( MasterMenu, menu,
915  _( "Set Language" ),
916  _( "Select application language (only for testing)" ),
917  KiBitmap( language_xpm ) );
918 
919  // Set Check mark on current selected language
920  for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
921  {
922  if( m_language_id == s_Languages[ii].m_WX_Lang_Identifier )
923  menu->Check( s_Languages[ii].m_KI_Lang_Identifier, true );
924  else
925  menu->Check( s_Languages[ii].m_KI_Lang_Identifier, false );
926  }
927 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:174
int m_language_id
The current language setting.
Definition: pgm_base.h:356
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.cpp:92
static LANGUAGE_DESCR s_Languages[]
Variable s_Languages Note: because this list is not created on the fly, wxTranslation must be called ...
Definition: pgm_base.cpp:105
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 323 of file pgm_base.cpp.

Referenced by WS_DRAW_ITEM_LIST::BuildFullText(), DIALOG_SHIM::DIALOG_SHIM(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), PCB_EDIT_FRAME::DoGenFootprintsReport(), MacOpenFile(), PGM_SINGLE_TOP::MacOpenFile(), OnPgmInit(), and PGM_SINGLE_TOP::OnPgmInit().

324 {
325  wxASSERT( wxTheApp );
326  return *wxTheApp;
327 }
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 375 of file pgm_base.cpp.

References EDA_FILE_SELECTOR(), and name.

Referenced by EDA_BASE_FRAME::OnSelectPreferredEditor().

376 {
377  // Create a mask representing the executable files in the current platform
378 #ifdef __WINDOWS__
379  wxString mask( _( "Executable file (*.exe)|*.exe" ) );
380 #else
381  wxString mask( _( "Executable file (*)|*" ) );
382 #endif
383 
384  // Extract the path, name and extension from the default editor (even if the editor's
385  // name was empty, this method will succeed and return empty strings).
386  wxString path, name, ext;
387  wxFileName::SplitPath( aDefaultEditor, &path, &name, &ext );
388 
389  // Show the modal editor and return the file chosen (may be empty if the user cancels
390  // the dialog).
391  return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path,
392  name, ext, mask,
393  NULL, wxFD_OPEN | wxFD_FILE_MUST_EXIST,
394  true );
395 }
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:82
const char * name
Definition: DXF_plotter.cpp:61
VTBL_ENTRY wxConfigBase* PGM_BASE::CommonSettings ( ) const
inlineinherited

Definition at line 145 of file pgm_base.h.

References VTBL_ENTRY.

Referenced by DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), PCB_EDIT_FRAME::Process_Special_Functions(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::WIZARD_3DSHAPE_LIBS_DOWNLOADER(), and WIZARD_3DSHAPE_LIBS_DOWNLOADER::~WIZARD_3DSHAPE_LIBS_DOWNLOADER().

145 { return m_common_settings; }
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
void PGM_BASE::ConfigurePaths ( wxWindow *  aParent = NULL)
inherited

Function ConfigurePaths.

presents a dialog to the user to edit local environment variable settings for use in the footprint library table and the 3D model importer. It was added to PGM_BASE because it will eventually find use for in schematic I/O design so it needs to accessible by almost every KiCad application.

Parameters
aParent- a pointer the wxWindow parent of the dialog or NULL to use the top level window.

Definition at line 970 of file pgm_base.cpp.

References DIALOG_ENV_VAR_CONFIG::ExternalDefsChanged(), GetChars(), DIALOG_ENV_VAR_CONFIG::GetEnvVarMap(), and traceEnvVars.

Referenced by DLG_3D_PATH_CONFIG::OnConfigEnvVar(), FOOTPRINT_EDIT_FRAME::OnConfigurePaths(), CVPCB_MAINFRAME::OnConfigurePaths(), KICAD_MANAGER_FRAME::OnConfigurePaths(), SCH_BASE_FRAME::OnConfigurePaths(), and PCB_EDIT_FRAME::OnConfigurePaths().

971 {
972  DIALOG_ENV_VAR_CONFIG dlg_envvars( aParent, GetLocalEnvVariables() );
973 
974  if( dlg_envvars.ShowModal() == wxID_CANCEL )
975  return;
976 
977  ENV_VAR_MAP envVarMap = dlg_envvars.GetEnvVarMap();
978 
979  for( ENV_VAR_MAP_ITER it = envVarMap.begin(); it != envVarMap.end(); ++it )
980  {
981  wxLogTrace( traceEnvVars, wxT( "Environment variable %s=%s defined externally = %d" ),
982  GetChars( it->first ), GetChars( it->second.GetValue() ),
983  it->second.GetDefinedExternally() );
984  }
985 
986  // If any of the environment variables are defined externally, warn the user that the
987  // next time kicad is run that the externally defined variables will be used instead of
988  // the user's settings. This is by design.
989  if( dlg_envvars.ExternalDefsChanged() && m_show_env_var_dialog )
990  {
991  wxString msg1 = _( "Warning! Some of paths you have configured have been defined \n"
992  "externally to the running process and will be temporarily overwritten." );
993  wxString msg2 = _( "The next time KiCad is launched, any paths that have already\n"
994  "been defined are honored and any settings defined in the path\n"
995  "configuration dialog are ignored. If you did not intend for this\n"
996  "behavior, either rename any conflicting entries or remove the\n"
997  "external environment variable definition(s) from your system." );
998  wxRichMessageDialog dlg( aParent, msg1, _( "Warning" ), wxOK | wxCENTRE );
999  dlg.ShowDetailedText( msg2 );
1000  dlg.ShowCheckBox( _( "Do not show this message again." ) );
1001  dlg.ShowModal();
1002  m_show_env_var_dialog = !dlg.IsCheckBoxChecked();
1003  }
1004 
1005  SetLocalEnvVariables( dlg_envvars.GetEnvVarMap() );
1006 }
static const wxChar traceEnvVars[]
enable/disable icons in menus
Definition: pgm_base.cpp:67
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:385
VTBL_ENTRY const ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.h:270
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
Definition: pgm_base.h:87
DIALOG_ENV_VAR_CONFIG class declaration.
VTBL_ENTRY void SetLocalEnvVariables(const ENV_VAR_MAP &aEnvVarMap)
Function SetLocalEnvVariables.
Definition: pgm_base.cpp:949
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:92
std::map< wxString, ENV_VAR_ITEM >::iterator ENV_VAR_MAP_ITER
Definition: pgm_base.h:88
void PGM_KICAD::Destroy ( )

Definition at line 200 of file kicad.cpp.

References PGM_BASE::Destroy(), BIN_MOD::End(), KFCTL_CPP_PROJECT_SUITE, Kiway, m_bm, and Pgm().

Referenced by GetHelpFileName(), OnPgmExit(), and ~PGM_KICAD().

201 {
202  // unlike a normal destructor, this is designed to be called more
203  // than once safely:
204 
205  m_bm.End();
206 
208 }
void Destroy()
Definition: pgm_base.cpp:308
BIN_MOD m_bm
Definition: pgm_kicad.h:72
void End()
Definition: bin_mod.cpp:53
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 196 of file pgm_base.h.

References VTBL_ENTRY.

Referenced by KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser(), and KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser().

196 { 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:359
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 338 of file pgm_base.cpp.

References DisplayInfoMessage().

Referenced by TREEPROJECT_ITEM::Activate(), DIALOG_CONFIG_EQUFILES::OnEditEquFile(), DIALOG_BOM::OnEditPlugin(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor(), KICAD_MANAGER_FRAME::OnOpenTextEditor(), EDA_BASE_FRAME::OnSelectPreferredEditor(), and GERBVIEW_FRAME::OnShowGerberSourceFile().

339 {
340  wxString editorname = m_editor_name;
341 
342  if( !editorname )
343  {
344  if( !wxGetEnv( wxT( "EDITOR" ), &editorname ) )
345  {
346  // If there is no EDITOR variable set, try the desktop default
347 #ifdef __WXMAC__
348  editorname = "/usr/bin/open";
349 #elif __WXX11__
350  editorname = "/usr/bin/xdg-open";
351 #endif
352  }
353  }
354 
355  // If we still don't have an editor name show a dialog asking the user to select one
356  if( !editorname && aCanShowFileChooser )
357  {
358  DisplayInfoMessage( NULL,
359  _( "No default editor found, you must choose it" ) );
360 
361  editorname = AskUserForPreferredEditor();
362  }
363 
364  // If we finally have a new editor name request it to be copied to m_editor_name and
365  // saved to the preferences file.
366  if( !editorname.IsEmpty() )
367  SetEditorName( editorname );
368 
369  // m_editor_name already has the same value that editorname, or empty if no editor was
370  // found/chosen.
371  return m_editor_name;
372 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:330
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:375
wxString m_editor_name
Definition: pgm_base.h:378
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:216
VTBL_ENTRY const wxString& PGM_BASE::GetExecutablePath ( ) const
inlineinherited
wxFileHistory& PGM_KICAD::GetFileHistory ( )
inline
wxString PGM_KICAD::GetHelpFileName ( )
inline

Definition at line 63 of file pgm_kicad.h.

References Destroy(), m_bm, and BIN_MOD::m_help_file.

Referenced by KICAD_MANAGER_FRAME::help_name().

63 { return m_bm.m_help_file; }
wxString m_help_file
Definition: bin_mod.h:59
BIN_MOD m_bm
Definition: pgm_kicad.h:72
double PGM_BASE::GetIconsScale ( )
inlineinherited

Definition at line 325 of file pgm_base.h.

325 { return m_iconsScale; }
double m_iconsScale
Scaling factor for menus and tool icons.
Definition: pgm_base.h:362
VTBL_ENTRY const wxString& PGM_BASE::GetKicadEnvVariable ( ) const
inlineinherited

Definition at line 171 of file pgm_base.h.

Referenced by FindKicadFile(), and KicadDatasPath().

171 { return m_kicad_env; }
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:350
VTBL_ENTRY wxLocale* PGM_BASE::GetLocale ( )
inlineinherited

Definition at line 175 of file pgm_base.h.

Referenced by CMP_TREE_NODE_UNIT::CMP_TREE_NODE_UNIT(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), and SearchHelpFileFullPath().

175 { return m_locale; }
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:353
VTBL_ENTRY const ENV_VAR_MAP& PGM_BASE::GetLocalEnvVariables ( ) const
inlineinherited

Definition at line 270 of file pgm_base.h.

References VTBL_ENTRY.

Referenced by S3D_FILENAME_RESOLVER::GetKicadPaths(), KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate(), and OnPgmInit().

271  {
272  return m_local_env_vars;
273  }
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:382
VTBL_ENTRY const wxString& PGM_BASE::GetPdfBrowserName ( ) const
inlineinherited

Definition at line 177 of file pgm_base.h.

Referenced by KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser(), OpenPDF(), and PGM_BASE::WritePdfBrowserInfos().

177 { return m_pdf_browser; }
wxString m_pdf_browser
The file name of the the program selected for browsing pdf files.
Definition: pgm_base.h:377
bool PGM_BASE::GetUseIconsInMenus ( )
inlineinherited

Definition at line 328 of file pgm_base.h.

Referenced by AddMenuItem(), CONTEXT_MENU::appendCopy(), and set_wxMenuIcon().

328 { return m_useIconsInMenus; }
bool m_useIconsInMenus
True to use menu icons.
Definition: pgm_base.h:364
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 398 of file pgm_base.cpp.

References SEARCH_STACK::AddPaths(), Format(), GetChars(), GetKicadLockFilePath(), GetNewConfig(), i, IsOK(), KICAD_COMMON, ENV_VAR_ITEM::SetDefinedExternally(), ENV_VAR_ITEM::SetValue(), SystemDirsAppend(), UNIX_STRING_DIR_SEP, and WIN_STRING_DIR_SEP.

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

399 {
400  wxFileName pgm_name( App().argv[0] );
401 
402  wxConfigBase::DontCreateOnDemand();
403 
404  wxInitAllImageHandlers();
405 
406  m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) +
407  wxGetUserId(), GetKicadLockFilePath() );
408 
409  if( m_pgm_checker->IsAnotherRunning() )
410  {
411  wxString quiz = wxString::Format(
412  _( "%s is already running. Continue?" ),
413  GetChars( pgm_name.GetName() )
414  );
415 
416  if( !IsOK( NULL, quiz ) )
417  return false;
418  }
419 
420  // Init KiCad environment
421  // the environment variable KICAD (if exists) gives the kicad path:
422  // something like set KICAD=d:\kicad
423  bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );
424 
425  if( isDefined ) // ensure m_kicad_env ends by "/"
426  {
428 
429  if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
431  }
432 
433  // Init parameters for configuration
434  App().SetVendorName( wxT( "KiCad" ) );
435  App().SetAppName( pgm_name.GetName().Lower() );
436 
437  // Install some image handlers, mainly for help
438  if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL )
439  wxImage::AddHandler( new wxPNGHandler );
440 
441  if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL )
442  wxImage::AddHandler( new wxGIFHandler );
443 
444  if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL )
445  wxImage::AddHandler( new wxJPEGHandler );
446 
447  wxFileSystem::AddHandler( new wxZipFSHandler );
448 
449  // Analyze the command line & initialize the binary path
451 
452  SetLanguagePath();
453 
454  // OS specific instantiation of wxConfigBase derivative:
456 
457  wxString envVarName = wxT( "KIGITHUB" );
458  ENV_VAR_ITEM envVarItem;
459  wxString envValue;
460  wxFileName tmpFileName;
461 
462  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
463  {
464  tmpFileName.AssignDir( envValue );
465  envVarItem.SetDefinedExternally( true );
466  }
467  else
468  {
469  envVarItem.SetValue( wxString( wxT( "https://github.com/KiCad" ) ) );
470  envVarItem.SetDefinedExternally( false );
471  }
472 
473  m_local_env_vars[ envVarName ] = envVarItem;
474 
475  wxFileName baseSharePath;
476  baseSharePath.AssignDir( wxString( wxT( DEFAULT_INSTALL_PATH ) ) );
477 
478 #if !defined( __WXMAC__ )
479  baseSharePath.AppendDir( wxT( "share" ) );
480  baseSharePath.AppendDir( wxT( "kicad" ) );
481 #endif
482 
483  // KISYSMOD
484  envVarName = wxT( "KISYSMOD" );
485 
486  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
487  {
488  tmpFileName.AssignDir( envValue );
489  envVarItem.SetDefinedExternally( true );
490  }
491  else
492  {
493  tmpFileName = baseSharePath;
494  tmpFileName.AppendDir( wxT( "modules" ) );
495  envVarItem.SetDefinedExternally( false );
496  }
497 
498  envVarItem.SetValue( tmpFileName.GetPath() );
499  m_local_env_vars[ envVarName ] = envVarItem;
500 
501  // KISYS3DMOD
502  envVarName = wxT( "KISYS3DMOD" );
503 
504  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
505  {
506  tmpFileName.AssignDir( envValue );
507  envVarItem.SetDefinedExternally( true );
508  }
509  else
510  {
511  tmpFileName.AppendDir( wxT( "packages3d" ) );
512  envVarItem.SetDefinedExternally( false );
513  }
514 
515  envVarItem.SetValue( tmpFileName.GetFullPath() );
516  m_local_env_vars[ envVarName ] = envVarItem;
517 
518  // KICAD_TEMPLATE_DIR
519  envVarName = "KICAD_TEMPLATE_DIR";
520 
521  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
522  {
523  tmpFileName.AssignDir( envValue );
524  envVarItem.SetDefinedExternally( true );
525  }
526  else
527  {
528  // Attempt to find the best default template path.
529  SEARCH_STACK bases;
530  SEARCH_STACK templatePaths;
531 
532  SystemDirsAppend( &bases );
533 
534  for( unsigned i = 0; i < bases.GetCount(); ++i )
535  {
536  wxFileName fn( bases[i], wxEmptyString );
537 
538  // Add KiCad template file path to search path list.
539  fn.AppendDir( "template" );
540 
541  // Only add path if exists and can be read by the user.
542  if( fn.DirExists() && fn.IsDirReadable() )
543  {
544  wxLogDebug( "Checking template path '%s' exists", fn.GetPath() );
545  templatePaths.AddPaths( fn.GetPath() );
546  }
547  }
548 
549  if( templatePaths.IsEmpty() )
550  {
551  tmpFileName = baseSharePath;
552  tmpFileName.AppendDir( "template" );
553  }
554  else
555  {
556  // Take the first one. There may be more but this will likely be the best option.
557  tmpFileName.AssignDir( templatePaths[0] );
558  }
559 
560  envVarItem.SetDefinedExternally( false );
561  }
562 
563  envVarItem.SetValue( tmpFileName.GetPath() );
564  m_local_env_vars[ envVarName ] = envVarItem;
565 
566  // KICAD_USER_TEMPLATE_DIR
567  envVarName = "KICAD_USER_TEMPLATE_DIR";
568 
569  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
570  {
571  tmpFileName.AssignDir( envValue );
572  envVarItem.SetDefinedExternally( true );
573  }
574  else
575  {
576  // Default user template path.
577  tmpFileName = wxStandardPaths::Get().GetDocumentsDir();
578  tmpFileName.AppendDir( "kicad" );
579  tmpFileName.AppendDir( "template" );
580  envVarItem.SetDefinedExternally( false );
581  }
582 
583  envVarItem.SetValue( tmpFileName.GetPath() );
584  m_local_env_vars[ envVarName ] = envVarItem;
585 
586  // KICAD_SYMBOLS
587  envVarName = wxT( "KICAD_SYMBOL_DIR" );
588 
589  if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
590  {
591  tmpFileName.AssignDir( envValue );
592  envVarItem.SetDefinedExternally( true );
593  }
594  else
595  {
596  tmpFileName = baseSharePath;
597  tmpFileName.AppendDir( wxT( "library" ) );
598  envVarItem.SetDefinedExternally( false );
599  }
600 
601  envVarItem.SetValue( tmpFileName.GetPath() );
602  m_local_env_vars[ envVarName ] = envVarItem;
603 
604  ReadPdfBrowserInfos(); // needs m_common_settings
605 
606  // Init user language *before* calling loadCommonSettings, because
607  // env vars could be incorrectly initialized on Linux
608  // (if the value contains some non ASCII7 chars, the env var is not initialized)
609  SetLanguage( true );
610 
612 
613 #ifdef __WXMAC__
614  // Always show filters on Open dialog to be able to choose plugin
615  wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
616 #endif
617 
618  return true;
619 }
void loadCommonSettings()
Function loadCommonSettings loads the program (process) settings subset which are stored in ...
Definition: pgm_base.cpp:664
wxString GetKicadLockFilePath()
Function GetKicadLockFilePath.
Definition: lockfile.cpp:59
#define WIN_STRING_DIR_SEP
Definition: gestfich.h:44
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:382
#define UNIX_STRING_DIR_SEP
Definition: gestfich.h:43
Class ENV_VAR_ITEM.
Definition: pgm_base.h:58
wxConfigBase * GetNewConfig(const wxString &aProgName)
Create a new wxConfig so we can put configuration files in a more proper place for each platform...
Definition: common.cpp:199
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition: pgm_base.cpp:323
bool setExecutablePath()
Function setExecutablePath finds the path to the executable and stores it in PGM_BASE::m_bin_dir.
Definition: pgm_base.cpp:622
wxSingleInstanceChecker * m_pgm_checker
prevents multiple instances of a program from being run at the same time.
Definition: pgm_base.h:340
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
#define KICAD_COMMON
Definition: pgm_base.cpp:58
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:350
void SetDefinedExternally(bool aIsDefinedExternally)
Definition: pgm_base.h:70
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:854
VTBL_ENTRY bool SetLanguage(bool first_time=false)
Function SetLanguage sets the dictionary file name for internationalization.
Definition: pgm_base.cpp:746
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:42
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:92
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:76
size_t i
Definition: json11.cpp:597
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:233
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
VTBL_ENTRY bool PGM_BASE::IsKicadEnvVariableDefined ( ) const
inlineinherited

Definition at line 169 of file pgm_base.h.

169 { return !m_kicad_env.IsEmpty(); }
wxString m_kicad_env
The KICAD system environment variable.
Definition: pgm_base.h:350
void PGM_BASE::loadCommonSettings ( )
protectedinherited

Function loadCommonSettings loads the program (process) settings subset which are stored in .kicad_common.

Definition at line 664 of file pgm_base.cpp.

References entryUseIconsInMenus, GetChars(), i, pathEnvVariables, showEnvVarWarningDialog, and traceEnvVars.

665 {
666  wxASSERT( m_common_settings );
667 
668  m_help_size.x = 500;
669  m_help_size.y = 400;
670  m_iconsScale = 1.0;
671 
672  // This only effect the first time KiCad is run. The user's setting will be used for all
673  // subsequent runs. Menu icons are off by default on OSX and on for all other platforms.
674 #if defined( __WXMAC__ )
675  m_useIconsInMenus = false;
676 #else
677  m_useIconsInMenus = true;
678 #endif
679 
682 
683  m_editor_name = m_common_settings->Read( wxT( "Editor" ) );
684 
685  wxString entry, oldPath;
686  wxArrayString entries;
687  long index = 0L;
688 
689  oldPath = m_common_settings->GetPath();
691 
692  while( m_common_settings->GetNextEntry( entry, index ) )
693  {
694  wxLogTrace( traceEnvVars,
695  wxT( "Enumerating over entry %s, %ld." ), GetChars( entry ), index );
696  entries.Add( entry );
697  }
698 
699  for( unsigned i = 0; i < entries.GetCount(); i++ )
700  {
701  wxString val = m_common_settings->Read( entries[i], wxEmptyString );
702 
703  if( m_local_env_vars[ entries[i] ].GetDefinedExternally() )
704  continue;
705 
706  m_local_env_vars[ entries[i] ] = ENV_VAR_ITEM( val, wxGetEnv( entries[i], NULL ) );
707  }
708 
709  for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it )
710  SetLocalEnvVariable( it->first, it->second.GetValue() );
711 
712  m_common_settings->SetPath( oldPath );
713 }
static const wxChar pathEnvVariables[]
Definition: pgm_base.cpp:65
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:382
Class ENV_VAR_ITEM.
Definition: pgm_base.h:58
static const wxChar showEnvVarWarningDialog[]
Definition: pgm_base.cpp:66
static const wxChar traceEnvVars[]
enable/disable icons in menus
Definition: pgm_base.cpp:67
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:385
static const wxChar entryUseIconsInMenus[]
Definition: pgm_base.cpp:69
double m_iconsScale
Scaling factor for menus and tool icons.
Definition: pgm_base.h:362
VTBL_ENTRY bool SetLocalEnvVariable(const wxString &aName, const wxString &aValue)
Function SetLocalEnvVariable.
Definition: pgm_base.cpp:930
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
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:92
wxSize m_help_size
Definition: pgm_base.h:379
size_t i
Definition: json11.cpp:597
wxString m_editor_name
Definition: pgm_base.h:378
bool m_useIconsInMenus
True to use menu icons.
Definition: pgm_base.h:364
std::map< wxString, ENV_VAR_ITEM >::iterator ENV_VAR_MAP_ITER
Definition: pgm_base.h:88
void PGM_KICAD::MacOpenFile ( const wxString &  aFileName)
overridevirtual

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 187 of file kicad.cpp.

References PGM_BASE::App(), and KICAD_MANAGER_FRAME::LoadProject().

Referenced by ~PGM_KICAD().

188 {
189 #if defined(__WXMAC__)
190 
191  KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) App().GetTopWindow();
192 
193  if( !aFileName.empty() && wxFileExists( aFileName ) )
194  frame->LoadProject( wxFileName( aFileName ) );
195 
196 #endif
197 }
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition: pgm_base.cpp:323
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
The main KiCad project manager frame.
Definition: kicad.h:137
void PGM_KICAD::OnPgmExit ( )

Definition at line 174 of file kicad.cpp.

References Destroy(), Kiway, KIWAY::OnKiwayEnd(), and PGM_BASE::SaveCommonSettings().

Referenced by APP_KICAD::OnExit(), and ~PGM_KICAD().

175 {
176  Kiway.OnKiwayEnd();
177 
179 
180  // write common settings to disk, and destroy everything in PGM_KICAD,
181  // especially wxSingleInstanceCheckerImpl earlier than wxApp and earlier
182  // than static destruction would.
183  Destroy();
184 }
void SaveCommonSettings()
Function saveCommonSettings saves the program (process) settings subset which are stored ...
Definition: pgm_base.cpp:716
void OnKiwayEnd()
Definition: kiway.cpp:484
void Destroy()
Definition: kicad.cpp:200
KIWAY Kiway
bool PGM_KICAD::OnPgmInit ( )

Definition at line 78 of file kicad.cpp.

References SEARCH_STACK::AddPaths(), PGM_BASE::App(), GetFileHistory(), PGM_BASE::GetLocalEnvVariables(), i, BIN_MOD::Init(), PGM_BASE::InitPgm(), KICAD_MANAGER_FRAME_NAME, Kiway, KICAD_MANAGER_FRAME::LoadProject(), m_bm, BIN_MOD::m_search, ReadHotkeyConfig(), KIWAY::SetTop(), and SystemDirsAppend().

Referenced by APP_KICAD::OnInit(), and ~PGM_KICAD().

79 {
80 #if defined(DEBUG)
81  wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();
82 
83  if( !wxIsAbsolutePath( absoluteArgv0 ) )
84  {
85  wxLogError( wxT( "No meaningful argv[0]" ) );
86  return false;
87  }
88 #endif
89 
90  if( !InitPgm() )
91  return false;
92 
93  m_bm.Init();
94 
95  // Add search paths to feed the PGM_KICAD::SysSearch() function,
96  // currenly limited in support to only look for project templates
97  {
98  SEARCH_STACK bases;
99 
100  SystemDirsAppend( &bases );
101 
102  for( unsigned i = 0; i < bases.GetCount(); ++i )
103  {
104  wxFileName fn( bases[i], wxEmptyString );
105 
106  // Add KiCad template file path to search path list.
107  fn.AppendDir( wxT( "template" ) );
108 
109  // Only add path if exists and can be read by the user.
110  if( fn.DirExists() && fn.IsDirReadable() )
111  m_bm.m_search.AddPaths( fn.GetPath() );
112  }
113 
114  // The KICAD_TEMPLATE_DIR takes precedence over the search stack template path.
115  ENV_VAR_MAP_CITER it = GetLocalEnvVariables().find( "KICAD_TEMPLATE_DIR" );
116 
117  if( it != GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
118  m_bm.m_search.Insert( it->second.GetValue(), 0 );
119 
120  // The KICAD_USER_TEMPLATE_DIR takes precedence over KICAD_TEMPLATE_DIR and the search
121  // stack template path.
122  it = GetLocalEnvVariables().find( "KICAD_USER_TEMPLATE_DIR" );
123 
124  if( it != GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
125  m_bm.m_search.Insert( it->second.GetValue(), 0 );
126  }
127 
128  // Must be called before creating the main frame in order to
129  // display the real hotkeys in menus or tool tips
132 
133  KICAD_MANAGER_FRAME* frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ),
134  wxDefaultPosition, wxDefaultSize );
135  App().SetTopWindow( frame );
136 
137  Kiway.SetTop( frame );
138 
139  wxString projToLoad;
140 
141  if( App().argc > 1 )
142  {
143  projToLoad = App().argv[1];
144  }
145  else if( GetFileHistory().GetCount() )
146  {
147  wxString last_pro = GetFileHistory().GetHistoryFile( 0 );
148 
149  if( !wxFileExists( last_pro ) )
150  {
151  GetFileHistory().RemoveFileFromHistory( 0 );
152  }
153  else
154  {
155  // Try to open the last opened project,
156  // if a project name is not given when starting Kicad
157  projToLoad = last_pro;
158  }
159  }
160 
161  // Do not attempt to load a non-existent project file.
162  if( !projToLoad.empty() && wxFileExists( projToLoad ) )
163  {
164  frame->LoadProject( projToLoad );
165  }
166 
167  frame->Show( true );
168  frame->Raise();
169 
170  return true;
171 }
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:89
void Init()
Definition: bin_mod.cpp:36
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition: pgm_base.cpp:323
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
struct EDA_HOTKEY_CONFIG kicad_Manager_Hokeys_Descr[]
VTBL_ENTRY const ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.h:270
std::map< wxString, ENV_VAR_ITEM >::const_iterator ENV_VAR_MAP_CITER
Definition: pgm_base.h:89
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Function SystemDirsAppend appends system places to aSearchStack in a platform specific way...
void SetTop(wxFrame *aTop)
Function SetTop tells this KIWAY about the top most frame in the program and optionally allows it to ...
Definition: kiway.cpp:76
SEARCH_STACK m_search
Definition: bin_mod.h:61
int ReadHotkeyConfig(const wxString &aAppname, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
BIN_MOD m_bm
Definition: pgm_kicad.h:72
size_t i
Definition: json11.cpp:597
bool InitPgm()
Function initPgm initializes this program (process) in a KiCad standard way, using some generalized t...
Definition: pgm_base.cpp:398
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
The main KiCad project manager frame.
Definition: kicad.h:137
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
#define KICAD_MANAGER_FRAME_NAME
Definition: kicad.h:40
KIWAY Kiway
wxConfigBase* PGM_KICAD::PgmSettings ( )
inline

Definition at line 59 of file pgm_kicad.h.

References m_bm, and BIN_MOD::m_config.

Referenced by KICAD_MANAGER_FRAME::config().

59 { return m_bm.m_config; }
BIN_MOD m_bm
Definition: pgm_kicad.h:72
wxConfigBase * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57
void PGM_BASE::ReadPdfBrowserInfos ( )
inherited

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

Definition at line 42 of file eda_doc.cpp.

References PGM_BASE::m_common_settings, PGM_BASE::m_use_system_pdf_browser, and PGM_BASE::SetPdfBrowserName().

Referenced by KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser(), and OpenPDF().

43 {
44  wxASSERT( m_common_settings );
45 
46  wxString browser = m_common_settings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
47  SetPdfBrowserName( browser );
48 
49  int tmp;
50  m_common_settings->Read( wxT( "UseSystemBrowser" ), &tmp, 0 );
51  m_use_system_pdf_browser = bool( tmp );
52 }
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:359
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
Definition: pgm_base.h:179
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
void PGM_BASE::SaveCommonSettings ( )
inherited

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

Definition at line 716 of file pgm_base.cpp.

References entryUseIconsInMenus, GetChars(), pathEnvVariables, showEnvVarWarningDialog, and traceEnvVars.

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

717 {
718  // m_common_settings is not initialized until fairly late in the
719  // process startup: InitPgm(), so test before using:
720  if( m_common_settings )
721  {
722  wxString cur_dir = wxGetCwd();
723 
724  m_common_settings->Write( workingDirKey, cur_dir );
727 
728  // Save the local environment variables.
730 
731  for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it )
732  {
733  if( it->second.GetDefinedExternally() )
734  continue;
735 
736  wxLogTrace( traceEnvVars, wxT( "Saving environment variable config entry %s as %s" ),
737  GetChars( it->first ), GetChars( it->second.GetValue() ) );
738  m_common_settings->Write( it->first, it->second.GetValue() );
739  }
740 
741  m_common_settings->SetPath( wxT( ".." ) );
742  }
743 }
static const wxChar pathEnvVariables[]
Definition: pgm_base.cpp:65
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:382
static const wxChar workingDirKey[]
Definition: pgm_base.h:297
static const wxChar showEnvVarWarningDialog[]
Definition: pgm_base.cpp:66
static const wxChar traceEnvVars[]
enable/disable icons in menus
Definition: pgm_base.cpp:67
bool m_show_env_var_dialog
Flag to indicate if the environment variable overwrite warning dialog should be shown.
Definition: pgm_base.h:385
static const wxChar entryUseIconsInMenus[]
Definition: pgm_base.cpp:69
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
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:92
bool m_useIconsInMenus
True to use menu icons.
Definition: pgm_base.h:364
std::map< wxString, ENV_VAR_ITEM >::iterator ENV_VAR_MAP_ITER
Definition: pgm_base.h:88
void PGM_BASE::SetEditorName ( const wxString &  aFileName)
inherited

Definition at line 330 of file pgm_base.cpp.

Referenced by EDA_BASE_FRAME::OnSelectPreferredEditor().

331 {
332  m_editor_name = aFileName;
333  wxASSERT( m_common_settings );
334  m_common_settings->Write( wxT( "Editor" ), aFileName );
335 }
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
wxString m_editor_name
Definition: pgm_base.h:378
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 622 of file pgm_base.cpp.

References UNIX_STRING_DIR_SEP, and WIN_STRING_DIR_SEP.

623 {
624  m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
625 
626 #ifdef __WXMAC__
627  // On OSX Pgm().GetExecutablePath() will always point to main
628  // bundle directory, e.g., /Applications/kicad.app/
629 
630  wxFileName fn( m_bin_dir );
631 
632  if( fn.GetName() == wxT( "kicad" ) )
633  {
634  // kicad launcher, so just remove the Contents/MacOS part
635  fn.RemoveLastDir();
636  fn.RemoveLastDir();
637  }
638  else
639  {
640  // standalone binaries live in Contents/Applications/<standalone>.app/Contents/MacOS
641  fn.RemoveLastDir();
642  fn.RemoveLastDir();
643  fn.RemoveLastDir();
644  fn.RemoveLastDir();
645  fn.RemoveLastDir();
646  }
647 
648  m_bin_dir = fn.GetPath() + wxT( "/" );
649 #else
650  // Use unix notation for paths. I am not sure this is a good idea,
651  // but it simplifies compatibility between Windows and Unices.
652  // However it is a potential problem in path handling under Windows.
654 
655  // Remove file name form command line:
656  while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
657  m_bin_dir.RemoveLast();
658 #endif
659 
660  return true;
661 }
#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:347
void PGM_BASE::SetIconsScale ( double  aValue)
inlineinherited

Scaling factor for menus and tool icons.

Definition at line 324 of file pgm_base.h.

324 { m_iconsScale = aValue; }
double m_iconsScale
Scaling factor for menus and tool icons.
Definition: pgm_base.h:362
bool PGM_BASE::SetLanguage ( bool  first_time = false)
inherited

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

References DIM, GetChars(), languageCfgKey, LANGUAGE_DESCR::m_Lang_Label, and LANGUAGE_DESCR::m_WX_Lang_Identifier.

Referenced by KIWAY::SetLanguage(), and KIWAY::~KIWAY().

747 {
748  bool retv = true;
749 
750  if( first_time )
751  {
752  setLanguageId( wxLANGUAGE_DEFAULT );
753  // First time SetLanguage is called, the user selected language id is set
754  // from commun user config settings
755  wxString languageSel;
756 
757  m_common_settings->Read( languageCfgKey, &languageSel );
758 
759  // Search for the current selection
760  for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
761  {
762  if( s_Languages[ii].m_Lang_Label == languageSel )
763  {
764  setLanguageId( s_Languages[ii].m_WX_Lang_Identifier );
765  break;
766  }
767  }
768  }
769 
770  // dictionary file name without extend (full name is kicad.mo)
771  wxString dictionaryName( wxT( "kicad" ) );
772 
773  delete m_locale;
774  m_locale = new wxLocale;
775 
776  if( !m_locale->Init( m_language_id ) )
777  {
778  wxLogDebug( wxT( "This language is not supported by the system." ) );
779 
780  setLanguageId( wxLANGUAGE_DEFAULT );
781  delete m_locale;
782 
783  m_locale = new wxLocale;
784  m_locale->Init();
785  retv = false;
786  }
787  else if( !first_time )
788  {
789  wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ),
790  GetChars( dictionaryName ), GetChars( m_locale->GetName() ) );
791  }
792 
793  if( !first_time )
794  {
795  // If we are here, the user has selected another language.
796  // Therefore the new prefered language name is stored in common config.
797  // Do NOT store the wxWidgets language Id, it can change between wxWidgets
798  // versions, for a given language
799  wxString languageSel;
800 
801  // Search for the current selection language name
802  for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
803  {
804  if( s_Languages[ii].m_WX_Lang_Identifier == m_language_id )
805  {
806  languageSel = s_Languages[ii].m_Lang_Label;
807  break;
808  }
809  }
810 
811  m_common_settings->Write( languageCfgKey, languageSel );
812  }
813 
814  // Test if floating point notation is working (bug encountered in cross compilation)
815  // Make a conversion double <=> string
816  double dtst = 0.5;
817  wxString msg;
818 
819  msg << dtst;
820  double result;
821  msg.ToDouble( &result );
822 
823  if( result != dtst )
824  // string to double encode/decode does not work! Bug detected:
825  // Disable floating point localization:
826  setlocale( LC_ALL, "C" );
827 
828  if( !m_locale->IsLoaded( dictionaryName ) )
829  m_locale->AddCatalog( dictionaryName );
830 
831  if( !retv )
832  return retv;
833 
834  return m_locale->IsOk();
835 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
wxLocale * m_locale
The current locale.
Definition: pgm_base.h:353
int m_language_id
The current language setting.
Definition: pgm_base.h:356
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:367
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.cpp:92
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
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:92
static const wxChar languageCfgKey[]
Definition: pgm_base.cpp:64
static LANGUAGE_DESCR s_Languages[]
Variable s_Languages Note: because this list is not created on the fly, wxTranslation must be called ...
Definition: pgm_base.cpp:105
void PGM_BASE::setLanguageId ( int  aId)
inlineprotectedinherited

Trap all changes in here, simplifies debugging.

Definition at line 367 of file pgm_base.h.

367 { m_language_id = aId; }
int m_language_id
The current language setting.
Definition: pgm_base.h:356
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 838 of file pgm_base.cpp.

References DIM, LANGUAGE_DESCR::m_KI_Lang_Identifier, and LANGUAGE_DESCR::m_WX_Lang_Identifier.

Referenced by KIWAY::SetLanguage().

839 {
840  wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
841  menu_id, DIM( s_Languages ) );
842 
843  for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
844  {
845  if( menu_id == s_Languages[ii].m_KI_Lang_Identifier )
846  {
847  setLanguageId( s_Languages[ii].m_WX_Lang_Identifier );
848  break;
849  }
850  }
851 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition: pgm_base.h:367
static LANGUAGE_DESCR s_Languages[]
Variable s_Languages Note: because this list is not created on the fly, wxTranslation must be called ...
Definition: pgm_base.cpp:105
void PGM_BASE::SetLanguagePath ( )
inherited

Definition at line 854 of file pgm_base.cpp.

References i, and SystemDirsAppend().

855 {
856  SEARCH_STACK guesses;
857 
858  SystemDirsAppend( &guesses );
859 
860  // Add our internat dir to the wxLocale catalog of paths
861  for( unsigned i = 0; i < guesses.GetCount(); i++ )
862  {
863  wxFileName fn( guesses[i], wxEmptyString );
864 
865  // Append path for Windows and unix KiCad package install
866  fn.AppendDir( wxT( "share" ) );
867  fn.AppendDir( wxT( "internat" ) );
868 
869  if( fn.IsDirReadable() )
870  {
871  wxLogDebug( wxT( "Adding locale lookup path: " ) + fn.GetPath() );
872  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
873  }
874 
875  // Append path for unix standard install
876  fn.RemoveLastDir();
877  fn.AppendDir( wxT( "kicad" ) );
878  fn.AppendDir( wxT( "internat" ) );
879 
880  if( fn.IsDirReadable() )
881  {
882  wxLogDebug( wxT( "Adding locale lookup path: " ) + fn.GetPath() );
883  wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
884  }
885  }
886 }
Class 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...
size_t i
Definition: json11.cpp:597
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 930 of file pgm_base.cpp.

References GetChars(), and traceEnvVars.

931 {
932  wxString env;
933 
934  // Check to see if the environment variable is already set.
935  if( wxGetEnv( aName, &env ) )
936  {
937  wxLogTrace( traceEnvVars, wxT( "Environment variable %s already set to %s." ),
938  GetChars( aName ), GetChars( env ) );
939  return env == aValue;
940  }
941 
942  wxLogTrace( traceEnvVars, wxT( "Setting local environment variable %s to %s." ),
943  GetChars( aName ), GetChars( aValue ) );
944 
945  return wxSetEnv( aName, aValue );
946 }
static const wxChar traceEnvVars[]
enable/disable icons in menus
Definition: pgm_base.cpp:67
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:92
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 949 of file pgm_base.cpp.

References GetChars(), pathEnvVariables, and traceEnvVars.

Referenced by DIALOG_ENV_VAR_CONFIG::TransferDataFromWindow().

950 {
951  m_local_env_vars.clear();
952  m_local_env_vars = aEnvVarMap;
953 
954  if( m_common_settings )
955  m_common_settings->DeleteGroup( pathEnvVariables );
956 
958 
959  // Overwrites externally defined environment variable until the next time the application
960  // is run.
961  for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it )
962  {
963  wxLogTrace( traceEnvVars, wxT( "Setting local environment variable %s to %s." ),
964  GetChars( it->first ), GetChars( it->second.GetValue() ) );
965  wxSetEnv( it->first, it->second.GetValue() );
966  }
967 }
static const wxChar pathEnvVariables[]
Definition: pgm_base.cpp:65
ENV_VAR_MAP m_local_env_vars
Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
Definition: pgm_base.h:382
void SaveCommonSettings()
Function saveCommonSettings saves the program (process) settings subset which are stored ...
Definition: pgm_base.cpp:716
static const wxChar traceEnvVars[]
enable/disable icons in menus
Definition: pgm_base.cpp:67
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344
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:92
std::map< wxString, ENV_VAR_ITEM >::iterator ENV_VAR_MAP_ITER
Definition: pgm_base.h:88
VTBL_ENTRY void PGM_BASE::SetPdfBrowserName ( const wxString &  aFileName)
inlineinherited

Definition at line 179 of file pgm_base.h.

Referenced by KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser(), and PGM_BASE::ReadPdfBrowserInfos().

179 { m_pdf_browser = aFileName; }
wxString m_pdf_browser
The file name of the the program selected for browsing pdf files.
Definition: pgm_base.h:377
void PGM_BASE::SetUseIconsInMenus ( bool  aUseIcons)
inlineinherited

True to use menu icons.

Definition at line 327 of file pgm_base.h.

Referenced by EDA_BASE_FRAME::OnChangeIconsOptions(), and DIALOG_GENERALOPTIONS::OnOkClick().

327 { m_useIconsInMenus = aUseIcons; }
bool m_useIconsInMenus
True to use menu icons.
Definition: pgm_base.h:364
SEARCH_STACK& PGM_KICAD::SysSearch ( )
inline

Definition at line 61 of file pgm_kicad.h.

References m_bm, and BIN_MOD::m_search.

Referenced by KICAD_MANAGER_FRAME::sys_search().

61 { return m_bm.m_search; }
SEARCH_STACK m_search
Definition: bin_mod.h:61
BIN_MOD m_bm
Definition: pgm_kicad.h:72
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 187 of file pgm_base.h.

188  {
189  return m_use_system_pdf_browser || m_pdf_browser.IsEmpty();
190  }
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:359
wxString m_pdf_browser
The file name of the the program selected for browsing pdf files.
Definition: pgm_base.h:377
void PGM_BASE::WritePdfBrowserInfos ( )
inherited

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

Definition at line 55 of file eda_doc.cpp.

References PGM_BASE::GetPdfBrowserName(), PGM_BASE::m_common_settings, and PGM_BASE::m_use_system_pdf_browser.

Referenced by KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser(), and KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser().

56 {
57  wxASSERT( m_common_settings );
58 
59  m_common_settings->Write( wxT( "PdfBrowserName" ), GetPdfBrowserName() );
60  m_common_settings->Write( wxT( "UseSystemBrowser" ), m_use_system_pdf_browser );
61 }
VTBL_ENTRY const wxString & GetPdfBrowserName() const
Definition: pgm_base.h:177
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:359
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
Definition: pgm_base.h:344

Member Data Documentation

wxString PGM_BASE::m_bin_dir
protectedinherited

full path to this program

Definition at line 347 of file pgm_base.h.

BIN_MOD PGM_KICAD::m_bm
protected

Definition at line 72 of file pgm_kicad.h.

Referenced by Destroy(), GetFileHistory(), GetHelpFileName(), OnPgmInit(), PgmSettings(), and SysSearch().

wxConfigBase* PGM_BASE::m_common_settings
protectedinherited

Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.

Definition at line 344 of file pgm_base.h.

Referenced by PGM_BASE::ReadPdfBrowserInfos(), and PGM_BASE::WritePdfBrowserInfos().

wxString PGM_BASE::m_editor_name
protectedinherited

Definition at line 378 of file pgm_base.h.

wxSize PGM_BASE::m_help_size
protectedinherited

Definition at line 379 of file pgm_base.h.

double PGM_BASE::m_iconsScale
protectedinherited

Scaling factor for menus and tool icons.

Definition at line 362 of file pgm_base.h.

wxString PGM_BASE::m_kicad_env
protectedinherited

The KICAD system environment variable.

Definition at line 350 of file pgm_base.h.

int PGM_BASE::m_language_id
protectedinherited

The current language setting.

Definition at line 356 of file pgm_base.h.

ENV_VAR_MAP PGM_BASE::m_local_env_vars
protectedinherited

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

Definition at line 382 of file pgm_base.h.

wxLocale* PGM_BASE::m_locale
protectedinherited

The current locale.

Definition at line 353 of file pgm_base.h.

wxString PGM_BASE::m_pdf_browser
protectedinherited

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

Definition at line 377 of file pgm_base.h.

wxSingleInstanceChecker* PGM_BASE::m_pgm_checker
protectedinherited

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

Definition at line 340 of file pgm_base.h.

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 385 of file pgm_base.h.

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 359 of file pgm_base.h.

Referenced by PGM_BASE::ReadPdfBrowserInfos(), and PGM_BASE::WritePdfBrowserInfos().

bool PGM_BASE::m_useIconsInMenus
protectedinherited

True to use menu icons.

Definition at line 364 of file pgm_base.h.

const wxChar PGM_BASE::workingDirKey = wxT( "WorkingDir" )
staticinherited

Definition at line 297 of file pgm_base.h.


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