void RightTabs::Add(const Image& img, const String& tip) { Tab& t = tab.Add(); t.img = img; t.tip = tip; cx = max(cx, img.GetSize().cx + 7); Repos(); }
//********************************************************************************** void CBCGPRibbonBackstageViewPanel::AdjustScrollBars() { ASSERT_VALID(this); if (m_bInAdjustScrollBars) { return; } m_bInAdjustScrollBars = TRUE; int nScrollOffsetOld = m_nScrollOffset; int nScrollOffsetHorzOld = m_nScrollOffsetHorz; m_rectScrollCorner.SetRectEmpty(); m_rectRight.right = m_rect.right; m_rectRight.bottom = m_rect.bottom; const int cxScroll = ::GetSystemMetrics (SM_CXVSCROLL); const int cyScroll = ::GetSystemMetrics (SM_CYHSCROLL); int nTotalWidth = m_rectMenuElements.Width() + m_sizeRightView.cx; BOOL bHasVertScrollBar = FALSE; BOOL bHasHorzScrollBar = m_pScrollBarHorz->GetSafeHwnd() != NULL && nTotalWidth > m_rect.Width(); // Adjust vertical scroll bar: if (m_pScrollBar->GetSafeHwnd() == NULL) { m_nScrollOffset = 0; } else { int nTotalHeight = max(m_nTotalHeight, m_sizeRightView.cy); if (nTotalHeight <= m_rect.Height()) { m_pScrollBar->ShowWindow(SW_HIDE); m_nScrollOffset = 0; } else { int nVertScrollHeight = m_rect.Height(); if (bHasHorzScrollBar) { nVertScrollHeight -= cyScroll; } m_pScrollBar->SetWindowPos (NULL, m_rect.right - cxScroll, m_rect.top, cxScroll, nVertScrollHeight, SWP_NOZORDER | SWP_NOACTIVATE); SCROLLINFO si; ZeroMemory (&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; si.nMax = nTotalHeight; si.nPage = m_rect.Height (); m_pScrollBar->SetScrollInfo (&si, TRUE); m_pScrollBar->ShowWindow(SW_SHOWNOACTIVATE); m_pScrollBar->RedrawWindow(); m_rectRight.right -= cxScroll; if (m_nScrollOffset > nTotalHeight) { m_nScrollOffset = nTotalHeight; } bHasVertScrollBar = TRUE; } } // Adjust horizontal scroll bar: if (m_pScrollBarHorz->GetSafeHwnd() == NULL) { m_nScrollOffsetHorz = 0; } else { if (nTotalWidth <= m_rect.Width()) { m_pScrollBarHorz->ShowWindow(SW_HIDE); m_nScrollOffsetHorz = 0; } else { int nHorzScrollWidth = m_rect.Width(); if (bHasVertScrollBar) { nHorzScrollWidth -= cxScroll; } m_pScrollBarHorz->SetWindowPos (NULL, m_rect.left, m_rect.bottom - cyScroll, nHorzScrollWidth, cyScroll, SWP_NOZORDER | SWP_NOACTIVATE); SCROLLINFO si; ZeroMemory (&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; si.nMax = nTotalWidth; si.nPage = m_rect.Width (); m_pScrollBarHorz->SetScrollInfo (&si, TRUE); m_pScrollBarHorz->ShowWindow(SW_SHOWNOACTIVATE); m_pScrollBarHorz->RedrawWindow(); m_rectRight.bottom -= cyScroll; if (m_nScrollOffsetHorz > nTotalWidth) { m_nScrollOffsetHorz = nTotalWidth; } } } if (bHasVertScrollBar && bHasHorzScrollBar) { m_rectScrollCorner = m_rect; m_rectScrollCorner.left = m_rectScrollCorner.right - cxScroll - 1; m_rectScrollCorner.top = m_rectScrollCorner.bottom - cyScroll - 1; } if ((nScrollOffsetOld != m_nScrollOffset) || (nScrollOffsetHorzOld != m_nScrollOffsetHorz) && m_pMainButton != NULL) { ASSERT_VALID (m_pMainButton); ASSERT_VALID (m_pMainButton->GetParentRibbonBar ()); CClientDC dc(m_pMainButton->GetParentRibbonBar()); CFont* pOldFont = dc.SelectObject (m_pMainButton->GetParentRibbonBar()->GetFont()); ASSERT (pOldFont != NULL); Repos(&dc, m_rect); dc.SelectObject (pOldFont); GetParentWnd()->RedrawWindow(); m_pMainButton->GetParentRibbonBar()->SetBackstageHorzOffset(m_nScrollOffsetHorz); } m_bInAdjustScrollBars = FALSE; }