Exemplo n.º 1
0
void CDialog::OnPaint(CDC& rDC)
{
	// Not resizable OR size grip disabled?
	if (m_vGravities.empty() || m_bNoSizeGrip)
		return;

	// Get window dimensions.
	CRect rcClient = ClientRect();

	// Get bottom right co-ordinates.
	CPoint ptCorner(rcClient.right-1, rcClient.bottom-1);

	// Create pens.
	CPen oDarkPen (PS_SOLID, 0, ::GetSysColor(COLOR_BTNSHADOW));
	CPen oLightPen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNHIGHLIGHT));
	CPen oFacePen (PS_SOLID, 0, ::GetSysColor(COLOR_BTNFACE));

	// For all lines.
	for (int i = 0; i < 12; ++i)
	{
		// Select the required pen.
		if ((i % 4) == 3)
			rDC.Select(oLightPen);
		else if ( ((i % 4) == 1) || ((i % 4) == 2) )
			rDC.Select(oDarkPen);
		else
			rDC.Select(oFacePen);

		// Draw the line.
		rDC.Line(ptCorner.x-i-1, ptCorner.y, ptCorner.x, ptCorner.y-i-1);
	}

	// Save grip position for later.
	m_rcOldGrip = CRect(CPoint(ptCorner.x-12, ptCorner.y-12), CSize(13, 13));

#ifdef _DEBUG
	// Passify BoundsChecker.
	rDC.Select(CPen(NULL_PEN));
#endif
}
Exemplo n.º 2
0
void CSpiroView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if (m_bMovingPencil)
	{
		CImageList& il = GetApp()->m_imageList;
		il.DragLeave(this);
		il.EndDrag();
		::ShowCursor(TRUE);

		ENSURE(m_pWheel != NULL);
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);
		OnPrepareDC(pDC);

		// undo the effect of the zoom factor on the point value
		pDC->DPtoLP(&point);
		point.x = point.x * m_nZoomDenom / m_nZoomNumer;
		point.y = point.y * m_nZoomDenom / m_nZoomNumer;
		if (m_pWheel->SetPenLocation(this, pDC, point, m_nZoomNumer, m_nZoomDenom))
		{
			GetDocument()->TransferCurrentFigure();
			CreateFigure();  // create figure for the new pen location
		}

		ReleaseDC(pDC);
		ReleaseCapture();
		m_bMovingPencil = false;
	}
	else if (m_pFigureDrag != NULL)
	{
		ENSURE(m_pILDragFigure != NULL);

		CPoint ptWindow(point);
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);

		// get new position for the figure being drawn and insert it into figure arrays
		
		CPoint	ptCorner(point.x - m_ptHotSpotDragFigure.x, point.y - m_ptHotSpotDragFigure.y);
		OnPrepareDC(pDC);
		pDC->DPtoLP(&ptCorner);   // convert corner of figure to logical coords

		ptCorner.x = ptCorner.x * m_nZoomDenom / m_nZoomNumer;  // undo effect of zooming
		ptCorner.y = ptCorner.y * m_nZoomDenom / m_nZoomNumer;


		if (m_pFigureDrag->MoveFigure(ptCorner, GetDocument()))   // move figure to new place
		{
			CSpiroRect	rect;
			m_pFigureDrag->GetBoundingRect(&rect);
			rect.Scale(m_nZoomNumer, m_nZoomDenom);
			pDC->LPtoDP(&rect);
			InvalidateRect(&rect);
			ReleaseDC(pDC);
		}

 		m_pILDragFigure->DragLeave(this);
		m_pILDragFigure->EndDrag();
 		UpdateWindow();
		delete m_pILDragFigure;  
		delete m_pBitmapDragFigure;   
		m_pBitmapDragFigure = NULL;
		m_pILDragFigure = NULL;

		ReleaseCapture();
		m_pFigureDrag = NULL;
	}

	CScrollView::OnLButtonUp(nFlags, point);
}