Exemple #1
0
void CCurve::Draw(HDC hDC, BOOL bShowSelection, BOOL bWantHandles)
{
	// A hack to compute the pen width based on the curve window width
	#define WIDTH 254

	if ( bShowSelection && Selected() )
		Pen.SetWidth(((2/*pixels*/ * nSCALE) + WIDTH/2) / WIDTH);
	else
		Pen.SetWidth(0);

	HPEN oldPen = Pen.SetInto(hDC);
	SplineLine(hDC);
	DrawHandles(hDC, bWantHandles);
	SelectObject(hDC, oldPen);	
}
Exemple #2
0
void CTrack::Draw(bool bOn, HDC hDC)
{
	if (!m_pAGDC)
		return;

	m_bIsDrawn = bOn;

	if (!hDC)
		hDC = m_pAGDC->GetHDC();

	CPoint pt[4];
	pt[0] = m_Distort.p[0];
	pt[1] = m_Distort.p[1];
	pt[2] = m_Distort.p[2];
	pt[3] = m_Distort.p[3];

	CAGMatrix Matrix = m_Matrix * m_ViewToDeviceMatrix;

	// A trick to draw the selection rectangle outside of a transformed object
	if (!(m_iWhatCanDo & TR_DRAWASLINE))
	{
		CRect Offset(-1, -1, 0, 0);
		Matrix.Inverse().Transform((CPoint*)&Offset, 2, false);

		pt[0].x += Offset.left;
		pt[0].y += Offset.top;
		pt[1].x += Offset.right;
		pt[1].y += Offset.top;
		pt[2].x += Offset.right;
		pt[2].y += Offset.bottom;
		pt[3].x += Offset.left;
		pt[3].y += Offset.bottom;
	}

	Matrix.Transform(pt[0]);
	Matrix.Transform(pt[1]);
	Matrix.Transform(pt[2]);
	Matrix.Transform(pt[3]);

	// Before drawing the transform border, open up the clipping to include a border pixel
	HRGN hClipRegion = m_pAGDC->SaveClipRegion();
	CRect rClipRect = m_PageRect;	
	rClipRect.InflateRect(1, 1); // Add a border pixel
	rClipRect.InflateRect(H_SIZE, H_SIZE); // Add the tracking handle size
	m_pAGDC->SetClipRect(rClipRect);

	if (m_iWhatCanDo & TR_DRAWASLINE)
	{
		DrawLine(hDC, pt[0].x, pt[0].y, pt[2].x, pt[2].y, bOn);
	}
	else
	{
		Hline(hDC, pt[0].x, pt[0].y, pt[1].x, pt[1].y, bOn);
		Hline(hDC, pt[1].x, pt[1].y, pt[2].x, pt[2].y, bOn);
		Hline(hDC, pt[2].x, pt[2].y, pt[3].x, pt[3].y, bOn);
		Hline(hDC, pt[3].x, pt[3].y, pt[0].x, pt[0].y, bOn);
	}

	DrawHandles(hDC, bOn, pt);

	m_pAGDC->RestoreClipRegion(hClipRegion);
}
Exemple #3
0
void CSelection::InvertSelection(HWND hWnd, HDC hDC, RECT* pRect, int fFlags)
{
	short OldROP;
	bool fNeedDC;
	RECT SelectRect;
	static RECT LastSelectRect;
	static int LastFlags;
	bool fDoc = false;
	int type;

	if (pRect->right - pRect->left > 50)
		int i = 0;

	if (fFlags && pRect)
	{ // Saved for the display hook
		LastSelectRect = *pRect;
		LastFlags = fFlags;
	}
	else
	{ // Called from the display hook
		fFlags = LastFlags;
	}

	type = fFlags & SL_TYPE;
	SelectRect = LastSelectRect;
	if (fDoc)
	{
//j		if (type == SL_LINE)
//j		{
//j			File2DisplayEx(hWnd, (LPINT)&SelectRect.left, (LPINT)&SelectRect.top, true);
//j			File2DisplayEx(hWnd, (LPINT)&SelectRect.right, (LPINT)&SelectRect.bottom, true);
//j		}
//j		else
//j		{
//j			OrderRect(&SelectRect, &SelectRect);
//j			File2DispRectExact(hWnd, &SelectRect, &SelectRect); 
//j		}
	}

	if (fNeedDC = (!hDC))
		hDC = GetDC(hWnd);

	switch (type)
	{
		case SL_BOX:
		{
			OldROP = SetROP2(hDC, R2_NOT);
			MoveToEx(hDC, SelectRect.left, SelectRect.top, NULL);
			LineTo(hDC, SelectRect.right, SelectRect.top);
			LineTo(hDC, SelectRect.right, SelectRect.bottom);
			LineTo(hDC, SelectRect.left, SelectRect.bottom);
			LineTo(hDC, SelectRect.left, SelectRect.top);
			SetROP2(hDC, OldROP);
			break;
		}

		case SL_BOXHANDLES:
		{
			OldROP = SetROP2(hDC, R2_NOT);
			MoveToEx(hDC, SelectRect.left, SelectRect.top, NULL);
			LineTo(hDC, SelectRect.right, SelectRect.top);
			LineTo(hDC, SelectRect.right, SelectRect.bottom);
			LineTo(hDC, SelectRect.left, SelectRect.bottom);
			LineTo(hDC, SelectRect.left, SelectRect.top);
			SetROP2(hDC, OldROP);
			DrawHandles(hDC, &SelectRect);
			break;
		}

	#ifdef NOTUSED //j
		case SL_GRID:
		{
			RECT ClientRect;
			int x, y, dx, dy, cx, cy;

			OldROP = SetROP2(hDC, R2_NOT);
			GetClientRect(hWnd, &ClientRect);
			dx = abs(RectWidth(&SelectRect));
			dy = abs(RectHeight(&SelectRect));
			if (dx > CLOSENESS && dy > CLOSENESS)
			{
				x = min(SelectRect.left, SelectRect.right);
				cx = x;
				Image2Control(&cx, &cy);
				while (cx >= ClientRect.left)
				{
					MoveToEx(hDC, cx, ClientRect.top, NULL);
					LineTo(hDC, cx, ClientRect.bottom);
					x -= dx;
					cx = x;
					Image2Control(&cx, &cy);
				}
				x = max(SelectRect.left, SelectRect.right);
				cx = x;
				Image2Control(&cx, &cy);
				while (cx <= ClientRect.right)
				{
					MoveToEx(hDC, cx, ClientRect.top, NULL);
					LineTo(hDC, cx, ClientRect.bottom);
					x += dx;
					cx = x;
					Image2Control(&cx, &cy);
				}
				y = min(SelectRect.top, SelectRect.bottom);
				cy = y;
				Image2Control(&cx, &cy);
				while (cy >= ClientRect.top)
				{
					MoveToEx(hDC, ClientRect.left, cy, NULL);
					LineTo(hDC, ClientRect.right, cy);
					y -= dy;
					cy = y;
					Image2Control(&cx, &cy);
				}
				y = max(SelectRect.top, SelectRect.bottom);
				cy = y;
				Image2Control(&cx, &cy);
				while (cy <= ClientRect.bottom)
				{
					MoveToEx(hDC, ClientRect.left, cy, NULL);
					LineTo(hDC, ClientRect.right, cy);
					y += dy;
					cy = y;
					Image2Control(&cx, &cy);
				}
			}
			else
			{
				Image2Control((LPINT)&SelectRect.left, (LPINT)&SelectRect.top);
				Image2Control((LPINT)&SelectRect.right, (LPINT)&SelectRect.bottom);
				MoveToEx(hDC, SelectRect.left, SelectRect.top, NULL);
				LineTo(hDC, SelectRect.right, SelectRect.top);
				LineTo(hDC, SelectRect.right, SelectRect.bottom);
				LineTo(hDC, SelectRect.left, SelectRect.bottom);
				LineTo(hDC, SelectRect.left, SelectRect.top);
			}
			SetROP2(hDC, OldROP);
			break;
		}
	#endif NOTUSED //j

		case SL_LINE:
		{
			OldROP = SetROP2(hDC, R2_NOT);
			MoveToEx(hDC, SelectRect.left, SelectRect.top, NULL);
			LineTo(hDC, SelectRect.right, SelectRect.bottom);
			SetROP2(hDC, OldROP);
			break;
		}

		case SL_ELLIPSE:
		{
			OldROP = SetROP2(hDC, R2_NOT);
			HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
			Ellipse(hDC, SelectRect.left, SelectRect.top,
				SelectRect.right, SelectRect.bottom);
			SetROP2(hDC, OldROP);
			SelectObject(hDC, hOldBrush);
			break;
		}

		case SL_BLOCK:
		{
			PatBlt(hDC, SelectRect.left, SelectRect.top,
				SelectRect.right - SelectRect.left,
				SelectRect.bottom - SelectRect.top, DSTINVERT);
			break;
		}
	}

	if (fNeedDC)
		ReleaseDC(hWnd, hDC);
}