Esempio n. 1
0
void CDataView::Render2D(CPaintDC& dc)
{
	CRect updateRect = dc.m_ps.rcPaint;


	int w = updateRect.Width();
	int h = updateRect.Height();

	int tx = updateRect.left;
	int ty = updateRect.top;
	
	int sx = std::max(0, GetScrollPos(SB_HORZ)) + tx;
	int sy = std::max(0, GetScrollPos(SB_VERT)) + ty;

#if 1
	dc.StretchBlt(
		tx, ty, w, h,
		m_memDC, sx/m_scale, sy/m_scale, w/m_scale, h/m_scale,
		SRCCOPY
		);
#else
	dc.BitBlt(
		tx,
		ty,
		w,
		h,
		m_memDC,
		sx,
		sy,
		SRCCOPY
	);
#endif
}
Esempio n. 2
0
void CStaticFilespec::OnPaint() 
{
CPaintDC		dc (this);            // device context for painting
DWORD       dwFormat;             // text format
RECT				rectWnd;						  // window rectangle
CString			strText;              // window text
CWnd*       pWndParent = NULL;    // parent window

	// Set default font
  pWndParent = GetParent();
  if (pWndParent)
     dc.SelectObject (pWndParent->GetFont());

	// Draw text
  GetWindowText (strText);
  GetClientRect (&rectWnd);
  dwFormat = m_dwFormat | (m_bPathEllipsis ? DT_PATH_ELLIPSIS : DT_END_ELLIPSIS);
  ::DrawTextEx (dc.m_hDC,
                strText.GetBuffer (0),
                strText.GetLength(),
                &rectWnd,
                dwFormat,
                NULL);
  strText.ReleaseBuffer();
	
	// Do not call CWnd::OnPaint() for painting messages
}
Esempio n. 3
0
void CChildView::DrawTree(CPaintDC& inDC, bool inUseRepaintRect)
{
	if (_tree == nullptr)
		return;

	CPen leafPen(PS_SOLID, 1, RGB(0, 0, 255));

	CBrush clearbrush;
	clearbrush.CreateSolidBrush(RGB(255, 255, 255));

	CBrush closedbrush;
	closedbrush.CreateSolidBrush(RGB(155, 155, 155));

	_tree->ForEachLeaf([&inDC, &clearbrush, &closedbrush, &leafPen](const CQuadLeaf& inLeaf)
	{
		inDC.SelectObject(&leafPen);
		if (inLeaf.IsClear())
			inDC.SelectObject(&clearbrush);
		else
			inDC.SelectObject(&closedbrush);

		Rect2Df boundrect = inLeaf.GetBound();

		inDC.Rectangle(&boundrect.GetWinRect());
	});
}
void CSplashWnd::OnPaint()
{
	CPaintDC dc (this);

	Graphics g (dc.GetSafeHdc ());
	g.DrawImage ((Bitmap*) *m_pBitmap, 0, 0, m_nWidth, m_nHeight);
}
Esempio n. 5
0
void CSeparator::DrawLine(CPaintDC &dc, CRect &clientRect)
{
   HPEN hp = dc.SelectPen(Globals::Instance().sep.pen);
   dc.MoveTo(clientRect.left, (clientRect.top + clientRect.bottom) / 2-1);
   dc.LineTo(clientRect.right, (clientRect.top + clientRect.bottom) / 2-1);
   dc.SelectPen(hp);
}
Esempio n. 6
0
void CHeaderDockPane::DrawAd(CPaintDC & dc)
{
	//CPaintDC dc(this); 
	//CDC pDC;
	//pDC.CreateCompatibleDC(&dc);

	CRect rect;
	GetClientRect(&rect);

	if(rect.right > 500)
	{
		CBrush bg;
		bg.CreateStockObject(RGB(0,0,0));
		CBrush fillBrush(RGB(250, 0, 0));
		CBrush *oldFillBrush = dc.SelectObject(&fillBrush);
		//rect = CRect( CPoint(rect.left, rect.top), CPoint(rect.right, rect.bottom - 2) );
		//rect = CRect( CPoint(200, 5), CPoint(400, 25) );
		//dc.FillRect(&rect, &bg);


		int height = 22;
		int progress_x = rect.right - 300 - 1;
		int progress_y = -22;
		CPoint prorgess_border_points[5];
		prorgess_border_points[0] = CPoint(progress_x, progress_y);
		prorgess_border_points[1] = CPoint(progress_x, progress_y + height);
		prorgess_border_points[2] = CPoint(progress_x+(rect.right - progress_x)-20 - 1, progress_y + height);
		prorgess_border_points[3] = CPoint(progress_x+(rect.right - progress_x)-20 - 1, progress_y);
		prorgess_border_points[4] = CPoint(progress_x, progress_y);
		CPen penOutline(PS_SOLID, 1, RGB(175, 175, 175));
		dc.SelectObject(&penOutline);
		dc.Polyline(prorgess_border_points, 5);

	}
}
void CDepartmentEstimationDialog::DrawText(CPaintDC &dc, CString Text, COLORREF Color, int l, int t, int r, int b)
{
	CRect TextRect(l, t, r, b);

	dc.SetTextColor(Color);
	dc.SetBkMode( TRANSPARENT );
	dc.DrawText(Text, &TextRect, DT_SINGLELINE | DT_CENTER);
}
	void CModelFormItem::DrawField(CPaintDC & dc)
	{
		CRect rectItem;
		GetClientRect(rectItem);
		int eff = m_param.GetEndFirstField();
		int bsf = m_param.GetBeginSecondField();

		dc.MoveTo(eff, rectItem.top + 2);
		dc.LineTo(eff, rectItem.bottom - 2);
		dc.MoveTo(bsf, rectItem.top + 2);
		dc.LineTo(bsf, rectItem.bottom - 2);

	}
