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-2015 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2015 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 
70 #define AUTOSAVE_PREFIX_FILENAME wxT( "_saved_" )
71 
72 
73 class EDA_ITEM;
74 class EDA_RECT;
75 class EDA_DRAW_PANEL;
76 class EDA_DRAW_PANEL_GAL;
77 class EDA_MSG_PANEL;
78 class BASE_SCREEN;
79 class PARAM_CFG_BASE;
80 class PAGE_INFO;
81 class PLOTTER;
82 class TITLE_BLOCK;
83 class MSG_PANEL_ITEM;
84 class TOOL_MANAGER;
85 class TOOL_DISPATCHER;
86 class ACTIONS;
87 
88 
94 };
95 
96 
98 extern const wxChar traceAutoSave[];
99 
100 
112 class EDA_BASE_FRAME : public wxFrame
113 {
125  void windowClosing( wxCloseEvent& event );
126 
127 protected:
130  wxSize m_FrameSize;
131 
132  wxString m_configFrameName;
133 
135  wxAuiToolBar* m_mainToolBar;
136 
137  wxString m_AboutTitle;
138 
139  wxAuiManager m_auimgr;
140 
143 
146 
149 
151  wxTimer* m_autoSaveTimer;
152 
153  wxString m_perspective;
154 
155  wxString m_mruPath;
156 
161  void onAutoSaveTimer( wxTimerEvent& aEvent );
162 
168  virtual bool isAutoSaveRequired() const { return false; }
169 
176  virtual bool doAutoSave();
177 
183  virtual wxConfigBase* config();
184 
190  virtual const SEARCH_STACK& sys_search();
191 
192  virtual wxString help_name();
193 
194 public:
195  EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
196  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
197  long aStyle, const wxString& aFrameName );
198 
199  ~EDA_BASE_FRAME();
200 
208  bool ProcessEvent( wxEvent& aEvent ) override;
209 
210  bool Enable( bool enable ) override;
211 
212  void SetAutoSaveInterval( int aInterval );
213 
214  int GetAutoSaveInterval() const { return m_autoSaveInterval; }
215 
216  bool IsType( FRAME_T aType ) const { return m_Ident == aType; }
217 
218  void GetKicadHelp( wxCommandEvent& event );
219 
220  void GetKicadContribute( wxCommandEvent& event );
221 
222  void GetKicadAbout( wxCommandEvent& event );
223 
224  void PrintMsg( const wxString& text );
225 
233  virtual void LoadSettings( wxConfigBase* aCfg );
234 
243  virtual void SaveSettings( wxConfigBase* aCfg );
244 
255  wxString ConfigBaseName()
256  {
257  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
258  return baseCfgName;
259  }
260 
261 
269  virtual void SaveProjectSettings( bool aAskForSave ) {};
270 
277  virtual void OnSelectPreferredEditor( wxCommandEvent& event );
278 
279  // Read/Save and Import/export hotkeys config
280 
286  int ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList );
287 
299  virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
300 
308  int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList );
309 
318  const wxString& aDefaultShortname );
319 
328  const wxString& aDefaultShortname );
329 
342  wxString GetFileFromHistory( int cmdId, const wxString& type,
343  wxFileHistory* aFileHistory = NULL );
344 
354  void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL );
355 
356  void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
357 
358  wxString GetMruPath() const { return m_mruPath; }
359 
365  virtual void ReCreateMenuBar();
366 
384  bool IsWritable( const wxFileName& aFileName );
385 
402  void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension );
403 
408  virtual void ShowChangedLanguage();
409 
415  virtual void OnChangeIconsOptions( wxCommandEvent& event );
416 
421  virtual void ShowChangedIcons();
422 
431  void AddMenuIconsOptions( wxMenu* MasterMenu );
432 
433 
440  bool PostCommandMenuEvent( int evt_type );
441 };
442 
443 
465 class EDA_PANEINFO : public wxAuiPaneInfo
466 {
467 
468 public:
469 
475  {
476  ToolbarPane();
477  CloseButton( false );
478  LeftDockable( false );
479  RightDockable( false );
480  //==================== Remove calls below here for movable toolbars //
481  Gripper( false );
482  DockFixed( true );
483  Movable( false );
484  Resizable( true );
485  return *this;
486  }
487 
493  {
494  ToolbarPane();
495  CloseButton( false );
496  TopDockable( false );
497  BottomDockable( false );
498  //==================== Remove calls below here for movable toolbars //
499  Gripper( false );
500  DockFixed( true );
501  Movable( false );
502  Resizable( true );
503  return *this;
504  }
505 
512  {
513  Gripper( false );
514  DockFixed( true );
515  Movable( false );
516  Floatable( false );
517  CloseButton( false );
518  CaptionVisible( false );
519  return *this;
520  }
521 
527  {
528  CloseButton( false );
529  return *this;
530  }
531 
540  {
541  Gripper( false );
542  CloseButton( false );
543  CaptionVisible( false );
544  return *this;
545  }
546 };
547 
548 #endif // WXSTRUCT_H_
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:474
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:576
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:145
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:155
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:356
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:255
wxString m_AboutTitle
Name of program displayed in About.
Definition: wxstruct.h:137
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:660
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxAuiManager m_auimgr
Definition: wxstruct.h:139
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:532
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:526
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:151
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:465
wxString m_perspective
wxAuiManager perspective.
Definition: wxstruct.h:153
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:492
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:128
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:525
const wxChar traceAutoSave[]
Custom trace mask to enable and disable auto save tracing.
Definition: basicframe.cpp:53
wxPoint m_FramePos
Definition: wxstruct.h:129
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:132
bool PostCommandMenuEvent(int evt_type)
Function PostCommandMenuEvent.
Definition: basicframe.cpp:645
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:539
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:135
Class TOOL_DISPATCHER.
virtual void SaveProjectSettings(bool aAskForSave)
Function SaveProjectSettings saves changes to the project settings to the project (...
Definition: wxstruct.h:269
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:511
void AddMenuIconsOptions(wxMenu *MasterMenu)
Function AddMenuIconsOptions creates a menu list for icons in menu and icon sizes choice...
Definition: basicframe.cpp:671
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:112
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:151
The common library.
virtual wxString help_name()
Definition: basicframe.cpp:376
id_librarytype
Definition: wxstruct.h:89
Class ACTIONS.
Definition: actions.h:41
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:168
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:142
bool IsType(FRAME_T aType) const
Definition: wxstruct.h:216
wxSize m_FrameSize
Definition: wxstruct.h:130
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:358
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:148
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:214
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: basicframe.cpp:237
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