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

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 OnChangeIconsOptions (wxCommandEvent &event) override
 Select the current icons options in menus (or toolbars) in Kicad (the default for toolbars/menus is 26x26 pixels, and shows icons in menus). More...
 
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 OnOpenTextEditor (wxCommandEvent &event)
 
void OnOpenFileInTextEditor (wxCommandEvent &event)
 
void OnOpenFileInEditor (wxCommandEvent &event)
 
void OnFileHistory (wxCommandEvent &event)
 
void OnExit (wxCommandEvent &event)
 
void Process_Preferences (wxCommandEvent &event)
 
void Process_Config (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 OnSelectDefaultPdfBrowser (wxCommandEvent &event)
 
void OnSelectPreferredPdfBrowser (wxCommandEvent &event)
 
void OnUpdateDefaultPdfBrowser (wxUpdateUIEvent &event)
 
void OnUpdatePreferredPdfBrowser (wxUpdateUIEvent &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 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)
 
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 void OnSelectPreferredEditor (wxCommandEvent &event)
 Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit or display files (reports ... 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...
 
virtual void ShowChangedIcons ()
 Function ShowChangedIcons redraws items menus after a icon was changed option. More...
 
void AddMenuIconsOptions (wxMenu *MasterMenu)
 Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice, and add it as submenu to MasterMenu. More...
 
bool PostCommandMenuEvent (int evt_type)
 Function PostCommandMenuEvent. More...
 
virtual int GetIconScale ()
 Function GetIconScale. More...
 
virtual void SetIconScale (int aScale)
 Function SetIconScale. 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 137 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 50 of file mainframe.cpp.

References config(), GetBuildVersion(), LAUNCHER_PANEL::GetPanelHeight(), LAUNCHER_PANEL::GetPanelWidth(), EDA_PANEINFO::HorizontalToolbarPane(), EDA_PANEINFO::InfoToolbarPane(), 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.

51  :
52  EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
54 {
55  m_active_project = false;
56  m_leftWinWidth = 60;
58 
59  // Create the status line (bottom of the frame)
60  static const int dims[3] = { -1, -1, 100 };
61 
62  CreateStatusBar( 3 );
63  SetStatusWidths( 3, dims );
64 
65  // Give an icon
66  wxIcon icon;
67  icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) );
68  SetIcon( icon );
69 
70  // Give the last size and pos to main window
71  LoadSettings( config() );
72  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
73 
74  // Left window: is the box which display tree project
75  m_LeftWin = new TREE_PROJECT_FRAME( this );
76 
77  // Right top Window: buttons to launch applications
78  m_Launcher = new LAUNCHER_PANEL( this );
79 
80  // Add the wxTextCtrl showing all messages from KiCad:
81  m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
82  wxDefaultPosition, wxDefaultSize,
83  wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY );
84 
87 
88  m_auimgr.SetManagedWindow( this );
89 
90  EDA_PANEINFO horiztb;
91  horiztb.HorizontalToolbarPane();
92 
93  EDA_PANEINFO info;
94  info.InfoToolbarPane();
95 
96  m_auimgr.AddPane( m_mainToolBar,
97  wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() );
98 
99  m_auimgr.AddPane( m_LeftWin,
100  wxAuiPaneInfo(info).Name( wxT( "m_LeftWin" ) ).Left().
101  BestSize( m_leftWinWidth, -1 ).
102  Layer( 1 ) );
103 
104  m_auimgr.AddPane( m_Launcher, wxTOP );
105  m_auimgr.GetPane( m_Launcher).CaptionVisible( false ).PaneBorder(false)
106  .MinSize( wxSize( m_Launcher->GetPanelWidth(), m_Launcher->GetPanelHeight() ) )
107  .Resizable( false );
108 
109  m_auimgr.AddPane( m_MessagesBox,
110  wxAuiPaneInfo().Name( wxT( "m_MessagesBox" ) ).CentrePane().Layer( 2 ) );
111 
112  m_auimgr.GetPane( m_LeftWin ).MinSize( wxSize( 150, -1) );
113  m_auimgr.GetPane( m_LeftWin ).BestSize(wxSize(m_leftWinWidth, -1) );
114 
115  m_auimgr.Update();
116 
117  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
118 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
class LAUNCHER_PANEL
Definition: kicad.h:320
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: mainframe.cpp:535
wxAuiManager m_auimgr
int GetPanelHeight() const
Specialization of the wxAuiPaneInfo class for KiCad panels.
LAUNCHER_PANEL * m_Launcher
Definition: kicad.h:305
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
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:310
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void ReCreateMenuBar() override
(Re)Create the menubar
int GetPanelWidth() const
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
wxConfigBase * config() override
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: mainframe.cpp:127
bool m_active_project
Definition: kicad.h:314
#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 121 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

122 {
123  m_auimgr.UnInit();
124 }
wxAuiManager m_auimgr

Member Function Documentation

void EDA_BASE_FRAME::AddMenuIconsOptions ( wxMenu *  MasterMenu)
inherited

Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice, and add it as submenu to MasterMenu.

Parameters
MasterMenuThe main menu. The sub menu list will be accessible from the menu item with id ID_KICAD_SELECT_ICONS_OPTIONS

Definition at line 686 of file eda_base_frame.cpp.

References AddMenuItem(), ID_KICAD_SELECT_ICONS_IN_MENUS, ID_KICAD_SELECT_ICONS_OPTIONS, KiBitmap(), and Pgm().

Referenced by EDA_BASE_FRAME::GetMruPath(), preparePreferencesMenu(), PL_EDITOR_FRAME::ReCreateMenuBar(), ReCreateMenuBar(), and GERBVIEW_FRAME::ReCreateMenuBar().

687 {
688  wxMenu* menu = NULL;
689  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
690 
691  if( item ) // This menu exists, do nothing
692  return;
693 
694  menu = new wxMenu;
695 
696  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
697  _( "Icons in Menus" ), wxEmptyString,
698  wxITEM_CHECK ) );
699  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
700 
701  AddMenuItem( MasterMenu, menu,
703  _( "Icons Options" ),
704  _( "Select show icons in menus and icons sizes" ),
705  KiBitmap( icon_xpm ) );
706 }
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:174
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
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 591 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().

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

References m_MessagesBox.

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

530 {
531  m_MessagesBox->Clear();
532 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
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 127 of file mainframe.cpp.

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

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

128 {
129  wxConfigBase* ret = PgmTop().PgmSettings();
130  wxASSERT( ret );
131  return ret;
132 }
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 260 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_configFrameName.

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

261  {
262  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
263  return baseCfgName;
264  }
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(), 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
PROJECT & Prj()
Definition: kicad.cpp:287
const wxString LegacyPcbFileExtension
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
#define GeneralGroupName
Definition: prjconfig.cpp:56
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:135
const wxString KiCadPcbFileExtension
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:71
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:189
const wxString SchematicFileExtension
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 244 of file eda_base_frame.cpp.

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

245 {
246  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
247 }
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 272 of file mainframe.cpp.

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

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

274 {
275  if( params.size() )
276  AddDelimiterString( params );
277 
278  TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
279 
280  long pid = ExecuteFile( frame, execFile, params, callback );
281 
282  if( pid > 0 )
283  {
284  wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
285  GetChars( execFile ), GetChars( params ), pid );
286 
287  PrintMsg( msg );
288  }
289  else
290  {
291  delete callback;
292  }
293 }
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:201
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 777 of file hotkeys_basic.cpp.

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

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

