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