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...
 
bool Enable (bool enable) override
 
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...
 

Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private Member Functions

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

Private Attributes

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

Detailed Description

The main KiCad project manager frame.

It is not a KIWAY_PLAYER.

Definition at line 137 of file kicad.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file mainframe.cpp.

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

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

Definition at line 121 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

122 {
123  m_auimgr.UnInit();
124 }
wxAuiManager m_auimgr
Definition: wxstruct.h:149

Member Function Documentation

void EDA_BASE_FRAME::AddMenuIconsOptions ( wxMenu *  MasterMenu)
inherited

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

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

Definition at line 692 of file basicframe.cpp.

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

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

693 {
694  wxMenu* menu = NULL;
695  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
696 
697  if( item ) // This menu exists, do nothing
698  return;
699 
700  menu = new wxMenu;
701 
702  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
703  _( "Icons in Menus" ), wxEmptyString,
704  wxITEM_CHECK ) );
705  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
706 
707  AddMenuItem( MasterMenu, menu,
709  _( "Icons Options" ),
710  _( "Select show icons in menus and icons sizes" ),
711  KiBitmap( icon_xpm ) );
712 }
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:55
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:36
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 597 of file basicframe.cpp.

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

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

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

Erase the text panel.

Definition at line 523 of file mainframe.cpp.

References m_MessagesBox.

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

524 {
525  m_MessagesBox->Clear();
526 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
wxConfigBase * KICAD_MANAGER_FRAME::config ( )
overrideprivatevirtual

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 127 of file mainframe.cpp.

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

Referenced by KICAD_MANAGER_FRAME().

128 {
129  wxConfigBase* ret = PgmTop().PgmSettings();
130  wxASSERT( ret );
131  return ret;
132 }
wxConfigBase * PgmSettings()
Definition: pgm_kicad.h:59
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited

Function ConfigBaseName.

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

Definition at line 268 of file wxstruct.h.

References EDA_BASE_FRAME::m_configFrameName.

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

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

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

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

Parameters
aProjectFileNameis the absolute path of the project file name.

Definition at line 108 of file prjconfig.cpp.

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

Referenced by OnCreateProjectFromTemplate(), and OnNewProject().

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

Referenced by EDA_BASE_FRAME::onAutoSaveTimer().

251 {
252  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
253 }
bool EDA_BASE_FRAME::Enable ( bool  enable)
overrideinherited

Definition at line 211 of file basicframe.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), and KIWAY_PLAYER::ShowModal().

212 {
213  // so we can do logging of this state change:
214 
215 #if defined(DEBUG)
216  const char* type_id = typeid( *this ).name();
217  printf( "wxFrame %-28s: %s\n", type_id, enable ? "enabled" : "disabled" );
218 #endif
219 
220  return wxFrame::Enable( enable );
221 }
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 768 of file hotkeys_basic.cpp.

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

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

770 {
771  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
772  wxString mask = wxT( "*." ) + ext;
773 
774 #if 0
775  wxString path = wxPathOnly( Prj().GetProjectFullName() );
776 #else
777  wxString path = GetMruPath();
778 #endif
779  wxFileName fn( aDefaultShortname );
780  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
781 
782  wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ),
783  path,
784  fn.GetFullPath(),
785  ext,
786  mask,
787  this,
788  wxFD_SAVE,
789  true );
790 
791  if( filename.IsEmpty() )
792  return;
793 
794  WriteHotkeyConfig( aDescList, &filename );
795  SetMruPath( wxFileName( filename ).GetPath() );
796 }
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:369
PROJECT & Prj()
Definition: kicad.cpp:270
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:82
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
wxString GetMruPath() const
Definition: wxstruct.h:371
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 227 of file wxstruct.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

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

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

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

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

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

Definition at line 419 of file basicframe.cpp.

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

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

421 {
422  wxFileHistory* fileHistory = aFileHistory;
423 
424  if( !fileHistory )
425  fileHistory = &Kiface().GetFileHistory();
426 
427  int baseId = fileHistory->GetBaseId();
428 
429  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
430 
431  unsigned i = cmdId - baseId;
432 
433  if( i < fileHistory->GetCount() )
434  {
435  wxString fn = fileHistory->GetHistoryFile( i );
436 
437  if( wxFileName::FileExists( fn ) )
438  return fn;
439  else
440  {
441  wxString msg = wxString::Format(
442  wxT( "file '%s' was not found." ),
443  GetChars( fn ) );
444 
445  wxMessageBox( msg );
446 
447  fileHistory->RemoveFileFromHistory( i );
448  }
449  }
450 
451  return wxEmptyString;
452 }
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
void EDA_BASE_FRAME::GetKicadAbout ( wxCommandEvent &  event)
inherited

