KiCad PCB EDA Suite
KICAD_MANAGER_FRAME Class Reference

Class KICAD_MANAGER_FRAME is 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
 Function OnChangeIconsOptions Selects 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)
 Function OnLoadProject loads an exiting or creates a new project (.pro) file. More...
 
void OnCreateProjectFromTemplate (wxCommandEvent &event)
 Function OnCreateProjectFromTemplate Creates a new project folder, copy a template into this new folder. More...
 
void OnSaveProject (wxCommandEvent &event)
 Function OnSaveProject is the command event hendler to 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 PrintMsg (const wxString &aText)
 Function PrintMsg displays aText in the text panel. More...
 
void PrintPrjInfo ()
 a minor helper function: Prints the Current Working Dir name and the projet name on the text panel. More...
 
void ClearMsg ()
 a minor helper function: 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 wxString &aPrjFullFileName, bool aTemplateSelector)
 
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)
 Function Execute opens 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...
 

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

Class KICAD_MANAGER_FRAME is 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 49 of file mainframe.cpp.

References config(), LAUNCHER_PANEL::GetPanelHeight(), 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.

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

References EDA_BASE_FRAME::m_auimgr.

118 {
119  m_auimgr.UnInit();
120 }
wxAuiManager m_auimgr
Definition: wxstruct.h:139

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

672 {
673  wxMenu* menu = NULL;
674  wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS );
675 
676  if( item ) // This menu exists, do nothing
677  return;
678 
679  menu = new wxMenu;
680 
681  menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS,
682  _( "Icons in Menus" ), wxEmptyString,
683  wxITEM_CHECK ) );
684  menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() );
685 
686  AddMenuItem( MasterMenu, menu,
688  _( "Icons Options" ),
689  _( "Select show icons in menus and icons sizes" ),
690  KiBitmap( hammer_xpm ) );
691 }
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 576 of file basicframe.cpp.

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

Referenced by SCH_EDIT_FRAME::LoadOneEEFile(), and PCB_EDIT_FRAME::OpenProjectFiles().

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

a minor helper function: Erase the text panel.

Definition at line 525 of file mainframe.cpp.

References m_MessagesBox.

Referenced by CreateNewProject(), and OnLoadProject().

526 {
527  m_MessagesBox->Clear();
528 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
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 123 of file mainframe.cpp.

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

Referenced by KICAD_MANAGER_FRAME().

124 {
125  wxConfigBase* ret = PgmTop().PgmSettings();
126  wxASSERT( ret );
127  return ret;
128 }
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 255 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().

256  {
257  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
258  return baseCfgName;
259  }
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:132
void KICAD_MANAGER_FRAME::CreateNewProject ( const wxString &  aPrjFullFileName,
bool  aTemplateSelector = false 
)

Definition at line 59 of file prjconfig.cpp.

References DIALOG_TEMPLATE_SELECTOR::AddTemplatesPage(), ClearMsg(), PROJECT::ConfigSave(), PROJECT_TEMPLATE::CreateProject(), GeneralGroupName, DIALOG_TEMPLATE_SELECTOR::GetSelectedTemplate(), KiCadPcbFileExtension, LegacyPcbFileExtension, m_active_project, m_MessagesBox, PgmTop(), Prj(), SchematicFileExtension, SEP, and SetProjectFileName().

Referenced by OnCreateProjectFromTemplate(), and OnLoadProject().

61 {
62  wxFileName newProjectName = aPrjFullFileName;
63  wxChar sep[2] = { SEP(), 0 }; // nul terminated separator wxChar string.
64 
65  ClearMsg();
66 
67  // If we are creating a project from a template, make sure the template directory is sane
68  if( aTemplateSelector )
69  {
71 
72  wxFileName templatePath;
73  wxString envStr;
74 
75 #ifndef __WXMAC__
76  wxGetEnv( wxT( "KICAD" ), &envStr );
77 
78  // Add a new tab for system templates
79  if( !envStr.empty() )
80  {
81  // user may or may not have including terminating separator.
82  if( !envStr.EndsWith( sep ) )
83  envStr += sep;
84 
85  templatePath = envStr + wxT( "template" ) + sep;
86  }
87  else
88  {
89  // The standard path should be in the share directory for kicad. As
90  // it is normal on Windows to only have the share directory and not
91  // the kicad sub-directory we fall back to that if the directory
92  // doesn't exist
93  templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) +
94  sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "kicad" ) +
95  sep + wxT( "template" ) + sep;
96 
97  if( !wxDirExists( templatePath.GetFullPath() ) )
98  {
99  templatePath = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) +
100  sep + wxT( ".." ) + sep + wxT( "share" ) + sep + wxT( "template" ) + sep;
101  }
102  }
103 #else
104  // Use what is provided in the bundle data dir
105  templatePath = GetOSXKicadDataDir() + sep + wxT( "template" );
106 #endif
107 
108  ps->AddTemplatesPage( _( "System Templates" ), templatePath );
109 
110  // Add a new tab for user templates
111  wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() +
112  sep + wxT( "kicad" ) + sep + wxT( "template" ) + sep;
113 
114  ps->AddTemplatesPage( _( "User Templates" ), userPath );
115 
116  // Check to see if a custom template location is available and setup a
117  // new selection tab if there is.
118  envStr.clear();
119  wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr );
120 
121  if( !envStr.empty() )
122  {
123  if( !envStr.EndsWith( sep ) )
124  envStr += sep;
125 
126  wxFileName envPath = envStr;
127 
128  ps->AddTemplatesPage( _( "Portable Templates" ), envPath );
129  }
130 
131  // Show the project template selector dialog
132  int result = ps->ShowModal();
133 
134  if( ( result != wxID_OK ) || ( ps->GetSelectedTemplate() == NULL ) )
135  {
136  if( ps->GetSelectedTemplate() == NULL )
137  {
138  wxMessageBox( _( "No project template was selected. Cannot generate new "
139  "project." ),
140  _( "Error" ),
141  wxOK | wxICON_ERROR,
142  this );
143  }
144  }
145  else
146  {
147  // The selected template widget contains the template we're attempting to use to
148  // create a project
149  if( !ps->GetSelectedTemplate()->CreateProject( newProjectName ) )
150  {
151  wxMessageBox( _( "Problem whilst creating new project from template!" ),
152  _( "Template Error" ),
153  wxOK | wxICON_ERROR,
154  this );
155  }
156  }
157  }
158 
159  // Init project filename
160  SetProjectFileName( newProjectName.GetFullPath() );
161 
162  // Write settings to project file
163  // was: wxGetApp().WriteProjectConfig( aPrjFullFileName, GeneralGroupName, s_KicadManagerParams );
165 
166  // Ensure a "stub" for a schematic root sheet and a board exist.
167  // It will avoid messages from the schematic editor or the board editor to create a new file
168  // And forces the user to create main files under the right name for the project manager
169  wxFileName fn( newProjectName.GetFullPath() );
170  fn.SetExt( SchematicFileExtension );
171 
172  // If a <project>.sch file does not exist, create a "stub" file
173  // ( minimal schematic file )
174  if( !fn.FileExists() )
175  {
176  wxFile file( fn.GetFullPath(), wxFile::write );
177 
178  if( file.IsOpened() )
179  file.Write( wxT( "EESchema Schematic File Version 2\n"
180  "EELAYER 25 0\nEELAYER END\n$EndSCHEMATC\n" ) );
181 
182  // wxFile dtor will close the file
183  }
184 
185  // If a <project>.kicad_pcb or <project>.brd file does not exist,
186  // create a .kicad_pcb "stub" file
187  fn.SetExt( KiCadPcbFileExtension );
188  wxFileName leg_fn( fn );
189  leg_fn.SetExt( LegacyPcbFileExtension );
190 
191  if( !fn.FileExists() && !leg_fn.FileExists() )
192  {
193  wxFile file( fn.GetFullPath(), wxFile::write );
194 
195  if( file.IsOpened() )
196  file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );
197 
198  // wxFile dtor will close the file
199  }
200 
201  // Enable the toolbar and menubar buttons and clear the help text.
202  m_active_project = true;
203  m_MessagesBox->Clear();
204 }
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:307
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:57
PROJECT_TEMPLATE * GetSelectedTemplate()
PROJECT & Prj()
Definition: kicad.cpp:293
#define SEP()
Definition: prjconfig.cpp:49
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
#define GeneralGroupName
Definition: prjconfig.cpp:55
const wxString SchematicFileExtension
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:131
bool CreateProject(wxFileName &aNewProjectPath)
Copies and renames all template files to create a new project.
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
const wxString LegacyPcbFileExtension
const wxString KiCadPcbFileExtension
void AddTemplatesPage(const wxString &aTitle, wxFileName &aPath)
Add a new page with aTitle, populated with templates from aPath.
bool m_active_project
Definition: kicad.h:304
void ClearMsg()
a minor helper function: Erase the text panel.
Definition: mainframe.cpp:525
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 231 of file basicframe.cpp.

