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.
class LAUNCHER_PANEL
Definition: kicad.h:320
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: mainframe.cpp:535
wxAuiManager m_auimgr
int GetPanelHeight() const
Specialization of the wxAuiPaneInfo class for KiCad panels.
LAUNCHER_PANEL * m_Launcher
Definition: kicad.h:305
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
class TREE_PROJECT_FRAME Window to display the tree files
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:310
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void ReCreateMenuBar() override
(Re)Create the menubar
int GetPanelWidth() const
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
wxConfigBase * config() override
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: mainframe.cpp:127
bool m_active_project
Definition: kicad.h:314
#define KICAD_MANAGER_FRAME_NAME
Definition: kicad.h:40
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME ( )

Definition at line 121 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

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

Member Function Documentation

void EDA_BASE_FRAME::AddMenuIconsOptions ( wxMenu *  MasterMenu)
inherited

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

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

Definition at line 693 of file eda_base_frame.cpp.

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

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

694 {
695  wxMenu* menu = NULL;
696  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
697 
698  if( item ) // This menu exists, do nothing
699  return;
700 
701  menu = new wxMenu;
702 
703  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
704  _( "Icons in Menus" ), wxEmptyString,
705  wxITEM_CHECK ) );
706  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
707 
708  AddMenuItem( MasterMenu, menu,
710  _( "Icons Options" ),
711  _( "Select show icons in menus and icons sizes" ),
712  KiBitmap( icon_xpm ) );
713 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:174
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp: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 598 of file eda_base_frame.cpp.

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

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

