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);
	}
}
Example #2
0
void CEditFrameDialog::AddTab_Format ()
{
	CBCGPRibbonCategory* pCategory = m_wndRibbonBar.AddCategory (
		_T("Format Text\no"), IDB_EDITCTRL_SMALL, IDB_EDITCTRL_LARGE);

	CBCGPRibbonPanel* pPanelClipboard = pCategory->AddPanel (_T("Clipboard"), m_PanelImages.ExtractIcon (0));
	pPanelClipboard->Add (new CBCGPRibbonButton (ID_EDIT_PASTE, _T("Paste"), 0, 0));
	pPanelClipboard->Add (new CBCGPRibbonButton (ID_EDIT_CUT, _T("Cut"), 1, -1));
	pPanelClipboard->Add (new CBCGPRibbonButton (ID_EDIT_COPY, _T("Copy"), 2, -1));

	CBCGPRibbonFontComboBox::m_bDrawUsingFont = TRUE;
	CBCGPRibbonPanel* pPanelFont = pCategory->AddPanel (_T("Font"), m_PanelImages.ExtractIcon (1));
	CBCGPRibbonButtonsGroup* pFontGroup = new CBCGPRibbonButtonsGroup;

	CBCGPRibbonFontComboBox* pFontCombo = new CBCGPRibbonFontComboBox (ID_FONT_FONT);
	pFontCombo->SelectItem (_T("Arial"));
	pFontGroup->AddButton (pFontCombo);

	CBCGPRibbonComboBox* pFontSizeCombo = new CBCGPRibbonComboBox (ID_FONT_SIZE, TRUE, 20);
	pFontSizeCombo->AddItem (_T("8"));
	pFontSizeCombo->AddItem (_T("9"));
	pFontSizeCombo->AddItem (_T("10"));
	pFontSizeCombo->AddItem (_T("11"));
	pFontSizeCombo->AddItem (_T("12"));
	pFontSizeCombo->AddItem (_T("14"));
	pFontSizeCombo->AddItem (_T("16"));
	pFontSizeCombo->AddItem (_T("18"));
	pFontSizeCombo->AddItem (_T("20"));
	pFontSizeCombo->AddItem (_T("22"));
	pFontSizeCombo->AddItem (_T("24"));
	pFontSizeCombo->AddItem (_T("26"));
	pFontSizeCombo->AddItem (_T("28"));
	pFontSizeCombo->AddItem (_T("36"));
	pFontSizeCombo->AddItem (_T("48"));
	pFontSizeCombo->AddItem (_T("72"));
	pFontSizeCombo->SelectItem (4);
	pFontGroup->AddButton (pFontSizeCombo);

	pPanelFont->Add (pFontGroup);

	pPanelFont->AddToolBar (IDR_EDITCTRL_FONT);

	CBCGPRibbonColorButton* pFontColorHighlightBtn = new CBCGPRibbonColorButton ();
	pFontColorHighlightBtn->EnableOtherButton (_T("Other..."));
	pFontColorHighlightBtn->SetColor (RGB (255, 255, 255));

	pPanelFont->ReplaceByID (ID_FONT_TEXTHIGHLIGHT, pFontColorHighlightBtn);

	CBCGPRibbonColorButton* pFontColorBtn = new CBCGPRibbonColorButton ();
	pFontColorBtn->SetDefaultCommand (FALSE);
	pFontColorBtn->EnableAutomaticButton (_T("&Automatic"), RGB (0, 0, 0));
	pFontColorBtn->EnableOtherButton (_T("&More Colors..."), _T("More Colors"));
	pFontColorBtn->SetColumns (10);
	pFontColorBtn->SetColorBoxSize (CSize (17, 17));
	pFontColorBtn->AddColorsGroup (_T("Theme Colors"), m_lstMainColors);
	pFontColorBtn->AddColorsGroup (_T(""), m_lstAdditionalColors, TRUE);
	pFontColorBtn->AddColorsGroup (_T("Standard Colors"), m_lstStandardColors);

	pPanelFont->ReplaceByID (ID_FONT_COLOR, pFontColorBtn);

	//pPanelFont->EnableLaunchButton (ID_FONT_BOX);

	CBCGPRibbonPanel* pPanelEditing = pCategory->AddPanel (_T("Editing"), m_PanelImages.ExtractIcon (2));
	pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_UNDO, _T("Undo"), 3, -1));
	pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_REDO, _T("Redo"), 5, -1));
	pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_REPEAT, _T("Repeat"), 4, -1));

	pPanelEditing->Add (new CBCGPRibbonSeparator ());

	pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_FIND, _T("Find"), 6, -1));
	pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_REPLACE, _T("Replace"), 7, -1));
	pPanelEditing->Add (new CBCGPRibbonButton (ID_EDIT_SELECT_ALL, _T("Select All"), 8, -1));
}