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 <bitmap_store.h>
28 #include <dialog_shim.h>
31 #include <eda_dde.h>
32 #include <filehistory.h>
33 #include <id.h>
34 #include <kiface_i.h>
35 #include <menus_helpers.h>
36 #include <panel_hotkeys_editor.h>
37 #include <paths.h>
38 #include <pgm_base.h>
39 #include <settings/app_settings.h>
42 #include <pgm_base.h>
44 #include <tool/action_manager.h>
45 #include <tool/action_menu.h>
46 #include <tool/action_toolbar.h>
47 #include <tool/actions.h>
48 #include <tool/common_control.h>
49 #include <tool/tool_manager.h>
50 #include <tool/tool_dispatcher.h>
51 #include <trace_helpers.h>
52 #include <widgets/paged_dialog.h>
53 #include <widgets/infobar.h>
55 #include <wx/display.h>
56 #include <wx/stdpaths.h>
57 #include <wx/string.h>
58 #include <kiplatform/app.h>
59 #include <kiplatform/ui.h>
60 
61 #include <functional>
62 
63 wxDEFINE_EVENT( UNITS_CHANGED, wxCommandEvent );
64 
65 
66 // Minimum window size
67 static const wxSize minSize( FRAME_T aFrameType )
68 {
69  switch( aFrameType )
70  {
71  case KICAD_MAIN_FRAME_T:
72  return wxSize( 406, 354 );
73 
74  default:
75  return wxSize( 500, 400 );
76  }
77 }
78 
79 static const wxSize defaultSize( FRAME_T aFrameType )
80 {
81  switch( aFrameType )
82  {
83  case KICAD_MAIN_FRAME_T:
84  return wxSize( 850, 540 );
85 
86  default:
87  return wxSize( 1280, 720 );
88  }
89 }
90 
91 
92 BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
93  EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
94  EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
95 
96  EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
97  EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
98  EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent )
99  EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent )
100  EVT_MOVE( EDA_BASE_FRAME::OnMove )
101  EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize )
102 
103  EVT_SYS_COLOUR_CHANGED( EDA_BASE_FRAME::onSystemColorChange )
104 END_EVENT_TABLE()
105 
106 EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
107  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
108  long aStyle, const wxString& aFrameName, KIWAY* aKiway ) :
109  wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
110  TOOLS_HOLDER(),
111  KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
112  m_ident( aFrameType ),
113  m_maximizeByDefault( false ),
114  m_infoBar( nullptr ),
115  m_settingsManager( nullptr ),
116  m_fileHistory( nullptr ),
117  m_hasAutoSave( false ),
118  m_autoSaveState( false ),
119  m_autoSaveInterval(-1 ),
120  m_undoRedoCountMax( DEFAULT_MAX_UNDO_ITEMS ),
121  m_userUnits( EDA_UNITS::MILLIMETRES ),
122  m_isClosing( false ),
123  m_isNonUserClose( false )
124 {
125  m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
126  m_mruPath = PATHS::GetDefaultUserProjectsPath();
127  m_frameSize = defaultSize( aFrameType );
128 
129  m_auimgr.SetArtProvider( new WX_AUI_DOCK_ART() );
130 
131  m_settingsManager = &Pgm().GetSettingsManager();
132 
133  // Set a reasonable minimal size for the frame
134  SetSizeHints( minSize( aFrameType ).x, minSize( aFrameType ).y, -1, -1, -1, -1 );
135 
136  // Store dimensions of the user area of the main window.
137  GetClientSize( &m_frameSize.x, &m_frameSize.y );
138 
139  Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
140  wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
141 
142  // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
143  // to be called before any other hook for wxCloseEvent, which is necessary.
144  Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
145 
146  initExitKey();
147 }
148 
149 
151 {
152  for( wxWindow* iter : GetChildren() )
153  {
154  DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
155 
156  if( dlg && dlg->IsQuasiModal() )
157  return dlg;
158  }
159 
160  // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
161  // so we have to look for it separately.
162  if( m_ident == FRAME_SCH )
163  {
164  wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
165 
166  if( cvpcb )
167  return cvpcb;
168  }
169 
170  return nullptr;
171 }
172 
173 
174 void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
175 {
176  // Don't allow closing when a quasi-modal is open.
177  wxWindow* quasiModal = findQuasiModalDialog();
178 
179  if( quasiModal )
180  {
181  // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
182  // when they have no idea what those are.
183  quasiModal->Raise();
184  wxBell();
185 
186  if( event.CanVeto() )
187  event.Veto();
188 
189  return;
190  }
191 
192 
193  if( event.GetId() == wxEVT_QUERY_END_SESSION
194  || event.GetId() == wxEVT_END_SESSION )
195  {
196  // End session means the OS is going to terminate us
197  m_isNonUserClose = true;
198  }
199 
200  if( canCloseWindow( event ) )
201  {
202  m_isClosing = true;
203  APP_SETTINGS_BASE* cfg = config();
204 
205  if( cfg )
206  SaveSettings( cfg ); // virtual, wxFrame specific
207 
208  doCloseWindow();
209 
210  // Destroy (safe delete frame) this frame only in non modal mode.
211  // In modal mode, the caller will call Destroy().
212  if( !IsModal() )
213  Destroy();
214  }
215  else
216  {
217  if( event.CanVeto() )
218  event.Veto();
219  }
220 }
221 
222 
224 {
225  delete m_autoSaveTimer;
226  delete m_fileHistory;
227 
229 
230  SocketCleanup();
231 
233 }
234 
235 
236 bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
237 {
238 #ifdef __WXMAC__
239  // Apple in its infinite wisdom will raise a disabled window before even passing
240  // us the event, so we have no way to stop it. Instead, we have to catch an
241  // improperly ordered disabled window and quasi-modal dialog here and reorder
242  // them.
243  if( !IsEnabled() && IsActive() )
244  {
245  wxWindow* dlg = findQuasiModalDialog();
246  if( dlg )
247  dlg->Raise();
248  }
249 #endif
250 
251  if( !wxFrame::ProcessEvent( aEvent ) )
252  return false;
253 
254  if( IsShown() && m_hasAutoSave && IsActive() &&
256  {
257  if( !m_autoSaveState )
258  {
259  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
260  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
261  m_autoSaveState = true;
262  }
263  else if( m_autoSaveTimer->IsRunning() )
264  {
265  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
266  m_autoSaveTimer->Stop();
267  m_autoSaveState = false;
268  }
269  }
270 
271  return true;
272 }
273 
274 
276 {
277  m_autoSaveInterval = aInterval;
278 
279  if( m_autoSaveTimer->IsRunning() )
280  {
281  if( m_autoSaveInterval > 0 )
282  {
283  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
284  }
285  else
286  {
287  m_autoSaveTimer->Stop();
288  m_autoSaveState = false;
289  }
290  }
291 }
292 
293 
294 void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
295 {
296  if( !doAutoSave() )
297  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
298 }
299 
300 
302 {
303  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
304 }
305 
306 
307 void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent )
308 {
309  wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( aKeyEvent ) );
310 
311  // Key events can be filtered here.
312  // Currently no filtering is made.
313  aKeyEvent.Skip();
314 }
315 
316 
317 void EDA_BASE_FRAME::OnMenuEvent( wxMenuEvent& aEvent )
318 {
319  if( !m_toolDispatcher )
320  aEvent.Skip();
321  else
323 }
324 
325 
327 {
329  std::placeholders::_1,
330  this,
331  aConditions );
332 
333  m_uiUpdateMap[aID] = evtFunc;
334 
335  Bind( wxEVT_UPDATE_UI, evtFunc, aID );
336 }
337 
338 
340 {
341  const auto it = m_uiUpdateMap.find( aID );
342 
343  if( it == m_uiUpdateMap.end() )
344  return;
345 
346  Unbind( wxEVT_UPDATE_UI, it->second, aID );
347 }
348 
349 
350 void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAME* aFrame,
351  ACTION_CONDITIONS aCond )
352 {
353  bool checkRes = false;
354  bool enableRes = true;
355  bool showRes = true;
356  SELECTION& selection = aFrame->GetCurrentSelection();
357 
358  try
359  {
360  checkRes = aCond.checkCondition( selection );
361  enableRes = aCond.enableCondition( selection );
362  showRes = aCond.showCondition( selection );
363  }
364  catch( std::exception& )
365  {
366  // Something broke with the conditions, just skip the event.
367  aEvent.Skip();
368  return;
369  }
370 
371  aEvent.Enable( enableRes );
372  aEvent.Show( showRes );
373 
374  // wxWidgets 3.1.5+ includes a field in the event that says if the event supports being
375  // checked, since wxMenuItems don't want to be checked unless they actually are checkable
376 #if wxCHECK_VERSION( 3, 1, 5 )
377  if( aEvent.IsCheckable() )
378  aEvent.Check( checkRes );
379 #else
380  bool canCheck = true;
381 
382  // wxMenuItems don't want to be checked unless they actually are checkable, so we have to check to
383  // see if they can be and can't just universally apply a check in this event.
384  if( auto menu = dynamic_cast<wxMenu*>( aEvent.GetEventObject() ) )
385  canCheck = menu->FindItem( aEvent.GetId() )->IsCheckable();
386 
387  if( canCheck )
388  aEvent.Check( checkRes );
389 #endif
390 }
391 
392 
394 {
395  // Setup the conditions to check a language menu item
396  auto isCurrentLang =
397  [] ( const SELECTION& aSel, int aLangIdentifier )
398  {
399  return Pgm().GetSelectedLanguageIdentifier() == aLangIdentifier;
400  };
401 
402  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
403  {
404  ACTION_CONDITIONS cond;
405  cond.Check( std::bind( isCurrentLang, std::placeholders::_1,
406  LanguagesList[ii].m_WX_Lang_Identifier ) );
407 
408  RegisterUIUpdateHandler( LanguagesList[ii].m_KI_Lang_Identifier, cond );
409  }
410 }
411 
412 
414 {
415 }
416 
417 
418 void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
419 {
420  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
421  ACTION_MENU* helpMenu = new ACTION_MENU( false, commonControl );
422 
423  helpMenu->Add( ACTIONS::help );
424  helpMenu->Add( ACTIONS::gettingStarted );
425  helpMenu->Add( ACTIONS::listHotKeys );
426  helpMenu->Add( ACTIONS::getInvolved );
427  helpMenu->Add( ACTIONS::donate );
428  helpMenu->Add( ACTIONS::reportBug );
429 
430  helpMenu->AppendSeparator();
431  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, BITMAPS::about );
432 
433  aMenuBar->Append( helpMenu, _( "&Help" ) );
434 }
435 
436 
438 {
439  if( GetMenuBar() )
440  {
441  ReCreateMenuBar();
442  GetMenuBar()->Refresh();
443  }
444 }
445 
446 
447 void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
448 {
449  TOOLS_HOLDER::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
450 
451  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
452 
453  if( m_fileHistory )
454  {
455  int historySize = settings->m_System.file_history_size;
456  m_fileHistory->SetMaxFiles( (unsigned) std::max( 0, historySize ) );
457  }
458 
459  if( GetBitmapStore()->ThemeChanged() )
460  {
461  ThemeChanged();
462  }
463 
464  if( GetMenuBar() )
465  {
466  // For icons in menus, icon scaling & hotkeys
467  ReCreateMenuBar();
468  GetMenuBar()->Refresh();
469  }
470 }
471 
472 
474 {
476 
477  // Update all the toolbars to have new icons
478  wxAuiPaneInfoArray panes = m_auimgr.GetAllPanes();
479 
480  for( size_t i = 0; i < panes.GetCount(); ++i )
481  {
482  if( ACTION_TOOLBAR* toolbar = dynamic_cast<ACTION_TOOLBAR*>( panes[i].window ) )
483  toolbar->RefreshBitmaps();
484  }
485 }
486 
487 
488 void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
489 {
490  if( !Pgm().GetCommonSettings()->m_Session.remember_open_files )
491  return;
492 
493  const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
494 
495  if( state != nullptr )
496  {
497  LoadWindowState( state->window );
498  }
499 }
500 
501 
503 {
504  bool wasDefault = false;
505 
506  m_framePos.x = aState.pos_x;
507  m_framePos.y = aState.pos_y;
508  m_frameSize.x = aState.size_x;
509  m_frameSize.y = aState.size_y;
510 
511  wxLogTrace( traceDisplayLocation, "Config position (%d, %d) with size (%d, %d)",
513 
514  // Ensure minimum size is set if the stored config was zero-initialized
515  if( m_frameSize.x < minSize( m_ident ).x || m_frameSize.y < minSize( m_ident ).y )
516  {
518  wasDefault = true;
519 
520  wxLogTrace( traceDisplayLocation, "Using minimum size (%d, %d)", m_frameSize.x, m_frameSize.y );
521  }
522 
523  wxLogTrace( traceDisplayLocation, "Number of displays: %d", wxDisplay::GetCount() );
524 
525  if( aState.display >= wxDisplay::GetCount() )
526  {
527  wxLogTrace( traceDisplayLocation, "Previous display not found" );
528 
529  // If it isn't attached, use the first display
530  // Warning wxDisplay has 2 ctor variants. the parameter needs a type:
531  const unsigned int index = 0;
532  wxDisplay display( index );
533  wxRect clientSize = display.GetGeometry();
534 
535  m_framePos = wxDefaultPosition;
536 
537  // Ensure the window fits on the display, since the other one could have been larger
538  if( m_frameSize.x > clientSize.width )
539  m_frameSize.x = clientSize.width;
540 
541  if( m_frameSize.y > clientSize.height )
542  m_frameSize.y = clientSize.height;
543  }
544  else
545  {
546  wxPoint upperRight( m_framePos.x + m_frameSize.x, m_framePos.y );
547  wxPoint upperLeft( m_framePos.x, m_framePos.y );
548 
549  wxDisplay display( aState.display );
550  wxRect clientSize = display.GetClientArea();
551 
552 #ifndef _WIN32
553  // The percentage size (represented in decimal) of the region around the screen's border where
554  // an upper corner is not allowed
555  #define SCREEN_BORDER_REGION 0.10
556 #else
557  // Windows uses a very rectangular clearly defined display region, there is no ambigious "screen border region"
558  // GetClientArea already accounts for the taskbar stealing display space
559  #define SCREEN_BORDER_REGION 0
560 #endif
561 
562  int yLimTop = clientSize.y + ( clientSize.height * ( SCREEN_BORDER_REGION ) );
563  int yLimBottom = clientSize.y + ( clientSize.height * ( 1.0 - SCREEN_BORDER_REGION ) );
564  int xLimLeft = clientSize.x + ( clientSize.width * SCREEN_BORDER_REGION );
565  int xLimRight = clientSize.x + ( clientSize.width * ( 1.0 - SCREEN_BORDER_REGION ) );
566 
567  if( upperLeft.x > xLimRight || // Upper left corner too close to right edge of screen
568  upperRight.x < xLimLeft || // Upper right corner too close to left edge of screen
569  upperLeft.y < yLimTop || // Upper corner too close to the bottom of the screen
570  upperLeft.y > yLimBottom )
571  {
572  m_framePos = wxDefaultPosition;
573  wxLogTrace( traceDisplayLocation, "Resetting to default position" );
574  }
575  }
576 
577  // Ensure Window title bar is visible
578 #if defined( __WXOSX__ )
579  // for macOSX, the window must be below system (macOSX) toolbar
580  int Ypos_min = 20;
581 #else
582  int Ypos_min = 0;
583 #endif
584  if( m_framePos.y < Ypos_min )
585  m_framePos.y = Ypos_min;
586 
587  wxLogTrace( traceDisplayLocation, "Final window position (%d, %d) with size (%d, %d)",
589 
590  SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
591 
592  // Center the window if we reset to default
593  if( m_framePos.x == -1 )
594  {
595  wxLogTrace( traceDisplayLocation, "Centering window" );
596  Center();
597  m_framePos = GetPosition();
598  }
599 
600  // Record the frame sizes in an un-maximized state
603 
604  // Maximize if we were maximized before
605  if( aState.maximized || ( wasDefault && m_maximizeByDefault ) )
606  {
607  wxLogTrace( traceDisplayLocation, "Maximizing window" );
608  Maximize();
609  }
610 }
611 
612 
614 {
615  LoadWindowState( aCfg->state );
616 
617  if( m_hasAutoSave )
618  m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
619 
620  m_perspective = aCfg->perspective;
621  m_mruPath = aCfg->mru_path;
622 
623  TOOLS_HOLDER::CommonSettingsChanged( false, false );
624 }
625 
626 
628 {
629  wxString text;
630 
631  if( IsIconized() )
632  return;
633 
634  wxString baseCfgName = ConfigBaseName();
635 
636  // If the window is maximized, we use the saved window size from before it was maximized
637  if( IsMaximized() )
638  {
641  }
642  else
643  {
645  m_framePos = GetPosition();
646  }
647 
648  aCfg->state.pos_x = m_framePos.x;
649  aCfg->state.pos_y = m_framePos.y;
650  aCfg->state.size_x = m_frameSize.x;
651  aCfg->state.size_y = m_frameSize.y;
652  aCfg->state.maximized = IsMaximized();
653  aCfg->state.display = wxDisplay::GetFromWindow( this );
654 
655  wxLogTrace( traceDisplayLocation, "Saving window maximized: %s", IsMaximized() ? "true" : "false" );
656  wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)",
658 
659  // TODO(JE) should auto-save in common settings be overwritten by every app?
660  if( m_hasAutoSave )
661  Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
662 
663  // Once this is fully implemented, wxAuiManager will be used to maintain
664  // the persistence of the main frame and all it's managed windows and
665  // all of the legacy frame persistence position code can be removed.
666  aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
667 
668  aCfg->mru_path = m_mruPath;
669 }
670 
671 
673 {
675 
676  // Get file history size from common settings
677  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
678 
679  // Load the recently used files into the history menu
680  m_fileHistory = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ),
682  m_fileHistory->Load( *aCfg );
683 }
684 
685 
687 {
689 
690  bool fileOpen = m_isClosing && m_isNonUserClose;
691 
692  wxString currentlyOpenedFile = GetCurrentFileName();
693 
694  if( Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
695  {
696  wxFileName rfn( currentlyOpenedFile );
697  rfn.MakeRelativeTo( Prj().GetProjectPath() );
698  Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &aCfg->m_Window, fileOpen );
699  }
700 
701  // Save the recently used files list
702  if( m_fileHistory )
703  {
704  // Save the currently opened file in the file history
705  if( !currentlyOpenedFile.IsEmpty() )
706  UpdateFileHistory( currentlyOpenedFile );
707 
708  m_fileHistory->Save( *aCfg );
709  }
710 }
711 
712 
714 {
715  return &aCfg->m_Window;
716 }
717 
718 
720 {
721  // KICAD_MANAGER_FRAME overrides this
722  return Kiface().KifaceSettings();
723 }
724 
725 
727 {
728  return Kiface().KifaceSearch();
729 }
730 
731 
733 {
734  return Kiface().GetHelpFileName();
735 }
736 
737 
738 void EDA_BASE_FRAME::PrintMsg( const wxString& text )
739 {
740  SetStatusText( text );
741 }
742 
743 
745 {
746 #if defined( __WXOSX_MAC__ )
748 #else
749  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
750 
751  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
752 #endif
753 }
754 
755 
757 {
758 #if defined( __WXOSX_MAC__ )
759  m_auimgr.Update();
760 #else
761  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
762  // hiding it.
763  m_auimgr.Update();
764 
765  // We don't want the infobar displayed right away
766  m_auimgr.GetPane( "InfoBar" ).Hide();
767  m_auimgr.Update();
768 #endif
769 }
770 
771 
772 void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton )
773 {
775 
776  if( aShowCloseButton )
778 
779  GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR );
780 }
781 
782 
783 void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton,
784  std::function<void(void)> aCallback )
785 {
787 
788  if( aShowCloseButton )
790 
791  if( aCallback )
792  m_infoBar->SetCallback( aCallback );
793 
794  GetInfoBar()->ShowMessageFor( aErrorMsg, 6000, wxICON_ERROR );
795 }
796 
797 
798 void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton )
799 {
801 
802  if( aShowCloseButton )
804 
805  GetInfoBar()->ShowMessageFor( aWarningMsg, 6000, wxICON_WARNING );
806 }
807 
808 
809 void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton )
810 {
812 
813  if( aShowCloseButton )
815 
816  GetInfoBar()->ShowMessageFor( aMsg, 8000, wxICON_INFORMATION );
817 }
818 
819 
820 void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory )
821 {
822  if( !aFileHistory )
823  aFileHistory = m_fileHistory;
824 
825  wxASSERT( aFileHistory );
826 
827  aFileHistory->AddFileToHistory( FullFileName );
828 
829  // Update the menubar to update the file history menu
830  if( !m_isClosing && GetMenuBar() )
831  {
832  ReCreateMenuBar();
833  GetMenuBar()->Refresh();
834  }
835 }
836 
837 
838 wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
839  FILE_HISTORY* aFileHistory )
840 {
841  if( !aFileHistory )
842  aFileHistory = m_fileHistory;
843 
844  wxASSERT( aFileHistory );
845 
846  int baseId = aFileHistory->GetBaseId();
847 
848  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) aFileHistory->GetCount() );
849 
850  unsigned i = cmdId - baseId;
851 
852  if( i < aFileHistory->GetCount() )
853  {
854  wxString fn = aFileHistory->GetHistoryFile( i );
855 
856  if( wxFileName::FileExists( fn ) )
857  return fn;
858  else
859  {
860  wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
861  wxMessageBox( msg );
862 
863  aFileHistory->RemoveFileFromHistory( i );
864  }
865  }
866 
867  // Update the menubar to update the file history menu
868  if( GetMenuBar() )
869  {
870  ReCreateMenuBar();
871  GetMenuBar()->Refresh();
872  }
873 
874  return wxEmptyString;
875 }
876 
877 
879 {
880  if( !aFileHistory )
881  aFileHistory = m_fileHistory;
882 
883  wxASSERT( aFileHistory );
884 
885  aFileHistory->ClearFileHistory();
886 
887  // Update the menubar to update the file history menu
888  if( GetMenuBar() )
889  {
890  ReCreateMenuBar();
891  GetMenuBar()->Refresh();
892  }
893 }
894 
895 
896 void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
897 {
898  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
899  ShowAboutDialog( this );
900 }
901 
902 
903 void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
904 {
905  PAGED_DIALOG dlg( this, _( "Preferences" ), true );
906  wxTreebook* book = dlg.GetTreebook();
907 
908  book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
909 
910  book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Touchpad" ) );
911 
912  PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
913  book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
914 
915  for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
916  {
917  KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
918 
919  if( frame )
920  frame->InstallPreferences( &dlg, hotkeysPanel );
921  }
922 
923  // The Kicad manager frame is not a player so we have to add it by hand
924  wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
925 
926  if( manager )
927  static_cast<EDA_BASE_FRAME*>( manager )->InstallPreferences( &dlg, hotkeysPanel );
928 
929  for( size_t i = 0; i < book->GetPageCount(); ++i )
930  book->GetPage( i )->Layout();
931 
932  if( dlg.ShowModal() == wxID_OK )
933  dlg.Kiway().CommonSettingsChanged( false, false );
934 }
935 
936 
937 bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
938 {
939  wxString msg;
940  wxFileName fn = aFileName;
941 
942  // Check for absence of a file path with a file name. Unfortunately KiCad
943  // uses paths relative to the current project path without the ./ part which
944  // confuses wxFileName. Making the file name path absolute may be less than
945  // elegant but it solves the problem.
946  if( fn.GetPath().IsEmpty() && fn.HasName() )
947  fn.MakeAbsolute();
948 
949  wxCHECK_MSG( fn.IsOk(), false,
950  wxT( "File name object is invalid. Bad programmer!" ) );
951  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
952  wxT( "File name object path <" ) + fn.GetFullPath() +
953  wxT( "> is not set. Bad programmer!" ) );
954 
955  if( fn.IsDir() && !fn.IsDirWritable() )
956  {
957  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
958  fn.GetPath() );
959  }
960  else if( !fn.FileExists() && !fn.IsDirWritable() )
961  {
962  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
963  fn.GetFullName(), fn.GetPath() );
964  }
965  else if( fn.FileExists() && !fn.IsFileWritable() )
966  {
967  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
968  fn.GetFullPath() );
969  }
970 
971  if( !msg.IsEmpty() )
972  {
973  wxMessageBox( msg );
974  return false;
975  }
976 
977  return true;
978 }
979 
980 
981 void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
982 {
983  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
984 
985  wxFileName autoSaveFileName = aFileName;
986 
987  // Check for auto save file.
988  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
989 
990  wxLogTrace( traceAutoSave,
991  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
992 
993  if( !autoSaveFileName.FileExists() )
994  return;
995 
996  wxString msg = wxString::Format( _(
997  "Well this is potentially embarrassing!\n"
998  "It appears that the last time you were editing the file\n"
999  "\"%s\"\n"
1000  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
1001  aFileName.GetFullName()
1002  );
1003 
1004  int response = wxMessageBox( msg, Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1005  this );
1006 
1007  // Make a backup of the current file, delete the file, and rename the auto save file to
1008  // the file name.
1009  if( response == wxYES )
1010  {
1011  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
1012  {
1013  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
1014  Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION, this );
1015  }
1016  }
1017  else
1018  {
1019  wxLogTrace( traceAutoSave,
1020  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
1021 
1022  // Remove the auto save file when using the previous file as is.
1023  wxRemoveFile( autoSaveFileName.GetFullPath() );
1024  }
1025 }
1026 
1027 
1029 {
1030  // This function should be overridden in child classes
1031  return false;
1032 }
1033 
1034 
1036 {
1037  wxAcceleratorEntry entries[1];
1038  entries[0].Set( wxACCEL_CTRL, int( 'Q' ), wxID_EXIT );
1039  wxAcceleratorTable accel( 1, entries );
1040  SetAcceleratorTable( accel );
1041 }
1042 
1043 
1045 {
1048 }
1049 
1050 
1052 {
1053  m_undoList.PushCommand( aNewitem );
1054 
1055  // Delete the extra items, if count max reached
1056  if( m_undoRedoCountMax > 0 )
1057  {
1058  int extraitems = GetUndoCommandCount() - m_undoRedoCountMax;
1059 
1060  if( extraitems > 0 )
1061  ClearUndoORRedoList( UNDO_LIST, extraitems );
1062  }
1063 }
1064 
1065 
1067 {
1068  m_redoList.PushCommand( aNewitem );
1069 
1070  // Delete the extra items, if count max reached
1071  if( m_undoRedoCountMax > 0 )
1072  {
1073  int extraitems = GetRedoCommandCount() - m_undoRedoCountMax;
1074 
1075  if( extraitems > 0 )
1076  ClearUndoORRedoList( REDO_LIST, extraitems );
1077  }
1078 }
1079 
1080 
1082 {
1083  return m_undoList.PopCommand();
1084 }
1085 
1086 
1088 {
1089  return m_redoList.PopCommand();
1090 }
1091 
1092 
1094 {
1095  SetUserUnits( aUnits );
1097 
1098  wxCommandEvent e( UNITS_CHANGED );
1099  ProcessEventLocally( e );
1100 }
1101 
1102 
1103 void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
1104 {
1105  // When we maximize the window, we want to save the old information
1106  // so that we can add it to the settings on next window load.
1107  // Contrary to the documentation, this event seems to be generated
1108  // when the window is also being unmaximized on OSX, so we only
1109  // capture the size information when we maximize the window when on OSX.
1110 #ifdef __WXOSX__
1111  if( !IsMaximized() )
1112 #endif
1113  {
1115  m_normalFramePos = GetPosition();
1116  wxLogTrace( traceDisplayLocation, "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1118  }
1119 
1120  // Skip event to actually maximize the window
1121  aEvent.Skip();
1122 }
1123 
1124 
1126 {
1127 #ifdef __WXGTK__
1128  // GTK includes the window decorations in the normal GetSize call,
1129  // so we have to use a GTK-specific sizing call that returns the
1130  // non-decorated window size.
1131  int width = 0;
1132  int height = 0;
1133  GTKDoGetSize( &width, &height );
1134 
1135  wxSize winSize( width, height );
1136 #else
1137  wxSize winSize = GetSize();
1138 #endif
1139 
1140  return winSize;
1141 }
1142 
1143 
1145 {
1146  // Update the icon theme when the system theme changes and update the toolbars
1147  if( GetBitmapStore()->ThemeChanged() )
1148  ThemeChanged();
1149 
1150  // This isn't handled by ThemeChanged()
1151  if( GetMenuBar() )
1152  {
1153  // For icons in menus, icon scaling & hotkeys
1154  ReCreateMenuBar();
1155  GetMenuBar()->Refresh();
1156  }
1157 }
1158 
1159 
1160 void EDA_BASE_FRAME::onSystemColorChange( wxSysColourChangedEvent& aEvent )
1161 {
1162  // Call the handler to update the colors used in the frame
1164 
1165  // Skip the change event to ensure the rest of the window controls get it
1166  aEvent.Skip();
1167 }
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:123
wxString mru_path
Definition: app_settings.h:84
virtual void HandleSystemColorChange()
Update the UI in response to a change in the system colors.
static TOOL_ACTION listHotKeys
Definition: actions.h:180
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:68
void PrintMsg(const wxString &text)
A mix in class which holds the location of a wxWindow's KIWAY.
Definition: kiway_holder.h:39
Define the structure of a toolbar with buttons that invoke ACTIONs.
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
DDE server & client.
void SaveFileState(const wxString &aFileName, const WINDOW_SETTINGS *aWindowCfg, bool aOpen)
wxString m_mruPath
virtual void OnCharHook(wxKeyEvent &aKeyEvent)
Capture the key event before it is sent to the GUI.
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:47
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
void onSystemColorChange(wxSysColourChangedEvent &aEvent)
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
Cursor control event types.
Definition: actions.h:183
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.
void ClearScaledBitmapCache()
Wipes out the scaled bitmap cache so that the icon theme can be changed.
Definition: bitmap.cpp:169
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:368
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
static TOOL_ACTION donate
Definition: actions.h:181
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()
void SocketCleanup()
Definition: eda_dde.cpp:321
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)
wxString perspective
Definition: app_settings.h:85
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:152
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:287
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:130
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
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 void ThemeChanged()
Process light/dark theme change.
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:538
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:86
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:182
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:71
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:277
virtual void ReCreateMenuBar()
Recreates the menu bar.
BITMAP_STORE * GetBitmapStore()
Definition: bitmap.cpp:92