KiCad PCB EDA Suite
|
Container for data for KiCad programs. More...
#include <pgm_base.h>
Public Member Functions | |
PGM_BASE () | |
virtual | ~PGM_BASE () |
void | BuildArgvUtf8 () |
Builds the UTF8 based argv variable. More... | |
virtual void | MacOpenFile (const wxString &aFileName)=0 |
Specific to MacOSX (not used under Linux or Windows). More... | |
virtual SETTINGS_MANAGER & | GetSettingsManager () const |
virtual COMMON_SETTINGS * | GetCommonSettings () const |
virtual void | SetTextEditor (const wxString &aFileName) |
virtual const wxString & | GetTextEditor (bool aCanShowFileChooser=true) |
Return the path to the preferred text editor application. More... | |
virtual const wxString | AskUserForPreferredEditor (const wxString &aDefaultEditor=wxEmptyString) |
Shows a dialog that instructs the user to select a new preferred editor. More... | |
virtual bool | IsKicadEnvVariableDefined () const |
virtual const wxString & | GetKicadEnvVariable () const |
virtual const wxString & | GetExecutablePath () const |
virtual wxLocale * | GetLocale () |
virtual const wxString & | GetPdfBrowserName () const |
virtual void | SetPdfBrowserName (const wxString &aFileName) |
virtual bool | UseSystemPdfBrowser () const |
virtual void | ForceSystemPdfBrowser (bool aFlg) |
Force the use of system PDF browser, even if a preferred PDF browser is set. More... | |
virtual bool | SetLanguage (wxString &aErrMsg, bool first_time=false) |
Set the dictionary file name for internationalization. More... | |
bool | SetDefaultLanguage (wxString &aErrMsg) |
Set the default language without reference to any preferences. More... | |
virtual void | SetLanguageIdentifier (int menu_id) |
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal menu identifier). More... | |
virtual int | GetSelectedLanguageIdentifier () const |
virtual wxString | GetLanguageTag () |
virtual void | SetLanguagePath () |
virtual void | ReadPdfBrowserInfos () |
Read the PDF browser choice from the common configuration. More... | |
virtual void | WritePdfBrowserInfos () |
Save the PDF browser choice to the common configuration. More... | |
virtual bool | SetLocalEnvVariable (const wxString &aName, const wxString &aValue) |
Sets the environment variable aName to aValue. More... | |
virtual void | SetLocalEnvVariables () |
Updates the local environment with the contents of the current ENV_VAR_MAP stored in the COMMON_SETTINGS. More... | |
virtual ENV_VAR_MAP & | GetLocalEnvVariables () const |
virtual wxApp & | App () |
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe. More... | |
bool | InitPgm (bool aHeadless=false, bool aSkipPyInit=false, bool aIsUnitTest=false) |
Initialize this program. More... | |
void | Destroy () |
void | SaveCommonSettings () |
Save 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... | |
std::vector< void * > | m_ModalDialogs |
bool | m_Quitting |
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 () |
Find the path to the executable and stores it in PGM_BASE::m_bin_dir. More... | |
Protected Attributes | |
std::unique_ptr< SETTINGS_MANAGER > | m_settings_manager |
std::unique_ptr< SCRIPTING > | m_python_scripting |
wxString | m_bin_dir |
wxString | m_kicad_env |
full path to this program More... | |
wxLocale * | m_locale |
The KICAD system environment variable. More... | |
int | m_language_id |
bool | m_use_system_pdf_browser |
wxString | m_pdf_browser |
wxString | m_text_editor |
Filename of the app selected for browsing PDFs. More... | |
char ** | m_argvUtf8 |
int | m_argcUtf8 |
argv parameters converted to utf8 form, because wxwidgets has opinions and will return argv as either force converted to ascii in char* or wchar_t only More... | |
Container for data for KiCad programs.
The functions are virtual so we can do cross module calls without linking to them. This used to be a wxApp derivative, but that is difficult under wxPython which shapes the wxApp. So now this is a "side-car" (like a motorcycle side-car) object with a back pointer into the wxApp which initializes it.
Definition at line 94 of file pgm_base.h.
PGM_BASE::PGM_BASE | ( | ) |
Definition at line 124 of file pgm_base.cpp.
References ForceSystemPdfBrowser(), m_argcUtf8, m_argvUtf8, m_locale, m_Printing, m_Quitting, and setLanguageId().
|
virtual |
Definition at line 138 of file pgm_base.cpp.
References Destroy(), m_argcUtf8, and m_argvUtf8.
|
virtual |
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
This should return what wxGetApp() returns.
Definition at line 163 of file pgm_base.cpp.
Referenced by BuildArgvUtf8(), InitPgm(), PGM_SINGLE_TOP::MacOpenFile(), PGM_KICAD::MacOpenFile(), PGM_TEST_FRAME::MacOpenFile(), and PGM_KICAD::OnPgmInit().
|
virtual |
Shows a dialog that instructs the user to select a new preferred editor.
aDefaultEditor | Default full path for the default editor this dialog should show by default. |
Definition at line 213 of file pgm_base.cpp.
Referenced by GetTextEditor().
void PGM_BASE::BuildArgvUtf8 | ( | ) |
Builds the UTF8 based argv variable.
Definition at line 383 of file pgm_base.cpp.
References App(), m_argcUtf8, and m_argvUtf8.
void PGM_BASE::Destroy | ( | ) |
Definition at line 151 of file pgm_base.cpp.
References m_locale.
Referenced by PGM_KICAD::Destroy(), PGM_SINGLE_TOP::OnPgmExit(), PGM_TEST_FRAME::OnPgmExit(), and ~PGM_BASE().
|
inlinevirtual |
Force the use of system PDF browser, even if a preferred PDF browser is set.
Definition at line 187 of file pgm_base.h.
References m_use_system_pdf_browser.
Referenced by PGM_BASE().
|
virtual |
Definition at line 615 of file pgm_base.cpp.
References m_settings_manager.
Referenced by GetLocalEnvVariables(), InitPgm(), loadCommonSettings(), ReadPdfBrowserInfos(), SaveCommonSettings(), SetLanguage(), SetLocalEnvVariables(), SetTextEditor(), and WritePdfBrowserInfos().
|
inlinevirtual |
Definition at line 166 of file pgm_base.h.
References m_bin_dir.
Referenced by PGM_SINGLE_TOP::OnPgmInit(), and SetLanguagePath().
|
inlinevirtual |
|
virtual |
Definition at line 778 of file pgm_base.cpp.
References m_language_id.
|
inlinevirtual |
|
virtual |
Definition at line 856 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_Env, and COMMON_SETTINGS::ENVIRONMENT::vars.
Referenced by FILENAME_RESOLVER::GetKicadPaths(), and PGM_KICAD::OnPgmInit().
|
inlinevirtual |
Definition at line 170 of file pgm_base.h.
References m_pdf_browser.
Referenced by WritePdfBrowserInfos().
|
inlinevirtual |
Definition at line 221 of file pgm_base.h.
References m_language_id.
|
inlinevirtual |
Definition at line 135 of file pgm_base.h.
References m_settings_manager.
Referenced by InitPgm(), LIB_PIN::LIB_PIN(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), PGM_KICAD::OnPgmInit(), SCH::readSchematicFromFile(), SaveFileAs(), and SetLanguage().
|
virtual |
Return the path to the preferred text editor application.
aCanShowFileChooser | If 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. |
Definition at line 177 of file pgm_base.cpp.
References _, AskUserForPreferredEditor(), DisplayInfoMessage(), m_text_editor, and SetTextEditor().
bool PGM_BASE::InitPgm | ( | bool | aHeadless = false , |
bool | aSkipPyInit = false , |
||
bool | aIsUnitTest = false |
||
) |
Initialize this program.
Initialize the process in a KiCad standard way using some generalized techniques:
aHeadless | If true, run in headless mode (e.g. for unit tests) |
aSkipPyInit | If true, do not init python stuff. Useful in application that do not use python, to disable python dependency at run time |
Should never happen but boost unit_test isn't playing nicely in some cases
Definition at line 398 of file pgm_base.cpp.
References _, App(), DisplayErrorMessage(), PATHS::EnsureUserPathsExist(), ADVANCED_CFG::GetCfg(), GetCommonSettings(), GetSettingsManager(), COMMON_SETTINGS::InitializeEnvironment(), SETTINGS_MANAGER::Load(), loadCommonSettings(), SETTINGS_MANAGER::LoadProject(), m_kicad_env, m_python_scripting, m_settings_manager, ReadPdfBrowserInfos(), SetDefaultLanguage(), setExecutablePath(), SetLanguage(), SetLanguagePath(), UNIX_STRING_DIR_SEP, WarnUserIfOperatingSystemUnsupported(), WIN_STRING_DIR_SEP, and wxPGGlobalVars.
Referenced by PGM_KICAD::OnPgmInit().
|
inlinevirtual |
|
protected |
Loads internal settings from COMMON_SETTINGS.
Definition at line 579 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, m_text_editor, PROJECT_VAR_NAME, SetLocalEnvVariable(), COMMON_SETTINGS::SYSTEM::text_editor, and traceEnvVars.
Referenced by InitPgm().
|
pure virtual |
Specific to MacOSX (not used under Linux or Windows).
MacOSX requires it for file association.
Implemented in PGM_SINGLE_TOP, PGM_KICAD, and PGM_TEST_FRAME.
|
virtual |
Read the PDF browser choice from the common configuration.
Definition at line 37 of file eda_doc.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, m_use_system_pdf_browser, SetPdfBrowserName(), and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.
Referenced by InitPgm().
void PGM_BASE::SaveCommonSettings | ( | ) |
Save the program (process) settings subset which are stored .kicad_common.
Definition at line 606 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, and COMMON_SETTINGS::SYSTEM::working_dir.
Referenced by PGM_SINGLE_TOP::OnPgmExit(), and PGM_KICAD::OnPgmExit().
bool PGM_BASE::SetDefaultLanguage | ( | wxString & | aErrMsg | ) |
Set the default language without reference to any preferences.
Can be used to set the language for dialogs that show before preferences are loaded
aErrMsg | String to return the error message(s) in |
Definition at line 721 of file pgm_base.cpp.
References _, m_language_id, m_locale, setLanguageId(), and traceLocale.
Referenced by InitPgm().
|
protected |
Find the path to the executable and stores it in PGM_BASE::m_bin_dir.
Definition at line 537 of file pgm_base.cpp.
References m_bin_dir, UNIX_STRING_DIR_SEP, and WIN_STRING_DIR_SEP.
Referenced by InitPgm().
|
virtual |
Set the dictionary file name for internationalization.
The files are in kicad/internat/xx or kicad/internat/xx_XX and are named kicad.mo
aErrMsg | is the string to return the error message it. |
first_time | must be set to true the first time this function is called, false otherwise. |
Definition at line 621 of file pgm_base.cpp.
References _, GetCommonSettings(), GetSettingsManager(), COMMON_SETTINGS::SYSTEM::language, LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, LANGUAGE_DESCR::m_Lang_Label, m_language_id, m_locale, COMMON_SETTINGS::m_System, JSON_SETTINGS::SaveToFile(), setLanguageId(), and traceLocale.
Referenced by InitPgm().
|
inlineprotected |
Trap all changes in here, simplifies debugging.
Definition at line 320 of file pgm_base.h.
References m_language_id.
Referenced by PGM_BASE(), SetDefaultLanguage(), SetLanguage(), and SetLanguageIdentifier().
|
virtual |
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal menu identifier).
menu_id | The KiCad menuitem id (returned by Menu Event, when clicking on a menu item) |
Definition at line 762 of file pgm_base.cpp.
References arrayDim(), LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, setLanguageId(), and traceLocale.
|
virtual |
Definition at line 798 of file pgm_base.cpp.
References GetExecutablePath(), PATHS::GetLocaleDataPath(), and Pgm().
Referenced by InitPgm().
|
virtual |
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.
aName | is a wxString containing the environment variable name. |
aValue | is a wxString containing the environment variable value. |
Definition at line 812 of file pgm_base.cpp.
References traceEnvVars.
Referenced by loadCommonSettings().
|
virtual |
Updates the local environment with the contents of the current ENV_VAR_MAP stored in the COMMON_SETTINGS.
Definition at line 841 of file pgm_base.cpp.
References GetCommonSettings(), and traceEnvVars.
|
inlinevirtual |
Definition at line 172 of file pgm_base.h.
References m_pdf_browser.
Referenced by ReadPdfBrowserInfos().
|
virtual |
Definition at line 170 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, m_text_editor, and COMMON_SETTINGS::SYSTEM::text_editor.
Referenced by GetTextEditor().
|
inlinevirtual |
Definition at line 179 of file pgm_base.h.
References m_pdf_browser, and m_use_system_pdf_browser.
|
virtual |
Save the PDF browser choice to the common configuration.
Definition at line 44 of file eda_doc.cpp.
References GetCommonSettings(), GetPdfBrowserName(), COMMON_SETTINGS::m_System, m_use_system_pdf_browser, COMMON_SETTINGS::SYSTEM::pdf_viewer_name, and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.
|
protected |
argv parameters converted to utf8 form, because wxwidgets has opinions and will return argv as either force converted to ascii in char* or wchar_t only
Definition at line 360 of file pgm_base.h.
Referenced by BuildArgvUtf8(), PGM_BASE(), and ~PGM_BASE().
|
protected |
Definition at line 357 of file pgm_base.h.
Referenced by BuildArgvUtf8(), PGM_BASE(), and ~PGM_BASE().
|
protected |
Definition at line 340 of file pgm_base.h.
Referenced by GetExecutablePath(), and setExecutablePath().
|
protected |
full path to this program
Definition at line 341 of file pgm_base.h.
Referenced by GetKicadEnvVariable(), InitPgm(), and IsKicadEnvVariableDefined().
|
protected |
Definition at line 344 of file pgm_base.h.
Referenced by GetLanguageTag(), GetSelectedLanguageIdentifier(), SetDefaultLanguage(), SetLanguage(), and setLanguageId().
|
protected |
The KICAD system environment variable.
Definition at line 343 of file pgm_base.h.
Referenced by Destroy(), GetLocale(), PGM_BASE(), SetDefaultLanguage(), and SetLanguage().
std::vector<void*> PGM_BASE::m_ModalDialogs |
Definition at line 311 of file pgm_base.h.
Referenced by APP_KICAD::FilterEvent(), and APP_KICAD_CLI::FilterEvent().
|
protected |
Definition at line 347 of file pgm_base.h.
Referenced by GetPdfBrowserName(), SetPdfBrowserName(), and UseSystemPdfBrowser().
bool PGM_BASE::m_Printing |
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
Definition at line 309 of file pgm_base.h.
Referenced by BOARD::ComputeBoundingBox(), and PGM_BASE().
|
protected |
Definition at line 338 of file pgm_base.h.
Referenced by InitPgm().
bool PGM_BASE::m_Quitting |
Definition at line 313 of file pgm_base.h.
Referenced by PGM_BASE().
|
protected |
Definition at line 336 of file pgm_base.h.
Referenced by GetCommonSettings(), GetSettingsManager(), InitPgm(), PGM_SINGLE_TOP::OnPgmExit(), and PGM_KICAD::OnPgmExit().
|
protected |
Filename of the app selected for browsing PDFs.
Definition at line 349 of file pgm_base.h.
Referenced by GetTextEditor(), loadCommonSettings(), and SetTextEditor().
|
protected |
Definition at line 346 of file pgm_base.h.
Referenced by ForceSystemPdfBrowser(), ReadPdfBrowserInfos(), UseSystemPdfBrowser(), and WritePdfBrowserInfos().
|
static |
Definition at line 270 of file pgm_base.h.