600 {
601  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
602  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
603 
604  wxFileName autoSaveFileName = aFileName;
605 
606  // Check for auto save file.
607  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
608 
609  wxLogTrace( traceAutoSave,
610  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
611 
612  if( !autoSaveFileName.FileExists() )
613  return;
614 
615  wxString msg = wxString::Format( _(
616  "Well this is potentially embarrassing!\n"
617  "It appears that the last time you were editing the file\n"
618  "\"%s\"\n"
619  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
620  GetChars( aFileName.GetFullName() )
621  );
622 
623  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
624 
625  // Make a backup of the current file, delete the file, and rename the auto save file to
626  // the file name.
627  if( response == wxYES )
628  {
629  // Get the backup file name.
630  wxFileName backupFileName = aFileName;
631  backupFileName.SetExt( aBackupFileExtension );
632 
633  // If an old backup file exists, delete it. If an old copy of the file exists, rename
634  // it to the backup file name
635  if( aFileName.FileExists() )
636  {
637  // Remove the old file backup file.
638  if( backupFileName.FileExists() )
639  wxRemoveFile( backupFileName.GetFullPath() );
640 
641  // Rename the old file to the backup file name.
642  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
643  {
644  msg.Printf( _( "Could not create backup file \"%s\"" ),
645  GetChars( backupFileName.GetFullPath() ) );
646  wxMessageBox( msg );
647  }
648  }
649 
650  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
651  {
652  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
653  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
654  }
655  }
656  else
657  {
658  wxLogTrace( traceAutoSave,
659  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
660 
661  // Remove the auto save file when using the previous file as is.
662  wxRemoveFile( autoSaveFileName.GetFullPath() );
663  }
664 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void KICAD_MANAGER_FRAME::ClearMsg ( )

Erase the text panel.

Definition at line 529 of file mainframe.cpp.

References m_MessagesBox.

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

530 {
531  m_MessagesBox->Clear();
532 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
wxConfigBase * KICAD_MANAGER_FRAME::config ( )
overrideprivatevirtual

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 127 of file mainframe.cpp.

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

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

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

References EDA_BASE_FRAME::m_configFrameName.

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

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

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

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

Parameters
aProjectFileNameis the absolute path of the project file name.

Definition at line 108 of file prjconfig.cpp.

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

Referenced by OnCreateProjectFromTemplate(), and OnNewProject().

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

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

252 {
253  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
254 }
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(), and Prj().

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

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)
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
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 219 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

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

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

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

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

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

Definition at line 420 of file eda_base_frame.cpp.

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

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

422 {
423  wxFileHistory* fileHistory = aFileHistory;
424 
425  if( !fileHistory )
426  fileHistory = &Kiface().GetFileHistory();
427 
428  int baseId = fileHistory->GetBaseId();
429 
430  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
431 
432  unsigned i = cmdId - baseId;
433 
434  if( i < fileHistory->GetCount() )
435  {
436  wxString fn = fileHistory->GetHistoryFile( i );
437 
438  if( wxFileName::FileExists( fn ) )
439  return fn;
440  else
441  {
442  wxString msg = wxString::Format(
443  _( "File \"%s\" was not found." ),
444  GetChars( fn ) );
445 
446  wxMessageBox( msg );
447 
448  fileHistory->RemoveFileFromHistory( i );
449  }
450  }
451 
452  return wxEmptyString;
453 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:123
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
size_t i
Definition: json11.cpp:597
virtual int EDA_BASE_FRAME::GetIconScale ( )
inlinevirtualinherited

Function GetIconScale.

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

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

Definition at line 453 of file eda_base_frame.h.

Referenced by get_scale_factor(), and FOOTPRINT_EDIT_FRAME::GetIconScale().

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

Definition at line 547 of file eda_base_frame.cpp.

References ShowAboutDialog().

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

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

Definition at line 534 of file eda_base_frame.cpp.

References URL_GET_INVOLVED.

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

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

Definition at line 456 of file eda_base_frame.cpp.

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

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

457 {
458  const SEARCH_STACK& search = sys_search();
459 
460  /* We have to get document for beginners,
461  * or the full specific doc
462  * if event id is wxID_INDEX, we want the document for beginners.
463  * else the specific doc file (its name is in Kiface().GetHelpFileName())
464  * The document for beginners is the same for all KiCad utilities
465  */
466  if( event.GetId() == wxID_INDEX )
467  {
468  // List of possible names for Getting Started in KiCad
469  const wxChar* names[2] = {
470  wxT( "getting_started_in_kicad" ),
471  wxT( "Getting_Started_in_KiCad" )
472  };
473 
474  wxString helpFile;
475  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
476  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
477  for( unsigned ii = 0; ii < DIM( names ); ii++ )
478  {
479  helpFile = SearchHelpFileFullPath( search, names[ii] );
480 
481  if( !helpFile.IsEmpty() )
482  break;
483  }
484 
485  if( !helpFile )
486  {
487  wxString msg = wxString::Format( _(
488  "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
489  wxMessageBox( msg );
490  }
491  else
492  {
493  GetAssociatedDocument( this, helpFile );
494  }
495 
496  return;
497  }
498 
499  wxString base_name = help_name();
500  wxString helpFile = SearchHelpFileFullPath( search, base_name );
501 
502  if( !helpFile )
503  {
504  wxString msg = wxString::Format( _(
505  "Help file \"%s\" could not be found." ),
506  GetChars( base_name )
507  );
508  wxMessageBox( msg );
509  }
510  else
511  {
512  GetAssociatedDocument( this, helpFile );
513  }
514 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
virtual const SEARCH_STACK & sys_search()
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSStack, const wxString &aBaseName)
Function SearchHelpFileFullPath returns the help file&#39;s full path.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
virtual wxString help_name()
wxString KICAD_MANAGER_FRAME::help_name ( )
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 195 of file mainframe.cpp.

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

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

196 {
197  return PgmTop().GetHelpFileName();
198 }
PGM_KICAD & PgmTop()
Definition: kicad.cpp: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, and EDA_FILE_SELECTOR().

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

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)
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfigFile Read an old configuration file (&ltfile&gt.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
virtual bool EDA_BASE_FRAME::isAutoSaveRequired ( ) const
inlineprotectedvirtualinherited

Function autoSaveRequired returns the auto save status of the application.

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

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 175 of file eda_base_frame.h.

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

Referenced by EDA_BASE_FRAME::ProcessEvent().

175 { return false; }
bool EDA_BASE_FRAME::IsWritable ( const wxFileName &  aFileName)
inherited

Function IsWritable checks if aFileName can be written.

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

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

Definition at line 554 of file eda_base_frame.cpp.

References GetChars().

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

555 {
556  wxString msg;
557  wxFileName fn = aFileName;
558 
559  // Check for absence of a file path with a file name. Unfortunately KiCad
560  // uses paths relative to the current project path without the ./ part which
561  // confuses wxFileName. Making the file name path absolute may be less than
562  // elegant but it solves the problem.
563  if( fn.GetPath().IsEmpty() && fn.HasName() )
564  fn.MakeAbsolute();
565 
566  wxCHECK_MSG( fn.IsOk(), false,
567  wxT( "File name object is invalid. Bad programmer!" ) );
568  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
569  wxT( "File name object path <" ) + fn.GetFullPath() +
570  wxT( "> is not set. Bad programmer!" ) );
571 
572  if( fn.IsDir() && !fn.IsDirWritable() )
573  {
574  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
575  GetChars( fn.GetPath() ) );
576  }
577  else if( !fn.FileExists() && !fn.IsDirWritable() )
578  {
579  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
580  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
581  }
582  else if( fn.FileExists() && !fn.IsFileWritable() )
583  {
584  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
585  GetChars( fn.GetFullPath() ) );
586  }
587 
588  if( !msg.IsEmpty() )
589  {
590  wxMessageBox( msg );
591  return false;
592  }
593 
594  return true;
595 }
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void KICAD_MANAGER_FRAME::language_change ( wxCommandEvent &  event)
private

Definition at line 522 of file mainframe.cpp.

References Kiway, and KIWAY::SetLanguage().

523 {
524  int id = event.GetId();
525  Kiway.SetLanguage( id );
526 }
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs...
Definition: kiway.cpp:395
KIWAY Kiway
void KICAD_MANAGER_FRAME::LoadProject ( const wxFileName &  aProjectFileName)

Definition at line 61 of file prjconfig.cpp.

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

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

62 {
63  // The project file should be valid by the time we get here or something has gone wrong.
64  if( !aProjectFileName.Exists() )
65  return;
66 
67  // Any open KIFACE's must be closed if they are not part of the new project.
68  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
69  // User is prompted here to close those KIWAY_PLAYERs:
70  if( !Kiway.PlayersClose( false ) )
71  return;
72 
73  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
74 
75  // Save the project file for the currently loaded project.
76  if( m_active_project )
78 
79  m_active_project = true;
80  ClearMsg();
81  SetProjectFileName( aProjectFileName.GetFullPath() );
83 
84  wxString title = GetTitle() + " " + aProjectFileName.GetFullPath();
85 
86  if( !aProjectFileName.IsDirWritable() )
87  title += _( " [Read Only]" );
88  else
89  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
90 
91  SetTitle( title );
92 
93  UpdateFileHistory( aProjectFileName.GetFullPath(), &PgmTop().GetFileHistory() );
94 
96 
97  // Rebuild the list of watched paths.
98  // however this is possible only when the main loop event handler is running,
99  // so we use it to run the rebuild function.
100  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
101 
102  wxPostEvent( this, cmd );
103 
104  PrintPrjInfo();
105 }
VTBL_ENTRY bool PlayersClose(bool doForce)
Function PlayersClose calls the KIWAY_PLAYER::Close( bool force ) function on all the windows and if ...
Definition: kiway.cpp:373
void SetMruPath(const wxString &aPath)
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:270
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
void ReCreateTreePrj()
Create or modify the tree showing project file names.
PGM_KICAD & PgmTop()
Definition: kicad.cpp: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.
void KICAD_MANAGER_FRAME::OnArchiveFiles ( wxCommandEvent &  event)

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

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

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

Function onAutoSaveTimer handles the auto save timer event.

Definition at line 244 of file eda_base_frame.cpp.

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

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

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

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 451 of file mainframe.cpp.

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

452 {
455 }
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
VTBL_ENTRY void ShowChangedIcons()
Function ShowChangedIcons Calls ShowChangedIcons() on all KIWAY_PLAYERs.
Definition: kiway.cpp:431
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnChangeWatchedPaths ( wxCommandEvent &  aEvent)

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

Definition at line 1090 of file tree_project_frame.cpp.

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

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

Definition at line 216 of file mainframe.cpp.

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

217 {
218  if( Kiway.PlayersClose( false ) )
219  {
220  int px, py;
221 
222  if( !GetProjectFileName().empty() )
224 
225  if( !IsIconized() ) // save main frame position and size
226  {
227  GetPosition( &px, &py );
228  m_FramePos.x = px;
229  m_FramePos.y = py;
230 
231  GetSize( &px, &py );
232  m_FrameSize.x = px;
233  m_FrameSize.y = py;
234  }
235 
236  Event.SetCanVeto( true );
237 
238  m_LeftWin->Show( false );
239 
240  Destroy();
241  }
242 }
VTBL_ENTRY bool PlayersClose(bool doForce)
Function PlayersClose calls the KIWAY_PLAYER::Close( bool force ) function on all the windows and if ...
Definition: kiway.cpp:373
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnConfigurePaths ( wxCommandEvent &  aEvent)

Definition at line 589 of file mainframe.cpp.

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

590 {
591  Pgm().ConfigurePaths( this );
592 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
VTBL_ENTRY void ConfigurePaths(wxWindow *aParent=NULL)
Function ConfigurePaths.
Definition: pgm_base.cpp:912
void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate ( wxCommandEvent &  event)

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

and open this new projrct as working project

Definition at line 271 of file prjconfig.cpp.

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

272 {
273  wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
274  wxString title = _( "New Project Folder" );
275  wxDirDialog dlg( this, title, default_dir );
276 
277  if( dlg.ShowModal() == wxID_CANCEL )
278  return;
279 
280  // Builds the project .pro filename, from the new project folder name
281  wxFileName fn;
282  fn.AssignDir( dlg.GetPath() );
283  fn.SetName( dlg.GetPath().AfterLast( SEP() ) );
284  fn.SetExt( wxT( "pro" ) );
285 
286  wxChar sep[2] = { SEP(), 0 }; // nul terminated separator wxChar string.
287 
288  ClearMsg();
289 
291 
292  wxFileName templatePath;
293  wxString envStr;
294 
295 #ifndef __WXMAC__
296  wxGetEnv( wxT( "KICAD" ), &envStr );
297 
298  // Add a new tab for system templates
299  if( !envStr.empty() )
300  {
301  // user may or may not have including terminating separator.
302  if( !envStr.EndsWith( sep ) )
303  envStr += sep;
304 
305  templatePath = envStr + wxT( "template" ) + sep;
306  }
307  else
308  {
309  // The standard path should be in the share directory for kicad. As
310  // it is normal on Windows to only have the share directory and not
311  // the kicad sub-directory we fall back to that if the directory
312  // doesn't exist
313  templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) +
314  sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "kicad" ) +
315  sep + wxT( "template" ) + sep;
316 
317  if( !wxDirExists( templatePath.GetFullPath() ) )
318  {
319  templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + sep +
320  wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "template" ) + sep;
321  }
322  }
323 #else
324  // Use what is provided in the bundle data dir
325  templatePath = GetOSXKicadDataDir() + sep + wxT( "template" );
326 #endif
327 
328  ps->AddTemplatesPage( _( "System Templates" ), templatePath );
329 
330  // Add a new tab for user templates
331  wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() + sep + wxT( "kicad" ) +
332  sep + wxT( "template" ) + sep;
333 
334  ps->AddTemplatesPage( _( "User Templates" ), userPath );
335 
336  // Check to see if a custom template location is available and setup a
337  // new selection tab if there is.
338  envStr.clear();
339  wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr );
340 
341  if( !envStr.empty() )
342  {
343  if( !envStr.EndsWith( sep ) )
344  envStr += sep;
345 
346  wxFileName envPath = envStr;
347 
348  ps->AddTemplatesPage( _( "Portable Templates" ), envPath );
349  }
350 
351  // Show the project template selector dialog
352  if( ps->ShowModal() != wxID_OK )
353  return;
354 
355  if( ps->GetSelectedTemplate() == NULL )
356  {
357  wxMessageBox( _( "No project template was selected. Cannot generate new project." ),
358  _( "Error" ),
359  wxOK | wxICON_ERROR,
360  this );
361 
362  return;
363  }
364 
365  // Make sure the user has write permissions to the base path.
366  wxFileName prjPath = fn;
367 
368  while( !prjPath.DirExists() )
369  prjPath.RemoveLastDir();
370 
371  if( !prjPath.IsDirWritable() )
372  {
373  wxString msg;
374 
375  msg.Printf( _( "Cannot write to folder \"%s\"." ), prjPath.GetPath() );
376  wxMessageDialog msgDlg( this, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
377  msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder "
378  "and try again." ) );
379  msgDlg.ShowModal();
380  return;
381  }
382 
383  // Make sure we are not overwriting anything in the destination folder.
384  std::vector< wxFileName > destFiles;
385 
386  if( ps->GetSelectedTemplate()->GetDestinationFiles( fn, destFiles ) )
387  {
388  std::vector< wxFileName > overwrittenFiles;
389 
390  for( const auto& file : destFiles )
391  {
392  if( file.FileExists() )
393  overwrittenFiles.push_back( file );
394  }
395 
396  if( !overwrittenFiles.empty() )
397  {
398  wxString extendedMsg = _( "Overwriting files:" ) + "\n";
399 
400  for( const auto& file : overwrittenFiles )
401  {
402  extendedMsg += "\n" + file.GetFullName();
403  }
404 
405  wxMessageDialog owDlg( this,
406  _( "Are you sure you want to overwrite files in "
407  "the destination folder?" ),
408  _( "Warning!" ),
409  wxYES_NO | wxICON_QUESTION | wxCENTER );
410  owDlg.SetExtendedMessage( extendedMsg );
411  owDlg.SetYesNoLabels( _( "Overwrite" ), _( "Do Not Overwrite" ) );
412 
413  if( owDlg.ShowModal() == wxID_NO )
414  return;
415  }
416  }
417 
418  wxString errorMsg;
419 
420  // The selected template widget contains the template we're attempting to use to
421  // create a project
422  if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
423  {
424  wxMessageDialog createDlg( this,
425  _( "A problem occurred creating new project from template!" ),
426  _( "Template Error" ),
427  wxOK | wxICON_ERROR );
428 
429  if( !errorMsg.empty() )
430  createDlg.SetExtendedMessage( errorMsg );
431 
432  createDlg.ShowModal();
433  return;
434  }
435 
436  CreateNewProject( fn.GetFullPath() );
437  LoadProject( fn );
438 }
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.
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
void KICAD_MANAGER_FRAME::OnImportEagleFiles ( wxCommandEvent &  event)

