KiCad PCB EDA Suite
PROJECT_TREE Class Reference

PROJECT_TREE This is the class to show (as a tree) the files in the project directory. More...

#include <project_tree.h>

Inheritance diagram for PROJECT_TREE:

Public Member Functions

PROJECT_TREE_PANEGetProjectTreePane () const
 
 PROJECT_TREE (PROJECT_TREE_PANE *parent)
 
 ~PROJECT_TREE ()
 
void LoadIcons ()
 

Private Member Functions

int OnCompareItems (const wxTreeItemId &item1, const wxTreeItemId &item2) override
 

Private Attributes

PROJECT_TREE_PANEm_projectTreePane
 
wxImageList * m_imageList
 

Detailed Description

PROJECT_TREE This is the class to show (as a tree) the files in the project directory.

Definition at line 38 of file project_tree.h.

Constructor & Destructor Documentation

◆ PROJECT_TREE()

PROJECT_TREE::PROJECT_TREE ( PROJECT_TREE_PANE parent)

Definition at line 44 of file project_tree.cpp.

44  :
45  wxTreeCtrl( parent, ID_PROJECT_TREE, wxDefaultPosition, wxDefaultSize,
46  PLATFORM_STYLE | wxTR_HAS_BUTTONS | wxTR_MULTIPLE, wxDefaultValidator,
47  wxT( "EDATreeCtrl" ) ),
48  m_imageList( nullptr )
49 {
50  m_projectTreePane = parent;
51 
52  // Make sure the GUI font scales properly on GTK
53  SetFont( KIUI::GetControlFont( this ) );
54 
55  LoadIcons();
56 }
wxImageList * m_imageList
Definition: project_tree.h:44
PROJECT_TREE_PANE * m_projectTreePane
Definition: project_tree.h:43
wxFont GetControlFont(wxWindow *aWindow)
Definition: ui_common.cpp:150
#define PLATFORM_STYLE
void LoadIcons()

References KIUI::GetControlFont(), LoadIcons(), and m_projectTreePane.

◆ ~PROJECT_TREE()

PROJECT_TREE::~PROJECT_TREE ( )

Definition at line 59 of file project_tree.cpp.

60 {
61  delete m_imageList;
62 }
wxImageList * m_imageList
Definition: project_tree.h:44

References m_imageList.

Member Function Documentation

◆ GetProjectTreePane()

PROJECT_TREE_PANE* PROJECT_TREE::GetProjectTreePane ( ) const
inline

Definition at line 47 of file project_tree.h.

47 { return m_projectTreePane; }
PROJECT_TREE_PANE * m_projectTreePane
Definition: project_tree.h:43

References m_projectTreePane.

◆ LoadIcons()

void PROJECT_TREE::LoadIcons ( )

Definition at line 65 of file project_tree.cpp.

