32#ifndef EDA_BASE_FRAME_H_
33#define EDA_BASE_FRAME_H_
40#include <wx/aui/aui.h>
55#define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
58#define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )
59#define QUALIFIED_VIEWER3D_FRAMENAME( parent ) \
60 ( wxString( VIEWER3D_FRAMENAME ) + wxT( ":" ) + parent->GetName() )
62#define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
93#define DEFAULT_MAX_UNDO_ITEMS 0
94#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
123 const wxPoint& aPos,
const wxSize& aSize,
long aStyle,
160 virtual void OnCharHook( wxKeyEvent& aKeyEvent );
194 virtual void OnMove( wxMoveEvent& aEvent )
199 virtual void OnSize( wxSizeEvent& aEvent );
225 void ShowPreferences( wxString aStartPage, wxString aStartParentPage );
247 void ShowInfoBarError(
const wxString& aErrorMsg,
bool aShowCloseButton =
false,
265 std::function<
void(
void)> aCallback );
276 void ShowInfoBarWarning(
const wxString& aWarningMsg,
bool aShowCloseButton =
false );
287 void ShowInfoBarMsg(
const wxString& aMsg,
bool aShowCloseButton =
false );
380 const wxString& aDefaultShortname );
475 void SetMenuBar( wxMenuBar *menu_bar )
override;
497 bool IsWritable(
const wxFileName& aFileName,
bool aVerbose =
true );
629 return Close( aForce );
665 void onIconize( wxIconizeEvent& aEvent );
724 virtual void OnDropFiles( wxDropFilesEvent& aEvent );
743 DECLARE_EVENT_TABLE()
772 virtual
bool IsModal()
const {
return false; }
778 WXLRESULT MSWWindowProc( WXUINT message, WXWPARAM wParam, WXLPARAM lParam )
override;
873 CloseButton(
false );
882 SetFlag( optionToolbar,
true );
883 CaptionVisible(
false );
884 TopDockable().BottomDockable();
896 SetFlag( optionToolbar,
true );
897 CaptionVisible(
false );
898 LeftDockable().RightDockable();
910 CaptionVisible(
true );
920 CaptionVisible(
false );
932 CaptionVisible(
false );
933 BottomDockable(
true );
945 CaptionVisible(
false );
Gather all the actions that are shared by tools.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Handles how to draw a screen (a board, a schematic ...)
The base frame for deriving all KiCad main window classes.
virtual wxString help_name()
virtual void saveProjectSettings()
Save any design-related project settings associated with this frame.
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
wxString ConfigBaseName() override
Get the configuration base name.
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 windowClosing(wxCloseEvent &event)
(with its unexpected name so it does not collide with the real OnWindowClose() function provided in d...
APPEARANCE_CONTROLS_3D * m_appearancePanel
virtual void OnCharHook(wxKeyEvent &aKeyEvent)
Capture the key event before it is sent to the GUI.
virtual int GetRedoCommandCount() const
bool NonUserClose(bool aForce)
virtual void ProjectChanged()
Notification event that the project has changed.
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()
const wxString & GetUntranslatedAboutTitle() const
virtual void UpdateStatusBar()
Update the status bar information.
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 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.
const wxString & GetAboutTitle() const
void LoadWindowSettings(const WINDOW_SETTINGS *aCfg)
Load window settings from the given settings object.
std::vector< wxFileName > m_AcceptedFiles
virtual SEVERITY GetSeverity(int aErrorCode) const
virtual void CheckForAutoSaveFile(const wxFileName &aFileName)
Check if an auto save file exists for aFileName and takes the appropriate action depending on the use...
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()
SETTINGS_MANAGER * GetSettingsManager() const
virtual void DoWithAcceptedFiles()
Execute action on accepted dropped file.
UNDO_REDO_LIST
Specify whether we are interacting with the undo or redo stacks.
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()
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...
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.
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars.
ACTION_TOOLBAR * m_tbRight
void ShowPreferences(wxString aStartPage, wxString aStartParentPage)
Display the preferences and settings of all opened editors paged dialog, starting with a particular p...
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 void ToggleUserUnits()
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.
void SetMenuBar(wxMenuBar *menu_bar) override
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 UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void PrintMsg(const wxString &text)
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 ...
int GetMaxUndoItems() const
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual bool CanAcceptApiCommands()
Check if this frame is ready to accept API commands.
virtual void RecreateToolbars()
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Remove all files from the file history.
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)
UNDO_REDO_CONTAINER m_redoList
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
wxString GetMruPath() const
FILE_HISTORY * m_fileHistory
ACTION_TOOLBAR * m_tbLeft
SETTINGS_MANAGER * m_settingsManager
FILE_HISTORY & GetFileHistory()
Get the frame's main file history.
virtual void DeleteAutoSaveFile(const wxFileName &aFileName)
virtual void OnSize(wxSizeEvent &aEvent)
virtual wxString GetUndoActionDescription() const
void ImportHotkeyConfigFromFile(std::map< std::string, TOOL_ACTION * > aActionMap, const wxString &aDefaultShortname)
Prompt the user for a hotkey file to read, and read it.
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
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)
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
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 SetMruPath(const wxString &aPath)
void onSystemColorChange(wxSysColourChangedEvent &aEvent)
virtual int GetUndoCommandCount() const
ORIGIN_TRANSFORMS m_originTransforms
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 SaveProjectLocalSettings()
Save changes to the project local settings.
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_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...
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
bool IsType(FRAME_T aType) const
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()
A base class for most all the KiCad significant classes used in schematics and boards.
A panel to display various information messages.
Specialization of the wxAuiPaneInfo class for KiCad panels.
EDA_PANE & Canvas()
Turn *this into an undecorated pane suitable for a drawing canvas.
EDA_PANE & Messages()
Turn *this into a messages pane for KiCad.
EDA_PANE & InfoBar()
Turn *this into a infobar for KiCad.
EDA_PANE & HToolbar()
Turn *this to a horizontal toolbar for KiCad.
EDA_PANE & VToolbar()
Turn *this into a vertical toolbar for KiCad.
EDA_PANE & Palette()
Turn *this into a captioned palette suitable for a symbol tree, layers manager, etc.
This class implements a file history object to store a list of files, that can then be added to a men...
A mix in class which holds the location of a wxWindow's KIWAY.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
EDA_MSG_PANEL items for displaying messages.
Describe the page size and margins of a paper page on which to eventually print or plot.
A holder to handle information on schematic or board items.
Base plotter engine class.
Look for files in a number of paths.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
A modified version of the wxInfoBar class that allows us to:
MESSAGE_TYPE
Sets the type of message for special handling if needed.
@ GENERIC
GENERIC Are messages that do not have special handling.
std::function< void(wxUpdateUIEvent &) > UIUpdateHandler
This is the handler functor for the update UI events.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
Store the common settings that are saved and loaded for each window / frame.
Store the window positioning/state.
Functions to provide common constants and other functions to assist in making a consistent UI.