Пример #1
0
/*====================================================================*/
int CTimeStatusBar::SetTimeStatusBarTextWidth() {
  /*====================================================================*/
  int width[4];
  if (GetStatusBarCtrl().GetParts(1,width)<1) return 0;
  width[0] -= 380;           width[1] = width[0] +  80;
  width[2] = width[1] + 100; width[3] = width[2] + 200;
  if (!GetStatusBarCtrl().SetParts(4,width)) return 0;
  return 1;
}
Пример #2
0
void CAppStatusBar::OnSize(UINT nType, int cx, int cy) 
{
	CStatusBar::OnSize(nType, cx, cy);
	
	CRect rc;
	int i = CommandToIndex (ID_SB_TRAFFIC_THISMONTH);
	GetStatusBarCtrl ().GetRect (i, &rc);
	m_ttip.SetToolRect (this, ID_SB_TRAFFIC_THISMONTH, &rc);

	i = CommandToIndex (ID_SB_TOTALSPEED);
	GetStatusBarCtrl ().GetRect (i, &rc);
	m_ttip.SetToolRect (this, ID_SB_TOTALSPEED, &rc);	
}
Пример #3
0
// sets a pane's tool-tip text, by the pane's index
BOOL CStatusBarACT::SetPaneTooltipIndex(int nIndex, LPCTSTR lpszText/*=NULL*/)
{
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	if (nIndex >= nMax || nIndex < 0)
	{
		return FALSE;
	}
	CToolInfo ti;
	if (lpszText == NULL || *lpszText == _T('\0'))
	{
		m_tooltip.DelTool(this, nIndex + 1);
	}
	else if (! m_tooltip.GetToolInfo(ti, this, nIndex + 1))
	{
		// get bounding rect of pane, and add tool
		// add one to index, as tooltips don't allow ids of 0
		CRect rc;
		GetItemRect(nIndex, &rc);
		m_tooltip.AddTool(this, lpszText, rc, nIndex + 1);
	}
	else
	{
		m_tooltip.UpdateTipText(lpszText, this, nIndex + 1);
	}
	return TRUE;
}
Пример #4
0
void MPCStatusBar::PositionControls()
{
 int h,v,s;
 GetStatusBarCtrl( ).GetBorders( h, v, s ) ;


 for(int i = 0; i < m_aPans.GetSize(); i++ )
 {
  CRect rect;

  int index = CommandToIndex( m_aPans[i]->m_nPaneID );
  GetItemRect(index,rect);
  if( (GetPaneStyle(index) & SBPS_NOBORDERS) == SBPS_NOBORDERS)
   m_aPans[i]->m_hWnd->MoveWindow(rect);
  else
  {
   rect.top+=v;
   rect.bottom-=v;
   rect.left+=h+s;
   rect.right-=(h+s);
   m_aPans[i]->m_hWnd->MoveWindow(rect);
  }

 }
}
Пример #5
0
// sets the flags for a pane by the pane's index
BOOL CStatusBarACT::SetPaneFlagsIndex(int nIndex, DWORD dwFlags/*=SBACTF_NORMAL*/)
{
	// make sure array is big enough
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);

	if (nIndex >= nMax || nIndex < 0)
	{
		return FALSE;
	}

	if ((dwFlags & SBACTF_CLICKFLAGMASK) == 0)
	{
		dwFlags |= SBACTF_DOUBLECLICK;   // default to just double-click
	}

	if ((dwFlags & SBACTF_BUTTONFLAGMASK) == 0)
	{
		dwFlags |= SBACTF_LEFTBUTTON;   // default to just left button
	}

	if (dwFlags & SBACTF_STRETCHY)
	{
		dwFlags &= ~SBACTF_AUTOFIT;
		SetPaneStyle(nIndex, GetPaneStyle(nIndex) | SBPS_STRETCH);
	}

	m_adwFlags.SetAtGrow(nIndex, dwFlags);

	return TRUE;
}
Пример #6
0
HCURSOR CStatusBarACT::GetPaneCursorIndex(int nIndex)
{
	// make sure array is big enough
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	if (nIndex >= nMax || nIndex < 0 || m_adwCursors.GetSize() <= nIndex)
	{
		return 0;
	}
	return m_adwCursors[nIndex];
}
Пример #7
0
// need to tell the tooltips when the 'tools' have moved
// for each pane, get new rect, and pass to the tooltip control
void CStatusBarACT::UpdateTooltipRects()
{
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	for (int n = 0; n < nMax; n++)
	{
		CRect rc;
		GetItemRect(n, &rc);
		m_tooltip.SetToolRect(this, n + 1, &rc);
	}
}
Пример #8
0
// sets the cursor for a pane by the pane's index
BOOL CStatusBarACT::SetPaneCursorIndex(int nIndex, HCURSOR hCursor)
{
	// make sure array is big enough
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	if (nIndex >= nMax || nIndex < 0)
	{
		return FALSE;
	}
	m_adwCursors.SetAtGrow(nIndex, hCursor);
	return TRUE;
}
Пример #9
0
// gets the flags for a pane by the pane's index
DWORD CStatusBarACT::GetPaneFlagsIndex(int nIndex)
{
	// make sure array is big enough
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	if (nIndex >= nMax || nIndex < 0 || m_adwFlags.GetSize() <= nIndex)
	{
		return 0;
	}
	DWORD dwFlags = m_adwFlags[nIndex];
	return dwFlags;
}
Пример #10
0
void CExtStatusControlBar::_SyncStatusBarColors()
{
COLORREF clrStatusBkNeeded =
		g_PaintManager->GetColor(
			CExtPaintManager::CLR_3DFACE_OUT
			);
	if( m_clrStatusBk != clrStatusBkNeeded )
	{
		m_clrStatusBk = clrStatusBkNeeded;
		GetStatusBarCtrl().SetBkColor( m_clrStatusBk );
	}
}
Пример #11
0
// returns index under point, where point is client co-ords
// returns -1 if no pane is under the point
int CStatusBarACT::HitTest(CPoint point)
{
	CStatusBarCtrl& bar = GetStatusBarCtrl();
	int nMax = bar.GetParts(0, NULL);
	for (int nIndex = 0; nIndex < nMax; nIndex++)
	{
		CRect rc;
		GetItemRect(nIndex, &rc);
		if (rc.PtInRect(point))
		{
			return nIndex;
		}
	}
	return -1;
}
Пример #12
0
// called to modify a pane
BOOL CStatusBarACT::SetPane(LPSBACTPANEINFO lpsbactpi)
{
	if (lpsbactpi == NULL)
	{
		return FALSE;
	}
	int nIndex = CommandToIndex(lpsbactpi->nID);
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	if (nIndex < nMax)
	{
		return FALSE;
	}
	SetPaneTooltipIndex(nIndex, lpsbactpi->lpszTip);
	SetPaneFlagsIndex(nIndex, lpsbactpi->dwFlags);
	SetPaneCursorIndex(nIndex, lpsbactpi->lpszCursor);
	return TRUE;
}
Пример #13
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);
	}
}
Пример #14
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 (...)
	{
		;
	}
}
Пример #15
0
// sets the cursor for a pane by the pane's index
BOOL CStatusBarACT::SetPaneCursorIndex(int nIndex, LPCTSTR lpszCursor)
{
	// make sure array is big enough
	int nMax = GetStatusBarCtrl().GetParts(0, NULL);
	if (nIndex >= nMax || nIndex < 0)
	{
		return FALSE;
	}
	// get cursor handle and add to array of handles
	HCURSOR hCursor = NULL;
	if (lpszCursor != NULL)
	{
		CWinApp* pApp = AfxGetApp();
		ASSERT(pApp != NULL);
		if (pApp == NULL)
		{
			return FALSE;
		}
		hCursor = pApp->LoadCursor(lpszCursor);
	}
	SetPaneCursorIndex(nIndex, hCursor);
	return TRUE;
}
Пример #16
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;
}
Пример #17
0
/*====================================================================*/
int CTimeStatusBar::SetTimeStatusBarText() {
  /*====================================================================*/
  if (!GetStatusBarCtrl().SetText(timeStepNbString,1,0)) return 0;
  if (!GetStatusBarCtrl().SetText(presentTimeString,2,0)) return 0;
  return 1;
}