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 (C) 1992-2024 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
27#include <eda_base_frame.h>
28
29#include <advanced_config.h>
30#include <bitmaps.h>
31#include <bitmap_store.h>
32#include <dialog_shim.h>
38#include <eda_dde.h>
39#include <file_history.h>
40#include <id.h>
41#include <kiface_base.h>
42#include <hotkeys_basic.h>
44#include <paths.h>
45#include <confirm.h>
47#include <pgm_base.h>
52#include <tool/action_manager.h>
53#include <tool/action_menu.h>
54#include <tool/action_toolbar.h>
55#include <tool/actions.h>
56#include <tool/common_control.h>
57#include <tool/tool_manager.h>
59#include <trace_helpers.h>
62#include <widgets/wx_infobar.h>
64#include <widgets/wx_grid.h>
65#include <widgets/wx_treebook.h>
66#include <wx/app.h>
67#include <wx/config.h>
68#include <wx/display.h>
69#include <wx/stdpaths.h>
70#include <wx/string.h>
71#include <wx/msgdlg.h>
72#include <kiplatform/app.h>
73#include <kiplatform/io.h>
74#include <kiplatform/ui.h>
75
76#include <functional>
77#include <kiface_ids.h>
78
79#ifdef KICAD_IPC_API
80#include <api/api_server.h>
81#endif
82
83
84// Minimum window size
85static const wxSize minSizeLookup( FRAME_T aFrameType, wxWindow* aWindow )
86{
87 switch( aFrameType )
88 {
90 return wxWindow::FromDIP( wxSize( 406, 354 ), aWindow );
91
92 default:
93 return wxWindow::FromDIP( wxSize( 500, 400 ), aWindow );
94 }
95}
96
97
98static const wxSize defaultSize( FRAME_T aFrameType, wxWindow* aWindow )
99{
100 switch( aFrameType )
101 {
103 return wxWindow::FromDIP( wxSize( 850, 540 ), aWindow );
104
105 default:
106 return wxWindow::FromDIP( wxSize( 1280, 720 ), aWindow );
107 }
108}
109
110
111BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
112 // These event table entries are needed to handle events from the mac application menu
113 EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
114 EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
115
116 EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
117 EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
118 EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
119 EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
120 EVT_MOVE( EDA_BASE_FRAME::OnMove )
121 EVT_SIZE( EDA_BASE_FRAME::OnSize )
122 EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
123
124 EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
125 EVT_ICONIZE( EDA_BASE_FRAME::onIconize )
126END_EVENT_TABLE()
127
128
129void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType )
130{
131 m_ident = aFrameType;
132 m_maximizeByDefault = false;
133 m_infoBar = nullptr;
134 m_settingsManager = nullptr;
135 m_fileHistory = nullptr;
136 m_supportsAutoSave = false;
137 m_autoSavePending = false;
138 m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
139 m_isClosing = false;
140 m_isNonUserClose = false;
141 m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
142 m_autoSaveRequired = false;
144 m_frameSize = defaultSize( aFrameType, this );
145 m_displayIndex = -1;
146
147 m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
148
149 m_settingsManager = &Pgm().GetSettingsManager();
150
151 // Set a reasonable minimal size for the frame
152 wxSize minSize = minSizeLookup( aFrameType, this );
153 SetSizeHints( minSize.x, minSize.y, -1, -1, -1, -1 );
154
155 // Store dimensions of the user area of the main window.
156 GetClientSize( &m_frameSize.x, &m_frameSize.y );
157
158 Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
159 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
160
161 // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
162 // to be called before any other hook for wxCloseEvent, which is necessary.
163 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
164
165 initExitKey();
166}
167
168
169EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle,
170 const wxPoint& aPos, const wxSize& aSize, long aStyle,
171 const wxString& aFrameName, KIWAY* aKiway,
172 const EDA_IU_SCALE& aIuScale ) :
173 wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
174 TOOLS_HOLDER(),
175 KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
177{
178 commonInit( aFrameType );
179}
180
181
182wxWindow* findQuasiModalDialog( wxWindow* aParent )
183{
184 for( wxWindow* child : aParent->GetChildren() )
185 {
186 if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( child ) )
187 {
188 if( dlg->IsQuasiModal() )
189 return dlg;
190
191 if( wxWindow* nestedDlg = findQuasiModalDialog( child ) )
192 return nestedDlg;
193 }
194 }
195
196 return nullptr;
197}
198
199
201{
202 if( wxWindow* dlg = ::findQuasiModalDialog( this ) )
203 return dlg;
204
205 // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
206 // so we have to look for it separately.
207 if( m_ident == FRAME_SCH )
208 {
209 wxWindow* cvpcb = wxWindow::FindWindowByName( wxS( "CvpcbFrame" ) );
210
211 if( cvpcb )
212 return cvpcb;
213 }
214
215 return nullptr;
216}
217
218
219void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
220{
221 // Don't allow closing when a quasi-modal is open.
222 wxWindow* quasiModal = findQuasiModalDialog();
223
224 if( quasiModal )
225 {
226 // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
227 // when they have no idea what those are.
228 quasiModal->Raise();
229 wxBell();
230
231 if( event.CanVeto() )
232 event.Veto();
233
234 return;
235 }
236
237
238 if( event.GetId() == wxEVT_QUERY_END_SESSION
239 || event.GetId() == wxEVT_END_SESSION )
240 {
241 // End session means the OS is going to terminate us
242 m_isNonUserClose = true;
243 }
244
245 if( canCloseWindow( event ) )
246 {
247 m_isClosing = true;
248
249 if( m_infoBar )
251
252 APP_SETTINGS_BASE* cfg = config();
253
254 if( cfg )
255 SaveSettings( cfg ); // virtual, wxFrame specific
256
258
259 // Destroy (safe delete frame) this frame only in non modal mode.
260 // In modal mode, the caller will call Destroy().
261 if( !IsModal() )
262 Destroy();
263 }
264 else
265 {
266 if( event.CanVeto() )
267 event.Veto();
268 }
269}
270
271
273{
274 Disconnect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
275 wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
276 Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
277
278 delete m_autoSaveTimer;
279 delete m_fileHistory;
280
282
284
286}
287
288
289bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
290{
291#ifdef __WXMAC__
292 // Apple in its infinite wisdom will raise a disabled window before even passing
293 // us the event, so we have no way to stop it. Instead, we have to catch an
294 // improperly ordered disabled window and quasi-modal dialog here and reorder
295 // them.
296 if( !IsEnabled() && IsActive() )
297 {
298 wxWindow* dlg = findQuasiModalDialog();
299 if( dlg )
300 dlg->Raise();
301 }
302#endif
303
304 if( !wxFrame::ProcessEvent( aEvent ) )
305 return false;
306
307 if( Pgm().m_Quitting )
308 return true;
309
310 if( !m_isClosing && m_supportsAutoSave && IsShownOnScreen() && IsActive()
312 && GetAutoSaveInterval() > 0 )
313 {
314 if( !m_autoSavePending )
315 {
316 wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
317 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
318 m_autoSavePending = true;
319 }
320 else if( m_autoSaveTimer->IsRunning() )
321 {
322 wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
323 m_autoSaveTimer->Stop();
324 m_autoSavePending = false;
325 }
326 }
327
328 return true;
329}
330
331
333{
335}
336
337
338void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
339{
340 // Don't stomp on someone else's timer event.
341 if( aEvent.GetId() != ID_AUTO_SAVE_TIMER )
342 {
343 aEvent.Skip();
344 return;
345 }
346
347 if( !doAutoSave() )
348 m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
349}
350
351
353{
354 wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
355}
356
357
358void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
359{
360 wxLogTrace( kicadTraceKeyEvent, wxS( "EDA_BASE_FRAME::OnCharHook %s" ), dump( aKeyEvent ) );
361
362 // Key events can be filtered here.
363 // Currently no filtering is made.
364 aKeyEvent.Skip();
365}
366
367
368void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
369{
370 if( !m_toolDispatcher )
371 aEvent.Skip();
372 else
374}
375
376
378{
380 std::placeholders::_1,
381 this,
382 aConditions );
383
384 m_uiUpdateMap[aID] = evtFunc;
385
386 Bind( wxEVT_UPDATE_UI, evtFunc, aID );
387}
388
389
391{
392 const auto it = m_uiUpdateMap.find( aID );
393
394 if( it == m_uiUpdateMap.end() )
395 return;
396
397 Unbind( wxEVT_UPDATE_UI, it->second, aID );
398}
399
400
401void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
402 ACTION_CONDITIONS aCond )
403{
404 bool checkRes = false;
405 bool enableRes = true;
406 bool showRes = true;
407 bool isCut = aEvent.GetId() == ACTIONS::cut.GetUIId();
408 bool isCopy = aEvent.GetId() == ACTIONS::copy.GetUIId();
409 bool isPaste = aEvent.GetId() == ACTIONS::paste.GetUIId();
410 SELECTION& selection = aFrame->GetCurrentSelection();
411
412 try
413 {
414 checkRes = aCond.checkCondition( selection );
415 enableRes = aCond.enableCondition( selection );
416 showRes = aCond.showCondition( selection );
417 }
418 catch( std::exception& )
419 {
420 // Something broke with the conditions, just skip the event.
421 aEvent.Skip();
422 return;
423 }
424
425 if( showRes && aEvent.GetId() == ACTIONS::undo.GetUIId() )
426 {
427 wxString msg = _( "Undo" );
428
429 if( enableRes )
430 msg += wxS( " " ) + aFrame->GetUndoActionDescription();
431
432 aEvent.SetText( msg );
433 }
434 else if( showRes && aEvent.GetId() == ACTIONS::redo.GetUIId() )
435 {
436 wxString msg = _( "Redo" );
437
438 if( enableRes )
439 msg += wxS( " " ) + aFrame->GetRedoActionDescription();
440
441 aEvent.SetText( msg );
442 }
443
444 if( isCut || isCopy || isPaste )
445 {
446 wxWindow* focus = wxWindow::FindFocus();
447 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
448
449 if( textEntry && isCut && textEntry->CanCut() )
450 enableRes = true;
451 else if( textEntry && isCopy && textEntry->CanCopy() )
452 enableRes = true;
453 else if( textEntry && isPaste && textEntry->CanPaste() )
454 enableRes = true;
455 else if( dynamic_cast<WX_GRID*>( focus ) )
456 enableRes = false; // Must disable menu in order to get command as CharHook event
457 }
458
459 aEvent.Enable( enableRes );
460 aEvent.Show( showRes );
461
462 if( aEvent.IsCheckable() )
463 aEvent.Check( checkRes );
464}
465
466
468{
469 // Setup the conditions to check a language menu item
470 auto isCurrentLang =
471 [] ( const SELECTION& aSel, int aLangIdentifier )
472 {
473 return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
474 };
475
476 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
477 {
479 cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
480 LanguagesList[ii].m_WX_Lang_Identifier ) );
481
482 RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
483 }
484}
485
486
488{
496 CallAfter( [this]()
497 {
498 if( !m_isClosing )
500 } );
501}
502
503
504void EDA_BASE_FRAME::SetMenuBar( wxMenuBar* menu_bar )
505{
506 wxFrame::SetMenuBar( menu_bar );
507
508 // Move Help menu back to end of menubar
509
510 int pos = GetMenuBar()->FindMenu( _( "&Help" ) + wxS( " " ) );
511
512 if( pos != wxNOT_FOUND )
513 {
514 wxMenu* helpMenu = GetMenuBar()->Remove( pos );
515 GetMenuBar()->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
516 }
517}
518
519
520void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
521{
523 ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
524
525 helpMenu->Add( ACTIONS::help );
526 helpMenu->Add( ACTIONS::gettingStarted );
527 helpMenu->Add( ACTIONS::listHotKeys );
528 helpMenu->Add( ACTIONS::getInvolved );
529 helpMenu->Add( ACTIONS::donate );
530 helpMenu->Add( ACTIONS::reportBug );
531
532 helpMenu->AppendSeparator();
533 helpMenu->Add( ACTIONS::about );
534
535 // Trailing space keeps OSX from hijacking our menu (and disabling everything in it).
536 aMenuBar->Append( helpMenu, _( "&Help" ) + wxS( " " ) );
537
538 // This change is only needed on macOS, and creates a bug on Windows
539 #ifdef __WXMAC__
540 helpMenu->wxMenu::SetTitle( _( "&Help" ) + wxS( " " ) );
541 #endif
542}
543
544
546{
548
549 if( GetMenuBar() )
550 {
552 GetMenuBar()->Refresh();
553 }
554}
555
556
557void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
558{
559 TOOLS_HOLDER::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
560
561 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
562
563#ifdef KICAD_IPC_API
564 bool running = Pgm().GetApiServer().Running();
565
566 if( running && !settings->m_Api.enable_server )
567 Pgm().GetApiServer().Stop();
568 else if( !running && settings->m_Api.enable_server )
569 Pgm().GetApiServer().Start();
570#endif
571
572 if( m_fileHistory )
573 {
574 int historySize = settings->m_System.file_history_size;
575 m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
576 }
577
579 ThemeChanged();
580
581 if( GetMenuBar() )
582 {
583 // For icons in menus, icon scaling & hotkeys
585 GetMenuBar()->Refresh();
586 }
587}
588
589
591{
593
594 // Update all the toolbars to have new icons
595 wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
596
597 for( size_t i = 0; i < panes.GetCount(); ++i )
598 {
599 if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
600 toolbar->RefreshBitmaps();
601 }
602}
603
604
605void EDA_BASE_FRAME::OnSize( wxSizeEvent& aEvent )
606{
607#ifdef __WXMAC__
608 int currentDisplay = wxDisplay::GetFromWindow( this );
609
610 if( m_displayIndex >= 0 && currentDisplay >= 0 && currentDisplay != m_displayIndex )
611 {
612 wxLogTrace( traceDisplayLocation, wxS( "OnSize: current display changed %d to %d" ),
613 m_displayIndex, currentDisplay );
614 m_displayIndex = currentDisplay;
616 }
617#endif
618
619 aEvent.Skip();
620}
621
622
623void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
624{
625 if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
626 return;
627
628 const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
629
630 if( state != nullptr )
631 {
632 LoadWindowState( state->window );
633 }
634}
635
636
638{
639 bool wasDefault = false;
640
641 m_framePos.x = aState.pos_x;
642 m_framePos.y = aState.pos_y;
643 m_frameSize.x = aState.size_x;
644 m_frameSize.y = aState.size_y;
645
646 wxLogTrace( traceDisplayLocation, wxS( "Config position (%d, %d) with size (%d, %d)" ),
648
649 // Ensure minimum size is set if the stored config was zero-initialized
650 wxSize minSize = minSizeLookup( m_ident, this );
651 if( m_frameSize.x < minSize.x || m_frameSize.y < minSize.y )
652 {
654 wasDefault = true;
655
656 wxLogTrace( traceDisplayLocation, wxS( "Using minimum size (%d, %d)" ),
658 }
659
660 wxLogTrace( traceDisplayLocation, wxS( "Number of displays: %d" ), wxDisplay::GetCount() );
661
662 if( aState.display >= wxDisplay::GetCount() )
663 {
664 wxLogTrace( traceDisplayLocation, wxS( "Previous display not found" ) );
665
666 // If it isn't attached, use the first display
667 // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
668 const unsigned int index = 0;
669 wxDisplay display( index );
670 wxRect clientSize = display.GetGeometry();
671
672 m_framePos = wxDefaultPosition;
673
674 // Ensure the window fits on the display, since the other one could have been larger
675 if( m_frameSize.x > clientSize.width )
676 m_frameSize.x = clientSize.width;
677
678 if( m_frameSize.y > clientSize.height )
679 m_frameSize.y = clientSize.height;
680 }
681 else
682 {
683 wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
684 wxPoint upperLeft( m_framePos.x, m_framePos.y );
685
686 wxDisplay display( aState.display );
687 wxRect clientSize = display.GetClientArea();
688
689 int yLimTop = clientSize.y;
690 int yLimBottom = clientSize.y + clientSize.height;
691 int xLimLeft = clientSize.x;
692 int xLimRight = clientSize.x + clientSize.width;
693
694 if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
695 upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
696 upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
697 upperLeft.y > yLimBottom )
698 {
699 m_framePos = wxDefaultPosition;
700 wxLogTrace( traceDisplayLocation, wxS( "Resetting to default position" ) );
701 }
702 }
703
704 wxLogTrace( traceDisplayLocation, wxS( "Final window position (%d, %d) with size (%d, %d)" ),
706
707 SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
708
709 // Center the window if we reset to default
710 if( m_framePos.x == -1 )
711 {
712 wxLogTrace( traceDisplayLocation, wxS( "Centering window" ) );
713 Center();
714 m_framePos = GetPosition();
715 }
716
717 // Record the frame sizes in an un-maximized state
720
721 // Maximize if we were maximized before
722 if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
723 {
724 wxLogTrace( traceDisplayLocation, wxS( "Maximizing window" ) );
725 Maximize();
726 }
727
728 m_displayIndex = wxDisplay::GetFromWindow( this );
729}
730
731
733{
734 wxDisplay display( wxDisplay::GetFromWindow( this ) );
735 wxRect clientSize = display.GetClientArea();
736 wxPoint pos = GetPosition();
737 wxSize size = GetWindowSize();
738
739 wxLogTrace( traceDisplayLocation,
740 wxS( "ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d" ),
741 clientSize.x, clientSize.y,
742 clientSize.width, clientSize.height );
743
744 if( pos.y < clientSize.y )
745 {
746 wxLogTrace( traceDisplayLocation,
747 wxS( "ensureWindowIsOnScreen: y pos %d below minimum, setting to %d" ), pos.y,
748 clientSize.y );
749 pos.y = clientSize.y;
750 }
751
752 if( pos.x < clientSize.x )
753 {
754 wxLogTrace( traceDisplayLocation,
755 wxS( "ensureWindowIsOnScreen: x pos %d is off the client rect, setting to %d" ),
756 pos.x, clientSize.x );
757 pos.x = clientSize.x;
758 }
759
760 if( pos.x + size.x - clientSize.x > clientSize.width )
761 {
762 int newWidth = clientSize.width - ( pos.x - clientSize.x );
763 wxLogTrace( traceDisplayLocation,
764 wxS( "ensureWindowIsOnScreen: effective width %d above available %d, setting "
765 "to %d" ), pos.x + size.x, clientSize.width, newWidth );
766 size.x = newWidth;
767 }
768
769 if( pos.y + size.y - clientSize.y > clientSize.height )
770 {
771 int newHeight = clientSize.height - ( pos.y - clientSize.y );
772 wxLogTrace( traceDisplayLocation,
773 wxS( "ensureWindowIsOnScreen: effective height %d above available %d, setting "
774 "to %d" ), pos.y + size.y, clientSize.height, newHeight );
775 size.y = newHeight;
776 }
777
778 wxLogTrace( traceDisplayLocation, wxS( "Updating window position (%d, %d) with size (%d, %d)" ),
779 pos.x, pos.y, size.x, size.y );
780
781 SetSize( pos.x, pos.y, size.x, size.y );
782}
783
784
786{
787 LoadWindowState( aCfg->state );
788
790 m_mruPath = aCfg->mru_path;
791
793}
794
795
797{
798 if( IsIconized() )
799 return;
800
801 // If the window is maximized, we use the saved window size from before it was maximized
802 if( IsMaximized() )
803 {
806 }
807 else
808 {
810 m_framePos = GetPosition();
811 }
812
813 aCfg->state.pos_x = m_framePos.x;
814 aCfg->state.pos_y = m_framePos.y;
815 aCfg->state.size_x = m_frameSize.x;
816 aCfg->state.size_y = m_frameSize.y;
817 aCfg->state.maximized = IsMaximized();
818 aCfg->state.display = wxDisplay::GetFromWindow( this );
819
820 wxLogTrace( traceDisplayLocation, wxS( "Saving window maximized: %s" ),
821 IsMaximized() ? wxS( "true" ) : wxS( "false" ) );
822 wxLogTrace( traceDisplayLocation, wxS( "Saving config position (%d, %d) with size (%d, %d)" ),
824
825 // Once this is fully implemented, wxAuiManager will be used to maintain
826 // the persistence of the main frame and all it's managed windows and
827 // all of the legacy frame persistence position code can be removed.
828 aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
829
830 aCfg->mru_path = m_mruPath;
831}
832
833
835{
837
838 // Get file history size from common settings
839 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
840
841 // Load the recently used files into the history menu
842 m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 1, fileHistorySize ),
844 m_fileHistory->Load( *aCfg );
845}
846
847
849{
850 wxCHECK( config(), /* void */ );
851
853
854 bool fileOpen = m_isClosing && m_isNonUserClose;
855
856 wxString currentlyOpenedFile = GetCurrentFileName();
857
858 if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
859 {
860 wxFileName rfn( currentlyOpenedFile );
861 rfn.MakeRelativeTo( Prj().GetProjectPath() );
862 Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
863 }
864
865 // Save the recently used files list
866 if( m_fileHistory )
867 {
868 // Save the currently opened file in the file history
869 if( !currentlyOpenedFile.IsEmpty() )
870 UpdateFileHistory( currentlyOpenedFile );
871
872 m_fileHistory->Save( *aCfg );
873 }
874}
875
876
878{
879 return &aCfg->m_Window;
880}
881
882
884{
885 // KICAD_MANAGER_FRAME overrides this
886 return Kiface().KifaceSettings();
887}
888
889
891{
892 return Kiface().KifaceSearch();
893}
894
895
897{
898 return Kiface().GetHelpFileName();
899}
900
901
902void EDA_BASE_FRAME::PrintMsg( const wxString& text )
903{
904 SetStatusText( text );
905}
906
907
909{
910#if defined( __WXOSX_MAC__ )
912#else
913 m_infoBar = new WX_INFOBAR( this, &m_auimgr );
914
915 m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( wxS( "InfoBar" ) ).Top().Layer(1) );
916#endif
917}
918
919
921{
922#if defined( __WXOSX_MAC__ )
923 m_auimgr.Update();
924#else
925 // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
926 // hiding it.
927 m_auimgr.Update();
928
929 // We don't want the infobar displayed right away
930 m_auimgr.GetPane( wxS( "InfoBar" ) ).Hide();
931 m_auimgr.Update();
932#endif
933}
934
935
936void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
938{
940
941 if( aShowCloseButton )
943
944 GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR, aType );
945}
946
947
948void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
949 std::function<void(void)> aCallback )
950{
952
953 if( aShowCloseButton )
955
956 if( aCallback )
957 m_infoBar->SetCallback( aCallback );
958
959 GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
960}
961
962
963void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
964{
966
967 if( aShowCloseButton )
969
970 GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
971}
972
973
974void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
975{
977
978 if( aShowCloseButton )
980
981 GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
982}
983
984
985void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
986{
987 if( !aFileHistory )
988 aFileHistory = m_fileHistory;
989
990 wxASSERT( aFileHistory );
991
992 aFileHistory->AddFileToHistory( FullFileName );
993
994 // Update the menubar to update the file history menu
995 if( !m_isClosing && GetMenuBar() )
996 {
998 GetMenuBar()->Refresh();
999 }
1000}
1001
1002
1003wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
1004 FILE_HISTORY* aFileHistory )
1005{
1006 if( !aFileHistory )
1007 aFileHistory = m_fileHistory;
1008
1009 wxASSERT( aFileHistory );
1010
1011 int baseId = aFileHistory->GetBaseId();
1012
1013 wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
1014
1015 unsigned i = cmdId - baseId;
1016
1017 if( i < aFileHistory->GetCount() )
1018 {
1019 wxString fn = aFileHistory->GetHistoryFile( i );
1020
1021 if( wxFileName::FileExists( fn ) )
1022 {
1023 return fn;
1024 }
1025 else
1026 {
1027 DisplayErrorMessage( this, wxString::Format( _( "File '%s' was not found." ), fn ) );
1028 aFileHistory->RemoveFileFromHistory( i );
1029 }
1030 }
1031
1032 // Update the menubar to update the file history menu
1033 if( GetMenuBar() )
1034 {
1036 GetMenuBar()->Refresh();
1037 }
1038
1039 return wxEmptyString;
1040}
1041
1042
1044{
1045 if( !aFileHistory )
1046 aFileHistory = m_fileHistory;
1047
1048 wxASSERT( aFileHistory );
1049
1050 aFileHistory->ClearFileHistory();
1051
1052 // Update the menubar to update the file history menu
1053 if( GetMenuBar() )
1054 {
1056 GetMenuBar()->Refresh();
1057 }
1058}
1059
1060
1061void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
1062{
1063 void ShowAboutDialog( EDA_BASE_FRAME * aParent ); // See AboutDialog_main.cpp
1064 ShowAboutDialog( this );
1065}
1066
1067
1068void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
1069{
1070 ShowPreferences( wxEmptyString, wxEmptyString );
1071}
1072
1073
1074void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParentPage )
1075{
1076 PAGED_DIALOG dlg( this, _( "Preferences" ), true, true, wxEmptyString,
1077 wxWindow::FromDIP( wxSize( 980, 560 ), NULL ) );
1078
1079 dlg.SetEvtHandlerEnabled( false );
1080
1081 {
1082 WX_BUSY_INDICATOR busy_cursor;
1083
1084 WX_TREEBOOK* book = dlg.GetTreebook();
1085 PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
1086 KIFACE* kiface = nullptr;
1087 std::vector<int> expand;
1088
1089 Kiway().GetActions( hotkeysPanel->ActionsList() );
1090
1091 book->AddLazyPage(
1092 []( wxWindow* aParent ) -> wxWindow*
1093 {
1094 return new PANEL_COMMON_SETTINGS( aParent );
1095 },
1096 _( "Common" ) );
1097
1098 book->AddLazyPage(
1099 []( wxWindow* aParent ) -> wxWindow*
1100 {
1101 return new PANEL_MOUSE_SETTINGS( aParent );
1102 }, _( "Mouse and Touchpad" ) );
1103
1104 book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
1105
1106 // This currently allows pre-defined repositories that we
1107 // don't use, so keep it disabled at the moment
1108 if( ADVANCED_CFG::GetCfg().m_EnableGit && false )
1109 {
1110 book->AddLazyPage(
1111 []( wxWindow* aParent ) -> wxWindow*
1112 {
1113 return new PANEL_GIT_REPOS( aParent );
1114 }, _( "Version Control" ) );
1115 }
1116
1117 #ifdef KICAD_USE_SENTRY
1118 book->AddLazyPage(
1119 []( wxWindow* aParent ) -> wxWindow*
1120 {
1121 return new PANEL_DATA_COLLECTION( aParent );
1122 }, _( "Data Collection" ) );
1123 #endif
1124
1125 #define LAZY_CTOR( key ) \
1126 [this, kiface]( wxWindow* aParent ) \
1127 { \
1128 return kiface->CreateKiWindow( aParent, key, &Kiway() ); \
1129 }
1130
1131 // If a dll is not loaded, the loader will show an error message.
1132
1133 try
1134 {
1136
1137 if( !kiface )
1138 return;
1139
1140 kiface->GetActions( hotkeysPanel->ActionsList() );
1141
1143 expand.push_back( (int) book->GetPageCount() );
1144
1145 book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) );
1146 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_DISP_OPTIONS ), _( "Display Options" ) );
1147 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_GRIDS ), _( "Grids" ) );
1148 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) );
1149 book->AddLazySubPage( LAZY_CTOR( PANEL_SYM_COLORS ), _( "Colors" ) );
1150
1151 if( GetFrameType() == FRAME_SCH )
1152 expand.push_back( (int) book->GetPageCount() );
1153
1154 book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) );
1155 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_DISP_OPTIONS ), _( "Display Options" ) );
1156 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_GRIDS ), _( "Grids" ) );
1157 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_EDIT_OPTIONS ), _( "Editing Options" ) );
1158 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_ANNO_OPTIONS ), _( "Annotation Options" ) );
1159 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_COLORS ), _( "Colors" ) );
1160 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_FIELD_NAME_TEMPLATES ), _( "Field Name Templates" ) );
1161 book->AddLazySubPage( LAZY_CTOR( PANEL_SCH_SIMULATOR ), _( "Simulator" ) );
1162 }
1163 catch( ... )
1164 {
1165 }
1166
1167 try
1168 {
1170
1171 if( !kiface )
1172 return;
1173
1174 kiface->GetActions( hotkeysPanel->ActionsList() );
1175
1177 expand.push_back( (int) book->GetPageCount() );
1178
1179 book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) );
1180 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DISPLAY_OPTIONS ), _( "Display Options" ) );
1181 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_GRIDS ), _( "Grids" ) );
1182 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_ORIGINS_AXES ), _( "Origins & Axes" ) );
1183 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) );
1184 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_COLORS ), _( "Colors" ) );
1185 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_FIELDS ), _( "New Footprint Defaults" ) );
1186 book->AddLazySubPage( LAZY_CTOR( PANEL_FP_DEFAULT_GRAPHICS_VALUES ), _( "Graphics Defaults" ) );
1187
1189 expand.push_back( (int) book->GetPageCount() );
1190
1191 book->AddPage( new wxPanel( book ), _( "PCB Editor" ) );
1192 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_DISPLAY_OPTS ), _( "Display Options" ) );
1193 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_GRIDS ), _( "Grids" ) );
1194 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ORIGINS_AXES ), _( "Origins & Axes" ) );
1195 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_EDIT_OPTIONS ), _( "Editing Options" ) );
1196 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_COLORS ), _( "Colors" ) );
1197 book->AddLazySubPage( LAZY_CTOR( PANEL_PCB_ACTION_PLUGINS ), _( "Plugins" ) );
1198
1200 expand.push_back( (int) book->GetPageCount() );
1201
1202 book->AddPage( new wxPanel( book ), _( "3D Viewer" ) );
1203 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) );
1204 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) );
1205 book->AddLazySubPage( LAZY_CTOR( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) );
1206 }
1207 catch( ... )
1208 {
1209 }
1210
1211 try
1212 {
1214
1215 if( !kiface )
1216 return;
1217
1218 kiface->GetActions( hotkeysPanel->ActionsList() );
1219
1220 if( GetFrameType() == FRAME_GERBER )
1221 expand.push_back( (int) book->GetPageCount() );
1222
1223 book->AddPage( new wxPanel( book ), _( "Gerber Viewer" ) );
1224 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) );
1225 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_COLORS ), _( "Colors" ) );
1226 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_GRIDS ), _( "Grids" ) );
1227 book->AddLazySubPage( LAZY_CTOR( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) );
1228 }
1229 catch( ... )
1230 {
1231 }
1232
1233 try
1234 {
1236
1237 if( !kiface )
1238 return;
1239
1240 kiface->GetActions( hotkeysPanel->ActionsList() );
1241
1242 if( GetFrameType() == FRAME_PL_EDITOR )
1243 expand.push_back( (int) book->GetPageCount() );
1244
1245 book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) );
1246 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_DISPLAY_OPTIONS ), _( "Display Options" ) );
1247 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_GRIDS ), _( "Grids" ) );
1248 book->AddLazySubPage( LAZY_CTOR( PANEL_DS_COLORS ), _( "Colors" ) );
1249
1250 book->AddLazyPage(
1251 []( wxWindow* aParent ) -> wxWindow*
1252 {
1253 return new PANEL_PACKAGES_AND_UPDATES( aParent );
1254 }, _( "Packages and Updates" ) );
1255 }
1256 catch( ... )
1257 {
1258 }
1259
1260#ifdef KICAD_IPC_API
1261 book->AddPage( new PANEL_PLUGIN_SETTINGS( book ), _( "Plugins" ) );
1262#endif
1263
1264 // Update all of the action hotkeys. The process of loading the actions through
1265 // the KiFACE will only get us the default hotkeys
1266 ReadHotKeyConfigIntoActions( wxEmptyString, hotkeysPanel->ActionsList() );
1267
1268 for( size_t i = 0; i < book->GetPageCount(); ++i )
1269 book->GetPage( i )->Layout();
1270
1271 for( int page : expand )
1272 book->ExpandNode( page );
1273
1274 if( !aStartPage.IsEmpty() )
1275 dlg.SetInitialPage( aStartPage, aStartParentPage );
1276
1277 dlg.SetEvtHandlerEnabled( true );
1278#undef LAZY_CTOR
1279 }
1280
1281 if( dlg.ShowModal() == wxID_OK )
1282 {
1283 // Update our grids that are cached in the tool
1286 dlg.Kiway().CommonSettingsChanged( false, false );
1287 }
1288
1289}
1290
1291
1292void EDA_BASE_FRAME::OnDropFiles( wxDropFilesEvent& aEvent )
1293{
1294 wxString* files = aEvent.GetFiles();
1295
1296 for( int nb = 0; nb < aEvent.GetNumberOfFiles(); nb++ )
1297 {
1298 const wxFileName fn = wxFileName( files[nb] );
1299 wxString ext = fn.GetExt();
1300
1301 // Alias all gerber files as GerberFileExtension
1304
1305 if( m_acceptedExts.find( ext.ToStdString() ) != m_acceptedExts.end() )
1306 m_AcceptedFiles.emplace_back( fn );
1307 }
1308
1310 m_AcceptedFiles.clear();
1311}
1312
1313
1315{
1316 for( const wxFileName& file : m_AcceptedFiles )
1317 {
1318 wxString fn = file.GetFullPath();
1319 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( file.GetExt() ), &fn );
1320 }
1321}
1322
1323
1324bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName, bool aVerbose )
1325{
1326 wxString msg;
1327 wxFileName fn = aFileName;
1328
1329 // Check for absence of a file path with a file name. Unfortunately KiCad
1330 // uses paths relative to the current project path without the ./ part which
1331 // confuses wxFileName. Making the file name path absolute may be less than
1332 // elegant but it solves the problem.
1333 if( fn.GetPath().IsEmpty() && fn.HasName() )
1334 fn.MakeAbsolute();
1335
1336 wxCHECK_MSG( fn.IsOk(), false,
1337 wxT( "File name object is invalid. Bad programmer!" ) );
1338 wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
1339 wxT( "File name object path <" ) + fn.GetFullPath() +
1340 wxT( "> is not set. Bad programmer!" ) );
1341
1342 if( fn.IsDir() && !fn.IsDirWritable() )
1343 {
1344 msg.Printf( _( "Insufficient permissions to folder '%s'." ), fn.GetPath() );
1345 }
1346 else if( !fn.FileExists() && !fn.IsDirWritable() )
1347 {
1348 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1349 }
1350 else if( fn.FileExists() && !fn.IsFileWritable() )
1351 {
1352 msg.Printf( _( "Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1353 }
1354
1355 if( !msg.IsEmpty() )
1356 {
1357 if( aVerbose )
1358 DisplayErrorMessage( this, msg );
1359
1360 return false;
1361 }
1362
1363 return true;
1364}
1365
1366
1367void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
1368{
1369 if( !Pgm().IsGUI() )
1370 return;
1371
1372 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1373
1374 wxFileName autoSaveFileName = aFileName;
1375
1376 // Check for auto save file.
1377 autoSaveFileName.SetName( FILEEXT::AutoSaveFilePrefix + aFileName.GetName() );
1378
1379 wxLogTrace( traceAutoSave,
1380 wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
1381
1382 if( !autoSaveFileName.FileExists() )
1383 return;
1384
1385 wxString msg = wxString::Format( _( "Well this is potentially embarrassing!\n"
1386 "It appears that the last time you were editing\n"
1387 "%s\n"
1388 "KiCad exited before saving.\n"
1389 "\n"
1390 "Do you wish to open the auto-saved file instead?" ),
1391 aFileName.GetFullName() );
1392
1393 int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1394 this );
1395
1396 // Make a backup of the current file, delete the file, and rename the auto save file to
1397 // the file name.
1398 if( response == wxYES )
1399 {
1400 // Preserve the permissions of the current file
1401 KIPLATFORM::IO::DuplicatePermissions( aFileName.GetFullPath(), autoSaveFileName.GetFullPath() );
1402
1403 if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
1404 {
1405 wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
1406 Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1407 }
1408 }
1409 else
1410 {
1411 DeleteAutoSaveFile( aFileName );
1412 }
1413}
1414
1415
1416void EDA_BASE_FRAME::DeleteAutoSaveFile( const wxFileName& aFileName )
1417{
1418 if( !Pgm().IsGUI() )
1419 return;
1420
1421 wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
1422
1423 wxFileName autoSaveFn = aFileName;
1424 autoSaveFn.SetName( FILEEXT::AutoSaveFilePrefix + aFileName.GetName() );
1425
1426 if( autoSaveFn.FileExists() )
1427 {
1428 wxLogTrace( traceAutoSave, wxT( "Removing auto save file " ) + autoSaveFn.GetFullPath() );
1429 wxRemoveFile( autoSaveFn.GetFullPath() );
1430 }
1431}
1432
1433
1435{
1436 // This function should be overridden in child classes
1437 return false;
1438}
1439
1440
1442{
1443 wxAcceleratorEntry entries[1];
1444 entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
1445 wxAcceleratorTable accel( 1, entries );
1446 SetAcceleratorTable( accel );
1447}
1448
1449
1451{
1454}
1455
1456
1458{
1459 m_undoList.PushCommand( aNewitem );
1460
1461 // Delete the extra items, if count max reached
1462 if( m_undoRedoCountMax > 0 )
1463 {
1464 int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
1465
1466 if( extraitems > 0 )
1467 ClearUndoORRedoList( UNDO_LIST, extraitems );
1468 }
1469}
1470
1471
1473{
1474 m_redoList.PushCommand( aNewitem );
1475
1476 // Delete the extra items, if count max reached
1477 if( m_undoRedoCountMax > 0 )
1478 {
1479 int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
1480
1481 if( extraitems > 0 )
1482 ClearUndoORRedoList( REDO_LIST, extraitems );
1483 }
1484}
1485
1486
1488{
1489 return m_undoList.PopCommand();
1490}
1491
1492
1494{
1495 return m_redoList.PopCommand();
1496}
1497
1498
1500{
1501 if( GetUndoCommandCount() > 0 )
1502 return m_undoList.m_CommandsList.back()->GetDescription();
1503
1504 return wxEmptyString;
1505}
1506
1507
1509{
1510 if( GetRedoCommandCount() > 0 )
1511 return m_redoList.m_CommandsList.back()->GetDescription();
1512
1513 return wxEmptyString;
1514}
1515
1516
1518{
1519 m_autoSaveRequired = true;
1520}
1521
1522
1524{
1525 SetUserUnits( aUnits );
1527
1528 wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
1529 e.SetInt( static_cast<int>( aUnits ) );
1530 e.SetClientData( this );
1531 ProcessEventLocally( e );
1532}
1533
1534
1535void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
1536{
1537 // When we maximize the window, we want to save the old information
1538 // so that we can add it to the settings on next window load.
1539 // Contrary to the documentation, this event seems to be generated
1540 // when the window is also being unmaximized on OSX, so we only
1541 // capture the size information when we maximize the window when on OSX.
1542#ifdef __WXOSX__
1543 if( !IsMaximized() )
1544#endif
1545 {
1547 m_normalFramePos = GetPosition();
1548 wxLogTrace( traceDisplayLocation,
1549 "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1552 }
1553
1554 // Skip event to actually maximize the window
1555 aEvent.Skip();
1556}
1557
1558
1560{
1561#ifdef __WXGTK__
1562 wxSize winSize = GetSize();
1563
1564 // GTK includes the window decorations in the normal GetSize call,
1565 // so we have to use a GTK-specific sizing call that returns the
1566 // non-decorated window size.
1568 {
1569 int width = 0;
1570 int height = 0;
1571 GTKDoGetSize( &width, &height );
1572
1573 winSize.Set( width, height );
1574 }
1575#else
1576 wxSize winSize = GetSize();
1577#endif
1578
1579 return winSize;
1580}
1581
1582
1584{
1585 // Update the icon theme when the system theme changes and update the toolbars
1587 ThemeChanged();
1588
1589 // This isn't handled by ThemeChanged()
1590 if( GetMenuBar() )
1591 {
1592 // For icons in menus, icon scaling & hotkeys
1594 GetMenuBar()->Refresh();
1595 }
1596}
1597
1598
1599void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
1600{
1601 // Call the handler to update the colors used in the frame
1603
1604 // Skip the change event to ensure the rest of the window controls get it
1605 aEvent.Skip();
1606}
1607
1608
1609void EDA_BASE_FRAME::onIconize( wxIconizeEvent& aEvent )
1610{
1611 // Call the handler
1612 handleIconizeEvent( aEvent );
1613
1614 // Skip the event.
1615 aEvent.Skip();
1616}
1617
1618
1619#ifdef __WXMSW__
1620WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
1621{
1622 // This will help avoid the menu keeping focus when the alt key is released
1623 // You can still trigger accelerators as long as you hold down alt
1624 if( message == WM_SYSCOMMAND )
1625 {
1626 if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
1627 return 0;
1628 }
1629
1630 return wxFrame::MSWWindowProc( message, wParam, lParam );
1631}
1632#endif
1633
1634
1643{
1644 ACTION_MENU* langsMenu = new ACTION_MENU( false, aControlTool );
1645 langsMenu->SetTitle( _( "Set Language" ) );
1646 langsMenu->SetIcon( BITMAPS::language );
1647
1648 wxString tooltip;
1649
1650 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
1651 {
1652 wxString label;
1653
1654 if( LanguagesList[ii].m_DoNotTranslate )
1655 label = LanguagesList[ii].m_Lang_Label;
1656 else
1657 label = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
1658
1659 wxMenuItem* item =
1660 new wxMenuItem( langsMenu,
1661 LanguagesList[ii].m_KI_Lang_Identifier, // wxMenuItem wxID
1662 label, tooltip, wxITEM_CHECK );
1663
1664 langsMenu->Append( item );
1665 }
1666
1667 // This must be done after the items are added
1668 aMasterMenu->Add( langsMenu );
1669}
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
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:73
static TOOL_ACTION about
Definition: actions.h:234
static TOOL_ACTION reportBug
Definition: actions.h:238
static TOOL_ACTION copy
Definition: actions.h:71
static TOOL_ACTION donate
Definition: actions.h:236
static TOOL_ACTION listHotKeys
Definition: actions.h:235
static TOOL_ACTION getInvolved
Definition: actions.h:237
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION gettingStarted
Definition: actions.h:232
static TOOL_ACTION help
Definition: actions.h:233
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:92
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:78
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
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.
Definition: app_settings.h:92
WINDOW_SETTINGS m_Window
Definition: app_settings.h:194
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:88
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
Returns 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
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 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()
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
std::vector< wxFileName > m_AcceptedFiles
virtual void CheckForAutoSaveFile(const wxFileName &aFileName)
Check if an auto save file exists for aFileName and takes the appropriate action depending on the use...
void OnKicadAbout(wxCommandEvent &event)
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.
wxSize m_normalFrameSize
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)
void ShowPreferences(wxString aStartPage, wxString aStartParentPage)
Displays the preferences and settings of all opened editors paged dialog, starting with a particular ...
void initExitKey()
Sets 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
void FinishAUIInitialization()
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)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
void SetMenuBar(wxMenuBar *menu_bar) override
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...
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.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
std::map< int, UIUpdateHandler > m_uiUpdateMap
< Map containing the UI update handlers registered with wx for each action.
UNDO_REDO_CONTAINER m_redoList
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
FILE_HISTORY * m_fileHistory
virtual void DeleteAutoSaveFile(const wxFileName &aFileName)
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.
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)
Checks if aFileName can be written.
wxPoint m_normalFramePos
void OnMaximize(wxMaximizeEvent &aEvent)
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associates files 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)
Fetches 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.
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 NonUserClose() to indicate that the user did not request the current close.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
wxString m_mruPath
void ReCreateMenuBar()
Recreates 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...
Definition: file_history.h:43
void AddFileToHistory(const wxString &aFile) override
Adds a file to the history.
void ClearFileHistory()
Clear all entries from the file history.
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_base.h:116
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
void GetActions(std::vector< TOOL_ACTION * > &aActions) const override
Append this Kiface's registered actions to the given list.
Definition: kiface_base.h:118
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
Definition: kiface_base.h:112
A mix in class which holds the location of a wxWindow's KIWAY.
Definition: kiway_holder.h:39
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:285
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:617
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition: kiway.cpp:202
@ FACE_SCH
eeschema DSO
Definition: kiway.h:292
@ FACE_PL_EDITOR
Definition: kiway.h:296
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:293
@ FACE_GERBVIEW
Definition: kiway.h:295
virtual void GetActions(std::vector< TOOL_ACTION * > &aActions) const
Append all registered actions to the given list.
Definition: kiway.cpp:536
WX_TREEBOOK * GetTreebook()
Definition: paged_dialog.h:39
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:140
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
virtual int GetSelectedLanguageIdentifier() const
Definition: pgm_base.h:238
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
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)
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:206
Look for files in a number of paths.
Definition: search_stack.h:43
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
virtual void ShowChangedLanguage()
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Definition: tools_holder.h:98
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Notification event that some of the common (suite-wide) settings have changed.
int GetUIId() const
Definition: tool_action.h:339
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:83
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void PushCommand(PICKED_ITEMS_LIST *aCommand)
PICKED_ITEMS_LIST * PopCommand()
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
void SetUserUnits(EDA_UNITS aUnits)
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 RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:304
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.
Definition: wx_infobar.cpp:140
MESSAGE_TYPE
Sets the type of message for special handling if needed.
Definition: wx_infobar.h:94
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:190
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:294
void SetCallback(std::function< void(void)> aCallback)
Provide a callback to be called when the infobar is dismissed (either by user action or timer).
Definition: wx_infobar.h:158
bool AddLazyPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
Definition: wx_treebook.cpp:89
bool AddLazySubPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
Definition: wx_treebook.cpp:96
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
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 DEFAULT_MAX_UNDO_ITEMS
std::function< void(wxUpdateUIEvent &) > UIUpdateHandler
This is the handler functor for the update UI events.
void SocketCleanup()
Definition: eda_dde.cpp:319
DDE server & client.
EDA_UNITS
Definition: eda_units.h:46
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:94
@ 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_SCH_FIELD_NAME_TEMPLATES
Definition: frame_type.h:82
@ PANEL_GBR_DISPLAY_OPTIONS
Definition: frame_type.h:104
@ PANEL_3DV_OPENGL
Definition: frame_type.h:101
@ PANEL_FP_DEFAULT_GRAPHICS_VALUES
Definition: frame_type.h:90
@ PANEL_PCB_ORIGINS_AXES
Definition: frame_type.h:98
@ PANEL_PCB_EDIT_OPTIONS
Definition: frame_type.h:95
@ PANEL_SCH_DISP_OPTIONS
Definition: frame_type.h:77
@ PANEL_FP_DISPLAY_OPTIONS
Definition: frame_type.h:85
@ PANEL_SCH_SIMULATOR
Definition: frame_type.h:83
@ FRAME_SCH
Definition: frame_type.h:34
@ PANEL_DS_COLORS
Definition: frame_type.h:112
@ PANEL_PCB_COLORS
Definition: frame_type.h:96
@ PANEL_3DV_RAYTRACING
Definition: frame_type.h:102
@ PANEL_SYM_EDIT_OPTIONS
Definition: frame_type.h:74
@ PANEL_FP_GRIDS
Definition: frame_type.h:86
@ PANEL_SCH_EDIT_OPTIONS
Definition: frame_type.h:79
@ PANEL_FP_ORIGINS_AXES
Definition: frame_type.h:91
@ PANEL_SYM_DISP_OPTIONS
Definition: frame_type.h:72
@ PANEL_PCB_DISPLAY_OPTS
Definition: frame_type.h:93
@ PANEL_FP_COLORS
Definition: frame_type.h:88
@ PANEL_FP_DEFAULT_FIELDS
Definition: frame_type.h:89
@ PANEL_SYM_COLORS
Definition: frame_type.h:75
@ FRAME_PL_EDITOR
Definition: frame_type.h:59
@ PANEL_GBR_GRIDS
Definition: frame_type.h:107
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
@ FRAME_GERBER
Definition: frame_type.h:57
@ PANEL_DS_GRIDS
Definition: frame_type.h:111
@ FRAME_PCB_DISPLAY3D
Definition: frame_type.h:47
@ PANEL_FP_EDIT_OPTIONS
Definition: frame_type.h:87
@ PANEL_SCH_ANNO_OPTIONS
Definition: frame_type.h:80
@ PANEL_SCH_GRIDS
Definition: frame_type.h:78
@ PANEL_PCB_ACTION_PLUGINS
Definition: frame_type.h:97
@ PANEL_3DV_DISPLAY_OPTIONS
Definition: frame_type.h:100
@ PANEL_DS_DISPLAY_OPTIONS
Definition: frame_type.h:110
@ PANEL_SCH_COLORS
Definition: frame_type.h:81
@ PANEL_GBR_COLORS
Definition: frame_type.h:108
@ PANEL_GBR_EXCELLON_OPTIONS
Definition: frame_type.h:106
@ KICAD_MAIN_FRAME_T
Definition: frame_type.h:68
bool m_EnableGit
Enable git integration.
static const std::string GerberFileExtension
static const std::string AutoSaveFilePrefix
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)
Reads a hotkey config file into a list of actions.
@ ID_FILE_LIST_CLEAR
Definition: id.h:86
@ ID_FILE1
Definition: id.h:83
@ ID_AUTO_SAVE_TIMER
Definition: id.h:78
void RemoveShutdownBlockReason(wxWindow *aWindow)
Removes any shutdown block reason set.
Definition: unix/app.cpp:85
bool DuplicatePermissions(const wxString &aSrc, const wxString &aDest)
Duplicates the file security data from one file to another ensuring that they are the same between bo...
Definition: unix/io.cpp:40
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:95
see class PGM_BASE
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:152
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:73
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.h:76
struct WINDOW_STATE window
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:74
WINDOW_STATE state
Definition: app_settings.h:75
wxString mru_path
Definition: app_settings.h:76
wxString perspective
Definition: app_settings.h:77
Stores the window positioning/state.
Definition: app_settings.h:61
unsigned int display
Definition: app_settings.h:67
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxLogTrace helper definitions.