void COXStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
	{
	ASSERT(TRUE);
	
	// You should get the pointer to the device context from the "lpDrawItemStruct" ptr.
	CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);

	int nOldBkMode=pDC->SetBkMode(TRANSPARENT);
	CFont* pPaneFont=(CFont*)m_PaneFont[lpDrawItemStruct->itemID];
	CFont* pOldFont=NULL;

	if (pPaneFont == NULL)
	{
		pPaneFont = GetFont();
	}

	if (pPaneFont != NULL)
	{
		pOldFont=pDC->SelectObject(pPaneFont);
		ASSERT(pOldFont != NULL);
	}

	COLORREF clrOldTextColor=
		pDC->SetTextColor(m_ColorArray[lpDrawItemStruct->itemID]);

	CString PaneText=GetPaneText(lpDrawItemStruct->itemID);
	CSize sStrSize=pDC->GetTextExtent(PaneText);
	pDC->TextOut(lpDrawItemStruct->rcItem.left + 2, lpDrawItemStruct->rcItem.top +
		((lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top - sStrSize.cy) / 2), PaneText);
	pDC->SetTextColor(clrOldTextColor);
	if (pOldFont != NULL)
		pDC->SelectObject(pOldFont);

	pDC->SetBkMode(nOldBkMode);
	}
