Example #1
0
IDropTarget::Pointer DragUtil::GetDropTarget(void* toSearch,
    Object::Pointer draggedObject, const Point& position,
    const Rectangle& dragRectangle)
{
  // Search for a listener by walking the control's parent hierarchy
  for (void* current = toSearch; current != 0; current = Tweaklets::Get(
      GuiWidgetsTweaklet::KEY)->GetParent(current))
  {
    TargetListType::Pointer targetList = GetTargetList(current);
    std::list<IDragOverListener::Pointer> targets;
    if (targetList != 0)
      targets.assign(targetList->begin(), targetList->end());

    IDropTarget::Pointer dropTarget = GetDropTarget(targets, toSearch,
        draggedObject, position, dragRectangle);

    if (dropTarget != 0)
    {
      return dropTarget;
    }

    //          // Don't look to parent shells for drop targets
    //          if (current instanceof Shell) {
    //              break;
    //          }
  }

  // No controls could handle this event -- check for default targets
  return GetDropTarget(defaultTargets, toSearch, draggedObject, position,
      dragRectangle);
}
wxJigsawShape *wxJigsawEditorCanvas::GetDragShape() const
{
	if(GetDropTarget() && GetDropTarget()->GetDataObject())
	{
		DnDJigsawShapeDataObject *pData = (DnDJigsawShapeDataObject *)GetDropTarget()->GetDataObject();
		if(pData && pData->ReadShapeInfo())
		{
			return pData->ReadShapeInfo()->m_shape;
		}
	}

	return NULL;
}
Example #3
0
void CGroupEditTree::OnMouseMove(UINT nFlags, CPoint point) 
{
	HTREEITEM hitem;
	UINT flags;

	if (m_bDragging)
	{
		POINT pt = point;
		ClientToScreen(&pt);
		CImageList::DragMove(pt);
		if ((hitem = HitTest(point, &flags)) != NULL)
		{
			CImageList::DragShowNolock(FALSE);
			m_hitemDrop = GetDropTarget(hitem);
			SelectDropTarget(m_hitemDrop);
			CImageList::DragShowNolock(TRUE);
		}
		else
			m_hitemDrop = NULL;

		if (m_hitemDrop)
			SetCursor(m_dropCursor);
		else
			SetCursor(m_noDropCursor);
	}

	CTreeCtrl::OnMouseMove(nFlags, point);
}
Example #4
0
void CLTWinTreeMgr::OnMouseMove(UINT nFlags, CPoint pt)
{
	CTreeCtrl::OnMouseMove(nFlags, pt);

	//make sure we are in a drag operation
	if(!IsInDrag())
	{
		return;
	}


	//hilite the drop target if one exists
	CLTWinTreeItem* pHit = GetDropTarget(pt);

	if(pHit)
	{
		//this is a valid drop target, so make it look like one
		SelectDropTarget(pHit->m_hTreeItem);
	}

	//move the drag image
	if(m_pDragImage)
	{
		m_pDragImage->DragMove(pt);
	}


}
void CEditTreeCtrl::DragMove() {
	ASSERT(m_pDragData != 0);
	TRACE1(_T("CEditTreeCtrl::DragMove('%s')\n"), LPCTSTR(GetItemText(m_pDragData->GetDragItem())));

	EDropHint eHint;
	HTREEITEM hDrop = GetDropTarget(eHint);
	SetDragCursor(hDrop, eHint);
}
Example #6
0
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
{
    HRESULT hr=::RegisterDragDrop(m_hWnd,GetDropTarget());

    m_imgMergerHandler.OnInit(this);
    m_codeLineCounter.OnInit(this);
    m_2UnicodeHandler.OnInit(this);
    m_folderScanHandler.OnInit(this);
    m_calcMd5Handler.OnInit(this);
	return 0;
}
Example #7
0
void CLTWinTreeMgr::OnLButtonUp(UINT nFlags, CPoint pt)
{
	CTreeCtrl::OnLButtonUp(nFlags, pt);

	//make sure we are in a drag operation
	if(!IsInDrag())
	{
		return;
	}

	//see if we have a place to drop it
	CLTWinTreeItem* pHit = GetDropTarget(pt);

	if(pHit)
	{
		//we are moving it, so lets make the move

		//first erase the old tree
		CTreeCtrl::DeleteItem(m_pDragItem->m_hTreeItem);

		//unlink the item
		UnlinkFromSiblings(m_pDragItem);

		//now build the new tree  recursively
		RebuildDraggedTree(m_pDragItem, pHit);

		//select the moved item
		CTreeCtrl::SelectItem(m_pDragItem->m_hTreeItem);
	}

	//clear the drop target
	SelectDropTarget(NULL);

	//clean up the drag stuff
	m_bDragging		= FALSE;
	m_pDragItem		= NULL;

	//clean up the image list
	if(m_pDragImage)
	{
		m_pDragImage->EndDrag();
		delete m_pDragImage;
		m_pDragImage	= NULL;
	}

	//clean up the cursor
	ReleaseCapture();


}
Example #8
0
void CTreeFileCtrl::OnMouseMove(UINT nFlags, CPoint point) 
{
	if (IsDragging())
  {
    CRect clientRect;
    GetClientRect(&clientRect);

    //Draw the drag
    POINT pt = point;
    ClientToScreen(&pt);
    CImageList::DragMove(pt);

    //Only select the drop item if we are in the client area
    HTREEITEM hItem = NULL;
    if (clientRect.PtInRect(point))
    {
      UINT flags;
      hItem = HitTest(point, &flags);
      if (m_hItemDrop != hItem)
      {
        CImageList::DragShowNolock(FALSE);
        SelectDropTarget(hItem);
        m_hItemDrop = hItem;
        CImageList::DragShowNolock(TRUE);
      }
    }
    
    if (hItem)
      hItem = GetDropTarget(hItem);

    //Change the cursor to give feedback
    if (hItem)
    {
      if ((GetKeyState(VK_CONTROL) & 0x8000))
        SetCursor(m_DropCopyCursor);
      else
        SetCursor(m_DropMoveCursor);
    }
    else
    {
      if ((GetKeyState(VK_CONTROL) & 0x8000))
        SetCursor(m_NoDropCopyCursor);
      else
        SetCursor(m_NoDropMoveCursor);
    }
  }

  //Let the parent class do its thing	
	CTreeCtrl::OnMouseMove(nFlags, point);
}
Example #9
0
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
{
	m_bLayoutInited = TRUE;
	shellNotifyIcon.Create(m_hWnd,GETRESPROVIDER->LoadIcon(_T("ICON_LOGO"),16));
	shellNotifyIcon.Show();
	//InitListCtrl();

	//拖拽功能
	SWindow *pListBox = FindChildByName(L"music_lbe");
	if(pListBox)
	{
		HRESULT hr=::RegisterDragDrop(m_hWnd,GetDropTarget());
		CTestDropTarget1 *pDrop=new CTestDropTarget1(pListBox);
		RegisterDragDrop(pListBox->GetSwnd(),pDrop);
		pDrop->GetDragData(GetAudioAllPath,this);
	}
    
	//初始化音频操作类
	m_pMuOPreat=new CMusicOpreat(m_hWnd);
	m_pMuOPreat->InitDatas();

	//找到列表控件
	SScrollLrc *pTreeBox=FindChildByName2<SScrollLrc>(L"music_lrc");
	if(pTreeBox)
	{
		SStringW m_sTemp;
		STreeItem *pItem;
		HSTREEITEM rootItem;

		for (int i=0;i<20;i++)
		{
			m_sTemp.Format(L"<item><text pos=\"10,0,-5,-0\" name=\"数据_%d\" valign=\"middle\" align=\"left\" colorText=\"#ff0000\" align=\"center\" font=\"face:微软雅黑,adding:5\">%s</text></item>",i,szLrc[i]);
			//m_sTemp=_T(,strTemp); 
			pItem=pTreeBox->InsertItem((LPCWSTR )m_sTemp,(DWORD)rootItem,STVI_ROOT,STVI_LAST,FALSE);
			m_TreItemInfo.insert(std::make_pair(i,pItem));
		}
		pTreeBox->GetSetLrcFun(SetLrcStyle,this);
		pTreeBox->StarsRollLrc();
	}

	return 0;
}
void CEditTreeCtrl::DragEnd() {
	ASSERT(m_pDragData != 0);
	TRACE1(_T("CEditTreeCtrl::DragEnd('%s')\n"), LPCTSTR(GetItemText(m_pDragData->GetDragItem())));

	EDropHint eHint;
	HTREEITEM hDrop = GetDropTarget(eHint);

	if(m_pDragData->IsRightDragging()) {
		if(eHint == DROP_NODROP)
			DragStop();
		else {
			CPoint point;
			GetCursorPos(&point);
			DragDisplayContextMenu(point);
		}
	} else {
		bool bCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
		DragMoveItem(m_pDragData->GetDragItem(), hDrop, eHint, bCtrl);
		DragStop();
	}
}
Example #11
0
void CTreeFileCtrl::EndDragging(BOOL bCancel)
{
  if (IsDragging())
  {
    KillTimer(m_nTimerID);

    CImageList::DragLeave(this);
    CImageList::EndDrag();
    ReleaseCapture();

    delete m_pilDrag;
    m_pilDrag = NULL;

    //Remove drop target highlighting
    SelectDropTarget(NULL);

    m_hItemDrop = GetDropTarget(m_hItemDrop);
    if (m_hItemDrop == NULL)
      return;

    if (!bCancel)
    {
      //Also need to make the change on disk
      CString sFromPath = ItemToPath(m_hItemDrag);
      CString sToPath = ItemToPath(m_hItemDrop);

      int nFromLength = sFromPath.GetLength();
      int nToLength = sToPath.GetLength();
      SHFILEOPSTRUCT shfo;
      ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
      shfo.hwnd = GetSafeHwnd();

      if ((GetKeyState(VK_CONTROL) & 0x8000))
        shfo.wFunc = FO_COPY;
      else
        shfo.wFunc = FO_MOVE;

      shfo.fFlags = FOF_SILENT | FOF_NOCONFIRMMKDIR;
      //Undo is not allowed if the SHIFT key is held down
      if (!(GetKeyState(VK_SHIFT) & 0x8000))
        shfo.fFlags |= FOF_ALLOWUNDO;

      TCHAR* pszFrom = new TCHAR[nFromLength + 2];
      _tcscpy(pszFrom, sFromPath);
      pszFrom[nFromLength+1] = _T('\0');
      shfo.pFrom = pszFrom;

      TCHAR* pszTo = new TCHAR[nToLength + 2];
      _tcscpy(pszTo, sToPath);
      pszTo[nToLength+1] = _T('\0');
      shfo.pTo = pszTo;

      //Let the shell perform the actual deletion
      BOOL bSuccess = ((SHFileOperation(&shfo) == 0) && (shfo.fAnyOperationsAborted == FALSE));

      //Free up the memory we had allocated
      delete [] pszFrom;
      delete [] pszTo;

      if (bSuccess)
      {
        //Only copy the item in the tree if there is not an item with the same
        //text under m_hItemDrop
        CString sText = GetItemText(m_hItemDrag);
        if (!HasChildWithText(m_hItemDrop, sText))
        {
          //Do the actual copy
          BOOL bHadChildren = (GetChildItem(m_hItemDrop) != NULL);
          CopyBranch(m_hItemDrag, m_hItemDrop);

          //Update the children indicator for the folder we just dropped into
          if (!bHadChildren)
          {
            TV_ITEM tvItem;
            tvItem.hItem = m_hItemDrop;
            tvItem.mask = TVIF_CHILDREN;  
            tvItem.cChildren = 1;
            SetItem(&tvItem);
          }
        }

        BOOL bExpanded = (GetChildItem(m_hItemDrop) != NULL); 
        if (shfo.wFunc == FO_MOVE)
        {
          //Get the parent of the item we moved prior to deleting it
          HTREEITEM hParent = GetParentItem(m_hItemDrag);

          //Delete the item we just moved
          DeleteItem(m_hItemDrag);

          //Update the children indicator for the item we just dragged from
          BOOL bHasChildren = (GetChildItem(hParent) != NULL);
          if (hParent && !bHasChildren)
          {
            TV_ITEM tvItem;
            tvItem.hItem = hParent;
            tvItem.mask = TVIF_CHILDREN;  
            tvItem.cChildren = 0;
            SetItem(&tvItem);
          }
        }
        SetSelectedPath(sToPath, bExpanded);
      }
    }
  }
}
Example #12
0
IDropTarget::Pointer DragUtil::DragToTarget(Object::Pointer draggedItem,
    const Rectangle& sourceBounds, const Point& initialLocation,
    bool allowSnapping)
{
  //final Display display = Display.getCurrent();

  // Testing...immediately 'drop' onto the test target
  if (forcedDropTarget != 0)
  {
    Point location = forcedDropTarget->GetLocation();

    void* currentControl =
        Tweaklets::Get(GuiWidgetsTweaklet::KEY)->FindControl(
            forcedDropTarget->GetShells(), location);
    return GetDropTarget(currentControl, draggedItem, location, sourceBounds);
  }

  // Create a tracker.  This is just an XOR rect on the screen.
  // As it moves we notify the drag listeners.
  ITracker* tracker = Tweaklets::Get(DnDTweaklet::KEY)->CreateTracker();
  //tracker.setStippled(true);

  GuiTk::IControlListener::Pointer trackerListener(new TrackerMoveListener(
      draggedItem, sourceBounds, initialLocation, allowSnapping));

  tracker->AddControlListener(trackerListener);

  // Setup...when the drag starts we might already be over a valid target, check this...
  // If there is a 'global' target then skip the check
  IDropTarget::Pointer target;
  void* startControl =
      Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();

  if (startControl != 0 && allowSnapping)
  {
    target = GetDropTarget(startControl, draggedItem, initialLocation,
        sourceBounds);
  }

  // Set up an initial tracker rectangle
  Rectangle startRect = sourceBounds;
  if (target != 0)
  {
    Rectangle rect = target->GetSnapRectangle();

    if (rect.width != 0 && rect.height != 0)
    {
      startRect = rect;
    }

    tracker->SetCursor(target->GetCursor());
  }

  if (startRect.width != 0 && startRect.height != 0)
  {
    tracker->SetRectangle(startRect);
  }

  // Tracking Loop...tracking is preformed on the 'SWT.Move' listener registered
  // against the tracker.

  //  // HACK:
  //  // Some control needs to capture the mouse during the drag or other
  //  // controls will interfere with the cursor
  //  Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
  //  if (shell != null)
  //  {
  //    shell.setCapture(true);
  //  }

  // Run tracker until mouse up occurs or escape key pressed.
  bool trackingOk = tracker->Open();

  //  // HACK:
  //  // Release the mouse now
  //  if (shell != null)
  //  {
  //    shell.setCapture(false);
  //  }

  // Done tracking...

  // Get the current drop target
  IDropTarget::Pointer dropTarget;
  Point finalLocation =
      Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorLocation();
  void* targetControl =
      Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
  dropTarget = GetDropTarget(targetControl, draggedItem, finalLocation,
      tracker->GetRectangle());

  // Cleanup...
  delete tracker;

  // if we're going to perform a 'drop' then delay the issuing of the 'finished'
  // callback until after it's done...
  if (trackingOk)
  {
    return dropTarget;
  }
  else if (dropTarget != 0)
  {
    // If the target can handle a 'finished' notification then send one
    dropTarget->DragFinished(false);
  }

  return IDropTarget::Pointer(0);
}