KiCad PCB EDA Suite
kicad_manager_frame.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) 2013 CERN (www.cern.ch)
5  * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef KICAD_H
26 #define KICAD_H
27 
28 
29 #include <wx/process.h>
30 #include <eda_base_frame.h>
31 #include <kiway_player.h>
32 
33 class TREEPROJECTFILES;
34 class TREE_PROJECT_FRAME;
35 class ACTION_TOOLBAR;
36 class KICAD_SETTINGS;
37 
38 // Identify the type of files handled by KiCad manager
39 //
40 // When changing this enum please verify (and perhaps update)
41 // TREE_PROJECT_FRAME::GetFileExt(),
42 // s_AllowedExtensionsToList[]
43 
45  TREE_ROOT = 0,
46  TREE_LEGACY_PROJECT, // Legacy project file (.pro)
47  TREE_JSON_PROJECT, // JSON formatted project file (.kicad_pro)
48  TREE_LEGACY_SCHEMATIC, // Schematic file (.sch)
49  TREE_SEXPR_SCHEMATIC, // Schematic file (.kicad_sch)
50  TREE_LEGACY_PCB, // board file (.brd) legacy format
51  TREE_SEXPR_PCB, // board file (.kicad_brd) new s expression format
52  TREE_GERBER, // Gerber file (.pho, .g*)
53  TREE_GERBER_JOB_FILE, // Gerber file (.gbrjob)
54  TREE_HTML, // HTML file (.htm, *.html)
55  TREE_PDF, // PDF file (.pdf)
56  TREE_TXT, // ascii text file (.txt)
57  TREE_NET, // netlist file (.net)
60  TREE_CMP_LINK, // cmp/footprint link file (.cmp)
61  TREE_REPORT, // report file (.rpt)
62  TREE_FP_PLACE, // footprints position (place) file (.pos)
63  TREE_DRILL, // Excellon drill file (.drl)
64  TREE_DRILL_NC, // Similar Excellon drill file (.nc)
65  TREE_DRILL_XNC, // Similar Excellon drill file (.xnc)
66  TREE_SVG, // SVG file (.svg)
67  TREE_PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
68  TREE_FOOTPRINT_FILE, // footprint file (.kicad_mod)
69  TREE_SCHEMATIC_LIBFILE, // schematic library file (.lib)
70  TREE_SEXPR_SYMBOL_LIB_FILE, // s-expression symbol library file (.kicad_sym)
72 };
73 
74 
79 {
80 public:
81  KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
82  const wxPoint& pos, const wxSize& size );
83 
85 
86  void OnIdle( wxIdleEvent& event );
87 
88  bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
89  void doCloseWindow() override;
90  void OnSize( wxSizeEvent& event );
91 
92  void OnArchiveFiles( wxCommandEvent& event );
93  void OnUnarchiveFiles( wxCommandEvent& event );
94 
95  void OnOpenFileInTextEditor( wxCommandEvent& event );
96  void OnBrowseInFileExplorer( wxCommandEvent& event );
97 
98  void OnFileHistory( wxCommandEvent& event );
99  void OnClearFileHistory( wxCommandEvent& aEvent );
100  void OnExit( wxCommandEvent& event );
101 
102  void ReCreateMenuBar() override;
103  void RecreateBaseHToolbar();
104  void RecreateLauncher();
105 
106  wxString GetCurrentFileName() const override
107  {
108  return GetProjectFileName();
109  }
110 
114  void OnImportEagleFiles( wxCommandEvent& event );
115 
121  void PrintMsg( const wxString& aText );
122 
126  void PrintPrjInfo();
127 
131  void ClearMsg();
132 
133  void RefreshProjectTree();
134 
146  void CreateNewProject( const wxFileName& aProjectFileName, bool aCreateStubFiles = true );
147 
151  bool CloseProject( bool aSave );
152  void LoadProject( const wxFileName& aProjectFileName );
153 
154 
155  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
156 
157  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
158 
159  void ShowChangedLanguage() override;
160  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
161  void ProjectChanged() override;
162 
167  void OnChangeWatchedPaths( wxCommandEvent& aEvent );
168 
169  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
170 
171  const wxString GetProjectFileName() const;
172 
173  bool IsProjectActive();
174  // read only accessors
175  const wxString SchFileName();
176  const wxString SchLegacyFileName();
177  const wxString PcbFileName();
178  const wxString PcbLegacyFileName();
179 
180  void ReCreateTreePrj();
181 
182  wxWindow* GetToolCanvas() const override;
183 
184  DECLARE_EVENT_TABLE()
185 
186 protected:
187  virtual void setupUIConditions() override;
188 
189 private:
190  void setupTools();
191  void setupActions();
192 
193  APP_SETTINGS_BASE* config() const override;
194 
195  KICAD_SETTINGS* kicadSettings() const;
196 
197  const SEARCH_STACK& sys_search() override;
198 
199  wxString help_name() override;
200 
201  void language_change( wxCommandEvent& event );
202 
204 
205 private:
208  wxTextCtrl* m_messagesBox;
210 
213 };
214 
215 
216 // The C++ project manager includes a single PROJECT in its link image.
217 class PROJECT;
218 extern PROJECT& Prj();
219 
220 #endif
void OnBrowseInFileExplorer(wxCommandEvent &event)
ACTION_TOOLBAR.
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
void language_change(wxCommandEvent &event)
const wxString GetProjectFileName() const
PROJECT holds project specific data.
Definition: project.h:61
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Function InstallPreferences Allow a frame to load its preference panels (if any) into the preferences...
void OnClearFileHistory(wxCommandEvent &aEvent)
void doCloseWindow() override
void OnIdle(wxIdleEvent &event)
TREEPROJECTFILES This is the class to show (as a tree) the files in the project directory.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
wxWindow * GetToolCanvas() const override
Canvas access.
void OnImportEagleFiles(wxCommandEvent &event)
Open dialog to import Eagle schematic and board files.
virtual void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void OnOpenFileInTextEditor(wxCommandEvent &event)
const wxString SchLegacyFileName()
KICAD_SETTINGS * kicadSettings() const
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
void OnFileHistory(wxCommandEvent &event)
const wxString SchFileName()
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
TREE_PROJECT_FRAME Window to display the tree files.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
TreeFileType
wxString help_name() override
Base window classes and related definitions.
void OnChangeWatchedPaths(wxCommandEvent &aEvent)
Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of watched paths.
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
void ProjectChanged() override
Notification event that the project has changed.
void OnArchiveFiles(wxCommandEvent &event)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void CreateNewProject(const wxFileName &aProjectFileName, bool aCreateStubFiles=true)
Creates a new project by setting up and initial project, schematic, and board files.
KICAD_MANAGER_FRAME(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
bool CloseProject(bool aSave)
Closes the project, and saves it if aSave is true;.
ACTION_TOOLBAR * m_launcher
const wxString PcbLegacyFileName()
void ReCreateMenuBar() override
Recreates the menu bar.
void OnSize(wxSizeEvent &event)
The base frame for deriving all KiCad main window classes.
const wxString PcbFileName()
void LoadProject(const wxFileName &aProjectFileName)
void OnUnarchiveFiles(wxCommandEvent &event)
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void OnExit(wxCommandEvent &event)
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
ACTION_TOOLBAR * m_mainToolBar
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
const SEARCH_STACK & sys_search() override
Return a SEARCH_STACK pertaining to entire program.
void ClearMsg()
Erase the text panel.
void PrintPrjInfo()
Prints the current working directory name and the project name on the text panel.
TREE_PROJECT_FRAME * m_leftWin
The main KiCad project manager frame.