Definition at line 546 of file basicframe.cpp.

References ShowAboutDialog().

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

Definition at line 533 of file basicframe.cpp.

References URL_GET_INVOLVED.

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

Definition at line 455 of file basicframe.cpp.

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

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 195 of file mainframe.cpp.

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

196 {
197  return PgmTop().GetHelpFileName();
198 }
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
wxString GetHelpFileName()
Definition: pgm_kicad.h:63
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile ( EDA_HOTKEY_CONFIG aDescList,
const wxString &  aDefaultShortname 
)
inherited

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

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

Definition at line 737 of file hotkeys_basic.cpp.

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

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

739 {
740  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
741  wxString mask = wxT( "*." ) + ext;
742 
743 #if 0 // pass in the project dir as an argument
744  wxString path = wxPathOnly( Prj().GetProjectFullName() );
745 #else
746  wxString path = GetMruPath();
747 #endif
748  wxFileName fn( aDefaultShortname );
749  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
750 
751  wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ),
752  path,
753  fn.GetFullPath(),
754  ext,
755  mask,
756  this,
757  wxFD_OPEN,
758  true );
759 
760  if( filename.IsEmpty() )
761  return;
762 
763  ReadHotkeyConfigFile( filename, aDescList );
764  SetMruPath( wxFileName( filename ).GetPath() );
765 }
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:369
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfigFile Read an old configuration file (<file>.key) and fill the current ho...
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
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
wxString GetMruPath() const
Definition: wxstruct.h:371
virtual bool EDA_BASE_FRAME::isAutoSaveRequired ( ) const
inlineprotectedvirtualinherited

Function autoSaveRequired returns the auto save status of the application.

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

Reimplemented in PCB_EDIT_FRAME, and SCH_EDIT_FRAME.

Definition at line 181 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ProcessEvent().

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

Function IsWritable checks if aFileName can be written.

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

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

Definition at line 553 of file basicframe.cpp.

References GetChars().

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

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

References Kiway, and KIWAY::SetLanguage().

517 {
518  int id = event.GetId();
519  Kiway.SetLanguage( id );
520 }
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs...
Definition: kiway.cpp:396
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:374
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:369
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:270
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:407
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:353
bool m_active_project
Definition: kicad.h:314
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:523
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.
Definition: mainframe.cpp:543
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 529 of file mainframe.cpp.

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

Referenced by KICAD_MANAGER_FRAME().

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

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

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

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

Function onAutoSaveTimer handles the auto save timer event.

Definition at line 243 of file basicframe.cpp.

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

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

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

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 446 of file mainframe.cpp.

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

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

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

Definition at line 1090 of file tree_project_frame.cpp.

References TREE_PROJECT_FRAME::FileWatcherReset(), and m_LeftWin.

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

Definition at line 216 of file mainframe.cpp.

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

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

Definition at line 583 of file mainframe.cpp.

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

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

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

and open this new projrct as working project

Definition at line 235 of file prjconfig.cpp.

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

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

Definition at line 245 of file mainframe.cpp.

246 {
247  Close( true );
248 }
void KICAD_MANAGER_FRAME::OnFileHistory ( wxCommandEvent &  event)

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

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

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

Open dialog to import Eagle schematic and board files.

Definition at line 58 of file import_project.cpp.

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

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

Load an exiting project (.pro) file.

Definition at line 165 of file prjconfig.cpp.

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

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

Definition at line 187 of file prjconfig.cpp.

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

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

Definition at line 490 of file mainframe.cpp.

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

491 {
492  wxString wildcard = TextFileWildcard() + "|" + AllFilesWildcard;
493 
494  wxString default_dir = Prj().GetProjectPath();
495 
496  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
497  wxEmptyString, wildcard, wxFD_OPEN );
498 
499  if( dlg.ShowModal() == wxID_CANCEL )
500  return;
501 
502  wxString filename = wxT( "\"" );
503  filename += dlg.GetPath() + wxT( "\"" );
504 
505  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
506  Execute( this, Pgm().GetEditorName(), filename );
507 }
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:102
wxString TextFileWildcard()
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 481 of file mainframe.cpp.

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