Esempio n. 9
0
void CIperfView::PaintItems(CPaintDC &dc, CIperfViewItem *pa)
{
	POSITION pos;
	INT_PTR count;
	INT_PTR idx = 0;
	double x0 = 0, x1 = 0, y = 0;
	double t0, t1;
	double xstep, ystep;
	double speed;
	int fast = 0;
	CRect rect;

	count = pa->m_List.GetCount();
	GetClientRect(&rect);

    xstep = rect.Width() / 60.0;
    ystep = rect.Height() / HEIGHT;

	CPen pen(PS_SOLID, 1, pa->m_color);
	CPen* pOldPen = dc.SelectObject(&pen);


    for ( pos = pa->m_List.GetHeadPosition(); pos != NULL; pa->m_List.GetNext( pos ) )
    {
		t0 = pa->m_List.GetAt( pos ).t0;
		t1 = pa->m_List.GetAt( pos ).t1;
		if(pa->m_List.GetAt( pos ).speed) {
			speed = 10*log10(pa->m_List.GetAt( pos ).speed);
		} else {
			speed = 0;
		}

		//
		x0 = t0 * xstep;
		x1 = t1 * xstep;
		y = rect.Height() - speed * ystep;

		// point set
		CRect rect0( (int)x0-2, (int)y-2, (int)x0+2, (int)y+2);
		CRect rect1( (int)x1-2, (int)y-2, (int)x1+2, (int)y+2);

		//dc.Ellipse(rect0);
		dc.Ellipse(rect1);

		if(fast++ == 0)
			dc.MoveTo(CPoint((int)x0,(int)y));
		dc.LineTo(CPoint((int)x1,(int)y));

	}
	dc.SelectObject(pOldPen);
}
Esempio n. 10
0
void CTimeEv::PaintVideoFrame(CPaintDC& dc)
{
	if(!m_hdd)
		return;

	m_videoRect = m_MainRect;
	
	m_videoRect.left += 11 + 550;
	m_videoRect.bottom -= 4; //45
	m_videoRect.top = m_videoRect.bottom - 206;
	m_videoRect.right = m_videoRect.left + 275;

	m_videoRect.left += 1;
	m_videoRect.top += 1;
	m_videoRect.right -= 1;
	m_videoRect.bottom -= 1;

	bool bChangeSz = false;

	if(m_videoRect.Width() != m_iFrameW)
	{
		m_iFrameW = m_videoRect.Width();
		bChangeSz = true;
	}
	
	if(m_videoRect.Height() != m_iFrameH)
	{
		m_iFrameH = m_videoRect.Height();
		bChangeSz = true;
	}

	if(bChangeSz || !m_pDIBFrame)
	{
		if(m_pDIBFrame) delete [] m_pDIBFrame;
		makeRgbDIB(m_pDIBFrame,m_iFrameW,m_iFrameH,0,0);
	}
		
	LPBITMAPINFOHEADER pBMP = m_oAVIR.GetCurrentFrame();

//	SaveBMP(pBMP,"orig_frame.bmp");

	if(!pBMP)
	{	Write2Log("Couldn't extract frame %d",m_oAVIR.CurrentFrame());
		return;
	}

	BITMAPINFOHEADER* pbmpnew = (BITMAPINFOHEADER*)m_pDIBFrame;

	StretchDIB(pbmpnew,(byte*)pbmpnew+sizeof(BITMAPINFOHEADER),0,0,pbmpnew->biWidth,pbmpnew->biHeight,
		pBMP,(byte*)pBMP+sizeof(BITMAPINFOHEADER),0,0,pBMP->biWidth,pBMP->biHeight);

	//byte* pdata=(byte*)pBMP+pBMP->biSize+pBMP->biClrUsed*sizeof(RGBQUAD);
	byte* pdata = (byte*)pbmpnew+sizeof(BITMAPINFOHEADER);

//	SaveBMP(pbmpnew,"new_frame.bmp");

	// Convert Data To Requested Bitmap Format & Draw IT!!!
	DrawDibDraw(m_hdd, dc.GetSafeHdc(), m_videoRect.left, m_videoRect.top, pbmpnew->biWidth, pbmpnew->biHeight, pbmpnew, pdata, 0, 0, pbmpnew->biWidth, pbmpnew->biHeight, 0);
}
Esempio n. 11
0
void CMainWindow::OnPaint()
{
	// Paint handler device context to THIS window!
	CPaintDC	dc (this);
	CRect		rect;

	// current bounding rectangle of entire client area...


	GetClientRect (&rect);

	
	dc.DrawText("Hello, mo fo.", 
				-1 , 
				&rect,
				DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
void CDepartmentEstimationDialog::DrawSquare(CPaintDC &dc, COLORREF Color, int l, int t, int r, int b)
{
	CRect UserRect(l, t, r, b);

	CBrush brush(Color);
	dc.FillRect(UserRect, &brush);
	brush.DeleteObject();
}
Esempio n. 13
0
void CIperfView::PaintXMaps(CPaintDC &dc)
{
	CRect rect;
	GetClientRect(&rect);
	double x, xstep;

	xstep = rect.Width() / 60.0 * 2;
	for(x =0.0; x < rect.Width() ; x += xstep)
	{
		CPen pen(PS_SOLID, 1, RGB(240,240,240));
		CPen* pOldPen = dc.SelectObject(&pen);

		dc.MoveTo(CPoint( (int)x, 1));
		dc.LineTo(CPoint( (int)x, (int)rect.Height() - 1));
		dc.SelectObject(pOldPen);
	}
}
Esempio n. 14
0
void CAfficheMesPol::AxeGraph(CPaintDC &dc)
{
	dc.FillSolidRect(PosGrX(0),PosGrY(255),PosGrX(255)-20,PosGrY(0)-40,RGB(255,255,255));

	CPen PenAxe(PS_SOLID,1,RGB(0,0,0));
	dc.SelectObject(&PenAxe);
	dc.MoveTo(PosGrX(0),PosGrY(0));
	dc.LineTo(PosGrX(0),PosGrY(255));
	dc.MoveTo(PosGrX(0),PosGrY(0));
	dc.LineTo(PosGrX(255),PosGrY(0));

	for(int i=5;i<255;i+=5)
	{
		dc.MoveTo(PosGrX(0),PosGrY(i));
		dc.LineTo(PosGrX(3),PosGrY(i));
		dc.MoveTo(PosGrX(i),PosGrY(0));
		dc.LineTo(PosGrX(i),PosGrY(3));
	}
	DeleteObject(&PenAxe);
}
Esempio n. 15
0
// CFileOpenDlg::DoPaint
//
//		Paints the splitter if it is displayed
//
void CFileOpenDlg::DoPaint(CPaintDC& dc) 
{
	if(m_nState == vsStandard)
	{
		CRect	rcClient;
		int		y;

		GetClientRect(&rcClient);

		y = m_ySplit;

		dc.MoveTo(0, y);
		dc.LineTo(rcClient.right, y);

		y += 6;		// This is the splitter height

		dc.MoveTo(0, y);
		dc.LineTo(rcClient.right, y);
	}
}
Esempio n. 16
0
void Tree::display(CPaintDC& dc, int x, int y, int age)
{
	CBrush brushGreen(RGB(0, 255, 0));

	int d = 20 + (age/2);

	CRect rcEllipse(CPoint(x, y), CSize(d, d));
	CRgn rgnEllipse;

	rgnEllipse.CreateEllipticRgnIndirect(&rcEllipse);
	dc.FillRgn(&rgnEllipse, &brushGreen);
}
Esempio n. 17
0
void CPartialGroupBox::Draw3dLine(CPaintDC & dc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF /*clrBottomRight*/)
{
	int x = lpRect->left;
	int y = lpRect->top;
	int cx = lpRect->right - lpRect->left;
	//int cy = lpRect->bottom - lpRect->top;

	dc.FillSolidRect(x, y, cx - 1, 1, clrTopLeft);
	//dc.FillSolidRect(x, y, 1, cy - 1, clrTopLeft);
	//dc.FillSolidRect(x + cx, y, -1, cy, clrBottomRight);
	//dc.FillSolidRect(x, y + cy, cx, -1, clrBottomRight);
}
void CDepartmentEstimationDialog::DrawDepartment(CPaintDC &dc, std::vector<SPosition> Coordinates, std::string DerpartmentName /*= ""*/)
{
	// First, Draw Contour
	// -------------------
	if (Coordinates.size() == 0)
		return;

	CBrush brush(3, RGB(255,255,255));	
	dc.SelectObject(&brush); 

	dc.MoveTo(ConvertPhysicalCoordinateToCanvas(Coordinates[0]));

	for (unsigned int i = 1; i < Coordinates.size(); i++)
	{
		dc.LineTo(ConvertPhysicalCoordinateToCanvas(Coordinates[i]));
	}

	dc.LineTo(ConvertPhysicalCoordinateToCanvas(Coordinates[0]));

	brush.DeleteObject();

	if (DerpartmentName == "")
		return; // this is the establishment itself and does not require name printing

	// Then, Print Title
	// -----------------
	CRectReal RectReal = GetEncapsulatingRect(Coordinates);
	SPosition DepartmentNamePosition;
	
	DepartmentNamePosition.x = (RectReal.left + RectReal.right) / 2;
	DepartmentNamePosition.y = (RectReal.top + RectReal.bottom) / 2;

	POINT DepartmentNamePositionOnCanvas = ConvertPhysicalCoordinateToCanvas(DepartmentNamePosition);

	DrawText(dc, DerpartmentName.c_str(), RGB(255,255,255), 
		DepartmentNamePositionOnCanvas.x - HALF_TEXT_WIDTH,
		DepartmentNamePositionOnCanvas.y - HALF_TEXT_HEIGHT,
		DepartmentNamePositionOnCanvas.x + HALF_TEXT_WIDTH,
		DepartmentNamePositionOnCanvas.y + HALF_TEXT_HEIGHT);
}
Esempio n. 19
0
void CMainWindow::OnPaint ()
{
	CRect rect;
	GetClientRect(&rect);


    CPaintDC dc (this);
	dc.SetViewportOrg(rect.Width()/2, rect.Height()/2);
	dc.SetBkMode(TRANSPARENT);

	for (int i = 0; i<300; i+=150)
	{
		LOGFONT lf;
		::ZeroMemory(&lf, sizeof(LOGFONT));
		lf.lfHeight = 160;
		lf.lfHeight = FW_BOLD;
		lf.lfEscapement = i;
		lf.lfOrientation = i;
		::lstrcpy(lf.lfFaceName, _T("Arial"));

		CFont font;
		font.CreateFontIndirect(&lf);

		CFont * pOldFont = dc.SelectObject(&font);
		dc.TextOut(0,0, CString(_T("M")));
		dc.SelectObject(pOldFont);
	}

}
Esempio n. 20
0
void CAimComboCtrl::OnPaint () {
	CRect rect;
	CPaintDC dc (this);
	GetClientRect (&rect);

	m_rectBtn = rect;
	m_rectBtn.left = rect.right - 13;
	m_rectText = rect;
	m_rectText.right = rect.right - 13;
	m_rectText.DeflateRect (2, 1);
	dc.FillSolidRect (rect, ::GetSysColor (COLOR_WINDOW));
	dc.FillSolidRect (m_rectBtn, ::GetSysColor (COLOR_BTNFACE));
	dc.DrawIcon (m_rectBtn.CenterPoint () - CSize (5, 5), theApp.LoadIcon (IDI_PIC_DOWNARROW));
	dc.DrawEdge (m_rectBtn, BDR_RAISEDINNER, BF_RECT);

	CDC dcMem;
	dcMem.CreateCompatibleDC (&dc);
	CBitmap *pOld = dcMem.GetCurrentBitmap ();
	dcMem.SelectObject (m_pbmpImage);
	dc.SetBkMode (TRANSPARENT);
	//dc.SetROP2 (R2_NOP);
	//dc.SetStretchBltMode (STRETCH_HALFTONE);
	//dc.StretchBlt (m_rectText.left, m_rectText.top, m_rectText.Width(), m_rectText.Height (), &dcMem, 0, 0, 
	//               16, 16, SRCCOPY);
	dcMem.SelectObject (pOld);
	dcMem.DeleteDC ();

	Paint (dc);
}
void PreviousImagesView::DrawImageInfos(CPaintDC& dc, int iWidth)
{
   std::shared_ptr<PreviousImageInfo> spCurrentImage = m_spCurrentImage;

   if (spCurrentImage == nullptr)
      return;

   CRect rcPaint;
   GetClientRect(&rcPaint);
   rcPaint.left = iWidth + c_uiPaddingImageInfo;
   rcPaint.top += c_uiPaddingImageInfo;

   HFONT oldFont = dc.SelectFont(GetFont());

   dc.SetBkMode(TRANSPARENT);
   dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));

   CString cszText;
   cszText.Format(
      _T("Filename: %s\n")
      _T("Av: %s\n")
      _T("Tv: %s\n")
      _T("ISO: %s\n")
      _T("Zoom: %s\n")
      _T("Date: %s\n")
      _T("%s"),
      spCurrentImage->Filename().GetString(),
      spCurrentImage->InfoText(PreviousImageInfo::typeAperture).GetString(),
      spCurrentImage->InfoText(PreviousImageInfo::typeShutterSpeed).GetString(),
      spCurrentImage->InfoText(PreviousImageInfo::typeIsoSetting).GetString(),
      spCurrentImage->InfoText(PreviousImageInfo::typeFocalLength).GetString(),
      spCurrentImage->InfoText(PreviousImageInfo::typeDateTime).GetString(),
      spCurrentImage->InfoText(PreviousImageInfo::typeFlashFired).GetString());

   dc.DrawText(cszText, cszText.GetLength(), rcPaint, DT_LEFT | DT_TOP);

   dc.SelectFont(oldFont);
}
BOOL CSkinScrollWnd::_DoPaint()
{
	//bHandled = FALSE;
	CPaintDC dc ( m_hWnd );

	CRect rcClient;
	GetClientRect ( &rcClient );

	CRect rcFill;
	rcFill.SetRectEmpty();
	INT32 nLeft = 0, nTop = 0;

	if ( 1 == m_nAngleType ) // LeftScrollBar
	{
		nLeft = rcClient.left;
		nTop = rcClient.bottom - m_nScrollWidth;
		rcFill.SetRect ( nLeft, nTop, nLeft + m_nScrollWidth, nTop + m_nScrollWidth );
	}
	else if ( 2 == m_nAngleType )
	{
		nLeft = rcClient.right - m_nScrollWidth;
		nTop = rcClient.bottom - m_nScrollWidth;
		rcFill.SetRect ( nLeft, nTop, nLeft + m_nScrollWidth, nTop + m_nScrollWidth );
	}

	if ( !rcFill.IsRectEmpty() )
	{
		CRgn rgn;
		rgn.CreateRectRgnIndirect(&rcFill);
		dc.SelectClipRgn(rgn);


		dc.FillRect(rcFill, m_brBackground);
		m_imgCorner.Draw( dc.m_hDC, rcFill.left, rcFill.top, rcFill.Width(), rcFill.Height() );

	}
	return TRUE;
}
Esempio n. 23
0
void CIperfView::PaintYMaps(CPaintDC &dc)
{
	CRect rect;
	GetClientRect(&rect);
	double y, ystep, k, j;

	ystep =  rect.Height() / HEIGHT;
	for(j = 1; j < 10000000000; j*=10)
	{
		for(k = 1; k < 10; k++)
		{
			y = rect.Height() - 10*log10(k*j) * ystep;
			if(y < 0) goto over;
			CPen pen(PS_SOLID, 1, ((k != 1) ? RGB(240,240,240) : RGB(120,120,120)) );
			CPen* pOldPen = dc.SelectObject(&pen);
			dc.MoveTo(CPoint( 1, (int)y));
			dc.LineTo(CPoint( (int)rect.Width() -1, (int)y));
			dc.SelectObject(pOldPen);
		}
	}
over:
	return;
}
void CUsbtestDlg::ShowWave(CPaintDC& dc, RECT& rc)
{
    if (!m_buffer)
        return;

    CDC memDC;  //定义内存DC
    CBitmap memBitmap;
    CBitmap* pOldBmp = NULL;

    memDC.CreateCompatibleDC(&dc);
    memBitmap.CreateCompatibleBitmap(&dc, rc.right, rc.bottom);
    pOldBmp = memDC.SelectObject(&memBitmap);
    memDC.BitBlt(rc.left, rc.top, rc.right, rc.bottom, &dc, 0, 0, SRCCOPY);

    RECT rect;
    rect.top = rc.top + 30;
    rect.bottom = rc.bottom - 30;
    rect.left = rc.left + 2;
    rect.right = rc.right - 2;

    unsigned char* waveData = m_buffer;
    int len = waveSize;

    double step = (double)(rect.right - rect.left) / len;
    double scale = (double)(rect.bottom - rect.top) / (double)255;

    memDC.MoveTo(rect.left, rect.bottom - waveData[0] * scale);

    for (int i = 1; i < len; i++)
    {
        memDC.LineTo(rect.left + i*step, rect.bottom - waveData[i] * scale);
    }

    char str[10];
    sprintf_s(str, 10, "%d", curNo);

    memDC.TextOut(0, 0, CString(str));


    dc.BitBlt(rc.left, rc.top, rc.right, rc.bottom, &memDC, 0, 0, SRCCOPY);
    memDC.SelectObject(pOldBmp);
    memDC.DeleteDC();
    memBitmap.DeleteObject();
}
Esempio n. 25
0
void MyField::DrawField(CPaintDC &dc)
{
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			SetDCPenColor(dc, RGB(0, 0, 0));
			SetDCBrushColor(dc, RGB(255, 255, 255));
			dc.Rectangle(i * RectSize, j * RectSize,
				i * RectSize + RectSize, j * RectSize + RectSize);
			if (arrVector[row*j + i] == 1) 
			{
				SetColor(dc);
				DrawRectByCoordanates(dc, i, j);
				SetDefaultColor(dc);
			}
		}
	}
	SetDCPenColor(dc, RGB(0, 0, 0));
	SetDCBrushColor(dc, RGB(0, 0, 0));
}
Esempio n. 26
0
void CMyURLCtrl::OnPaint (void)
{
	CPaintDC dc (this);

	// Set Current Drawing Properties
	CFont* pCurrentFont = dc.SelectObject (&o_Font);
	COLORREF crCurrentTextColor = dc.SetTextColor (RGB (0, 0, 255));

	CRect rc;
	GetWindowRect (&rc);
	ScreenToClient (rc);
	
	dc.SetBkMode (TRANSPARENT);

	dc.DrawText (s_Text, rc, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS);
	
	// Reset Drawing Properties
	dc.SelectObject (pCurrentFont);
	dc.SetTextColor (crCurrentTextColor);
}
Esempio n. 27
0
void CSeparator::DrawTextImpl(CPaintDC &dc, CString text, CRect clientRect)
{
   auto &g = Globals::Instance();

   HFONT hOldFont = dc.SelectFont(g.sep.font);

   dc.SetTextColor(g.sep.textColor);
   dc.SetBkColor(g.bkColor);

   const int margin = 0;
   CSize textSize;
   dc.GetTextExtent(text, -1, &textSize);
   CRect textRect(clientRect);
   textRect.left = margin;
   textRect.right = textRect.left + textSize.cx + 2 * 3;
   dc.FillSolidRect(textRect, g.bkColor);
   textRect.InflateRect(-3, 0);
   dc.DrawText(text, -1, textRect, DT_VCENTER | DT_CENTER | DT_SINGLELINE);

   dc.SelectFont(hOldFont);
}
Esempio n. 28
0
void CChildView::OnPaint() 
{
  CPaintDC *dc;
  CDC *pdc;
  CRgn ur;
  ur.CreateRectRgn(0, 0, 0, 0);
  GetUpdateRgn(&ur);

  CRect cr;
  GetClientRect(&cr);
  if (theApp.m_bStarted && !theApp.m_map.IsEmpty()) {
//    pdc = &dc;
    m_MemDC.SelectClipRgn(&ur);
    pdc = &m_MemDC;

    theApp.m_map.DrawMap(*pdc, &cr, &ur);

    CRect r;
//    r = cr;
    ur.GetRgnBox(r);
//    r.InflateRect(1, 1);
    if (r.left < 0)
      r.left = 0;
    if (r.top < 0)
      r.top = 0;
  	dc = new CPaintDC(this); // device context for painting
    dc->BitBlt(r.left, r.top, r.Width(), r.Height(), &m_MemDC, r.left, r.top, SRCCOPY);
  }
  else {
  	dc = new CPaintDC(this); // device context for painting
    if (theApp.m_bStarted) {
      dc->SetTextAlign(TA_CENTER);
      CPoint cp = cr.CenterPoint();
      CString s;
      s.Format("There are no maps in '%s'", theApp.m_map.m_sMapsPath);
      dc->ExtTextOut(cp.x, cp.y - dc->GetOutputTextExtent("W").cy/2, ETO_OPAQUE, &cr, s, NULL);
    }
    else {
      dc->FillSolidRect(cr, 0);
    }
  }
  delete dc;
}
void PreviousImagesView::DrawEmptyView(CPaintDC& dc)
{
   DWORD dwColor = ::GetSysColor(COLOR_APPWORKSPACE);
   dc.FillSolidRect(&dc.m_ps.rcPaint, dwColor);

   // output "no image" string
   CRect rcClient;
   GetClientRect(&rcClient);

   HFONT oldFont = dc.SelectFont(GetFont());

   dc.SetBkColor(dwColor);
   dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));

   CString cszText = m_manager.ImagesAvail() ? _T("<Loading image...>") : _T("<No images available>");

   // add DT_SINGLELINE to center both vertically and horizontally
   dc.DrawText(cszText, cszText.GetLength(), rcClient, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

   dc.SelectFont(oldFont);
}
Esempio n. 30
0
//***************************************************************************************
LRESULT CALLBACK CBCGPFileDialog::WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_NOTIFY:
		{
			CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);

			LPNMHDR pHdr = (LPNMHDR) lParam;
			ASSERT (pHdr != NULL);

			if (wParam == iTabCtrlId && pHdr->code == TCN_SELCHANGE)
			{
				pFD->OnTabSelchange();
			}
			else if ((wParam == iNewListCtrlId || wParam == iRecentListCtrlId) 
				&& pHdr->code == NM_DBLCLK)
			{
				pFD->OnItemDblClick();
			}
		}
		break;

	case WM_COMMAND:
		{
			if ((int) LOWORD(wParam) == IDOK)
			{
				CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);
				if (pFD->GetPage () != CBCGPFileDialog::BCGFileOpen)
				{
					pFD->OnItemDblClick();
					return 0;
				}
			}
		}
		break;

	case WM_PAINT:
		{
			CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);
			pFD->CollectControls ();
	
			if (pFD->m_pBmpLogo != NULL)
			{
				ASSERT_VALID (pFD->m_pBmpLogo);

				CFileDialog* pDlg = (CFileDialog*)CWnd::FromHandle (hwnd);
				ASSERT (pDlg != NULL);

				CPaintDC dc (pDlg); // device context for painting
				dc.DrawState (pFD->m_rectLogo.TopLeft (),
					pFD->m_rectLogo.Size (), pFD->m_pBmpLogo,
					DSS_NORMAL);

				CRect rectFrame = pFD->m_rectLogo;
				rectFrame.InflateRect (1, 1);

				dc.Draw3dRect (rectFrame, globalData.clrBtnShadow, globalData.clrBtnLight);
			}
		}
		break;

	case WM_SIZE:
		{
			LRESULT lRes = CallWindowProc(CBCGPFileDialog::m_wndProc, hwnd, message, wParam, lParam);

			CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);
			ASSERT_VALID (pFD);

			CWnd* pFDParent = pFD->GetParent();
			ASSERT (pFDParent != NULL);

			CRect rectTabs;
			pFDParent->GetClientRect (rectTabs);
			rectTabs.DeflateRect (4, 4);
			rectTabs.top += pFD->m_iLogoAreaHeight;

			pFD->m_wndTab.SetWindowPos (NULL, -1, -1,
				rectTabs.Width (), rectTabs.Height (),
				SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);

			pFD->m_lstFDControls.RemoveAll ();
			pFD->CollectControls ();

			return lRes;
		}
	}

	return CallWindowProc(CBCGPFileDialog::m_wndProc, hwnd, message, wParam, lParam);
}