KiCad PCB EDA Suite
project_tree_item.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) 2010-2014 Jean-Pierre Charras
5  * Copyright (C) 2004-2021 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 PROJECT_TREE_ITEM_H
26 #define PROJECT_TREE_ITEM_H
27 
28 
29 #include <wx/treebase.h>
30 
31 #include "tree_file_type.h"
32 
33 class PROJECT_TREE_PANE;
34 class wxTreeCtrl;
35 
39 class PROJECT_TREE_ITEM : public wxTreeItemData
40 {
41 public:
42 
43  PROJECT_TREE_ITEM( TREE_FILE_TYPE type, const wxString& data, wxTreeCtrl* parent );
44 
46  m_parent( nullptr )
47  { }
48 
50  m_type( src.m_type ),
51  m_file_name( src.m_file_name ),
52  m_parent( src.m_parent )
53  {
54  SetState( src.m_state );
55  m_isPopulated = false;
56  }
57 
58  TREE_FILE_TYPE GetType() const { return m_type; }
59  void SetType( TREE_FILE_TYPE aType ) { m_type = aType; }
60 
61  const wxString& GetFileName() const { return m_file_name; }
62  void SetFileName( const wxString& name ) { m_file_name = name; }
63 
64  bool IsRootFile() const { return m_isRootFile; }
65  void SetRootFile( bool aValue ) { m_isRootFile = aValue; }
66 
67  bool IsPopulated() const { return m_isPopulated; }
68  void SetPopulated( bool aValue ) { m_isPopulated = aValue; }
69 
75  const wxString GetDir() const;
76 
77  bool Rename( const wxString& name, bool check = true );
78  void Delete();
79  void Print();
80  void Activate( PROJECT_TREE_PANE* aTreePrjFrame );
81  void SetState( int state );
82 
83 
84 private:
85  TREE_FILE_TYPE m_type; // = TREE_PROJECT, TREE_DIRECTORY ...
86  wxString m_file_name; // Filename for a file, or directory name
87  bool m_isRootFile; // True if m_Filename is a root schematic (same name as project)
88  bool m_isPopulated; // True if the name is a directory, and its content was read
89  wxTreeCtrl* m_parent;
90  int m_state;
91 };
92 
93 #endif // PROJECT_TREE_ITEM_H
const wxString & GetFileName() const
void SetFileName(const wxString &name)
bool IsPopulated() const
void Activate(PROJECT_TREE_PANE *aTreePrjFrame)
TREE_FILE_TYPE GetType() const
TREE_FILE_TYPE
void SetPopulated(bool aValue)
bool IsRootFile() const
void SetState(int state)
PROJECT_TREE_PANE Window to display the tree files.
PROJECT_TREE_ITEM(const PROJECT_TREE_ITEM &src)
TREE_FILE_TYPE m_type
bool Rename(const wxString &name, bool check=true)
const wxString GetDir() const
wxTreeCtrl * m_parent
const char * name
Definition: DXF_plotter.cpp:56
void SetType(TREE_FILE_TYPE aType)
Handle one item (a file or a directory name) for the tree file.
void SetRootFile(bool aValue)