KiCad PCB EDA Suite
tree_project_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) 1992-2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2012 KiCad Developers, see change_log.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 TREEPRJ_FRAME_H
31 #define TREEPRJ_FRAME_H
32 
33 #include <wx/fswatcher.h>
34 #include <wx/laywin.h>
35 #include <wx/treebase.h>
36 
37 #include "kicad_manager_frame.h"
38 
39 
41 class TREEPROJECT_ITEM;
42 class TREEPROJECTFILES;
43 
47 class TREE_PROJECT_FRAME : public wxSashLayoutWindow
48 {
49  friend class TREEPROJECT_ITEM;
50 public:
53 
54 private:
55  wxTreeItemId m_root;
56  std::vector<wxString> m_filters;
57  wxFileSystemWatcher* m_watcher; // file system watcher (since wxWidgets 2.9.2)
58 
59 public:
62 
66  void ReCreateTreePrj();
67 
74  void FileWatcherReset();
75 
76 protected:
77  static wxString GetFileExt( TreeFileType type );
78 
86 
93  TREEPROJECT_ITEM* GetItemIdData( wxTreeItemId aId );
94 
95 private:
99  void OnSelect( wxTreeEvent& Event );
100 
104  void OnExpand( wxTreeEvent& Event );
105 
109  void OnRight( wxTreeEvent& Event );
110 
115  void OnOpenSelectedFileWithTextEditor( wxCommandEvent& event );
116 
121  void OnDeleteFile( wxCommandEvent& event );
122 
127  void OnPrintFile( wxCommandEvent& event );
128 
133  void OnRenameFile( wxCommandEvent& event );
134 
139  void OnOpenDirectory( wxCommandEvent& event );
140 
146  void OnCreateNewDirectory( wxCommandEvent& event );
147 
152  void OnSwitchToSelectedProject( wxCommandEvent& event );
153 
163  bool AddItemToTreeProject( const wxString& aName, wxTreeItemId& aRoot, bool aRecurse = true );
164 
172  wxTreeItemId findSubdirTreeItem( const wxString& aSubDir );
173 
179  void OnFileSystemEvent( wxFileSystemWatcherEvent& event );
180 
181  DECLARE_EVENT_TABLE()
182 };
183 
184 #endif // TREEPRJ_FRAME_H
void OnOpenDirectory(wxCommandEvent &event)
Function OnOpenDirectory Handles the right-click menu for opening a directory in the current system f...
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file.
Class TREEPROJECTFILES This is the class to show (as a tree) the files in the project directory.
TREE_PROJECT_FRAME(KICAD_MANAGER_FRAME *parent)
class TREE_PROJECT_FRAME is the frame that shows the tree list of files and subdirs inside the workin...
TREEPROJECTFILES * m_TreeProject
wxTreeItemId findSubdirTreeItem(const wxString &aSubDir)
Function findSubdirTreeItem searches for the item in tree project which is the node of the subdirecto...
void OnSelect(wxTreeEvent &Event)
Called on a double click on an item.
void OnSwitchToSelectedProject(wxCommandEvent &event)
Switch to a other project selected from the tree project (by selecting an other .pro file inside the ...
void OnFileSystemEvent(wxFileSystemWatcherEvent &event)
called when a file or directory is modified/created/deleted The tree project is modified when a file ...
class TREE_PROJECT_FRAME Window to display the tree files
TreeFileType
void OnPrintFile(wxCommandEvent &event)
Function OnDeleteFile Print the selected file or directory in the tree project.
KICAD_MANAGER_FRAME * m_Parent
void OnDeleteFile(wxCommandEvent &event)
Function OnDeleteFile Delete the selected file or directory in the tree project.
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void OnOpenSelectedFileWithTextEditor(wxCommandEvent &event)
Function OnOpenSelectedFileWithTextEditor Call the text editor to open the selected file in the tree ...
void OnRight(wxTreeEvent &Event)
Called on a right click on an item.
void OnRenameFile(wxCommandEvent &event)
Function OnRenameFile Rename the selected file or directory in the tree project.
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
TREEPROJECT_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
wxFileSystemWatcher * m_watcher
void OnExpand(wxTreeEvent &Event)
Called on a click on the + or - button of an item with children.
bool AddItemToTreeProject(const wxString &aName, wxTreeItemId &aRoot, bool aRecurse=true)
Function AddItemToTreeProject.
std::vector< wxString > m_filters
static wxString GetFileExt(TreeFileType type)
void OnCreateNewDirectory(wxCommandEvent &event)
Function OnCreateNewDirectory Creates a new subdirectory inside the current kicad project directory t...
The main KiCad project manager frame.