43#include <wx/stdpaths.h>
48#ifdef KICAD_USE_SENTRY
58 m_program( aProgram ), m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
80void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
93 m_top->Disconnect( wxEVT_DESTROY,
94 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
100 aTop->Connect( wxEVT_DESTROY,
101 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
126 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFaceId" ) );
127 return wxEmptyString;
137 path = wxStandardPaths::Get().GetExecutablePath();
140 wxFileName fn =
path;
143 wxFileName fn =
Pgm().GetExecutablePath();
144 fn.AppendDir( wxT(
"Contents" ) );
145 fn.AppendDir( wxT(
"PlugIns" ) );
154 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
161 fn = wxStandardPaths::Get().GetExecutablePath();
167 fn.AppendDir( wxT(
"kicad" ) );
168 fn.AppendDir( wxT(
"kicad.app" ) );
169 fn.AppendDir( wxT(
"Contents" ) );
170 fn.AppendDir( wxT(
"PlugIns" ) );
180 default: dirName =
name + 1;
break;
184 fn.AppendDir( dirName );
190 fn.SetExt( &KIFACE_SUFFIX[1] );
192 return fn.GetFullPath();
198 return Pgm().GetSettingsManager().
Prj();
211 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFaceId" ) );
225 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
227 wxFileName myPath = wxStandardPaths::Get().GetExecutablePath();
229 if( !myPath.GetPath().EndsWith( wxT(
"pcbnew" ) ) )
231 myPath.RemoveLastDir();
232 myPath.AppendDir( wxT(
"pcbnew" ) );
239#ifdef KICAD_WIN32_VERIFY_CODESIGN
243 msg.Printf(
_(
"Failed to verify kiface library '%s' signature." ), dname );
248 wxDynamicLibrary dso;
250 void* addr =
nullptr;
256 int lc_new_type = LC_COLLATE;
257 std::string user_locale = setlocale( lc_new_type,
nullptr );
258 setlocale( lc_new_type,
"C" );
260 bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
262 setlocale( lc_new_type, user_locale.c_str() );
264#ifdef KICAD_USE_SENTRY
265 if(
Pgm().IsSentryOptedIn() )
267 msg = wxString::Format(
"Loading kiface %d", aFaceId );
268 sentry_value_t crumb = sentry_value_new_breadcrumb(
"navigation", msg.utf8_str() );
269 sentry_value_set_by_key( crumb,
"category", sentry_value_new_string(
"kiway.kiface" ) );
270 sentry_value_set_by_key( crumb,
"level", sentry_value_new_string(
"info" ) );
271 sentry_add_breadcrumb( crumb );
283 msg.Printf(
_(
"Failed to load kiface library '%s'." ), dname );
291 msg.Printf(
_(
"Could not read instance name and version from kiface library '%s'." ),
303 wxT(
"attempted DSO has a bug, failed to return a KIFACE*" ) );
305 wxDllType dsoHandle = dso.Detach();
307 bool startSuccess =
false;
321 Pgm().HandleException( std::current_exception() );
333 dso.Attach( dsoHandle );
347 msg = wxString::Format(
_(
"Fatal Installation Bug. File:\n"
348 "'%s'\ncould not be loaded\n" ), dname );
350 if( ! wxFileExists( dname ) )
351 msg <<
_(
"It is missing.\n" );
353 msg <<
_(
"Perhaps a shared library (.dll or .so) file is missing.\n" );
355 msg <<
_(
"From command line: argv[0]:\n'" );
356 msg << wxStandardPaths::Get().GetExecutablePath() << wxT(
"'\n" );
418 if( storedId == wxID_NONE )
421 wxWindow* frame = wxWindow::FindWindowById( storedId );
426 m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
441 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFrameType" ) );
455#ifdef KICAD_USE_SENTRY
456 if(
Pgm().IsSentryOptedIn() )
458 wxString msg = wxString::Format(
"Creating window type %d", aFrameType );
459 sentry_value_t crumb = sentry_value_new_breadcrumb(
"navigation", msg.utf8_str() );
460 sentry_value_set_by_key( crumb,
"category",
461 sentry_value_new_string(
"kiway.player" ) );
462 sentry_value_set_by_key( crumb,
"level", sentry_value_new_string(
"info" ) );
463 sentry_add_breadcrumb( crumb );
487 Pgm().HandleException( std::current_exception() );
488 wxLogError(
_(
"Error loading editor." ) );
505 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFrameType" ) );
511 if( frame ==
nullptr )
514#ifdef KICAD_USE_SENTRY
515 if(
Pgm().IsSentryOptedIn() )
517 wxString msg = wxString::Format(
"Closing window type %d", aFrameType );
518 sentry_value_t crumb = sentry_value_new_breadcrumb(
"navigation", msg.utf8_str() );
519 sentry_value_set_by_key( crumb,
"category",
520 sentry_value_new_string(
"kiway.playerclose" ) );
521 sentry_value_set_by_key( crumb,
"level", sentry_value_new_string(
"info" ) );
522 sentry_add_breadcrumb( crumb );
556 KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
565 aActions.push_back( action );
578 Pgm().SetLanguageIdentifier( aLanguage );
600 wxString::Format(
_(
"Unable to switch language to %s" ), lang ),
662#ifdef KICAD_USE_SENTRY
663 sentry_value_t crumb = sentry_value_new_breadcrumb(
"navigation",
"Changing project" );
664 sentry_value_set_by_key( crumb,
"category", sentry_value_new_string(
"kiway.projectchanged" ) );
665 sentry_value_set_by_key( crumb,
"level", sentry_value_new_string(
"info" ) );
666 sentry_add_breadcrumb( crumb );
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
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 ShowChangedLanguage() override
Redraw the menus and what not in current language.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
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_EXPRESS &aEvent)
Receive KIWAY_EXPRESS messages from other players.
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
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 *job)
void SetBlockingDialog(wxWindow *aWin)
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
KIWAY(PGM_BASE *aProgram, int aCtlBits, wxFrame *aTop=nullptr)
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
static KIFACE * m_kiface[KIWAY_FACE_COUNT]
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
FACE_T
Known KIFACE implementations.
static int m_kiface_version[KIWAY_FACE_COUNT]
KIWAY_PLAYER * GetPlayerFrame(FRAME_T aFrameType)
bool ProcessEvent(wxEvent &aEvent) override
virtual bool PlayersClose(bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on all the windows and if none are vetoed,...
std::atomic< wxWindowID > m_playerFrameId[KIWAY_PLAYER_COUNT]
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
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.
Container for data for KiCad programs.
Container for project specific data.
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_FOOTPRINT_VIEWER_MODAL
@ FRAME_SCH_SYMBOL_EDITOR
#define THROW_IO_ERROR(msg)
#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 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.
MAIL_T
The set of mail types sendable via KIWAY::ExpressMail() and supplied as the aCommand parameter to tha...
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Typically start_common() is called from here.
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
Implement a participant in the KIWAY alchemy.
virtual int HandleJob(JOB *aJob)
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
wxString m_Lang_Label
Labels used in menus.
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)