38#include <wx/cmdline.h>
40#include <wx/filename.h>
41#include <wx/stdpaths.h>
42#include <wx/snglinst.h>
43#include <wx/html/htmlwin.h>
58#ifdef KICAD_USE_SENTRY
99 git_libgit2_shutdown();
104 wxFileName filename( aFileName );
106 if( filename.FileExists() )
118 blocking_win->Close(
true );
136 virtual bool OnInit()
override { AddDependency( CLASSINFO( wxHtmlWinParser ) );
return true; };
145void CustomAssertHandler(
const wxString& file,
147 const wxString& func,
148 const wxString& cond,
174 wxSizerFlags::DisableConsistencyChecks();
175 wxDISABLE_DEBUG_SUPPORT();
176 wxSetAssertHandler( CustomAssertHandler );
187 if( wxGetEnv( wxS(
"KICAD_ENABLE_WXTRACE" ),
nullptr ) )
189 wxLog::EnableLogging(
true );
190 wxLog::SetLogLevel( wxLOG_Trace );
216 return wxApp::OnExit();
225 ret = wxApp::OnRun();
237 if( aEvent.GetEventType() == wxEVT_SHOW )
239 wxShowEvent&
event =
static_cast<wxShowEvent&
>( aEvent );
240 wxDialog* dialog =
dynamic_cast<wxDialog*
>(
event.GetEventObject() );
246 if( event.IsShown() && dialog->IsModal() )
248 dlgs.push_back( dialog );
251 else if( !event.IsShown() && !dlgs.empty() )
254 if( dlgs.back() == dialog )
257 else if(
auto it = std::find( dlgs.begin(), dlgs.end(), dialog ) ; it != dlgs.end() )
258 dlgs.erase( it, dlgs.end() );
274 virtual bool OnExceptionInMainLoop()
override
297 void MacOpenFile(
const wxString& aFileName )
override
313 if( !wxIsAbsolutePath( absoluteArgv0 ) )
315 wxLogError( wxT(
"No meaningful argv[0]" ) );
325 bool skip_python_initialization =
false;
326#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) ||\
327 defined( PCB_CALCULATOR_BUILD )
328 skip_python_initialization =
true;
331 if( !InitPgm(
false, skip_python_initialization ) )
338#if !defined(BUILD_KIWAY_DLL)
364 m_api_server = std::make_unique<KICAD_API_SERVER>();
372 if( frame ==
nullptr )
381 App().SetTopWindow( frame );
394 std::vector<wxString> fileArgs;
397 static const wxCmdLineEntryDesc desc[] = {
398 { wxCMD_LINE_PARAM,
nullptr,
nullptr,
"File to load", wxCMD_LINE_VAL_STRING,
399 wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
400 { wxCMD_LINE_NONE,
nullptr,
nullptr,
nullptr, wxCMD_LINE_VAL_NONE, 0 }
403 wxCmdLineParser parser( App().argc, App().argv );
404 parser.SetDesc( desc );
405 parser.Parse(
false );
406 if( parser.GetParamCount() )
417 for(
size_t i = 0; i < parser.GetParamCount(); i++ )
418 fileArgs.push_back( parser.GetParam( i ) );
421 if( fileArgs.size() == 1 )
423 wxFileName argv1( fileArgs[0] );
425#if defined(PGM_DATA_FILE_EXT)
430 if( !argv1.GetExt() )
431 argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
433 argv1.MakeAbsolute();
435 fileArgs[0] = argv1.GetFullPath();
442 m_api_server->SetReadyToReply();
const 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...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
static FACE_T KifaceType(FRAME_T aFrameType)
A simple mapping function which returns the FACE_T which is known to implement aFrameType.
bool set_kiface(FACE_T aFaceType, KIFACE *aKiface)
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
void SetTop(wxFrame *aTop)
Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of ...
Container for data for KiCad programs.
virtual wxApp & App()
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
virtual void MacOpenFile(const wxString &aFileName)=0
Specific to MacOSX (not used under Linux or Windows).
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
std::vector< void * > m_ModalDialogs
void HandleException(std::exception_ptr aPtr)
A exception handler to be used at the top level if exceptions bubble up that for.
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 const wxString & GetExecutablePath() const
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
void SetKiway(KIWAY *aKiway)
Associate this setting manager with the given Kiway.
This file is part of the common library.
KIFACE * KIFACE_GETTER_FUNC(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
Point to the one and only KIFACE export.
#define KIFACE_VERSION
The KIWAY and KIFACE classes are used to communicate between various process modules,...
#define KFCTL_STANDALONE
Running as a standalone Top.
This file contains miscellaneous commonly used macros and functions.
SETTINGS_MANAGER * GetSettingsManager()
void SetPgm(PGM_BASE *pgm)
PGM_BASE & Pgm()
The global Program "get" accessor.
wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule)
KIWAY Kiway(KFCTL_STANDALONE)
Struct APP_SINGLE_TOP implements a bare naked wxApp (so that we don't become dependent on functionali...
int FilterEvent(wxEvent &aEvent) override
Implement a participant in the KIWAY alchemy.
Struct PGM_SINGLE_TOP implements 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)