KiCad PCB EDA Suite
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 <stambaughw@gmail.com>
6  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <bitmaps.h>
27 #include <dialog_shim.h>
30 #include <filehistory.h>
31 #include <id.h>
32 #include <kiface_i.h>
33 #include <menus_helpers.h>
34 #include <panel_hotkeys_editor.h>
35 #include <paths.h>
36 #include <pgm_base.h>
37 #include <settings/app_settings.h>
40 #include <pgm_base.h>
42 #include <tool/action_manager.h>
43 #include <tool/action_menu.h>
44 #include <tool/actions.h>
45 #include <tool/common_control.h>
46 #include <tool/tool_manager.h>
47 #include <tool/tool_dispatcher.h>
48 #include <trace_helpers.h>
49 #include <widgets/paged_dialog.h>
50 #include <widgets/infobar.h>
52 #include <wx/display.h>
53 #include <wx/stdpaths.h>
54 #include <wx/string.h>
55 #include <kiplatform/app.h>
56 
57 #include <functional>
58 
59 wxDEFINE_EVENT( UNITS_CHANGED, wxCommandEvent );
60 
61 
62 // Minimum window size
63 static const wxSize minSize( FRAME_T aFrameType )
64 {
65  switch( aFrameType )
66  {
67  case KICAD_MAIN_FRAME_T:
68  return wxSize( 406, 354 );
69 
70  default:
71  return wxSize( 500, 400 );
72  }
73 }
74 
75 static const wxSize defaultSize( FRAME_T aFrameType )
76 {
77  switch( aFrameType )
78  {
79  case KICAD_MAIN_FRAME_T:
80  return wxSize( 850, 540 );
81 
82  default:
83  return wxSize( 1280, 720 );
84  }
85 }
86 
87 
88 BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
89  EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
90  EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
91 
92  EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
93  EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
94  EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
95  EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
96  EVT_MOVE( EDA_BASE_FRAME::OnMove )
97  EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
98 END_EVENT_TABLE()
99 
100 EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
101  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
102  long aStyle, const wxString& aFrameName, KIWAY* aKiway ) :
103  wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
104  TOOLS_HOLDER(),
105  KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
106  m_ident( aFrameType ),
107  m_maximizeByDefault( false ),
108  m_infoBar( nullptr ),
109  m_settingsManager( nullptr ),
110  m_fileHistory( nullptr ),
111  m_hasAutoSave( false ),
112  m_autoSaveState( false ),
113  m_autoSaveInterval(-1 ),
114  m_undoRedoCountMax( DEFAULT_MAX_UNDO_ITEMS ),
115  m_userUnits( EDA_UNITS::MILLIMETRES ),
116  m_isClosing( false ),
117  m_isNonUserClose( false )
118 {
119  m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
120  m_mruPath = PATHS::GetDefaultUserProjectsPath();
121  m_frameSize = defaultSize( aFrameType );
122 
123  m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
124 
125  m_settingsManager = &Pgm().GetSettingsManager();
126 
127  // Set a reasonable minimal size for the frame
128  SetSizeHints( minSize( aFrameType ).x, minSize( aFrameType ).y, -1, -1, -1, -1 );
129 
130  // Store dimensions of the user area of the main window.
131  GetClientSize( &m_frameSize.x, &m_frameSize.y );
132 
133  Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
134  wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
135 
136  // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
137  // to be called before any other hook for wxCloseEvent, which is necessary.
138  Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
139 
140  initExitKey();
141 }
142 
143 
145 {
146  for( wxWindow* iter : GetChildren() )
147  {
148  DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
149 
150  if( dlg && dlg->IsQuasiModal() )
151  return dlg;
152  }
153 
154  // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
155  // so we have to look for it separately.
156  if( m_ident == FRAME_SCH )
157  {
158  wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
159 
160  if( cvpcb )
161  return cvpcb;
162  }
163 
164  return nullptr;
165 }
166 
167 
168 void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
169 {
170  // Don't allow closing when a quasi-modal is open.
171  wxWindow* quasiModal = findQuasiModalDialog();
172 
173  if( quasiModal )
174  {
175  // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
176  // when they have no idea what those are.
177  quasiModal->Raise();
178  wxBell();
179 
180  if( event.CanVeto() )
181  event.Veto();
182 
183  return;
184  }
185 
186 
187  if( event.GetId() == wxEVT_QUERY_END_SESSION
188  || event.GetId() == wxEVT_END_SESSION )
189  {
190  // End session means the OS is going to terminate us
191  m_isNonUserClose = true;
192  }
193 
194  if( canCloseWindow( event ) )
195  {
196  m_isClosing = true;
197  APP_SETTINGS_BASE* cfg = config();
198 
199  if( cfg )
200  SaveSettings( cfg ); // virtual, wxFrame specific
201 
202  doCloseWindow();
203 
204  // Destroy (safe delete frame) this frame only in non modal mode.
205  // In modal mode, the caller will call Destroy().
206  if( !IsModal() )
207  Destroy();
208  }
209  else
210  {
211  if( event.CanVeto() )
212  event.Veto();
213  }
214 }
215 
216 
218 {
219  delete m_autoSaveTimer;
220  delete m_fileHistory;
221 
223 
225 }
226 
227 
228 bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
229 {
230 #ifdef __WXMAC__
231  // Apple in its infinite wisdom will raise a disabled window before even passing
232  // us the event, so we have no way to stop it. Instead, we have to catch an
233  // improperly ordered disabled window and quasi-modal dialog here and reorder
234  // them.
235  if( !IsEnabled() && IsActive() )
236  {
237  wxWindow* dlg = findQuasiModalDialog();
238  if( dlg )
239  dlg->Raise();
240  }
241 #endif
242 
243  if( !wxFrame::ProcessEvent( aEvent ) )
244  return false;
245 
246  if( IsShown() && m_hasAutoSave && IsActive() &&
248  {
249  if( !m_autoSaveState )
250  {
251  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
252  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
253  m_autoSaveState = true;
254  }
255  else if( m_autoSaveTimer->IsRunning() )
256  {
257  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
258  m_autoSaveTimer->Stop();
259  m_autoSaveState = false;
260  }
261  }
262 
263  return true;
264 }
265 
266 
268 {
269  m_autoSaveInterval = aInterval;
270 
271  if( m_autoSaveTimer->IsRunning() )
272  {
273  if( m_autoSaveInterval > 0 )
274  {
275  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
276  }
277  else
278  {
279  m_autoSaveTimer->Stop();
280  m_autoSaveState = false;
281  }
282  }
283 }
284 
285 
286 void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
287 {
288  if( !doAutoSave() )
289  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
290 }
291 
292 
294 {
295  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
296 }
297 
298 
299 void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& event )
300 {
301  wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( event ) );
302  // Key events can be filtered here.
303  // Currently no filtering is made.
304  event.Skip();
305 }
306 
307 
308 void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
309 {
310  if( !m_toolDispatcher )
311  aEvent.Skip();
312  else
314 }
315 
316 
318 {
320  std::placeholders::_1,
321  this,
322  aConditions );
323 
324  m_uiUpdateMap[aID] = evtFunc;
325 
326  Bind( wxEVT_UPDATE_UI, evtFunc, aID );
327 }
328 
329 
331 {
332  const auto it = m_uiUpdateMap.find( aID );
333 
334  if( it == m_uiUpdateMap.end() )
335  return;
336 
337  Unbind( wxEVT_UPDATE_UI, it->second, aID );
338 }
339 
340 
341 void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
342  ACTION_CONDITIONS aCond )
343 {
344  bool checkRes = false;
345  bool enableRes = true;
346  bool showRes = true;
347  SELECTION& selection = aFrame->GetCurrentSelection();
348 
349  try
350  {
351  checkRes = aCond.checkCondition( selection );
352  enableRes = aCond.enableCondition( selection );
353  showRes = aCond.showCondition( selection );
354  }
355  catch( std::exception& )
356  {
357  // Something broke with the conditions, just skip the event.
358  aEvent.Skip();
359  return;
360  }
361 
362  aEvent.Enable( enableRes );
363  aEvent.Show( showRes );
364 
365  // wxWidgets 3.1.5+ includes a field in the event that says if the event supports being
366  // checked, since wxMenuItems don't want to be checked unless they actually are checkable
367 #if wxCHECK_VERSION( 3, 1, 5 )
368  if( aEvent.IsCheckable() )
369  aEvent.Check( checkRes );
370 #else
371  bool canCheck = true;
372 
373  // wxMenuItems don't want to be checked unless they actually are checkable, so we have to check to
374  // see if they can be and can't just universally apply a check in this event.
375  if( auto menu = dynamic_cast<wxMenu*>( aEvent.GetEventObject() ) )
376  canCheck = menu->FindItem( aEvent.GetId() )->IsCheckable();
377 
378  if( canCheck )
379  aEvent.Check( checkRes );
380 #endif
381 }
382 
383 
385 {
386  // Setup the conditions to check a language menu item
387  auto isCurrentLang =
388  [] ( const SELECTION& aSel, int aLangIdentifier )
389  {
390  return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
391  };
392 
393  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
394  {
395  ACTION_CONDITIONS cond;
396  cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
397  LanguagesList[ii].m_WX_Lang_Identifier ) );
398 
399  RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
400  }
401 }
402 
403 
405 {
406 }
407 
408 
409 void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
410 {
411  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
412  ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
413 
414  helpMenu->Add( ACTIONS::help );
415  helpMenu->Add( ACTIONS::gettingStarted );
416  helpMenu->Add( ACTIONS::listHotKeys );
417  helpMenu->Add( ACTIONS::getInvolved );
418  helpMenu->Add( ACTIONS::reportBug );
419 
420  helpMenu->AppendSeparator();
421  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
422 
423  aMenuBar->Append( helpMenu, _( "&Help" ) );
424 }
425 
426 
428 {
429  if( GetMenuBar() )
430  {
431  ReCreateMenuBar();
432  GetMenuBar()->Refresh();
433  }
434 }
435 
436 
437 void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
438 {
439  TOOLS_HOLDER::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
440 
441  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
442 
443  if( m_fileHistory )
444  {
445  int historySize = settings->m_System.file_history_size;
446  m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
447  }
448 
449  if( GetMenuBar() )
450  {
451  // For icons in menus, icon scaling & hotkeys
452  ReCreateMenuBar();
453  GetMenuBar()->Refresh();
454  }
455 }
456 
457 
458 void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
459 {
460  if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
461  return;
462 
463  const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
464 
465  if( state != nullptr )
466  {
467  LoadWindowState( state->window );
468  }
469 }
470 
471 
473 {
474  bool wasDefault = false;
475 
476  m_framePos.x = aState.pos_x;
477  m_framePos.y = aState.pos_y;
478  m_frameSize.x = aState.size_x;
479  m_frameSize.y = aState.size_y;
480 
481  wxLogTrace( traceDisplayLocation, "Config position (%d, %d) with size (%d, %d)",
483 
484  // Ensure minimum size is set if the stored config was zero-initialized
485  if( m_frameSize.x < minSize( m_ident ).x || m_frameSize.y < minSize( m_ident ).y )
486  {
488  wasDefault = true;
489 
490  wxLogTrace( traceDisplayLocation, "Using minimum size (%d, %d)", m_frameSize.x, m_frameSize.y );
491  }
492 
493  wxLogTrace( traceDisplayLocation, "Number of displays: %d", wxDisplay::GetCount() );
494 
495  if( aState.display >= wxDisplay::GetCount() )
496  {
497  wxLogTrace( traceDisplayLocation, "Previous display not found" );
498 
499  // If it isn't attached, use the first display
500  // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
501  const unsigned int index = 0;
502  wxDisplay display( index );
503  wxRect clientSize = display.GetGeometry();
504 
505  m_framePos = wxDefaultPosition;
506 
507  // Ensure the window fits on the display, since the other one could have been larger
508  if( m_frameSize.x > clientSize.width )
509  m_frameSize.x = clientSize.width;
510 
511  if( m_frameSize.y > clientSize.height )
512  m_frameSize.y = clientSize.height;
513  }
514  else
515  {
516  wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
517  wxPoint upperLeft( m_framePos.x, m_framePos.y );
518 
519  wxDisplay display( aState.display );
520  wxRect clientSize = display.GetClientArea();
521 
522  // The percentage size (represented in decimal) of the region around the screen's border where
523  // an upper corner is not allowed
524 #define SCREEN_BORDER_REGION 0.10
525 
526  int yLim = clientSize.y + ( clientSize.height * ( 1.0 - SCREEN_BORDER_REGION ) );
527  int xLimLeft = clientSize.x + ( clientSize.width * SCREEN_BORDER_REGION );
528  int xLimRight = clientSize.x + ( clientSize.width * ( 1.0 - SCREEN_BORDER_REGION ) );
529 
530  if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
531  upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
532  upperRight.y > yLim ) // Upper corner too close to the bottom of the screen
533  {
534  m_framePos = wxDefaultPosition;
535  wxLogTrace( traceDisplayLocation, "Resetting to default position" );
536  }
537  }
538 
539  // Ensure Window title bar is visible
540 #if defined( __WXOSX__ )
541  // for macOSX, the window must be below system (macOSX) toolbar
542  int Ypos_min = 20;
543 #else
544  int Ypos_min = 0;
545 #endif
546  if( m_framePos.y < Ypos_min )
547  m_framePos.y = Ypos_min;
548 
549  wxLogTrace( traceDisplayLocation, "Final window position (%d, %d) with size (%d, %d)",
551 
552  SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
553 
554  // Center the window if we reset to default
555  if( m_framePos.x == -1 )
556  {
557  wxLogTrace( traceDisplayLocation, "Centering window" );
558  Center();
559  m_framePos = GetPosition();
560  }
561 
562  // Record the frame sizes in an un-maximized state
565 
566  // Maximize if we were maximized before
567  if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
568  {
569  wxLogTrace( traceDisplayLocation, "Maximizing window" );
570  Maximize();
571  }
572 }
573 
574 
576 {
577  LoadWindowState( aCfg->state );
578 
579  if( m_hasAutoSave )
580  m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
581 
582  m_perspective = aCfg->perspective;
583  m_mruPath = aCfg->mru_path;
584 
585  TOOLS_HOLDER::CommonSettingsChanged( false, false );
586 }
587 
588 
590 {
591  wxString text;
592 
593  if( IsIconized() )
594  return;
595 
596  wxString baseCfgName = ConfigBaseName();
597 
598  // If the window is maximized, we use the saved window size from before it was maximized
599  if( IsMaximized() )
600  {
603  }
604  else
605  {
607  m_framePos = GetPosition();
608  }
609 
610  aCfg->state.pos_x = m_framePos.x;
611  aCfg->state.pos_y = m_framePos.y;
612  aCfg->state.size_x = m_frameSize.x;
613  aCfg->state.size_y = m_frameSize.y;
614  aCfg->state.maximized = IsMaximized();
615  aCfg->state.display = wxDisplay::GetFromWindow( this );
616 
617  wxLogTrace( traceDisplayLocation, "Saving window maximized: %s", IsMaximized() ? "true" : "false" );
618  wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)",
620 
621  // TODO(JE) should auto-save in common settings be overwritten by every app?
622  if( m_hasAutoSave )
623  Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
624 
625  // Once this is fully implemented, wxAuiManager will be used to maintain
626  // the persistance of the main frame and all it's managed windows and
627  // all of the legacy frame persistence position code can be removed.
628  aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
629 
630  aCfg->mru_path = m_mruPath;
631 }
632 
633 
635 {
637 
638  // Get file history size from common settings
639  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
640 
641  // Load the recently used files into the history menu
642  m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ),
644  m_fileHistory->Load( *aCfg );
645 }
646 
647 
649 {
651 
652  bool fileOpen = m_isClosing && m_isNonUserClose;
653 
654  wxString currentlyOpenedFile = GetCurrentFileName();
655 
656  if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
657  {
658  wxFileName rfn( currentlyOpenedFile );
659  rfn.MakeRelativeTo( Prj().GetProjectPath() );
660  Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
661  }
662 
663  // Save the recently used files list
664  if( m_fileHistory )
665  {
666  // Save the currently opened file in the file history
667  if( !currentlyOpenedFile.IsEmpty() )
668  UpdateFileHistory( currentlyOpenedFile );
669 
670  m_fileHistory->Save( *aCfg );
671  }
672 }
673 
674 
676 {
677  return &aCfg->m_Window;
678 }
679 
680 
682 {
683  // KICAD_MANAGER_FRAME overrides this
684  return Kiface().KifaceSettings();
685 }
686 
687 
689 {
690  return Kiface().KifaceSearch();
691 }
692 
693 
695 {
696  return Kiface().GetHelpFileName();
697 }
698 
699 
700 void EDA_BASE_FRAME::PrintMsg( const wxString& text )
701 {
702  SetStatusText( text );
703 }
704 
705 
707 {
708 #if defined( __WXOSX_MAC__ )
710 #else
711  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
712 
713  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
714 #endif
715 }
716 
717 
719 {
720 #if defined( __WXOSX_MAC__ )
721  m_auimgr.Update();
722 #else
723  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
724  // hidding it.
725  m_auimgr.Update();
726 
727  // We don't want the infobar displayed right away
728  m_auimgr.GetPane( "InfoBar" ).Hide();
729  m_auimgr.Update();
730 #endif
731 }
732 
733 
734 void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton )
735 {
737 
738  if( aShowCloseButton )
740 
741  GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR );
742 }
743 
744 
745 void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
746  std::function<void(void)> aCallback )
747 {
749 
750  if( aShowCloseButton )
752 
753  if( aCallback )
754  m_infoBar->SetCallback( aCallback );
755 
756  GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR );
757 }
758 
759 
760 void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
761 {
763 
764  if( aShowCloseButton )
766 
767  GetInfoBar()->ShowMessageFor( aWarningMsg, 8000, wxICON_WARNING );
768 }
769 
770 
771 void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
772 {
774 
775  if( aShowCloseButton )
777 
778  GetInfoBar()->ShowMessageFor( aMsg, 10000, wxICON_INFORMATION );
779 }
780 
781 
782 void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
783 {
784  if( !aFileHistory )
785  aFileHistory = m_fileHistory;
786 
787  wxASSERT( aFileHistory );
788 
789  aFileHistory->AddFileToHistory( FullFileName );
790 
791  // Update the menubar to update the file history menu
792  if( !m_isClosing && GetMenuBar() )
793  {
794  ReCreateMenuBar();
795  GetMenuBar()->Refresh();
796  }
797 }
798 
799 
800 wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
801  FILE_HISTORY* aFileHistory )
802 {
803  if( !aFileHistory )
804  aFileHistory = m_fileHistory;
805 
806  wxASSERT( aFileHistory );
807 
808  int baseId = aFileHistory->GetBaseId();
809 
810  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
811 
812  unsigned i = cmdId - baseId;
813 
814  if( i < aFileHistory->GetCount() )
815  {
816  wxString fn = aFileHistory->GetHistoryFile( i );
817 
818  if( wxFileName::FileExists( fn ) )
819  return fn;
820  else
821  {
822  wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
823  wxMessageBox( msg );
824 
825  aFileHistory->RemoveFileFromHistory( i );
826  }
827  }
828 
829  // Update the menubar to update the file history menu
830  if( GetMenuBar() )
831  {
832  ReCreateMenuBar();
833  GetMenuBar()->Refresh();
834  }
835 
836  return wxEmptyString;
837 }
838 
839 
841 {
842  if( !aFileHistory )
843  aFileHistory = m_fileHistory;
844 
845  wxASSERT( aFileHistory );
846 
847  aFileHistory->ClearFileHistory();
848 
849  // Update the menubar to update the file history menu
850  if( GetMenuBar() )
851  {
852  ReCreateMenuBar();
853  GetMenuBar()->Refresh();
854  }
855 }
856 
857 
858 void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
859 {
860  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
861  ShowAboutDialog( this );
862 }
863 
864 
865 void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
866 {
867  PAGED_DIALOG dlg( this, _( "Preferences" ), true );
868  wxTreebook* book = dlg.GetTreebook();
869 
870  book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
871 
872  book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Touchpad" ) );
873 
874  PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
875  book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
876 
877  for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
878  {
879  KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
880 
881  if( frame )
882  frame->InstallPreferences( &dlg, hotkeysPanel );
883  }
884 
885  // The Kicad manager frame is not a player so we have to add it by hand
886  wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
887 
888  if( manager )
889  static_cast<EDA_BASE_FRAME*>( manager )->InstallPreferences( &dlg, hotkeysPanel );
890 
891  for( size_t i = 0; i < book->GetPageCount(); ++i )
892  book->GetPage( i )->Layout();
893 
894  if( dlg.ShowModal() == wxID_OK )
895  dlg.Kiway().CommonSettingsChanged( false, false );
896 }
897 
898 
899 bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
900 {
901  wxString msg;
902  wxFileName fn = aFileName;
903 
904  // Check for absence of a file path with a file name. Unfortunately KiCad
905  // uses paths relative to the current project path without the ./ part which
906  // confuses wxFileName. Making the file name path absolute may be less than
907  // elegant but it solves the problem.
908  if( fn.GetPath().IsEmpty() && fn.HasName() )
909  fn.MakeAbsolute();
910 
911  wxCHECK_MSG( fn.IsOk(), false,
912  wxT( "File name object is invalid. Bad programmer!" ) );
913  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
914  wxT( "File name object path <" ) + fn.GetFullPath() +
915  wxT( "> is not set. Bad programmer!" ) );
916 
917  if( fn.IsDir() && !fn.IsDirWritable() )
918  {
919  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
920  fn.GetPath() );
921  }
922  else if( !fn.FileExists() && !fn.IsDirWritable() )
923  {
924  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
925  fn.GetFullName(), fn.GetPath() );
926  }
927  else if( fn.FileExists() && !fn.IsFileWritable() )
928  {
929  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
930  fn.GetFullPath() );
931  }
932 
933  if( !msg.IsEmpty() )
934  {
935  wxMessageBox( msg );
936  return false;
937  }
938 
939  return true;
940 }
941 
942 
943 void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
944 {
945  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
946 
947  wxFileName autoSaveFileName = aFileName;
948 
949  // Check for auto save file.
950  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
951 
952  wxLogTrace( traceAutoSave,
953  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
954 
955  if( !autoSaveFileName.FileExists() )
956  return;
957 
958  wxString msg = wxString::Format( _(
959  "Well this is potentially embarrassing!\n"
960  "It appears that the last time you were editing the file\n"
961  "\"%s\"\n"
962  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
963  aFileName.GetFullName()
964  );
965 
966  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
967 
968  // Make a backup of the current file, delete the file, and rename the auto save file to
969  // the file name.
970  if( response == wxYES )
971  {
972  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
973  {
974  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
975  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
976  }
977  }
978  else
979  {
980  wxLogTrace( traceAutoSave,
981  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
982 
983  // Remove the auto save file when using the previous file as is.
984  wxRemoveFile( autoSaveFileName.GetFullPath() );
985  }
986 }
987 
988 
990 {
991  // This function should be overridden in child classes
992  return false;
993 }
994 
995 
997 {
998  wxAcceleratorEntry entries[1];
999  entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
1000  wxAcceleratorTable accel( 1, entries );
1001  SetAcceleratorTable( accel );
1002 }
1003 
1004 
1006 {
1009 }
1010 
1011 
1013 {
1014  m_undoList.PushCommand( aNewitem );
1015 
1016  // Delete the extra items, if count max reached
1017  if( m_undoRedoCountMax > 0 )
1018  {
1019  int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
1020 
1021  if( extraitems > 0 )
1022  ClearUndoORRedoList( UNDO_LIST, extraitems );
1023  }
1024 }
1025 
1026 
1028 {
1029  m_redoList.PushCommand( aNewitem );
1030 
1031  // Delete the extra items, if count max reached
1032  if( m_undoRedoCountMax > 0 )
1033  {
1034  int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
1035 
1036  if( extraitems > 0 )
1037  ClearUndoORRedoList( REDO_LIST, extraitems );
1038  }
1039 }
1040 
1041 
1043 {
1044  return m_undoList.PopCommand();
1045 }
1046 
1047 
1049 {
1050  return m_redoList.PopCommand();
1051 }
1052 
1053 
1055 {
1056  SetUserUnits( aUnits );
1058 
1059  wxCommandEvent e( UNITS_CHANGED );
1060  ProcessEventLocally( e );
1061 }
1062 
1063 
1064 void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
1065 {
1066  // When we maximize the window, we want to save the old information
1067  // so that we can add it to the settings on next window load.
1068  // Contrary to the documentation, this event seems to be generated
1069  // when the window is also being unmaximized on OSX, so we only
1070  // capture the size information when we maximize the window when on OSX.
1071 #ifdef __WXOSX__
1072  if( !IsMaximized() )
1073 #endif
1074  {
1076  m_normalFramePos = GetPosition();
1077  wxLogTrace( traceDisplayLocation, "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1079  }
1080 
1081  // Skip event to actually maximize the window
1082  aEvent.Skip();
1083 }
1084 
1085 
1087 {
1088 #ifdef __WXGTK__
1089  // GTK includes the window decorations in the normal GetSize call,
1090  // so we have to use a GTK-specific sizing call that returns the
1091  // non-decorated window size.
1092  int width = 0;
1093  int height = 0;
1094  GTKDoGetSize( &width, &height );
1095 
1096  wxSize winSize( width, height );
1097 #else
1098  wxSize winSize = GetSize();
1099 #endif
1100 
1101  return winSize;
1102 }
SELECTION_CONDITION showCondition
Returns true if the UI control should be shown.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:113
wxString mru_path
Definition: app_settings.h:84
static TOOL_ACTION listHotKeys
Definition: actions.h:180
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:76
void PrintMsg(const wxString &text)
A mix in class which holds the location of a wxWindow's KIWAY.
Definition: kiway_holder.h:39
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
void SaveFileState(const wxString &aFileName, const WINDOW_SETTINGS *aWindowCfg, bool aOpen)
wxString m_mruPath
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:45
void SaveWindowSettings(WINDOW_SETTINGS *aCfg)
Save window settings to the given settings object.
UNDO_REDO_CONTAINER m_undoList
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
SELECTION_CONDITION enableCondition
Returns true if the UI control should be enabled.
void windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
SELECTION_CONDITION checkCondition
Returns true if the UI control should be checked.
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...
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:63
virtual bool isAutoSaveRequired() const
Return the auto save status of the application.
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:67
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void onAutoSaveTimer(wxTimerEvent &aEvent)
Handle the auto save timer event.
static TOOL_ACTION reportBug
Definition: actions.h:182
virtual void doCloseWindow()
bool IsQuasiModal() const
Definition: dialog_shim.h:107
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:92
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
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...
virtual bool IsContentModified()
Get if the contents of the frame have been modified since the last save.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
Definition: filehistory.cpp:45
virtual int GetRedoCommandCount() const
wxPoint m_normalFramePos
void ChangeUserUnits(EDA_UNITS aUnits)
Look for files in a number of paths.
Definition: search_stack.h:41
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
wxAuiManager m_auimgr
bool IsWritable(const wxFileName &aFileName)
Checks if aFileName can be written.
This class implements a file history object to store a list of files, that can then be added to a men...
Definition: filehistory.h:42
#define DEFAULT_MAX_UNDO_ITEMS
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
wxTimer * m_autoSaveTimer
void LoadWindowState(const wxString &aFileName)
PICKED_ITEMS_LIST * PopCommand()
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 ...
void ClearFileHistory()
Clear all entries from the file history.
std::function< void(wxUpdateUIEvent &) > UIUpdateHandler
This is the handler functor for the update UI events.
virtual void ClearUndoORRedoList(UNDO_REDO_LIST aList, int aItemCount=-1)
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxString m_perspective
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:151
#define SCREEN_BORDER_REGION
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
void PushCommand(PICKED_ITEMS_LIST *aCommand)
void initExitKey()
Sets the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
wxTreebook * GetTreebook()
Definition: paged_dialog.h:52
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...
void AddFileToHistory(const wxString &aFile) override
Adds a file to the history.
Definition: filehistory.cpp:96
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:113
wxWindow * findQuasiModalDialog()
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
Definition: kiface_i.h:109
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
virtual void OnCharHook(wxKeyEvent &event)
Capture the key event before it is sent to the GUI.
wxString perspective
Definition: app_settings.h:85
const BITMAP_OPAQUE about_xpm[1]
Definition: about.cpp:40
wxSize m_normalFrameSize
void CheckForAutoSaveFile(const wxFileName &aFileName)
Check if an auto save file exists for aFileName and takes the appropriate action depending on the use...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
virtual int GetUndoCommandCount() const
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
static const wxSize defaultSize(FRAME_T aFrameType)
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
std::map< int, UIUpdateHandler > m_uiUpdateMap
Set by the close window event handler after frames are asked if they can close.
virtual void UnregisterUIUpdateHandler(int aID) override
Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler.
void FinishAUIInitialization()
virtual const SEARCH_STACK & sys_search()
Return a SEARCH_STACK pertaining to entire program.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
struct WINDOW_STATE window
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
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: infobar.h:150
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
wxLogTrace helper definitions.
void OnKicadAbout(wxCommandEvent &event)
A holder to handle information on schematic or board items.
Handle actions that are shared between different applications.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Stores the window positioning/state.
Definition: app_settings.h:68
UNDO_REDO_CONTAINER m_redoList
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:277
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
wxDEFINE_EVENT(UNITS_CHANGED, wxCommandEvent)
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
const PROJECT_FILE_STATE * GetFileState(const wxString &aFileName)
virtual void OnMove(wxMoveEvent &aEvent)
EDA_UNITS
Definition: eda_units.h:38
static wxString GetAutoSaveFilePrefix()
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:129
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:85
void OnMaximize(wxMaximizeEvent &aEvent)
void SetAutoSaveInterval(int aInterval)
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Definition: tools_holder.h:102
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.
see class PGM_BASE
wxString ConfigBaseName() override
Get the configuration base name.
WX_INFOBAR * m_infoBar
#define KICAD_MANAGER_FRAME_NAME
#define _(s)
Definition: 3d_actions.cpp:33
WINDOW_STATE state
Definition: app_settings.h:83
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
The base frame for deriving all KiCad main window classes.
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
static TOOL_ACTION help
Definition: actions.h:179
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
virtual wxString help_name()
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Notification event that some of the common (suite-wide) settings have changed.
void OnPreferences(wxCommandEvent &event)
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:515
static const wxSize minSize(FRAME_T aFrameType)
WX_INFOBAR * GetInfoBar()
ACTION_CONDITIONS & Check(const SELECTION_CONDITION &aCondition)
void SetUserUnits(EDA_UNITS aUnits)
Definition: id.h:87
virtual void InstallPreferences(PAGED_DIALOG *, PANEL_HOTKEYS_EDITOR *)
Allow a frame to load its preference panels (if any) into the preferences dialog.
unsigned int display
Definition: app_settings.h:75
static TOOL_ACTION getInvolved
Definition: actions.h:181
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
static TOOL_ACTION gettingStarted
Definition: actions.h:178
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
virtual wxString GetCurrentFileName() const
Get the full filename + path of the currently opened file in the frame.
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
void RemoveShutdownBlockReason(wxWindow *aWindow)
Removes any shutdown block reason set.
Definition: gtk/app.cpp:46
FILE_HISTORY * m_fileHistory
void OnMenuEvent(wxMenuEvent &event)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:267
virtual void ReCreateMenuBar()
Recreates the menu bar.