38#include <wx/cmdline.h>
39#include <wx/filename.h>
40#include <wx/stdpaths.h>
41#include <wx/snglinst.h>
42#include <wx/html/htmlwin.h>
87 wxFileName filename( aFileName );
89 if( filename.FileExists() )
101 blocking_win->Close(
true );
125 virtual bool OnInit()
override { AddDependency( CLASSINFO( wxHtmlWinParser ) );
return true; };
161 catch(
const std::exception& e )
163 wxLogError( wxT(
"Unhandled exception class: %s what: %s" ),
168 wxLogError( ioe.
What() );
172 wxLogError( wxT(
"Unhandled exception of unknown type" ) );
183 return wxApp::OnExit();
192 ret = wxApp::OnRun();
194 catch(
const std::exception& e )
196 wxLogError( wxT(
"Unhandled exception class: %s what: %s" ),
201 wxLogError( ioe.
What() );
205 wxLogError( wxT(
"Unhandled exception of unknown type" ) );
213 if( aEvent.GetEventType() == wxEVT_SHOW )
215 wxShowEvent&
event =
static_cast<wxShowEvent&
>( aEvent );
216 wxDialog* dialog =
dynamic_cast<wxDialog*
>(
event.GetEventObject() );
218 std::vector<void*>& dlgs =
Pgm().m_ModalDialogs;
222 if( event.IsShown() && dialog->IsModal() )
224 dlgs.push_back( dialog );
227 else if( !event.IsShown() && !dlgs.empty() )
230 if( dlgs.back() == dialog )
233 else if(
auto it = std::find( dlgs.begin(), dlgs.end(), dialog ) ; it != dlgs.end() )
234 dlgs.erase( it, dlgs.end() );
250 virtual bool OnExceptionInMainLoop()
override
256 catch(
const std::exception& e )
258 wxLogError(
"Unhandled exception class: %s what: %s",
264 wxLogError( ioe.
What() );
268 wxLogError(
"Unhandled exception of unknown type" );
283 void MacOpenFile(
const wxString& aFileName )
override
285 Pgm().MacOpenFile( aFileName );
299 if( !wxIsAbsolutePath( absoluteArgv0 ) )
301 wxLogError( wxT(
"No meaningful argv[0]" ) );
308 bool skip_python_initialization =
false;
309#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) ||\
310 defined( PCB_CALCULATOR_BUILD )
311 skip_python_initialization =
true;
314 if( !InitPgm(
false, skip_python_initialization ) )
321#if !defined(BUILD_KIWAY_DLL)
348 if( frame ==
nullptr )
355 App().SetTopWindow( frame );
367 std::vector<wxString> fileArgs;
370 static const wxCmdLineEntryDesc desc[] = {
371 { wxCMD_LINE_PARAM,
nullptr,
nullptr,
"File to load", wxCMD_LINE_VAL_STRING,
372 wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
373 { wxCMD_LINE_NONE,
nullptr,
nullptr,
nullptr, wxCMD_LINE_VAL_NONE, 0 }
376 wxCmdLineParser parser( App().argc, App().argv );
377 parser.SetDesc( desc );
378 parser.Parse(
false );
379 if( parser.GetParamCount() )
390 for(
size_t i = 0; i < parser.GetParamCount(); i++ )
391 fileArgs.push_back( parser.GetParam( i ) );
394 if( fileArgs.size() == 1 )
396 wxFileName argv1( fileArgs[0] );
398#if defined(PGM_DATA_FILE_EXT)
403 if( !argv1.GetExt() )
404 argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
406 argv1.MakeAbsolute();
408 fileArgs[0] = argv1.GetFullPath();
const wxString & GetAboutTitle() const
virtual bool OnInit() override
virtual void OnExit() override
wxDECLARE_DYNAMIC_CLASS(HtmlModule)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
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.
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
virtual const wxString & GetExecutablePath() const
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
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.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
SETTINGS_MANAGER * GetSettingsManager()
wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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).