예제 #1
0
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);
			}
		}
	}
}
//**********************************************************************
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;
	}
}
예제 #3
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));
}