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-2017 Wayne Stambaugh <stambaughw@verizon.net>
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 
99 extern const wxChar traceAutoSave[];
100 
101 
113 class EDA_BASE_FRAME : public wxFrame
114 {
126  void windowClosing( wxCloseEvent& event );
127 
128 protected:
131  wxSize m_FrameSize;
132 
133  wxString m_configFrameName;
134 
136  wxAuiToolBar* m_mainToolBar;
137 
138  wxString m_AboutTitle;
139 
140  wxAuiManager m_auimgr;
141 
144 
147 
150 
152  wxTimer* m_autoSaveTimer;
153 
154  wxString m_perspective;
155 
156  wxString m_mruPath;
157 
162  void onAutoSaveTimer( wxTimerEvent& aEvent );
163 
169  virtual bool isAutoSaveRequired() const { return false; }
170 
177  virtual bool doAutoSave();
178 
184  virtual wxConfigBase* config();
185 
191  virtual const SEARCH_STACK& sys_search();
192 
193  virtual wxString help_name();
194 
195 public:
196  EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
197  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
198  long aStyle, const wxString& aFrameName );
199 
200  ~EDA_BASE_FRAME();
201 
209  bool ProcessEvent( wxEvent& aEvent ) override;
210 
211  bool Enable( bool enable ) override;
212 
213  void SetAutoSaveInterval( int aInterval );
214 
215  int GetAutoSaveInterval() const { return m_autoSaveInterval; }
216 
217  bool IsType( FRAME_T aType ) const { return m_Ident == aType; }
218 
219  void GetKicadHelp( wxCommandEvent& event );
220 
221  void GetKicadContribute( wxCommandEvent& event );
222 
223  void GetKicadAbout( wxCommandEvent& event );
224 
225  void PrintMsg( const wxString& text );
226 
234  virtual void LoadSettings( wxConfigBase* aCfg );
235 
244  virtual void SaveSettings( wxConfigBase* aCfg );
245 
256  wxString ConfigBaseName()
257  {
258  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
259  return baseCfgName;
260  }
261 
262 
270  virtual void SaveProjectSettings( bool aAskForSave ) {};
271 
278  virtual void OnSelectPreferredEditor( wxCommandEvent& event );
279 
280  // Read/Save and Import/export hotkeys config
281 
287  int ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList );
288 
300  virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
301 
309  int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList );
310 
319  const wxString& aDefaultShortname );
320 
329  const wxString& aDefaultShortname );
330 
343  wxString GetFileFromHistory( int cmdId, const wxString& type,
344  wxFileHistory* aFileHistory = NULL );
345 
355  void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL );
356 
357  void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; }
358 
359  wxString GetMruPath() const { return m_mruPath; }
360 
366  virtual void ReCreateMenuBar();
367 
385  bool IsWritable( const wxFileName& aFileName );
386 
403  void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension );
404 
409  virtual void ShowChangedLanguage();
410 
416  virtual void OnChangeIconsOptions( wxCommandEvent& event );
417 
422  virtual void ShowChangedIcons();
423 
432  void AddMenuIconsOptions( wxMenu* MasterMenu );
433 
434 
441  bool PostCommandMenuEvent( int evt_type );
442 };
443 
444 
466 class EDA_PANEINFO : public wxAuiPaneInfo
467 {
468 
469 public:
470 
476  {
477  ToolbarPane();
478  CloseButton( false );
479  LeftDockable( false );
480  RightDockable( false );
481  //==================== Remove calls below here for movable toolbars //
482  Gripper( false );
483  DockFixed( true );
484  Movable( false );
485  Resizable( true );
486  return *this;
487  }
488 
494  {
495  ToolbarPane();
496  CloseButton( false );
497  TopDockable( false );
498  BottomDockable( false );
499  //==================== Remove calls below here for movable toolbars //
500  Gripper( false );
501  DockFixed( true );
502  Movable( false );
503  Resizable( true );
504  return *this;
505  }
506 
513  {
514  Gripper( false );
515  DockFixed( true );
516  Movable( false );
517  Floatable( false );
518  CloseButton( false );
519  CaptionVisible( false );
520  return *this;
521  }
522 
528  {
529  CloseButton( false );
530  return *this;
531  }
532 
541  {
542  Gripper( false );
543  CloseButton( false );
544  CaptionVisible( false );
545  return *this;
546  }
547 };
548 
549 #endif // WXSTRUCT_H_
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:475
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:146
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:156
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:357
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:256
wxString m_AboutTitle
Name of program displayed in About.
Definition: wxstruct.h:138
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:140
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:527
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:152
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:466
wxString m_perspective
wxAuiManager perspective.
Definition: wxstruct.h:154
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:493
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:129
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:130
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:133
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:540
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:136
Class TOOL_DISPATCHER.
virtual void SaveProjectSettings(bool aAskForSave)
Function SaveProjectSettings saves changes to the project settings to the project (...
Definition: wxstruct.h:270
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:512
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:113
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:90
Class ACTIONS.
Definition: actions.h:41
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
Definition: wxstruct.h:169
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
Definition: wxstruct.h:143
bool IsType(FRAME_T aType) const
Definition: wxstruct.h:217
wxSize m_FrameSize
Definition: wxstruct.h:131
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:359
int m_autoSaveInterval
The auto save interval time in seconds.
Definition: wxstruct.h:149
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:215
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