779 {
780  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
781  wxString mask = wxT( "*." ) + ext;
782 
783 #if 0
784  wxString path = wxPathOnly( Prj().GetProjectFullName() );
785 #else
786  wxString path = GetMruPath();
787 #endif
788  wxFileName fn( aDefaultShortname );
789  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
790 
791  wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ),
792  path,
793  fn.GetFullPath(),
794  ext,
795  mask,
796  this,
797  wxFD_SAVE,
798  true );
799 
800  if( filename.IsEmpty() )
801  return;
802 
803  WriteHotkeyConfig( aDescList, &filename );
804  SetMruPath( wxFileName( filename ).GetPath() );
805 }
void SetMruPath(const wxString &aPath)
PROJECT & Prj()
Definition: kicad.cpp:287
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 219 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

Referenced by DIALOG_GENERALOPTIONS::init(), and SCH_EDIT_FRAME::OnPreferencesOptions().

219 { 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 413 of file eda_base_frame.cpp.

References Format(), GetChars(), 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().

415 {
416  wxFileHistory* fileHistory = aFileHistory;
417 
418  if( !fileHistory )
419  fileHistory = &Kiface().GetFileHistory();
420 
421  int baseId = fileHistory->GetBaseId();
422 
423  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
424 
425  unsigned i = cmdId - baseId;
426 
427  if( i < fileHistory->GetCount() )
428  {
429  wxString fn = fileHistory->GetHistoryFile( i );
430 
431  if( wxFileName::FileExists( fn ) )
432  return fn;
433  else
434  {
435  wxString msg = wxString::Format(
436  _( "File \"%s\" was not found." ),
437  GetChars( fn ) );
438 
439  wxMessageBox( msg );
440 
441  fileHistory->RemoveFileFromHistory( i );
442  }
443  }
444 
445  return wxEmptyString;
446 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:123
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
size_t i
Definition: json11.cpp:597
virtual int EDA_BASE_FRAME::GetIconScale ( )
inlinevirtualinherited

Function GetIconScale.

Return the desired scaling for toolbar/menubar icons in fourths (e.g. 4 is unity). A negative number indicates autoscale based on font size.

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

Definition at line 437 of file eda_base_frame.h.

Referenced by get_scale_factor().

437 { return -1; }
void EDA_BASE_FRAME::GetKicadAbout ( wxCommandEvent &  event)
inherited

Definition at line 540 of file eda_base_frame.cpp.

References ShowAboutDialog().

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

541 {
542  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
543  ShowAboutDialog( this );
544 }
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 527 of file eda_base_frame.cpp.

References URL_GET_INVOLVED.

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

528 {
529  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
530  {
531  wxString msg;
532  msg.Printf( _( "Could not launch the default browser.\n"
533  "For information on how to help the KiCad project, visit %s" ),
535  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
536  }
537 }
#define URL_GET_INVOLVED
void EDA_BASE_FRAME::GetKicadHelp ( wxCommandEvent &  event)
inherited

Definition at line 449 of file eda_base_frame.cpp.

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

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

450 {
451  const SEARCH_STACK& search = sys_search();
452 
453  /* We have to get document for beginners,
454  * or the full specific doc
455  * if event id is wxID_INDEX, we want the document for beginners.
456  * else the specific doc file (its name is in Kiface().GetHelpFileName())
457  * The document for beginners is the same for all KiCad utilities
458  */
459  if( event.GetId() == wxID_INDEX )
460  {
461  // List of possible names for Getting Started in KiCad
462  const wxChar* names[2] = {
463  wxT( "getting_started_in_kicad" ),
464  wxT( "Getting_Started_in_KiCad" )
465  };
466 
467  wxString helpFile;
468  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
469  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
470  for( unsigned ii = 0; ii < DIM( names ); ii++ )
471  {
472  helpFile = SearchHelpFileFullPath( search, names[ii] );
473 
474  if( !helpFile.IsEmpty() )
475  break;
476  }
477 
478  if( !helpFile )
479  {
480  wxString msg = wxString::Format( _(
481  "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
482  wxMessageBox( msg );
483  }
484  else
485  {
486  GetAssociatedDocument( this, helpFile );
487  }
488 
489  return;
490  }
491 
492  wxString base_name = help_name();
493  wxString helpFile = SearchHelpFileFullPath( search, base_name );
494 
495  if( !helpFile )
496  {
497  wxString msg = wxString::Format( _(
498  "Help file \"%s\" could not be found." ),
499  GetChars( base_name )
500  );
501  wxMessageBox( msg );
502  }
503  else
504  {
505  GetAssociatedDocument( this, helpFile );
506  }
507 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
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...
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSStack, const wxString &aBaseName)
Return the help file&#39;s full path.
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()
wxString KICAD_MANAGER_FRAME::help_name ( )
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 195 of file mainframe.cpp.

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

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

196 {
197  return PgmTop().GetHelpFileName();
198 }
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 748 of file hotkeys_basic.cpp.

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

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

750 {
751  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
752  wxString mask = wxT( "*." ) + ext;
753 
754 
755  wxString path = GetMruPath();
756  wxFileName fn( aDefaultShortname );
757  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
758 
759  wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ),
760  path,
761  fn.GetFullPath(),
762  ext,
763  mask,
764  this,
765  wxFD_OPEN,
766  true );
767 
768  if( filename.IsEmpty() )
769  return;
770 
771  ::ReadHotkeyConfigFile( filename, aDescList, false );
772  WriteHotkeyConfig( aDescList );
773  SetMruPath( wxFileName( filename ).GetPath() );
774 }
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 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 175 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().

175 { return false; }
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 547 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().

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

Definition at line 522 of file mainframe.cpp.

References Kiway, and KIWAY::SetLanguage().

523 {
524  int id = event.GetId();
525  Kiway.SetLanguage( id );
526 }
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs...
Definition: kiway.cpp:395
KIWAY Kiway
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, m_active_project, m_LeftWin, PgmTop(), KIWAY::PlayersClose(), PrintPrjInfo(), Prj(), TREE_PROJECT_FRAME::ReCreateTreePrj(), EDA_BASE_FRAME::SetMruPath(), SetProjectFileName(), and EDA_BASE_FRAME::UpdateFileHistory().

Referenced by PGM_KICAD::MacOpenFile(), OnCreateProjectFromTemplate(), OnFileHistory(), OnLoadProject(), OnNewProject(), and PGM_KICAD::OnPgmInit().

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
void SetMruPath(const wxString &aPath)
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:287
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
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:135
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
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:314
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:529
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.
Definition: mainframe.cpp:549
KIWAY Kiway
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 535 of file mainframe.cpp.

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

Referenced by KICAD_MANAGER_FRAME().

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

238 {
239  if( !doAutoSave() )
240  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
241 }
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::OnChangeIconsOptions ( wxCommandEvent &  event)
overridevirtual

Select the current icons options in menus (or toolbars) in Kicad (the default for toolbars/menus is 26x26 pixels, and shows icons in menus).

Reimplemented from EDA_BASE_FRAME.

Definition at line 451 of file mainframe.cpp.

References Kiway, EDA_BASE_FRAME::OnChangeIconsOptions(), and KIWAY::ShowChangedIcons().

452 {
455 }
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
VTBL_ENTRY void ShowChangedIcons()
Function ShowChangedIcons Calls ShowChangedIcons() on all KIWAY_PLAYERs.
Definition: kiway.cpp:431
KIWAY Kiway
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 1090 of file tree_project_frame.cpp.

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

1091 {
1093 }
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:304
void KICAD_MANAGER_FRAME::OnCloseWindow ( wxCloseEvent &  Event)

Definition at line 216 of file mainframe.cpp.

References PGM_KICAD::GetFileHistory(), GetProjectFileName(), Kiway, EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, m_LeftWin, PgmTop(), KIWAY::PlayersClose(), EDA_BASE_FRAME::UpdateFileHistory(), wxPoint::x, and wxPoint::y.

217 {
218  if( Kiway.PlayersClose( false ) )
219  {
220  int px, py;
221 
222  if( !GetProjectFileName().empty() )
224 
225  if( !IsIconized() ) // save main frame position and size
226  {
227  GetPosition( &px, &py );
228  m_FramePos.x = px;
229  m_FramePos.y = py;
230 
231  GetSize( &px, &py );
232  m_FrameSize.x = px;
233  m_FrameSize.y = py;
234  }
235 
236  Event.SetCanVeto( true );
237 
238  m_LeftWin->Show( false );
239 
240  Destroy();
241  }
242 }
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
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:147
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnConfigurePaths ( wxCommandEvent &  aEvent)

Definition at line 589 of file mainframe.cpp.

References PGM_BASE::ConfigurePaths(), and Pgm().

590 {
591  Pgm().ConfigurePaths( this );
592 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY void ConfigurePaths(wxWindow *aParent=NULL)
Function ConfigurePaths.
Definition: pgm_base.cpp:970
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(), PROJECT_TEMPLATE::GetDestinationFiles(), PGM_BASE::GetLocalEnvVariables(), DIALOG_TEMPLATE_SELECTOR::GetSelectedTemplate(), LoadProject(), Pgm(), Prj(), and SEP.

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  {
363  extendedMsg += "\n" + file.GetFullName();
364  }
365 
366  wxMessageDialog owDlg( this,
367  _( "Are you sure you want to overwrite files in "
368  "the destination folder?" ),
369  _( "Warning!" ),
370  wxYES_NO | wxICON_QUESTION | wxCENTER );
371  owDlg.SetExtendedMessage( extendedMsg );
372  owDlg.SetYesNoLabels( _( "Overwrite" ), _( "Do Not Overwrite" ) );
373 
374  if( owDlg.ShowModal() == wxID_NO )
375  return;
376  }
377  }
378 
379  wxString errorMsg;
380 
381  // The selected template widget contains the template we're attempting to use to
382  // create a project
383  if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
384  {
385  wxMessageDialog createDlg( this,
386  _( "A problem occurred creating new project from template!" ),
387  _( "Template Error" ),
388  wxOK | wxICON_ERROR );
389 
390  if( !errorMsg.empty() )
391  createDlg.SetExtendedMessage( errorMsg );
392 
393  createDlg.ShowModal();
394  return;
395  }
396 
397  CreateNewProject( fn.GetFullPath() );
398  LoadProject( fn );
399 }
PROJECT_TEMPLATE * GetSelectedTemplate()
PROJECT & Prj()
Definition: kicad.cpp:287
#define SEP()
Definition: prjconfig.cpp:50
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY const ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.h:270
std::map< wxString, ENV_VAR_ITEM >::const_iterator ENV_VAR_MAP_CITER
Definition: pgm_base.h:89
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:529
void KICAD_MANAGER_FRAME::OnExit ( wxCommandEvent &  event)

Definition at line 245 of file mainframe.cpp.

246 {
247  Close( true );
248 }
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 }
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
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
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(), IO_MGR::EAGLE, EagleFilesWildcard(), err, KIWAY::ExpressMail(), Format(), FRAME_PCB, FRAME_SCH, EDA_BASE_FRAME::GetMruPath(), GetProjectFileName(), IsOK(), KIWAY_HOLDER::Kiway(), Kiway, LegacyPcbFileExtension, m_active_project, MAIL_IMPORT_FILE, KIWAY::Player(), KIWAY::PlayersClose(), ProjectFileExtension, ReCreateTreePrj(), SchematicFileExtension, SetProjectFileName(), 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  if( IsOK( this, msg ) )
102  {
103  // Append a new directory with the same name of the project file
104  // and try to create it
105  pro.AppendDir( pro.GetName() );
106 
107  if( !wxMkdir( pro.GetPath() ) )
108  // There was a problem, undo
109  pro.RemoveLastDir();
110  }
111  }
112 
113  wxFileName pcb( sch );
114  pro.SetExt( ProjectFileExtension ); // enforce extension
115  pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
116 
117  if( !pro.IsAbsolute() )
118  pro.MakeAbsolute();
119 
120  SetProjectFileName( pro.GetFullPath() );
121  wxString prj_filename = GetProjectFileName();
122 
123  if( sch.FileExists() )
124  {
125  KIWAY_PLAYER* schframe = Kiway.Player( FRAME_SCH, false );
126 
127  if( !schframe )
128  {
129  try // SCH frame was not available, try to start it
130  {
131  schframe = Kiway.Player( FRAME_SCH, true );
132  }
133  catch( const IO_ERROR& err )
134  {
135  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
136  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
137  return;
138  }
139  }
140 
142  wxString::Format( "%d\n%s", SCH_IO_MGR::SCH_EAGLE,
143  sch.GetFullPath() ).ToStdString(), this );
144 
145  if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor)
146  // but no project loaded.
147  {
148  schframe->Show( true );
149  }
150 
151  if( schframe->IsIconized() )
152  schframe->Iconize( false );
153 
154  schframe->Raise();
155  }
156 
157 
158  if( pcb.FileExists() )
159  {
160  KIWAY_PLAYER* pcbframe = Kiway.Player( FRAME_PCB, false );
161 
162  if( !pcbframe )
163  {
164  try // PCB frame was not available, try to start it
165  {
166  pcbframe = Kiway.Player( FRAME_PCB, true );
167  }
168  catch( const IO_ERROR& err )
169  {
170  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
171  wxOK | wxICON_ERROR, this );
172  return;
173  }
174  }
175 
176  // a pcb frame can be already existing, but not yet used.
177  // this is the case when running the footprint editor, or the footprint viewer first
178  // if the frame is not visible, the board is not yet loaded
179  if( !pcbframe->IsVisible() )
180  {
181  pcbframe->Show( true );
182  }
183 
185  wxString::Format( "%d\n%s", IO_MGR::EAGLE, pcb.GetFullPath() ).ToStdString(), this );
186 
187  // On Windows, Raise() does not bring the window on screen, when iconized
188  if( pcbframe->IsIconized() )
189  pcbframe->Iconize( false );
190 
191  pcbframe->Raise();
192  }
193 
194  ReCreateTreePrj();
195  m_active_project = true;
196 }
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
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h: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
const wxString ProjectFileExtension
const wxString 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
string & err
Definition: json11.cpp:598
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:135
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:314
wxString GetMruPath() const
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:529
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
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:233
const wxString SchematicFileExtension
KIWAY Kiway
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 wxString 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:199
const wxString 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:233
void KICAD_MANAGER_FRAME::OnOpenFileInEditor ( wxCommandEvent &  event)
void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ( wxCommandEvent &  event)

