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-2018 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 #include <wx/display.h>
35 
36 #include <dialog_shim.h>
37 #include <eda_doc.h>
38 #include <id.h>
39 #include <kiface_i.h>
40 #include <pgm_base.h>
41 #include <trace_helpers.h>
42 #include <panel_hotkeys_editor.h>
44 #include <widgets/paged_dialog.h>
45 
46 
48 #define DEFAULT_AUTO_SAVE_INTERVAL 600
49 
50 #define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/"
51 
54 
56 static const wxString entryAutoSaveInterval = "AutoSaveInterval";
57 
59 static const wxString entryPerspective = "Perspective";
60 
62 static const wxString entryMruPath = "MostRecentlyUsedPath";
63 
64 static const wxString entryPosY = "Pos_y";
65 static const wxString entryPosX = "Pos_x";
66 static const wxString entrySizeY = "Size_y";
67 static const wxString entrySizeX = "Size_x";
68 static const wxString entryMaximized = "Maximized";
69 
71 EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
72  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
73  long aStyle, const wxString& aFrameName ) :
74  wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName )
75 {
76  m_Ident = aFrameType;
77  m_mainToolBar = NULL;
78  m_hasAutoSave = false;
79  m_autoSaveState = false;
80  m_autoSaveInterval = -1;
81  m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
82  m_mruPath = wxStandardPaths::Get().GetDocumentsDir();
83 
84  // Gives a reasonable minimal size to the frame:
85  const int minsize_x = 500;
86  const int minsize_y = 400;
87  SetSizeHints( minsize_x, minsize_y, -1, -1, -1, -1 );
88 
89  // Store dimensions of the user area of the main window.
90  GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
91 
92  Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
93  wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
94 
95  // hook wxEVT_CLOSE_WINDOW so we can call SaveSettings(). This function seems
96  // to be called before any other hook for wxCloseEvent, which is necessary.
97  Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_BASE_FRAME::windowClosing ) );
98 }
99 
100 
102 {
103  for( auto& iter : GetChildren() )
104  {
105  DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
106  if( dlg && dlg->IsQuasiModal() )
107  return dlg;
108  }
109 
110  // FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
111  // so we have to look for it separately.
112  if( m_Ident == FRAME_SCH )
113  {
114  wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
115  if( cvpcb )
116  return cvpcb;
117  }
118 
119  return nullptr;
120 }
121 
122 
123 void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
124 {
125  // Don't allow closing when a quasi-modal is open.
126  wxWindow* quasiModal = findQuasiModalDialog();
127 
128  if( quasiModal )
129  {
130  // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
131  // when they have no idea what those are.
132  quasiModal->Raise();
133  wxBell();
134 
135  event.Veto();
136  return;
137  }
138 
139  wxConfigBase* cfg = config();
140 
141  if( cfg )
142  SaveSettings( cfg ); // virtual, wxFrame specific
143 
144  event.Skip(); // we did not "handle" the event, only eavesdropped on it.
145 }
146 
147 
149 {
150  delete m_autoSaveTimer;
151 
152  // This is needed for OSX: avoids further OnDraw processing after this
153  // destructor and before the native window is destroyed
154  this->Freeze();
155 }
156 
157 
158 bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
159 {
160 #ifdef __WXMAC__
161  // Apple in its infinite wisdom will raise a disabled window before even passing
162  // us the event, so we have no way to stop it. Instead, we have to catch an
163  // improperly ordered disabled window and quasi-modal dialog here and reorder
164  // them.
165  if( !IsEnabled() && IsActive() )
166  {
167  wxWindow* dlg = findQuasiModalDialog();
168  if( dlg )
169  dlg->Raise();
170  }
171 #endif
172 
173  if( !wxFrame::ProcessEvent( aEvent ) )
174  return false;
175 
176  if( IsShown() && m_hasAutoSave && IsActive() &&
178  {
179  if( !m_autoSaveState )
180  {
181  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
182  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
183  m_autoSaveState = true;
184  }
185  else if( m_autoSaveTimer->IsRunning() )
186  {
187  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
188  m_autoSaveTimer->Stop();
189  m_autoSaveState = false;
190  }
191  }
192 
193  return true;
194 }
195 
196 
198 {
199  m_autoSaveInterval = aInterval;
200 
201  if( m_autoSaveTimer->IsRunning() )
202  {
203  if( m_autoSaveInterval > 0 )
204  {
205  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
206  }
207  else
208  {
209  m_autoSaveTimer->Stop();
210  m_autoSaveState = false;
211  }
212  }
213 }
214 
215 
216 void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
217 {
218  if( !doAutoSave() )
219  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
220 }
221 
222 
224 {
225  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
226 }
227 
228 
230 {
231 }
232 
233 
235 {
236  if( GetMenuBar() )
237  {
238  ReCreateMenuBar();
239  GetMenuBar()->Refresh();
240  }
241 }
242 
243 
245 {
246  if( GetMenuBar() )
247  {
248  // For icons in menus, icon scaling & hotkeys
249  ReCreateMenuBar();
250  GetMenuBar()->Refresh();
251  }
252 }
253 
254 
255 void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
256 {
257  int maximized = 0;
258 
259  wxString baseCfgName = ConfigBaseName();
260 
261  wxString text = baseCfgName + entryPosX;
262  aCfg->Read( text, &m_FramePos.x, m_FramePos.x );
263 
264  text = baseCfgName + entryPosY;
265  aCfg->Read( text, &m_FramePos.y, m_FramePos.y );
266 
267  text = baseCfgName + entrySizeX;
268  aCfg->Read( text, &m_FrameSize.x, m_FrameSize.x );
269 
270  text = baseCfgName + entrySizeY;
271  aCfg->Read( text, &m_FrameSize.y, m_FrameSize.y );
272 
273  text = baseCfgName + entryMaximized;
274  aCfg->Read( text, &maximized, 0 );
275 
276  if( m_hasAutoSave )
277  {
278  text = baseCfgName + entryAutoSaveInterval;
279  aCfg->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
280  }
281 
282  // Ensure the window is on a connected display, and is visible.
283  // (at least a corner of the frame must be visible on screen)
284  // Sometimes, if a window was moved on an auxiliary display, and when this
285  // display is no more available, it is not the case.
286  wxRect rect( m_FramePos, m_FrameSize );
287 
288  if( wxDisplay::GetFromPoint( rect.GetTopLeft() ) == wxNOT_FOUND &&
289  wxDisplay::GetFromPoint( rect.GetTopRight() ) == wxNOT_FOUND &&
290  wxDisplay::GetFromPoint( rect.GetBottomLeft() ) == wxNOT_FOUND &&
291  wxDisplay::GetFromPoint( rect.GetBottomRight() ) == wxNOT_FOUND )
292  {
293  m_FramePos = wxDefaultPosition;
294  }
295 
296  // Ensure Window title bar is visible
297 #if defined( __WXMAC__ )
298  // for macOSX, the window must be below system (macOSX) toolbar
299  // Ypos_min = GetMBarHeight(); seems no more exist in new API (subject to change)
300  int Ypos_min = 20;
301 #else
302  int Ypos_min = 0;
303 #endif
304  if( m_FramePos.y < Ypos_min )
305  m_FramePos.y = Ypos_min;
306 
307  if( maximized )
308  Maximize();
309 
310  aCfg->Read( baseCfgName + entryPerspective, &m_perspective );
311  aCfg->Read( baseCfgName + entryMruPath, &m_mruPath );
312 }
313 
314 
315 void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
316 {
317  wxString text;
318 
319  if( IsIconized() )
320  return;
321 
322  wxString baseCfgName = ConfigBaseName();
323 
324  m_FrameSize = GetSize();
325  m_FramePos = GetPosition();
326 
327  text = baseCfgName + wxT( "Pos_x" );
328  aCfg->Write( text, (long) m_FramePos.x );
329 
330  text = baseCfgName + wxT( "Pos_y" );
331  aCfg->Write( text, (long) m_FramePos.y );
332 
333  text = baseCfgName + wxT( "Size_x" );
334  aCfg->Write( text, (long) m_FrameSize.x );
335 
336  text = baseCfgName + wxT( "Size_y" );
337  aCfg->Write( text, (long) m_FrameSize.y );
338 
339  text = baseCfgName + wxT( "Maximized" );
340  aCfg->Write( text, IsMaximized() );
341 
342  if( m_hasAutoSave )
343  {
344  text = baseCfgName + entryAutoSaveInterval;
345  aCfg->Write( text, m_autoSaveInterval );
346  }
347 
348  // Once this is fully implemented, wxAuiManager will be used to maintain
349  // the persistance of the main frame and all it's managed windows and
350  // all of the legacy frame persistence position code can be removed.
351  wxString perspective = m_auimgr.SavePerspective();
352 
353  // printf( "perspective(%s): %s\n",
354  // TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) );
355  aCfg->Write( baseCfgName + entryPerspective, perspective );
356  aCfg->Write( baseCfgName + entryMruPath, m_mruPath );
357 }
358 
359 
360 wxConfigBase* EDA_BASE_FRAME::config()
361 {
362  // KICAD_MANAGER_FRAME overrides this
363  wxConfigBase* ret = Kiface().KifaceSettings();
364  //wxASSERT( ret );
365  return ret;
366 }
367 
368 
370 {
371  return Kiface().KifaceSearch();
372 }
373 
374 
376 {
377  return Kiface().GetHelpFileName();
378 }
379 
380 
381 void EDA_BASE_FRAME::PrintMsg( const wxString& text )
382 {
383  SetStatusText( text );
384 }
385 
386 
387 void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
388  wxFileHistory* aFileHistory )
389 {
390  wxFileHistory* fileHistory = aFileHistory;
391 
392  if( !fileHistory )
393  fileHistory = &Kiface().GetFileHistory();
394 
395  fileHistory->AddFileToHistory( FullFileName );
396 }
397 
398 
399 wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
400  wxFileHistory* aFileHistory )
401 {
402  wxFileHistory* fileHistory = aFileHistory;
403 
404  if( !fileHistory )
405  fileHistory = &Kiface().GetFileHistory();
406 
407  int baseId = fileHistory->GetBaseId();
408 
409  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
410 
411  unsigned i = cmdId - baseId;
412 
413  if( i < fileHistory->GetCount() )
414  {
415  wxString fn = fileHistory->GetHistoryFile( i );
416 
417  if( wxFileName::FileExists( fn ) )
418  return fn;
419  else
420  {
421  wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
422  wxMessageBox( msg );
423 
424  fileHistory->RemoveFileFromHistory( i );
425  }
426  }
427 
428  return wxEmptyString;
429 }
430 
431 
432 void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
433 {
434  const SEARCH_STACK& search = sys_search();
435 
436  /* We have to get document for beginners,
437  * or the full specific doc
438  * if event id is wxID_INDEX, we want the document for beginners.
439  * else the specific doc file (its name is in Kiface().GetHelpFileName())
440  * The document for beginners is the same for all KiCad utilities
441  */
442  if( event.GetId() == wxID_INDEX )
443  {
444  // List of possible names for Getting Started in KiCad
445  const wxChar* names[2] = {
446  wxT( "getting_started_in_kicad" ),
447  wxT( "Getting_Started_in_KiCad" )
448  };
449 
450  wxString helpFile;
451  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
452  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
453  for( unsigned ii = 0; ii < DIM( names ); ii++ )
454  {
455  helpFile = SearchHelpFileFullPath( search, names[ii] );
456 
457  if( !helpFile.IsEmpty() )
458  break;
459  }
460 
461  if( !helpFile )
462  {
463  wxString msg = wxString::Format( _(
464  "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
465  wxMessageBox( msg );
466  }
467  else
468  {
469  GetAssociatedDocument( this, helpFile );
470  }
471 
472  return;
473  }
474 
475  wxString base_name = help_name();
476  wxString helpFile = SearchHelpFileFullPath( search, base_name );
477 
478  if( !helpFile )
479  {
480  wxString msg = wxString::Format( _(
481  "Help file \"%s\" could not be found." ),
482  GetChars( base_name )
483  );
484  wxMessageBox( msg );
485  }
486  else
487  {
488  GetAssociatedDocument( this, helpFile );
489  }
490 }
491 
492 
493 void EDA_BASE_FRAME::GetKicadContribute( wxCommandEvent& event )
494 {
495  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
496  {
497  wxString msg;
498  msg.Printf( _( "Could not launch the default browser.\n"
499  "For information on how to help the KiCad project, visit %s" ),
501  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
502  }
503 }
504 
505 
506 void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event )
507 {
508  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
509  ShowAboutDialog( this );
510 }
511 
512 
514  const wxString& aHotkeysNickname )
515 {
516  PAGED_DIALOG dlg( this, _( "Preferences" ) );
517  wxTreebook* book = dlg.GetTreebook();
518 
519  book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
520  book->AddPage( new PANEL_HOTKEYS_EDITOR( this, book, false,
521  aHotkeys, aShowHotkeys, aHotkeysNickname ), _( "Hotkeys" ) );
522 
523  for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
524  {
525  KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
526 
527  if( frame )
528  frame->InstallPreferences( &dlg );
529  }
530 
531  if( dlg.ShowModal() == wxID_OK )
532  {
534  return true;
535  }
536 
537  return false;
538 }
539 
540 
541 bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
542 {
543  wxString msg;
544  wxFileName fn = aFileName;
545 
546  // Check for absence of a file path with a file name. Unfortunately KiCad
547  // uses paths relative to the current project path without the ./ part which
548  // confuses wxFileName. Making the file name path absolute may be less than
549  // elegant but it solves the problem.
550  if( fn.GetPath().IsEmpty() && fn.HasName() )
551  fn.MakeAbsolute();
552 
553  wxCHECK_MSG( fn.IsOk(), false,
554  wxT( "File name object is invalid. Bad programmer!" ) );
555  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
556  wxT( "File name object path <" ) + fn.GetFullPath() +
557  wxT( "> is not set. Bad programmer!" ) );
558 
559  if( fn.IsDir() && !fn.IsDirWritable() )
560  {
561  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
562  GetChars( fn.GetPath() ) );
563  }
564  else if( !fn.FileExists() && !fn.IsDirWritable() )
565  {
566  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
567  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
568  }
569  else if( fn.FileExists() && !fn.IsFileWritable() )
570  {
571  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
572  GetChars( fn.GetFullPath() ) );
573  }
574 
575  if( !msg.IsEmpty() )
576  {
577  wxMessageBox( msg );
578  return false;
579  }
580 
581  return true;
582 }
583 
584 
585 void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
586  const wxString& aBackupFileExtension )
587 {
588  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
589  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
590 
591  wxFileName autoSaveFileName = aFileName;
592 
593  // Check for auto save file.
594  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
595 
596  wxLogTrace( traceAutoSave,
597  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
598 
599  if( !autoSaveFileName.FileExists() )
600  return;
601 
602  wxString msg = wxString::Format( _(
603  "Well this is potentially embarrassing!\n"
604  "It appears that the last time you were editing the file\n"
605  "\"%s\"\n"
606  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
607  GetChars( aFileName.GetFullName() )
608  );
609 
610  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
611 
612  // Make a backup of the current file, delete the file, and rename the auto save file to
613  // the file name.
614  if( response == wxYES )
615  {
616  // Get the backup file name.
617  wxFileName backupFileName = aFileName;
618  backupFileName.SetExt( aBackupFileExtension );
619 
620  // If an old backup file exists, delete it. If an old copy of the file exists, rename
621  // it to the backup file name
622  if( aFileName.FileExists() )
623  {
624  // Remove the old file backup file.
625  if( backupFileName.FileExists() )
626  wxRemoveFile( backupFileName.GetFullPath() );
627 
628  // Rename the old file to the backup file name.
629  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
630  {
631  msg.Printf( _( "Could not create backup file \"%s\"" ),
632  GetChars( backupFileName.GetFullPath() ) );
633  wxMessageBox( msg );
634  }
635  }
636 
637  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
638  {
639  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
640  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
641  }
642  }
643  else
644  {
645  wxLogTrace( traceAutoSave,
646  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
647 
648  // Remove the auto save file when using the previous file as is.
649  wxRemoveFile( autoSaveFileName.GetFullPath() );
650  }
651 }
652 
653 
655 {
656  if( evt_type != 0 )
657  {
658  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
659  evt.SetEventObject( this );
660  evt.SetId( evt_type );
661  wxPostEvent( this, evt );
662  return true;
663  }
664 
665  return false;
666 }
667 
void CheckForAutoSaveFile(const wxFileName &aFileName, const wxString &aBackupFileExtension)
Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropri...
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool m_autoSaveState
Flag to indicate the last auto save state.
void PrintMsg(const wxString &text)
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:94
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSearchStack, const wxString &aBaseName)
Return the help file&#39;s full path.
wxString m_mruPath
Most recently used path.
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
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()...
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
#define URL_GET_INVOLVED
void onAutoSaveTimer(wxTimerEvent &aEvent)
Function onAutoSaveTimer handles the auto save timer event.
wxString ConfigBaseName()
Function ConfigBaseName.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
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:82
wxAuiManager m_auimgr
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
static const wxString entryPosX
X position of frame, in pixels (suffix)
wxString m_perspective
wxAuiManager perspective.
void GetKicadHelp(wxCommandEvent &event)
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
SEARCH_STACK & KifaceSearch()
Only for DSO specific &#39;non-library&#39; files.
Definition: kiface_i.h:127
wxWindow * findQuasiModalDialog()
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
VTBL_ENTRY void CommonSettingsChanged()
Function CommonSettingsChanged Calls CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:431
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
virtual const SEARCH_STACK & sys_search()
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
FRAME_T m_Ident
Id Type (pcb, schematic, library..)
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
void GetKicadAbout(wxCommandEvent &event)
static const wxString entryPerspective
Configuration file entry for wxAuiManger perspective.
bool IsQuasiModal()
Definition: dialog_shim.h:124
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
wxLogTrace helper definitions.
#define DEFAULT_AUTO_SAVE_INTERVAL
The default auto save interval is 10 minutes.
bool PostCommandMenuEvent(int evt_type)
Function PostCommandMenuEvent.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
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)
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
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)
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)
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:123
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
size_t i
Definition: json11.cpp:597
static const wxString entrySizeY
Height of frame, in pixels (suffix)
wxString GetFileFromHistory(int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
Function GetFileFromHistory fetches the file name from the file history list.
static const wxString entryPosY
Y position of frame, in pixels (suffix)
virtual wxString help_name()
static const wxString entryAutoSaveInterval
Configuration file entry name for auto save interval.
virtual void InstallPreferences(PAGED_DIALOG *aParent)
Function InstallPreferences allows a Frame to load its preference panels (if any) into the preference...
virtual void CommonSettingsChanged()
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
static const wxString entryMaximized
Nonzero iff frame is maximized (suffix)
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
bool ShowPreferences(EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
static const wxString entryMruPath
Configuration file entry for most recently used path.
int m_autoSaveInterval
The auto save interval time in seconds.
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)