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 <advanced_config.h>
30 #include <bitmaps.h>
31 #include <build_version.h>
33 #include <eda_base_frame.h>
34 #include <filehistory.h>
35 #include <kiplatform/app.h>
36 #include <kiway.h>
37 #include <kiway_express.h>
38 #include <launch_ext.h>
39 #include <panel_hotkeys_editor.h>
40 #include <reporter.h>
42 #include <sch_file_versions.h>
44 #include <tool/action_manager.h>
45 #include <tool/action_toolbar.h>
46 #include <tool/common_control.h>
47 #include <tool/tool_dispatcher.h>
48 #include <tool/tool_manager.h>
53 #include <wx/ffile.h>
54 #include <wx/filedlg.h>
55 #include <wx/dcclient.h>
56 #include <atomic>
57 
58 
59 #include <../pcbnew/plugins/kicad/kicad_plugin.h> // for SEXPR_BOARD_FILE_VERSION def
60 
61 
62 #ifdef __WXMAC__
63 #include <MacTypes.h>
64 #include <ApplicationServices/ApplicationServices.h>
65 #endif
66 
67 #include "kicad_manager_frame.h"
68 #include "kicad_settings.h"
69 
70 
71 #define SEP() wxFileName::GetPathSeparator()
72 
73 
74 // Menubar and toolbar event table
75 BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
76  // Window events
77  EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
78  EVT_IDLE( KICAD_MANAGER_FRAME::OnIdle )
79 
80  // Menu events
81  EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
88 
89  // Range menu events
91  KICAD_MANAGER_FRAME::language_change )
92 
94  EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
95 
96  // Special functions
97  EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
98 END_EVENT_TABLE()
99 
100 
101 #ifdef PCM
102 // See below the purpose of this include
103 #include <wx/xml/xml.h>
104 #endif
105 
106 KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
107  const wxPoint& pos, const wxSize& size ) :
108  EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
110  m_leftWin( nullptr ),
111  m_launcher( nullptr ),
112  m_mainToolBar( nullptr )
113 {
114  m_active_project = false;
115  m_leftWinWidth = 250; // Default value
116  m_aboutTitle = "KiCad";
117 
118 #ifdef PCM
119  // JPC: A very ugly hack to fix an issue on Linux: if the wxbase315u_xml_gcc_custom.so is
120  // used **only** in PCM, it is not found in some cases at run time.
121  // So just use it in the main module to avoid a not found issue
122  // wxbase315u_xml_gcc_custom shared object when launching Kicad
123  wxXmlDocument dummy;
124 #endif
125 
126  // Create the status line (bottom of the frame). Left half is for project name; right half
127  // is for Reporter (currently used by archiver/unarchiver).
128  CreateStatusBar( 2 );
129  GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
130 
131  // Give an icon
132  wxIcon icon;
133  wxIconBundle icon_bundle;
134 
135  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad ) );
136  icon_bundle.AddIcon( icon );
137  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
138  icon_bundle.AddIcon( icon );
139  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
140  icon_bundle.AddIcon( icon );
141 
142  SetIcons( icon_bundle );
143 
144  // Load the settings
145  LoadSettings( config() );
146 
147  // Left window: is the box which display tree project
148  m_leftWin = new PROJECT_TREE_PANE( this );
149 
150  setupTools();
151  setupUIConditions();
152 
153  m_launcher = new PANEL_KICAD_LAUNCHER( this );
154 
155  RecreateBaseHToolbar();
156  ReCreateMenuBar();
157 
158  m_auimgr.SetManagedWindow( this );
159  m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
160 
161  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Left()
162  .Layer( 2 ) );
163 
164  // BestSize() does not always set the actual pane size of m_leftWin to the required value.
165  // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
166  // (Well, BestSize() sets the best size... not the window size)
167  // A trick is to use MinSize() to set the required pane width,
168  // and after give a reasonable MinSize value
169  m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
170  .Caption( _( "Project Files" ) ).PaneBorder( true )
171  .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
172 
173  m_auimgr.AddPane( m_launcher, EDA_PANE().Canvas().Name( "Launcher" ).Center()
174  .Caption( _( "Editors" ) ).PaneBorder( false )
175  .MinSize( m_launcher->GetBestSize() ) );
176 
177  m_auimgr.Update();
178 
179  // Now the actual m_leftWin size is set, give it a reasonable min width
180  m_auimgr.GetPane( m_leftWin ).MinSize( 250, -1 );
181 
182  wxSizer* mainSizer = GetSizer();
183 
184  // Only fit the initial window size the first time KiCad is run.
185  if( mainSizer && config()->m_Window.state.size_x == 0 && config()->m_Window.state.size_y == 0 )
186  mainSizer->Fit( this );
187 
188  if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
189  SetTitle( wxT( "KiCad" ) );
190  else
191  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
192 
193  // Do not let the messages window have initial focus
194  m_leftWin->SetFocus();
195 
196  // Ensure the window is on top
197  Raise();
198 }
199 
200 
202 {
203  // Shutdown all running tools
204  if( m_toolManager )
206 
207  delete m_actions;
208  delete m_toolManager;
209  delete m_toolDispatcher;
210 
211  m_auimgr.UnInit();
212 }
213 
214 
216 {
217  // Create the manager
219  m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
221 
223 
224  // Attach the events to the tool dispatcher
226  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
227 
228  // Register tools
232 }
233 
234 
236 {
238 
240 
241  wxASSERT( manager );
242 
243  auto activeProject =
244  [this] ( const SELECTION& )
245  {
246  return m_active_project;
247  };
248 
249  ACTION_CONDITIONS activeProjectCond;
250  activeProjectCond.Enable( activeProject );
251 
252  manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
253  manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
254 
255  // TODO: Switch this to an action
256  RegisterUIUpdateHandler( ID_SAVE_AND_ZIP_FILES, activeProjectCond );
257 }
258 
259 
261 {
262  return m_leftWin;
263 }
264 
265 
267 {
269  wxASSERT( ret );
270  return ret;
271 }
272 
273 
275 {
276  KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
277  wxASSERT( ret );
278  return ret;
279 }
280 
281 
283 {
284  return Pgm().GetSettingsManager().IsProjectOpen() ? Prj().GetProjectFullName() :
285  wxString( wxEmptyString );
286 }
287 
288 
290 {
291  wxFileName fn( GetProjectFileName() );
292 
293  fn.SetExt( KiCadSchematicFileExtension );
294  return fn.GetFullPath();
295 }
296 
297 
299 {
300  wxFileName fn( GetProjectFileName() );
301 
302  fn.SetExt( LegacySchematicFileExtension );
303  return fn.GetFullPath();
304 }
305 
306 
308 {
309  wxFileName fn( GetProjectFileName() );
310 
311  fn.SetExt( PcbFileExtension );
312  return fn.GetFullPath();
313 }
314 
315 
317 {
318  wxFileName fn( GetProjectFileName() );
319 
320  fn.SetExt( LegacyPcbFileExtension );
321  return fn.GetFullPath();
322 }
323 
324 
326 {
328 }
329 
330 
332 {
333  return PgmTop().SysSearch();
334 }
335 
336 
338 {
339  return PgmTop().GetHelpFileName();
340 }
341 
342 
343 void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
344 {
345  if( m_auimgr.GetManagedWindow() )
346  m_auimgr.Update();
347 
348  PrintPrjInfo();
349 
350  event.Skip();
351 }
352 
353 
354 bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
355 {
356  KICAD_SETTINGS* settings = kicadSettings();
358 
359  // CloseProject will recursively ask all the open editors if they need to save changes.
360  // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
361  if( CloseProject( true ) )
362  {
363  return true;
364  }
365  else
366  {
367  if( aEvent.CanVeto() )
368  aEvent.Veto();
369 
370  return false;
371  }
372 }
373 
374 
376 {
377 #ifdef _WINDOWS_
378  // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
379  // if a editor frame (schematic, library, board editor or fp editor) is open and has
380  // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
381  // conditions between OnCloseWindow() code.
382  // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
383  // execution of the first call (only one call is right).
384  // Note also if there is no change made in editors, this behavior does not happen.
385  static std::atomic<unsigned int> lock_close_event( 0 );
386 
387  if( ++lock_close_event > 1 ) // Skip extra calls
388  {
389  return;
390  }
391 #endif
392 
393  m_leftWin->Show( false );
394 
395  Destroy();
396 
397 #ifdef _WINDOWS_
398  lock_close_event = 0; // Reenable event management
399 #endif
400 }
401 
402 
403 void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
404 {
405  Close( true );
406 }
407 
408 
410 {
411  if( !Kiway().PlayersClose( false ) )
412  return false;
413 
414  // Give a timeslice for the save-changes? dialog (and for the project to actually close)
415  wxSafeYield();
416 
417  // Save the project file for the currently loaded project.
418  if( m_active_project )
419  {
420  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
421 
423 
424  if( aSave )
425  mgr.SaveProject();
426 
427  m_active_project = false;
428  mgr.UnloadProject( &Prj() );
429  }
430 
431  SetStatusText( "" );
432 
434 
435  return true;
436 }
437 
438 
439 void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
440 {
441  // The project file should be valid by the time we get here or something has gone wrong.
442  if( !aProjectFileName.Exists() )
443  return;
444 
445  // Any open KIFACE's must be closed if they are not part of the new project.
446  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
447  // User is prompted here to close those KIWAY_PLAYERs:
448  if( !CloseProject( true ) )
449  return;
450 
451  m_active_project = true;
452 
453  Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
454 
455  LoadWindowState( aProjectFileName.GetFullName() );
456 
457  if( aProjectFileName.IsDirWritable() )
458  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
459 
460  UpdateFileHistory( Prj().GetProjectFullName() );
461 
463 
464  // Rebuild the list of watched paths.
465  // however this is possible only when the main loop event handler is running,
466  // so we use it to run the rebuild function.
467  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
468 
469  wxPostEvent( this, cmd );
470 
471  PrintPrjInfo();
472 
473  KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
474  m_openSavedWindows = true;
475 }
476 
477 
478 void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName,
479  bool aCreateStubFiles )
480 {
481  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
482  "Project folder must exist and be writable to create a new project." );
483 
484  // If the project is legacy, convert it
485  if( !aProjectFileName.FileExists() )
486  {
487  wxFileName legacyPro( aProjectFileName );
488  legacyPro.SetExt( LegacyProjectFileExtension );
489 
490  if( legacyPro.FileExists() )
491  {
492  GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
494 
495  wxRemoveFile( legacyPro.GetFullPath() );
496  }
497  else
498  {
499  // Copy template project file from template folder.
500  wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
501 
502  wxFileName destFileName( aProjectFileName );
503  destFileName.SetExt( ProjectFileExtension );
504 
505  // Create a minimal project file if the template project file could not be copied
506  if( !wxFileName::FileExists( srcFileName )
507  || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
508  {
509  wxFFile file( destFileName.GetFullPath(), "wb" );
510 
511  if( file.IsOpened() )
512  file.Write( wxT( "{\n}\n") );
513 
514  // wxFFile dtor will close the file
515  }
516  }
517  }
518 
519  // Create a "stub" for a schematic root sheet and a board if requested.
520  // It will avoid messages from the schematic editor or the board editor to create a new file
521  // And forces the user to create main files under the right name for the project manager
522  if( aCreateStubFiles )
523  {
524  wxFileName fn( aProjectFileName.GetFullPath() );
525  fn.SetExt( KiCadSchematicFileExtension );
526 
527  // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic
528  // file ).
529  if( !fn.FileExists() )
530  {
531  wxFFile file( fn.GetFullPath(), "wb" );
532 
533  if( file.IsOpened() )
534  file.Write( wxString::Format( "(kicad_sch (version %d) (generator eeschema)\n"
535  " (paper \"A4\")\n (lib_symbols)\n"
536  " (symbol_instances)\n)\n",
538 
539  // wxFFile dtor will close the file
540  }
541 
542  // If a <project>.kicad_pcb or <project>.brd file does not exist,
543  // create a .kicad_pcb "stub" file
544  fn.SetExt( KiCadPcbFileExtension );
545  wxFileName leg_fn( fn );
546  leg_fn.SetExt( LegacyPcbFileExtension );
547 
548  if( !fn.FileExists() && !leg_fn.FileExists() )
549  {
550  wxFFile file( fn.GetFullPath(), "wb" );
551 
552  if( file.IsOpened() )
553  // Create a small dummy file as a stub for pcbnew:
554  file.Write( wxString::Format( "(kicad_pcb (version %d) (generator pcbnew)\n)",
556 
557  // wxFFile dtor will close the file
558  }
559  }
560 
561  UpdateFileHistory( aProjectFileName.GetFullPath() );
562 
563  m_openSavedWindows = true;
564 }
565 
566 
567 void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
568 {
569  // show all files in file dialog (in Kicad all files are editable texts):
570  wxString wildcard = AllFilesWildcard();
571 
572  wxString default_dir = Prj().GetProjectPath();
573 
574  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
575  wxEmptyString, wildcard, wxFD_OPEN );
576 
577  if( dlg.ShowModal() == wxID_CANCEL )
578  return;
579 
580  wxString filename = wxT( "\"" );
581  filename += dlg.GetPath() + wxT( "\"" );
582 
583  if( !dlg.GetPath().IsEmpty() && !Pgm().GetTextEditor().IsEmpty() )
585 }
586 
587 
588 void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
589 {
590  // open project directory in host OS's file explorer
591  LaunchExternal( Prj().GetProjectPath() );
592 }
593 
594 
596 {
598 }
599 
600 
601 void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
602 {
603  int id = event.GetId();
604  Kiway().SetLanguage( id );
605 }
606 
607 
609 {
610  // call my base class
612 
613  // tooltips in toolbars
616 
617  PrintPrjInfo();
618 }
619 
620 
621 void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
622 {
623  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
624 }
625 
626 
628 {
629  wxString file = GetProjectFileName();
630  wxString title;
631 
632  if( !file.IsEmpty() )
633  {
634  wxFileName fn( file );
635 
636  title = fn.GetName();
637 
638  if( !fn.IsDirWritable() )
639  title += wxS( " " ) + _( "[Read Only]" );
640  }
641  else
642  {
643  title = _( "[no project loaded]" );
644  }
645 
646  if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
647  title += wxT( " \u2014 " ) + wxString( "KiCad" );
648  else
649  title += wxT( " \u2014 " ) + wxString( "KiCad " ) + GetMajorMinorVersion();
650 
651  SetTitle( title );
652 }
653 
654 
656 {
658 
659  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
660 
661  wxCHECK( settings, /*void*/ );
662 
663  m_leftWinWidth = settings->m_LeftWinWidth;
664 }
665 
666 
668 {
670 
671  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
672 
673  wxCHECK( settings, /*void*/);
674 
675  settings->m_LeftWinWidth = m_leftWin->GetSize().x;
676 }
677 
678 
680  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
681 {
682  aHotkeysPanel->AddHotKeys( GetToolManager() );
683 }
684 
685 
687 {
688  // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac).
689 
690  wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() );
691  wxStatusBar* statusBar = GetStatusBar();
692  int width = statusBar->GetSize().GetWidth() / 2;
693 
694  if( width > 20 )
695  {
696  wxClientDC dc( this );
697  status = wxControl::Ellipsize( status, dc, wxELLIPSIZE_MIDDLE, width );
698  }
699 
700  SetStatusText( status );
701 }
702 
703 
705 {
706  return m_active_project;
707 }
708 
709 
710 void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
711 {
717  if( !m_openSavedWindows )
718  return;
719 
720  m_openSavedWindows = false;
721 
722  if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
723  {
724  int previousOpenCount =
725  std::count_if( Prj().GetLocalSettings().m_files.begin(),
726  Prj().GetLocalSettings().m_files.end(),
727  [&]( const PROJECT_FILE_STATE& f )
728  {
729  return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
730  } );
731 
732  if( previousOpenCount > 0 )
733  {
734  APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
735  previousOpenCount, this );
736 
737  int i = 0;
738 
739  for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
740  {
741  if( file.open )
742  {
743  progressReporter.Update( i++,
744  wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
745 
746  wxFileName fn( file.fileName );
747 
748  if( fn.GetExt() == LegacySchematicFileExtension
749  || fn.GetExt() == KiCadSchematicFileExtension )
750  {
752  }
753  else if( fn.GetExt() == LegacyPcbFileExtension
754  || fn.GetExt() == KiCadPcbFileExtension )
755  {
757  }
758  }
759 
760  wxYield();
761  }
762  }
763  }
764 
765  // clear file states regardless if we opened windows or not due to setting
767 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
void OnBrowseInFileExplorer(wxCommandEvent &event)
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=nullptr) override
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:56
SETTINGS_MANAGER * GetSettingsManager() const
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
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:485
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:122
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.
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
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:159
Definition of file extensions used in Kicad.
Base window classes and related definitions.
#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:116
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
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:129
PGM_KICAD & PgmTop()
Definition: kicad.cpp:87
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
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
KICAD_MANAGER_FRAME(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
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:158
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:54
const std::string KiCadSchematicFileExtension
wxProgressDialog with the option to also update the application progress on the taskbar
wxString GetHelpFileName()
Definition: pgm_kicad.h:58
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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:117
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.
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