31 #include <wx/filename.h> 34 #include <wx/stdpaths.h> 35 #include <wx/msgdlg.h> 53 #include <VersionHelpers.h> 63 wxLogFatalError( wxT(
"Unexpected call to Kiface() in kicad/kicad.cpp" ) );
65 throw std::logic_error(
"Unexpected call to Kiface() in kicad/kicad.cpp" );
94 wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();
96 if( !wxIsAbsolutePath( absoluteArgv0 ) )
98 wxLogError( wxT(
"No meaningful argv[0]" ) );
118 for(
unsigned i = 0; i < bases.GetCount(); ++i )
120 wxFileName fn( bases[i], wxEmptyString );
123 fn.AppendDir( wxT(
"template" ) );
126 if( fn.DirExists() && fn.IsDirReadable() )
148 wxDefaultPosition, wxSize( 775, -1 ) );
149 App().SetTopWindow( frame );
159 wxFileName tmp =
App().argv[1];
165 msg.Printf(
_(
"File '%s'\ndoes not appear to be a valid KiCad project file." ),
167 wxMessageDialog dlg(
nullptr, msg,
_(
"Error" ), wxOK | wxICON_EXCLAMATION );
172 projToLoad = tmp.GetFullPath();
182 if( wxFileExists( last_pro ) )
186 projToLoad = last_pro;
191 if( !projToLoad.empty() )
193 wxFileName fn( projToLoad );
228 #if defined(__WXMAC__) 232 if( !aFileName.empty() && wxFileExists( aFileName ) )
258 #if defined (__LINUX__) 266 if( wxGetEnv( wxT(
"XDG_CURRENT_DESKTOP" ), &wm ) && wm.CmpNoCase( wxT(
"Unity" ) ) == 0 )
268 wxSetEnv ( wxT(
"UBUNTU_MENUPROXY" ), wxT(
"0" ) );
273 wxSetEnv( wxT(
"GDK_BACKEND" ), wxT(
"x11" ) );
277 wxSetEnv( wxT(
"GTK_OVERLAY_SCROLLING" ), wxT(
"0" ) );
282 wxSetEnv( wxT(
"GDK_CORE_DEVICE_EVENTS" ), wxT(
"1" ) );
288 #if defined( _MSC_VER ) && defined( DEBUG ) 291 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
294 #if defined( _WIN32 ) && defined( PYTHON_VERSION_MAJOR ) \ 295 && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \ 296 || PYTHON_VERSION_MAJOR > 3 ) 301 if( !IsWindows8OrGreater() )
303 wxMessageBox(
_(
"Windows 7 and older is no longer supported by KiCad and its " 304 "dependencies." ),
_(
"Unsupported Operating System" ),
305 wxOK | wxICON_ERROR );
323 #if defined(__FreeBSD__) 325 wxLog::EnableLogging(
false );
328 return wxApp::OnExit();
335 return wxApp::OnRun();
337 catch(
const std::exception& e )
339 wxLogError( wxT(
"Unhandled exception class: %s what: %s" ),
344 wxLogError( ioe.
What() );
348 wxLogError( wxT(
"Unhandled exception of unknown type" ) );
356 if( aEvent.GetEventType() == wxEVT_SHOW )
358 wxShowEvent&
event = static_cast<wxShowEvent&>( aEvent );
359 wxDialog* dialog = dynamic_cast<wxDialog*>( event.GetEventObject() );
361 if( dialog && dialog->IsModal() )
373 #if defined( __WXMAC__ ) 374 void MacOpenFile(
const wxString& aFileName )
override virtual SETTINGS_MANAGER & GetSettingsManager() const
#define KFCTL_CPP_PROJECT_SUITE
Running under C++ project mgr, possibly with others.
A KIFACE (I)mplementation.
Container for project specific data.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
const std::string ProjectFileExtension
Container for data for KiCad programs.
PGM_KICAD extends PGM_BASE to bring in FileHistory() and PdfBrowser() which were moved from EDA_APP i...
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
virtual void MacOpenFile(const wxString &aFileName)=0
Specific to MacOSX (not used under Linux or Windows).
void MacOpenFile(const wxString &aFileName) override
Specific to MacOSX (not used under Linux or Windows).
virtual wxApp & App()
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
System directories search utilities.
virtual const ENV_VAR_MAP & GetLocalEnvVariables() const
Look for files in a number of paths.
std::vector< wxString > m_OpenProjects
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
int FilterEvent(wxEvent &aEvent) override
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
void SetKiway(KIWAY *aKiway)
Associate this setting manager with the given Kiway.
virtual const wxString What() const
A composite of Problem() and Where()
std::map< wxString, ENV_VAR_ITEM >::const_iterator ENV_VAR_MAP_CITER
Definition of file extensions used in Kicad.
static wxString GetUserTemplatesPath()
Gets the user path for custom templates.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Append system places to aSearchStack in a platform specific way and pertinent to KiCad programs.
PGM_BASE & Pgm()
The global Program "get" accessor.
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
const std::string LegacyProjectFileExtension
void SetTop(wxFrame *aTop)
Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of ...
JSON_SETTINGS * RegisterSettings(JSON_SETTINGS *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
APP_SETTINGS_BASE * PgmSettings()
bool InitPgm()
Initialize this program.
void LoadProject(const wxFileName &aProjectFileName)
Not publicly visible because most of the action is in PGM_KICAD these days.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
The main KiCad project manager frame.
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).