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.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  static wxString GetFileWildcard( TreeFileType type );
79 
87 
94  TREEPROJECT_ITEM* GetItemIdData( wxTreeItemId aId );
95 
96 private:
100  void OnSelect( wxTreeEvent& Event );
101 
105  void OnExpand( wxTreeEvent& Event );
106 
110  void OnRight( wxTreeEvent& Event );
111 
118  void OnOpenSelectedFileWithTextEditor( wxCommandEvent& event );
119 
126  void OnDeleteFile( wxCommandEvent& event );
127 
134  void OnRenameFile( wxCommandEvent& event );
135 
141  void OnCreateNewDirectory( wxCommandEvent& event );
142 
144  {
145  m_filters.clear();
146  }
147 
148  const std::vector<wxString>& GetFilters()
149  {
150  return m_filters;
151  }
152 
153  void RemoveFilter( const wxString& filter );
154 
164  bool AddItemToTreeProject( const wxString& aName,
165  wxTreeItemId& aRoot,
166  bool aRecurse = true );
167 
178  wxTreeItemId findSubdirTreeItem( const wxString& aSubDir );
179 
185  void OnFileSystemEvent( wxFileSystemWatcherEvent& event );
186 
187  DECLARE_EVENT_TABLE()
188 };
189 
190 #endif // TREEPRJ_FRAME_H
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TreeFileType
Definition: kicad.h:52
static wxString GetFileWildcard(TreeFileType type)
const std::vector< wxString > & GetFilters()
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 OnFileSystemEvent(wxFileSystemWatcherEvent &event)
called when a file or directory is modified/created/deleted The tree project is modified when a file ...
KICAD_MANAGER_FRAME is the KiCad main frame.
class TREE_PROJECT_FRAME Window to display the tree files
KICAD_MANAGER_FRAME * m_Parent
void OnDeleteFile(wxCommandEvent &event)
Function OnDeleteFile Called via the popup menu, when right clicking on a file name or a directory na...
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void OnOpenSelectedFileWithTextEditor(wxCommandEvent &event)
Function OnOpenSelectedFileWithTextEditor Called via the popup menu, when right clicking on a file na...
void OnRight(wxTreeEvent &Event)
Called on a right click on an item.
void OnRenameFile(wxCommandEvent &event)
Function OnRenameFile Called via the popup menu, when right clicking on a file name or a directory na...
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 RemoveFilter(const wxString &filter)
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.
Definition: kicad.h:137