Open dialog to import Eagle schematic and board files.

Definition at line 53 of file import_project.cpp.

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

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

Load an exiting project (.pro) file.

Definition at line 165 of file prjconfig.cpp.

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

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

Definition at line 219 of file prjconfig.cpp.

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

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

Definition at line 495 of file mainframe.cpp.

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

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

Referenced by OnUnarchiveFiles().

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

Definition at line 458 of file mainframe.cpp.

References BITMAPCONVERTER_EXE, and Execute().

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

Definition at line 343 of file mainframe.cpp.

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

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

Definition at line 477 of file mainframe.cpp.

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

478 {
479  // Gerbview is called without any file to open, because we do not know
480  // the list and the name of files to open (if any...).
481  // however we run it in the path of the project
482  Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() );
483 }
PROJECT & Prj()
Definition: kicad.cpp: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 err, FRAME_PCB_MODULE_EDITOR, Kiway, KIWAY::Player(), and IO_ERROR::What().

424 {
426 
427  if( !frame )
428  {
429  try
430  {
431  frame = Kiway.Player( FRAME_PCB_MODULE_EDITOR, true );
432  }
433  catch( IO_ERROR err )
434  {
435  wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
436  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
437  return;
438  }
439 
440  frame->Show( true );
441  }
442 
443  // On Windows, Raise() does not bring the window on screen, when iconized
444  if( frame->IsIconized() )
445  frame->Iconize( false );
446 
447  frame->Raise();
448 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h: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 err, FRAME_SCH_LIB_EDITOR, Kiway, KIWAY::Player(), and IO_ERROR::What().

352 {
353  KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, false );
354 
355  if( !frame )
356  {
357  try
358  {
359  frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, true );
360  }
361  catch( IO_ERROR err )
362  {
363  wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
364  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
365  return;
366  }
367 
368  frame->Show( true );
369  }
370 
371  // On Windows, Raise() does not bring the window on screen, when iconized
372  if( frame->IsIconized() )
373  frame->Iconize( false );
374 
375  frame->Raise();
376 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnSaveProject ( wxCommandEvent &  event)

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

