KiCad PCB EDA Suite
wxstruct.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2009-2015 Jean-Pierre Charras, jp.charras wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #ifndef WXSTRUCT_H_
32 #define WXSTRUCT_H_
33 
34 
35 #include <vector>
36 
37 #include <wx/socket.h>
38 #include <wx/log.h>
39 #include <wx/config.h>
40 #include <wx/wxhtml.h>
41 #include <wx/laywin.h>
42 #include <wx/aui/aui.h>
43 #include <wx/docview.h>
44 
45 #include <fctsys.h>
46 #include <common.h>
48 #include <frame_type.h>
49 
50 #ifdef USE_WX_OVERLAY
51 #include <wx/overlay.h>
52 #endif
53 
54 // Option for main frames
55 #define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
56 
57 
58 // Readability helper definitions for creating backup files.
59 #define CREATE_BACKUP_FILE true
60 #define NO_BACKUP_FILE false
61 
71 #define AUTOSAVE_PREFIX_FILENAME wxT( "_saved_" )
72 
73 
74 class EDA_ITEM;
75 class EDA_RECT;
76 class EDA_DRAW_PANEL;
77 class EDA_DRAW_PANEL_GAL;
78 class EDA_MSG_PANEL;
79 class BASE_SCREEN;
80 class PARAM_CFG_BASE;
81 class PAGE_INFO;
82 class PLOTTER;
83 class TITLE_BLOCK;
84 class MSG_PANEL_ITEM;
85 class TOOL_MANAGER;
86 class TOOL_DISPATCHER;
87 class ACTIONS;
88 
89 
95 };
96 
97 
103 extern const wxChar traceAutoSave[];
104 
105 
117 class EDA_BASE_FRAME : public wxFrame
118 {
130  void windowClosing( wxCloseEvent& event );
131 
135  void removePaneBorder( wxShowEvent& event );
136 
137 protected:
140  wxSize m_FrameSize;
141 
142  wxString m_configFrameName;
143 
145  wxAuiToolBar* m_mainToolBar;
146 
147  wxString m_AboutTitle;
148 
149  wxAuiManager m_auimgr;
150 
153 
156 
159 
161  wxTimer* m_autoSaveTimer;
162 
163  wxString m_perspective;
164 
165  wxString m_mruPath;
166 
168  static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND;
169 
174  void onAutoSaveTimer( wxTimerEvent& aEvent );
175 
181  virtual bool isAutoSaveRequired() const { return false; }
182 
189  virtual bool doAutoSave();
190 
196  virtual wxConfigBase* config();
197 
203  virtual const SEARCH_STACK& sys_search();
204 
205  virtual wxString help_name();
206 
207 public:
208  EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
209  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
210  long aStyle, const wxString& aFrameName );
211 
212  ~EDA_BASE_FRAME();
213 
221  bool ProcessEvent( wxEvent& aEvent ) override;
222 
223  bool Enable( bool enable ) override;
224 
225  void SetAutoSaveInterval( int aInterval );
226 
227  int GetAutoSaveInterval() const { return m_autoSaveInterval; }
228 
229  bool IsType( FRAME_T aType ) const { return m_Ident == aType; }
230 
231  void GetKicadHelp( wxCommandEvent& event );
232 
233  void GetKicadContribute( wxCommandEvent& event );
234 
235  void GetKicadAbout( wxCommandEvent& event );
236 
237  void PrintMsg( const wxString& text );
238 
246  virtual void LoadSettings( wxConfigBase* aCfg );
247 
256  virtual void SaveSettings( wxConfigBase* aCfg );
257 
268  wxString ConfigBaseName()
269  {
270  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
271  return baseCfgName;
272  }
273 
274 
282  virtual void SaveProjectSettings( bool aAskForSave ) {};
283 
290  virtual void OnSelectPreferredEditor( wxCommandEvent& event );
291 
292  // Read/Save and Import/export hotkeys config
293 
299  int ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList );
300 
312  virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
313 
321  int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList );
322 
331  const wxString& aDefaultShortname );
332 
341  const wxString& aDefaultShortname );
342 
355  wxString GetFileFromHistory( int cmdId, const wxString& type,
356  wxFileHistory* aFileHistory = NULL );
357 
367  void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL );
368 
369  void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
370 
371  wxString GetMruPath() const { return m_mruPath; }
372 
378  virtual void ReCreateMenuBar();
379 
397  bool IsWritable( const wxFileName& aFileName );
398 
415  void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension );
416 
421  virtual void ShowChangedLanguage();
422 
428  virtual void OnChangeIconsOptions( wxCommandEvent& event );
429 
434  virtual void ShowChangedIcons();
435 
444  void AddMenuIconsOptions( wxMenu* MasterMenu );
445 
446 
453  bool PostCommandMenuEvent( int evt_type );
454 };
455 
456 
478 class EDA_PANEINFO : public wxAuiPaneInfo
479 {
480 
481 public:
482 
488  {
489  ToolbarPane();
490  CloseButton( false );
491  LeftDockable( false );
492  RightDockable( false );
493  //==================== Remove calls below here for movable toolbars //
494  Gripper( false );
495  DockFixed( true );
496  Movable( false );
497  Resizable( true );
498  return *this;
499  }
500 
506  {
507  ToolbarPane();
508  CloseButton( false );
509  TopDockable( false );
510  BottomDockable( false );
511  //==================== Remove calls below here for movable toolbars //
512  Gripper( false );
513  DockFixed( true );
514  Movable( false );
515  Resizable( true );
516  return *this;
517  }
518 
525  {
526  Gripper( false );
527  DockFixed( true );
528  Movable( false );
529  Floatable( false );
530  CloseButton( false );
531  CaptionVisible( false );
532  return *this;
533  }
534 
540  {
541  CloseButton( false );
542  return *this;
543  }
544 
553  {
554  Gripper( false );
555  CloseButton( false );
556  CaptionVisible( false );
557  return *this;
558  }
559 };
560 
561 #endif // WXSTRUCT_H_
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
void CheckForAutoSaveFile(const wxFileName &aFileName, const wxString &aBackupFileExtension)
Function CheckForAutoSaveFile checks if an auto save file exists for aFileName and takes the appropri...
Definition: basicframe.cpp:597
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
void PrintMsg(const wxString &text)
Definition: basicframe.cpp:401
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:87
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:165
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
Definition: basicframe.cpp:250
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:369
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfigFile Read an old configuration file (<file>.key) and fill the current ho...
virtual void ShowChangedIcons()
Function ShowChangedIcons redraws items menus after a icon was changed option.
Definition: basicframe.cpp:268
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
void windowClosing(wxCloseEvent &event)
Function windowClosing (with its unexpected name so it does not collide with the real OnWindowClose()...
Definition: basicframe.cpp:115
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: basicframe.cpp:335
void ExportHotkeyConfigToFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it...
void onAutoSaveTimer(wxTimerEvent &aEvent)
Function onAutoSaveTimer handles the auto save timer event.
Definition: basicframe.cpp:243
wxString ConfigBaseName()
Function ConfigBaseName.
Definition: wxstruct.h:268
wxString m_AboutTitle
Name of program displayed in About.
Definition: wxstruct.h:147
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:380
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: basicframe.cpp:681
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxAuiManager m_auimgr
Definition: wxstruct.h:149
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:553
int ReadHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList)
Function ReadHotkeyConfig Read configuration data and fill the current hotkey list with hotkeys...
class EDA_MSG_PANEL is a panel to display various information messages.
Definition: msgpanel.h:111
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:539
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
Definition: wxstruct.h:161
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:407
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
wxString m_perspective
wxAuiManager perspective.
Definition: wxstruct.h:163
void GetKicadHelp(wxCommandEvent &event)
Definition: basicframe.cpp:455
Class TOOL_MANAGER.
Definition: tool_manager.h:49
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:505
void removePaneBorder(wxShowEvent &event)
Removes border from wxAui panes.
Definition: basicframe.cpp:159
virtual const SEARCH_STACK & sys_search()
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
Definition: basicframe.cpp:389
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
bool Enable(bool enable) override
Definition: basicframe.cpp:211
FRAME_T m_Ident
Id Type (pcb, schematic, library..)
Definition: wxstruct.h:138
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
Definition: basicframe.cpp:275
virtual void OnSelectPreferredEditor(wxCommandEvent &event)
Function OnSelectPreferredEditor Open a dialog to select the editor that will used in KiCad to edit o...
Definition: basicframe.cpp:516
void GetKicadAbout(wxCommandEvent &event)
Definition: basicframe.cpp:546
wxPoint m_FramePos
Definition: wxstruct.h:139
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:142
bool PostCommandMenuEvent(int evt_type)
Function PostCommandMenuEvent.
Definition: basicframe.cpp:666
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
Definition: wxstruct.h:552
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
Class TOOL_DISPATCHER.
virtual void SaveProjectSettings(bool aAskForSave)
Function SaveProjectSettings saves changes to the project settings to the project (...
Definition: wxstruct.h:282
Base plotter engine class.
Definition: class_plotter.h:97
void SetAutoSaveInterval(int aInterval)
Definition: basicframe.cpp:224
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:524
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
Definition: basicframe.cpp:692
Board layer functions and definitions.
void GetKicadContribute(wxCommandEvent &event)
Definition: basicframe.cpp:533
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
wxString GetFileFromHistory(int cmdId, const wxString &type, wxFileHistory *aFileHistory=NULL)
Function GetFileFromHistory fetches the file name from the file history list.
Definition: basicframe.cpp:419
Class EDA_RECT handles the component boundary box.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
The common library.
virtual wxString help_name()
Definition: basicframe.cpp:395
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
Definition: wxstruct.h:168
id_librarytype
Definition: wxstruct.h:90
Class ACTIONS.
Definition: actions.h:41
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:181
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:152
bool IsType(FRAME_T aType) const
Definition: wxstruct.h:229
wxSize m_FrameSize
Definition: wxstruct.h:140
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
void ImportHotkeyConfigFromFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.
wxString GetMruPath() const
Definition: wxstruct.h:371
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:158
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Definition: basicframe.cpp:261
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
Definition: basicframe.cpp:185
int GetAutoSaveInterval() const
Definition: wxstruct.h:227
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:256
const wxChar traceAutoSave[]
Flag to enable auto save feature debug tracing.
Definition: basicframe.cpp:53
EDA_BASE_FRAME(wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
Definition: basicframe.cpp:74