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/pcb_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( false )
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 " ) + GetMajorMinorVersion() );
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  // Don't propagate event to frames which have already been closed
364  aEvent.StopPropagation();
365 
366  return true;
367  }
368  else
369  {
370  if( aEvent.CanVeto() )
371  aEvent.Veto();
372 
373  return false;
374  }
375 }
376 
377 
379 {
380 #ifdef _WINDOWS_
381  // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
382  // if a editor frame (schematic, library, board editor or fp editor) is open and has
383  // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
384  // conditions between OnCloseWindow() code.
385  // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
386  // execution of the first call (only one call is right).
387  // Note also if there is no change made in editors, this behavior does not happen.
388  static std::atomic<unsigned int> lock_close_event( 0 );
389 
390  if( ++lock_close_event > 1 ) // Skip extra calls
391  {
392  return;
393  }
394 #endif
395 
396  m_leftWin->Show( false );
397  Pgm().m_Quitting = true;
398 
399  Destroy();
400 
401 #ifdef _WINDOWS_
402  lock_close_event = 0; // Reenable event management
403 #endif
404 }
405 
406 
407 void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
408 {
409  Close( true );
410 }
411 
412 
414 {
415  if( !Kiway().PlayersClose( false ) )
416  return false;
417 
418  // Save the project file for the currently loaded project.
419  if( m_active_project )
420  {
421  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
422 
424 
425  if( aSave )
426  mgr.SaveProject();
427 
428  m_active_project = false;
429  mgr.UnloadProject( &Prj() );
430  }
431 
432  SetStatusText( "" );
433 
435 
436  return true;
437 }
438 
439 
440 void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
441 {
442  // The project file should be valid by the time we get here or something has gone wrong.
443  if( !aProjectFileName.Exists() )
444  return;
445 
446  // Any open KIFACE's must be closed if they are not part of the new project.
447  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
448  // User is prompted here to close those KIWAY_PLAYERs:
449  if( !CloseProject( true ) )
450  return;
451 
452  m_active_project = true;
453 
454  Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
455 
456  LoadWindowState( aProjectFileName.GetFullName() );
457 
458  if( aProjectFileName.IsDirWritable() )
459  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
460 
461  UpdateFileHistory( Prj().GetProjectFullName() );
462 
464 
465  // Rebuild the list of watched paths.
466  // however this is possible only when the main loop event handler is running,
467  // so we use it to run the rebuild function.
468  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
469 
470  wxPostEvent( this, cmd );
471 
472  PrintPrjInfo();
473 
474  KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
475  m_openSavedWindows = true;
476 }
477 
478 
479 void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName,
480  bool aCreateStubFiles )
481 {
482  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
483  "Project folder must exist and be writable to create a new project." );
484 
485  // If the project is legacy, convert it
486  if( !aProjectFileName.FileExists() )
487  {
488  wxFileName legacyPro( aProjectFileName );
489  legacyPro.SetExt( LegacyProjectFileExtension );
490 
491  if( legacyPro.FileExists() )
492  {
493  GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
495 
496  wxRemoveFile( legacyPro.GetFullPath() );
497  }
498  else
499  {
500  // Copy template project file from template folder.
501  wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
502 
503  wxFileName destFileName( aProjectFileName );
504  destFileName.SetExt( ProjectFileExtension );
505 
506  // Create a minimal project file if the template project file could not be copied
507  if( !wxFileName::FileExists( srcFileName )
508  || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
509  {
510  wxFFile file( destFileName.GetFullPath(), "wb" );
511 
512  if( file.IsOpened() )
513  file.Write( wxT( "{\n}\n") );
514 
515  // wxFFile dtor will close the file
516  }
517  }
518  }
519 
520  // Create a "stub" for a schematic root sheet and a board if requested.
521  // It will avoid messages from the schematic editor or the board editor to create a new file
522  // And forces the user to create main files under the right name for the project manager
523  if( aCreateStubFiles )
524  {
525  wxFileName fn( aProjectFileName.GetFullPath() );
526  fn.SetExt( KiCadSchematicFileExtension );
527 
528  // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic
529  // file ).
530  if( !fn.FileExists() )
531  {
532  wxFFile file( fn.GetFullPath(), "wb" );
533 
534  if( file.IsOpened() )
535  file.Write( wxString::Format( "(kicad_sch (version %d) (generator eeschema)\n"
536  " (paper \"A4\")\n (lib_symbols)\n"
537  " (symbol_instances)\n)\n",
539 
540  // wxFFile dtor will close the file
541  }
542 
543  // If a <project>.kicad_pcb or <project>.brd file does not exist,
544  // create a .kicad_pcb "stub" file
545  fn.SetExt( KiCadPcbFileExtension );
546  wxFileName leg_fn( fn );
547  leg_fn.SetExt( LegacyPcbFileExtension );
548 
549  if( !fn.FileExists() && !leg_fn.FileExists() )
550  {
551  wxFFile file( fn.GetFullPath(), "wb" );
552 
553  if( file.IsOpened() )
554  // Create a small dummy file as a stub for pcbnew:
555  file.Write( wxString::Format( "(kicad_pcb (version %d) (generator pcbnew)\n)",
557 
558  // wxFFile dtor will close the file
559  }
560  }
561 
562  UpdateFileHistory( aProjectFileName.GetFullPath() );
563 
564  m_openSavedWindows = true;
565 }
566 
567 
568 void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
569 {
570  // show all files in file dialog (in Kicad all files are editable texts):
571  wxString wildcard = AllFilesWildcard();
572 
573  wxString default_dir = Prj().GetProjectPath();
574 
575  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
576  wxEmptyString, wildcard, wxFD_OPEN );
577 
578  if( dlg.ShowModal() == wxID_CANCEL )
579  return;
580 
581  wxString filename = wxT( "\"" );
582  filename += dlg.GetPath() + wxT( "\"" );
583 
584  if( !dlg.GetPath().IsEmpty() && !Pgm().GetTextEditor().IsEmpty() )
586 }
587 
588 
589 void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
590 {
591  // open project directory in host OS's file explorer
592  LaunchExternal( Prj().GetProjectPath() );
593 }
594 
595 
597 {
599 }
600 
601 
602 void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
603 {
604  int id = event.GetId();
605  Kiway().SetLanguage( id );
606 }
607 
608 
610 {
611  // call my base class
613 
614  // tooltips in toolbars
617 
618  PrintPrjInfo();
619 }
620 
621 
622 void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
623 {
624  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
625 }
626 
627 
629 {
630  wxString file = GetProjectFileName();
631  wxString title;
632 
633  if( !file.IsEmpty() )
634  {
635  wxFileName fn( file );
636 
637  title = fn.GetName();
638 
639  if( !fn.IsDirWritable() )
640  title += wxS( " " ) + _( "[Read Only]" );
641  }
642  else
643  {
644  title = _( "[no project loaded]" );
645  }
646 
647  if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
648  title += wxT( " \u2014 " ) + wxString( "KiCad" );
649  else
650  title += wxT( " \u2014 " ) + wxString( "KiCad " ) + GetMajorMinorVersion();
651 
652  SetTitle( title );
653 }
654 
655 
657 {
659 
660  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
661 
662  wxCHECK( settings, /*void*/ );
663 
664  m_leftWinWidth = settings->m_LeftWinWidth;
665 }
666 
667 
669 {
671 
672  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
673 
674  wxCHECK( settings, /*void*/);
675 
676  settings->m_LeftWinWidth = m_leftWin->GetSize().x;
677 }
678 
679 
681  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
682 {
683  aHotkeysPanel->AddHotKeys( GetToolManager() );
684 }
685 
686 
688 {
689  // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac).
690 
691  wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() );
692  wxStatusBar* statusBar = GetStatusBar();
693  int width = statusBar->GetSize().GetWidth() / 2;
694 
695  if( width > 20 )
696  {
697  wxClientDC dc( this );
698  status = wxControl::Ellipsize( status, dc, wxELLIPSIZE_MIDDLE, width );
699  }
700 
701  SetStatusText( status );
702 }
703 
704 
706 {
707  return m_active_project;
708 }
709 
710 
711 void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
712 {
718  if( !m_openSavedWindows )
719  return;
720 
721  m_openSavedWindows = false;
722 
723  if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
724  {
725  int previousOpenCount =
726  std::count_if( Prj().GetLocalSettings().m_files.begin(),
727  Prj().GetLocalSettings().m_files.end(),
728  [&]( const PROJECT_FILE_STATE& f )
729  {
730  return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
731  } );
732 
733  if( previousOpenCount > 0 )
734  {
735  APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
736  previousOpenCount, this );
737 
738  int i = 0;
739 
740  for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
741  {
742  if( file.open )
743  {
744  progressReporter.Update( i++,
745  wxString::Format( _( "Restoring '%s'" ), file.fileName ) );
746 
747  wxFileName fn( file.fileName );
748 
749  if( fn.GetExt() == LegacySchematicFileExtension
750  || fn.GetExt() == KiCadSchematicFileExtension )
751  {
753  }
754  else if( fn.GetExt() == LegacyPcbFileExtension
755  || fn.GetExt() == KiCadPcbFileExtension )
756  {
758  }
759  }
760 
761  wxYield();
762  }
763  }
764  }
765 
766  // clear file states regardless if we opened windows or not due to setting
768 }
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.
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
Definition: pcb_plugin.h:105
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:486
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
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:132
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()
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
Definition: launch_ext.cpp:25
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 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 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