void CBCGPRibbonConstructor::ConstructElement (CBCGPBaseRibbonElement& element, const CBCGPRibbonInfo::XElement& info) const { if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Main) == 0 && element.IsKindOf (RUNTIME_CLASS (CBCGPRibbonMainButton))) { ConstructBaseElement (element, info); const CBCGPRibbonInfo::XElementButtonMain& infoElement = (const CBCGPRibbonInfo::XElementButtonMain&)info; CBCGPRibbonMainButton* pElement = (CBCGPRibbonMainButton*)&element; ASSERT_VALID (pElement); const_cast<CBCGPToolBarImages&>(infoElement.m_Image.m_Image).CopyTo (pElement->m_Image); const_cast<CBCGPToolBarImages&>(infoElement.m_ImageScenic.m_Image).CopyTo (pElement->m_ImageScenic); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Launch) == 0 && element.IsKindOf (RUNTIME_CLASS (CBCGPRibbonLaunchButton))) { ConstructBaseElement (element, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szGroup) == 0 && element.IsKindOf (RUNTIME_CLASS (CBCGPRibbonButtonsGroup))) { const CBCGPRibbonInfo::XElementGroup& infoElement = (const CBCGPRibbonInfo::XElementGroup&)info; CBCGPRibbonButtonsGroup* pElement = (CBCGPRibbonButtonsGroup*)&element; ASSERT_VALID (pElement); const_cast<CBCGPToolBarImages&>(infoElement.m_Images.m_Image).CopyTo (pElement->m_Images); for (int i = 0; i < infoElement.m_arButtons.GetSize (); i++) { CBCGPBaseRibbonElement* pButton = CreateElement (*(const CBCGPRibbonInfo::XElement*)infoElement.m_arButtons[i]); if (pButton != NULL) { ASSERT_VALID (pButton); pElement->AddButton (pButton); } } } else { ASSERT (FALSE); } }
//***************************************************************************** void CBCGPRibbonQuickStepsButton::CopyFrom (const CBCGPBaseRibbonElement& s) { ASSERT_VALID (this); CBCGPRibbonPaletteButton::CopyFrom (s); if (!s.IsKindOf (RUNTIME_CLASS (CBCGPRibbonQuickStepsButton))) { return; } CBCGPRibbonQuickStepsButton& src = (CBCGPRibbonQuickStepsButton&) s; RemoveAll (); for (int i = 0; i < src.m_arIcons.GetSize(); i++) { CBCGPRibbonQuickStep* pButton = new CBCGPRibbonQuickStep(); pButton->CopyFrom(*src.m_arIcons[i]); pButton->m_pOwner = this; m_arIcons.Add(pButton); } }
//****************************************************************************** void CBCGPRibbonCommandsListBox::FillFromArray ( const CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*>& arElements, BOOL bDeep, BOOL bIgnoreSeparators) { ASSERT_VALID (this); ResetContent (); m_nTextOffset = 0; BOOL bIsRibbonImageScale = globalData.IsRibbonImageScaleEnabled (); globalData.EnableRibbonImageScale (FALSE); for (int i = 0; i < arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElem = arElements [i]; ASSERT_VALID (pElem); if (bIgnoreSeparators && pElem->IsKindOf (RUNTIME_CLASS (CBCGPRibbonSeparator))) { continue; } pElem->AddToListBox (this, bDeep); int nImageWidth = pElem->GetImageSize (CBCGPBaseRibbonElement::RibbonImageSmall).cx; m_nTextOffset = max (m_nTextOffset, nImageWidth + 2); } if (GetCount () > 0) { SetCurSel (0); } globalData.EnableRibbonImageScale (bIsRibbonImageScale); }
//************************************************************************************* void CBCGPKeyMapDlg::OnSelchangeCategory() { UpdateData (); ASSERT (m_lpAccel != NULL); int iIndex = m_wndCategoryList.GetCurSel (); if (iIndex == LB_ERR) { return; } HINSTANCE hInstRes = AfxGetResourceHandle (); #ifndef BCGP_EXCLUDE_RIBBON if (m_pWndRibbonBar != NULL) { CBCGPRibbonCategory* pCategory = NULL; if (m_pWndRibbonBar->GetMainCategory () != NULL) { iIndex--; if (iIndex < 0) { pCategory = m_pWndRibbonBar->GetMainCategory (); } } if (pCategory == NULL) { pCategory = m_pWndRibbonBar->GetCategory (iIndex); } ASSERT_VALID(pCategory); CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arElements; pCategory->GetElements (arElements); AfxSetResourceHandle (m_hInstDefault); int nItem = 0; m_KeymapList.DeleteAllItems(); for (int i = 0; i < (int)arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElem = arElements [i]; ASSERT_VALID (pElem); if (!pElem->IsKindOf (RUNTIME_CLASS (CBCGPRibbonSeparator)) && pElem->GetID() > 0 && pElem->GetID() != (UINT) -1) { CString strLabel = pElem->GetToolTip(); if (strLabel.IsEmpty ()) { strLabel = pElem->GetText(); } if (!strLabel.IsEmpty()) { OnInsertItem(pElem, nItem); if (m_bItemWasAdded) { nItem++; } } } } } else #endif { CObList* pCategoryButtonsList = (CObList*) m_wndCategoryList.GetItemData (iIndex); ASSERT_VALID (pCategoryButtonsList); AfxSetResourceHandle (m_hInstDefault); int nItem = 0; m_KeymapList.DeleteAllItems(); for (POSITION pos = pCategoryButtonsList->GetHeadPosition (); pos != NULL;) { CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) pCategoryButtonsList->GetNext (pos); ASSERT (pButton != NULL); if (pButton->m_nID > 0 && pButton->m_nID != (UINT) -1) { OnInsertItem (pButton, nItem); if (m_bItemWasAdded) { nItem++; } } } } m_KeymapList.SortItems (listCompareFunc, (LPARAM) this); AfxSetResourceHandle (hInstRes); }