From 38eef11db2c3826929dc2002eb5546fe23e67da4 Mon Sep 17 00:00:00 2001 From: Tim Warren Date: Tue, 14 Jul 2015 10:40:53 -0400 Subject: [PATCH] First step to new file pane --- src/widgets/FilePane.cpp | 28 ++++++++++++++++++++++++++-- src/widgets/FilePane.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/widgets/FilePane.cpp b/src/widgets/FilePane.cpp index 714be97..7960230 100644 --- a/src/widgets/FilePane.cpp +++ b/src/widgets/FilePane.cpp @@ -1,5 +1,12 @@ #include "src/widgets/FilePane.h" +enum +{ + Icon_File, + Icon_FolderClosed, + Icon_FolderOpened +}; + FilePane::FilePane( wxWindow* parent, wxWindowID id, @@ -13,14 +20,16 @@ FilePane::FilePane( this->InitImageList(); this->SetImageList(this->img_list); - this->dir->Open("."); + const wxString defaultPath = wxString("."); + wxTreeListItem root = this->GetRootItem(); + this->CreateTree(defaultPath, root); this->AppendColumn("", wxCOL_WIDTH_AUTOSIZE, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE); - wxTreeListItem root = this->GetRootItem(); + } FilePane::~FilePane() @@ -28,6 +37,21 @@ FilePane::~FilePane() } +void FilePane::CreateTree(const wxString &path, wxTreeListItem &root) +{ + wxString *filename = new wxString(""); + this->dir->Open(path); + + this->dir->GetFirst(filename, wxEmptyString, wxDIR_DEFAULT | wxDIR_NO_FOLLOW); + + this->AppendItem(root, *filename, Icon_FolderClosed, Icon_FolderOpened); + + while (this->dir->GetNext(filename)) + { + this->AppendItem(root, *filename, Icon_FolderClosed, Icon_FolderOpened); + } +} + void FilePane::InitImageList() { wxSize iconSize = wxArtProvider::GetSizeHint(wxART_LIST); diff --git a/src/widgets/FilePane.h b/src/widgets/FilePane.h index c452404..8916720 100644 --- a/src/widgets/FilePane.h +++ b/src/widgets/FilePane.h @@ -18,6 +18,7 @@ private: wxImageList *img_list = nullptr; wxDir *dir = nullptr; void InitImageList(); + void CreateTree(const wxString &path, wxTreeListItem &root); }; #endif /* TYRO_FILE_PANE_H */