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 
132 protected:
135  wxSize m_FrameSize;
136 
137  wxString m_configFrameName;
138 
140  wxAuiToolBar* m_mainToolBar;
141 
142  wxString m_AboutTitle;
143 
144  wxAuiManager m_auimgr;
145 
148 
151 
154 
156  wxTimer* m_autoSaveTimer;
157 
158  wxString m_perspective;
159 
160  wxString m_mruPath;
161 
166  void onAutoSaveTimer( wxTimerEvent& aEvent );
167 
173  virtual bool isAutoSaveRequired() const { return false; }
174 
181  virtual bool doAutoSave();
182 
188  virtual wxConfigBase* config();
189 
195  virtual const SEARCH_STACK& sys_search();
196 
197  virtual wxString help_name();
198 
199 public:
200  EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
201  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
202  long aStyle, const wxString& aFrameName );
203 
204  ~EDA_BASE_FRAME();
205 
213  bool ProcessEvent( wxEvent& aEvent ) override;
214 
215  bool Enable( bool enable ) override;
216 
217  void SetAutoSaveInterval( int aInterval );
218 
219  int GetAutoSaveInterval() const { return m_autoSaveInterval; }
220 
221  bool IsType( FRAME_T aType ) const { return m_Ident == aType; }
222 
223  void GetKicadHelp( wxCommandEvent& event );
224 
225  void GetKicadContribute( wxCommandEvent& event );
226 
227  void GetKicadAbout( wxCommandEvent& event );
228 
229  void PrintMsg( const wxString& text );
230 
238  virtual void LoadSettings( wxConfigBase* aCfg );
239 
248  virtual void SaveSettings( wxConfigBase* aCfg );
249 
260  wxString ConfigBaseName()
261  {
262  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
263  return baseCfgName;
264  }
265 
266 
274  virtual void SaveProjectSettings( bool aAskForSave ) {};
275 
282  virtual void OnSelectPreferredEditor( wxCommandEvent& event );
283 
284  // Read/Save and Import/export hotkeys config
285 
291  int ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList );
292 
304  virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
305 
313  int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList );
314 
323  const wxString& aDefaultShortname );
324 
333  const wxString& aDefaultShortname );
334 
347  wxString GetFileFromHistory( int cmdId, const wxString& type,
348  wxFileHistory* aFileHistory = NULL );
349 
359  void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL );
360 
361  void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
362 
363  wxString GetMruPath() const { return m_mruPath; }
364 
370  virtual void ReCreateMenuBar();
371 
389  bool IsWritable( const wxFileName& aFileName );
390 
407  void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension );
408 
413  virtual void ShowChangedLanguage();
414 
420  virtual void OnChangeIconsOptions( wxCommandEvent& event );
421 
426  virtual void ShowChangedIcons();
427 
436  void AddMenuIconsOptions( wxMenu* MasterMenu );
437 
438 
445  bool PostCommandMenuEvent( int evt_type );
446 };
447 
448 
470 class EDA_PANEINFO : public wxAuiPaneInfo
471 {
472 
473 public:
474 
480  {
481  ToolbarPane();
482  CloseButton( false );
483  LeftDockable( false );
484  RightDockable( false );
485  //==================== Remove calls below here for movable toolbars //
486  Gripper( false );
487  DockFixed( true );
488  Movable( false );
489  Resizable( true );
490  return *this;
491  }
492 
498  {
499  ToolbarPane();
500  CloseButton( false );
501  TopDockable( false );
502  BottomDockable( false );
503  //==================== Remove calls below here for movable toolbars //
504  Gripper( false );
505  DockFixed( true );
506  Movable( false );
507  Resizable( true );
508  return *this;
509  }
510 
517  {
518  Gripper( false );
519  DockFixed( true );
520  Movable( false );
521  Floatable( false );
522  CloseButton( false );
523  CaptionVisible( false );
524  return *this;
525  }
526 
532  {
533  CloseButton( false );
534  return *this;
535  }
536 
545  {
546  Gripper( false );
547  CloseButton( false );
548  CaptionVisible( false );
549  return *this;
550  }
551 };
552 
553 #endif // WXSTRUCT_H_
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:479
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:578
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:150
void PrintMsg(const wxString &text)
Definition: basicframe.cpp:382
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:160
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
Definition: basicframe.cpp:231
void SetMruPath(const wxString &aPath)
Definition: wxstruct.h:361
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:249
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:112
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: basicframe.cpp:316
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:224
wxString ConfigBaseName()
Function ConfigBaseName.
Definition: wxstruct.h:260
wxString m_AboutTitle
Name of program displayed in About.
Definition: wxstruct.h:142
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:361
virtual void OnChangeIconsOptions(wxCommandEvent &event)
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: basicframe.cpp:662
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxAuiManager m_auimgr
Definition: wxstruct.h:144
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:534
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:531
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:156
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:388
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:470
wxString m_perspective
wxAuiManager perspective.
Definition: wxstruct.h:158
void GetKicadHelp(wxCommandEvent &event)
Definition: basicframe.cpp:436
Class TOOL_MANAGER.
Definition: tool_manager.h:49
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:497
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:370
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:192
FRAME_T m_Ident
Id Type (pcb, schematic, library..)
Definition: wxstruct.h:133
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
Definition: basicframe.cpp:256
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:497
void GetKicadAbout(wxCommandEvent &event)
Definition: basicframe.cpp:527
wxPoint m_FramePos
Definition: wxstruct.h:134
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:137
bool PostCommandMenuEvent(int evt_type)
Function PostCommandMenuEvent.
Definition: basicframe.cpp:647
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:544
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:140
Class TOOL_DISPATCHER.
virtual void SaveProjectSettings(bool aAskForSave)
Function SaveProjectSettings saves changes to the project settings to the project (...
Definition: wxstruct.h:274
Base plotter engine class.
Definition: plot_common.h:86
void SetAutoSaveInterval(int aInterval)
Definition: basicframe.cpp:205
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:516
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
Definition: basicframe.cpp:673
Board layer functions and definitions.
void GetKicadContribute(wxCommandEvent &event)
Definition: basicframe.cpp:514
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:400
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:376
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:173
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:147
bool IsType(FRAME_T aType) const
Definition: wxstruct.h:221
wxSize m_FrameSize
Definition: wxstruct.h:135
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:363
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:153
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Definition: basicframe.cpp:242
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
Definition: basicframe.cpp:166
int GetAutoSaveInterval() const
Definition: wxstruct.h:219
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
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