diff --git a/Interfaces/imanager.h b/Interfaces/imanager.h index 3c8221e4f1..9cbc47ffd5 100644 --- a/Interfaces/imanager.h +++ b/Interfaces/imanager.h @@ -293,7 +293,7 @@ class IManager * @param type the type of tree * @sa TreeType */ - virtual clTreeCtrl* GetFileExplorerTree() = 0; + virtual wxTreeCtrl* GetFileExplorerTree() = 0; virtual clTreeCtrl* GetWorkspaceTree() = 0; /** diff --git a/LiteEditor/fileexplorer.cpp b/LiteEditor/fileexplorer.cpp index a0cdcec856..89e886bd75 100644 --- a/LiteEditor/fileexplorer.cpp +++ b/LiteEditor/fileexplorer.cpp @@ -24,21 +24,13 @@ ////////////////////////////////////////////////////////////////////////////// #include "fileexplorer.h" -#include "OpenFolderDlg.h" #include "SideBar.hpp" #include "clFileOrFolderDropTarget.h" -#include "clToolBarButton.h" #include "clTreeCtrlPanel.h" -#include "clWorkspaceView.h" #include "cl_config.h" #include "codelite_events.h" -#include "editor_config.h" -#include "event_notifier.h" -#include "file_logger.h" #include "frame.h" #include "globals.h" -#include "macros.h" -#include "manager.h" #include "plugin.h" #include @@ -77,7 +69,7 @@ void FileExplorer::CreateGUIControls() void FileExplorer::OnFolderDropped(clCommandEvent& event) { const wxArrayString& folders = event.GetStrings(); - for(size_t i = 0; i < folders.size(); ++i) { + for (size_t i = 0; i < folders.size(); ++i) { m_view->AddFolder(folders.Item(i)); } clGetManager()->BookSelectPage(PaneId::SIDE_BAR, _("Explorer")); @@ -88,7 +80,7 @@ void FileExplorer::OpenFolder(const wxString& path) { m_view->AddFolder(path); } void FileExplorer::OnOpenFolder(wxCommandEvent& event) { wxString path = ::wxDirSelector(_("Select folder to open")); - if(path.IsEmpty()) { + if (path.IsEmpty()) { return; } OpenFolder(path); diff --git a/LiteEditor/fileexplorer.h b/LiteEditor/fileexplorer.h index 3fada560b6..5242c0a054 100644 --- a/LiteEditor/fileexplorer.h +++ b/LiteEditor/fileexplorer.h @@ -50,7 +50,7 @@ class FileExplorer : public wxPanel virtual ~FileExplorer(); const wxString& GetCaption() const { return m_caption; } TreeItemInfo GetItemInfo() { return m_view->GetSelectedItemInfo(); } - clTreeCtrl* GetTree() { return m_view->GetTreeCtrl(); } + auto GetTree() { return m_view->GetTreeCtrl(); } void OpenFolder(const wxString& path); }; diff --git a/LiteEditor/pluginmanager.cpp b/LiteEditor/pluginmanager.cpp index 549ac2e818..e3165c6db8 100644 --- a/LiteEditor/pluginmanager.cpp +++ b/LiteEditor/pluginmanager.cpp @@ -367,7 +367,7 @@ TreeItemInfo PluginManager::GetSelectedTreeItemInfo(TreeType type) clTreeCtrl* PluginManager::GetWorkspaceTree() { return clMainFrame::Get()->GetWorkspaceTab()->GetFileView(); } -clTreeCtrl* PluginManager::GetFileExplorerTree() { return clMainFrame::Get()->GetFileExplorer()->GetTree(); } +wxTreeCtrl* PluginManager::GetFileExplorerTree() { return clMainFrame::Get()->GetFileExplorer()->GetTree(); } MainNotebook* PluginManager::GetMainNotebook() { return clMainFrame::Get()->GetMainBook()->GetNotebook(); } diff --git a/LiteEditor/pluginmanager.h b/LiteEditor/pluginmanager.h index 910aa001f7..91efc869fc 100644 --- a/LiteEditor/pluginmanager.h +++ b/LiteEditor/pluginmanager.h @@ -94,7 +94,7 @@ class PluginManager : public IManager wxMenuBar* GetMenuBar() override; IConfigTool* GetConfigTool() override; TreeItemInfo GetSelectedTreeItemInfo(TreeType type) override; - clTreeCtrl* GetFileExplorerTree() override; + wxTreeCtrl* GetFileExplorerTree() override; clTreeCtrl* GetWorkspaceTree() override; MainNotebook* GetMainNotebook() override; IEditor* OpenFile(const wxString& fileName, const wxString& projectName = wxEmptyString, int lineno = wxNOT_FOUND, diff --git a/Plugin/clFileViwerTreeCtrl.cpp b/Plugin/clFileViwerTreeCtrl.cpp index 8945117a44..d81542bfb0 100644 --- a/Plugin/clFileViwerTreeCtrl.cpp +++ b/Plugin/clFileViwerTreeCtrl.cpp @@ -2,8 +2,9 @@ clFileViewerTreeCtrl::clFileViewerTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) - : clThemedTreeCtrl(parent, id, pos, size, (style & ~wxTR_FULL_ROW_HIGHLIGHT)) + : wxTreeCtrl(parent, id, pos, size, (style | wxTR_FULL_ROW_HIGHLIGHT)) { +#if 0 std::function SortFunc = [&](const wxTreeItemId& itemA, const wxTreeItemId& itemB) { clTreeCtrlData* a = static_cast(GetItemData(itemA)); @@ -16,19 +17,22 @@ clFileViewerTreeCtrl::clFileViewerTreeCtrl(wxWindow* parent, wxWindowID id, cons return (a->GetName().CmpNoCase(b->GetName()) < 0); }; SetSortFunction(SortFunc); +#endif } clFileViewerTreeCtrl::~clFileViewerTreeCtrl() {} +void clFileViewerTreeCtrl::SetBitmaps(BitmapLoader::Vec_t* bitmaps) { m_bitmaps = bitmaps; } + wxTreeItemId clTreeNodeIndex::Find(const wxString& path) { #ifdef __WXMSW__ wxString lcpath = path.Lower(); - if(m_children.count(lcpath)) { + if (m_children.count(lcpath)) { return m_children.find(lcpath)->second; } #else - if(m_children.count(path)) { + if (m_children.count(path)) { return m_children.find(path)->second; } #endif diff --git a/Plugin/clFileViwerTreeCtrl.h b/Plugin/clFileViwerTreeCtrl.h index b78ebd5eb2..a648b468bb 100644 --- a/Plugin/clFileViwerTreeCtrl.h +++ b/Plugin/clFileViwerTreeCtrl.h @@ -27,11 +27,11 @@ #define CLFILEVIWERTREECTRL_H #include "clThemedTreeCtrl.h" -#include "clTreeCtrl.h" #include "codelite_exports.h" #include "wxStringHash.h" #include +#include #include #include @@ -78,7 +78,7 @@ class WXDLLIMPEXP_SDK clTreeCtrlData : public wxTreeItemData : m_kind(kind) , m_index(NULL) { - if(IsFolder()) { + if (IsFolder()) { m_index = new clTreeNodeIndex(); } } @@ -95,14 +95,14 @@ class WXDLLIMPEXP_SDK clTreeCtrlData : public wxTreeItemData void SetPath(const wxString& path) { this->m_path = path; - if(IsFolder()) { + if (IsFolder()) { wxFileName fn(m_path, ""); - if(fn.GetDirCount()) { + if (fn.GetDirCount()) { m_name = fn.GetDirs().Last(); } else { m_name = m_path; } - } else if(IsFile()) { + } else if (IsFile()) { wxFileName fn(m_path); m_name = fn.GetFullName(); } else { @@ -127,13 +127,19 @@ class WXDLLIMPEXP_SDK clTreeCtrlData : public wxTreeItemData bool IsDummy() const { return m_kind == kDummy; } }; -class WXDLLIMPEXP_SDK clFileViewerTreeCtrl : public clThemedTreeCtrl +#include "bitmap_loader.h" +class WXDLLIMPEXP_SDK clFileViewerTreeCtrl : public wxTreeCtrl { public: clFileViewerTreeCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxTR_DEFAULT_STYLE | wxTR_MULTIPLE | wxTR_HIDE_ROOT | wxBORDER_STATIC); + long style = wxTR_DEFAULT_STYLE | wxTR_MULTIPLE | wxTR_HIDE_ROOT | wxBORDER_NONE); virtual ~clFileViewerTreeCtrl(); + + void SetBitmaps(BitmapLoader::Vec_t* bitmaps); + +private: + BitmapLoader::Vec_t* m_bitmaps = nullptr; }; #endif // CLFILEVIWERTREECTRL_H diff --git a/Plugin/clTreeCtrlPanel.cpp b/Plugin/clTreeCtrlPanel.cpp index f9433da06e..f07be7b952 100644 --- a/Plugin/clTreeCtrlPanel.cpp +++ b/Plugin/clTreeCtrlPanel.cpp @@ -374,7 +374,7 @@ wxTreeItemId clTreeCtrlPanel::DoAddFile(const wxTreeItemId& parent, const wxStri // use gray text for hidden items if (isHidden) { // a hidden item, use a disabled colour - GetTreeCtrl()->SetItemTextColour(fileItem, GetTreeCtrl()->GetColours().GetGrayText()); + GetTreeCtrl()->SetItemTextColour(fileItem, wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } return fileItem; @@ -421,7 +421,7 @@ wxTreeItemId clTreeCtrlPanel::DoAddFolder(const wxTreeItemId& parent, const wxSt // use gray text for hidden items if (isHiddenFolder) { // a hidden item, use a disabled colour - GetTreeCtrl()->SetItemTextColour(itemFolder, GetTreeCtrl()->GetColours().GetGrayText()); + GetTreeCtrl()->SetItemTextColour(itemFolder, wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } // Add this entry to the index @@ -823,7 +823,7 @@ bool clTreeCtrlPanel::ExpandToFile(const wxFileName& file_to_search) void clTreeCtrlPanel::GetTopLevelFolders(wxArrayString& paths, wxArrayTreeItemIds& items) const { wxTreeItemIdValue cookie; - const clTreeCtrl* tree = m_treeCtrl; + const auto tree = m_treeCtrl; wxTreeItemId child = tree->GetFirstChild(tree->GetRootItem(), cookie); while (child.IsOk()) { clTreeCtrlData* clientData = GetItemData(child); diff --git a/WebTools/NodeJSWorkspaceView.cpp b/WebTools/NodeJSWorkspaceView.cpp index 37eb63ac51..6a6dd0a14d 100644 --- a/WebTools/NodeJSWorkspaceView.cpp +++ b/WebTools/NodeJSWorkspaceView.cpp @@ -49,7 +49,7 @@ NodeJSWorkspaceView::~NodeJSWorkspaceView() void NodeJSWorkspaceView::OnContextMenu(clContextMenuEvent& event) { event.Skip(); - if((event.GetEventObject() == this)) { + if ((event.GetEventObject() == this)) { wxMenu* menu = event.GetMenu(); // Locate the "Close" menu entry @@ -57,16 +57,16 @@ void NodeJSWorkspaceView::OnContextMenu(clContextMenuEvent& event) wxMenuItem* closeItem = NULL; int pos = ::clFindMenuItemPosition(menu, XRCID("tree_ctrl_close_folder")); - if(pos != wxNOT_FOUND) { + if (pos != wxNOT_FOUND) { closeItem = menu->FindItem(XRCID("tree_ctrl_close_folder"), NULL); } openShellPos = ::clFindMenuItemPosition(menu, XRCID("tree_ctrl_open_shell_folder")); - if(openShellPos != wxNOT_FOUND) { + if (openShellPos != wxNOT_FOUND) { ++openShellPos; // insert after ++openShellPos; // skip the separator } - if((pos != wxNOT_FOUND) && closeItem) { + if ((pos != wxNOT_FOUND) && closeItem) { wxMenuItem* showHiddenItem = menu->Insert(pos, XRCID("nodejs_show_hidden_files"), _("Show hidden files"), "", wxITEM_CHECK); NodeJSWorkspaceConfiguration conf(NodeJSWorkspace::Get()->GetFilename()); @@ -87,13 +87,13 @@ void NodeJSWorkspaceView::OnContextMenu(clContextMenuEvent& event) wxArrayTreeItemIds folderItems, fileItems; GetSelections(folders, folderItems, files, fileItems); - if((openShellPos != wxNOT_FOUND) && (folderItems.size() == 1) && (fileItems.size() == 0)) { + if ((openShellPos != wxNOT_FOUND) && (folderItems.size() == 1) && (fileItems.size() == 0)) { // only a folder is selected, check to see if this is a project folder // we do this by testing for the existence of the file package.json // under the folder path int npmInstallPosAfter = wxNOT_FOUND; wxFileName packageJSON(folders.Item(0), "package.json"); - if(packageJSON.FileExists()) { + if (packageJSON.FileExists()) { // A project folder menu->InsertSeparator(openShellPos); menu->Insert(openShellPos, XRCID("nodejs_project_settings"), _("Open package.json")); @@ -116,7 +116,7 @@ void NodeJSWorkspaceView::OnContextMenu(clContextMenuEvent& event) } int npmInstallPos = ::clFindMenuItemPosition(menu, npmInstallPosAfter); - if(npmInstallPos != wxNOT_FOUND) { + if (npmInstallPos != wxNOT_FOUND) { npmInstallPos++; // install after it menu->Insert(npmInstallPos, XRCID("nodejs_npm_install"), _("npm install")); menu->Bind(wxEVT_MENU, &NodeJSWorkspaceView::OnNpmInstall, this, XRCID("nodejs_npm_install")); @@ -129,12 +129,12 @@ void NodeJSWorkspaceView::OnFolderDropped(clCommandEvent& event) { // Add only non existent folders to the workspace const wxArrayString& folders = event.GetStrings(); - if(folders.IsEmpty()) + if (folders.IsEmpty()) return; - if(!NodeJSWorkspace::Get()->IsOpen()) { + if (!NodeJSWorkspace::Get()->IsOpen()) { wxFileName workspaceFile(folders.Item(0), ""); - if(!workspaceFile.GetDirCount()) { + if (!workspaceFile.GetDirCount()) { ::wxMessageBox(_("Can not create workspace in the root folder"), _("New Workspace"), wxICON_ERROR | wxOK | wxCENTER); return; @@ -148,10 +148,10 @@ void NodeJSWorkspaceView::OnFolderDropped(clCommandEvent& event) NodeJSWorkspace::Get()->Open(workspaceFile); } - if(NodeJSWorkspace::Get()->IsOpen()) { + if (NodeJSWorkspace::Get()->IsOpen()) { wxArrayString& workspaceFolders = NodeJSWorkspace::Get()->GetFolders(); - for(size_t i = 0; i < folders.size(); ++i) { - if(workspaceFolders.Index(folders.Item(i)) == wxNOT_FOUND) { + for (size_t i = 0; i < folders.size(); ++i) { + if (workspaceFolders.Index(folders.Item(i)) == wxNOT_FOUND) { // New folder, add it to the workspace workspaceFolders.Add(folders.Item(i)); AddFolder(folders.Item(i)); @@ -171,19 +171,19 @@ void NodeJSWorkspaceView::RebuildTree() Clear(); - for(size_t i = 0; i < paths.size(); ++i) { + for (size_t i = 0; i < paths.size(); ++i) { AddFolder(paths.Item(i)); } IEditor* editor = clGetManager()->GetActiveEditor(); - if(editor) { + if (editor) { ExpandToFile(editor->GetFileName()); } } void NodeJSWorkspaceView::ShowHiddenFiles(bool show) { - if(show) { + if (show) { m_options |= kShowHiddenFiles; m_options |= kShowHiddenFolders; } else { @@ -216,7 +216,7 @@ void NodeJSWorkspaceView::OnOpenPackageJsonFile(wxCommandEvent& event) { wxString path; wxTreeItemId item; - if(!GetSelectProjectPath(path, item)) + if (!GetSelectProjectPath(path, item)) return; wxFileName packageJson(path, "package.json"); @@ -241,7 +241,7 @@ bool NodeJSWorkspaceView::GetSelectProjectPath(wxString& path, wxTreeItemId& ite wxArrayString folders, files; wxArrayTreeItemIds folderItems, fileItems; GetSelections(folders, folderItems, files, fileItems); - if((folders.size() == 1) && (files.IsEmpty())) { + if ((folders.size() == 1) && (files.IsEmpty())) { path = folders.Item(0); item = folderItems.Item(0); return true; @@ -253,12 +253,12 @@ void NodeJSWorkspaceView::DoExecuteProject(NodeJSDebuggerDlg::eDialogType type) { wxString path; wxTreeItemId item; - if(!GetSelectProjectPath(path, item)) + if (!GetSelectProjectPath(path, item)) return; NodeJSPackageJSON pj; - if(!pj.Load(path)) { - if(!pj.Create(path)) { + if (!pj.Load(path)) { + if (!pj.Create(path)) { ::wxMessageBox(_("Failed to load package.json file from path:\n") + path, "CodeLite", wxICON_ERROR | wxOK | wxCENTER); return; @@ -268,12 +268,12 @@ void NodeJSWorkspaceView::DoExecuteProject(NodeJSDebuggerDlg::eDialogType type) // Sanity // No debugger? - if(!NodeJSWorkspace::Get()->GetDebugger() && - ((type == NodeJSDebuggerDlg::kDebug) || (type == NodeJSDebuggerDlg::kDebugCLI))) + if (!NodeJSWorkspace::Get()->GetDebugger() && + ((type == NodeJSDebuggerDlg::kDebug) || (type == NodeJSDebuggerDlg::kDebugCLI))) return; NodeJSDebuggerDlg dlg(EventNotifier::Get()->TopFrame(), type, pj.GetScript(), pj.GetArgs()); - if(dlg.ShowModal() != wxID_OK) { + if (dlg.ShowModal() != wxID_OK) { return; } @@ -309,18 +309,20 @@ void NodeJSWorkspaceView::OnItemExpanding(wxTreeEvent& event) { // change the icon for the parent folder as well wxFileName packageJSON(itemData->GetPath(), "package.json"); - if(packageJSON.FileExists()) { - GetTreeCtrl()->SetItemImage(item, imageIndex, imageIndexExpanded); + if (packageJSON.FileExists()) { + GetTreeCtrl()->SetItemImage(item, imageIndex); + GetTreeCtrl()->SetItemImage(item, imageIndexExpanded, wxTreeItemIcon_Expanded); + GetTreeCtrl()->SetItemImage(item, imageIndexExpanded, wxTreeItemIcon_SelectedExpanded); } } wxTreeItemIdValue cookie; wxTreeItemId child = GetTreeCtrl()->GetFirstChild(item, cookie); - while(child.IsOk()) { + while (child.IsOk()) { clTreeCtrlData* cd = GetItemData(child); - if(cd && cd->IsFolder()) { + if (cd && cd->IsFolder()) { wxFileName packageJSON(cd->GetPath(), "package.json"); - if(packageJSON.FileExists()) { + if (packageJSON.FileExists()) { // A project GetTreeCtrl()->SetItemImage(child, imageIndex); } @@ -335,7 +337,7 @@ void NodeJSWorkspaceView::OnNpmInit(wxCommandEvent& event) wxString path; wxTreeItemId item; - if(!GetSelectProjectPath(path, item)) + if (!GetSelectProjectPath(path, item)) return; clNodeJS::Get().NpmInit(path, this); } @@ -351,11 +353,11 @@ void NodeJSWorkspaceView::OnNpmInstall(wxCommandEvent& event) wxUnusedVar(event); wxTreeItemId item; wxString path; - if(!GetSelectProjectPath(path, item)) + if (!GetSelectProjectPath(path, item)) return; wxString packageName = ::wxGetTextFromUser(_("Package name:"), "npm install"); - if(packageName.IsEmpty()) { + if (packageName.IsEmpty()) { return; } clNodeJS::Get().NpmInstall(packageName, path, "--save", this); @@ -371,7 +373,7 @@ void NodeJSWorkspaceView::OnFindInFilesDismissed(clFindInFilesEvent& event) { event.Skip(); // Let the parent process this event first (it will handle any transient paths) - if(NodeJSWorkspace::Get()->IsOpen()) { + if (NodeJSWorkspace::Get()->IsOpen()) { // store the find in files mask clConfig::Get().Write("FindInFiles/NodeJS/LookIn", event.GetPaths()); clConfig::Get().Write("FindInFiles/NodeJS/Mask", event.GetFileMask()); @@ -382,7 +384,7 @@ void NodeJSWorkspaceView::OnFindInFilesShowing(clFindInFilesEvent& event) { event.Skip(); clTreeCtrlPanel::OnFindInFilesShowing(event); - if(NodeJSWorkspace::Get()->IsOpen()) { + if (NodeJSWorkspace::Get()->IsOpen()) { // store the find in files mask // Load the NodeJS workspace values from the configuration wxString mask = "*.js;*.html;*.css;*.scss;*.json;*.xml;*.ini;*.md;*.txt;*.text;.htaccess;*.sql";