Referenced by EDA_BASE_FRAME::onAutoSaveTimer().

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

Definition at line 192 of file basicframe.cpp.

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

193 {
194  // so we can do logging of this state change:
195 
196 #if defined(DEBUG)
197  const char* type_id = typeid( *this ).name();
198  printf( "wxFrame %-28s: %s\n", type_id, enable ? "enabled" : "disabled" );
199 #endif
200 
201  return wxFrame::Enable( enable );
202 }
void KICAD_MANAGER_FRAME::Execute ( wxWindow *  frame,
const wxString &  execFile,
wxString  param = wxEmptyString 
)

Function Execute opens 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 267 of file mainframe.cpp.

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

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

269 {
270  if( params.size() )
271  AddDelimiterString( params );
272 
273  TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
274 
275  long pid = ExecuteFile( frame, execFile, params, callback );
276 
277  if( pid > 0 )
278  {
279  wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
280  GetChars( execFile ), GetChars( params ), pid );
281 
282  PrintMsg( msg );
283  }
284  else
285  {
286  delete callback;
287  }
288 }
void PrintMsg(const wxString &aText)
Function PrintMsg displays aText in the text panel.
Definition: mainframe.cpp:197
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 Process_Config(), LIB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Config(), PL_EDITOR_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), GERBVIEW_FRAME::Process_Config(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

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:356
PROJECT & Prj()
Definition: kicad.cpp:293
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:358
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 214 of file wxstruct.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

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

214 { return m_autoSaveInterval; }
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
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 400 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(), and GERBVIEW_FRAME::OnZipFileHistory().

402 {
403  wxFileHistory* fileHistory = aFileHistory;
404 
405  if( !fileHistory )
406  fileHistory = &Kiface().GetFileHistory();
407 
408  int baseId = fileHistory->GetBaseId();
409 
410  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
411 
412  unsigned i = cmdId - baseId;
413 
414  if( i < fileHistory->GetCount() )
415  {
416  wxString fn = fileHistory->GetHistoryFile( i );
417 
418  if( wxFileName::FileExists( fn ) )
419  return fn;
420  else
421  {
422  wxString msg = wxString::Format(
423  wxT( "file '%s' was not found." ),
424  GetChars( fn ) );
425 
426  wxMessageBox( msg );
427 
428  fileHistory->RemoveFileFromHistory( i );
429  }
430  }
431 
432  return wxEmptyString;
433 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:121
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 525 of file basicframe.cpp.

References ShowAboutDialog().

526 {
527  bool ShowAboutDialog(wxWindow * parent);
528  ShowAboutDialog( this );
529 }
bool ShowAboutDialog(wxWindow *parent)
void EDA_BASE_FRAME::GetKicadContribute ( wxCommandEvent &  event)
inherited

Definition at line 514 of file basicframe.cpp.

References URL_GET_INVOLVED.

515 {
516  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
517  {
518  wxString msg = _( "Could not launch the default browser. For information on how to help the KiCad project, visit " );
519  msg.Append( URL_GET_INVOLVED );
520  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
521  }
522 }
#define URL_GET_INVOLVED
Definition: basicframe.cpp:51
void EDA_BASE_FRAME::GetKicadHelp ( wxCommandEvent &  event)
inherited

Definition at line 436 of file basicframe.cpp.

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

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

Definition at line 358 of file wxstruct.h.

References EDA_BASE_FRAME::m_mruPath.

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

358 { return m_mruPath; }
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:155
const wxString KICAD_MANAGER_FRAME::GetProjectFileName ( )
wxString KICAD_MANAGER_FRAME::help_name ( )
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 191 of file mainframe.cpp.

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

192 {
193  return PgmTop().GetHelpFileName();
194 }
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 Process_Config(), LIB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Config(), PL_EDITOR_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), GERBVIEW_FRAME::Process_Config(), and FOOTPRINT_EDIT_FRAME::ProcessPreferences().

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:356
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:293
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:358
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 168 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ProcessEvent().

168 { 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 532 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().

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

References Kiway, and KIWAY::SetLanguage().

519 {
520  int id = event.GetId();
521  Kiway.SetLanguage( id );
522 }
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::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 531 of file mainframe.cpp.

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

Referenced by KICAD_MANAGER_FRAME().

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

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

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

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

Function onAutoSaveTimer handles the auto save timer event.

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

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

Function OnChangeIconsOptions Selects 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 443 of file mainframe.cpp.

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

444 {
447 }
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: basicframe.cpp:660
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 1089 of file tree_project_frame.cpp.

References TREE_PROJECT_FRAME::FileWatcherReset(), and m_LeftWin.

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

Definition at line 212 of file mainframe.cpp.

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

213 {
214  if( Kiway.PlayersClose( false ) )
215  {
216  int px, py;
217 
218  UpdateFileHistory( GetProjectFileName(), &PgmTop().GetFileHistory() );
219 
220  if( !IsIconized() ) // save main frame position and size
221  {
222  GetPosition( &px, &py );
223  m_FramePos.x = px;
224  m_FramePos.y = py;
225 
226  GetSize( &px, &py );
227  m_FrameSize.x = px;
228  m_FrameSize.y = py;
229  }
230 
231  Event.SetCanVeto( true );
232 
233  m_LeftWin->Show( false );
234 
235  Destroy();
236  }
237 }
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:388
wxPoint m_FramePos
Definition: wxstruct.h:129
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
wxSize m_FrameSize
Definition: wxstruct.h:130
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnConfigurePaths ( wxCommandEvent &  aEvent)

Definition at line 589 of file mainframe.cpp.

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

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

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

and open this new projrct as working project

Definition at line 359 of file prjconfig.cpp.

References CreateNewProject(), OnLoadProject(), Prj(), and SEP.

360 {
361  wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
362  wxString title = _("New Project Folder");
363  wxDirDialog dlg( this, title, default_dir );
364 
365  if( dlg.ShowModal() == wxID_CANCEL )
366  return;
367 
368  // Builds the project .pro filename, from the new project folder name
369  wxFileName fn;
370  fn.AssignDir( dlg.GetPath() );
371  fn.SetName( dlg.GetPath().AfterLast( SEP() ) );
372  fn.SetExt( wxT( "pro" ) );
373 
374  // Launch the template selector dialog, and copy files
375  CreateNewProject( fn.GetFullPath(), true );
376 
377  // Initialize the project
378  event.SetId( wxID_ANY );
379  OnLoadProject( event );
380 }
PROJECT & Prj()
Definition: kicad.cpp:293
#define SEP()
Definition: prjconfig.cpp:49
void CreateNewProject(const wxString &aPrjFullFileName, bool aTemplateSelector)
Definition: prjconfig.cpp:59
void OnLoadProject(wxCommandEvent &event)
Function OnLoadProject loads an exiting or creates a new project (.pro) file.
Definition: prjconfig.cpp:207
void KICAD_MANAGER_FRAME::OnExit ( wxCommandEvent &  event)

Definition at line 240 of file mainframe.cpp.

241 {
242  Close( true );
243 }
void KICAD_MANAGER_FRAME::OnFileHistory ( wxCommandEvent &  event)

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

References EDA_BASE_FRAME::GetFileFromHistory(), PGM_KICAD::GetFileHistory(), Kiway, OnLoadProject(), PgmTop(), KIWAY::PlayersClose(), and SetProjectFileName().

Referenced by PGM_KICAD::OnPgmInit().

48 {
49  wxString fn = GetFileFromHistory( event.GetId(),
50  _( "KiCad project file" ), &PgmTop().GetFileHistory() );
51 
52  if( fn.size() )
53  {
54  // Any open KIFACE's must be closed before changing the project.
55  // We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project,
56  // and then break one project.
57  // Remember when saving files, the full path is build from the current project path
58  // User is prompted here to close those KIWAY_PLAYERs:
59  if( !Kiway.PlayersClose( false ) )
60  return;
61 
62  // We can now set the new project filename and load this project
63  SetProjectFileName( fn );
64  wxCommandEvent cmd( 0, wxID_ANY );
65  OnLoadProject( cmd );
66  }
67 }
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 OnLoadProject(wxCommandEvent &event)
Function OnLoadProject loads an exiting or creates a new project (.pro) file.
Definition: prjconfig.cpp:207
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:131
wxString GetFileFromHistory(int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
Function GetFileFromHistory fetches the file name from the file history list.
Definition: basicframe.cpp:400
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnLoadProject ( wxCommandEvent &  event)

Function OnLoadProject loads an exiting or creates a new project (.pro) file.

Definition at line 207 of file prjconfig.cpp.

References ClearMsg(), PROJECT::ConfigLoad(), CreateNewProject(), DisplayError(), Format(), GeneralGroupName, GetChars(), PGM_KICAD::GetFileHistory(), EDA_BASE_FRAME::GetMruPath(), GetProjectFileName(), ID_INIT_WATCHED_PATHS, ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, IsOK(), Kiway, m_active_project, m_LeftWin, m_MessagesBox, NAMELESS_PROJECT, PgmTop(), KIWAY::PlayersClose(), PrintPrjInfo(), Prj(), ProjectFileExtension, ProjectFileWildcard, TREE_PROJECT_FRAME::ReCreateTreePrj(), EDA_BASE_FRAME::SetMruPath(), SetProjectFileName(), and EDA_BASE_FRAME::UpdateFileHistory().

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

208 {
209  // Any open KIFACE's must be closed if they are not part of the new project.
210  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
211  // User is prompted here to close those KIWAY_PLAYERs:
212  if( !Kiway.PlayersClose( false ) )
213  return;
214 
215  // evt_id can be one of:
216  // ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, ID_LOAD_PROJECT, and
217  // wxID_ANY from 3 different places.
218  int evt_id = event.GetId();
219 
220  wxString title;
221 
222  ClearMsg();
223 
224  bool newProject = ( evt_id == ID_NEW_PROJECT ) ||
225  ( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE );
226 
227  if( evt_id != wxID_ANY )
228  {
229  int style;
230 
231  if( newProject )
232  {
233  title = _( "Create New Project" );
234  style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;
235  }
236  else
237  {
238  title = _( "Open Existing Project" );
239  style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
240  }
241 
242  wxString default_dir = GetMruPath();
243  wxFileDialog dlg( this, title, default_dir, wxEmptyString,
244  ProjectFileWildcard, style );
245 
246  if( dlg.ShowModal() == wxID_CANCEL )
247  return;
248 
249  //DBG( printf( "%s: wxFileDialog::GetPath=%s\n", __func__, TO_UTF8( dlg.GetPath() ) );)
250 
251  wxFileName pro( dlg.GetPath() );
252  pro.SetExt( ProjectFileExtension ); // enforce extension
253 
254  if( !pro.IsAbsolute() )
255  pro.MakeAbsolute();
256 
257  if( newProject )
258  {
259  // Check if the project directory is empty
260  wxDir directory( pro.GetPath() );
261 
262  if( directory.HasFiles() )
263  {
264  wxString msg = _( "The selected directory is not empty. We recommend you "
265  "create projects in their own clean directory.\n\nDo you "
266  "want to create a new empty directory for the project?" );
267 
268  if( IsOK( this, msg ) )
269  {
270  // Append a new directory with the same name of the project file
271  // and try to create it
272  pro.AppendDir( pro.GetName() );
273 
274  if( !wxMkdir( pro.GetPath() ) )
275  // There was a problem, undo
276  pro.RemoveLastDir();
277  }
278  }
279 
280  if( evt_id == ID_NEW_PROJECT )
281  {
282  CreateNewProject( pro.GetFullPath() );
283  }
284  else if( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE )
285  {
286  // Launch the template selector dialog
287  CreateNewProject( pro.GetFullPath(), true );
288  }
289  }
290 
291  SetProjectFileName( pro.GetFullPath() );
292  }
293 
294  wxString prj_filename = GetProjectFileName();
295 
296  wxString nameless_prj = NAMELESS_PROJECT wxT( ".pro" );
297 
298  wxLogDebug( wxT( "%s: %s" ),
299  GetChars( wxFileName( prj_filename ).GetFullName() ),
300  GetChars( nameless_prj ) );
301 
302  // Check if project file exists and if it is not noname.pro
303  if( !wxFileExists( prj_filename )
304  && !wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) )
305  {
306  wxString msg = wxString::Format( _(
307  "KiCad project file '%s' not found" ),
308  GetChars( prj_filename ) );
309 
310  DisplayError( this, msg );
311  return;
312  }
313 
314  // Either this is the first time kicad has been run or one of the projects in the
315  // history list is no longer valid. This prevents kicad from automatically creating
316  // a noname.pro file in the same folder as the kicad binary.
317  if( wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) && !newProject )
318  {
319  m_active_project = false;
320  m_MessagesBox->SetValue( _( "To proceed, you can use the File menu to start a new project." ) );
321  return;
322  }
323  else
324  {
325  m_active_project = true;
326  m_MessagesBox->Clear();
327  }
328 
330 
331  title = L"KiCad \u2014 " + prj_filename;
332 
333  if( !wxFileName( prj_filename ).IsDirWritable() )
334  title += _( " [Read Only]" );
335  else
336  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access.
337 
338  SetTitle( title );
339 
340  if( !prj_filename.IsSameAs( nameless_prj ) )
341  UpdateFileHistory( prj_filename, &PgmTop().GetFileHistory() );
342 
344 
345  // Rebuild the list of watched paths.
346  // however this is possible only when the main loop event handler is running,
347  // so we use it to run the rebuild function.
348  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
349 
350  wxPostEvent( this, cmd );
351 
352  PrintPrjInfo();
353 }
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:356
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:57
const wxString ProjectFileExtension
PROJECT & Prj()
Definition: kicad.cpp:293
const wxString ProjectFileWildcard
void CreateNewProject(const wxString &aPrjFullFileName, bool aTemplateSelector)
Definition: prjconfig.cpp:59
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:388
void ReCreateTreePrj()
Create or modify the tree showing project file names.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
#define GeneralGroupName
Definition: prjconfig.cpp:55
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:131
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
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:342
bool m_active_project
Definition: kicad.h:304
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
#define NAMELESS_PROJECT
default name for nameless projects
Definition: common.h:73
wxString GetMruPath() const
Definition: wxstruct.h:358
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
void ClearMsg()
a minor helper function: Erase the text panel.
Definition: mainframe.cpp:525
void PrintPrjInfo()
a minor helper function: Prints the Current Working Dir name and the projet name on the text panel...
Definition: mainframe.cpp:549
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:111
KIWAY Kiway
void KICAD_MANAGER_FRAME::OnOpenFileInEditor ( wxCommandEvent &  event)
void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ( wxCommandEvent &  event)

Definition at line 487 of file mainframe.cpp.

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

488 {
489  wxString mask( wxT( "*" ) );
490 
491 #ifdef __WINDOWS__
492  mask += wxT( ".*" );
493 #endif
494 
495  mask = _( "Text file (" ) + mask + wxT( ")|" ) + mask;
496  wxString default_dir = Prj().GetProjectPath();
497 
498  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
499  wxEmptyString, mask, wxFD_OPEN );
500 
501  if( dlg.ShowModal() == wxID_CANCEL )
502  return;
503 
504  wxString filename = wxT( "\"" );
505  filename += dlg.GetPath() + wxT( "\"" );
506 
507  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
508  Execute( this, Pgm().GetEditorName(), filename );
509 }
PROJECT & Prj()
Definition: kicad.cpp:293
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:336
void KICAD_MANAGER_FRAME::OnOpenTextEditor ( wxCommandEvent &  event)

