KiCad PCB EDA Suite
treeprojectfiles.cpp
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) 2004-2012 Jean-Pierre Charras
5  * Copyright (C) 2004-2012 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 
31 #include <bitmaps.h>
32 
33 #include "treeproject_item.h"
34 #include "tree_project_frame.h"
35 
36 #include "treeprojectfiles.h"
37 
38 
39 IMPLEMENT_ABSTRACT_CLASS( TREEPROJECTFILES, wxTreeCtrl )
40 
41 
43  wxTreeCtrl( parent, ID_PROJECT_TREE,
44  wxDefaultPosition, wxDefaultSize,
45  wxTR_HAS_BUTTONS, wxDefaultValidator,
46  wxT( "EDATreeCtrl" ) )
47 {
48  m_Parent = parent;
49 
50  // icons size is not know (depending on they are built)
51  // so get it:
52  wxSize iconsize;
53  wxBitmap dummy = KiBitmap( eeschema_xpm );
54  iconsize.x = dummy.GetWidth();
55  iconsize.y = dummy.GetHeight();
56 
57  // Make an image list containing small icons
58  m_ImageList = new wxImageList( iconsize.x, iconsize.y, true, TREE_MAX );
59 
60  m_ImageList->Add( KiBitmap( new_project_xpm ) ); // TREE_PROJECT
61  m_ImageList->Add( KiBitmap( eeschema_xpm ) ); // TREE_SCHEMA
62  m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_LEGACY_PCB
63  m_ImageList->Add( KiBitmap( pcbnew_xpm ) ); // TREE_SFMT_PCB
64  m_ImageList->Add( KiBitmap( icon_gerbview_small_xpm ) ); // TREE_GERBER
65  m_ImageList->Add( KiBitmap( html_xpm ) ); // TREE_HTML
66  m_ImageList->Add( KiBitmap( datasheet_xpm ) ); // TREE_PDF
67  m_ImageList->Add( KiBitmap( editor_xpm ) ); // TREE_TXT
68  m_ImageList->Add( KiBitmap( netlist_xpm ) ); // TREE_NET
69  m_ImageList->Add( KiBitmap( unknown_xpm ) ); // TREE_UNKNOWN
70  m_ImageList->Add( KiBitmap( directory_xpm ) ); // TREE_DIRECTORY
71  m_ImageList->Add( KiBitmap( icon_cvpcb_small_xpm ) ); // TREE_CMP_LINK
72  m_ImageList->Add( KiBitmap( tools_xpm ) ); // TREE_REPORT
73  m_ImageList->Add( KiBitmap( post_compo_xpm ) ); // TREE_POS
74  m_ImageList->Add( KiBitmap( post_drill_xpm ) ); // TREE_DRILL
75  m_ImageList->Add( KiBitmap( post_drill_xpm ) ); // TREE_DRILL_NC (similar TREE_DRILL)
76  m_ImageList->Add( KiBitmap( post_drill_xpm ) ); // TREE_DRILL_XNC (similar TREE_DRILL)
77  m_ImageList->Add( KiBitmap( svg_file_xpm ) ); // TREE_SVG
78  m_ImageList->Add( KiBitmap( pagelayout_load_xpm ) ); // TREE_PAGE_LAYOUT_DESCR
79  m_ImageList->Add( KiBitmap( module_xpm ) ); // TREE_FOOTPRINT_FILE
80  m_ImageList->Add( KiBitmap( library_xpm ) ); // TREE_SCHEMATIC_LIBFILE
81 
82  SetImageList( m_ImageList );
83 }
84 
85 
87 {
88  delete m_ImageList;
89 }
90 
91 
92 int TREEPROJECTFILES::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
93 {
94  TREEPROJECT_ITEM* myitem1 = (TREEPROJECT_ITEM*) GetItemData( item1 );
95  TREEPROJECT_ITEM* myitem2 = (TREEPROJECT_ITEM*) GetItemData( item2 );
96 
97  if( myitem1->GetType() == TREE_DIRECTORY && myitem2->GetType() != TREE_DIRECTORY )
98  return -1;
99 
100  if( myitem2->GetType() == TREE_DIRECTORY && myitem1->GetType() != TREE_DIRECTORY )
101  return 1;
102 
103  if( myitem1->IsRootFile() && !myitem2->IsRootFile() )
104  return -1;
105 
106  if( myitem2->IsRootFile() && !myitem1->IsRootFile() )
107  return 1;
108 
109  return myitem1->GetFileName().CmpNoCase( myitem2->GetFileName() );
110 }
bool IsRootFile() const
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.
wxImageList * m_ImageList
TreeFileType GetType() const
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
class TREE_PROJECT_FRAME Window to display the tree files
int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2) override
Definition: kicad.h:74
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
const wxString & GetFileName() const