//********************************************************************** void CBCGPRibbonCustomizeRibbonPage::OnAdd() { ASSERT_VALID (m_pRibbonBar); if (m_pSelCategorySrc != NULL) { ASSERT_VALID(m_pSelCategorySrc); UINT nContextID = GetNewTabContextID(); CBCGPRibbonCategory* pNewTab = m_pSelCategorySrc->CreateCustomCopy(m_pRibbonBar); ASSERT_VALID(pNewTab); pNewTab->m_uiContextID = nContextID; pNewTab->m_bIsVisible = nContextID == 0; if (nContextID != 0) { pNewTab->SetTabColor(m_pRibbonBar->GetContextColor(nContextID)); } m_pRibbonBar->AddCustomCategory(pNewTab, TRUE); m_CustomizationData.AddCustomTab(*pNewTab, GetNewTabIndex(), nContextID); RebuildDestTree((DWORD_PTR)pNewTab, TRUE); m_wndRibbonTreeSrc.MoveSelection(TRUE); return; } if (m_pSelPanelSrc != NULL) { ASSERT_VALID(m_pSelPanelSrc); CBCGPRibbonCategory* pParentCategory = m_pSelCategoryDest; if (pParentCategory == NULL) { if (m_pSelPanelDest != NULL) { ASSERT_VALID(m_pSelPanelDest); pParentCategory = m_pSelPanelDest->GetParentCategory(); } else if (m_pSelElemDest != NULL) { ASSERT_VALID(m_pSelElemDest); pParentCategory = m_pSelElemDest->GetParentCategory(); } } if (pParentCategory == NULL) { ASSERT(FALSE); return; } ASSERT_VALID(pParentCategory); if (pParentCategory->HasPanel(m_pSelPanelSrc)) { if (m_CustomizationData.IsPanelHidden(m_pSelPanelSrc)) { m_CustomizationData.ShowPanel(m_pSelPanelSrc, TRUE); RebuildDestTree((DWORD_PTR)m_pSelPanelSrc, TRUE); } } else { CBCGPRibbonPanel* pNewPanel = m_pSelPanelSrc->CreateCustomCopy(pParentCategory); ASSERT_VALID(pNewPanel); pNewPanel->m_bIsNew = TRUE; int nIndex = GetNewPanelIndex(); pParentCategory->AddCustomPanel(pNewPanel, nIndex); m_CustomizationData.AddCustomPanel(*pNewPanel, nIndex); RebuildDestTree((DWORD_PTR)pNewPanel, TRUE); m_wndRibbonTreeSrc.MoveSelection(TRUE); } return; } if (m_pSelElemSrc != NULL) { ASSERT_VALID(m_pSelElemSrc); CBCGPRibbonPanel* pPanel = m_pSelPanelDest; if (pPanel == NULL) { if (m_pSelElemDest != NULL) { pPanel = m_pSelElemDest->GetParentPanel(); } } if (pPanel == NULL) { ASSERT(FALSE); return; } ASSERT_VALID(pPanel); CBCGPBaseRibbonElement* pElem = m_pSelElemSrc->CreateCustomCopy(); ASSERT_VALID (pElem); pElem->SetParentCategory(pPanel->GetParentCategory()); pElem->m_bIsNew = TRUE; pPanel->Add(pElem); m_CustomizationData.AddCustomElement(*pPanel, *pElem); m_wndRibbonTreeSrc.MoveSelection(TRUE); RebuildDestTree((DWORD_PTR)pElem); return; } }