2014-02-03 15:10:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2023-03-19 11:30:53 +00:00
|
|
|
* Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
2014-02-03 15:10:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2019-12-05 14:03:15 +00:00
|
|
|
#include <cstring>
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2023-04-19 02:44:04 +00:00
|
|
|
#include <core/ignore.h>
|
2014-04-19 18:47:20 +00:00
|
|
|
#include <macros.h>
|
2014-02-03 15:10:37 +00:00
|
|
|
#include <kiway.h>
|
2014-04-19 18:47:20 +00:00
|
|
|
#include <kiway_player.h>
|
2014-04-21 06:28:17 +00:00
|
|
|
#include <kiway_express.h>
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
#include <pgm_base.h>
|
2014-02-03 19:26:18 +00:00
|
|
|
#include <config.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
#include <id.h>
|
2021-03-21 13:16:47 +00:00
|
|
|
#include <kiplatform/app.h>
|
2022-03-13 00:12:34 +00:00
|
|
|
#include <kiplatform/environment.h>
|
2020-05-25 17:38:09 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <tool/action_manager.h>
|
2020-09-01 22:41:06 +00:00
|
|
|
#include <logging.h>
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2021-06-09 01:35:02 +00:00
|
|
|
#include <wx/dynlib.h>
|
2014-05-04 00:44:57 +00:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
#include <wx/debug.h>
|
2019-04-20 19:08:34 +00:00
|
|
|
#include <wx/utils.h>
|
2020-07-13 20:21:34 +00:00
|
|
|
#include <confirm.h>
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2023-04-21 03:01:31 +00:00
|
|
|
#ifdef KICAD_USE_SENTRY
|
|
|
|
#include <sentry.h>
|
|
|
|
#endif
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
|
|
|
|
int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];
|
|
|
|
|
|
|
|
|
2014-04-21 14:49:33 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):
|
2022-07-12 21:44:53 +00:00
|
|
|
m_program( aProgram ), m_ctl( aCtlBits ), m_top( nullptr ), m_blockingDialog( wxID_NONE )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
SetTop( aTop ); // hook player_destroy_handler() into aTop.
|
2014-04-19 19:44:59 +00:00
|
|
|
|
2021-07-02 19:07:26 +00:00
|
|
|
// Set the array of all known frame window IDs to empty = wxID_NONE,
|
|
|
|
// once they are be created, they are added with FRAME_T as index to this array.
|
|
|
|
// Note: A non empty entry does not mean the frame still exists.
|
|
|
|
// It means only the frame was created at least once. It can be destroyed after.
|
|
|
|
// These entries are not cleared automatically on window closing. The purpose is just
|
|
|
|
// to allow a call to wxWindow::FindWindowById() using a FRAME_T frame type
|
|
|
|
for( int n = 0; n < KIWAY_PLAYER_COUNT; n++ )
|
|
|
|
m_playerFrameId[n] = wxID_NONE;
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2016-03-21 16:36:06 +00:00
|
|
|
#if 0
|
2014-04-19 19:44:59 +00:00
|
|
|
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
|
2016-06-10 17:47:19 +00:00
|
|
|
// propagated upwards to parent windows if not handled below. Therefore the
|
2014-04-20 04:35:34 +00:00
|
|
|
// m_top window should receive all wxWindowDestroyEvents originating from
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// KIWAY_PLAYERs. It does anyways, but now player_destroy_handler eavesdrops
|
2014-04-19 19:44:59 +00:00
|
|
|
// on that event stream looking for KIWAY_PLAYERs being closed.
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
|
2014-04-19 19:44:59 +00:00
|
|
|
{
|
2016-03-21 16:36:06 +00:00
|
|
|
// Currently : do nothing
|
2014-07-17 14:10:15 +00:00
|
|
|
event.Skip(); // skip to who, the wxApp? I'm the top window.
|
2014-04-19 19:44:59 +00:00
|
|
|
}
|
2016-03-21 16:36:06 +00:00
|
|
|
#endif
|
2014-04-19 19:44:59 +00:00
|
|
|
|
2016-06-10 17:47:19 +00:00
|
|
|
|
2014-04-19 19:44:59 +00:00
|
|
|
void KIWAY::SetTop( wxFrame* aTop )
|
|
|
|
{
|
2016-03-21 16:36:06 +00:00
|
|
|
#if 0
|
2014-04-19 19:44:59 +00:00
|
|
|
if( m_top )
|
|
|
|
{
|
2021-07-15 19:26:35 +00:00
|
|
|
m_top->Disconnect( wxEVT_DESTROY,
|
|
|
|
wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
|
|
|
|
nullptr, this );
|
2014-04-19 19:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( aTop )
|
|
|
|
{
|
2021-07-15 19:26:35 +00:00
|
|
|
aTop->Connect( wxEVT_DESTROY,
|
|
|
|
wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
|
|
|
|
nullptr, this );
|
2014-04-19 19:44:59 +00:00
|
|
|
}
|
2016-03-21 16:36:06 +00:00
|
|
|
#endif
|
2014-04-19 19:44:59 +00:00
|
|
|
|
|
|
|
m_top = aTop;
|
|
|
|
}
|
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2016-09-20 15:59:43 +00:00
|
|
|
const wxString KIWAY::dso_search_path( FACE_T aFaceId )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2016-09-20 15:59:43 +00:00
|
|
|
const char* name;
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
switch( aFaceId )
|
|
|
|
{
|
2016-09-20 15:59:43 +00:00
|
|
|
case FACE_SCH: name = KIFACE_PREFIX "eeschema"; break;
|
|
|
|
case FACE_PCB: name = KIFACE_PREFIX "pcbnew"; break;
|
|
|
|
case FACE_CVPCB: name = KIFACE_PREFIX "cvpcb"; break;
|
|
|
|
case FACE_GERBVIEW: name = KIFACE_PREFIX "gerbview"; break;
|
|
|
|
case FACE_PL_EDITOR: name = KIFACE_PREFIX "pl_editor"; break;
|
|
|
|
case FACE_PCB_CALCULATOR: name = KIFACE_PREFIX "pcb_calculator"; break;
|
|
|
|
case FACE_BMP2CMP: name = KIFACE_PREFIX "bitmap2component"; break;
|
2021-03-08 14:54:22 +00:00
|
|
|
case FACE_PYTHON: name = KIFACE_PREFIX "kipython"; break;
|
2014-02-03 15:10:37 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2022-01-31 23:57:56 +00:00
|
|
|
#ifndef __WXMAC__
|
2016-09-20 15:59:43 +00:00
|
|
|
wxString path;
|
|
|
|
|
|
|
|
if( m_ctl & (KFCTL_STANDALONE | KFCTL_CPP_PROJECT_SUITE) )
|
|
|
|
{
|
|
|
|
// The 2 *.cpp program launchers: single_top.cpp and kicad.cpp expect
|
2019-08-20 17:22:30 +00:00
|
|
|
// the *.kiface's to reside in same directory as their binaries do.
|
2016-09-20 15:59:43 +00:00
|
|
|
path = wxStandardPaths::Get().GetExecutablePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxFileName fn = path;
|
2014-10-17 17:45:33 +00:00
|
|
|
#else
|
|
|
|
// we have the dso's in main OSX bundle kicad.app/Contents/PlugIns
|
|
|
|
wxFileName fn = Pgm().GetExecutablePath();
|
|
|
|
fn.AppendDir( wxT( "Contents" ) );
|
|
|
|
fn.AppendDir( wxT( "PlugIns" ) );
|
2014-10-08 18:41:36 +00:00
|
|
|
#endif
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
fn.SetName( name );
|
|
|
|
|
2019-04-20 19:08:34 +00:00
|
|
|
// To speed up development, it's sometimes nice to run kicad from inside
|
|
|
|
// the build path. In that case, each program will be in a subdirectory.
|
2019-10-03 17:27:23 +00:00
|
|
|
// To find the DSOs, we need to go up one directory and then enter a subdirectory.
|
2019-04-20 19:08:34 +00:00
|
|
|
|
|
|
|
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
|
|
|
|
{
|
2022-01-31 23:57:56 +00:00
|
|
|
#ifdef __WXMAC__
|
2021-04-29 03:21:19 +00:00
|
|
|
// On Mac, all of the kifaces are placed in the kicad.app bundle, even though the individual
|
|
|
|
// standalone binaries are placed in separate bundles before the make install step runs.
|
|
|
|
// So, we have to jump up to the kicad directory, then the PlugIns section of the kicad
|
|
|
|
// bundle.
|
2019-04-29 02:59:51 +00:00
|
|
|
fn = wxStandardPaths::Get().GetExecutablePath();
|
2021-04-29 03:21:19 +00:00
|
|
|
|
|
|
|
fn.RemoveLastDir();
|
|
|
|
fn.RemoveLastDir();
|
|
|
|
fn.RemoveLastDir();
|
2019-04-29 02:59:51 +00:00
|
|
|
fn.RemoveLastDir();
|
2021-04-29 03:21:19 +00:00
|
|
|
fn.AppendDir( wxT( "kicad" ) );
|
|
|
|
fn.AppendDir( wxT( "kicad.app" ) );
|
|
|
|
fn.AppendDir( wxT( "Contents" ) );
|
2019-04-29 02:59:51 +00:00
|
|
|
fn.AppendDir( wxT( "PlugIns" ) );
|
|
|
|
fn.SetName( name );
|
|
|
|
#else
|
2019-12-06 04:05:21 +00:00
|
|
|
const char* dirName;
|
|
|
|
|
|
|
|
// The subdirectories usually have the same name as the kiface
|
|
|
|
switch( aFaceId )
|
|
|
|
{
|
|
|
|
case FACE_PL_EDITOR: dirName = "pagelayout_editor"; break;
|
2021-04-23 22:59:06 +00:00
|
|
|
case FACE_PYTHON: dirName = "scripting"; break;
|
2019-12-06 04:05:21 +00:00
|
|
|
default: dirName = name + 1; break;
|
|
|
|
}
|
|
|
|
|
2019-04-20 19:08:34 +00:00
|
|
|
fn.RemoveLastDir();
|
2019-10-03 17:27:23 +00:00
|
|
|
fn.AppendDir( dirName );
|
2019-04-29 02:59:51 +00:00
|
|
|
#endif
|
2019-04-20 19:08:34 +00:00
|
|
|
}
|
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
// Here a "suffix" == an extension with a preceding '.',
|
|
|
|
// so skip the preceding '.' to get an extension
|
2020-11-25 00:08:09 +00:00
|
|
|
fn.SetExt( &KIFACE_SUFFIX[1] );
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
return fn.GetFullPath();
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
PROJECT& KIWAY::Prj() const
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2020-05-25 17:38:09 +00:00
|
|
|
return Pgm().GetSettingsManager().Prj();
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
// Since this will be called from python, cannot assume that code will
|
|
|
|
// not pass a bad aFaceId.
|
2019-03-27 22:37:26 +00:00
|
|
|
if( (unsigned) aFaceId >= arrayDim( m_kiface ) )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
// @todo : throw an exception here for python's benefit, at least that
|
|
|
|
// way it gets some explanatory text.
|
2014-02-03 15:10:37 +00:00
|
|
|
|
|
|
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
|
2021-07-15 19:26:35 +00:00
|
|
|
return nullptr;
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
// return the previously loaded KIFACE, if it was.
|
|
|
|
if( m_kiface[aFaceId] )
|
|
|
|
return m_kiface[aFaceId];
|
|
|
|
|
|
|
|
// DSO with KIFACE has not been loaded yet, does caller want to load it?
|
2021-07-15 19:26:35 +00:00
|
|
|
if( doLoad )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2016-09-20 15:59:43 +00:00
|
|
|
wxString dname = dso_search_path( aFaceId );
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2021-03-21 13:16:47 +00:00
|
|
|
// Insert DLL search path for kicad_3dsg from build dir
|
|
|
|
if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
|
|
|
|
{
|
|
|
|
wxFileName myPath = wxStandardPaths::Get().GetExecutablePath();
|
|
|
|
|
|
|
|
if( !myPath.GetPath().EndsWith( wxT( "pcbnew" ) ) )
|
|
|
|
{
|
|
|
|
myPath.RemoveLastDir();
|
|
|
|
myPath.AppendDir( wxT( "pcbnew" ) );
|
|
|
|
KIPLATFORM::APP::AddDynamicLibrarySearchPath( myPath.GetPath() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-21 03:05:06 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2022-03-13 00:12:34 +00:00
|
|
|
#ifdef KICAD_WIN32_VERIFY_CODESIGN
|
|
|
|
bool codeSignOk = KIPLATFORM::ENV::VerifyFileSignature( dname );
|
|
|
|
if( !codeSignOk )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Failed to verify kiface library '%s' signature." ), dname );
|
|
|
|
THROW_IO_ERROR( msg );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
wxDynamicLibrary dso;
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void* addr = nullptr;
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2019-11-24 10:56:02 +00:00
|
|
|
// For some reason wxDynamicLibrary::Load() crashes in some languages
|
|
|
|
// (chinese for instance) when loading the dynamic library.
|
|
|
|
// The crash happens for Eeschema.
|
|
|
|
// So switch to "C" locale during loading (LC_COLLATE is enough).
|
|
|
|
int lc_new_type = LC_COLLATE;
|
|
|
|
std::string user_locale = setlocale( lc_new_type, nullptr );
|
|
|
|
setlocale( lc_new_type, "C" );
|
|
|
|
|
|
|
|
bool success = dso.Load( dname, wxDL_VERBATIM | wxDL_NOW | wxDL_GLOBAL );
|
|
|
|
|
|
|
|
setlocale( lc_new_type, user_locale.c_str() );
|
|
|
|
|
2023-04-21 03:01:31 +00:00
|
|
|
#ifdef KICAD_USE_SENTRY
|
2023-04-21 03:05:06 +00:00
|
|
|
if( Pgm().IsSentryOptedIn() )
|
|
|
|
{
|
|
|
|
msg = wxString::Format( "Loading kiface %d", aFaceId );
|
|
|
|
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
|
|
|
|
sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.kiface" ) );
|
|
|
|
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
|
|
|
|
sentry_add_breadcrumb( crumb );
|
|
|
|
}
|
2023-04-21 03:01:31 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-24 10:56:02 +00:00
|
|
|
if( !success )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-04-18 02:05:40 +00:00
|
|
|
// Failure: error reporting UI was done via wxLogSysError().
|
2016-06-10 17:47:19 +00:00
|
|
|
// No further reporting required here. Apparently this is not true on all
|
|
|
|
// platforms and/or wxWidgets builds and KiCad will crash. Throwing the exception
|
|
|
|
// here and catching it in the KiCad launcher resolves the crash issue. See bug
|
|
|
|
// report https://bugs.launchpad.net/kicad/+bug/1577786.
|
2014-02-03 15:10:37 +00:00
|
|
|
|
2021-06-27 23:26:54 +00:00
|
|
|
msg.Printf( _( "Failed to load kiface library '%s'." ), dname );
|
2016-06-10 17:47:19 +00:00
|
|
|
THROW_IO_ERROR( msg );
|
|
|
|
}
|
2021-07-15 19:26:35 +00:00
|
|
|
else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == nullptr )
|
2014-04-18 02:05:40 +00:00
|
|
|
{
|
|
|
|
// Failure: error reporting UI was done via wxLogSysError().
|
2016-06-10 17:47:19 +00:00
|
|
|
// No further reporting required here. Assume the same thing applies here as
|
|
|
|
// above with the Load() call. This has not been tested.
|
2021-06-27 23:26:54 +00:00
|
|
|
msg.Printf( _( "Could not read instance name and version from kiface library '%s'." ),
|
2020-11-12 20:19:22 +00:00
|
|
|
dname );
|
2016-06-10 17:47:19 +00:00
|
|
|
THROW_IO_ERROR( msg );
|
2014-04-18 02:05:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-15 21:56:13 +00:00
|
|
|
KIFACE_GETTER_FUNC* ki_getter = (KIFACE_GETTER_FUNC*) addr;
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2021-03-15 21:56:13 +00:00
|
|
|
KIFACE* kiface = ki_getter( &m_kiface_version[aFaceId], KIFACE_VERSION, m_program );
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
// KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
|
|
|
|
wxASSERT_MSG( kiface,
|
2016-06-10 17:47:19 +00:00
|
|
|
wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2023-04-20 00:38:12 +00:00
|
|
|
wxDllType dsoHandle = dso.Detach();
|
|
|
|
|
|
|
|
bool startSuccess = false;
|
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
// Give the DSO a single chance to do its "process level" initialization.
|
|
|
|
// "Process level" specifically means stay away from any projects in there.
|
2023-04-20 00:38:12 +00:00
|
|
|
|
|
|
|
try
|
2014-04-18 02:05:40 +00:00
|
|
|
{
|
2024-02-02 23:04:56 +00:00
|
|
|
startSuccess = kiface->OnKifaceStart( m_program, m_ctl, this );
|
2023-04-20 00:38:12 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
// OnKiFaceStart may generate an exception
|
|
|
|
// Before we continue and ultimately unload our module to retry we need
|
|
|
|
// to process the exception before we delete the free the memory space the exception resides in
|
|
|
|
Pgm().HandleException( std::current_exception() );
|
|
|
|
}
|
2014-04-18 02:05:40 +00:00
|
|
|
|
2023-04-20 00:38:12 +00:00
|
|
|
if( startSuccess )
|
|
|
|
{
|
2014-04-18 02:05:40 +00:00
|
|
|
return m_kiface[aFaceId] = kiface;
|
|
|
|
}
|
2023-03-19 11:30:53 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Usually means cancelled initial global library setup
|
2023-04-20 00:38:12 +00:00
|
|
|
// But it could have been an exception/failure
|
|
|
|
// Let the module go out of scope to unload
|
|
|
|
dso.Attach( dsoHandle );
|
2023-03-19 11:30:53 +00:00
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
2014-04-18 02:05:40 +00:00
|
|
|
|
|
|
|
// In any of the failure cases above, dso.Unload() should be called here
|
|
|
|
// by dso destructor.
|
2014-04-24 11:30:14 +00:00
|
|
|
// However:
|
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
// There is a file installation bug. We only look for KIFACE's which we know
|
2014-04-24 11:30:14 +00:00
|
|
|
// to exist, and we did not find one. If we do not find one, this is an
|
|
|
|
// installation bug.
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
msg = wxString::Format( _( "Fatal Installation Bug. File:\n"
|
2021-09-14 22:45:14 +00:00
|
|
|
"'%s'\ncould not be loaded\n" ), dname );
|
2015-03-26 17:27:13 +00:00
|
|
|
|
|
|
|
if( ! wxFileExists( dname ) )
|
2016-06-10 17:47:19 +00:00
|
|
|
msg << _( "It is missing.\n" );
|
2015-03-26 17:27:13 +00:00
|
|
|
else
|
2016-06-10 17:47:19 +00:00
|
|
|
msg << _( "Perhaps a shared library (.dll or .so) file is missing.\n" );
|
2015-03-26 17:27:13 +00:00
|
|
|
|
2016-06-10 17:47:19 +00:00
|
|
|
msg << _( "From command line: argv[0]:\n'" );
|
2015-03-26 17:27:13 +00:00
|
|
|
msg << wxStandardPaths::Get().GetExecutablePath() << wxT( "'\n" );
|
2014-04-24 11:30:14 +00:00
|
|
|
|
|
|
|
// This is a fatal error, one from which we cannot recover, nor do we want
|
|
|
|
// to protect against in client code which would require numerous noisy
|
|
|
|
// tests in numerous places. So we inform the user that the installation
|
2014-04-24 17:25:57 +00:00
|
|
|
// is bad. This exception will likely not get caught until way up in the
|
|
|
|
// wxApp derivative, at which point the process will exit gracefully.
|
2014-04-24 11:30:14 +00:00
|
|
|
THROW_IO_ERROR( msg );
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
return nullptr;
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
2014-04-19 18:47:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
|
|
|
|
{
|
|
|
|
switch( aFrameType )
|
|
|
|
{
|
|
|
|
case FRAME_SCH:
|
2020-10-31 01:27:16 +00:00
|
|
|
case FRAME_SCH_SYMBOL_EDITOR:
|
2014-04-19 18:47:20 +00:00
|
|
|
case FRAME_SCH_VIEWER:
|
2023-09-28 13:09:45 +00:00
|
|
|
case FRAME_SYMBOL_CHOOSER:
|
2016-08-11 12:41:01 +00:00
|
|
|
case FRAME_SIMULATOR:
|
2014-04-19 18:47:20 +00:00
|
|
|
return FACE_SCH;
|
|
|
|
|
2019-09-05 22:00:47 +00:00
|
|
|
case FRAME_PCB_EDITOR:
|
|
|
|
case FRAME_FOOTPRINT_EDITOR:
|
|
|
|
case FRAME_FOOTPRINT_VIEWER:
|
2023-09-26 17:31:45 +00:00
|
|
|
case FRAME_FOOTPRINT_CHOOSER:
|
2019-09-05 22:00:47 +00:00
|
|
|
case FRAME_FOOTPRINT_WIZARD:
|
2014-04-19 18:47:20 +00:00
|
|
|
case FRAME_PCB_DISPLAY3D:
|
|
|
|
return FACE_PCB;
|
|
|
|
|
|
|
|
case FRAME_CVPCB:
|
|
|
|
case FRAME_CVPCB_DISPLAY:
|
|
|
|
return FACE_CVPCB;
|
|
|
|
|
2021-03-08 14:54:22 +00:00
|
|
|
case FRAME_PYTHON:
|
|
|
|
return FACE_PYTHON;
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
case FRAME_GERBER:
|
|
|
|
return FACE_GERBVIEW;
|
|
|
|
|
|
|
|
case FRAME_PL_EDITOR:
|
|
|
|
return FACE_PL_EDITOR;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case FRAME_CALC:
|
|
|
|
return FACE_PCB_CALCULATOR;
|
|
|
|
|
|
|
|
case FRAME_BM2CMP:
|
|
|
|
return FACE_BMP2CMP;
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
default:
|
|
|
|
return FACE_T( -1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-06 07:36:08 +00:00
|
|
|
KIWAY_PLAYER* KIWAY::GetPlayerFrame( FRAME_T aFrameType )
|
|
|
|
{
|
2021-07-02 19:07:26 +00:00
|
|
|
wxWindowID storedId = m_playerFrameId[aFrameType];
|
|
|
|
|
|
|
|
if( storedId == wxID_NONE )
|
2021-07-15 19:26:35 +00:00
|
|
|
return nullptr;
|
2016-01-06 07:36:08 +00:00
|
|
|
|
2021-07-02 19:07:26 +00:00
|
|
|
wxWindow* frame = wxWindow::FindWindowById( storedId );
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
// Since wxWindow::FindWindow*() is not cheap (especially if the window does not exist),
|
2021-07-02 19:07:26 +00:00
|
|
|
// clear invalid entries to save CPU on repeated calls that do not lead to frame creation
|
2023-01-24 11:54:10 +00:00
|
|
|
if( !frame )
|
2021-07-02 19:07:26 +00:00
|
|
|
m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
|
|
|
|
|
2023-01-24 11:54:10 +00:00
|
|
|
return static_cast<KIWAY_PLAYER*>( frame );
|
2016-01-06 07:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-01 09:41:43 +00:00
|
|
|
KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow* aParent )
|
2014-04-19 18:47:20 +00:00
|
|
|
{
|
|
|
|
// Since this will be called from python, cannot assume that code will
|
|
|
|
// not pass a bad aFrameType.
|
2019-03-27 22:37:26 +00:00
|
|
|
if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
|
2014-04-19 18:47:20 +00:00
|
|
|
{
|
|
|
|
// @todo : throw an exception here for python's benefit, at least that
|
|
|
|
// way it gets some explanatory text.
|
|
|
|
|
|
|
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
|
2020-11-14 02:14:03 +00:00
|
|
|
return nullptr;
|
2014-04-19 18:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// return the previously opened window
|
2016-01-06 07:36:08 +00:00
|
|
|
KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
return frame;
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2014-04-20 04:35:34 +00:00
|
|
|
if( doCreate )
|
|
|
|
{
|
2020-07-13 20:21:34 +00:00
|
|
|
try
|
2014-04-22 16:16:34 +00:00
|
|
|
{
|
2023-04-21 03:01:31 +00:00
|
|
|
#ifdef KICAD_USE_SENTRY
|
2023-04-21 03:05:06 +00:00
|
|
|
if( Pgm().IsSentryOptedIn() )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( "Creating window type %d", aFrameType );
|
|
|
|
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
|
|
|
|
sentry_value_set_by_key( crumb, "category",
|
|
|
|
sentry_value_new_string( "kiway.player" ) );
|
|
|
|
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
|
|
|
|
sentry_add_breadcrumb( crumb );
|
|
|
|
}
|
2023-04-21 03:01:31 +00:00
|
|
|
#endif
|
|
|
|
|
2020-07-13 20:21:34 +00:00
|
|
|
FACE_T face_type = KifaceType( aFrameType );
|
|
|
|
KIFACE* kiface = KiFACE( face_type );
|
|
|
|
|
2023-03-19 11:30:53 +00:00
|
|
|
if( !kiface )
|
|
|
|
return nullptr;
|
|
|
|
|
2022-11-08 09:14:40 +00:00
|
|
|
frame = (KIWAY_PLAYER*) kiface->CreateKiWindow(
|
2020-07-13 20:21:34 +00:00
|
|
|
aParent, // Parent window of frame in modal mode,
|
|
|
|
// NULL in non modal mode
|
|
|
|
aFrameType,
|
|
|
|
this,
|
|
|
|
m_ctl // questionable need, these same flags
|
|
|
|
// were passed to KIFACE::OnKifaceStart()
|
|
|
|
);
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2021-07-02 19:07:26 +00:00
|
|
|
m_playerFrameId[aFrameType].store( frame->GetId() );
|
2016-03-21 16:36:06 +00:00
|
|
|
return frame;
|
2014-04-22 16:16:34 +00:00
|
|
|
}
|
2020-07-13 20:21:34 +00:00
|
|
|
catch( ... )
|
|
|
|
{
|
2023-04-20 01:17:31 +00:00
|
|
|
Pgm().HandleException( std::current_exception() );
|
2023-03-19 10:01:54 +00:00
|
|
|
wxLogError( _( "Error loading editor." ) );
|
2020-07-13 20:21:34 +00:00
|
|
|
}
|
2014-04-20 04:35:34 +00:00
|
|
|
}
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2020-11-14 02:14:03 +00:00
|
|
|
return nullptr;
|
2014-04-19 18:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
|
|
|
|
{
|
|
|
|
// Since this will be called from python, cannot assume that code will
|
|
|
|
// not pass a bad aFrameType.
|
2019-03-27 22:37:26 +00:00
|
|
|
if( (unsigned) aFrameType >= KIWAY_PLAYER_COUNT )
|
2014-04-19 18:47:20 +00:00
|
|
|
{
|
|
|
|
// @todo : throw an exception here for python's benefit, at least that
|
|
|
|
// way it gets some explanatory text.
|
|
|
|
|
|
|
|
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFrameType" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-11 19:30:52 +00:00
|
|
|
KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
if( frame == nullptr ) // Already closed
|
2016-01-06 07:36:08 +00:00
|
|
|
return true;
|
|
|
|
|
2023-04-21 03:01:31 +00:00
|
|
|
#ifdef KICAD_USE_SENTRY
|
2023-04-21 03:05:06 +00:00
|
|
|
if( Pgm().IsSentryOptedIn() )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( "Closing window type %d", aFrameType );
|
|
|
|
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
|
|
|
|
sentry_value_set_by_key( crumb, "category",
|
|
|
|
sentry_value_new_string( "kiway.playerclose" ) );
|
|
|
|
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
|
|
|
|
sentry_add_breadcrumb( crumb );
|
|
|
|
}
|
2023-04-21 03:01:31 +00:00
|
|
|
#endif
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
if( frame->NonUserClose( doForce ) )
|
2022-12-27 15:07:52 +00:00
|
|
|
{
|
|
|
|
m_playerFrameId[aFrameType] = wxID_NONE;
|
2016-01-06 07:36:08 +00:00
|
|
|
return true;
|
2022-12-27 15:07:52 +00:00
|
|
|
}
|
2014-04-19 18:47:20 +00:00
|
|
|
|
2016-01-06 07:36:08 +00:00
|
|
|
return false;
|
2014-04-19 18:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KIWAY::PlayersClose( bool doForce )
|
|
|
|
{
|
|
|
|
bool ret = true;
|
|
|
|
|
2015-12-30 07:46:32 +00:00
|
|
|
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
|
2014-04-19 18:47:20 +00:00
|
|
|
ret = ret && PlayerClose( FRAME_T( i ), doForce );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2014-04-21 06:28:17 +00:00
|
|
|
|
|
|
|
|
2023-06-11 19:30:52 +00:00
|
|
|
void KIWAY::PlayerDidClose( FRAME_T aFrameType )
|
|
|
|
{
|
|
|
|
m_playerFrameId[aFrameType] = wxID_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
|
|
|
|
wxWindow* aSource )
|
2014-04-21 06:28:17 +00:00
|
|
|
{
|
|
|
|
KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );
|
|
|
|
|
|
|
|
ProcessEvent( mail );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
void KIWAY::GetActions( std::vector<TOOL_ACTION*>& aActions ) const
|
|
|
|
{
|
|
|
|
for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() )
|
|
|
|
aActions.push_back( action );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
void KIWAY::SetLanguage( int aLanguage )
|
|
|
|
{
|
2020-09-01 22:41:06 +00:00
|
|
|
wxString errMsg;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
{
|
|
|
|
// Only allow the traces to be logged by wx. We use our own system to log when the
|
|
|
|
// OS doesn't support the language, so we want to hide the wx error.
|
|
|
|
WX_LOG_TRACE_ONLY logtraceOnly;
|
|
|
|
Pgm().SetLanguageIdentifier( aLanguage );
|
|
|
|
ret = Pgm().SetLanguage( errMsg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !ret )
|
|
|
|
{
|
|
|
|
wxString lang;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
|
|
|
|
{
|
|
|
|
if( aLanguage == LanguagesList[ii].m_KI_Lang_Identifier )
|
|
|
|
{
|
|
|
|
if( LanguagesList[ii].m_DoNotTranslate )
|
|
|
|
lang = LanguagesList[ii].m_Lang_Label;
|
|
|
|
else
|
|
|
|
lang = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayErrorMessage( nullptr,
|
|
|
|
wxString::Format( _( "Unable to switch language to %s" ), lang ),
|
|
|
|
errMsg );
|
|
|
|
return;
|
|
|
|
}
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
// This is a risky hack that goes away if we allow the language to be
|
|
|
|
// set only from the top most frame if !Kiface.IsSingle()
|
|
|
|
|
|
|
|
// Only for the C++ project manager, and not for the python one and not for
|
|
|
|
// single_top do we look for the EDA_BASE_FRAME as the top level window.
|
|
|
|
// For single_top this is not needed because that window is registered in
|
|
|
|
// the array below.
|
|
|
|
if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
|
|
|
|
{
|
2016-01-06 11:08:43 +00:00
|
|
|
// A dynamic_cast could be better, but creates link issues
|
|
|
|
// (some basic_frame functions not found) on some platforms,
|
|
|
|
// so a static_cast is used.
|
|
|
|
EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
|
2016-01-06 07:36:08 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( top )
|
|
|
|
top->ShowChangedLanguage();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-30 07:46:32 +00:00
|
|
|
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
{
|
2016-01-06 07:36:08 +00:00
|
|
|
KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
frame->ShowChangedLanguage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-09 18:49:26 +00:00
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void KIWAY::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2017-03-02 13:46:18 +00:00
|
|
|
{
|
|
|
|
if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
|
|
|
|
{
|
|
|
|
// A dynamic_cast could be better, but creates link issues
|
|
|
|
// (some basic_frame functions not found) on some platforms,
|
|
|
|
// so a static_cast is used.
|
|
|
|
EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
|
|
|
|
|
|
|
|
if( top )
|
2020-07-17 20:04:14 +00:00
|
|
|
top->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2017-03-02 13:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
|
|
|
|
{
|
|
|
|
KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
|
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
if( frame )
|
2020-07-17 20:04:14 +00:00
|
|
|
frame->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2017-03-02 13:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2020-08-09 18:49:26 +00:00
|
|
|
void KIWAY::ProjectChanged()
|
|
|
|
{
|
2023-04-21 03:01:31 +00:00
|
|
|
#ifdef KICAD_USE_SENTRY
|
|
|
|
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", "Changing project" );
|
|
|
|
sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.projectchanged" ) );
|
|
|
|
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
|
|
|
|
sentry_add_breadcrumb( crumb );
|
|
|
|
#endif
|
|
|
|
|
2020-08-09 18:49:26 +00:00
|
|
|
if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
|
|
|
|
{
|
|
|
|
// A dynamic_cast could be better, but creates link issues
|
|
|
|
// (some basic_frame functions not found) on some platforms,
|
|
|
|
// so a static_cast is used.
|
|
|
|
EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
|
|
|
|
|
|
|
|
if( top )
|
|
|
|
top->ProjectChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
|
|
|
|
{
|
|
|
|
KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
frame->ProjectChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:44:53 +00:00
|
|
|
wxWindow* KIWAY::GetBlockingDialog()
|
|
|
|
{
|
|
|
|
return wxWindow::FindWindowById( m_blockingDialog );
|
|
|
|
}
|
|
|
|
|
|
|
|
void KIWAY::SetBlockingDialog( wxWindow* aWin )
|
|
|
|
{
|
|
|
|
if( !aWin )
|
|
|
|
m_blockingDialog = wxID_NONE;
|
|
|
|
else
|
|
|
|
m_blockingDialog = aWin->GetId();
|
|
|
|
}
|
|
|
|
|
2020-08-09 18:49:26 +00:00
|
|
|
|
2014-04-21 06:28:17 +00:00
|
|
|
bool KIWAY::ProcessEvent( wxEvent& aEvent )
|
|
|
|
{
|
|
|
|
KIWAY_EXPRESS* mail = dynamic_cast<KIWAY_EXPRESS*>( &aEvent );
|
|
|
|
|
|
|
|
if( mail )
|
|
|
|
{
|
|
|
|
FRAME_T dest = mail->Dest();
|
|
|
|
|
|
|
|
// see if recipient is alive
|
|
|
|
KIWAY_PLAYER* alive = Player( dest, false );
|
|
|
|
|
|
|
|
if( alive )
|
2014-04-21 06:51:33 +00:00
|
|
|
{
|
2014-04-21 14:49:33 +00:00
|
|
|
#if 1
|
2014-04-21 06:28:17 +00:00
|
|
|
return alive->ProcessEvent( aEvent );
|
2014-04-21 06:51:33 +00:00
|
|
|
#else
|
|
|
|
alive->KiwayMailIn( *mail );
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
2014-04-21 06:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
int KIWAY::ProcessJob( KIWAY::FACE_T aFace, JOB* job )
|
|
|
|
{
|
|
|
|
KIFACE* kiface = KiFACE( aFace );
|
|
|
|
|
|
|
|
return kiface->HandleJob( job );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
void KIWAY::OnKiCadExit()
|
|
|
|
{
|
|
|
|
if( m_ctl & KFCTL_CPP_PROJECT_SUITE )
|
|
|
|
{
|
|
|
|
// A dynamic_cast could be better, but creates link issues
|
|
|
|
// (some basic_frame functions not found) on some platforms,
|
|
|
|
// so a static_cast is used.
|
|
|
|
EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
|
|
|
|
|
|
|
|
if( top )
|
|
|
|
top->Close( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
void KIWAY::OnKiwayEnd()
|
|
|
|
{
|
2019-03-27 22:37:26 +00:00
|
|
|
for( KIFACE* i : m_kiface )
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
{
|
2019-03-27 22:37:26 +00:00
|
|
|
if( i )
|
|
|
|
i->OnKifaceEnd();
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
}
|
|
|
|
}
|