Definition at line 478 of file mainframe.cpp.

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

479 {
480  wxString editorname = Pgm().GetEditorName();
481 
482  if( !editorname.IsEmpty() )
483  Execute( this, editorname, wxEmptyString );
484 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:336
void KICAD_MANAGER_FRAME::OnRefresh ( wxCommandEvent &  event)

Definition at line 512 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

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

Definition at line 450 of file mainframe.cpp.

References BITMAPCONVERTER_EXE, and Execute().

451 {
452  Execute( this, BITMAPCONVERTER_EXE );
453 }
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
const wxString BITMAPCONVERTER_EXE
void KICAD_MANAGER_FRAME::OnRunEeschema ( wxCommandEvent &  event)

Definition at line 333 of file mainframe.cpp.

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

334 {
335  wxFileName fn( GetProjectFileName() );
336  fn.SetExt( SchematicFileExtension );
337  RunEeschema( fn.GetFullPath() );
338 }
void RunEeschema(const wxString &aProjectSchematicFileName)
Call this only for a SCH associated with the current project.
Definition: mainframe.cpp:291
const wxString SchematicFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
void KICAD_MANAGER_FRAME::OnRunGerbview ( wxCommandEvent &  event)

Definition at line 469 of file mainframe.cpp.

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

470 {
471  // Gerbview is called without any file to open, because we do not know
472  // the list and the name of files to open (if any...).
473  // however we run it in the path of the project
474  Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() );
475 }
PROJECT & Prj()
Definition: kicad.cpp:293
const wxString GERBVIEW_EXE
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor ( wxCommandEvent &  event)

