KiCad PCB EDA Suite
KICAD_MANAGER_FRAME Class Reference

The main KiCad project manager frame. More...

#include <kicad_manager_frame.h>

Inheritance diagram for KICAD_MANAGER_FRAME:
EDA_BASE_FRAME KIWAY_HOLDER

Public Types

enum  HOLDER_TYPE { DIALOG, FRAME, PANEL, SCREEN }
 

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 OnArchiveFiles (wxCommandEvent &event)
 
void OnUnarchiveFiles (wxCommandEvent &event)
 
void OnOpenFileInTextEditor (wxCommandEvent &event)
 
void OnBrowseInFileExplorer (wxCommandEvent &event)
 
void OnFileHistory (wxCommandEvent &event)
 
void OnClearFileHistory (wxCommandEvent &aEvent)
 
void OnExit (wxCommandEvent &event)
 
void ReCreateMenuBar () override
 Recreates the menu bar. More...
 
void RecreateBaseHToolbar ()
 (Re)Create the horizontal toolbar More...
 
void RecreateLauncher ()
 
void OnImportEagleFiles (wxCommandEvent &event)
 Open dialog to import Eagle schematic and board files. More...
 
void PrintMsg (const wxString &aText)
 Displays aText in the text panel. More...
 
void PrintPrjInfo ()
 Prints the current working directory name and the projet name on the text panel. More...
 
void ClearMsg ()
 Erase the text panel. More...
 
void RefreshProjectTree ()
 
void CreateNewProject (const wxFileName &aProjectFileName)
 Creates a new project by setting up and initial project, schematic, and board files. More...
 
void LoadProject (const wxFileName &aProjectFileName)
 
void LoadSettings (APP_SETTINGS_BASE *aCfg) override
 Load common frame parameters from a configuration file. More...
 
void SaveSettings (APP_SETTINGS_BASE *aCfg) override
 Saves common frame parameters to a configuration data file. More...
 
void ShowChangedLanguage () override
 Redraw the menus and what not in current language. More...
 
void CommonSettingsChanged (bool aEnvVarsChanged) override
 Notification event that some of the common (suite-wide) settings have changed. More...
 
void OnChangeWatchedPaths (wxCommandEvent &aEvent)
 Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of wahtched paths. More...
 
void SyncToolbars () override
 Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state. More...
 
void InstallPreferences (PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
 Function InstallPreferences Allow a frame to load its preference panels (if any) into the preferences dialog. More...
 
void SetProjectFileName (const wxString &aFullProjectProFileName)
 
const wxString GetProjectFileName ()
 
const wxString SchFileName ()
 
const wxString PcbFileName ()
 
const wxString PcbLegacyFileName ()
 
void ReCreateTreePrj ()
 
EDA_UNITS GetUserUnits () const
 Return the user units currently in use. More...
 
void SetUserUnits (EDA_UNITS aUnits)
 
void ChangeUserUnits (EDA_UNITS aUnits)
 
SETTINGS_MANAGERGetSettingsManager () const
 
virtual int GetSeverity (int aErrorCode) const
 
TOOL_MANAGERGetToolManager () const
 Return the MVC controller. More...
 
virtual void PushTool (const std::string &actionName)
 NB: the definition of "tool" is different at the user level. More...
 
virtual void PopTool (const std::string &actionName)
 
bool ToolStackIsEmpty ()
 
std::string CurrentToolName () const
 
bool IsCurrentTool (const TOOL_ACTION &aAction) const
 
virtual void DisplayToolMsg (const wxString &msg)
 
bool GetDoImmediateActions () const
 Indicates that hotkeys should perform an immediate action even if another tool is currently active. More...
 
bool GetDragSelects () const
 Indicates that a drag should draw a selection rectangle, even when started over an item. More...
 
bool GetMoveWarpsCursor () const
 Indicates that a move operation should warp the mouse pointer to the origin of the move object. More...
 
bool ProcessEvent (wxEvent &aEvent) override
 Override the default process event handler to implement the auto save feature. More...
 
virtual void OnCharHook (wxKeyEvent &event)
 Capture the key event before it is sent to the GUI. More...
 
void OnMenuOpen (wxMenuEvent &event)
 Workaround some issues in wxWidgets where the menu events aren't captured by the menus themselves. More...
 
virtual void OnMove (wxMoveEvent &aEvent)
 
void SetAutoSaveInterval (int aInterval)
 
int GetAutoSaveInterval () const
 
bool IsType (FRAME_T aType) const
 
void OnKicadAbout (wxCommandEvent &event)
 
void OnPreferences (wxCommandEvent &event)
 
void LoadWindowSettings (WINDOW_SETTINGS *aCfg)
 Loads window settings from the given settings object Normally called by LoadSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window. More...
 
void SaveWindowSettings (WINDOW_SETTINGS *aCfg)
 Saves window settings to the given settings object Normally called by SaveSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window. More...
 
virtual WINDOW_SETTINGSGetWindowSettings (APP_SETTINGS_BASE *aCfg)
 Returns a pointer to the window settings for this frame. More...
 
wxString ConfigBaseName ()
 
virtual void SaveProjectSettings ()
 Save changes to the project settings to the project (.pro) file. More...
 
void ImportHotkeyConfigFromFile (std::map< std::string, TOOL_ACTION * > aActionMap, const wxString &aDefaultShortname)
 Prompt the user for a hotkey file to read, and read it. More...
 
wxString GetFileFromHistory (int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=NULL)
 Fetches the file name from the file history list. More...
 
void ClearFileHistory (FILE_HISTORY *aFileHistory=NULL)
 Removes all files from the file history. More...
 
void UpdateFileHistory (const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
 Update the list of recently opened files. More...
 
void SetMruPath (const wxString &aPath)
 
wxString GetMruPath () const
 
void AddStandardHelpMenu (wxMenuBar *aMenuBar)
 Adds the standard KiCad help menu to the menubar. More...
 
bool IsWritable (const wxFileName &aFileName)
 Checks if aFileName can be written. More...
 
void CheckForAutoSaveFile (const wxFileName &aFileName)
 Check if an auto save file exists for aFileName and takes the appropriate action depending on the user input. More...
 
virtual void UpdateStatusBar ()
 Update the status bar information. More...
 
virtual void RefreshCanvas ()
 Notification to refresh the drawing canvas (if any). More...
 
const wxString & GetAboutTitle () const
 
void SetShutdownBlockReason (const wxString &reason)
 Sets the block reason why the window/application is preventing OS shutdown. More...
 
void RemoveShutdownBlockReason ()
 Removes any shutdown block reason set. More...
 
bool SupportsShutdownBlockReason ()
 Whether or not the window supports setting a shutdown block reason. More...
 
virtual bool IsContentModified ()
 Get if the contents of the frame have been modified since the last save. More...
 
HOLDER_TYPE GetType ()
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Protected Member Functions

void onAutoSaveTimer (wxTimerEvent &aEvent)
 Handle the auto save timer event. More...
 
virtual bool isAutoSaveRequired () const
 Return the auto save status of the application. More...
 
virtual bool doAutoSave ()
 This should be overridden by the derived class to handle the auto save feature. More...
 
virtual void unitsChangeRefresh ()
 Called when when the units setting has changed to allow for any derived classes to handle refreshing and controls that have units based measurements in them. More...
 

Static Protected Member Functions

static wxString GetBackupSuffix ()
 
static wxString GetAutoSaveFilePrefix ()
 

Protected Attributes

FRAME_T m_Ident
 
wxPoint m_FramePos
 
wxSize m_FrameSize
 
wxString m_AboutTitle
 
wxAuiManager m_auimgr
 
wxString m_configName
 
SETTINGS_MANAGERm_settingsManager
 
TOOL_MANAGERm_toolManager
 
ACTIONSm_actions
 
std::vector< std::string > m_toolStack
 
bool m_immediateActions
 
bool m_dragSelects
 
bool m_moveWarpsCursor
 
bool m_hasAutoSave
 
bool m_autoSaveState
 
int m_autoSaveInterval
 
wxTimer * m_autoSaveTimer
 
wxString m_perspective
 
wxString m_mruPath
 
EDA_UNITS m_userUnits
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private Member Functions

APP_SETTINGS_BASEconfig () override
 Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME. More...
 
const SEARCH_STACKsys_search () override
 Return a SEARCH_STACK pertaining to entire program. More...
 
wxString help_name () override
 
void language_change (wxCommandEvent &event)
 

Private Attributes

TREE_PROJECT_FRAMEm_leftWin
 
ACTION_TOOLBARm_launcher
 
wxTextCtrl * m_messagesBox
 
ACTION_TOOLBARm_mainToolBar
 
int m_leftWinWidth
 
bool m_active_project
 

Detailed Description

The main KiCad project manager frame.

It is not a KIWAY_PLAYER.

Definition at line 74 of file kicad_manager_frame.h.

Member Enumeration Documentation

◆ HOLDER_TYPE

enum KIWAY_HOLDER::HOLDER_TYPE
inherited
Enumerator
DIALOG 
FRAME 
PANEL 
SCREEN 

Definition at line 42 of file kiway_holder.h.

Constructor & Destructor Documentation

◆ KICAD_MANAGER_FRAME()

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

◆ ~KICAD_MANAGER_FRAME()

KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME ( )

Definition at line 169 of file kicad_manager_frame.cpp.

170 {
171  // Shutdown all running tools
172  if( m_toolManager )
174 
175  delete m_actions;
176  delete m_toolManager;
177 
178  m_auimgr.UnInit();
179 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
ACTIONS * m_actions
wxAuiManager m_auimgr
TOOL_MANAGER * m_toolManager

References EDA_BASE_FRAME::m_actions, EDA_BASE_FRAME::m_auimgr, EDA_BASE_FRAME::m_toolManager, and TOOL_MANAGER::ShutdownAllTools().

Member Function Documentation

◆ AddStandardHelpMenu()

void EDA_BASE_FRAME::AddStandardHelpMenu ( wxMenuBar *  aMenuBar)
inherited

Adds the standard KiCad help menu to the menubar.

Definition at line 397 of file eda_base_frame.cpp.

398 {
399  COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
400  ACTION_MENU* helpMenu = new ACTION_MENU( false );
401 
402  helpMenu->SetTool( commonControl );
403 
404  helpMenu->Add( ACTIONS::help );
405  helpMenu->Add( ACTIONS::gettingStarted );
406  helpMenu->Add( ACTIONS::listHotKeys );
407  helpMenu->Add( ACTIONS::getInvolved );
408 
409  helpMenu->AppendSeparator();
410  helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );
411 
412  aMenuBar->Append( helpMenu, _( "&Help" ) );
413 }
static TOOL_ACTION listHotKeys
Definition: actions.h:171
ACTION_MENU.
Definition: action_menu.h:43
const BITMAP_OPAQUE about_xpm[1]
Definition: about.cpp:84
COMMON_CONTROL.
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION help
Definition: actions.h:170
TOOL_MANAGER * m_toolManager
static TOOL_ACTION getInvolved
Definition: actions.h:172
static TOOL_ACTION gettingStarted
Definition: actions.h:169

References _, about_xpm, ACTIONS::getInvolved, ACTIONS::gettingStarted, TOOL_MANAGER::GetTool(), ACTIONS::help, ACTIONS::listHotKeys, and EDA_BASE_FRAME::m_toolManager.

Referenced by EDA_3D_VIEWER::CreateMenuBar(), ReCreateMenuBar(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), and PCB_EDIT_FRAME::ReCreateMenuBar().

◆ ChangeUserUnits()

void EDA_BASE_FRAME::ChangeUserUnits ( EDA_UNITS  aUnits)
inlineinherited

Definition at line 225 of file eda_base_frame.h.

226  {
227  SetUserUnits( aUnits );
229  }
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void SetUserUnits(EDA_UNITS aUnits)

References EDA_BASE_FRAME::SetUserUnits(), and EDA_BASE_FRAME::unitsChangeRefresh().

Referenced by COMMON_TOOLS::ImperialUnits(), COMMON_TOOLS::MetricUnits(), and COMMON_TOOLS::ToggleUnits().

◆ CheckForAutoSaveFile()

void EDA_BASE_FRAME::CheckForAutoSaveFile ( const wxFileName &  aFileName)
inherited

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

Definition at line 735 of file eda_base_frame.cpp.

736 {
737  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
738 
739  wxFileName autoSaveFileName = aFileName;
740 
741  // Check for auto save file.
742  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
743 
744  wxLogTrace( traceAutoSave,
745  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
746 
747  if( !autoSaveFileName.FileExists() )
748  return;
749 
750  wxString msg = wxString::Format( _(
751  "Well this is potentially embarrassing!\n"
752  "It appears that the last time you were editing the file\n"
753  "\"%s\"\n"
754  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
755  GetChars( aFileName.GetFullName() )
756  );
757 
758  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
759 
760  // Make a backup of the current file, delete the file, and rename the auto save file to
761  // the file name.
762  if( response == wxYES )
763  {
764  // Get the backup file name.
765  wxFileName backupFileName = aFileName;
766  backupFileName.SetExt( aFileName.GetExt() + GetBackupSuffix() );
767 
768  // If an old backup file exists, delete it. If an old copy of the file exists, rename
769  // it to the backup file name
770  if( aFileName.FileExists() )
771  {
772  // Rename the old file to the backup file name.
773  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath(), true ) )
774  {
775  msg.Printf( _( "Could not create backup file \"%s\"" ),
776  GetChars( backupFileName.GetFullPath() ) );
777  wxMessageBox( msg );
778  }
779  }
780 
781  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
782  {
783  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
784  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
785  }
786  }
787  else
788  {
789  wxLogTrace( traceAutoSave,
790  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
791 
792  // Remove the auto save file when using the previous file as is.
793  wxRemoveFile( autoSaveFileName.GetFullPath() );
794  }
795 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
static wxString GetBackupSuffix()
static wxString GetAutoSaveFilePrefix()
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:101
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 _(s)
Definition: 3d_actions.cpp:33

References _, Format(), EDA_BASE_FRAME::GetAutoSaveFilePrefix(), EDA_BASE_FRAME::GetBackupSuffix(), GetChars(), Pgm(), and traceAutoSave.

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

◆ ClearFileHistory()

void EDA_BASE_FRAME::ClearFileHistory ( FILE_HISTORY aFileHistory = NULL)
inherited

Removes all files from the file history.

Parameters
aFileHistoryThe FILE_HISTORY in use. If null, the main application file history is used

Definition at line 643 of file eda_base_frame.cpp.

644 {
645  if( !aFileHistory )
646  aFileHistory = &Kiface().GetFileHistory();
647 
648  aFileHistory->ClearFileHistory();
649 }
void ClearFileHistory()
Clear all entries from the file history.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:125

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

Referenced by GERBVIEW_FRAME::OnClearDrlFileHistory(), OnClearFileHistory(), PCB_EDIT_FRAME::OnClearFileHistory(), SCH_EDIT_FRAME::OnClearFileHistory(), GERBVIEW_FRAME::OnClearGbrFileHistory(), GERBVIEW_FRAME::OnClearJobFileHistory(), and GERBVIEW_FRAME::OnClearZipFileHistory().

◆ ClearMsg()

void KICAD_MANAGER_FRAME::ClearMsg ( )

Erase the text panel.

Definition at line 470 of file kicad_manager_frame.cpp.

471 {
472  m_messagesBox->Clear();
473 }

References m_messagesBox.

Referenced by LoadProject(), KICAD_MANAGER_CONTROL::NewFromTemplate(), and OnImportEagleFiles().

◆ CommonSettingsChanged()

void KICAD_MANAGER_FRAME::CommonSettingsChanged ( bool  aEnvVarsChanged)
overridevirtual

Notification event that some of the common (suite-wide) settings have changed.

Update menus, toolbars, local variables, etc.

Reimplemented from EDA_BASE_FRAME.

Definition at line 463 of file kicad_manager_frame.cpp.

464 {
465  int historySize = Pgm().GetCommonSettings()->m_System.file_history_size;
466  PgmTop().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) );
467 }
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:56
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:83

References PGM_KICAD::GetFileHistory(), Pgm(), PgmTop(), and FILE_HISTORY::SetMaxFiles().

◆ config()

APP_SETTINGS_BASE * KICAD_MANAGER_FRAME::config ( )
overrideprivatevirtual

Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented from EDA_BASE_FRAME.

Definition at line 182 of file kicad_manager_frame.cpp.

183 {
185  wxASSERT( ret );
186  return ret;
187 }
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:75
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
APP_SETTINGS_BASE * PgmSettings()
Definition: pgm_kicad.h:58

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

◆ ConfigBaseName()

wxString EDA_BASE_FRAME::ConfigBaseName ( )
inlineinherited
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, except for frames shown in multiple modes in which case the m_configName must be set to the base name so that a single config can be used.

Definition at line 379 of file eda_base_frame.h.

380  {
381  wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName;
382  return baseCfgName;
383  }
wxString m_configName

References EDA_BASE_FRAME::m_configName.

Referenced by EDA_DRAW_FRAME::LoadSettings(), EDA_BASE_FRAME::SaveWindowSettings(), and ACTION_MANAGER::UpdateHotKeys().

◆ CreateNewProject()

void KICAD_MANAGER_FRAME::CreateNewProject ( const wxFileName &  aProjectFileName)

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

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

Parameters
aProjectFileNameis the absolute path of the project file name.

Definition at line 352 of file kicad_manager_frame.cpp.

353 {
354  wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
355  "Project folder must exist and be writable to create a new project." );
356 
357  // Init project filename. This clears all elements from the project object.
358  SetProjectFileName( aProjectFileName.GetFullPath() );
359 
360  // Copy kicad.pro file from template folder.
361  if( !aProjectFileName.FileExists() )
362  {
363  wxString srcFileName = sys_search().FindValidPath( "kicad.pro" );
364 
365  // Create a minimal project (.pro) file if the template project file could not be copied.
366  if( !wxFileName::FileExists( srcFileName )
367  || !wxCopyFile( srcFileName, aProjectFileName.GetFullPath() ) )
368  {
370  }
371  }
372 
373  // Ensure a "stub" for a schematic root sheet and a board exist.
374  // It will avoid messages from the schematic editor or the board editor to create a new file
375  // And forces the user to create main files under the right name for the project manager
376  wxFileName fn( aProjectFileName.GetFullPath() );
377  fn.SetExt( LegacySchematicFileExtension );
378 
379  // If a <project>.sch file does not exist, create a "stub" file ( minimal schematic file )
380  if( !fn.FileExists() )
381  {
382  wxFile file( fn.GetFullPath(), wxFile::write );
383 
384  if( file.IsOpened() )
385  file.Write( wxT( "EESchema Schematic File Version 2\n"
386  "EELAYER 25 0\nEELAYER END\n$EndSCHEMATC\n" ) );
387 
388  // wxFile dtor will close the file
389  }
390 
391  // If a <project>.kicad_pcb or <project>.brd file does not exist,
392  // create a .kicad_pcb "stub" file
393  fn.SetExt( KiCadPcbFileExtension );
394  wxFileName leg_fn( fn );
395  leg_fn.SetExt( LegacyPcbFileExtension );
396 
397  if( !fn.FileExists() && !leg_fn.FileExists() )
398  {
399  wxFile file( fn.GetFullPath(), wxFile::write );
400 
401  if( file.IsOpened() )
402  file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );
403 
404  // wxFile dtor will close the file
405  }
406 }
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:73
const std::string LegacyPcbFileExtension
std::vector< PARAM_CFG * > s_KicadManagerParams
const std::string KiCadPcbFileExtension
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative.
Definition: project.cpp:350
const std::string LegacySchematicFileExtension
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void SetProjectFileName(const wxString &aFullProjectProFileName)
const SEARCH_STACK & sys_search() override
Return a SEARCH_STACK pertaining to entire program.
#define GeneralGroupName

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

