[ENHANCE] Enhance Project Manager.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@809 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
489f63cd6b
commit
0fd460401a
@ -33,6 +33,31 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
|
|||||||
{
|
{
|
||||||
case WM_INITDIALOG :
|
case WM_INITDIALOG :
|
||||||
{
|
{
|
||||||
|
// Create toolbar menu
|
||||||
|
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT;
|
||||||
|
_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
|
||||||
|
0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL);
|
||||||
|
TBBUTTON tbButtons[2];
|
||||||
|
|
||||||
|
static TCHAR *projectMenuStr = TEXT("Project");
|
||||||
|
tbButtons[0].idCommand = IDB_PROJECT_BTN;
|
||||||
|
tbButtons[0].iBitmap = I_IMAGENONE;
|
||||||
|
tbButtons[0].fsState = TBSTATE_ENABLED;
|
||||||
|
tbButtons[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
||||||
|
tbButtons[0].iString = (INT_PTR)projectMenuStr;
|
||||||
|
|
||||||
|
static TCHAR *editMenuStr = TEXT("Edit");
|
||||||
|
tbButtons[1].idCommand = IDB_EDIT_BTN;
|
||||||
|
tbButtons[1].iBitmap = I_IMAGENONE;
|
||||||
|
tbButtons[1].fsState = TBSTATE_ENABLED;
|
||||||
|
tbButtons[1].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
|
||||||
|
tbButtons[1].iString = (INT_PTR)editMenuStr;
|
||||||
|
|
||||||
|
SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
|
||||||
|
SendMessage(_hToolbarMenu, TB_ADDBUTTONS, (WPARAM)sizeof(tbButtons) / sizeof(TBBUTTON), (LPARAM)&tbButtons);
|
||||||
|
SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
|
||||||
|
ShowWindow(_hToolbarMenu, SW_SHOW);
|
||||||
|
|
||||||
_treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW);
|
_treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW);
|
||||||
|
|
||||||
_treeView.initImageList(IDI_PROJECT_ROOT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);
|
_treeView.initImageList(IDI_PROJECT_ROOT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);
|
||||||
@ -51,9 +76,14 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
|
|||||||
{
|
{
|
||||||
int width = LOWORD(lParam);
|
int width = LOWORD(lParam);
|
||||||
int height = HIWORD(lParam);
|
int height = HIWORD(lParam);
|
||||||
|
RECT toolbarMenuRect;
|
||||||
|
::GetClientRect(_hToolbarMenu, &toolbarMenuRect);
|
||||||
|
|
||||||
|
::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);
|
||||||
|
|
||||||
HWND hwnd = _treeView.getHSelf();
|
HWND hwnd = _treeView.getHSelf();
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
::MoveWindow(hwnd, 0, 0, width, height, TRUE);
|
::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,20 +113,27 @@ void ProjectPanel::init(HINSTANCE hInst, HWND hPere)
|
|||||||
{
|
{
|
||||||
DockingDlgInterface::init(hInst, hPere);
|
DockingDlgInterface::init(hInst, hPere);
|
||||||
|
|
||||||
|
_hProjectMenu = ::CreatePopupMenu();
|
||||||
|
::InsertMenu(_hProjectMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWPROJ, TEXT("New Project"));
|
||||||
|
::InsertMenu(_hProjectMenu, 0, MF_BYCOMMAND, IDM_PROJECT_OPENPROJ, TEXT("Open Project File"));
|
||||||
|
::InsertMenu(_hProjectMenu, 0, MF_BYCOMMAND, IDM_PROJECT_SAVEPROJ, TEXT("Save"));
|
||||||
|
::InsertMenu(_hProjectMenu, 0, MF_BYCOMMAND, IDM_PROJECT_SAVEASPROJ, TEXT("Save As..."));
|
||||||
|
|
||||||
_hRootMenu = ::CreatePopupMenu();
|
_hRootMenu = ::CreatePopupMenu();
|
||||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_RENAME, TEXT("Rename"));
|
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_RENAME, TEXT("Rename"));
|
||||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWFOLDER, TEXT("New Folder..."));
|
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWFOLDER, TEXT("Add Folder"));
|
||||||
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_ADDFILES, TEXT("Add Files..."));
|
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_ADDFILES, TEXT("Add Files..."));
|
||||||
|
::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_PROJECT_DELETEFOLDER, TEXT("Remove"));
|
||||||
|
|
||||||
_hFolderMenu = ::CreatePopupMenu();
|
_hFolderMenu = ::CreatePopupMenu();
|
||||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_RENAME, TEXT("Rename"));
|
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_RENAME, TEXT("Rename"));
|
||||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWFOLDER, TEXT("New Folder..."));
|
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWFOLDER, TEXT("Add Folder"));
|
||||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_DELETEFOLDER, TEXT("Delete"));
|
|
||||||
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_ADDFILES, TEXT("Add Files..."));
|
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_ADDFILES, TEXT("Add Files..."));
|
||||||
|
::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_PROJECT_DELETEFOLDER, TEXT("Remove"));
|
||||||
|
|
||||||
_hFileMenu = ::CreatePopupMenu();
|
_hFileMenu = ::CreatePopupMenu();
|
||||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_PROJECT_RENAME, TEXT("Rename"));
|
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_PROJECT_RENAME, TEXT("Rename"));
|
||||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_PROJECT_DELETEFILE, TEXT("Delete"));
|
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_PROJECT_DELETEFILE, TEXT("Remove"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectPanel::openProject(TCHAR *projectFileName)
|
bool ProjectPanel::openProject(TCHAR *projectFileName)
|
||||||
@ -266,6 +303,31 @@ void ProjectPanel::notified(LPNMHDR notification)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NodeType ProjectPanel::getNodeType(HTREEITEM hItem)
|
||||||
|
{
|
||||||
|
TVITEM tvItem;
|
||||||
|
tvItem.hItem = hItem;
|
||||||
|
tvItem.mask = TVIF_IMAGE | TVIF_PARAM;
|
||||||
|
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
|
||||||
|
|
||||||
|
|
||||||
|
// Root
|
||||||
|
if (tvItem.iImage == INDEX_PROJECT_ROOT)
|
||||||
|
{
|
||||||
|
return nodeType_root;
|
||||||
|
}
|
||||||
|
// Folder
|
||||||
|
else if (tvItem.lParam == NULL)
|
||||||
|
{
|
||||||
|
return nodeType_node;
|
||||||
|
}
|
||||||
|
// File
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nodeType_leaf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectPanel::showContextMenu(int x, int y)
|
void ProjectPanel::showContextMenu(int x, int y)
|
||||||
{
|
{
|
||||||
TVHITTESTINFO tvHitInfo;
|
TVHITTESTINFO tvHitInfo;
|
||||||
@ -283,32 +345,31 @@ void ProjectPanel::showContextMenu(int x, int y)
|
|||||||
// Make item selected
|
// Make item selected
|
||||||
TreeView_SelectItem(_treeView.getHSelf(), tvHitInfo.hItem);
|
TreeView_SelectItem(_treeView.getHSelf(), tvHitInfo.hItem);
|
||||||
|
|
||||||
// get clicked item info
|
// get clicked item type
|
||||||
TVITEM tvItem;
|
NodeType nodeType = getNodeType(tvHitInfo.hItem);
|
||||||
tvItem.hItem = tvHitInfo.hItem;
|
|
||||||
tvItem.mask = TVIF_IMAGE;
|
|
||||||
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
|
|
||||||
|
|
||||||
HMENU hMenu = NULL;
|
HMENU hMenu = NULL;
|
||||||
// Root
|
if (nodeType == nodeType_root)
|
||||||
if (tvItem.iImage == INDEX_PROJECT_ROOT)
|
|
||||||
{
|
|
||||||
hMenu = _hRootMenu;
|
hMenu = _hRootMenu;
|
||||||
}
|
else if (nodeType == nodeType_node)
|
||||||
// Folder
|
|
||||||
else if (tvItem.lParam == NULL)
|
|
||||||
{
|
|
||||||
hMenu = _hFolderMenu;
|
hMenu = _hFolderMenu;
|
||||||
}
|
else //nodeType_leaf
|
||||||
// File
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hMenu = _hFileMenu;
|
hMenu = _hFileMenu;
|
||||||
}
|
|
||||||
TrackPopupMenu(hMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL);
|
TrackPopupMenu(hMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
POINT ProjectPanel::getMenuDisplyPoint(int iButton)
|
||||||
|
{
|
||||||
|
POINT p;
|
||||||
|
RECT btnRect;
|
||||||
|
SendMessage(_hToolbarMenu, TB_GETITEMRECT, iButton, (LPARAM)&btnRect);
|
||||||
|
|
||||||
|
p.x = btnRect.left;
|
||||||
|
p.y = btnRect.top + btnRect.bottom;
|
||||||
|
ClientToScreen(_hToolbarMenu, &p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectPanel::popupMenuCmd(int cmdID)
|
void ProjectPanel::popupMenuCmd(int cmdID)
|
||||||
{
|
{
|
||||||
// get selected item handle
|
// get selected item handle
|
||||||
@ -318,6 +379,28 @@ void ProjectPanel::popupMenuCmd(int cmdID)
|
|||||||
|
|
||||||
switch (cmdID)
|
switch (cmdID)
|
||||||
{
|
{
|
||||||
|
case IDB_PROJECT_BTN:
|
||||||
|
{
|
||||||
|
POINT p = getMenuDisplyPoint(0);
|
||||||
|
TrackPopupMenu(_hProjectMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDB_EDIT_BTN:
|
||||||
|
{
|
||||||
|
POINT p = getMenuDisplyPoint(0);
|
||||||
|
HMENU hMenu = NULL;
|
||||||
|
NodeType nodeType = getNodeType(hTreeItem);
|
||||||
|
if (nodeType == nodeType_root)
|
||||||
|
hMenu = _hRootMenu;
|
||||||
|
else if (nodeType == nodeType_node)
|
||||||
|
hMenu = _hFolderMenu;
|
||||||
|
else //nodeType_leaf
|
||||||
|
hMenu = _hFileMenu;
|
||||||
|
TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_PROJECT_RENAME :
|
case IDM_PROJECT_RENAME :
|
||||||
TreeView_EditLabel(_treeView.getHSelf(), hTreeItem);
|
TreeView_EditLabel(_treeView.getHSelf(), hTreeItem);
|
||||||
break;
|
break;
|
||||||
|
@ -28,23 +28,21 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
#include "TreeView.h"
|
#include "TreeView.h"
|
||||||
#include "ProjectPanel_rc.h"
|
#include "ProjectPanel_rc.h"
|
||||||
|
|
||||||
#define IDM_PROJECT_RENAME 2560
|
enum NodeType {
|
||||||
#define IDM_PROJECT_NEWFOLDER 2561
|
nodeType_root = 0, nodeType_node = 1, nodeType_leaf = 2
|
||||||
#define IDM_PROJECT_ADDFILES 2562
|
};
|
||||||
#define IDM_PROJECT_DELETEFOLDER 2563
|
|
||||||
#define IDM_PROJECT_DELETEFILE 2564
|
|
||||||
|
|
||||||
|
|
||||||
class TiXmlNode;
|
class TiXmlNode;
|
||||||
|
|
||||||
class ProjectPanel : public DockingDlgInterface {
|
class ProjectPanel : public DockingDlgInterface {
|
||||||
public:
|
public:
|
||||||
ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL),\
|
ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL),\
|
||||||
_hRootMenu(NULL), _hFolderMenu(NULL), _hFileMenu(NULL){};
|
_hToolbarMenu(NULL), _hProjectMenu(NULL), _hRootMenu(NULL), _hFolderMenu(NULL), _hFileMenu(NULL){};
|
||||||
|
|
||||||
void init(HINSTANCE hInst, HWND hPere);
|
void init(HINSTANCE hInst, HWND hPere);
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
|
::DestroyMenu(_hProjectMenu);
|
||||||
::DestroyMenu(_hRootMenu);
|
::DestroyMenu(_hRootMenu);
|
||||||
::DestroyMenu(_hFolderMenu);
|
::DestroyMenu(_hFolderMenu);
|
||||||
::DestroyMenu(_hFileMenu);
|
::DestroyMenu(_hFileMenu);
|
||||||
@ -63,12 +61,15 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
TreeView _treeView;
|
TreeView _treeView;
|
||||||
HMENU _hRootMenu, _hFolderMenu, _hFileMenu;
|
HWND _hToolbarMenu;
|
||||||
|
HMENU _hProjectMenu, _hRootMenu, _hFolderMenu, _hFileMenu;
|
||||||
void popupMenuCmd(int cmdID);
|
void popupMenuCmd(int cmdID);
|
||||||
|
POINT getMenuDisplyPoint(int iButton);
|
||||||
virtual BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
bool buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem);
|
bool buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem);
|
||||||
void notified(LPNMHDR notification);
|
void notified(LPNMHDR notification);
|
||||||
void showContextMenu(int x, int y);
|
void showContextMenu(int x, int y);
|
||||||
|
NodeType getNodeType(HTREEITEM hItem);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // PROJECTPANEL_H
|
#endif // PROJECTPANEL_H
|
||||||
|
@ -19,7 +19,25 @@
|
|||||||
#define PROJECTPANEL_RC_H
|
#define PROJECTPANEL_RC_H
|
||||||
|
|
||||||
#define IDD_PROJECTPANEL 3100
|
#define IDD_PROJECTPANEL 3100
|
||||||
#define ID_PROJECTTREEVIEW (IDD_PROJECTPANEL + 1)
|
|
||||||
|
#define IDD_PROJECTPANEL_MENU (IDD_PROJECTPANEL + 10)
|
||||||
|
#define IDM_PROJECT_RENAME (IDD_PROJECTPANEL_MENU + 1)
|
||||||
|
#define IDM_PROJECT_NEWFOLDER (IDD_PROJECTPANEL_MENU + 2)
|
||||||
|
#define IDM_PROJECT_ADDFILES (IDD_PROJECTPANEL_MENU + 3)
|
||||||
|
#define IDM_PROJECT_DELETEFOLDER (IDD_PROJECTPANEL_MENU + 4)
|
||||||
|
#define IDM_PROJECT_DELETEFILE (IDD_PROJECTPANEL_MENU + 5)
|
||||||
|
|
||||||
|
#define IDD_PROJECTPANEL_MENUPROJ (IDD_PROJECTPANEL + 20)
|
||||||
|
#define IDM_PROJECT_NEWPROJ (IDD_PROJECTPANEL_MENUPROJ + 1)
|
||||||
|
#define IDM_PROJECT_OPENPROJ (IDD_PROJECTPANEL_MENUPROJ + 2)
|
||||||
|
#define IDM_PROJECT_SAVEPROJ (IDD_PROJECTPANEL_MENUPROJ + 3)
|
||||||
|
#define IDM_PROJECT_SAVEASPROJ (IDD_PROJECTPANEL_MENUPROJ + 4)
|
||||||
|
|
||||||
|
|
||||||
|
#define IDD_PROJECTPANEL_CTRL (IDD_PROJECTPANEL + 30)
|
||||||
|
#define ID_PROJECTTREEVIEW (IDD_PROJECTPANEL_CTRL + 1)
|
||||||
|
#define IDB_PROJECT_BTN (IDD_PROJECTPANEL_CTRL + 2)
|
||||||
|
#define IDB_EDIT_BTN (IDD_PROJECTPANEL_CTRL + 3)
|
||||||
|
|
||||||
#endif // PROJECTPANEL_RC_H
|
#endif // PROJECTPANEL_RC_H
|
||||||
|
|
||||||
|
@ -154,6 +154,9 @@ void TreeView::cleanSubEntries(HTREEITEM hTreeItem)
|
|||||||
|
|
||||||
void TreeView::collapsItemGUI(HTREEITEM hTreeItem)
|
void TreeView::collapsItemGUI(HTREEITEM hTreeItem)
|
||||||
{
|
{
|
||||||
|
if (TreeView_GetRoot(_hSelf) == hTreeItem)
|
||||||
|
return;
|
||||||
|
|
||||||
if (getChildFrom(hTreeItem) == NULL)
|
if (getChildFrom(hTreeItem) == NULL)
|
||||||
{
|
{
|
||||||
TVITEM tvItem;
|
TVITEM tvItem;
|
||||||
|
Loading…
Reference in New Issue
Block a user