Definition at line 462 of file mainframe.cpp.

References Execute(), and PL_EDITOR_EXE.

463 {
464  Execute( this, PL_EDITOR_EXE );
465 }
const wxString PL_EDITOR_EXE
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
void KICAD_MANAGER_FRAME::OnRunPcbCalculator ( wxCommandEvent &  event)

Definition at line 456 of file mainframe.cpp.

References Execute(), and PCB_CALCULATOR_EXE.

457 {
458  Execute( this, PCB_CALCULATOR_EXE );
459 }
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
const wxString PCB_CALCULATOR_EXE
void KICAD_MANAGER_FRAME::OnRunPcbFpEditor ( wxCommandEvent &  event)

Definition at line 414 of file mainframe.cpp.

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

415 {
417 
418  if( !frame )
419  {
420  try
421  {
422  frame = Kiway.Player( FRAME_PCB_MODULE_EDITOR, true );
423  }
424  catch( IO_ERROR err )
425  {
426  wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
427  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
428  return;
429  }
430 
431 // frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
432  frame->Show( true );
433  }
434 
435  // On Windows, Raise() does not bring the window on screen, when iconized
436  if( frame->IsIconized() )
437  frame->Iconize( false );
438 
439  frame->Raise();
440 }
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 402 of file mainframe.cpp.

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

