Пример #1
0
void ScreenDev::lineTo( long x2, long y2 )
//----------------------------------------
{
    REQUIRE( _window != NULL, "accessing unopened output device" );
    REQUIRE( _pinf != NULL, "paint info not set" );

    long x1 = _currx;
    long y1 = _curry;

    if( ClipToRect( x1, y1, x2, y2, _clipRect ) ) {
        WPoint p1( (int) x1, (int) y1 );
        WPoint p2( (int) x2, (int) y2 );
        _window->drawLine( p1, p2, _pinf->getStyle(),
                           _pinf->getThickness(), _pinf->getColour() );
    }
}
Пример #2
0
void CPuzzle::DrawPiece(int i,
						HDC hDC,
						PDIB pDibOut,
						LPPOINT ptDib,
						LPRECT lpPaint,
						BOOL fDrawGrid,
						LPPOINT ptPiece)
/***********************************************************************/
{
	int sx, sy, iSrcCol, iSrcRow, dx, dy, iDstCol, iDstRow, iPiece;
	int iColWidth, iRowHeight;
	RECT rDst, rSrc, rSect, rFrame, rClient;

	iColWidth = m_pDib->GetWidth() / m_iCols;
	iRowHeight = m_pDib->GetHeight() / m_iRows;

	iPiece = m_iMap[i];
	iSrcCol = iPiece % m_iCols;
	iSrcRow = iPiece / m_iCols;
	sx = iSrcCol * iColWidth;
	sy = iSrcRow * iRowHeight;
	iDstCol = i % m_iCols;
	iDstRow = i / m_iCols;
	if (ptPiece)
	{
		dx = ptPiece->x;
		dy = ptPiece->y;
	}
	else
	{
		dx = iDstCol * iColWidth;
		dy = iDstRow * iRowHeight;
	}

	SetRect(&rDst, dx, dy, dx+iColWidth, dy+iRowHeight);
	SetRect(&rSrc, sx, sy, sx+iColWidth, sy+iRowHeight);

	if (!IntersectRect(&rSect, &rDst, lpPaint))
		return;

	rFrame = rDst;
	rFrame.left -= 1;
	rFrame.top -= 1;
	GetClientRect(m_hWnd, &rClient);
	if (abs(rFrame.right-rClient.right) < 5)
		rFrame.right = rClient.right+1;
	if (abs(rFrame.bottom-rClient.bottom) < 5)
		rFrame.bottom = rClient.bottom+1;
   	OffsetRect(&rFrame, ptDib->x, ptDib->y);

	if (m_iSelect == i && (ptPiece == NULL))
	{
		OffsetRect(&rSect, ptDib->x, ptDib->y);
		FillRect(hDC, &rSect, (HBRUSH)GetStockObject(GRAY_BRUSH));
	}
	else
	{
		ClipToRect(&rSect, &rDst, &rSrc);
		if (pDibOut)
		{
			OffsetRect(&rDst, ptDib->x, ptDib->y);
			m_pDib->DibBlt(pDibOut,
   				rDst.left, rDst.top, rDst.right-rDst.left, rDst.bottom-rDst.top,
   				rSrc.left, rSrc.top, rSrc.right-rSrc.left, rSrc.bottom-rSrc.top,
				NO);
		}
		else
		{
			m_pDib->DCBlt(hDC,
   				rDst.left, rDst.top, rDst.right-rDst.left, rDst.bottom-rDst.top,
   				rSrc.left, rSrc.top, rSrc.right-rSrc.left, rSrc.bottom-rSrc.top);
		}
	}
	if (fDrawGrid)
		FrameRect(hDC, &rFrame, (HBRUSH)GetStockObject(BLACK_BRUSH));
}