Exemplo n.º 1
0
void CBigScrollView::FillOutsideRect(wxDC* pDC, wxBrush* pBrush)
{
	wxRect rectClient;
	GetClientRect(&rectClient);

	// if client area is larger than total device size
	wxPoint pointOrg = GetDeviceOrg();
	if (pointOrg == wxPoint(0, 0)) return;
	
	pDC->SaveDC();

	// draw the document background
	wxRect rectDoc(pointOrg, m_totalDev);
	pDC->FillRect(rectDoc, pBrush);

	// draw the client area
	wxRect draw;
	//wxBrush SideBrush(::GetSysColor(COLOR_APPWORKSPACE));
	wxBrush SideBrush(RGB(192,192,192));
	draw.SetRect(rectClient.left, rectClient.top, rectDoc.left, rectClient.bottom);
	if (!draw.IsRectEmpty()) pDC->FillRect(draw, &SideBrush);
	draw.SetRect(rectDoc.right, rectClient.top, rectClient.right, rectClient.bottom);
	if (!draw.IsRectEmpty()) pDC->FillRect(draw, &SideBrush);
	draw.SetRect(rectClient.left, rectClient.top, rectClient.right, rectDoc.top);
	if (!draw.IsRectEmpty()) pDC->FillRect(draw, &SideBrush);
	draw.SetRect(rectClient.left, rectDoc.bottom, rectClient.right, rectClient.bottom);
	if (!draw.IsRectEmpty()) pDC->FillRect(draw, &SideBrush);

	// draw the document frame (from ViewScrl.cpp)
	CPen rectPen, shadowPen;
	rectPen.CreatePen(PS_SOLID, 2, ::GetSysColor(COLOR_WINDOWFRAME));
	shadowPen.CreatePen(PS_SOLID, 3, ::GetSysColor(COLOR_BTNSHADOW));

	pDC->SelectStockObject(HOLLOW_BRUSH);
	pDC->SelectObject(&rectPen);
	rectDoc.InflateRect(1, 1, 2, 2);
	pDC->Rectangle(rectDoc);
    
	pDC->SelectObject(&shadowPen);
	pDC->MoveTo(rectDoc.right + 1, rectDoc.top    + 2);
	pDC->LineTo(rectDoc.right + 1, rectDoc.bottom + 1);
	pDC->MoveTo(rectDoc.left  + 2, rectDoc.bottom + 1);
	pDC->LineTo(rectDoc.right + 1, rectDoc.bottom + 1);

	rectPen.DeleteObject();
	shadowPen.DeleteObject();

	pDC->RestoreDC(-1);
}
Exemplo n.º 2
0
void CSpiroView::OnDraw(CDC* pDC)
{
	ENSURE(pDC != NULL);
	
	CPaintDC*	pDCPaint;
	int			nWidthClip(0);  // Initialize to avoid compiler warnings.
	int			nHeightClip(0);  // Initialize to avoid compiler warnings.
	CRect		rectClip;
	CSpiroRect	rectLogClip;
	
	if (!pDC->IsPrinting())
	{
		ASSERT(pDC->IsKindOf(RUNTIME_CLASS(CPaintDC)));
		pDCPaint = (CPaintDC*)pDC;
		rectClip = pDCPaint->m_ps.rcPaint;
		rectLogClip = rectClip;
		pDC->DPtoLP(&rectLogClip);   // this will be the clip rectangle which includes the zoom factor in it
		nWidthClip = rectLogClip.Width();
		nHeightClip = rectLogClip.Height();
		// Prepare a memory DC to draw on
		if (nWidthClip <= 0 || nHeightClip >= 0)  // the clipping region is empty
			return;  // nothing to draw in this case
	}

	g_pView = this;
	CSpiroDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	CDC* pDCUse = pDC;
	int nSavedDC(0);  // Initialized to avoid compiler warnings.

	CRgn*	prgnWheel = NULL;

	if (!pDC->IsPrinting())
	{
		if (m_pDCMem == NULL)
		{
			m_pDCMem = new CDC();
			ASSERT(m_pDCMem != NULL);
			VERIFY(m_pDCMem->CreateCompatibleDC(pDC));
			m_pDCMem->SetMapMode(MM_SPIRO);
		}

		int cxClip = rectClip.Width();
		int cyClip = rectClip.Height();
		ASSERT(cxClip > 0 && cyClip >0);

		if (m_pBitmap == NULL)
			m_pBitmap = new CBitmap();

		if (cxClip > m_sizeBitmap.cx || cyClip > m_sizeBitmap.cy)
		{
			if (m_pbitmapOld != NULL)
			{
				m_pDCMem->SelectObject(m_pbitmapOld);
				m_pBitmap->DeleteObject();
			}

			VERIFY(m_pBitmap->CreateCompatibleBitmap(pDC, cxClip, cyClip));
			m_pbitmapOld  = m_pDCMem->SelectObject(m_pBitmap);
			m_sizeBitmap.cx = cxClip;
			m_sizeBitmap.cy = cyClip;
		}

		CPoint ptViewportOrg = pDC->GetViewportOrg();
		ptViewportOrg.x -= rectClip.left;
		ptViewportOrg.y -= rectClip.top;
		m_pDCMem->SetViewportOrg(ptViewportOrg);
		m_pDCMem->SetWindowOrg(pDC->GetWindowOrg());

		CSpiroRect  rectDoc(rectLogClip);
		CSpiroRect	rectOut(rectDoc);  // strip to the right of the doc (vertical strip)

		int cx = pDoc->m_sizeExtent.cx * m_nZoomNumer / m_nZoomDenom;
		CBrush	br(GetSysColor(COLOR_3DLIGHT));

		if (rectDoc.right > cx)  // paint vertical strip
		{
			rectOut.left = cx;
			rectDoc.right = cx;
			m_pDCMem->FillRect(&rectOut, &br);
		}

		if (rectDoc.bottom < 0)
		{
			rectOut.SetRect(rectDoc.left, 0, cx, rectDoc.bottom);
			m_pDCMem->FillRect(&rectOut, &br);
			rectDoc.bottom = 0;
		}

		CBrush brush(GetSysColor(COLOR_WINDOW));
		m_pDCMem->FillRect(&rectDoc, &brush);

		pDCUse = m_pDCMem;
		nSavedDC = pDCUse->SaveDC();
		pDCUse->IntersectClipRect(0, pDoc->m_sizeExtent.cy * m_nZoomNumer / m_nZoomDenom, cx, 0);

		if (m_pWheel != NULL)
		{
			prgnWheel = new CRgn();
			m_pWheel->GetLogPieceRgn(prgnWheel, m_nZoomNumer, m_nZoomDenom);
		}
	}


	// draw the current figure
	pDoc->m_pFigureCurrent->Draw(pDCUse, m_nZoomNumer, m_nZoomDenom
												, prgnWheel, &rectLogClip);

	// draw all the other figures
	INT_PTR nLast = pDoc->m_arrPFigures.GetUpperBound();
	CFigure* pFig;
	for (int i = 0; i <= nLast; i++)
	{
		pFig = (CFigure*)pDoc->m_arrPFigures.GetAt(i);
		pFig->Draw(pDCUse, m_nZoomNumer, m_nZoomDenom, prgnWheel, &rectLogClip);
	}

	delete prgnWheel;

	if (!pDC->IsPrinting())
	{

		pDCUse->RestoreDC(nSavedDC);

		if (m_pAnchor != NULL) 
			m_pAnchor->Draw(m_pDCMem, m_nZoomNumer, m_nZoomDenom);

		if (m_pWheel != NULL)
			m_pWheel->Draw(m_pDCMem, m_nZoomNumer, m_nZoomDenom);

		// now transfer the information in the memory DC to the device DC
		VERIFY(pDC->BitBlt(rectLogClip.left, rectLogClip.top, nWidthClip, nHeightClip, 
													pDCUse, rectLogClip.left, rectLogClip.top, SRCCOPY));

	}
}