[NEW_FEATURE] enhance Project manager (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@804 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-09-03 12:00:38 +00:00
parent de6036b575
commit f88cbf265e
3 changed files with 84 additions and 9 deletions

View File

@ -17,11 +17,15 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "precompiledHeaders.h" #include "precompiledHeaders.h"
#include "ProjectPanel.h" #include "ProjectPanel.h"
#include "resource.h" #include "resource.h"
#include "tinyxml.h" #include "tinyxml.h"
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
@ -38,7 +42,7 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
case WM_NOTIFY: case WM_NOTIFY:
{ {
notified((LPNMTREEVIEW)lParam); notified((LPNMHDR)lParam);
} }
return TRUE; return TRUE;
@ -51,7 +55,11 @@ BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
::MoveWindow(hwnd, 0, 0, width, height, TRUE); ::MoveWindow(hwnd, 0, 0, width, height, TRUE);
break; break;
} }
case WM_CONTEXTMENU:
showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return TRUE;
case WM_DESTROY: case WM_DESTROY:
{ {
//_fileListView.destroy(); //_fileListView.destroy();
@ -113,12 +121,35 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
return true; return true;
} }
void ProjectPanel::notified(LPNMTREEVIEW notification) void ProjectPanel::notified(LPNMHDR notification)
{ {
TVITEM tv_item; //LPNMTREEVIEW
TCHAR text_buffer[MAX_PATH]; //TVITEM tv_item;
//TCHAR text_buffer[MAX_PATH];
if((notification->hdr).hwndFrom == _treeView.getHSelf()) switch (notification->code)
{
case NM_DBLCLK:
{
//printStr(TEXT("double click"));
}
break;
/*
case NM_RCLICK:
{
//printStr(TEXT("right click"));
}
break;
case TVN_SELCHANGED:
{
printStr(TEXT("TVN_SELCHANGED"));
}
break;
*/
}
/*
if((notification->hdr).hwndFrom == _treeView.getHSelf())
{ {
if((notification->hdr).code == TVN_SELCHANGED) if((notification->hdr).code == TVN_SELCHANGED)
{ {
@ -128,12 +159,54 @@ void ProjectPanel::notified(LPNMTREEVIEW notification)
tv_item.cchTextMax = MAX_PATH; tv_item.cchTextMax = MAX_PATH;
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tv_item); SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tv_item);
/*
if(tv_item.lParam==DOMAIN_LEVEL) if(tv_item.lParam==DOMAIN_LEVEL)
ShowDomainContent(tv_item.pszText); ShowDomainContent(tv_item.pszText);
else if(tv_item.lParam==SERVER_LEVEL) else if(tv_item.lParam==SERVER_LEVEL)
ShowServerContent(tv_item.pszText); ShowServerContent(tv_item.pszText);
*/
} }
} }
*/
}
void ProjectPanel::showContextMenu(int x, int y)
{
TCHAR text_buffer[MAX_PATH];
TVHITTESTINFO tv_hit_info;
HTREEITEM hTreeItem;
TVITEM tv_item;
// Detect if the given position is on the element TVITEM
tv_hit_info.pt.x = x;
tv_hit_info.pt.y = y;
tv_hit_info.flags = 0;
ScreenToClient(_treeView.getHSelf(), &(tv_hit_info.pt));
hTreeItem = TreeView_HitTest(_treeView.getHSelf(),&tv_hit_info);
if(tv_hit_info.hItem != NULL)
{
// get clicked item info
tv_item.hItem = tv_hit_info.hItem;
tv_item.mask = TVIF_TEXT | TVIF_PARAM;
tv_item.pszText = text_buffer;
tv_item.cchTextMax = MAX_PATH;
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tv_item);
/*
// Display dynamique menu
if(tv_item.lParam == DOMAIN_LEVEL)
{
lstrcpy(window_main->right_clicked_label,tv_item.pszText);
window_main->right_clicked_node_type = DOMAIN_LEVEL;
TrackPopupMenu(window_main->hMenu_domain, TPM_LEFTALIGN, x, y, 0, window_main->hwndMain, NULL);
}
else if(tv_item.lParam == SERVER_LEVEL)
{
lstrcpy(window_main->right_clicked_label,tv_item.pszText);
window_main->right_clicked_node_type = SERVER_LEVEL;
TrackPopupMenu(window_main->hMenu_server, TPM_LEFTALIGN, x, y, 0, window_main->hwndMain, NULL);
}
*/
}
} }

View File

@ -52,7 +52,8 @@ protected:
TreeView _treeView; TreeView _treeView;
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(LPNMTREEVIEW notification); void notified(LPNMHDR notification);
void showContextMenu(int x, int y);
}; };
#endif // PROJECTPANEL_H #endif // PROJECTPANEL_H

View File

@ -111,6 +111,7 @@ HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iI
return (HTREEITEM)::SendMessage(_hSelf, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvInsertStruct); return (HTREEITEM)::SendMessage(_hSelf, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvInsertStruct);
} }
/* /*
HTREEITEM TreeView::addItem(const TCHAR *itemName, int nLevel) HTREEITEM TreeView::addItem(const TCHAR *itemName, int nLevel)
{ {