Definition at line 441 of file prjconfig.cpp.

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

442 {
443  if( !wxIsWritable( GetProjectFileName() ) )
444  return;
445 
447 }
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:55
void EDA_BASE_FRAME::OnSelectPreferredEditor ( wxCommandEvent &  event)
virtualinherited

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

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

Definition at line 517 of file eda_base_frame.cpp.

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

Referenced by EDA_BASE_FRAME::SaveProjectSettings().

518 {
519  // Ask for the current editor and instruct GetEditorName() to not show
520  // unless we pass false as argument.
521  wxString editorname = Pgm().GetEditorName( false );
522 
523  // Ask the user to select a new editor, but suggest the current one as the default.
524  editorname = Pgm().AskUserForPreferredEditor( editorname );
525 
526  // If we have a new editor name request it to be copied to m_editor_name and saved
527  // to the preferences file. If the user cancelled the dialog then the previous
528  // value will be retained.
529  if( !editorname.IsEmpty() )
530  Pgm().SetEditorName( editorname );
531 }
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:55
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
Definition: pgm_base.h:179
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:42
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
void KICAD_MANAGER_FRAME::OnSize ( wxSizeEvent &  event)

Definition at line 207 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

208 {
209  if( m_auimgr.GetManagedWindow() )
210  m_auimgr.Update();
211 
212  event.Skip();
213 }
wxAuiManager m_auimgr
void KICAD_MANAGER_FRAME::OnUnarchiveFiles ( wxCommandEvent &  event)

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

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

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

