[ENHANCE] Enhancement for drag and drop feature in Project Manager.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@848 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 13 years ago
parent 0598f46e9f
commit ab2836f716

@ -240,6 +240,8 @@ bool TreeView::canBeDropped(HTREEITEM draggedItem, HTREEITEM targetItem)
return false;
if (isDescendant(targetItem, draggedItem))
return false;
if (isParent(targetItem, draggedItem))
return false;
// candragItem, canBeDropInItems
if (!canDropIn(targetItem))
return false;
@ -259,22 +261,34 @@ bool TreeView::isDescendant(HTREEITEM targetItem, HTREEITEM draggedItem)
return isDescendant(parent, draggedItem);
}
bool TreeView::isParent(HTREEITEM targetItem, HTREEITEM draggedItem)
{
HTREEITEM parent = TreeView_GetParent(_hSelf, draggedItem);
if (parent == targetItem)
return true;
return false;
}
void TreeView::moveTreeViewItem(HTREEITEM draggedItem, HTREEITEM targetItem)
{
TCHAR textBuffer[MAX_PATH];
TVITEM tvItem;
tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvItem.pszText = textBuffer;
tvItem.cchTextMax = MAX_PATH;
tvItem.hItem = draggedItem;
SendMessage(_hSelf, TVM_GETITEM, 0,(LPARAM)&tvItem);
TVITEM tvDraggingItem;
tvDraggingItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvDraggingItem.pszText = textBuffer;
tvDraggingItem.cchTextMax = MAX_PATH;
tvDraggingItem.hItem = draggedItem;
SendMessage(_hSelf, TVM_GETITEM, 0,(LPARAM)&tvDraggingItem);
if (tvDraggingItem.lParam)
tvDraggingItem.lParam = (LPARAM)(new generic_string(*((generic_string *)(tvDraggingItem.lParam))));
TVINSERTSTRUCT tvInsertStruct;
tvInsertStruct.item = tvItem;
tvInsertStruct.item = tvDraggingItem;
tvInsertStruct.hInsertAfter = (HTREEITEM)TVI_LAST;
tvInsertStruct.hParent = targetItem;
::SendMessage(_hSelf, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvInsertStruct);
removeItem(draggedItem);
}
bool TreeView::canDropIn(HTREEITEM targetItem)
@ -292,6 +306,7 @@ bool TreeView::canDropIn(HTREEITEM targetItem)
return true;
}
bool TreeView::canDragOut(HTREEITEM targetItem)
{
TVITEM tvItem;

@ -83,6 +83,7 @@ protected:
std::vector<int> _canNotDropInList;
bool canBeDropped(HTREEITEM draggedItem, HTREEITEM targetItem);
void moveTreeViewItem(HTREEITEM draggedItem, HTREEITEM targetItem);
bool isParent(HTREEITEM targetItem, HTREEITEM draggedItem);
bool isDescendant(HTREEITEM targetItem, HTREEITEM draggedItem);
bool canDragOut(HTREEITEM targetItem);
bool canDropIn(HTREEITEM targetItem);

Loading…
Cancel
Save