Referenced by KICAD_MANAGER_CONTROL::NewFromTemplate(), KICAD_MANAGER_CONTROL::NewProject(), and KICAD_MANAGER_CONTROL::SaveProjectAs().

◆ CurrentToolName()

std::string EDA_BASE_FRAME::CurrentToolName ( ) const
inherited

Definition at line 252 of file eda_base_frame.cpp.

253 {
254  if( m_toolStack.empty() )
255  return ACTIONS::selectionTool.GetName();
256  else
257  return m_toolStack.back();
258 }
std::vector< std::string > m_toolStack
static TOOL_ACTION selectionTool
Definition: actions.h:146

References EDA_BASE_FRAME::m_toolStack, and ACTIONS::selectionTool.

Referenced by TOOL_MANAGER::processEvent().

◆ DisplayToolMsg()

virtual void EDA_BASE_FRAME::DisplayToolMsg ( const wxString &  msg)
inlinevirtualinherited

Reimplemented in EDA_DRAW_FRAME.

Definition at line 253 of file eda_base_frame.h.

253 {};

Referenced by EDA_BASE_FRAME::PopTool(), and EDA_BASE_FRAME::PushTool().

◆ doAutoSave()

bool EDA_BASE_FRAME::doAutoSave ( )
protectedvirtualinherited

This 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 335 of file eda_base_frame.cpp.

336 {
337  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
338 }

Referenced by EDA_BASE_FRAME::onAutoSaveTimer().

◆ GetAboutTitle()

const wxString& EDA_BASE_FRAME::GetAboutTitle ( ) const
inlineinherited

Definition at line 517 of file eda_base_frame.h.

517 { return m_AboutTitle; }
wxString m_AboutTitle

References EDA_BASE_FRAME::m_AboutTitle.

Referenced by DIALOG_ABOUT::DIALOG_ABOUT().

◆ GetAutoSaveFilePrefix()

static wxString EDA_BASE_FRAME::GetAutoSaveFilePrefix ( )
inlinestaticprotectedinherited
Returns
the string to prepend to a file name for automatic save.

Definition at line 171 of file eda_base_frame.h.

172  {
173  return wxT( "_autosave-" );
174  }

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), SCH_EDIT_FRAME::doAutoSave(), PCB_EDIT_FRAME::doAutoSave(), PCB_EDIT_FRAME::Files_io_from_id(), SCH_EDIT_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnExportSTEP(), SCH_EDIT_FRAME::SaveEEFile(), and PCB_EDIT_FRAME::SavePcbFile().

◆ GetAutoSaveInterval()

int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 303 of file eda_base_frame.h.

303 { return m_autoSaveInterval; }

References EDA_BASE_FRAME::m_autoSaveInterval.

◆ GetBackupSuffix()

static wxString EDA_BASE_FRAME::GetBackupSuffix ( )
inlinestaticprotectedinherited
Returns
the suffix to be appended to the file extension on backup

Definition at line 163 of file eda_base_frame.h.

164  {
165  return wxT( "-bak" );
166  }

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), PCB_EDIT_FRAME::createBackupFile(), PCB_EDIT_FRAME::Files_io_from_id(), and SCH_EDIT_FRAME::SaveEEFile().

◆ GetDoImmediateActions()

bool EDA_BASE_FRAME::GetDoImmediateActions ( ) const
inlineinherited

Indicates that hotkeys should perform an immediate action even if another tool is currently active.

If false, the first hotkey should select the relevant tool.

Definition at line 259 of file eda_base_frame.h.

259 { return m_immediateActions; }

References EDA_BASE_FRAME::m_immediateActions.

◆ GetDragSelects()

bool EDA_BASE_FRAME::GetDragSelects ( ) const
inlineinherited

Indicates that a drag should draw a selection rectangle, even when started over an item.

Definition at line 265 of file eda_base_frame.h.

265 { return m_dragSelects; }

References EDA_BASE_FRAME::m_dragSelects.

Referenced by EE_SELECTION_TOOL::Main().

◆ GetFileFromHistory()

wxString EDA_BASE_FRAME::GetFileFromHistory ( int  cmdId,
const wxString &  type,
FILE_HISTORY aFileHistory = NULL 
)
inherited

Fetches the file name from the file history list.

This removes the selected file, if this file does not exist. The menu is also updated, if FILE_HISTORY::UseMenu was called at init time

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

Definition at line 610 of file eda_base_frame.cpp.

612 {
613  FILE_HISTORY* fileHistory = aFileHistory;
614 
615  if( !fileHistory )
616  fileHistory = &Kiface().GetFileHistory();
617 
618  int baseId = fileHistory->GetBaseId();
619 
620  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
621 
622  unsigned i = cmdId - baseId;
623 
624  if( i < fileHistory->GetCount() )
625  {
626  wxString fn = fileHistory->GetHistoryFile( i );
627 
628  if( wxFileName::FileExists( fn ) )
629  return fn;
630  else
631  {
632  wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
633  wxMessageBox( msg );
634 
635  fileHistory->RemoveFileFromHistory( i );
636  }
637  }
638 
639  return wxEmptyString;
640 }
This class implements a file history object to store a list of files, that can then be added to a men...
Definition: filehistory.h:42
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
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 _(s)
Definition: 3d_actions.cpp:33
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:125

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

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

◆ GetMoveWarpsCursor()

bool EDA_BASE_FRAME::GetMoveWarpsCursor ( ) const
inlineinherited

Indicates that a move operation should warp the mouse pointer to the origin of the move object.

This improves snapping, but some users are alergic to mouse warping.

Definition at line 271 of file eda_base_frame.h.

271 { return m_moveWarpsCursor; }

References EDA_BASE_FRAME::m_moveWarpsCursor.

Referenced by SCH_MOVE_TOOL::Main(), and LIB_MOVE_TOOL::Main().

◆ GetMruPath()

wxString EDA_BASE_FRAME::GetMruPath ( ) const
inlineinherited

◆ GetProjectFileName()

const wxString KICAD_MANAGER_FRAME::GetProjectFileName ( )

Definition at line 210 of file kicad_manager_frame.cpp.