Definition at line 37 of file preferences.cpp.

References Pgm().

38 {
39  event.Check( Pgm().UseSystemPdfBrowser() );
40 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp: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 450 of file prjconfig.cpp.

References m_active_project.

451 {
452  event.Enable( m_active_project );
453 }
bool m_active_project
Definition: kicad.h:314
const wxString KICAD_MANAGER_FRAME::PcbFileName ( )

Definition at line 163 of file mainframe.cpp.

References GetProjectFileName(), and PcbFileExtension.

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

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

Definition at line 173 of file mainframe.cpp.

References GetProjectFileName(), and LegacyPcbFileExtension.

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

174 {
175  wxFileName fn( GetProjectFileName() );
176 
177  fn.SetExt( LegacyPcbFileExtension );
178 
179  return fn.GetFullPath();
180 }
const wxString LegacyPcbFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
bool EDA_BASE_FRAME::PostCommandMenuEvent ( int  evt_type)
inherited

Function PostCommandMenuEvent.

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

Definition at line 667 of file eda_base_frame.cpp.

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

668 {
669  if( evt_type != 0 )
670  {
671  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
672  evt.SetEventObject( this );
673  evt.SetId( evt_type );
674  wxPostEvent( this, evt );
675  return true;
676  }
677 
678  return false;
679 }
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 186 of file eda_base_frame.cpp.

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

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

187 {
188 #ifdef __WXMAC__
189  // Apple in its infinite wisdom will raise a disabled window before even passing
190  // us the event, so we have no way to stop it. Instead, we have to catch an
191  // improperly ordered disabled window and quasi-modal dialog here and reorder
192  // them.
193  if( !IsEnabled() && IsActive() )
194  {
195  wxWindow* dlg = findQuasiModalDialog();
196  if( dlg )
197  dlg->Raise();
198  }
199 #endif
200 
201  if( !wxFrame::ProcessEvent( aEvent ) )
202  return false;
203 
204  if( IsShown() && m_hasAutoSave && IsActive() &&
206  {
207  if( !m_autoSaveState )
208  {
209  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
210  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
211  m_autoSaveState = true;
212  }
213  else if( m_autoSaveTimer->IsRunning() )
214  {
215  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
216  m_autoSaveTimer->Stop();
217  m_autoSaveState = false;
218  }
219  }
220 
221  return true;
222 }
bool m_autoSaveState
Flag to indicate the last auto save state.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
wxWindow * findQuasiModalDialog()
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
int m_autoSaveInterval
The auto save interval time in seconds.
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.

References ReadHotkeyConfig().

Referenced by EDA_BASE_FRAME::SaveProjectSettings().

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::SaveProjectSettings().

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 497 of file kicad/menubar.cpp.

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

Referenced by KICAD_MANAGER_FRAME().

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

(Re)Create the menubar

Reimplemented from EDA_BASE_FRAME.

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

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

Referenced by KICAD_MANAGER_FRAME().

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

Definition at line 183 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

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

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

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

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

Definition at line 296 of file mainframe.cpp.

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

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

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

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

380 {
381  KIWAY_PLAYER* frame;
382 
383  try
384  {
385  frame = Kiway.Player( FRAME_PCB, true );
386  }
387  catch( IO_ERROR err )
388  {
389  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
390  wxOK | wxICON_ERROR, this );
391  return;
392  }
393 
394  // a pcb frame can be already existing, but not yet used.
395  // this is the case when running the footprint editor, or the footprint viewer first
396  // if the frame is not visible, the board is not yet loaded
397  if( !frame->IsVisible() )
398  {
399  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
400  frame->Show( true );
401  }
402 
403  // On Windows, Raise() does not bring the window on screen, when iconized
404  if( frame->IsIconized() )
405  frame->Iconize( false );
406 
407  frame->Raise();
408 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
VTBL_ENTRY bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList...
Definition: kiway_player.h:170
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
string & err
Definition: json11.cpp:598
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h: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 274 of file eda_base_frame.h.

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

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

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

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

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 542 of file mainframe.cpp.

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

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

Definition at line 153 of file mainframe.cpp.

References GetProjectFileName(), and SchematicFileExtension.

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

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

Definition at line 225 of file eda_base_frame.cpp.

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

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

226 {
227  m_autoSaveInterval = aInterval;
228 
229  if( m_autoSaveTimer->IsRunning() )
230  {
231  if( m_autoSaveInterval > 0 )
232  {
233  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
234  }
235  else
236  {
237  m_autoSaveTimer->Stop();
238  m_autoSaveState = false;
239  }
240  }
241 }
bool m_autoSaveState
Flag to indicate the last auto save state.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
int m_autoSaveInterval
The auto save interval time in seconds.
virtual void EDA_BASE_FRAME::SetIconScale ( int  aScale)
inlinevirtualinherited

Function SetIconScale.

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

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, GERBVIEW_FRAME, and LIB_EDIT_FRAME.

Definition at line 460 of file eda_base_frame.h.

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

Definition at line 361 of file eda_base_frame.h.

Referenced by LoadProject().

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

Definition at line 135 of file mainframe.cpp.

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

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

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

References EDA_BASE_FRAME::ReCreateMenuBar().

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

270 {
271  ReCreateMenuBar();
272  GetMenuBar()->Refresh();
273 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
void EDA_BASE_FRAME::ShowChangedLanguage ( )
virtualinherited

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

Reimplemented in PCB_EDIT_FRAME, GERBVIEW_FRAME, PCB_BASE_FRAME, and CVPCB_MAINFRAME.

Definition at line 262 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

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

263 {
264  ReCreateMenuBar();
265  GetMenuBar()->Refresh();
266 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
const SEARCH_STACK & KICAD_MANAGER_FRAME::sys_search ( )
overrideprivatevirtual

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 189 of file mainframe.cpp.

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

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

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

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

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

410 {
411  wxFileHistory* fileHistory = aFileHistory;
412 
413  if( !fileHistory )
414  fileHistory = &Kiface().GetFileHistory();
415 
416  fileHistory->AddFileToHistory( FullFileName );
417 }
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(), 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::SaveProjectSettings(), 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:206
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
#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 141 of file eda_base_frame.h.

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

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

Definition at line 136 of file eda_base_frame.h.

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

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

Definition at line 146 of file eda_base_frame.h.

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

FRAME_T EDA_BASE_FRAME::m_Ident
protectedinherited

Id Type (pcb, schematic, library..)

Definition at line 132 of file eda_base_frame.h.

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

LAUNCHER_PANEL* KICAD_MANAGER_FRAME::m_Launcher
private

Definition at line 305 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME().

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

Definition at line 309 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), and LoadSettings().

wxAuiToolBar* EDA_BASE_FRAME::m_mainToolBar
protectedinherited

Standard horizontal Toolbar.

Definition at line 139 of file eda_base_frame.h.

Referenced by PCB_EDIT_FRAME::createPopUpMenuForFpPads(), EDA_BASE_FRAME::EDA_BASE_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), EDA_DRAW_FRAME::GetToolbarTool(), EDA_DRAW_FRAME::GetToolToggled(), KICAD_MANAGER_FRAME(), LIB_EDIT_FRAME::LIB_EDIT_FRAME(), LIB_VIEW_FRAME::LIB_VIEW_FRAME(), FOOTPRINT_VIEWER_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnPlaceOrRouteFootprints(), PCB_EDIT_FRAME::OnRightClick(), LIB_EDIT_FRAME::OnUpdateDeMorganConvert(), LIB_EDIT_FRAME::OnUpdateDeMorganNormal(), FOOTPRINT_EDIT_FRAME::OnUpdateSelectTool(), LIB_EDIT_FRAME::OnUpdateSelectTool(), SCH_EDIT_FRAME::OnUpdateSelectTool(), PCB_EDIT_FRAME::OnUpdateVerticalToolbar(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), PCB_EDIT_FRAME::PrepareLayerIndicator(), LIB_EDIT_FRAME::Process_Special_Functions(), RecreateBaseHToolbar(), DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar(), LIB_VIEW_FRAME::ReCreateHToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar(), PL_EDITOR_FRAME::ReCreateHToolbar(), FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar(), GERBVIEW_FRAME::ReCreateHToolbar(), SCH_EDIT_FRAME::ReCreateHToolbar(), LIB_EDIT_FRAME::ReCreateHToolbar(), PCB_EDIT_FRAME::ReCreateHToolbar(), PCB_EDIT_FRAME::ReCreateLayerBox(), EDA_3D_VIEWER::ReCreateMainToolbar(), GERBVIEW_FRAME::ReCreateOptToolbar(), GERBVIEW_FRAME::ReCreateVToolbar(), SCH_EDIT_FRAME::RedrawActiveWindow(), and EDA_3D_VIEWER::RenderEngineChanged().

EDA_HOTKEY_CONFIG* KICAD_MANAGER_FRAME::m_manager_Hokeys_Descr
private

Definition at line 310 of file kicad.h.

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

wxTextCtrl* KICAD_MANAGER_FRAME::m_MessagesBox
private

Definition at line 306 of file kicad.h.

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

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 157 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::LoadSettings().

wxAuiToolBar* KICAD_MANAGER_FRAME::m_VToolBar
private

Definition at line 307 of file kicad.h.


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