482 {
483  wxString editorname = Pgm().GetEditorName();
484 
485  if( !editorname.IsEmpty() )
486  Execute( this, editorname, wxEmptyString );
487 }
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 510 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

511 {
513 }
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 453 of file mainframe.cpp.

References BITMAPCONVERTER_EXE, and Execute().

454 {
455  Execute( this, BITMAPCONVERTER_EXE );
456 }
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 338 of file mainframe.cpp.

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

339 {
340  wxFileName fn( GetProjectFileName() );
341  fn.SetExt( SchematicFileExtension );
342  RunEeschema( fn.GetFullPath() );
343 }
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 472 of file mainframe.cpp.

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

473 {
474  // Gerbview is called without any file to open, because we do not know
475  // the list and the name of files to open (if any...).
476  // however we run it in the path of the project
477  Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() );
478 }
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 465 of file mainframe.cpp.

References Execute(), and PL_EDITOR_EXE.

466 {
467  Execute( this, PL_EDITOR_EXE );
468 }
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 459 of file mainframe.cpp.

References Execute(), and PCB_CALCULATOR_EXE.

460 {
461  Execute( this, PCB_CALCULATOR_EXE );
462 }
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 418 of file mainframe.cpp.

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

419 {
421 
422  if( !frame )
423  {
424  try
425  {
426  frame = Kiway.Player( FRAME_PCB_MODULE_EDITOR, true );
427  }
428  catch( IO_ERROR err )
429  {
430  wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
431  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
432  return;
433  }
434 
435  frame->Show( true );
436  }
437 
438  // On Windows, Raise() does not bring the window on screen, when iconized
439  if( frame->IsIconized() )
440  frame->Iconize( false );
441 
442  frame->Raise();
443 }
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, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
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 406 of file mainframe.cpp.

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

407 {
408  wxFileName kicad_board( PcbFileName() );
409  wxFileName legacy_board( PcbLegacyFileName() );
410 
411  wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
412  kicad_board : legacy_board;
413 
414  RunPcbNew( board.GetFullPath() );
415 }
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:374
void KICAD_MANAGER_FRAME::OnRunSchLibEditor ( wxCommandEvent &  event)

Definition at line 346 of file mainframe.cpp.

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

347 {
348  KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, false );
349 
350  if( !frame )
351  {
352  try
353  {
354  frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, true );
355  }
356  catch( IO_ERROR err )
357  {
358  wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
359  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
360  return;
361  }
362 
363  frame->Show( true );
364  }
365 
366  // On Windows, Raise() does not bring the window on screen, when iconized
367  if( frame->IsIconized() )
368  frame->Iconize( false );
369 
370  frame->Raise();
371 }
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, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnSaveProject ( wxCommandEvent &  event)

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

Definition at line 405 of file prjconfig.cpp.

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

406 {
407  if( !wxIsWritable( GetProjectFileName() ) )
408  return;
409 
411 }
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:318
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:270
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
#define GeneralGroupName
Definition: prjconfig.cpp:56
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
void KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser ( wxCommandEvent &  event)

Definition at line 43 of file preferences.cpp.

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

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

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

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

Definition at line 516 of file basicframe.cpp.

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

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

Definition at line 56 of file preferences.cpp.

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

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

Definition at line 207 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

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

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

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

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

Definition at line 37 of file preferences.cpp.

References Pgm().

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

Definition at line 50 of file preferences.cpp.

References Pgm().

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

Definition at line 414 of file prjconfig.cpp.

References m_active_project.

415 {
416  event.Enable( m_active_project );
417 }
bool m_active_project
Definition: kicad.h:314
const wxString KICAD_MANAGER_FRAME::PcbFileName ( )

Definition at line 163 of file mainframe.cpp.

References GetProjectFileName(), and PcbFileExtension.

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

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

Definition at line 173 of file mainframe.cpp.

References GetProjectFileName(), and LegacyPcbFileExtension.

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

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

Function PostCommandMenuEvent.

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

Definition at line 666 of file basicframe.cpp.

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

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

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

Referenced by LoadProject().

544 {
545  wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
547  PrintMsg( msg );
548 }
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 551 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.

