BOOL COXStatusBar::SetPaneFont(int nIndex, CFont* pFont /*=NULL */) { CFont* pPaneFont=(CFont*)m_PaneFont[nIndex]; if(pPaneFont != NULL) pPaneFont->DeleteObject(); // to restore the default font if (pFont==NULL) { // if pane font==NULL there was no special font selected, so just return if (pPaneFont != NULL) { if (m_ColorArray[nIndex]==::GetSysColor(COLOR_BTNTEXT)) { UINT nID, nStyle; int cxWidth; GetPaneInfo(nIndex, nID, nStyle, cxWidth); nStyle &= ~SBT_OWNERDRAW; SetPaneInfo(nIndex, nID, nStyle, cxWidth); } delete pPaneFont; m_PaneFont[nIndex]=NULL; } return TRUE; } // Create a new font object for this pane pPaneFont=new CFont; // Assign this font to the pane m_PaneFont[nIndex]=pPaneFont; LOGFONT logFont; // Logical font struct pFont->GetObject(sizeof(LOGFONT), &logFont); if (!pPaneFont->CreateFontIndirect(&logFont)) { TRACE(_T("In COXStatusBar::SetPaneFont : Failed to create the font for pane %d\n"), nIndex); delete pPaneFont; m_PaneFont[nIndex]=NULL; return FALSE; } UINT nID, nStyle; int cxWidth; GetPaneInfo(nIndex, nID, nStyle, cxWidth); nStyle |= SBT_OWNERDRAW; SetPaneInfo(nIndex, nID, nStyle, cxWidth); return TRUE; }
BOOL COXStatusBar::SetPaneText(int nIndex, LPCTSTR lpszNewText, COLORREF clrTextColor /*=::GetSysColor(COLOR_BTNTEXT) */, BOOL bUpdate /*=TRUE */) { BOOL bSuccess=CStatusBar::SetPaneText(nIndex, lpszNewText, bUpdate); if (!bSuccess) return FALSE; // changing the textcolor requires an ownerdrawn style if (clrTextColor != m_ColorArray[nIndex] && m_PaneFont[nIndex]==NULL) { UINT nID, nStyle; int cxWidth; GetPaneInfo(nIndex, nID, nStyle, cxWidth); // if the color is changed back to the default stausbar text color, // remove the OWNERDRAWN style if (clrTextColor != ::GetSysColor(COLOR_BTNTEXT)) nStyle |= SBT_OWNERDRAW; else nStyle &= ~SBT_OWNERDRAW; m_ColorArray[nIndex]=clrTextColor; SetPaneInfo(nIndex, nID, nStyle, cxWidth); } else m_ColorArray[nIndex]=clrTextColor; return TRUE; }
void CPmwStatusBar::DoPaint(CDC* pDC) { INHERITED::DoPaint(pDC); if (m_nCount > 1) { DRAWITEMSTRUCT dis; memset(&dis, 0, sizeof(dis)); dis.hwndItem = GetSafeHwnd(); dis.hDC = pDC->m_hDC; for (dis.itemID = 1; dis.itemID <= 3; dis.itemID++) { UINT uStyle; int nWidth; // Get the pane info to get the ID. GetPaneInfo(dis.itemID, dis.CtlID, uStyle, nWidth); // Get the item rect. GetItemRect(dis.itemID, &dis.rcItem); // If we need to draw this item, do it now. if (::RectVisible(pDC->m_hDC, &dis.rcItem)) { DrawItem(&dis); } } } }
//------------------------------------------------------------------------------ void CNetscapeStatusBar::DrawSignedStatus(HDC hdc) { int idx = CommandToIndex( IDS_SIGNED_STATUS ); if (idx < 0) return; UINT nID, nStyle; int cxWidth; GetPaneInfo(idx, nID, nStyle, cxWidth); BOOL bSigned = !(nStyle & SBPS_DISABLED); if (bSigned) { RECT rect; GetItemRect( idx, &rect ); HDC hdcBitmap = ::CreateCompatibleDC( hdc ); HBITMAP hbmOld = (HBITMAP)::SelectObject( hdcBitmap, sm_hbmpSecure ); FEU_TransBlt( hdc, rect.left+1, rect.top+1, sm_sizeSecure.cx, sm_sizeSecure.cy, hdcBitmap, sm_sizeSecure.cx * 2, 0 ,WFE_GetUIPalette(GetParentFrame())); ::SelectObject( hdcBitmap, hbmOld ); VERIFY( ::DeleteDC( hdcBitmap )); } }
//------------------------------------------------------------------------------ void CNetscapeStatusBar::SaveModeState() { switch( m_enStatBarMode ) { case eSBM_Panes: { #ifdef MOZ_TASKBAR if( m_bTaskbar ) { // Save the IDS_TASKBAR pane width UINT u; GetPaneInfo( CommandToIndex( IDS_TASKBAR ), u, u, m_iStatBarPaneWidth ); } #endif /* MOZ_TASKBAR */ break; } case eSBM_Simple: { // Don't care to save anything break; } default: { break; } } }
void CColorStatusBar::SetOwnerDraw(int PaneIdx) { UINT nID, nStyle; int nWidth; GetPaneInfo(PaneIdx, nID, nStyle, nWidth); SetPaneInfo(PaneIdx, nID, nStyle | SBPS_OWNERDRAW, nWidth); }
void MPCStatusBar::SetPaneWidth(int index, int cxWidth) { UINT nID,nStyle; int width; GetPaneInfo(index,nID,nStyle,width); SetPaneInfo(index,nID,nStyle,cxWidth); }
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; }
BOOL CStatusBarXP::SetIndicators (const UINT* lpIDArray, int nIDCount) { if ( !CStatusBar::SetIndicators (lpIDArray, nIDCount) ) { return false; } SendMessage (SB_SETMINHEIGHT, 20); for ( int i = 0; i < nIDCount; i++ ) { UINT a, b; int c; GetPaneInfo (i, a, b, c); SetPaneInfo (i, a, b|SBPS_NOBORDERS, c); } return true; }
void CPmwStatusBar::SetPreviewPanes(void) { SetIndicators(uIndicatorIDs, 1); // Set up the panes. UINT uID; UINT uStyle; int nWidth; GetPaneInfo(0, uID, uStyle, nWidth); SetPaneInfo(0, uID, uStyle, 1); #if 0 SetPaneInfo(1, 0, 0, 0); SetPaneInfo(2, 0, 0, 0); SetPaneInfo(3, 0, 0, 0); #endif }
// 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 (...) { ; } }
//------------------------------------------------------------------------------ BOOL CNetscapeStatusBar::SetTaskBarPaneWidth( int iWidth ) { #ifdef MOZ_TASKBAR if( !m_bTaskbar || (iWidth < 0) ) { return FALSE; } int nIndex = CommandToIndex( IDS_TASKBAR ); if( nIndex != -1 ) { UINT nID, nStyle; int nWidth; GetPaneInfo( nIndex, nID, nStyle, nWidth ); SetPaneInfo( nIndex, nID, nStyle, iWidth ); } else { // The pane is not available right now. We'll resize the pane later. m_iStatBarPaneWidth = iWidth; } #endif /* MOZ_TASKBAR */ return TRUE; }
void CPWStatusBar::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bUseToolTips) { goto exit; } else { CRect rectClient; GetClientRect(&rectClient); int nPane = -1; if (rectClient.PtInRect(point)) { CPoint pointScreen; ::GetCursorPos(&pointScreen); RECT rc; for (int i = 0; i < SB_TOTAL; i++) { GetItemRect(i, &rc); // Fix width for the last Panel under Windows XP (not later versions) // http://stackoverflow.com/questions/628933/cstatusbarctrl-getitemrect-xp-manifest if (i == SB_TOTAL - 1) { UINT uiID, uiStyle; int cxWidth; GetPaneInfo(i, uiID, uiStyle, cxWidth); if (rc.right - rc.left < cxWidth) rc.right = rc.left + ::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXBORDER) * 2; } if (PtInRect(&rc, point)) { nPane = i; break; } } } if (m_nHoverSBTimerID) { if (nPane >= 0 && m_HoverSBnPane == nPane) return; KillTimer(m_nHoverSBTimerID); m_nHoverSBTimerID = 0; } if (m_nShowSBTimerID) { if (nPane >= 0 && m_HoverSBnPane == nPane) return; KillTimer(m_nShowSBTimerID); m_nShowSBTimerID = 0; ShowToolTip(m_HoverSBnPane, false); } if (!m_bMouseInWindow) { m_bMouseInWindow = true; TRACKMOUSEEVENT tme = {sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd, 0}; VERIFY(TrackMouseEvent(&tme)); } m_nHoverSBTimerID = SetTimer(TIMER_SB_HOVER, HOVER_TIME_SB, NULL); m_HoverSBPoint = point; m_HoverSBnPane = nPane; } exit: CStatusBar::OnMouseMove(nFlags, point); }