66 {
67  delete m_imageList;
68 
69  // icons size is not know (depending on they are built)
70  // so get it:
71  wxSize iconsize;
73  iconsize.x = dummy.GetWidth();
74  iconsize.y = dummy.GetHeight();
75 
76  // Make an image list containing small icons
77  m_imageList = new wxImageList( iconsize.x, iconsize.y, true,
78  static_cast<int>( TREE_FILE_TYPE::MAX ) );
79 
80  m_imageList->Add( KiBitmap( BITMAPS::project ) ); // TREE_LEGACY_PROJECT
81  m_imageList->Add( KiBitmap( BITMAPS::project_kicad ) ); // TREE_JSON_PROJECT
82  m_imageList->Add( KiBitmap( BITMAPS::icon_eeschema_24 ) ); // TREE_LEGACY_SCHEMATIC
83  m_imageList->Add( KiBitmap( BITMAPS::icon_eeschema_24 ) ); // TREE_SEXPR_SCHEMATIC
84  m_imageList->Add( KiBitmap( BITMAPS::icon_pcbnew_24 ) ); // TREE_LEGACY_PCB
85  m_imageList->Add( KiBitmap( BITMAPS::icon_pcbnew_24 ) ); // TREE_SEXPR_PCB
86  m_imageList->Add( KiBitmap( BITMAPS::icon_gerbview_24 ) ); // TREE_GERBER
87  m_imageList->Add( KiBitmap( BITMAPS::file_gerber_job ) ); // TREE_GERBER_JOB_FILE (.gbrjob)
88  m_imageList->Add( KiBitmap( BITMAPS::file_html ) ); // TREE_HTML
89  m_imageList->Add( KiBitmap( BITMAPS::file_pdf ) ); // TREE_PDF
90  m_imageList->Add( KiBitmap( BITMAPS::editor ) ); // TREE_TXT
91  m_imageList->Add( KiBitmap( BITMAPS::netlist ) ); // TREE_NET
92  m_imageList->Add( KiBitmap( BITMAPS::unknown ) ); // TREE_UNKNOWN
93  m_imageList->Add( KiBitmap( BITMAPS::directory ) ); // TREE_DIRECTORY
94  m_imageList->Add( KiBitmap( BITMAPS::icon_cvpcb_24 ) ); // TREE_CMP_LINK
95  m_imageList->Add( KiBitmap( BITMAPS::tools ) ); // TREE_REPORT
96  m_imageList->Add( KiBitmap( BITMAPS::file_pos ) ); // TREE_POS
97  m_imageList->Add( KiBitmap( BITMAPS::file_drl ) ); // TREE_DRILL
98  m_imageList->Add( KiBitmap( BITMAPS::file_drl ) ); // TREE_DRILL_NC (similar TREE_DRILL)
99  m_imageList->Add( KiBitmap( BITMAPS::file_drl ) ); // TREE_DRILL_XNC (similar TREE_DRILL)
100  m_imageList->Add( KiBitmap( BITMAPS::file_svg ) ); // TREE_SVG
101  m_imageList->Add( KiBitmap( BITMAPS::icon_pagelayout_editor_24 ) ); // TREE_PAGE_LAYOUT_DESCR
102  m_imageList->Add( KiBitmap( BITMAPS::module ) ); // TREE_FOOTPRINT_FILE
103  m_imageList->Add( KiBitmap( BITMAPS::library ) ); // TREE_SCHEMATIC_LIBFILE
104  m_imageList->Add( KiBitmap( BITMAPS::library ) ); // TREE_SEXPR_SYMBOL_LIB_FILE
105  m_imageList->Add( KiBitmap( BITMAPS::editor ) ); // DESIGN_RULES
106 
107  SetImageList( m_imageList );
108 }
wxImageList * m_imageList
Definition: project_tree.h:44
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105

References directory, dummy(), editor, file_drl, file_gerber_job, file_html, file_pdf, file_pos, file_svg, icon_cvpcb_24, icon_eeschema_24, icon_gerbview_24, icon_pagelayout_editor_24, icon_pcbnew_24, KiBitmap(), library, m_imageList, MAX, module, netlist, project, project_kicad, tools, and unknown.

Referenced by PROJECT_TREE_PANE::onThemeChanged(), and PROJECT_TREE().

◆ OnCompareItems()

int PROJECT_TREE::OnCompareItems ( const wxTreeItemId &  item1,
const wxTreeItemId &  item2 
)
overrideprivate

Definition at line 111 of file project_tree.cpp.

112 {
113  PROJECT_TREE_ITEM* myitem1 = (PROJECT_TREE_ITEM*) GetItemData( item1 );
114  PROJECT_TREE_ITEM* myitem2 = (PROJECT_TREE_ITEM*) GetItemData( item2 );
115 
116  if( !myitem1 || !myitem2 )
117  return 0;
118 
119  if( myitem1->GetType() == TREE_FILE_TYPE::DIRECTORY
120  && myitem2->GetType() != TREE_FILE_TYPE::DIRECTORY )
121  return -1;
122 
123  if( myitem2->GetType() == TREE_FILE_TYPE::DIRECTORY
124  && myitem1->GetType() != TREE_FILE_TYPE::DIRECTORY )
125  return 1;
126 
127  if( myitem1->IsRootFile() && !myitem2->IsRootFile() )
128  return -1;
129 
130  if( myitem2->IsRootFile() && !myitem1->IsRootFile() )
131  return 1;
132 
133  return myitem1->GetFileName().CmpNoCase( myitem2->GetFileName() );
134 }
const wxString & GetFileName() const
TREE_FILE_TYPE GetType() const
bool IsRootFile() const
Handle one item (a file or a directory name) for the tree file.

References DIRECTORY, PROJECT_TREE_ITEM::GetFileName(), PROJECT_TREE_ITEM::GetType(), and PROJECT_TREE_ITEM::IsRootFile().

Member Data Documentation

◆ m_imageList

wxImageList* PROJECT_TREE::m_imageList
private

Definition at line 44 of file project_tree.h.

Referenced by LoadIcons(), and ~PROJECT_TREE().

◆ m_projectTreePane

PROJECT_TREE_PANE* PROJECT_TREE::m_projectTreePane
private

Definition at line 43 of file project_tree.h.

Referenced by GetProjectTreePane(), and PROJECT_TREE().


The documentation for this class was generated from the following files: