CEditTreeCtrl::EDropHint CEditTreeCtrl::GetDropHint(UINT flags) {
	EDropHint hint = DROP_NODROP;

	if((flags & TVHT_ONITEMRIGHT))
		hint = DROP_CHILD;

	else if(flags & TVHT_ONITEM) {
		// check whether we should drop below or above
		// the item
		CRect rc;
		if(GetItemRect(GetDropHilightItem(), rc, false)) {
			CPoint pt;
			::GetCursorPos(&pt);
			ScreenToClient(&pt);
			if((pt.y - rc.top) > (rc.bottom - pt.y))
				hint = DROP_BELOW;
			else
				hint = DROP_ABOVE;
		} else
			hint = DROP_ABOVE;

	} else if((flags & TVHT_NOWHERE))
		// below the last item
		hint = DROP_BELOW;

	ASSERT(m_pDragData != 0);
	m_pDragData->SetDropHint(hint);

	return hint;
}
Пример #2
0
LRESULT MFTreeView::OnRClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)
{
   HMENU ctxMenu = CreatePopupMenu();

   WTL::CTreeItem item = GetDropHilightItem();
   if (item.IsNull())
   {
      item = GetSelectedItem();
   }
   MFTreeViewItem* pItem = (MFTreeViewItem*)item.GetData();

   if (pItem == NULL)
   {
      DestroyMenu(ctxMenu);
      return 0;
   }

   unsigned int nextID = pItem->AppendMenuCmd(ctxMenu, 1, item);

   if (GetMenuItemCount(ctxMenu) > 0)
   {
      AppendMenu(ctxMenu, MF_SEPARATOR, 0, NULL);
   }
   unsigned int refreshID = nextID++;
   nextID = AppendMenu(ctxMenu, MF_STRING, refreshID, _T("Refresh"));

   if (GetMenuItemCount(ctxMenu) == 0)
   {
      DestroyMenu(ctxMenu);
      return 0;
   }

   POINT pos;
   GetCursorPos(&pos);

   int command = TrackPopupMenuEx(ctxMenu, TPM_NONOTIFY | TPM_RETURNCMD, pos.x, pos.y, pnmh->hwndFrom, NULL);

   if (!pItem->HandleMenuCmd(command, item))
   {
      if (command == refreshID)
      {
         WTL::CTreeItem parent = item.GetParent();
         parent.Expand(TVE_COLLAPSE | TVE_COLLAPSERESET);
         parent.Expand();
      }
   }

   DestroyMenu(ctxMenu);

   return 1;
}
Пример #3
0
void CNZProjectTreeCtrl::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	HTREEITEM		hitem;
	UINT			flags;

	if (m_bDragging)
	{
		//TRACE0("MOUSE MOVE/t");
		POINT pt = point;
		ClientToScreen( &pt );
		CImageList::DragMove(pt);
		if ((hitem = HitTest(point, &flags)) != NULL)
		{
			if( m_htiOldDrop == NULL )
				m_htiOldDrop = GetDropHilightItem();

			CXNode* pNode = (CXNode*)GetItemData(hitem);
			if (pNode->m_enNodeType == XNODE_FILE)
			{
				// use the file's parent (folder or project)
				hitem = pNode->m_pParent->m_hTreeItem;
				ASSERT(hitem);
			}

			// select the node to which we can drop
			CImageList::DragShowNolock(FALSE);
			SelectDropTarget(hitem);
			m_htiDrop = hitem;
			CImageList::DragShowNolock(TRUE);

			// kill the timer if selection changed
			if( m_nExpandTimer && hitem == m_htiOldDrop )
			{
				KillTimer( m_nExpandTimer );
				m_nExpandTimer = 0;
			}
			
			// start the timer again
			if( !m_nExpandTimer )
				m_nExpandTimer = SetTimer( 1000, EXPAND_TIMER, NULL );
		}
	}

	CTreeCtrl::OnMouseMove(nFlags, point);
}
Пример #4
0
LRESULT MFTreeView::OnKeydown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) {
	int x = 9;
	TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*)pnmh;

	if (pTVKeyDown->wVKey == VK_F2) {

		WTL::CTreeItem item = GetDropHilightItem();
		if (item.IsNull()) {
			item = GetSelectedItem();
		}
		MFTreeViewItem* pItem = (MFTreeViewItem*)item.GetData();
		if (pItem == NULL) 
			return 0;

		pItem->HandleMenuCmd(4 /*CMD_RENAME*/, item);		
	}
	return 0;
}
void EXTreeCtrl::Moveup()
{
    // Get Item
    HTREEITEM hItem = GetDropHilightItem();
    if(hItem)
        SelectItem(hItem);
    else
        hItem = GetSelectedItem();

    // Get previous item
    HTREEITEM hSibling = GetNextItem(hItem,TVGN_PREVIOUS);

    if(hSibling != NULL)
    {

        // Get previous to previous item
        HTREEITEM hNewItem=NULL;
        HTREEITEM hItemBefore = GetNextItem(hSibling,TVGN_PREVIOUS);

        if(hItemBefore != NULL)
        {
            // Insert before item
            hNewItem = CopyItem(hItem,GetParentItem(hItem),hItemBefore);

            // Don't delete item data
            SetItemData(hItem, NULL);
            DeleteItem(hItem);
            SelectItem(hNewItem);
        }
        else
        {
            // Insert at start
            hNewItem = CopyItem(hItem,GetParentItem(hItem),TVI_FIRST);

            // Don't delete item data
            SetItemData(hItem, NULL);
            DeleteItem(hItem);
            SelectItem(hNewItem);
        }

        if(hNewItem)
            RefreshSubItems(hNewItem);
    }
}
Пример #6
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  : nFlags -
//			point -
//-----------------------------------------------------------------------------
void CGroupList::OnMouseMove(UINT nFlags, CPoint point)
{
    CTreeCtrl::OnMouseMove(nFlags, point);

    if (m_bRButtonDown && !m_hDragItem && (point.x != m_ptRButtonDown.x) && (point.y != m_ptRButtonDown.y))
    {
        // First mouse move since a right button down. Start dragging.
        HTREEITEM hItem = HitTest(m_ptRButtonDown);
        BeginDrag(point, hItem);
    }

    if (!m_hDragItem)
    {
        return;
    }

    if (m_pDragImageList)
    {
        m_pDragImageList->DragMove(point);
    }

    //
    // Highlight the item we hit.
    //
    HTREEITEM hItem = HitTest(point);
    if (hItem == GetDropHilightItem())
    {
        return;
    }

    // hide image first
    if (m_pDragImageList)
    {
        m_pDragImageList->DragLeave(this);
        m_pDragImageList->DragShowNolock(FALSE);
    }

    SelectDropTarget(hItem);

    if (m_pDragImageList)
    {
        m_pDragImageList->DragEnter(this, point);
    }
}
Пример #7
0
COLORREF CSiteGroupsTree::GetGroupColor(const WebWatch::SiteItemGroup & group, COLORREF defColor)
{
    HTREEITEM item = GetItemFromGroup(group);
    HTREEITEM selected = GetSelectedItem();
    HTREEITEM dropTarget = GetDropHilightItem();
    
    if (item == selected || item == dropTarget)
        return defColor;

    COLORREF color = m_colors->regular.color;

    int muCount = WebWatch::Statistics::GetMUSiteCount(group, WebWatch::Statistics::recursiveCount);
    if (muCount > 0) {
        color = m_colors->mu.color;
    } else {
        int updatedCount = WebWatch::Statistics::GetSiteCountByState(group, WebWatch::SiteItem::updated, WebWatch::Statistics::deepCount);
        if (updatedCount > 0)
            color = m_colors->updated.color;
    }
    
    return color;
}
void EXTreeCtrl::Movedown()
{
    // Get Item
    HTREEITEM hItem = GetDropHilightItem();
    if(hItem)
        SelectItem(hItem);
    else
        hItem = GetSelectedItem();

    // Get next item
    HTREEITEM hNewItem=NULL;
    HTREEITEM hSibling = GetNextItem(hItem,TVGN_NEXT);

    if(hSibling != NULL)
    {
        // Insert before item
        hNewItem = CopyItem(hItem,GetParentItem(hItem),hSibling);

        // Don't delete item data
        SetItemData(hItem, NULL);
        DeleteItem(hItem);
        SelectItem(hNewItem);
    }
    else
    {
        // Insert at start
        hNewItem = CopyItem(hItem,GetParentItem(hItem),TVI_LAST);

        // Don't delete item data
        SetItemData(hItem, NULL);
        DeleteItem(hItem);
        SelectItem(hNewItem);
    }
    if(hNewItem)
        RefreshSubItems(hNewItem);
}
Пример #9
0
// the timer event for expanding nodes in drag n drop procedure
void CNZProjectTreeCtrl::OnTimer(UINT nIDEvent) 
{
	if( nIDEvent == m_nExpandTimer )
	{
		HTREEITEM htiFloat = GetDropHilightItem();
		if( htiFloat && htiFloat == m_htiDrop )
		{
			if( ItemHasChildren( htiFloat ) )
				Expand( htiFloat, TVE_EXPAND );
		}
	}
	else if( nIDEvent == m_nScrollTimer )
	{
		// Doesn't matter that we didn't initialize m_timerticks
		m_timerticks++;

		POINT pt;
		GetCursorPos( &pt );
		RECT rect;
		GetClientRect( &rect );
		ClientToScreen( &rect );

		// NOTE: Screen coordinate is being used because the call
		// to DragEnter had used the Desktop window.
		//CImageList::DragMove(pt);

		HTREEITEM hitem = GetFirstVisibleItem();

		if( pt.y < rect.top + 10 ) // scroll up
		{
			// Scroll slowly if cursor near the treeview control
			int slowscroll = 6 - (rect.top + 10 - pt.y) / 20;
			if( 0 == ( m_timerticks % (slowscroll > 0? slowscroll : 1) ) )
			{
				CImageList::DragShowNolock(FALSE);
				SendMessage( WM_VSCROLL, SB_LINEUP);
				SelectDropTarget(hitem);
				m_htiDrop = hitem;
				CImageList::DragShowNolock(TRUE);
			}
		}
		else if( pt.y > rect.bottom - 10 ) // scroll down
		{
			// Scroll slowly if cursor near the treeview control
			int slowscroll = 6 - (pt.y - rect.bottom + 10 ) / 20;
			if( 0 == ( m_timerticks % (slowscroll > 0? slowscroll : 1) ) )
			{
				CImageList::DragShowNolock(FALSE);
				SendMessage( WM_VSCROLL, SB_LINEDOWN);
				int nCount = GetVisibleCount();
				for ( int i=0; i<nCount-1; ++i )
					hitem = GetNextVisibleItem(hitem);
				if( hitem )
					SelectDropTarget(hitem);
				m_htiDrop = hitem;
				CImageList::DragShowNolock(TRUE);
			}
		}
	}

	CTreeCtrl::OnTimer(nIDEvent);
}