211 {
212  return Prj().GetProjectFullName();
213 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96

References PROJECT::GetProjectFullName(), and KIWAY_HOLDER::Prj().

Referenced by TREE_PROJECT_FRAME::AddItemToTreeProject(), TREE_PROJECT_FRAME::FileWatcherReset(), TREE_PROJECT_FRAME::findSubdirTreeItem(), OnArchiveFiles(), OnCloseWindow(), TREE_PROJECT_FRAME::OnCreateNewDirectory(), OnImportEagleFiles(), TREE_PROJECT_FRAME::OnOpenDirectory(), OnUnarchiveFiles(), PcbFileName(), PcbLegacyFileName(), PrintPrjInfo(), TREE_PROJECT_FRAME::ReCreateTreePrj(), and SchFileName().

◆ GetSettingsManager()

SETTINGS_MANAGER* EDA_BASE_FRAME::GetSettingsManager ( ) const
inlineinherited

Definition at line 231 of file eda_base_frame.h.

231 { return m_settingsManager; }
SETTINGS_MANAGER * m_settingsManager

References EDA_BASE_FRAME::m_settingsManager.

Referenced by GERBVIEW_FRAME::applyDisplaySettingsToGAL().

◆ GetSeverity()

virtual int EDA_BASE_FRAME::GetSeverity ( int  aErrorCode) const
inlinevirtualinherited

Reimplemented in PCB_EDIT_FRAME.

Definition at line 233 of file eda_base_frame.h.

References RPT_SEVERITY_UNDEFINED.

Referenced by RC_TREE_MODEL::GetValue().

◆ GetToolManager()

TOOL_MANAGER* EDA_BASE_FRAME::GetToolManager ( ) const
inlineinherited

Return the MVC controller.

Definition at line 238 of file eda_base_frame.h.

238 { return m_toolManager; }
TOOL_MANAGER * m_toolManager

References EDA_BASE_FRAME::m_toolManager.

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), TREEPROJECT_ITEM::Activate(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), LIB_CONTROL::AddSymbolToSchematic(), BOARD_COMMIT::BOARD_COMMIT(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), EDA_BASE_FRAME::CommonSettingsChanged(), DIALOG_ERC::deleteAllMarkers(), DIALOG_DRC::deleteAllMarkers(), DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), TRACK_WIDTH_MENU::eventHandler(), DIFF_PAIR_MENU::eventHandler(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), GERBVIEW_FRAME::GERBVIEW_FRAME(), FP_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool(), InstallPreferences(), FOOTPRINT_EDIT_FRAME::InstallPreferences(), LIB_EDIT_FRAME::InstallPreferences(), GERBVIEW_FRAME::InstallPreferences(), PCB_EDIT_FRAME::InstallPreferences(), SCH_EDIT_FRAME::InstallPreferences(), LIB_VIEW_FRAME::LIB_VIEW_FRAME(), SIM_PLOT_FRAME::onClose(), SYMBOL_TREE_PANE::onComponentSelected(), DIALOG_DRC::OnDeleteOneClick(), DIALOG_ERC::OnERCItemSelected(), FOOTPRINTS_LISTBOX::OnLeftDClick(), SIM_PLOT_FRAME::onProbe(), DIALOG_PLOT::onRunDRC(), HIERARCHY_NAVIG_DLG::onSelectSheetPath(), DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick(), SIM_PLOT_FRAME::onTune(), DIALOG_PLOT::Plot(), EDA_BASE_FRAME::PopTool(), SCH_EDIT_FRAME::PutDataInPreviousState(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), DIALOG_FIND::search(), PCB_BASE_FRAME::SetFastGrid1(), PCB_BASE_FRAME::SetFastGrid2(), CVPCB_MAINFRAME::setupEventHandlers(), PCB_LAYER_WIDGET::SyncLayerAlphaIndicators(), PANEL_SETUP_NETCLASSES::TransferDataFromWindow(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow(), EDA_DRAW_FRAME::UpdateMsgPanel(), DIALOG_NETLIST::~DIALOG_NETLIST(), and DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB().

◆ GetType()

HOLDER_TYPE KIWAY_HOLDER::GetType ( )
inlineinherited

Definition at line 49 of file kiway_holder.h.

49 { return m_type; }
HOLDER_TYPE m_type
Definition: kiway_holder.h:82

References KIWAY_HOLDER::m_type.

Referenced by DIALOG_SHIM::DIALOG_SHIM().

◆ GetUserUnits()

EDA_UNITS EDA_BASE_FRAME::GetUserUnits ( ) const
inlineinherited

Return the user units currently in use.

Definition at line 215 of file eda_base_frame.h.

216  {
217  return m_userUnits;
218  }
EDA_UNITS m_userUnits

References EDA_BASE_FRAME::m_userUnits.

Referenced by PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs(), PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth(), PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize(), PCB_EDIT_FRAME::Create_MuWaveComponent(), MWAVE::CreateMicrowaveInductor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), GERBER_FILE_IMAGE::DisplayImageInfo(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), LIB_EDIT_TOOL::editGraphicProperties(), LIB_PIN_TOOL::EditPinProperties(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), EVT_GRID_CMD_CELL_CHANGED(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::GenFootprintsReport(), PANEL_MODEDIT_DEFAULTS::getGridValue(), PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue(), PANEL_SETUP_NETCLASSES::getNetclassValue(), GetUserUnits(), GRID_MENU::GRID_MENU(), PCB_INSPECTION_TOOL::highlightNet(), GERBVIEW_FRAME::Liste_D_Codes(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), PANEL_SETUP_BOARD_STACKUP::onThicknessChange(), PANEL_SETUP_BOARD_STACKUP::onUpdateThicknessValue(), PANEL_PREV_3D::PANEL_PREV_3D(), PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP(), POSITION_RELATIVE_TOOL::PositionRelative(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateMenuBar(), CONNECTION_SUBGRAPH::ResolveDrivers(), DISPLAY_FOOTPRINTS_FRAME::SyncToolbars(), FOOTPRINT_EDIT_FRAME::SyncToolbars(), LIB_EDIT_FRAME::SyncToolbars(), GERBVIEW_FRAME::SyncToolbars(), PCB_EDIT_FRAME::SyncToolbars(), SCH_EDIT_FRAME::SyncToolbars(), DRC::testDrilledHoles(), DRC::testUnconnected(), COMMON_TOOLS::ToggleUnits(), PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup(), PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow(), PANEL_SETUP_NETCLASSES::TransferDataFromWindow(), PANEL_EESCHEMA_SETTINGS::TransferDataToWindow(), PANEL_MODEDIT_SETTINGS::TransferDataToWindow(), PANEL_GERBVIEW_SETTINGS::TransferDataToWindow(), PANEL_PCBNEW_SETTINGS::TransferDataToWindow(), PANEL_SETUP_NETCLASSES::TransferDataToWindow(), UNIT_BINDER::UNIT_BINDER(), GRID_MENU::update(), TRACK_WIDTH_MENU::update(), DIFF_PAIR_MENU::update(), GERBVIEW_FRAME::updateDCodeSelectBox(), GERBVIEW_FRAME::updateGridSelectBox(), PCB_BASE_FRAME::UpdateGridSelectBox(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PNS_TUNE_STATUS_POPUP::UpdateStatus(), SCH_BASE_FRAME::UpdateStatusBar(), PCB_BASE_FRAME::UpdateStatusBar(), GERBVIEW_FRAME::UpdateStatusBar(), PCB_EDIT_FRAME::UpdateTrackWidthSelectBox(), PCB_EDIT_FRAME::UpdateViaSizeSelectBox(), DRC::userUnits(), PANEL_SETUP_TRACKS_AND_VIAS::validateData(), and PANEL_SETUP_NETCLASSES::validateData().

◆ GetWindowSettings()

WINDOW_SETTINGS * EDA_BASE_FRAME::GetWindowSettings ( APP_SETTINGS_BASE aCfg)
virtualinherited

Returns a pointer to the window settings for this frame.

By default, points to aCfg->m_Window for top-level frames.

Parameters
aCfgis this frame's config object

Reimplemented in SIM_PLOT_FRAME, FOOTPRINT_WIZARD_FRAME, FOOTPRINT_VIEWER_FRAME, LIB_VIEW_FRAME, and DISPLAY_FOOTPRINTS_FRAME.

Definition at line 566 of file eda_base_frame.cpp.

567 {
568  return &aCfg->m_Window;
569 }
WINDOW_SETTINGS m_Window
Definition: app_settings.h:132

References APP_SETTINGS_BASE::m_Window.

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

◆ help_name()

wxString KICAD_MANAGER_FRAME::help_name ( )
overrideprivatevirtual

Reimplemented from EDA_BASE_FRAME.

Definition at line 255 of file kicad_manager_frame.cpp.

256 {
257  return PgmTop().GetHelpFileName();
258 }
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
wxString GetHelpFileName()
Definition: pgm_kicad.h:62

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

◆ ImportHotkeyConfigFromFile()

void EDA_BASE_FRAME::ImportHotkeyConfigFromFile ( std::map< std::string, TOOL_ACTION * >  aActionMap,
const wxString &  aDefaultShortname 
)
inherited

Prompt the user for a hotkey file to read, and read it.

Parameters
aActionMap= current hotkey map (over which the imported hotkeys will be applied)
aDefaultShortname= a default short name (extension not needed) like eechema, kicad...

◆ InstallPreferences()

void KICAD_MANAGER_FRAME::InstallPreferences ( PAGED_DIALOG ,
PANEL_HOTKEYS_EDITOR  
)
overridevirtual

Function InstallPreferences Allow a frame to load its preference panels (if any) into the preferences dialog.

Parameters
aParenta paged dialog into which the preference panels should be installed

Reimplemented from EDA_BASE_FRAME.

Definition at line 494 of file kicad_manager_frame.cpp.

496 {
497  aHotkeysPanel->AddHotKeys( GetToolManager() );
498 }
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.

References PANEL_HOTKEYS_EDITOR::AddHotKeys(), and EDA_BASE_FRAME::GetToolManager().

◆ isAutoSaveRequired()

virtual bool EDA_BASE_FRAME::isAutoSaveRequired ( ) const
inlineprotectedvirtualinherited

Return 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 186 of file eda_base_frame.h.

186 { return false; }

Referenced by EDA_BASE_FRAME::ProcessEvent().

◆ IsContentModified()

bool EDA_BASE_FRAME::IsContentModified ( )
virtualinherited

Get if the contents of the frame have been modified since the last save.

Returns
true if the contents of the frame have not been saved

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

Definition at line 798 of file eda_base_frame.cpp.

799 {
800  // This function should be overridden in child classes
801  return false;
802 }

◆ IsCurrentTool()

bool EDA_BASE_FRAME::IsCurrentTool ( const TOOL_ACTION aAction) const
inherited

Definition at line 261 of file eda_base_frame.cpp.

262 {
263  if( m_toolStack.empty() )
264  return &aAction == &ACTIONS::selectionTool;
265  else
266  return m_toolStack.back() == aAction.GetName();
267 }
std::vector< std::string > m_toolStack
static TOOL_ACTION selectionTool
Definition: actions.h:146
const std::string & GetName() const
Function GetName() Returns name of the action.
Definition: tool_action.h:78

References TOOL_ACTION::GetName(), EDA_BASE_FRAME::m_toolStack, and ACTIONS::selectionTool.

Referenced by PCB_INSPECTION_TOOL::HighlightNetTool(), SCH_EDIT_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), DISPLAY_FOOTPRINTS_FRAME::SyncToolbars(), and LIB_EDIT_FRAME::SyncToolbars().

◆ IsType()

bool EDA_BASE_FRAME::IsType ( FRAME_T  aType) const
inlineinherited

Definition at line 305 of file eda_base_frame.h.

305 { return m_Ident == aType; }

References EDA_BASE_FRAME::m_Ident.

Referenced by LIB_CONTROL::AddLibrary(), PCBNEW_CONTROL::AddLibrary(), LIB_CONTROL::AddSymbol(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), BOARD_COMMIT::BOARD_COMMIT(), EDA_3D_VIEWER::CreateMenuBar(), LIB_CONTROL::CutCopyDelete(), DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES(), DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT(), DIALOG_PUSH_PAD_PROPERTIES::DIALOG_PUSH_PAD_PROPERTIES(), KIGFX::SCH_VIEW::DisplaySheet(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), LIB_CONTROL::DuplicateSymbol(), LIB_CONTROL::EditSymbol(), LIB_CONTROL::ExportSymbol(), LIB_CONTROL::Init(), DIALOG_EDIT_ONE_FIELD::init(), SELECTION_TOOL::Init(), DIALOG_PAD_PROPERTIES::initValues(), PICKER_TOOL::Main(), LIB_CONTROL::OnDeMorgan(), PCB_LAYER_WIDGET::OnRenderEnable(), PCBNEW_CONTROL::Paste(), LIB_CONTROL::PinLibrary(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), LIB_CONTROL::Revert(), EE_INSPECTION_TOOL::RunERC(), LIB_CONTROL::Save(), PCBNEW_CONTROL::Show3DViewer(), LIB_CONTROL::ShowComponentTree(), EE_INSPECTION_TOOL::ShowDatasheet(), LIB_CONTROL::UnpinLibrary(), and COMMON_TOOLS::ZoomFitScreen().

◆ IsWritable()

bool EDA_BASE_FRAME::IsWritable ( const wxFileName &  aFileName)
inherited

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 691 of file eda_base_frame.cpp.

692 {
693  wxString msg;
694  wxFileName fn = aFileName;
695 
696  // Check for absence of a file path with a file name. Unfortunately KiCad
697  // uses paths relative to the current project path without the ./ part which
698  // confuses wxFileName. Making the file name path absolute may be less than
699  // elegant but it solves the problem.
700  if( fn.GetPath().IsEmpty() && fn.HasName() )
701  fn.MakeAbsolute();
702 
703  wxCHECK_MSG( fn.IsOk(), false,
704  wxT( "File name object is invalid. Bad programmer!" ) );
705  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
706  wxT( "File name object path <" ) + fn.GetFullPath() +
707  wxT( "> is not set. Bad programmer!" ) );
708 
709  if( fn.IsDir() && !fn.IsDirWritable() )
710  {
711  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
712  GetChars( fn.GetPath() ) );
713  }
714  else if( !fn.FileExists() && !fn.IsDirWritable() )
715  {
716  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
717  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
718  }
719  else if( fn.FileExists() && !fn.IsFileWritable() )
720  {
721  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
722  GetChars( fn.GetFullPath() ) );
723  }
724 
725  if( !msg.IsEmpty() )
726  {
727  wxMessageBox( msg );
728  return false;
729  }
730 
731  return true;
732 }
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:101
#define _(s)
Definition: 3d_actions.cpp:33

References _, and GetChars().

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

◆ Kiway()

KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 56 of file kiway_holder.h.

57  {
58  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
59  return *m_kiway;
60  }
KIWAY * m_kiway
Definition: kiway_holder.h:81

References KIWAY_HOLDER::m_kiway.

Referenced by TREEPROJECT_ITEM::Activate(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCB_BASE_EDIT_FRAME::AddLibrary(), LIB_CONTROL::AddSymbolToSchematic(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), COMMON_CONTROL::ConfigurePaths(), DIALOG_CHOOSE_FOOTPRINT::ConstructRightPanel(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), PCB_BASE_FRAME::CreateAndShow3D_Frame(), SCH_EDIT_FRAME::CreateScreens(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), DIALOG_SHIM::DIALOG_SHIM(), CVPCB_MAINFRAME::DisplayStatus(), FIELDS_GRID_TRICKS::doPopupSelection(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), EDIT_TOOL::EditFpInFpEditor(), SCH_EDITOR_CONTROL::EditWithLibEdit(), BACK_ANNOTATE::FetchNetlistFromPCB(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), LIB_MANAGER::GetBufferedPart(), LIB_MANAGER::getLibraryBuffer(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::InitSheet(), language_change(), KIWAY_PLAYER::language_change(), LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER(), CVPCB_MAINFRAME::LoadFootprintFiles(), LoadProject(), SCH_EDIT_FRAME::LoadSheetFromFile(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), TEXT_BUTTON_FP_CHOOSER::OnButtonClick(), OnCloseWindow(), SCH_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnExit(), FOOTPRINT_EDIT_FRAME::OnExitKiCad(), FOOTPRINT_VIEWER_FRAME::OnExitKiCad(), LIB_EDIT_FRAME::OnExitKiCad(), SAVE_AS_TRAVERSER::OnFile(), OnImportEagleFiles(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnOpenCvpcb(), SCH_EDIT_FRAME::OnOpenPcbnew(), EDA_BASE_FRAME::OnPreferences(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), SCH_EDIT_FRAME::OnUpdatePCB(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), KIWAY_HOLDER::Prj(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_EDIT_FRAME::refreshSchematic(), SCH_EDIT_FRAME::rescueProject(), EE_INSPECTION_TOOL::RunSimulation(), SCH_EDIT_FRAME::SaveEEFile(), CVPCB_MAINFRAME::SaveFootprintAssociation(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), LIB_TREE_MODEL_ADAPTER::SavePinnedItems(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), SCH_EDIT_FRAME::SendCrossProbeClearHighlight(), SCH_EDIT_FRAME::SendCrossProbeNetName(), PCB_EDIT_FRAME::SendCrossProbeNetName(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlistToCvpcb(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), CVPCB_CONTROL::ShowFootprintViewer(), COMMON_CONTROL::ShowLibraryTable(), COMMON_CONTROL::ShowPlayer(), KICAD_MANAGER_CONTROL::ShowPlayer(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow(), LIB_MANAGER::UpdatePart(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), and DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint().

◆ language_change()

void KICAD_MANAGER_FRAME::language_change ( wxCommandEvent &  event)
private

Definition at line 443 of file kicad_manager_frame.cpp.

444 {
445  int id = event.GetId();
446  Kiway().SetLanguage( id );
447 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
VTBL_ENTRY void SetLanguage(int aLanguage)
Function SetLanguage changes the language and then calls ShowChangedLanguage() on all KIWAY_PLAYERs.
Definition: kiway.cpp:435

References KIWAY_HOLDER::Kiway(), and KIWAY::SetLanguage().

◆ LoadProject()

void KICAD_MANAGER_FRAME::LoadProject ( const wxFileName &  aProjectFileName)

Definition at line 311 of file kicad_manager_frame.cpp.

312 {
313  // The project file should be valid by the time we get here or something has gone wrong.
314  if( !aProjectFileName.Exists() )
315  return;
316 
317  // Any open KIFACE's must be closed if they are not part of the new project.
318  // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
319  // User is prompted here to close those KIWAY_PLAYERs:
320  if( !Kiway().PlayersClose( false ) )
321  return;
322 
323  // Save the project file for the currently loaded project.
324  if( m_active_project )
326 
327  m_active_project = true;
328  ClearMsg();
329  SetProjectFileName( aProjectFileName.GetFullPath() );
331 
332  if( aProjectFileName.IsDirWritable() )
333  SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
334 
335  UpdateFileHistory( aProjectFileName.GetFullPath(), &PgmTop().GetFileHistory() );
336 
338 
339  SyncToolbars();
340 
341  // Rebuild the list of watched paths.
342  // however this is possible only when the main loop event handler is running,
343  // so we use it to run the rebuild function.
344  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
345 
346  wxPostEvent( this, cmd );
347 
348  PrintPrjInfo();
349 }
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:414
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:56
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void SetMruPath(const wxString &aPath)
std::vector< PARAM_CFG * > s_KicadManagerParams
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
Update the list of recently opened files.
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:385
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void SetProjectFileName(const wxString &aFullProjectProFileName)
void ClearMsg()
Erase the text panel.
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.
TREE_PROJECT_FRAME * m_leftWin
#define GeneralGroupName

References ClearMsg(), PROJECT::ConfigLoad(), GeneralGroupName, PGM_KICAD::GetFileHistory(), PROJECT::GetProjectPath(), ID_INIT_WATCHED_PATHS, KIWAY_HOLDER::Kiway(), m_active_project, m_leftWin, PgmTop(), KIWAY::PlayersClose(), PrintPrjInfo(), KIWAY_HOLDER::Prj(), TREE_PROJECT_FRAME::ReCreateTreePrj(), s_KicadManagerParams, EDA_BASE_FRAME::SetMruPath(), SetProjectFileName(), SyncToolbars(), and EDA_BASE_FRAME::UpdateFileHistory().

Referenced by TREEPROJECT_ITEM::Activate(), PGM_KICAD::MacOpenFile(), KICAD_MANAGER_CONTROL::NewFromTemplate(), KICAD_MANAGER_CONTROL::NewProject(), OnFileHistory(), PGM_KICAD::OnPgmInit(), TREE_PROJECT_FRAME::OnSwitchToSelectedProject(), KICAD_MANAGER_CONTROL::OpenProject(), and KICAD_MANAGER_CONTROL::SaveProjectAs().

◆ LoadSettings()

void KICAD_MANAGER_FRAME::LoadSettings ( APP_SETTINGS_BASE aCfg)
overridevirtual

Load 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 476 of file kicad_manager_frame.cpp.

477 {
479 
480  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
481  m_leftWinWidth = settings->m_LeftWinWidth;
482 }
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.

References EDA_BASE_FRAME::LoadSettings(), and m_leftWinWidth.

◆ LoadWindowSettings()

void EDA_BASE_FRAME::LoadWindowSettings ( WINDOW_SETTINGS aCfg)
inherited

Loads window settings from the given settings object Normally called by LoadSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window.

Definition at line 446 of file eda_base_frame.cpp.

447 {
448  m_FramePos.x = aCfg->pos_x;
449  m_FramePos.y = aCfg->pos_y;
450  m_FrameSize.x = aCfg->size_x;
451  m_FrameSize.y = aCfg->size_y;
452 
453  // Ensure minimum size is set if the stored config was zero-initialized
455  {
458  }
459 
460  // Ensure window isn't bigger than can be displayed
461  int displayIndex = wxDisplay::GetFromPoint( m_FramePos );
462 
463  if( displayIndex == wxNOT_FOUND )
464  displayIndex = 0;
465 
466  wxDisplay display( displayIndex );
467  wxRect clientSize = display.GetClientArea();
468 
469  // The window may have been saved on a display that is no longer present.
470  // First, check the window origin and move it if it's off the chosen display
471 
472  if( m_FramePos.x >= clientSize.x + clientSize.width ||
473  m_FramePos.y >= clientSize.y + clientSize.height )
474  m_FramePos = wxDefaultPosition;
475 
476  // Now, fix up the size if needed
477 
478  if( m_FrameSize.x + m_FramePos.x > clientSize.x + clientSize.width )
479  {
480  m_FrameSize.x = clientSize.width;
481  m_FramePos.x = 0;
482  }
483 
484  if( m_FrameSize.y + m_FramePos.y > clientSize.y + clientSize.height )
485  {
486  m_FrameSize.y = clientSize.height;
487  m_FramePos.y = 0;
488  }
489 
490  if( m_hasAutoSave )
491  m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
492 
493  // Ensure Window title bar is visible
494 #if defined( __WXMAC__ )
495  // for macOSX, the window must be below system (macOSX) toolbar
496  // Ypos_min = GetMBarHeight(); seems no more exist in new API (subject to change)
497  int Ypos_min = 20;
498 #else
499  int Ypos_min = 0;
500 #endif
501  if( m_FramePos.y < Ypos_min )
502  {
503  if( m_FrameSize.y + ( Ypos_min - m_FramePos.y ) > clientSize.height)
504  m_FrameSize.y = clientSize.height - Ypos_min;
505 
506  m_FramePos.y = Ypos_min;
507  }
508 
509  if( aCfg->maximized )
510  Maximize();
511 
512  m_perspective = aCfg->perspective;
513  m_mruPath = aCfg->mru_path;
514 
515  COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
516 
520 }
wxString mru_path
Definition: app_settings.h:55
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
wxString m_mruPath
wxString m_perspective
wxString perspective
Definition: app_settings.h:58
static const int s_minsize_x
static const int s_minsize_y

References COMMON_SETTINGS::INPUT::immediate_actions, EDA_BASE_FRAME::m_autoSaveInterval, EDA_BASE_FRAME::m_dragSelects, EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, EDA_BASE_FRAME::m_hasAutoSave, EDA_BASE_FRAME::m_immediateActions, COMMON_SETTINGS::m_Input, EDA_BASE_FRAME::m_moveWarpsCursor, EDA_BASE_FRAME::m_mruPath, EDA_BASE_FRAME::m_perspective, WINDOW_SETTINGS::maximized, WINDOW_SETTINGS::mru_path, WINDOW_SETTINGS::perspective, Pgm(), WINDOW_SETTINGS::pos_x, WINDOW_SETTINGS::pos_y, COMMON_SETTINGS::INPUT::prefer_select_to_drag, s_minsize_x, s_minsize_y, WINDOW_SETTINGS::size_x, WINDOW_SETTINGS::size_y, COMMON_SETTINGS::INPUT::warp_mouse_on_move, wxPoint::x, and wxPoint::y.

Referenced by EDA_BASE_FRAME::LoadSettings().

◆ OnArchiveFiles()

void KICAD_MANAGER_FRAME::OnArchiveFiles ( wxCommandEvent &  event)

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

140 {
141  // List of file extensions to save.
142  static const wxChar* extensionList[] = {
143  wxT( "*.pro" ),
144  wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.dcm" ), // Schematic related files
145  wxT( "*.cmp" ),
146  wxT( "*.brd" ), wxT( "*.kicad_pcb" ), // Brd files
147  wxT( "*.mod" ), wxT( "*.kicad_mod" ), // fp files
148  wxT( "*.gb?" ), wxT( "*.gbrjob" ), // Gerber files
149  wxT( "*.gko" ), wxT( "*.gm1" ),
150  wxT( "*.gm2" ), wxT( "*.g?" ),
151  wxT( "*.gp1" ), wxT( "*.gp2" ),
152  wxT( "*.gpb" ), wxT( "*.gpt" ),
153  wxT( "*.gt?" ),
154  wxT( "*.pos" ), wxT( "*.drl" ), wxT( "*.nc" ), wxT( "*.xnc" ), // Fab files
155  wxT( "*.d356" ), wxT( "*.rpt" ),
156  wxT( "*.stp" ), wxT( "*.step" ), // 3d files
157  wxT( "*.wrl" ),
158  wxT( "*.net" ), wxT( "*.py" ),
159  wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.kicad_wks" ),
160  wxT( "fp-lib-table" ), wxT( "sym-lib-table" )
161  };
162 
163  wxString msg;
164  wxFileName fileName = GetProjectFileName();
165  wxString oldCwd = wxGetCwd();
166 
167  fileName.SetExt( wxT( "zip" ) );
168 
169  wxFileDialog dlg( this, _( "Archive Project Files" ),
170  fileName.GetPath(), fileName.GetFullName(),
171  ZipFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
172 
173  if( dlg.ShowModal() == wxID_CANCEL )
174  return;
175 
176  wxFileName zip = dlg.GetPath();
177 
178  wxString currdirname = fileName.GetPathWithSep();
179  wxDir dir( currdirname );
180 
181  if( !dir.IsOpened() ) // wxWidgets display a error message on issue.
182  return;
183 
184  wxSetWorkingDirectory( currdirname );
185 
186  // Prepare the zip file
187  wxString zipfilename = zip.GetFullPath();
188 
189  wxFFileOutputStream ostream( zipfilename );
190 
191  if( !ostream.IsOk() ) // issue to create the file. Perhaps not writable dir
192  {
193  wxMessageBox( wxString::Format( _( "Unable to create zip archive file \"%s\"" ),
194  zipfilename ) );
195  return;
196  }
197 
198  wxZipOutputStream zipstream( ostream );
199 
200  // Build list of filenames to put in zip archive
201  wxString currFilename;
202 
203  wxArrayString files;
204 
205  for( unsigned ii = 0; ii < arrayDim( extensionList ); ii++ )
206  wxDir::GetAllFiles( currdirname, &files, extensionList[ii] );
207 
208  files.Sort();
209 
210  int zipBytesCnt = 0;
211 
212  for( unsigned ii = 0; ii < files.GetCount(); ii++ )
213  {
214  wxFileSystem fsfile;
215 
216  wxFileName curr_fn( files[ii] );
217  curr_fn.MakeRelativeTo( currdirname );
218  currFilename = curr_fn.GetFullPath();
219 
220  msg.Printf( _( "Archive file \"%s\"" ), GetChars( currFilename ) );
221  PrintMsg( msg );
222 
223  // Read input file and add it to the zip file:
224  wxFSFile* infile = fsfile.OpenFile( currFilename );
225 
226  if( infile )
227  {
228  zipstream.PutNextEntry( currFilename, infile->GetModificationTime() );
229  infile->GetStream()->Read( zipstream );
230  zipstream.CloseEntry();
231  int zippedsize = zipstream.GetSize() - zipBytesCnt;
232  zipBytesCnt = zipstream.GetSize();
233  PrintMsg( wxT(" ") );
234  msg.Printf( _( "(%lu bytes, compressed %d bytes)\n" ),
235  (unsigned long)infile->GetStream()->GetSize(), zippedsize );
236  PrintMsg( msg );
237  delete infile;
238  }
239  else
240  PrintMsg( _( " >>Error\n" ) );
241  }
242 
243  zipBytesCnt = ostream.GetSize();
244 
245  if( zipstream.Close() )
246  {
247  msg.Printf( _( "\nZip archive \"%s\" created (%d bytes)" ),
248  GetChars( zipfilename ), zipBytesCnt );
249  PrintMsg( msg );
250  PrintMsg( wxT( "\n** end **\n" ) );
251  }
252  else
253  {
254  msg.Printf( wxT( "Unable to create archive \"%s\", abort\n" ),
255  GetChars( zipfilename ) );
256  PrintMsg( msg );
257  }
258 
259  wxSetWorkingDirectory( oldCwd );
260 }
static const std::vector< std::string > extensionList
wxString ZipFileWildcard()
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
const wxString GetProjectFileName()
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:101
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 _(s)
Definition: 3d_actions.cpp:33

References _, arrayDim(), extensionList, Format(), GetChars(), GetProjectFileName(), PrintMsg(), and ZipFileWildcard().

◆ onAutoSaveTimer()

void EDA_BASE_FRAME::onAutoSaveTimer ( wxTimerEvent &  aEvent)
protectedinherited

Handle the auto save timer event.

Definition at line 328 of file eda_base_frame.cpp.

329 {
330  if( !doAutoSave() )
331  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
332 }
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
wxTimer * m_autoSaveTimer

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

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME().

◆ OnBrowseInFileExplorer()

void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer ( wxCommandEvent &  event)

Definition at line 430 of file kicad_manager_frame.cpp.

431 {
432  // open project directory in host OS's file explorer
433  LaunchExternal( Prj().GetProjectPath() );
434 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
Definition: launch_ext.cpp:26

References LaunchExternal(), and KIWAY_HOLDER::Prj().

◆ OnChangeWatchedPaths()

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 1125 of file tree_project_frame.cpp.

1126 {
1128 }
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

References TREE_PROJECT_FRAME::FileWatcherReset(), and m_leftWin.

◆ OnCharHook()

void EDA_BASE_FRAME::OnCharHook ( wxKeyEvent &  event)
virtualinherited

Capture the key event before it is sent to the GUI.

The basic frame does not capture this event. Editor frames should override this event function to capture and filter these keys when they are used as hotkeys, and skip it if the key is not used as hotkey (otherwise the key events will be not sent to menus).

Reimplemented in FOOTPRINT_VIEWER_FRAME.

Definition at line 341 of file eda_base_frame.cpp.

342 {
343  wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( event ) );
344  // Key events can be filtered here.
345  // Currently no filtering is made.
346  event.Skip();
347 }
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.

References dump(), and kicadTraceKeyEvent.

◆ OnClearFileHistory()

void KICAD_MANAGER_FRAME::OnClearFileHistory ( wxCommandEvent &  aEvent)

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

59 {
60  ClearFileHistory( &PgmTop().GetFileHistory() );
61 }
void ClearFileHistory(FILE_HISTORY *aFileHistory=NULL)
Removes all files from the file history.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72

References EDA_BASE_FRAME::ClearFileHistory(), and PgmTop().

◆ OnCloseWindow()

void KICAD_MANAGER_FRAME::OnCloseWindow ( wxCloseEvent &  Event)

Definition at line 276 of file kicad_manager_frame.cpp.

277 {
278  if( Kiway().PlayersClose( false ) )
279  {
280  int px, py;
281 
282  if( !GetProjectFileName().empty() )
283  UpdateFileHistory( GetProjectFileName(), &PgmTop().GetFileHistory() );
284 
285  if( !IsIconized() ) // save main frame position and size
286  {
287  GetPosition( &px, &py );
288  m_FramePos.x = px;
289  m_FramePos.y = py;
290 
291  GetSize( &px, &py );
292  m_FrameSize.x = px;
293  m_FrameSize.y = py;
294  }
295 
296  Event.SetCanVeto( true );
297 
298  m_leftWin->Show( false );
299 
300  Destroy();
301  }
302 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
Update the list of recently opened files.
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
const wxString GetProjectFileName()
static bool empty(const wxTextEntryBase *aCtrl)
TREE_PROJECT_FRAME * m_leftWin

References empty(), GetProjectFileName(), KIWAY_HOLDER::Kiway(), EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, m_leftWin, PgmTop(), EDA_BASE_FRAME::UpdateFileHistory(), wxPoint::x, and wxPoint::y.

◆ OnExit()

void KICAD_MANAGER_FRAME::OnExit ( wxCommandEvent &  event)

Definition at line 305 of file kicad_manager_frame.cpp.

306 {
307  Close( true );
308 }

◆ OnFileHistory()

void KICAD_MANAGER_FRAME::OnFileHistory ( wxCommandEvent &  event)

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

48 {
49  wxFileName projFileName = GetFileFromHistory( event.GetId(), _( "KiCad project file" ),
50  &PgmTop().GetFileHistory() );
51  if( !projFileName.FileExists() )
52  return;
53 
54  LoadProject( projFileName );
55 }
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:56
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=NULL)
Fetches the file name from the file history list.
#define _(s)
Definition: 3d_actions.cpp:33
void LoadProject(const wxFileName &aProjectFileName)

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

◆ OnImportEagleFiles()

void KICAD_MANAGER_FRAME::OnImportEagleFiles ( wxCommandEvent &  event)

Open dialog to import Eagle schematic and board files.

Definition at line 54 of file kicad/import_project.cpp.

55 {
56  // Close other windows.
57  if( !Kiway().PlayersClose( false ) )
58  return;
59 
60 
61  wxString title = _( "Import Eagle Project Files" );
62  int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
63  wxString default_dir = GetMruPath();
64 
65  ClearMsg();
66 
67  wxFileDialog schdlg( this, title, default_dir, wxEmptyString,
68  EagleFilesWildcard(), style );
69 
70  if( schdlg.ShowModal() == wxID_CANCEL )
71  return;
72 
73 
74  wxFileName sch( schdlg.GetPath() );
75 
76  sch.SetExt( LegacySchematicFileExtension );
77 
78  wxFileName pro = sch;
79 
80  pro.SetExt( ProjectFileExtension );
81 
82  wxString protitle = _( "KiCad Project Destination" );
83 
84  // Don't use wxFileDialog here. On GTK builds, the default path is returned unless a
85  // file is actually selected.
86  wxDirDialog prodlg( this, protitle, pro.GetPath(), wxDD_DEFAULT_STYLE );
87 
88  if( prodlg.ShowModal() == wxID_CANCEL )
89  return;
90 
91  pro.SetPath( prodlg.GetPath() );
92 
93  // Check if the project directory is empty
94  wxDir directory( pro.GetPath() );
95 
96  if( directory.HasFiles() )
97  {
98  wxString msg = _( "The selected directory is not empty. We recommend you "
99  "create projects in their own clean directory.\n\nDo you "
100  "want to create a new empty directory for the project?" );
101 
102  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxYES_NO | wxICON_WARNING );
103  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
104 
105  if( dlg.ShowModal() == wxID_YES )
106  {
107  // Append a new directory with the same name of the project file
108  // and try to create it
109  pro.AppendDir( pro.GetName() );
110 
111  if( !wxMkdir( pro.GetPath() ) )
112  // There was a problem, undo
113  pro.RemoveLastDir();
114  }
115  }
116 
117  wxFileName pcb( sch );
118  pro.SetExt( ProjectFileExtension ); // enforce extension
119  pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
120 
121  if( !pro.IsAbsolute() )
122  pro.MakeAbsolute();
123 
124  SetProjectFileName( pro.GetFullPath() );
125  wxString prj_filename = GetProjectFileName();
126 
127  if( sch.FileExists() )
128  {
129  KIWAY_PLAYER* schframe = Kiway().Player( FRAME_SCH, false );
130 
131  if( !schframe )
132  {
133  try // SCH frame was not available, try to start it
134  {
135  schframe = Kiway().Player( FRAME_SCH, true );
136  }
137  catch( const IO_ERROR& err )
138  {
139  wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
140  _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
141  return;
142  }
143  }
144 
145  std::string packet = StrPrintf( "%d\n%s", SCH_IO_MGR::SCH_EAGLE,
146  TO_UTF8( sch.GetFullPath() ) );
147  schframe->Kiway().ExpressMail( FRAME_SCH, MAIL_IMPORT_FILE, packet, this );
148 
149  if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor)
150  // but no project loaded.
151  {
152  schframe->Show( true );
153  }
154 
155  if( schframe->IsIconized() )
156  schframe->Iconize( false );
157 
158  schframe->Raise();
159  }
160 
161 
162  if( pcb.FileExists() )
163  {
164  KIWAY_PLAYER* pcbframe = Kiway().Player( FRAME_PCB_EDITOR, false );
165 
166  if( !pcbframe )
167  {
168  try // PCB frame was not available, try to start it
169  {
170  pcbframe = Kiway().Player( FRAME_PCB_EDITOR, true );
171  }
172  catch( const IO_ERROR& err )
173  {
174  wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ),
175  wxOK | wxICON_ERROR, this );
176  return;
177  }
178  }
179 
180  // a pcb frame can be already existing, but not yet used.
181  // this is the case when running the footprint editor, or the footprint viewer first
182  // if the frame is not visible, the board is not yet loaded
183  if( !pcbframe->IsVisible() )
184  {
185  pcbframe->Show( true );
186  }
187 
188  std::string packet = StrPrintf( "%d\n%s", IO_MGR::EAGLE,
189  TO_UTF8( pcb.GetFullPath() ) );
190  pcbframe->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_IMPORT_FILE, packet, this );
191 
192  // On Windows, Raise() does not bring the window on screen, when iconized
193  if( pcbframe->IsIconized() )
194  pcbframe->Iconize( false );
195 
196  pcbframe->Raise();
197  }
198 
199  ReCreateTreePrj();
200  m_active_project = true;
201 }
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
int StrPrintf(std::string *aResult, const char *aFormat,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:74
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
const std::string ProjectFileExtension
const std::string LegacyPcbFileExtension
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
wxString GetMruPath() const
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:341
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
const std::string LegacySchematicFileExtension
const wxString GetProjectFileName()
void SetProjectFileName(const wxString &aFullProjectProFileName)
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:427
Import a different format file.
Definition: mail_type.h:45
#define _(s)
Definition: 3d_actions.cpp:33
wxString EagleFilesWildcard()
void ClearMsg()
Erase the text panel.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References _, ClearMsg(), KIDIALOG::DoNotShowCheckbox(), IO_MGR::EAGLE, EagleFilesWildcard(), KIWAY::ExpressMail(), FRAME_PCB_EDITOR, FRAME_SCH, EDA_BASE_FRAME::GetMruPath(), GetProjectFileName(), KIWAY_HOLDER::Kiway(), LegacyPcbFileExtension, LegacySchematicFileExtension, m_active_project, MAIL_IMPORT_FILE, KIWAY::Player(), ProjectFileExtension, ReCreateTreePrj(), SetProjectFileName(), KIDIALOG::ShowModal(), numEval::StrPrintf(), TO_UTF8, and IO_ERROR::What().

◆ OnKicadAbout()

void EDA_BASE_FRAME::OnKicadAbout ( wxCommandEvent &  event)
inherited

Definition at line 652 of file eda_base_frame.cpp.

653 {
654  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
655  ShowAboutDialog( this );
656 }
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
The base frame for deriving all KiCad main window classes.

References ShowAboutDialog().

◆ OnMenuOpen()

void EDA_BASE_FRAME::OnMenuOpen ( wxMenuEvent &  event)
inherited

Workaround some issues in wxWidgets where the menu events aren't captured by the menus themselves.

Definition at line 350 of file eda_base_frame.cpp.

351 {
352  //
353  // wxWidgets has several issues that we have to work around:
354  //
355  // 1) wxWidgets 3.0.x Windows has a bug where wxEVT_MENU_OPEN and wxEVT_MENU_HIGHLIGHT
356  // events are not captured by the ACTON_MENU menus. So we forward them here.
357  // (FWIW, this one is fixed in wxWidgets 3.1.x.)
358  //
359  // 2) wxWidgets doesn't pass the menu pointer for wxEVT_MENU_HIGHLIGHT events. So we
360  // store the menu pointer from the wxEVT_MENU_OPEN call.
361  //
362  // 3) wxWidgets has no way to tell whether a command is from a menu selection or a
363  // hotkey. So we keep track of menu highlighting so we can differentiate.
364  //
365 
366  static ACTION_MENU* currentMenu;
367 
368  if( event.GetEventType() == wxEVT_MENU_OPEN )
369  {
370  currentMenu = dynamic_cast<ACTION_MENU*>( event.GetMenu() );
371 
372  if( currentMenu )
373  currentMenu->OnMenuEvent( event );
374  }
375  else if( event.GetEventType() == wxEVT_MENU_HIGHLIGHT )
376  {
377  if( currentMenu )
378  currentMenu->OnMenuEvent( event );
379  }
380  else if( event.GetEventType() == wxEVT_MENU_CLOSE )
381  {
382  if( currentMenu )
383  currentMenu->OnMenuEvent( event );
384 
385  currentMenu = nullptr;
386  }
387 
388  event.Skip();
389 }
ACTION_MENU.
Definition: action_menu.h:43
void OnMenuEvent(wxMenuEvent &aEvent)

References ACTION_MENU::OnMenuEvent().

◆ OnMove()

virtual void EDA_BASE_FRAME::OnMove ( wxMoveEvent &  aEvent)
inlinevirtualinherited

Reimplemented in EDA_DRAW_FRAME.

Definition at line 296 of file eda_base_frame.h.

297  {
298  aEvent.Skip();
299  }

◆ OnOpenFileInTextEditor()

void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ( wxCommandEvent &  event)

Definition at line 409 of file kicad_manager_frame.cpp.

410 {
411  // show all files in file dialog (in Kicad all files are editable texts):
412  wxString wildcard = AllFilesWildcard();
413 
414  wxString default_dir = Prj().GetProjectPath();
415 
416  wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
417  wxEmptyString, wildcard, wxFD_OPEN );
418 
419  if( dlg.ShowModal() == wxID_CANCEL )
420  return;
421 
422  wxString filename = wxT( "\"" );
423  filename += dlg.GetPath() + wxT( "\"" );
424 
425  if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
427 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
wxString AllFilesWildcard()
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
#define _(s)
Definition: 3d_actions.cpp:33
TOOL_MANAGER * m_toolManager
static TOOL_ACTION openTextEditor

References _, AllFilesWildcard(), PROJECT::GetProjectPath(), EDA_BASE_FRAME::m_toolManager, KICAD_MANAGER_ACTIONS::openTextEditor, Pgm(), KIWAY_HOLDER::Prj(), and TOOL_MANAGER::RunAction().

◆ OnPreferences()

void EDA_BASE_FRAME::OnPreferences ( wxCommandEvent &  event)
inherited

Definition at line 659 of file eda_base_frame.cpp.

660 {
661  PAGED_DIALOG dlg( this, _( "Preferences" ) );
662  wxTreebook* book = dlg.GetTreebook();
663 
664  book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
665 
666  PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false );
667  book->AddPage( hotkeysPanel, _( "Hotkeys" ) );
668 
669  for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
670  {
671  KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
672 
673  if( frame )
674  frame->InstallPreferences( &dlg, hotkeysPanel );
675  }
676 
677  // The Kicad manager frame is not a player so we have to add it by hand
678  wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
679 
680  if( manager )
681  static_cast<EDA_BASE_FRAME*>( manager )->InstallPreferences( &dlg, hotkeysPanel );
682 
683  for( int i = 0; i < book->GetPageCount(); ++i )
684  book->GetPage( i )->Layout();
685 
686  if( dlg.ShowModal() == wxID_OK )
687  dlg.Kiway().CommonSettingsChanged( false );
688 }
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:341
#define KICAD_MANAGER_FRAME_NAME
#define _(s)
Definition: 3d_actions.cpp:33
virtual void InstallPreferences(PAGED_DIALOG *, PANEL_HOTKEYS_EDITOR *)
Function InstallPreferences Allow a frame to load its preference panels (if any) into the preferences...

References _, KIWAY::CommonSettingsChanged(), PAGED_DIALOG::GetTreebook(), EDA_BASE_FRAME::InstallPreferences(), KICAD_MANAGER_FRAME_NAME, KIWAY_HOLDER::Kiway(), KIWAY_PLAYER_COUNT, and KIWAY::Player().

◆ OnSize()

void KICAD_MANAGER_FRAME::OnSize ( wxSizeEvent &  event)

Definition at line 267 of file kicad_manager_frame.cpp.

268 {
269  if( m_auimgr.GetManagedWindow() )
270  m_auimgr.Update();
271 
272  event.Skip();
273 }
wxAuiManager m_auimgr

References EDA_BASE_FRAME::m_auimgr.

◆ OnUnarchiveFiles()

void KICAD_MANAGER_FRAME::OnUnarchiveFiles ( wxCommandEvent &  event)

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

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

References _, DisplayError(), Format(), GetChars(), GetProjectFileName(), NULL, PrintMsg(), KIWAY_HOLDER::Prj(), RefreshProjectTree(), ZipFileExtension, and ZipFileWildcard().

◆ PcbFileName()

const wxString KICAD_MANAGER_FRAME::PcbFileName ( )

Definition at line 225 of file kicad_manager_frame.cpp.

226 {
227  wxFileName fn( GetProjectFileName() );
228 
229  fn.SetExt( PcbFileExtension );
230  return fn.GetFullPath();
231 }
#define PcbFileExtension
const wxString GetProjectFileName()

References GetProjectFileName(), and PcbFileExtension.

Referenced by TREEPROJECT_ITEM::Activate(), and KICAD_MANAGER_CONTROL::ShowPlayer().

◆ PcbLegacyFileName()

const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName ( )

Definition at line 234 of file kicad_manager_frame.cpp.

235 {
236  wxFileName fn( GetProjectFileName() );
237 
238  fn.SetExt( LegacyPcbFileExtension );
239  return fn.GetFullPath();
240 }
const std::string LegacyPcbFileExtension
const wxString GetProjectFileName()

References GetProjectFileName(), and LegacyPcbFileExtension.

Referenced by TREEPROJECT_ITEM::Activate(), and KICAD_MANAGER_CONTROL::ShowPlayer().

◆ PopTool()

void EDA_BASE_FRAME::PopTool ( const std::string &  actionName)
virtualinherited

Definition at line 214 of file eda_base_frame.cpp.

215 {
216  // Push/pop events can get out of order (such as when they're generated by the Simulator
217  // frame but not processed until the mouse is back in the Schematic frame), so make sure
218  // we're popping the right stack frame.
219 
220  for( int i = m_toolStack.size() - 1; i >= 0; --i )
221  {
222  if( m_toolStack[ i ] == actionName )
223  {
224  m_toolStack.erase( m_toolStack.begin() + i );
225 
226  // If there's something underneath us, and it's now the top of the stack, then
227  // re-activate it
228  if( ( --i ) >= 0 && i == (int)m_toolStack.size() - 1 )
229  {
230  std::string back = m_toolStack[ i ];
232 
233  if( action )
234  {
235  // Pop the action as running it will push it back onto the stack
236  m_toolStack.pop_back();
237 
238  TOOL_EVENT evt = action->MakeEvent();
239  evt.SetHasPosition( false );
240  GetToolManager()->PostEvent( evt );
241  }
242  }
243  else
245 
246  return;
247  }
248  }
249 }
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
TOOL_ACTION * FindAction(const std::string &aActionName) const
Function FindAction() Finds an action with a given name (if there is one available).
virtual void DisplayToolMsg(const wxString &msg)
TOOL_EVENT.
Definition: tool_event.h:171
std::vector< std::string > m_toolStack
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:193
TOOL_ACTION.
Definition: tool_action.h:46
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:107
TOOL_MANAGER * m_toolManager
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
static TOOL_ACTION selectionTool
Definition: actions.h:146
void SetHasPosition(bool aHasPosition)
Definition: tool_event.h:261

References EDA_BASE_FRAME::DisplayToolMsg(), ACTION_MANAGER::FindAction(), TOOL_MANAGER::GetActionManager(), EDA_BASE_FRAME::GetToolManager(), EDA_BASE_FRAME::m_toolManager, EDA_BASE_FRAME::m_toolStack, TOOL_ACTION::MakeEvent(), TOOL_MANAGER::PostEvent(), ACTIONS::selectionTool, and TOOL_EVENT::SetHasPosition().

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ PrintMsg()

void KICAD_MANAGER_FRAME::PrintMsg ( const wxString &  aText)

Displays aText in the text panel.

Parameters
aTextThe text to display.

Definition at line 261 of file kicad_manager_frame.cpp.

262 {
263  m_messagesBox->AppendText( aText );
264 }

References m_messagesBox.

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

◆ PrintPrjInfo()

void KICAD_MANAGER_FRAME::PrintPrjInfo ( )

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

Definition at line 504 of file kicad_manager_frame.cpp.

505 {
506  wxString msg = wxString::Format( _( "Project name:\n%s\n" ),
508  PrintMsg( msg );
509 }
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
const wxString GetProjectFileName()
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:101
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 _(s)
Definition: 3d_actions.cpp:33

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

Referenced by LoadProject(), and ShowChangedLanguage().

◆ Prj()

PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Function Prj returns a reference to the PROJECT "associated with" this KIWAY.

Definition at line 35 of file kiway_holder.cpp.

36 {
37  return Kiway().Prj();
38 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:171

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), LIB_MANAGER::addLibrary(), LIB_CONTROL::AddSymbolToSchematic(), SCH_EDIT_FRAME::AppendSchematic(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), DIALOG_SYMBOL_REMAP::backupProject(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_FOOTPRINT_FP_EDITOR::Cfg3DPath(), DIALOG_FOOTPRINT_BOARD_EDITOR::Cfg3DPath(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), CreateNewProject(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS(), DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT(), DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP(), LIB_VIEW_FRAME::DisplayLibInfos(), CVPCB_MAINFRAME::DisplayStatus(), PCB_EDIT_FRAME::doAutoSave(), KICAD_MANAGER_CONTROL::Execute(), PCB_EDIT_FRAME::Export_IDF3(), LIB_CONTROL::ExportSymbolAsSVG(), LIB_CONTROL::ExportView(), PCB_EDIT_FRAME::ExportVRML_File(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::GenD356File(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), SCH_BASE_FRAME::GetLibPart(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), GetProjectFileName(), LIB_VIEW_FRAME::GetSelectedSymbol(), FP_THREAD_IFACE::GetTable(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), SCH_EDITOR_CONTROL::ImportFPAssignments(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), LIB_EDIT_FRAME::KiwayMailIn(), EDA_DRAW_FRAME::LibraryFileBrowser(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), CVPCB_MAINFRAME::LoadFootprintFiles(), DIALOG_SPICE_MODEL::loadLibrary(), LIB_EDIT_FRAME::LoadOneSymbol(), LoadProject(), SCH_EDIT_FRAME::LoadProject(), SCH_EDIT_FRAME::LoadProjectFile(), CVPCB_MAINFRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), SCH_EDIT_FRAME::LoadSheetFromFile(), DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged(), DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), OnBrowseInFileExplorer(), DIALOG_EDIT_COMPONENTS_LIBID::onClickOrphansButton(), SCH_EDIT_FRAME::OnCloseWindow(), DIALOG_GENDRILL::OnGenReportFile(), SCH_EDIT_FRAME::OnImportProject(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnOpenCvpcb(), OnOpenFileInTextEditor(), DIALOG_NETLIST::OnOpenNetlistClick(), SCH_EDIT_FRAME::OnOpenPcbnew(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), DIALOG_BOM::OnRunGenerator(), FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), DIALOG_SPICE_MODEL::onSelectLibrary(), LIB_VIEW_FRAME::OnSelectSymbol(), OnUnarchiveFiles(), SCH_EDIT_FRAME::OnUpdatePCB(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PANEL_PREV_3D::PANEL_PREV_3D(), SCH_EDITOR_CONTROL::Paste(), MODULE_EDITOR_TOOLS::PasteFootprint(), PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME(), SCH_DRAWING_TOOLS::PlaceComponent(), DIALOG_CHOOSE_COMPONENT::PopulateFootprintSelector(), SCH_EDIT_FRAME::Print(), SCH_EDIT_FRAME::PrintPage(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), EDA_3D_VIEWER::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), SCH_EDIT_FRAME::RescueLegacyProject(), SCH_EDIT_FRAME::RescueSymbolLibTableProject(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::saveLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), LIB_EDIT_FRAME::savePartAs(), SCH_EDIT_FRAME::SaveProject(), CVPCB_MAINFRAME::SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), DIALOG_BOARD_STATISTICS::saveReportClicked(), SCH_BASE_FRAME::saveSymbolLibTables(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectCompFromLibTree(), PCB_BASE_FRAME::SelectLibrary(), LIB_EDIT_FRAME::SelectLibraryFromList(), LIB_EDIT_FRAME::selectSymLibTable(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), SetProjectFileName(), EE_INSPECTION_TOOL::ShowDatasheet(), DIALOG_CHOOSE_COMPONENT::ShowFootprintFor(), LIB_VIEW_FRAME::ShowModal(), FOOTPRINT_VIEWER_FRAME::ShowModal(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), LIB_MANAGER::symTable(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), NETLIST_DIALOG::TransferDataFromWindow(), DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary(), SIM_PLOT_FRAME::updateNetlistExporter(), SCH_SCREEN::UpdateSymbolLinks(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), SCH_EDIT_FRAME::UpdateTitle(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::~DIALOG_FOOTPRINT_FP_EDITOR(), and PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME().

◆ ProcessEvent()

bool EDA_BASE_FRAME::ProcessEvent ( wxEvent &  aEvent)
overrideinherited

Override 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 270 of file eda_base_frame.cpp.

271 {
272 #ifdef __WXMAC__
273  // Apple in its infinite wisdom will raise a disabled window before even passing
274  // us the event, so we have no way to stop it. Instead, we have to catch an
275  // improperly ordered disabled window and quasi-modal dialog here and reorder
276  // them.
277  if( !IsEnabled() && IsActive() )
278  {
279  wxWindow* dlg = findQuasiModalDialog();
280  if( dlg )
281  dlg->Raise();
282  }
283 #endif
284 
285  if( !wxFrame::ProcessEvent( aEvent ) )
286  return false;
287 
288  if( IsShown() && m_hasAutoSave && IsActive() &&
290  {
291  if( !m_autoSaveState )
292  {
293  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
294  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
295  m_autoSaveState = true;
296  }
297  else if( m_autoSaveTimer->IsRunning() )
298  {
299  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
300  m_autoSaveTimer->Stop();
301  m_autoSaveState = false;
302  }
303  }
304 
305  return true;
306 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
virtual bool isAutoSaveRequired() const
Return the auto save status of the application.
wxTimer * m_autoSaveTimer
wxWindow * findQuasiModalDialog()

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

Referenced by COMMON_TOOLS::GridProperties(), LIB_VIEW_FRAME::onSelectNextSymbol(), LIB_VIEW_FRAME::onSelectPreviousSymbol(), KIWAY::ProcessEvent(), and LIB_VIEW_FRAME::ReCreateListCmp().

◆ PushTool()

void EDA_BASE_FRAME::PushTool ( const std::string &  actionName)
virtualinherited

NB: the definition of "tool" is different at the user level.

The implementation uses a single TOOL_BASE derived class to implement several user "tools", such as rectangle and circle, or wire and bus. So each user-level tool is actually a TOOL_ACTION.

Definition at line 197 of file eda_base_frame.cpp.

198 {
199  m_toolStack.push_back( actionName );
200 
201  // Human cognitive stacking is very shallow; deeper tool stacks just get annoying
202  if( m_toolStack.size() > 3 )
203  m_toolStack.erase( m_toolStack.begin() );
204 
205  TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName );
206 
207  if( action )
208  DisplayToolMsg( action->GetLabel() );
209  else
210  DisplayToolMsg( actionName );
211 }
TOOL_ACTION * FindAction(const std::string &aActionName) const
Function FindAction() Finds an action with a given name (if there is one available).
virtual void DisplayToolMsg(const wxString &msg)
wxString GetLabel() const
Definition: tool_action.cpp:69
std::vector< std::string > m_toolStack
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:193
TOOL_ACTION.
Definition: tool_action.h:46
TOOL_MANAGER * m_toolManager

References EDA_BASE_FRAME::DisplayToolMsg(), ACTION_MANAGER::FindAction(), TOOL_MANAGER::GetActionManager(), TOOL_ACTION::GetLabel(), EDA_BASE_FRAME::m_toolManager, and EDA_BASE_FRAME::m_toolStack.

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ RecreateBaseHToolbar()

void KICAD_MANAGER_FRAME::RecreateBaseHToolbar ( )

(Re)Create the horizontal toolbar

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

174 {
175  if( m_mainToolBar )
176  m_mainToolBar->Clear();
177  else
178  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
179  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
180 
181  // New
185 
187  m_mainToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, wxEmptyString,
188  KiScaledBitmap( zip_xpm, this ),
189  _( "Archive all project files" ) );
190 
191  m_mainToolBar->AddTool( ID_READ_ZIP_ARCHIVE, wxEmptyString,
192  KiScaledBitmap( unzip_xpm, this ),
193  _( "Unarchive project files from zip archive" ) );
194 
197 
199  m_mainToolBar->AddTool( ID_BROWSE_IN_FILE_EXPLORER, wxEmptyString,
201 #ifdef __APPLE__
202  _( "Reveal project directory in Finder" ) );
203 #else
204  _( "Open project directory in file explorer" ) );
205 #endif
206 
207  // Create m_mainToolBar
208  m_mainToolBar->Realize();
209 }
static TOOL_ACTION newProject
ACTION_TOOLBAR.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false)
Function Add() Adds a TOOL_ACTION-based button to the toolbar.
const BITMAP_OPAQUE directory_browser_xpm[1]
const BITMAP_OPAQUE zip_xpm[1]
Definition: zip.cpp:60
static TOOL_ACTION newFromTemplate
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
static TOOL_ACTION openProject
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:87
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
Definition: bitmap.cpp:167
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
ACTION_TOOLBAR * m_mainToolBar
const BITMAP_OPAQUE unzip_xpm[1]
Definition: unzip.cpp:61

References _, ACTION_TOOLBAR::Add(), directory_browser_xpm, ID_BROWSE_IN_FILE_EXPLORER, ID_H_TOOLBAR, ID_READ_ZIP_ARCHIVE, ID_SAVE_AND_ZIP_FILES, EDA_BASE_FRAME::KICAD_AUI_TB_STYLE, KiScaledBitmap(), KiScaledSeparator(), m_mainToolBar, KICAD_MANAGER_ACTIONS::newFromTemplate, KICAD_MANAGER_ACTIONS::newProject, KICAD_MANAGER_ACTIONS::openProject, unzip_xpm, zip_xpm, and ACTIONS::zoomRedraw.

Referenced by ShowChangedLanguage().

◆ RecreateLauncher()

void KICAD_MANAGER_FRAME::RecreateLauncher ( )

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

213 {
214  if( m_launcher )
215  m_launcher->Clear();
216  else
217  m_launcher = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
218  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
219 
220  // Add tools. Note these KICAD_MANAGER_ACTIONS are defined with a bitmap
221  // suitable for menus. The icans will be changed later.
224 
225  KiScaledSeparator( m_launcher, this );
228 
229  KiScaledSeparator( m_launcher, this );
234 
235  // Now set big icons for these tools:
239  KiScaledBitmap( icon_libedit_xpm, this ) );
241  KiScaledBitmap( icon_pcbnew_xpm, this ) );
243  KiScaledBitmap( icon_modedit_xpm, this ) );
252 
253  // Create mlauncher
254  m_launcher->Realize();
255 
256  // And update the visual tools state:
257  SyncToolbars();
258 }
ACTION_TOOLBAR.
static TOOL_ACTION showCalculator
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false)
Function Add() Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION viewGerbers
const BITMAP_OPAQUE icon_pcbcalculator_xpm[1]
const BITMAP_OPAQUE icon_bitmap2component_xpm[1]
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
static TOOL_ACTION convertImage
const BITMAP_OPAQUE icon_eeschema_xpm[1]
static TOOL_ACTION editSchematic
const BITMAP_OPAQUE icon_pagelayout_editor_xpm[1]
static TOOL_ACTION editFootprints
static TOOL_ACTION editWorksheet
const BITMAP_OPAQUE icon_gerbview_xpm[1]
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
const BITMAP_OPAQUE icon_modedit_xpm[1]
const BITMAP_OPAQUE icon_libedit_xpm[1]
static TOOL_ACTION editPCB
ACTION_TOOLBAR * m_launcher
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Function SetToolBitmap() Updates the bitmap of a particular tool.
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
Definition: bitmap.cpp:167
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
const BITMAP_OPAQUE icon_pcbnew_xpm[1]
Definition: icon_pcbnew.cpp:49
static TOOL_ACTION editSymbols

