Add "Fold All" toolbar command in Folder As Workspace
This commit is contained in:
parent
b41a480d68
commit
e0d995c1a6
@ -207,6 +207,7 @@ IDI_FB_ROOTOPEN BITMAP "icons/fb_root_open.bmp"
|
||||
IDI_FB_ROOTCLOSE BITMAP "icons/fb_root_close.bmp"
|
||||
|
||||
IDI_FB_SELECTCURRENTFILE BITMAP "icons/fb_select_current_file.bmp"
|
||||
IDI_FB_FOLDALL BITMAP "icons/fb_fold_all.bmp"
|
||||
|
||||
IDI_FUNCLIST_ROOT BITMAP "icons/project_file.bmp"
|
||||
IDI_FUNCLIST_NODE BITMAP "icons/funcList_node.bmp"
|
||||
|
@ -54,6 +54,7 @@
|
||||
#define FB_RMFILE (WM_USER + 1025)
|
||||
#define FB_RNFILE (WM_USER + 1026)
|
||||
#define FB_CMD_AIMFILE 1
|
||||
#define FB_CMD_FOLDALL 2
|
||||
|
||||
FileBrowser::~FileBrowser()
|
||||
{
|
||||
@ -109,19 +110,27 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS;
|
||||
_hToolbarMenu = CreateWindowEx(WS_EX_LAYOUTRTL, TOOLBARCLASSNAME, NULL, style, 0, 0, 0, 0, _hSelf, nullptr, _hInst, NULL);
|
||||
TBBUTTON tbButtons[1];
|
||||
TBBUTTON tbButtons[2];
|
||||
// Add the bmap image into toolbar's imagelist
|
||||
TBADDBITMAP addbmp = { _hInst, 0 };
|
||||
addbmp.nID = IDI_FB_SELECTCURRENTFILE;
|
||||
::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp));
|
||||
addbmp.nID = IDI_FB_FOLDALL;
|
||||
::SendMessage(_hToolbarMenu, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp));
|
||||
tbButtons[0].idCommand = FB_CMD_AIMFILE;
|
||||
tbButtons[0].iBitmap = 0;
|
||||
tbButtons[0].fsState = TBSTATE_ENABLED;
|
||||
tbButtons[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
||||
tbButtons[0].iString = reinterpret_cast<INT_PTR>(TEXT(""));
|
||||
tbButtons[1].idCommand = FB_CMD_FOLDALL;
|
||||
tbButtons[1].iBitmap = 1;
|
||||
tbButtons[1].fsState = TBSTATE_ENABLED;
|
||||
tbButtons[1].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
||||
tbButtons[1].iString = reinterpret_cast<INT_PTR>(TEXT(""));
|
||||
|
||||
::SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
::SendMessage(_hToolbarMenu, TB_SETBUTTONSIZE, 0, MAKELONG(nppParam._dpiManager.scaleX(20), nppParam._dpiManager.scaleY(20)));
|
||||
::SendMessage(_hToolbarMenu, TB_SETPADDING, 0, MAKELONG(30, 0));
|
||||
::SendMessage(_hToolbarMenu, TB_SETPADDING, 0, MAKELONG(20, 0));
|
||||
::SendMessage(_hToolbarMenu, TB_ADDBUTTONS, sizeof(tbButtons) / sizeof(TBBUTTON), reinterpret_cast<LPARAM>(&tbButtons));
|
||||
::SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
|
||||
ShowWindow(_hToolbarMenu, SW_SHOW);
|
||||
@ -199,6 +208,12 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
break;
|
||||
}
|
||||
|
||||
case FB_CMD_FOLDALL:
|
||||
{
|
||||
_treeView.foldAll();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
popupMenuCmd(LOWORD(wParam));
|
||||
}
|
||||
@ -348,17 +363,17 @@ void FileBrowser::initPopupMenus()
|
||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str());
|
||||
}
|
||||
|
||||
bool FileBrowser::selectCurrentEditingFile()
|
||||
bool FileBrowser::selectCurrentEditingFile() const
|
||||
{
|
||||
TCHAR currentDocPath[MAX_PATH] = { '0' };
|
||||
::SendMessage(_hParent, NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(currentDocPath));
|
||||
generic_string rootFolderPath = currentDocPath;
|
||||
size_t nbFolderUpdaters = _folderUpdaters.size();
|
||||
for (size_t i = 0; i < nbFolderUpdaters; ++i)
|
||||
|
||||
for (const auto f : _folderUpdaters)
|
||||
{
|
||||
if (isRelatedRootFolder(_folderUpdaters[i]->_rootFolder._rootPath, rootFolderPath))
|
||||
if (isRelatedRootFolder(f->_rootFolder._rootPath, rootFolderPath))
|
||||
{
|
||||
generic_string rootPath = _folderUpdaters[i]->_rootFolder._rootPath;
|
||||
generic_string rootPath = f->_rootFolder._rootPath;
|
||||
generic_string pathSuffix = rootFolderPath.substr(rootPath.size() + 1, rootFolderPath.size() - rootPath.size());
|
||||
vector<generic_string> linarPathArray = split(pathSuffix, '\\');
|
||||
|
||||
@ -1054,7 +1069,7 @@ HTREEITEM FileBrowser::getRootFromFullPath(const generic_string & rootPath) cons
|
||||
return node;
|
||||
}
|
||||
|
||||
HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const generic_string& label)
|
||||
HTREEITEM FileBrowser::findChildNodeFromName(HTREEITEM parent, const generic_string& label) const
|
||||
{
|
||||
HTREEITEM childNodeFound = nullptr;
|
||||
|
||||
@ -1164,7 +1179,7 @@ bool FileBrowser::addInTree(const generic_string& rootPath, const generic_string
|
||||
}
|
||||
}
|
||||
|
||||
HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray)
|
||||
HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray) const
|
||||
{
|
||||
if (node == nullptr) // it's a root. Search the right root with rootPath
|
||||
{
|
||||
|
@ -142,10 +142,10 @@ public:
|
||||
void addRootFolder(generic_string);
|
||||
|
||||
HTREEITEM getRootFromFullPath(const generic_string & rootPath) const;
|
||||
HTREEITEM findChildNodeFromName(HTREEITEM parent, const generic_string&);
|
||||
HTREEITEM findChildNodeFromName(HTREEITEM parent, const generic_string&) const;
|
||||
|
||||
bool addInTree(const generic_string& rootPath, const generic_string& addItemFullPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||
HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||
HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray) const;
|
||||
bool deleteFromTree(const generic_string& rootPath, HTREEITEM node, const std::vector<generic_string>& linarPathArray);
|
||||
void deleteAllFromTree() {
|
||||
popupMenuCmd(IDM_FILEBROWSER_REMOVEALLROOTS);
|
||||
@ -174,7 +174,8 @@ protected:
|
||||
|
||||
BrowserNodeType getNodeType(HTREEITEM hItem);
|
||||
void popupMenuCmd(int cmdID);
|
||||
bool selectCurrentEditingFile();
|
||||
bool selectCurrentEditingFile() const;
|
||||
|
||||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void notified(LPNMHDR notification);
|
||||
void showContextMenu(int x, int y);
|
||||
|
@ -263,6 +263,31 @@ void TreeView::cleanSubEntries(HTREEITEM hTreeItem)
|
||||
}
|
||||
}
|
||||
|
||||
void TreeView::foldRecursively(HTREEITEM hParentItem) const
|
||||
{
|
||||
if (!hParentItem)
|
||||
return;
|
||||
|
||||
HTREEITEM hItem = getChildFrom(hParentItem);
|
||||
|
||||
for (; hItem != NULL; hItem = getNextSibling(hItem))
|
||||
{
|
||||
foldRecursively(hItem);
|
||||
fold(hItem);
|
||||
}
|
||||
fold(hParentItem);
|
||||
}
|
||||
|
||||
void TreeView::foldAll() const
|
||||
{
|
||||
for (HTREEITEM tvProj = getRoot();
|
||||
tvProj != NULL;
|
||||
tvProj = getNextSibling(tvProj))
|
||||
{
|
||||
foldRecursively(tvProj);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeView::setItemImage(HTREEITEM hTreeItem, int iImage, int iSelectedImage)
|
||||
{
|
||||
TVITEM tvItem;
|
||||
|
@ -88,6 +88,9 @@ public:
|
||||
TreeView_Expand(_hSelf, hItem, TVE_COLLAPSE);
|
||||
};
|
||||
|
||||
void foldRecursively(HTREEITEM hItem) const;
|
||||
void foldAll() const;
|
||||
|
||||
void toggleExpandCollapse(HTREEITEM hItem) const {
|
||||
TreeView_Expand(_hSelf, hItem, TVE_TOGGLE);
|
||||
};
|
||||
|
BIN
PowerEditor/src/icons/fb_fold_all.bmp
Normal file
BIN
PowerEditor/src/icons/fb_fold_all.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -145,6 +145,7 @@
|
||||
#define IDI_FB_ROOTOPEN 608
|
||||
#define IDI_FB_ROOTCLOSE 609
|
||||
#define IDI_FB_SELECTCURRENTFILE 610
|
||||
#define IDI_FB_FOLDALL 611
|
||||
|
||||
#define IDI_FUNCLIST_ROOT 620
|
||||
#define IDI_FUNCLIST_NODE 621
|
||||
|
Loading…
Reference in New Issue
Block a user