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, see <https://www.gnu.org/licenses/>.
21 */
22
24#include "kicad_manager_frame.h"
25#include <eda_base_frame.h>
26#include <nlohmann/json.hpp>
27
28#include <advanced_config.h>
30#include <api/api_server.h>
31#include <bitmaps.h>
32#include <bitmap_store.h>
33#include <dialog_shim.h>
41#include <file_history.h>
42#include <id.h>
43#include <kiface_base.h>
44#include <hotkeys_basic.h>
46#include <paths.h>
47#include <local_history.h>
48#include <confirm.h>
50#include <pgm_base.h>
51#include <scoped_set_reset.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
89
90// Minimum window size
91static const wxSize minSizeLookup( FRAME_T aFrameType, wxWindow* aWindow )
92{
93 switch( aFrameType )
94 {
96 return wxWindow::FromDIP( wxSize( 406, 354 ), aWindow );
97
98 default:
99 return wxWindow::FromDIP( wxSize( 500, 400 ), aWindow );
100 }
101}
102
103
104static const wxSize defaultSize( FRAME_T aFrameType, wxWindow* aWindow )
105{
106 switch( aFrameType )
107 {
109 return wxWindow::FromDIP( wxSize( 850, 540 ), aWindow );
110
111 default:
112 return wxWindow::FromDIP( wxSize( 1280, 720 ), aWindow );
113 }
114}
115
116
117BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
118 // These event table entries are needed to handle events from the mac application menu
120 EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
121
122 EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
123 EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
124 EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
125 EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
126 EVT_MOVE( EDA_BASE_FRAME::OnMove )
127 EVT_SIZE( EDA_BASE_FRAME::OnSize )
128 EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
129
130 EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
131 EVT_ICONIZE( EDA_BASE_FRAME::onIconize )
132
134 END_EVENT_TABLE()
135
136
138{
139 m_ident = aFrameType;
140 m_maximizeByDefault = false;
141 m_infoBar = nullptr;
142 m_settingsManager = nullptr;
143 m_fileHistory = nullptr;
144 m_supportsAutoSave = false;
145 m_autoSavePending = false;
147 m_isClosing = false;
148 m_closeInProgress = 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, wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
169
170 // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
171 // to be called before any other hook for wxCloseEvent, which is necessary.
172 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
173
174 KIPLATFORM::UI::SetWMClass( this, Pgm().GetDesktopAppId() );
175
176 initExitKey();
177}
178
179
180EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
181 const wxPoint& aPos, const wxSize& aSize, long aStyle,
182 const wxString& aFrameName, KIWAY* aKiway,
183 const EDA_IU_SCALE& aIuScale ) :
184 wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
185 TOOLS_HOLDER(),
186 KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
187 UNITS_PROVIDER( aIuScale, EDA_UNITS::MM )
188{
189 m_tbTopMain = nullptr;
190 m_tbTopAux = nullptr;
191 m_tbRight = nullptr;
192 m_tbLeft = nullptr;
194
195 commonInit( aFrameType );
196
197 Bind( wxEVT_DPI_CHANGED,
198 [&]( wxDPIChangedEvent& aEvent )
199 {
200#ifdef __WXMSW__
201 // Workaround to update toolbar sizes on MSW
202 if( m_auimgr.GetManagedWindow() )
203 {
204 wxAuiPaneInfoArray& panes = m_auimgr.GetAllPanes();
205
206 for( size_t ii = 0; ii < panes.GetCount(); ii++ )
207 {
208 wxAuiPaneInfo& pinfo = panes.Item( ii );
209 pinfo.best_size = pinfo.window->GetSize();
210
211 // But we still shouldn't make it too small.
212 pinfo.best_size.IncTo( pinfo.window->GetBestSize() );
213 pinfo.best_size.IncTo( pinfo.min_size );
214 }
215
216 m_auimgr.Update();
217 }
218#endif
219
220 aEvent.Skip();
221 } );
222}
223
224
225wxWindow* findQuasiModalDialog( wxWindow* aParent )
226{
227 for( wxWindow* child : aParent->GetChildren() )
228 {
229 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( child ) )
230 {
231 if( dlg->IsQuasiModal() )
232 return dlg;
233
234 if( wxWindow* nestedDlg = findQuasiModalDialog( child ) )
235 return nestedDlg;
236 }
237 }
238
239 return nullptr;
240}
241
242
244{
245 if( wxWindow* dlg = ::findQuasiModalDialog( this ) )
246 return dlg;
247
248 // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
249 // so we have to look for it separately.
250 if( m_ident == FRAME_SCH )
251 {
252 wxWindow* cvpcb = wxWindow::FindWindowByName( wxS( "CvpcbFrame" ) );
253
254 if( cvpcb )
255 return cvpcb;
256 }
257
258 return nullptr;
259}
260
261
262void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
263{
264 // Guard against re-entrant close events. GTK can deliver a second wxEVT_CLOSE_WINDOW
265 // while we are still processing the first one (e.g. during Destroy() calls), which leads
266 // to use-after-free crashes when child objects have already been torn down.
267 if( m_isClosing )
268 return;
269
270 // The unsaved-changes prompt in canCloseWindow() pumps messages, so a second close event
271 // (queued title-bar click, Alt+F4 repeat, session end) can arrive while the first close is
272 // still deciding. m_isClosing is not set until canCloseWindow() succeeds, so without this
273 // guard the second event would run the entire prompt and teardown re-entrantly and the
274 // first close would then resume against a demolished frame.
275 //
276 // A non-vetoable session end that lands during the prompt is dropped here rather than run
277 // re-entrantly. That trades a rare failure to persist settings on forced logoff for not
278 // crashing; the durable fix keeps the close off the OS default-window-proc stack entirely and
279 // needs Windows verification.
281 {
282 if( event.CanVeto() )
283 event.Veto();
284
285 return;
286 }
287
288 // Don't allow closing when a quasi-modal is open.
289 wxWindow* quasiModal = findQuasiModalDialog();
290
291 if( quasiModal )
292 {
293 // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
294 // when they have no idea what those are.
295 quasiModal->Raise();
296 wxBell();
297
298 if( event.CanVeto() )
299 event.Veto();
300
301 return;
302 }
303
304
305 // End session means the OS is going to terminate us
306 SCOPED_SET_RESET<bool> nonUserClose( m_isNonUserClose, m_isNonUserClose || Pgm().IsSessionEnding() );
307
308 SCOPED_SET_RESET<bool> closeGuard( m_closeInProgress, true );
309
310 if( canCloseWindow( event ) )
311 {
312 m_isClosing = true;
313
314 if( m_infoBar )
315 m_infoBar->Dismiss();
316
317 APP_SETTINGS_BASE* cfg = config();
318
319 if( cfg )
320 SaveSettings( cfg ); // virtual, wxFrame specific
321
323
324 // Destroy (safe delete frame) this frame only in non modal mode.
325 // In modal mode, the caller will call Destroy().
326 if( !IsModal() )
327 Destroy();
328 }
329 else
330 {
331 if( event.CanVeto() )
332 event.Veto();
333 }
334}
335
336
341
342
344{
345 Disconnect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER, wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
346 Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
347
348 delete m_autoSaveTimer;
349 delete m_fileHistory;
350
352
354}
355
356
357bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
358{
359#ifdef __WXMAC__
360 // Apple in its infinite wisdom will raise a disabled window before even passing
361 // us the event, so we have no way to stop it. Instead, we have to catch an
362 // improperly ordered disabled window and quasi-modal dialog here and reorder
363 // them.
364 if( !IsEnabled() && IsActive() )
365 {
366 wxWindow* dlg = findQuasiModalDialog();
367
368 if( dlg )
369 dlg->Raise();
370 }
371#endif
372
373#ifdef __WXMSW__
374 // When changing DPI to a lower value, somehow, called from wxNonOwnedWindow::HandleDPIChange,
375 // our sizers compute a min size that is larger than the old frame size. wx then sets this wrong size.
376 // This shouldn't be needed since the OS have already sent a size event.
377 // Avoid this wx behaviour by pretending we've processed the event even if we use Skip in handlers.
378 if( aEvent.GetEventType() == wxEVT_DPI_CHANGED )
379 {
380 wxFrame::ProcessEvent( aEvent );
381 return true;
382 }
383#endif
384
385 if( !wxFrame::ProcessEvent( aEvent ) )
386 return false;
387
388 if( Pgm().m_Quitting )
389 return true;
390
391 if( !m_isClosing && m_supportsAutoSave && IsShownOnScreen() && IsActive()
393 && GetAutoSaveInterval() > 0 )
394 {
395 if( !m_autoSavePending )
396 {
397 wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
398 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
399 m_autoSavePending = true;
400
401 // A fresh cycle starts here (a prior snapshot completed or an explicit save cleared
402 // the pending state), so drop any deferral streak left over from that cycle; otherwise
403 // its stale start time could force the next snapshot to run mid-interaction.
404 m_autoSaveDeferredSince = wxInvalidDateTime;
405 }
406 else if( m_autoSaveTimer->IsRunning() )
407 {
408 wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
409 m_autoSaveTimer->Stop();
410 m_autoSavePending = false;
411 }
412 }
413
414 return true;
415}
416
417
422
423
424void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
425{
426 // Don't stomp on someone else's timer event.
427 if( aEvent.GetId() != ID_AUTO_SAVE_TIMER )
428 {
429 aEvent.Skip();
430 return;
431 }
432
433 // A one-shot tick can already be queued when the frame starts closing; running the saver batch
434 // then would serialize documents whose editors are mid-teardown, so bail once closing begins.
435 if( m_isClosing )
436 return;
437
438 // When the save is deferred (an interactive operation is in progress) keep the timer armed so
439 // a later tick retries. Maintaining m_autoSavePending here preserves the "pending == timer
440 // running" invariant that ProcessEvent() relies on to avoid re-arming the timer on every event.
442 {
443 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
444 m_autoSavePending = true;
445 }
446 else
447 {
448 m_autoSavePending = false;
449 }
450}
451
452
453static wxString buildRecoveredFileName( const wxFileName& aSrcFn, const wxDateTime& aStamp )
454{
455 wxString stamp = aStamp.IsValid() ? aStamp.Format( wxS( "%Y-%m-%d_%H%M%S" ) ) : wxString( wxS( "unknown-time" ) );
456
457 wxFileName recovered( aSrcFn );
458 recovered.SetName( aSrcFn.GetName() + wxS( ".recovered." ) + stamp );
459
460 int seq = 1;
461
462 while( recovered.FileExists() )
463 recovered.SetName( aSrcFn.GetName() + wxS( ".recovered." ) + stamp + wxString::Format( wxS( ".%d" ), seq++ ) );
464
465 return recovered.GetFullPath();
466}
467
468
469void EDA_BASE_FRAME::CheckForAutosaveFiles( const wxString& aProjectPath, const std::vector<wxString>& aExtensions )
470{
471 auto stale = Kiway().LocalHistory().FindStaleAutosaveFiles( aProjectPath, aExtensions );
472
473 if( stale.empty() )
474 return;
475
476 DIALOG_AUTOSAVE_RECOVERY dlg( this, stale );
477 dlg.ShowModal();
478
479 auto selected = dlg.GetSelectedStale();
480
481 switch( dlg.GetChoice() )
482 {
484 for( const auto& [autosavePath, srcPath] : selected )
485 {
486 if( !wxCopyFile( autosavePath, srcPath, true ) )
487 {
488 wxLogError( _( "Failed to recover auto-saved file '%s'." ), srcPath );
489 continue;
490 }
491
492 wxRemoveFile( autosavePath );
493 }
494 break;
495
497 for( const auto& [autosavePath, srcPath] : selected )
498 {
499 if( wxFileExists( autosavePath ) )
500 wxRemoveFile( autosavePath );
501 }
502 break;
503
505 for( const auto& [autosavePath, srcPath] : selected )
506 {
507 wxFileName autosaveFn( autosavePath );
508 wxFileName srcFn( srcPath );
509 wxDateTime stamp = autosaveFn.FileExists() ? autosaveFn.GetModificationTime() : wxDateTime::Now();
510
511 wxString target = buildRecoveredFileName( srcFn, stamp );
512
513 if( !wxCopyFile( autosavePath, target, true ) )
514 {
515 wxLogError( _( "Failed to write recovered file '%s'." ), target );
516 continue;
517 }
518
519 wxRemoveFile( autosavePath );
520 }
521 break;
522
524 // Leave all autosaves on disk so the dialog can offer them again next open.
525 break;
526 }
527}
528
529
531{
532 // Defer the snapshot if the user is mid-interaction. Serializing a large document on the
533 // UI thread freezes the editor for seconds; deferring keeps the dirty flags set so the
534 // rescheduled timer tick will pick the work up once the operation completes. To avoid
535 // starving the snapshot when the user parks in an interactive tool, the deferral is bounded
536 // and the save is forced once it has been outstanding for longer than the cap.
537 if( !canRunAutoSave() )
538 {
539 wxDateTime now = wxDateTime::Now();
540
541 if( !m_autoSaveDeferredSince.IsValid() )
543
544 wxTimeSpan maxDeferral = wxTimeSpan::Seconds( std::max( 60, GetAutoSaveInterval() * 12 ) );
545
546 if( now - m_autoSaveDeferredSince < maxDeferral )
547 {
548 wxLogTrace( traceAutoSave, wxT( "Deferring auto save; an interactive operation is in progress." ) );
549 return false;
550 }
551
552 wxLogTrace( traceAutoSave, wxT( "Auto save deferral exceeded; saving despite interactive operation." ) );
553 }
554
555 // The deferral is resolved (either the user went idle or the cap forced the snapshot), so the
556 // cycle is now consumed regardless of the saver outcome. The snapshot is best effort: a
557 // droppable cycle (a prior autosave still writing) is recaptured by the next edit's OnModify,
558 // so clear the flags here rather than re-arming on the saver result, which would poll forever
559 // in degenerate states such as no registered savers.
560 m_autoSaveDeferredSince = wxInvalidDateTime;
561 m_autoSaveRequired = false;
562
564
565 // Incremental and zip-autosave both write outside the project tree when the user
566 // selects USER_DIR, so a read-only project is fine in that mode. Only when the
567 // chosen location is the project directory does the project tree need to be writable.
568 if( cs->m_Backup.location == BACKUP_LOCATION::PROJECT_DIR && Prj().IsReadOnly() )
569 return true;
570
571 if( cs->AutosaveUsesLocalHistory() )
572 Kiway().LocalHistory().RunRegisteredSaversAndCommit( Prj().GetProjectPath(), wxS( "Autosave" ) );
573 else
575
576 return true;
577}
578
579
580void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
581{
582 wxLogTrace( kicadTraceKeyEvent, wxS( "EDA_BASE_FRAME::OnCharHook %s" ), dump( aKeyEvent ) );
583
584 // Key events can be filtered here.
585 // Currently no filtering is made.
586 aKeyEvent.Skip();
587}
588
589
590void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
591{
592 if( !m_toolDispatcher )
593 aEvent.Skip();
594 else
595 m_toolDispatcher->DispatchWxEvent( aEvent );
596}
597
598
600{
601 // Bind a single wxID_ANY dispatcher on first use rather than one Bind() per action.
602 // wxEvtHandler::SearchDynamicEventTable does a linear scan through all dynamic bindings
603 // for every event dispatch (including mouse motion), so 150 individual bindings cost
604 // O(150) per event regardless of event type. One wxID_ANY binding costs O(1).
606 {
607 Bind( wxEVT_UPDATE_UI, &EDA_BASE_FRAME::onUpdateUI, this );
609 }
610
612 std::placeholders::_1,
613 this,
614 aConditions );
615}
616
617
619{
620 m_uiUpdateMap.erase( aID );
621}
622
623
624void EDA_BASE_FRAME::onUpdateUI( wxUpdateUIEvent& aEvent )
625{
626 const auto it = m_uiUpdateMap.find( aEvent.GetId() );
627
628 if( it != m_uiUpdateMap.end() )
629 it->second( aEvent );
630 else
631 aEvent.Skip();
632}
633
634
635void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
636 ACTION_CONDITIONS& aCond )
637{
638 bool checkRes = false;
639 bool enableRes = true;
640 bool showRes = true;
641 bool isCut = aEvent.GetId() == ACTIONS::cut.GetUIId();
642 bool isCopy = aEvent.GetId() == ACTIONS::copy.GetUIId();
643 bool isPaste = aEvent.GetId() == ACTIONS::paste.GetUIId();
644 SELECTION& selection = aFrame->GetCurrentSelection();
645
646 try
647 {
648 checkRes = aCond.checkCondition( selection );
649 enableRes = aCond.enableCondition( selection );
650 showRes = aCond.showCondition( selection );
651 }
652 catch( std::exception& )
653 {
654 // Something broke with the conditions, just skip the event.
655 aEvent.Skip();
656 return;
657 }
658
659 if( showRes && aEvent.GetId() == ACTIONS::undo.GetUIId() )
660 {
661 wxString msg = _( "Undo" );
662
663 if( enableRes )
664 msg += wxS( " " ) + aFrame->GetUndoActionDescription();
665
666 aEvent.SetText( msg );
667 }
668 else if( showRes && aEvent.GetId() == ACTIONS::redo.GetUIId() )
669 {
670 wxString msg = _( "Redo" );
671
672 if( enableRes )
673 msg += wxS( " " ) + aFrame->GetRedoActionDescription();
674
675 aEvent.SetText( msg );
676 }
677
678 if( isCut || isCopy || isPaste )
679 {
680 wxWindow* focus = wxWindow::FindFocus();
681 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
682
683 if( textEntry && isCut && textEntry->CanCut() )
684 enableRes = true;
685 else if( textEntry && isCopy && textEntry->CanCopy() )
686 enableRes = true;
687 else if( textEntry && isPaste && textEntry->CanPaste() )
688 enableRes = true;
689 else if( dynamic_cast<WX_GRID*>( focus ) )
690 enableRes = false; // Must disable menu in order to get command as CharHook event
691 }
692
693 aEvent.Enable( enableRes );
694 aEvent.Show( showRes );
695
696 if( aEvent.IsCheckable() )
697 aEvent.Check( checkRes );
698}
699
700
702{
703 // Setup the conditions to check a language menu item
704 auto isCurrentLang =
705 [] ( const SELECTION& aSel, int aLangIdentifier )
706 {
707 return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
708 };
709
710 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
711 {
713 cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
714 LanguagesList[ii].m_WX_Lang_Identifier ) );
715 RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
716 }
717}
718
719
721 const ACTION_TOOLBAR_CONTROL_FACTORY& aControlFactory )
722{
723 m_toolbarControlFactories.emplace( aControlDesc.GetName(), aControlFactory );
724}
725
726
728{
729 for( auto& control : m_toolbarControlFactories )
730 {
731 if( control.first == aName )
732 return &control.second;
733 }
734
735 return nullptr;
736}
737
738
742
743
745{
746 if( m_tbLeft )
747 m_tbLeft->SelectAction( aAction );
748
749 if( m_tbTopMain )
750 m_tbTopMain->SelectAction( aAction );
751
752 if( m_tbTopAux )
753 m_tbTopAux->SelectAction( aAction );
754
755 if( m_tbRight )
756 m_tbRight->SelectAction( aAction );
757}
758
759
761{
762 wxWindowUpdateLocker dummy( this );
763
764 wxASSERT( m_toolbarSettings );
765
766 if( m_tbRight )
767 m_tbRight->ClearToolbar();
768
769 if( m_tbLeft )
770 m_tbLeft->ClearToolbar();
771
772 if( m_tbTopMain )
773 m_tbTopMain->ClearToolbar();
774
775 if( m_tbTopAux )
776 m_tbTopAux->ClearToolbar();
777
778 std::optional<TOOLBAR_CONFIGURATION> tbConfig;
779
780 // Drawing tools (typically on right edge of window)
781 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::RIGHT, config()->m_CustomToolbars );
782
783 if( tbConfig.has_value() )
784 {
785 if( !m_tbRight )
786 {
787 m_tbRight = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
788 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL | wxAUI_TB_TEXT
789 | wxAUI_TB_OVERFLOW );
790 m_tbRight->SetAuiManager( &m_auimgr );
791 }
792
793 m_tbRight->ApplyConfiguration( tbConfig.value() );
794 }
795
796 // Options (typically on left edge of window)
797 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::LEFT, config()->m_CustomToolbars );
798
799 if( tbConfig.has_value() )
800 {
801 if( !m_tbLeft )
802 {
803 m_tbLeft = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
804 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL | wxAUI_TB_TEXT | wxAUI_TB_OVERFLOW );
805 m_tbLeft->SetAuiManager( &m_auimgr );
806 }
807
808 m_tbLeft->ApplyConfiguration( tbConfig.value() );
809 }
810
811 // Top main toolbar (the top one)
812 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_MAIN, config()->m_CustomToolbars );
813
814 if( tbConfig.has_value() )
815 {
816 if( !m_tbTopMain )
817 {
818 m_tbTopMain = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
819 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL
820 | wxAUI_TB_TEXT | wxAUI_TB_OVERFLOW );
821 m_tbTopMain->SetAuiManager( &m_auimgr );
822 }
823
824 m_tbTopMain->ApplyConfiguration( tbConfig.value() );
825 }
826
827 // Top aux toolbar (the bottom one)
828 tbConfig = m_toolbarSettings->GetToolbarConfig( TOOLBAR_LOC::TOP_AUX, config()->m_CustomToolbars );
829
830 if( tbConfig.has_value() )
831 {
832 if( !m_tbTopAux )
833 {
834 m_tbTopAux = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
835 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL
836 | wxAUI_TB_TEXT | wxAUI_TB_OVERFLOW );
837 m_tbTopAux->SetAuiManager( &m_auimgr );
838 }
839
840 m_tbTopAux->ApplyConfiguration( tbConfig.value() );
841 }
842
844}
845
846
848{
849 if( m_tbTopMain )
850 m_tbTopMain->UpdateControlWidths();
851
852 if( m_tbRight )
853 m_tbRight->UpdateControlWidths();
854
855 if( m_tbLeft )
856 m_tbLeft->UpdateControlWidths();
857
858 if( m_tbTopAux )
859 m_tbTopAux->UpdateControlWidths();
860
861}
862
863
865{
866 if( m_tbTopMain )
867 m_auimgr.GetPane( m_tbTopMain ).MaxSize( m_tbTopMain->GetSize() );
868
869 if( m_tbRight )
870 m_auimgr.GetPane( m_tbRight ).MaxSize( m_tbRight->GetSize() );
871
872 if( m_tbLeft )
873 m_auimgr.GetPane( m_tbLeft ).MaxSize( m_tbLeft->GetSize() );
874
875 if( m_tbTopAux )
876 m_auimgr.GetPane( m_tbTopAux ).MaxSize( m_tbTopAux->GetSize() );
877
878 m_auimgr.Update();
879}
880
881
883{
890
891 CallAfter( [this]()
892 {
893 if( m_isClosing )
894 return;
895
897
898 // A submenu entry gets a new automatic id in each menubar, and its handler
899 // is registered under that id, so the ones of the old menubar are dead
900 wxMenuBar* menuBar = GetMenuBar();
901
902 std::erase_if( m_uiUpdateMap,
903 [menuBar]( const auto& aEntry )
904 {
905 int id = aEntry.first;
906
907 return id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST
908 && !( menuBar && menuBar->FindItem( id ) );
909 } );
910 } );
911}
912
913
914void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
915{
916 COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
917 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
918
919 helpMenu->Add( ACTIONS::help );
920 helpMenu->Add( ACTIONS::gettingStarted );
921 helpMenu->Add( ACTIONS::listHotKeys );
922 helpMenu->Add( ACTIONS::getInvolved );
923 helpMenu->Add( ACTIONS::donate );
924 helpMenu->Add( ACTIONS::reportBug );
925
926 helpMenu->AppendSeparator();
927 helpMenu->Add( ACTIONS::about );
928
929 aMenuBar->Append( helpMenu, _( "&Help" ) );
930}
931
932
933
935{
936 wxString menuItemLabel = aAction.GetMenuLabel();
937 wxMenuBar* menuBar = GetMenuBar();
938
939 for( size_t ii = 0; ii < menuBar->GetMenuCount(); ++ii )
940 {
941 for( wxMenuItem* menuItem : menuBar->GetMenu( ii )->GetMenuItems() )
942 {
943 if( menuItem->GetItemLabelText() == menuItemLabel )
944 {
945 wxString menuTitleLabel = menuBar->GetMenuLabelText( ii );
946
947 menuTitleLabel.Replace( wxS( "&" ), wxS( "&&" ) );
948 menuItemLabel.Replace( wxS( "&" ), wxS( "&&" ) );
949
950 return wxString::Format( _( "Run: %s > %s" ),
951 menuTitleLabel,
952 menuItemLabel );
953 }
954 }
955 }
956
957 return wxString::Format( _( "Run: %s" ), aAction.GetFriendlyName() );
958};
959
960
962{
964
965 if( GetMenuBar() )
966 {
968 GetMenuBar()->Refresh();
969 }
970}
971
972
974{
976
977 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
978
979 bool running = Pgm().GetApiServer().Running();
980
981 if( running && !settings->m_Api.enable_server )
982 {
983 Pgm().GetApiServer().Stop();
984 }
985 else if( !running && settings->m_Api.enable_server )
986 {
987 Pgm().GetApiServer().Start();
989 }
990
991 if( m_fileHistory )
992 {
993 int historySize = settings->m_System.file_history_size;
994 m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
995 }
996
997 if( Pgm().GetCommonSettings()->AutosaveUsesLocalHistory() )
998 Kiway().LocalHistory().Init( Prj().GetProjectPath() );
999
1001 ThemeChanged();
1002
1003 if( GetMenuBar() )
1004 {
1005 // For icons in menus, icon scaling & hotkeys
1007 GetMenuBar()->Refresh();
1008 }
1009
1010 // Update the toolbars
1012}
1013
1014
1016{
1018
1019 // Update all the toolbars to have new icons
1020 wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
1021
1022 for( size_t i = 0; i < panes.GetCount(); ++i )
1023 {
1024 if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
1025 toolbar->RefreshBitmaps();
1026 }
1027}
1028
1029
1030void EDA_BASE_FRAME::OnSize( wxSizeEvent& aEvent )
1031{
1032#ifdef __WXMAC__
1033 int currentDisplay = wxDisplay::GetFromWindow( this );
1034
1035 if( m_displayIndex >= 0 && currentDisplay >= 0 && currentDisplay != m_displayIndex )
1036 {
1037 wxLogTrace( traceDisplayLocation, wxS( "OnSize: current display changed %d to %d" ),
1038 m_displayIndex, currentDisplay );
1039 m_displayIndex = currentDisplay;
1041 }
1042#endif
1043
1044 aEvent.Skip();
1045}
1046
1047
1048void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
1049{
1050 if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
1051 return;
1052
1053 if( const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName ) )
1054 LoadWindowState( state->window );
1055}
1056
1057
1059{
1060 bool wasDefault = false;
1061
1062 m_framePos.x = aState.pos_x;
1063 m_framePos.y = aState.pos_y;
1064 m_frameSize.x = aState.size_x;
1065 m_frameSize.y = aState.size_y;
1066
1067 wxLogTrace( traceDisplayLocation, wxS( "Config position (%d, %d) with size (%d, %d)" ),
1069
1070 // Ensure minimum size is set if the stored config was zero-initialized
1071 wxSize minSize = minSizeLookup( m_ident, this );
1072
1073 if( m_frameSize.x < minSize.x || m_frameSize.y < minSize.y )
1074 {
1075 m_frameSize = defaultSize( m_ident, this );
1076 wasDefault = true;
1077
1078 wxLogTrace( traceDisplayLocation, wxS( "Using minimum size (%d, %d)" ), m_frameSize.x, m_frameSize.y );
1079 }
1080
1081 wxLogTrace( traceDisplayLocation, wxS( "Number of displays: %d" ), wxDisplay::GetCount() );
1082
1083 if( aState.display >= wxDisplay::GetCount() )
1084 {
1085 wxLogTrace( traceDisplayLocation, wxS( "Previous display not found" ) );
1086
1087 // If it isn't attached, use the first display
1088 // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
1089 const unsigned int index = 0;
1090 wxDisplay display( index );
1091 wxRect clientSize = display.GetGeometry();
1092
1093 m_framePos = wxDefaultPosition;
1094
1095 // Ensure the window fits on the display, since the other one could have been larger
1096 if( m_frameSize.x > clientSize.width )
1097 m_frameSize.x = clientSize.width;
1098
1099 if( m_frameSize.y > clientSize.height )
1100 m_frameSize.y = clientSize.height;
1101 }
1102 else
1103 {
1104 wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
1105 wxPoint upperLeft( m_framePos.x, m_framePos.y );
1106
1107 wxDisplay display( aState.display );
1108 wxRect clientSize = display.GetClientArea();
1109
1110 int yLimTop = clientSize.y;
1111 int yLimBottom = clientSize.y + clientSize.height;
1112 int xLimLeft = clientSize.x;
1113 int xLimRight = clientSize.x + clientSize.width;
1114
1115 if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
1116 upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
1117 upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
1118 upperLeft.y > yLimBottom )
1119 {
1120 m_framePos = wxDefaultPosition;
1121 wxLogTrace( traceDisplayLocation, wxS( "Resetting to default position" ) );
1122 }
1123
1124 // Clamp the saved size to the current display, in case the window was sized for a
1125 // larger external monitor that is no longer attached.
1126 if( m_frameSize.x > clientSize.width )
1127 {
1128 wxLogTrace( traceDisplayLocation, wxS( "Clamping window width %d to display width %d" ),
1129 m_frameSize.x, clientSize.width );
1130 m_frameSize.x = clientSize.width;
1131 }
1132
1133 if( m_frameSize.y > clientSize.height )
1134 {
1135 wxLogTrace( traceDisplayLocation, wxS( "Clamping window height %d to display height %d" ),
1136 m_frameSize.y, clientSize.height );
1137 m_frameSize.y = clientSize.height;
1138 }
1139 }
1140
1141 wxLogTrace( traceDisplayLocation, wxS( "Final window position (%d, %d) with size (%d, %d)" ),
1143
1144 SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
1145
1146 // Center the window if we reset to default
1147 if( m_framePos.x == -1 )
1148 {
1149 wxLogTrace( traceDisplayLocation, wxS( "Centering window" ) );
1150 Center();
1151 m_framePos = GetPosition();
1152 }
1153
1154 // Record the frame sizes in an un-maximized state
1157
1158 // Maximize if we were maximized before
1159 if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
1160 {
1161 wxLogTrace( traceDisplayLocation, wxS( "Maximizing window" ) );
1162 Maximize();
1163 }
1164
1165 m_displayIndex = wxDisplay::GetFromWindow( this );
1166}
1167
1168
1170{
1171 wxDisplay display( wxDisplay::GetFromWindow( this ) );
1172 wxRect clientSize = display.GetClientArea();
1173 wxPoint pos = GetPosition();
1174 wxSize size = GetWindowSize();
1175
1176 wxLogTrace( traceDisplayLocation, wxS( "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d" ),
1177 clientSize.x, clientSize.y,
1178 clientSize.width, clientSize.height );
1179
1180 if( pos.y < clientSize.y )
1181 {
1182 wxLogTrace( traceDisplayLocation, wxS( "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d" ),
1183 pos.y, clientSize.y );
1184 pos.y = clientSize.y;
1185 }
1186
1187 if( pos.x < clientSize.x )
1188 {
1189 wxLogTrace( traceDisplayLocation, wxS( "ensureWindowIsOnScreen: x pos %d below minimum, setting to %d" ),
1190 pos.x, clientSize.x );
1191 pos.x = clientSize.x;
1192 }
1193
1194 if( pos.x + size.x - clientSize.x > clientSize.width )
1195 {
1196 int newWidth = clientSize.width - ( pos.x - clientSize.x );
1197 wxLogTrace( traceDisplayLocation, wxS( "ensureWindowIsOnScreen: width %d above available %d, setting to %d" ),
1198 pos.x + size.x, clientSize.width, newWidth );
1199 size.x = newWidth;
1200 }
1201
1202 if( pos.y + size.y - clientSize.y > clientSize.height )
1203 {
1204 int newHeight = clientSize.height - ( pos.y - clientSize.y );
1205 wxLogTrace( traceDisplayLocation, wxS( "ensureWindowIsOnScreen: height %d above available %d, setting to %d" ),
1206 pos.y + size.y, clientSize.height, newHeight );
1207 size.y = newHeight;
1208 }
1209
1210 wxLogTrace( traceDisplayLocation, wxS( "Updating window position (%d, %d) with size (%d, %d)" ),
1211 pos.x, pos.y, size.x, size.y );
1212
1213 SetSize( pos.x, pos.y, size.x, size.y );
1214}
1215
1216
1218{
1219 LoadWindowState( aCfg->state );
1220
1221 m_perspective = aCfg->perspective;
1222 m_auiLayoutState = std::make_unique<nlohmann::json>( aCfg->aui_state );
1223 m_mruPath = aCfg->mru_path;
1224
1226}
1227
1228
1230{
1231 if( IsIconized() )
1232 return;
1233
1234 // If the window is maximized, we use the saved window size from before it was maximized
1235 if( IsMaximized() )
1236 {
1239 }
1240 else
1241 {
1243 m_framePos = GetPosition();
1244 }
1245
1246 aCfg->state.pos_x = m_framePos.x;
1247 aCfg->state.pos_y = m_framePos.y;
1248 aCfg->state.size_x = m_frameSize.x;
1249 aCfg->state.size_y = m_frameSize.y;
1250 aCfg->state.maximized = IsMaximized();
1251 aCfg->state.display = wxDisplay::GetFromWindow( this );
1252
1253 wxLogTrace( traceDisplayLocation, wxS( "Saving window maximized: %s" ),
1254 IsMaximized() ? wxS( "true" ) : wxS( "false" ) );
1255 wxLogTrace( traceDisplayLocation, wxS( "Saving config position (%d, %d) with size (%d, %d)" ),
1257
1258 // Once this is fully implemented, wxAuiManager will be used to maintain
1259 // the persistence of the main frame and all it's managed windows and
1260 // all of the legacy frame persistence position code can be removed.
1261#if wxCHECK_VERSION( 3, 3, 0 )
1262 {
1263 WX_AUI_JSON_SERIALIZER serializer( m_auimgr );
1264 nlohmann::json state = serializer.Serialize();
1265
1266 if( state.is_null() || state.empty() )
1267 aCfg->aui_state = nlohmann::json();
1268 else
1269 aCfg->aui_state = state;
1270
1271 aCfg->perspective.clear();
1272 }
1273#else
1274 aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
1275 aCfg->aui_state = nlohmann::json();
1276#endif
1277
1278 aCfg->mru_path = m_mruPath;
1279}
1280
1281
1283{
1285
1286 // Get file history size from common settings
1287 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
1288
1289 // Load the recently used files into the history menu
1290 m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 1, fileHistorySize ), ID_FILE1, ID_FILE_LIST_CLEAR );
1291 m_fileHistory->Load( *aCfg );
1292}
1293
1294
1296{
1297 wxCHECK( config(), /* void */ );
1298
1300
1301 bool fileOpen = m_isClosing && m_isNonUserClose;
1302
1303 wxString currentlyOpenedFile = GetCurrentFileName();
1304
1305 if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
1306 {
1307 wxFileName rfn( currentlyOpenedFile );
1308 rfn.MakeRelativeTo( Prj().GetProjectPath() );
1309 Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
1310 }
1311
1312 // Save the recently used files list
1313 if( m_fileHistory )
1314 {
1315 // Save the currently opened file in the file history
1316 if( !currentlyOpenedFile.IsEmpty() )
1317 UpdateFileHistory( currentlyOpenedFile );
1318
1319 m_fileHistory->Save( *aCfg );
1320 }
1321}
1322
1323
1328
1329
1331{
1332 // KICAD_MANAGER_FRAME overrides this
1333 return Kiface().KifaceSettings();
1334}
1335
1336
1338{
1339 return Kiface().KifaceSearch();
1340}
1341
1342
1344{
1345 return Kiface().GetHelpFileName();
1346}
1347
1348
1349void EDA_BASE_FRAME::PrintMsg( const wxString& text )
1350{
1351 SetStatusText( text );
1352}
1353
1354
1356{
1357 wxWindow* canvas = GetToolCanvas();
1358
1359 wxCHECK( canvas, /* void */ );
1360
1361 m_infoBar = new WX_INFOBAR( canvas, wxID_ANY, true );
1362}
1363
1364
1366{
1367 m_auimgr.Update();
1368}
1369
1370
1372{
1373 if( !ADVANCED_CFG::GetCfg().m_EnableUseAuiPerspective )
1374 return;
1375
1376 bool restored = false;
1377
1378#if wxCHECK_VERSION( 3, 3, 0 )
1379 if( m_auiLayoutState && !m_auiLayoutState->is_null() && !m_auiLayoutState->empty() )
1380 {
1381 WX_AUI_JSON_SERIALIZER serializer( m_auimgr );
1382
1383 if( serializer.Deserialize( *m_auiLayoutState ) )
1384 restored = true;
1385 }
1386#endif
1387
1388 /*
1389 * Legacy loading of the string AUI perspective (if it exists). This is needed for
1390 * wx 3.2 or the first settings upgrade when wx 3.3 is used in KiCad (e.g., 9.0->10.0 for Windows and macOS).
1391 */
1392 if( !restored && !m_perspective.IsEmpty() )
1393 m_auimgr.LoadPerspective( m_perspective );
1394
1395 // Workaround for two bugs:
1396 // 1) wx 3.2: LoadPerspective() hides all panes first, then shows only
1397 // those in the saved string. If toolbar names changed or new toolbars were added,
1398 // they'd stay hidden. Ensure all toolbars are visible after restore.
1399 // 2) We still saw this even after this fix, so just make the toolbars shown unconditionally
1400 // since we don't actually allow hiding them. The root cause of this part is not known.
1401 wxAuiPaneInfoArray& panes = m_auimgr.GetAllPanes();
1402
1403 for( size_t i = 0; i < panes.GetCount(); ++i )
1404 {
1405 if( panes.Item( i ).IsToolbar() )
1406 panes.Item( i ).Show( true );
1407 }
1408}
1409
1410
1411void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
1412 INFOBAR_MESSAGE_TYPE aType )
1413{
1414 wxCHECK( m_infoBar, /* void */ );
1415
1416 m_infoBar->RemoveAllButtons();
1417
1418 if( aShowCloseButton )
1419 m_infoBar->AddCloseButton();
1420
1421 GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType );
1422}
1423
1424
1425void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
1426 std::function<void(void)> aCallback )
1427{
1428 wxCHECK( m_infoBar, /* void */ );
1429
1430 m_infoBar->RemoveAllButtons();
1431
1432 if( aShowCloseButton )
1433 m_infoBar->AddCloseButton();
1434
1435 if( aCallback )
1436 m_infoBar->SetCallback( aCallback );
1437
1438 GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
1439}
1440
1441
1442void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
1443{
1444 wxCHECK( m_infoBar, /* void */ );
1445
1446 m_infoBar->RemoveAllButtons();
1447
1448 if( aShowCloseButton )
1449 m_infoBar->AddCloseButton();
1450
1451 GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
1452}
1453
1454
1455void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
1456{
1457 wxCHECK( m_infoBar, /* void */ );
1458
1459 m_infoBar->RemoveAllButtons();
1460
1461 if( aShowCloseButton )
1462 m_infoBar->AddCloseButton();
1463
1464 GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
1465}
1466
1467
1468void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
1469{
1470 if( !aFileHistory )
1471 aFileHistory = m_fileHistory;
1472
1473 wxASSERT( aFileHistory );
1474
1475 aFileHistory->AddFileToHistory( FullFileName );
1476
1477 // Update the menubar to update the file history menu
1478 if( !m_isClosing && GetMenuBar() )
1479 {
1481 GetMenuBar()->Refresh();
1482 }
1483}
1484
1485
1486wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, FILE_HISTORY* aFileHistory )
1487{
1488 if( !aFileHistory )
1489 aFileHistory = m_fileHistory;
1490
1491 wxASSERT( aFileHistory );
1492
1493 int baseId = aFileHistory->GetBaseId();
1494
1495 wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
1496 int i = cmdId - baseId;
1497
1498 wxString fn = aFileHistory->GetHistoryFile( i );
1499
1500 if( !wxFileName::FileExists( fn ) )
1501 {
1502 KICAD_MESSAGE_DIALOG dlg( this, wxString::Format( _( "File '%s' was not found.\n" ), fn ), _( "Error" ),
1503 wxYES_NO | wxYES_DEFAULT | wxICON_ERROR | wxCENTER );
1504
1505 dlg.SetExtendedMessage( _( "Do you want to remove it from list of recently opened files?" ) );
1506 dlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Remove" ) ),
1507 KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Keep" ) ) );
1508
1509 if( dlg.ShowModal() == wxID_YES )
1510 aFileHistory->RemoveFileFromHistory( i );
1511
1512 fn.Clear();
1513 }
1514
1515 // Update the menubar to update the file history menu
1516 if( GetMenuBar() )
1517 {
1519 GetMenuBar()->Refresh();
1520 }
1521
1522 return fn;
1523}
1524
1525
1527{
1528 wxASSERT( m_fileHistory );
1529
1530 m_fileHistory->ClearFileHistory();
1531
1532 // Update the menubar to update the file history menu
1533 if( GetMenuBar() )
1534 {
1536 GetMenuBar()->Refresh();
1537 }
1538}
1539
1540
1541void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
1542{
1543 void ShowAboutDialog( EDA_BASE_FRAME * aParent ); // See AboutDialog_main.cpp
1544 ShowAboutDialog( this );
1545}
1546
1547
1548void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
1549{
1550 ShowPreferences( wxEmptyString, wxEmptyString );
1551}
1552
1553
1554void EDA_BASE_FRAME::ShowPreferences( const wxString& aStartPage, const wxString& aStartParentPage )
1555{
1556 PAGED_DIALOG dlg( this, _( "Preferences" ), true, true, wxEmptyString,
1557 wxWindow::FromDIP( wxSize( 980, 560 ), nullptr ) );
1558
1559 dlg.SetEvtHandlerEnabled( false );
1560
1561 {
1562 WX_BUSY_INDICATOR busy_cursor;
1563
1564 WX_TREEBOOK* book = dlg.GetTreebook();
1565 PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
1566 std::vector<int> expand;
1567
1568 wxWindow* kicadMgr_window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
1569
1570 if( KICAD_MANAGER_FRAME* kicadMgr = static_cast<KICAD_MANAGER_FRAME*>( kicadMgr_window ) )
1571 {
1572 ACTION_MANAGER* actionMgr = kicadMgr->GetToolManager()->GetActionManager();
1573
1574 for( const auto& [name, action] : actionMgr->GetActions() )
1575 hotkeysPanel->ActionsList().push_back( action );
1576 }
1577
1578 book->AddLazyPage(
1579 []( wxWindow* aParent ) -> wxWindow*
1580 {
1581 return new PANEL_COMMON_SETTINGS( aParent );
1582 },
1583 _( "Common" ) );
1584
1585 book->AddLazyPage(
1586 []( wxWindow* aParent ) -> wxWindow*
1587 {
1588 return new PANEL_MOUSE_SETTINGS( aParent );
1589 }, _( "Mouse and Touchpad" ) );
1590
1591#if defined(__linux__) || defined(__FreeBSD__)
1592 book->AddLazyPage(
1593 [] ( wxWindow* aParent ) -> wxWindow*
1594 {
1595 return new PANEL_SPACEMOUSE( aParent );
1596 }, _( "SpaceMouse" ) );
1597#endif
1598
1599 book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
1600
1601 book->AddLazyPage(
1602 []( wxWindow* aParent ) -> wxWindow*
1603 {
1604 return new PANEL_GIT_REPOS( aParent );
1605 }, _( "Version Control" ) );
1606
1607#ifdef KICAD_USE_SENTRY
1608 book->AddLazyPage(
1609 []( wxWindow* aParent ) -> wxWindow*
1610 {
1611 return new PANEL_DATA_COLLECTION( aParent );
1612 }, _( "Data Collection" ) );
1613#endif
1614
1615#define LAZY_CTOR( key ) \
1616 [this, kiface]( wxWindow* aParent ) \
1617 { \
1618 return kiface->CreateKiWindow( aParent, key, &Kiway() ); \
1619 }
1620
1621 // If a dll is not loaded, the loader will show an error message.
1622
1623 try
1624 {
1625 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_SCH ) )
1626 {
1627 kiface->GetActions( hotkeysPanel->ActionsList() );
1628
1630 expand.push_back( (int) book->GetPageCount() );
1631
1632 book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) );
1633 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_DISP_OPTIONS ), _( "Display Options" ) );
1634 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_GRIDS ), _( "Grids" ) );
1635 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_SNAPPING ), _( "Snapping" ) );
1636 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) );
1637 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_COLORS ), _( "Colors" ) );
1638 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_TOOLBARS ), _( "Toolbars" ) );
1639
1640 if( GetFrameType() == FRAME_SCH )
1641 expand.push_back( (int) book->GetPageCount() );
1642
1643 book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) );
1644 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_DISP_OPTIONS ), _( "Display Options" ) );
1645 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_GRIDS ), _( "Grids" ) );
1646 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_SNAPPING ), _( "Snapping" ) );
1647 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_EDIT_OPTIONS ), _( "Editing Options" ) );
1648 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_COLORS ), _( "Colors" ) );
1649 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_TOOLBARS ), _( "Toolbars" ) );
1650 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_FIELD_NAME_TEMPLATES ), _( "Field Name Templates" ) );
1651 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_DATA_SOURCES ), _( "Data Sources" ) );
1652 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_SIMULATOR ), _( "Simulator" ) );
1653 }
1654 }
1655 catch( ... )
1656 {
1657 }
1658
1659 try
1660 {
1661 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PCB ) )
1662 {
1663 kiface->GetActions( hotkeysPanel->ActionsList() );
1664
1666 expand.push_back( (int) book->GetPageCount() );
1667
1668 book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
1669 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DISPLAY_OPTIONS ), _( "Display Options" ) );
1670 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_GRIDS ), _( "Grids" ) );
1671 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_SNAPPING ), _( "Snapping" ) );
1672 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_ORIGINS_AXES ), _( "Origins & Axes" ) );
1673 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) );
1674 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_COLORS ), _( "Colors" ) );
1675 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_TOOLBARS ), _( "Toolbars" ) );
1676 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_FIELDS ), _( "Footprint Defaults" ) );
1677 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_GRAPHICS_VALUES ), _( "Graphics Defaults" ) );
1678 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_USER_LAYER_NAMES ), _( "User Layer Names" ) );
1679
1681 expand.push_back( (int) book->GetPageCount() );
1682
1683 book->AddPage( new wxPanel( book ), _( "PCB Editor" ) );
1684 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_DISPLAY_OPTS ), _( "Display Options" ) );
1685 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_GRIDS ), _( "Grids" ) );
1686 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_SNAPPING ), _( "Snapping" ) );
1687 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ORIGINS_AXES ), _( "Origins & Axes" ) );
1688 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_EDIT_OPTIONS ), _( "Editing Options" ) );
1689 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_COLORS ), _( "Colors" ) );
1690 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_TOOLBARS ), _( "Toolbars" ) );
1691 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ACTION_PLUGINS ), _( "Plugins" ) );
1692
1694 expand.push_back( (int) book->GetPageCount() );
1695
1696 book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
1697 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) );
1698 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_TOOLBARS ), _( "Toolbars" ) );
1699 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) );
1700 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) );
1701 }
1702 }
1703 catch( ... )
1704 {
1705 }
1706
1707 try
1708 {
1709 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_GERBVIEW ) )
1710 {
1711 kiface->GetActions( hotkeysPanel->ActionsList() );
1712
1713 if( GetFrameType() == FRAME_GERBER )
1714 expand.push_back( (int) book->GetPageCount() );
1715
1716 book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) );
1717 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) );
1718 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_COLORS ), _( "Colors" ) );
1719 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_TOOLBARS ), _( "Toolbars" ) );
1720 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_GRIDS ), _( "Grids" ) );
1721 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_SNAPPING ), _( "Snapping" ) );
1722 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) );
1723 }
1724 }
1725 catch( ... )
1726 {
1727 }
1728
1729 try
1730 {
1731 if( KIFACE* kiface = Kiway().KiFACE( KIWAY::FACE_PL_EDITOR ) )
1732 {
1733 kiface->GetActions( hotkeysPanel->ActionsList() );
1734
1735 if( GetFrameType() == FRAME_PL_EDITOR )
1736 expand.push_back( (int) book->GetPageCount() );
1737
1738 book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) );
1739 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_DISPLAY_OPTIONS ), _( "Display Options" ) );
1740 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_GRIDS ), _( "Grids" ) );
1741 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_SNAPPING ), _( "Snapping" ) );
1742 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_COLORS ), _( "Colors" ) );
1743 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_TOOLBARS ), _( "Toolbars" ) );
1744
1745 book->AddLazyPage(
1746 []( wxWindow* aParent ) -> wxWindow*
1747 {
1748 return new PANEL_PACKAGES_AND_UPDATES( aParent );
1749 }, _( "Packages and Updates" ) );
1750 }
1751 }
1752 catch( ... )
1753 {
1754 }
1755
1756 book->AddPage( new PANEL_PLUGIN_SETTINGS( book ), _( "Plugins" ) );
1757
1758 book->AddPage( new PANEL_MAINTENANCE( book, this ), _( "Maintenance" ) );
1759
1760 // Update all of the action hotkeys. The process of loading the actions through
1761 // the KiFACE will only get us the default hotkeys
1762 ReadHotKeyConfigIntoActions( wxEmptyString, hotkeysPanel->ActionsList() );
1763
1764 for( size_t i = 0; i < book->GetPageCount(); ++i )
1765 book->GetPage( i )->Layout();
1766
1767 for( int page : expand )
1768 book->ExpandNode( page );
1769
1770 if( !aStartPage.IsEmpty() )
1771 dlg.SetInitialPage( aStartPage, aStartParentPage );
1772
1773 dlg.SetEvtHandlerEnabled( true );
1774#undef LAZY_CTOR
1775 }
1776
1777 if( dlg.ShowModal() == wxID_OK )
1778 {
1779 // Update our grids that are cached in the tool
1780 m_toolManager->ResetTools( TOOL_BASE::REDRAW );
1783 }
1784
1785}
1786
1787
1788void EDA_BASE_FRAME::OnDropFiles( wxDropFilesEvent& aEvent )
1789{
1790 Raise();
1791
1792 wxString* files = aEvent.GetFiles();
1793
1794 for( int nb = 0; nb < aEvent.GetNumberOfFiles(); nb++ )
1795 {
1796 const wxFileName fn = wxFileName( files[nb] );
1797 wxString ext = fn.GetExt();
1798
1799 // Alias all gerber files as GerberFileExtension
1802
1803 if( m_acceptedExts.find( ext.ToStdString() ) != m_acceptedExts.end() )
1804 m_AcceptedFiles.emplace_back( fn );
1805 }
1806
1808 m_AcceptedFiles.clear();
1809}
1810
1811
1813{
1814 for( const wxFileName& file : m_AcceptedFiles )
1815 {
1816 wxString fn = file.GetFullPath();
1817 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( file.GetExt() ), &fn );
1818 }
1819}
1820
1821
1822bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName, bool aVerbose )
1823{
1824 wxString msg;
1825 wxFileName fn = aFileName;
1826
1827 // Check for absence of a file path with a file name. Unfortunately KiCad
1828 // uses paths relative to the current project path without the ./ part which
1829 // confuses wxFileName. Making the file name path absolute may be less than
1830 // elegant but it solves the problem.
1831 if( fn.GetPath().IsEmpty() && fn.HasName() )
1832 fn.MakeAbsolute();
1833
1834 wxCHECK_MSG( fn.IsOk(), false, wxT( "File name object is invalid. Bad programmer!" ) );
1835 wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
1836 wxT( "File name object path <" ) + fn.GetFullPath() + wxT( "> is not set. Bad programmer!" ) );
1837
1838 if( fn.IsDir() && !fn.IsDirWritable() )
1839 {
1840 msg.Printf( _( "Insufficient permissions to folder '%s'." ), fn.GetPath() );
1841 }
1842 else if( !fn.FileExists() && !fn.IsDirWritable() )
1843 {
1844 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1845 }
1846 else if( fn.FileExists() && !fn.IsFileWritable() )
1847 {
1848 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1849 }
1850
1851 if( !msg.IsEmpty() )
1852 {
1853 if( aVerbose )
1854 DisplayErrorMessage( this, msg );
1855
1856 return false;
1857 }
1858
1859 return true;
1860}
1861
1862
1864{
1865 // This function should be overridden in child classes
1866 return false;
1867}
1868
1869
1871{
1872 wxAcceleratorEntry entries[1];
1873 entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
1874 wxAcceleratorTable accel( 1, entries );
1875 SetAcceleratorTable( accel );
1876}
1877
1878
1884
1885
1887{
1888 m_undoList.PushCommand( aNewitem );
1889
1890 // Delete the extra items, if count max reached
1891 if( m_undoRedoCountMax > 0 )
1892 {
1893 int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
1894
1895 if( extraitems > 0 )
1896 ClearUndoORRedoList( UNDO_LIST, extraitems );
1897 }
1898}
1899
1900
1902{
1903 m_redoList.PushCommand( aNewitem );
1904
1905 // Delete the extra items, if count max reached
1906 if( m_undoRedoCountMax > 0 )
1907 {
1908 int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
1909
1910 if( extraitems > 0 )
1911 ClearUndoORRedoList( REDO_LIST, extraitems );
1912 }
1913}
1914
1915
1920
1921
1926
1927
1929{
1930 if( GetUndoCommandCount() > 0 )
1931 return m_undoList.m_CommandsList.back()->GetDescription();
1932
1933 return wxEmptyString;
1934}
1935
1936
1938{
1939 if( GetRedoCommandCount() > 0 )
1940 return m_redoList.m_CommandsList.back()->GetDescription();
1941
1942 return wxEmptyString;
1943}
1944
1945
1947{
1948 m_autoSaveRequired = true;
1949}
1950
1951
1953{
1954 SetUserUnits( aUnits );
1956
1957 wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
1958 e.SetInt( static_cast<int>( aUnits ) );
1959 e.SetClientData( this );
1960 ProcessEventLocally( e );
1961}
1962
1963
1964void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
1965{
1966 // When we maximize the window, we want to save the old information
1967 // so that we can add it to the settings on next window load.
1968 // Contrary to the documentation, this event seems to be generated
1969 // when the window is also being unmaximized on OSX, so we only
1970 // capture the size information when we maximize the window when on OSX.
1971#ifdef __WXOSX__
1972 if( !IsMaximized() )
1973#endif
1974 {
1976 m_normalFramePos = GetPosition();
1977 wxLogTrace( traceDisplayLocation, "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1980 }
1981
1982 // Skip event to actually maximize the window
1983 aEvent.Skip();
1984}
1985
1986
1988{
1989#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 9 )
1990 wxSize winSize = GetSize();
1991
1992 // GTK includes the window decorations in the normal GetSize call,
1993 // so we have to use a GTK-specific sizing call that returns the
1994 // non-decorated window size.
1996 {
1997 int width = 0;
1998 int height = 0;
1999 GTKDoGetSize( &width, &height );
2000
2001 winSize.Set( width, height );
2002 }
2003#else
2004 wxSize winSize = GetSize();
2005#endif
2006
2007 return winSize;
2008}
2009
2010
2012{
2013 ThemeChanged();
2014
2015 // This isn't handled by ThemeChanged()
2016 if( GetMenuBar() )
2017 {
2018 // For icons in menus, icon scaling & hotkeys
2020 GetMenuBar()->Refresh();
2021 }
2022}
2023
2024
2025void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
2026{
2027 // Call the handler to update the colors used in the frame
2029
2030 // Skip the change event to ensure the rest of the window controls get it
2031 aEvent.Skip();
2032}
2033
2034
2035void EDA_BASE_FRAME::onIconize( wxIconizeEvent& aEvent )
2036{
2037 // Call the handler
2038 handleIconizeEvent( aEvent );
2039
2040 // Skip the event.
2041 aEvent.Skip();
2042}
2043
2044
2045#ifdef __WXMSW__
2046WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
2047{
2048 // This will help avoid the menu keeping focus when the alt key is released
2049 // You can still trigger accelerators as long as you hold down alt
2050 if( message == WM_SYSCOMMAND )
2051 {
2052 if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
2053 return 0;
2054 }
2055
2056 return wxFrame::MSWWindowProc( message, wParam, lParam );
2057}
2058#endif
2059
2060
2062{
2063 ACTION_MENU* langsMenu = new ACTION_MENU( false, aControlTool );
2064 langsMenu->SetTitle( _( "Set Language" ) );
2065 langsMenu->SetIcon( BITMAPS::language );
2066
2067 wxString tooltip;
2068
2069 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
2070 {
2071 wxString label;
2072
2073 if( LanguagesList[ii].m_DoNotTranslate )
2074 label = LanguagesList[ii].m_Lang_Label;
2075 else
2076 label = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
2077
2078 wxMenuItem* item = new wxMenuItem( langsMenu, LanguagesList[ii].m_KI_Lang_Identifier, // wxMenuItem wxID
2079 label, tooltip, wxITEM_CHECK );
2080
2081 langsMenu->Append( item );
2082 }
2083
2084 // This must be done after the items are added
2085 aMasterMenu->Add( langsMenu );
2086}
2087
2088
2089void EDA_BASE_FRAME::OnLanguageSelectionEvent( wxCommandEvent& event )
2090{
2091 int id = event.GetId();
2092
2093 // tell all the KIWAY_PLAYERs about the language change.
2094 Kiway().SetLanguage( id );
2095}
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
int index
const char * name
void ClearScaledBitmapCache()
Wipes out the scaled bitmap cache so that the icon theme can be changed.
Definition bitmap.cpp:180
BITMAP_STORE * GetBitmapStore()
Definition bitmap.cpp:88
static TOOL_ACTION paste
Definition actions.h:77
static TOOL_ACTION about
Definition actions.h:288
static TOOL_ACTION reportBug
Definition actions.h:292
static TOOL_ACTION copy
Definition actions.h:75
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:72
static TOOL_ACTION redo
Definition actions.h:73
static TOOL_ACTION cut
Definition actions.h:74
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:43
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.
void ReloadPlugins(std::optional< wxString > aDirectoryToScan=std::nullopt, std::shared_ptr< REPORTER > aReporter=nullptr)
Clears the loaded plugins and actions and re-scans the filesystem to register new ones.
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.
std::vector< std::pair< wxString, wxString > > GetSelectedStale() const
AUTOSAVE_RECOVERY_CHOICE GetChoice() const
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:81
int ShowModal() override
The base frame for deriving all KiCad main window classes.
void SelectToolbarAction(const TOOL_ACTION &aAction) override
Select the given action in the toolbar group which contains it, if any.
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 ShowPreferences(const wxString &aStartPage, const wxString &aStartParentPage)
Display the preferences and settings of all opened editors paged dialog, starting with a particular p...
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 syncToolbarSelections()
Called after the toolbars are rebuilt so a frame can select the group entries that reflect its saved ...
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
bool m_isNonUserClose
Set by NonUserClose() to indicate that the user did not request the current close.
void CheckForAutosaveFiles(const wxString &aProjectPath, const std::vector< wxString > &aExtensions)
Check for autosave files newer than their source files for the given project.
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
std::vector< wxFileName > m_AcceptedFiles
bool m_uiUpdateHandlerBound
True once the single wxID_ANY UPDATE_UI handler has been bound.
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()
bool isBlockableSessionEnd() const
Return true when the session is ending on a platform that shows a shutdown block reason.
wxString m_perspective
wxDateTime m_autoSaveDeferredSince
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.
bool m_closeInProgress
Set while windowClosing() is deciding whether the frame may close.
ACTION_TOOLBAR * m_tbRight
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.
virtual bool canRunAutoSave() const
Return true when it is safe to run an autosave snapshot right now.
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 ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, INFOBAR_MESSAGE_TYPE aType=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...
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 onUpdateUI(wxUpdateUIEvent &aEvent)
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)
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...
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.
void OnLanguageSelectionEvent(wxCommandEvent &aEvent)
An event handler called on a language menu selection.
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)
std::unique_ptr< nlohmann::json > m_auiLayoutState
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.
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.
void ReCreateMenuBar()
Recreate the menu bar.
virtual void doReCreateMenuBar()
WX_INFOBAR * GetInfoBar()
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.
bool Running() const
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:92
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:348
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all KIWAY_PLAYER objects.
Definition kiway.cpp:531
@ FACE_SCH
eeschema DSO
Definition kiway.h:355
@ FACE_PL_EDITOR
Definition kiway.h:359
@ FACE_PCB
pcbnew DSO
Definition kiway.h:356
@ FACE_GERBVIEW
Definition kiway.h:358
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:460
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition kiway.cpp:605
bool RunRegisteredSaversAndCommit(const wxString &aProjectPath, const wxString &aTitle, const wxString &aTagFileType=wxEmptyString)
Run all registered savers and, if any staged changes differ from HEAD, create a commit.
std::vector< std::pair< wxString, wxString > > FindStaleAutosaveFiles(const wxString &aProjectPath, const std::vector< wxString > &aExtensions) const
Enumerate autosave files newer than their corresponding source files for the project at aProjectPath,...
bool Init(const wxString &aProjectPath)
Initialize the local history repository for the given project path.
bool RunRegisteredSaversAsAutosaveFiles(const wxString &aProjectPath)
Run all registered savers and write their output to autosave files instead of committing to the local...
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:137
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:600
bool IsSessionEnding() const
Return true while the operating system is closing the application because the user session is ending,...
Definition pgm_base.h:416
virtual API_PLUGIN_MANAGER & GetPluginManager() const
Definition pgm_base.h:140
virtual int GetSelectedLanguageIdentifier() const
Definition pgm_base.h:230
KICAD_API_SERVER & GetApiServer()
Definition pgm_base.h:142
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:124
A holder to handle information on schematic or board items.
void SaveFileState(const wxString &aFileName, const WINDOW_SETTINGS *aWindowCfg, bool aOpen)
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition project.h:207
RAII class that sets an value at construction and resets it to the original value at destruction.
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:79
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:77
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.
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)
@ PROJECT_DIR
Inside the project directory (default)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
Definition confirm.h:48
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition cvpcb.cpp:178
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
static wxString buildRecoveredFileName(const wxFileName &aSrcFn, const wxDateTime &aStamp)
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
std::function< void(ACTION_TOOLBAR *)> ACTION_TOOLBAR_CONTROL_FACTORY
#define DEFAULT_MAX_UNDO_ITEMS
EDA_UNITS
Definition eda_units.h:45
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:29
@ PANEL_PCB_GRIDS
Definition frame_type.h:100
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ PANEL_SYM_EDIT_GRIDS
Definition frame_type.h:72
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ PANEL_3DV_TOOLBARS
Definition frame_type.h:111
@ PANEL_SCH_FIELD_NAME_TEMPLATES
Definition frame_type.h:84
@ PANEL_DS_TOOLBARS
Definition frame_type.h:125
@ PANEL_SCH_TOOLBARS
Definition frame_type.h:83
@ PANEL_GBR_DISPLAY_OPTIONS
Definition frame_type.h:113
@ PANEL_3DV_OPENGL
Definition frame_type.h:109
@ PANEL_GBR_SNAPPING
Definition frame_type.h:117
@ PANEL_FP_DEFAULT_GRAPHICS_VALUES
Definition frame_type.h:95
@ PANEL_PCB_TOOLBARS
Definition frame_type.h:104
@ PANEL_SYM_SNAPPING
Definition frame_type.h:73
@ PANEL_PCB_ORIGINS_AXES
Definition frame_type.h:106
@ PANEL_PCB_EDIT_OPTIONS
Definition frame_type.h:102
@ PANEL_SCH_DISP_OPTIONS
Definition frame_type.h:78
@ PANEL_FP_DISPLAY_OPTIONS
Definition frame_type.h:88
@ PANEL_SCH_SIMULATOR
Definition frame_type.h:85
@ FRAME_SCH
Definition frame_type.h:30
@ PANEL_DS_COLORS
Definition frame_type.h:124
@ PANEL_PCB_COLORS
Definition frame_type.h:103
@ PANEL_SYM_TOOLBARS
Definition frame_type.h:76
@ PANEL_FP_SNAPPING
Definition frame_type.h:90
@ PANEL_3DV_RAYTRACING
Definition frame_type.h:110
@ PANEL_SYM_EDIT_OPTIONS
Definition frame_type.h:74
@ PANEL_FP_GRIDS
Definition frame_type.h:89
@ PANEL_SCH_EDIT_OPTIONS
Definition frame_type.h:81
@ PANEL_FP_ORIGINS_AXES
Definition frame_type.h:97
@ PANEL_SYM_DISP_OPTIONS
Definition frame_type.h:71
@ PANEL_PCB_DISPLAY_OPTS
Definition frame_type.h:99
@ PANEL_DS_SNAPPING
Definition frame_type.h:123
@ PANEL_FP_COLORS
Definition frame_type.h:92
@ PANEL_FP_DEFAULT_FIELDS
Definition frame_type.h:94
@ PANEL_SYM_COLORS
Definition frame_type.h:75
@ FRAME_PL_EDITOR
Definition frame_type.h:55
@ PANEL_SCH_SNAPPING
Definition frame_type.h:80
@ PANEL_GBR_GRIDS
Definition frame_type.h:116
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:39
@ FRAME_GERBER
Definition frame_type.h:53
@ PANEL_DS_GRIDS
Definition frame_type.h:122
@ FRAME_PCB_DISPLAY3D
Definition frame_type.h:43
@ PANEL_GBR_TOOLBARS
Definition frame_type.h:119
@ PANEL_FP_EDIT_OPTIONS
Definition frame_type.h:91
@ PANEL_SCH_GRIDS
Definition frame_type.h:79
@ PANEL_FP_TOOLBARS
Definition frame_type.h:93
@ PANEL_PCB_ACTION_PLUGINS
Definition frame_type.h:105
@ PANEL_3DV_DISPLAY_OPTIONS
Definition frame_type.h:108
@ PANEL_DS_DISPLAY_OPTIONS
Definition frame_type.h:121
@ PANEL_SCH_COLORS
Definition frame_type.h:82
@ PANEL_GBR_COLORS
Definition frame_type.h:118
@ PANEL_GBR_EXCELLON_OPTIONS
Definition frame_type.h:115
@ PANEL_PCB_SNAPPING
Definition frame_type.h:101
@ KICAD_MAIN_FRAME_T
Definition frame_type.h:67
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:58
@ ID_LANGUAGE_CHOICE
Definition id.h:62
@ ID_LANGUAGE_CHOICE_END
Definition id.h:110
@ ID_FILE1
Definition id.h:55
@ ID_AUTO_SAVE_TIMER
Definition id.h:50
std::string message
EVT_MENU(ID_COMPARE_PROJECT_BRANCHES, KICAD_MANAGER_FRAME::OnCompareProjectBranches) KICAD_MANAGER_FRAME
void RemoveShutdownBlockReason(wxWindow *aWindow)
Removes any shutdown block reason set.
Definition unix/app.cpp:103
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:97
void SetWMClass(wxWindow *aWindow, const wxString &aClass)
Tag a top-level window with the freedesktop application id of its installed launcher,...
Definition wxgtk/ui.cpp:336
PGM_BASE & Pgm()
The global program "get" accessor.
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition pgm_base.cpp:92
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:153
Store the common settings that are saved and loaded for each window / frame.
WINDOW_STATE state
nlohmann::json aui_state
wxString perspective
Store the window positioning/state.
unsigned int display
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
struct DROP_TABLE cs
static const long long MM
@ 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.
INFOBAR_MESSAGE_TYPE
Sets the type of message for special handling if needed.