1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Copyright : (C) 2015 Eran Ifrah
// File name : clTreeCtrlPanel.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef CLTREECTRLPANEL_H
#define CLTREECTRLPANEL_H
#include "bitmap_loader.h"
#include "clEnhancedToolBar.hpp"
#include "clFileSystemEvent.h"
#include "clFileViwerTreeCtrl.h"
#include "clToolBar.h"
#include "cl_command_event.h"
#include "cl_config.h"
#include "wxcrafter_plugin.h"
#include <imanager.h>
class clTreeCtrlPanelDefaultPage;
class WXDLLIMPEXP_SDK clTreeCtrlPanel : public clTreeCtrlPanelBase
{
public:
enum {
kShowHiddenFiles = (1 << 0),
kShowHiddenFolders = (1 << 1),
kLinkToEditor = (1 << 2),
kShowRootFullPath = (1 << 3),
};
protected:
clConfig* m_config = nullptr;
wxString m_viewName;
clTreeCtrlPanelDefaultPage* m_defaultView = nullptr;
wxString m_newfileTemplate;
size_t m_newfileTemplateHighlightLen = 0;
int m_options = (kShowHiddenFiles | kShowHiddenFolders | kLinkToEditor);
clToolBar* m_toolbar = nullptr;
wxString m_excludeFilePatterns;
protected:
void ToggleView();
void RefreshNonTopLevelFolder(const wxTreeItemId& item);
virtual void OnLinkEditor(wxCommandEvent& event);
virtual void OnLinkEditorUI(wxUpdateUIEvent& event);
void OnFilesCreated(clFileSystemEvent& event);
public:
clTreeCtrlPanel(wxWindow* parent);
virtual ~clTreeCtrlPanel();
/**
* @brief getter for the toolbar
*/
clToolBar* GetToolBar() { return m_toolbar; }
/**
* @brief set the tree options
*/
void SetOptions(int options) { m_options = options; }
/**
* @brief set the new file template (default is "Untitled.txt")
*/
void SetNewFileTemplate(const wxString& newfile, size_t charsToHighlight);
void SetViewName(const wxString& viewName) { this->m_viewName = viewName; }
const wxString& GetViewName() const { return m_viewName; }
clConfig* GetConfig() { return m_config; }
/**
* @brief clear the view (i.e. close all top level folders)
*/
void Clear();
/**
* @brief set exclude file pattern. Excluded files will not be shown in the tree
* @param excludeFilePatterns
*/
void SetExcludeFilePatterns(const wxString& excludeFilePatterns)
{
this->m_excludeFilePatterns = excludeFilePatterns;
}
const wxString& GetExcludeFilePatterns() const { return m_excludeFilePatterns; }
/**
* @brief return the configuration tool used for storing information about
* this tree. Override it to provide a custom configuration tool
*/
void SetConfig(clConfig* config) { this->m_config = config; }
/**
* @brief add top level folder
*/
void AddFolder(const wxString& path);
/**
* @brief return an info about the selected items in the tree
* @return
*/
TreeItemInfo GetSelectedItemInfo();
/**
* @brief return 2 arrays of the selected items
* @param folders [output]
* @param files [output]
*/
void GetSelections(wxArrayString& folders, wxArrayString& files);
/**
* @brief select a given filename in the tree. Expand the tree if needed
*/
bool ExpandToFile(const wxFileName& filename);
/**
* @brief return true if a folder is opened in this view
*/
bool IsFolderOpened() const;
/**
* @brief refresh the entire tree, unconditionally
*/
void RefreshTree();
protected:
void UpdateItemDeleted(const wxTreeItemId& item);
void GetTopLevelFolders(wxArrayString& paths, wxArrayTreeItemIds& items) const;
/**
* @brief ensure that item is selected (single selection)
*/
void SelectItem(const wxTreeItemId& item);
/**
* @brief return list of selected files and folders. In addition return the
* tree ctrl items. You can always assume that the folders and the folderItems are of the same
* size. Same for the file arrays
*/
void GetSelections(wxArrayString& folders, wxArrayTreeItemIds& folderItems, wxArrayString& files,
wxArrayTreeItemIds& fileItems);
// void version of the expandToFile, so it can be called with CallAfter
void ExpandToFileVoid(const wxFileName& fn);
// Make the event handler functions virtual
// so any subclass could override them
virtual void OnActiveEditorChanged(wxCommandEvent& event);
virtual void OnFindInFilesShowing(clFindInFilesEvent& event);
virtual void OnInitDone(wxCommandEvent& event);
virtual void OnContextMenu(wxTreeEvent& event);
virtual void OnItemActivated(wxTreeEvent& event);
virtual void OnItemExpanding(wxTreeEvent& event);
virtual void OnCloseFolder(wxCommandEvent& event);
virtual void OnNewFolder(wxCommandEvent& event);
virtual void OnNewFile(wxCommandEvent& event);
virtual void OnOpenFile(wxCommandEvent& event);
virtual void OnOpenWithDefaultApplication(wxCommandEvent& event);
virtual void OnRenameFile(wxCommandEvent& event);
virtual void OnDeleteSelections(wxCommandEvent& event);
virtual void OnRenameFolder(wxCommandEvent& event);
virtual void OnFindInFilesFolder(wxCommandEvent& event);
virtual void OnOpenContainingFolder(wxCommandEvent& event);
virtual void OnOpenShellFolder(wxCommandEvent& event);
virtual void OnFolderDropped(clCommandEvent& event);
virtual void OnRefresh(wxCommandEvent& event);
void OnOpenFolder(wxCommandEvent& event);
// Helpers
void DoExpandItem(const wxTreeItemId& parent, bool expand);
void DoRenameItem(const wxTreeItemId& item, const wxString& oldname, const wxString& newname);
bool IsTopLevelFolder(const wxTreeItemId& item);
clTreeCtrlData* GetItemData(const wxTreeItemId& item) const;
wxTreeItemId DoAddFolder(const wxTreeItemId& parent, const wxString& path);
wxTreeItemId DoAddFile(const wxTreeItemId& parent, const wxString& path);
void DoCloseFolder(const wxTreeItemId& item);
};
#endif // CLTREECTRLPANEL_H
|