Exemple #1
0
void CRTreeCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// draw the funky piccy
    m_pic.Render(pdc, rcBounds, rcBounds);

	// draw a box and fill it with text.
	// the zoom function will alter the font and box dimensions

    CFont* pOldFont;
    TEXTMETRIC tm;
    const CString& strCaption = InternalGetText();

    // Set the ForeColor property color and transparent background mode into the device context
    pdc->SetTextColor(TranslateColor(GetForeColor()));
    pdc->SetBkMode(TRANSPARENT);

    // Draw the caption using the stock Font and ForeColor properties
    pOldFont = SelectStockFont(pdc);
    pdc->GetTextMetrics(&tm);
    pdc->SetTextAlign(TA_LEFT | TA_TOP);
	int gapsize;
	int gapsize2;
	int ydistance;
	int xdistance=0;
	int index=0;
	char* buffer;
	CRect rect;
	for (int x=0;x<m_lDepth;x++)
	{
		gapsize=(int)(pow(2,x)-1)*m_lBoxHeight;
		ydistance=gapsize/2;
		gapsize2=(int)(pow(2,x-2)*m_lBoxHeight);
		for (int y=0;y<pow(2,m_lDepth-x-1);y++)
		{
			rect=CRect(xdistance,ydistance,xdistance+m_lBoxWidth,ydistance+m_lBoxHeight);
			buffer=(char*)GetText(index);
			if (buffer!=NULL)
			    pdc->ExtTextOut(rect.left+2, rect.top+2,
					ETO_CLIPPED, CRect(rect.left+2,rect.top+2,rect.right-2,rect.bottom-2), buffer, strlen(buffer), NULL);
			pdc->DrawEdge(rect,EDGE_ETCHED,BF_RECT);
			index++;
			if (x>0)
			{
				pdc->MoveTo(xdistance-m_lGapWidth,ydistance+(m_lBoxHeight/2)+gapsize2);
				pdc->LineTo(xdistance,ydistance+(m_lBoxHeight/2));
				pdc->MoveTo(xdistance-m_lGapWidth,ydistance+(m_lBoxHeight/2)-gapsize2);
				pdc->LineTo(xdistance,ydistance+(m_lBoxHeight/2));
			}
			ydistance+=gapsize+m_lBoxHeight;
		}
		xdistance+=m_lBoxWidth+m_lGapWidth;
	}
    pdc->SelectObject(pOldFont);
}
Exemple #2
0
void CTesthelpCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& /*rcInvalid*/)
{
	// Drawing code, mostly plagiarized from the Circ MFC sample.
	// The only thing done here is setting the border and drawing text
	// specified by our name properties in the control's client area.
		if(!GetBorderStyle())   //Control will always have a border.
					SetBorderStyle(TRUE);

		// Set up variables to use for drawing text background.
		// Use our current BackColor for the background color.
		CBrush* pOldBrush;
		CBrush bkBrush(TranslateColor(GetBackColor()));
		CPen* pOldPen;
		CRect rc = rcBounds;
		CFont* pOldFont;

		// Set up background mode and text color.  Use the
		// current ForeColor for the text color.
		pdc->SetTextColor(TranslateColor(GetForeColor()));
		pdc->SetBkMode(TRANSPARENT);

		// Fill our window with the current BackColor
		pdc->FillRect(rcBounds, &bkBrush);

		// Save off the existing brush and pen so they
		// can be restored when we're done.
		pOldBrush = pdc->SelectObject(&bkBrush);
		pOldPen = (CPen*)pdc->SelectStockObject(BLACK_PEN);

		// Save off the current font so we can restore it and
		// select our current stock font into this DC
		pOldFont = SelectStockFont(pdc);

		// Draw the text on our window
		pdc->ExtTextOut(rc.left+10, rc.top +2,
			ETO_CLIPPED, rc, m_szName1, m_szName1.GetLength(), NULL);
		pdc->ExtTextOut(rc.left+10, rc.top +22,
			ETO_CLIPPED, rc, m_szName2, m_szName2.GetLength(), NULL);
		pdc->ExtTextOut(rc.left+10, rc.top +42,
			ETO_CLIPPED, rc, m_szName3, m_szName3.GetLength(), NULL);

		// Restore our DC to it's original state.
		pdc->SelectObject(pOldFont);
		pdc->SelectObject(pOldPen);
		pdc->SelectObject(pOldBrush);

}
Exemple #3
0
void CRTitleCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// TODO: Replace the following code with your own drawing code.
	pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
    CRect rc = rcBounds;
    CFont* pOldFont;
    TEXTMETRIC tm;
    const CString& strCaption = InternalGetText();

    // Set the ForeColor property color and transparent background mode into the device context
    pdc->SetTextColor(TranslateColor(GetForeColor()));
    pdc->SetBkMode(TRANSPARENT);

    // Draw the caption using the stock Font and ForeColor properties
    pOldFont = SelectStockFont(pdc);
    pdc->GetTextMetrics(&tm);
    pdc->SetTextAlign(TA_CENTER | TA_TOP);
    pdc->ExtTextOut((rc.left + rc.right) / 2, 0,
		ETO_CLIPPED, rc, strCaption, strCaption.GetLength(), NULL);
    pdc->SelectObject(pOldFont);
}
Exemple #4
0
void CCircCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect&)
{
	CBrush* pOldBrush;
	CBrush bkBrush(TranslateColor(GetBackColor()));
	CPen* pOldPen;
	CRect rc = rcBounds;
	CFont* pOldFont;
	TEXTMETRIC tm;
	const CString& strCaption = InternalGetText();

	// Set the ForeColor property color and transparent background mode into the device context
	pdc->SetTextColor(TranslateColor(GetForeColor()));
	pdc->SetBkMode(TRANSPARENT);

	// Paint the background using the BackColor property
	pdc->FillRect(rcBounds, &bkBrush);

	// Draw the ellipse using the BackColor property and a black pen
	GetDrawRect(&rc);
	pOldBrush = pdc->SelectObject(&bkBrush);
	pOldPen = (CPen*)pdc->SelectStockObject(BLACK_PEN);
	pdc->Ellipse(rc);

	// Draw the caption and note using the stock Font and ForeColor properties
	pOldFont = SelectStockFont(pdc);
	GetStockTextMetrics(&tm);

	pdc->SetTextAlign(TA_CENTER | TA_TOP);
	pdc->ExtTextOut((rc.left + rc.right) / 2, (rc.top + rc.bottom - tm.tmHeight) / 2,
		ETO_CLIPPED, rc, strCaption, strCaption.GetLength(), NULL);
	pdc->SetTextAlign(TA_LEFT | TA_TOP);
	pdc->ExtTextOut(rcBounds.left, rcBounds.top,
		ETO_CLIPPED, rcBounds, m_note, m_note.GetLength(), NULL);
	pdc->SelectObject(pOldFont);

	pdc->SelectObject(pOldPen);
	pdc->SelectObject(pOldBrush);
}
Exemple #5
0
long CRTitleCtrl::SelStockFont(long pDC) 
{
    return (long)SelectStockFont((CDC*)pDC);
}