403 {
404  wxFileName kicad_board( PcbFileName() );
405  wxFileName legacy_board( PcbLegacyFileName() );
406 
407  wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
408  kicad_board : legacy_board;
409 
410  RunPcbNew( board.GetFullPath() );
411 }
const wxString PcbLegacyFileName()
Definition: mainframe.cpp:169
const wxString PcbFileName()
Definition: mainframe.cpp:159
void RunPcbNew(const wxString &aProjectBoardFileName)
Call this only for a PCB associated with the current project.
Definition: mainframe.cpp:370
void KICAD_MANAGER_FRAME::OnRunSchLibEditor ( wxCommandEvent &  event)

Definition at line 341 of file mainframe.cpp.

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

342 {
343  KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, false );
344 
345  if( !frame )
346  {
347  try
348  {
349  frame = Kiway.Player( FRAME_SCH_LIB_EDITOR, true );
350  }
351  catch( IO_ERROR err )
352  {
353  wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
354  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
355  return;
356  }
357 
358  // frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
359  frame->Show( true );
360  }
361 
362  // On Windows, Raise() does not bring the window on screen, when iconized
363  if( frame->IsIconized() )
364  frame->Iconize( false );
365 
366  frame->Raise();
367 }
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)

Function OnSaveProject is the command event hendler to Save the project (.pro) file containing the top level configuration parameters.

Definition at line 383 of file prjconfig.cpp.

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

384 {
385  if( !wxIsWritable( GetProjectFileName() ) )
386  return;
387 
388  // was: wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
389  // GeneralGroupName, s_KicadManagerParams );
391 }
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:307
PARAM_CFG_ARRAY s_KicadManagerParams
Definition: prjconfig.cpp:57
PROJECT & Prj()
Definition: kicad.cpp:293
PGM_KICAD & PgmTop()
Definition: kicad.cpp:71
#define GeneralGroupName
Definition: prjconfig.cpp:55
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
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 497 of file basicframe.cpp.

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

