41 #include <wx/dynlib.h> 42 #include <wx/stdpaths.h> 53 m_program(
aProgram ), m_ctl( aCtlBits ), m_top( nullptr )
75 void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
88 m_top->Disconnect( wxEVT_DESTROY,
89 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
95 aTop->Connect( wxEVT_DESTROY,
96 wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
121 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFaceId" ) );
122 return wxEmptyString;
132 path = wxStandardPaths::Get().GetExecutablePath();
135 wxFileName fn =
path;
138 wxFileName fn =
Pgm().GetExecutablePath();
139 fn.AppendDir( wxT(
"Contents" ) );
140 fn.AppendDir( wxT(
"PlugIns" ) );
149 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
156 fn = wxStandardPaths::Get().GetExecutablePath();
162 fn.AppendDir( wxT(
"kicad" ) );
163 fn.AppendDir( wxT(
"kicad.app" ) );
164 fn.AppendDir( wxT(
"Contents" ) );
165 fn.AppendDir( wxT(
"PlugIns" ) );
175 default: dirName =
name + 1;
break;
179 fn.AppendDir( dirName );
185 fn.SetExt( &KIFACE_SUFFIX[1] );
187 return fn.GetFullPath();
193 return Pgm().GetSettingsManager().
Prj();
206 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFaceId" ) );
222 if( wxGetEnv( wxT(
"KICAD_RUN_FROM_BUILD_DIR" ),
nullptr ) )
224 wxFileName myPath = wxStandardPaths::Get().GetExecutablePath();
226 if( !myPath.GetPath().EndsWith( wxT(
"pcbnew" ) ) )
228 myPath.RemoveLastDir();
229 myPath.AppendDir( wxT(
"pcbnew" ) );
234 #ifdef KICAD_WIN32_VERIFY_CODESIGN 238 msg.Printf(
_(
"Failed to verify kiface library '%s' signature." ), dname );
243 wxDynamicLibrary dso;
245 void* addr =
nullptr;
251 int lc_new_type = LC_COLLATE;
252 std::string user_locale = setlocale( lc_new_type,
nullptr );
253 setlocale( lc_new_type,
"C" );
255 bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
257 setlocale( lc_new_type, user_locale.c_str() );
267 msg.Printf(
_(
"Failed to load kiface library '%s'." ), dname );
275 msg.Printf(
_(
"Could not read instance name and version from kiface library '%s'." ),
287 wxT(
"attempted DSO has a bug, failed to return a KIFACE*" ) );
309 "'%s'\ncould not be loaded\n" ), dname );
311 if( ! wxFileExists( dname ) )
312 msg <<
_(
"It is missing.\n" );
314 msg <<
_(
"Perhaps a shared library (.dll or .so) file is missing.\n" );
316 msg <<
_(
"From command line: argv[0]:\n'" );
317 msg << wxStandardPaths::Get().GetExecutablePath() << wxT(
"'\n" );
379 if( storedId == wxID_NONE )
382 wxWindow* frame = wxWindow::FindWindowById( storedId );
387 m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
389 return static_cast<KIWAY_PLAYER*>( frame );
402 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFrameType" ) );
435 catch(
const std::exception& e)
458 wxASSERT_MSG( 0, wxT(
"caller has a bug, passed a bad aFrameType" ) );
464 if( frame ==
nullptr )
490 KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
505 Pgm().SetLanguageIdentifier( aLanguage );
612 KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
#define KFCTL_CPP_PROJECT_SUITE
Running under C++ project mgr, possibly with others.
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
BITMAP2CMP_SETTINGS kiface
virtual bool PlayersClose(bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on all the windows and if none are vetoed,...
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
std::atomic< wxWindowID > m_playerFrameId[KIWAY_PLAYER_COUNT]
Container for project specific data.
static FACE_T KifaceType(FRAME_T aFrameType)
A simple mapping function which returns the FACE_T which is known to implement aFrameType.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
KIWAY_PLAYER * GetPlayerFrame(FRAME_T aFrameType)
This file is part of the common library.
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.
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
#define KIFACE_INSTANCE_NAME_AND_VERSION
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...
virtual const wxString What() const
A composite of Problem() and Where()
bool NonUserClose(bool aForce)
virtual bool PlayerClose(FRAME_T aFrameType, bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed,...
bool ProcessEvent(wxEvent &aEvent) override
KIFACE * KIFACE_GETTER_FUNC(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
Point to the one and only KIFACE export.
virtual void ProjectChanged()
Calls ProjectChanged() on all KIWAY_PLAYERs.
virtual void KiwayMailIn(KIWAY_EXPRESS &aEvent)
Receive KIWAY_EXPRESS messages from other players.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
const wxString dso_search_path(FACE_T aFaceId)
Get the [path &] name of the DSO holding the requested FACE_T.
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
wxString m_Lang_Label
Labels used in menus.
void SetTop(wxFrame *aTop)
Tell this KIWAY about the top most frame in the program and optionally allows it to play the role of ...
A logger class that filters out all log messages that are not generated by wxLogTrace and ignores the...
FACE_T
Known KIFACE implementations.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
FRAME_T Dest()
Return the destination player id of the message.
The base frame for deriving all KiCad main window classes.
Implement a participant in the KIWAY alchemy.
KIWAY(PGM_BASE *aProgram, int aCtlBits, wxFrame *aTop=nullptr)
void ignore_unused(const T &)
static int m_kiface_version[KIWAY_FACE_COUNT]
virtual void ProjectChanged()
Notification event that the project has changed.
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
#define THROW_IO_ERROR(msg)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
static KIFACE * m_kiface[KIWAY_FACE_COUNT]
#define KFCTL_STANDALONE
Running as a standalone Top.