void CBCGPRibbonConstructor::ConstructPanel (CBCGPRibbonPanel& panel, const CBCGPRibbonInfo::XPanel& info) const { panel.SetKeys (info.m_strKeys); panel.SetJustifyColumns (info.m_bJustifyColumns); panel.SetCenterColumnVert (info.m_bCenterColumnVert); ConstructElement (panel.GetLaunchButton (), info.m_btnLaunch); int i = 0; for (i = 0; i < info.m_arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElement = CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]); if (pElement != NULL) { ASSERT_VALID (pElement); CBCGPRibbonSeparator* pSeparator = DYNAMIC_DOWNCAST (CBCGPRibbonSeparator, pElement); if (pSeparator) { panel.AddSeparator (); delete pSeparator; } else { panel.Add (pElement); } } } }
CMapStringToString::CAssoc* CMapStringToString::NewAssoc() { if (m_pFreeList == NULL) { // add another block CPlex* newBlock = CPlex::Create(m_pBlocks, m_nBlockSize, sizeof(CMapStringToString::CAssoc)); // chain them into free list CMapStringToString::CAssoc* pAssoc = (CMapStringToString::CAssoc*) newBlock->data(); // free in reverse order to make it easier to debug pAssoc += m_nBlockSize - 1; for (int i = m_nBlockSize-1; i >= 0; i--, pAssoc--) { pAssoc->pNext = m_pFreeList; m_pFreeList = pAssoc; } } ASSERT(m_pFreeList != NULL); // we must have something CMapStringToString::CAssoc* pAssoc = m_pFreeList; m_pFreeList = m_pFreeList->pNext; m_nCount++; ASSERT(m_nCount > 0); // make sure we don't overflow memcpy(&pAssoc->key, &afxEmptyString, sizeof(CString)); ConstructElement(&pAssoc->value); return pAssoc; }
CStringList::CNode* CStringList::NewNode(CStringList::CNode* pPrev, CStringList::CNode* pNext) { if (m_pNodeFree == NULL) { // add another block CPlex* pNewBlock = CPlex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode)); // chain them into free list CNode* pNode = (CNode*) pNewBlock->data(); // free in reverse order to make it easier to debug pNode += m_nBlockSize - 1; for (int i = m_nBlockSize-1; i >= 0; i--, pNode--) { pNode->pNext = m_pNodeFree; m_pNodeFree = pNode; } } ASSERT(m_pNodeFree != NULL); // we must have something CStringList::CNode* pNode = m_pNodeFree; m_pNodeFree = m_pNodeFree->pNext; pNode->pPrev = pPrev; pNode->pNext = pNext; m_nCount++; ASSERT(m_nCount > 0); // make sure we don't overflow ConstructElement(&pNode->data); return pNode; }
static void ConstructElements(CBotString* pNewData, int nCount) { while (nCount--) { ConstructElement(pNewData); pNewData++; } }
static void _ConstructElements(CString* pNewData, INT_PTR nCount) { ASSERT(nCount >= 0); while (nCount--) { ConstructElement(pNewData); pNewData++; } }
CBCGPBaseRibbonElement* CBCGPRibbonConstructor::CreateElement (const CBCGPRibbonInfo::XElement& info) const { CBCGPBaseRibbonElement* pElement = NULL; int i = 0; if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Main) == 0) { const CBCGPRibbonInfo::XElementButtonMain& infoElement = (const CBCGPRibbonInfo::XElementButtonMain&)info; CBCGPRibbonMainButton* pNewElement = new CBCGPRibbonMainButton; if (infoElement.m_Image.m_Image.GetImageWell () != NULL) { pNewElement->SetImage (infoElement.m_Image.m_Image.GetImageWell ()); } if (infoElement.m_ImageScenic.m_Image.GetImageWell () != NULL) { pNewElement->SetScenicImage (infoElement.m_ImageScenic.m_Image.GetImageWell ()); } pElement = pNewElement; ConstructElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Launch) == 0) { CBCGPRibbonLaunchButton* pNewElement = new CBCGPRibbonLaunchButton; pElement = pNewElement; ConstructElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szGroup) == 0) { CBCGPRibbonButtonsGroup* pNewElement = new CBCGPRibbonButtonsGroup; pElement = pNewElement; ConstructElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szLabel) == 0) { const CBCGPRibbonInfo::XElementLabel& infoElement = (const CBCGPRibbonInfo::XElementLabel&)info; CBCGPRibbonLabel* pNewElement = new CBCGPRibbonLabel (infoElement.m_strText, infoElement.m_bIsAlwaysLarge); pElement = pNewElement; } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szComboBox_Font) == 0) { const CBCGPRibbonInfo::XElementFontComboBox& infoElement = (const CBCGPRibbonInfo::XElementFontComboBox&)info; CBCGPRibbonFontComboBox* pNewElement = new CBCGPRibbonFontComboBox (infoElement.m_ID.m_Value, infoElement.m_nFontType, infoElement.m_nCharSet, infoElement.m_nPitchAndFamily, infoElement.m_nWidth); pElement = pNewElement; ConstructBaseElement (*pElement, info); if (infoElement.m_nWidthFloaty > 0) { pNewElement->SetWidth (infoElement.m_nWidthFloaty, TRUE); } pNewElement->SetTextAlign (infoElement.m_nTextAlign); pNewElement->SetPrompt(infoElement.m_strSearchPrompt); ((CBCGPRibbonFontComboBox*)pNewElement)->m_bHasEditBox = infoElement.m_bHasEditBox; pNewElement->EnableDropDownListResize (infoElement.m_bResizeDropDownList); if (infoElement.m_bHasEditBox) { pNewElement->EnableAutoComplete (infoElement.m_bAutoComplete); } } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szComboBox) == 0) { const CBCGPRibbonInfo::XElementComboBox& infoElement = (const CBCGPRibbonInfo::XElementComboBox&)info; CBCGPRibbonComboBox* pNewElement = new CBCGPRibbonComboBox (infoElement.m_ID.m_Value, infoElement.m_bCalculatorMode || infoElement.m_bHasEditBox, infoElement.m_nWidth, infoElement.m_strText, infoElement.m_nSmallImageIndex, infoElement.m_sortOrder); pElement = pNewElement; ConstructBaseElement (*pElement, info); if (infoElement.m_nWidthFloaty > 0) { pNewElement->SetWidth (infoElement.m_nWidthFloaty, TRUE); } pNewElement->SetTextAlign (infoElement.m_nTextAlign); pNewElement->SetPrompt(infoElement.m_strSearchPrompt); if (infoElement.m_bCalculatorMode) { pNewElement->EnableCalculator (TRUE, NULL, &infoElement.m_lstCalculatorExt); } else { pNewElement->EnableDropDownListResize (infoElement.m_bResizeDropDownList); if (infoElement.m_bHasEditBox) { pNewElement->EnableAutoComplete (infoElement.m_bAutoComplete); } if (infoElement.m_bSearchMode) { pNewElement->EnableSearchMode (TRUE, infoElement.m_strSearchPrompt); } for (i = 0; i < infoElement.m_arItems.GetSize (); i++) { pNewElement->AddItem (infoElement.m_arItems[i]); } } } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szEdit) == 0) { const CBCGPRibbonInfo::XElementEdit& infoElement = (const CBCGPRibbonInfo::XElementEdit&)info; CBCGPRibbonEdit* pNewElement = new CBCGPRibbonEdit (infoElement.m_ID.m_Value, infoElement.m_nWidth, infoElement.m_strText, infoElement.m_nSmallImageIndex); pElement = pNewElement; ConstructBaseElement (*pElement, info); if (infoElement.m_nWidthFloaty > 0) { pNewElement->SetWidth (infoElement.m_nWidthFloaty, TRUE); } pNewElement->SetTextAlign (infoElement.m_nTextAlign); pNewElement->SetPrompt(infoElement.m_strSearchPrompt); CString strValue (infoElement.m_strValue); if (infoElement.m_bSearchMode) { pNewElement->EnableSearchMode (TRUE, infoElement.m_strSearchPrompt); } else if (infoElement.m_bHasSpinButtons) { pNewElement->EnableSpinButtons (infoElement.m_nMin, infoElement.m_nMax); if (strValue.IsEmpty ()) { strValue.Format (_T("%d"), infoElement.m_nMin); } } BOOL bDontNotify = pNewElement->m_bDontNotify; pNewElement->m_bDontNotify = TRUE; pNewElement->SetEditText (strValue); pNewElement->m_bDontNotify = bDontNotify; } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Undo) == 0) { const CBCGPRibbonInfo::XElementButtonUndo& infoElement = (const CBCGPRibbonInfo::XElementButtonUndo&)info; CBCGPRibbonUndoButton* pNewElement = new CBCGPRibbonUndoButton (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_nSmallImageIndex, infoElement.m_nLargeImageIndex); pElement = pNewElement; ConstructBaseElement (*pElement, info, FALSE); pNewElement->SetButtonMode (infoElement.m_bIsButtonMode); pNewElement->EnableMenuResize (infoElement.m_bEnableMenuResize, infoElement.m_bMenuResizeVertical); pNewElement->SetDrawDisabledItems(infoElement.m_bDrawDisabledItems); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Color) == 0) { const CBCGPRibbonInfo::XElementButtonColor& infoElement = (const CBCGPRibbonInfo::XElementButtonColor&)info; CBCGPRibbonColorButton* pNewElement = new CBCGPRibbonColorButton (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_bSimpleButtonLook, infoElement.m_nSmallImageIndex, infoElement.m_nLargeImageIndex, infoElement.m_clrColor); pElement = pNewElement; ConstructBaseElement (*pElement, info); pNewElement->EnableAutomaticButton (infoElement.m_strAutomaticBtnLabel.IsEmpty () ? NULL : (LPCTSTR)infoElement.m_strAutomaticBtnLabel, infoElement.m_clrAutomaticBtnColor, !infoElement.m_strAutomaticBtnLabel.IsEmpty (), infoElement.m_strAutomaticBtnToolTip, infoElement.m_bAutomaticBtnOnTop, infoElement.m_bAutomaticBtnBorder); pNewElement->EnableOtherButton (infoElement.m_strOtherBtnLabel.IsEmpty () ? NULL : (LPCTSTR)infoElement.m_strOtherBtnLabel, infoElement.m_strOtherBtnToolTip); pNewElement->SetColorBoxSize (infoElement.m_sizeIcon); pNewElement->SetButtonMode (infoElement.m_bIsButtonMode); pNewElement->EnableMenuResize (infoElement.m_bEnableMenuResize, infoElement.m_bMenuResizeVertical); pNewElement->SetDrawDisabledItems(infoElement.m_bDrawDisabledItems); pNewElement->SetIconsInRow (infoElement.m_nIconsInRow); if (infoElement.m_arGroups.GetSize () == 0) { if (!infoElement.m_bIsButtonMode) { pNewElement->AddGroup (_T(""), (int)pNewElement->m_Colors.GetSize ()); pNewElement->m_bHasGroups = TRUE; } } } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Palette) == 0) { const CBCGPRibbonInfo::XElementButtonPalette& infoElement = (const CBCGPRibbonInfo::XElementButtonPalette&)info; CBCGPRibbonPaletteButton* pNewElement = new CBCGPRibbonPaletteButton (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_nSmallImageIndex, infoElement.m_nLargeImageIndex); pElement = pNewElement; ConstructBaseElement (*pElement, info); pNewElement->SetButtonMode (infoElement.m_bIsButtonMode); pNewElement->EnableMenuResize (infoElement.m_bEnableMenuResize, infoElement.m_bMenuResizeVertical); pNewElement->SetDrawDisabledItems(infoElement.m_bDrawDisabledItems); pNewElement->SetIconsInRow (infoElement.m_nIconsInRow); pNewElement->Clear (); int nCount = (int)infoElement.m_arGroups.GetSize (); if (nCount > 0) { BOOL bIsOwnerDraw = pNewElement->m_bIsOwnerDraw; pNewElement->m_bIsOwnerDraw = TRUE; for (int i = 0; i < nCount; i++) { pNewElement->AddGroup (infoElement.m_arGroups[i]->m_strName, infoElement.m_arGroups[i]->m_nItems); } pNewElement->m_bIsOwnerDraw = bIsOwnerDraw; } const_cast<CBCGPToolBarImages&>(infoElement.m_Images.m_Image).CopyTo (pNewElement->m_imagesPalette); pNewElement->m_nIcons = pNewElement->m_imagesPalette.GetCount (); pNewElement->CreateIcons (); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Hyperlink) == 0) { const CBCGPRibbonInfo::XElementButtonHyperlink& infoElement = (const CBCGPRibbonInfo::XElementButtonHyperlink&)info; CBCGPRibbonHyperlink* pNewElement = new CBCGPRibbonHyperlink (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_strLink); pElement = pNewElement; ConstructBaseElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Radio) == 0) { const CBCGPRibbonInfo::XElementButtonRadio& infoElement = (const CBCGPRibbonInfo::XElementButtonRadio&)info; CBCGPRibbonRadioButton* pNewElement = new CBCGPRibbonRadioButton (infoElement.m_ID.m_Value, infoElement.m_strText); pElement = pNewElement; ConstructBaseElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Check) == 0) { const CBCGPRibbonInfo::XElementButtonCheck& infoElement = (const CBCGPRibbonInfo::XElementButtonCheck&)info; CBCGPRibbonCheckBox* pNewElement = new CBCGPRibbonCheckBox (infoElement.m_ID.m_Value, infoElement.m_strText); pElement = pNewElement; ConstructBaseElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szStatusPane) == 0) { const CBCGPRibbonInfo::XElementStatusPane& infoElement = (const CBCGPRibbonInfo::XElementStatusPane&)info; CBCGPRibbonStatusBarPane* pNewElement = new CBCGPRibbonStatusBarPane (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_bIsStatic); pElement = pNewElement; ConstructBaseElement (*pElement, info); if (!infoElement.m_strAlmostLargeText.IsEmpty()) { pNewElement->SetAlmostLargeText (infoElement.m_strAlmostLargeText); } pNewElement->SetTextAlign (infoElement.m_nTextAlign); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_MainPanel) == 0) { const CBCGPRibbonInfo::XElementButtonMainPanel& infoElement = (const CBCGPRibbonInfo::XElementButtonMainPanel&)info; CBCGPRibbonMainPanelButton* pNewElement = new CBCGPRibbonMainPanelButton (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_nSmallImageIndex); pElement = pNewElement; ConstructBaseElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Command) == 0) { const CBCGPRibbonInfo::XElementButtonCommand& infoElement = (const CBCGPRibbonInfo::XElementButtonCommand&)info; CBCGPRibbonButton* pNewElement = new CBCGPRibbonButton (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_bIsMenu ? -1 : infoElement.m_nSmallImageIndex); pElement = pNewElement; ConstructBaseElement (*pElement, info, FALSE); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szButton) == 0) { const CBCGPRibbonInfo::XElementButton& infoElement = (const CBCGPRibbonInfo::XElementButton&)info; CBCGPRibbonButton* pNewElement = new CBCGPRibbonButton (infoElement.m_ID.m_Value, infoElement.m_strText, infoElement.m_nSmallImageIndex, infoElement.m_nLargeImageIndex, infoElement.m_bIsAlwaysShowDescription); pElement = pNewElement; ConstructBaseElement (*pElement, info); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szSlider) == 0) { const CBCGPRibbonInfo::XElementSlider& infoElement = (const CBCGPRibbonInfo::XElementSlider&)info; CBCGPRibbonSlider* pNewElement = new CBCGPRibbonSlider (infoElement.m_ID.m_Value, infoElement.m_nWidth, infoElement.m_dwStyle); pElement = pNewElement; ConstructBaseElement (*pElement, info); pNewElement->SetZoomButtons (infoElement.m_bZoomButtons); pNewElement->SetRange (infoElement.m_nMin, infoElement.m_nMax); pNewElement->SetPos (infoElement.m_nPos, FALSE); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szProgress) == 0) { const CBCGPRibbonInfo::XElementProgressBar& infoElement = (const CBCGPRibbonInfo::XElementProgressBar&)info; CBCGPRibbonProgressBar* pNewElement = new CBCGPRibbonProgressBar (infoElement.m_ID.m_Value, infoElement.m_nWidth, infoElement.m_nHeight, infoElement.m_bVertical); pElement = pNewElement; ConstructBaseElement (*pElement, info); pNewElement->SetRange (infoElement.m_nMin, infoElement.m_nMax); pNewElement->SetPos (infoElement.m_nPos, FALSE); pNewElement->SetInfiniteMode (infoElement.m_bInfinite); } else if (info.GetElementName ().Compare (CBCGPRibbonInfo::s_szSeparator) == 0) { const CBCGPRibbonInfo::XElementSeparator& infoElement = (const CBCGPRibbonInfo::XElementSeparator&)info; CBCGPRibbonSeparator* pSeparator = new CBCGPRibbonSeparator (infoElement.m_bIsHoriz); pElement = pSeparator; } return pElement; }
void CBCGPRibbonConstructor::ConstructRibbonBar (CBCGPRibbonBar& bar) const { const CBCGPRibbonInfo::XRibbonBar& infoBar = GetInfo ().GetRibbonBar (); CBCGPRibbonPanel::m_nNextPanelID = (UINT)-10; bar.m_VersionStamp = GetInfo ().GetVersionStamp (); bar.EnableToolTips (infoBar.m_bToolTip, infoBar.m_bToolTipDescr); bar.EnableKeyTips (infoBar.m_bKeyTips); bar.EnablePrintPreview (infoBar.m_bPrintPreview); bar.SetBackstageMode (infoBar.m_bBackstageMode); CBCGPRibbonFontComboBox::m_bDrawUsingFont = infoBar.m_bDrawUsingFont; const_cast<CBCGPToolBarImages&>(infoBar.m_Images.m_Image).CopyTo (bar.m_PanelIcons); if (infoBar.m_btnMain != NULL) { CBCGPRibbonMainButton* btnMain = bar.GetMainButton (); if (btnMain == NULL) { btnMain = CreateMainButton (bar); } if (btnMain != NULL) { ConstructElement (*btnMain, *infoBar.m_btnMain); } } if (infoBar.m_MainCategory != NULL) { ConstructCategoryMain (bar, *infoBar.m_MainCategory); } if (infoBar.m_BackstageCategory != NULL) { ConstructCategoryBackstage (bar, *infoBar.m_BackstageCategory); } ConstructTabElements (bar, infoBar); int i = 0; for (i = 0; i < infoBar.m_arCategories.GetSize (); i++) { const CBCGPRibbonInfo::XCategory& infoCategory = *(const CBCGPRibbonInfo::XCategory*)infoBar.m_arCategories[i]; CBCGPRibbonCategory* pCategory = CreateCategory (bar, infoCategory); if (pCategory != NULL) { ASSERT_VALID (pCategory); ConstructCategory (*pCategory, infoCategory); } } for (i = 0; i < infoBar.m_arContexts.GetSize (); i++) { const CBCGPRibbonInfo::XContext* context = infoBar.m_arContexts[i]; for (int j = 0; j < context->m_arCategories.GetSize (); j++) { const CBCGPRibbonInfo::XCategory& infoCategory = *(const CBCGPRibbonInfo::XCategory*)context->m_arCategories[j]; CBCGPRibbonCategory* pCategory = CreateCategoryContext (bar, *context, infoCategory); if (pCategory != NULL) { ASSERT_VALID (pCategory); ConstructCategory (*pCategory, infoCategory); } } } ConstructQATElements (bar, infoBar); }