void CSketcherView::OnMouseMove(UINT nFlags, CPoint point) { // Define a Device Context object for the view CClientDC aDC(this); // DC is for this view OnPrepareDC(&aDC); // Get origin adjusted aDC.DPtoLP(&point); // convert point to logical coordinates // If we are in move mode, move the selected element and return if(m_MoveMode) { MoveElement(aDC, point); // Move the element return; } if((nFlags & MK_LBUTTON) && (this == GetCapture())) { m_SecondPoint = point; // Save the current cursor position if(m_pTempElement) { if(CURVE == GetDocument()->GetElementType()) // Is it a curve? { // We are drawing a curve so add a segment to the existing curve static_cast<CCurve*>(m_pTempElement)->AddSegment(new CPoint(m_SecondPoint)); m_pTempElement->Draw(&aDC); // Now draw it return; // We are done } // If we get to here it's not a curve so // redraw the old element so it disappears from the view aDC.SetROP2(R2_NOTXORPEN); // Set the drawing mode m_pTempElement->Draw(&aDC); // Redraw the old element delete m_pTempElement; // Delete the old element m_pTempElement = 0; // Reset the pointer to 0 } // Create a temporary element of the type and color that // is recorded in the document object, and draw it m_pTempElement = CreateElement(); // Create a new element m_pTempElement->Draw(&aDC); // Draw the element } else { // We are not creating an element so do highlighting CSketcherDoc* pDoc=GetDocument(); // Get a pointer to the document CElement* pOldSelected(m_pSelected); m_pSelected = pDoc->FindElement(point); // Set selected element if(m_pSelected != pOldSelected) { if(m_pSelected) InvalidateRect(m_pSelected->GetBoundRect(), FALSE); if(pOldSelected) InvalidateRect(pOldSelected->GetBoundRect(), FALSE); pDoc->UpdateAllViews(0); } } }
void CSketcherView::OnRButtonDown(UINT nFlags, CPoint point) { if(m_MoveMode) { // In moving mode, so drop element back in original position CClientDC aDC(this); OnPrepareDC(&aDC); // Get origin adjusted MoveElement(aDC, m_FirstPos); // Move element to original position m_pSelected = nullptr; // De-select element GetDocument()->UpdateAllViews(nullptr); // Redraw all the views } }
void CSketcherView::OnRButtonDown(UINT nFlags, CPoint point) { if(m_MoveMode) { // In moving mode, so drop element back in original position CClientDC aDC(this); OnPrepareDC(&aDC); // Get origin adjusted MoveElement(aDC, m_FirstPos); // Move element to orig position m_MoveMode = FALSE; // Kill move mode m_pSelected = 0; // De-select element GetDocument()->UpdateAllViews(0); // Redraw all the views return; // We are done } //CScrollView::OnRButtonDown(nFlags, point); }
// MW-2014-06-12: [[ Bug 12628 ]] Use Remote operation to copy the root out of the new document. bool CXMLElement::MoveRemoteElement(CXMLElement *p_element, bool p_sibling, bool p_before) { // DOMWrapAdoptNode only allows you to move a node to under a parent, so first // we compute the parent node. In non-sibling mode, this is the parent node. In sibling // mode the parent of this is the parent node. xmlNodePtr t_parent; t_parent = element; if (p_sibling) t_parent = t_parent -> parent; // If this has no parent then badness. if (t_parent == NULL) return false; // Now make our doc tree adopt the source node. if (xmlDOMWrapAdoptNode(NULL, p_element -> element -> doc, p_element -> element, element -> doc, t_parent, 0) != 0) return false; // Now that p_element is in this's xmlTree we can use MoveElement to place it appropriately. return MoveElement(p_element, p_sibling, p_before); }
void CSketcherView::OnMouseMove(UINT nFlags, CPoint point) { // Define a Device Context object for the view CClientDC aDC(this); // DC is for this view OnPrepareDC(&aDC); // Get origin adjusted // If we are in move mode, move the selected element and return if(m_MoveMode) { aDC.DPtoLP(&point); // Convert to logical coordinatess MoveElement(aDC, point); // Move the element return; } aDC.SetROP2(R2_NOTXORPEN); // Set the drawing mode if((nFlags&MK_LBUTTON) && (this==GetCapture())) { aDC.DPtoLP(&point); // convert point to Logical m_SecondPoint = point; // Save the current cursor position if(m_pTempElement) { if(CURVE == GetDocument()->GetElementType()) // Is it a curve? { // We are drawing a curve // so add a segment to the existing curve static_cast<CCurve*>(m_pTempElement)->AddSegment(m_SecondPoint); m_pTempElement->Draw(&aDC); // Now draw it return; // We are done } aDC.SetROP2(R2_NOTXORPEN); // Set drawing mode // Redraw the old element so it disappears from the view m_pTempElement->Draw(&aDC); delete m_pTempElement; // Delete the old element m_pTempElement = 0; // Reset the pointer to 0 } // Create a temporary element of the type and color that // is recorded in the document object, and draw it m_pTempElement = CreateElement(); // Create a new element m_pTempElement->Draw(&aDC); // Draw the element } else { // We are not drawing an element so do highlighting... CSketcherDoc* pDoc=GetDocument(); // Get a pointer to the document CElement* pElement = 0; // Store an element pointer CRect aRect(0,0,0,0); // Store a rectangle POSITION aPos = pDoc->GetListHeadPosition(); // Get first element posn CElement* pOldSelection = m_pSelected; // Save old selected element m_pSelected = 0; while(aPos) // Iterate through the list { pElement = pDoc->GetNext(aPos); aRect = pElement->GetBoundRect(); aDC.LPtoDP(aRect); aRect.NormalizeRect(); // Select the first element that appears under the cursor if(aRect.PtInRect(point)) { m_pSelected = pElement; break; } } if(m_pSelected == pOldSelection) // If new selection is same as old return; // we are done // Unhighlight old selection if there is one if(pOldSelection != 0) // Verify there is one { aRect = pOldSelection->GetBoundRect(); aDC.LPtoDP(aRect); // Convert to device coords aRect.NormalizeRect(); // Normalize InvalidateRect(aRect, FALSE); // Invalidate area } // Highlight new selection if there is one if(m_pSelected != 0) // Verify there is one { aRect = m_pSelected->GetBoundRect(); aDC.LPtoDP(aRect); // Convert to device coords aRect.NormalizeRect(); // Normalize InvalidateRect(aRect, FALSE); // Invalidate area } } }