References ACTION_TOOLBAR::Add(), KICAD_MANAGER_ACTIONS::convertImage, KICAD_MANAGER_ACTIONS::editFootprints, KICAD_MANAGER_ACTIONS::editPCB, KICAD_MANAGER_ACTIONS::editSchematic, KICAD_MANAGER_ACTIONS::editSymbols, KICAD_MANAGER_ACTIONS::editWorksheet, icon_bitmap2component_xpm, icon_eeschema_xpm, icon_gerbview_xpm, icon_libedit_xpm, icon_modedit_xpm, icon_pagelayout_editor_xpm, icon_pcbcalculator_xpm, icon_pcbnew_xpm, ID_H_TOOLBAR, EDA_BASE_FRAME::KICAD_AUI_TB_STYLE, KiScaledBitmap(), KiScaledSeparator(), m_launcher, ACTION_TOOLBAR::SetToolBitmap(), KICAD_MANAGER_ACTIONS::showCalculator, SyncToolbars(), and KICAD_MANAGER_ACTIONS::viewGerbers.

Referenced by ShowChangedLanguage().

◆ ReCreateMenuBar()

void KICAD_MANAGER_FRAME::ReCreateMenuBar ( )
overridevirtual

Recreates the menu bar.

Needed when the language is changed

Reimplemented from EDA_BASE_FRAME.

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