Definition at line 495 of file mainframe.cpp.

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

496 {
497  // show all files in file dialog (in Kicad all files are editable texts):
498  wxString wildcard = AllFilesWildcard;
499 
500  wxString default_dir = Prj().GetProjectPath();
501 
502  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
503  wxEmptyString, wildcard, wxFD_OPEN );
504 
505  if( dlg.ShowModal() == wxID_CANCEL )
506  return;
507 
508  wxString filename = wxT( "\"" );
509  filename += dlg.GetPath() + wxT( "\"" );
510 
511  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
512  Execute( this, Pgm().GetEditorName(), filename );
513 }
PROJECT & Prj()
Definition: kicad.cpp:287
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:272
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:338
const wxString AllFilesWildcard
void KICAD_MANAGER_FRAME::OnOpenTextEditor ( wxCommandEvent &  event)

Definition at line 486 of file mainframe.cpp.

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

487 {
488  wxString editorname = Pgm().GetEditorName();
489 
490  if( !editorname.IsEmpty() )
491  Execute( this, editorname, wxEmptyString );
492 }
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:272
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:338
void KICAD_MANAGER_FRAME::OnRefresh ( wxCommandEvent &  event)

Definition at line 516 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

Referenced by OnUnarchiveFiles().

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

Definition at line 458 of file mainframe.cpp.

References BITMAPCONVERTER_EXE, and Execute().

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

Definition at line 343 of file mainframe.cpp.

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

344 {
345  wxFileName fn( GetProjectFileName() );
346  fn.SetExt( SchematicFileExtension );
347  RunEeschema( fn.GetFullPath() );
348 }
void RunEeschema(const wxString &aProjectSchematicFileName)
Call this only for a SCH associated with the current project.
Definition: mainframe.cpp:296
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
const wxString SchematicFileExtension
void KICAD_MANAGER_FRAME::OnRunGerbview ( wxCommandEvent &  event)

Definition at line 477 of file mainframe.cpp.

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

478 {
479  // Gerbview is called without any file to open, because we do not know
480  // the list and the name of files to open (if any...).
481  // however we run it in the path of the project
482  Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() );
483 }
PROJECT & Prj()
Definition: kicad.cpp:287
const wxString GERBVIEW_EXE
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:272
void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor ( wxCommandEvent &  event)

Definition at line 470 of file mainframe.cpp.

References Execute(), and PL_EDITOR_EXE.

471 {
472  Execute( this, PL_EDITOR_EXE );
473 }
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:272
void KICAD_MANAGER_FRAME::OnRunPcbCalculator ( wxCommandEvent &  event)

Definition at line 464 of file mainframe.cpp.

References Execute(), and PCB_CALCULATOR_EXE.

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

Definition at line 423 of file mainframe.cpp.

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

424 {
426 
427  if( !frame )
428  {
429  try
430  {
431  frame = Kiway.Player( FRAME_PCB_MODULE_EDITOR, true );
432  }
433  catch( const IO_ERROR& err )
434  {
435  wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
436  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
437  return;
438  }
439 
440  frame->Show( true );
441  }
442 
443  // On Windows, Raise() does not bring the window on screen, when iconized
444  if( frame->IsIconized() )
445  frame->Iconize( false );
446 
447  frame->Raise();
448 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
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
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnRunPcbNew ( wxCommandEvent &  event)

Definition at line 411 of file mainframe.cpp.

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

412 {
413  wxFileName kicad_board( PcbFileName() );
414  wxFileName legacy_board( PcbLegacyFileName() );
415 
416  wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
417  kicad_board : legacy_board;
418 
419  RunPcbNew( board.GetFullPath() );
420 }
const wxString PcbLegacyFileName()
Definition: mainframe.cpp:173
const wxString PcbFileName()
Definition: mainframe.cpp:163
void RunPcbNew(const wxString &aProjectBoardFileName)
Call this only for a PCB associated with the current project.
Definition: mainframe.cpp:379
void KICAD_MANAGER_FRAME::OnRunSchLibEditor ( wxCommandEvent &  event)

Definition at line 351 of file mainframe.cpp.

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

352 {
353  KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, false );
354 
355  if( !frame )
356  {
357  try
358  {
359  frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, true );
360  }
361  catch( const IO_ERROR& err )
362  {
363  wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
364  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
365  return;
366  }
367 
368  frame->Show( true );
369  }
370 
371  // On Windows, Raise() does not bring the window on screen, when iconized
372  if( frame->IsIconized() )
373  frame->Iconize( false );
374 
375  frame->Raise();
376 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
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
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnSaveProject ( wxCommandEvent &  event)

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

Definition at line 402 of file prjconfig.cpp.

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

403 {
404  if( !wxIsWritable( GetProjectFileName() ) )
405  return;
406 
408 }
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()
Definition: kicad.cpp:287
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
#define GeneralGroupName
Definition: prjconfig.cpp:56
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
void KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser ( wxCommandEvent &  event)

Definition at line 43 of file preferences.cpp.

References PGM_BASE::ForceSystemPdfBrowser(), Pgm(), and PGM_BASE::WritePdfBrowserInfos().

44 {
45  Pgm().ForceSystemPdfBrowser( true );
47 }
VTBL_ENTRY void ForceSystemPdfBrowser(bool aFlg)
Function ForceSystemPdfBrowser forces the use of system PDF browser, even if a preferred PDF browser ...
Definition: pgm_base.h:196
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY void WritePdfBrowserInfos()
Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.
Definition: eda_doc.cpp:55
void EDA_BASE_FRAME::OnSelectPreferredEditor ( wxCommandEvent &  event)
virtualinherited

Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit or display files (reports ...

) The full filename editor is saved in configuration (global params)

Definition at line 510 of file eda_base_frame.cpp.

References PGM_BASE::AskUserForPreferredEditor(), PGM_BASE::GetEditorName(), Pgm(), and PGM_BASE::SetEditorName().

Referenced by EDA_BASE_FRAME::SaveProjectSettings().

