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-2020 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 
54 #include <../pcbnew/plugins/kicad/kicad_plugin.h> // for SEXPR_BOARD_FILE_VERSION def
55 
56 
57 #ifdef __WXMAC__
58 #include <MacTypes.h>
59 #include <ApplicationServices/ApplicationServices.h>
60 #endif
61 
62 #include "kicad_manager_frame.h"
63 #include "kicad_settings.h"
64 
65 
66 #define SEP() wxFileName::GetPathSeparator()
67 
68 
69 // Menubar and toolbar event table
70 BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
71  // Window events
72  EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
73  EVT_IDLE( KICAD_MANAGER_FRAME::OnIdle )
74 
75  // Menu events
76  EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
83 
84  // Range menu events
86  KICAD_MANAGER_FRAME::language_change )
87 
89  EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
90 
91  // Special functions
92  EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
93 END_EVENT_TABLE()
94 
95 
96 KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
97  const wxPoint& pos, const wxSize& size ) :
98  EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
100  m_leftWin( nullptr ),
101  m_launcher( nullptr ),
102  m_mainToolBar( nullptr )
103 {
104  m_active_project = false;
105  m_leftWinWidth = 250; // Default value
106  m_aboutTitle = "KiCad";
107 
108  // Create the status line (bottom of the frame)
109  static const int dims[2] = { -1, -1 };
110 
111  CreateStatusBar( 2, wxSTB_SIZEGRIP | wxSTB_SHOW_TIPS | wxSTB_ELLIPSIZE_MIDDLE |
112  wxFULL_REPAINT_ON_RESIZE );
113  SetStatusWidths( 2, dims );
114 
115  // Give an icon
116  wxIcon icon;
117  wxIconBundle icon_bundle;
118 
119  icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) );
120  icon_bundle.AddIcon( icon );
121  icon.CopyFromBitmap( KiBitmap( icon_kicad_32_xpm ) );
122  icon_bundle.AddIcon( icon );
123  icon.CopyFromBitmap( KiBitmap( icon_kicad_16_xpm ) );
124  icon_bundle.AddIcon( icon );
125 
126  SetIcons( icon_bundle );
127 
128  // Load the settings
129  LoadSettings( config() );
130 
131  // Left window: is the box which display tree project
132  m_leftWin = new PROJECT_TREE_PANE( this );
133 
134  setupTools();
135  setupUIConditions();
136 
137  m_launcher = new PANEL_KICAD_LAUNCHER( this );
138 
139  RecreateBaseHToolbar();
140  ReCreateMenuBar();
141 
142  m_auimgr.SetManagedWindow( this );
143  m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
144 
145  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Left()
146  .Layer( 2 ) );
147 
148  // BestSize() does not always set the actual pane size of m_leftWin to the required value.
149  // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
150  // (Well, BestSize() sets the best size... not the window size)
151  // A trick is to use MinSize() to set the required pane width,
152  // and after give a reasonable MinSize value
153  m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
154  .Caption( _( "Project Files" ) ).PaneBorder( true )
155  .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
156 
157  m_auimgr.AddPane( m_launcher, EDA_PANE().Canvas().Name( "Launcher" ).Center()
158  .Caption( _( "Editors" ) ).PaneBorder( false )
159  .MinSize( m_launcher->GetBestSize() ) );
160 
161  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
162  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
163  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
164  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
165 
166  m_auimgr.Update();
167 
168  // Now the actual m_leftWin size is set, give it a reasonable min width
169  m_auimgr.GetPane( m_leftWin ).MinSize( 250, -1 );
170 
171  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
172 
173  // Do not let the messages window have initial focus
174  m_leftWin->SetFocus();
175 
176  // Ensure the window is on top
177  Raise();
178 }
179 
180 
182 {
183  // Shutdown all running tools
184  if( m_toolManager )
186 
187  delete m_actions;
188  delete m_toolManager;
189  delete m_toolDispatcher;
190 
191  m_auimgr.UnInit();
192 }
193 
194 
196 {
197  // Create the manager
199  m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
201 
203 
204  // Attach the events to the tool dispatcher
207  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
208 
209  // Register tools
213 }
214 
215 
217 {
219 
221 
222  wxASSERT( manager );
223 
224  auto activeProject =
225  [this] ( const SELECTION& )
226  {
227  return m_active_project;
228  };
229 
230  ACTION_CONDITIONS activeProjectCond;
231  activeProjectCond.Enable( activeProject );
232 
233  manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
234  manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
235 
236  // TODO: Switch this to an action
237  RegisterUIUpdateHandler( ID_SAVE_AND_ZIP_FILES, activeProjectCond );
238 }
239 
240 
242 {
243  return m_leftWin;
244 }
245 
246 
248 {
250  wxASSERT( ret );
251  return ret;
252 }
253 
254 
256 {
257  KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
258  wxASSERT( ret );
259  return ret;
260 }
261 
262 
264 {
265  return Pgm().GetSettingsManager().IsProjectOpen() ? Prj().GetProjectFullName() : wxString( wxEmptyString );
266 }
267 
268 
270 {
271  wxFileName fn( GetProjectFileName() );
272 
273  fn.SetExt( KiCadSchematicFileExtension );
274  return fn.GetFullPath();
275 }
276 
277 
279 {
280  wxFileName fn( GetProjectFileName() );
281 
282  fn.SetExt( LegacySchematicFileExtension );
283  return fn.GetFullPath();
284 }
285 
286 
288 {
289  wxFileName fn( GetProjectFileName() );
290 
291  fn.SetExt( PcbFileExtension );
292  return fn.GetFullPath();
293 }
294 
295 
297 {
298  wxFileName fn( GetProjectFileName() );
299 
300  fn.SetExt( LegacyPcbFileExtension );
301  return fn.GetFullPath();
302 }
303 
304 
306 {
308 }
309 
310 
312 {
313  return PgmTop().SysSearch();
314 }
315 
316 
318 {
319  return PgmTop().GetHelpFileName();
320 }
321 
322 
323 void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
324 {
325  if( m_auimgr.GetManagedWindow() )
326  m_auimgr.Update();
327 
328  event.Skip();
329 }
330 
331 
332 bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
333 {
334  KICAD_SETTINGS* settings = kicadSettings();
336 
337  // CloseProject will recursively ask all the open editors if they need to save changes.
338  // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
339  if( CloseProject( true ) )
340  {
341  return true;
342  }
343  else
344  {
345  if( aEvent.CanVeto() )
346  aEvent.Veto();
347 
348  return false;
349  }
350 }
351 
352 
354 {
355 #ifdef _WINDOWS_
356  // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
357  // if a editor frame (schematic, library, board editor or fp editor) is open and has
358  // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
359  // conditions between OnCloseWindow() code.
360  // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
361  // execution of the first call (only one call is right).
362  // Note also if there is no change made in editors, this behavior does not happen.
363  static std::atomic<unsigned int> lock_close_event( 0 );
364 
365  if( ++lock_close_event > 1 ) // Skip extra calls
366  {
367  return;
368  }
369 #endif
370 
371  m_leftWin->Show( false );
372 
373  Destroy();
374 
375 #ifdef _WINDOWS_
376  lock_close_event = 0; // Reenable event management
377 #endif
378 }
379 
380 
381 void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
382 {
383  Close( true );
384 }
385 
386 
388 {
389  if( !Kiway().PlayersClose( false ) )
390  return false;
391 
392  // Save the project file for the currently loaded project.
393  if( m_active_project )
394  {
395  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
396 
398 
399  if( aSave )
400  {
401  mgr.SaveProject();
402  }
403 
404  m_active_project = false;
405  mgr.UnloadProject( &Prj() );
406  }
407 
408  SetStatusText( "" );
409 
411 
412  return true;
413 }
414 
415 
416 void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
417 {
418  // The project file should be valid by the time we get here or something has gone wrong.
419  if( !aProjectFileName.Exists() )
420  return;
421 
422  // Any open KIFACE's must be closed if they are not part of the new project.
423  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
424  // User is prompted here to close those KIWAY_PLAYERs:
425  CloseProject( true );
426 
427  m_active_project = true;
428 
429  Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
430 
431  LoadWindowState( aProjectFileName.GetFullName() );
432 
433  if( aProjectFileName.IsDirWritable() )
434  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
435 
436  UpdateFileHistory( Prj().GetProjectFullName() );
437 
439 
440  // Rebuild the list of watched paths.
441  // however this is possible only when the main loop event handler is running,
442  // so we use it to run the rebuild function.
443  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
444 
445  wxPostEvent( this, cmd );
446 
447  PrintPrjInfo();
448 
449  KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
450  m_openSavedWindows = true;
451 }
452 
453 
454 void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName, bool aCreateStubFiles )
455 {
456  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
457  "Project folder must exist and be writable to create a new project." );
458 
459  // If the project is legacy, convert it
460  if( !aProjectFileName.FileExists() )
461  {
462  wxFileName legacyPro( aProjectFileName );
463  legacyPro.SetExt( LegacyProjectFileExtension );
464 
465  if( legacyPro.FileExists() )
466  {
467  GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
469 
470  wxRemoveFile( legacyPro.GetFullPath() );
471  }
472  else
473  {
474  // Copy template project file from template folder.
475  wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
476 
477  wxFileName destFileName( aProjectFileName );
478  destFileName.SetExt( ProjectFileExtension );
479 
480  // Create a minimal project file if the template project file could not be copied
481  if( !wxFileName::FileExists( srcFileName )
482  || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
483  {
484  wxFFile file( destFileName.GetFullPath(), "wb" );
485 
486  if( file.IsOpened() )
487  file.Write( wxT( "{\n}\n") );
488  // wxFFile dtor will close the file
489  }
490  }
491  }
492 
493  // Create a "stub" for a schematic root sheet and a board if requested.
494  // It will avoid messages from the schematic editor or the board editor to create a new file
495  // And forces the user to create main files under the right name for the project manager
496  if( aCreateStubFiles )
497  {
498  wxFileName fn( aProjectFileName.GetFullPath() );
499  fn.SetExt( KiCadSchematicFileExtension );
500 
501  // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic file )
502  if( !fn.FileExists() )
503  {
504  wxFFile file( fn.GetFullPath(), "wb" );
505 
506  if( file.IsOpened() )
507  file.Write( wxString::Format( "(kicad_sch (version %d) (generator eeschema)\n"
508  " (paper \"A4\")\n (lib_symbols)\n"
509  " (symbol_instances)\n)\n",
511 
512 
513  // wxFFile dtor will close the file
514  }
515 
516  // If a <project>.kicad_pcb or <project>.brd file does not exist,
517  // create a .kicad_pcb "stub" file
518  fn.SetExt( KiCadPcbFileExtension );
519  wxFileName leg_fn( fn );
520  leg_fn.SetExt( LegacyPcbFileExtension );
521 
522  if( !fn.FileExists() && !leg_fn.FileExists() )
523  {
524  wxFFile file( fn.GetFullPath(), "wb" );
525 
526  if( file.IsOpened() )
527  // Create a small dummy file as a stub for pcbnew:
528  file.Write( wxString::Format( "(kicad_pcb (version %d) (generator pcbnew)\n)",
530 
531  // wxFFile dtor will close the file
532  }
533  }
534 
535  UpdateFileHistory( aProjectFileName.GetFullPath() );
536 
537  m_openSavedWindows = true;
538 }
539 
540 
541 void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
542 {
543  // show all files in file dialog (in Kicad all files are editable texts):
544  wxString wildcard = AllFilesWildcard();
545 
546  wxString default_dir = Prj().GetProjectPath();
547 
548  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
549  wxEmptyString, wildcard, wxFD_OPEN );
550 
551  if( dlg.ShowModal() == wxID_CANCEL )
552  return;
553 
554  wxString filename = wxT( "\"" );
555  filename += dlg.GetPath() + wxT( "\"" );
556 
557  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
559 }
560 
561 
562 void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
563 {
564  // open project directory in host OS's file explorer
565  LaunchExternal( Prj().GetProjectPath() );
566 }
567 
568 
570 {
572 }
573 
574 
575 void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
576 {
577  int id = event.GetId();
578  Kiway().SetLanguage( id );
579 }
580 
581 
583 {
584  // call my base class
586 
587  // tooltips in toolbars
590 
591  PrintPrjInfo();
592 }
593 
594 
595 void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
596 {
597  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
598 }
599 
600 
602 {
603  wxString app = wxS( "KiCad " ) + GetMajorMinorVersion();
604  wxString file = GetProjectFileName();
605  wxString title;
606 
607  if( !file.IsEmpty() )
608  {
609  wxFileName fn( file );
610 
611  title += fn.GetName();
612 
613  if( !fn.IsDirWritable() )
614  title += wxS( " " ) + _( "[Read Only]" );
615 
616  title += wxS(" \u2014 ");
617  }
618 
619  title += app;
620 
621  SetTitle( title );
622 }
623 
624 
626 {
628 
629  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
630 
631  wxCHECK( settings, /*void*/);
632 
633  m_leftWinWidth = settings->m_LeftWinWidth;
634 }
635 
636 
638 {
640 
641  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
642 
643  wxCHECK( settings, /*void*/);
644 
645  settings->m_LeftWinWidth = m_leftWin->GetSize().x;
646 }
647 
648 
650  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
651 {
652  aHotkeysPanel->AddHotKeys( GetToolManager() );
653 }
654 
655 
657 {
658  SetStatusText( wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() ) );
659 
660 }
661 
662 
664 {
665  return m_active_project;
666 }
667 
668 
669 void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
670 {
676  if( !m_openSavedWindows )
677  return;
678 
679  m_openSavedWindows = false;
680 
681  if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
682  {
683  int previousOpenCount =
684  std::count_if( Prj().GetLocalSettings().m_files.begin(),
685  Prj().GetLocalSettings().m_files.end(),
686  [&]( const PROJECT_FILE_STATE& f )
687  {
688  return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
689  } );
690 
691  if( previousOpenCount > 0 )
692  {
693  APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
694  previousOpenCount, this );
695 
696  int i = 0;
697 
698  for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
699  {
700  if( file.open )
701  {
702  progressReporter.Update( i++,
703  wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
704 
705  wxFileName fn( file.fileName );
706 
707  if( fn.GetExt() == LegacySchematicFileExtension
708  || fn.GetExt() == KiCadSchematicFileExtension )
709  {
711  }
712  else if( fn.GetExt() == LegacyPcbFileExtension
713  || fn.GetExt() == KiCadPcbFileExtension )
714  {
716  }
717  }
718 
719  wxYield();
720  }
721  }
722  }
723 
724  // clear file states regardless if we opened windows or not due to setting
726 }
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:56
void language_change(wxCommandEvent &event)
const BITMAP_OPAQUE icon_kicad_16_xpm[1]
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:88
const std::string LegacyPcbFileExtension
void OnIdle(wxIdleEvent &event)
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
PANEL_KICAD_LAUNCHER * m_launcher
const BITMAP_OPAQUE icon_kicad_xpm[1]
Definition: icon_kicad.cpp:183
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:141
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:447
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.
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:52
void OnImportCadstarArchiveFiles(wxCommandEvent &event)
Open dialog to import CADSTAR Schematic and PCB Archive files.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
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:158
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 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.
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:85
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
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:157
const wxString PcbLegacyFileName()
static TOOL_ACTION saveAs
Definition: actions.h:55
std::vector< wxString > GetOpenProjects() const
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:197
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.
virtual void DispatchWxCommand(wxCommandEvent &aEvent)
Process wxCommands (mostly menu related events) and runs appropriate actions (eg.
#define KICAD_MANAGER_FRAME_NAME
#define _(s)
Definition: 3d_actions.cpp:33
void OnSize(wxSizeEvent &event)
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
Definition: id.h:87
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
void LoadProject(const wxFileName &aProjectFileName)
void OnUnarchiveFiles(wxCommandEvent &event)
void InitTools()
Initializes all registered tools.
static REPORTER & GetInstance()
Definition: reporter.cpp:105
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
Symbol library 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:26
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
const BITMAP_OPAQUE icon_kicad_32_xpm[1]
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:26
KIWAY Kiway