40 {
42  // wxWidgets handles the Mac Application menu behind the scenes, but that means
43  // we always have to start from scratch with a new wxMenuBar.
44  wxMenuBar* oldMenuBar = GetMenuBar();
45  wxMenuBar* menuBar = new wxMenuBar();
46 
47  //-- File menu -----------------------------------------------------------
48  //
49  CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, controlTool );
50  FILE_HISTORY& fileHistory = PgmTop().GetFileHistory();
51 
52  fileHistory.SetClearText( _( "Clear Recent Projects" ) );
53 
54  static ACTION_MENU* openRecentMenu;
55 
56  // Create the menu if it does not exist. Adding a file to/from the history
57  // will automatically refresh the menu.
58  if( !openRecentMenu )
59  {
60  openRecentMenu = new ACTION_MENU( false );
61  openRecentMenu->SetTool( controlTool );
62  openRecentMenu->SetTitle( _( "Open Recent" ) );
63  openRecentMenu->SetIcon( recent_xpm );
64 
65  fileHistory.UseMenu( openRecentMenu );
66  fileHistory.AddFilesToMenu();
67  }
68 
72  fileMenu->AddMenu( openRecentMenu,
73  FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) );
74 
75  fileMenu->AddSeparator();
77 
78  fileMenu->AddSeparator();
80  _( "Import EAGLE Project..." ),
81  _( "Import EAGLE CAD XML schematic and board" ),
83 
84  fileMenu->AddSeparator();
85  fileMenu->AddItem( ID_SAVE_AND_ZIP_FILES,
86  _( "&Archive Project..." ),
87  _( "Archive all needed project files into zip archive" ),
89 
90  fileMenu->AddItem( ID_READ_ZIP_ARCHIVE,
91  _( "&Unarchive Project..." ),
92  _( "Unarchive project files from zip archive" ),
94 
95  fileMenu->AddSeparator();
96  fileMenu->AddQuitOrClose( nullptr, "KiCad" );
97 
98  fileMenu->Resolve();
99 
100  //-- View menu -----------------------------------------------------------
101  //
102  CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, controlTool );
103 
105 
106  viewMenu->AddSeparator();
109  _( "Browse Project Files" ), _( "Open project directory in file browser" ),
111 
112 #ifdef __APPLE__
113  viewMenu->AddSeparator();
114 #endif
115 
116  viewMenu->Resolve();
117 
118  //-- Tools menu -----------------------------------------------
119  //
120  CONDITIONAL_MENU* toolsMenu = new CONDITIONAL_MENU( false, controlTool );
121 
126 
127  toolsMenu->AddSeparator();
132 
133  toolsMenu->AddSeparator();
135  _( "Edit Local File..." ), _( "Edit local file in text editor" ),
137 
138  toolsMenu->Resolve();
139 
140  //-- Preferences menu -----------------------------------------------
141  //
142  CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, controlTool );
143 
147  prefsMenu->AddItem( wxID_PREFERENCES,
148  _( "Preferences...\tCTRL+," ),
149  _( "Show preferences for all open tools" ),
151 
152  prefsMenu->AddSeparator();
153  AddMenuLanguageList( prefsMenu, controlTool );
154 
155  prefsMenu->Resolve();
156 
157  //-- Menubar -------------------------------------------------------------
158  //
159  menuBar->Append( fileMenu, _( "&File" ) );
160  menuBar->Append( viewMenu, _( "&View" ) );
161  menuBar->Append( toolsMenu, _( "&Tools" ) );
162  menuBar->Append( prefsMenu, _( "&Preferences" ) );
163  AddStandardHelpMenu( menuBar );
164 
165  SetMenuBar( menuBar );
166  delete oldMenuBar;
167 }
const BITMAP_OPAQUE browse_files_xpm[1]
void AddFilesToMenu() override
Add the files to all registered menus.
Definition: filehistory.h:98
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
static TOOL_ACTION newProject
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
FILE_HISTORY & GetFileHistory()
Definition: pgm_kicad.h:56
ACTION_MENU.
Definition: action_menu.h:43
static TOOL_ACTION showCalculator
void SetClearText(wxString aClearText)
Set the text displayed on the menu item that clears the entire menu.
Definition: filehistory.h:123
const BITMAP_OPAQUE directory_browser_xpm[1]
const BITMAP_OPAQUE zip_xpm[1]
Definition: zip.cpp:60
static TOOL_ACTION viewGerbers
static TOOL_ACTION showSymbolLibTable
Definition: actions.h:167
static TOOL_ACTION newFromTemplate
KICAD_MANAGER_CONTROL.
This class implements a file history object to store a list of files, that can then be added to a men...
Definition: filehistory.h:42
static TOOL_ACTION convertImage
const BITMAP_OPAQUE recent_xpm[1]
Definition: recent.cpp:68
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
static TOOL_ACTION editSchematic
static TOOL_ACTION showFootprintLibTable
Definition: actions.h:168
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: action_menu.cpp:68
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Adds the standard KiCad help menu to the menubar.
static TOOL_ACTION editFootprints
static TOOL_ACTION editWorksheet
void Resolve()
Function Resolve()
const BITMAP_OPAQUE import_project_xpm[1]
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void AddQuitOrClose(KIFACE_I *aKiface, wxString aAppname="")
Functions AddQuitOrClose()
static TOOL_ACTION editPCB
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:86
static SELECTION_CONDITION FileHistoryNotEmpty(const FILE_HISTORY &aHistory)
Create a SELECTION_CONDITION that can be used to enable a menu item when the file history has items i...
static TOOL_ACTION openProject
void AddMenuLanguageList(CONDITIONAL_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
static TOOL_ACTION saveAs
Definition: actions.h:55
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:87
TOOL_MANAGER * m_toolManager
const BITMAP_OPAQUE preference_xpm[1]
Definition: preference.cpp:66
static TOOL_ACTION editSymbols
static TOOL_ACTION configurePaths
Definition: actions.h:166
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION openTextEditor
const BITMAP_OPAQUE unzip_xpm[1]
Definition: unzip.cpp:61

References _, FILE_HISTORY::AddFilesToMenu(), CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), AddMenuLanguageList(), CONDITIONAL_MENU::AddQuitOrClose(), CONDITIONAL_MENU::AddSeparator(), EDA_BASE_FRAME::AddStandardHelpMenu(), browse_files_xpm, ACTIONS::configurePaths, KICAD_MANAGER_ACTIONS::convertImage, directory_browser_xpm, KICAD_MANAGER_ACTIONS::editFootprints, KICAD_MANAGER_ACTIONS::editPCB, KICAD_MANAGER_ACTIONS::editSchematic, KICAD_MANAGER_ACTIONS::editSymbols, KICAD_MANAGER_ACTIONS::editWorksheet, FILE_HISTORY::FileHistoryNotEmpty(), PGM_KICAD::GetFileHistory(), TOOL_MANAGER::GetTool(), ID_BROWSE_IN_FILE_EXPLORER, ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR, ID_IMPORT_EAGLE_PROJECT, ID_READ_ZIP_ARCHIVE, ID_SAVE_AND_ZIP_FILES, import_project_xpm, EDA_BASE_FRAME::m_toolManager, KICAD_MANAGER_ACTIONS::newFromTemplate, KICAD_MANAGER_ACTIONS::newProject, KICAD_MANAGER_ACTIONS::openProject, KICAD_MANAGER_ACTIONS::openTextEditor, PgmTop(), preference_xpm, recent_xpm, CONDITIONAL_MENU::Resolve(), ACTIONS::saveAs, FILE_HISTORY::SetClearText(), ACTION_MENU::SetIcon(), ACTION_MENU::SetTitle(), ACTION_MENU::SetTool(), SELECTION_CONDITIONS::ShowAlways(), KICAD_MANAGER_ACTIONS::showCalculator, ACTIONS::showFootprintLibTable, ACTIONS::showSymbolLibTable, unzip_xpm, KICAD_MANAGER_ACTIONS::viewGerbers, zip_xpm, and ACTIONS::zoomRedraw.

