Exemplo n.º 1
0
void CSketcherView::OnElementDelete()
{
	if(m_pSelected)
	{
		CSketcherDoc* pDoc = GetDocument();// Get the document pointer
		pDoc->DeleteElement(m_pSelected); // Delete the element
		pDoc->UpdateAllViews(nullptr); // Redraw all the views
		m_pSelected = nullptr; // Reset selected element ptr
	}
}
Exemplo n.º 2
0
void CSketcherView::OnLButtonDown(UINT nFlags, CPoint point)
{
	
	CClientDC aDC(this); // Create a device context
	OnPrepareDC(&aDC); // Get origin adjusted
	aDC.DPtoLP(&point); // Convert point to logical coordinatesm_FirstPoint = point; // Record the cursor position
	
	if(m_MoveMode)
	{
		// In moving mode, so drop the element
		m_MoveMode = false; // Kill move mode
		m_pSelected = nullptr; // De-select the element
		GetDocument()->UpdateAllViews(0); // Redraw all the views
		GetDocument()->SetModifiedFlag();
		return;
	}
	
	CSketcherDoc* pDoc = GetDocument();// Get a document pointer
	if(pDoc->GetElementType() == TEXT)
	{
		CTextDialog aDlg;
		if(aDlg.DoModal() == IDOK)
		{
			// Exit OK so create a text element
			CSize textExtent = aDC.GetTextExtent(aDlg.m_TextString);
			CRect rect(point, textExtent); //Create enclosing rectangle
			CText* pTextElement = new CText(
			aDlg.m_TextString, rect, pDoc->GetElementColor());
			// Add the element to the document
			pDoc->AddElement(pTextElement);
			// Get all views updated
			pDoc->UpdateAllViews(nullptr, 0, pTextElement);
		}
		return;
	}


	m_FirstPoint = point; // Record the cursor position
	SetCapture(); // Capture subsequent mouse messages

}