552 {
553  int id = event.GetId();
554  wxFileName fn;
555 
556  switch( id )
557  {
558  // Hotkey IDs
561  break;
562 
565  break;
566 
569  break;
570 
572  // Display current hotkey list for LibEdit.
574  break;
575 
576  default:
577  wxFAIL_MSG( wxT( "KICAD_MANAGER_FRAME::Process_Config error" ) );
578  break;
579  }
580 }
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 185 of file basicframe.cpp.

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

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

186 {
187  if( !wxFrame::ProcessEvent( aEvent ) )
188  return false;
189 
190  if( IsShown() && m_hasAutoSave && IsActive() &&
192  {
193  if( !m_autoSaveState )
194  {
195  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
196  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
197  m_autoSaveState = true;
198  }
199  else if( m_autoSaveTimer->IsRunning() )
200  {
201  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
202  m_autoSaveTimer->Stop();
203  m_autoSaveState = false;
204  }
205  }
206 
207  return true;
208 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:161
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:181
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:152
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
const wxChar traceAutoSave[]
Flag to enable auto save feature debug tracing.
Definition: basicframe.cpp:53
int EDA_BASE_FRAME::ReadHotkeyConfig ( struct EDA_HOTKEY_CONFIG aDescList)
inherited

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

Parameters
aDescList= current hotkey list descr. to initialize.

Definition at line 658 of file hotkeys_basic.cpp.

659 {
660  ::ReadHotkeyConfig( GetName(), aDescList );
661  return 1;
662 }
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 601 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, and ParseHotkeyConfig().

Referenced by EDA_BASE_FRAME::ImportHotkeyConfigFromFile().

603 {
604  wxFileName fn( aFilename );
605  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
606 
607  wxFile cfgfile( fn.GetFullPath() );
608 
609  if( !cfgfile.IsOpened() ) // There is a problem to open file
610  return 0;
611 
612  // get length
613  cfgfile.SeekEnd();
614  wxFileOffset size = cfgfile.Tell();
615  cfgfile.Seek( 0 );
616 
617  // read data
618  char* buffer = new char[size];
619  cfgfile.Read( buffer, size );
620 
621  wxString data( buffer, wxConvUTF8 );
622 
623  // parse
624  ParseHotkeyConfig( data, aDescList );
625 
626  // cleanup
627  delete[] buffer;
628  cfgfile.Close();
629  return 1;
630 }
void ParseHotkeyConfig(const wxString &data, struct EDA_HOTKEY_CONFIG *aDescList)
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34
void KICAD_MANAGER_FRAME::RecreateBaseHToolbar ( )

(Re)Create the horizontal toolbar

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

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

Referenced by KICAD_MANAGER_FRAME().

507 {
508  // Check if toolbar is not already created
509  if( m_mainToolBar != NULL )
510  return;
511 
512  // Allocate memory for m_mainToolBar
513  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
514  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
515 
516  // New
517  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
518  KiBitmap( new_project_xpm ),
519  _( "Create new project" ) );
520 
521  m_mainToolBar->AddTool( ID_NEW_PROJECT_FROM_TEMPLATE, wxEmptyString,
522  KiBitmap( new_project_with_template_xpm ),
523  _( "Create new project from template" ) );
524 
525  // Load
526  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString,
527  KiBitmap( open_project_xpm ),
528  _( "Open existing project" ) );
529 
530  // Currently there is nothing to save
531  // (Kicad manager does not save any info in .pro file)
532 #if 0
533  // Save
534  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString,
535  KiBitmap( save_project_xpm ),
536  _( "Save current project" ) );
537 #endif
538 
539  // Separator
540  m_mainToolBar->AddSeparator();
541 
542  // Archive
543  m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
544  KiBitmap( zip_xpm ),
545  _( "Archive all project files" ) );
546 
547  // Unarchive
548  m_mainToolBar->AddTool( ID_READ_ZIP_ARCHIVE, wxEmptyString,
549  KiBitmap( unzip_xpm ),
550  _( "Unarchive project files from zip archive" ) );
551 
552  // Separator
553  m_mainToolBar->AddSeparator();
554 
555  // Refresh project tree
556  m_mainToolBar->AddTool( ID_PROJECT_TREE_REFRESH, wxEmptyString,
557  KiBitmap( reload_xpm ),
558  _( "Refresh project tree" ) );
559 
560  // Create m_mainToolBar
561  m_mainToolBar->Realize();
562 }
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
Definition: wxstruct.h:168
void KICAD_MANAGER_FRAME::ReCreateMenuBar ( void  )
overridevirtual

