예제 #1
0
void
Canvas::DrawClippedText(int x, int y, const PixelRect &rc, const TCHAR *text)
{
  // TODO: implement full clipping
  if (rc.right > x)
    DrawClippedText(x, y, rc.right - x, text);
}
예제 #2
0
파일: Canvas.hpp 프로젝트: ppara/XCSoar
  void DrawClippedText(int x, int y, const PixelRect &rc,
                       const TCHAR *text) {
    // XXX

    if (x < rc.right)
      DrawClippedText(x, y, rc.right - x, text);
  }
예제 #3
0
  void DrawClippedText(PixelScalar x, PixelScalar y, const PixelRect &rc,
                       const TCHAR *text) {
    // XXX

    if (x < rc.right)
      DrawClippedText(x, y, rc.right - x, text);
  }
예제 #4
0
void
Canvas::DrawClippedText(int x, int y, unsigned width,
                        const TCHAR *text)
{
  const PixelSize size = CalcTextSize(text);

  PixelRect rc;
  ::SetRect(&rc, x, y, x + std::min(width, unsigned(size.cx)), y + size.cy);
  DrawClippedText(x, y, rc, text);
}
예제 #5
0
파일: Canvas.hpp 프로젝트: LK8000/LK8000
 /*
  * Clip text based on rough estimate of characters in string
  */
 void DrawClippedText(int x, int y, const PixelRect &rc, const TCHAR *text) {
   DrawClippedText(x, y, rc.right - rc.left, text);
 }
예제 #6
0
파일: Canvas.hpp 프로젝트: ppara/XCSoar
 /**
  * Render text, clip it within the bounds of this Canvas.
  */
 void TextAutoClipped(int x, int y, const TCHAR *t) {
   if (x < (int)GetWidth() && y < (int)GetHeight())
     DrawClippedText(x, y, GetWidth() - x, GetHeight() - y, t);
 }
예제 #7
0
파일: Canvas.hpp 프로젝트: ppara/XCSoar
 void DrawClippedText(int x, int y, unsigned width,
                      const TCHAR *text) {
   DrawClippedText(x, y, width, 16384, text);
 }
예제 #8
0
 /**
  * Render text, clip it within the bounds of this Canvas.
  */
 void TextAutoClipped(PixelScalar x, PixelScalar y, const TCHAR *t) {
   if (x < (int)GetWidth() && y < (int)GetHeight())
     DrawClippedText(x, y, GetWidth() - x, GetHeight() - y, t);
 }
예제 #9
0
 void DrawClippedText(PixelScalar x, PixelScalar y, UPixelScalar width,
                      const TCHAR *text) {
   DrawClippedText(x, y, width, 16384, text);
 }
예제 #10
0
void CProgressCtrlX::DrawText(const CDrawInfo& info, const CRect &rcMax, const CRect &rcBar)
{
	if(!(info.dwStyle&PBS_TEXTMASK))
		return;
	BOOL fVert = info.dwStyle&PBS_VERTICAL;
	CDC *pDC = info.pDC;
	int nValue = 0;
	CString sFormat;
	GetWindowText(sFormat);
	switch(info.dwStyle&PBS_TEXTMASK)
	{
		case PBS_SHOW_PERCENT:
			if(sFormat.IsEmpty())
				sFormat = _T("%d%%");
			// retrieve current position and range
			nValue = (int)((float)(info.nCurPos-info.nLower) * 100 / ((info.nUpper-info.nLower == 0) ? 1 : info.nUpper-info.nLower));
			break;
		case PBS_SHOW_POSITION:
			if(sFormat.IsEmpty())
				sFormat = _T("%d");
			// retrieve current position
			nValue = info.nCurPos;
			break;
	}

	if (sFormat.IsEmpty())
		return;

	CFont* pFont = GetFont();
	CSelFont sf(pDC, pFont);
	CSelTextColor tc(pDC, m_clrTextOnBar);
	CSelBkMode bm(pDC, TRANSPARENT);
	CSelTextAlign	ta(pDC, TA_BOTTOM|TA_CENTER);
  CPoint ptOrg = pDC->GetWindowOrg();
	CString sText;
	sText.Format(sFormat, nValue);
	
	LONG grad = 0;
	if(pFont)
	{
		LOGFONT lf;
		pFont->GetLogFont(&lf);
		grad = lf.lfEscapement/10;
	}
	int x = 0, y = 0, dx = 0, dy = 0;
	CSize sizText = pDC->GetTextExtent(sText);
	if(grad == 0)         {	x = sizText.cx; y = sizText.cy; dx = 0; dy = sizText.cy;}
	else if(grad == 90)   {	x = sizText.cy; y = sizText.cx; dx = sizText.cy; dy = 0;}
	else if(grad == 180)  {	x = sizText.cx; y = sizText.cy; dx = 0; dy = -sizText.cy;}
	else if(grad == 270)  {	x = sizText.cy; y = sizText.cx; dx = -sizText.cy; dy = 0;}
	else ASSERT(0); // angle not supported
	CPoint pt = pDC->GetViewportOrg();
	if(info.dwStyle&PBS_TIED_TEXT)
	{
		CRect rcFill(ConvertToReal(info, rcBar));
		if((fVert ? y : x) <= rcBar.Width())
		{
			pDC->SetViewportOrg(rcFill.left + (rcFill.Width() + dx)/2, 
													rcFill.top + (rcFill.Height() + dy)/2);
			DrawClippedText(info, rcBar, sText, ptOrg);
		}
	}
	else
	{
		pDC->SetViewportOrg(info.rcClient.left + (info.rcClient.Width() + dx)/2, 
												info.rcClient.top + (info.rcClient.Height() + dy)/2);
		if(m_clrTextOnBar == m_clrTextOnBk)
			// if the same color for bar and background draw text once
			DrawClippedText(info, rcMax, sText, ptOrg);
		else
		{	
			// else, draw clipped parts of text
			
			// draw text on gradient
			if(rcBar.left != rcBar.right)
				DrawClippedText(info, rcBar, sText, ptOrg);

			// draw text out of gradient
			if(rcMax.right > rcBar.right)
			{
				tc.Select(m_clrTextOnBk);
				CRect rc(rcMax);
				rc.left = rcBar.right;
				DrawClippedText(info, rc, sText, ptOrg);
			}
			if(rcMax.left < rcBar.left)
			{
				tc.Select(m_clrTextOnBk);
				CRect rc(rcMax);
				rc.right = rcBar.left;
				DrawClippedText(info, rc, sText, ptOrg);
			}
		}
	}
	pDC->SetViewportOrg(pt);
}