◆ ReCreateTreePrj()

void KICAD_MANAGER_FRAME::ReCreateTreePrj ( )

Definition at line 243 of file kicad_manager_frame.cpp.

244 {
246 }
void ReCreateTreePrj()
Create or modify the tree showing project file names.
TREE_PROJECT_FRAME * m_leftWin

References m_leftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

Referenced by OnImportEagleFiles().

◆ RefreshCanvas()

virtual void EDA_BASE_FRAME::RefreshCanvas ( )
inlinevirtualinherited

Notification to refresh the drawing canvas (if any).

Reimplemented in EDA_DRAW_FRAME.

Definition at line 515 of file eda_base_frame.h.

515 { };

◆ RefreshProjectTree()

void KICAD_MANAGER_FRAME::RefreshProjectTree ( )

Definition at line 437 of file kicad_manager_frame.cpp.

438 {
440 }
void ReCreateTreePrj()
Create or modify the tree showing project file names.
TREE_PROJECT_FRAME * m_leftWin

References m_leftWin, and TREE_PROJECT_FRAME::ReCreateTreePrj().

Referenced by OnUnarchiveFiles(), and KICAD_MANAGER_CONTROL::Refresh().

◆ RemoveShutdownBlockReason()

void EDA_BASE_FRAME::RemoveShutdownBlockReason ( )
inherited

Removes any shutdown block reason set.

Definition at line 169 of file eda_base_frame.cpp.

170 {
171 #if defined( _WIN32 )
172  // Windows: Destroys any block reason that may have existed
173  ShutdownBlockReasonDestroy( GetHandle() );
174 #endif
175 }

Referenced by EDA_BASE_FRAME::~EDA_BASE_FRAME().

◆ SaveProjectSettings()

virtual void EDA_BASE_FRAME::SaveProjectSettings ( )
inlinevirtualinherited

Save 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 392 of file eda_base_frame.h.

392 {};

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick().

◆ SaveSettings()

void KICAD_MANAGER_FRAME::SaveSettings ( APP_SETTINGS_BASE aCfg)
overridevirtual

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 485 of file kicad_manager_frame.cpp.

486 {
488 
489  auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
490  settings->m_LeftWinWidth = m_leftWin->GetSize().x;
491 }
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Saves common frame parameters to a configuration data file.
TREE_PROJECT_FRAME * m_leftWin

References m_leftWin, and EDA_BASE_FRAME::SaveSettings().

◆ SaveWindowSettings()

void EDA_BASE_FRAME::SaveWindowSettings ( WINDOW_SETTINGS aCfg)
inherited

Saves window settings to the given settings object Normally called by SaveSettings unless the window in question is a child window that stores its settings somewhere other than APP_SETTINGS_BASE::m_Window.

Definition at line 523 of file eda_base_frame.cpp.

524 {
525  wxString text;
526 
527  if( IsIconized() )
528  return;
529 
530  wxString baseCfgName = ConfigBaseName();
531 
532  m_FrameSize = GetSize();
533  m_FramePos = GetPosition();
534 
535  aCfg->pos_x = m_FramePos.x;
536  aCfg->pos_y = m_FramePos.y;
537  aCfg->size_x = m_FrameSize.x;
538  aCfg->size_y = m_FrameSize.y;
539  aCfg->maximized = IsMaximized();
540 
541  // TODO(JE) should auto-save in common settings be overwritten by every app?
542  if( m_hasAutoSave )
543  Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
544 
545  // Once this is fully implemented, wxAuiManager will be used to maintain
546  // the persistance of the main frame and all it's managed windows and
547  // all of the legacy frame persistence position code can be removed.
548  aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
549 
550  aCfg->mru_path = m_mruPath;
551 }
wxString mru_path
Definition: app_settings.h:55
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
wxString m_mruPath
wxString ConfigBaseName()
wxAuiManager m_auimgr
wxString perspective
Definition: app_settings.h:58

References EDA_BASE_FRAME::ConfigBaseName(), EDA_BASE_FRAME::m_auimgr, EDA_BASE_FRAME::m_autoSaveInterval, EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, EDA_BASE_FRAME::m_hasAutoSave, EDA_BASE_FRAME::m_mruPath, WINDOW_SETTINGS::maximized, WINDOW_SETTINGS::mru_path, WINDOW_SETTINGS::perspective, Pgm(), WINDOW_SETTINGS::pos_x, WINDOW_SETTINGS::pos_y, WINDOW_SETTINGS::size_x, WINDOW_SETTINGS::size_y, wxPoint::x, and wxPoint::y.

Referenced by EDA_BASE_FRAME::SaveSettings().

◆ SchFileName()

const wxString KICAD_MANAGER_FRAME::SchFileName ( )

Definition at line 216 of file kicad_manager_frame.cpp.

217 {
218  wxFileName fn( GetProjectFileName() );
219 
220  fn.SetExt( LegacySchematicFileExtension );
221  return fn.GetFullPath();
222 }
const std::string LegacySchematicFileExtension
const wxString GetProjectFileName()

References GetProjectFileName(), and LegacySchematicFileExtension.

Referenced by TREEPROJECT_ITEM::Activate(), and KICAD_MANAGER_CONTROL::ShowPlayer().

◆ SetAutoSaveInterval()

void EDA_BASE_FRAME::SetAutoSaveInterval ( int  aInterval)
inherited

Definition at line 309 of file eda_base_frame.cpp.

