KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_base_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2023 CERN (www.cern.ch)
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
28#include "kicad_manager_frame.h"
29#include <eda_base_frame.h>
30
31#include <advanced_config.h>
32#include <bitmaps.h>
33#include <bitmap_store.h>
34#include <dialog_shim.h>
41#include <eda_dde.h>
42#include <file_history.h>
43#include <id.h>
44#include <kiface_base.h>
45#include <hotkeys_basic.h>
47#include <paths.h>
48#include <local_history.h>
49#include <confirm.h>
51#include <pgm_base.h>
56#include <tool/action_manager.h>
57#include <tool/action_menu.h>
58#include <tool/action_toolbar.h>
59#include <tool/actions.h>
60#include <tool/common_control.h>
61#include <tool/tool_manager.h>
64#include <trace_helpers.h>
67#include <widgets/wx_infobar.h>
70#include <widgets/wx_grid.h>
71#include <widgets/wx_treebook.h>
72#include <wx/app.h>
73#include <wx/config.h>
74#include <wx/display.h>
75#include <wx/stdpaths.h>
76#include <wx/string.h>
77#include <wx/msgdlg.h>
78#include <wx/wupdlock.h>
79#include <kiplatform/app.h>
80#include <kiplatform/io.h>
81#include <kiplatform/ui.h>
82
83#include <nlohmann/json.hpp>
84
85#include <functional>
86#include <kiface_ids.h>
87
88#ifdef KICAD_IPC_API
89#include <api/api_server.h>
90#endif
91
92
93// Minimum window size
94static const wxSize minSizeLookup( FRAME_T aFrameType, wxWindow* aWindow )
95{
96 switch( aFrameType )
97 {
99 return wxWindow::FromDIP( wxSize( 406, 354 ), aWindow );
100
101 default:
102 return wxWindow::FromDIP( wxSize( 500, 400 ), aWindow );
103 }
104}
105
106
107static const wxSize defaultSize( FRAME_T aFrameType, wxWindow* aWindow )
108{
109 switch( aFrameType )
110 {
112 return wxWindow::FromDIP( wxSize( 850, 540 ), aWindow );
113
114 default:
115 return wxWindow::FromDIP( wxSize( 1280, 720 ), aWindow );
116 }
117}
118
119
120BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
121 // These event table entries are needed to handle events from the mac application menu
122 EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
123 EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
124
125 EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
126 EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
127 EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
128 EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
129 EVT_MOVE( EDA_BASE_FRAME::OnMove )
130 EVT_SIZE( EDA_BASE_FRAME::OnSize )
131 EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
132
133 EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
134 EVT_ICONIZE( EDA_BASE_FRAME::onIconize )
135END_EVENT_TABLE()
136
137
139{
140 m_ident = aFrameType;
141 m_maximizeByDefault = false;
142 m_infoBar = nullptr;
143 m_settingsManager = nullptr;
144 m_fileHistory = nullptr;
145 m_supportsAutoSave = false;
146 m_autoSavePending = false;
148 m_isClosing = false;
149 m_isNonUserClose = false;
150 m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
151 m_autoSaveRequired = false;
154 m_frameSize = defaultSize( aFrameType, this );
155 m_displayIndex = -1;
156
157 m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
158
160
161 // Set a reasonable minimal size for the frame
162 wxSize minSize = minSizeLookup( aFrameType, this );
163 SetSizeHints( minSize.x, minSize.y, -1, -1, -1, -1 );
164
165 // Store dimensions of the user area of the main window.
166 GetClientSize( &m_frameSize.x, &m_frameSize.y );
167
168 Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
169 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
170
171 // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
172 // to be called before any other hook for wxCloseEvent, which is necessary.
173 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
174
175 initExitKey();
176}
177
178
179EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
180 const wxPoint& aPos, const wxSize& aSize, long aStyle,
181 const wxString& aFrameName, KIWAY* aKiway,
182 const EDA_IU_SCALE& aIuScale ) :
183 wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
184 TOOLS_HOLDER(),
185 KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
186 UNITS_PROVIDER( aIuScale, EDA_UNITS::MM )
187{
188 m_tbTopMain = nullptr;
189 m_tbTopAux = nullptr;
190 m_tbRight = nullptr;
191 m_tbLeft = nullptr;
192
193 commonInit( aFrameType );
194
195 // Register project file saver. Ensures project file participates in
196 // autosave history commits without affecting dirty state.
198 [this]( const wxString& aProjectPath, std::vector<wxString>& aFiles )
199 {
200 Prj().SaveToHistory( aProjectPath, aFiles );
201 } );
202
203}
204
205
206wxWindow* findQuasiModalDialog( wxWindow* aParent )
207{
208 for( wxWindow* child : aParent->GetChildren() )
209 {
210 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( child ) )
211 {
212 if( dlg->IsQuasiModal() )
213 return dlg;
214
215 if( wxWindow* nestedDlg = findQuasiModalDialog( child ) )
216 return nestedDlg;
217 }
218 }
219
220 return nullptr;
221}
222
223
225{
226 if( wxWindow* dlg = ::findQuasiModalDialog( this ) )
227 return dlg;
228
229 // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
230 // so we have to look for it separately.
231 if( m_ident == FRAME_SCH )
232 {
233 wxWindow* cvpcb = wxWindow::FindWindowByName( wxS( "CvpcbFrame" ) );
234
235 if( cvpcb )
236 return cvpcb;
237 }
238
239 return nullptr;
240}
241
242
243void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
244{
245 // Don't allow closing when a quasi-modal is open.
246 wxWindow* quasiModal = findQuasiModalDialog();
247
248 if( quasiModal )
249 {
250 // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
251 // when they have no idea what those are.
252 quasiModal->Raise();
253 wxBell();
254
255 if( event.CanVeto() )
256 event.Veto();
257
258 return;
259 }
260
261
262 if( event.GetId() == wxEVT_QUERY_END_SESSION
263 || event.GetId() == wxEVT_END_SESSION )
264 {
265 // End session means the OS is going to terminate us
266 m_isNonUserClose = true;
267 }
268
269 if( canCloseWindow( event ) )
270 {
271 m_isClosing = true;
272
273 if( m_infoBar )
274 m_infoBar->Dismiss();
275
276 APP_SETTINGS_BASE* cfg = config();
277
278 if( cfg )
279 SaveSettings( cfg ); // virtual, wxFrame specific
280
282
283 // Destroy (safe delete frame) this frame only in non modal mode.
284 // In modal mode, the caller will call Destroy().
285 if( !IsModal() )
286 Destroy();
287 }
288 else
289 {
290 if( event.CanVeto() )
291 event.Veto();
292 }
293}
294
295
297{
298 Disconnect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
299 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
300 Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
301
302 delete m_autoSaveTimer;
303 delete m_fileHistory;
304
306
308
310}
311
312
313bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
314{
315#ifdef __WXMAC__
316 // Apple in its infinite wisdom will raise a disabled window before even passing
317 // us the event, so we have no way to stop it. Instead, we have to catch an
318 // improperly ordered disabled window and quasi-modal dialog here and reorder
319 // them.
320 if( !IsEnabled() && IsActive() )
321 {
322 wxWindow* dlg = findQuasiModalDialog();
323
324 if( dlg )
325 dlg->Raise();
326 }
327#endif
328
329 if( !wxFrame::ProcessEvent( aEvent ) )
330 return false;
331
332 if( Pgm().m_Quitting )
333 return true;
334
335 if( !m_isClosing && m_supportsAutoSave && IsShownOnScreen() && IsActive()
337 && GetAutoSaveInterval() > 0 )
338 {
339 if( !m_autoSavePending )
340 {
341 wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
342 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
343 m_autoSavePending = true;
344 }
345 else if( m_autoSaveTimer->IsRunning() )
346 {
347 wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
348 m_autoSaveTimer->Stop();
349 m_autoSavePending = false;
350 }
351 }
352
353 return true;
354}
355
356
361
362
363void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
364{
365 // Don't stomp on someone else's timer event.
366 if( aEvent.GetId() != ID_AUTO_SAVE_TIMER )
367 {
368 aEvent.Skip();
369 return;
370 }
371
372 if( !doAutoSave() )
373 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
374}
375
376
378{
379 m_autoSaveRequired = false;
380 m_autoSavePending = false;
381 // Use registered saver callbacks to snapshot editor state into .history and only commit
382 // if there are material changes.
383 Kiway().LocalHistory().RunRegisteredSaversAndCommit( Prj().GetProjectPath(), wxS( "Autosave" ) );
384 return true;
385}
386
387
388void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
389{
390 wxLogTrace( kicadTraceKeyEvent, wxS( "EDA_BASE_FRAME::OnCharHook %s" ), dump( aKeyEvent ) );
391
392 // Key events can be filtered here.
393 // Currently no filtering is made.
394 aKeyEvent.Skip();
395}
396
397
398void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
399{
400 if( !m_toolDispatcher )
401 aEvent.Skip();
402 else
403 m_toolDispatcher->DispatchWxEvent( aEvent );
404}
405
406
408{
410 std::placeholders::_1,
411 this,
412 aConditions );
413
414 m_uiUpdateMap[aID] = evtFunc;
415
416 Bind( wxEVT_UPDATE_UI, evtFunc, aID );
417}
418
419
421{
422 const auto it = m_uiUpdateMap.find( aID );
423
424 if( it == m_uiUpdateMap.end() )
425 return;
426
427 Unbind( wxEVT_UPDATE_UI, it->second, aID );
428}
429
430
431void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
432 ACTION_CONDITIONS aCond )
433{
434 bool checkRes = false;
435 bool enableRes = true;
436 bool showRes = true;
437 bool isCut = aEvent.GetId() == ACTIONS::cut.GetUIId();
438 bool isCopy = aEvent.GetId() == ACTIONS::copy.GetUIId();
439 bool isPaste = aEvent.GetId() == ACTIONS::paste.GetUIId();
440 SELECTION& selection = aFrame->GetCurrentSelection();
441
442 try
443 {
444 checkRes = aCond.checkCondition( selection );
445 enableRes = aCond.enableCondition( selection );
446 showRes = aCond.showCondition( selection );
447 }
448 catch( std::exception& )
449 {
450 // Something broke with the conditions, just skip the event.
451 aEvent.Skip();
452 return;
453 }
454
455 if( showRes && aEvent.GetId() == ACTIONS::undo.GetUIId() )
456 {
457 wxString msg = _( "Undo" );
458
459 if( enableRes )
460 msg += wxS( " " ) + aFrame->GetUndoActionDescription();
461
462 aEvent.SetText( msg );
463 }
464 else if( showRes && aEvent.GetId() == ACTIONS::redo.GetUIId() )
465 {
466 wxString msg = _( "Redo" );
467
468 if( enableRes )
469 msg += wxS( " " ) + aFrame->GetRedoActionDescription();
470
471 aEvent.SetText( msg );
472 }
473
474 if( isCut || isCopy || isPaste )
475 {
476 wxWindow* focus = wxWindow::FindFocus();
477 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
478
479 if( textEntry && isCut && textEntry->CanCut() )
480 enableRes = true;
481 else if( textEntry && isCopy && textEntry->CanCopy() )
482 enableRes = true;
483 else if( textEntry && isPaste && textEntry->CanPaste() )
484 enableRes = true;
485 else if( dynamic_cast<WX_GRID*>( focus ) )
486 enableRes = false; // Must disable menu in order to get command as CharHook event
487 }
488
489 aEvent.Enable( enableRes );
490 aEvent.Show( showRes );
491
492 if( aEvent.IsCheckable() )
493 aEvent.Check( checkRes );
494}
495
496
498{
499 // Setup the conditions to check a language menu item
500 auto isCurrentLang =
501 [] ( const SELECTION& aSel, int aLangIdentifier )
502 {
503 return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
504 };
505
506 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
507 {
509 cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
510 LanguagesList[ii].m_WX_Lang_Identifier ) );
511 RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
512 }
513}
514
515
517 const ACTION_TOOLBAR_CONTROL_FACTORY& aControlFactory )
518{
519 m_toolbarControlFactories.emplace( aControlDesc.GetName(), aControlFactory );
520}
521
522
524{
525 for( auto& control : m_toolbarControlFactories )
526 {
527 if( control.first == aName )
528 return &control.second;
529 }
530
531 return nullptr;
532}
533
534
538
539
541{
542 wxWindowUpdateLocker dummy( this );
543
544 wxASSERT( m_toolbarSettings );
545
546 std::optional<TOOLBAR_CONFIGURATION> tbConfig;
547
548 // Drawing tools (typically on right edge of window)
549 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::RIGHT, config()->m_CustomToolbars );
550
551 if( tbConfig.has_value() )
552 {
553 if( !m_tbRight )
554 {
555 m_tbRight = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
556 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
557 m_tbRight->SetAuiManager( &m_auimgr );
558 }
559
560 m_tbRight->ApplyConfiguration( tbConfig.value() );
561 }
562
563 // Options (typically on left edge of window)
564 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::LEFT, config()->m_CustomToolbars );
565
566 if( tbConfig.has_value() )
567 {
568 if( !m_tbLeft )
569 {
570 m_tbLeft = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
571 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
572 m_tbLeft->SetAuiManager( &m_auimgr );
573 }
574
575 m_tbLeft->ApplyConfiguration( tbConfig.value() );
576 }
577
578 // Top main toolbar (the top one)
579 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_MAIN, config()->m_CustomToolbars );
580
581 if( tbConfig.has_value() )
582 {
583 if( !m_tbTopMain )
584 {
585 m_tbTopMain = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
586 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
587 m_tbTopMain->SetAuiManager( &m_auimgr );
588 }
589
590 m_tbTopMain->ApplyConfiguration( tbConfig.value() );
591 }
592
593 // Top aux toolbar (the bottom one)
594 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_AUX, config()->m_CustomToolbars );
595
596 if( tbConfig.has_value() )
597 {
598 if( !m_tbTopAux )
599 {
600 m_tbTopAux = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
601 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
602 m_tbTopAux->SetAuiManager( &m_auimgr );
603 }
604
605 m_tbTopAux->ApplyConfiguration( tbConfig.value() );
606 }
607}
608
609
611{
612 if( m_tbTopMain )
613 m_tbTopMain->UpdateControlWidths();
614
615 if( m_tbRight )
616 m_tbRight->UpdateControlWidths();
617
618 if( m_tbLeft )
619 m_tbLeft->UpdateControlWidths();
620
621 if( m_tbTopAux )
622 m_tbTopAux->UpdateControlWidths();
623
624}
625
626
628{
629 if( m_tbTopMain )
630 m_auimgr.GetPane( m_tbTopMain ).MaxSize( m_tbTopMain->GetSize() );
631
632 if( m_tbRight )
633 m_auimgr.GetPane( m_tbRight ).MaxSize( m_tbRight->GetSize() );
634
635 if( m_tbLeft )
636 m_auimgr.GetPane( m_tbLeft ).MaxSize( m_tbLeft->GetSize() );
637
638 if( m_tbTopAux )
639 m_auimgr.GetPane( m_tbTopAux ).MaxSize( m_tbTopAux->GetSize() );
640
641 m_auimgr.Update();
642}
643
644
646{
653
654 CallAfter( [this]()
655 {
656 if( !m_isClosing )
658 } );
659}
660
661
662void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
663{
664 COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
665 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
666
667 helpMenu->Add( ACTIONS::help );
668 helpMenu->Add( ACTIONS::gettingStarted );
669 helpMenu->Add( ACTIONS::listHotKeys );
670 helpMenu->Add( ACTIONS::getInvolved );
671 helpMenu->Add( ACTIONS::donate );
672 helpMenu->Add( ACTIONS::reportBug );
673
674 helpMenu->AppendSeparator();
675 helpMenu->Add( ACTIONS::about );
676
677 aMenuBar->Append( helpMenu, _( "&Help" ) );
678}
679
680
681
683{
684 wxString menuItemLabel = aAction.GetMenuLabel();
685 wxMenuBar* menuBar = GetMenuBar();
686
687 for( size_t ii = 0; ii < menuBar->GetMenuCount(); ++ii )
688 {
689 for( wxMenuItem* menuItem : menuBar->GetMenu( ii )->GetMenuItems() )
690 {
691 if( menuItem->GetItemLabelText() == menuItemLabel )
692 {
693 wxString menuTitleLabel = menuBar->GetMenuLabelText( ii );
694
695 menuTitleLabel.Replace( wxS( "&" ), wxS( "&&" ) );
696 menuItemLabel.Replace( wxS( "&" ), wxS( "&&" ) );
697
698 return wxString::Format( _( "Run: %s > %s" ),
699 menuTitleLabel,
700 menuItemLabel );
701 }
702 }
703 }
704
705 return wxString::Format( _( "Run: %s" ), aAction.GetFriendlyName() );
706};
707
708
710{
712
713 if( GetMenuBar() )
714 {
716 GetMenuBar()->Refresh();
717 }
718}
719
720
722{
724
725 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
726
727#ifdef KICAD_IPC_API
728 bool running = Pgm().GetApiServer().Running();
729
730 if( running && !settings->m_Api.enable_server )
731 Pgm().GetApiServer().Stop();
732 else if( !running && settings->m_Api.enable_server )
733 Pgm().GetApiServer().Start();
734#endif
735
736 if( m_fileHistory )
737 {
738 int historySize = settings->m_System.file_history_size;
739 m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
740 }
741
742 if( Pgm().GetCommonSettings()->m_Backup.enabled )
743 Kiway().LocalHistory().Init( Prj().GetProjectPath() );
744
746 ThemeChanged();
747
748 if( GetMenuBar() )
749 {
750 // For icons in menus, icon scaling & hotkeys
752 GetMenuBar()->Refresh();
753 }
754
755 // Update the toolbars
757}
758
759
761{
763
764 // Update all the toolbars to have new icons
765 wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
766
767 for( size_t i = 0; i < panes.GetCount(); ++i )
768 {
769 if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
770 toolbar->RefreshBitmaps();
771 }
772}
773
774
775void EDA_BASE_FRAME::OnSize( wxSizeEvent& aEvent )
776{
777#ifdef __WXMAC__
778 int currentDisplay = wxDisplay::GetFromWindow( this );
779
780 if( m_displayIndex >= 0 && currentDisplay >= 0 && currentDisplay != m_displayIndex )
781 {
782 wxLogTrace( traceDisplayLocation, wxS( "OnSize: current display changed %d to %d" ),
783 m_displayIndex, currentDisplay );
784 m_displayIndex = currentDisplay;
786 }
787#endif
788
789 aEvent.Skip();
790}
791
792
793void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
794{
795 if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
796 return;
797
798 const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
799
800 if( state != nullptr )
801 {
802 LoadWindowState( state->window );
803 }
804}
805
806
808{
809 bool wasDefault = false;
810
811 m_framePos.x = aState.pos_x;
812 m_framePos.y = aState.pos_y;
813 m_frameSize.x = aState.size_x;
814 m_frameSize.y = aState.size_y;
815
816 wxLogTrace( traceDisplayLocation, wxS( "Config position (%d, %d) with size (%d, %d)" ),
818
819 // Ensure minimum size is set if the stored config was zero-initialized
820 wxSize minSize = minSizeLookup( m_ident, this );
821
822 if( m_frameSize.x < minSize.x || m_frameSize.y < minSize.y )
823 {
825 wasDefault = true;
826
827 wxLogTrace( traceDisplayLocation, wxS( "Using minimum size (%d, %d)" ),
829 }
830
831 wxLogTrace( traceDisplayLocation, wxS( "Number of displays: %d" ), wxDisplay::GetCount() );
832
833 if( aState.display >= wxDisplay::GetCount() )
834 {
835 wxLogTrace( traceDisplayLocation, wxS( "Previous display not found" ) );
836
837 // If it isn't attached, use the first display
838 // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
839 const unsigned int index = 0;
840 wxDisplay display( index );
841 wxRect clientSize = display.GetGeometry();
842
843 m_framePos = wxDefaultPosition;
844
845 // Ensure the window fits on the display, since the other one could have been larger
846 if( m_frameSize.x > clientSize.width )
847 m_frameSize.x = clientSize.width;
848
849 if( m_frameSize.y > clientSize.height )
850 m_frameSize.y = clientSize.height;
851 }
852 else
853 {
854 wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
855 wxPoint upperLeft( m_framePos.x, m_framePos.y );
856
857 wxDisplay display( aState.display );
858 wxRect clientSize = display.GetClientArea();
859
860 int yLimTop = clientSize.y;
861 int yLimBottom = clientSize.y + clientSize.height;
862 int xLimLeft = clientSize.x;
863 int xLimRight = clientSize.x + clientSize.width;
864
865 if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
866 upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
867 upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
868 upperLeft.y > yLimBottom )
869 {
870 m_framePos = wxDefaultPosition;
871 wxLogTrace( traceDisplayLocation, wxS( "Resetting to default position" ) );
872 }
873 }
874
875 wxLogTrace( traceDisplayLocation, wxS( "Final window position (%d, %d) with size (%d, %d)" ),
877
878 SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
879
880 // Center the window if we reset to default
881 if( m_framePos.x == -1 )
882 {
883 wxLogTrace( traceDisplayLocation, wxS( "Centering window" ) );
884 Center();
885 m_framePos = GetPosition();
886 }
887
888 // Record the frame sizes in an un-maximized state
891
892 // Maximize if we were maximized before
893 if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
894 {
895 wxLogTrace( traceDisplayLocation, wxS( "Maximizing window" ) );
896 Maximize();
897 }
898
899 m_displayIndex = wxDisplay::GetFromWindow( this );
900}
901
902
904{
905 wxDisplay display( wxDisplay::GetFromWindow( this ) );
906 wxRect clientSize = display.GetClientArea();
907 wxPoint pos = GetPosition();
908 wxSize size = GetWindowSize();
909
910 wxLogTrace( traceDisplayLocation,
911 wxS( "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d" ),
912 clientSize.x, clientSize.y,
913 clientSize.width, clientSize.height );
914
915 if( pos.y < clientSize.y )
916 {
917 wxLogTrace( traceDisplayLocation,
918 wxS( "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d" ), pos.y,
919 clientSize.y );
920 pos.y = clientSize.y;
921 }
922
923 if( pos.x < clientSize.x )
924 {
925 wxLogTrace( traceDisplayLocation,
926 wxS( "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d" ),
927 pos.x, clientSize.x );
928 pos.x = clientSize.x;
929 }
930
931 if( pos.x + size.x - clientSize.x > clientSize.width )
932 {
933 int newWidth = clientSize.width - ( pos.x - clientSize.x );
934 wxLogTrace( traceDisplayLocation,
935 wxS( "ensureWindowIsOnScreen: effective width %d above available %d, setting "
936 "to %d" ), pos.x + size.x, clientSize.width, newWidth );
937 size.x = newWidth;
938 }
939
940 if( pos.y + size.y - clientSize.y > clientSize.height )
941 {
942 int newHeight = clientSize.height - ( pos.y - clientSize.y );
943 wxLogTrace( traceDisplayLocation,
944 wxS( "ensureWindowIsOnScreen: effective height %d above available %d, setting "
945 "to %d" ), pos.y + size.y, clientSize.height, newHeight );
946 size.y = newHeight;
947 }
948
949 wxLogTrace( traceDisplayLocation, wxS( "Updating window position (%d, %d) with size (%d, %d)" ),
950 pos.x, pos.y, size.x, size.y );
951
952 SetSize( pos.x, pos.y, size.x, size.y );
953}
954
955
966
967
969{
970 if( IsIconized() )
971 return;
972
973 // If the window is maximized, we use the saved window size from before it was maximized
974 if( IsMaximized() )
975 {
978 }
979 else
980 {
982 m_framePos = GetPosition();
983 }
984
985 aCfg->state.pos_x = m_framePos.x;
986 aCfg->state.pos_y = m_framePos.y;
987 aCfg->state.size_x = m_frameSize.x;
988 aCfg->state.size_y = m_frameSize.y;
989 aCfg->state.maximized = IsMaximized();
990 aCfg->state.display = wxDisplay::GetFromWindow( this );
991
992 wxLogTrace( traceDisplayLocation, wxS( "Saving window maximized: %s" ),
993 IsMaximized() ? wxS( "true" ) : wxS( "false" ) );
994 wxLogTrace( traceDisplayLocation, wxS( "Saving config position (%d, %d) with size (%d, %d)" ),
996
997 // Once this is fully implemented, wxAuiManager will be used to maintain
998 // the persistence of the main frame and all it's managed windows and
999 // all of the legacy frame persistence position code can be removed.
1000#if wxCHECK_VERSION( 3, 3, 0 )
1001 {
1002 WX_AUI_JSON_SERIALIZER serializer( m_auimgr );
1003 nlohmann::json state = serializer.Serialize();
1004
1005 if( state.is_null() || state.empty() )
1006 aCfg->aui_state = nlohmann::json();
1007 else
1008 aCfg->aui_state = state;
1009
1010 aCfg->perspective.clear();
1011 }
1012#else
1013 aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
1014 aCfg->aui_state = nlohmann::json();
1015#endif
1016
1017 aCfg->mru_path = m_mruPath;
1018}
1019
1020
1022{
1024
1025 // Get file history size from common settings
1026 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
1027
1028 // Load the recently used files into the history menu
1029 m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 1, fileHistorySize ),
1031 m_fileHistory->Load( *aCfg );
1032}
1033
1034
1036{
1037 wxCHECK( config(), /* void */ );
1038
1040
1041 bool fileOpen = m_isClosing && m_isNonUserClose;
1042
1043 wxString currentlyOpenedFile = GetCurrentFileName();
1044
1045 if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
1046 {
1047 wxFileName rfn( currentlyOpenedFile );
1048 rfn.MakeRelativeTo( Prj().GetProjectPath() );
1049 Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
1050 }
1051
1052 // Save the recently used files list
1053 if( m_fileHistory )
1054 {
1055 // Save the currently opened file in the file history
1056 if( !currentlyOpenedFile.IsEmpty() )
1057 UpdateFileHistory( currentlyOpenedFile );
1058
1059 m_fileHistory->Save( *aCfg );
1060 }
1061}
1062
1063
1068
1069
1071{
1072 // KICAD_MANAGER_FRAME overrides this
1073 return Kiface().KifaceSettings();
1074}
1075
1076
1078{
1079 return Kiface().KifaceSearch();
1080}
1081
1082
1084{
1085 return Kiface().GetHelpFileName();
1086}
1087
1088
1089void EDA_BASE_FRAME::PrintMsg( const wxString& text )
1090{
1091 SetStatusText( text );
1092}
1093
1094
1096{
1097#if defined( __WXOSX_MAC__ )
1099#else
1100 m_infoBar = new WX_INFOBAR( this, &m_auimgr );
1101
1102 m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxS( "InfoBar" ) ).Top().Layer(1) );
1103#endif
1104}
1105
1106
1108{
1109#if defined( __WXOSX_MAC__ )
1110 m_auimgr.Update();
1111#else
1112 // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
1113 // hiding it.
1114 m_auimgr.Update();
1115
1116 // We don't want the infobar displayed right away
1117 m_auimgr.GetPane( wxS( "InfoBar" ) ).Hide();
1118 m_auimgr.Update();
1119#endif
1120}
1121
1122
1124{
1125 if( !ADVANCED_CFG::GetCfg().m_EnableUseAuiPerspective )
1126 return;
1127
1128#if wxCHECK_VERSION( 3, 3, 0 )
1129 bool restored = false;
1130
1131 if( !m_auiLayoutState.is_null() && !m_auiLayoutState.empty() )
1132 {
1133 WX_AUI_JSON_SERIALIZER serializer( m_auimgr );
1134
1135 if( serializer.Deserialize( m_auiLayoutState ) )
1136 restored = true;
1137 }
1138
1139 if( !restored && !m_perspective.IsEmpty() )
1140 m_auimgr.LoadPerspective( m_perspective );
1141#else
1142 // Do nothing: Save/LoadPerspective() is broken on wx before 3.3
1143#endif
1144}
1145
1146
1147void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
1149{
1150 m_infoBar->RemoveAllButtons();
1151
1152 if( aShowCloseButton )
1153 m_infoBar->AddCloseButton();
1154
1155 GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType );
1156}
1157
1158
1159void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
1160 std::function<void(void)> aCallback )
1161{
1162 m_infoBar->RemoveAllButtons();
1163
1164 if( aShowCloseButton )
1165 m_infoBar->AddCloseButton();
1166
1167 if( aCallback )
1168 m_infoBar->SetCallback( aCallback );
1169
1170 GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
1171}
1172
1173
1174void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
1175{
1176 m_infoBar->RemoveAllButtons();
1177
1178 if( aShowCloseButton )
1179 m_infoBar->AddCloseButton();
1180
1181 GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
1182}
1183
1184
1185void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
1186{
1187 m_infoBar->RemoveAllButtons();
1188
1189 if( aShowCloseButton )
1190 m_infoBar->AddCloseButton();
1191
1192 GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
1193}
1194
1195
1196void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
1197{
1198 if( !aFileHistory )
1199 aFileHistory = m_fileHistory;
1200
1201 wxASSERT( aFileHistory );
1202
1203 aFileHistory->AddFileToHistory( FullFileName );
1204
1205 // Update the menubar to update the file history menu
1206 if( !m_isClosing && GetMenuBar() )
1207 {
1209 GetMenuBar()->Refresh();
1210 }
1211}
1212
1213
1214wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
1215 FILE_HISTORY* aFileHistory )
1216{
1217 if( !aFileHistory )
1218 aFileHistory = m_fileHistory;
1219
1220 wxASSERT( aFileHistory );
1221
1222 int baseId = aFileHistory->GetBaseId();
1223
1224 wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
1225
1226 unsigned i = cmdId - baseId;
1227
1228 if( i < aFileHistory->GetCount() )
1229 {
1230 wxString fn = aFileHistory->GetHistoryFile( i );
1231
1232 if( wxFileName::FileExists( fn ) )
1233 {
1234 return fn;
1235 }
1236 else
1237 {
1238 DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
1239 aFileHistory->RemoveFileFromHistory( i );
1240 }
1241 }
1242
1243 // Update the menubar to update the file history menu
1244 if( GetMenuBar() )
1245 {
1247 GetMenuBar()->Refresh();
1248 }
1249
1250 return wxEmptyString;
1251}
1252
1253
1255{
1256 wxASSERT( m_fileHistory );
1257
1258 m_fileHistory->ClearFileHistory();
1259
1260 // Update the menubar to update the file history menu
1261 if( GetMenuBar() )
1262 {
1264 GetMenuBar()->Refresh();
1265 }
1266}
1267
1268
1269void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
1270{
1271 void ShowAboutDialog( EDA_BASE_FRAME * aParent ); // See AboutDialog_main.cpp
1272 ShowAboutDialog( this );
1273}
1274
1275
1276void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
1277{
1278 ShowPreferences( wxEmptyString, wxEmptyString );
1279}
1280
1281
1282void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParentPage )
1283{
1284 PAGED_DIALOG dlg( this, _( "Preferences" ), true, true, wxEmptyString,
1285 wxWindow::FromDIP( wxSize( 980, 560 ), nullptr ) );
1286
1287 dlg.SetEvtHandlerEnabled( false );
1288
1289 {
1290 WX_BUSY_INDICATOR busy_cursor;
1291
1292 WX_TREEBOOK* book = dlg.GetTreebook();
1293 PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
1294 std::vector<int> expand;
1295
1296 wxWindow* kicadMgr_window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
1297
1298 if( KICAD_MANAGER_FRAME* kicadMgr = static_cast<KICAD_MANAGER_FRAME*>( kicadMgr_window ) )
1299 {
1300 ACTION_MANAGER* actionMgr = kicadMgr->GetToolManager()->GetActionManager();
1301
1302 for( const auto& [name, action] : actionMgr->GetActions() )
1303 hotkeysPanel->ActionsList().push_back( action );
1304 }
1305
1306 book->AddLazyPage(
1307 []( wxWindow* aParent ) -> wxWindow*
1308 {
1309 return new PANEL_COMMON_SETTINGS( aParent );
1310 },
1311 _( "Common" ) );
1312
1313 book->AddLazyPage(
1314 []( wxWindow* aParent ) -> wxWindow*
1315 {
1316 return new PANEL_MOUSE_SETTINGS( aParent );
1317 }, _( "Mouse and Touchpad" ) );
1318
1319 book->AddLazyPage(
1320 [] ( wxWindow* aParent ) -> wxWindow*
1321 {
1322 return new PANEL_SPACEMOUSE( aParent );
1323 }, _( "SpaceMouse" ) );
1324
1325 book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
1326
1327 book->AddLazyPage(
1328 []( wxWindow* aParent ) -> wxWindow*
1329 {
1330 return new PANEL_GIT_REPOS( aParent );
1331 }, _( "Version Control" ) );
1332
1333#ifdef KICAD_USE_SENTRY
1334 book->AddLazyPage(
1335 []( wxWindow* aParent ) -> wxWindow*
1336 {
1337 return new PANEL_DATA_COLLECTION( aParent );
1338 }, _( "Data Collection" ) );
1339#endif
1340
1341#define LAZY_CTOR( key ) \
1342 [this, kiface]( wxWindow* aParent ) \
1343 { \
1344 return kiface->CreateKiWindow( aParent, key, &Kiway() ); \
1345 }
1346
1347 // If a dll is not loaded, the loader will show an error message.
1348
1349 try
1350 {
1351 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_SCH ) )
1352 {
1353 kiface->GetActions( hotkeysPanel->ActionsList() );
1354
1356 expand.push_back( (int) book->GetPageCount() );
1357
1358 book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) );
1359 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_DISP_OPTIONS ), _( "Display Options" ) );
1360 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_GRIDS ), _( "Grids" ) );
1361 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) );
1362 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_COLORS ), _( "Colors" ) );
1363
1364 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1365 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_TOOLBARS ), _( "Toolbars" ) );
1366
1367 if( GetFrameType() == FRAME_SCH )
1368 expand.push_back( (int) book->GetPageCount() );
1369
1370 book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) );
1371 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_DISP_OPTIONS ), _( "Display Options" ) );
1372 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_GRIDS ), _( "Grids" ) );
1373 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_EDIT_OPTIONS ), _( "Editing Options" ) );
1374 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_COLORS ), _( "Colors" ) );
1375
1376 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1377 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_TOOLBARS ), _( "Toolbars" ) );
1378
1379 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_FIELD_NAME_TEMPLATES ), _( "Field Name Templates" ) );
1380 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_SIMULATOR ), _( "Simulator" ) );
1381 }
1382 }
1383 catch( ... )
1384 {
1385 }
1386
1387 try
1388 {
1389 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PCB ) )
1390 {
1391 kiface->GetActions( hotkeysPanel->ActionsList() );
1392
1394 expand.push_back( (int) book->GetPageCount() );
1395
1396 book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
1397 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DISPLAY_OPTIONS ), _( "Display Options" ) );
1398 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_GRIDS ), _( "Grids" ) );
1399 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_ORIGINS_AXES ), _( "Origins & Axes" ) );
1400 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) );
1401 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_COLORS ), _( "Colors" ) );
1402
1403 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1404 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_TOOLBARS ), _( "Toolbars" ) );
1405
1406 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_FIELDS ), _( "Footprint Defaults" ) );
1407 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_GRAPHICS_VALUES ), _( "Graphics Defaults" ) );
1408
1410 expand.push_back( (int) book->GetPageCount() );
1411
1412 book->AddPage( new wxPanel( book ), _( "PCB Editor" ) );
1413 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_DISPLAY_OPTS ), _( "Display Options" ) );
1414 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_GRIDS ), _( "Grids" ) );
1415 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ORIGINS_AXES ), _( "Origins & Axes" ) );
1416 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_EDIT_OPTIONS ), _( "Editing Options" ) );
1417 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_COLORS ), _( "Colors" ) );
1418
1419 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1420 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_TOOLBARS ), _( "Toolbars" ) );
1421
1422 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ACTION_PLUGINS ), _( "Plugins" ) );
1423
1425 expand.push_back( (int) book->GetPageCount() );
1426
1427 book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
1428 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) );
1429
1430 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1431 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_TOOLBARS ), _( "Toolbars" ) );
1432
1433 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) );
1434 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) );
1435 }
1436 }
1437 catch( ... )
1438 {
1439 }
1440
1441 try
1442 {
1443 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_GERBVIEW ) )
1444 {
1445 kiface->GetActions( hotkeysPanel->ActionsList() );
1446
1447 if( GetFrameType() == FRAME_GERBER )
1448 expand.push_back( (int) book->GetPageCount() );
1449
1450 book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) );
1451 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) );
1452 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_COLORS ), _( "Colors" ) );
1453
1454 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1455 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_TOOLBARS ), _( "Toolbars" ) );
1456
1457 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_GRIDS ), _( "Grids" ) );
1458 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) );
1459 }
1460 }
1461 catch( ... )
1462 {
1463 }
1464
1465 try
1466 {
1467 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PL_EDITOR ) )
1468 {
1469 kiface->GetActions( hotkeysPanel->ActionsList() );
1470
1471 if( GetFrameType() == FRAME_PL_EDITOR )
1472 expand.push_back( (int) book->GetPageCount() );
1473
1474 book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) );
1475 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_DISPLAY_OPTIONS ), _( "Display Options" ) );
1476 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_GRIDS ), _( "Grids" ) );
1477 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_COLORS ), _( "Colors" ) );
1478
1479 if( ADVANCED_CFG::GetCfg().m_ConfigurableToolbars )
1480 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_TOOLBARS ), _( "Toolbars" ) );
1481
1482 book->AddLazyPage(
1483 []( wxWindow* aParent ) -> wxWindow*
1484 {
1485 return new PANEL_PACKAGES_AND_UPDATES( aParent );
1486 }, _( "Packages and Updates" ) );
1487 }
1488 }
1489 catch( ... )
1490 {
1491 }
1492
1493#ifdef KICAD_IPC_API
1494 book->AddPage( new PANEL_PLUGIN_SETTINGS( book ), _( "Plugins" ) );
1495#endif
1496
1497 book->AddPage( new PANEL_MAINTENANCE( book, this ), _( "Maintenance" ) );
1498
1499 // Update all of the action hotkeys. The process of loading the actions through
1500 // the KiFACE will only get us the default hotkeys
1501 ReadHotKeyConfigIntoActions( wxEmptyString, hotkeysPanel->ActionsList() );
1502
1503 for( size_t i = 0; i < book->GetPageCount(); ++i )
1504 book->GetPage( i )->Layout();
1505
1506 for( int page : expand )
1507 book->ExpandNode( page );
1508
1509 if( !aStartPage.IsEmpty() )
1510 dlg.SetInitialPage( aStartPage, aStartParentPage );
1511
1512 dlg.SetEvtHandlerEnabled( true );
1513#undef LAZY_CTOR
1514 }
1515
1516 if( dlg.ShowModal() == wxID_OK )
1517 {
1518 // Update our grids that are cached in the tool
1519 m_toolManager->ResetTools( TOOL_BASE::REDRAW );
1522 }
1523
1524}
1525
1526
1527void EDA_BASE_FRAME::OnDropFiles( wxDropFilesEvent& aEvent )
1528{
1529 Raise();
1530
1531 wxString* files = aEvent.GetFiles();
1532
1533 for( int nb = 0; nb < aEvent.GetNumberOfFiles(); nb++ )
1534 {
1535 const wxFileName fn = wxFileName( files[nb] );
1536 wxString ext = fn.GetExt();
1537
1538 // Alias all gerber files as GerberFileExtension
1541
1542 if( m_acceptedExts.find( ext.ToStdString() ) != m_acceptedExts.end() )
1543 m_AcceptedFiles.emplace_back( fn );
1544 }
1545
1547 m_AcceptedFiles.clear();
1548}
1549
1550
1552{
1553 for( const wxFileName& file : m_AcceptedFiles )
1554 {
1555 wxString fn = file.GetFullPath();
1556 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( file.GetExt() ), &fn );
1557 }
1558}
1559
1560
1561bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName, bool aVerbose )
1562{
1563 wxString msg;
1564 wxFileName fn = aFileName;
1565
1566 // Check for absence of a file path with a file name. Unfortunately KiCad
1567 // uses paths relative to the current project path without the ./ part which
1568 // confuses wxFileName. Making the file name path absolute may be less than
1569 // elegant but it solves the problem.
1570 if( fn.GetPath().IsEmpty() && fn.HasName() )
1571 fn.MakeAbsolute();
1572
1573 wxCHECK_MSG( fn.IsOk(), false,
1574 wxT( "File name object is invalid. Bad programmer!" ) );
1575 wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
1576 wxT( "File name object path <" ) + fn.GetFullPath() +
1577 wxT( "> is not set. Bad programmer!" ) );
1578
1579 if( fn.IsDir() && !fn.IsDirWritable() )
1580 {
1581 msg.Printf( _( "Insufficient permissions to folder '%s'." ), fn.GetPath() );
1582 }
1583 else if( !fn.FileExists() && !fn.IsDirWritable() )
1584 {
1585 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1586 }
1587 else if( fn.FileExists() && !fn.IsFileWritable() )
1588 {
1589 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1590 }
1591
1592 if( !msg.IsEmpty() )
1593 {
1594 if( aVerbose )
1595 DisplayErrorMessage( this, msg );
1596
1597 return false;
1598 }
1599
1600 return true;
1601}
1602
1603
1605{
1606 // This function should be overridden in child classes
1607 return false;
1608}
1609
1610
1612{
1613 wxAcceleratorEntry entries[1];
1614 entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
1615 wxAcceleratorTable accel( 1, entries );
1616 SetAcceleratorTable( accel );
1617}
1618
1619
1625
1626
1628{
1629 m_undoList.PushCommand( aNewitem );
1630
1631 // Delete the extra items, if count max reached
1632 if( m_undoRedoCountMax > 0 )
1633 {
1634 int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
1635
1636 if( extraitems > 0 )
1637 ClearUndoORRedoList( UNDO_LIST, extraitems );
1638 }
1639}
1640
1641
1643{
1644 m_redoList.PushCommand( aNewitem );
1645
1646 // Delete the extra items, if count max reached
1647 if( m_undoRedoCountMax > 0 )
1648 {
1649 int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
1650
1651 if( extraitems > 0 )
1652 ClearUndoORRedoList( REDO_LIST, extraitems );
1653 }
1654}
1655
1656
1661
1662
1667
1668
1670{
1671 if( GetUndoCommandCount() > 0 )
1672 return m_undoList.m_CommandsList.back()->GetDescription();
1673
1674 return wxEmptyString;
1675}
1676
1677
1679{
1680 if( GetRedoCommandCount() > 0 )
1681 return m_redoList.m_CommandsList.back()->GetDescription();
1682
1683 return wxEmptyString;
1684}
1685
1686
1688{
1689 m_autoSaveRequired = true;
1690}
1691
1692
1694{
1695 SetUserUnits( aUnits );
1697
1698 wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
1699 e.SetInt( static_cast<int>( aUnits ) );
1700 e.SetClientData( this );
1701 ProcessEventLocally( e );
1702}
1703
1704
1705void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
1706{
1707 // When we maximize the window, we want to save the old information
1708 // so that we can add it to the settings on next window load.
1709 // Contrary to the documentation, this event seems to be generated
1710 // when the window is also being unmaximized on OSX, so we only
1711 // capture the size information when we maximize the window when on OSX.
1712#ifdef __WXOSX__
1713 if( !IsMaximized() )
1714#endif
1715 {
1717 m_normalFramePos = GetPosition();
1718 wxLogTrace( traceDisplayLocation,
1719 "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1722 }
1723
1724 // Skip event to actually maximize the window
1725 aEvent.Skip();
1726}
1727
1728
1730{
1731#ifdef __WXGTK__
1732 wxSize winSize = GetSize();
1733
1734 // GTK includes the window decorations in the normal GetSize call,
1735 // so we have to use a GTK-specific sizing call that returns the
1736 // non-decorated window size.
1738 {
1739 int width = 0;
1740 int height = 0;
1741 GTKDoGetSize( &width, &height );
1742
1743 winSize.Set( width, height );
1744 }
1745#else
1746 wxSize winSize = GetSize();
1747#endif
1748
1749 return winSize;
1750}
1751
1752
1754{
1755 // Update the icon theme when the system theme changes and update the toolbars
1757 ThemeChanged();
1758
1759 // This isn't handled by ThemeChanged()
1760 if( GetMenuBar() )
1761 {
1762 // For icons in menus, icon scaling & hotkeys
1764 GetMenuBar()->Refresh();
1765 }
1766}
1767
1768
1769void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
1770{
1771 // Call the handler to update the colors used in the frame
1773
1774 // Skip the change event to ensure the rest of the window controls get it
1775 aEvent.Skip();
1776}
1777
1778
1779void EDA_BASE_FRAME::onIconize( wxIconizeEvent& aEvent )
1780{
1781 // Call the handler
1782 handleIconizeEvent( aEvent );
1783
1784 // Skip the event.
1785 aEvent.Skip();
1786}
1787
1788
1789#ifdef __WXMSW__
1790WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
1791{
1792 // This will help avoid the menu keeping focus when the alt key is released
1793 // You can still trigger accelerators as long as you hold down alt
1794 if( message == WM_SYSCOMMAND )
1795 {
1796 if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
1797 return 0;
1798 }
1799
1800 return wxFrame::MSWWindowProc( message, wParam, lParam );
1801}
1802#endif
1803
1804
1806{
1807 ACTION_MENU* langsMenu = new ACTION_MENU( false, aControlTool );
1808 langsMenu->SetTitle( _( "Set Language" ) );
1809 langsMenu->SetIcon( BITMAPS::language );
1810
1811 wxString tooltip;
1812
1813 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
1814 {
1815 wxString label;
1816
1817 if( LanguagesList[ii].m_DoNotTranslate )
1818 label = LanguagesList[ii].m_Lang_Label;
1819 else
1820 label = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
1821
1822 wxMenuItem* item =
1823 new wxMenuItem( langsMenu,
1824 LanguagesList[ii].m_KI_Lang_Identifier, // wxMenuItem wxID
1825 label, tooltip, wxITEM_CHECK );
1826
1827 langsMenu->Append( item );
1828 }
1829
1830 // This must be done after the items are added
1831 aMasterMenu->Add( langsMenu );
1832}
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
const char * name
std::function< void(ACTION_TOOLBAR *)> ACTION_TOOLBAR_CONTROL_FACTORY
Type for the function signature that is used to add custom controls to the toolbar.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void ClearScaledBitmapCache()
Wipes out the scaled bitmap cache so that the icon theme can be changed.
Definition bitmap.cpp:172
BITMAP_STORE * GetBitmapStore()
Definition bitmap.cpp:92
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION about
Definition actions.h:288
static TOOL_ACTION reportBug
Definition actions.h:292
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION donate
Definition actions.h:290
static TOOL_ACTION listHotKeys
Definition actions.h:289
static TOOL_ACTION getInvolved
Definition actions.h:291
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION gettingStarted
Definition actions.h:286
static TOOL_ACTION help
Definition actions.h:287
Manage TOOL_ACTION objects.
const std::map< std::string, TOOL_ACTION * > & GetActions() const
Get a list of currently-registered actions mapped by their name.
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:47
void SetTitle(const wxString &aTitle) override
Set title for the menu.
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
Class to hold basic information about controls that can be added to the toolbars.
const std::string & GetName() const
Define the structure of a toolbar with buttons that invoke ACTIONs.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
WINDOW_SETTINGS m_Window
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
Handle actions that are shared between different applications.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:68
int ShowModal() override
The base frame for deriving all KiCad main window classes.
virtual wxString help_name()
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
void LoadWindowState(const wxString &aFileName)
FRAME_T GetFrameType() const
virtual void UnregisterUIUpdateHandler(int aID) override
Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler.
virtual bool isAutoSaveRequired() const
Return the auto save status of the application.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
void windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
virtual void OnCharHook(wxKeyEvent &aKeyEvent)
Capture the key event before it is sent to the GUI.
virtual int GetRedoCommandCount() const
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
UNDO_REDO_CONTAINER m_undoList
virtual void OnMove(wxMoveEvent &aEvent)
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
virtual void doCloseWindow()
void OnToolbarSizeChanged()
Update toolbars if desired toolbar icon changed.
void OnMenuEvent(wxMenuEvent &event)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
virtual bool IsModal() const
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void HandleSystemColorChange()
Update the UI in response to a change in the system colors.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void ensureWindowIsOnScreen()
bool m_isNonUserClose
Set by NonUserClose() to indicate that the user did not request the current close.
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
std::vector< wxFileName > m_AcceptedFiles
bool m_autoSavePermissionError
void OnKicadAbout(wxCommandEvent &event)
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
virtual void DoWithAcceptedFiles()
Execute action on accepted dropped file.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
wxWindow * findQuasiModalDialog()
static void HandleUpdateUIEvent(wxUpdateUIEvent &aEvent, EDA_BASE_FRAME *aFrame, ACTION_CONDITIONS aCond)
Handle events generated when the UI is trying to figure out the current state of the UI controls rela...
wxString m_perspective
virtual void ClearUndoORRedoList(UNDO_REDO_LIST aList, int aItemCount=-1)
Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if nee...
virtual void ThemeChanged()
Process light/dark theme change.
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)
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars.
ACTION_TOOLBAR * m_tbRight
void ShowPreferences(wxString aStartPage, wxString aStartParentPage)
Display the preferences and settings of all opened editors paged dialog, starting with a particular p...
void initExitKey()
Set the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
void OnPreferences(wxCommandEvent &event)
virtual const SEARCH_STACK & sys_search()
Return a SEARCH_STACK pertaining to entire program.
WX_INFOBAR * m_infoBar
void onAutoSaveTimer(wxTimerEvent &aEvent)
Handle the auto save timer event.
void SaveWindowSettings(WINDOW_SETTINGS *aCfg)
Save window settings to the given settings object.
virtual wxString GetRedoActionDescription() const
TOOLBAR_SETTINGS * m_toolbarSettings
virtual wxString GetCurrentFileName() const
Get the full filename + path of the currently opened file in the frame.
void ChangeUserUnits(EDA_UNITS aUnits)
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual void configureToolbars()
wxTimer * m_autoSaveTimer
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxAuiManager m_auimgr
void PrintMsg(const wxString &text)
void commonInit(FRAME_T aFrameType)
Collect common initialization functions used in all CTORs.
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual void RecreateToolbars()
std::map< int, UIUpdateHandler > m_uiUpdateMap
Map containing the UI update handlers registered with wx for each action.
std::map< std::string, ACTION_TOOLBAR_CONTROL_FACTORY > m_toolbarControlFactories
ACTION_TOOLBAR_CONTROL_FACTORY * GetCustomToolbarControlFactory(const std::string &aName)
UNDO_REDO_CONTAINER m_redoList
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
FILE_HISTORY * m_fileHistory
ACTION_TOOLBAR * m_tbLeft
SETTINGS_MANAGER * m_settingsManager
virtual void OnSize(wxSizeEvent &aEvent)
virtual wxString GetUndoActionDescription() const
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
wxString GetRunMenuCommandDescription(const TOOL_ACTION &aAction)
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Check if aFileName can be written.
wxPoint m_normalFramePos
void OnMaximize(wxMaximizeEvent &aEvent)
virtual void ClearFileHistory()
Remove all files from the file history.
ACTION_TOOLBAR * m_tbTopAux
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
void onIconize(wxIconizeEvent &aEvent)
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.
int GetAutoSaveInterval() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void onSystemColorChange(wxSysColourChangedEvent &aEvent)
virtual int GetUndoCommandCount() const
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
ACTION_TOOLBAR * m_tbTopMain
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
nlohmann::json m_auiLayoutState
void ReCreateMenuBar()
Recreate the menu bar.
virtual void doReCreateMenuBar()
WX_INFOBAR * GetInfoBar()
Specialization of the wxAuiPaneInfo class for KiCad panels.
This class implements a file history object to store a list of files, that can then be added to a men...
void AddFileToHistory(const wxString &aFile) override
Adds a file to the history.
The main KiCad project manager frame.
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY_HOLDER(KIWAY *aKiway, HOLDER_TYPE aType)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:292
@ FACE_SCH
eeschema DSO
Definition kiway.h:299
@ FACE_PL_EDITOR
Definition kiway.h:303
@ FACE_PCB
pcbnew DSO
Definition kiway.h:300
@ FACE_GERBVIEW
Definition kiway.h:302
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:404
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition kiway.cpp:600
bool Init(const wxString &aProjectPath)
Initialize the local history repository for the given project path.
bool RunRegisteredSaversAndCommit(const wxString &aProjectPath, const wxString &aTitle)
Run all registered savers and, if any staged changes differ from HEAD, create a commit.
void RegisterSaver(const void *aSaverObject, const std::function< void(const wxString &, std::vector< wxString > &)> &aSaver)
Register a saver callback invoked during autosave history commits.
WX_TREEBOOK * GetTreebook()
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
std::vector< TOOL_ACTION * > & ActionsList()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition paths.cpp:136
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:537
virtual int GetSelectedLanguageIdentifier() const
Definition pgm_base.h:234
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:128
A holder to handle information on schematic or board items.
void SaveFileState(const wxString &aFileName, const WINDOW_SETTINGS *aWindowCfg, bool aOpen)
const PROJECT_FILE_STATE * GetFileState(const wxString &aFileName)
void SaveToHistory(const wxString &aProjectPath, std::vector< wxString > &aFiles)
Save project files (.kicad_pro and .kicad_prl) to the .history directory.
Definition project.cpp:482
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition project.h:211
Look for files in a number of paths.
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
virtual void CommonSettingsChanged(int aFlags=0)
Notification event that some of the common (suite-wide) settings have changed.
TOOL_MANAGER * m_toolManager
virtual void ShowChangedLanguage()
TOOL_DISPATCHER * m_toolDispatcher
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Represent a single user action.
wxString GetMenuLabel() const
Return the translated label for the action.
wxString GetFriendlyName() const
Return the translated user-friendly name of the action.
@ REDRAW
Full drawing refresh.
Definition tool_base.h:83
UNITS_PROVIDER(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
void SetUserUnits(EDA_UNITS aUnits)
bool Deserialize(const nlohmann::json &aState) const
nlohmann::json Serialize() const
Simple wrapper around wxBusyCursor for used with the generic BUSY_INDICATOR interface.
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:76
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
MESSAGE_TYPE
Sets the type of message for special handling if needed.
Definition wx_infobar.h:94
bool AddLazyPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
bool AddLazySubPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
This file is part of the common library.
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
static const wxSize minSizeLookup(FRAME_T aFrameType, wxWindow *aWindow)
#define LAZY_CTOR(key)
static const wxSize defaultSize(FRAME_T aFrameType, wxWindow *aWindow)
wxWindow * findQuasiModalDialog(wxWindow *aParent)
Base window classes and related definitions.
#define KICAD_MANAGER_FRAME_NAME
#define DEFAULT_MAX_UNDO_ITEMS
std::function< void(wxUpdateUIEvent &) > UIUpdateHandler
This is the handler functor for the update UI events.
void SocketCleanup()
Must be called to clean up the socket thread used by SendCommand.
Definition eda_dde.cpp:319
DDE server & client.
EDA_UNITS
Definition eda_units.h:48
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
@ PANEL_PCB_GRIDS
Definition frame_type.h:96
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ PANEL_SYM_EDIT_GRIDS
Definition frame_type.h:73
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ PANEL_3DV_TOOLBARS
Definition frame_type.h:106
@ PANEL_SCH_FIELD_NAME_TEMPLATES
Definition frame_type.h:83
@ PANEL_DS_TOOLBARS
Definition frame_type.h:118
@ PANEL_SCH_TOOLBARS
Definition frame_type.h:82
@ PANEL_GBR_DISPLAY_OPTIONS
Definition frame_type.h:108
@ PANEL_3DV_OPENGL
Definition frame_type.h:104
@ PANEL_FP_DEFAULT_GRAPHICS_VALUES
Definition frame_type.h:92
@ PANEL_PCB_TOOLBARS
Definition frame_type.h:99
@ PANEL_PCB_ORIGINS_AXES
Definition frame_type.h:101
@ PANEL_PCB_EDIT_OPTIONS
Definition frame_type.h:97
@ PANEL_SCH_DISP_OPTIONS
Definition frame_type.h:78
@ PANEL_FP_DISPLAY_OPTIONS
Definition frame_type.h:86
@ PANEL_SCH_SIMULATOR
Definition frame_type.h:84
@ FRAME_SCH
Definition frame_type.h:34
@ PANEL_DS_COLORS
Definition frame_type.h:117
@ PANEL_PCB_COLORS
Definition frame_type.h:98
@ PANEL_SYM_TOOLBARS
Definition frame_type.h:76
@ PANEL_3DV_RAYTRACING
Definition frame_type.h:105
@ PANEL_SYM_EDIT_OPTIONS
Definition frame_type.h:74
@ PANEL_FP_GRIDS
Definition frame_type.h:87
@ PANEL_SCH_EDIT_OPTIONS
Definition frame_type.h:80
@ PANEL_FP_ORIGINS_AXES
Definition frame_type.h:93
@ PANEL_SYM_DISP_OPTIONS
Definition frame_type.h:72
@ PANEL_PCB_DISPLAY_OPTS
Definition frame_type.h:95
@ PANEL_FP_COLORS
Definition frame_type.h:89
@ PANEL_FP_DEFAULT_FIELDS
Definition frame_type.h:91
@ PANEL_SYM_COLORS
Definition frame_type.h:75
@ FRAME_PL_EDITOR
Definition frame_type.h:59
@ PANEL_GBR_GRIDS
Definition frame_type.h:111
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
@ FRAME_GERBER
Definition frame_type.h:57
@ PANEL_DS_GRIDS
Definition frame_type.h:116
@ FRAME_PCB_DISPLAY3D
Definition frame_type.h:47
@ PANEL_GBR_TOOLBARS
Definition frame_type.h:113
@ PANEL_FP_EDIT_OPTIONS
Definition frame_type.h:88
@ PANEL_SCH_GRIDS
Definition frame_type.h:79
@ PANEL_FP_TOOLBARS
Definition frame_type.h:90
@ PANEL_PCB_ACTION_PLUGINS
Definition frame_type.h:100
@ PANEL_3DV_DISPLAY_OPTIONS
Definition frame_type.h:103
@ PANEL_DS_DISPLAY_OPTIONS
Definition frame_type.h:115
@ PANEL_SCH_COLORS
Definition frame_type.h:81
@ PANEL_GBR_COLORS
Definition frame_type.h:112
@ PANEL_GBR_EXCELLON_OPTIONS
Definition frame_type.h:110
@ KICAD_MAIN_FRAME_T
Definition frame_type.h:68
static const std::string GerberFileExtension
static bool IsGerberFileExtension(const wxString &ext)
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
void ReadHotKeyConfigIntoActions(const wxString &aFileName, std::vector< TOOL_ACTION * > &aActions)
Read a hotkey config file into a list of actions.
@ ID_FILE_LIST_CLEAR
Definition id.h:62
@ ID_FILE1
Definition id.h:59
@ ID_AUTO_SAVE_TIMER
Definition id.h:54
void RemoveShutdownBlockReason(wxWindow *aWindow)
Removes any shutdown block reason set.
Definition unix/app.cpp:85
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:946
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition pgm_base.cpp:94
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
SELECTION_CONDITION enableCondition
Returns true if the UI control should be enabled.
SELECTION_CONDITION checkCondition
Returns true if the UI control should be checked.
SELECTION_CONDITION showCondition
Returns true if the UI control should be shown.
ACTION_CONDITIONS & Check(const SELECTION_CONDITION &aCondition)
Implement a participant in the KIWAY alchemy.
Definition kiway.h:155
struct WINDOW_STATE window
Store the common settings that are saved and loaded for each window / frame.
WINDOW_STATE state
wxString mru_path
nlohmann::json aui_state
wxString perspective
Store the window positioning/state.
unsigned int display
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.
#define HOTKEYS_CHANGED
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxLogTrace helper definitions.