43#include <wx/stdpaths.h>
83void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
96 m_top->Disconnect( wxEVT_DESTROY,
97 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
103 aTop->Connect( wxEVT_DESTROY,
104 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
127 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFaceId" ) );
128 return wxEmptyString;
143 if( wxGetEnv( wxT(
"APPDIR" ), &appDir ) )
144 path = appDir + wxT(
"/usr/bin/kicad" );
146 path = wxStandardPaths::Get().GetExecutablePath();
149 wxFileName fn =
path;
153 fn.AppendDir( wxT(
"Contents" ) );
154 fn.AppendDir( wxT(
"PlugIns" ) );
169 fn = wxStandardPaths::Get().GetExecutablePath();
175 fn.AppendDir( wxT(
"kicad" ) );
176 fn.AppendDir( wxT(
"kicad.app" ) );
177 fn.AppendDir( wxT(
"Contents" ) );
178 fn.AppendDir( wxT(
"PlugIns" ) );
187 default: dirName =
name + 1;
break;
192 if( !buildRoot.IsEmpty() )
193 fn.AssignDir( buildRoot );
197 fn.AppendDir( dirName );
204 fn.SetExt( &KIFACE_SUFFIX[1] );
206 return fn.GetFullPath();
220 if( (
unsigned) aFaceId >=
m_kiface.size() )
222 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFaceId" ) );
246 if( !buildRoot.IsEmpty() )
247 myPath.AssignDir( buildRoot );
249 myPath.Assign( wxStandardPaths::Get().GetExecutablePath() );
251 if( !myPath.GetPath().EndsWith( wxT(
"pcbnew" ) ) )
253 if( buildRoot.IsEmpty() )
254 myPath.RemoveLastDir();
256 myPath.AppendDir( wxT(
"pcbnew" ) );
261#ifdef KICAD_WIN32_VERIFY_CODESIGN
266 wxLogError(
_(
"Failed to verify kiface library '%s' signature." ), dname );
272 wxDynamicLibrary dso;
273 void* addr =
nullptr;
279 int lc_new_type = LC_COLLATE;
280 std::string user_locale = setlocale( lc_new_type,
nullptr );
281 setlocale( lc_new_type,
"C" );
283 bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
285 setlocale( lc_new_type, user_locale.c_str() );
292 wxLogError(
_(
"Failed to load kiface library '%s'." ), dname );
298 wxLogError(
_(
"Could not read instance name and version from kiface library '%s'." ), dname );
309 wxASSERT_MSG(
kiface, wxT(
"attempted DSO has a bug, failed to return a KIFACE*" ) );
311 wxDllType dsoHandle = dso.Detach();
313 bool startSuccess =
false;
340 dso.Attach( dsoHandle );
393 if( storedId == wxID_NONE )
396 wxWindow* frame = wxWindow::FindWindowById( storedId );
401 m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
413 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFrameType" ) );
427 wxString msg = wxString::Format(
"Creating window type %d", aFrameType );
437 wxLogError(
_(
"Application cannot start." ) );
458 wxLogError(
_(
"Error loading editor." ) );
472 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFrameType" ) );
478 if( frame ==
nullptr )
481 wxString msg = wxString::Format(
"Closing window type %d", aFrameType );
512 wxWindow* aSource,
bool aFromOtherThread )
514 std::unique_ptr<KIWAY_MAIL_EVENT> mail =
515 std::make_unique<KIWAY_MAIL_EVENT>( aDestination, aCommand, aPayload, aSource );
517 if( aFromOtherThread )
527 aActions.push_back( action );
548 for(
unsigned ii = 0;
LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
562 wxString::Format(
_(
"Unable to switch language to %s" ), lang ),
584 top->ShowChangedLanguage();
585 wxCommandEvent e( EDA_LANG_CHANGED );
586 top->GetEventHandler()->ProcessEvent( e );
598 wxCommandEvent e( EDA_LANG_CHANGED );
619 top->CommonSettingsChanged( aFlags );
625 sch->PreloadLibraries(
this );
628 pcb->PreloadLibraries(
this );
651 top->ClearFileHistory();
683 top->ProjectChanged();
690 schface->ProjectChanged();
693 pcbface->ProjectChanged();
759 alive->GetEventHandler()->QueueEvent( aEvent );
773 aReporter->
Report( wxString::Format(
_(
"Failed to load kiface library '%s'." ),
dso_search_path( aFace ) ),
780 return kiface->HandleJob( job, aReporter, aProgressReporter );
788 return kiface &&
kiface->HandleJobConfig( aJob, aWindow );
800 *aError = wxS(
"Failed to load requested face" );
805 return kiface->HandleApiOpenDocument( aSpec, aServer, aError );
817 *aError = wxS(
"Failed to load requested face" );
822 return kiface->HandleApiCloseDocument( aSpec, aServer, aError );
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
The base frame for deriving all KiCad main window classes.
bool NonUserClose(bool aForce)
virtual void ProjectChanged()
Notification event that the project has changed.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
virtual void ClearFileHistory()
Remove all files from the file history.
An simple container class that lets us dispatch output jobs to kifaces.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
FRAME_T Dest()
Return the destination player id of the message.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent)
Receive KIWAY_MAIL_EVENT messages from other players.
bool ProcessJobConfigDialog(KIWAY::FACE_T aFace, JOB *aJob, wxWindow *aWindow)
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual const wxString dso_search_path(FACE_T aFaceId)
Get the [path &] name of the DSO holding the requested FACE_T.
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
void SetBlockingDialog(wxWindow *aWin)
LOCAL_HISTORY * m_local_history
virtual bool PlayerClose(FRAME_T aFrameType, bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed,...
static FACE_T KifaceType(FRAME_T aFrameType)
A simple mapping function which returns the FACE_T which is known to implement aFrameType.
wxWindowID m_blockingDialog
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
static std::array< KIFACE *, KIWAY_FACE_COUNT > m_kiface
std::array< bool, KIWAY_FACE_COUNT > m_kifaceLoadFailed
void ClearFileHistory()
Clear the wxWidgets file history on each open frame.
bool ProcessApiOpenDocument(KIWAY::FACE_T aFace, const KIFACE::DOCUMENT_SPEC &aSpec, KICAD_API_SERVER *aServer, wxString *aError=nullptr)
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all KIWAY_PLAYER objects.
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
FACE_T
Known KIFACE implementations.
KIWAY_PLAYER * GetPlayerFrame(FRAME_T aFrameType)
bool ProcessEvent(wxEvent &aEvent) override
static std::array< int, KIWAY_FACE_COUNT > m_kiface_version
virtual bool PlayersClose(bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on all the windows and if none are vetoed,...
bool ProcessApiCloseDocument(KIWAY::FACE_T aFace, const KIFACE::DOCUMENT_SPEC &aSpec, KICAD_API_SERVER *aServer, wxString *aError=nullptr)
std::atomic< wxWindowID > m_playerFrameId[KIWAY_PLAYER_COUNT]
KIWAY(int aCtlBits, wxFrame *aTop=nullptr)
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
void QueueEvent(wxEvent *aEvent) override
void PlayerDidClose(FRAME_T aFrameType)
Notifies a Kiway that a player has been closed.
virtual void GetActions(std::vector< TOOL_ACTION * > &aActions) const
Append all registered actions to the given list.
void SetTop(wxFrame *aTop)
Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of ...
virtual void ProjectChanged()
Calls ProjectChanged() on all KIWAY_PLAYERs.
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Simple local history manager built on libgit2.
void ClearAllSavers()
Clear all registered savers.
static bool RunningFromBuildDir()
True when KiCad runs from its build tree or KICAD_RUN_FROM_BUILD_DIR is set.
static const wxString & GetBuildRoot()
The build root of the running executable, or empty outside a KiCad build tree.
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.
virtual void SetLanguageIdentifier(int menu_id)
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal me...
virtual const wxString & GetExecutablePath() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
virtual bool SetLanguage(wxString &aErrMsg, bool first_time=false)
Set the dictionary file name for internationalization.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
void SyncGlobalFieldNameTemplatesToProjects()
Synchronize the global field name templates into every loaded project.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
A logger class that filters out all log messages that are not generated by wxLogTrace and ignores the...
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
@ FRAME_SCH_SYMBOL_EDITOR
@ FRAME_FOOTPRINT_CHOOSER
#define KFCTL_CPP_PROJECT_SUITE
Running under C++ project mgr, possibly with others.
KIFACE * KIFACE_GETTER_FUNC(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
Point to the one and only KIFACE export.
#define KIFACE_INSTANCE_NAME_AND_VERSION
#define KFCTL_STANDALONE
Running as a standalone Top.
This file contains miscellaneous commonly used macros and functions.
MAIL_T
The set of mail types sendable via KIWAY::ExpressMail() and supplied as the aCommand parameter to tha...
void AddNavigationBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a navigation breadcrumb.
static const int ERR_UNKNOWN
PGM_BASE & Pgm()
The global program "get" accessor.
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Implement a participant in the KIWAY alchemy.
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
KIBIS top(path, &reporter)