26#include <nlohmann/json.hpp>
74#include <wx/display.h>
75#include <wx/stdpaths.h>
78#include <wx/wupdlock.h>
83#include <nlohmann/json.hpp>
96 return wxWindow::FromDIP( wxSize( 406, 354 ), aWindow );
99 return wxWindow::FromDIP( wxSize( 500, 400 ), aWindow );
109 return wxWindow::FromDIP( wxSize( 850, 540 ), aWindow );
112 return wxWindow::FromDIP( wxSize( 1280, 720 ), aWindow );
181 const wxPoint& aPos,
const wxSize& aSize,
long aStyle,
182 const wxString& aFrameName,
KIWAY* aKiway,
184 wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
197 Bind( wxEVT_DPI_CHANGED,
198 [&]( wxDPIChangedEvent& aEvent )
204 wxAuiPaneInfoArray& panes =
m_auimgr.GetAllPanes();
206 for(
size_t ii = 0; ii < panes.GetCount(); ii++ )
208 wxAuiPaneInfo& pinfo = panes.Item( ii );
209 pinfo.best_size = pinfo.window->GetSize();
212 pinfo.best_size.IncTo( pinfo.window->GetBestSize() );
213 pinfo.best_size.IncTo( pinfo.min_size );
227 for( wxWindow* child : aParent->GetChildren() )
231 if( dlg->IsQuasiModal() )
252 wxWindow* cvpcb = wxWindow::FindWindowByName( wxS(
"CvpcbFrame" ) );
282 if( event.CanVeto() )
298 if( event.CanVeto() )
331 if( event.CanVeto() )
364 if( !IsEnabled() && IsActive() )
378 if( aEvent.GetEventType() == wxEVT_DPI_CHANGED )
380 wxFrame::ProcessEvent( aEvent );
385 if( !wxFrame::ProcessEvent( aEvent ) )
388 if(
Pgm().m_Quitting )
397 wxLogTrace(
traceAutoSave, wxT(
"Starting auto save timer." ) );
408 wxLogTrace(
traceAutoSave, wxT(
"Stopping auto save timer." ) );
455 wxString stamp = aStamp.IsValid() ? aStamp.Format( wxS(
"%Y-%m-%d_%H%M%S" ) ) : wxString( wxS(
"unknown-time" ) );
457 wxFileName recovered( aSrcFn );
458 recovered.SetName( aSrcFn.GetName() + wxS(
".recovered." ) + stamp );
462 while( recovered.FileExists() )
463 recovered.SetName( aSrcFn.GetName() + wxS(
".recovered." ) + stamp + wxString::Format( wxS(
".%d" ), seq++ ) );
465 return recovered.GetFullPath();
484 for(
const auto& [autosavePath, srcPath] : selected )
486 if( !wxCopyFile( autosavePath, srcPath,
true ) )
488 wxLogError(
_(
"Failed to recover auto-saved file '%s'." ), srcPath );
492 wxRemoveFile( autosavePath );
497 for(
const auto& [autosavePath, srcPath] : selected )
499 if( wxFileExists( autosavePath ) )
500 wxRemoveFile( autosavePath );
505 for(
const auto& [autosavePath, srcPath] : selected )
507 wxFileName autosaveFn( autosavePath );
508 wxFileName srcFn( srcPath );
509 wxDateTime stamp = autosaveFn.FileExists() ? autosaveFn.GetModificationTime() : wxDateTime::Now();
513 if( !wxCopyFile( autosavePath, target,
true ) )
515 wxLogError(
_(
"Failed to write recovered file '%s'." ), target );
519 wxRemoveFile( autosavePath );
539 wxDateTime now = wxDateTime::Now();
544 wxTimeSpan maxDeferral = wxTimeSpan::Seconds( std::max( 60,
GetAutoSaveInterval() * 12 ) );
548 wxLogTrace(
traceAutoSave, wxT(
"Deferring auto save; an interactive operation is in progress." ) );
552 wxLogTrace(
traceAutoSave, wxT(
"Auto save deferral exceeded; saving despite interactive operation." ) );
571 if(
cs->AutosaveUsesLocalHistory() )
612 std::placeholders::_1,
629 it->second( aEvent );
638 bool checkRes =
false;
639 bool enableRes =
true;
652 catch( std::exception& )
661 wxString msg =
_(
"Undo" );
666 aEvent.SetText( msg );
668 else if( showRes && aEvent.GetId() ==
ACTIONS::redo.GetUIId() )
670 wxString msg =
_(
"Redo" );
675 aEvent.SetText( msg );
678 if( isCut || isCopy || isPaste )
680 wxWindow* focus = wxWindow::FindFocus();
681 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( focus );
683 if( textEntry && isCut && textEntry->CanCut() )
685 else if( textEntry && isCopy && textEntry->CanCopy() )
687 else if( textEntry && isPaste && textEntry->CanPaste() )
689 else if(
dynamic_cast<WX_GRID*
>( focus ) )
693 aEvent.Enable( enableRes );
694 aEvent.Show( showRes );
696 if( aEvent.IsCheckable() )
697 aEvent.Check( checkRes );
705 [] (
const SELECTION& aSel,
int aLangIdentifier )
710 for(
unsigned ii = 0;
LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
713 cond.
Check( std::bind( isCurrentLang, std::placeholders::_1,
731 if( control.first == aName )
732 return &control.second;
762 wxWindowUpdateLocker
dummy(
this );
778 std::optional<TOOLBAR_CONFIGURATION> tbConfig;
783 if( tbConfig.has_value() )
789 | wxAUI_TB_OVERFLOW );
793 m_tbRight->ApplyConfiguration( tbConfig.value() );
799 if( tbConfig.has_value() )
808 m_tbLeft->ApplyConfiguration( tbConfig.value() );
814 if( tbConfig.has_value() )
820 | wxAUI_TB_TEXT | wxAUI_TB_OVERFLOW );
824 m_tbTopMain->ApplyConfiguration( tbConfig.value() );
830 if( tbConfig.has_value() )
836 | wxAUI_TB_TEXT | wxAUI_TB_OVERFLOW );
840 m_tbTopAux->ApplyConfiguration( tbConfig.value() );
900 wxMenuBar* menuBar = GetMenuBar();
903 [menuBar](
const auto& aEntry )
905 int id = aEntry.first;
907 return id >= wxID_AUTO_LOWEST &&
id <= wxID_AUTO_HIGHEST
908 && !( menuBar && menuBar->FindItem(
id ) );
926 helpMenu->AppendSeparator();
929 aMenuBar->Append( helpMenu,
_(
"&Help" ) );
937 wxMenuBar* menuBar = GetMenuBar();
939 for(
size_t ii = 0; ii < menuBar->GetMenuCount(); ++ii )
941 for( wxMenuItem* menuItem : menuBar->GetMenu( ii )->GetMenuItems() )
943 if( menuItem->GetItemLabelText() == menuItemLabel )
945 wxString menuTitleLabel = menuBar->GetMenuLabelText( ii );
947 menuTitleLabel.Replace( wxS(
"&" ), wxS(
"&&" ) );
948 menuItemLabel.Replace( wxS(
"&" ), wxS(
"&&" ) );
950 return wxString::Format(
_(
"Run: %s > %s" ),
968 GetMenuBar()->Refresh();
994 m_fileHistory->SetMaxFiles( (
unsigned) std::max( 0, historySize ) );
997 if(
Pgm().GetCommonSettings()->AutosaveUsesLocalHistory() )
1007 GetMenuBar()->Refresh();
1020 wxAuiPaneInfoArray panes =
m_auimgr.GetAllPanes();
1022 for(
size_t i = 0; i < panes.GetCount(); ++i )
1025 toolbar->RefreshBitmaps();
1033 int currentDisplay = wxDisplay::GetFromWindow(
this );
1050 if( !
Pgm().GetCommonSettings()->m_Session.remember_open_files )
1060 bool wasDefault =
false;
1083 if( aState.
display >= wxDisplay::GetCount() )
1089 const unsigned int index = 0;
1090 wxDisplay display(
index );
1091 wxRect clientSize = display.GetGeometry();
1107 wxDisplay display( aState.
display );
1108 wxRect clientSize = display.GetClientArea();
1110 int yLimTop = clientSize.y;
1111 int yLimBottom = clientSize.y + clientSize.height;
1112 int xLimLeft = clientSize.x;
1113 int xLimRight = clientSize.x + clientSize.width;
1115 if( upperLeft.x > xLimRight ||
1116 upperRight.x < xLimLeft ||
1117 upperLeft.y < yLimTop ||
1118 upperLeft.y > yLimBottom )
1171 wxDisplay display( wxDisplay::GetFromWindow(
this ) );
1172 wxRect clientSize = display.GetClientArea();
1173 wxPoint pos = GetPosition();
1176 wxLogTrace(
traceDisplayLocation, wxS(
"ensureWindowIsOnScreen: clientArea (%d, %d) w %d h %d" ),
1177 clientSize.x, clientSize.y,
1178 clientSize.width, clientSize.height );
1180 if( pos.y < clientSize.y )
1182 wxLogTrace(
traceDisplayLocation, wxS(
"ensureWindowIsOnScreen: y pos %d below minimum, setting to %d" ),
1183 pos.y, clientSize.y );
1184 pos.y = clientSize.y;
1187 if( pos.x < clientSize.x )
1189 wxLogTrace(
traceDisplayLocation, wxS(
"ensureWindowIsOnScreen: x pos %d below minimum, setting to %d" ),
1190 pos.x, clientSize.x );
1191 pos.x = clientSize.x;
1194 if( pos.x + size.x - clientSize.x > clientSize.width )
1196 int newWidth = clientSize.width - ( pos.x - clientSize.x );
1197 wxLogTrace(
traceDisplayLocation, wxS(
"ensureWindowIsOnScreen: width %d above available %d, setting to %d" ),
1198 pos.x + size.x, clientSize.width, newWidth );
1202 if( pos.y + size.y - clientSize.y > clientSize.height )
1204 int newHeight = clientSize.height - ( pos.y - clientSize.y );
1205 wxLogTrace(
traceDisplayLocation, wxS(
"ensureWindowIsOnScreen: height %d above available %d, setting to %d" ),
1206 pos.y + size.y, clientSize.height, newHeight );
1210 wxLogTrace(
traceDisplayLocation, wxS(
"Updating window position (%d, %d) with size (%d, %d)" ),
1211 pos.x, pos.y, size.x, size.y );
1213 SetSize( pos.x, pos.y, size.x, size.y );
1251 aCfg->
state.
display = wxDisplay::GetFromWindow(
this );
1254 IsMaximized() ? wxS(
"true" ) : wxS(
"false" ) );
1261#if wxCHECK_VERSION( 3, 3, 0 )
1264 nlohmann::json state = serializer.
Serialize();
1266 if( state.is_null() || state.empty() )
1305 if(
Pgm().GetCommonSettings()->m_Session.remember_open_files && !currentlyOpenedFile.IsEmpty() )
1307 wxFileName rfn( currentlyOpenedFile );
1308 rfn.MakeRelativeTo(
Prj().GetProjectPath() );
1316 if( !currentlyOpenedFile.IsEmpty() )
1351 SetStatusText(
text );
1376 bool restored =
false;
1378#if wxCHECK_VERSION( 3, 3, 0 )
1401 wxAuiPaneInfoArray& panes =
m_auimgr.GetAllPanes();
1403 for(
size_t i = 0; i < panes.GetCount(); ++i )
1405 if( panes.Item( i ).IsToolbar() )
1406 panes.Item( i ).Show(
true );
1418 if( aShowCloseButton )
1426 std::function<
void(
void)> aCallback )
1432 if( aShowCloseButton )
1448 if( aShowCloseButton )
1461 if( aShowCloseButton )
1473 wxASSERT( aFileHistory );
1481 GetMenuBar()->Refresh();
1491 wxASSERT( aFileHistory );
1493 int baseId = aFileHistory->GetBaseId();
1495 wxASSERT( cmdId >= baseId && cmdId < baseId + (
int) aFileHistory->GetCount() );
1496 int i = cmdId - baseId;
1498 wxString fn = aFileHistory->GetHistoryFile( i );
1500 if( !wxFileName::FileExists( fn ) )
1503 wxYES_NO | wxYES_DEFAULT | wxICON_ERROR | wxCENTER );
1505 dlg.SetExtendedMessage(
_(
"Do you want to remove it from list of recently opened files?" ) );
1506 dlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel(
_(
"Remove" ) ),
1507 KICAD_MESSAGE_DIALOG::ButtonLabel(
_(
"Keep" ) ) );
1509 if( dlg.ShowModal() == wxID_YES )
1510 aFileHistory->RemoveFileFromHistory( i );
1519 GetMenuBar()->Refresh();
1536 GetMenuBar()->Refresh();
1556 PAGED_DIALOG dlg(
this,
_(
"Preferences" ),
true,
true, wxEmptyString,
1557 wxWindow::FromDIP( wxSize( 980, 560 ),
nullptr ) );
1559 dlg.SetEvtHandlerEnabled(
false );
1566 std::vector<int> expand;
1572 ACTION_MANAGER* actionMgr = kicadMgr->GetToolManager()->GetActionManager();
1579 []( wxWindow* aParent ) -> wxWindow*
1586 []( wxWindow* aParent ) -> wxWindow*
1589 },
_(
"Mouse and Touchpad" ) );
1591#if defined(__linux__) || defined(__FreeBSD__)
1593 [] ( wxWindow* aParent ) -> wxWindow*
1596 },
_(
"SpaceMouse" ) );
1599 book->AddPage( hotkeysPanel,
_(
"Hotkeys" ) );
1602 []( wxWindow* aParent ) -> wxWindow*
1605 },
_(
"Version Control" ) );
1607#ifdef KICAD_USE_SENTRY
1609 []( wxWindow* aParent ) -> wxWindow*
1612 },
_(
"Data Collection" ) );
1615#define LAZY_CTOR( key ) \
1616 [this, kiface]( wxWindow* aParent ) \
1618 return kiface->CreateKiWindow( aParent, key, &Kiway() ); \
1630 expand.push_back( (
int) book->GetPageCount() );
1632 book->AddPage(
new wxPanel( book ),
_(
"Symbol Editor" ) );
1641 expand.push_back( (
int) book->GetPageCount() );
1643 book->AddPage(
new wxPanel( book ),
_(
"Schematic Editor" ) );
1666 expand.push_back( (
int) book->GetPageCount() );
1668 book->AddPage(
new wxPanel( book ),
_(
"Footprint Editor" ) );
1681 expand.push_back( (
int) book->GetPageCount() );
1683 book->AddPage(
new wxPanel( book ),
_(
"PCB Editor" ) );
1694 expand.push_back( (
int) book->GetPageCount() );
1696 book->AddPage(
new wxPanel( book ),
_(
"3D Viewer" ) );
1714 expand.push_back( (
int) book->GetPageCount() );
1716 book->AddPage(
new wxPanel( book ),
_(
"Gerber Viewer" ) );
1736 expand.push_back( (
int) book->GetPageCount() );
1738 book->AddPage(
new wxPanel( book ),
_(
"Drawing Sheet Editor" ) );
1746 []( wxWindow* aParent ) -> wxWindow*
1749 },
_(
"Packages and Updates" ) );
1764 for(
size_t i = 0; i < book->GetPageCount(); ++i )
1765 book->GetPage( i )->Layout();
1767 for(
int page : expand )
1768 book->ExpandNode( page );
1770 if( !aStartPage.IsEmpty() )
1773 dlg.SetEvtHandlerEnabled(
true );
1792 wxString* files = aEvent.GetFiles();
1794 for(
int nb = 0; nb < aEvent.GetNumberOfFiles(); nb++ )
1796 const wxFileName fn = wxFileName( files[nb] );
1797 wxString ext = fn.GetExt();
1816 wxString fn = file.GetFullPath();
1825 wxFileName fn = aFileName;
1831 if( fn.GetPath().IsEmpty() && fn.HasName() )
1834 wxCHECK_MSG( fn.IsOk(),
false, wxT(
"File name object is invalid. Bad programmer!" ) );
1835 wxCHECK_MSG( !fn.GetPath().IsEmpty(),
false,
1836 wxT(
"File name object path <" ) + fn.GetFullPath() + wxT(
"> is not set. Bad programmer!" ) );
1838 if( fn.IsDir() && !fn.IsDirWritable() )
1840 msg.Printf(
_(
"Insufficient permissions to folder '%s'." ), fn.GetPath() );
1842 else if( !fn.FileExists() && !fn.IsDirWritable() )
1844 msg.Printf(
_(
"Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1846 else if( fn.FileExists() && !fn.IsFileWritable() )
1848 msg.Printf(
_(
"Insufficient permissions to save file '%s'." ), fn.GetFullPath() );
1851 if( !msg.IsEmpty() )
1872 wxAcceleratorEntry entries[1];
1873 entries[0].Set( wxACCEL_CTRL,
int(
'Q' ), wxID_EXIT );
1874 wxAcceleratorTable accel( 1, entries );
1875 SetAcceleratorTable( accel );
1895 if( extraitems > 0 )
1910 if( extraitems > 0 )
1931 return m_undoList.m_CommandsList.back()->GetDescription();
1933 return wxEmptyString;
1940 return m_redoList.m_CommandsList.back()->GetDescription();
1942 return wxEmptyString;
1957 wxCommandEvent e( EDA_EVT_UNITS_CHANGED );
1958 e.SetInt(
static_cast<int>( aUnits ) );
1959 e.SetClientData(
this );
1960 ProcessEventLocally( e );
1972 if( !IsMaximized() )
1977 wxLogTrace(
traceDisplayLocation,
"Maximizing window - Saving position (%d, %d) with size (%d, %d)",
1989#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 9 )
1990 wxSize winSize = GetSize();
1999 GTKDoGetSize( &width, &height );
2001 winSize.Set( width, height );
2004 wxSize winSize = GetSize();
2020 GetMenuBar()->Refresh();
2046WXLRESULT EDA_BASE_FRAME::MSWWindowProc( WXUINT
message, WXWPARAM wParam, WXLPARAM lParam )
2050 if(
message == WM_SYSCOMMAND )
2052 if( wParam == SC_KEYMENU && ( lParam >> 16 ) <= 0 )
2056 return wxFrame::MSWWindowProc(
message, wParam, lParam );
2064 langsMenu->
SetTitle(
_(
"Set Language" ) );
2069 for(
unsigned ii = 0;
LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
2078 wxMenuItem* item =
new wxMenuItem( langsMenu,
LanguagesList[ii].m_KI_Lang_Identifier,
2079 label, tooltip, wxITEM_CHECK );
2081 langsMenu->Append( item );
2085 aMasterMenu->
Add( langsMenu );
2091 int id =
event.GetId();
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
void ClearScaledBitmapCache()
Wipes out the scaled bitmap cache so that the icon theme can be changed.
BITMAP_STORE * GetBitmapStore()
static TOOL_ACTION reportBug
static TOOL_ACTION donate
static TOOL_ACTION listHotKeys
static TOOL_ACTION getInvolved
static TOOL_ACTION gettingStarted
Manage TOOL_ACTION objects.
const std::map< std::string, TOOL_ACTION * > & GetActions() const
Get a list of currently-registered actions mapped by their name.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void ReloadPlugins(std::optional< wxString > aDirectoryToScan=std::nullopt, std::shared_ptr< REPORTER > aReporter=nullptr)
Clears the loaded plugins and actions and re-scans the filesystem to register new ones.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
Handle actions that are shared between different applications.
std::vector< std::pair< wxString, wxString > > GetSelectedStale() const
AUTOSAVE_RECOVERY_CHOICE GetChoice() const
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
The base frame for deriving all KiCad main window classes.
void SelectToolbarAction(const TOOL_ACTION &aAction) override
Select the given action in the toolbar group which contains it, if any.
virtual wxString help_name()
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
void LoadWindowState(const wxString &aFileName)
FRAME_T GetFrameType() const
virtual void UnregisterUIUpdateHandler(int aID) override
Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler.
virtual bool isAutoSaveRequired() const
Return the auto save status of the application.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
void ShowPreferences(const wxString &aStartPage, const wxString &aStartParentPage)
Display the preferences and settings of all opened editors paged dialog, starting with a particular p...
void windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
virtual void OnCharHook(wxKeyEvent &aKeyEvent)
Capture the key event before it is sent to the GUI.
virtual int GetRedoCommandCount() const
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
UNDO_REDO_CONTAINER m_undoList
virtual void OnMove(wxMoveEvent &aEvent)
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
virtual void doCloseWindow()
void OnToolbarSizeChanged()
Update toolbars if desired toolbar icon changed.
void OnMenuEvent(wxMenuEvent &event)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
virtual bool IsModal() const
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void HandleSystemColorChange()
Update the UI in response to a change in the system colors.
virtual void syncToolbarSelections()
Called after the toolbars are rebuilt so a frame can select the group entries that reflect its saved ...
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void ensureWindowIsOnScreen()
bool m_isNonUserClose
Set by NonUserClose() to indicate that the user did not request the current close.
void CheckForAutosaveFiles(const wxString &aProjectPath, const std::vector< wxString > &aExtensions)
Check for autosave files newer than their source files for the given project.
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
std::vector< wxFileName > m_AcceptedFiles
bool m_uiUpdateHandlerBound
True once the single wxID_ANY UPDATE_UI handler has been bound.
bool m_autoSavePermissionError
void OnKicadAbout(wxCommandEvent &event)
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
virtual void DoWithAcceptedFiles()
Execute action on accepted dropped file.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
wxWindow * findQuasiModalDialog()
bool isBlockableSessionEnd() const
Return true when the session is ending on a platform that shows a shutdown block reason.
wxDateTime m_autoSaveDeferredSince
virtual void ClearUndoORRedoList(UNDO_REDO_LIST aList, int aItemCount=-1)
Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if nee...
virtual void ThemeChanged()
Process light/dark theme change.
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, KIWAY *aKiway, const EDA_IU_SCALE &aIuScale)
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars.
bool m_closeInProgress
Set while windowClosing() is deciding whether the frame may close.
ACTION_TOOLBAR * m_tbRight
void initExitKey()
Set the common key-pair for exiting the application (Ctrl-Q) and ties it to the wxID_EXIT event id.
void OnPreferences(wxCommandEvent &event)
virtual const SEARCH_STACK & sys_search()
Return a SEARCH_STACK pertaining to entire program.
void onAutoSaveTimer(wxTimerEvent &aEvent)
Handle the auto save timer event.
void SaveWindowSettings(WINDOW_SETTINGS *aCfg)
Save window settings to the given settings object.
virtual wxString GetRedoActionDescription() const
TOOLBAR_SETTINGS * m_toolbarSettings
void FinishAUIInitialization()
virtual wxString GetCurrentFileName() const
Get the full filename + path of the currently opened file in the frame.
void ChangeUserUnits(EDA_UNITS aUnits)
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Create a menu list for language choice, and add it as submenu to MasterMenu.
virtual bool canRunAutoSave() const
Return true when it is safe to run an autosave snapshot right now.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
virtual void configureToolbars()
wxTimer * m_autoSaveTimer
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, INFOBAR_MESSAGE_TYPE aType=INFOBAR_MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void PrintMsg(const wxString &text)
void onUpdateUI(wxUpdateUIEvent &aEvent)
void commonInit(FRAME_T aFrameType)
Collect common initialization functions used in all CTORs.
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual void RecreateToolbars()
std::map< int, UIUpdateHandler > m_uiUpdateMap
Map containing the UI update handlers registered with wx for each action.
std::map< std::string, ACTION_TOOLBAR_CONTROL_FACTORY > m_toolbarControlFactories
ACTION_TOOLBAR_CONTROL_FACTORY * GetCustomToolbarControlFactory(const std::string &aName)
static void HandleUpdateUIEvent(wxUpdateUIEvent &aEvent, EDA_BASE_FRAME *aFrame, ACTION_CONDITIONS &aCond)
Handle events generated when the UI is trying to figure out the current state of the UI controls rela...
UNDO_REDO_CONTAINER m_redoList
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
FILE_HISTORY * m_fileHistory
ACTION_TOOLBAR * m_tbLeft
SETTINGS_MANAGER * m_settingsManager
virtual void OnSize(wxSizeEvent &aEvent)
virtual wxString GetUndoActionDescription() const
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
void OnLanguageSelectionEvent(wxCommandEvent &aEvent)
An event handler called on a language menu selection.
wxString GetRunMenuCommandDescription(const TOOL_ACTION &aAction)
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Check if aFileName can be written.
void OnMaximize(wxMaximizeEvent &aEvent)
std::unique_ptr< nlohmann::json > m_auiLayoutState
virtual void ClearFileHistory()
Remove all files from the file history.
ACTION_TOOLBAR * m_tbTopAux
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
void onIconize(wxIconizeEvent &aEvent)
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
wxSize GetWindowSize()
Get the undecorated window size that can be used for restoring the window size.
int GetAutoSaveInterval() const
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void onSystemColorChange(wxSysColourChangedEvent &aEvent)
virtual int GetUndoCommandCount() const
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions) override
Register a UI update handler for the control with ID aID.
ACTION_TOOLBAR * m_tbTopMain
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
void AddStandardHelpMenu(wxMenuBar *aMenuBar)
Add the standard KiCad help menu to the menubar.
void ReCreateMenuBar()
Recreate the menu bar.
virtual void doReCreateMenuBar()
WX_INFOBAR * GetInfoBar()
This class implements a file history object to store a list of files, that can then be added to a men...
void AddFileToHistory(const wxString &aFile) override
Adds a file to the history.
The main KiCad project manager frame.
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
APP_SETTINGS_BASE * KifaceSettings() const
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY_HOLDER(KIWAY *aKiway, HOLDER_TYPE aType)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all KIWAY_PLAYER objects.
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
bool RunRegisteredSaversAndCommit(const wxString &aProjectPath, const wxString &aTitle, const wxString &aTagFileType=wxEmptyString)
Run all registered savers and, if any staged changes differ from HEAD, create a commit.
std::vector< std::pair< wxString, wxString > > FindStaleAutosaveFiles(const wxString &aProjectPath, const std::vector< wxString > &aExtensions) const
Enumerate autosave files newer than their corresponding source files for the project at aProjectPath,...
bool Init(const wxString &aProjectPath)
Initialize the local history repository for the given project path.
bool RunRegisteredSaversAsAutosaveFiles(const wxString &aProjectPath)
Run all registered savers and write their output to autosave files instead of committing to the local...
WX_TREEBOOK * GetTreebook()
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
std::vector< TOOL_ACTION * > & ActionsList()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
virtual COMMON_SETTINGS * GetCommonSettings() const
bool IsSessionEnding() const
Return true while the operating system is closing the application because the user session is ending,...
virtual API_PLUGIN_MANAGER & GetPluginManager() const
virtual int GetSelectedLanguageIdentifier() const
KICAD_API_SERVER & GetApiServer()
virtual SETTINGS_MANAGER & GetSettingsManager() const
A holder to handle information on schematic or board items.
void SaveFileState(const wxString &aFileName, const WINDOW_SETTINGS *aWindowCfg, bool aOpen)
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
RAII class that sets an value at construction and resets it to the original value at destruction.
Look for files in a number of paths.
UNITS_PROVIDER(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
void SetUserUnits(EDA_UNITS aUnits)
bool Deserialize(const nlohmann::json &aState) const
nlohmann::json Serialize() const
Simple wrapper around wxBusyCursor for used with the generic BUSY_INDICATOR interface.
A modified version of the wxInfoBar class that allows us to:
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
bool AddLazyPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
bool AddLazySubPage(std::function< wxWindow *(wxWindow *aParent)> aLazyCtor, const wxString &text, bool bSelect=false, int imageId=NO_IMAGE)
@ PROJECT_DIR
Inside the project directory (default)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
const int minSize
Push and Shove router track width and via size dialog.
static wxString buildRecoveredFileName(const wxFileName &aSrcFn, const wxDateTime &aStamp)
static const wxSize minSizeLookup(FRAME_T aFrameType, wxWindow *aWindow)
static const wxSize defaultSize(FRAME_T aFrameType, wxWindow *aWindow)
wxWindow * findQuasiModalDialog(wxWindow *aParent)
Base window classes and related definitions.
#define KICAD_MANAGER_FRAME_NAME
std::function< void(ACTION_TOOLBAR *)> ACTION_TOOLBAR_CONTROL_FACTORY
#define DEFAULT_MAX_UNDO_ITEMS
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
@ FRAME_SCH_SYMBOL_EDITOR
@ PANEL_SCH_FIELD_NAME_TEMPLATES
@ PANEL_GBR_DISPLAY_OPTIONS
@ PANEL_FP_DEFAULT_GRAPHICS_VALUES
@ PANEL_FP_DISPLAY_OPTIONS
@ PANEL_FP_DEFAULT_FIELDS
@ PANEL_PCB_ACTION_PLUGINS
@ PANEL_3DV_DISPLAY_OPTIONS
@ PANEL_DS_DISPLAY_OPTIONS
@ PANEL_GBR_EXCELLON_OPTIONS
static const std::string GerberFileExtension
static bool IsGerberFileExtension(const wxString &ext)
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
void ReadHotKeyConfigIntoActions(const wxString &aFileName, std::vector< TOOL_ACTION * > &aActions)
Read a hotkey config file into a list of actions.
EVT_MENU(ID_COMPARE_PROJECT_BRANCHES, KICAD_MANAGER_FRAME::OnCompareProjectBranches) KICAD_MANAGER_FRAME
PGM_BASE & Pgm()
The global program "get" accessor.
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
std::vector< FAB_LAYER_COLOR > dummy
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
SELECTION_CONDITION enableCondition
Returns true if the UI control should be enabled.
SELECTION_CONDITION checkCondition
Returns true if the UI control should be checked.
SELECTION_CONDITION showCondition
Returns true if the UI control should be shown.
ACTION_CONDITIONS & Check(const SELECTION_CONDITION &aCondition)
int local_history_debounce
Implement a participant in the KIWAY alchemy.
Store the common settings that are saved and loaded for each window / frame.
Store the window positioning/state.
IFACE KIFACE_BASE kiface("pcb_test_frame", KIWAY::FACE_PCB)
static const long long MM
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxLogTrace helper definitions.
INFOBAR_MESSAGE_TYPE
Sets the type of message for special handling if needed.