KiCad PCB EDA Suite
KICAD_MANAGER_FRAME Class Reference

The main KiCad project manager frame. More...

#include <kicad.h>

Inheritance diagram for KICAD_MANAGER_FRAME:
EDA_BASE_FRAME KIWAY_HOLDER

Classes

class  TERMINATE_HANDLER
 

Public Member Functions

 KICAD_MANAGER_FRAME (wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
 
 ~KICAD_MANAGER_FRAME ()
 
void OnCloseWindow (wxCloseEvent &Event)
 
void OnSize (wxSizeEvent &event)
 
void OnLoadProject (wxCommandEvent &event)
 Load an exiting project (.pro) file. More...
 
void OnCreateProjectFromTemplate (wxCommandEvent &event)
 Creates a new project folder, copy a template into this new folder. More...
 
void OnNewProject (wxCommandEvent &aEvent)
 
void OnSaveProject (wxCommandEvent &event)
 Save the project (.pro) file containing the top level configuration parameters. More...
 
void OnArchiveFiles (wxCommandEvent &event)
 
void OnUnarchiveFiles (wxCommandEvent &event)
 
void OnRunEeschema (wxCommandEvent &event)
 
void OnRunSchLibEditor (wxCommandEvent &event)
 
void OnRunPcbNew (wxCommandEvent &event)
 
void OnRunPcbFpEditor (wxCommandEvent &event)
 
void OnRunGerbview (wxCommandEvent &event)
 
void OnRunBitmapConverter (wxCommandEvent &event)
 
void OnRunPcbCalculator (wxCommandEvent &event)
 
void OnRunPageLayoutEditor (wxCommandEvent &event)
 
void OnConfigurePaths (wxCommandEvent &aEvent)
 
void OnEditSymLibTable (wxCommandEvent &aEvent)
 
void OnEditFpLibTable (wxCommandEvent &aEvent)
 
void OnPreferences (wxCommandEvent &aEvent)
 
void OnOpenTextEditor (wxCommandEvent &event)
 
void OnOpenFileInTextEditor (wxCommandEvent &event)
 
void OnBrowseInFileExplorer (wxCommandEvent &event)
 
void OnShowHotkeys (wxCommandEvent &event)
 
void OnFileHistory (wxCommandEvent &event)
 
void OnExit (wxCommandEvent &event)
 
void ReCreateMenuBar () override
 (Re)Create the menubar More...
 
void RecreateBaseHToolbar ()
 (Re)Create the horizontal toolbar More...
 
void OnImportEagleFiles (wxCommandEvent &event)
 Open dialog to import Eagle schematic and board files. More...
 
void PrintMsg (const wxString &aText)
 Displays aText in the text panel. More...
 
void PrintPrjInfo ()
 Prints the current working directory name and the projet name on the text panel. More...
 
void ClearMsg ()
 Erase the text panel. More...
 
void OnRefresh (wxCommandEvent &event)
 
void OnUpdateRequiresProject (wxUpdateUIEvent &event)
 
void CreateNewProject (const wxFileName &aProjectFileName)
 Creates a new project by setting up and initial project, schematic, and board files. More...
 
void LoadProject (const wxFileName &aProjectFileName)
 
void LoadSettings (wxConfigBase *aCfg) override
 Function LoadSettings loads common frame parameters from a configuration file. More...
 
void SaveSettings (wxConfigBase *aCfg) override
 Function SaveSettings saves common frame parameters to a configuration data file. More...
 
void CommonSettingsChanged () override
 Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have changed. More...
 
void Execute (wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
 Open another KiCad application and logs a message. More...
 
void OnChangeWatchedPaths (wxCommandEvent &aEvent)
 Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of wahtched paths. More...
 
void SetProjectFileName (const wxString &aFullProjectProFileName)
 
const wxString GetProjectFileName ()
 
const wxString SchFileName ()
 
const wxString PcbFileName ()
 
const wxString PcbLegacyFileName ()
 
void ReCreateTreePrj ()
 
void RunPcbNew (const wxString &aProjectBoardFileName)
 Call this only for a PCB associated with the current project. More...
 
void RunEeschema (const wxString &aProjectSchematicFileName)
 Call this only for a SCH associated with the current project. More...
 
bool ProcessEvent (wxEvent &aEvent) override
 Function ProcessEvent overrides the default process event handler to implement the auto save feature. More...
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
void GetKicadHelp (wxCommandEvent &event)
 
void GetKicadContribute (wxCommandEvent &event)
 
void GetKicadAbout (wxCommandEvent &event)
 
bool ShowPreferences (EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
 
virtual void InstallPreferences (PAGED_DIALOG *aParent)
 Function InstallPreferences allows a Frame to load its preference panels (if any) into the preferences dialog. More...
 
wxString ConfigBaseName ()
 Function ConfigBaseName. More...
 
virtual void SaveProjectSettings (bool aAskForSave)
 Function SaveProjectSettings saves changes to the project settings to the project (.pro) file. More...
 
virtual int WriteHotkeyConfig (struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
 Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mechanism or a file. More...
 
void ImportHotkeyConfigFromFile (EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
 Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it. More...
 
void ExportHotkeyConfigToFile (EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
 Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
 Function GetFileFromHistory fetches the file name from the file history list. More...
 
void UpdateFileHistory (const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
 Function UpdateFileHistory Updates the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
bool IsWritable (const wxFileName &aFileName)
 Function IsWritable checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName, const wxString &aBackupFileExtension)
 Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
virtual void ShowChangedLanguage ()
 Function ShowChangedLanguage redraws the menus and what not in current language. More...
 
bool PostCommandMenuEvent (int evt_type)
 Function PostCommandMenuEvent. More...
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
VTBL_ENTRY EDA_UNITS_T GetUserUnits () const
 Function GetUserUnits Allows participation in KEYWAY_PLAYER/DIALOG_SHIM userUnits inheritance. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Protected Member Functions

void onAutoSaveTimer (wxTimerEvent &aEvent)
 Function onAutoSaveTimer handles the auto save timer event. More...
 
virtual bool isAutoSaveRequired () const
 Function autoSaveRequired returns the auto save status of the application. More...
 
virtual bool doAutoSave ()
 Function doAutoSave should be overridden by the derived class to handle the auto save feature. More...
 

Protected Attributes

FRAME_T m_Ident
 Id Type (pcb, schematic, library..) More...
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_configFrameName
 prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTOR is used More...
 
wxAuiToolBar * m_mainToolBar
 Standard horizontal Toolbar. More...
 
wxString m_AboutTitle
 Name of program displayed in About. More...
 
wxAuiManager m_auimgr
 
bool m_hasAutoSave
 Flag to indicate if this frame supports auto save. More...
 
bool m_autoSaveState
 Flag to indicate the last auto save state. More...
 
int m_autoSaveInterval
 The auto save interval time in seconds. More...
 
wxTimer * m_autoSaveTimer
 The timer used to implement the auto save feature;. More...
 
wxString m_perspective
 wxAuiManager perspective. More...
 
wxString m_mruPath
 Most recently used path. More...
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private Member Functions

wxConfigBase * config () override
 Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
const SEARCH_STACKsys_search () override
 Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_MANAGER_FRAME. More...
 
wxString help_name () override
 
void language_change (wxCommandEvent &event)
 

Private Attributes

TREE_PROJECT_FRAMEm_LeftWin
 
LAUNCHER_PANELm_Launcher
 
wxTextCtrl * m_MessagesBox
 
wxAuiToolBar * m_VToolBar
 
int m_leftWinWidth
 
EDA_HOTKEY_CONFIGm_manager_Hokeys_Descr
 
bool m_active_project
 

Detailed Description

The main KiCad project manager frame.

It is not a KIWAY_PLAYER.

Definition at line 135 of file kicad.h.

Constructor & Destructor Documentation

KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME ( wxWindow *  parent,
const wxString &  title,
const wxPoint pos,
const wxSize &  size 
)

Definition at line 56 of file mainframe.cpp.

References PCAD2KICAD::Center, config(), GetBuildVersion(), LAUNCHER_PANEL::GetPanelHeight(), LAUNCHER_PANEL::GetPanelWidth(), KiBitmap(), PCAD2KICAD::Left, LoadSettings(), m_active_project, EDA_BASE_FRAME::m_auimgr, EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, m_Launcher, m_LeftWin, m_leftWinWidth, EDA_BASE_FRAME::m_mainToolBar, m_manager_Hokeys_Descr, m_MessagesBox, RecreateBaseHToolbar(), ReCreateMenuBar(), wxPoint::x, and wxPoint::y.

57  :
58  EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
60  KIWAY_HOLDER( &::Kiway )
61 {
62  m_active_project = false;
63  m_leftWinWidth = 60;
65 
66  // Create the status line (bottom of the frame)
67  static const int dims[3] = { -1, -1, 100 };
68 
69  CreateStatusBar( 3 );
70  SetStatusWidths( 3, dims );
71 
72  // Give an icon
73  wxIcon icon;
74  icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) );
75  SetIcon( icon );
76 
77  // Give the last size and pos to main window
78  LoadSettings( config() );
79  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
80 
81  // Left window: is the box which display tree project
82  m_LeftWin = new TREE_PROJECT_FRAME( this );
83 
84  // Right top Window: buttons to launch applications
85  m_Launcher = new LAUNCHER_PANEL( this );
86 
87  // Add the wxTextCtrl showing all messages from KiCad:
88  m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
89  wxDefaultPosition, wxDefaultSize,
90  wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE );
91 
94 
95  m_auimgr.SetManagedWindow( this );
96 
97  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
98 
99  m_auimgr.AddPane( m_LeftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer(3)
100  .CaptionVisible( false ).PaneBorder( false )
101  .MinSize( 150, -1 ).BestSize( m_leftWinWidth, -1 ) );
102 
103  m_auimgr.AddPane( m_Launcher, EDA_PANE().HToolbar().Name( "Launcher" ).Top().Layer(1)
104  .MinSize( m_Launcher->GetPanelWidth(), m_Launcher->GetPanelHeight() ) );
105 
106  m_auimgr.AddPane( m_MessagesBox, EDA_PANE().Messages().Name( "MsgPanel" ).Center() );
107 
108  m_auimgr.Update();
109 
110  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
111 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
class LAUNCHER_PANEL
Definition: kicad.h:310
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: mainframe.cpp:526
wxAuiManager m_auimgr
int GetPanelHeight() const
LAUNCHER_PANEL * m_Launcher
Definition: kicad.h:295
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
class TREE_PROJECT_FRAME Window to display the tree files
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:300
KIWAY_HOLDER(KIWAY *aKiway)
Definition: kiway_player.h:51
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
Specialization of the wxAuiPaneInfo class for KiCad panels.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void ReCreateMenuBar() override
(Re)Create the menubar
int GetPanelWidth() const
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
wxConfigBase * config() override
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: mainframe.cpp:120
bool m_active_project
Definition: kicad.h:304
#define KICAD_MANAGER_FRAME_NAME
Definition: kicad.h:40
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME ( )

Definition at line 114 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

115 {
116  m_auimgr.UnInit();
117 }
wxAuiManager m_auimgr

Member Function Documentation

void EDA_BASE_FRAME::CheckForAutoSaveFile ( const wxFileName &  aFileName,
const wxString &  aBackupFileExtension 
)
inherited

Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropriate action depending on the user input.

If an auto save file exists for aFileName, the user is prompted if they wish to replace file aFileName with the auto saved file. If the user chooses to replace the file, the backup file of aFileName is removed, aFileName is renamed to the backup file name, and the auto save file is renamed to aFileName. If user chooses to keep the existing version of aFileName, the auto save file is removed.

Parameters
aFileNameA wxFileName object containing the file name to check.
aBackupFileExtensionA wxString object containing the backup file extension used to create the backup file name.

Definition at line 585 of file eda_base_frame.cpp.

References AUTOSAVE_PREFIX_FILENAME, Format(), GetChars(), Pgm(), and traceAutoSave.

Referenced by EDA_BASE_FRAME::GetMruPath(), and PCB_EDIT_FRAME::OpenProjectFiles().

587 {
588  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
589  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
590 
591  wxFileName autoSaveFileName = aFileName;
592 
593  // Check for auto save file.
594  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
595 
596  wxLogTrace( traceAutoSave,
597  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
598 
599  if( !autoSaveFileName.FileExists() )
600  return;
601 
602  wxString msg = wxString::Format( _(
603  "Well this is potentially embarrassing!\n"
604  "It appears that the last time you were editing the file\n"
605  "\"%s\"\n"
606  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
607  GetChars( aFileName.GetFullName() )
608  );
609 
610  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
611 
612  // Make a backup of the current file, delete the file, and rename the auto save file to
613  // the file name.
614  if( response == wxYES )
615  {
616  // Get the backup file name.
617  wxFileName backupFileName = aFileName;
618  backupFileName.SetExt( aBackupFileExtension );
619 
620  // If an old backup file exists, delete it. If an old copy of the file exists, rename
621  // it to the backup file name
622  if( aFileName.FileExists() )
623  {
624  // Remove the old file backup file.
625  if( backupFileName.FileExists() )
626  wxRemoveFile( backupFileName.GetFullPath() );
627 
628  // Rename the old file to the backup file name.
629  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
630  {
631  msg.Printf( _( "Could not create backup file \"%s\"" ),
632  GetChars( backupFileName.GetFullPath() ) );
633  wxMessageBox( msg );
634  }
635  }
636 
637  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
638  {
639  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
640  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
641  }
642  }
643  else
644  {
645  wxLogTrace( traceAutoSave,
646  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
647 
648  // Remove the auto save file when using the previous file as is.
649  wxRemoveFile( autoSaveFileName.GetFullPath() );
650  }
651 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
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:92
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:205
void KICAD_MANAGER_FRAME::ClearMsg ( )

Erase the text panel.

Definition at line 520 of file mainframe.cpp.

References m_MessagesBox.

Referenced by LoadProject(), OnCreateProjectFromTemplate(), and OnImportEagleFiles().

521 {
522  m_MessagesBox->Clear();
523 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
void KICAD_MANAGER_FRAME::CommonSettingsChanged ( )
overridevirtual

Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have changed.

Update menus, toolbars, local variables, etc.

Reimplemented from EDA_BASE_FRAME.

Definition at line 512 of file mainframe.cpp.

References PGM_BASE::CommonSettings(), DEFAULT_FILE_HISTORY_SIZE, FILE_HISTORY_SIZE_KEY, PGM_KICAD::GetFileHistory(), max, Pgm(), PgmTop(), and FILE_HISTORY::SetMaxFiles().

513 {
514  int historySize;
516  PgmTop().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) );
517 }
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:57
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
#define DEFAULT_FILE_HISTORY_SIZE
The default file history size is 9.
Definition: pgm_base.h:58
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:51
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void SetMaxFiles(size_t aMaxFiles)
Definition: pgm_base.cpp:79
#define max(a, b)
Definition: auxiliary.h:86
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
wxConfigBase * KICAD_MANAGER_FRAME::config ( )
overrideprivatevirtual

Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented from EDA_BASE_FRAME.

Definition at line 120 of file mainframe.cpp.

References PGM_KICAD::PgmSettings(), and PgmTop().

Referenced by KICAD_MANAGER_FRAME(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

121 {
122  wxConfigBase* ret = PgmTop().PgmSettings();
123  wxASSERT( ret );
124  return ret;
125 }
wxConfigBase * PgmSettings()
Definition: pgm_kicad.h:59
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited

Function ConfigBaseName.

Returns
a base name prefix used in Load/Save settings to build the full name of keys used in config. This is usually the name of the frame set by CTOR, unless m_configFrameName contains a base name. this is the case of frames which can be shown in normal or modal mode. This is needed because we want only one base name prefix, regardless the mode used.

Definition at line 269 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_configFrameName.

Referenced by DISPLAY_FOOTPRINTS_FRAME::LoadSettings(), FOOTPRINT_VIEWER_FRAME::LoadSettings(), EDA_BASE_FRAME::LoadSettings(), EDA_DRAW_FRAME::LoadSettings(), DISPLAY_FOOTPRINTS_FRAME::SaveSettings(), FOOTPRINT_VIEWER_FRAME::SaveSettings(), EDA_BASE_FRAME::SaveSettings(), and EDA_DRAW_FRAME::SaveSettings().

270  {
271  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
272  return baseCfgName;
273  }
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
void KICAD_MANAGER_FRAME::CreateNewProject ( const wxFileName &  aProjectFileName)

Creates a new project by setting up and initial project, schematic, and board files.

The project file is copied from the kicad.pro template file if possible. Otherwise, a minimal project file is created from an empty project. A minimal schematic and board file are created to prevent the schematic and board editors from complaining. If any of these files already exist, they are not overwritten.

Parameters
aProjectFileNameis the absolute path of the project file name.

Definition at line 108 of file prjconfig.cpp.

References PROJECT::ConfigSave(), SEARCH_STACK::FindValidPath(), GeneralGroupName, KiCadPcbFileExtension, LegacyPcbFileExtension, PgmTop(), KIWAY_HOLDER::Prj(), SchematicFileExtension, SetProjectFileName(), and sys_search().

Referenced by OnCreateProjectFromTemplate(), and OnNewProject().

109 {
110  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
111  "Project folder must exist and be writable to create a new project." );
112 
113  // Init project filename. This clears all elements from the project object.
114  SetProjectFileName( aProjectFileName.GetFullPath() );
115 
116  // Copy kicad.pro file from template folder.
117  if( !aProjectFileName.FileExists() )
118  {
119  wxString srcFileName = sys_search().FindValidPath( "kicad.pro" );
120 
121  // Create a minimal project (.pro) file if the template project file could not be copied.
122  if( !wxFileName::FileExists( srcFileName )
123  || !wxCopyFile( srcFileName, aProjectFileName.GetFullPath() ) )
124  {
126  }
127  }
128 
129  // Ensure a "stub" for a schematic root sheet and a board exist.
130  // It will avoid messages from the schematic editor or the board editor to create a new file
131  // And forces the user to create main files under the right name for the project manager
132  wxFileName fn( aProjectFileName.GetFullPath() );
133  fn.SetExt( SchematicFileExtension );
134 
135  // If a <project>.sch file does not exist, create a "stub" file ( minimal schematic file )
136  if( !fn.FileExists() )
137  {
138  wxFile file( fn.GetFullPath(), wxFile::write );
139 
140  if( file.IsOpened() )
141  file.Write( wxT( "EESchema Schematic File Version 2\n"
142  "EELAYER 25 0\nEELAYER END\n$EndSCHEMATC\n" ) );
143 
144  // wxFile dtor will close the file
145  }
146 
147  // If a <project>.kicad_pcb or <project>.brd file does not exist,
148  // create a .kicad_pcb "stub" file
149  fn.SetExt( KiCadPcbFileExtension );
150  wxFileName leg_fn( fn );
151  leg_fn.SetExt( LegacyPcbFileExtension );
152 
153  if( !fn.FileExists() && !leg_fn.FileExists() )
154  {
155  wxFile file( fn.GetFullPath(), wxFile::write );
156 
157  if( file.IsOpened() )
158  file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );
159 
160  // wxFile dtor will close the file
161  }
162 }
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:318
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
const std::string LegacyPcbFileExtension
const std::string KiCadPcbFileExtension
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const std::string SchematicFileExtension
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
#define GeneralGroupName
Definition: prjconfig.cpp:56
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:128
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:73
const SEARCH_STACK & sys_search() override
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
Definition: mainframe.cpp:182
bool EDA_BASE_FRAME::doAutoSave ( )
protectedvirtualinherited

Function doAutoSave should be overridden by the derived class to handle the auto save feature.

Returns
true if the auto save was successful otherwise false.

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 223 of file eda_base_frame.cpp.

Referenced by EDA_BASE_FRAME::isAutoSaveRequired(), and EDA_BASE_FRAME::onAutoSaveTimer().

224 {
225  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
226 }
void KICAD_MANAGER_FRAME::Execute ( wxWindow *  frame,
const wxString &  execFile,
wxString  param = wxEmptyString 
)

Open another KiCad application and logs a message.

Parameters
frame= owner frame.
execFile= name of the executable file.
param= parameters to be passed to the executable.

Definition at line 265 of file mainframe.cpp.

References AddDelimiterString(), ExecuteFile(), Format(), GetChars(), and PrintMsg().

Referenced by TREEPROJECT_ITEM::Activate(), OnOpenFileInTextEditor(), OnOpenTextEditor(), OnRunBitmapConverter(), OnRunGerbview(), OnRunPageLayoutEditor(), and OnRunPcbCalculator().

267 {
268  if( params.size() )
269  AddDelimiterString( params );
270 
271  TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
272 
273  long pid = ExecuteFile( frame, execFile, params, callback );
274 
275  if( pid > 0 )
276  {
277  wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
278  GetChars( execFile ), GetChars( params ), pid );
279 
280  PrintMsg( msg );
281 
282 #ifdef __WXMAC__
283  msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile );
284  system( msg.c_str() );
285 #endif
286  }
287  else
288  {
289  delete callback;
290  }
291 }
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:194
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
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:92
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:205
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param...
Definition: gestfich.cpp:208
void EDA_BASE_FRAME::ExportHotkeyConfigToFile ( EDA_HOTKEY_CONFIG aDescList,
const wxString &  aDefaultShortname 
)
inherited

Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it.

Parameters
aDescList= current hotkey list descr. to initialize.
aDefaultShortname= a default short name (extention not needed) like eechema, kicad...

Definition at line 738 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), and Prj().

Referenced by PANEL_HOTKEYS_EDITOR::installButtons(), and EDA_BASE_FRAME::SaveProjectSettings().

740 {
741  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
742  wxString mask = wxT( "*." ) + ext;
743 
744 #if 0
745  wxString path = wxPathOnly( Prj().GetProjectFullName() );
746 #else
747  wxString path = GetMruPath();
748 #endif
749  wxFileName fn( aDefaultShortname );
750  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
751 
752  wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ),
753  path,
754  fn.GetFullPath(),
755  ext,
756  mask,
757  this,
758  wxFD_SAVE,
759  true );
760 
761  if( filename.IsEmpty() )
762  return;
763 
764  WriteHotkeyConfig( aDescList, &filename );
765  SetMruPath( wxFileName( filename ).GetPath() );
766 }
void SetMruPath(const wxString &aPath)
PROJECT & Prj()
Definition: kicad.cpp:292
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
wxString GetMruPath() const
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 217 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

217 { return m_autoSaveInterval; }
int m_autoSaveInterval
The auto save interval time in seconds.
wxString EDA_BASE_FRAME::GetFileFromHistory ( int  cmdId,
const wxString &  type,
wxFileHistory *  aFileHistory = NULL 
)
inherited

Function GetFileFromHistory fetches the file name from the file history list.

and removes the selected file, if this file does not exists Note also the menu is updated, if wxFileHistory::UseMenu was called at init time

Parameters
cmdIdThe command ID associated with the aFileHistory object.
typePlease document me!
aFileHistoryThe wxFileHistory in use. If null, the main application file history is used
Returns
a wxString containing the selected filename

Definition at line 399 of file eda_base_frame.cpp.

References Format(), KIFACE_I::GetFileHistory(), i, and Kiface().

Referenced by GERBVIEW_FRAME::OnDrlFileHistory(), OnFileHistory(), PL_EDITOR_FRAME::OnFileHistory(), PCB_EDIT_FRAME::OnFileHistory(), GERBVIEW_FRAME::OnGbrFileHistory(), GERBVIEW_FRAME::OnJobFileHistory(), GERBVIEW_FRAME::OnZipFileHistory(), and EDA_BASE_FRAME::SaveProjectSettings().

401 {
402  wxFileHistory* fileHistory = aFileHistory;
403 
404  if( !fileHistory )
405  fileHistory = &Kiface().GetFileHistory();
406 
407  int baseId = fileHistory->GetBaseId();
408 
409  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
410 
411  unsigned i = cmdId - baseId;
412 
413  if( i < fileHistory->GetCount() )
414  {
415  wxString fn = fileHistory->GetHistoryFile( i );
416 
417  if( wxFileName::FileExists( fn ) )
418  return fn;
419  else
420  {
421  wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
422  wxMessageBox( msg );
423 
424  fileHistory->RemoveFileFromHistory( i );
425  }
426  }
427 
428  return wxEmptyString;
429 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
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:205
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:123
size_t i
Definition: json11.cpp:597
void EDA_BASE_FRAME::GetKicadAbout ( wxCommandEvent &  event)
inherited

Definition at line 506 of file eda_base_frame.cpp.

References ShowAboutDialog().

Referenced by add_search_paths(), and EDA_BASE_FRAME::IsType().

507 {
508  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
509  ShowAboutDialog( this );
510 }
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
void EDA_BASE_FRAME::GetKicadContribute ( wxCommandEvent &  event)
inherited

Definition at line 493 of file eda_base_frame.cpp.

References URL_GET_INVOLVED.

Referenced by add_search_paths(), and EDA_BASE_FRAME::IsType().

494 {
495  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
496  {
497  wxString msg;
498  msg.Printf( _( "Could not launch the default browser.\n"
499  "For information on how to help the KiCad project, visit %s" ),
501  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
502  }
503 }
#define URL_GET_INVOLVED
void EDA_BASE_FRAME::GetKicadHelp ( wxCommandEvent &  event)
inherited

Definition at line 432 of file eda_base_frame.cpp.

References DIM, Format(), GetAssociatedDocument(), GetChars(), EDA_BASE_FRAME::help_name(), numEval::SearchHelpFileFullPath(), and EDA_BASE_FRAME::sys_search().

Referenced by add_search_paths(), and EDA_BASE_FRAME::IsType().

433 {
434  const SEARCH_STACK& search = sys_search();
435 
436  /* We have to get document for beginners,
437  * or the full specific doc
438  * if event id is wxID_INDEX, we want the document for beginners.
439  * else the specific doc file (its name is in Kiface().GetHelpFileName())
440  * The document for beginners is the same for all KiCad utilities
441  */
442  if( event.GetId() == wxID_INDEX )
443  {
444  // List of possible names for Getting Started in KiCad
445  const wxChar* names[2] = {
446  wxT( "getting_started_in_kicad" ),
447  wxT( "Getting_Started_in_KiCad" )
448  };
449 
450  wxString helpFile;
451  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
452  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
453  for( unsigned ii = 0; ii < DIM( names ); ii++ )
454  {
455  helpFile = SearchHelpFileFullPath( search, names[ii] );
456 
457  if( !helpFile.IsEmpty() )
458  break;
459  }
460 
461  if( !helpFile )
462  {
463  wxString msg = wxString::Format( _(
464  "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
465  wxMessageBox( msg );
466  }
467  else
468  {
469  GetAssociatedDocument( this, helpFile );
470  }
471 
472  return;
473  }
474 
475  wxString base_name = help_name();
476  wxString helpFile = SearchHelpFileFullPath( search, base_name );
477 
478  if( !helpFile )
479  {
480  wxString msg = wxString::Format( _(
481  "Help file \"%s\" could not be found." ),
482  GetChars( base_name )
483  );
484  wxMessageBox( msg );
485  }
486  else
487  {
488  GetAssociatedDocument( this, helpFile );
489  }
490 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSearchStack, const wxString &aBaseName)
Return the help file&#39;s full path.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
virtual const SEARCH_STACK & sys_search()
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
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:92
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:205
virtual wxString help_name()
const wxString KICAD_MANAGER_FRAME::GetProjectFileName ( )

Definition at line 140 of file mainframe.cpp.

References PROJECT::GetProjectFullName(), and KIWAY_HOLDER::Prj().

Referenced by TREE_PROJECT_FRAME::AddItemToTreeProject(), TREE_PROJECT_FRAME::FileWatcherReset(), TREE_PROJECT_FRAME::findSubdirTreeItem(), OnArchiveFiles(), OnCloseWindow(), TREE_PROJECT_FRAME::OnCreateNewDirectory(), OnImportEagleFiles(), OnRunEeschema(), OnSaveProject(), OnUnarchiveFiles(), PcbFileName(), PcbLegacyFileName(), PrintPrjInfo(), TREE_PROJECT_FRAME::ReCreateTreePrj(), SchFileName(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

141 {
142  return Prj().GetProjectFullName();
143 }
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
EDA_UNITS_T KIWAY_HOLDER::GetUserUnits ( ) const
inherited

Function GetUserUnits Allows participation in KEYWAY_PLAYER/DIALOG_SHIM userUnits inheritance.

This would fit better in KEYWAY_PLAYER, but DIALOG_SHIMs can only use mix-ins because their primary superclass must be wxDialog.

Definition at line 40 of file kiway_holder.cpp.

References MILLIMETRES.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and KIWAY_HOLDER::Kiway().

41 {
42  return MILLIMETRES;
43 }
wxString KICAD_MANAGER_FRAME::help_name ( )
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 188 of file mainframe.cpp.

References PGM_KICAD::GetHelpFileName(), and PgmTop().

Referenced by KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

189 {
190  return PgmTop().GetHelpFileName();
191 }
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
wxString GetHelpFileName()
Definition: pgm_kicad.h:63
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile ( EDA_HOTKEY_CONFIG aDescList,
const wxString &  aDefaultShortname 
)
inherited

Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.

Parameters
aDescList= current hotkey list descr. to initialize.
aDefaultShortname= a default short name (extention not needed) like eechema, kicad...

Definition at line 709 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), and ReadHotkeyConfigFile().

Referenced by PANEL_HOTKEYS_EDITOR::installButtons(), and EDA_BASE_FRAME::SaveProjectSettings().

711 {
712  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
713  wxString mask = wxT( "*." ) + ext;
714 
715 
716  wxString path = GetMruPath();
717  wxFileName fn( aDefaultShortname );
718  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
719 
720  wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ),
721  path,
722  fn.GetFullPath(),
723  ext,
724  mask,
725  this,
726  wxFD_OPEN,
727  true );
728 
729  if( filename.IsEmpty() )
730  return;
731 
732  ::ReadHotkeyConfigFile( filename, aDescList, false );
733  WriteHotkeyConfig( aDescList );
734  SetMruPath( wxFileName( filename ).GetPath() );
735 }
void SetMruPath(const wxString &aPath)
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList, const bool aDefaultLocation)
Function ReadHotkeyConfig Read hotkey configuration for a given app, possibly before the frame for th...
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
wxString GetMruPath() const
virtual void EDA_BASE_FRAME::InstallPreferences ( PAGED_DIALOG aParent)
inlinevirtualinherited

Function InstallPreferences allows a Frame to load its preference panels (if any) into the preferences dialog.

Parameters
aParenta paged dialog into which the preference panels should be installed

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, LIB_EDIT_FRAME, GERBVIEW_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 238 of file eda_base_frame.h.

References EDA_BASE_FRAME::LoadSettings(), and EDA_BASE_FRAME::SaveSettings().

Referenced by EDA_BASE_FRAME::ShowPreferences().

238 { }
virtual bool EDA_BASE_FRAME::isAutoSaveRequired ( ) const
inlineprotectedvirtualinherited

Function autoSaveRequired returns the auto save status of the application.

Override this function if your derived frame supports automatic file saving.

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 173 of file eda_base_frame.h.

References EDA_BASE_FRAME::config(), EDA_BASE_FRAME::doAutoSave(), EDA_BASE_FRAME::EDA_BASE_FRAME(), EDA_BASE_FRAME::help_name(), EDA_BASE_FRAME::ProcessEvent(), EDA_BASE_FRAME::SetAutoSaveInterval(), EDA_BASE_FRAME::sys_search(), and EDA_BASE_FRAME::~EDA_BASE_FRAME().

Referenced by EDA_BASE_FRAME::ProcessEvent().

173 { return false; }
bool EDA_BASE_FRAME::IsType ( FRAME_T  aType) const
inlineinherited
bool EDA_BASE_FRAME::IsWritable ( const wxFileName &  aFileName)
inherited

Function IsWritable checks if aFileName can be written.

The function performs a number of tests on aFileName to verify that it can be saved. If aFileName defines a path with no file name, them the path is tested for user write permission. If aFileName defines a file name that does not exist in the path, the path is tested for user write permission. If aFileName defines a file that already exits, the file name is tested for user write permissions.

Note
The file name path must be set or an assertion will be raised on debug builds and return false on release builds.
Parameters
aFileNameThe full path and/or file name of the file to test.
Returns
False if aFileName cannot be written.

Definition at line 541 of file eda_base_frame.cpp.

References GetChars().

Referenced by SCH_EDIT_FRAME::doAutoSave(), EDA_BASE_FRAME::GetMruPath(), SCH_EDIT_FRAME::SaveEEFile(), LIB_EDIT_FRAME::saveLibrary(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), CVPCB_MAINFRAME::SaveProjectFile(), and SCH_EDIT_FRAME::SaveProjectSettings().

542 {
543  wxString msg;
544  wxFileName fn = aFileName;
545 
546  // Check for absence of a file path with a file name. Unfortunately KiCad
547  // uses paths relative to the current project path without the ./ part which
548  // confuses wxFileName. Making the file name path absolute may be less than
549  // elegant but it solves the problem.
550  if( fn.GetPath().IsEmpty() && fn.HasName() )
551  fn.MakeAbsolute();
552 
553  wxCHECK_MSG( fn.IsOk(), false,
554  wxT( "File name object is invalid. Bad programmer!" ) );
555  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
556  wxT( "File name object path <" ) + fn.GetFullPath() +
557  wxT( "> is not set. Bad programmer!" ) );
558 
559  if( fn.IsDir() && !fn.IsDirWritable() )
560  {
561  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
562  GetChars( fn.GetPath() ) );
563  }
564  else if( !fn.FileExists() && !fn.IsDirWritable() )
565  {
566  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
567  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
568  }
569  else if( fn.FileExists() && !fn.IsFileWritable() )
570  {
571  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
572  GetChars( fn.GetFullPath() ) );
573  }
574 
575  if( !msg.IsEmpty() )
576  {
577  wxMessageBox( msg );
578  return false;
579  }
580 
581  return true;
582 }
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:92
KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 60 of file kiway_player.h.

