KiCad PCB EDA Suite
basicframe.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-2017 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 
32 #include <wx/stdpaths.h>
33 #include <wx/string.h>
34 
35 #include <dialog_shim.h>
36 #include <eda_doc.h>
37 #include <id.h>
38 #include <kiface_i.h>
39 #include <pgm_base.h>
40 #include <wxstruct.h>
41 #include <menus_helpers.h>
42 #include <bitmaps.h>
43 
44 #include <wx/display.h>
45 #include <wx/utils.h>
46 
47 
49 #define DEFAULT_AUTO_SAVE_INTERVAL 600
50 
51 #define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/"
52 
53 const wxChar traceAutoSave[] = wxT( "KICAD_TRACE_AUTOSAVE" );
54 
57 
59 static const wxString entryAutoSaveInterval = "AutoSaveInterval";
60 
62 static const wxString entryPerspective = "Perspective";
63 
65 static const wxString entryMruPath = "MostRecentlyUsedPath";
66 
67 static const wxString entryPosY = "Pos_y";
68 static const wxString entryPosX = "Pos_x";
69 static const wxString entrySizeY = "Size_y";
70 static const wxString entrySizeX = "Size_x";
71 static const wxString entryMaximized = "Maximized";
72 
74 EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
75  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
76  long aStyle, const wxString& aFrameName ) :
77  wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName )
78 {
79  wxSize minsize;
80 
81  m_Ident = aFrameType;
82  m_mainToolBar = NULL;
83  m_hasAutoSave = false;
84  m_autoSaveState = false;
85  m_autoSaveInterval = -1;
86  m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
87  m_mruPath = wxStandardPaths::Get().GetDocumentsDir();
88  minsize.x = 470;
89  minsize.y = 350;
90 
91  SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
92 
93  if( ( aSize.x < minsize.x ) || ( aSize.y < minsize.y ) )
94  SetSize( 0, 0, minsize.x, minsize.y );
95 
96  // Create child subwindows.
97 
98  // Dimensions of the user area of the main window.
99  GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
100 
101  m_FramePos.x = m_FramePos.y = 0;
102 
103  Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
104  wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
105 
106  // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
107  // to be called before any other hook for wxCloseEvent, which is necessary.
108  Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
109 }
110 
111 
112 void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
113 {
114  DIALOG_SHIM* dlg = NULL;
115  wxWindowList list = GetChildren();
116 
117  // Quasi modal dialogs create issues (crashes) when closing Kicad.
118  // I am guessing they are delete too late, when deleting main frames.
119  // AFAIK, only these DIALOG_SHIM dialogs create such issues.
120  // The policy is do not allow closing Kicad if a Quasi modal dialog is open.
121  // (Anyway, closing without prompting the user is certainly bad,
122  // because an edit is in preogress)
123  // Therefore, iterate through the child list to find at least
124  // a DIALOG_SHIM opened in quasi modal mode
125  for( wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter )
126  {
127  if( (dlg = dynamic_cast<DIALOG_SHIM*> (*iter) ) != NULL )
128  {
129  if( dlg->IsQuasiModal() )
130  break;
131  else
132  dlg = NULL;
133  }
134  }
135 
136  if( dlg )
137  {
138  // Happens when a quasi modal dialog is currently open.
139  // For example: if the Kicad manager try to close Kicad.
140  wxMessageBox( _(
141  "The program cannot be closed\n"
142  "A quasi-modal dialog window is currently open, please close it first." ) );
143  event.Veto();
144  return;
145  }
146 
147  wxConfigBase* cfg = config();
148 
149  if( cfg )
150  SaveSettings( cfg ); // virtual, wxFrame specific
151 
152  event.Skip(); // we did not "handle" the event, only eavesdropped on it.
153 }
154 
155 
157 {
158  delete m_autoSaveTimer;
159 
160  // This is needed for OSX: avoids further OnDraw processing after this
161  // destructor and before the native window is destroyed
162  this->Freeze();
163 }
164 
165 
166 bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
167 {
168  if( !wxFrame::ProcessEvent( aEvent ) )
169  return false;
170 
171  if( IsShown() && m_hasAutoSave && IsActive() &&
173  {
174  if( !m_autoSaveState )
175  {
176  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
177  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
178  m_autoSaveState = true;
179  }
180  else if( m_autoSaveTimer->IsRunning() )
181  {
182  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
183  m_autoSaveTimer->Stop();
184  m_autoSaveState = false;
185  }
186  }
187 
188  return true;
189 }
190 
191 
192 bool EDA_BASE_FRAME::Enable( bool enable )
193 {
194  // so we can do logging of this state change:
195 
196 #if defined(DEBUG)
197  const char* type_id = typeid( *this ).name();
198  printf( "wxFrame %-28s: %s\n", type_id, enable ? "enabled" : "disabled" );
199 #endif
200 
201  return wxFrame::Enable( enable );
202 }
203 
204 
206 {
207  m_autoSaveInterval = aInterval;
208 
209  if( m_autoSaveTimer->IsRunning() )
210  {
211  if( m_autoSaveInterval > 0 )
212  {
213  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
214  }
215  else
216  {
217  m_autoSaveTimer->Stop();
218  m_autoSaveState = false;
219  }
220  }
221 }
222 
223 
224 void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
225 {
226  if( !doAutoSave() )
227  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
228 }
229 
230 
232 {
233  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
234 }
235 
236 
238 {
239 }
240 
241 
243 {
244  ReCreateMenuBar();
245  GetMenuBar()->Refresh();
246 }
247 
248 
250 {
251  ReCreateMenuBar();
252  GetMenuBar()->Refresh();
253 }
254 
255 
256 void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
257 {
258  int maximized = 0;
259 
260  wxString baseCfgName = ConfigBaseName();
261 
262  wxString text = baseCfgName + entryPosX;
263  aCfg->Read( text, &m_FramePos.x );
264 
265  text = baseCfgName + entryPosY;
266  aCfg->Read( text, &m_FramePos.y );
267 
268  text = baseCfgName + entrySizeX;
269  aCfg->Read( text, &m_FrameSize.x, 600 );
270 
271  text = baseCfgName + entrySizeY;
272  aCfg->Read( text, &m_FrameSize.y, 400 );
273 
274  text = baseCfgName + entryMaximized;
275  aCfg->Read( text, &maximized, 0 );
276 
277  if( m_hasAutoSave )
278  {
279  text = baseCfgName + entryAutoSaveInterval;
280  aCfg->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
281  }
282 
283  // Ensure the window is on a connected display, and is visible.
284  // (at least a corner of the frame must be visible on screen)
285  // Sometimes, if a window was moved on an auxiliary display, and when this
286  // display is no more available, it is not the case.
287  wxRect rect( m_FramePos, m_FrameSize );
288 
289  if( wxDisplay::GetFromPoint( rect.GetTopLeft() ) == wxNOT_FOUND &&
290  wxDisplay::GetFromPoint( rect.GetTopRight() ) == wxNOT_FOUND &&
291  wxDisplay::GetFromPoint( rect.GetBottomLeft() ) == wxNOT_FOUND &&
292  wxDisplay::GetFromPoint( rect.GetBottomRight() ) == wxNOT_FOUND )
293  {
294  m_FramePos = wxDefaultPosition;
295  }
296 
297  // Ensure Window title bar is visible
298 #if defined( __WXMAC__ )
299  // for macOSX, the window must be below system (macOSX) toolbar
300  // Ypos_min = GetMBarHeight(); seems no more exist in new API (subject to change)
301  int Ypos_min = 20;
302 #else
303  int Ypos_min = 0;
304 #endif
305  if( m_FramePos.y < Ypos_min )
306  m_FramePos.y = Ypos_min;
307 
308  if( maximized )
309  Maximize();
310 
311  aCfg->Read( baseCfgName + entryPerspective, &m_perspective );
312  aCfg->Read( baseCfgName + entryMruPath, &m_mruPath );
313 }
314 
315 
316 void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
317 {
318  wxString text;
319 
320  if( IsIconized() )
321  return;
322 
323  wxString baseCfgName = ConfigBaseName();
324 
325  m_FrameSize = GetSize();
326  m_FramePos = GetPosition();
327 
328  text = baseCfgName + wxT( "Pos_x" );
329  aCfg->Write( text, (long) m_FramePos.x );
330 
331  text = baseCfgName + wxT( "Pos_y" );
332  aCfg->Write( text, (long) m_FramePos.y );
333 
334  text = baseCfgName + wxT( "Size_x" );
335  aCfg->Write( text, (long) m_FrameSize.x );
336 
337  text = baseCfgName + wxT( "Size_y" );
338  aCfg->Write( text, (long) m_FrameSize.y );
339 
340  text = baseCfgName + wxT( "Maximized" );
341  aCfg->Write( text, IsMaximized() );
342 
343  if( m_hasAutoSave )
344  {
345  text = baseCfgName + entryAutoSaveInterval;
346  aCfg->Write( text, m_autoSaveInterval );
347  }
348 
349  // Once this is fully implemented, wxAuiManager will be used to maintain
350  // the persistance of the main frame and all it's managed windows and
351  // all of the legacy frame persistence position code can be removed.
352  wxString perspective = m_auimgr.SavePerspective();
353 
354  // printf( "perspective(%s): %s\n",
355  // TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) );
356  aCfg->Write( baseCfgName + entryPerspective, perspective );
357  aCfg->Write( baseCfgName + entryMruPath, m_mruPath );
358 }
359 
360 
361 wxConfigBase* EDA_BASE_FRAME::config()
362 {
363  // KICAD_MANAGER_FRAME overrides this
364  wxConfigBase* ret = Kiface().KifaceSettings();
365  //wxASSERT( ret );
366  return ret;
367 }
368 
369 
371 {
372  return Kiface().KifaceSearch();
373 }
374 
375 
377 {
378  return Kiface().GetHelpFileName();
379 }
380 
381 
382 void EDA_BASE_FRAME::PrintMsg( const wxString& text )
383 {
384  SetStatusText( text );
385 }
386 
387 
388 void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
389  wxFileHistory* aFileHistory )
390 {
391  wxFileHistory* fileHistory = aFileHistory;
392 
393  if( !fileHistory )
394  fileHistory = &Kiface().GetFileHistory();
395 
396  fileHistory->AddFileToHistory( FullFileName );
397 }
398 
399 
400 wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
401  wxFileHistory* aFileHistory )
402 {
403  wxFileHistory* fileHistory = aFileHistory;
404 
405  if( !fileHistory )
406  fileHistory = &Kiface().GetFileHistory();
407 
408  int baseId = fileHistory->GetBaseId();
409 
410  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
411 
412  unsigned i = cmdId - baseId;
413 
414  if( i < fileHistory->GetCount() )
415  {
416  wxString fn = fileHistory->GetHistoryFile( i );
417 
418  if( wxFileName::FileExists( fn ) )
419  return fn;
420  else
421  {
422  wxString msg = wxString::Format(
423  wxT( "file '%s' was not found." ),
424  GetChars( fn ) );
425 
426  wxMessageBox( msg );
427 
428  fileHistory->RemoveFileFromHistory( i );
429  }
430  }
431 
432  return wxEmptyString;
433 }
434 
435 
436 void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
437 {
438  const SEARCH_STACK& search = sys_search();
439 
440  /* We have to get document for beginners,
441  * or the full specific doc
442  * if event id is wxID_INDEX, we want the document for beginners.
443  * else the specific doc file (its name is in Kiface().GetHelpFileName())
444  * The document for beginners is the same for all KiCad utilities
445  */
446  if( event.GetId() == wxID_INDEX )
447  {
448  // List of possible names for Getting Started in KiCad
449  const wxChar* names[2] = {
450  wxT( "getting_started_in_kicad" ),
451  wxT( "Getting_Started_in_KiCad" )
452  };
453 
454  wxString helpFile;
455  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
456  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
457  for( unsigned ii = 0; ii < DIM( names ); ii++ )
458  {
459  helpFile = SearchHelpFileFullPath( search, names[ii] );
460 
461  if( !helpFile.IsEmpty() )
462  break;
463  }
464 
465  if( !helpFile )
466  {
467  wxString msg = wxString::Format( _(
468  "Html or pdf help file \n'%s'\n or\n'%s' could not be found." ), names[0], names[1] );
469  wxMessageBox( msg );
470  }
471  else
472  {
473  GetAssociatedDocument( this, helpFile );
474  }
475 
476  return;
477  }
478 
479  wxString base_name = help_name();
480  wxString helpFile = SearchHelpFileFullPath( search, base_name );
481 
482  if( !helpFile )
483  {
484  wxString msg = wxString::Format( _(
485  "Help file '%s' could not be found." ),
486  GetChars( base_name )
487  );
488  wxMessageBox( msg );
489  }
490  else
491  {
492  GetAssociatedDocument( this, helpFile );
493  }
494 }
495 
496 
497 void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
498 {
499  // Ask for the current editor and instruct GetEditorName() to not show
500  // unless we pass false as argument.
501  wxString editorname = Pgm().GetEditorName( false );
502 
503  // Ask the user to select a new editor, but suggest the current one as the default.
504  editorname = Pgm().AskUserForPreferredEditor( editorname );
505 
506  // If we have a new editor name request it to be copied to m_editor_name and saved
507  // to the preferences file. If the user cancelled the dialog then the previous
508  // value will be retained.
509  if( !editorname.IsEmpty() )
510  Pgm().SetEditorName( editorname );
511 }
512 
513 
514 void EDA_BASE_FRAME::GetKicadContribute( wxCommandEvent& event )
515 {
516  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
517  {
518  wxString msg;
519  msg.Printf( _( "Could not launch the default browser.\n"
520  "For information on how to help the KiCad project, visit %s" ),
522  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
523  }
524 }
525 
526 
527 void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event )
528 {
529  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
530  ShowAboutDialog( this );
531 }
532 
533 
534 bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
535 {
536  wxString msg;
537  wxFileName fn = aFileName;
538 
539  // Check for absence of a file path with a file name. Unfortunately KiCad
540  // uses paths relative to the current project path without the ./ part which
541  // confuses wxFileName. Making the file name path absolute may be less than
542  // elegant but it solves the problem.
543  if( fn.GetPath().IsEmpty() && fn.HasName() )
544  fn.MakeAbsolute();
545 
546  wxCHECK_MSG( fn.IsOk(), false,
547  wxT( "File name object is invalid. Bad programmer!" ) );
548  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
549  wxT( "File name object path <" ) + fn.GetFullPath() +
550  wxT( "> is not set. Bad programmer!" ) );
551 
552  if( fn.IsDir() && !fn.IsDirWritable() )
553  {
554  msg.Printf( _( "You do not have write permissions to folder <%s>." ),
555  GetChars( fn.GetPath() ) );
556  }
557  else if( !fn.FileExists() && !fn.IsDirWritable() )
558  {
559  msg.Printf( _( "You do not have write permissions to save file <%s> to folder <%s>." ),
560  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
561  }
562  else if( fn.FileExists() && !fn.IsFileWritable() )
563  {
564  msg.Printf( _( "You do not have write permissions to save file <%s>." ),
565  GetChars( fn.GetFullPath() ) );
566  }
567 
568  if( !msg.IsEmpty() )
569  {
570  wxMessageBox( msg );
571  return false;
572  }
573 
574  return true;
575 }
576 
577 
578 void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
579  const wxString& aBackupFileExtension )
580 {
581  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
582  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
583 
584  wxFileName autoSaveFileName = aFileName;
585 
586  // Check for auto save file.
587  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
588 
589  wxLogTrace( traceAutoSave,
590  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
591 
592  if( !autoSaveFileName.FileExists() )
593  return;
594 
595  wxString msg = wxString::Format( _(
596  "Well this is potentially embarrassing!\n"
597  "It appears that the last time you were editing the file\n"
598  "'%s'\n"
599  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
600  GetChars( aFileName.GetFullName() )
601  );
602 
603  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
604 
605  // Make a backup of the current file, delete the file, and rename the auto save file to
606  // the file name.
607  if( response == wxYES )
608  {
609  // Get the backup file name.
610  wxFileName backupFileName = aFileName;
611  backupFileName.SetExt( aBackupFileExtension );
612 
613  // If an old backup file exists, delete it. If an old copy of the file exists, rename
614  // it to the backup file name
615  if( aFileName.FileExists() )
616  {
617  // Remove the old file backup file.
618  if( backupFileName.FileExists() )
619  wxRemoveFile( backupFileName.GetFullPath() );
620 
621  // Rename the old file to the backup file name.
622  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
623  {
624  msg.Printf( _( "Could not create backup file <%s>" ),
625  GetChars( backupFileName.GetFullPath() ) );
626  wxMessageBox( msg );
627  }
628  }
629 
630  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
631  {
632  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
633  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
634  }
635  }
636  else
637  {
638  wxLogTrace( traceAutoSave,
639  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
640 
641  // Remove the auto save file when using the previous file as is.
642  wxRemoveFile( autoSaveFileName.GetFullPath() );
643  }
644 }
645 
646 
648 {
649  if( evt_type != 0 )
650  {
651  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
652  evt.SetEventObject( this );
653  evt.SetId( evt_type );
654  wxPostEvent( this, evt );
655  return true;
656  }
657 
658  return false;
659 }
660 
661 
662 void EDA_BASE_FRAME::OnChangeIconsOptions( wxCommandEvent& event )
663 {
664  if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS )
665  {
666  Pgm().SetUseIconsInMenus( event.IsChecked() );
667  }
668 
669  ReCreateMenuBar();
670 }
671 
672 
673 void EDA_BASE_FRAME::AddMenuIconsOptions( wxMenu* MasterMenu )
674 {
675  wxMenu* menu = NULL;
676  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
677 
678  if( item ) // This menu exists, do nothing
679  return;
680 
681  menu = new wxMenu;
682 
683  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
684  _( "Icons in Menus" ), wxEmptyString,
685  wxITEM_CHECK ) );
686  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
687 
688  AddMenuItem( MasterMenu, menu,
690  _( "Icons Options" ),
691  _( "Select show icons in menus and icons sizes" ),
692  KiBitmap( icon_xpm ) );
693 }
void CheckForAutoSaveFile(const wxFileName &aFileName, const wxString &aBackupFileExtension)
Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropri...
Definition: basicframe.cpp:578
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:150
void PrintMsg(const wxString &text)
Definition: basicframe.cpp:382
void SetUseIconsInMenus(bool aUseIcons)
True to use menu icons.
Definition: pgm_base.h:327
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:330
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:160
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
Definition: basicframe.cpp:231
virtual void ShowChangedIcons()
Function ShowChangedIcons redraws items menus after a icon was changed option.
Definition: basicframe.cpp:249
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
This file is part of the common library.
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void windowClosing(wxCloseEvent &event)
Function windowClosing (with its unexpected name so it does not collide with the real OnWindowClose()...
Definition: basicframe.cpp:112
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: basicframe.cpp:316
#define URL_GET_INVOLVED
Definition: basicframe.cpp:51
void onAutoSaveTimer(wxTimerEvent &aEvent)
Function onAutoSaveTimer handles the auto save timer event.
Definition: basicframe.cpp:224
wxString ConfigBaseName()
Function ConfigBaseName.
Definition: wxstruct.h:260
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:86
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:361
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: basicframe.cpp:662
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:60
wxAuiManager m_auimgr
Definition: wxstruct.h:144
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:534
VTBL_ENTRY const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Shows a dialog that instructs the user to select a new preferred editor.
Definition: pgm_base.cpp:375
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:156
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:388
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
static const wxString entryPosX
X position of frame, in pixels (suffix)
Definition: basicframe.cpp:68
wxString m_perspective
wxAuiManager perspective.
Definition: wxstruct.h:158
void GetKicadHelp(wxCommandEvent &event)
Definition: basicframe.cpp:436
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:127
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
virtual const SEARCH_STACK & sys_search()
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
Definition: basicframe.cpp:370
Base window classes and related definitions.
bool Enable(bool enable) override
Definition: basicframe.cpp:192
FRAME_T m_Ident
Id Type (pcb, schematic, library..)
Definition: wxstruct.h:133
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
Definition: basicframe.cpp:256
virtual void OnSelectPreferredEditor(wxCommandEvent &event)
Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit o...
Definition: basicframe.cpp:497
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:123
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSStack, const wxString &aBaseName)
Function SearchHelpFileFullPath returns the help file's full path.
void GetKicadAbout(wxCommandEvent &event)
Definition: basicframe.cpp:527
static const wxString entryPerspective
Configuration file entry for wxAuiManger perspective.
Definition: basicframe.cpp:62
bool IsQuasiModal()
Definition: dialog_shim.h:93
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
wxPoint m_FramePos
Definition: wxstruct.h:134
bool PostCommandMenuEvent(int evt_type)
Function PostCommandMenuEvent.
Definition: basicframe.cpp:647
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:140
const wxString & GetHelpFileName() const
Function GetHelpFileName returns just the basename portion of the current help file.
Definition: kiface_i.h:121
void SetAutoSaveInterval(int aInterval)
Definition: basicframe.cpp:205
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
Definition: basicframe.cpp:673
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
static const wxString entrySizeX
Width of frame, in pixels (suffix)
Definition: basicframe.cpp:70
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void GetKicadContribute(wxCommandEvent &event)
Definition: basicframe.cpp:514
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
static const wxString entrySizeY
Height of frame, in pixels (suffix)
Definition: basicframe.cpp:69
wxString GetFileFromHistory(int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
Function GetFileFromHistory fetches the file name from the file history list.
Definition: basicframe.cpp:400
static const wxString entryPosY
Y position of frame, in pixels (suffix)
Definition: basicframe.cpp:67
virtual wxString help_name()
Definition: basicframe.cpp:376
static const wxString entryAutoSaveInterval
Configuration file entry name for auto save interval.
Definition: basicframe.cpp:59
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:338
static const wxString entryMaximized
Nonzero iff frame is maximized (suffix)
Definition: basicframe.cpp:71
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:173
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:147
wxSize m_FrameSize
Definition: wxstruct.h:135
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
Definition: wxstruct.h:71
static const wxString entryMruPath
Configuration file entry for most recently used path.
Definition: basicframe.cpp:65
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:153
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Definition: basicframe.cpp:242
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
Definition: basicframe.cpp:166
#define DEFAULT_AUTO_SAVE_INTERVAL
The default auto save interval is 10 minutes.
Definition: basicframe.cpp:49
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
const wxChar traceAutoSave[]
Flag to enable auto save feature debug tracing.
Definition: basicframe.cpp:53
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
Definition: basicframe.cpp:74