498 {
499  // Ask for the current editor and instruct GetEditorName() to not show
500  // unless we pass false as argument.
501  wxString editorname = Pgm().GetEditorName( false );
502 
503  // Ask the user to select a new editor, but suggest the current one as the default.
504  editorname = Pgm().AskUserForPreferredEditor( editorname );
505 
506  // If we have a new editor name request it to be copied to m_editor_name and saved
507  // to the preferences file. If the user cancelled the dialog then the previous
508  // value will be retained.
509  if( !editorname.IsEmpty() )
510  Pgm().SetEditorName( editorname );
511 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:328
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:373
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:336
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:69
void KICAD_MANAGER_FRAME::OnSize ( wxSizeEvent &  event)

Definition at line 203 of file mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr.

204 {
205  if( m_auimgr.GetManagedWindow() )
206  m_auimgr.Update();
207 
208  event.Skip();
209 }
wxAuiManager m_auimgr
Definition: wxstruct.h:139
void KICAD_MANAGER_FRAME::OnUnarchiveFiles ( wxCommandEvent &  event)

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

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

71 {
72  wxFileName fn = GetProjectFileName();
73 
74  fn.SetExt( ZipFileExtension );
75 
76  wxFileDialog zipfiledlg( this, _( "Unzip Project" ), fn.GetPath(),
77  fn.GetFullName(), ZipFileWildcard,
78  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
79 
80  if( zipfiledlg.ShowModal() == wxID_CANCEL )
81  return;
82 
83  wxString msg = wxString::Format( _("\nOpen '%s'\n" ), GetChars( zipfiledlg.GetPath() ) );
84  PrintMsg( msg );
85 
86  wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
87  wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
88 
89  if( dirDlg.ShowModal() == wxID_CANCEL )
90  return;
91 
92  wxString unzipDir = dirDlg.GetPath() + wxT( "/" );
93  msg.Printf( _( "Unzipping project in '%s'\n" ), GetChars( unzipDir ) );
94  PrintMsg( msg );
95 
96  wxFileSystem zipfilesys;
97 
98  zipfilesys.AddHandler( new wxZipFSHandler );
99  zipfilesys.ChangePathTo( zipfiledlg.GetPath() + wxT( "#zip:" ), true );
100 
101  wxFSFile* zipfile = NULL;
102  wxString localfilename = zipfilesys.FindFirst( wxT( "*.*" ) );
103 
104  while( !localfilename.IsEmpty() )
105  {
106  zipfile = zipfilesys.OpenFile( localfilename );
107  if( !zipfile )
108  {
109  DisplayError( this, wxT( "Zip file read error" ) );
110  break;
111  }
112 
113  wxFileName uzfn = localfilename.AfterLast( ':' );
114  uzfn.MakeAbsolute( unzipDir );
115  wxString unzipfilename = uzfn.GetFullPath();
116 
117  msg.Printf( _( "Extract file '%s'" ), GetChars( unzipfilename ) );
118  PrintMsg( msg );
119 
120  wxInputStream* stream = zipfile->GetStream();
121  wxFFileOutputStream* ofile = new wxFFileOutputStream( unzipfilename );
122 
123  if( ofile->Ok() )
124  {
125  ofile->Write( *stream );
126  PrintMsg( _( " OK\n" ) );
127  }
128  else
129  PrintMsg( _( " *ERROR*\n" ) );
130 
131  delete ofile;
132  delete zipfile;
133 
134  localfilename = zipfilesys.FindNext();
135  }
136 
137  PrintMsg( wxT( "** end **\n" ) );
138 }
void PrintMsg(const wxString &aText)
Function PrintMsg displays aText in the text panel.
Definition: mainframe.cpp:197
#define ZipFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
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 ZipFileWildcard
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
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 394 of file prjconfig.cpp.

References m_active_project.

395 {
396  event.Enable( m_active_project );
397 }
bool m_active_project
Definition: kicad.h:304
const wxString KICAD_MANAGER_FRAME::PcbFileName ( )

Definition at line 159 of file mainframe.cpp.

References GetProjectFileName(), and PcbFileExtension.

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

160 {
161  wxFileName fn( GetProjectFileName() );
162 
163  fn.SetExt( PcbFileExtension );
164 
165  return fn.GetFullPath();
166 }
#define PcbFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName ( )

Definition at line 169 of file mainframe.cpp.

References GetProjectFileName(), and LegacyPcbFileExtension.

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

170 {
171  wxFileName fn( GetProjectFileName() );
172 
173  fn.SetExt( LegacyPcbFileExtension );
174 
175  return fn.GetFullPath();
176 }
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
const wxString LegacyPcbFileExtension
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 645 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().

646 {
647  if( evt_type != 0 )
648  {
649  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
650  evt.SetEventObject( this );
651  evt.SetId( evt_type );
652  wxPostEvent( this, evt );
653  return true;
654  }
655 
656  return false;
657 }
void KICAD_MANAGER_FRAME::PrintMsg ( const wxString &  aText)

Function PrintMsg displays aText in the text panel.

Parameters
aTextThe text to display.

Definition at line 197 of file mainframe.cpp.

References m_MessagesBox.

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

198 {
199  m_MessagesBox->AppendText( aText );
200 }
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
void KICAD_MANAGER_FRAME::PrintPrjInfo ( )

a minor helper function: Prints the Current Working Dir name and the projet name on the text panel.

a minor helper function: Prints the Current Project full name on the text panel.

Definition at line 549 of file mainframe.cpp.

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

Referenced by OnLoadProject().

550 {
551  wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
553  PrintMsg( msg );
554 }
void PrintMsg(const wxString &aText)
Function PrintMsg displays aText in the text panel.
Definition: mainframe.cpp:197
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void KICAD_MANAGER_FRAME::Process_Config ( wxCommandEvent &  event)

Definition at line 557 of file mainframe.cpp.

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

558 {
559  int id = event.GetId();
560  wxFileName fn;
561 
562  switch( id )
563  {
564  // Hotkey IDs
567  break;
568 
571  break;
572 
575  break;
576 
578  // Display current hotkey list for LibEdit.
580  break;
581 
582  default:
583  wxFAIL_MSG( wxT( "KICAD_MANAGER_FRAME::Process_Config error" ) );
584  break;
585  }
586 }
void ExportHotkeyConfigToFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it...
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:300
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 166 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().

167 {
168  if( !wxFrame::ProcessEvent( aEvent ) )
169  return false;
170 
171  if( IsShown() && m_hasAutoSave &&
173  {
174  if( !m_autoSaveState )
175  {
176  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
177  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
178  m_autoSaveState = true;
179  }
180  else if( m_autoSaveTimer->IsRunning() )
181  {
182  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
183  m_autoSaveTimer->Stop();
184  m_autoSaveState = false;
185  }
186  }
187 
188  return true;
189 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:145
const wxChar traceAutoSave[]
Custom trace mask to enable and disable auto save tracing.
Definition: basicframe.cpp:53
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:151
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:168
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:142
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
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 476 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_SAVE_AND_ZIP_FILES, ID_SAVE_PROJECT, KiBitmap(), and EDA_BASE_FRAME::m_mainToolBar.

Referenced by KICAD_MANAGER_FRAME().

477 {
478  // Check if toolbar is not already created
479  if( m_mainToolBar != NULL )
480  return;
481 
482  // Allocate memory for m_mainToolBar
483  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
484  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
485 
486  // New
487  m_mainToolBar->AddTool( ID_NEW_PROJECT, wxEmptyString,
488  KiBitmap( new_project_xpm ),
489  _( "Create new project" ) );
490 
491  m_mainToolBar->AddTool( ID_NEW_PROJECT_FROM_TEMPLATE, wxEmptyString,
492  KiBitmap( new_project_with_template_xpm ),
493  _( "Create new project from template" ) );
494 
495  // Load
496  m_mainToolBar->AddTool( ID_LOAD_PROJECT, wxEmptyString,
497  KiBitmap( open_project_xpm ),
498  _( "Open existing project" ) );
499 
500  // Save
501  m_mainToolBar->AddTool( ID_SAVE_PROJECT, wxEmptyString,
502  KiBitmap( save_project_xpm ),
503  _( "Save current project" ) );
504 
505  // Separator
506  m_mainToolBar->AddSeparator();
507 
508  // Archive
509  m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
510  KiBitmap( zip_xpm ),
511  _( "Archive all project files" ) );
512 
513  // Separator
514  m_mainToolBar->AddSeparator();
515 
516  // Refresh project tree
517  m_mainToolBar->AddTool( ID_PROJECT_TREE_REFRESH, wxEmptyString,
518  KiBitmap( reload_xpm ),
519  _( "Refresh project tree" ) );
520 
521  // Create m_mainToolBar
522  m_mainToolBar->Realize();
523 }
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:135
void KICAD_MANAGER_FRAME::ReCreateMenuBar ( void  )
overridevirtual

(Re)Create the menubar

Reimplemented from EDA_BASE_FRAME.

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

References AddHotkeyConfigMenu(), AddHotkeyName(), EDA_BASE_FRAME::AddMenuIconsOptions(), AddMenuItem(), PGM_BASE::AddMenuLanguageList(), PGM_KICAD::GetFileHistory(), HK_HELP, ID_BROWSE_AN_SELECT_FILE, ID_HELP_GET_INVOLVED, ID_LOAD_PROJECT, ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, ID_PREFERENCES_CONFIGURE_PATHS, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, 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().

188 {
189  wxString msg;
190  static wxMenu* openRecentMenu; // Open Recent submenu,
191  // static to remember this menu
192 
194 
195  // Create and try to get the current menubar
196  wxMenuBar* menuBar = GetMenuBar();
197 
198  if( !menuBar )
199  menuBar = new wxMenuBar();
200 
201  // Delete all existing menus so they can be rebuilt.
202  // This allows language changes of the menu text on the fly.
203  menuBar->Freeze();
204 
205  // Before deleting, remove the menus managed by m_fileHistory
206  // (the file history will be updated when adding/removing files in history)
207  if( openRecentMenu )
208  PgmTop().GetFileHistory().RemoveMenu( openRecentMenu );
209 
210  // Delete all existing menus
211  while( menuBar->GetMenuCount() )
212  delete menuBar->Remove( 0 );
213 
214  // Recreate all menus:
215 
216  // Menu File:
217  wxMenu* fileMenu = new wxMenu;
218 
219  // Open
220  msg = AddHotkeyName( _( "&Open Project" ), kicad_Manager_Hokeys_Descr, HK_LOAD_PROJECT );
221  AddMenuItem( fileMenu, ID_LOAD_PROJECT, msg,
222  _( "Open existing project" ),
223  KiBitmap( open_project_xpm ) );
224 
225  // File history
226  openRecentMenu = new wxMenu();
227  PgmTop().GetFileHistory().UseMenu( openRecentMenu );
228  PgmTop().GetFileHistory().AddFilesToMenu( );
229  AddMenuItem( fileMenu, openRecentMenu,
230  wxID_ANY,
231  _( "Open &Recent" ),
232  _( "Open recent schematic project" ),
233  KiBitmap( open_project_xpm ) );
234 
235  // New project creation
236  wxMenu* newprjSubMenu = new wxMenu();
237 
238  msg = AddHotkeyName( _( "&New Project" ), kicad_Manager_Hokeys_Descr, HK_NEW_PRJ );
239  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT, msg,
240  _( "Create new blank project" ),
241  KiBitmap( new_project_xpm ) );
242 
243  msg = AddHotkeyName( _( "New Project from &Template" ),
244  kicad_Manager_Hokeys_Descr, HK_NEW_PRJ_TEMPLATE );
245  AddMenuItem( newprjSubMenu, ID_NEW_PROJECT_FROM_TEMPLATE, msg,
246  _( "Create a new project from a template" ),
247  KiBitmap( new_project_with_template_xpm ) );
248 
249  AddMenuItem( fileMenu, newprjSubMenu,
250  wxID_ANY,
251  _( "New Project" ),
252  _( "Create new project" ),
253  KiBitmap( new_project_xpm ) );
254 
255  // Currently there is nothing to save
256  // (Kicad manager does not save any info in .pro file)
257 #if 0
258  // Save
259  msg = AddHotkeyName( _( "&Save" ), kicad_Manager_Hokeys_Descr, HK_SAVE_PROJECT );
260  AddMenuItem( fileMenu, ID_SAVE_PROJECT, msg,
261  _( "Save current project" ),
262  KiBitmap( save_project_xpm ) );
263 #endif
264 
265  // Archive
266  fileMenu->AppendSeparator();
267  AddMenuItem( fileMenu,
269  _( "&Archive Current Project..." ),
270  _( "Archive project files in zip archive" ),
271  KiBitmap( zip_xpm ) );
272 
273  // Unarchive
274  AddMenuItem( fileMenu,
276  _( "&Unarchive Project" ),
277  _( "Unarchive project files from zip file" ),
278  KiBitmap( unzip_xpm ) );
279 
280  // Separator
281  fileMenu->AppendSeparator();
282 
283  // Quit
284  AddMenuItem( fileMenu,
285  wxID_EXIT,
286  _( "&Close" ),
287  _( "Close KiCad" ),
288  KiBitmap( exit_xpm ) );
289 
290  // Menu Browse:
291  wxMenu* browseMenu = new wxMenu();
292 
293  // Text editor
294  AddMenuItem( browseMenu,
296  _( "Open Text E&ditor" ),
297  _( "Launch preferred text editor" ),
298  KiBitmap( editor_xpm ) );
299 
300  // View file
301  AddMenuItem( browseMenu,
303  _( "&Open Local File" ),
304  _( "Edit local file" ),
305  KiBitmap( browse_files_xpm ) );
306 
307  // Menu Preferences:
308  wxMenu* preferencesMenu = new wxMenu;
309 
310  // Path configuration edit dialog.
311  AddMenuItem( preferencesMenu,
313  _( "Configure Pa&ths" ),
314  _( "Edit path configuration environment variables" ),
315  KiBitmap( editor_xpm ) );
316 
317  // Text editor
318  AddMenuItem( preferencesMenu,
320  _( "&Set Text Editor" ),
321  _( "Set your preferred text editor" ),
322  KiBitmap( editor_xpm ) );
323 
324  // PDF Viewer submenu:System browser or user defined checkbox
325  wxMenu* SubMenuPdfBrowserChoice = new wxMenu;
326 
327  // Default
328  AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_DEFAULT_PDF_BROWSER,
329  _( "System &Default PDF Viewer" ),
330  _( "Use system default PDF viewer" ),
331  KiBitmap( datasheet_xpm ),
332  wxITEM_CHECK );
333  SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
334  Pgm().UseSystemPdfBrowser() );
335 
336  // Favourite
337  AddMenuItem( SubMenuPdfBrowserChoice, ID_SELECT_PREFERED_PDF_BROWSER,
338  _( "&Favourite PDF Viewer" ),
339  _( "Use favourite PDF viewer" ),
340  KiBitmap( datasheet_xpm ),
341  wxITEM_CHECK );
342  SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER,
343  !Pgm().UseSystemPdfBrowser() );
344 
345  SubMenuPdfBrowserChoice->AppendSeparator();
346  // Append PDF Viewer submenu to preferences
347  AddMenuItem( SubMenuPdfBrowserChoice,
349  _( "Set &PDF Viewer" ),
350  _( "Set favourite PDF viewer" ),
351  KiBitmap( datasheet_xpm ) );
352 
353  // PDF viewer submenu
354  AddMenuItem( preferencesMenu, SubMenuPdfBrowserChoice, -1,
355  _( "&PDF Viewer" ),
356  _( "PDF viewer preferences" ),
357  KiBitmap( datasheet_xpm ) );
358 
359  // Hotkey submenu
360  preferencesMenu->AppendSeparator();
361  AddHotkeyConfigMenu( preferencesMenu );
362 
363  // Language submenu
364  preferencesMenu->AppendSeparator();
365  Pgm().AddMenuLanguageList( preferencesMenu );
366 
367  // Icons options submenu
368  preferencesMenu->AppendSeparator();
369  AddMenuIconsOptions( preferencesMenu );
370 
371  // Menu Tools:
372  wxMenu* toolsMenu = new wxMenu;
373 
374  msg = AddHotkeyName( _( "Run Eeschema" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA );
375  AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
376 
377  msg = AddHotkeyName( _( "Run Library Editor" ),
378  kicad_Manager_Hokeys_Descr, HK_RUN_LIBEDIT );
379  AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
380 
381  msg = AddHotkeyName( _( "Run Pcbnew" ),
382  kicad_Manager_Hokeys_Descr, HK_RUN_PCBNEW );
383  AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
384 
385  msg = AddHotkeyName( _( "Run Footprint Editor" ),
386  kicad_Manager_Hokeys_Descr, HK_RUN_FPEDITOR );
387  AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
388 
389  msg = AddHotkeyName( _( "Run Gerbview" ),
390  kicad_Manager_Hokeys_Descr, HK_RUN_GERBVIEW );
391  AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
392 
393  msg = AddHotkeyName( _( "Run Bitmap2Component" ),
394  kicad_Manager_Hokeys_Descr, HK_RUN_BM2COMPONENT );
395  AddMenuItem( toolsMenu, ID_TO_BITMAP_CONVERTER, msg,
396  _( "Bitmap2Component - Convert bitmap images to Eeschema\n"
397  "or Pcbnew elements" ),
398  KiBitmap( image_xpm ) );
399 
400  msg = AddHotkeyName( _( "Run Pcb Calculator" ), kicad_Manager_Hokeys_Descr, HK_RUN_PCBCALCULATOR );
401  AddMenuItem( toolsMenu, ID_TO_PCB_CALCULATOR, msg,
402  _( "Pcb calculator - Calculator for components, track width, etc." ),
403  KiBitmap( options_module_xpm ) );
404 
405  msg = AddHotkeyName( _( "Run Page Layout Editor" ), kicad_Manager_Hokeys_Descr, HK_RUN_PLEDITOR );
406  AddMenuItem( toolsMenu, ID_TO_PL_EDITOR, msg,
407  _( "Pl editor - Worksheet layout editor" ),
408  KiBitmap( pagelayout_load_xpm ) );
409 
410  // Menu Help:
411  wxMenu* helpMenu = new wxMenu;
412 
413  // Contents
414  AddMenuItem( helpMenu, wxID_HELP,
415  _( "KiCad &Manual" ),
416  _( "Open KiCad user manual" ),
417  KiBitmap( online_help_xpm ) );
418 
419  AddMenuItem( helpMenu, wxID_INDEX,
420  _( "&Getting Started in KiCad" ),
421  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
422  KiBitmap( help_xpm ) );
423 
424  AddMenuItem( helpMenu,
426  _( "&List Hotkeys" ),
427  _( "Displays the current hotkeys list and corresponding commands" ),
428  KiBitmap( hotkeys_xpm ) );
429 
430  // Separator
431  helpMenu->AppendSeparator();
432 
433  // Get involved with KiCad
435  _( "Get &Involved" ),
436  _( "Contribute to KiCad (opens a web browser)" ),
437  KiBitmap( info_xpm ) );
438 
439  helpMenu->AppendSeparator();
440 
441  // About
442  AddMenuItem( helpMenu, wxID_ABOUT,
443  _( "&About KiCad" ),
444  _( "About KiCad" ),
445  KiBitmap( info_xpm ) );
446 
447  // Create the menubar and append all submenus
448  menuBar->Append( fileMenu, _( "&File" ) );
449  menuBar->Append( browseMenu, _( "&Browse" ) );
450  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
451  menuBar->Append( toolsMenu, _( "&Tools" ) );
452  menuBar->Append( helpMenu, _( "&Help" ) );
453 
454  menuBar->Thaw();
455 
456  // Associate the menu bar with the frame, if no previous menubar
457  if( GetMenuBar() == NULL )
458  SetMenuBar( menuBar );
459  else
460  menuBar->Refresh();
461 
462  // Add the hotkey to the "show hotkey list" menu, because we do not have
463  // a management of the keyboard keys in Kicad.
464  // So all hotheys should be added to the menubar
465  // Note Use wxMenuBar::SetLabel only after the menubar
466  // has been associated with a frame. (see wxWidgets doc)
467  msg = AddHotkeyName( menuBar->GetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST ),
469  menuBar->SetLabel( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg );
470 }
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:300
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:671
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:795
wxFileHistory & GetFileHistory()
Definition: pgm_kicad.h:57
void KICAD_MANAGER_FRAME::ReCreateTreePrj ( )

