コード例 #1
0
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);
}
コード例 #2
0
ファイル: MyURLCtrl.cpp プロジェクト: AdrianRys/wsf
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);
}
コード例 #3
0
ファイル: Separator.cpp プロジェクト: strogo/AppRunner
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);
}
コード例 #4
0
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);
}
コード例 #5
0
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);
}
コード例 #6
0
void CInspectorTreeCtrl::drawValues(CPaintDC & dc)
{
    CRect rect;
    GetWindowRect(rect);

    dc.SetViewportOrg(0, 0);
    dc.SelectObject(linePen);
    dc.SetBkMode(TRANSPARENT);
    dc.SelectObject(GetFont());
    dc.SetTextColor(color_windowtext);  

    DRAWLINE(0, 0, rect.right, 0);

    int cWid0 = getColumnWidth(0);
    int cWid1 = getColumnWidth(1);

    int height = 0;
    HTREEITEM hItemFocus = GetSelectedItem();
    HTREEITEM hItem = GetFirstVisibleItem();
    while(hItem && height < rect.Height())
    {
        CRect iRect;
        GetItemRect(hItem, &iRect, FALSE);

        DRAWLINE(0, iRect.bottom, rect.right, iRect.bottom);
        height += iRect.Height();

        CTreeListItem * itemData = GetTreeListItem(hItem);
        if(itemData)
        {
            iRect.left = cWid0 + 6;
            iRect.right = cWid0 + cWid1;
            
            if(hItem == hItemFocus)
            {
                CRect whitespaceRect;
                GetItemRect(hItem, &whitespaceRect, TRUE);

                if(whitespaceRect.right < cWid0)
                {
                    whitespaceRect.left = whitespaceRect.right;
                    whitespaceRect.right = cWid0;
                
                    CWnd * focusWnd = GetFocus();
                    if(focusWnd && (focusWnd->m_hWnd == m_hWnd))        // I have focus             
                        dc.FillRect(whitespaceRect, &whitespaceHighlightBrush_Focused);                 
                    else                
                        dc.FillRect(whitespaceRect, &whitespaceHighlightBrush_Unfocused);                                   
                }               
                CString xpath;
                getTypeText(itemData->getType(), xpath, true);
                if(getFullXPath(hItem, xpath)) 
                {
                    CRect itemRect, r;
                    GetItemRect(hItem, &itemRect, FALSE);
                    r.UnionRect(&itemRect, &whitespaceRect);
                    tooltipCtrl->DelTool(this, TREE_TOOLTIP_ID);
                    tooltipCtrl->AddTool(this, xpath, r, TREE_TOOLTIP_ID);
                }
            }
            dc.DrawText(itemData->getValue(), &iRect, DT_SINGLELINE | DT_LEFT);
        }
        hItem = GetNextVisibleItem(hItem);      
    }
    DRAWLINE(cWid0, 0, cWid0, height);
}
コード例 #7
0
void CLeftPanelDlgBar::OnPaint() 
{
	CPaintDC dc (this); // device context for painting

	CDC dcMem;
	dcMem.CreateCompatibleDC (&dc);
	CBrush brush (::GetSysColor (COLOR_3DFACE));

	CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive ();

	CRect r;
	GetClientRect (&r);

	if (pChild == NULL)
	{
		dc.FillRect (&r, &brush);
		goto __end;
	}

	CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument ();
	if (pDoc == NULL)
	{
		// look whether the last doc is still valid
		POSITION pos = AfxGetApp ()->GetFirstDocTemplatePosition ();
		CDocTemplate* pDocTmpl = AfxGetApp ()->GetNextDocTemplate (pos);
		bool bIsValid = false;
		for (pos = pDocTmpl->GetFirstDocPosition (); pos; )
			if (pDocTmpl->GetNextDoc (pos) == m_pLastDoc)
			{
				bIsValid = true;
				break;
			}

		if (bIsValid)
			pDoc = m_pLastDoc;
		else
			m_pLastDoc = NULL;
	}
	else
		m_pLastDoc = pDoc;

	if (pDoc == NULL)
	{
		dc.FillRect (&r, &brush);
		goto __end;
	}

	CRect rect;
	GetClientRect (rect);
	rect.DeflateRect (5, 5, 5, 5);

	if (pDoc->m_pStyle != NULL)
	{
		CCdCoverCreator2View* pView = (CCdCoverCreator2View*) pChild->GetActiveView ();
		if (pView == NULL)
			goto __end;

		int nHeight = (rect.Width () / 5) * 4;
		CRenderDC rdc (&dc, nHeight, pView->GetDocument ()->m_pStyle);

		m_y[Cover] = 5;
		m_y[Back] = m_y[Cover] + rdc.GetHeight (Cover) + 10;
		m_y[Inlay] = m_y[Back] + rdc.GetHeight (Back) + 10;
		m_y[Label] = m_y[Inlay] + rdc.GetHeight (Inlay) + 10;
		m_y[Booklet] = m_y[Label] + rdc.GetHeight (Label) + 10;

		if (m_bRedraw)
		{
			CLabelRenderer renderer (pDoc->m_pTracks, pDoc->m_pDataCDInfo,
				reinterpret_cast<CBackgroundInfo**> (&(pDoc->m_pBackground)),
				pDoc->m_listFloatingObjects, *(pDoc->m_pStyle));

			for (int i = 0; i < NUM_RENDER_TYPES - 1; i++)
			{
				if ((RenderType) i == Booklet)
					continue;

				CRect rectBmp (0, 0, rdc.GetWidth ((RenderType) i) + 5, /*nHeight*/(m_y[i + 1] - m_y[i]) + 5);

				m_Bitmap[i].DeleteObject ();
				m_Bitmap[i].CreateCompatibleBitmap (&dc, rectBmp.right, rectBmp.bottom);

				// render
				dcMem.SelectObject (&m_Bitmap[i]);
				dcMem.FillRect (rectBmp, &brush);

				renderer.Render (CRenderDC (&dcMem, nHeight, pDoc->m_pStyle), (RenderType) i, true);
			}

			m_bRedraw = false;
		}

		// draw the bitmaps
		int x[] = {
			(rect.Width () - rdc.GetWidth (Cover)) / 2 + 5,
			(rect.Width () - rdc.GetWidth (Back)) / 2 + 5,
			(rect.Width () - rdc.GetWidth (Inlay)) / 2 + 5,
			(rect.Width () - rdc.GetWidth (Label)) / 2 + 5,
			(rect.Width () - rdc.GetWidth (Cover)) / 2 + 5
		};

		dc.SetViewportOrg (x[Booklet], m_y[Booklet]);
		DrawBooklet (&dc, rdc.GetWidth (Cover), rdc.GetWidth (Cover) / 2, pDoc, pView->GetRenderType ());
		dc.SetViewportOrg (0, 0);

		CBrush* pOldBrush = dc.GetCurrentBrush ();

		for (int i = 0; i < NUM_RENDER_TYPES; i++)
		{
			CRect rectArea (rect.left, m_y[i], rect.right,
				m_y[i] + ((RenderType) i == Booklet ? rdc.GetWidth (Cover) / 2 : rdc.GetHeight ((RenderType) i)));

			if ((RenderType) i != Booklet)
			{
				dcMem.SelectObject (m_Bitmap[i]);

				if (pDoc->m_pStyle->m_bHasRenderType[i])
					dc.SelectStockObject (WHITE_BRUSH);
				else
				{
					dc.SetTextColor (RGB (0xff, 0xff, 0xff));
					dc.SetBkColor (RGB (0x7f, 0x7f, 0x7f));
					dc.SelectObject (dc.GetHalftoneBrush ());
				}

				//dc.BitBlt (x[i], m_y[i], rdc.GetWidth ((RenderType) i) + 5, /*nHeight*/(m_y[i + 1] - m_y[i]) + 5, &dcMem, 0, 0, MERGECOPY);
				dc.BitBlt (x[i], m_y[i], rectArea.Width (), rectArea.Height () + 4, &dcMem, 0, 0, MERGECOPY);
			}

			// marker
			Mark (&dc, rectArea, pView->GetRenderType () != (RenderType) i);
		}

		dc.SelectObject (pOldBrush);
	}

__end:

#ifdef PEROUTKA_FEDORISIN
	CBitmap* pOldBmp = (CBitmap*) dcMem.SelectObject (m_bmpLogo);
	dc.FillSolidRect (0, r.bottom - 32, 148, 32, RGB (0xff, 0xff, 0xff));
	dc.BitBlt ((148 - 80) / 2, r.bottom - 32, 80, 32, &dcMem, 0, 0, SRCCOPY);
//	dcMem.SelectObject (pOldBmp);
#endif

	dcMem.DeleteDC ();
	brush.DeleteObject ();
}