KiCad PCB EDA Suite
kicad_manager_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 CERN (www.cern.ch)
6  * Copyright (C) 2004-2021 KiCad Developers, see change_log.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 "kicad_id.h"
27 #include "pgm_kicad.h"
28 #include "project_tree_pane.h"
29 #include <bitmaps.h>
30 #include <build_version.h>
32 #include <eda_base_frame.h>
33 #include <filehistory.h>
34 #include <kiplatform/app.h>
35 #include <kiway.h>
36 #include <kiway_express.h>
37 #include <launch_ext.h>
38 #include <panel_hotkeys_editor.h>
39 #include <reporter.h>
41 #include <sch_file_versions.h>
43 #include <tool/action_manager.h>
44 #include <tool/action_toolbar.h>
45 #include <tool/common_control.h>
46 #include <tool/tool_dispatcher.h>
47 #include <tool/tool_manager.h>
52 #include <wx/ffile.h>
53 #include <wx/filedlg.h>
54 #include <atomic>
55 
56 
57 #include <../pcbnew/plugins/kicad/kicad_plugin.h> // for SEXPR_BOARD_FILE_VERSION def
58 
59 
60 #ifdef __WXMAC__
61 #include <MacTypes.h>
62 #include <ApplicationServices/ApplicationServices.h>
63 #endif
64 
65 #include "kicad_manager_frame.h"
66 #include "kicad_settings.h"
67 
68 
69 #define SEP() wxFileName::GetPathSeparator()
70 
71 
72 // Menubar and toolbar event table
73 BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
74  // Window events
75  EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
76  EVT_IDLE( KICAD_MANAGER_FRAME::OnIdle )
77 
78  // Menu events
79  EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
86 
87  // Range menu events
89  KICAD_MANAGER_FRAME::language_change )
90 
92  EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
93 
94  // Special functions
95  EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
96 END_EVENT_TABLE()
97 
98 
99 KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
100  const wxPoint& pos, const wxSize& size ) :
101  EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
103  m_leftWin( nullptr ),
104  m_launcher( nullptr ),
105  m_mainToolBar( nullptr )
106 {
107  m_active_project = false;
108  m_leftWinWidth = 250; // Default value
109  m_aboutTitle = "KiCad";
110 
111  // Create the status line (bottom of the frame)
112  static const int dims[2] = { -1, -1 };
113 
114  CreateStatusBar( 2, wxSTB_SIZEGRIP | wxSTB_SHOW_TIPS | wxSTB_ELLIPSIZE_MIDDLE |
115  wxFULL_REPAINT_ON_RESIZE );
116  SetStatusWidths( 2, dims );
117 
118  // Give an icon
119  wxIcon icon;
120  wxIconBundle icon_bundle;
121 
122  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
123  icon_bundle.AddIcon( icon );
124  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
125  icon_bundle.AddIcon( icon );
126  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
127  icon_bundle.AddIcon( icon );
128 
129  SetIcons( icon_bundle );
130 
131  // Load the settings
132  LoadSettings( config() );
133 
134  // Left window: is the box which display tree project
135  m_leftWin = new PROJECT_TREE_PANE( this );
136 
137  setupTools();
138  setupUIConditions();
139 
140  m_launcher = new PANEL_KICAD_LAUNCHER( this );
141 
142  RecreateBaseHToolbar();
143  ReCreateMenuBar();
144 
145  m_auimgr.SetManagedWindow( this );
146  m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
147 
148  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Left()
149  .Layer( 2 ) );
150 
151  // BestSize() does not always set the actual pane size of m_leftWin to the required value.
152  // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
153  // (Well, BestSize() sets the best size... not the window size)
154  // A trick is to use MinSize() to set the required pane width,
155  // and after give a reasonable MinSize value
156  m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
157  .Caption( _( "Project Files" ) ).PaneBorder( true )
158  .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
159 
160  m_auimgr.AddPane( m_launcher, EDA_PANE().Canvas().Name( "Launcher" ).Center()
161  .Caption( _( "Editors" ) ).PaneBorder( false )
162  .MinSize( m_launcher->GetBestSize() ) );
163 
164  m_auimgr.Update();
165 
166  // Now the actual m_leftWin size is set, give it a reasonable min width
167  m_auimgr.GetPane( m_leftWin ).MinSize( 250, -1 );
168 
169  wxSizer* mainSizer = GetSizer();
170 
171  // Only fit the initial window size the first time KiCad is run.
172  if( mainSizer && config()->m_Window.state.size_x == 0 && config()->m_Window.state.size_y == 0 )
173  mainSizer->Fit( this );
174 
175  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
176 
177  // Do not let the messages window have initial focus
178  m_leftWin->SetFocus();
179 
180  // Ensure the window is on top
181  Raise();
182 }
183 
184 
186 {
187  // Shutdown all running tools
188  if( m_toolManager )
190 
191  delete m_actions;
192  delete m_toolManager;
193  delete m_toolDispatcher;
194 
195  m_auimgr.UnInit();
196 }
197 
198 
200 {
201  // Create the manager
203  m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
205 
207 
208  // Attach the events to the tool dispatcher
210  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
211 
212  // Register tools
216 }
217 
218 
220 {
222 
224 
225  wxASSERT( manager );
226 
227  auto activeProject =
228  [this] ( const SELECTION& )
229  {
230  return m_active_project;
231  };
232 
233  ACTION_CONDITIONS activeProjectCond;
234  activeProjectCond.Enable( activeProject );
235 
236  manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
237  manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
238 
239  // TODO: Switch this to an action
240  RegisterUIUpdateHandler( ID_SAVE_AND_ZIP_FILES, activeProjectCond );
241 }
242 
243 
245 {
246  return m_leftWin;
247 }
248 
249 
251 {
253  wxASSERT( ret );
254  return ret;
255 }
256 
257 
259 {
260  KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
261  wxASSERT( ret );
262  return ret;
263 }
264 
265 
267 {
268  return Pgm().GetSettingsManager().IsProjectOpen() ? Prj().GetProjectFullName() :
269  wxString( wxEmptyString );
270 }
271 
272 
274 {
275  wxFileName fn( GetProjectFileName() );
276 
277  fn.SetExt( KiCadSchematicFileExtension );
278  return fn.GetFullPath();
279 }
280 
281 
283 {
284  wxFileName fn( GetProjectFileName() );
285 
286  fn.SetExt( LegacySchematicFileExtension );
287  return fn.GetFullPath();
288 }
289 
290 
292 {
293  wxFileName fn( GetProjectFileName() );
294 
295  fn.SetExt( PcbFileExtension );
296  return fn.GetFullPath();
297 }
298 
299 
301 {
302  wxFileName fn( GetProjectFileName() );
303 
304  fn.SetExt( LegacyPcbFileExtension );
305  return fn.GetFullPath();
306 }
307 
308 
310 {
312 }
313 
314 
316 {
317  return PgmTop().SysSearch();
318 }
319 
320 
322 {
323  return PgmTop().GetHelpFileName();
324 }
325 
326 
327 void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
328 {
329  if( m_auimgr.GetManagedWindow() )
330  m_auimgr.Update();
331 
332  event.Skip();
333 }
334 
335 
336 bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
337 {
338  KICAD_SETTINGS* settings = kicadSettings();
340 
341  // CloseProject will recursively ask all the open editors if they need to save changes.
342  // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
343  if( CloseProject( true ) )
344  {
345  return true;
346  }
347  else
348  {
349  if( aEvent.CanVeto() )
350  aEvent.Veto();
351 
352  return false;
353  }
354 }
355 
356 
358 {
359 #ifdef _WINDOWS_
360  // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
361  // if a editor frame (schematic, library, board editor or fp editor) is open and has
362  // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
363  // conditions between OnCloseWindow() code.
364  // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
365  // execution of the first call (only one call is right).
366  // Note also if there is no change made in editors, this behavior does not happen.
367  static std::atomic<unsigned int> lock_close_event( 0 );
368 
369  if( ++lock_close_event > 1 ) // Skip extra calls
370  {
371  return;
372  }
373 #endif
374 
375  m_leftWin->Show( false );
376 
377  Destroy();
378 
379 #ifdef _WINDOWS_
380  lock_close_event = 0; // Reenable event management
381 #endif
382 }
383 
384 
385 void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
386 {
387  Close( true );
388 }
389 
390 
392 {
393  if( !Kiway().PlayersClose( false ) )
394  return false;
395 
396  // Save the project file for the currently loaded project.
397  if( m_active_project )
398  {
399  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
400 
402 
403  if( aSave )
404  mgr.SaveProject();
405 
406  m_active_project = false;
407  mgr.UnloadProject( &Prj() );
408  }
409 
410  SetStatusText( "" );
411 
413 
414  return true;
415 }
416 
417 
418 void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
419 {
420  // The project file should be valid by the time we get here or something has gone wrong.
421  if( !aProjectFileName.Exists() )
422  return;
423 
424  // Any open KIFACE's must be closed if they are not part of the new project.
425  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
426  // User is prompted here to close those KIWAY_PLAYERs:
427  if( !CloseProject( true ) )
428  return;
429 
430  m_active_project = true;
431 
432  Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
433 
434  LoadWindowState( aProjectFileName.GetFullName() );
435 
436  if( aProjectFileName.IsDirWritable() )
437  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
438 
439  UpdateFileHistory( Prj().GetProjectFullName() );
440 
442 
443  // Rebuild the list of watched paths.
444  // however this is possible only when the main loop event handler is running,
445  // so we use it to run the rebuild function.
446  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
447 
448  wxPostEvent( this, cmd );
449 
450  PrintPrjInfo();
451 
452  KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
453  m_openSavedWindows = true;
454 }
455 
456 
457 void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName,
458  bool aCreateStubFiles )
459 {
460  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
461  "Project folder must exist and be writable to create a new project." );
462 
463  // If the project is legacy, convert it
464  if( !aProjectFileName.FileExists() )
465  {
466  wxFileName legacyPro( aProjectFileName );
467  legacyPro.SetExt( LegacyProjectFileExtension );
468 
469  if( legacyPro.FileExists() )
470  {
471  GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
473 
474  wxRemoveFile( legacyPro.GetFullPath() );
475  }
476  else
477  {
478  // Copy template project file from template folder.
479  wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
480 
481  wxFileName destFileName( aProjectFileName );
482  destFileName.SetExt( ProjectFileExtension );
483 
484  // Create a minimal project file if the template project file could not be copied
485  if( !wxFileName::FileExists( srcFileName )
486  || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
487  {
488  wxFFile file( destFileName.GetFullPath(), "wb" );
489 
490  if( file.IsOpened() )
491  file.Write( wxT( "{\n}\n") );
492 
493  // wxFFile dtor will close the file
494  }
495  }
496  }
497 
498  // Create a "stub" for a schematic root sheet and a board if requested.
499  // It will avoid messages from the schematic editor or the board editor to create a new file
500  // And forces the user to create main files under the right name for the project manager
501  if( aCreateStubFiles )
502  {
503  wxFileName fn( aProjectFileName.GetFullPath() );
504  fn.SetExt( KiCadSchematicFileExtension );
505 
506  // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic
507  // file ).
508  if( !fn.FileExists() )
509  {
510  wxFFile file( fn.GetFullPath(), "wb" );
511 
512  if( file.IsOpened() )
513  file.Write( wxString::Format( "(kicad_sch (version %d) (generator eeschema)\n"
514  " (paper \"A4\")\n (lib_symbols)\n"
515  " (symbol_instances)\n)\n",
517 
518  // wxFFile dtor will close the file
519  }
520 
521  // If a <project>.kicad_pcb or <project>.brd file does not exist,
522  // create a .kicad_pcb "stub" file
523  fn.SetExt( KiCadPcbFileExtension );
524  wxFileName leg_fn( fn );
525  leg_fn.SetExt( LegacyPcbFileExtension );
526 
527  if( !fn.FileExists() && !leg_fn.FileExists() )
528  {
529  wxFFile file( fn.GetFullPath(), "wb" );
530 
531  if( file.IsOpened() )
532  // Create a small dummy file as a stub for pcbnew:
533  file.Write( wxString::Format( "(kicad_pcb (version %d) (generator pcbnew)\n)",
535 
536  // wxFFile dtor will close the file
537  }
538  }
539 
540  UpdateFileHistory( aProjectFileName.GetFullPath() );
541 
542  m_openSavedWindows = true;
543 }
544 
545 
546 void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
547 {
548  // show all files in file dialog (in Kicad all files are editable texts):
549  wxString wildcard = AllFilesWildcard();
550 
551  wxString default_dir = Prj().GetProjectPath();
552 
553  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
554  wxEmptyString, wildcard, wxFD_OPEN );
555 
556  if( dlg.ShowModal() == wxID_CANCEL )
557  return;
558 
559  wxString filename = wxT( "\"" );
560  filename += dlg.GetPath() + wxT( "\"" );
561 
562  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
564 }
565 
566 
567 void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
568 {
569  // open project directory in host OS's file explorer
570  LaunchExternal( Prj().GetProjectPath() );
571 }
572 
573 
575 {
577 }
578 
579 
580 void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
581 {
582  int id = event.GetId();
583  Kiway().SetLanguage( id );
584 }
585 
586 
588 {
589  // call my base class
591 
592  // tooltips in toolbars
595 
596  PrintPrjInfo();
597 }
598 
599 
600 void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
601 {
602  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
603 }
604 
605 
607 {
608  wxString file = GetProjectFileName();
609  wxString title;
610 
611  if( !file.IsEmpty() )
612  {
613  wxFileName fn( file );
614 
615  title = fn.GetName();
616 
617  if( !fn.IsDirWritable() )
618  title += wxS( " " ) + _( "[Read Only]" );
619  }
620  else
621  {
622  title = _( "[no project loaded]" );
623  }
624 
625  title += wxT( " \u2014 " ) + _( "KiCad " ) + GetMajorMinorVersion();
626 
627  SetTitle( title );
628 }
629 
630 
632 {
634 
635  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
636 
637  wxCHECK( settings, /*void*/ );
638 
639  m_leftWinWidth = settings->m_LeftWinWidth;
640 }
641 
642 
644 {
646 
647  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
648 
649  wxCHECK( settings, /*void*/);
650 
651  settings->m_LeftWinWidth = m_leftWin->GetSize().x;
652 }
653 
654 
656  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
657 {
658  aHotkeysPanel->AddHotKeys( GetToolManager() );
659 }
660 
661 
663 {
664  SetStatusText( wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() ) );
665 
666 }
667 
668 
670 {
671  return m_active_project;
672 }
673 
674 
675 void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
676 {
682  if( !m_openSavedWindows )
683  return;
684 
685  m_openSavedWindows = false;
686 
687  if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
688  {
689  int previousOpenCount =
690  std::count_if( Prj().GetLocalSettings().m_files.begin(),
691  Prj().GetLocalSettings().m_files.end(),
692  [&]( const PROJECT_FILE_STATE& f )
693  {
694  return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
695  } );
696 
697  if( previousOpenCount > 0 )
698  {
699  APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
700  previousOpenCount, this );
701 
702  int i = 0;
703 
704  for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
705  {
706  if( file.open )
707  {
708  progressReporter.Update( i++,
709  wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
710 
711  wxFileName fn( file.fileName );
712 
713  if( fn.GetExt() == LegacySchematicFileExtension
714  || fn.GetExt() == KiCadSchematicFileExtension )
715  {
717  }
718  else if( fn.GetExt() == LegacyPcbFileExtension
719  || fn.GetExt() == KiCadPcbFileExtension )
720  {
722  }
723  }
724 
725  wxYield();
726  }
727  }
728  }
729 
730  // clear file states regardless if we opened windows or not due to setting
732 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
void OnBrowseInFileExplorer(wxCommandEvent &event)
IDs used in KiCad main frame foe menuitems and tools.
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:70
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void language_change(wxCommandEvent &event)
const wxString GetProjectFileName() const
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow a frame to load its preference panels (if any) into the preferences dialog.
void SetMruPath(const wxString &aPath)
SEARCH_STACK & SysSearch()
Definition: pgm_kicad.h:57
SETTINGS_MANAGER * GetSettingsManager() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void doCloseWindow() override
const std::string ProjectFileExtension
Definition: id.h:87
const std::string LegacyPcbFileExtension
void OnIdle(wxIdleEvent &event)
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
PANEL_KICAD_LAUNCHER * m_launcher
wxWindow * GetToolCanvas() const override
Canvas access.
void OnImportEagleFiles(wxCommandEvent &event)
Open dialog to import Eagle schematic and board files.
virtual void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void OnOpenFileInTextEditor(wxCommandEvent &event)
const wxString SchLegacyFileName()
KICAD_SETTINGS * kicadSettings() const
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
void AddHotKeys(TOOL_MANAGER *aToolMgr)
Handle actions in the kicad manager frame.
Look for files in a number of paths.
Definition: search_stack.h:41
std::vector< wxString > m_OpenProjects
void ReCreateTreePrj()
Create or modify the tree showing project file names.
wxAuiManager m_auimgr
Manage TOOL_ACTION objects.
const std::string KiCadPcbFileExtension
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
Definition: kiway.cpp:475
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
void LoadWindowState(const wxString &aFileName)
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
wxString AllFilesWildcard()
PROJECT_TREE_PANE * m_leftWin
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
static TOOL_ACTION closeProject
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:151
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)
PROJECT_TREE_PANE Window to display the tree files.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
Master controller class:
Definition: tool_manager.h:54
void OnImportCadstarArchiveFiles(wxCommandEvent &event)
Open dialog to import CADSTAR Schematic and PCB Archive files.
const wxString SchFileName()
static TOOL_ACTION editSchematic
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
wxString GetBuildVersion()
Get the full KiCad version string.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
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.
wxString help_name() override
ACTIONS * m_actions
Definition: tools_holder.h:157
Definition of file extensions used in Kicad.
Base window classes and related definitions.
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=NULL) override
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PcbFileExtension
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:117
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
const std::string LegacyProjectFileExtension
Handle actions that are shared between different applications.
void ProjectChanged() override
Notification event that the project has changed.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const std::string LegacySchematicFileExtension
void OnArchiveFiles(wxCommandEvent &event)
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::language_change) KICAD_MANAGER_FRAME
PGM_KICAD & PgmTop()
Definition: kicad.cpp:87
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:158
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void CreateNewProject(const wxFileName &aProjectFileName, bool aCreateStubFiles=true)
Creates a new project by setting up and initial project, schematic, and board files.
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
bool CloseProject(bool aSave)
Closes the project, and saves it if aSave is true;.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static TOOL_ACTION editPCB
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:156
const wxString PcbLegacyFileName()
static TOOL_ACTION saveAs
Definition: actions.h:52
std::vector< wxString > GetOpenProjects() const
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
#define KICAD_MANAGER_FRAME_NAME
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
void EmptyTreePrj()
Delete all m_TreeProject entries.
The base frame for deriving all KiCad main window classes.
const wxString PcbFileName()
bool SaveProject(const wxString &aFullPath=wxEmptyString)
Saves a loaded project.
APP_SETTINGS_BASE * PgmSettings()
Definition: pgm_kicad.h:55
const std::string KiCadSchematicFileExtension
wxProgressDialog with the option to also update the application progress on the taskbar
wxString GetHelpFileName()
Definition: pgm_kicad.h:59
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
Definition: id.h:86
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
void LoadProject(const wxFileName &aProjectFileName)
void OnUnarchiveFiles(wxCommandEvent &event)
void InitTools()
Initializes all registered tools.
static REPORTER & GetInstance()
Definition: reporter.cpp:108
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
void OnExit(wxCommandEvent &event)
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
Definition: launch_ext.cpp:25
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
std::vector< PROJECT_FILE_STATE > m_files
Project scope.
const SEARCH_STACK & sys_search() override
Return a SEARCH_STACK pertaining to entire program.
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
void PrintPrjInfo()
Prints the current working directory name and the project name on the text panel.
The main KiCad project manager frame.
static TOOL_ACTION openTextEditor
void OnSize(wxSizeEvent &event) override
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
bool RegisterApplicationRestart(const wxString &aCommandLine)
Registers the application for restart with the OS with the given command line string to pass as args.
Definition: gtk/app.cpp:58
KIWAY Kiway