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-2018 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  void SetAutoSaveInterval( int aInterval );
224 
225  int GetAutoSaveInterval() const { return m_autoSaveInterval; }
226 
227  bool IsType( FRAME_T aType ) const { return m_Ident == aType; }
228 
229  void GetKicadHelp( wxCommandEvent& event );
230 
231  void GetKicadContribute( wxCommandEvent& event );
232 
233  void GetKicadAbout( wxCommandEvent& event );
234 
235  void PrintMsg( const wxString& text );
236 
244  virtual void LoadSettings( wxConfigBase* aCfg );
245 
254  virtual void SaveSettings( wxConfigBase* aCfg );
255 
266  wxString ConfigBaseName()
267  {
268  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
269  return baseCfgName;
270  }
271 
272 
280  virtual void SaveProjectSettings( bool aAskForSave ) {};
281 
288  virtual void OnSelectPreferredEditor( wxCommandEvent& event );
289 
290  // Read/Save and Import/export hotkeys config
291 
297  int ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList );
298 
310  virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
311 
319  int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList );
320 
329  const wxString& aDefaultShortname );
330 
339  const wxString& aDefaultShortname );
340 
353  wxString GetFileFromHistory( int cmdId, const wxString& type,
354  wxFileHistory* aFileHistory = NULL );
355 
365  void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL );
366 
367  void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
368 
369  wxString GetMruPath() const { return m_mruPath; }
370 
376  virtual void ReCreateMenuBar();
377 
395  bool IsWritable( const wxFileName& aFileName );
396 
413  void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension );
414 
419  virtual void ShowChangedLanguage();
420 
426  virtual void OnChangeIconsOptions( wxCommandEvent& event );
427 
432  virtual void ShowChangedIcons();
433 
442  void AddMenuIconsOptions( wxMenu* MasterMenu );
443 
444 
451  bool PostCommandMenuEvent( int evt_type );
452 
459  virtual int GetIconScale() { return -1; }
460 
466  virtual void SetIconScale( int aScale ) {}
467 };
468 
469 
491 class EDA_PANEINFO : public wxAuiPaneInfo
492 {
493 
494 public:
495 
501  {
502  ToolbarPane();
503  CloseButton( false );
504  LeftDockable( false );
505  RightDockable( false );
506  //==================== Remove calls below here for movable toolbars //
507  Gripper( false );
508  DockFixed( true );
509  Movable( false );
510  Resizable( true );
511  return *this;
512  }
513 
519  {
520  ToolbarPane();
521  CloseButton( false );
522  TopDockable( false );
523  BottomDockable( false );
524  //==================== Remove calls below here for movable toolbars //
525  Gripper( false );
526  DockFixed( true );
527  Movable( false );
528  Resizable( true );
529  return *this;
530  }
531 
538  {
539  Gripper( false );
540  DockFixed( true );
541  Movable( false );
542  Floatable( false );
543  CloseButton( false );
544  CaptionVisible( false );
545  return *this;
546  }
547 
553  {
554  CloseButton( false );
555  return *this;
556  }
557 
566  {
567  Gripper( false );
568  CloseButton( false );
569  CaptionVisible( false );
570  return *this;
571  }
572 };
573 
574 #endif // WXSTRUCT_H_
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:500
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:582
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
void PrintMsg(const wxString &text)
Definition: basicframe.cpp:386
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:87
virtual void SetIconScale(int aScale)
Function SetIconScale.
Definition: wxstruct.h:466
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:235
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:367
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:253
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:127
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: basicframe.cpp:320
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:228
wxString ConfigBaseName()
Function ConfigBaseName.
Definition: wxstruct.h:266
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:365
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: basicframe.cpp:666
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:538
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:552
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:392
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:491
wxString m_perspective
wxAuiManager perspective.
Definition: wxstruct.h:163
void GetKicadHelp(wxCommandEvent &event)
Definition: basicframe.cpp:440
Class TOOL_MANAGER.
Definition: tool_manager.h:49
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:518
void removePaneBorder(wxShowEvent &event)
Removes border from wxAui panes.
Definition: basicframe.cpp:150
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:374
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 ...)
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:260
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:501
void GetKicadAbout(wxCommandEvent &event)
Definition: basicframe.cpp:531
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:651
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:565
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:280
Base plotter engine class.
Definition: class_plotter.h:96
void SetAutoSaveInterval(int aInterval)
Definition: basicframe.cpp:209
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:537
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
Definition: basicframe.cpp:677
Board layer functions and definitions.
void GetKicadContribute(wxCommandEvent &event)
Definition: basicframe.cpp:518
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:404
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:178
The common library.
virtual wxString help_name()
Definition: basicframe.cpp:380
virtual int GetIconScale()
Function GetIconScale.
Definition: wxstruct.h:459
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:227
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:369
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:246
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
Definition: basicframe.cpp:176
int GetAutoSaveInterval() const
Definition: wxstruct.h:225
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:241
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