34#include <wx/cmdline.h>
36#include <wx/filename.h>
37#include <wx/stdpaths.h>
38#include <wx/snglinst.h>
39#include <wx/html/htmlwin.h>
67#ifdef KICAD_USE_SENTRY
115 wxFileName filename( aFileName );
117 if( filename.FileExists() )
129 blocking_win->Close(
true );
148 virtual bool OnInit()
override { AddDependency( CLASSINFO( wxHtmlWinParser ) );
return true; };
160void CustomAssertHandler(
const wxString& file,
162 const wxString& func,
163 const wxString& cond,
164 const wxString& msg )
190 wxSizerFlags::DisableConsistencyChecks();
191 wxDISABLE_DEBUG_SUPPORT();
192 wxSetAssertHandler( CustomAssertHandler );
203 if( wxGetEnv( wxS(
"KICAD_ENABLE_WXTRACE" ),
nullptr ) )
205 wxLog::EnableLogging(
true );
206 wxLog::SetLogLevel( wxLOG_Trace );
236 int ret = wxApp::OnExit();
247 ret = wxApp::OnRun();
259 if( aEvent.GetEventType() == wxEVT_SHOW )
261 wxShowEvent&
event =
static_cast<wxShowEvent&
>( aEvent );
262 wxDialog* dialog =
dynamic_cast<wxDialog*
>(
event.GetEventObject() );
268 if( event.IsShown() && dialog->IsModal() )
270 dlgs.push_back( dialog );
273 else if( !event.IsShown() && !dlgs.empty() )
276 if( dlgs.back() == dialog )
279 else if(
auto it = std::find( dlgs.begin(), dlgs.end(), dialog ); it != dlgs.end() )
280 dlgs.erase( it, dlgs.end() );
301 virtual bool OnExceptionInMainLoop()
override
325 void MacOpenFile(
const wxString& aFileName )
override
339 wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();
341 if( !wxIsAbsolutePath( absoluteArgv0 ) )
343 wxLogError( wxT(
"No meaningful argv[0]" ) );
354 const git_error* err = git_error_last();
355 wxString msg = wxS(
"Failed to initialize git library" );
357 if( err && err->message )
358 msg += wxS(
": " ) + wxString::FromUTF8( err->message );
371#if !defined(BUILD_KIWAY_DLL)
412 if( frame ==
nullptr )
419 Kiway.SetTop( frame );
427 App().SetTopWindow( frame );
443 std::vector<wxString> fileArgs;
446 static const wxCmdLineEntryDesc desc[] = {
447 { wxCMD_LINE_PARAM,
nullptr,
nullptr,
"File to load", wxCMD_LINE_VAL_STRING,
448 wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
449 { wxCMD_LINE_NONE,
nullptr,
nullptr,
nullptr, wxCMD_LINE_VAL_NONE, 0 }
452 wxCmdLineParser parser(
App().argc,
App().argv );
453 parser.SetDesc( desc );
454 parser.Parse(
false );
456 if( parser.GetParamCount() )
467 for(
size_t i = 0; i < parser.GetParamCount(); i++ )
468 fileArgs.push_back( parser.GetParam( i ) );
471 if( fileArgs.size() == 1 )
473 wxFileName argv1( fileArgs[0] );
475#if defined(PGM_DATA_FILE_EXT)
480 if( !argv1.GetExt() )
481 argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
483 argv1.MakeAbsolute();
485 fileArgs[0] = argv1.GetFullPath();
492 topFrame->PreloadLibraries( &
Kiway );
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
wxString GetAboutTitle() const
virtual bool OnInit() override
virtual void OnExit() override
wxDECLARE_DYNAMIC_CLASS(HtmlModule)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
static FACE_T KifaceType(FRAME_T aFrameType)
A simple mapping function which returns the FACE_T which is known to implement aFrameType.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
static const wxString & GetExecutablePath()
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual wxApp & App()
Return a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
void PreloadDesignBlockLibraries(KIWAY *aKiway)
Starts a background job to preload the global and project design block libraries.
virtual void MacOpenFile(const wxString &aFileName)=0
Specific to MacOSX (not used under Linux or Windows).
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
void HandleException(std::exception_ptr aPtr, bool aUnhandled=false)
A exception handler to be used at the top level if exceptions bubble up that for.
std::vector< void * > m_ModalDialogs
bool InitPgm(bool aHeadless=false, bool aIsUnitTest=false)
Initialize this program.
std::unique_ptr< KICAD_API_SERVER > m_api_server
void HandleAssert(const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg)
A common assert handler to be used between single_top and kicad.
virtual SETTINGS_MANAGER & GetSettingsManager() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
void CheckAndRun(wxWindow *parent)
This file is part of the common library.
void SetGitBackend(GIT_BACKEND *aBackend)
GIT_BACKEND * GetGitBackend()
KIFACE * KIFACE_GETTER_FUNC(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
Point to the one and only KIFACE export.
#define KFCTL_STANDALONE
Running as a standalone Top.
This file contains miscellaneous commonly used macros and functions.
void SetPgm(PGM_BASE *pgm)
PGM_BASE & Pgm()
The global program "get" accessor.
wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule)
KIWAY Kiway(KFCTL_STANDALONE)
Implement a bare naked wxApp (so that we don't become dependent on functionality in a wxApp derivativ...
void OnUnhandledException() override
int FilterEvent(wxEvent &aEvent) override
Implement a participant in the KIWAY alchemy.
Implement PGM_BASE with its own OnPgmInit() and OnPgmExit().
void MacOpenFile(const wxString &aFileName) override
Specific to MacOSX (not used under Linux or Windows).
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.