(Re)Create the menubar

Reimplemented from EDA_BASE_FRAME.

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

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

Referenced by KICAD_MANAGER_FRAME().

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

Definition at line 183 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

Referenced by OnImportEagleFiles().

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

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

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

Definition at line 296 of file mainframe.cpp.

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

Referenced by OnRunEeschema().

297 {
298  KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );
299 
300  // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
301  // Kiway.Player( FRAME_SCH, true )
302  // therefore, the schematic editor is sometimes running, but the schematic project
303  // is not loaded, if the library editor was called, and the dialog field editor was used.
304  // On linux, it happens the first time the schematic editor is launched, if
305  // library editor was running, and the dialog field editor was open
306  // On Windows, it happens always after the library editor was called,
307  // and the dialog field editor was used
308  if( !frame )
309  {
310  try
311  {
312  frame = Kiway.Player( FRAME_SCH, true );
313  }
314  catch( IO_ERROR err )
315  {
316  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
317  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
318  return;
319  }
320  }
321 
322  if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
323  // but no project loaded.
324  {
325  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
326  frame->Show( true );
327  }
328 
329  // On Windows, Raise() does not bring the window on screen, when iconized or not shown
330  // On linux, Raise() brings the window on screen, but this code works fine
331  if( frame->IsIconized() )
332  frame->Iconize( false );
333 
334  frame->Raise();
335 }
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, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
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 374 of file mainframe.cpp.

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

Referenced by OnRunPcbNew().

375 {
376  KIWAY_PLAYER* frame;
377 
378  try
379  {
380  frame = Kiway.Player( FRAME_PCB, true );
381  }
382  catch( IO_ERROR err )
383  {
384  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
385  wxOK | wxICON_ERROR, this );
386  return;
387  }
388 
389  // a pcb frame can be already existing, but not yet used.
390  // this is the case when running the footprint editor, or the footprint viewer first
391  // if the frame is not visible, the board is not yet loaded
392  if( !frame->IsVisible() )
393  {
394  frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
395  frame->Show( true );
396  }
397 
398  // On Windows, Raise() does not bring the window on screen, when iconized
399  if( frame->IsIconized() )
400  frame->Iconize( false );
401 
402  frame->Raise();
403 }
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, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
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 282 of file wxstruct.h.

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick().

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

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

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

Definition at line 153 of file mainframe.cpp.

References GetProjectFileName(), and SchematicFileExtension.

Referenced by TREEPROJECT_ITEM::Activate().

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

Definition at line 224 of file basicframe.cpp.

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

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

225 {
226  m_autoSaveInterval = aInterval;
227 
228  if( m_autoSaveTimer->IsRunning() )
229  {
230  if( m_autoSaveInterval > 0 )
231  {
232  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
233  }
234  else
235  {
236  m_autoSaveTimer->Stop();
237  m_autoSaveState = false;
238  }
239  }
240 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:161
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
void EDA_BASE_FRAME::SetMruPath ( const wxString &  aPath)
inlineinherited

Definition at line 369 of file wxstruct.h.

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

369 { m_mruPath = aPath; }
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:165
void KICAD_MANAGER_FRAME::SetProjectFileName ( const wxString &  aFullProjectProFileName)

Definition at line 135 of file mainframe.cpp.

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

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

136 {
137  // ensure file name is absolute:
138  wxFileName fn( aFullProjectProFileName );
139 
140  if( !fn.IsAbsolute() )
141  fn.MakeAbsolute();
142 
143  Prj().SetProjectFullName( fn.GetFullPath() );
144 }
PROJECT & Prj()
Definition: kicad.cpp:270
VTBL_ENTRY void SetProjectFullName(const wxString &aFullPathAndName)
Function SetProjectFullName sets the: 1) full directory, 2) basename, and 3) extension of the project...
Definition: project.cpp:65
void EDA_BASE_FRAME::ShowChangedIcons ( )
virtualinherited

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

Definition at line 268 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by KIWAY::ShowChangedIcons().

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

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

Reimplemented in PCB_EDIT_FRAME, and GERBVIEW_FRAME.

