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() )
94 KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>(
App().GetTopWindow() );
120 virtual bool OnInit()
override { AddDependency( CLASSINFO( wxHtmlWinParser ) );
return true; };
156 catch(
const std::exception& e )
158 wxLogError( wxT(
"Unhandled exception class: %s what: %s" ),
163 wxLogError( ioe.
What() );
167 wxLogError( wxT(
"Unhandled exception of unknown type" ) );
178 return wxApp::OnExit();
187 ret = wxApp::OnRun();
189 catch(
const std::exception& e )
191 wxLogError( wxT(
"Unhandled exception class: %s what: %s" ),
196 wxLogError( ioe.
What() );
200 wxLogError( wxT(
"Unhandled exception of unknown type" ) );
208 if( aEvent.GetEventType() == wxEVT_SHOW )
210 wxShowEvent&
event = static_cast<wxShowEvent&>( aEvent );
211 wxDialog* dialog = dynamic_cast<wxDialog*>( event.GetEventObject() );
213 if( dialog && dialog->IsModal() )
214 Pgm().m_ModalDialogCount +=
event.IsShown() ? 1 : -1;
228 virtual bool OnExceptionInMainLoop()
override 234 catch(
const std::exception& e )
236 wxLogError( wxT(
"Unhandled exception class: %s what: %s" ),
242 wxLogError( ioe.
What() );
246 wxLogError( wxT(
"Unhandled exception of unknown type" ) );
261 void MacOpenFile(
const wxString& aFileName )
override 263 Pgm().MacOpenFile( aFileName );
277 if( !wxIsAbsolutePath( absoluteArgv0 ) )
279 wxLogError( wxT(
"No meaningful argv[0]" ) );
286 bool skip_python_initialization =
false;
287 #if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) ||\ 288 defined( PCB_CALCULATOR_BUILD ) 289 skip_python_initialization =
true;
292 if( !InitPgm(
false, skip_python_initialization ) )
299 #if !defined(BUILD_KIWAY_DLL) 318 static const wxCmdLineEntryDesc desc[] = {
319 { wxCMD_LINE_OPTION,
"f",
"frame",
"Frame to load", wxCMD_LINE_VAL_STRING, 0 },
320 { wxCMD_LINE_PARAM,
nullptr,
nullptr,
"File to load", wxCMD_LINE_VAL_STRING,
321 wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
322 { wxCMD_LINE_NONE,
nullptr,
nullptr,
nullptr, wxCMD_LINE_VAL_NONE, 0 }
325 wxCmdLineParser parser( App().argc, App().argv );
326 parser.SetDesc( desc );
327 parser.Parse(
false );
343 if( parser.Found( wxT(
"frame" ), &frameName ) )
347 for(
const auto& it : frameTypes )
349 if( it.name == frameName )
355 wxLogError( wxT(
"Unknown frame: %s" ), frameName );
370 if( frame ==
nullptr )
377 App().SetTopWindow( frame );
393 std::vector<wxString> fileArgs;
395 if( parser.GetParamCount() )
406 for(
size_t i = 0; i < parser.GetParamCount(); i++ )
407 fileArgs.push_back( parser.GetParam( i ) );
410 if( fileArgs.size() == 1 )
412 wxFileName argv1( fileArgs[0] );
414 #if defined(PGM_DATA_FILE_EXT) 419 if( !argv1.GetExt() )
420 argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
422 argv1.MakeAbsolute();
424 fileArgs[0] = argv1.GetFullPath();
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
BITMAP2CMP_SETTINGS kiface
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
void MacOpenFile(const wxString &aFileName) override
Specific to MacOSX (not used under Linux or Windows).
Struct PGM_SINGLE_TOP implements PGM_BASE with its own OnPgmInit() and OnPgmExit().
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
static FACE_T KifaceType(FRAME_T aFrameType)
A simple mapping function which returns the FACE_T which is known to implement aFrameType.
This file is part of the common library.
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
Container for data for KiCad programs.
#define KIFACE_VERSION
The KIWAY and KIFACE classes are used to communicate between various process modules,...
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
wxDECLARE_DYNAMIC_CLASS(HtmlModule)
virtual wxApp & App()
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
This file contains miscellaneous commonly used macros and functions.
bool set_kiface(FACE_T aFaceType, KIFACE *aKiface)
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()
KIFACE * KIFACE_GETTER_FUNC(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
Point to the one and only KIFACE export.
virtual bool OnInit() override
virtual void OnExit() override
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule)
void SetTop(wxFrame *aTop)
Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of ...
SETTINGS_MANAGER * GetSettingsManager()
virtual const wxString & GetExecutablePath() const
const wxString & GetAboutTitle() const
Implement a participant in the KIWAY alchemy.
int FilterEvent(wxEvent &aEvent) override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual void ParseArgs(wxCmdLineParser &aParser)
Handle command-line arguments in a frame-specific way.
Struct APP_SINGLE_TOP implements a bare naked wxApp (so that we don't become dependent on functionali...
#define KFCTL_STANDALONE
Running as a standalone Top.