References KIWAY_HOLDER::GetUserUnits(), KIWAY_HOLDER::m_kiway, KIWAY_HOLDER::Prj(), KIWAY_HOLDER::SetKiway(), and VTBL_ENTRY.

Referenced by TREEPROJECT_ITEM::Activate(), PCB_BASE_EDIT_FRAME::AddLibrary(), SCH_EDIT_FRAME::AppendSchematic(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_CHOOSE_FOOTPRINT::ConstructRightPanel(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), PCB_BASE_FRAME::CreateAndShow3D_Frame(), CVPCB_MAINFRAME::CreateScreenCmp(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), DIALOG_SHIM::DIALOG_SHIM(), FIELDS_GRID_TRICKS::doPopupSelection(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), EDIT_TOOL::editFootprintInFpEditor(), SCH_EDIT_FRAME::EditSheet(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), LIB_MANAGER::GetBufferedPart(), LIB_MANAGER::getLibraryBuffer(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::KiwayMailIn(), KIWAY_PLAYER::language_change(), language_change(), CVPCB_MAINFRAME::LoadFootprintFiles(), LoadProject(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), TEXT_BUTTON_FP_CHOOSER::OnButtonClick(), OnCloseWindow(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), OnEditFpLibTable(), SCH_BASE_FRAME::OnEditSymbolLibTable(), OnEditSymLibTable(), OnImportEagleFiles(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnLeftClick(), SCH_BASE_FRAME::OnOpenLibraryViewer(), OnRunPcbFpEditor(), OnRunSchLibEditor(), SCH_EDIT_FRAME::OnSimulate(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), SCH_EDIT_FRAME::OpenProjectFiles(), KIWAY_HOLDER::Prj(), PCB_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar(), LIB_EDIT_FRAME::refreshSchematic(), RunEeschema(), RunPcbNew(), SCH_EDIT_FRAME::SaveEEFile(), CVPCB_MAINFRAME::SaveFootprintAssociation(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), SCH_EDIT_FRAME::SendCrossProbeNetName(), PCB_EDIT_FRAME::SendCrossProbeNetName(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), FOOTPRINT_VIEWER_FRAME::Show3D_Frame(), FOOTPRINT_WIZARD_FRAME::Show3D_Frame(), EDA_BASE_FRAME::ShowPreferences(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), LIB_MANAGER::UpdatePart(), and DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint().

61  {
62  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
63  return *m_kiway;
64  }
KIWAY * m_kiway
Definition: kiway_player.h:94
void KICAD_MANAGER_FRAME::language_change ( wxCommandEvent &  event)
private

Definition at line 505 of file mainframe.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::SetLanguage().

506 {
507  int id = event.GetId();
508  Kiway().SetLanguage( id );
509 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs...
Definition: kiway.cpp:395
void KICAD_MANAGER_FRAME::LoadProject ( const wxFileName &  aProjectFileName)

Definition at line 61 of file prjconfig.cpp.

References ClearMsg(), PROJECT::ConfigLoad(), GeneralGroupName, GetBuildVersion(), PGM_KICAD::GetFileHistory(), ID_INIT_WATCHED_PATHS, KIWAY_HOLDER::Kiway(), m_active_project, m_LeftWin, PgmTop(), KIWAY::PlayersClose(), PrintPrjInfo(), KIWAY_HOLDER::Prj(), TREE_PROJECT_FRAME::ReCreateTreePrj(), EDA_BASE_FRAME::SetMruPath(), SetProjectFileName(), and EDA_BASE_FRAME::UpdateFileHistory().

Referenced by TREEPROJECT_ITEM::Activate(), PGM_KICAD::MacOpenFile(), OnCreateProjectFromTemplate(), OnFileHistory(), OnLoadProject(), OnNewProject(), PGM_KICAD::OnPgmInit(), and TREE_PROJECT_FRAME::OnSwitchToSelectedProject().

62 {
63  // The project file should be valid by the time we get here or something has gone wrong.
64  if( !aProjectFileName.Exists() )
65  return;
66 
67  // Any open KIFACE's must be closed if they are not part of the new project.
68  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
69  // User is prompted here to close those KIWAY_PLAYERs:
70  if( !Kiway().PlayersClose( false ) )
71  return;
72 
73  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
74 
75  // Save the project file for the currently loaded project.
76  if( m_active_project )
78 
79  m_active_project = true;
80  ClearMsg();
81  SetProjectFileName( aProjectFileName.GetFullPath() );
83 
84  wxString title = GetTitle() + " " + aProjectFileName.GetFullPath();
85 
86  if( !aProjectFileName.IsDirWritable() )
87  title += _( " [Read Only]" );
88  else
89  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
90 
91  SetTitle( title );
92 
93  UpdateFileHistory( aProjectFileName.GetFullPath(), &PgmTop().GetFileHistory() );
94 
96 
97  // Rebuild the list of watched paths.
98  // however this is possible only when the main loop event handler is running,
99  // so we use it to run the rebuild function.
100  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
101 
102  wxPostEvent( this, cmd );
103 
104  PrintPrjInfo();
105 }
VTBL_ENTRY bool PlayersClose(bool doForce)
Function PlayersClose calls the KIWAY_PLAYER::Close( bool force ) function on all the windows and if ...
Definition: kiway.cpp:373
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:57
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
void SetMruPath(const wxString &aPath)
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
void ReCreateTreePrj()
Create or modify the tree showing project file names.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
#define GeneralGroupName
Definition: prjconfig.cpp:56
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:128
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:353
bool m_active_project
Definition: kicad.h:304
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:520
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.
Definition: mainframe.cpp:540
void KICAD_MANAGER_FRAME::LoadSettings ( wxConfigBase *  aCfg)
overridevirtual

Function LoadSettings loads common frame parameters from a configuration file.

Don't forget to call the base method or your frames won't remember their positions and sizes.

Reimplemented from EDA_BASE_FRAME.

Definition at line 526 of file mainframe.cpp.

References EDA_BASE_FRAME::LoadSettings(), m_leftWinWidth, and TREE_FRAME_WIDTH_ENTRY.

Referenced by KICAD_MANAGER_FRAME().

527 {
529  aCfg->Read( TREE_FRAME_WIDTH_ENTRY, &m_leftWinWidth );
530 }
#define TREE_FRAME_WIDTH_ENTRY
Definition: mainframe.cpp:54
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
void KICAD_MANAGER_FRAME::OnArchiveFiles ( wxCommandEvent &  event)

Definition at line 134 of file kicad/files-io.cpp.

References DIM, Format(), GetChars(), GetProjectFileName(), PrintMsg(), and ZipFileWildcard().

135 {
136  // List of file extensions to save.
137  static const wxChar* extentionList[] = {
138  wxT( "*.pro" ),
139  wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.dcm" ), // Schematic related files
140  wxT( "*.cmp" ),
141  wxT( "*.brd" ), wxT( "*.kicad_pcb" ), // Brd files
142  wxT( "*.mod" ), wxT( "*.kicad_mod" ), // fp files
143  wxT( "*.gbr" ), wxT( "*.gbrjob" ), // Gerber files
144  wxT( "*.pos" ), wxT( "*.drl" ), // Fab files
145  wxT( "*.net" ), wxT( "*.py" ),
146  wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.kicad_wks" ),
147  };
148 
149  wxString msg;
150  wxFileName fileName = GetProjectFileName();
151  wxString oldCwd = wxGetCwd();
152 
153  fileName.SetExt( wxT( "zip" ) );
154 
155  wxFileDialog dlg( this, _( "Archive Project Files" ),
156  fileName.GetPath(), fileName.GetFullName(),
157  ZipFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
158 
159  if( dlg.ShowModal() == wxID_CANCEL )
160  return;
161 
162  wxFileName zip = dlg.GetPath();
163 
164  wxString currdirname = fileName.GetPathWithSep();
165  wxDir dir( currdirname );
166 
167  if( !dir.IsOpened() ) // wxWidgets display a error message on issue.
168  return;
169 
170  wxSetWorkingDirectory( currdirname );
171 
172  // Prepare the zip file
173  wxString zipfilename = zip.GetFullPath();
174 
175  wxFFileOutputStream ostream( zipfilename );
176 
177  if( !ostream.IsOk() ) // issue to create the file. Perhaps not writable dir
178  {
179  wxMessageBox( wxString::Format( _( "Unable to create zip archive file \"%s\"" ),
180  zipfilename ) );
181  return;
182  }
183 
184  wxZipOutputStream zipstream( ostream );
185 
186  // Build list of filenames to put in zip archive
187  wxString currFilename;
188 
189  wxArrayString files;
190 
191  for( unsigned ii = 0; ii < DIM( extentionList ); ii++ )
192  wxDir::GetAllFiles( currdirname, &files, extentionList[ii] );
193 
194  files.Sort();
195 
196  int zipBytesCnt = 0;
197 
198  for( unsigned ii = 0; ii < files.GetCount(); ii++ )
199  {
200  wxFileSystem fsfile;
201 
202  wxFileName curr_fn( files[ii] );
203  curr_fn.MakeRelativeTo( currdirname );
204  currFilename = curr_fn.GetFullPath();
205 
206  msg.Printf( _( "Archive file \"%s\"" ), GetChars( currFilename ) );
207  PrintMsg( msg );
208 
209  // Read input file and add it to the zip file:
210  wxFSFile* infile = fsfile.OpenFile( currFilename );
211 
212  if( infile )
213  {
214  zipstream.PutNextEntry( currFilename, infile->GetModificationTime() );
215  infile->GetStream()->Read( zipstream );
216  zipstream.CloseEntry();
217  int zippedsize = zipstream.GetSize() - zipBytesCnt;
218  zipBytesCnt = zipstream.GetSize();
219  PrintMsg( wxT(" ") );
220  msg.Printf( _( "(%lu bytes, compressed %d bytes)\n" ),
221  (unsigned long)infile->GetStream()->GetSize(), zippedsize );
222  PrintMsg( msg );
223  delete infile;
224  }
225  else
226  PrintMsg( _( " >>Error\n" ) );
227  }
228 
229  zipBytesCnt = ostream.GetSize();
230 
231  if( zipstream.Close() )
232  {
233  msg.Printf( _( "\nZip archive \"%s\" created (%d bytes)" ),
234  GetChars( zipfilename ), zipBytesCnt );
235  PrintMsg( msg );
236  PrintMsg( wxT( "\n** end **\n" ) );
237  }
238  else
239  {
240  msg.Printf( wxT( "Unable to create archive \"%s\", abort\n" ),
241  GetChars( zipfilename ) );
242  PrintMsg( msg );
243  }
244 
245  wxSetWorkingDirectory( oldCwd );
246 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
wxString ZipFileWildcard()
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:194
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
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:92
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:205
void EDA_BASE_FRAME::onAutoSaveTimer ( wxTimerEvent &  aEvent)
protectedinherited

Function onAutoSaveTimer handles the auto save timer event.

Definition at line 216 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::doAutoSave(), EDA_BASE_FRAME::m_autoSaveInterval, and EDA_BASE_FRAME::m_autoSaveTimer.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

217 {
218  if( !doAutoSave() )
219  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
220 }
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
int m_autoSaveInterval
The auto save interval time in seconds.
void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer ( wxCommandEvent &  event)

Definition at line 487 of file mainframe.cpp.

References AddDelimiterString(), PROJECT::GetProjectPath(), and KIWAY_HOLDER::Prj().

488 {
489  // open project directory in host OS's file explorer
490  wxString project_dir = Prj().GetProjectPath();
491 
492  // Quote in case there are spaces in the path.
493  AddDelimiterString( project_dir );
494 
495  wxLaunchDefaultApplication( project_dir );
496 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void KICAD_MANAGER_FRAME::OnChangeWatchedPaths ( wxCommandEvent &  aEvent)

Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of wahtched paths.

Definition at line 1117 of file tree_project_frame.cpp.

Referenced by KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

1118 {
1120 }
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
void KICAD_MANAGER_FRAME::OnCloseWindow ( wxCloseEvent &  Event)

Definition at line 209 of file mainframe.cpp.

References empty(), GetProjectFileName(), KIWAY_HOLDER::Kiway(), EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, m_LeftWin, PgmTop(), EDA_BASE_FRAME::UpdateFileHistory(), wxPoint::x, and wxPoint::y.

210 {
211  if( Kiway().PlayersClose( false ) )
212  {
213  int px, py;
214 
215  if( !GetProjectFileName().empty() )
216  UpdateFileHistory( GetProjectFileName(), &PgmTop().GetFileHistory() );
217 
218  if( !IsIconized() ) // save main frame position and size
219  {
220  GetPosition( &px, &py );
221  m_FramePos.x = px;
222  m_FramePos.y = py;
223 
224  GetSize( &px, &py );
225  m_FrameSize.x = px;
226  m_FrameSize.y = py;
227  }
228 
229  Event.SetCanVeto( true );
230 
231  m_LeftWin->Show( false );
232 
233  Destroy();
234  }
235 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
static bool empty(const wxTextEntryBase *aCtrl)
void KICAD_MANAGER_FRAME::OnConfigurePaths ( wxCommandEvent &  aEvent)

Definition at line 554 of file mainframe.cpp.

555 {
556  DIALOG_CONFIGURE_PATHS dlg( this, nullptr );
557  dlg.ShowModal();
558 }
void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate ( wxCommandEvent &  event)

Creates a new project folder, copy a template into this new folder.

and open this new projrct as working project

Definition at line 271 of file prjconfig.cpp.

References DIALOG_TEMPLATE_SELECTOR::AddTemplatesPage(), ClearMsg(), CreateNewProject(), PROJECT_TEMPLATE::CreateProject(), KIDIALOG::DoNotShowCheckbox(), PROJECT_TEMPLATE::GetDestinationFiles(), PGM_BASE::GetLocalEnvVariables(), DIALOG_TEMPLATE_SELECTOR::GetSelectedTemplate(), LoadProject(), Pgm(), KIWAY_HOLDER::Prj(), SEP, and KIDIALOG::ShowModal().

272 {
274 
275  wxFileName templatePath;
276  wxString envStr;
277 
278  // KiCad system template path.
279  ENV_VAR_MAP_CITER it = Pgm().GetLocalEnvVariables().find( "KICAD_TEMPLATE_DIR" );
280 
281  if( it != Pgm().GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
282  {
283  templatePath.AssignDir( it->second.GetValue() );
284  ps->AddTemplatesPage( _( "System Templates" ), templatePath );
285  }
286 
287  // User template path.
288  it = Pgm().GetLocalEnvVariables().find( "KICAD_USER_TEMPLATE_DIR" );
289 
290  if( it != Pgm().GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
291  {
292  templatePath.AssignDir( it->second.GetValue() );
293  ps->AddTemplatesPage( _( "User Templates" ), templatePath );
294  }
295 
296  // Show the project template selector dialog
297  if( ps->ShowModal() != wxID_OK )
298  return;
299 
300  if( ps->GetSelectedTemplate() == NULL )
301  {
302  wxMessageBox( _( "No project template was selected. Cannot generate new project." ),
303  _( "Error" ),
304  wxOK | wxICON_ERROR,
305  this );
306 
307  return;
308  }
309 
310  // Get project destination folder and project file name.
311  wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
312  wxString title = _( "New Project Folder" );
313  wxDirDialog dlg( this, title, default_dir );
314 
315  if( dlg.ShowModal() == wxID_CANCEL )
316  return;
317 
318  // Builds the project .pro filename, from the new project folder name
319  wxFileName fn;
320  fn.AssignDir( dlg.GetPath() );
321  fn.SetName( dlg.GetPath().AfterLast( SEP() ) );
322  fn.SetExt( "pro" );
323 
324  // Make sure the user has write permissions to the project path.
325  wxFileName prjPath = fn;
326 
327  while( !prjPath.DirExists() )
328  prjPath.RemoveLastDir();
329 
330  if( !prjPath.IsDirWritable() )
331  {
332  wxString msg;
333 
334  msg.Printf( _( "Cannot write to folder \"%s\"." ), prjPath.GetPath() );
335  wxMessageDialog msgDlg( this, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
336  msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder "
337  "and try again." ) );
338  msgDlg.ShowModal();
339  return;
340  }
341 
342  ClearMsg();
343 
344  // Make sure we are not overwriting anything in the destination folder.
345  std::vector< wxFileName > destFiles;
346 
347  if( ps->GetSelectedTemplate()->GetDestinationFiles( fn, destFiles ) )
348  {
349  std::vector< wxFileName > overwrittenFiles;
350 
351  for( const auto& file : destFiles )
352  {
353  if( file.FileExists() )
354  overwrittenFiles.push_back( file );
355  }
356 
357  if( !overwrittenFiles.empty() )
358  {
359  wxString extendedMsg = _( "Overwriting files:" ) + "\n";
360 
361  for( const auto& file : overwrittenFiles )
362  extendedMsg += "\n" + file.GetFullName();
363 
364  KIDIALOG msgDlg( this, _( "Similar files already exist in the destination folder." ),
365  _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
366  msgDlg.SetExtendedMessage( extendedMsg );
367  msgDlg.SetOKLabel( _( "Overwrite" ) );
368  msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
369 
370  if( msgDlg.ShowModal() == wxID_CANCEL )
371  return;
372  }
373  }
374 
375  wxString errorMsg;
376 
377  // The selected template widget contains the template we're attempting to use to
378  // create a project
379  if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
380  {
381  wxMessageDialog createDlg( this,
382  _( "A problem occurred creating new project from template!" ),
383  _( "Template Error" ),
384  wxOK | wxICON_ERROR );
385 
386  if( !errorMsg.empty() )
387  createDlg.SetExtendedMessage( errorMsg );
388 
389  createDlg.ShowModal();
390  return;
391  }
392 
393  CreateNewProject( fn.GetFullPath() );
394  LoadProject( fn );
395 }
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:44
PROJECT_TEMPLATE * GetSelectedTemplate()
#define SEP()
Definition: prjconfig.cpp:50
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY const ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.h:312
std::map< wxString, ENV_VAR_ITEM >::const_iterator ENV_VAR_MAP_CITER
Definition: pgm_base.h:131
size_t GetDestinationFiles(const wxFileName &aNewProjectPath, std::vector< wxFileName > &aDestFiles)
Fetch the list of destination files to be copied when the new project is created. ...
bool CreateProject(wxFileName &aNewProjectPath, wxString *aErrorMsg=nullptr)
Copies and renames all template files to create a new project.
void AddTemplatesPage(const wxString &aTitle, wxFileName &aPath)
Add a new page with aTitle, populated with templates from aPath.
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
void CreateNewProject(const wxFileName &aProjectFileName)
Creates a new project by setting up and initial project, schematic, and board files.
Definition: prjconfig.cpp:108
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:520
void KICAD_MANAGER_FRAME::OnEditFpLibTable ( wxCommandEvent &  aEvent)

Definition at line 568 of file mainframe.cpp.

References KIFACE::CreateWindow(), DIALOG_PCB_LIBRARY_TABLE, KIWAY::FACE_PCB, kiface, KIWAY::KiFACE(), and KIWAY_HOLDER::Kiway().

569 {
571  kiface->CreateWindow( this, DIALOG_PCB_LIBRARY_TABLE, &Kiway() );
572 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0)=0
Function CreateWindow creates a wxWindow for the current project.
pcbnew DSO
Definition: kiway.h:267
VTBL_ENTRY KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Function KiFACE returns the KIFACE* given a FACE_T.
Definition: kiway.cpp:148
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:151
return & kiface
Definition: pcbnew.cpp:219
void KICAD_MANAGER_FRAME::OnEditSymLibTable ( wxCommandEvent &  aEvent)

Definition at line 561 of file mainframe.cpp.

References KIFACE::CreateWindow(), DIALOG_SCH_LIBRARY_TABLE, KIWAY::FACE_SCH, kiface, KIWAY::KiFACE(), and KIWAY_HOLDER::Kiway().

562 {
564  kiface->CreateWindow( this, DIALOG_SCH_LIBRARY_TABLE, &Kiway() );
565 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0)=0
Function CreateWindow creates a wxWindow for the current project.
VTBL_ENTRY KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Function KiFACE returns the KIFACE* given a FACE_T.
Definition: kiway.cpp:148
eeschema DSO
Definition: kiway.h:266
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:151
return & kiface
Definition: pcbnew.cpp:219
void KICAD_MANAGER_FRAME::OnExit ( wxCommandEvent &  event)

Definition at line 238 of file mainframe.cpp.

239 {
240  Close( true );
241 }
void KICAD_MANAGER_FRAME::OnFileHistory ( wxCommandEvent &  event)

Definition at line 46 of file kicad/files-io.cpp.

References EDA_BASE_FRAME::GetFileFromHistory(), PGM_KICAD::GetFileHistory(), LoadProject(), and PgmTop().

47 {
48  wxFileName projFileName = GetFileFromHistory( event.GetId(), _( "KiCad project file" ),
49  &PgmTop().GetFileHistory() );
50  if( !projFileName.FileExists() )
51  return;
52 
53  LoadProject( projFileName );
54 }
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:57
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
wxString GetFileFromHistory(int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
Function GetFileFromHistory fetches the file name from the file history list.
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
void KICAD_MANAGER_FRAME::OnImportEagleFiles ( wxCommandEvent &  event)

Open dialog to import Eagle schematic and board files.

Definition at line 53 of file import_project.cpp.

References ClearMsg(), KIDIALOG::DoNotShowCheckbox(), IO_MGR::EAGLE, EagleFilesWildcard(), err, KIWAY::ExpressMail(), Format(), FRAME_PCB, FRAME_SCH, EDA_BASE_FRAME::GetMruPath(), GetProjectFileName(), KIWAY_HOLDER::Kiway(), LegacyPcbFileExtension, m_active_project, MAIL_IMPORT_FILE, KIWAY::Player(), ProjectFileExtension, ReCreateTreePrj(), SchematicFileExtension, SetProjectFileName(), KIDIALOG::ShowModal(), and IO_ERROR::What().

54 {
55  // Close other windows.
56  if( !Kiway().PlayersClose( false ) )
57  return;
58 
59 
60  wxString title = _( "Import Eagle Project Files" );
61  int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
62  wxString default_dir = GetMruPath();
63 
64  ClearMsg();
65 
66  wxFileDialog schdlg( this, title, default_dir, wxEmptyString,
67  EagleFilesWildcard(), style );
68 
69  if( schdlg.ShowModal() == wxID_CANCEL )
70  return;
71 
72 
73  wxFileName sch( schdlg.GetPath() );
74 
75  sch.SetExt( SchematicFileExtension );
76 
77  wxFileName pro = sch;
78 
79  pro.SetExt( ProjectFileExtension );
80 
81  wxString protitle = _( "KiCad Project Destination" );
82 
83  // Don't use wxFileDialog here. On GTK builds, the default path is returned unless a
84  // file is actually selected.
85  wxDirDialog prodlg( this, protitle, pro.GetPath(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
86 
87  if( prodlg.ShowModal() == wxID_CANCEL )
88  return;
89 
90  pro.SetPath( prodlg.GetPath() );
91 
92  // Check if the project directory is empty
93  wxDir directory( pro.GetPath() );
94 
95  if( directory.HasFiles() )
96  {
97  wxString msg = _( "The selected directory is not empty. We recommend you "
98  "create projects in their own clean directory.\n\nDo you "
99  "want to create a new empty directory for the project?" );
100 
101  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxYES_NO | wxICON_WARNING );
102  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
103 
104  if( dlg.ShowModal() == wxID_YES )
105  {
106  // Append a new directory with the same name of the project file
107  // and try to create it
108  pro.AppendDir( pro.GetName() );
109 
110  if( !wxMkdir( pro.GetPath() ) )
111  // There was a problem, undo
112  pro.RemoveLastDir();
113  }
114  }
115 
116  wxFileName pcb( sch );
117  pro.SetExt( ProjectFileExtension ); // enforce extension
118  pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
119 
120  if( !pro.IsAbsolute() )
121  pro.MakeAbsolute();
122 
123  SetProjectFileName( pro.GetFullPath() );
124  wxString prj_filename = GetProjectFileName();
125 
126  if( sch.FileExists() )
127  {
128  KIWAY_PLAYER* schframe = Kiway().Player( FRAME_SCH, false );
129 
130  if( !schframe )
131  {
132  try // SCH frame was not available, try to start it
133  {
134  schframe = Kiway().Player( FRAME_SCH, true );
135  }
136  catch( const IO_ERROR& err )
137  {
138  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
139  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
140  return;
141  }
142  }
143 
145  wxString::Format( "%d\n%s", SCH_IO_MGR::SCH_EAGLE,
146  sch.GetFullPath() ).ToStdString(), this );
147 
148  if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor)
149  // but no project loaded.
150  {
151  schframe->Show( true );
152  }
153 
154  if( schframe->IsIconized() )
155  schframe->Iconize( false );
156 
157  schframe->Raise();
158  }
159 
160 
161  if( pcb.FileExists() )
162  {
163  KIWAY_PLAYER* pcbframe = Kiway().Player( FRAME_PCB, false );
164 
165  if( !pcbframe )
166  {
167  try // PCB frame was not available, try to start it
168  {
169  pcbframe = Kiway().Player( FRAME_PCB, true );
170  }
171  catch( const IO_ERROR& err )
172  {
173  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
174  wxOK | wxICON_ERROR, this );
175  return;
176  }
177  }
178 
179  // a pcb frame can be already existing, but not yet used.
180  // this is the case when running the footprint editor, or the footprint viewer first
181  // if the frame is not visible, the board is not yet loaded
182  if( !pcbframe->IsVisible() )
183  {
184  pcbframe->Show( true );
185  }
186 
188  wxString::Format( "%d\n%s", IO_MGR::EAGLE, pcb.GetFullPath() ).ToStdString(), this );
189 
190  // On Windows, Raise() does not bring the window on screen, when iconized
191  if( pcbframe->IsIconized() )
192  pcbframe->Iconize( false );
193 
194  pcbframe->Raise();
195  }
196 
197  ReCreateTreePrj();
198  m_active_project = true;
199 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:44
const std::string ProjectFileExtension
const std::string LegacyPcbFileExtension
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:386
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
const std::string SchematicFileExtension
string & err
Definition: json11.cpp:598
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:128
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
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:205
Import a different format file.
Definition: mail_type.h:44
wxString EagleFilesWildcard()
bool m_active_project
Definition: kicad.h:304
wxString GetMruPath() const
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:520
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void KICAD_MANAGER_FRAME::OnLoadProject ( wxCommandEvent &  event)

Load an exiting project (.pro) file.

Definition at line 165 of file prjconfig.cpp.

References EDA_BASE_FRAME::GetMruPath(), LoadProject(), ProjectFileExtension, and ProjectFileWildcard().

166 {
167  wxString default_dir = GetMruPath();
168  wxFileDialog dlg( this, _( "Open Existing Project" ), default_dir, wxEmptyString,
169  ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
170 
171  if( dlg.ShowModal() == wxID_CANCEL )
172  return;
173 
174  wxFileName pro( dlg.GetPath() );
175  pro.SetExt( ProjectFileExtension ); // enforce extension
176 
177  if( !pro.IsAbsolute() )
178  pro.MakeAbsolute();
179 
180  if( !pro.FileExists() )
181  return;
182 
183  LoadProject( pro );
184 }
const std::string ProjectFileExtension
wxString ProjectFileWildcard()
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
wxString GetMruPath() const
void KICAD_MANAGER_FRAME::OnNewProject ( wxCommandEvent &  aEvent)

Definition at line 219 of file prjconfig.cpp.

References DIR_CHECKBOX::Create(), CreateNewProject(), DisplayErrorMessage(), EDA_BASE_FRAME::GetMruPath(), IsOK(), LoadProject(), ProjectFileExtension, and ProjectFileWildcard().

220 {
221  wxString default_dir = GetMruPath();
222  wxFileDialog dlg( this, _( "Create New Project" ), default_dir, wxEmptyString,
223  ProjectFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
224 
225  // Add a "Create a new directory" checkbox
226  dlg.SetExtraControlCreator( &DIR_CHECKBOX::Create );
227 
228  if( dlg.ShowModal() == wxID_CANCEL )
229  return;
230 
231  wxFileName pro( dlg.GetPath() );
232  pro.SetExt( ProjectFileExtension ); // enforce extension
233 
234  if( !pro.IsAbsolute() )
235  pro.MakeAbsolute();
236 
237  // Append a new directory with the same name of the project file.
238  if( static_cast<DIR_CHECKBOX*>( dlg.GetExtraControl() )->CreateNewDir() )
239  pro.AppendDir( pro.GetName() );
240 
241  // Check if the project directory is empty if it already exists.
242  wxDir directory( pro.GetPath() );
243 
244  if( !pro.DirExists() )
245  {
246  if( !pro.Mkdir() )
247  {
248  wxString msg;
249  msg.Printf( _( "Directory \"%s\" could not be created.\n\n"
250  "Please make sure you have write permissions and try again." ),
251  pro.GetPath() );
252  DisplayErrorMessage( this, msg );
253  return;
254  }
255  }
256  else if( directory.HasFiles() )
257  {
258  wxString msg = _( "The selected directory is not empty. It is recommended that you "
259  "create projects in their own empty directory.\n\nDo you "
260  "want to continue?" );
261 
262  if( !IsOK( this, msg ) )
263  return;
264  }
265 
266  CreateNewProject( pro );
267  LoadProject( pro );
268 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
const std::string ProjectFileExtension
wxString ProjectFileWildcard()
static wxWindow * Create(wxWindow *aParent)
Definition: prjconfig.cpp:209
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
void CreateNewProject(const wxFileName &aProjectFileName)
Creates a new project by setting up and initial project, schematic, and board files.
Definition: prjconfig.cpp:108
wxString GetMruPath() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:295
void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ( wxCommandEvent &  event)

Definition at line 467 of file mainframe.cpp.

References AllFilesWildcard, Execute(), PGM_BASE::GetEditorName(), PROJECT::GetProjectPath(), Pgm(), and KIWAY_HOLDER::Prj().

468 {
469  // show all files in file dialog (in Kicad all files are editable texts):
470  wxString wildcard = AllFilesWildcard;
471 
472  wxString default_dir = Prj().GetProjectPath();
473 
474  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
475  wxEmptyString, wildcard, wxFD_OPEN );
476 
477  if( dlg.ShowModal() == wxID_CANCEL )
478  return;
479 
480  wxString filename = wxT( "\"" );
481  filename += dlg.GetPath() + wxT( "\"" );
482 
483  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
484  Execute( this, Pgm().GetEditorName(), filename );
485 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
const wxString AllFilesWildcard
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:203
void KICAD_MANAGER_FRAME::OnOpenTextEditor ( wxCommandEvent &  event)

Definition at line 458 of file mainframe.cpp.

References Execute(), PGM_BASE::GetEditorName(), and Pgm().

459 {
460  wxString editorname = Pgm().GetEditorName();
461 
462  if( !editorname.IsEmpty() )
463  Execute( this, editorname, wxEmptyString );
464 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:203
void KICAD_MANAGER_FRAME::OnPreferences ( wxCommandEvent &  aEvent)

Definition at line 575 of file mainframe.cpp.

References m_manager_Hokeys_Descr, and EDA_BASE_FRAME::ShowPreferences().

576 {
578 }
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:300
bool ShowPreferences(EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
void KICAD_MANAGER_FRAME::OnRefresh ( wxCommandEvent &  event)

Definition at line 499 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

Referenced by OnUnarchiveFiles().

500 {
502 }
void ReCreateTreePrj()
Create or modify the tree showing project file names.
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
void KICAD_MANAGER_FRAME::OnRunBitmapConverter ( wxCommandEvent &  event)

Definition at line 430 of file mainframe.cpp.

References BITMAPCONVERTER_EXE, and Execute().

431 {
432  Execute( this, BITMAPCONVERTER_EXE );
433 }
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
const wxString BITMAPCONVERTER_EXE
void KICAD_MANAGER_FRAME::OnRunEeschema ( wxCommandEvent &  event)

Definition at line 329 of file mainframe.cpp.

References GetProjectFileName(), RunEeschema(), and SchematicFileExtension.

330 {
331  wxFileName fn( GetProjectFileName() );
332  fn.SetExt( SchematicFileExtension );
333  RunEeschema( fn.GetFullPath() );
334 }
void RunEeschema(const wxString &aProjectSchematicFileName)
Call this only for a SCH associated with the current project.
Definition: mainframe.cpp:294
const std::string SchematicFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
void KICAD_MANAGER_FRAME::OnRunGerbview ( wxCommandEvent &  event)

Definition at line 449 of file mainframe.cpp.

References Execute(), GERBVIEW_EXE, and KIWAY_HOLDER::Prj().

450 {
451  // Gerbview is called without any file to open, because we do not know
452  // the list and the name of files to open (if any...).
453  // however we run it in the path of the project
454  Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() );
455 }
const wxString GERBVIEW_EXE
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor ( wxCommandEvent &  event)

Definition at line 442 of file mainframe.cpp.

References Execute(), and PL_EDITOR_EXE.

443 {
444  Execute( this, PL_EDITOR_EXE );
445 }
const wxString PL_EDITOR_EXE
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
void KICAD_MANAGER_FRAME::OnRunPcbCalculator ( wxCommandEvent &  event)

Definition at line 436 of file mainframe.cpp.

References Execute(), and PCB_CALCULATOR_EXE.

437 {
438  Execute( this, PCB_CALCULATOR_EXE );
439 }
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
const wxString PCB_CALCULATOR_EXE
void KICAD_MANAGER_FRAME::OnRunPcbFpEditor ( wxCommandEvent &  event)

Definition at line 404 of file mainframe.cpp.

References err, FRAME_PCB_MODULE_EDITOR, KIWAY_HOLDER::Kiway(), KIWAY::Player(), and IO_ERROR::What().

Referenced by TREEPROJECT_ITEM::Activate().

405 {
406  KIWAY_PLAYER* frame;
407 
408  try
409  {
410  frame = Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
411  }
412  catch( const IO_ERROR& err )
413  {
414  wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
415  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
416  return;
417  }
418 
419  if( !frame->IsShown() )
420  frame->Show( true );
421 
422  // On Windows, Raise() does not bring the window on screen, when iconized
423  if( frame->IsIconized() )
424  frame->Iconize( false );
425 
426  frame->Raise();
427 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void KICAD_MANAGER_FRAME::OnRunPcbNew ( wxCommandEvent &  event)

Definition at line 392 of file mainframe.cpp.

References PcbFileName(), PcbLegacyFileName(), and RunPcbNew().

393 {
394  wxFileName kicad_board( PcbFileName() );
395  wxFileName legacy_board( PcbLegacyFileName() );
396 
397  wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
398  kicad_board : legacy_board;
399 
400  RunPcbNew( board.GetFullPath() );
401 }
const wxString PcbLegacyFileName()
Definition: mainframe.cpp:166
const wxString PcbFileName()
Definition: mainframe.cpp:156
void RunPcbNew(const wxString &aProjectBoardFileName)
Call this only for a PCB associated with the current project.
Definition: mainframe.cpp:363
void KICAD_MANAGER_FRAME::OnRunSchLibEditor ( wxCommandEvent &  event)

Definition at line 337 of file mainframe.cpp.

References err, FRAME_SCH_LIB_EDITOR, KIWAY_HOLDER::Kiway(), KIWAY::Player(), and IO_ERROR::What().

Referenced by TREEPROJECT_ITEM::Activate().

338 {
339  KIWAY_PLAYER* frame;
340 
341  try
342  {
343  frame = Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
344  }
345  catch( const IO_ERROR& err )
346  {
347  wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
348  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
349  return;
350  }
351 
352  if( !frame->IsShown() )
353  frame->Show( true );
354 
355  // On Windows, Raise() does not bring the window on screen, when iconized
356  if( frame->IsIconized() )
357  frame->Iconize( false );
358 
359  frame->Raise();
360 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void KICAD_MANAGER_FRAME::OnSaveProject ( wxCommandEvent &  event)

Save the project (.pro) file containing the top level configuration parameters.

Definition at line 398 of file prjconfig.cpp.

References PROJECT::ConfigSave(), GeneralGroupName, GetProjectFileName(), PgmTop(), and KIWAY_HOLDER::Prj().

399 {
400  if( !wxIsWritable( GetProjectFileName() ) )
401  return;
402 
404 }
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:318
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
#define GeneralGroupName
Definition: prjconfig.cpp:56
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
void KICAD_MANAGER_FRAME::OnShowHotkeys ( wxCommandEvent &  event)

Definition at line 548 of file mainframe.cpp.

References DisplayHotkeyList(), and m_manager_Hokeys_Descr.

549 {
551 }
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:300
void KICAD_MANAGER_FRAME::OnSize ( wxSizeEvent &  event)

Definition at line 200 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

201 {
202  if( m_auimgr.GetManagedWindow() )
203  m_auimgr.Update();
204 
205  event.Skip();
206 }
wxAuiManager m_auimgr
void KICAD_MANAGER_FRAME::OnUnarchiveFiles ( wxCommandEvent &  event)

Definition at line 57 of file kicad/files-io.cpp.

References DisplayError(), dummy(), Format(), GetChars(), GetProjectFileName(), OnRefresh(), PrintMsg(), KIWAY_HOLDER::Prj(), ZipFileExtension, and ZipFileWildcard().

58 {
59  wxFileName fn = GetProjectFileName();
60 
61  fn.SetExt( ZipFileExtension );
62 
63  wxFileDialog zipfiledlg( this, _( "Unzip Project" ), fn.GetPath(),
64  fn.GetFullName(), ZipFileWildcard(),
65  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
66 
67  if( zipfiledlg.ShowModal() == wxID_CANCEL )
68  return;
69 
70  wxString msg = wxString::Format( _( "\nOpen \"%s\"\n" ), GetChars( zipfiledlg.GetPath() ) );
71  PrintMsg( msg );
72 
73  wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
74  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
75 
76  if( dirDlg.ShowModal() == wxID_CANCEL )
77  return;
78 
79  wxString unzipDir = dirDlg.GetPath() + wxT( "/" );
80  msg.Printf( _( "Unzipping project in \"%s\"\n" ), GetChars( unzipDir ) );
81  PrintMsg( msg );
82 
83  wxFileSystem zipfilesys;
84 
85  zipfilesys.AddHandler( new wxZipFSHandler );
86  zipfilesys.ChangePathTo( zipfiledlg.GetPath() + wxT( "#zip:" ), true );
87 
88  wxFSFile* zipfile = NULL;
89  wxString localfilename = zipfilesys.FindFirst( wxT( "*.*" ) );
90 
91  while( !localfilename.IsEmpty() )
92  {
93  zipfile = zipfilesys.OpenFile( localfilename );
94  if( !zipfile )
95  {
96  DisplayError( this, wxT( "Zip file read error" ) );
97  break;
98  }
99 
100  wxFileName uzfn = localfilename.AfterLast( ':' );
101  uzfn.MakeAbsolute( unzipDir );
102  wxString unzipfilename = uzfn.GetFullPath();
103 
104  msg.Printf( _( "Extract file \"%s\"" ), GetChars( unzipfilename ) );
105  PrintMsg( msg );
106 
107  wxInputStream* stream = zipfile->GetStream();
108  wxFFileOutputStream* ofile = new wxFFileOutputStream( unzipfilename );
109 
110  if( ofile->Ok() )
111  {
112  ofile->Write( *stream );
113  PrintMsg( _( " OK\n" ) );
114  }
115  else
116  PrintMsg( _( " *ERROR*\n" ) );
117 
118  delete ofile;
119  delete zipfile;
120 
121  localfilename = zipfilesys.FindNext();
122  }
123 
124  PrintMsg( wxT( "** end **\n" ) );
125 
126  if( unzipDir == Prj().GetProjectPath() )
127  {
128  wxCommandEvent dummy;
129  OnRefresh( dummy );
130  }
131 }
void OnRefresh(wxCommandEvent &event)
Definition: mainframe.cpp:499
wxString ZipFileWildcard()
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:194
#define ZipFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
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:92
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:205
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
void KICAD_MANAGER_FRAME::OnUpdateRequiresProject ( wxUpdateUIEvent &  event)

Definition at line 407 of file prjconfig.cpp.

References m_active_project.

408 {
409  event.Enable( m_active_project );
410 }
bool m_active_project
Definition: kicad.h:304
const wxString KICAD_MANAGER_FRAME::PcbFileName ( )

Definition at line 156 of file mainframe.cpp.

References GetProjectFileName(), and PcbFileExtension.

Referenced by TREEPROJECT_ITEM::Activate(), OnRunPcbNew(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

157 {
158  wxFileName fn( GetProjectFileName() );
159 
160  fn.SetExt( PcbFileExtension );
161 
162  return fn.GetFullPath();
163 }
#define PcbFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName ( )

Definition at line 166 of file mainframe.cpp.

References GetProjectFileName(), and LegacyPcbFileExtension.

Referenced by TREEPROJECT_ITEM::Activate(), OnRunPcbNew(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

167 {
168  wxFileName fn( GetProjectFileName() );
169 
170  fn.SetExt( LegacyPcbFileExtension );
171 
172  return fn.GetFullPath();
173 }
const std::string LegacyPcbFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
bool EDA_BASE_FRAME::PostCommandMenuEvent ( int  evt_type)
inherited

Function PostCommandMenuEvent.

Post a menu event to the frame, which can be used to trigger actions bound to menu items.

Definition at line 654 of file eda_base_frame.cpp.

Referenced by EDA_BASE_FRAME::GetMruPath(), FOOTPRINT_EDIT_FRAME::OnHotKey(), FOOTPRINT_EDIT_FRAME::OnHotkeyDeleteItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyDuplicateItem(), PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyEditItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyMoveItem(), FOOTPRINT_EDIT_FRAME::OnHotkeyMoveItemExact(), and FOOTPRINT_EDIT_FRAME::OnHotkeyRotateItem().

655 {
656  if( evt_type != 0 )
657  {
658  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
659  evt.SetEventObject( this );
660  evt.SetId( evt_type );
661  wxPostEvent( this, evt );
662  return true;
663  }
664 
665  return false;
666 }
void KICAD_MANAGER_FRAME::PrintMsg ( const wxString &  aText)

Displays aText in the text panel.

Parameters
aTextThe text to display.

Definition at line 194 of file mainframe.cpp.

References m_MessagesBox.

Referenced by Execute(), OnArchiveFiles(), KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate(), OnUnarchiveFiles(), and PrintPrjInfo().

195 {
196  m_MessagesBox->AppendText( aText );
197 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
void KICAD_MANAGER_FRAME::PrintPrjInfo ( )

Prints the current working directory name and the projet name on the text panel.

Definition at line 540 of file mainframe.cpp.

References Format(), GetChars(), GetProjectFileName(), and PrintMsg().

Referenced by LoadProject().

541 {
542  wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
544  PrintMsg( msg );
545 }
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:194
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
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:92
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:205
PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Function Prj returns a reference to the PROJECT "associated with" this KIWAY.

Definition at line 34 of file kiway_holder.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), LIB_MANAGER::addLibrary(), SCH_EDIT_FRAME::AppendSchematic(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), DIALOG_SYMBOL_REMAP::backupProject(), LIB_VIEW_FRAME::BestZoom(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_FOOTPRINT_FP_EDITOR::Cfg3DPath(), DIALOG_FOOTPRINT_BOARD_EDITOR::Cfg3DPath(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::checkAliasName(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), CreateNewProject(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT(), DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), PCB_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::Files_io_from_id(), NETLIST_DIALOG::GenNetlist(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), SCH_BASE_FRAME::GetLibAlias(), SCH_BASE_FRAME::GetLibPart(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), DIALOG_BOM::getPluginFileName(), GetProjectFileName(), LIB_VIEW_FRAME::getSelectedAlias(), FP_THREAD_IFACE::GetTable(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), PCB_EDIT_FRAME::InstallNetlistFrame(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), KIWAY_HOLDER::Kiway(), LIB_EDIT_FRAME::KiwayMailIn(), EDA_DRAW_FRAME::LibraryFileBrowser(), SCH_EDIT_FRAME::Load_Component(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), CVPCB_MAINFRAME::LoadFootprintFiles(), DIALOG_SPICE_MODEL::loadLibrary(), LIB_EDIT_FRAME::LoadOneSymbol(), LoadProject(), CVPCB_MAINFRAME::LoadProjectFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_DRC_CONTROL::makeValidFileNameReport(), DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged(), DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), DIALOG_GENCAD_EXPORT_OPTIONS::onBrowse(), OnBrowseInFileExplorer(), DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick(), DIALOG_EDIT_COMPONENTS_LIBID::onClickOrphansButton(), CVPCB_MAINFRAME::OnConfigurePaths(), FOOTPRINT_EDIT_FRAME::OnConfigurePaths(), OnCreateProjectFromTemplate(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_GENDRILL::OnGenReportFile(), SCH_EDIT_FRAME::OnImportProject(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), OnOpenFileInTextEditor(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OnRightClick(), OnRunGerbview(), DIALOG_BOM::OnRunPlugin(), FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng(), OnSaveProject(), DIALOG_SPICE_MODEL::onSelectLibrary(), LIB_VIEW_FRAME::OnSelectSymbol(), OnUnarchiveFiles(), LIB_EDIT_FRAME::OnViewEntryDoc(), LIB_VIEW_FRAME::onViewSymbolDocument(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PANEL_PREV_3D::PANEL_PREV_3D(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME(), DIALOG_CHOOSE_COMPONENT::PopulateFootprintSelector(), SCH_EDIT_FRAME::Process_Config(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), EDA_3D_VIEWER::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::saveFootprintInLibrary(), LIB_EDIT_FRAME::saveLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), LIB_EDIT_FRAME::savePartAs(), SCH_EDIT_FRAME::SaveProject(), CVPCB_MAINFRAME::SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), SCH_BASE_FRAME::saveSymbolLibTables(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectComponentFromLibTree(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), LIB_EDIT_FRAME::selectSymLibTable(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), SetProjectFileName(), DIALOG_CHOOSE_COMPONENT::ShowFootprintFor(), FOOTPRINT_VIEWER_FRAME::ShowModal(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), LIB_MANAGER::symTable(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow(), SIM_PLOT_FRAME::updateNetlistExporter(), SCH_SCREEN::UpdateSymbolLinks(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::~DIALOG_FOOTPRINT_FP_EDITOR(), LAUNCHER_PANEL::~LAUNCHER_PANEL(), and PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME().

35 {
36  return Kiway().Prj();
37 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:142
bool EDA_BASE_FRAME::ProcessEvent ( wxEvent &  aEvent)
overrideinherited

Function ProcessEvent overrides the default process event handler to implement the auto save feature.

Warning
If you override this function in a derived class, make sure you call down to this or the auto save feature will be disabled.

Definition at line 158 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::findQuasiModalDialog(), EDA_BASE_FRAME::isAutoSaveRequired(), EDA_BASE_FRAME::m_autoSaveInterval, EDA_BASE_FRAME::m_autoSaveState, EDA_BASE_FRAME::m_autoSaveTimer, EDA_BASE_FRAME::m_hasAutoSave, and traceAutoSave.

Referenced by EDA_BASE_FRAME::isAutoSaveRequired(), STATUS_POPUP::onCharHook(), LIB_VIEW_FRAME::onSelectNextSymbol(), LIB_VIEW_FRAME::onSelectPreviousSymbol(), KIWAY::ProcessEvent(), LIB_VIEW_FRAME::ReCreateListCmp(), CVPCB_CONTROL::SwitchUnits(), GERBVIEW_CONTROL::SwitchUnits(), and PCBNEW_CONTROL::SwitchUnits().

159 {
160 #ifdef __WXMAC__
161  // Apple in its infinite wisdom will raise a disabled window before even passing
162  // us the event, so we have no way to stop it. Instead, we have to catch an
163  // improperly ordered disabled window and quasi-modal dialog here and reorder
164  // them.
165  if( !IsEnabled() && IsActive() )
166  {
167  wxWindow* dlg = findQuasiModalDialog();
168  if( dlg )
169  dlg->Raise();
170  }
171 #endif
172 
173  if( !wxFrame::ProcessEvent( aEvent ) )
174  return false;
175 
176  if( IsShown() && m_hasAutoSave && IsActive() &&
178  {
179  if( !m_autoSaveState )
180  {
181  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
182  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
183  m_autoSaveState = true;
184  }
185  else if( m_autoSaveTimer->IsRunning() )
186  {
187  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
188  m_autoSaveTimer->Stop();
189  m_autoSaveState = false;
190  }
191  }
192 
193  return true;
194 }
bool m_autoSaveState
Flag to indicate the last auto save state.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
wxWindow * findQuasiModalDialog()
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
int m_autoSaveInterval
The auto save interval time in seconds.
void KICAD_MANAGER_FRAME::RecreateBaseHToolbar ( )

(Re)Create the horizontal toolbar

Definition at line 461 of file kicad/menubar.cpp.

References ID_BROWSE_IN_FILE_EXPLORER, ID_H_TOOLBAR, ID_LOAD_PROJECT, ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, ID_PROJECT_TREE_REFRESH, ID_READ_ZIP_ARCHIVE, ID_SAVE_AND_ZIP_FILES, ID_SAVE_PROJECT, EDA_BASE_FRAME::KICAD_AUI_TB_STYLE, KiScaledBitmap(), KiScaledSeparator(), and EDA_BASE_FRAME::m_mainToolBar.

Referenced by KICAD_MANAGER_FRAME().

462 {
463  if( m_mainToolBar )
464  m_mainToolBar->Clear();
465  else
466  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
467  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
468 
469  // New
470  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
471  KiScaledBitmap( new_project_xpm, this ),
472  _( "Create new project" ) );
473 
474  m_mainToolBar->AddTool( ID_NEW_PROJECT_FROM_TEMPLATE, wxEmptyString,
475  KiScaledBitmap( new_project_with_template_xpm, this ),
476  _( "Create new project from template" ) );
477 
478  // Load
479  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString,
480  KiScaledBitmap( open_project_xpm, this ),
481  _( "Open existing project" ) );
482 
483  // Currently there is nothing to save
484  // (Kicad manager does not save any info in .pro file)
485 #if 0
486  // Save
487  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString,
488  KiScaledBitmap( save_project_xpm, this ),
489  _( "Save current project" ) );
490 #endif
491 
493 
494  // Archive
495  m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
496  KiScaledBitmap( zip_xpm, this ),
497  _( "Archive all project files" ) );
498 
499  // Unarchive
500  m_mainToolBar->AddTool( ID_READ_ZIP_ARCHIVE, wxEmptyString,
501  KiScaledBitmap( unzip_xpm, this ),
502  _( "Unarchive project files from zip archive" ) );
503 
505 
506  // Refresh project tree
507  m_mainToolBar->AddTool( ID_PROJECT_TREE_REFRESH, wxEmptyString,
508  KiScaledBitmap( reload_xpm, this ),
509  _( "Refresh project tree" ) );
510 
511  // Acces to the system file manager
513  m_mainToolBar->AddTool( ID_BROWSE_IN_FILE_EXPLORER, wxEmptyString,
514  KiScaledBitmap( directory_browser_xpm, this ),
515  _( "Open project directory in file explorer" ) );
516 
517  // Create m_mainToolBar
518  m_mainToolBar->Realize();
519 }
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
Definition: bitmap.cpp:167
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
void KICAD_MANAGER_FRAME::ReCreateMenuBar ( void  )
overridevirtual

(Re)Create the menubar

Reimplemented from EDA_BASE_FRAME.

Definition at line 186 of file kicad/menubar.cpp.

References AddHotkeyName(), AddMenuItem(), PGM_BASE::AddMenuLanguageList(), PGM_KICAD::GetFileHistory(), HK_HELP, HK_NEW, HK_NEW_PRJ_TEMPLATE, HK_OPEN, HK_REFRESH, HK_RUN_BM2COMPONENT, HK_RUN_EESCHEMA, HK_RUN_FPEDITOR, HK_RUN_GERBVIEW, HK_RUN_LIBEDIT, HK_RUN_PCBCALCULATOR, HK_RUN_PCBNEW, HK_RUN_PLEDITOR, HK_SAVE, ID_BROWSE_AN_SELECT_FILE, ID_BROWSE_IN_FILE_EXPLORER, ID_EDIT_FOOTPRINT_LIBRARY_TABLE, ID_EDIT_SYMBOL_LIBRARY_TABLE, ID_HELP_GET_INVOLVED, ID_IMPORT_EAGLE_PROJECT, ID_LOAD_PROJECT, ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, ID_PREFERENCES_CONFIGURE_PATHS, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, ID_PROJECT_TREE_REFRESH, ID_READ_ZIP_ARCHIVE, ID_SAVE_AND_ZIP_FILES, ID_SAVE_PROJECT, ID_TO_BITMAP_CONVERTER, ID_TO_GERBVIEW, ID_TO_PCB, ID_TO_PCB_CALCULATOR, ID_TO_PCB_FP_EDITOR, ID_TO_PL_EDITOR, ID_TO_SCH, ID_TO_SCH_LIB_EDITOR, ID_TO_TEXT_EDITOR, KiBitmap(), kicad_Manager_Hokeys_Descr, m_manager_Hokeys_Descr, Pgm(), and PgmTop().

Referenced by KICAD_MANAGER_FRAME().

187 {
188  wxString msg;
189  static wxMenu* openRecentMenu; // Open Recent submenu,
190  // static to remember this menu
191 
193 
194  // wxWidgets handles the Mac Application menu behind the scenes, but that means
195  // we always have to start from scratch with a new wxMenuBar.
196  wxMenuBar* oldMenuBar = GetMenuBar();
197  wxMenuBar* menuBar = new wxMenuBar();
198 
199  // Before deleting, remove the menus managed by m_fileHistory
200  // (the file history will be updated when adding/removing files in history)
201  if( openRecentMenu )
202  PgmTop().GetFileHistory().RemoveMenu( openRecentMenu );
203 
204  // Recreate all menus:
205 
206  // Menu File:
207  wxMenu* fileMenu = new wxMenu;
208 
209  // New project creation
210  wxMenu* newprjSubMenu = new wxMenu();
211  msg = AddHotkeyName( _( "&Project..." ), kicad_Manager_Hokeys_Descr, HK_NEW );
212  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT, msg,
213  _( "Create new blank project" ),
214  KiBitmap( new_project_xpm ) );
215  msg = AddHotkeyName( _( "Project from &Template..." ),
217  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT_FROM_TEMPLATE, msg,
218  _( "Create new project from template" ),
219  KiBitmap( new_project_with_template_xpm ) );
220  AddMenuItem( fileMenu, newprjSubMenu,
221  wxID_ANY,
222  _( "&New" ),
223  _( "Create new project" ),
224  KiBitmap( new_project_xpm ) );
225 
226  // Open
227  msg = AddHotkeyName( _( "&Open Project..." ), kicad_Manager_Hokeys_Descr, HK_OPEN );
228  AddMenuItem( fileMenu, ID_LOAD_PROJECT, msg,
229  _( "Open an existing project" ),
230  KiBitmap( open_project_xpm ) );
231 
232  // File history
233  openRecentMenu = new wxMenu();
234  PgmTop().GetFileHistory().UseMenu( openRecentMenu );
235  PgmTop().GetFileHistory().AddFilesToMenu( );
236  AddMenuItem( fileMenu, openRecentMenu,
237  wxID_ANY,
238  _( "Open &Recent" ),
239  _( "Open a recent project" ),
240  KiBitmap( recent_xpm ) );
241 
242  // Currently there is nothing to save
243  // (Kicad manager does not save any info in .pro file)
244 #if 0
245  // Save
246  msg = AddHotkeyName( _( "&Save" ), kicad_Manager_Hokeys_Descr, HK_SAVE );
247  AddMenuItem( fileMenu, ID_SAVE_PROJECT, msg,
248  _( "Save current project" ),
249  KiBitmap( save_project_xpm ) );
250 #endif
251 
252  fileMenu->AppendSeparator();
253  wxMenu* importprjSubMenu = new wxMenu();
254 
255  AddMenuItem( importprjSubMenu, ID_IMPORT_EAGLE_PROJECT, _( "EAGLE CAD..." ),
256  _( "Import EAGLE CAD XML schematic and board" ),
257  KiBitmap( import_project_xpm ) );
258 
259 
260  AddMenuItem( fileMenu, importprjSubMenu,
261  wxID_ANY,
262  _( "Import Project" ),
263  _( "Import project files from other software" ),
264  KiBitmap( import_project_xpm ) );
265 
266 
267  fileMenu->AppendSeparator();
268 
269  // Archive
270  AddMenuItem( fileMenu,
272  _( "&Archive Project..." ),
273  _( "Archive all needed project files into zip archive" ),
274  KiBitmap( zip_xpm ) );
275 
276  // Unarchive
277  AddMenuItem( fileMenu,
279  _( "&Unarchive Project..." ),
280  _( "Unarchive project files from zip archive" ),
281  KiBitmap( unzip_xpm ) );
282 
283  // Separator
284  fileMenu->AppendSeparator();
285 
286  // Quit
287  AddMenuItem( fileMenu,
288  wxID_EXIT,
289  _( "&Exit" ),
290  _( "Close KiCad" ),
291  KiBitmap( exit_xpm ) );
292 
293  // View Menu:
294  wxMenu* viewMenu = new wxMenu();
295 
296  // Refresh project tree
297  msg = AddHotkeyName( _( "&Refresh" ), kicad_Manager_Hokeys_Descr, HK_REFRESH );
298  AddMenuItem( viewMenu, ID_PROJECT_TREE_REFRESH, msg,
299  _( "Refresh project tree" ),
300  KiBitmap( reload_xpm ) );
301 
302 #ifdef __APPLE__
303  viewMenu->AppendSeparator();
304 #endif
305 
306  // Menu Browse:
307  wxMenu* browseMenu = new wxMenu();
308 
309  // Text editor
310  AddMenuItem( browseMenu,
312  _( "Open Text E&ditor" ),
313  _( "Launch preferred text editor" ),
314  KiBitmap( editor_xpm ) );
315 
316  // View file
317  AddMenuItem( browseMenu,
319  _( "&Open Local File..." ),
320  _( "Edit local file" ),
321  KiBitmap( browse_files_xpm ) );
322 
323  // Browse in file explorer
324  browseMenu->AppendSeparator();
325  AddMenuItem( browseMenu,
327  _( "&Browse Project Files" ),
328  _( "Open project directory in file explorer" ),
329  KiBitmap( directory_browser_xpm ) );
330 
331  // Menu Preferences:
332  wxMenu* preferencesMenu = new wxMenu;
333 
334  // Path configuration edit dialog.
335  AddMenuItem( preferencesMenu,
337  _( "&Configure Paths..." ),
338  _( "Edit path configuration environment variables" ),
339  KiBitmap( path_xpm ) );
340 
341  AddMenuItem( preferencesMenu,
343  _( "Manage &Symbol Libraries..." ),
344  _( "Edit the global and project symbol library tables" ),
345  KiBitmap( library_table_xpm ) );
346 
347  AddMenuItem( preferencesMenu,
349  _( "Manage &Footprint Libraries..." ),
350  _( "Configure footprint library table" ),
351  KiBitmap( library_table_xpm ) );
352 
353  AddMenuItem( preferencesMenu,
354  wxID_PREFERENCES,
355  _( "&Preferences..." ),
356  _( "Show preferences for all open tools" ),
357  KiBitmap( preference_xpm ) );
358 
359  preferencesMenu->AppendSeparator();
360 
361  // Language submenu
362  Pgm().AddMenuLanguageList( preferencesMenu );
363 
364  // Menu Tools:
365  wxMenu* toolsMenu = new wxMenu;
366 
367  msg = AddHotkeyName( _( "Edit Schematic" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA );
368  AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
369 
370  msg = AddHotkeyName( _( "Edit Schematic Symbols" ),
372  AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
373 
374  msg = AddHotkeyName( _( "Edit PCB" ),
376  AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
377 
378  msg = AddHotkeyName( _( "Edit PCB Footprints" ),
380  AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
381 
382  msg = AddHotkeyName( _( "View Gerber Files" ),
384  AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
385 
386  msg = AddHotkeyName( _( "Convert Image" ),
388  AddMenuItem( toolsMenu, ID_TO_BITMAP_CONVERTER, msg,
389  _( "Convert bitmap images to schematic or PCB components" ),
390  KiBitmap( bitmap2component_xpm ) );
391 
392  msg = AddHotkeyName( _( "Calculator Tools" ), kicad_Manager_Hokeys_Descr, HK_RUN_PCBCALCULATOR );
393  AddMenuItem( toolsMenu, ID_TO_PCB_CALCULATOR, msg,
394  _( "Run component calculations, track width calculations, etc." ),
395  KiBitmap( calculator_xpm ) );
396 
397  msg = AddHotkeyName( _( "Edit Worksheet" ), kicad_Manager_Hokeys_Descr, HK_RUN_PLEDITOR );
398  AddMenuItem( toolsMenu, ID_TO_PL_EDITOR, msg,
399  _( "Edit worksheet graphics and text" ),
400  KiBitmap( pagelayout_load_xpm ) );
401 
402  // Menu Help:
403  wxMenu* helpMenu = new wxMenu;
404 
405  // Contents
406  AddMenuItem( helpMenu, wxID_HELP,
407  _( "KiCad &Manual" ),
408  _( "Open KiCad user manual" ),
409  KiBitmap( online_help_xpm ) );
410 
411  AddMenuItem( helpMenu, wxID_INDEX,
412  _( "&Getting Started in KiCad" ),
413  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
414  KiBitmap( help_xpm ) );
415 
416  AddMenuItem( helpMenu,
418  _( "&List Hotkeys" ),
419  _( "Displays the current hotkeys list and corresponding commands" ),
420  KiBitmap( hotkeys_xpm ) );
421 
422  // Separator
423  helpMenu->AppendSeparator();
424 
425  // Get involved with KiCad
427  _( "Get &Involved" ),
428  _( "Contribute to KiCad (opens a web browser)" ),
429  KiBitmap( info_xpm ) );
430 
431  helpMenu->AppendSeparator();
432 
433  // About
434  AddMenuItem( helpMenu, wxID_ABOUT, _( "&About KiCad" ), KiBitmap( about_xpm ) );
435 
436  // Create the menubar and append all submenus
437  menuBar->Append( fileMenu, _( "&File" ) );
438  menuBar->Append( viewMenu, _( "&View" ) );
439  menuBar->Append( toolsMenu, _( "&Tools" ) );
440  menuBar->Append( browseMenu, _( "&Browse" ) );
441  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
442  menuBar->Append( helpMenu, _( "&Help" ) );
443 
444  SetMenuBar( menuBar );
445  delete oldMenuBar;
446 
447  // Add the hotkey to the "show hotkey list" menu, because we do not have
448  // a management of the keyboard keys in Kicad.
449  // So all hotheys should be added to the menubar
450  // Note Use wxMenuBar::SetLabel only after the menubar
451  // has been associated with a frame. (see wxWidgets doc)
452  msg = AddHotkeyName( menuBar->GetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST ),
454  menuBar->SetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg );
455 }
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:57
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
struct EDA_HOTKEY_CONFIG kicad_Manager_Hokeys_Descr[]
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:300
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
VTBL_ENTRY void AddMenuLanguageList(wxMenu *MasterMenu)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
Definition: pgm_base.cpp:800
ID_TO_PCB_FP_EDITOR
void KICAD_MANAGER_FRAME::ReCreateTreePrj ( )

Definition at line 176 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

Referenced by OnImportEagleFiles(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

177 {
179 }
void ReCreateTreePrj()
Create or modify the tree showing project file names.
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
void KICAD_MANAGER_FRAME::RunEeschema ( const wxString &  aProjectSchematicFileName)

Call this only for a SCH associated with the current project.

That is, it must have the same path and name as the project *.pro file.

Definition at line 294 of file mainframe.cpp.

References err, FRAME_SCH, KIWAY_HOLDER::Kiway(), KIWAY_PLAYER::OpenProjectFiles(), KIWAY::Player(), and IO_ERROR::What().

Referenced by OnRunEeschema(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

295 {
296  KIWAY_PLAYER* frame;
297 
298  try
299  {
300  frame = Kiway().Player( FRAME_SCH, true );
301  }
302  catch( const IO_ERROR& err )
303  {
304  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
305  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
306  return;
307  }
308 
309  if( !frame->IsShown() ) // A hidden frame might not have the project loaded.
310  {
311  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
312  frame->Show( true );
313  }
314 
315  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
316  // On linux, Raise() brings the window on screen, but this code works fine
317  if( frame->IsIconized() )
318  {
319  frame->Iconize( false );
320  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
321  // to show the frame at its normal size: Maximize should be called.
322  frame->Maximize( false );
323  }
324 
325  frame->Raise();
326 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList...
Definition: kiway_player.h:179
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void KICAD_MANAGER_FRAME::RunPcbNew ( const wxString &  aProjectBoardFileName)

Call this only for a PCB associated with the current project.

That is, it must have the same path and name as the project *.pro file.

Definition at line 363 of file mainframe.cpp.

References err, FRAME_PCB, KIWAY_HOLDER::Kiway(), KIWAY_PLAYER::OpenProjectFiles(), KIWAY::Player(), and IO_ERROR::What().

Referenced by OnRunPcbNew(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

364 {
365  KIWAY_PLAYER* frame;
366 
367  try
368  {
369  frame = Kiway().Player( FRAME_PCB, true );
370  }
371  catch( const IO_ERROR& err )
372  {
373  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
374  wxOK | wxICON_ERROR, this );
375  return;
376  }
377 
378  if( !frame->IsVisible() ) // A hidden frame might not have the board loaded.
379  {
380  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
381  frame->Show( true );
382  }
383 
384  // On Windows, Raise() does not bring the window on screen, when iconized
385  if( frame->IsIconized() )
386  frame->Iconize( false );
387 
388  frame->Raise();
389 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList...
Definition: kiway_player.h:179
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
virtual void EDA_BASE_FRAME::SaveProjectSettings ( bool  aAskForSave)
inlinevirtualinherited

Function SaveProjectSettings saves changes to the project settings to the project (.pro) file.

The method is virtual so you can override it to call the suitable save method. The base method do nothing

Parameters
aAskForSave= true to open a dialog before saving the settings

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 283 of file eda_base_frame.h.

References EDA_BASE_FRAME::ExportHotkeyConfigToFile(), EDA_BASE_FRAME::GetFileFromHistory(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), EDA_BASE_FRAME::UpdateFileHistory(), and EDA_BASE_FRAME::WriteHotkeyConfig().

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick(), and SCH_EDIT_FRAME::Process_Config().

283 {};
void KICAD_MANAGER_FRAME::SaveSettings ( wxConfigBase *  aCfg)
overridevirtual

Function SaveSettings saves common frame parameters to a configuration data file.

Don't forget to call the base class's SaveSettings() from your derived SaveSettings() otherwise the frames won't remember their positions and sizes.

Reimplemented from EDA_BASE_FRAME.

Definition at line 533 of file mainframe.cpp.

References m_LeftWin, EDA_BASE_FRAME::SaveSettings(), and TREE_FRAME_WIDTH_ENTRY.

534 {
536  aCfg->Write( TREE_FRAME_WIDTH_ENTRY, m_LeftWin->GetSize().x );
537 }
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
#define TREE_FRAME_WIDTH_ENTRY
Definition: mainframe.cpp:54
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
const wxString KICAD_MANAGER_FRAME::SchFileName ( )

Definition at line 146 of file mainframe.cpp.

References GetProjectFileName(), and SchematicFileExtension.

Referenced by TREEPROJECT_ITEM::Activate(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

147 {
148  wxFileName fn( GetProjectFileName() );
149 
150  fn.SetExt( SchematicFileExtension );
151 
152  return fn.GetFullPath();
153 }
const std::string SchematicFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
void EDA_BASE_FRAME::SetAutoSaveInterval ( int  aInterval)
inherited

Definition at line 197 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::m_autoSaveInterval, EDA_BASE_FRAME::m_autoSaveState, and EDA_BASE_FRAME::m_autoSaveTimer.

Referenced by EDA_DRAW_FRAME::CommonSettingsChanged(), and EDA_BASE_FRAME::isAutoSaveRequired().

198 {
199  m_autoSaveInterval = aInterval;
200 
201  if( m_autoSaveTimer->IsRunning() )
202  {
203  if( m_autoSaveInterval > 0 )
204  {
205  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
206  }
207  else
208  {
209  m_autoSaveTimer->Stop();
210  m_autoSaveState = false;
211  }
212  }
213 }
bool m_autoSaveState
Flag to indicate the last auto save state.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
int m_autoSaveInterval
The auto save interval time in seconds.
void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

Function SetKiway.

Parameters
aDestis the recipient of aKiway pointer. It is only used for debugging, since "this" is not a wxWindow*. "this" is a KIWAY_HOLDER mix-in.
aKiwayis often from a parent window, or from KIFACE::CreateWindow().

Definition at line 47 of file kiway_holder.cpp.

References KIWAY_HOLDER::m_kiway, and name.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), InvokePcbLibTableEditor(), KIWAY_HOLDER::Kiway(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

48 {
49 #if defined(DEBUG)
50  // offer a trap point for debugging most any window
51  wxASSERT( aDest );
52  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
53  {
54  int breakhere=1;
55  (void) breakhere;
56  }
57 #endif
58 
59  (void) aDest;
60 
61  m_kiway = aKiway;
62 }
KIWAY * m_kiway
Definition: kiway_player.h:94
const char * name
Definition: DXF_plotter.cpp:61
void EDA_BASE_FRAME::SetMruPath ( const wxString &  aPath)
inlineinherited

Definition at line 346 of file eda_base_frame.h.

Referenced by LoadProject().

346 { m_mruPath = aPath; }
wxString m_mruPath
Most recently used path.
void KICAD_MANAGER_FRAME::SetProjectFileName ( const wxString &  aFullProjectProFileName)

Definition at line 128 of file mainframe.cpp.

References KIWAY_HOLDER::Prj(), and PROJECT::SetProjectFullName().

Referenced by CreateNewProject(), LoadProject(), OnImportEagleFiles(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

129 {
130  // ensure file name is absolute:
131  wxFileName fn( aFullProjectProFileName );
132 
133  if( !fn.IsAbsolute() )
134  fn.MakeAbsolute();
135 
136  Prj().SetProjectFullName( fn.GetFullPath() );
137 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY void SetProjectFullName(const wxString &aFullPathAndName)
Function SetProjectFullName sets the: 1) full directory, 2) basename, and 3) extension of the project...
Definition: project.cpp:64
void EDA_BASE_FRAME::ShowChangedLanguage ( )
virtualinherited

Function ShowChangedLanguage redraws the menus and what not in current language.

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, LIB_EDIT_FRAME, FOOTPRINT_EDIT_FRAME, GERBVIEW_FRAME, PCB_BASE_FRAME, and CVPCB_MAINFRAME.

Definition at line 234 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by EDA_BASE_FRAME::GetMruPath(), KIWAY::SetLanguage(), CVPCB_MAINFRAME::ShowChangedLanguage(), PCB_BASE_FRAME::ShowChangedLanguage(), GERBVIEW_FRAME::ShowChangedLanguage(), LIB_EDIT_FRAME::ShowChangedLanguage(), and SCH_EDIT_FRAME::ShowChangedLanguage().

235 {
236  if( GetMenuBar() )
237  {
238  ReCreateMenuBar();
239  GetMenuBar()->Refresh();
240  }
241 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
bool EDA_BASE_FRAME::ShowPreferences ( EDA_HOTKEY_CONFIG aHotkeys,
EDA_HOTKEY_CONFIG aShowHotkeys,
const wxString &  aHotkeysNickname 
)
inherited

Definition at line 513 of file eda_base_frame.cpp.

References KIWAY::CommonSettingsChanged(), PAGED_DIALOG::GetTreebook(), i, EDA_BASE_FRAME::InstallPreferences(), KIWAY_HOLDER::Kiway(), KIWAY_PLAYER_COUNT, and KIWAY::Player().

Referenced by EDA_BASE_FRAME::IsType(), OnPreferences(), LIB_EDIT_FRAME::OnPreferencesOptions(), SCH_EDIT_FRAME::OnPreferencesOptions(), PL_EDITOR_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), GERBVIEW_FRAME::Process_Config(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

515 {
516  PAGED_DIALOG dlg( this, _( "Preferences" ) );
517  wxTreebook* book = dlg.GetTreebook();
518 
519  book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
520  book->AddPage( new PANEL_HOTKEYS_EDITOR( this, book, false,
521  aHotkeys, aShowHotkeys, aHotkeysNickname ), _( "Hotkeys" ) );
522 
523  for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
524  {
525  KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
526 
527  if( frame )
528  frame->InstallPreferences( &dlg );
529  }
530 
531  if( dlg.ShowModal() == wxID_OK )
532  {
533  dlg.Kiway().CommonSettingsChanged();
534  return true;
535  }
536 
537  return false;
538 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
size_t i
Definition: json11.cpp:597
virtual void InstallPreferences(PAGED_DIALOG *aParent)
Function InstallPreferences allows a Frame to load its preference panels (if any) into the preference...
const SEARCH_STACK & KICAD_MANAGER_FRAME::sys_search ( )
overrideprivatevirtual

Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented from EDA_BASE_FRAME.

Definition at line 182 of file mainframe.cpp.

References PgmTop(), and PGM_KICAD::SysSearch().

Referenced by CreateNewProject(), and KICAD_MANAGER_FRAME::TERMINATE_HANDLER::TERMINATE_HANDLER().

183 {
184  return PgmTop().SysSearch();
185 }
SEARCH_STACK & SysSearch()
Definition: pgm_kicad.h:61
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void EDA_BASE_FRAME::UpdateFileHistory ( const wxString &  FullFileName,
wxFileHistory *  aFileHistory = NULL 
)
inherited

Function UpdateFileHistory Updates the list of recently opened files.

Note also the menu is updated, if wxFileHistory::UseMenu was called at init time

Parameters
FullFileNameThe full file name including the path.
aFileHistoryThe wxFileHistory in use. If NULL, the main application file history is used.

Definition at line 387 of file eda_base_frame.cpp.

References KIFACE_I::GetFileHistory(), and Kiface().

Referenced by SCH_EDIT_FRAME::importFile(), GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::loadListOfGerberFiles(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), LoadProject(), OnCloseWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::SavePcbFile(), EDA_BASE_FRAME::SaveProjectSettings(), and GERBVIEW_FRAME::unarchiveFiles().

389 {
390  wxFileHistory* fileHistory = aFileHistory;
391 
392  if( !fileHistory )
393  fileHistory = &Kiface().GetFileHistory();
394 
395  fileHistory->AddFileToHistory( FullFileName );
396 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:123
int EDA_BASE_FRAME::WriteHotkeyConfig ( struct EDA_HOTKEY_CONFIG aDescList,
wxString *  aFullFileName = NULL 
)
virtualinherited

Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mechanism or a file.

Parameters
aDescList= pointer to the current hotkey list.
aFullFileName= a wxString pointer to a full file name. if NULL, use the standard wxConfig mechanism (default) the output format is: shortcut "key" "function" lines starting with # are comments

Reimplemented in EDA_DRAW_FRAME.

Definition at line 489 of file hotkeys_basic.cpp.

References AddDelimiterString(), DEFAULT_HOTKEY_FILENAME_EXT, EESCHEMA_HOTKEY_NAME, FOOTPRINT_EDIT_FRAME_NAME, GetChars(), GetKicadConfigPath(), KeyNameFromKeyCode(), LIB_EDIT_FRAME_NAME, EDA_HOTKEY_CONFIG::m_HK_InfoList, EDA_HOTKEY::m_InfoMsg, EDA_HOTKEY::m_KeyCode, EDA_HOTKEY_CONFIG::m_SectionTag, EDA_HOTKEY_CONFIG::m_Title, PCB_EDIT_FRAME_NAME, PCBNEW_HOTKEY_NAME, and SCH_EDIT_FRAME_NAME.

Referenced by EDA_BASE_FRAME::SaveProjectSettings(), PANEL_HOTKEYS_EDITOR::TransferDataFromWindow(), and EDA_DRAW_FRAME::WriteHotkeyConfig().

491 {
492  wxString msg;
493  wxString keyname, infokey;
494  FILE* file;
495 
496  msg = wxT( "$hotkey list\n" );
497 
498  // Print the current hotkey list
499  EDA_HOTKEY** list;
500 
501  for( ; aDescList->m_HK_InfoList != nullptr; aDescList++ )
502  {
503  if( aDescList->m_Title )
504  {
505  msg += wxT( "# " );
506  msg += *aDescList->m_Title;
507  msg += wxT( "\n" );
508  }
509 
510  msg += *aDescList->m_SectionTag;
511  msg += wxT( "\n" );
512 
513  list = aDescList->m_HK_InfoList;
514 
515  for( ; *list != nullptr; list++ )
516  {
517  EDA_HOTKEY* hk_decr = *list;
518  msg += wxT( "shortcut " );
519  keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
520  AddDelimiterString( keyname );
521  infokey = hk_decr->m_InfoMsg;
522  AddDelimiterString( infokey );
523  msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
524  }
525  }
526 
527  msg += wxT( "$Endlist\n" );
528 
529  if( aFullFileName )
530  file = wxFopen( *aFullFileName, wxT( "wt" ) );
531  else
532  {
533  wxString configName( ConfigBaseName() );
534  if( configName == SCH_EDIT_FRAME_NAME || configName == LIB_EDIT_FRAME_NAME )
535  configName = EESCHEMA_HOTKEY_NAME;
536  else if( configName == PCB_EDIT_FRAME_NAME ||
537  configName == FOOTPRINT_EDIT_FRAME_NAME )
538  configName = PCBNEW_HOTKEY_NAME;
539 
540  wxFileName fn( configName );
541  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
542  fn.SetPath( GetKicadConfigPath() );
543  file = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
544  }
545 
546  if( file )
547  {
548  wxFputs( msg, file );
549  fclose( file );
550  }
551  else
552  {
553  msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
554  return 0;
555  }
556 
557  return 1;
558 }
#define LIB_EDIT_FRAME_NAME
Definition: draw_frame.h:49
EDA_HOTKEY ** m_HK_InfoList
Definition: hotkeys_basic.h:98
wxString ConfigBaseName()
Function ConfigBaseName.
#define PCB_EDIT_FRAME_NAME
Definition: draw_frame.h:56
#define SCH_EDIT_FRAME_NAME
Definition: draw_frame.h:50
#define FOOTPRINT_EDIT_FRAME_NAME
Definition: draw_frame.h:53
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
wxString GetKicadConfigPath()
Return the user configuration path used to store KiCad&#39;s configuration files.
Definition: common.cpp:263
wxString * m_SectionTag
Definition: hotkeys_basic.h:97
wxString m_InfoMsg
Definition: hotkeys_basic.h:66
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:92
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
wxString * m_Title
Definition: hotkeys_basic.h:99
#define EESCHEMA_HOTKEY_NAME
Definition: hotkeys_basic.h:35
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Function KeyNameFromKeyCode return the key name from the key code Only some wxWidgets key values are ...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
#define PCBNEW_HOTKEY_NAME
Definition: hotkeys_basic.h:36

Member Data Documentation

wxString EDA_BASE_FRAME::m_AboutTitle
protectedinherited

Name of program displayed in About.

Definition at line 139 of file eda_base_frame.h.

bool KICAD_MANAGER_FRAME::m_active_project
private
bool EDA_BASE_FRAME::m_autoSaveState
protectedinherited
wxTimer* EDA_BASE_FRAME::m_autoSaveTimer
protectedinherited
wxString EDA_BASE_FRAME::m_configFrameName
protectedinherited

prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTOR is used

Definition at line 134 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::ConfigBaseName(), and FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME().

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

Definition at line 144 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME(), EDA_BASE_FRAME::LoadSettings(), EDA_BASE_FRAME::ProcessEvent(), and EDA_BASE_FRAME::SaveSettings().

FRAME_T EDA_BASE_FRAME::m_Ident
protectedinherited

Id Type (pcb, schematic, library..)

Definition at line 130 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME(), and EDA_BASE_FRAME::findQuasiModalDialog().

LAUNCHER_PANEL* KICAD_MANAGER_FRAME::m_Launcher
private

Definition at line 295 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME().

TREE_PROJECT_FRAME* KICAD_MANAGER_FRAME::m_LeftWin
private
int KICAD_MANAGER_FRAME::m_leftWinWidth
private

Definition at line 299 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), and LoadSettings().

wxAuiToolBar* EDA_BASE_FRAME::m_mainToolBar
protectedinherited
EDA_HOTKEY_CONFIG* KICAD_MANAGER_FRAME::m_manager_Hokeys_Descr
private

Definition at line 300 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), OnPreferences(), OnShowHotkeys(), and ReCreateMenuBar().

wxTextCtrl* KICAD_MANAGER_FRAME::m_MessagesBox
private

Definition at line 296 of file kicad.h.

Referenced by ClearMsg(), KICAD_MANAGER_FRAME(), and PrintMsg().

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 155 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::LoadSettings().

wxAuiToolBar* KICAD_MANAGER_FRAME::m_VToolBar
private

Definition at line 297 of file kicad.h.


The documentation for this class was generated from the following files: