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...
 
int ReadHotkeyConfig (struct EDA_HOTKEY_CONFIG *aDescList)
 Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys. 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...
 
int ReadHotkeyConfigFile (const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
 Function ReadHotkeyConfigFile Read an old configuration file (&ltfile&gt.key) and fill the current hotkey list with hotkeys. 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 sise 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.
Definition: wxstruct.h:500
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
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
Definition: wxstruct.h:149
int GetPanelHeight() const
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:491
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
wxPoint m_FramePos
Definition: wxstruct.h:139
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
Definition: wxstruct.h:565
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
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
wxSize m_FrameSize
Definition: wxstruct.h:140
#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)
Definition: basicframe.cpp:74
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
Definition: wxstruct.h:149

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 677 of file basicframe.cpp.

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

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

678 {
679  wxMenu* menu = NULL;
680  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
681 
682  if( item ) // This menu exists, do nothing
683  return;
684 
685  menu = new wxMenu;
686 
687  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
688  _( "Icons in Menus" ), wxEmptyString,
689  wxITEM_CHECK ) );
690  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
691 
692  AddMenuItem( MasterMenu, menu,
694  _( "Icons Options" ),
695  _( "Select show icons in menus and icons sizes" ),
696  KiBitmap( icon_xpm ) );
697 }
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:173
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
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 582 of file basicframe.cpp.

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

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

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

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:71
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 266 of file wxstruct.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().

267  {
268  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
269  return baseCfgName;
270  }
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:142
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:316
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:270
const wxString LegacyPcbFileExtension
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
#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 235 of file basicframe.cpp.

Referenced by EDA_BASE_FRAME::onAutoSaveTimer().

236 {
237  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
238 }
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 757 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), EDA_BASE_FRAME::GetMruPath(), Prj(), EDA_BASE_FRAME::SetMruPath(), and EDA_BASE_FRAME::WriteHotkeyConfig().

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(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

759 {
760  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
761  wxString mask = wxT( "*." ) + ext;
762 
763 #if 0
764  wxString path = wxPathOnly( Prj().GetProjectFullName() );
765 #else
766  wxString path = GetMruPath();
767 #endif
768  wxFileName fn( aDefaultShortname );
769  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
770 
771  wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ),
772  path,
773  fn.GetFullPath(),
774  ext,
775  mask,
776  this,
777  wxFD_SAVE,
778  true );
779 
780  if( filename.IsEmpty() )
781  return;
782 
783  WriteHotkeyConfig( aDescList, &filename );
784  SetMruPath( wxFileName( filename ).GetPath() );
785 }
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:367
PROJECT & Prj()
Definition: kicad.cpp:270
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
Definition: wxstruct.h:369
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 225 of file wxstruct.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

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

225 { return m_autoSaveInterval; }
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
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 404 of file basicframe.cpp.

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

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

406 {
407  wxFileHistory* fileHistory = aFileHistory;
408 
409  if( !fileHistory )
410  fileHistory = &Kiface().GetFileHistory();
411 
412  int baseId = fileHistory->GetBaseId();
413 
414  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
415 
416  unsigned i = cmdId - baseId;
417 
418  if( i < fileHistory->GetCount() )
419  {
420  wxString fn = fileHistory->GetHistoryFile( i );
421 
422  if( wxFileName::FileExists( fn ) )
423  return fn;
424  else
425  {
426  wxString msg = wxString::Format(
427  _( "File \"%s\" was not found." ),
428  GetChars( fn ) );
429 
430  wxMessageBox( msg );
431 
432  fileHistory->RemoveFileFromHistory( i );
433  }
434  }
435 
436  return wxEmptyString;
437 }
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
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 459 of file wxstruct.h.

Referenced by get_scale_factor().

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

Definition at line 531 of file basicframe.cpp.

References ShowAboutDialog().

532 {
533  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
534  ShowAboutDialog( this );
535 }
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
void EDA_BASE_FRAME::GetKicadContribute ( wxCommandEvent &  event)
inherited

Definition at line 518 of file basicframe.cpp.

References URL_GET_INVOLVED.

519 {
520  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
521  {
522  wxString msg;
523  msg.Printf( _( "Could not launch the default browser.\n"
524  "For information on how to help the KiCad project, visit %s" ),
526  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
527  }
528 }
#define URL_GET_INVOLVED
Definition: basicframe.cpp:51
void EDA_BASE_FRAME::GetKicadHelp ( wxCommandEvent &  event)
inherited

Definition at line 440 of file basicframe.cpp.

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

441 {
442  const SEARCH_STACK& search = sys_search();
443 
444  /* We have to get document for beginners,
445  * or the full specific doc
446  * if event id is wxID_INDEX, we want the document for beginners.
447  * else the specific doc file (its name is in Kiface().GetHelpFileName())
448  * The document for beginners is the same for all KiCad utilities
449  */
450  if( event.GetId() == wxID_INDEX )
451  {
452  // List of possible names for Getting Started in KiCad
453  const wxChar* names[2] = {
454  wxT( "getting_started_in_kicad" ),
455  wxT( "Getting_Started_in_KiCad" )
456  };
457 
458  wxString helpFile;
459  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
460  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
461  for( unsigned ii = 0; ii < DIM( names ); ii++ )
462  {
463  helpFile = SearchHelpFileFullPath( search, names[ii] );
464 
465  if( !helpFile.IsEmpty() )
466  break;
467  }
468 
469  if( !helpFile )
470  {
471  wxString msg = wxString::Format( _(
472  "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
473  wxMessageBox( msg );
474  }
475  else
476  {
477  GetAssociatedDocument( this, helpFile );
478  }
479 
480  return;
481  }
482 
483  wxString base_name = help_name();
484  wxString helpFile = SearchHelpFileFullPath( search, base_name );
485 
486  if( !helpFile )
487  {
488  wxString msg = wxString::Format( _(
489  "Help file \"%s\" could not be found." ),
490  GetChars( base_name )
491  );
492  wxMessageBox( msg );
493  }
494  else
495  {
496  GetAssociatedDocument( this, helpFile );
497  }
498 }
#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:86
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...
Definition: basicframe.cpp:374
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSStack, const wxString &aBaseName)
Function SearchHelpFileFullPath returns the help file'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()
Definition: basicframe.cpp:380
wxString EDA_BASE_FRAME::GetMruPath ( ) const
inlineinherited
const wxString KICAD_MANAGER_FRAME::GetProjectFileName ( )
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().

196 {
197  return PgmTop().GetHelpFileName();
198 }
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
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 728 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), EDA_BASE_FRAME::GetMruPath(), EDA_BASE_FRAME::ReadHotkeyConfigFile(), EDA_BASE_FRAME::SetMruPath(), and EDA_BASE_FRAME::WriteHotkeyConfig().

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(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

730 {
731  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
732  wxString mask = wxT( "*." ) + ext;
733 
734 
735  wxString path = GetMruPath();
736  wxFileName fn( aDefaultShortname );
737  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
738 
739  wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ),
740  path,
741  fn.GetFullPath(),
742  ext,
743  mask,
744  this,
745  wxFD_OPEN,
746  true );
747 
748  if( filename.IsEmpty() )
749  return;
750 
751  ReadHotkeyConfigFile( filename, aDescList );
752  WriteHotkeyConfig( aDescList );
753  SetMruPath( wxFileName( filename ).GetPath() );
754 }
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:367
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfigFile Read an old configuration file (<file>.key) and fill the current ho...
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
Definition: wxstruct.h:369
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 181 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ProcessEvent().

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

Function IsWritable checks if aFileName can be written.

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

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

Definition at line 538 of file basicframe.cpp.

References GetChars().

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

539 {
540  wxString msg;
541  wxFileName fn = aFileName;
542 
543  // Check for absence of a file path with a file name. Unfortunately KiCad
544  // uses paths relative to the current project path without the ./ part which
545  // confuses wxFileName. Making the file name path absolute may be less than
546  // elegant but it solves the problem.
547  if( fn.GetPath().IsEmpty() && fn.HasName() )
548  fn.MakeAbsolute();
549 
550  wxCHECK_MSG( fn.IsOk(), false,
551  wxT( "File name object is invalid. Bad programmer!" ) );
552  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
553  wxT( "File name object path <" ) + fn.GetFullPath() +
554  wxT( "> is not set. Bad programmer!" ) );
555 
556  if( fn.IsDir() && !fn.IsDirWritable() )
557  {
558  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
559  GetChars( fn.GetPath() ) );
560  }
561  else if( !fn.FileExists() && !fn.IsDirWritable() )
562  {
563  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
564  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
565  }
566  else if( fn.FileExists() && !fn.IsFileWritable() )
567  {
568  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
569  GetChars( fn.GetFullPath() ) );
570  }
571 
572  if( !msg.IsEmpty() )
573  {
574  wxMessageBox( msg );
575  return false;
576  }
577 
578  return true;
579 }
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)
Definition: wxstruct.h:367
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:270
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:392
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:71
#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:351
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.
Definition: basicframe.cpp:260
void KICAD_MANAGER_FRAME::OnArchiveFiles ( wxCommandEvent &  event)

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

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

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

229 {
230  if( !doAutoSave() )
231  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
232 }
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
Definition: basicframe.cpp:235
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:161
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
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 ...
Definition: basicframe.cpp:666
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.

References TREE_PROJECT_FRAME::FileWatcherReset(), and m_LeftWin.

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.
Definition: basicframe.cpp:392
wxPoint m_FramePos
Definition: wxstruct.h:139
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
wxSize m_FrameSize
Definition: wxstruct.h:140
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:65
VTBL_ENTRY void ConfigurePaths(wxWindow *aParent=NULL)
Function ConfigurePaths.
Definition: pgm_base.cpp:905
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 235 of file prjconfig.cpp.

References DIALOG_TEMPLATE_SELECTOR::AddTemplatesPage(), ClearMsg(), CreateNewProject(), PROJECT_TEMPLATE::CreateProject(), PROJECT_TEMPLATE::GetDestinationFiles(), DIALOG_TEMPLATE_SELECTOR::GetSelectedTemplate(), LoadProject(), Prj(), and SEP.

236 {
237  wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
238  wxString title = _( "New Project Folder" );
239  wxDirDialog dlg( this, title, default_dir );
240 
241  if( dlg.ShowModal() == wxID_CANCEL )
242  return;
243 
244  // Builds the project .pro filename, from the new project folder name
245  wxFileName fn;
246  fn.AssignDir( dlg.GetPath() );
247  fn.SetName( dlg.GetPath().AfterLast( SEP() ) );
248  fn.SetExt( wxT( "pro" ) );
249 
250  wxChar sep[2] = { SEP(), 0 }; // nul terminated separator wxChar string.
251 
252  ClearMsg();
253 
255 
256  wxFileName templatePath;
257  wxString envStr;
258 
259 #ifndef __WXMAC__
260  wxGetEnv( wxT( "KICAD" ), &envStr );
261 
262  // Add a new tab for system templates
263  if( !envStr.empty() )
264  {
265  // user may or may not have including terminating separator.
266  if( !envStr.EndsWith( sep ) )
267  envStr += sep;
268 
269  templatePath = envStr + wxT( "template" ) + sep;
270  }
271  else
272  {
273  // The standard path should be in the share directory for kicad. As
274  // it is normal on Windows to only have the share directory and not
275  // the kicad sub-directory we fall back to that if the directory
276  // doesn't exist
277  templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) +
278  sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "kicad" ) +
279  sep + wxT( "template" ) + sep;
280 
281  if( !wxDirExists( templatePath.GetFullPath() ) )
282  {
283  templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + sep +
284  wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "template" ) + sep;
285  }
286  }
287 #else
288  // Use what is provided in the bundle data dir
289  templatePath = GetOSXKicadDataDir() + sep + wxT( "template" );
290 #endif
291 
292  ps->AddTemplatesPage( _( "System Templates" ), templatePath );
293 
294  // Add a new tab for user templates
295  wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() + sep + wxT( "kicad" ) +
296  sep + wxT( "template" ) + sep;
297 
298  ps->AddTemplatesPage( _( "User Templates" ), userPath );
299 
300  // Check to see if a custom template location is available and setup a
301  // new selection tab if there is.
302  envStr.clear();
303  wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr );
304 
305  if( !envStr.empty() )
306  {
307  if( !envStr.EndsWith( sep ) )
308  envStr += sep;
309 
310  wxFileName envPath = envStr;
311 
312  ps->AddTemplatesPage( _( "Portable Templates" ), envPath );
313  }
314 
315  // Show the project template selector dialog
316  if( ps->ShowModal() != wxID_OK )
317  return;
318 
319  if( ps->GetSelectedTemplate() == NULL )
320  {
321  wxMessageBox( _( "No project template was selected. Cannot generate new project." ),
322  _( "Error" ),
323  wxOK | wxICON_ERROR,
324  this );
325 
326  return;
327  }
328 
329  // Make sure the user has write permissions to the base path.
330  wxFileName prjPath = fn;
331 
332  while( !prjPath.DirExists() )
333  prjPath.RemoveLastDir();
334 
335  if( !prjPath.IsDirWritable() )
336  {
337  wxString msg;
338 
339  msg.Printf( _( "Cannot write to folder \"%s\"." ), prjPath.GetPath() );
340  wxMessageDialog msgDlg( this, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
341  msgDlg.SetExtendedMessage( _( "Plese check your access permissions to this folder "
342  "and try again." ) );
343  msgDlg.ShowModal();
344  return;
345  }
346 
347  // Make sure we are not overwriting anything in the destination folder.
348  std::vector< wxFileName > destFiles;
349 
350  if( ps->GetSelectedTemplate()->GetDestinationFiles( fn, destFiles ) )
351  {
352  std::vector< wxFileName > overwrittenFiles;
353 
354  for( const auto& file : destFiles )
355  {
356  if( file.FileExists() )
357  overwrittenFiles.push_back( file );
358  }
359 
360  if( !overwrittenFiles.empty() )
361  {
362  wxString extendedMsg = _( "Overwriting files:" ) + "\n";
363 
364  for( const auto& file : overwrittenFiles )
365  {
366  extendedMsg += "\n" + file.GetFullName();
367  }
368 
369  wxMessageDialog owDlg( this,
370  _( "Are you sure you want to overwrite files in "
371  "the destination folder?" ),
372  _( "Warning!" ),
373  wxYES_NO | wxICON_QUESTION | wxCENTER );
374  owDlg.SetExtendedMessage( extendedMsg );
375  owDlg.SetYesNoLabels( _( "Overwrite" ), _( "Do Not Overwrite" ) );
376 
377  if( owDlg.ShowModal() == wxID_NO )
378  return;
379  }
380  }
381 
382  wxString errorMsg;
383 
384  // The selected template widget contains the template we're attempting to use to
385  // create a project
386  if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
387  {
388  wxMessageDialog createDlg( this,
389  _( "A problem occurred creating new project from template!" ),
390  _( "Template Error" ),
391  wxOK | wxICON_ERROR );
392 
393  if( !errorMsg.empty() )
394  createDlg.SetExtendedMessage( errorMsg );
395 
396  createDlg.ShowModal();
397  return;
398  }
399 
400  CreateNewProject( fn.GetFullPath() );
401  LoadProject( fn );
402 }
PROJECT_TEMPLATE * GetSelectedTemplate()
PROJECT & Prj()
Definition: kicad.cpp:270
#define SEP()
Definition: prjconfig.cpp:50
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:71
wxString GetFileFromHistory(int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
Function GetFileFromHistory fetches the file name from the file history list.
Definition: basicframe.cpp:404
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 58 of file import_project.cpp.

References ClearMsg(), SCH_EDIT_FRAME::CreateNetlist(), IO_MGR::EAGLE, EagleFilesWildcard(), FRAME_PCB, FRAME_SCH, EDA_BASE_FRAME::GetMruPath(), GetProjectFileName(), SCH_EDIT_FRAME::ImportFile(), PCB_EDIT_FRAME::ImportFile(), IsOK(), Kiway, LegacyPcbFileExtension, m_active_project, NET_TYPE_PCBNEW, NetlistFileExtension, KIWAY::Player(), KIWAY::PlayersClose(), ProjectFileExtension, PCB_EDIT_FRAME::ReadPcbNetlist(), ReCreateTreePrj(), SchematicFileExtension, SetProjectFileName(), and IO_ERROR::What().

59 {
60  // Close other windows.
61  if( !Kiway.PlayersClose( false ) )
62  return;
63 
64 
65  wxString title = _( "Import Eagle Project Files" );
66  int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
67  wxString default_dir = GetMruPath();
68 
69  ClearMsg();
70 
71  wxFileDialog schdlg( this, title, default_dir, wxEmptyString,
72  EagleFilesWildcard(), style );
73 
74  if( schdlg.ShowModal() == wxID_CANCEL )
75  return;
76 
77 
78  wxFileName sch( schdlg.GetPath() );
79 
80  sch.SetExt( SchematicFileExtension );
81 
82  wxFileName pro = sch;
83 
84  pro.SetExt( ProjectFileExtension );
85 
86  wxString protitle = _( "KiCad Project Destination" );
87 
88  // Don't use wxFileDialog here. On GTK builds, the default path is returned unless a
89  // file is actually selected.
90  wxDirDialog prodlg( this, protitle, pro.GetPath(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
91 
92  if( prodlg.ShowModal() == wxID_CANCEL )
93  return;
94 
95  pro.SetPath( prodlg.GetPath() );
96 
97  // Check if the project directory is empty
98  wxDir directory( pro.GetPath() );
99 
100  if( directory.HasFiles() )
101  {
102  wxString msg = _( "The selected directory is not empty. We recommend you "
103  "create projects in their own clean directory.\n\nDo you "
104  "want to create a new empty directory for the project?" );
105 
106  if( IsOK( this, msg ) )
107  {
108  // Append a new directory with the same name of the project file
109  // and try to create it
110  pro.AppendDir( pro.GetName() );
111 
112  if( !wxMkdir( pro.GetPath() ) )
113  // There was a problem, undo
114  pro.RemoveLastDir();
115  }
116  }
117 
118 
119 
120  wxFileName pcb( sch );
121  wxFileName netlist( pro );
122  pro.SetExt( ProjectFileExtension ); // enforce extension
123  pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
124  netlist.SetExt( NetlistFileExtension );
125 
126  if( !pro.IsAbsolute() )
127  pro.MakeAbsolute();
128 
129  SetProjectFileName( pro.GetFullPath() );
130 
131  wxString prj_filename = GetProjectFileName();
132 
133  wxString sch_filename = sch.GetFullPath();
134 
135  if( sch.FileExists() )
136  {
137  SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, false );
138 
139  if( !schframe )
140  {
141  try
142  {
143  schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, true );
144  }
145  catch( IO_ERROR err )
146  {
147  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
148  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
149  return;
150  }
151  }
152 
153  schframe->ImportFile( sch_filename, SCH_IO_MGR::SCH_EAGLE );
154 
155  if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor)
156  // but no project loaded.
157  {
158  schframe->Show( true );
159  }
160 
161  if( schframe->IsIconized() )
162  schframe->Iconize( false );
163 
164  schframe->Raise();
165 
166  schframe->CreateNetlist( NET_TYPE_PCBNEW, netlist.GetFullPath(), 0, NULL, true );
167  }
168 
169  if( pcb.FileExists() )
170  {
171  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, false );
172 
173  if( !pcbframe )
174  {
175  try
176  {
177  pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, true );
178  }
179  catch( IO_ERROR err )
180  {
181  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
182  wxOK | wxICON_ERROR, this );
183  return;
184  }
185  }
186 
187  // a pcb frame can be already existing, but not yet used.
188  // this is the case when running the footprint editor, or the footprint viewer first
189  // if the frame is not visible, the board is not yet loaded
190  if( !pcbframe->IsVisible() )
191  {
192  pcbframe->ImportFile( pcb.GetFullPath(), IO_MGR::EAGLE );
193  pcbframe->Show( true );
194  }
195 
196  // On Windows, Raise() does not bring the window on screen, when iconized
197  if( pcbframe->IsIconized() )
198  pcbframe->Iconize( false );
199 
200  pcbframe->Raise();
201 
202  if( netlist.FileExists() )
203  {
204  pcbframe->ReadPcbNetlist( netlist.GetFullPath(),
205  wxEmptyString,
206  NULL,
207  false,
208  false,
209  false,
210  false,
211  false,
212  false );
213  }
214  }
215 
216  ReCreateTreePrj();
217  m_active_project = true;
218 }
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
const wxString ProjectFileExtension
bool CreateNetlist(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL, bool silent=false) override
Create a netlist for the current schematic.
const wxString LegacyPcbFileExtension
Schematic editor (Eeschema) main window.
Definition: schframe.h:118
bool ImportFile(const wxString &aFileName, int aFileType) override
Load the given filename but sets the path to the current project path.
const wxString NetlistFileExtension
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
void ReadPcbNetlist(const wxString &aNetlistFileName, const wxString &aCmpFileName, REPORTER *aReporter, bool aChangeFootprint, bool aDeleteBadTracks, bool aDeleteExtraFootprints, bool aSelectByTimestamp, bool aDeleteSinglePadNets, bool aIsDryRun) override
Function ReadPcbNetlist reads aNetlistFileName and updates the footprints (load missing footprints an...
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
bool ImportFile(const wxString &aFileName, int aFileType) override
Function ImportFile load the given filename but sets the path to the current project path...
wxString EagleFilesWildcard()
bool m_active_project
Definition: kicad.h:314
wxString GetMruPath() const
Definition: wxstruct.h:369
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:47
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:122
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
Definition: wxstruct.h:369
void KICAD_MANAGER_FRAME::OnNewProject ( wxCommandEvent &  aEvent)

Definition at line 187 of file prjconfig.cpp.

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

188 {
189  wxString default_dir = GetMruPath();
190  wxFileDialog dlg( this, _( "Create New Project" ), default_dir, wxEmptyString,
191  ProjectFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
192 
193  if( dlg.ShowModal() == wxID_CANCEL )
194  return;
195 
196  wxFileName pro( dlg.GetPath() );
197  pro.SetExt( ProjectFileExtension ); // enforce extension
198 
199  if( !pro.IsAbsolute() )
200  pro.MakeAbsolute();
201 
202  // Append a new directory with the same name of the project file.
203  pro.AppendDir( pro.GetName() );
204 
205  // Check if the project directory is empty if it already exists.
206  wxDir directory( pro.GetPath() );
207 
208  if( !pro.DirExists() )
209  {
210  if( !pro.Mkdir() )
211  {
212  wxString msg;
213  msg.Printf( _( "Directory \"%s\" could not be created.\n\n"
214  "Please make sure you have write permissions and try again." ),
215  pro.GetPath() );
216  DisplayErrorMessage( this, msg );
217  return;
218  }
219  }
220  else if( directory.HasFiles() )
221  {
222  wxString msg = _( "The selected directory is not empty. It is recommended that you "
223  "create projects in their own empty directory.\n\nDo you "
224  "want to continue?" );
225 
226  if( !IsOK( this, msg ) )
227  return;
228  }
229 
230  CreateNewProject( pro );
231  LoadProject( pro );
232 }
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:88
const wxString ProjectFileExtension
wxString ProjectFileWildcard()
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
Definition: wxstruct.h:369
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:122
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:270
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
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:100
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:65
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().

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:270
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 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( 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
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:47
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 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( 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
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:47
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnSaveProject ( wxCommandEvent &  event)

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

Definition at line 405 of file prjconfig.cpp.

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

406 {
407  if( !wxIsWritable( GetProjectFileName() ) )
408  return;
409 
411 }
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:316
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:270
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
#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:65
VTBL_ENTRY void WritePdfBrowserInfos()
Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.
Definition: eda_doc.cpp:54
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 501 of file basicframe.cpp.

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

502 {
503  // Ask for the current editor and instruct GetEditorName() to not show
504  // unless we pass false as argument.
505  wxString editorname = Pgm().GetEditorName( false );
506 
507  // Ask the user to select a new editor, but suggest the current one as the default.
508  editorname = Pgm().AskUserForPreferredEditor( editorname );
509 
510  // If we have a new editor name request it to be copied to m_editor_name and saved
511  // to the preferences file. If the user cancelled the dialog then the previous
512  // value will be retained.
513  if( !editorname.IsEmpty() )
514  Pgm().SetEditorName( editorname );
515 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:330
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
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:65
VTBL_ENTRY void WritePdfBrowserInfos()
Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.
Definition: eda_doc.cpp:54
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:41
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:74
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
Definition: wxstruct.h:149
void KICAD_MANAGER_FRAME::OnUnarchiveFiles ( wxCommandEvent &  event)

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

References DisplayError(), Format(), GetChars(), GetProjectFileName(), PrintMsg(), 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 }
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
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:74
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:65
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:65
void KICAD_MANAGER_FRAME::OnUpdateRequiresProject ( wxUpdateUIEvent &  event)

Definition at line 414 of file prjconfig.cpp.

References m_active_project.

415 {
416  event.Enable( m_active_project );
417 }
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(), and OnRunPcbNew().

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(), and OnRunPcbNew().

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 651 of file basicframe.cpp.

Referenced by 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().

652 {
653  if( evt_type != 0 )
654  {
655  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
656  evt.SetEventObject( this );
657  evt.SetId( evt_type );
658  wxPostEvent( this, evt );
659  return true;
660  }
661 
662  return false;
663 }
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)
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 176 of file basicframe.cpp.

References 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 LIB_VIEW_FRAME::onSelectNextSymbol(), LIB_VIEW_FRAME::onSelectPreviousSymbol(), KIWAY::ProcessEvent(), LIB_VIEW_FRAME::ReCreateListCmp(), and PCBNEW_CONTROL::SwitchUnits().

177 {
178  if( !IsEnabled() && IsActive() )
179  {
180  DIALOG_SHIM* dlg = findQuasiModalDialog( GetChildren() );
181  if( dlg )
182  dlg->Raise();
183  }
184 
185  if( !wxFrame::ProcessEvent( aEvent ) )
186  return false;
187 
188  if( IsShown() && m_hasAutoSave && IsActive() &&
190  {
191  if( !m_autoSaveState )
192  {
193  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
194  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
195  m_autoSaveState = true;
196  }
197  else if( m_autoSaveTimer->IsRunning() )
198  {
199  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
200  m_autoSaveTimer->Stop();
201  m_autoSaveState = false;
202  }
203  }
204 
205  return true;
206 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:70
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:161
DIALOG_SHIM * findQuasiModalDialog(wxWindowList &aList)
Definition: basicframe.cpp:115
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:181
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:152
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
const wxChar traceAutoSave[]
Flag to enable auto save feature debug tracing.
Definition: basicframe.cpp:53
int EDA_BASE_FRAME::ReadHotkeyConfig ( struct EDA_HOTKEY_CONFIG aDescList)
inherited

Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys.

Parameters
aDescList= current hotkey list descr. to initialize.

Definition at line 649 of file hotkeys_basic.cpp.

650 {
651  ::ReadHotkeyConfig( GetName(), aDescList );
652  return 1;
653 }
int ReadHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
int EDA_BASE_FRAME::ReadHotkeyConfigFile ( const wxString &  aFilename,
struct EDA_HOTKEY_CONFIG aDescList 
)
inherited

Function ReadHotkeyConfigFile Read an old configuration file (&ltfile&gt.key) and fill the current hotkey list with hotkeys.

Parameters
aFilename= file name to read.
aDescList= current hotkey list descr. to initialize.

Definition at line 594 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, and ParseHotkeyConfig().

Referenced by EDA_BASE_FRAME::ImportHotkeyConfigFromFile().

596 {
597  wxFileName fn( aFilename );
598  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
599 
600  wxFile cfgfile( fn.GetFullPath() );
601 
602  if( !cfgfile.IsOpened() ) // There is a problem to open file
603  return 0;
604 
605  // get length
606  cfgfile.SeekEnd();
607  wxFileOffset size = cfgfile.Tell();
608  cfgfile.Seek( 0 );
609 
610  // read data
611  std::vector<char> buffer( size );
612  cfgfile.Read( buffer.data(), size );
613  wxString data( buffer.data(), wxConvUTF8 );
614 
615  // parse
616  ParseHotkeyConfig( data, aDescList );
617 
618  // cleanup
619  cfgfile.Close();
620  return 1;
621 }
void ParseHotkeyConfig(const wxString &data, struct EDA_HOTKEY_CONFIG *aDescList)
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
void KICAD_MANAGER_FRAME::RecreateBaseHToolbar ( )

(Re)Create the horizontal toolbar

Definition at line 506 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().

507 {
508  if( m_mainToolBar )
509  m_mainToolBar->Clear();
510  else
511  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
512  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
513 
514  // New
515  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
516  KiScaledBitmap( new_project_xpm, this ),
517  _( "Create new project" ) );
518 
519  m_mainToolBar->AddTool( ID_NEW_PROJECT_FROM_TEMPLATE, wxEmptyString,
520  KiScaledBitmap( new_project_with_template_xpm, this ),
521  _( "Create new project from template" ) );
522 
523  // Load
524  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString,
525  KiScaledBitmap( open_project_xpm, this ),
526  _( "Open existing project" ) );
527 
528  // Currently there is nothing to save
529  // (Kicad manager does not save any info in .pro file)
530 #if 0
531  // Save
532  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString,
533  KiScaledBitmap( save_project_xpm, this ),
534  _( "Save current project" ) );
535 #endif
536 
538 
539  // Archive
540  m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
541  KiScaledBitmap( zip_xpm, this ),
542  _( "Archive all project files" ) );
543 
544  // Unarchive
545  m_mainToolBar->AddTool( ID_READ_ZIP_ARCHIVE, wxEmptyString,
546  KiScaledBitmap( unzip_xpm, this ),
547  _( "Unarchive project files from zip archive" ) );
548 
550 
551  // Refresh project tree
552  m_mainToolBar->AddTool( ID_PROJECT_TREE_REFRESH, wxEmptyString,
553  KiScaledBitmap( reload_xpm, this ),
554  _( "Refresh project tree" ) );
555 
556  // Create m_mainToolBar
557  m_mainToolBar->Realize();
558 }
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.
Definition: wxstruct.h:145
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
Definition: wxstruct.h:168
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  // Create and try to get the current menubar
203  wxMenuBar* menuBar = GetMenuBar();
204 
205  if( !menuBar )
206  menuBar = new wxMenuBar();
207 
208  // Delete all existing menus so they can be rebuilt.
209  // This allows language changes of the menu text on the fly.
210  menuBar->Freeze();
211 
212  // Before deleting, remove the menus managed by m_fileHistory
213  // (the file history will be updated when adding/removing files in history)
214  if( openRecentMenu )
215  PgmTop().GetFileHistory().RemoveMenu( openRecentMenu );
216 
217  // Delete all existing menus
218  while( menuBar->GetMenuCount() )
219  delete menuBar->Remove( 0 );
220 
221  // Recreate all menus:
222 
223  // Menu File:
224  wxMenu* fileMenu = new wxMenu;
225 
226  // New project creation
227  wxMenu* newprjSubMenu = new wxMenu();
228  msg = AddHotkeyName( _( "&Project..." ), kicad_Manager_Hokeys_Descr, HK_NEW );
229  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT, msg,
230  _( "Create new blank project" ),
231  KiBitmap( new_project_xpm ) );
232  msg = AddHotkeyName( _( "Project from &Template..." ),
234  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT_FROM_TEMPLATE, msg,
235  _( "Create new project from template" ),
236  KiBitmap( new_project_with_template_xpm ) );
237  AddMenuItem( fileMenu, newprjSubMenu,
238  wxID_ANY,
239  _( "&New" ),
240  _( "Create new project" ),
241  KiBitmap( new_project_xpm ) );
242 
243  // Open
244  msg = AddHotkeyName( _( "&Open Project..." ), kicad_Manager_Hokeys_Descr, HK_OPEN );
245  AddMenuItem( fileMenu, ID_LOAD_PROJECT, msg,
246  _( "Open an existing project" ),
247  KiBitmap( open_project_xpm ) );
248 
249  // File history
250  openRecentMenu = new wxMenu();
251  PgmTop().GetFileHistory().UseMenu( openRecentMenu );
252  PgmTop().GetFileHistory().AddFilesToMenu( );
253  AddMenuItem( fileMenu, openRecentMenu,
254  wxID_ANY,
255  _( "Open &Recent" ),
256  _( "Open a recent project" ),
257  KiBitmap( recent_xpm ) );
258 
259  // Currently there is nothing to save
260  // (Kicad manager does not save any info in .pro file)
261 #if 0
262  // Save
263  msg = AddHotkeyName( _( "&Save" ), kicad_Manager_Hokeys_Descr, HK_SAVE );
264  AddMenuItem( fileMenu, ID_SAVE_PROJECT, msg,
265  _( "Save current project" ),
266  KiBitmap( save_project_xpm ) );
267 #endif
268 
269  fileMenu->AppendSeparator();
270  wxMenu* importprjSubMenu = new wxMenu();
271 
272  AddMenuItem( importprjSubMenu, ID_IMPORT_EAGLE_PROJECT, _( "Eagle CAD" ),
273  _( "Import Eagle CAD XML schematic and board" ),
274  KiBitmap( import_project_xpm ) );
275 
276 
277  AddMenuItem( fileMenu, importprjSubMenu,
278  wxID_ANY,
279  _( "Import Project" ),
280  _( "Import project files from other software" ),
281  KiBitmap( import_project_xpm ) );
282 
283 
284  fileMenu->AppendSeparator();
285 
286  // Archive
287  AddMenuItem( fileMenu,
289  _( "&Archive Project..." ),
290  _( "Archive all needed project files into zip archive" ),
291  KiBitmap( zip_xpm ) );
292 
293  // Unarchive
294  AddMenuItem( fileMenu,
296  _( "&Unarchive Project..." ),
297  _( "Unarchive project files from zip archive" ),
298  KiBitmap( unzip_xpm ) );
299 
300  // Separator
301  fileMenu->AppendSeparator();
302 
303  // Quit
304  AddMenuItem( fileMenu,
305  wxID_EXIT,
306  _( "&Close" ),
307  _( "Close KiCad" ),
308  KiBitmap( exit_xpm ) );
309 
310  // View Menu:
311  wxMenu* viewMenu = new wxMenu();
312 
313  // Refresh project tree
314  msg = AddHotkeyName( _( "&Refresh" ), kicad_Manager_Hokeys_Descr, HK_REFRESH );
315  AddMenuItem( viewMenu, ID_PROJECT_TREE_REFRESH, msg,
316  _( "Refresh project tree" ),
317  KiBitmap( reload_xpm ) );
318 
319  // Menu Browse:
320  wxMenu* browseMenu = new wxMenu();
321 
322  // Text editor
323  AddMenuItem( browseMenu,
325  _( "Open Text E&ditor" ),
326  _( "Launch preferred text editor" ),
327  KiBitmap( editor_xpm ) );
328 
329  // View file
330  AddMenuItem( browseMenu,
332  _( "&Open Local File" ),
333  _( "Edit local file" ),
334  KiBitmap( browse_files_xpm ) );
335 
336  // Menu Preferences:
337  wxMenu* preferencesMenu = new wxMenu;
338 
339  // Path configuration edit dialog.
340  AddMenuItem( preferencesMenu,
342  _( "Configure Pa&ths" ),
343  _( "Edit path configuration environment variables" ),
344  KiBitmap( path_xpm ) );
345 
346  // Text editor
347  AddMenuItem( preferencesMenu,
349  _( "&Set Text Editor" ),
350  _( "Set your preferred text editor" ),
351  KiBitmap( editor_xpm ) );
352 
353  // PDF Viewer submenu:System browser or user defined checkbox
354  wxMenu* SubMenuPdfBrowserChoice = new wxMenu;
355 
356  // Default
357  AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_DEFAULT_PDF_BROWSER,
358  _( "System &Default PDF Viewer" ),
359  _( "Use system default PDF viewer" ),
360  KiBitmap( datasheet_xpm ),
361  wxITEM_CHECK );
362  SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
363  Pgm().UseSystemPdfBrowser() );
364 
365  // Favourite
366  AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER,
367  _( "&Favourite PDF Viewer" ),
368  _( "Use favourite PDF viewer" ),
369  KiBitmap( datasheet_xpm ),
370  wxITEM_CHECK );
371  SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER,
372  !Pgm().UseSystemPdfBrowser() );
373 
374  SubMenuPdfBrowserChoice->AppendSeparator();
375  // Append PDF Viewer submenu to preferences
376  AddMenuItem( SubMenuPdfBrowserChoice,
378  _( "Set &PDF Viewer" ),
379  _( "Set favourite PDF viewer" ),
380  KiBitmap( datasheet_xpm ) );
381 
382  // PDF viewer submenu
383  AddMenuItem( preferencesMenu, SubMenuPdfBrowserChoice, -1,
384  _( "&PDF Viewer" ),
385  _( "PDF viewer preferences" ),
386  KiBitmap( datasheet_xpm ) );
387 
388  // Hotkey submenu
389  preferencesMenu->AppendSeparator();
390  AddHotkeyConfigMenu( preferencesMenu );
391 
392  // Language submenu
393  preferencesMenu->AppendSeparator();
394  Pgm().AddMenuLanguageList( preferencesMenu );
395 
396  // Icons options submenu
397  preferencesMenu->AppendSeparator();
398  AddMenuIconsOptions( preferencesMenu );
399 
400  // Menu Tools:
401  wxMenu* toolsMenu = new wxMenu;
402 
403  msg = AddHotkeyName( _( "Edit Schematic" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA );
404  AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
405 
406  msg = AddHotkeyName( _( "Edit Schematic Symbols" ),
408  AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
409 
410  msg = AddHotkeyName( _( "Edit PCB Layout" ),
412  AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
413 
414  msg = AddHotkeyName( _( "Edit PCB Footprints" ),
416  AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
417 
418  msg = AddHotkeyName( _( "View Gerber Files" ),
420  AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
421 
422  msg = AddHotkeyName( _( "Convert Image" ),
424  AddMenuItem( toolsMenu, ID_TO_BITMAP_CONVERTER, msg,
425  _( "Bitmap2Component - Convert bitmap images to schematic\n"
426  "or PCB elements" ),
427  KiBitmap( bitmap2component_xpm ) );
428 
429  msg = AddHotkeyName( _( "Run PCB Calculator" ), kicad_Manager_Hokeys_Descr, HK_RUN_PCBCALCULATOR );
430  AddMenuItem( toolsMenu, ID_TO_PCB_CALCULATOR, msg,
431  _( "Pcb calculator - Calculator for components, track width, etc." ),
432  KiBitmap( calculator_xpm ) );
433 
434  msg = AddHotkeyName( _( "Edit Page Layout" ), kicad_Manager_Hokeys_Descr, HK_RUN_PLEDITOR );
435  AddMenuItem( toolsMenu, ID_TO_PL_EDITOR, msg,
436  _( "Pl editor - Worksheet layout editor" ),
437  KiBitmap( pagelayout_load_xpm ) );
438 
439  // Menu Help:
440  wxMenu* helpMenu = new wxMenu;
441 
442  // Contents
443  AddMenuItem( helpMenu, wxID_HELP,
444  _( "KiCad &Manual" ),
445  _( "Open KiCad user manual" ),
446  KiBitmap( online_help_xpm ) );
447 
448  AddMenuItem( helpMenu, wxID_INDEX,
449  _( "&Getting Started in KiCad" ),
450  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
451  KiBitmap( help_xpm ) );
452 
453  AddMenuItem( helpMenu,
455  _( "&List Hotkeys" ),
456  _( "Displays the current hotkeys list and corresponding commands" ),
457  KiBitmap( hotkeys_xpm ) );
458 
459  // Separator
460  helpMenu->AppendSeparator();
461 
462  // Get involved with KiCad
464  _( "Get &Involved" ),
465  _( "Contribute to KiCad (opens a web browser)" ),
466  KiBitmap( info_xpm ) );
467 
468  helpMenu->AppendSeparator();
469 
470  // About
471  AddMenuItem( helpMenu, wxID_ABOUT,
472  _( "&About KiCad" ),
473  _( "About KiCad" ),
474  KiBitmap( about_xpm ) );
475 
476  // Create the menubar and append all submenus
477  menuBar->Append( fileMenu, _( "&File" ) );
478  menuBar->Append( viewMenu, _( "&View" ) );
479  menuBar->Append( toolsMenu, _( "&Tools" ) );
480  menuBar->Append( browseMenu, _( "&Browse" ) );
481  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
482  menuBar->Append( helpMenu, _( "&Help" ) );
483 
484  menuBar->Thaw();
485 
486  // Associate the menu bar with the frame, if no previous menubar
487  if( GetMenuBar() == NULL )
488  SetMenuBar( menuBar );
489  else
490  menuBar->Refresh();
491 
492  // Add the hotkey to the "show hotkey list" menu, because we do not have
493  // a management of the keyboard keys in Kicad.
494  // So all hotheys should be added to the menubar
495  // Note Use wxMenuBar::SetLabel only after the menubar
496  // has been associated with a frame. (see wxWidgets doc)
497  msg = AddHotkeyName( menuBar->GetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST ),
499  menuBar->SetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg );
500 }
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:173
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
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:71
void AddHotkeyConfigMenu(wxMenu *aMenu)
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
Definition: basicframe.cpp:677
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:824
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().

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 FRAME_SCH, Kiway, KIWAY_PLAYER::OpenProjectFiles(), KIWAY::Player(), and IO_ERROR::What().

Referenced by OnRunEeschema().

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( 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
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:47
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 FRAME_PCB, Kiway, KIWAY_PLAYER::OpenProjectFiles(), KIWAY::Player(), and IO_ERROR::What().

Referenced by OnRunPcbNew().

380 {
381  KIWAY_PLAYER* frame;
382 
383  try
384  {
385  frame = Kiway.Player( FRAME_PCB, true );
386  }
387  catch( 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
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:47
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 280 of file wxstruct.h.

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick().

280 {};
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. ...
Definition: basicframe.cpp:320
#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().

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 209 of file basicframe.cpp.

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

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

210 {
211  m_autoSaveInterval = aInterval;
212 
213  if( m_autoSaveTimer->IsRunning() )
214  {
215  if( m_autoSaveInterval > 0 )
216  {
217  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
218  }
219  else
220  {
221  m_autoSaveTimer->Stop();
222  m_autoSaveState = false;
223  }
224  }
225 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:161
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
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, LIB_EDIT_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 466 of file wxstruct.h.

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

Definition at line 367 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ExportHotkeyConfigToFile(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), and LoadProject().

367 { m_mruPath = aPath; }
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:165
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(), and OnImportEagleFiles().

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:270
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:63
void EDA_BASE_FRAME::ShowChangedIcons ( )
virtualinherited

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

Definition at line 253 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by KIWAY::ShowChangedIcons().

254 {
255  ReCreateMenuBar();
256  GetMenuBar()->Refresh();
257 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:241
void EDA_BASE_FRAME::ShowChangedLanguage ( )
virtualinherited

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

Reimplemented in PCB_EDIT_FRAME, and GERBVIEW_FRAME.

Definition at line 246 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by KIWAY::SetLanguage(), GERBVIEW_FRAME::ShowChangedLanguage(), and PCB_EDIT_FRAME::ShowChangedLanguage().

247 {
248  ReCreateMenuBar();
249  GetMenuBar()->Refresh();
250 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:241
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().

190 {
191  return PgmTop().SysSearch();
192 }
SEARCH_STACK & SysSearch()
Definition: pgm_kicad.h:61
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
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 392 of file basicframe.cpp.

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

Referenced by SCH_EDIT_FRAME::ImportFile(), GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::LoadGerberFiles(), GERBVIEW_FRAME::LoadGerberJobFile(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), LoadProject(), OnCloseWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::SavePcbFile(), and GERBVIEW_FRAME::unarchiveFiles().

394 {
395  wxFileHistory* fileHistory = aFileHistory;
396 
397  if( !fileHistory )
398  fileHistory = &Kiface().GetFileHistory();
399 
400  fileHistory->AddFileToHistory( FullFileName );
401 }
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 528 of file hotkeys_basic.cpp.

References AddDelimiterString(), EDA_BASE_FRAME::config(), DEFAULT_HOTKEY_FILENAME_EXT, GetChars(), GetNewConfig(), HOTKEYS_CONFIG_KEY, KeyNameFromKeyCode(), EDA_HOTKEY_CONFIG::m_HK_InfoList, EDA_HOTKEY::m_InfoMsg, EDA_HOTKEY::m_KeyCode, EDA_HOTKEY_CONFIG::m_SectionTag, EDA_HOTKEY_CONFIG::m_Title, and TO_UTF8.

Referenced by EDA_BASE_FRAME::ExportHotkeyConfigToFile(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), HOTKEYS_EDITOR_DIALOG::TransferDataFromWindow(), and EDA_DRAW_FRAME::WriteHotkeyConfig().

530 {
531  wxString msg;
532  wxString keyname, infokey;
533 
534  msg = wxT( "$hotkey list\n" );
535 
536  // Print the current hotkey list
537  EDA_HOTKEY** list;
538 
539  for( ; aDescList->m_HK_InfoList != nullptr; aDescList++ )
540  {
541  if( aDescList->m_Title )
542  {
543  msg += wxT( "# " );
544  msg += *aDescList->m_Title;
545  msg += wxT( "\n" );
546  }
547 
548  msg += *aDescList->m_SectionTag;
549  msg += wxT( "\n" );
550 
551  list = aDescList->m_HK_InfoList;
552 
553  for( ; *list != nullptr; list++ )
554  {
555  EDA_HOTKEY* hk_decr = *list;
556  msg += wxT( "shortcut " );
557  keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
558  AddDelimiterString( keyname );
559  infokey = hk_decr->m_InfoMsg;
560  AddDelimiterString( infokey );
561  msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
562  }
563  }
564 
565  msg += wxT( "$Endlist\n" );
566 
567  if( aFullFileName )
568  {
569  FILE* file = wxFopen( *aFullFileName, wxT( "wt" ) );
570 
571  if( file )
572  {
573  fputs( TO_UTF8( msg ), file );
574  fclose( file );
575  }
576  else
577  {
578  msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
579  return 0;
580  }
581  }
582  else
583  {
584  wxFileName fn( GetName() );
585  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
586  std::unique_ptr<wxConfigBase> config( GetNewConfig( fn.GetFullPath() ) );
587  config->Write( HOTKEYS_CONFIG_KEY, msg );
588  }
589 
590  return 1;
591 }
EDA_HOTKEY ** m_HK_InfoList
Definition: hotkeys_basic.h:91
wxConfigBase * GetNewConfig(const wxString &aProgName)
Function GetNewConfig.
Definition: common.cpp:205
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:365
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
#define HOTKEYS_CONFIG_KEY
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 * m_SectionTag
Definition: hotkeys_basic.h:90
wxString m_InfoMsg
Definition: hotkeys_basic.h:64
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:57
wxString * m_Title
Definition: hotkeys_basic.h:92
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

Member Data Documentation

wxString EDA_BASE_FRAME::m_AboutTitle
protectedinherited

Name of program displayed in About.

Definition at line 147 of file wxstruct.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 142 of file wxstruct.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 152 of file wxstruct.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 138 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

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 163 of file wxstruct.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: