KiCad PCB EDA Suite
class_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 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 
31 #include <bitmaps.h>
32 
33 #include "class_treeproject_item.h"
34 #include "tree_project_frame.h"
35 
36 #include "class_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( kicad_icon_small_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( svg_file_xpm ) ); // TREE_SVG
76  m_ImageList->Add( KiBitmap( pagelayout_load_xpm ) ); // TREE_PAGE_LAYOUT_DESCR
77  m_ImageList->Add( KiBitmap( module_xpm ) ); // TREE_FOOTPRINT_FILE
78  m_ImageList->Add( KiBitmap( library_xpm ) ); // TREE_SCHEMATIC_LIBFILE
79 
80  SetImageList( m_ImageList );
81 }
82 
83 
85 {
86  delete m_ImageList;
87 }
88 
89 
90 int TREEPROJECTFILES::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
91 {
92  TREEPROJECT_ITEM* myitem1 = (TREEPROJECT_ITEM*) GetItemData( item1 );
93  TREEPROJECT_ITEM* myitem2 = (TREEPROJECT_ITEM*) GetItemData( item2 );
94 
95  if( myitem1->GetType() == TREE_DIRECTORY && myitem2->GetType() != TREE_DIRECTORY )
96  return -1;
97 
98  if( myitem2->GetType() == TREE_DIRECTORY && myitem1->GetType() != TREE_DIRECTORY )
99  return 1;
100 
101  if( myitem1->IsRootFile() && !myitem2->IsRootFile() )
102  return -1;
103 
104  if( myitem2->IsRootFile() && !myitem1->IsRootFile() )
105  return 1;
106 
107  return myitem1->GetFileName().CmpNoCase( myitem2->GetFileName() );
108 }
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...
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
class TREE_PROJECT_FRAME Window to display the tree files
TreeFileType GetType() const
int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2) override
Definition: kicad.h:72
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