Definition at line 179 of file mainframe.cpp.

References m_LeftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

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

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

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

Definition at line 291 of file mainframe.cpp.

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

Referenced by OnRunEeschema().

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

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

Referenced by OnRunPcbNew().

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

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick().

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

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

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

Definition at line 149 of file mainframe.cpp.

References GetProjectFileName(), and SchematicFileExtension.

Referenced by TREEPROJECT_ITEM::Activate().

150 {
151  wxFileName fn( GetProjectFileName() );
152 
153  fn.SetExt( SchematicFileExtension );
154 
155  return fn.GetFullPath();
156 }
const wxString SchematicFileExtension
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
void EDA_BASE_FRAME::SetAutoSaveInterval ( int  aInterval)
inherited

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

206 {
207  m_autoSaveInterval = aInterval;
208 
209  if( m_autoSaveTimer->IsRunning() )
210  {
211  if( m_autoSaveInterval > 0 )
212  {
213  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
214  }
215  else
216  {
217  m_autoSaveTimer->Stop();
218  m_autoSaveState = false;
219  }
220  }
221 }
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:145
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:151
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
void EDA_BASE_FRAME::SetMruPath ( const wxString &  aPath)
inlineinherited

Definition at line 356 of file wxstruct.h.

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

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

Definition at line 131 of file mainframe.cpp.

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

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