310 {
311  m_autoSaveInterval = aInterval;
312 
313  if( m_autoSaveTimer->IsRunning() )
314  {
315  if( m_autoSaveInterval > 0 )
316  {
317  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
318  }
319  else
320  {
321  m_autoSaveTimer->Stop();
322  m_autoSaveState = false;
323  }
324  }
325 }
wxTimer * m_autoSaveTimer

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

Referenced by EDA_DRAW_FRAME::CommonSettingsChanged().

◆ SetKiway()

void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

Function SetKiway.

Parameters
aDestis the recipient of aKiway pointer. It is only used for debugging, since "this" is not a wxWindow*. "this" is a KIWAY_HOLDER mix-in.
aKiwayis often from a parent window, or from KIFACE::CreateWindow().

Definition at line 42 of file kiway_holder.cpp.

43 {
44 #if defined(DEBUG)
45  // offer a trap point for debugging most any window
46  wxASSERT( aDest );
47  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
48  {
49  int breakhere=1;
50  (void) breakhere;
51  }
52 #endif
53 
54  (void) aDest;
55 
56  m_kiway = aKiway;
57 }
KIWAY * m_kiway
Definition: kiway_holder.h:81
const char * name
Definition: DXF_plotter.cpp:60

References KIWAY_HOLDER::m_kiway, and name.

Referenced by BM2CMP_FRAME::BM2CMP_FRAME(), InvokePcbLibTableEditor(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

◆ SetMruPath()

void EDA_BASE_FRAME::SetMruPath ( const wxString &  aPath)
inlineinherited

Definition at line 440 of file eda_base_frame.h.

440 { m_mruPath = aPath; }
wxString m_mruPath

References EDA_BASE_FRAME::m_mruPath.

Referenced by PANEL_HOTKEYS_EDITOR::ImportHotKeys(), and LoadProject().

◆ SetProjectFileName()

void KICAD_MANAGER_FRAME::SetProjectFileName ( const wxString &  aFullProjectProFileName)

Definition at line 190 of file kicad_manager_frame.cpp.

191 {
192  // ensure file name is absolute:
193  wxFileName fn( aFullProjectProFileName );
194 
195  if( !fn.IsAbsolute() )
196  fn.MakeAbsolute();
197 
198  Prj().SetProjectFullName( fn.GetFullPath() );
199 
200  SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
201  wxString title = GetTitle() + " " + fn.GetFullPath();
202 
203  if( !fn.IsDirWritable() )
204  title += _( " [Read Only]" );
205 
206  SetTitle( title );
207 }
wxString GetBuildVersion()
Get the full KiCad version string.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY void SetProjectFullName(const wxString &aFullPathAndName)
Function SetProjectFullName sets the: 1) full directory, 2) basename, and 3) extension of the project...
Definition: project.cpp:64
#define _(s)
Definition: 3d_actions.cpp:33

References _, GetBuildVersion(), KIWAY_HOLDER::Prj(), and PROJECT::SetProjectFullName().

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

◆ SetShutdownBlockReason()

void EDA_BASE_FRAME::SetShutdownBlockReason ( const wxString &  reason)
inherited

Sets the block reason why the window/application is preventing OS shutdown.

This should be set far ahead of any close event.

This is mainly intended for Windows platforms where this is a native feature.

Definition at line 178 of file eda_base_frame.cpp.

179 {
180 #if defined( _WIN32 )
181  // Windows: sets up the pretty message on the shutdown page on why it's being "blocked"
182  // This is used in conjunction with handling WM_QUERYENDSESSION (wxCloseEvent)
183  // ShutdownBlockReasonCreate does not block by itself
184 
185  ShutdownBlockReasonDestroy( GetHandle() ); // Destroys any existing or nonexisting reason
186 
187  if( !ShutdownBlockReasonCreate( GetHandle(), aReason.wc_str() ) )
188  {
189  // Nothing bad happens if this fails, at worst it uses a generic application is preventing shutdown message
190  wxLogDebug( wxT( "ShutdownBlockReasonCreate failed to set reason: %s" ), aReason );
191  }
192 #endif
193 }

Referenced by CVPCB_MAINFRAME::CVPCB_MAINFRAME(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ SetUserUnits()

◆ ShowChangedLanguage()

void KICAD_MANAGER_FRAME::ShowChangedLanguage ( )
overridevirtual

Redraw the menus and what not in current language.

Reimplemented from EDA_BASE_FRAME.

Definition at line 450 of file kicad_manager_frame.cpp.

451 {
452  // call my base class
454 
455  // tooltips in toolbars
458 
459  PrintPrjInfo();
460 }
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.

References PrintPrjInfo(), RecreateBaseHToolbar(), RecreateLauncher(), and EDA_BASE_FRAME::ShowChangedLanguage().

◆ SupportsShutdownBlockReason()

bool EDA_BASE_FRAME::SupportsShutdownBlockReason ( )
inherited

Whether or not the window supports setting a shutdown block reason.

Definition at line 159 of file eda_base_frame.cpp.

160 {
161 #if defined( _WIN32 )
162  return true;
163 #else
164  return false;
165 #endif
166 }

Referenced by FOOTPRINT_EDIT_FRAME::OnCloseWindow(), CVPCB_MAINFRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnCloseWindow(), and EDA_BASE_FRAME::~EDA_BASE_FRAME().

◆ SyncToolbars()

void KICAD_MANAGER_FRAME::SyncToolbars ( )
overridevirtual

Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.

Reimplemented from EDA_BASE_FRAME.

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

References KICAD_MANAGER_ACTIONS::editFootprints, KICAD_MANAGER_ACTIONS::editPCB, KICAD_MANAGER_ACTIONS::editSchematic, KICAD_MANAGER_ACTIONS::editSymbols, m_active_project, m_launcher, and ACTION_TOOLBAR::Toggle().

Referenced by LoadProject(), and RecreateLauncher().

◆ sys_search()

const SEARCH_STACK & KICAD_MANAGER_FRAME::sys_search ( )
overrideprivatevirtual

Return a SEARCH_STACK pertaining to entire program.

This is overloaded in KICAD_MANAGER_FRAME

Reimplemented from EDA_BASE_FRAME.

Definition at line 249 of file kicad_manager_frame.cpp.

250 {
251  return PgmTop().SysSearch();
252 }
SEARCH_STACK & SysSearch()
Definition: pgm_kicad.h:60
PGM_KICAD & PgmTop()
Definition: kicad.cpp:72

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

Referenced by CreateNewProject().

◆ ToolStackIsEmpty()

◆ unitsChangeRefresh()

virtual void EDA_BASE_FRAME::unitsChangeRefresh ( )
inlineprotectedvirtualinherited

Called when when the units setting has changed to allow for any derived classes to handle refreshing and controls that have units based measurements in them.

The default version only updates the status bar. Don't forget to call the default in your derived class or the status bar will not get updated properly.

Reimplemented in PCB_BASE_EDIT_FRAME, GERBVIEW_FRAME, EDA_DRAW_FRAME, and PCB_BASE_FRAME.

Definition at line 201 of file eda_base_frame.h.

201 { }

Referenced by EDA_BASE_FRAME::ChangeUserUnits().

◆ UpdateFileHistory()

void EDA_BASE_FRAME::UpdateFileHistory ( const wxString &  FullFileName,
FILE_HISTORY aFileHistory = NULL 
)
inherited

Update the list of recently opened files.

The menu is also updated, if FILE_HISTORY::UseMenu was called at init time.

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

Definition at line 599 of file eda_base_frame.cpp.

600 {
601  FILE_HISTORY* fileHistory = aFileHistory;
602 
603  if( !fileHistory )
604  fileHistory = &Kiface().GetFileHistory();
605 
606  fileHistory->AddFileToHistory( FullFileName );
607 }
This class implements a file history object to store a list of files, that can then be added to a men...
Definition: filehistory.h:42
void AddFileToHistory(const wxString &aFile) override
Adds a file to the history.
Definition: filehistory.cpp:94
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:125

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

Referenced by SCH_EDIT_FRAME::importFile(), GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::LoadGerberJobFile(), GERBVIEW_FRAME::loadListOfGerberAndDrillFiles(), LoadProject(), OnCloseWindow(), SCH_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::SavePcbFile(), and GERBVIEW_FRAME::unarchiveFiles().

◆ UpdateStatusBar()

virtual void EDA_BASE_FRAME::UpdateStatusBar ( )
inlinevirtualinherited

Update the status bar information.

The status bar can draw itself. This is not a drawing function per se, but rather updates lines of text held by the components within the status bar which is owned by the wxFrame.

Reimplemented in EDA_DRAW_FRAME, GERBVIEW_FRAME, PCB_BASE_FRAME, and SCH_BASE_FRAME.

Definition at line 493 of file eda_base_frame.h.

493 { }

Referenced by TOOL_MANAGER::UpdateUI().

Member Data Documentation

◆ KICAD_AUI_TB_STYLE

◆ m_AboutTitle

wxString EDA_BASE_FRAME::m_AboutTitle
protectedinherited

◆ m_actions

◆ m_active_project

bool KICAD_MANAGER_FRAME::m_active_project
private

Definition at line 182 of file kicad_manager_frame.h.

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

◆ m_auimgr

◆ m_autoSaveInterval

◆ m_autoSaveState

bool EDA_BASE_FRAME::m_autoSaveState
protectedinherited

◆ m_autoSaveTimer

wxTimer* EDA_BASE_FRAME::m_autoSaveTimer
protectedinherited

◆ m_configName

wxString EDA_BASE_FRAME::m_configName
protectedinherited

◆ m_dragSelects

bool EDA_BASE_FRAME::m_dragSelects
protectedinherited

◆ m_FramePos

◆ m_FrameSize

◆ m_hasAutoSave

bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

◆ m_Ident

FRAME_T EDA_BASE_FRAME::m_Ident
protectedinherited

◆ m_immediateActions

bool EDA_BASE_FRAME::m_immediateActions
protectedinherited

◆ m_launcher

ACTION_TOOLBAR* KICAD_MANAGER_FRAME::m_launcher
private

Definition at line 177 of file kicad_manager_frame.h.

Referenced by RecreateLauncher(), and SyncToolbars().

◆ m_leftWin

TREE_PROJECT_FRAME* KICAD_MANAGER_FRAME::m_leftWin
private

◆ m_leftWinWidth

int KICAD_MANAGER_FRAME::m_leftWinWidth
private

Definition at line 181 of file kicad_manager_frame.h.

Referenced by LoadSettings().

◆ m_mainToolBar

ACTION_TOOLBAR* KICAD_MANAGER_FRAME::m_mainToolBar
private

Definition at line 179 of file kicad_manager_frame.h.

Referenced by RecreateBaseHToolbar().

◆ m_messagesBox

wxTextCtrl* KICAD_MANAGER_FRAME::m_messagesBox
private

Definition at line 178 of file kicad_manager_frame.h.

Referenced by ClearMsg(), and PrintMsg().

◆ m_moveWarpsCursor

bool EDA_BASE_FRAME::m_moveWarpsCursor
protectedinherited

◆ m_mruPath

◆ m_perspective

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

Definition at line 151 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::LoadWindowSettings().

◆ m_settingsManager

SETTINGS_MANAGER* EDA_BASE_FRAME::m_settingsManager
protectedinherited

Definition at line 131 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::GetSettingsManager().

◆ m_toolManager

TOOL_MANAGER* EDA_BASE_FRAME::m_toolManager
protectedinherited

Definition at line 133 of file eda_base_frame.h.

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::ActivateGalCanvas(), SCH_EDIT_FRAME::AddJunction(), EDA_BASE_FRAME::AddStandardHelpMenu(), EDA_DRAW_FRAME::AddStandardSubMenus(), SCH_EDIT_FRAME::AppendSchematic(), GERBVIEW_FRAME::Clear_DrawLayers(), SCH_EDIT_FRAME::ConvertPart(), SCH_EDIT_FRAME::ConvertTextType(), EDA_3D_VIEWER::CreateMenuBar(), LIB_EDIT_FRAME::CreateNewPart(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), LIB_VIEW_FRAME::DClickOnCmpList(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_FRAME::DisplayCurrentSheet(), LIB_EDIT_FRAME::emptyScreen(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), EDA_BASE_FRAME::GetToolManager(), SCH_EDIT_FRAME::importFile(), PCB_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::KiwayMailIn(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), LIB_EDIT_FRAME::LoadOneLibraryPartAux(), LIB_EDIT_FRAME::LoadOneSymbol(), SCH_EDIT_FRAME::OnCloseWindow(), GERBVIEW_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnExportBody(), LIB_EDIT_FRAME::OnImportBody(), OnOpenFileInTextEditor(), EDA_DRAW_FRAME::OnSelectGrid(), LIB_EDIT_FRAME::OnSelectUnit(), EDA_DRAW_FRAME::OnSelectZoom(), SCH_EDIT_FRAME::OpenProjectFiles(), EDA_BASE_FRAME::PopTool(), EDA_BASE_FRAME::PushTool(), SCH_EDIT_FRAME::PutDataInPreviousState(), ReCreateMenuBar(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), SCH_BASE_FRAME::RefreshSelection(), FOOTPRINT_WIZARD_FRAME::ReloadFootprint(), LIB_EDIT_FRAME::RollbackPartFromUndo(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), LIB_EDIT_FRAME::saveLibrary(), SCH_EDIT_FRAME::SchematicCleanUp(), GERBVIEW_FRAME::SetActiveLayer(), PCB_BASE_EDIT_FRAME::SetBoard(), LIB_EDIT_FRAME::SetCurPart(), SCH_BASE_FRAME::SetScreen(), LIB_VIEW_FRAME::SetSelectedComponent(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), CVPCB_MAINFRAME::setupTools(), SCH_EDIT_FRAME::setupTools(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), DISPLAY_FOOTPRINTS_FRAME::updateView(), FOOTPRINT_WIZARD_FRAME::updateView(), FOOTPRINT_VIEWER_FRAME::updateView(), FOOTPRINT_EDIT_FRAME::updateView(), EDA_DRAW_FRAME::Zoom_Automatique(), CVPCB_MAINFRAME::~CVPCB_MAINFRAME(), DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME(), EDA_DRAW_FRAME::~EDA_DRAW_FRAME(), FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME(), FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME(), FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME(), GERBVIEW_FRAME::~GERBVIEW_FRAME(), ~KICAD_MANAGER_FRAME(), LIB_EDIT_FRAME::~LIB_EDIT_FRAME(), LIB_VIEW_FRAME::~LIB_VIEW_FRAME(), and SCH_EDIT_FRAME::~SCH_EDIT_FRAME().

◆ m_toolStack

std::vector<std::string> EDA_BASE_FRAME::m_toolStack
protectedinherited

◆ m_userUnits


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