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 "tree_project_frame.h"
29 #include <bitmaps.h>
30 #include <build_version.h>
31 #include <executable_names.h>
32 #include <filehistory.h>
33 #include <gestfich.h>
34 #include <kiplatform/app.h>
35 #include <kiway.h>
36 #include <kiway_express.h>
37 #include <kiway_player.h>
38 #include <launch_ext.h>
39 #include <panel_hotkeys_editor.h>
40 #include <reporter.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 
54 #ifdef __WXMAC__
55 #include <MacTypes.h>
56 #include <ApplicationServices/ApplicationServices.h>
57 #endif
58 
59 #include "kicad_manager_frame.h"
60 #include "kicad_settings.h"
61 
62 
63 #define SEP() wxFileName::GetPathSeparator()
64 
65 
66 // Menubar and toolbar event table
67 BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
68  // Window events
69  EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
70  EVT_IDLE( KICAD_MANAGER_FRAME::OnIdle )
71 
72  // Menu events
73  EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
79 
80  // Range menu events
82  KICAD_MANAGER_FRAME::language_change )
83 
85  EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
86 
87  // Special functions
88  EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
89 END_EVENT_TABLE()
90 
91 
92 KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
93  const wxPoint& pos, const wxSize& size ) :
94  EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
96  m_leftWin( nullptr ),
97  m_launcher( nullptr ),
98  m_messagesBox( nullptr ),
99  m_mainToolBar( nullptr )
100 {
101  m_active_project = false;
102  m_leftWinWidth = 250; // Default value
103  m_AboutTitle = "KiCad";
104 
105  // Create the status line (bottom of the frame)
106  static const int dims[3] = { -1, -1, 100 };
107 
108  CreateStatusBar( 3 );
109  SetStatusWidths( 3, dims );
110 
111  // Give an icon
112  wxIcon icon;
113  icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) );
114  SetIcon( icon );
115 
116  // Load the settings
117  LoadSettings( config() );
118 
119  // Left window: is the box which display tree project
120  m_leftWin = new TREE_PROJECT_FRAME( this );
121 
122  // Add the wxTextCtrl showing all messages from KiCad:
123  m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
124  wxDefaultPosition, wxDefaultSize,
125  wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE );
126 
127  setupTools();
128  setupUIConditions();
129 
130  RecreateBaseHToolbar();
131  RecreateLauncher();
132  ReCreateMenuBar();
133 
134  m_auimgr.SetManagedWindow( this );
135 
136  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
137 
138  // BestSize() does not always set the actual pane size of m_leftWin to the required value.
139  // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
140  // (Well, BestSize() sets the best size... not the window size)
141  // A trick is to use MinSize() to set the required pane width,
142  // and after give a reasonable MinSize value
143  m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer(3)
144  .CaptionVisible( false ).PaneBorder( false )
145  .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
146 
147  m_auimgr.AddPane( m_launcher, EDA_PANE().HToolbar().Name( "Launcher" ).Top().Layer(1) );
148 
149  m_auimgr.AddPane( m_messagesBox, EDA_PANE().Messages().Name( "MsgPanel" ).Center() );
150 
151  m_auimgr.Update();
152 
153  // Now the actual m_leftWin size is set, give it a reasonable min width
154  m_auimgr.GetPane( m_leftWin ).MinSize( 200, -1 );
155 
156  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
157 
158  // Do not let the messages window have initial focus
159  m_leftWin->SetFocus();
160 
161  // Ensure the window is on top
162  Raise();
163 }
164 
165 
167 {
168  // Shutdown all running tools
169  if( m_toolManager )
171 
172  delete m_actions;
173  delete m_toolManager;
174  delete m_toolDispatcher;
175 
176  m_auimgr.UnInit();
177 }
178 
179 
181 {
182  // Create the manager
184  m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
186 
188 
189  // Attach the events to the tool dispatcher
192  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
193 
194  // Register tools
198 }
199 
200 
202 {
204 
206 
207  wxASSERT( manager );
208 
209  auto activeProject =
210  [this] ( const SELECTION& )
211  {
212  return m_active_project;
213  };
214 
215  ACTION_CONDITIONS activeProjectCond;
216  activeProjectCond.Enable( activeProject );
217 
218  manager->SetConditions( KICAD_MANAGER_ACTIONS::editSchematic, activeProjectCond );
219  manager->SetConditions( KICAD_MANAGER_ACTIONS::editPCB, activeProjectCond );
220  manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
221  manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
222 
223  // TODO: Switch this to an action
224  RegisterUIUpdateHandler( ID_SAVE_AND_ZIP_FILES, activeProjectCond );
225 }
226 
227 
229 {
230  return m_leftWin;
231 }
232 
233 
235 {
237  wxASSERT( ret );
238  return ret;
239 }
240 
241 
243 {
244  KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
245  wxASSERT( ret );
246  return ret;
247 }
248 
249 
251 {
252  return Pgm().GetSettingsManager().IsProjectOpen() ? Prj().GetProjectFullName() : wxString( wxEmptyString );
253 }
254 
255 
257 {
258  wxFileName fn( GetProjectFileName() );
259 
260  fn.SetExt( KiCadSchematicFileExtension );
261  return fn.GetFullPath();
262 }
263 
264 
266 {
267  wxFileName fn( GetProjectFileName() );
268 
269  fn.SetExt( LegacySchematicFileExtension );
270  return fn.GetFullPath();
271 }
272 
273 
275 {
276  wxFileName fn( GetProjectFileName() );
277 
278  fn.SetExt( PcbFileExtension );
279  return fn.GetFullPath();
280 }
281 
282 
284 {
285  wxFileName fn( GetProjectFileName() );
286 
287  fn.SetExt( LegacyPcbFileExtension );
288  return fn.GetFullPath();
289 }
290 
291 
293 {
295 }
296 
297 
299 {
300  return PgmTop().SysSearch();
301 }
302 
303 
305 {
306  return PgmTop().GetHelpFileName();
307 }
308 
309 
310 void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText )
311 {
312  m_messagesBox->AppendText( aText );
313 }
314 
315 
316 void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
317 {
318  if( m_auimgr.GetManagedWindow() )
319  m_auimgr.Update();
320 
321  event.Skip();
322 }
323 
324 
325 bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
326 {
327  KICAD_SETTINGS* settings = kicadSettings();
329 
330  // CloseProject will recursively ask all the open editors if they need to save changes.
331  // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
332  if( CloseProject( true ) )
333  {
334  return true;
335  }
336  else
337  {
338  if( aEvent.CanVeto() )
339  aEvent.Veto();
340 
341  return false;
342  }
343 }
344 
345 
347 {
348 #ifdef _WINDOWS_
349  // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
350  // if a editor frame (schematic, library, board editor or fp editor) is open and has
351  // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
352  // conditions between OnCloseWindow() code.
353  // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
354  // execution of the first call (only one call is right).
355  // Note also if there is no change made in editors, this behavior does not happen.
356  static std::atomic<unsigned int> lock_close_event( 0 );
357 
358  if( ++lock_close_event > 1 ) // Skip extra calls
359  {
360  return;
361  }
362 #endif
363 
364  m_leftWin->Show( false );
365 
366  Destroy();
367 
368 #ifdef _WINDOWS_
369  lock_close_event = 0; // Reenable event management
370 #endif
371 }
372 
373 
374 void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
375 {
376  Close( true );
377 }
378 
379 
381 {
382  if( !Kiway().PlayersClose( false ) )
383  return false;
384 
385  // Save the project file for the currently loaded project.
386  if( m_active_project )
387  {
388  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
389 
391 
392  if( aSave )
393  {
394  mgr.SaveProject();
395  }
396 
397  m_active_project = false;
398  mgr.UnloadProject( &Prj() );
399  }
400 
401  ClearMsg();
402 
404 
405  return true;
406 }
407 
408 
409 void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
410 {
411  // The project file should be valid by the time we get here or something has gone wrong.
412  if( !aProjectFileName.Exists() )
413  return;
414 
415  // Any open KIFACE's must be closed if they are not part of the new project.
416  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
417  // User is prompted here to close those KIWAY_PLAYERs:
418  CloseProject( true );
419 
420  m_active_project = true;
421 
422  Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
423 
424  LoadWindowState( aProjectFileName.GetFullName() );
425 
426  if( aProjectFileName.IsDirWritable() )
427  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
428 
429  UpdateFileHistory( Prj().GetProjectFullName() );
430 
432 
433  // Rebuild the list of watched paths.
434  // however this is possible only when the main loop event handler is running,
435  // so we use it to run the rebuild function.
436  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
437 
438  wxPostEvent( this, cmd );
439 
440  PrintPrjInfo();
441 
442  KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
443  m_openSavedWindows = true;
444 }
445 
446 
447 void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName, bool aCreateStubFiles )
448 {
449  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
450  "Project folder must exist and be writable to create a new project." );
451 
452  // If the project is legacy, convert it
453  if( !aProjectFileName.FileExists() )
454  {
455  wxFileName legacyPro( aProjectFileName );
456  legacyPro.SetExt( LegacyProjectFileExtension );
457 
458  if( legacyPro.FileExists() )
459  {
460  GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
462 
463  wxRemoveFile( legacyPro.GetFullPath() );
464  }
465  else
466  {
467  // Copy template project file from template folder.
468  wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
469 
470  wxFileName destFileName( aProjectFileName );
471  destFileName.SetExt( ProjectFileExtension );
472 
473  // Create a minimal project file if the template project file could not be copied
474  if( !wxFileName::FileExists( srcFileName )
475  || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
476  {
477  wxFile file( destFileName.GetFullPath(), wxFile::write );
478 
479  if( file.IsOpened() )
480  file.Write( wxT( "{\n}\n") );
481  // wxFile dtor will close the file
482  }
483  }
484  }
485 
486  // Create a "stub" for a schematic root sheet and a board if requested.
487  // It will avoid messages from the schematic editor or the board editor to create a new file
488  // And forces the user to create main files under the right name for the project manager
489  if( aCreateStubFiles )
490  {
491  wxFileName fn( aProjectFileName.GetFullPath() );
492  fn.SetExt( KiCadSchematicFileExtension );
493 
494  // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic file )
495  if( !fn.FileExists() )
496  {
497  wxFile file( fn.GetFullPath(), wxFile::write );
498 
499  if( file.IsOpened() )
500  file.Write( wxT( "(kicad_sch (version 20200310) (host eeschema \"unknown\")\n"
501  "( page \"A4\")\n (lib_symbols)\n"
502  " (symbol_instances)\n)\n" ) );
503 
504 
505  // wxFile dtor will close the file
506  }
507 
508  // If a <project>.kicad_pcb or <project>.brd file does not exist,
509  // create a .kicad_pcb "stub" file
510  fn.SetExt( KiCadPcbFileExtension );
511  wxFileName leg_fn( fn );
512  leg_fn.SetExt( LegacyPcbFileExtension );
513 
514  if( !fn.FileExists() && !leg_fn.FileExists() )
515  {
516  wxFile file( fn.GetFullPath(), wxFile::write );
517 
518  if( file.IsOpened() )
519  file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );
520 
521  // wxFile dtor will close the file
522  }
523  }
524 
525  UpdateFileHistory( aProjectFileName.GetFullPath() );
526 
527  m_openSavedWindows = true;
528 }
529 
530 
531 void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
532 {
533  // show all files in file dialog (in Kicad all files are editable texts):
534  wxString wildcard = AllFilesWildcard();
535 
536  wxString default_dir = Prj().GetProjectPath();
537 
538  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
539  wxEmptyString, wildcard, wxFD_OPEN );
540 
541  if( dlg.ShowModal() == wxID_CANCEL )
542  return;
543 
544  wxString filename = wxT( "\"" );
545  filename += dlg.GetPath() + wxT( "\"" );
546 
547  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
549 }
550 
551 
552 void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
553 {
554  // open project directory in host OS's file explorer
555  LaunchExternal( Prj().GetProjectPath() );
556 }
557 
558 
560 {
562 }
563 
564 
565 void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
566 {
567  int id = event.GetId();
568  Kiway().SetLanguage( id );
569 }
570 
571 
573 {
574  // call my base class
576 
577  // tooltips in toolbars
580 
581  PrintPrjInfo();
582 }
583 
584 
585 void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
586 {
587  EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
588 }
589 
590 
592 {
593  wxString app = wxS( "KiCad " ) + GetMajorMinorVersion();
594  wxString file = GetProjectFileName();
595  wxString title;
596 
597  if( !file.IsEmpty() )
598  {
599  wxFileName fn( file );
600 
601  title += fn.GetName();
602 
603  if( !fn.IsDirWritable() )
604  title += _( " [Read Only]" );
605 
606  title += wxS(" \u2014 ");
607  }
608 
609  title += app;
610 
611  SetTitle( title );
612 }
613 
614 
616 {
617  m_messagesBox->Clear();
618 }
619 
620 
622 {
624 
625  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
626 
627  wxCHECK( settings, /*void*/);
628 
629  m_leftWinWidth = settings->m_LeftWinWidth;
630 }
631 
632 
634 {
636 
637  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
638 
639  wxCHECK( settings, /*void*/);
640 
641  settings->m_LeftWinWidth = m_leftWin->GetSize().x;
642 }
643 
644 
646  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
647 {
648  aHotkeysPanel->AddHotKeys( GetToolManager() );
649 }
650 
651 
653 {
654  wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
656  PrintMsg( msg );
657 }
658 
659 
661 {
662  return m_active_project;
663 }
664 
665 
666 void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
667 {
673  if( !m_openSavedWindows )
674  return;
675 
676  m_openSavedWindows = false;
677 
678  if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
679  {
680  int previousOpenCount =
681  std::count_if( Prj().GetLocalSettings().m_files.begin(),
682  Prj().GetLocalSettings().m_files.end(),
683  [&]( const PROJECT_FILE_STATE& f )
684  {
685  return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
686  } );
687 
688  if( previousOpenCount > 0 )
689  {
690  APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
691  previousOpenCount, this );
692 
693  int i = 0;
694 
695  for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
696  {
697  if( file.open )
698  {
699  progressReporter.Update( i++,
700  wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
701 
702  wxFileName fn( file.fileName );
703 
704  if( fn.GetExt() == LegacySchematicFileExtension
705  || fn.GetExt() == KiCadSchematicFileExtension )
706  {
708  }
709  else if( fn.GetExt() == LegacyPcbFileExtension
710  || fn.GetExt() == KiCadPcbFileExtension )
711  {
713  }
714  }
715 
716  wxYield();
717  }
718  }
719  }
720 
721  // clear file states regardless if we opened windows or not due to setting
723 }
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.
KiCad executable names.
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:73
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void language_change(wxCommandEvent &event)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
const wxString GetProjectFileName() const
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Function InstallPreferences Allow a frame to load its preference panels (if any) into the preferences...
void SetMruPath(const wxString &aPath)
SEARCH_STACK & SysSearch()
Definition: pgm_kicad.h:58
This file is part of the common library TODO brief description.
SETTINGS_MANAGER * GetSettingsManager() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Saves 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)
VTBL_ENTRY PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:147
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
const BITMAP_OPAQUE icon_kicad_xpm[1]
Definition: icon_kicad.cpp:153
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)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
virtual void RegisterUIUpdateHandler(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions) override
Register an action's update conditions with the UI layer to allow the UI to appropriately display the...
void AddHotKeys(TOOL_MANAGER *aToolMgr)
KICAD_MANAGER_CONTROL.
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
std::vector< wxString > m_OpenProjects
wxAuiManager m_auimgr
ACTION_MANAGER.
const std::string KiCadPcbFileExtension
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs.
Definition: kiway.cpp:445
void LoadWindowState(const wxString &aFileName)
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:124
wxString AllFilesWildcard()
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
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
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
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
wxString GetBuildVersion()
Get the full KiCad version string.
TREE_PROJECT_FRAME Window to display the tree files.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
virtual void DispatchWxEvent(wxEvent &aEvent)
Processes wxEvents (mostly UI events), translates them to TOOL_EVENTs, and makes tools handle those.
wxString help_name() override
ACTIONS * m_actions
Definition: tools_holder.h:51
Definition of file extensions used in Kicad.
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=NULL) override
void ReCreateTreePrj()
Create or modify the tree showing project file names.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PcbFileExtension
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:118
void EmptyTreePrj()
Delete all m_TreeProject entries.
const std::string LegacyProjectFileExtension
COMMON_CONTROL.
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:72
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:52
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.
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:50
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
const wxString PcbLegacyFileName()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
static TOOL_ACTION saveAs
Definition: actions.h:55
std::vector< wxString > GetOpenProjects() const
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:199
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
virtual void DispatchWxCommand(wxCommandEvent &aEvent)
Processes 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 ...
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:56
const std::string KiCadSchematicFileExtension
wxProgressDialog with the option to also update the application progress on the taskbar
wxString GetHelpFileName()
Definition: pgm_kicad.h:60
Definition: id.h:87
KICAD_MANAGER_ACTIONS.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
void LoadProject(const wxFileName &aProjectFileName)
void OnUnarchiveFiles(wxCommandEvent &event)
void InitTools()
Function 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.
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.
void ClearMsg()
Erase the text panel.
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.
TREE_PROJECT_FRAME * m_leftWin
The main KiCad project manager frame.
static TOOL_ACTION openTextEditor
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds 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