Definition at line 261 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

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

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

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 189 of file mainframe.cpp.

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

Referenced by CreateNewProject().

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

Function UpdateFileHistory Updates the list of recently opened files.

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

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

Definition at line 407 of file basicframe.cpp.

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

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

409 {
410  wxFileHistory* fileHistory = aFileHistory;
411 
412  if( !fileHistory )
413  fileHistory = &Kiface().GetFileHistory();
414 
415  fileHistory->AddFileToHistory( FullFileName );
416 }
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 534 of file hotkeys_basic.cpp.

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

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

536 {
537  wxString msg;
538  wxString keyname, infokey;
539 
540  msg = wxT( "$hotkey list\n" );
541 
542  // Print the current hotkey list
543  EDA_HOTKEY** list;
544 
545  for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
546  {
547  if( aDescList->m_Title )
548  {
549  msg += wxT( "# " );
550  msg += *aDescList->m_Title;
551  msg += wxT( "\n" );
552  }
553 
554  msg += *aDescList->m_SectionTag;
555  msg += wxT( "\n" );
556 
557  list = aDescList->m_HK_InfoList;
558 
559  for( ; *list != NULL; list++ )
560  {
561  EDA_HOTKEY* hk_decr = *list;
562  msg += wxT( "shortcut " );
563  keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
564  AddDelimiterString( keyname );
565  infokey = hk_decr->m_InfoMsg;
566  AddDelimiterString( infokey );
567  msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
568  }
569  }
570 
571  msg += wxT( "$Endlist\n" );
572 
573  if( aFullFileName )
574  {
575  FILE* file = wxFopen( *aFullFileName, wxT( "wt" ) );
576 
577  if( file )
578  {
579  fputs( TO_UTF8( msg ), file );
580  fclose( file );
581  }
582  else
583  {
584  msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
585  return 0;
586  }
587  }
588  else
589  {
590  wxFileName fn( GetName() );
591  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
592  wxConfigBase* config = GetNewConfig( fn.GetFullPath() );
593  config->Write( HOTKEYS_CONFIG_KEY, msg );
594  delete config;
595  }
596 
597  return 1;
598 }
EDA_HOTKEY ** m_HK_InfoList
Definition: hotkeys_basic.h:91
wxConfigBase * GetNewConfig(const wxString &aProgName)
Function GetNewConfig.
Definition: common.cpp:205
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:380
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
#define HOTKEYS_CONFIG_KEY
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
wxString * m_SectionTag
Definition: hotkeys_basic.h:90
wxString m_InfoMsg
Definition: hotkeys_basic.h:64
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:57
wxString * m_Title
Definition: hotkeys_basic.h:92
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Function KeyNameFromKeyCode return the key name from the key code Only some wxWidgets key values are ...
#define DEFAULT_HOTKEY_FILENAME_EXT
Definition: hotkeys_basic.h:34

Member Data Documentation

wxString EDA_BASE_FRAME::m_AboutTitle
protectedinherited

Name of program displayed in About.

Definition at line 147 of file wxstruct.h.

bool KICAD_MANAGER_FRAME::m_active_project
private

Definition at line 314 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), LoadProject(), and OnUpdateRequiresProject().

bool EDA_BASE_FRAME::m_autoSaveState
protectedinherited
wxTimer* EDA_BASE_FRAME::m_autoSaveTimer
protectedinherited
wxString EDA_BASE_FRAME::m_configFrameName
protectedinherited

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

Definition at line 142 of file wxstruct.h.

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

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

Definition at line 152 of file wxstruct.h.

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

FRAME_T EDA_BASE_FRAME::m_Ident
protectedinherited

Id Type (pcb, schematic, library..)

Definition at line 138 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

LAUNCHER_PANEL* KICAD_MANAGER_FRAME::m_Launcher
private

Definition at line 305 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME().

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

Definition at line 309 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), and LoadSettings().

EDA_HOTKEY_CONFIG* KICAD_MANAGER_FRAME::m_manager_Hokeys_Descr
private

Definition at line 310 of file kicad.h.

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

wxTextCtrl* KICAD_MANAGER_FRAME::m_MessagesBox
private

Definition at line 306 of file kicad.h.

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

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 163 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::LoadSettings().

wxAuiToolBar* KICAD_MANAGER_FRAME::m_VToolBar
private

Definition at line 307 of file kicad.h.


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