parent
8fd691a3b2
commit
69da7a765d
@ -25,6 +25,7 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// 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 <WindowsX.h>
|
||||||
|
|
||||||
#include "ProjectPanel.h"
|
#include "ProjectPanel.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
@ -44,9 +45,6 @@
|
|||||||
#define INDEX_LEAF 5
|
#define INDEX_LEAF 5
|
||||||
#define INDEX_LEAF_INVALID 6
|
#define INDEX_LEAF_INVALID 6
|
||||||
|
|
||||||
#define GET_X_LPARAM(lp) LOWORD(lp)
|
|
||||||
#define GET_Y_LPARAM(lp) HIWORD(lp)
|
|
||||||
|
|
||||||
INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
@ -133,7 +131,30 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
case WM_CONTEXTMENU:
|
case WM_CONTEXTMENU:
|
||||||
if (!_treeView.isDragging())
|
if (!_treeView.isDragging())
|
||||||
showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
{
|
||||||
|
int xPos = GET_X_LPARAM(lParam);
|
||||||
|
int yPos = GET_Y_LPARAM(lParam);
|
||||||
|
|
||||||
|
// If the context menu is generated from the keyboard, then we
|
||||||
|
// should display it at the location of the current selection
|
||||||
|
if (xPos == -1 && yPos == -1)
|
||||||
|
{
|
||||||
|
HTREEITEM selectedItem = _treeView.getSelection();
|
||||||
|
|
||||||
|
if (selectedItem)
|
||||||
|
{
|
||||||
|
RECT selectedItemRect;
|
||||||
|
if (TreeView_GetItemRect(_treeView.getHSelf(), selectedItem, &selectedItemRect, TRUE))
|
||||||
|
{
|
||||||
|
showContextMenuFromMenuKey(selectedItem, (selectedItemRect.left + selectedItemRect.right) / 2, (selectedItemRect.top + selectedItemRect.bottom) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showContextMenu(xPos, yPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
@ -763,10 +784,32 @@ void ProjectPanel::showContextMenu(int x, int y)
|
|||||||
{
|
{
|
||||||
// Make item selected
|
// Make item selected
|
||||||
_treeView.selectItem(tvHitInfo.hItem);
|
_treeView.selectItem(tvHitInfo.hItem);
|
||||||
|
HMENU hMenu = getMenuHandler(tvHitInfo.hItem);
|
||||||
|
TrackPopupMenu(hMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectPanel::showContextMenuFromMenuKey(HTREEITEM selectedItem, int x, int y)
|
||||||
|
{
|
||||||
|
POINT p;
|
||||||
|
p.x = x;
|
||||||
|
p.y = y;
|
||||||
|
|
||||||
|
ClientToScreen(_treeView.getHSelf(), &p);
|
||||||
|
|
||||||
|
if (selectedItem != NULL)
|
||||||
|
{
|
||||||
|
HMENU hMenu = getMenuHandler(selectedItem);
|
||||||
|
TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HMENU ProjectPanel::getMenuHandler(HTREEITEM selectedItem)
|
||||||
|
{
|
||||||
// get clicked item type
|
// get clicked item type
|
||||||
NodeType nodeType = getNodeType(tvHitInfo.hItem);
|
NodeType nodeType = getNodeType(selectedItem);
|
||||||
HMENU hMenu = NULL;
|
HMENU hMenu = NULL;
|
||||||
|
|
||||||
if (nodeType == nodeType_root)
|
if (nodeType == nodeType_root)
|
||||||
hMenu = _hWorkSpaceMenu;
|
hMenu = _hWorkSpaceMenu;
|
||||||
else if (nodeType == nodeType_project)
|
else if (nodeType == nodeType_project)
|
||||||
@ -775,8 +818,8 @@ void ProjectPanel::showContextMenu(int x, int y)
|
|||||||
hMenu = _hFolderMenu;
|
hMenu = _hFolderMenu;
|
||||||
else //nodeType_file
|
else //nodeType_file
|
||||||
hMenu = _hFileMenu;
|
hMenu = _hFileMenu;
|
||||||
TrackPopupMenu(hMenu, TPM_LEFTALIGN, x, y, 0, _hSelf, NULL);
|
|
||||||
}
|
return hMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
POINT ProjectPanel::getMenuDisplayPoint(int iButton)
|
POINT ProjectPanel::getMenuDisplayPoint(int iButton)
|
||||||
|
@ -135,6 +135,8 @@ protected:
|
|||||||
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);
|
||||||
|
void showContextMenuFromMenuKey(HTREEITEM selectedItem, int x, int y);
|
||||||
|
HMENU getMenuHandler(HTREEITEM selectedItem);
|
||||||
generic_string getAbsoluteFilePath(const TCHAR * relativePath);
|
generic_string getAbsoluteFilePath(const TCHAR * relativePath);
|
||||||
void openSelectFile();
|
void openSelectFile();
|
||||||
void setFileExtFilter(FileDialog & fDlg);
|
void setFileExtFilter(FileDialog & fDlg);
|
||||||
|
Loading…
Reference in New Issue
Block a user