KiCad PCB EDA Suite
kicad.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) 2017 KiCad Developers, see CHANGELOG.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 
30 #ifndef KICAD_H
31 #define KICAD_H
32 
33 
34 #include <wx/process.h>
35 
36 #include <id.h>
37 #include <wxstruct.h>
38 
39 
40 #define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
41 
42 class LAUNCHER_PANEL;
43 class TREEPROJECTFILES;
44 class TREE_PROJECT_FRAME;
45 
46 // Identify the type of files handled by Kicad manager
47 //
48 // When changing this enum please verify (and perhaps update)
49 // TREE_PROJECT_FRAME::GetFileExt(),
50 // s_AllowedExtensionsToList[]
51 
54  TREE_SCHEMA, // Schematic file (.sch)
55  TREE_LEGACY_PCB, // board file (.brd) legacy format
56  TREE_SEXP_PCB, // board file (.kicad_brd) new s expression format
57  TREE_GERBER, // Gerber file (.pho, .g*)
58  TREE_HTML, // HTML file (.htm, *.html)
59  TREE_PDF, // PDF file (.pdf)
60  TREE_TXT, // ascii text file (.txt)
61  TREE_NET, // netlist file (.net)
64  TREE_CMP_LINK, // cmp/footprint link file (.cmp)
65  TREE_REPORT, // report file (.rpt)
66  TREE_FP_PLACE, // fooprints position (place) file (.pos)
67  TREE_DRILL, // Excellon drill file (.drl)
68  TREE_SVG, // SVG file (.svg)
69  TREE_PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
70  TREE_FOOTPRINT_FILE, // footprint file (.kicad_mod)
71  TREE_SCHEMATIC_LIBFILE, // schematic library file (.lib)
73 };
74 
75 
106 
116 
127 
128  // Please, verify: the number of items in this list should be
129  // less than ROOM_FOR_KICADMANAGER (see id.h)
131 };
132 
133 
138 {
139 public:
140  KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
141  const wxPoint& pos, const wxSize& size );
142 
144 
145  void OnCloseWindow( wxCloseEvent& Event );
146  void OnSize( wxSizeEvent& event );
147 
152  void OnChangeIconsOptions( wxCommandEvent& event ) override;
153 
157  void OnLoadProject( wxCommandEvent& event );
158 
163  void OnCreateProjectFromTemplate( wxCommandEvent& event );
164 
165  void OnNewProject( wxCommandEvent& aEvent );
166 
170  void OnSaveProject( wxCommandEvent& event );
171 
172  void OnArchiveFiles( wxCommandEvent& event );
173  void OnUnarchiveFiles( wxCommandEvent& event );
174 
175  void OnRunEeschema( wxCommandEvent& event );
176  void OnRunSchLibEditor( wxCommandEvent& event );
177  void OnRunPcbNew( wxCommandEvent& event );
178  void OnRunPcbFpEditor( wxCommandEvent& event );
179  void OnRunGerbview( wxCommandEvent& event );
180  void OnRunBitmapConverter( wxCommandEvent& event );
181  void OnRunPcbCalculator( wxCommandEvent& event );
182  void OnRunPageLayoutEditor( wxCommandEvent& event );
183 
184  void OnConfigurePaths( wxCommandEvent& aEvent );
185  void OnOpenTextEditor( wxCommandEvent& event );
186  void OnOpenFileInTextEditor( wxCommandEvent& event );
187  void OnOpenFileInEditor( wxCommandEvent& event );
188 
189  void OnFileHistory( wxCommandEvent& event );
190  void OnExit( wxCommandEvent& event );
191  void Process_Preferences( wxCommandEvent& event );
192 
193  void Process_Config( wxCommandEvent& event );
194 
195  void ReCreateMenuBar() override;
196  void RecreateBaseHToolbar();
197 
201  void OnImportEagleFiles( wxCommandEvent& event );
202 
208  void PrintMsg( const wxString& aText );
209 
213  void PrintPrjInfo();
214 
218  void ClearMsg();
219 
220  void OnRefresh( wxCommandEvent& event );
221  void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
222  void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
223 
224  void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
225  void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
226  void OnUpdateRequiresProject( wxUpdateUIEvent& event );
227 
238  void CreateNewProject( const wxFileName& aProjectFileName );
239  void LoadProject( const wxFileName& aProjectFileName );
240 
241 
242  void LoadSettings( wxConfigBase* aCfg ) override;
243 
244  void SaveSettings( wxConfigBase* aCfg ) override;
245 
253  void Execute( wxWindow* frame, const wxString& execFile,
254  wxString param = wxEmptyString );
255 
256  class TERMINATE_HANDLER : public wxProcess
257  {
258  private:
259  wxString m_appName;
260 
261  public:
262  TERMINATE_HANDLER( const wxString& appName ) :
263  m_appName( appName )
264  {
265  }
266 
267  void OnTerminate( int pid, int status ) override;
268  };
269 
274  void OnChangeWatchedPaths( wxCommandEvent& aEvent );
275 
276 
277  void SetProjectFileName( const wxString& aFullProjectProFileName );
278  const wxString GetProjectFileName();
279 
280  // read only accessors
281  const wxString SchFileName();
282  const wxString PcbFileName();
283  const wxString PcbLegacyFileName();
284 
285  void ReCreateTreePrj();
286 
289  void RunPcbNew( const wxString& aProjectBoardFileName );
290 
293  void RunEeschema( const wxString& aProjectSchematicFileName );
294 
295  DECLARE_EVENT_TABLE()
296 
297 private:
298  wxConfigBase* config() override;
299 
300  const SEARCH_STACK& sys_search() override;
301 
302  wxString help_name() override;
303 
306  wxTextCtrl* m_MessagesBox;
307  wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
308 
311 
312  void language_change( wxCommandEvent& event );
313 
315 };
316 
317 
320 class LAUNCHER_PANEL : public wxPanel
321 {
322 private:
323  wxBoxSizer* m_buttonSizer;
324 
325  int m_height = 0;
326  int m_width = 0;
327 
328 public: LAUNCHER_PANEL( wxWindow* parent );
330 
331  int GetPanelHeight() const;
332  int GetPanelWidth() const;
333 
334 private:
335 
340  void CreateCommandToolbar( void );
341 
342  void AddButton( wxWindowID aId, const wxBitmap& aBitmap, wxString aToolTip );
343 };
344 
345 // The C++ project manager includes a single PROJECT in its link image.
346 class PROJECT;
347 extern PROJECT& Prj();
348 
349 #endif
void OnRunPcbCalculator(wxCommandEvent &event)
Definition: mainframe.cpp:459
Definition: kicad.h:59
void OnNewProject(wxCommandEvent &aEvent)
Definition: prjconfig.cpp:187
void OnRunPageLayoutEditor(wxCommandEvent &event)
Definition: mainframe.cpp:465
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:87
TreeFileType
Definition: kicad.h:52
void language_change(wxCommandEvent &event)
Definition: mainframe.cpp:517
Class PROJECT holds project specific data.
Definition: project.h:56
class LAUNCHER_PANEL
Definition: kicad.h:320
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: mainframe.cpp:530
void OnRefresh(wxCommandEvent &event)
Definition: mainframe.cpp:511
void OnRunPcbFpEditor(wxCommandEvent &event)
Definition: mainframe.cpp:418
void OnRunEeschema(wxCommandEvent &event)
Definition: mainframe.cpp:338
void OnUpdatePreferredPdfBrowser(wxUpdateUIEvent &event)
Definition: preferences.cpp:50
Class TREEPROJECTFILES This is the class to show (as a tree) the files in the project directory...
void OnImportEagleFiles(wxCommandEvent &event)
Open dialog to import Eagle schematic and board files.
void OnOpenFileInTextEditor(wxCommandEvent &event)
Definition: mainframe.cpp:490
void OnRunSchLibEditor(wxCommandEvent &event)
Definition: mainframe.cpp:346
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxAuiToolBar * m_VToolBar
Definition: kicad.h:307
void OnConfigurePaths(wxCommandEvent &aEvent)
Definition: mainframe.cpp:584
void OnLoadProject(wxCommandEvent &event)
Load an exiting project (.pro) file.
Definition: prjconfig.cpp:165
void OnRunBitmapConverter(wxCommandEvent &event)
Definition: mainframe.cpp:453
void OnOpenTextEditor(wxCommandEvent &event)
Definition: mainframe.cpp:481
Definition: kicad.h:61
void Process_Preferences(wxCommandEvent &event)
LAUNCHER_PANEL * m_Launcher
Definition: kicad.h:305
void RunEeschema(const wxString &aProjectSchematicFileName)
Call this only for a SCH associated with the current project.
Definition: mainframe.cpp:296
PROJECT & Prj()
Definition: kicad.cpp:270
void OnFileHistory(wxCommandEvent &event)
const wxString SchFileName()
Definition: mainframe.cpp:153
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:272
void OnSelectDefaultPdfBrowser(wxCommandEvent &event)
Definition: preferences.cpp:43
Definition: kicad.h:68
void OnUpdateRequiresProject(wxUpdateUIEvent &event)
Definition: prjconfig.cpp:414
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:201
~LAUNCHER_PANEL()
Definition: kicad.h:329
class TREE_PROJECT_FRAME Window to display the tree files
Base window classes and related definitions.
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:310
wxString help_name() override
Definition: mainframe.cpp:195
void OnUpdateDefaultPdfBrowser(wxUpdateUIEvent &event)
Definition: preferences.cpp:37
void OnChangeWatchedPaths(wxCommandEvent &aEvent)
Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of wahtched paths...
void OnCreateProjectFromTemplate(wxCommandEvent &event)
Creates a new project folder, copy a template into this new folder.
Definition: prjconfig.cpp:235
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
Definition: kicad.h:72
void OnRunGerbview(wxCommandEvent &event)
Definition: mainframe.cpp:472
void OnArchiveFiles(wxCommandEvent &event)
TERMINATE_HANDLER(const wxString &appName)
Definition: kicad.h:262
wxBoxSizer * m_buttonSizer
Definition: kicad.h:323
const wxString GetProjectFileName()
Definition: mainframe.cpp:147
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:135
KICAD_MANAGER_FRAME(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
Definition: mainframe.cpp:50
void OnCloseWindow(wxCloseEvent &Event)
Definition: mainframe.cpp:216
void OnRunPcbNew(wxCommandEvent &event)
Definition: mainframe.cpp:406
const wxString PcbLegacyFileName()
Definition: mainframe.cpp:173
void ReCreateMenuBar() override
(Re)Create the menubar
void OnSize(wxSizeEvent &event)
Definition: mainframe.cpp:207
wxTextCtrl * m_MessagesBox
Definition: kicad.h:306
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: mainframe.cpp:537
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:304
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
const wxString PcbFileName()
Definition: mainframe.cpp:163
void Process_Config(wxCommandEvent &event)
Definition: mainframe.cpp:552
void OnChangeIconsOptions(wxCommandEvent &event) override
Select the current icons options in menus (or toolbars) in Kicad (the default for toolbars/menus is 2...
Definition: mainframe.cpp:446
Definition: kicad.h:60
void OnOpenFileInEditor(wxCommandEvent &event)
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
wxConfigBase * config() override
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: mainframe.cpp:127
bool m_active_project
Definition: kicad.h:314
void OnUnarchiveFiles(wxCommandEvent &event)
void CreateNewProject(const wxFileName &aProjectFileName)
Creates a new project by setting up and initial project, schematic, and board files.
Definition: prjconfig.cpp:108
void OnExit(wxCommandEvent &event)
Definition: mainframe.cpp:245
const SEARCH_STACK & sys_search() override
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
Definition: mainframe.cpp:189
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:524
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.
Definition: mainframe.cpp:544
void OnTerminate(int pid, int status) override
Definition: mainframe.cpp:251
id_kicad_frm
Command IDs for KiCad.
Definition: kicad.h:97
The main KiCad project manager frame.
Definition: kicad.h:137
void OnSelectPreferredPdfBrowser(wxCommandEvent &event)
Definition: preferences.cpp:56
void RunPcbNew(const wxString &aProjectBoardFileName)
Call this only for a PCB associated with the current project.
Definition: mainframe.cpp:374
void OnSaveProject(wxCommandEvent &event)
Save the project (.pro) file containing the top level configuration parameters.
Definition: prjconfig.cpp:405