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>
|
2018-04-13 13:58:25 +00:00
|
|
|
* Copyright (C) 1992-2018 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>
|
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>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <filehistory.h>
|
2016-03-11 16:40:24 +00:00
|
|
|
#include <id.h>
|
|
|
|
#include <kiface_i.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <menus_helpers.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <panel_hotkeys_editor.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>
|
|
|
|
#include <tool/action_manager.h>
|
2019-05-18 10:27:36 +00:00
|
|
|
#include <tool/action_menu.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>
|
|
|
|
#include <wx/display.h>
|
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
#include <wx/string.h>
|
2011-10-13 19:56:32 +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
|
|
|
|
static const int s_minsize_x = 500;
|
|
|
|
static const int s_minsize_y = 400;
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
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 )
|
2020-04-26 23:14:12 +00:00
|
|
|
EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
|
2019-05-18 10:27:36 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
|
2019-06-08 22:14:57 +00:00
|
|
|
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
|
|
|
|
long aStyle, const wxString& aFrameName, KIWAY* aKiway ) :
|
|
|
|
wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
|
2020-06-03 23:00:40 +00:00
|
|
|
TOOLS_HOLDER(),
|
2020-01-13 19:46:39 +00:00
|
|
|
KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
|
2020-06-03 23:00:40 +00:00
|
|
|
m_Ident( aFrameType ),
|
|
|
|
m_infoBar( nullptr ),
|
|
|
|
m_settingsManager( nullptr ),
|
2020-05-16 21:47:01 +00:00
|
|
|
m_fileHistory( nullptr ),
|
2020-06-03 23:00:40 +00:00
|
|
|
m_hasAutoSave( false ),
|
|
|
|
m_autoSaveState( false ),
|
|
|
|
m_autoSaveInterval(-1 ),
|
2020-01-13 19:46:39 +00:00
|
|
|
m_userUnits( EDA_UNITS::MILLIMETRES )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-10-13 19:56:32 +00:00
|
|
|
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
|
2020-06-03 23:00:40 +00:00
|
|
|
m_mruPath = wxStandardPaths::Get().GetDocumentsDir();
|
|
|
|
m_FrameSize = wxSize( s_minsize_x, s_minsize_y );
|
2008-03-04 14:27:48 +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
|
|
|
|
SetSizeHints( s_minsize_x, s_minsize_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.
|
2011-12-31 05:44:00 +00:00
|
|
|
GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
|
|
|
|
|
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 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
wxWindow* EDA_BASE_FRAME::findQuasiModalDialog()
|
2014-02-02 20:18:10 +00:00
|
|
|
{
|
2018-03-24 18:28:35 +00:00
|
|
|
for( auto& 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 );
|
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.
|
|
|
|
if( m_Ident == FRAME_SCH )
|
|
|
|
{
|
|
|
|
wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
|
|
|
|
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();
|
|
|
|
|
2014-08-29 17:49:49 +00:00
|
|
|
event.Veto();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
APP_SETTINGS_BASE* cfg = config();
|
2014-04-24 18:31:11 +00:00
|
|
|
|
|
|
|
if( cfg )
|
2019-09-19 07:11:45 +00:00
|
|
|
SaveSettings( cfg ); // virtual, wxFrame specific
|
2014-02-02 20:18:10 +00:00
|
|
|
|
|
|
|
event.Skip(); // we did not "handle" the event, only eavesdropped on it.
|
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
|
|
|
|
|
|
|
if( SupportsShutdownBlockReason() )
|
|
|
|
{
|
|
|
|
RemoveShutdownBlockReason();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_BASE_FRAME::SupportsShutdownBlockReason()
|
|
|
|
{
|
|
|
|
#if defined( _WIN32 )
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::RemoveShutdownBlockReason()
|
|
|
|
{
|
|
|
|
#if defined( _WIN32 )
|
|
|
|
// Windows: Destroys any block reason that may have existed
|
|
|
|
ShutdownBlockReasonDestroy( GetHandle() );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_BASE_FRAME::SetShutdownBlockReason( const wxString& aReason )
|
|
|
|
{
|
|
|
|
#if defined( _WIN32 )
|
|
|
|
// Windows: sets up the pretty message on the shutdown page on why it's being "blocked"
|
|
|
|
// This is used in conjunction with handling WM_QUERYENDSESSION (wxCloseEvent)
|
|
|
|
// ShutdownBlockReasonCreate does not block by itself
|
|
|
|
|
|
|
|
ShutdownBlockReasonDestroy( GetHandle() ); // Destroys any existing or nonexisting reason
|
|
|
|
|
|
|
|
if( !ShutdownBlockReasonCreate( GetHandle(), aReason.wc_str() ) )
|
|
|
|
{
|
|
|
|
// Nothing bad happens if this fails, at worst it uses a generic application is preventing shutdown message
|
|
|
|
wxLogDebug( wxT( "ShutdownBlockReasonCreate failed to set reason: %s" ), aReason );
|
|
|
|
}
|
|
|
|
#endif
|
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
|
|
|
|
2017-07-26 10:03:24 +00:00
|
|
|
if( IsShown() && m_hasAutoSave && IsActive() &&
|
2015-08-08 12:44:39 +00:00
|
|
|
(m_autoSaveState != isAutoSaveRequired()) && (m_autoSaveInterval > 0) )
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
|
|
|
if( !m_autoSaveState )
|
|
|
|
{
|
2011-10-15 13:25:57 +00:00
|
|
|
wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
|
2011-10-13 19:56:32 +00:00
|
|
|
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
|
|
|
m_autoSaveState = true;
|
|
|
|
}
|
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();
|
|
|
|
m_autoSaveState = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2016-11-22 10:07:33 +00:00
|
|
|
void EDA_BASE_FRAME::SetAutoSaveInterval( int aInterval )
|
|
|
|
{
|
|
|
|
m_autoSaveInterval = aInterval;
|
|
|
|
|
|
|
|
if( m_autoSaveTimer->IsRunning() )
|
|
|
|
{
|
|
|
|
if( m_autoSaveInterval > 0 )
|
|
|
|
{
|
|
|
|
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_autoSaveTimer->Stop();
|
|
|
|
m_autoSaveState = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( !doAutoSave() )
|
|
|
|
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool EDA_BASE_FRAME::doAutoSave()
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& event )
|
|
|
|
{
|
2019-07-27 14:11:41 +00:00
|
|
|
wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( event ) );
|
2019-06-09 13:12:44 +00:00
|
|
|
// Key events can be filtered here.
|
|
|
|
// Currently no filtering is made.
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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>();
|
2019-06-15 00:29:42 +00:00
|
|
|
ACTION_MENU* helpMenu = new ACTION_MENU( false );
|
2019-05-18 10:27:36 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
helpMenu->SetTool( 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 );
|
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();
|
2019-06-09 21:57:23 +00:00
|
|
|
helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
|
2019-05-18 10:27:36 +00:00
|
|
|
|
|
|
|
aMenuBar->Append( helpMenu, _( "&Help" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
|
2019-06-24 09:22:49 +00:00
|
|
|
void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
|
2017-03-02 13:46:18 +00:00
|
|
|
{
|
2020-03-24 01:01:23 +00:00
|
|
|
TOOLS_HOLDER::CommonSettingsChanged( aEnvVarsChanged );
|
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 ) );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void EDA_BASE_FRAME::LoadWindowSettings( WINDOW_SETTINGS* aCfg )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-04-17 23:32:29 +00:00
|
|
|
m_FramePos.x = aCfg->pos_x;
|
|
|
|
m_FramePos.y = aCfg->pos_y;
|
2020-01-13 01:44:19 +00:00
|
|
|
m_FrameSize.x = aCfg->size_x;
|
|
|
|
m_FrameSize.y = aCfg->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)",
|
|
|
|
m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
// Ensure minimum size is set if the stored config was zero-initialized
|
2020-02-25 01:14:06 +00:00
|
|
|
if( m_FrameSize.x < s_minsize_x || m_FrameSize.y < s_minsize_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
|
|
|
{
|
2020-02-25 01:14:06 +00:00
|
|
|
m_FrameSize.x = s_minsize_x;
|
|
|
|
m_FrameSize.y = s_minsize_y;
|
2020-04-17 23:32:29 +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
|
|
|
wxPoint upperRight( m_FramePos.x + m_FrameSize.x, m_FramePos.y );
|
|
|
|
wxPoint upperLeft( m_FramePos.x, m_FramePos.y );
|
|
|
|
|
|
|
|
// Check to see if the requested display is still attached to the computer
|
|
|
|
int leftInd = wxDisplay::GetFromPoint( upperLeft );
|
|
|
|
int rightInd = wxDisplay::GetFromPoint( upperRight );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Number of displays: %d", wxDisplay::GetCount() );
|
|
|
|
wxLogTrace( traceDisplayLocation, "Previous display indices: %d and %d", leftInd, rightInd );
|
|
|
|
|
|
|
|
if( rightInd == wxNOT_FOUND && leftInd == wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
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-04-17 23:32:29 +00:00
|
|
|
wxRect clientSize = display.GetClientArea();
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogDebug( "Client size (%d, %d)", clientSize.width, clientSize.height );
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2016-05-23 08:51:17 +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
|
|
|
|
if( m_FrameSize.x > clientSize.width )
|
|
|
|
m_FrameSize.x = clientSize.width;
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-04-17 23:32:29 +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-04-17 23:32:29 +00:00
|
|
|
wxRect clientSize;
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
if( leftInd == wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
// If the top-left point is off-screen, use the display for the top-right point
|
|
|
|
wxDisplay display( rightInd );
|
|
|
|
clientSize = display.GetClientArea();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxDisplay display( leftInd );
|
|
|
|
clientSize = display.GetClientArea();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The percentage size (represented in decimal) of the region around the screen's border where
|
|
|
|
// an upper corner is not allowed
|
|
|
|
#define SCREEN_BORDER_REGION 0.10
|
|
|
|
|
|
|
|
int yLim = clientSize.y + ( clientSize.height * ( 1.0 - SCREEN_BORDER_REGION ) );
|
|
|
|
int xLimLeft = clientSize.x + ( clientSize.width * SCREEN_BORDER_REGION );
|
|
|
|
int xLimRight = clientSize.x + ( clientSize.width * ( 1.0 - SCREEN_BORDER_REGION ) );
|
|
|
|
|
|
|
|
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
|
|
|
|
upperRight.y > yLim ) // Upper corner too close to the bottom of the screen
|
|
|
|
{
|
|
|
|
m_FramePos = wxDefaultPosition;
|
|
|
|
wxLogTrace( traceDisplayLocation, "Resetting to default position" );
|
|
|
|
}
|
|
|
|
}
|
2020-02-21 20:52:30 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
// Ensure Window title bar is visible
|
2020-04-17 23:32:29 +00:00
|
|
|
#if defined( __WXOSX__ )
|
2008-03-04 14:27:48 +00:00
|
|
|
// for macOSX, the window must be below system (macOSX) toolbar
|
* 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
|
|
|
int Ypos_min = 20;
|
2007-05-06 16:03:28 +00:00
|
|
|
#else
|
* 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
|
|
|
int Ypos_min = 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
2008-03-04 14:27:48 +00:00
|
|
|
if( m_FramePos.y < Ypos_min )
|
|
|
|
m_FramePos.y = Ypos_min;
|
2020-04-17 23:32:29 +00:00
|
|
|
|
|
|
|
wxLogTrace( traceDisplayLocation, "Final window position (%d, %d) with size (%d, %d)",
|
|
|
|
m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
|
|
|
// Center the window if we reset to default
|
|
|
|
if( m_FramePos.x == -1 )
|
|
|
|
{
|
|
|
|
wxLogTrace( traceDisplayLocation, "Centering window" );
|
|
|
|
Center();
|
|
|
|
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
|
|
|
|
m_NormalFrameSize = m_FrameSize;
|
|
|
|
m_NormalFramePos = m_FramePos;
|
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Maximize if we were maximized before
|
2020-01-13 01:44:19 +00:00
|
|
|
if( aCfg->maximized )
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if( m_hasAutoSave )
|
|
|
|
m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
|
2013-12-07 00:33:16 +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-03-24 01:01:23 +00:00
|
|
|
TOOLS_HOLDER::CommonSettingsChanged( 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
|
|
|
wxString text;
|
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
|
|
|
|
2015-08-31 06:43:33 +00:00
|
|
|
wxString baseCfgName = ConfigBaseName();
|
2015-03-03 14:53:47 +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() )
|
|
|
|
{
|
|
|
|
m_FramePos = m_NormalFramePos;
|
|
|
|
m_FrameSize = m_NormalFrameSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-06 13:51:07 +00:00
|
|
|
m_FrameSize = GetWindowSize();
|
2020-04-26 23:14:12 +00:00
|
|
|
m_FramePos = GetPosition();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-04-26 23:14:12 +00:00
|
|
|
aCfg->pos_x = m_FramePos.x;
|
|
|
|
aCfg->pos_y = m_FramePos.y;
|
|
|
|
aCfg->size_x = m_FrameSize.x;
|
|
|
|
aCfg->size_y = m_FrameSize.y;
|
2020-01-13 01:44:19 +00:00
|
|
|
aCfg->maximized = IsMaximized();
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
wxLogTrace( traceDisplayLocation, "Saving window maximized: %s", IsMaximized() ? "true" : "false" );
|
|
|
|
wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)",
|
|
|
|
m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
// TODO(JE) should auto-save in common settings be overwritten by every app?
|
2011-10-13 19:56:32 +00:00
|
|
|
if( m_hasAutoSave )
|
2020-01-13 01:44:19 +00:00
|
|
|
Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
|
2013-12-07 00:33:16 +00:00
|
|
|
|
2014-01-28 01:29:26 +00:00
|
|
|
// Once this is fully implemented, wxAuiManager will be used to maintain
|
|
|
|
// the persistance of the main frame and all it's managed windows and
|
|
|
|
// 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
|
|
|
|
|
|
|
// 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
|
|
|
|
wxString currentlyOpenedFile = GetCurrentFileName();
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
if( GetMenuBar() )
|
|
|
|
{
|
|
|
|
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 ) )
|
|
|
|
return fn;
|
|
|
|
else
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2018-08-20 13:46:38 +00:00
|
|
|
wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
|
2012-03-06 14:08:59 +00:00
|
|
|
wxMessageBox( msg );
|
* 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-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
|
|
|
{
|
2017-08-18 06:06:45 +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
|
|
|
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
|
|
|
PAGED_DIALOG dlg( this, _( "Preferences" ) );
|
2018-07-15 23:15:48 +00:00
|
|
|
wxTreebook* book = dlg.GetTreebook();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2018-07-15 23:15:48 +00:00
|
|
|
book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
|
2019-07-30 17:12:16 +00:00
|
|
|
|
2020-05-24 20:24:43 +00:00
|
|
|
book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Touchpad" ) );
|
2020-05-17 00:19:48 +00:00
|
|
|
|
2019-06-10 15:58:32 +00:00
|
|
|
PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
|
2019-06-09 21:57:23 +00:00
|
|
|
book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
|
|
|
|
{
|
|
|
|
KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
|
|
|
|
|
|
|
|
if( frame )
|
2019-06-09 21:57:23 +00:00
|
|
|
frame->InstallPreferences( &dlg, hotkeysPanel );
|
2018-05-14 17:34:18 +00:00
|
|
|
}
|
|
|
|
|
2019-06-12 12:43:24 +00:00
|
|
|
// The Kicad manager frame is not a player so we have to add it by hand
|
2019-06-14 10:55:54 +00:00
|
|
|
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
|
|
|
|
|
|
|
|
if( manager )
|
|
|
|
static_cast<EDA_BASE_FRAME*>( manager )->InstallPreferences( &dlg, hotkeysPanel );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
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
|
|
|
|
2018-08-19 16:06:59 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2019-06-24 09:22:49 +00:00
|
|
|
dlg.Kiway().CommonSettingsChanged( false );
|
2018-05-14 17:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
|
2011-11-11 16:08:58 +00:00
|
|
|
GetChars( 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
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
|
2011-11-11 16:08:58 +00:00
|
|
|
GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
|
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
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
|
2011-11-11 16:08:58 +00:00
|
|
|
GetChars( fn.GetFullPath() ) );
|
2011-08-18 19:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
2012-03-06 14:08:59 +00:00
|
|
|
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;
|
|
|
|
|
* 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
|
|
|
wxString msg = wxString::Format( _(
|
2015-05-03 13:48:05 +00:00
|
|
|
"Well this is potentially embarrassing!\n"
|
|
|
|
"It appears that the last time you were editing the file\n"
|
2017-12-15 11:37:46 +00:00
|
|
|
"\"%s\"\n"
|
2015-05-03 13:48:05 +00:00
|
|
|
"it was not saved properly. Do you wish to restore the last saved edits you made?" ),
|
* 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
|
|
|
GetChars( aFileName.GetFullName() )
|
|
|
|
);
|
2011-10-15 13:25:57 +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
|
|
|
int response = wxMessageBox( msg, Pgm().App().GetAppName(), 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." ),
|
* 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
|
|
|
Pgm().App().GetAppName(), 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
|
|
|
|
|
|
|
|
2019-12-19 15:34:01 +00:00
|
|
|
bool EDA_BASE_FRAME::IsContentModified()
|
|
|
|
{
|
|
|
|
// 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
|
|
|
|
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-05-06 13:51:07 +00:00
|
|
|
m_NormalFrameSize = GetWindowSize();
|
2020-04-26 23:14:12 +00:00
|
|
|
m_NormalFramePos = GetPosition();
|
|
|
|
wxLogTrace( traceDisplayLocation, "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
|
|
|
|
m_NormalFramePos.x, m_NormalFramePos.y, m_NormalFrameSize.x, m_NormalFrameSize.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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__
|
|
|
|
// 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.
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
GTKDoGetSize( &width, &height );
|
|
|
|
|
|
|
|
wxSize winSize( width, height );
|
|
|
|
#else
|
|
|
|
wxSize winSize = GetSize();
|
|
|
|
#endif
|
2020-05-06 13:51:07 +00:00
|
|
|
|
|
|
|
return winSize;
|
|
|
|
}
|