511 {
512  // Ask for the current editor and instruct GetEditorName() to not show
513  // unless we pass false as argument.
514  wxString editorname = Pgm().GetEditorName( false );
515 
516  // Ask the user to select a new editor, but suggest the current one as the default.
517  editorname = Pgm().AskUserForPreferredEditor( editorname );
518 
519  // If we have a new editor name request it to be copied to m_editor_name and saved
520  // to the preferences file. If the user cancelled the dialog then the previous
521  // value will be retained.
522  if( !editorname.IsEmpty() )
523  Pgm().SetEditorName( editorname );
524 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:330
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Shows a dialog that instructs the user to select a new preferred editor.
Definition: pgm_base.cpp:375
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:338
void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser ( wxCommandEvent &  event)

Definition at line 56 of file preferences.cpp.

References DisplayError(), PGM_BASE::ForceSystemPdfBrowser(), PGM_BASE::GetPdfBrowserName(), ID_SELECT_PREFERED_PDF_BROWSER_NAME, Pgm(), PGM_BASE::ReadPdfBrowserInfos(), PGM_BASE::SetPdfBrowserName(), and PGM_BASE::WritePdfBrowserInfos().

57 {
58  bool setPdfBrowserName = event.GetId() == ID_SELECT_PREFERED_PDF_BROWSER_NAME;
59 
60  if( !Pgm().GetPdfBrowserName() && !setPdfBrowserName )
61  {
62  DisplayError( this,
63  _( "You must choose a PDF viewer before using this option." ) );
64  setPdfBrowserName = true;
65  }
66 
67  if( setPdfBrowserName )
68  {
69  wxString mask( wxT( "*" ) );
70 
71  #ifdef __WINDOWS__
72  mask += wxT( ".exe" );
73  #endif
74 
75  wxString wildcard = _( "Executable files (" ) + mask + wxT( ")|" ) + mask;
76 
78  wxFileName fn = Pgm().GetPdfBrowserName();
79 
80  wxFileDialog dlg( this, _( "Select Preferred PDF Browser" ), fn.GetPath(),
81  fn.GetFullPath(), wildcard,
82  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
83 
84  if( dlg.ShowModal() == wxID_CANCEL )
85  return;
86 
87  Pgm().SetPdfBrowserName( dlg.GetPath() );
88  }
89 
90  Pgm().ForceSystemPdfBrowser( false );
92 }
VTBL_ENTRY void ForceSystemPdfBrowser(bool aFlg)
Function ForceSystemPdfBrowser forces the use of system PDF browser, even if a preferred PDF browser ...
Definition: pgm_base.h:196
VTBL_ENTRY const wxString & GetPdfBrowserName() const
Definition: pgm_base.h:177
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY void WritePdfBrowserInfos()
Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.
Definition: eda_doc.cpp:55
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
Definition: pgm_base.h:179
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:42
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
void KICAD_MANAGER_FRAME::OnSize ( wxSizeEvent &  event)

Definition at line 207 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

208 {
209  if( m_auimgr.GetManagedWindow() )
210  m_auimgr.Update();
211 
212  event.Skip();
213 }
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(), 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:516
PROJECT & Prj()
Definition: kicad.cpp:287
wxString ZipFileWildcard()
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:201
#define ZipFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
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:185
void KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser ( wxUpdateUIEvent &  event)

Definition at line 37 of file preferences.cpp.

References Pgm().

38 {
39  event.Check( Pgm().UseSystemPdfBrowser() );
40 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser ( wxUpdateUIEvent &  event)

Definition at line 50 of file preferences.cpp.

References Pgm().

51 {
52  event.Check( !Pgm().UseSystemPdfBrowser() );
53 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void KICAD_MANAGER_FRAME::OnUpdateRequiresProject ( wxUpdateUIEvent &  event)

Definition at line 411 of file prjconfig.cpp.

References m_active_project.

412 {
413  event.Enable( m_active_project );
414 }
bool m_active_project
Definition: kicad.h:314
const wxString KICAD_MANAGER_FRAME::PcbFileName ( )

Definition at line 163 of file mainframe.cpp.

References GetProjectFileName(), and PcbFileExtension.

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

164 {
165  wxFileName fn( GetProjectFileName() );
166 
167  fn.SetExt( PcbFileExtension );
168 
169  return fn.GetFullPath();
170 }
#define PcbFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName ( )

Definition at line 173 of file mainframe.cpp.

References GetProjectFileName(), and LegacyPcbFileExtension.

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

174 {
175  wxFileName fn( GetProjectFileName() );
176 
177  fn.SetExt( LegacyPcbFileExtension );
178 
179  return fn.GetFullPath();
180 }
const wxString LegacyPcbFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
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 660 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().

661 {
662  if( evt_type != 0 )
663  {
664  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
665  evt.SetEventObject( this );
666  evt.SetId( evt_type );
667  wxPostEvent( this, evt );
668  return true;
669  }
670 
671  return false;
672 }
void KICAD_MANAGER_FRAME::PrintMsg ( const wxString &  aText)

Displays aText in the text panel.

Parameters
aTextThe text to display.

Definition at line 201 of file mainframe.cpp.

References m_MessagesBox.

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

202 {
203  m_MessagesBox->AppendText( aText );
204 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
void KICAD_MANAGER_FRAME::PrintPrjInfo ( )

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

Definition at line 549 of file mainframe.cpp.

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

Referenced by LoadProject().

550 {
551  wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
553  PrintMsg( msg );
554 }
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:201
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
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::Process_Config ( wxCommandEvent &  event)

Definition at line 557 of file mainframe.cpp.

References DisplayHotkeyList(), EDA_BASE_FRAME::ExportHotkeyConfigToFile(), ID_PREFERENCES_HOTKEY_EXPORT_CONFIG, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, ID_PREFERENCES_HOTKEY_SHOW_EDITOR, EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), InstallHotkeyFrame(), and m_manager_Hokeys_Descr.

558 {
559  int id = event.GetId();
560  wxFileName fn;
561 
562  switch( id )
563  {
564  // Hotkey IDs
567  break;
568 
571  break;
572 
575  break;
576 
578  // Display current hotkey list for LibEdit.
580  break;
581 
582  default:
583  wxFAIL_MSG( wxT( "KICAD_MANAGER_FRAME::Process_Config error" ) );
584  break;
585  }
586 }
void ExportHotkeyConfigToFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it...
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:310
void InstallHotkeyFrame(EDA_BASE_FRAME *aParent, EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys)
Function InstallHotkeyFrame Create a hotkey editor dialog window with the provided hotkey configurati...
void ImportHotkeyConfigFromFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.
void KICAD_MANAGER_FRAME::Process_Preferences ( wxCommandEvent &  event)
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 179 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(), GERBVIEW_CONTROL::SwitchUnits(), and PCBNEW_CONTROL::SwitchUnits().

180 {
181 #ifdef __WXMAC__
182  // Apple in its infinite wisdom will raise a disabled window before even passing
183  // us the event, so we have no way to stop it. Instead, we have to catch an
184  // improperly ordered disabled window and quasi-modal dialog here and reorder
185  // them.
186  if( !IsEnabled() && IsActive() )
187  {
188  wxWindow* dlg = findQuasiModalDialog();
189  if( dlg )
190  dlg->Raise();
191  }
192 #endif
193 
194  if( !wxFrame::ProcessEvent( aEvent ) )
195  return false;
196 
197  if( IsShown() && m_hasAutoSave && IsActive() &&
199  {
200  if( !m_autoSaveState )
201  {
202  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
203  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
204  m_autoSaveState = true;
205  }
206  else if( m_autoSaveTimer->IsRunning() )
207  {
208  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
209  m_autoSaveTimer->Stop();
210  m_autoSaveState = false;
211  }
212  }
213 
214  return true;
215 }
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 497 of file kicad/menubar.cpp.

References 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().

498 {
499  if( m_mainToolBar )
500  m_mainToolBar->Clear();
501  else
502  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
503  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
504 
505  // New
506  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
507  KiScaledBitmap( new_project_xpm, this ),
508  _( "Create new project" ) );
509 
510  m_mainToolBar->AddTool( ID_NEW_PROJECT_FROM_TEMPLATE, wxEmptyString,
511  KiScaledBitmap( new_project_with_template_xpm, this ),
512  _( "Create new project from template" ) );
513 
514  // Load
515  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString,
516  KiScaledBitmap( open_project_xpm, this ),
517  _( "Open existing project" ) );
518 
519  // Currently there is nothing to save
520  // (Kicad manager does not save any info in .pro file)
521 #if 0
522  // Save
523  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString,
524  KiScaledBitmap( save_project_xpm, this ),
525  _( "Save current project" ) );
526 #endif
527 
529 
530  // Archive
531  m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
532  KiScaledBitmap( zip_xpm, this ),
533  _( "Archive all project files" ) );
534 
535  // Unarchive
536  m_mainToolBar->AddTool( ID_READ_ZIP_ARCHIVE, wxEmptyString,
537  KiScaledBitmap( unzip_xpm, this ),
538  _( "Unarchive project files from zip archive" ) );
539 
541 
542  // Refresh project tree
543  m_mainToolBar->AddTool( ID_PROJECT_TREE_REFRESH, wxEmptyString,
544  KiScaledBitmap( reload_xpm, this ),
545  _( "Refresh project tree" ) );
546 
547  // Create m_mainToolBar
548  m_mainToolBar->Realize();
549 }
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Function KiScaledBitmap Constructs a wxBitmap from a memory record, scaling it if device DPI demands ...
Definition: bitmap.cpp:114
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Function KiScaledSeparator Adds a separator to the given toolbar scaled the same way as KiScaledBitma...
Definition: bitmap.cpp:146
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 194 of file kicad/menubar.cpp.

References AddHotkeyConfigMenu(), AddHotkeyName(), EDA_BASE_FRAME::AddMenuIconsOptions(), 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_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_SELECT_DEFAULT_PDF_BROWSER, ID_SELECT_PREFERED_EDITOR, ID_SELECT_PREFERED_PDF_BROWSER, ID_SELECT_PREFERED_PDF_BROWSER_NAME, 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().

195 {
196  wxString msg;
197  static wxMenu* openRecentMenu; // Open Recent submenu,
198  // static to remember this menu
199 
201 
202  // wxWidgets handles the Mac Application menu behind the scenes, but that means
203  // we always have to start from scratch with a new wxMenuBar.
204  wxMenuBar* oldMenuBar = GetMenuBar();
205  wxMenuBar* menuBar = new wxMenuBar();
206 
207  // Before deleting, remove the menus managed by m_fileHistory
208  // (the file history will be updated when adding/removing files in history)
209  if( openRecentMenu )
210  PgmTop().GetFileHistory().RemoveMenu( openRecentMenu );
211 
212  // Recreate all menus:
213 
214  // Menu File:
215  wxMenu* fileMenu = new wxMenu;
216 
217  // New project creation
218  wxMenu* newprjSubMenu = new wxMenu();
219  msg = AddHotkeyName( _( "&Project..." ), kicad_Manager_Hokeys_Descr, HK_NEW );
220  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT, msg,
221  _( "Create new blank project" ),
222  KiBitmap( new_project_xpm ) );
223  msg = AddHotkeyName( _( "Project from &Template..." ),
225  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT_FROM_TEMPLATE, msg,
226  _( "Create new project from template" ),
227  KiBitmap( new_project_with_template_xpm ) );
228  AddMenuItem( fileMenu, newprjSubMenu,
229  wxID_ANY,
230  _( "&New" ),
231  _( "Create new project" ),
232  KiBitmap( new_project_xpm ) );
233 
234  // Open
235  msg = AddHotkeyName( _( "&Open Project..." ), kicad_Manager_Hokeys_Descr, HK_OPEN );
236  AddMenuItem( fileMenu, ID_LOAD_PROJECT, msg,
237  _( "Open an existing project" ),
238  KiBitmap( open_project_xpm ) );
239 
240  // File history
241  openRecentMenu = new wxMenu();
242  PgmTop().GetFileHistory().UseMenu( openRecentMenu );
243  PgmTop().GetFileHistory().AddFilesToMenu( );
244  AddMenuItem( fileMenu, openRecentMenu,
245  wxID_ANY,
246  _( "Open &Recent" ),
247  _( "Open a recent project" ),
248  KiBitmap( recent_xpm ) );
249 
250  // Currently there is nothing to save
251  // (Kicad manager does not save any info in .pro file)
252 #if 0
253  // Save
254  msg = AddHotkeyName( _( "&Save" ), kicad_Manager_Hokeys_Descr, HK_SAVE );
255  AddMenuItem( fileMenu, ID_SAVE_PROJECT, msg,
256  _( "Save current project" ),
257  KiBitmap( save_project_xpm ) );
258 #endif
259 
260  fileMenu->AppendSeparator();
261  wxMenu* importprjSubMenu = new wxMenu();
262 
263  AddMenuItem( importprjSubMenu, ID_IMPORT_EAGLE_PROJECT, _( "EAGLE CAD..." ),
264  _( "Import EAGLE CAD XML schematic and board" ),
265  KiBitmap( import_project_xpm ) );
266 
267 
268  AddMenuItem( fileMenu, importprjSubMenu,
269  wxID_ANY,
270  _( "Import Project" ),
271  _( "Import project files from other software" ),
272  KiBitmap( import_project_xpm ) );
273 
274 
275  fileMenu->AppendSeparator();
276 
277  // Archive
278  AddMenuItem( fileMenu,
280  _( "&Archive Project..." ),
281  _( "Archive all needed project files into zip archive" ),
282  KiBitmap( zip_xpm ) );
283 
284  // Unarchive
285  AddMenuItem( fileMenu,
287  _( "&Unarchive Project..." ),
288  _( "Unarchive project files from zip archive" ),
289  KiBitmap( unzip_xpm ) );
290 
291  // Separator
292  fileMenu->AppendSeparator();
293 
294  // Quit
295  AddMenuItem( fileMenu,
296  wxID_EXIT,
297  _( "&Exit" ),
298  _( "Close KiCad" ),
299  KiBitmap( exit_xpm ) );
300 
301  // View Menu:
302  wxMenu* viewMenu = new wxMenu();
303 
304  // Refresh project tree
305  msg = AddHotkeyName( _( "&Refresh" ), kicad_Manager_Hokeys_Descr, HK_REFRESH );
306  AddMenuItem( viewMenu, ID_PROJECT_TREE_REFRESH, msg,
307  _( "Refresh project tree" ),
308  KiBitmap( reload_xpm ) );
309 
310 #ifdef __APPLE__
311  viewMenu->AppendSeparator();
312 #endif
313 
314  // Menu Browse:
315  wxMenu* browseMenu = new wxMenu();
316 
317  // Text editor
318  AddMenuItem( browseMenu,
320  _( "Open Text E&ditor" ),
321  _( "Launch preferred text editor" ),
322  KiBitmap( editor_xpm ) );
323 
324  // View file
325  AddMenuItem( browseMenu,
327  _( "&Open Local File..." ),
328  _( "Edit local file" ),
329  KiBitmap( browse_files_xpm ) );
330 
331  // Menu Preferences:
332  wxMenu* preferencesMenu = new wxMenu;
333 
334  // Path configuration edit dialog.
335  AddMenuItem( preferencesMenu,
337  _( "Configure Pa&ths..." ),
338  _( "Edit path configuration environment variables" ),
339  KiBitmap( path_xpm ) );
340 
341  // Text editor
342  AddMenuItem( preferencesMenu,
344  _( "&Set Text Editor..." ),
345  _( "Set your preferred text editor" ),
346  KiBitmap( editor_xpm ) );
347 
348  // PDF Viewer submenu:System browser or user defined checkbox
349  wxMenu* SubMenuPdfBrowserChoice = new wxMenu;
350 
351  // Default
352  AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_DEFAULT_PDF_BROWSER,
353  _( "System &Default PDF Viewer" ),
354  _( "Use system default PDF viewer" ),
355  KiBitmap( datasheet_xpm ),
356  wxITEM_CHECK );
357  SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
358  Pgm().UseSystemPdfBrowser() );
359 
360  // Favourite
361  AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER,
362  _( "&Favorite PDF Viewer" ),
363  _( "Use favorite PDF viewer" ),
364  KiBitmap( datasheet_xpm ),
365  wxITEM_CHECK );
366  SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER,
367  !Pgm().UseSystemPdfBrowser() );
368 
369  SubMenuPdfBrowserChoice->AppendSeparator();
370  // Append PDF Viewer submenu to preferences
371  AddMenuItem( SubMenuPdfBrowserChoice,
373  _( "Set &PDF Viewer..." ),
374  _( "Set favorite PDF viewer" ),
375  KiBitmap( datasheet_xpm ) );
376 
377  // PDF viewer submenu
378  AddMenuItem( preferencesMenu, SubMenuPdfBrowserChoice, -1,
379  _( "&PDF Viewer" ),
380  _( "PDF viewer preferences" ),
381  KiBitmap( datasheet_xpm ) );
382 
383  preferencesMenu->AppendSeparator();
384 
385  // Icons options submenu
386  AddMenuIconsOptions( preferencesMenu );
387 
388  preferencesMenu->AppendSeparator();
389 
390  // Language submenu
391  Pgm().AddMenuLanguageList( preferencesMenu );
392  // Hotkey submenu
393  AddHotkeyConfigMenu( preferencesMenu );
394 
395 
396  // Menu Tools:
397  wxMenu* toolsMenu = new wxMenu;
398 
399  msg = AddHotkeyName( _( "Edit Schematic" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA );
400  AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
401 
402  msg = AddHotkeyName( _( "Edit Schematic Symbols" ),
404  AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
405 
406  msg = AddHotkeyName( _( "Edit PCB Layout" ),
408  AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
409 
410  msg = AddHotkeyName( _( "Edit PCB Footprints" ),
412  AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
413 
414  msg = AddHotkeyName( _( "View Gerber Files" ),
416  AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
417 
418  msg = AddHotkeyName( _( "Convert Image" ),
420  AddMenuItem( toolsMenu, ID_TO_BITMAP_CONVERTER, msg,
421  _( "Bitmap2Component - Convert bitmap images to schematic\n"
422  "or PCB elements" ),
423  KiBitmap( bitmap2component_xpm ) );
424 
425  msg = AddHotkeyName( _( "Run PCB Calculator" ), kicad_Manager_Hokeys_Descr, HK_RUN_PCBCALCULATOR );
426  AddMenuItem( toolsMenu, ID_TO_PCB_CALCULATOR, msg,
427  _( "Pcb calculator - Calculator for components, track width, etc." ),
428  KiBitmap( calculator_xpm ) );
429 
430  msg = AddHotkeyName( _( "Edit Page Layout" ), kicad_Manager_Hokeys_Descr, HK_RUN_PLEDITOR );
431  AddMenuItem( toolsMenu, ID_TO_PL_EDITOR, msg,
432  _( "Pl editor - Worksheet layout editor" ),
433  KiBitmap( pagelayout_load_xpm ) );
434 
435  // Menu Help:
436  wxMenu* helpMenu = new wxMenu;
437 
438  // Contents
439  AddMenuItem( helpMenu, wxID_HELP,
440  _( "KiCad &Manual" ),
441  _( "Open KiCad user manual" ),
442  KiBitmap( online_help_xpm ) );
443 
444  AddMenuItem( helpMenu, wxID_INDEX,
445  _( "&Getting Started in KiCad" ),
446  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
447  KiBitmap( help_xpm ) );
448 
449  AddMenuItem( helpMenu,
451  _( "&List Hotkeys" ),
452  _( "Displays the current hotkeys list and corresponding commands" ),
453  KiBitmap( hotkeys_xpm ) );
454 
455  // Separator
456  helpMenu->AppendSeparator();
457 
458  // Get involved with KiCad
460  _( "Get &Involved" ),
461  _( "Contribute to KiCad (opens a web browser)" ),
462  KiBitmap( info_xpm ) );
463 
464  helpMenu->AppendSeparator();
465 
466  // About
467  AddMenuItem( helpMenu, wxID_ABOUT,
468  _( "&About KiCad" ),
469  _( "About KiCad" ),
470  KiBitmap( about_xpm ) );
471 
472  // Create the menubar and append all submenus
473  menuBar->Append( fileMenu, _( "&File" ) );
474  menuBar->Append( viewMenu, _( "&View" ) );
475  menuBar->Append( toolsMenu, _( "&Tools" ) );
476  menuBar->Append( browseMenu, _( "&Browse" ) );
477  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
478  menuBar->Append( helpMenu, _( "&Help" ) );
479 
480  SetMenuBar( menuBar );
481  delete oldMenuBar;
482 
483  // Add the hotkey to the "show hotkey list" menu, because we do not have
484  // a management of the keyboard keys in Kicad.
485  // So all hotheys should be added to the menubar
486  // Note Use wxMenuBar::SetLabel only after the menubar
487  // has been associated with a frame. (see wxWidgets doc)
488  msg = AddHotkeyName( menuBar->GetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST ),
490  menuBar->SetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg );
491 }
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:174
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)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:310
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void AddHotkeyConfigMenu(wxMenu *aMenu)
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
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:889
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
KICAD_MANAGER_FRAME::language_change KICAD_MANAGER_FRAME::OnChangeIconsOptions ID_TO_PCB_FP_EDITOR
void KICAD_MANAGER_FRAME::ReCreateTreePrj ( )

Definition at line 183 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

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

184 {
186 }
void ReCreateTreePrj()
Create or modify the tree showing project file names.
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
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 296 of file mainframe.cpp.

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

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

297 {
298  KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );
299 
300  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
301  // Kiway.Player( FRAME_SCH, true )
302  // therefore, the schematic editor is sometimes running, but the schematic project
303  // is not loaded, if the library editor was called, and the dialog field editor was used.
304  // On linux, it happens the first time the schematic editor is launched, if
305  // library editor was running, and the dialog field editor was open
306  // On Windows, it happens always after the library editor was called,
307  // and the dialog field editor was used
308  if( !frame )
309  {
310  try
311  {
312  frame = Kiway.Player( FRAME_SCH, true );
313  }
314  catch( const IO_ERROR& err )
315  {
316  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
317  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
318  return;
319  }
320  }
321 
322  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
323  // but no project loaded.
324  {
325  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
326  frame->Show( true );
327  }
328 
329  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
330  // On linux, Raise() brings the window on screen, but this code works fine
331  if( frame->IsIconized() )
332  {
333  frame->Iconize( false );
334  // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
335  // to show the frame at its normal size: Maximize should be called.
336  frame->Maximize( false );
337  }
338 
339  frame->Raise();
340 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
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:170
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
KIWAY Kiway
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 379 of file mainframe.cpp.

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

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

380 {
381  KIWAY_PLAYER* frame;
382 
383  try
384  {
385  frame = Kiway.Player( FRAME_PCB, true );
386  }
387  catch( const IO_ERROR& err )
388  {
389  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
390  wxOK | wxICON_ERROR, this );
391  return;
392  }
393 
394  // a pcb frame can be already existing, but not yet used.
395  // this is the case when running the footprint editor, or the footprint viewer first
396  // if the frame is not visible, the board is not yet loaded
397  if( !frame->IsVisible() )
398  {
399  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
400  frame->Show( true );
401  }
402 
403  // On Windows, Raise() does not bring the window on screen, when iconized
404  if( frame->IsIconized() )
405  frame->Iconize( false );
406 
407  frame->Raise();
408 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
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:170
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
KIWAY Kiway
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 274 of file eda_base_frame.h.

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

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

274 {};
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 542 of file mainframe.cpp.

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

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

Definition at line 153 of file mainframe.cpp.

References GetProjectFileName(), and SchematicFileExtension.

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

154 {
155  wxFileName fn( GetProjectFileName() );
156 
157  fn.SetExt( SchematicFileExtension );
158 
159  return fn.GetFullPath();
160 }
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
const wxString SchematicFileExtension
void EDA_BASE_FRAME::SetAutoSaveInterval ( int  aInterval)
inherited

Definition at line 218 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_BASE_FRAME::isAutoSaveRequired(), DIALOG_GENERALOPTIONS::OnOkClick(), and SCH_EDIT_FRAME::OnPreferencesOptions().

219 {
220  m_autoSaveInterval = aInterval;
221 
222  if( m_autoSaveTimer->IsRunning() )
223  {
224  if( m_autoSaveInterval > 0 )
225  {
226  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
227  }
228  else
229  {
230  m_autoSaveTimer->Stop();
231  m_autoSaveState = false;
232  }
233  }
234 }
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.
virtual void EDA_BASE_FRAME::SetIconScale ( int  aScale)
inlinevirtualinherited

Function SetIconScale.

Modify the scale of icons in the window; should refresh them and save the setting.

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, GERBVIEW_FRAME, and LIB_EDIT_FRAME.

Definition at line 444 of file eda_base_frame.h.

444 {}
void EDA_BASE_FRAME::SetMruPath ( const wxString &  aPath)
inlineinherited

Definition at line 345 of file eda_base_frame.h.

Referenced by LoadProject().

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

Definition at line 135 of file mainframe.cpp.

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

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

136 {
137  // ensure file name is absolute:
138  wxFileName fn( aFullProjectProFileName );
139 
140  if( !fn.IsAbsolute() )
141  fn.MakeAbsolute();
142 
143  Prj().SetProjectFullName( fn.GetFullPath() );
144 }
PROJECT & Prj()
Definition: kicad.cpp:287
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::ShowChangedIcons ( )
virtualinherited

Function ShowChangedIcons redraws items menus after a icon was changed option.

Definition at line 262 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by EDA_BASE_FRAME::GetMruPath(), and KIWAY::ShowChangedIcons().

263 {
264  ReCreateMenuBar();
265  GetMenuBar()->Refresh();
266 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
void EDA_BASE_FRAME::ShowChangedLanguage ( )
virtualinherited

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

Reimplemented in PCB_EDIT_FRAME, GERBVIEW_FRAME, PCB_BASE_FRAME, and CVPCB_MAINFRAME.

Definition at line 255 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(), and GERBVIEW_FRAME::ShowChangedLanguage().

256 {
257  ReCreateMenuBar();
258  GetMenuBar()->Refresh();
259 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
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 189 of file mainframe.cpp.

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

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

190 {
191  return PgmTop().SysSearch();
192 }
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 401 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().

403 {
404  wxFileHistory* fileHistory = aFileHistory;
405 
406  if( !fileHistory )
407  fileHistory = &Kiface().GetFileHistory();
408 
409  fileHistory->AddFileToHistory( FullFileName );
410 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & 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 529 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(), HOTKEYS_EDITOR_DIALOG::TransferDataFromWindow(), and EDA_DRAW_FRAME::WriteHotkeyConfig().

531 {
532  wxString msg;
533  wxString keyname, infokey;
534  FILE* file;
535 
536  msg = wxT( "$hotkey list\n" );
537 
538  // Print the current hotkey list
539  EDA_HOTKEY** list;
540 
541  for( ; aDescList->m_HK_InfoList != nullptr; aDescList++ )
542  {
543  if( aDescList->m_Title )
544  {
545  msg += wxT( "# " );
546  msg += *aDescList->m_Title;
547  msg += wxT( "\n" );
548  }
549 
550  msg += *aDescList->m_SectionTag;
551  msg += wxT( "\n" );
552 
553  list = aDescList->m_HK_InfoList;
554 
555  for( ; *list != nullptr; list++ )
556  {
557  EDA_HOTKEY* hk_decr = *list;
558  msg += wxT( "shortcut " );
559  keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
560  AddDelimiterString( keyname );
561  infokey = hk_decr->m_InfoMsg;
562  AddDelimiterString( infokey );
563  msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
564  }
565  }
566 
567  msg += wxT( "$Endlist\n" );
568 
569  if( aFullFileName )
570  file = wxFopen( *aFullFileName, wxT( "wt" ) );
571  else
572  {
573  wxString configName( ConfigBaseName() );
574  if( configName == SCH_EDIT_FRAME_NAME || configName == LIB_EDIT_FRAME_NAME )
575  configName = EESCHEMA_HOTKEY_NAME;
576  else if( configName == PCB_EDIT_FRAME_NAME ||
577  configName == FOOTPRINT_EDIT_FRAME_NAME )
578  configName = PCBNEW_HOTKEY_NAME;
579 
580  wxFileName fn( configName );
581  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
582  fn.SetPath( GetKicadConfigPath() );
583  file = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
584  }
585 
586  if( file )
587  {
588  wxFputs( msg, file );
589  fclose( file );
590  }
591  else
592  {
593  msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
594  return 0;
595  }
596 
597  return 1;
598 }
#define LIB_EDIT_FRAME_NAME
Definition: draw_frame.h:49
EDA_HOTKEY ** m_HK_InfoList
Definition: hotkeys_basic.h:93
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:211
wxString * m_SectionTag
Definition: hotkeys_basic.h:92
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:94
#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 141 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 136 of file eda_base_frame.h.

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

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

Definition at line 146 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 132 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 305 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 309 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), and LoadSettings().

EDA_HOTKEY_CONFIG* KICAD_MANAGER_FRAME::m_manager_Hokeys_Descr
private

Definition at line 310 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), Process_Config(), and ReCreateMenuBar().

wxTextCtrl* KICAD_MANAGER_FRAME::m_MessagesBox
private

Definition at line 306 of file kicad.h.

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

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 157 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::LoadSettings().

wxAuiToolBar* KICAD_MANAGER_FRAME::m_VToolBar
private

Definition at line 307 of file kicad.h.


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