132 {
133  // ensure file name is absolute:
134  wxFileName fn( aFullProjectProFileName );
135 
136  if( !fn.IsAbsolute() )
137  fn.MakeAbsolute();
138 
139  Prj().SetProjectFullName( fn.GetFullPath() );
140 }
PROJECT & Prj()
Definition: kicad.cpp:293
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 249 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by KIWAY::ShowChangedIcons().

250 {
251  ReCreateMenuBar();
252  GetMenuBar()->Refresh();
253 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
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 242 of file basicframe.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

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

243 {
244  ReCreateMenuBar();
245  GetMenuBar()->Refresh();
246 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
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 185 of file mainframe.cpp.

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

186 {
187  return PgmTop().SysSearch();
188 }
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 388 of file basicframe.cpp.

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

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

390 {
391  wxFileHistory* fileHistory = aFileHistory;
392 
393  if( !fileHistory )
394  fileHistory = &Kiface().GetFileHistory();
395 
396  fileHistory->AddFileToHistory( FullFileName );
397 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:121
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:361
#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 137 of file wxstruct.h.

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

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

Definition at line 132 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::ConfigBaseName().

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

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

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

LAUNCHER_PANEL* KICAD_MANAGER_FRAME::m_Launcher
private

Definition at line 295 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME().

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

Definition at line 299 of file kicad.h.

Referenced by KICAD_MANAGER_FRAME(), and LoadSettings().

EDA_HOTKEY_CONFIG* KICAD_MANAGER_FRAME::m_manager_Hokeys_Descr
private

Definition at line 300 of file kicad.h.

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

wxTextCtrl* KICAD_MANAGER_FRAME::m_MessagesBox
private

Definition at line 296 of file kicad.h.

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

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 153 of file wxstruct.h.

Referenced by EDA_BASE_FRAME::LoadSettings().

wxAuiToolBar* KICAD_MANAGER_FRAME::m_VToolBar
private

Definition at line 297 of file kicad.h.


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