2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-02 13:46:18 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-09-21 12:58:08 +00:00
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-09-10 15:11:24 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +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
|
|
|
|
*/
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <bitmaps.h>
|
2021-03-09 22:47:24 +00:00
|
|
|
#include <bitmap_store.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include <dialog_shim.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <dialogs/panel_common_settings.h>
|
2020-05-17 00:19:48 +00:00
|
|
|
#include <dialogs/panel_mouse_settings.h>
|
2022-04-02 01:21:55 +00:00
|
|
|
#include <dialogs/panel_data_collection.h>
|
2021-03-23 17:39:20 +00:00
|
|
|
#include <eda_dde.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <filehistory.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include <id.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <menus_helpers.h>
|
2022-06-23 17:36:25 +00:00
|
|
|
#include <hotkeys_basic.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <panel_hotkeys_editor.h>
|
2021-01-23 15:52:29 +00:00
|
|
|
#include <paths.h>
|
2021-06-27 09:58:05 +00:00
|
|
|
#include <confirm.h>
|
2022-08-18 20:41:43 +00:00
|
|
|
#include <panel_pcm_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/app_settings.h>
|
|
|
|
#include <settings/common_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-08-24 02:01:14 +00:00
|
|
|
#include <project/project_local_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-05-18 10:27:36 +00:00
|
|
|
#include <tool/action_menu.h>
|
2021-03-09 22:47:24 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/actions.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/common_control.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2020-03-24 01:01:23 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <trace_helpers.h>
|
|
|
|
#include <widgets/paged_dialog.h>
|
2020-08-31 13:19:57 +00:00
|
|
|
#include <widgets/infobar.h>
|
2021-03-02 04:10:03 +00:00
|
|
|
#include <widgets/wx_aui_art_providers.h>
|
2021-06-03 01:19:20 +00:00
|
|
|
#include <wx/app.h>
|
2021-06-03 12:45:41 +00:00
|
|
|
#include <wx/config.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <wx/display.h>
|
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
#include <wx/string.h>
|
2021-06-03 15:41:26 +00:00
|
|
|
#include <wx/treebook.h>
|
2020-09-01 10:14:51 +00:00
|
|
|
#include <kiplatform/app.h>
|
2021-03-09 22:47:24 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
#include <functional>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <kiface_ids.h>
|
2020-07-27 22:42:23 +00:00
|
|
|
|
2020-04-13 01:27:47 +00:00
|
|
|
wxDEFINE_EVENT( UNITS_CHANGED, wxCommandEvent );
|
|
|
|
|
2019-05-18 10:27:36 +00:00
|
|
|
|
2020-02-25 01:14:06 +00:00
|
|
|
// Minimum window size
|
2021-02-16 15:15:52 +00:00
|
|
|
static const wxSize minSize( FRAME_T aFrameType )
|
|
|
|
{
|
|
|
|
switch( aFrameType )
|
|
|
|
{
|
|
|
|
case KICAD_MAIN_FRAME_T:
|
|
|
|
return wxSize( 406, 354 );
|
|
|
|
|
|
|
|
default:
|
|
|
|
return wxSize( 500, 400 );
|
|
|
|
}
|
|
|
|
}
|
2020-02-25 01:14:06 +00:00
|
|
|
|
2021-07-14 19:47:32 +00:00
|
|
|
|
2021-02-16 15:15:52 +00:00
|
|
|
static const wxSize defaultSize( FRAME_T aFrameType )
|
|
|
|
{
|
|
|
|
switch( aFrameType )
|
|
|
|
{
|
|
|
|
case KICAD_MAIN_FRAME_T:
|
|
|
|
return wxSize( 850, 540 );
|
|
|
|
|
|
|
|
default:
|
|
|
|
return wxSize( 1280, 720 );
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 18:38:40 +00:00
|
|
|
|
2020-02-25 01:14:06 +00:00
|
|
|
|
2019-05-18 10:27:36 +00:00
|
|
|
BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
|
2019-06-09 21:57:23 +00:00
|
|
|
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
|
2021-06-07 19:45:17 +00:00
|
|
|
EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
|
2019-07-30 17:12:16 +00:00
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
|
2020-03-24 01:01:23 +00:00
|
|
|
EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
|
|
|
|
EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
|
|
|
|
EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
|
2020-02-21 22:57:32 +00:00
|
|
|
EVT_MOVE( EDA_BASE_FRAME::OnMove )
|
2021-06-18 03:04:34 +00:00
|
|
|
EVT_SIZE( EDA_BASE_FRAME::OnSize )
|
2020-04-26 23:14:12 +00:00
|
|
|
EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
|
2021-03-26 15:50:08 +00:00
|
|
|
|
|
|
|
EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
|
2022-03-31 19:03:41 +00:00
|
|
|
EVT_ICONIZE( EDA_BASE_FRAME::onIconize )
|
2019-05-18 10:27:36 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2021-03-15 21:56:13 +00:00
|
|
|
|
|
|
|
void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-03-15 21:56:13 +00:00
|
|
|
m_ident = aFrameType;
|
|
|
|
m_maximizeByDefault = false;
|
|
|
|
m_infoBar = nullptr;
|
|
|
|
m_settingsManager = nullptr;
|
|
|
|
m_fileHistory = nullptr;
|
2021-12-02 20:19:15 +00:00
|
|
|
m_supportsAutoSave = false;
|
2022-10-10 11:04:19 +00:00
|
|
|
m_autoSavePending = false;
|
2021-03-15 21:56:13 +00:00
|
|
|
m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
|
|
|
m_isClosing = false;
|
|
|
|
m_isNonUserClose = false;
|
|
|
|
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
|
2022-10-10 13:03:10 +00:00
|
|
|
m_autoSaveRequired = false;
|
2021-03-15 21:56:13 +00:00
|
|
|
m_mruPath = PATHS::GetDefaultUserProjectsPath();
|
|
|
|
m_frameSize = defaultSize( aFrameType );
|
2021-06-18 03:04:34 +00:00
|
|
|
m_displayIndex = -1;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2020-10-18 15:31:44 +00:00
|
|
|
m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
|
2020-10-18 14:36:17 +00:00
|
|
|
|
2020-05-25 20:41:24 +00:00
|
|
|
m_settingsManager = &Pgm().GetSettingsManager();
|
|
|
|
|
2020-02-25 01:14:06 +00:00
|
|
|
// Set a reasonable minimal size for the frame
|
2021-02-16 15:15:52 +00:00
|
|
|
SetSizeHints( minSize( aFrameType ).x, minSize( aFrameType ).y, -1, -1, -1, -1 );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2018-04-27 18:35:23 +00:00
|
|
|
// Store dimensions of the user area of the main window.
|
2020-11-16 11:16:44 +00:00
|
|
|
GetClientSize( &m_frameSize.x, &m_frameSize.y );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
|
|
|
|
wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
|
2014-02-02 20:18:10 +00:00
|
|
|
|
|
|
|
// hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
|
|
|
|
// to be called before any other hook for wxCloseEvent, which is necessary.
|
|
|
|
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
|
2021-02-09 19:41:36 +00:00
|
|
|
|
|
|
|
initExitKey();
|
2021-03-15 21:56:13 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 19:47:32 +00:00
|
|
|
|
2022-09-19 16:09:59 +00:00
|
|
|
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
|
|
|
const wxString& aFrameName, KIWAY* aKiway,
|
|
|
|
const EDA_IU_SCALE& aIuScale ) :
|
2021-03-15 21:56:13 +00:00
|
|
|
wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
|
|
|
|
TOOLS_HOLDER(),
|
2022-09-19 16:09:59 +00:00
|
|
|
KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
|
|
|
|
UNITS_PROVIDER( aIuScale, EDA_UNITS::MILLIMETRES )
|
2021-03-15 21:56:13 +00:00
|
|
|
{
|
|
|
|
commonInit( aFrameType );
|
2014-02-02 20:18:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
wxWindow* EDA_BASE_FRAME::findQuasiModalDialog()
|
2014-02-02 20:18:10 +00:00
|
|
|
{
|
2020-11-26 11:57:40 +00:00
|
|
|
for( wxWindow* iter : GetChildren() )
|
2014-08-29 17:49:49 +00:00
|
|
|
{
|
2018-03-24 18:28:35 +00:00
|
|
|
DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
|
2020-11-26 11:57:40 +00:00
|
|
|
|
2018-01-09 20:00:28 +00:00
|
|
|
if( dlg && dlg->IsQuasiModal() )
|
|
|
|
return dlg;
|
2014-08-29 17:49:49 +00:00
|
|
|
}
|
2018-03-24 18:28:35 +00:00
|
|
|
|
|
|
|
// FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
|
|
|
|
// so we have to look for it separately.
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_ident == FRAME_SCH )
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
|
|
|
wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
|
2020-11-26 11:57:40 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
if( cvpcb )
|
|
|
|
return cvpcb;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
2018-01-09 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
2014-08-29 17:49:49 +00:00
|
|
|
|
2018-01-09 20:00:28 +00:00
|
|
|
void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
|
|
|
|
{
|
2018-03-24 18:28:35 +00:00
|
|
|
// Don't allow closing when a quasi-modal is open.
|
|
|
|
wxWindow* quasiModal = findQuasiModalDialog();
|
2018-04-27 18:35:23 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
if( quasiModal )
|
2014-08-29 17:49:49 +00:00
|
|
|
{
|
2018-03-24 18:28:35 +00:00
|
|
|
// Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
|
|
|
|
// when they have no idea what those are.
|
|
|
|
quasiModal->Raise();
|
|
|
|
wxBell();
|
|
|
|
|
2020-08-30 23:47:16 +00:00
|
|
|
if( event.CanVeto() )
|
|
|
|
event.Veto();
|
|
|
|
|
2014-08-29 17:49:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-24 18:31:11 +00:00
|
|
|
|
2020-09-01 15:45:20 +00:00
|
|
|
if( event.GetId() == wxEVT_QUERY_END_SESSION
|
2020-08-24 02:01:14 +00:00
|
|
|
|| event.GetId() == wxEVT_END_SESSION )
|
|
|
|
{
|
|
|
|
// End session means the OS is going to terminate us
|
|
|
|
m_isNonUserClose = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( canCloseWindow( event ) )
|
|
|
|
{
|
|
|
|
m_isClosing = true;
|
|
|
|
APP_SETTINGS_BASE* cfg = config();
|
2014-02-02 20:18:10 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
if( cfg )
|
|
|
|
SaveSettings( cfg ); // virtual, wxFrame specific
|
|
|
|
|
|
|
|
doCloseWindow();
|
|
|
|
|
2020-09-01 15:45:20 +00:00
|
|
|
// Destroy (safe delete frame) this frame only in non modal mode.
|
|
|
|
// In modal mode, the caller will call Destroy().
|
|
|
|
if( !IsModal() )
|
|
|
|
Destroy();
|
2020-08-24 02:01:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-30 23:47:16 +00:00
|
|
|
if( event.CanVeto() )
|
|
|
|
event.Veto();
|
2020-08-24 02:01:14 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::~EDA_BASE_FRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-10-13 19:56:32 +00:00
|
|
|
delete m_autoSaveTimer;
|
2020-05-16 21:47:01 +00:00
|
|
|
delete m_fileHistory;
|
2019-12-19 14:11:11 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
ClearUndoRedoList();
|
|
|
|
|
2021-03-23 17:39:20 +00:00
|
|
|
SocketCleanup();
|
|
|
|
|
2020-09-01 10:14:51 +00:00
|
|
|
KIPLATFORM::APP::RemoveShutdownBlockReason( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-02-23 13:09:17 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Apple in its infinite wisdom will raise a disabled window before even passing
|
|
|
|
// us the event, so we have no way to stop it. Instead, we have to catch an
|
|
|
|
// improperly ordered disabled window and quasi-modal dialog here and reorder
|
|
|
|
// them.
|
2018-01-09 20:00:28 +00:00
|
|
|
if( !IsEnabled() && IsActive() )
|
|
|
|
{
|
2018-03-24 18:28:35 +00:00
|
|
|
wxWindow* dlg = findQuasiModalDialog();
|
2018-01-09 20:00:28 +00:00
|
|
|
if( dlg )
|
|
|
|
dlg->Raise();
|
|
|
|
}
|
2018-02-23 13:09:17 +00:00
|
|
|
#endif
|
2018-01-09 20:00:28 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
if( !wxFrame::ProcessEvent( aEvent ) )
|
|
|
|
return false;
|
2009-03-02 13:43:52 +00:00
|
|
|
|
2021-11-15 18:04:44 +00:00
|
|
|
if( Pgm().m_Quitting )
|
|
|
|
return true;
|
|
|
|
|
2021-12-02 20:19:15 +00:00
|
|
|
if( !m_isClosing && m_supportsAutoSave && IsShown() && IsActive()
|
2022-10-10 11:04:19 +00:00
|
|
|
&& m_autoSavePending != isAutoSaveRequired()
|
|
|
|
&& GetAutoSaveInterval() > 0 )
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
2022-10-10 11:04:19 +00:00
|
|
|
if( !m_autoSavePending )
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
2011-10-15 13:25:57 +00:00
|
|
|
wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
|
2021-12-02 20:19:15 +00:00
|
|
|
m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
|
2022-10-10 11:04:19 +00:00
|
|
|
m_autoSavePending = true;
|
2011-10-13 19:56:32 +00:00
|
|
|
}
|
2011-10-15 13:25:57 +00:00
|
|
|
else if( m_autoSaveTimer->IsRunning() )
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
2011-10-15 13:25:57 +00:00
|
|
|
wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
|
2011-10-13 19:56:32 +00:00
|
|
|
m_autoSaveTimer->Stop();
|
2022-10-10 11:04:19 +00:00
|
|
|
m_autoSavePending = false;
|
2011-10-13 19:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2021-12-02 20:19:15 +00:00
|
|
|
int EDA_BASE_FRAME::GetAutoSaveInterval() const
|
2016-11-22 10:07:33 +00:00
|
|
|
{
|
2021-12-02 20:19:15 +00:00
|
|
|
return Pgm().GetCommonSettings()->m_System.autosave_interval;
|
2016-11-22 10:07:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
2022-10-22 19:49:03 +00:00
|
|
|
// Don't stomp on someone else's timer event.
|
|
|
|
if( aEvent.GetId() != ID_AUTO_SAVE_TIMER )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
if( !doAutoSave() )
|
2021-12-02 20:19:15 +00:00
|
|
|
m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
|
2011-10-13 19:56:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_BASE_FRAME::doAutoSave()
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-03 20:07:16 +00:00
|
|
|
void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
|
2019-06-09 13:12:44 +00:00
|
|
|
{
|
2021-05-03 20:07:16 +00:00
|
|
|
wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( aKeyEvent ) );
|
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
// Key events can be filtered here.
|
|
|
|
// Currently no filtering is made.
|
2021-05-03 20:07:16 +00:00
|
|
|
aKeyEvent.Skip();
|
2019-06-09 13:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
|
2019-06-09 13:12:44 +00:00
|
|
|
{
|
2020-03-24 01:01:23 +00:00
|
|
|
if( !m_toolDispatcher )
|
|
|
|
aEvent.Skip();
|
|
|
|
else
|
|
|
|
m_toolDispatcher->DispatchWxEvent( aEvent );
|
2019-06-09 13:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
void EDA_BASE_FRAME::RegisterUIUpdateHandler( int aID, const ACTION_CONDITIONS& aConditions )
|
|
|
|
{
|
|
|
|
UIUpdateHandler evtFunc = std::bind( &EDA_BASE_FRAME::HandleUpdateUIEvent,
|
|
|
|
std::placeholders::_1,
|
|
|
|
this,
|
|
|
|
aConditions );
|
|
|
|
|
|
|
|
m_uiUpdateMap[aID] = evtFunc;
|
|
|
|
|
|
|
|
Bind( wxEVT_UPDATE_UI, evtFunc, aID );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::UnregisterUIUpdateHandler( int aID )
|
|
|
|
{
|
|
|
|
const auto it = m_uiUpdateMap.find( aID );
|
|
|
|
|
|
|
|
if( it == m_uiUpdateMap.end() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Unbind( wxEVT_UPDATE_UI, it->second, aID );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
|
|
|
|
ACTION_CONDITIONS aCond )
|
|
|
|
{
|
|
|
|
bool checkRes = false;
|
|
|
|
bool enableRes = true;
|
|
|
|
bool showRes = true;
|
2021-11-15 18:12:46 +00:00
|
|
|
bool isCut = aEvent.GetId() == ACTIONS::cut.GetUIId();
|
|
|
|
bool isCopy = aEvent.GetId() == ACTIONS::copy.GetUIId();
|
|
|
|
bool isPaste = aEvent.GetId() == ACTIONS::paste.GetUIId();
|
2020-07-27 22:42:23 +00:00
|
|
|
SELECTION& selection = aFrame->GetCurrentSelection();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
checkRes = aCond.checkCondition( selection );
|
|
|
|
enableRes = aCond.enableCondition( selection );
|
|
|
|
showRes = aCond.showCondition( selection );
|
|
|
|
}
|
|
|
|
catch( std::exception& )
|
|
|
|
{
|
|
|
|
// Something broke with the conditions, just skip the event.
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-15 18:12:46 +00:00
|
|
|
if( isCut || isCopy || isPaste )
|
|
|
|
{
|
|
|
|
wxWindow* focus = wxWindow::FindFocus();
|
|
|
|
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
|
|
|
|
|
|
|
|
if( textEntry && isCut && textEntry->CanCut() )
|
|
|
|
enableRes = true;
|
|
|
|
else if( textEntry && isCopy && textEntry->CanCopy() )
|
|
|
|
enableRes = true;
|
|
|
|
else if( textEntry && isPaste && textEntry->CanPaste() )
|
|
|
|
enableRes = true;
|
|
|
|
}
|
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
aEvent.Enable( enableRes );
|
|
|
|
aEvent.Show( showRes );
|
|
|
|
|
2020-11-11 00:33:37 +00:00
|
|
|
// wxWidgets 3.1.5+ includes a field in the event that says if the event supports being
|
|
|
|
// checked, since wxMenuItems don't want to be checked unless they actually are checkable
|
|
|
|
#if wxCHECK_VERSION( 3, 1, 5 )
|
|
|
|
if( aEvent.IsCheckable() )
|
|
|
|
aEvent.Check( checkRes );
|
|
|
|
#else
|
2020-07-27 22:42:23 +00:00
|
|
|
bool canCheck = true;
|
|
|
|
|
2021-07-14 19:47:32 +00:00
|
|
|
// wxMenuItems don't want to be checked unless they actually are checkable, so we have to
|
|
|
|
// check to see if they can be and can't just universally apply a check in this event.
|
2022-10-16 16:45:10 +00:00
|
|
|
if( wxMenu* menu = dynamic_cast<wxMenu*>( aEvent.GetEventObject() ) )
|
2020-07-27 22:42:23 +00:00
|
|
|
canCheck = menu->FindItem( aEvent.GetId() )->IsCheckable();
|
|
|
|
|
|
|
|
if( canCheck )
|
|
|
|
aEvent.Check( checkRes );
|
2020-11-11 00:33:37 +00:00
|
|
|
#endif
|
2020-07-27 22:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
// Setup the conditions to check a language menu item
|
|
|
|
auto isCurrentLang =
|
|
|
|
[] ( const SELECTION& aSel, int aLangIdentifier )
|
|
|
|
{
|
|
|
|
return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
|
|
|
|
};
|
|
|
|
|
|
|
|
for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
|
|
|
|
{
|
|
|
|
ACTION_CONDITIONS cond;
|
2020-08-05 22:00:26 +00:00
|
|
|
cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
|
|
|
|
LanguagesList[ii].m_WX_Lang_Identifier ) );
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
void EDA_BASE_FRAME::ReCreateMenuBar()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-18 10:27:36 +00:00
|
|
|
void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
|
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
|
2020-07-27 22:42:23 +00:00
|
|
|
ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
|
2019-05-18 10:27:36 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
helpMenu->Add( ACTIONS::help );
|
|
|
|
helpMenu->Add( ACTIONS::gettingStarted );
|
|
|
|
helpMenu->Add( ACTIONS::listHotKeys );
|
|
|
|
helpMenu->Add( ACTIONS::getInvolved );
|
2021-04-08 17:21:44 +00:00
|
|
|
helpMenu->Add( ACTIONS::donate );
|
2020-05-25 00:39:15 +00:00
|
|
|
helpMenu->Add( ACTIONS::reportBug );
|
2019-07-30 17:12:16 +00:00
|
|
|
|
2019-05-18 10:27:36 +00:00
|
|
|
helpMenu->AppendSeparator();
|
2021-03-08 02:59:07 +00:00
|
|
|
helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
|
2019-05-18 10:27:36 +00:00
|
|
|
|
2021-09-06 11:43:48 +00:00
|
|
|
// Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
|
|
|
|
aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
|
2019-05-18 10:27:36 +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
|
|
|
void EDA_BASE_FRAME::ShowChangedLanguage()
|
2010-02-26 15:39:10 +00:00
|
|
|
{
|
2021-07-23 19:15:55 +00:00
|
|
|
TOOLS_HOLDER::ShowChangedLanguage();
|
|
|
|
|
2018-07-01 14:48:35 +00:00
|
|
|
if( GetMenuBar() )
|
|
|
|
{
|
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
|
|
|
}
|
2010-02-26 15:39:10 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2017-03-02 13:46:18 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
TOOLS_HOLDER::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2019-06-14 10:55:54 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
|
|
|
|
|
|
|
if( m_fileHistory )
|
|
|
|
{
|
|
|
|
int historySize = settings->m_System.file_history_size;
|
|
|
|
m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
|
|
|
|
}
|
|
|
|
|
2021-09-13 22:30:22 +00:00
|
|
|
GetBitmapStore()->ThemeChanged();
|
|
|
|
ThemeChanged();
|
2021-03-09 22:47:24 +00:00
|
|
|
|
2018-07-01 14:48:35 +00:00
|
|
|
if( GetMenuBar() )
|
|
|
|
{
|
2018-08-16 10:32:31 +00:00
|
|
|
// For icons in menus, icon scaling & hotkeys
|
2018-07-01 14:48:35 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
|
|
|
}
|
2017-03-02 13:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-22 04:50:42 +00:00
|
|
|
void EDA_BASE_FRAME::ThemeChanged()
|
|
|
|
{
|
|
|
|
ClearScaledBitmapCache();
|
|
|
|
|
2021-03-26 15:50:08 +00:00
|
|
|
// Update all the toolbars to have new icons
|
2021-03-22 04:50:42 +00:00
|
|
|
wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
|
|
|
|
|
|
|
|
for( size_t i = 0; i < panes.GetCount(); ++i )
|
|
|
|
{
|
|
|
|
if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
|
|
|
|
toolbar->RefreshBitmaps();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-18 03:04:34 +00:00
|
|
|
void EDA_BASE_FRAME::OnSize( wxSizeEvent& aEvent )
|
|
|
|
{
|
2021-06-18 16:47:10 +00:00
|
|
|
#ifdef __WXMAC__
|
2021-06-18 03:04:34 +00:00
|
|
|
int currentDisplay = wxDisplay::GetFromWindow( this );
|
|
|
|
|
2021-06-18 22:15:00 +00:00
|
|
|
if( m_displayIndex >= 0 && currentDisplay >= 0 && currentDisplay != m_displayIndex )
|
2021-06-18 03:04:34 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation, "OnSize: current display changed %d to %d",
|
|
|
|
m_displayIndex, currentDisplay );
|
|
|
|
m_displayIndex = currentDisplay;
|
|
|
|
ensureWindowIsOnScreen();
|
|
|
|
}
|
2021-06-18 16:47:10 +00:00
|
|
|
#endif
|
2021-06-18 03:04:34 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-08-30 16:44:23 +00:00
|
|
|
if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
|
|
|
|
return;
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
|
2020-08-24 02:10:05 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
if( state != nullptr )
|
|
|
|
{
|
|
|
|
LoadWindowState( state->window );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::LoadWindowState( const WINDOW_STATE& aState )
|
|
|
|
{
|
2020-10-18 18:38:40 +00:00
|
|
|
bool wasDefault = false;
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos.x = aState.pos_x;
|
|
|
|
m_framePos.y = aState.pos_y;
|
|
|
|
m_frameSize.x = aState.size_x;
|
|
|
|
m_frameSize.y = aState.size_y;
|
2015-03-03 14:53:47 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Config position (%d, %d) with size (%d, %d)",
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
// Ensure minimum size is set if the stored config was zero-initialized
|
2021-02-16 15:15:52 +00:00
|
|
|
if( m_frameSize.x < minSize( m_ident ).x || m_frameSize.y < minSize( m_ident ).y )
|
* 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
|
|
|
{
|
2021-02-16 15:15:52 +00:00
|
|
|
m_frameSize = defaultSize( m_ident );
|
|
|
|
wasDefault = true;
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2021-07-14 19:47:32 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Using minimum size (%d, %d)",
|
|
|
|
m_frameSize.x, m_frameSize.y );
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Number of displays: %d", wxDisplay::GetCount() );
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
if( aState.display >= wxDisplay::GetCount() )
|
2020-04-17 23:32:29 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation, "Previous display not found" );
|
2016-05-23 08:51:17 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// If it isn't attached, use the first display
|
2020-04-18 10:36:05 +00:00
|
|
|
// Warning wxDisplay has 2 ctor variants. the parameter needs a type:
|
|
|
|
const unsigned int index = 0;
|
|
|
|
wxDisplay display( index );
|
2020-08-24 02:01:14 +00:00
|
|
|
wxRect clientSize = display.GetGeometry();
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos = wxDefaultPosition;
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Ensure the window fits on the display, since the other one could have been larger
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_frameSize.x > clientSize.width )
|
|
|
|
m_frameSize.x = clientSize.width;
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_frameSize.y > clientSize.height )
|
|
|
|
m_frameSize.y = clientSize.height;
|
2016-05-23 08:51:17 +00:00
|
|
|
}
|
2020-04-17 23:32:29 +00:00
|
|
|
else
|
2020-02-21 20:52:30 +00:00
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
|
|
|
|
wxPoint upperLeft( m_framePos.x, m_framePos.y );
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
wxDisplay display( aState.display );
|
|
|
|
wxRect clientSize = display.GetClientArea();
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2021-06-13 16:51:58 +00:00
|
|
|
int yLimTop = clientSize.y;
|
|
|
|
int yLimBottom = clientSize.y + clientSize.height;
|
|
|
|
int xLimLeft = clientSize.x;
|
|
|
|
int xLimRight = clientSize.x + clientSize.width;
|
2020-04-17 23:32:29 +00:00
|
|
|
|
|
|
|
if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
|
|
|
|
upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
|
2021-04-30 00:18:19 +00:00
|
|
|
upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
|
|
|
|
upperLeft.y > yLimBottom )
|
2020-04-17 23:32:29 +00:00
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos = wxDefaultPosition;
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Resetting to default position" );
|
|
|
|
}
|
|
|
|
}
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Final window position (%d, %d) with size (%d, %d)",
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
|
|
|
// Center the window if we reset to default
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_framePos.x == -1 )
|
2020-04-17 23:32:29 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation, "Centering window" );
|
|
|
|
Center();
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos = GetPosition();
|
2020-02-21 20:52:30 +00:00
|
|
|
}
|
2011-04-05 19:24:12 +00:00
|
|
|
|
2020-04-26 23:14:12 +00:00
|
|
|
// Record the frame sizes in an un-maximized state
|
2020-11-16 11:16:44 +00:00
|
|
|
m_normalFrameSize = m_frameSize;
|
|
|
|
m_normalFramePos = m_framePos;
|
2020-04-26 23:14:12 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Maximize if we were maximized before
|
2020-10-18 18:38:40 +00:00
|
|
|
if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
|
2020-04-17 23:32:29 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation, "Maximizing window" );
|
2011-04-05 19:24:12 +00:00
|
|
|
Maximize();
|
2020-04-17 23:32:29 +00:00
|
|
|
}
|
2021-06-18 03:04:34 +00:00
|
|
|
|
|
|
|
m_displayIndex = wxDisplay::GetFromWindow( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::ensureWindowIsOnScreen()
|
|
|
|
{
|
|
|
|
wxDisplay display( wxDisplay::GetFromWindow( this ) );
|
|
|
|
wxRect clientSize = display.GetClientArea();
|
|
|
|
wxPoint pos = GetPosition();
|
|
|
|
wxSize size = GetWindowSize();
|
|
|
|
|
|
|
|
wxLogTrace( traceDisplayLocation,
|
|
|
|
"ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d", clientSize.x, clientSize.y,
|
|
|
|
clientSize.width, clientSize.height );
|
|
|
|
|
|
|
|
if( pos.y < clientSize.y )
|
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation,
|
|
|
|
"ensureWindowIsOnScreen: y pos %d below minimum, setting to %d", pos.y,
|
|
|
|
clientSize.y );
|
|
|
|
pos.y = clientSize.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pos.x < clientSize.x )
|
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation,
|
|
|
|
"ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d", pos.x,
|
|
|
|
clientSize.x );
|
2021-06-19 15:45:48 +00:00
|
|
|
pos.x = clientSize.x;
|
2021-06-18 03:04:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( pos.x + size.x - clientSize.x > clientSize.width )
|
|
|
|
{
|
2021-06-18 22:15:00 +00:00
|
|
|
int newWidth = clientSize.width - ( pos.x - clientSize.x );
|
2021-06-18 03:04:34 +00:00
|
|
|
wxLogTrace( traceDisplayLocation,
|
|
|
|
"ensureWindowIsOnScreen: effective width %d above available %d, setting to %d",
|
|
|
|
pos.x + size.x, clientSize.width, newWidth );
|
|
|
|
size.x = newWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pos.y + size.y - clientSize.y > clientSize.height )
|
|
|
|
{
|
2021-06-18 22:15:00 +00:00
|
|
|
int newHeight = clientSize.height - ( pos.y - clientSize.y );
|
2021-06-18 03:04:34 +00:00
|
|
|
wxLogTrace( traceDisplayLocation,
|
|
|
|
"ensureWindowIsOnScreen: effective height %d above available %d, setting to %d",
|
|
|
|
pos.y + size.y, clientSize.height, newHeight );
|
|
|
|
size.y = newHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxLogTrace( traceDisplayLocation, "Updating window position (%d, %d) with size (%d, %d)",
|
|
|
|
pos.x, pos.y, size.x, size.y );
|
|
|
|
|
|
|
|
SetSize( pos.x, pos.y, size.x, size.y );
|
2020-08-24 02:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::LoadWindowSettings( const WINDOW_SETTINGS* aCfg )
|
|
|
|
{
|
|
|
|
LoadWindowState( aCfg->state );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_perspective = aCfg->perspective;
|
|
|
|
m_mruPath = aCfg->mru_path;
|
2019-07-25 16:48:11 +00:00
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
TOOLS_HOLDER::CommonSettingsChanged( false, false );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg )
|
2007-05-06 16:03:28 +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
|
|
|
if( IsIconized() )
|
2008-03-04 14:27:48 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-04-26 23:14:12 +00:00
|
|
|
// If the window is maximized, we use the saved window size from before it was maximized
|
|
|
|
if( IsMaximized() )
|
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos = m_normalFramePos;
|
|
|
|
m_frameSize = m_normalFrameSize;
|
2020-04-26 23:14:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
m_frameSize = GetWindowSize();
|
|
|
|
m_framePos = GetPosition();
|
2020-04-26 23:14:12 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
aCfg->state.pos_x = m_framePos.x;
|
|
|
|
aCfg->state.pos_y = m_framePos.y;
|
|
|
|
aCfg->state.size_x = m_frameSize.x;
|
|
|
|
aCfg->state.size_y = m_frameSize.y;
|
2020-08-24 02:01:14 +00:00
|
|
|
aCfg->state.maximized = IsMaximized();
|
|
|
|
aCfg->state.display = wxDisplay::GetFromWindow( this );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2021-07-14 19:47:32 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Saving window maximized: %s",
|
|
|
|
IsMaximized() ? "true" : "false" );
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)",
|
2020-11-16 11:16:44 +00:00
|
|
|
m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2014-01-28 01:29:26 +00:00
|
|
|
// Once this is fully implemented, wxAuiManager will be used to maintain
|
2021-04-05 13:24:57 +00:00
|
|
|
// the persistence of the main frame and all it's managed windows and
|
2014-01-28 01:29:26 +00:00
|
|
|
// all of the legacy frame persistence position code can be removed.
|
2020-01-13 01:44:19 +00:00
|
|
|
aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
|
|
|
|
|
|
|
|
aCfg->mru_path = m_mruPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
LoadWindowSettings( GetWindowSettings( aCfg ) );
|
2020-05-16 21:47:01 +00:00
|
|
|
|
|
|
|
// Get file history size from common settings
|
|
|
|
int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
|
|
|
|
|
|
|
|
// Load the recently used files into the history menu
|
|
|
|
m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ),
|
|
|
|
ID_FILE1, ID_FILE_LIST_CLEAR );
|
|
|
|
m_fileHistory->Load( *aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
SaveWindowSettings( GetWindowSettings( aCfg ) );
|
2020-05-16 21:47:01 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
bool fileOpen = m_isClosing && m_isNonUserClose;
|
|
|
|
|
2020-08-26 22:36:42 +00:00
|
|
|
wxString currentlyOpenedFile = GetCurrentFileName();
|
|
|
|
|
2020-08-30 16:44:23 +00:00
|
|
|
if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
|
2020-08-26 22:36:42 +00:00
|
|
|
{
|
|
|
|
wxFileName rfn( currentlyOpenedFile );
|
|
|
|
rfn.MakeRelativeTo( Prj().GetProjectPath() );
|
|
|
|
Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
|
|
|
|
}
|
2020-08-24 02:01:14 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
// Save the recently used files list
|
|
|
|
if( m_fileHistory )
|
2020-05-16 23:08:01 +00:00
|
|
|
{
|
|
|
|
// Save the currently opened file in the file history
|
|
|
|
if( !currentlyOpenedFile.IsEmpty() )
|
|
|
|
UpdateFileHistory( currentlyOpenedFile );
|
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
m_fileHistory->Save( *aCfg );
|
2020-05-16 23:08:01 +00:00
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
WINDOW_SETTINGS* EDA_BASE_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
return &aCfg->m_Window;
|
* 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
|
|
|
}
|
2014-01-28 01:29:26 +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
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
APP_SETTINGS_BASE* EDA_BASE_FRAME::config() const
|
* 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
|
|
|
{
|
|
|
|
// KICAD_MANAGER_FRAME overrides this
|
2020-04-12 23:09:17 +00:00
|
|
|
return Kiface().KifaceSettings();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-14 18:49:52 +00:00
|
|
|
const SEARCH_STACK& EDA_BASE_FRAME::sys_search()
|
|
|
|
{
|
|
|
|
return Kiface().KifaceSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString EDA_BASE_FRAME::help_name()
|
|
|
|
{
|
|
|
|
return Kiface().GetHelpFileName();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void EDA_BASE_FRAME::PrintMsg( const wxString& text )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
SetStatusText( text );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
void EDA_BASE_FRAME::CreateInfoBar()
|
|
|
|
{
|
|
|
|
#if defined( __WXOSX_MAC__ )
|
|
|
|
m_infoBar = new WX_INFOBAR( GetToolCanvas() );
|
|
|
|
#else
|
2020-12-22 21:53:46 +00:00
|
|
|
m_infoBar = new WX_INFOBAR( this, &m_auimgr );
|
2020-12-22 21:35:25 +00:00
|
|
|
|
|
|
|
m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::FinishAUIInitialization()
|
|
|
|
{
|
|
|
|
#if defined( __WXOSX_MAC__ )
|
|
|
|
m_auimgr.Update();
|
|
|
|
#else
|
|
|
|
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
|
2021-04-05 13:24:57 +00:00
|
|
|
// hiding it.
|
2020-12-22 21:35:25 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// We don't want the infobar displayed right away
|
|
|
|
m_auimgr.GetPane( "InfoBar" ).Hide();
|
|
|
|
m_auimgr.Update();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-01 20:51:08 +00:00
|
|
|
void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
|
|
|
|
WX_INFOBAR::MESSAGE_TYPE aType )
|
2020-08-31 13:19:57 +00:00
|
|
|
{
|
2020-10-16 16:07:59 +00:00
|
|
|
m_infoBar->RemoveAllButtons();
|
2020-12-04 13:45:14 +00:00
|
|
|
|
|
|
|
if( aShowCloseButton )
|
|
|
|
m_infoBar->AddCloseButton();
|
|
|
|
|
2021-08-01 20:51:08 +00:00
|
|
|
GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType );
|
2020-08-31 13:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-04 17:51:50 +00:00
|
|
|
void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
|
|
|
|
std::function<void(void)> aCallback )
|
|
|
|
{
|
|
|
|
m_infoBar->RemoveAllButtons();
|
|
|
|
|
|
|
|
if( aShowCloseButton )
|
|
|
|
m_infoBar->AddCloseButton();
|
|
|
|
|
|
|
|
if( aCallback )
|
|
|
|
m_infoBar->SetCallback( aCallback );
|
|
|
|
|
2021-04-21 14:29:51 +00:00
|
|
|
GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
|
2021-01-04 17:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-04 13:45:14 +00:00
|
|
|
void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
|
2020-08-31 13:19:57 +00:00
|
|
|
{
|
2020-10-16 16:07:59 +00:00
|
|
|
m_infoBar->RemoveAllButtons();
|
2020-12-04 13:45:14 +00:00
|
|
|
|
|
|
|
if( aShowCloseButton )
|
|
|
|
m_infoBar->AddCloseButton();
|
|
|
|
|
2021-04-21 14:29:51 +00:00
|
|
|
GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
|
2020-08-31 13:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-04 13:45:14 +00:00
|
|
|
void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
|
2020-08-31 13:19:57 +00:00
|
|
|
{
|
2020-10-16 16:07:59 +00:00
|
|
|
m_infoBar->RemoveAllButtons();
|
2020-12-04 13:45:14 +00:00
|
|
|
|
|
|
|
if( aShowCloseButton )
|
|
|
|
m_infoBar->AddCloseButton();
|
|
|
|
|
2021-04-21 14:29:51 +00:00
|
|
|
GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
|
2020-08-31 13:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-23 16:54:48 +00:00
|
|
|
void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-05-16 21:47:01 +00:00
|
|
|
if( !aFileHistory )
|
|
|
|
aFileHistory = m_fileHistory;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
wxASSERT( aFileHistory );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
aFileHistory->AddFileToHistory( FullFileName );
|
2020-04-05 17:05:24 +00:00
|
|
|
|
|
|
|
// Update the menubar to update the file history menu
|
2020-08-24 02:01:14 +00:00
|
|
|
if( !m_isClosing && GetMenuBar() )
|
2020-04-05 17:05:24 +00:00
|
|
|
{
|
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
|
|
|
}
|
2009-01-17 20:31:19 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-03-17 19:14:45 +00:00
|
|
|
wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
|
2019-11-23 16:54:48 +00:00
|
|
|
FILE_HISTORY* aFileHistory )
|
2009-01-17 20:31:19 +00:00
|
|
|
{
|
2020-05-16 21:47:01 +00:00
|
|
|
if( !aFileHistory )
|
|
|
|
aFileHistory = m_fileHistory;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
wxASSERT( aFileHistory );
|
2011-03-17 19:14:45 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
int baseId = aFileHistory->GetBaseId();
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
|
2009-01-17 20:31:19 +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
|
|
|
unsigned i = cmdId - baseId;
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
if( i < aFileHistory->GetCount() )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2020-05-16 21:47:01 +00:00
|
|
|
wxString fn = aFileHistory->GetHistoryFile( i );
|
2011-10-13 19:56:32 +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
|
|
|
if( wxFileName::FileExists( fn ) )
|
2021-06-27 09:58:05 +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
|
|
|
return fn;
|
2021-06-27 09:58:05 +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
|
|
|
else
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2021-06-27 09:58:05 +00:00
|
|
|
DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
|
2020-05-16 21:47:01 +00:00
|
|
|
aFileHistory->RemoveFileFromHistory( i );
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
// Update the menubar to update the file history menu
|
|
|
|
if( GetMenuBar() )
|
|
|
|
{
|
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
|
|
|
}
|
|
|
|
|
* 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
|
|
|
return wxEmptyString;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
void EDA_BASE_FRAME::ClearFileHistory( FILE_HISTORY* aFileHistory )
|
|
|
|
{
|
|
|
|
if( !aFileHistory )
|
2020-05-16 21:47:01 +00:00
|
|
|
aFileHistory = m_fileHistory;
|
|
|
|
|
|
|
|
wxASSERT( aFileHistory );
|
2020-02-25 15:46:56 +00:00
|
|
|
|
|
|
|
aFileHistory->ClearFileHistory();
|
2020-05-16 21:47:01 +00:00
|
|
|
|
|
|
|
// Update the menubar to update the file history menu
|
|
|
|
if( GetMenuBar() )
|
|
|
|
{
|
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
|
|
|
}
|
2020-02-25 15:46:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-07-14 19:47:32 +00:00
|
|
|
void ShowAboutDialog( EDA_BASE_FRAME * aParent ); // See AboutDialog_main.cpp
|
* 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
|
|
|
ShowAboutDialog( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2010-08-24 17:26:51 +00:00
|
|
|
|
|
|
|
|
2021-06-07 19:45:17 +00:00
|
|
|
void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2020-07-15 23:08:16 +00:00
|
|
|
PAGED_DIALOG dlg( this, _( "Preferences" ), true );
|
2018-07-15 23:15:48 +00:00
|
|
|
wxTreebook* book = dlg.GetTreebook();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
|
|
|
|
KIFACE* kiface = nullptr;
|
|
|
|
std::vector<int> expand;
|
2019-07-30 17:12:16 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
Kiway().GetActions( hotkeysPanel->ActionsList() );
|
2020-05-17 00:19:48 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
|
|
|
|
book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Touchpad" ) );
|
2019-06-09 21:57:23 +00:00
|
|
|
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2022-04-02 01:21:55 +00:00
|
|
|
#ifdef KICAD_USE_SENTRY
|
|
|
|
book->AddPage( new PANEL_DATA_COLLECTION( &dlg, book ), _( "Data Collection" ) );
|
|
|
|
#endif
|
|
|
|
|
2022-11-08 09:14:40 +00:00
|
|
|
#define CREATE_PANEL( key ) kiface->CreateKiWindow( book, key, &Kiway() )
|
2021-06-11 09:17:52 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
// If a dll is not loaded, the loader will show an error message.
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
kiface = Kiway().KiFACE( KIWAY::FACE_SCH );
|
2021-06-11 09:17:52 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
kiface->GetActions( hotkeysPanel->ActionsList() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_SCH_SYMBOL_EDITOR )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SYM_DISP_OPTIONS ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SYM_COLORS ), _( "Colors" ) );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_SCH )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SCH_DISP_OPTIONS ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SCH_EDIT_OPTIONS ), _( "Editing Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SCH_ANNO_OPTIONS ), _( "Annotation Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SCH_COLORS ), _( "Colors" ) );
|
2022-10-22 19:49:03 +00:00
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_SCH_FIELD_NAME_TEMPLATES ),
|
|
|
|
_( "Field Name Templates" ) );
|
2022-08-27 09:36:37 +00:00
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
}
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
kiface = Kiway().KiFACE( KIWAY::FACE_PCB );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
kiface->GetActions( hotkeysPanel->ActionsList() );
|
2021-06-11 09:17:52 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_FOOTPRINT_EDITOR )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2019-06-14 10:55:54 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_FP_DISPLAY_OPTIONS ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_FP_COLORS ), _( "Colors" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_FP_DEFAULT_VALUES ), _( "Default Values" ) );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_PCB_EDITOR )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "PCB Editor" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_PCB_DISPLAY_OPTIONS ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_PCB_EDIT_OPTIONS ), _( "Editing Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_PCB_COLORS ), _( "Colors" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_PCB_ACTION_PLUGINS ), _( "Action Plugins" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_PCB_ORIGINS_AXES ), _( "Origins & Axes" ) );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_PCB_DISPLAY3D )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_3DV_COLORS ), _( "Colors" ) );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
}
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
kiface = Kiway().KiFACE( KIWAY::FACE_GERBVIEW );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
kiface->GetActions( hotkeysPanel->ActionsList() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_GERBER )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) );
|
2022-09-10 15:11:24 +00:00
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_GBR_COLORS ), _( "Colors" ) );
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
}
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
kiface = Kiway().KiFACE( KIWAY::FACE_PL_EDITOR );
|
|
|
|
kiface->GetActions( hotkeysPanel->ActionsList() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
if( GetFrameType() == FRAME_PL_EDITOR )
|
|
|
|
expand.push_back( book->GetPageCount() );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_DS_DISPLAY_OPTIONS ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( CREATE_PANEL( PANEL_DS_COLORS ), _( "Colors" ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2022-08-27 09:36:37 +00:00
|
|
|
book->AddPage( new PANEL_PCM_SETTINGS( book ), _( "Plugin and Content Manager" ) );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
}
|
2022-06-23 17:36:25 +00:00
|
|
|
|
|
|
|
// Update all of the action hotkeys. The process of loading the actions through
|
|
|
|
// the KiFACE will only get us the default hotkeys
|
|
|
|
ReadHotKeyConfigIntoActions( wxEmptyString, hotkeysPanel->ActionsList() );
|
|
|
|
|
2020-03-22 08:45:51 +00:00
|
|
|
for( size_t i = 0; i < book->GetPageCount(); ++i )
|
2020-03-10 18:46:57 +00:00
|
|
|
book->GetPage( i )->Layout();
|
2019-06-12 12:43:24 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
for( int page : expand )
|
|
|
|
book->ExpandNode( page );
|
|
|
|
|
2020-10-18 16:43:38 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2022-07-27 15:07:33 +00:00
|
|
|
{
|
|
|
|
Pgm().GetSettingsManager().Save();
|
2020-10-18 16:43:38 +00:00
|
|
|
dlg.Kiway().CommonSettingsChanged( false, false );
|
2022-07-27 15:07:33 +00:00
|
|
|
}
|
2021-08-29 23:33:08 +00:00
|
|
|
|
|
|
|
#undef CREATE_PANEL
|
2018-05-14 17:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
void EDA_BASE_FRAME::OnDropFiles( wxDropFilesEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxString* files = aEvent.GetFiles();
|
2022-10-22 19:49:03 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
for( int nb = 0; nb < aEvent.GetNumberOfFiles(); nb++ )
|
|
|
|
{
|
|
|
|
const wxFileName fn = wxFileName( files[nb] );
|
|
|
|
for( const auto& [ext, tool] : m_acceptedExts )
|
|
|
|
{
|
|
|
|
if( IsExtensionAccepted( fn.GetExt(), { ext.ToStdString() } ) )
|
|
|
|
{
|
|
|
|
m_AcceptedFiles.emplace( m_AcceptedFiles.end(), fn );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-22 19:49:03 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
DoWithAcceptedFiles();
|
|
|
|
m_AcceptedFiles.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::DoWithAcceptedFiles()
|
|
|
|
{
|
2022-09-19 23:19:15 +00:00
|
|
|
for( const wxFileName& file : m_AcceptedFiles )
|
2022-09-14 22:28:09 +00:00
|
|
|
{
|
|
|
|
wxString fn = file.GetFullPath();
|
|
|
|
m_toolManager->RunAction( *m_acceptedExts.at( file.GetExt() ), true, &fn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-17 02:02:23 +00:00
|
|
|
bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName, bool aVerbose )
|
2011-08-18 19:25:12 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2011-11-11 16:08:58 +00:00
|
|
|
wxFileName fn = aFileName;
|
2011-08-18 19:25:12 +00:00
|
|
|
|
2011-11-11 16:08:58 +00:00
|
|
|
// Check for absence of a file path with a file name. Unfortunately KiCad
|
|
|
|
// uses paths relative to the current project path without the ./ part which
|
|
|
|
// confuses wxFileName. Making the file name path absolute may be less than
|
|
|
|
// elegant but it solves the problem.
|
|
|
|
if( fn.GetPath().IsEmpty() && fn.HasName() )
|
|
|
|
fn.MakeAbsolute();
|
|
|
|
|
|
|
|
wxCHECK_MSG( fn.IsOk(), false,
|
2011-10-28 20:30:50 +00:00
|
|
|
wxT( "File name object is invalid. Bad programmer!" ) );
|
2011-11-11 16:08:58 +00:00
|
|
|
wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
|
|
|
|
wxT( "File name object path <" ) + fn.GetFullPath() +
|
2011-10-28 20:30:50 +00:00
|
|
|
wxT( "> is not set. Bad programmer!" ) );
|
2011-08-18 19:25:12 +00:00
|
|
|
|
2011-11-11 16:08:58 +00:00
|
|
|
if( fn.IsDir() && !fn.IsDirWritable() )
|
2011-08-18 19:25:12 +00:00
|
|
|
{
|
2022-09-10 15:11:24 +00:00
|
|
|
msg.Printf( _( "Insufficient permissions to folder '%s'." ), fn.GetPath() );
|
2011-08-18 19:25:12 +00:00
|
|
|
}
|
2011-11-11 16:08:58 +00:00
|
|
|
else if( !fn.FileExists() && !fn.IsDirWritable() )
|
2011-08-18 19:25:12 +00:00
|
|
|
{
|
2022-09-10 15:11:24 +00:00
|
|
|
msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
|
2011-08-18 19:25:12 +00:00
|
|
|
}
|
2011-11-11 16:08:58 +00:00
|
|
|
else if( fn.FileExists() && !fn.IsFileWritable() )
|
2011-08-18 19:25:12 +00:00
|
|
|
{
|
2022-09-10 15:11:24 +00:00
|
|
|
msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
|
2011-08-18 19:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
2021-11-17 02:02:23 +00:00
|
|
|
if( aVerbose )
|
|
|
|
wxMessageBox( msg );
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-10-15 13:25:57 +00:00
|
|
|
|
|
|
|
|
2019-03-18 12:22:33 +00:00
|
|
|
void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
|
2011-10-15 13:25:57 +00:00
|
|
|
{
|
|
|
|
wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
|
|
|
|
|
|
|
|
wxFileName autoSaveFileName = aFileName;
|
|
|
|
|
|
|
|
// Check for auto save file.
|
2019-03-18 12:22:33 +00:00
|
|
|
autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
|
|
|
wxLogTrace( traceAutoSave,
|
|
|
|
wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
|
|
|
|
|
|
|
|
if( !autoSaveFileName.FileExists() )
|
|
|
|
return;
|
|
|
|
|
2022-10-12 09:55:41 +00:00
|
|
|
wxString msg = wxString::Format( _( "Well this is potentially embarrassing!\n"
|
|
|
|
"It appears that the last time you were editing\n"
|
|
|
|
"%s\n"
|
|
|
|
"KiCad exited before saving.\n"
|
|
|
|
"\n"
|
|
|
|
"Do you wish to open the auto-saved file instead?" ),
|
|
|
|
aFileName.GetFullName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2021-03-09 16:45:05 +00:00
|
|
|
int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
|
|
|
|
this );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
|
|
|
// Make a backup of the current file, delete the file, and rename the auto save file to
|
|
|
|
// the file name.
|
|
|
|
if( response == wxYES )
|
|
|
|
{
|
|
|
|
if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
|
2021-03-09 16:45:05 +00:00
|
|
|
Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
|
2011-10-15 13:25:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxLogTrace( traceAutoSave,
|
|
|
|
wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
|
|
|
|
|
|
|
|
// Remove the auto save file when using the previous file as is.
|
|
|
|
wxRemoveFile( autoSaveFileName.GetFullPath() );
|
|
|
|
}
|
|
|
|
}
|
2017-01-17 05:57:53 +00:00
|
|
|
|
|
|
|
|
2021-05-27 23:07:48 +00:00
|
|
|
bool EDA_BASE_FRAME::IsContentModified() const
|
2019-12-19 15:34:01 +00:00
|
|
|
{
|
|
|
|
// This function should be overridden in child classes
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-13 01:27:47 +00:00
|
|
|
|
2020-04-26 23:14:12 +00:00
|
|
|
|
2021-02-09 19:41:36 +00:00
|
|
|
void EDA_BASE_FRAME::initExitKey()
|
|
|
|
{
|
|
|
|
wxAcceleratorEntry entries[1];
|
|
|
|
entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
|
|
|
|
wxAcceleratorTable accel( 1, entries );
|
|
|
|
SetAcceleratorTable( accel );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
void EDA_BASE_FRAME::ClearUndoRedoList()
|
|
|
|
{
|
2020-07-13 13:50:35 +00:00
|
|
|
ClearUndoORRedoList( UNDO_LIST );
|
|
|
|
ClearUndoORRedoList( REDO_LIST );
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
|
|
|
|
{
|
2020-07-13 13:50:35 +00:00
|
|
|
m_undoList.PushCommand( aNewitem );
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
// Delete the extra items, if count max reached
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_undoRedoCountMax > 0 )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
if( extraitems > 0 )
|
2020-07-13 13:50:35 +00:00
|
|
|
ClearUndoORRedoList( UNDO_LIST, extraitems );
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
|
|
|
|
{
|
2020-07-13 13:50:35 +00:00
|
|
|
m_redoList.PushCommand( aNewitem );
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
// Delete the extra items, if count max reached
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_undoRedoCountMax > 0 )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
if( extraitems > 0 )
|
2020-07-13 13:50:35 +00:00
|
|
|
ClearUndoORRedoList( REDO_LIST, extraitems );
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromUndoList( )
|
|
|
|
{
|
2020-07-13 13:50:35 +00:00
|
|
|
return m_undoList.PopCommand();
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromRedoList( )
|
|
|
|
{
|
2020-07-13 13:50:35 +00:00
|
|
|
return m_redoList.PopCommand();
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-10 13:03:10 +00:00
|
|
|
void EDA_BASE_FRAME::OnModify()
|
|
|
|
{
|
|
|
|
m_autoSaveRequired = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-13 01:27:47 +00:00
|
|
|
void EDA_BASE_FRAME::ChangeUserUnits( EDA_UNITS aUnits )
|
|
|
|
{
|
|
|
|
SetUserUnits( aUnits );
|
|
|
|
unitsChangeRefresh();
|
|
|
|
|
|
|
|
wxCommandEvent e( UNITS_CHANGED );
|
|
|
|
ProcessEventLocally( e );
|
|
|
|
}
|
2020-04-26 23:14:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
// When we maximize the window, we want to save the old information
|
|
|
|
// so that we can add it to the settings on next window load.
|
|
|
|
// Contrary to the documentation, this event seems to be generated
|
2020-06-19 19:13:03 +00:00
|
|
|
// when the window is also being unmaximized on OSX, so we only
|
|
|
|
// capture the size information when we maximize the window when on OSX.
|
|
|
|
#ifdef __WXOSX__
|
2020-04-26 23:14:12 +00:00
|
|
|
if( !IsMaximized() )
|
2020-06-19 19:13:03 +00:00
|
|
|
#endif
|
2020-04-26 23:14:12 +00:00
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
m_normalFrameSize = GetWindowSize();
|
|
|
|
m_normalFramePos = GetPosition();
|
2021-07-14 19:47:32 +00:00
|
|
|
wxLogTrace( traceDisplayLocation,
|
|
|
|
"Maximizing window - Saving position (%d, %d) with size (%d, %d)",
|
|
|
|
m_normalFramePos.x, m_normalFramePos.y,
|
|
|
|
m_normalFrameSize.x, m_normalFrameSize.y );
|
2020-04-26 23:14:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip event to actually maximize the window
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
2020-05-06 13:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxSize EDA_BASE_FRAME::GetWindowSize()
|
|
|
|
{
|
2020-06-19 19:13:03 +00:00
|
|
|
#ifdef __WXGTK__
|
2021-10-07 20:58:37 +00:00
|
|
|
wxSize winSize = GetSize();
|
|
|
|
|
2020-06-19 19:13:03 +00:00
|
|
|
// GTK includes the window decorations in the normal GetSize call,
|
|
|
|
// so we have to use a GTK-specific sizing call that returns the
|
|
|
|
// non-decorated window size.
|
2021-10-07 20:58:37 +00:00
|
|
|
if( m_ident == KICAD_MAIN_FRAME_T )
|
|
|
|
{
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
GTKDoGetSize( &width, &height );
|
2020-06-19 19:13:03 +00:00
|
|
|
|
2021-10-07 20:58:37 +00:00
|
|
|
winSize.Set( width, height );
|
|
|
|
}
|
2020-06-19 19:13:03 +00:00
|
|
|
#else
|
|
|
|
wxSize winSize = GetSize();
|
|
|
|
#endif
|
2020-05-06 13:51:07 +00:00
|
|
|
|
|
|
|
return winSize;
|
|
|
|
}
|
2021-03-26 15:50:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::HandleSystemColorChange()
|
|
|
|
{
|
|
|
|
// Update the icon theme when the system theme changes and update the toolbars
|
2021-09-13 22:30:22 +00:00
|
|
|
GetBitmapStore()->ThemeChanged();
|
|
|
|
ThemeChanged();
|
2021-03-26 15:50:08 +00:00
|
|
|
|
|
|
|
// This isn't handled by ThemeChanged()
|
|
|
|
if( GetMenuBar() )
|
|
|
|
{
|
|
|
|
// For icons in menus, icon scaling & hotkeys
|
|
|
|
ReCreateMenuBar();
|
|
|
|
GetMenuBar()->Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Call the handler to update the colors used in the frame
|
|
|
|
HandleSystemColorChange();
|
|
|
|
|
|
|
|
// Skip the change event to ensure the rest of the window controls get it
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
2021-09-06 02:12:59 +00:00
|
|
|
|
|
|
|
|
2022-03-31 19:03:41 +00:00
|
|
|
void EDA_BASE_FRAME::onIconize( wxIconizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Call the handler
|
|
|
|
handleIconizeEvent( aEvent );
|
|
|
|
|
|
|
|
// Skip the event.
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-06 02:22:27 +00:00
|
|
|
#ifdef _WIN32
|
2021-09-06 02:12:59 +00:00
|
|
|
WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
|
|
|
|
{
|
|
|
|
// This will help avoid the menu keeping focus when the alt key is released
|
|
|
|
// You can still trigger accelerators as long as you hold down alt
|
|
|
|
if( message == WM_SYSCOMMAND )
|
2022-10-22 19:49:03 +00:00
|
|
|
{
|
2021-09-06 02:12:59 +00:00
|
|
|
if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
|
|
|
|
return 0;
|
2022-10-22 19:49:03 +00:00
|
|
|
}
|
2021-09-06 02:12:59 +00:00
|
|
|
|
|
|
|
return wxFrame::MSWWindowProc( message, wParam, lParam );
|
|
|
|
}
|
2021-10-07 20:58:37 +00:00
|
|
|
#endif
|