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 // Enum to 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 
126 
127  // Please, verify: the number of items in this list should be
128  // less than ROOM_FOR_KICADMANAGER (see id.h)
130 };
131 
132 
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 
153  void OnChangeIconsOptions( wxCommandEvent& event ) override;
154 
159  void OnLoadProject( wxCommandEvent& event );
160 
166  void OnCreateProjectFromTemplate( wxCommandEvent& event );
167 
173  void OnSaveProject( wxCommandEvent& event );
174 
175  void OnArchiveFiles( wxCommandEvent& event );
176  void OnUnarchiveFiles( wxCommandEvent& event );
177 
178  void OnRunEeschema( wxCommandEvent& event );
179  void OnRunSchLibEditor( wxCommandEvent& event );
180  void OnRunPcbNew( wxCommandEvent& event );
181  void OnRunPcbFpEditor( wxCommandEvent& event );
182  void OnRunGerbview( wxCommandEvent& event );
183  void OnRunBitmapConverter( wxCommandEvent& event );
184  void OnRunPcbCalculator( wxCommandEvent& event );
185  void OnRunPageLayoutEditor( wxCommandEvent& event );
186 
187  void OnConfigurePaths( wxCommandEvent& aEvent );
188  void OnOpenTextEditor( wxCommandEvent& event );
189  void OnOpenFileInTextEditor( wxCommandEvent& event );
190  void OnOpenFileInEditor( wxCommandEvent& event );
191 
192  void OnFileHistory( wxCommandEvent& event );
193  void OnExit( wxCommandEvent& event );
194  void Process_Preferences( wxCommandEvent& event );
195 
196  void Process_Config( wxCommandEvent& event );
197 
198  void ReCreateMenuBar() override;
199  void RecreateBaseHToolbar();
200 
207  void PrintMsg( const wxString& aText );
208 
213  void PrintPrjInfo();
214 
219  void ClearMsg();
220 
221  void OnRefresh( wxCommandEvent& event );
222  void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
223  void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
224 
225  void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
226  void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
227  void OnUpdateRequiresProject( wxUpdateUIEvent& event );
228 
229  void CreateNewProject( const wxString& aPrjFullFileName, bool aTemplateSelector );
230 
231  void LoadSettings( wxConfigBase* aCfg ) override;
232 
233  void SaveSettings( wxConfigBase* aCfg ) override;
234 
242  void Execute( wxWindow* frame, const wxString& execFile,
243  wxString param = wxEmptyString );
244 
245  class TERMINATE_HANDLER : public wxProcess
246  {
247  private:
248  wxString m_appName;
249 
250  public:
251  TERMINATE_HANDLER( const wxString& appName ) :
252  m_appName(appName)
253  {
254  }
255 
256  void OnTerminate( int pid, int status ) override;
257  };
258 
263  void OnChangeWatchedPaths(wxCommandEvent& aEvent );
264 
265 
266  void SetProjectFileName( const wxString& aFullProjectProFileName );
267  const wxString GetProjectFileName();
268 
269  // read only accessors
270  const wxString SchFileName();
271  const wxString PcbFileName();
272  const wxString PcbLegacyFileName();
273 
274  void ReCreateTreePrj();
275 
278  void RunPcbNew( const wxString& aProjectBoardFileName );
279 
282  void RunEeschema( const wxString& aProjectSchematicFileName );
283 
284  DECLARE_EVENT_TABLE()
285 
286 private:
287 
288  wxConfigBase* config() override;
289 
290  const SEARCH_STACK& sys_search() override;
291 
292  wxString help_name() override;
293 
296  wxTextCtrl* m_MessagesBox;
297  wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
298 
301 
302  void language_change( wxCommandEvent& event );
303 
305 };
306 
307 
310 class LAUNCHER_PANEL : public wxPanel
311 {
312 private:
313  int m_buttonSeparation; // button distance in pixels
314  wxPoint m_buttonsListPosition; /* position of the left bottom corner
315  * of the first bitmap button
316  */
317  wxPoint m_buttonLastPosition; // position of the last button in the window
318  int m_bitmapButtons_maxHeight; // height of bigger bitmap buttons
319  // Used to calculate the height of the panel.
320 
321 public: LAUNCHER_PANEL( wxWindow* parent );
323 
324  int GetPanelHeight() const;
325 
326 private:
327 
332  void CreateCommandToolbar( void );
333 
334  wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap );
335 };
336 
337 // The C++ project manager includes a single PROJECT in its link image.
338 class PROJECT;
339 extern PROJECT& Prj();
340 
341 #endif
void OnRunPcbCalculator(wxCommandEvent &event)
Definition: mainframe.cpp:456
Definition: kicad.h:59
void OnRunPageLayoutEditor(wxCommandEvent &event)
Definition: mainframe.cpp:462
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:518
Class PROJECT holds project specific data.
Definition: project.h:51
class LAUNCHER_PANEL
Definition: kicad.h:310
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: mainframe.cpp:531
void OnRefresh(wxCommandEvent &event)
Definition: mainframe.cpp:512
void OnRunPcbFpEditor(wxCommandEvent &event)
Definition: mainframe.cpp:414
void OnRunEeschema(wxCommandEvent &event)
Definition: mainframe.cpp:333
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...
int m_bitmapButtons_maxHeight
Definition: kicad.h:318
void OnOpenFileInTextEditor(wxCommandEvent &event)
Definition: mainframe.cpp:487
void CreateNewProject(const wxString &aPrjFullFileName, bool aTemplateSelector)
Definition: prjconfig.cpp:59
void OnRunSchLibEditor(wxCommandEvent &event)
Definition: mainframe.cpp:341
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxAuiToolBar * m_VToolBar
Definition: kicad.h:297
void OnConfigurePaths(wxCommandEvent &aEvent)
Definition: mainframe.cpp:589
void OnLoadProject(wxCommandEvent &event)
Function OnLoadProject loads an exiting or creates a new project (.pro) file.
Definition: prjconfig.cpp:207
void OnRunBitmapConverter(wxCommandEvent &event)
Definition: mainframe.cpp:450
void OnOpenTextEditor(wxCommandEvent &event)
Definition: mainframe.cpp:478
Definition: kicad.h:61
void Process_Preferences(wxCommandEvent &event)
LAUNCHER_PANEL * m_Launcher
Definition: kicad.h:295
void RunEeschema(const wxString &aProjectSchematicFileName)
Call this only for a SCH associated with the current project.
Definition: mainframe.cpp:291
PROJECT & Prj()
Definition: kicad.cpp:293
void OnFileHistory(wxCommandEvent &event)
const wxString SchFileName()
Definition: mainframe.cpp:149
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Function Execute opens another KiCad application and logs a message.
Definition: mainframe.cpp:267
void OnSelectDefaultPdfBrowser(wxCommandEvent &event)
Definition: preferences.cpp:43
Definition: kicad.h:68
void OnUpdateRequiresProject(wxUpdateUIEvent &event)
Definition: prjconfig.cpp:394
void PrintMsg(const wxString &aText)
Function PrintMsg displays aText in the text panel.
Definition: mainframe.cpp:197
~LAUNCHER_PANEL()
Definition: kicad.h:322
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:300
wxString help_name() override
Definition: mainframe.cpp:191
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)
Function OnCreateProjectFromTemplate Creates a new project folder, copy a template into this new fold...
Definition: prjconfig.cpp:359
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
Definition: kicad.h:72
void OnRunGerbview(wxCommandEvent &event)
Definition: mainframe.cpp:469
void OnArchiveFiles(wxCommandEvent &event)
TERMINATE_HANDLER(const wxString &appName)
Definition: kicad.h:251
int m_buttonSeparation
Definition: kicad.h:313
const wxString GetProjectFileName()
Definition: mainframe.cpp:143
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:131
KICAD_MANAGER_FRAME(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
Definition: mainframe.cpp:49
void OnCloseWindow(wxCloseEvent &Event)
Definition: mainframe.cpp:212
void OnRunPcbNew(wxCommandEvent &event)
Definition: mainframe.cpp:402
const wxString PcbLegacyFileName()
Definition: mainframe.cpp:169
void ReCreateMenuBar() override
(Re)Create the menubar
void OnSize(wxSizeEvent &event)
Definition: mainframe.cpp:203
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: mainframe.cpp:538
wxPoint m_buttonsListPosition
Definition: kicad.h:314
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:112
const wxString PcbFileName()
Definition: mainframe.cpp:159
void Process_Config(wxCommandEvent &event)
Definition: mainframe.cpp:557
void OnChangeIconsOptions(wxCommandEvent &event) override
Function OnChangeIconsOptions Selects the current icons options in menus (or toolbars) in Kicad (the ...
Definition: mainframe.cpp:443
Definition: kicad.h:60
void OnOpenFileInEditor(wxCommandEvent &event)
wxConfigBase * config() override
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: mainframe.cpp:123
bool m_active_project
Definition: kicad.h:304
void OnUnarchiveFiles(wxCommandEvent &event)
void OnExit(wxCommandEvent &event)
Definition: mainframe.cpp:240
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:185
wxPoint m_buttonLastPosition
Definition: kicad.h:317
void ClearMsg()
a minor helper function: Erase the text panel.
Definition: mainframe.cpp:525
void PrintPrjInfo()
a minor helper function: Prints the Current Working Dir name and the projet name on the text panel...
Definition: mainframe.cpp:549
void OnTerminate(int pid, int status) override
Definition: mainframe.cpp:246
id_kicad_frm
Command IDs for KiCad.
Definition: kicad.h:97
Class KICAD_MANAGER_FRAME is 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:370
void OnSaveProject(wxCommandEvent &event)
Function OnSaveProject is the command event hendler to Save the project (.pro) file containing the to...
Definition: prjconfig.cpp:383