Esempio n. 2
0
void CPmwStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
   CFont* pFont = GetFont();
   CRect rcItem = lpDrawItemStruct->rcItem;

   HDC hDC = lpDrawItemStruct->hDC;

   CString csText;
   GetPaneText(lpDrawItemStruct->itemID, csText);

   int nBitmapIndex = lpDrawItemStruct->itemID-1;
   if (m_Indicators[nBitmapIndex].m_fValid)
   {
      // We have a bitmap to draw.
      CDC dcBitmap;
      if (dcBitmap.CreateCompatibleDC(CDC::FromHandle(hDC)))
      {
         CBitmap* pOldBitmap = dcBitmap.SelectObject(&m_Indicators[nBitmapIndex].m_Bitmap);
         if (pOldBitmap != NULL)
         {
            CRect r;

            CSize Size = m_Indicators[nBitmapIndex].m_Size;
            r.left = rcItem.left + 2;
            r.right = r.left + Size.cx;
            r.top = (lpDrawItemStruct->rcItem.top + lpDrawItemStruct->rcItem.bottom - Size.cy)/2;
            r.bottom = r.top + Size.cy;
            ::BitBlt(hDC,
                     r.left,
                     r.top,
                     r.Width(),
                     r.Height(),
                     dcBitmap.GetSafeHdc(),
                     0,
                     0,
                     SRCCOPY);
            dcBitmap.SelectObject(pOldBitmap);

            rcItem.left = r.right + 2;
         }
         dcBitmap.DeleteDC();
      }
   }

   HFONT hOldFont = (HFONT)::SelectObject(hDC, pFont->GetSafeHandle());
   if (hOldFont != NULL)
   {
      int nOldMode = SetBkMode(hDC, TRANSPARENT);
      ::DrawText(hDC,
                 csText,
                 csText.GetLength(),
                 &rcItem,
                 DT_CENTER | DT_SINGLELINE | DT_VCENTER);
      SetBkMode(hDC, nOldMode);
      ::SelectObject(hDC, hOldFont);
   }
}
Esempio n. 3
0
BOOL MPCStatusBar::GetStatusPane(int nIndex, MPCStatusBarPane & xfxpane)
{
 if( nIndex < m_nCount  && nIndex >= 0 )
 {
  GetPaneInfo( nIndex,  xfxpane.nID, xfxpane.nStyle, xfxpane.cxText ) ;
  GetPaneText( nIndex , xfxpane.strText );
  return TRUE;
 }
 return FALSE;
}
Esempio n. 4
0
LRESULT CStatusBar::OnGetTextLength( WPARAM wParam, LPARAM lParam )
/*****************************************************************/
{
    UNUSED_ALWAYS( wParam );
    UNUSED_ALWAYS( lParam );

    int n = CommandToIndex( ID_SEPARATOR );
    if( n < 0 ) {
        return( 0L );
    }
    return( GetPaneText( n ).GetLength() );
}
Esempio n. 5
0
void CStatusBarACT::OnPaint()
{
	if (m_crText == -1 && m_crFrom == -1 && m_crTo == -1)
	{
		Default();
	}
	else
	{
		CPaintDC dc(this);
		CRect rClient;
		CFont* pOldFont = dc.SelectObject(GetFont());

		GetClientRect(rClient);
		DrawRectBkgnd(&dc, rClient);

		int nPane = GetStatusBarCtrl().GetParts(0, NULL);
		dc.SetTextColor(m_crText);
		dc.SetBkMode(TRANSPARENT);

		while (nPane--)
		{
			CRect rect;
			GetItemRect(nPane, &rect);

			dc.TextOut(rect.left + 2, rect.top, GetPaneText(nPane));
			dc.ExcludeClipRect(rect); // so adjacent item cannot overwrite

			// draw divider
			if (nPane) // ignore first
			{
				rect.left -= 2;
				rect.right = rect.left + 1;
				rect.bottom -= 2;

				// pick color
				COLORREF color = m_crFrom;

				int nLum = RGBX(color).Luminance();
				color = (nLum < 128) ? GraphicsMisc::Lighter(m_crTo, 0.25) : GraphicsMisc::Darker(m_crTo, 0.75);
				dc.FillSolidRect(rect, color);
			}
		}

		dc.SelectObject(pOldFont);
	}
}
Esempio n. 6
0
// re-size the specified pane to exactly fit its text
void CStatusBarACT::AutoFitPane(int nIndex)
{
	if (nIndex < 0 || nIndex >= GetStatusBarCtrl().GetParts(0, NULL))
	{
		return;
	}
	// get dc, and get text width on bar, then re-size pane to fit
	try
	{
		CClientDC dc(this);
		CRect rc(0, 0, 0, 0);
		CFont* pFont = GetFont(); // get the status bar font, so it gets the size correct
		CFont* pFontOld = NULL;
		if (pFont == NULL)
		{
			pFontOld = (CFont*)dc.SelectStockObject(ANSI_VAR_FONT);
		}
		else
		{
			pFontOld = dc.SelectObject(pFont);
		}
		CString sText = GetPaneText(nIndex);
		int nPos = sText.Find(_T('\n'));
		if (nPos != -1)
		{
			sText = sText.Left(nPos);
		}
		dc.DrawText(sText, &rc, DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX);
		dc.SelectObject(pFontOld);
		int nWidth;
		UINT nID, nStyle;
		GetPaneInfo(nIndex, nID, nStyle, nWidth);
		nWidth = rc.Width();
		SetPaneInfo(nIndex, nID, nStyle, nWidth);

		// need to tell the tooltips that the 'tools' have moved
		UpdateTooltipRects();

	}
	catch (...)
	{
		;
	}
}
Esempio n. 7
0
LRESULT CStatusBar::OnGetText( WPARAM wParam, LPARAM lParam )
/***********************************************************/
{
    ASSERT( (LPCTSTR)lParam != NULL );

    int n = CommandToIndex( ID_SEPARATOR );
    if( n < 0 ) {
        ((LPTSTR)lParam)[0] = _T('\0');
        return( 0L );
    }

    CString strText = GetPaneText( n );
    int     nLength = strText.GetLength();
    if( nLength >= (int)wParam ) {
        nLength = (int)wParam - 1;
    }
    _tcsncpy( (LPTSTR)lParam, (LPCTSTR)strText, nLength );
    ((LPTSTR)lParam)[0] = _T('\0');
    return( nLength );
}
void CColorStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    int	iPane = lpDrawItemStruct->itemID;
    if (!(GetPaneStyle(iPane) & SBPS_DISABLED)) {
        CWnd	*pParentWnd = GetParent();
        ASSERT(pParentWnd != NULL);	// parent window must exist
        // get pane's background color from parent window
        COLORREF	BkColor = (COLORREF)pParentWnd->SendMessage(
                                  UWM_COLORSTATUSBARPANE, WPARAM(lpDrawItemStruct->hDC), iPane);
        CDC dc;
        dc.Attach(lpDrawItemStruct->hDC);	// attach CDC object to device context
        CRect	r(&lpDrawItemStruct->rcItem);
        dc.FillSolidRect(r, BkColor);
        dc.SetBkMode(TRANSPARENT);
        dc.SetTextAlign(TA_CENTER);
        dc.TextOut(r.left + r.Width() / 2, r.top, GetPaneText(iPane));
        // must detach CDC object from device context, otherwise device
        // context would be destroyed when CDC object goes out of scope
        dc.Detach();
    }
}
Esempio n. 9
0
bool CIVStatusBar::IsOverURL(CPoint pt, CString & rstr )
{

	if ( ! IsWindowEnabled()  || !GetTopLevelParent()->IsWindowEnabled()   )
		return false;

	CStatusBarCtrl & sb = GetStatusBarCtrl();
	int iPart = -1;
	CRect rc;
	for (int i=0; i < sb.GetParts(0, NULL); i++ )
	{
		sb.GetRect (i, rc);
		if (rc.PtInRect(pt) && ( GetPaneStyle(i) & SBT_OWNERDRAW )  )
		{
			iPart = i;
			break;
		}
	}

	if (iPart == -1)
		return false;

	if ( ! (GetPaneStyle(iPart)  & SBPS_NOBORDERS) )
		rc.InflateRect(-GetSystemMetrics(SM_CYBORDER), -GetSystemMetrics(SM_CXBORDER));

	if (!rc.PtInRect(pt))
		return false;

	CString strText = GetPaneText(iPart);
	CDC * pDC = GetDC();

	CFont * pFont = GetFont();
	CFont fntURL;
	GetLinkFont(fntURL);
	
	CFont * pOldFont =  pDC->SelectObject (pFont);

	int x = CalcX (pDC, rc, strText);

	bool bFound = false;
	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart = strText.Mid (i, szPos.cx-i);
			CRect rcURL;
			x += pDC->GetTextExtent (strStart).cx;
			rcURL.left = x;
	
			pFont = pDC->SelectObject (&fntURL);
		
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			
			CSize szURL =  pDC->GetTextExtent (strURL);
			x += szURL.cx;
			
			rcURL.right = x;
			rcURL.top = rc.top;
			rcURL.bottom = rc.top + szURL.cy;

			pDC->SelectObject (pFont);
			
			if (rcURL.PtInRect(pt))
			{
				rstr = strURL;
				bFound = true;
				break;
			}

			i = szPos.cx + szPos.cy;
		}
		else
			break;

	}

	pDC->SelectObject (pOldFont);


	return bFound;
}
Esempio n. 10
0
void CIVStatusBar::DrawItem(LPDRAWITEMSTRUCT lpdis)
{
	CDC dc;
	dc.Attach(lpdis->hDC);
	
	CString strText = GetPaneText( lpdis->itemID);

	CRect rc = lpdis->rcItem; 
	CRect rcTmp = rc;

	COLORREF clrBack = dc.SetBkColor (GetSysColor (COLOR_3DFACE));
	COLORREF clrText = dc.SetTextColor (GetSysColor (COLOR_WINDOWTEXT));

	CFont * pFont =  GetFont();

	CFont fntURL;
	GetLinkFont(fntURL);
	CFont * pOldFont =  dc.SelectObject (pFont);
	
	int x = CalcX (&dc, rc, strText);
	int y = rc.top; 

	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart  = strText.Mid (i, szPos.cx-i);
			
			dc.TextOut (x, y, strStart);
			x += dc.GetTextExtent (strStart).cx;

			COLORREF clrText = dc.SetTextColor ( GetSysColor(COLOR_HIGHLIGHT));

			pFont = dc.SelectObject (&fntURL);
			
			
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			dc.TextOut (x, y, strURL);
			
			x += dc.GetTextExtent (strURL).cx;
			
			dc.SelectObject (pFont);
			dc.SetTextColor (clrText);

			i = szPos.cx + szPos.cy;
		}
		else
		{
			CString strStart  = strText.Mid (i);
			dc.TextOut (x, y, strStart);
			break;
		}

	}

	dc.SelectObject (pOldFont);

	dc.SetBkColor (clrBack);
	dc.SetTextColor (clrText);
	
	dc.Detach ();	

}