void CXTPCustomizeToolbarsPage::OnRenameToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (pToolBar->IsBuiltIn()) return; CXTPNewToolbarDlg dlg(m_pSheet, pCommandBars, pToolBar); if (dlg.DoModal() == IDOK) { pToolBar->SetTitle(dlg.m_strToolbar); m_checkList.DeleteString(nIndex); nIndex = m_checkList.InsertString(nIndex, pToolBar->GetTitle()); m_checkList.SetCheck(nIndex, pToolBar->IsVisible()); m_checkList.SetItemData(nIndex, i); m_checkList.SetCurSel(nIndex); } }
void CXTPDockBar::GetVisibleToolbars(int nPos, CToolBarArray& arrBars) { ASSERT(nPos != -1); ASSERT(m_arrBars[nPos]); while (m_arrBars[nPos] != NULL && nPos > 0) { nPos--; } nPos++; CDockInfoArray arrInfo; while (m_arrBars[nPos] != NULL) { CXTPToolBar* pBar = m_arrBars[nPos++]; if (pBar->IsVisible()) { DOCK_INFO dockInfo(pBar, CXTPWindowRect(pBar), nPos); arrInfo.Add(dockInfo); } } if (m_dwStyle & CBRS_LEFT || m_dwStyle & CBRS_RIGHT) arrInfo.InvertRects(); arrInfo.Sort(); for (int i = 0; i < arrInfo.GetSize(); i++) { arrBars.Add(arrInfo[i].pBar); } }
CSize CXTPDockBar::CalcDynamicLayout(int nLength, DWORD nMode, AFX_SIZEPARENTPARAMS* lpLayout) { BOOL bHorz = nMode & LM_HORZ; BOOL bStretch = nMode & LM_STRETCH; CSize sizeFixed (bStretch && bHorz ? 32767 : 0, bStretch && !bHorz ? 32767 : 0); BOOL bLayoutQuery = (lpLayout->hDWP == NULL); // prepare for layout AFX_SIZEPARENTPARAMS layout; layout.hDWP = bLayoutQuery ? 0 : ::BeginDeferWindowPos((int)m_arrBars.GetSize()); CPoint pt(0, 0); // layout all the control bars for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CToolBarArray lst; CXTPToolBar* pBar = GetDockedCommandBar(nPos); while (pBar) { if (pBar->IsVisible()) lst.Add(pBar); pBar = GetDockedCommandBar(++nPos); } int nWidth = 0; if (lst.GetSize() != 0) { nWidth = AdjustRow(lst, pt, nLength, bHorz, &layout); lst.RemoveAll(); } if (pBar == NULL && nWidth != 0) { // end of row because pBar == NULL if (bHorz) { pt.y += nWidth; sizeFixed.cy = max(sizeFixed.cy, pt.y); } else { pt.x += nWidth; sizeFixed.cx = max(sizeFixed.cx, pt.x); } } } if (!bLayoutQuery) { // move and resize all the windows at once! if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP)) TRACE0("Warning: DeferWindowPos failed - low system resources.\n"); } return sizeFixed; }
int CXTPDockBar::GetDockedVisibleCount() const { int nCount = 0; for (int i = 0; i < m_arrBars.GetSize(); i++) { CXTPToolBar* pBar = GetDockedCommandBar(i); if (pBar != NULL && pBar->IsVisible()) nCount++; } return nCount; }
int CXTPDockBar::Insert(CXTPToolBar* pBarIns, CRect /*rect*/, CPoint ptMid) { ASSERT_VALID(this); ASSERT(pBarIns != NULL); int nPos = 0; int nPosInsAfter = 0; int nWidth = 0; int nTotalWidth = 0; //int nPosInsBefore = 0; BOOL bHorz = m_dwStyle & CBRS_ORIENT_HORZ; BOOL bAllowTopMost = pBarIns->IsRibbonBar() || m_pCommandBars->GetMenuBar() == NULL || !m_pCommandBars->GetMenuBar()->IsRibbonBar() || FindBar(m_pCommandBars->GetMenuBar()) == -1; for (nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CXTPToolBar* pBar = GetDockedCommandBar(nPos); if (pBar && !pBar->IsVisible()) continue; if (pBar != NULL) { CRect rectBar; pBar->GetWindowRect(&rectBar); ScreenToClient(&rectBar); nWidth = max(nWidth, bHorz ? rectBar.bottom : rectBar.right); } else // end of row because pBar == NULL { if ((bHorz ? ptMid.y : ptMid.x) < nWidth && (bAllowTopMost || nPosInsAfter > 1)) { if (nPos == 0 || ((bHorz ? ptMid.y : ptMid.x) == nTotalWidth)) // first section m_arrBars.InsertAt(nPosInsAfter + 1, (CXTPToolBar*)NULL); m_arrBars.InsertAt(nPosInsAfter + 1, pBarIns); return nPosInsAfter + 1; } nTotalWidth = nWidth; nWidth = 0; nPosInsAfter = nPos; } } // create a new row m_arrBars.InsertAt(nPosInsAfter + 1, (CXTPToolBar*)NULL); m_arrBars.InsertAt(nPosInsAfter + 1, pBarIns); return nPosInsAfter + 1; }
void CXTPCustomizeToolbarsPage::RefreshToolbarsList() { int nIndexSel = 0; int nIndex = m_checkList.GetCurSel(); if (nIndex != LB_ERR) { nIndexSel = (int)m_checkList.GetItemData(nIndex); } int nTopIndex = m_checkList.GetTopIndex(); m_checkList.ResetContent(); CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int nCount = pCommandBars->GetCount(); for (int i = 0; i < nCount; i++) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsCustomizeDialogPresent()) continue; if (!pToolBar->IsCloseable() && !pToolBar->IsVisible()) continue; nIndex = m_checkList.AddString(pToolBar->GetTitle()); m_checkList.SetCheck(nIndex, pToolBar->IsVisible()); m_checkList.SetItemData(nIndex, i); if (i == nIndexSel) m_checkList.SetCurSel(nIndex); } if (m_checkList.GetTopIndex() != nTopIndex) m_checkList.SetTopIndex(nTopIndex); OnSelectionChanged(); }