//**********************************************************************
void CBCGPRibbonCustomizeRibbonPage::OnNewTab() 
{
	ASSERT_VALID (m_pRibbonBar);

	UINT nContextID = GetNewTabContextID();

	CBCGPRibbonCategory* pNewTab = new CBCGPRibbonCategory(m_pRibbonBar);
	pNewTab->m_bIsNew = TRUE;
	pNewTab->SetName(m_pRibbonBar->GetCustomizationOptions().m_strNewCategoryLabel);
	pNewTab->m_uiContextID = nContextID;
	pNewTab->m_bIsVisible = nContextID == 0;
	
	if (nContextID != 0)
	{
		pNewTab->SetTabColor(m_pRibbonBar->GetContextColor(nContextID));
	}

	CBCGPRibbonPanel* pNewPanel = pNewTab->AddPanel(m_pRibbonBar->GetCustomizationOptions().m_strNewPanelLabel);
	pNewPanel->m_bIsNew = TRUE;
	pNewPanel->m_bIsCustom = TRUE;

	m_pRibbonBar->AddCustomCategory(pNewTab, TRUE);
	m_CustomizationData.AddCustomTab(*pNewTab, GetNewTabIndex(), nContextID);

	RebuildDestTree((DWORD_PTR)pNewPanel, TRUE);
}
Ejemplo n.º 2
0
void CBCGPRibbonConstructor::ConstructCategory (CBCGPRibbonCategory& category, const CBCGPRibbonInfo::XCategory& info) const
{
	const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (category.GetSmallImages ());
	const_cast<CBCGPToolBarImages&>(info.m_LargeImages.m_Image).CopyTo (category.GetLargeImages ());

	category.SetKeys (info.m_strKeys);

	int i = 0;
	for (i = 0; i < info.m_arPanels.GetSize (); i++)
	{
		const CBCGPRibbonInfo::XPanel& infoPanel = 
			*(const CBCGPRibbonInfo::XPanel*)info.m_arPanels[i];

		CBCGPRibbonPanel* pPanel = CreatePanel (category, infoPanel);
		if (pPanel != NULL)
		{
			ASSERT_VALID (pPanel);
			ConstructPanel (*pPanel, infoPanel);
		}
	}

	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);
			category.AddHidden (pElement);
		}
	}

	category.SetCollapseOrder (info.m_arCollapseOrder);
}
//**********************************************************************
void CBCGPRibbonCustomizeRibbonPage::OnNewGroup() 
{
	ASSERT_VALID (m_pRibbonBar);

	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);

	CBCGPRibbonPanel* pNewPanel = pParentCategory->AddPanel(m_pRibbonBar->GetCustomizationOptions().m_strNewPanelLabel);
	pNewPanel->m_bIsNew = TRUE;
	pNewPanel->m_bIsCustom = TRUE;

	m_CustomizationData.AddCustomPanel(*pNewPanel, GetNewPanelIndex());

	RebuildDestTree((DWORD_PTR)pNewPanel, TRUE);
}
Ejemplo n.º 4
0
void CBCGPRibbonConstructor::ConstructCategoryBackstage (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XCategoryBackstage& info) const
{
	CBCGPRibbonBackstageViewPanel* pPanel = CreateCategoryBackstage (bar, info);
	ASSERT_VALID (pPanel);

	CBCGPRibbonCategory* pCategory = bar.GetBackstageCategory ();
	ASSERT_VALID (pCategory);

	const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (pCategory->GetSmallImages ());

	int i = 0;
	for (i = 0; i < info.m_arElements.GetSize (); i++)
	{
		if (info.m_arElements[i]->GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Command) == 0)
		{
			CBCGPBaseRibbonElement* pElement = 
				CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]);

			if (pElement != NULL)
			{
				ASSERT_VALID (pElement);

				pElement->SetBackstageViewMode ();
				pPanel->CBCGPRibbonMainPanel::Add (pElement);
			}
		}
	}
}
//**********************************************************************
void CBCGPRibbonCustomizeRibbonPage::OnToolbarReset() 
{
#ifndef BCGP_EXCLUDE_GRID_CTRL
	ASSERT_VALID (m_pRibbonBar);

	CBCGPLocalResource locaRes;
	if (AfxMessageBox (IDS_BCGBARRES_RESET_RIBBON, MB_YESNO | MB_ICONWARNING) != IDYES)
	{
		return;
	}

	// Mark all custom data as "to be deleted":
	for (int i = 0; i < m_wndRibbonTreeDest.GetRowCount(); i++)
	{
		CBCGPGridRow* pRow = m_wndRibbonTreeDest.GetRow(i);
		if (pRow == NULL)
		{
			continue;
		}

		CObject* lpData = (CObject*)pRow->GetData();
		if (lpData == NULL)
		{
			continue;
		}

		CBCGPRibbonCategory* pCategory = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, lpData);
		if (pCategory != NULL && pCategory->IsCustom())
		{
			pCategory->m_bToBeDeleted = TRUE;
		}
		else
		{
			CBCGPRibbonPanel* pPanel = DYNAMIC_DOWNCAST(CBCGPRibbonPanel, lpData);
			if (pPanel != NULL && pPanel->IsCustom())
			{
				pPanel->m_bToBeDeleted = TRUE;
			}
		}
	}

	m_CustomizationData.ResetAll(m_pRibbonBar);
	RebuildDestTree();
#endif
}
Ejemplo n.º 6
0
//*******************************************************************************
void CBCGPRibbonTabsGroup::UpdateTabs(CArray<CBCGPRibbonCategory*,CBCGPRibbonCategory*>& arCategories)
{
	m_arButtons.RemoveAll();

	for (int i = 0; i < arCategories.GetSize(); i++)
	{
		CBCGPRibbonCategory* pCategory  = (CBCGPRibbonCategory*)arCategories[i];
		if (pCategory != NULL)
		{
			ASSERT_VALID(pCategory);

			if (pCategory->IsVisible() && !pCategory->m_Tab.GetRect().IsRectEmpty())
			{
				m_arButtons.Add(&pCategory->m_Tab);
			}
		}
	}
}
Ejemplo n.º 7
0
void CBCGPRibbonConstructor::ConstructCategoryMain (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XCategoryMain& info) const
{
	CBCGPRibbonMainPanel* pPanel = CreateCategoryMain (bar, info);
	ASSERT_VALID (pPanel);

	CBCGPRibbonCategory* pCategory = bar.GetMainCategory ();
	ASSERT_VALID (pCategory);

	const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (pCategory->GetSmallImages ());
	const_cast<CBCGPToolBarImages&>(info.m_LargeImages.m_Image).CopyTo (pCategory->GetLargeImages ());

	if (info.m_bSearchEnable)
	{
		pPanel->EnableCommandSearch (info.m_bSearchEnable, info.m_strSearchLabel, info.m_strSearchKeys, info.m_nSearchWidth);
	}

	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);

			if (info.m_arElements[i]->GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_MainPanel) == 0)
			{
				pPanel->AddToBottom ((CBCGPRibbonMainPanelButton*)pElement);
			}
			else
			{
				pPanel->Add (pElement);
			}
		}
	}

	if (info.m_bRecentListEnable)
	{
		pPanel->AddRecentFilesList (info.m_strRecentListLabel, info.m_nRecentListWidth, info.m_bRecentListShowPins);
	}
}
//***************************************************************************
CSize CBCGPRibbonQuickStepsButton::GetItemSize () const
{
    CBCGPRibbonQuickStepsButton* pOrigButton = DYNAMIC_DOWNCAST(CBCGPRibbonQuickStepsButton, m_pOriginal);

    if (pOrigButton != NULL)
    {
        ASSERT_VALID (pOrigButton);
        return pOrigButton->GetItemSize();
    }

    CSize size = GetIconSize();

    CBCGPRibbonCategory* pParent = GetParentCategory();
    if (pParent != NULL)
    {
        ASSERT_VALID(pParent);

        size.cx += pParent->GetImageSize(TRUE).cx * 3;
        size.cy += 4;
    }

    return size;
}
//**********************************************************************
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;
	}
}
Ejemplo n.º 10
0
void CBCGPRibbonCustomizeRibbonPage::OnSelendokCategoryCombo() 
{
	ASSERT_VALID (m_pRibbonBar);

	CWaitCursor wait;

	UpdateData ();

	if (m_nCategory < 0)
	{
		return;
	}

	m_wndRibbonTreeSrc.SetRedraw(FALSE);

	DWORD_PTR dwData = m_wndCategoryCombo.GetItemData (m_nCategory);
	
	if (dwData == 0) // Tabs
	{
		int nTabs = m_bNoContextCategories ? 1 : m_nCategory - m_wndCategoryCombo.GetCount() + 3;
		m_wndRibbonTreeSrc.RebuildItems(nTabs, m_strMainTabs);
	}
	else
	{
		CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arElements;

		CBCGPRibbonCategory* pCategory = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, (CObject*)dwData);
		if (pCategory != NULL)
		{
			ASSERT_VALID(pCategory);

			pCategory->GetElements(arElements);
			m_wndRibbonTreeSrc.RebuildItems(arElements);
		}
		else
		{
			CBCGPRibbonCustomGroup* pCustomCategory = DYNAMIC_DOWNCAST(CBCGPRibbonCustomGroup, (CObject*)dwData);
			if (pCustomCategory != NULL)
			{
				ASSERT_VALID(pCustomCategory);

				for (POSITION pos = pCustomCategory->m_lstIDs.GetHeadPosition(); pos != NULL;)
				{
					UINT uiCmd = pCustomCategory->m_lstIDs.GetNext(pos);
					if (uiCmd != 0 && uiCmd != (UINT)-1)
					{
						CBCGPBaseRibbonElement* pElem = m_pRibbonBar->FindByID (uiCmd, FALSE, FALSE);
						if (pElem != NULL)
						{
							arElements.Add(pElem);
						}
					}
				}

				m_wndRibbonTreeSrc.RebuildItems(arElements);
			}
		}
	}

	m_wndRibbonTreeSrc.SetRedraw();
	m_wndRibbonTreeSrc.RedrawWindow();
}
Ejemplo n.º 11
0
//*************************************************************************************
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);
}
Ejemplo n.º 12
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));
}
//**********************************************************************
BOOL CBCGPRibbonCustomizeQATPage::OnInitDialog() 
{
	CBCGPPropertyPage::OnInitDialog();
	
	ASSERT_VALID (m_pRibbonBar);

	CBCGPStaticLayout* pLayout = (CBCGPStaticLayout*)GetLayout ();
	if (pLayout != NULL)
	{
		pLayout->AddAnchor (IDC_BCGBARRES_CATEGORY, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeHorz, CSize(0, 0), CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_COMMANDS_LIST, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth, CSize(0, 0), CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_QAT_ON_BOTTOM, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_KEYBOARD, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_ACCEL_LABEL, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDS_BCGBARRES_ADD, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_REMOVE, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_QAT_COMMANDS_LIST, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeBoth, CSize(50, 0), CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_MOVEUP, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_MOVEDOWN, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_RESET, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
	}

	//-----------------------------------
	// Setup Customize Keyboard controls:
	//-----------------------------------
	if (!m_bIsCustomizeKeyboard || g_pKeyboardManager == NULL)
	{
		if (GetDlgItem (IDC_BCGBARRES_ACCEL_LABEL) != NULL)
		{
			GetDlgItem (IDC_BCGBARRES_ACCEL_LABEL)->ShowWindow (SW_HIDE);
		}

		m_wndKbdCustomize.EnableWindow (FALSE);
		m_wndKbdCustomize.ShowWindow (SW_HIDE);
	}

	const CString strSeparator = _T("----------");

	m_wndUp.SetStdImage (CBCGPMenuImages::IdArowUpLarge, CBCGPMenuImages::ImageBlack2, CBCGPMenuImages::IdArowUpLarge, CBCGPMenuImages::ImageLtGray);
	m_wndUp.SetWindowText(_T("Up"));
	m_wndUp.SetDrawText(FALSE, FALSE);
	
	m_wndDown.SetStdImage (CBCGPMenuImages::IdArowDownLarge, CBCGPMenuImages::ImageBlack2, CBCGPMenuImages::IdArowDownLarge, CBCGPMenuImages::ImageLtGray);
	m_wndDown.SetWindowText(_T("Down"));
	m_wndDown.SetDrawText(FALSE, FALSE);

	//-----------------------
	// Add custom categories:
	//-----------------------
	for (POSITION pos = m_lstCustomCategories.GetHeadPosition (); pos != NULL;)
	{
		CBCGPRibbonCustomGroup* pCustCategory = m_lstCustomCategories.GetNext (pos);
		ASSERT_VALID (pCustCategory);

		int nIndex = m_wndCategoryCombo.AddString (pCustCategory->m_strName);
		m_wndCategoryCombo.SetItemData (nIndex, (DWORD_PTR) pCustCategory);
	}

	if (m_wndCategoryCombo.GetCount () > 0)
	{
		m_wndCategoryCombo.AddString (strSeparator);
	}

	//-------------------
	// Add main category:
	//-------------------
	CBCGPRibbonCategory* pMainCategory = m_pRibbonBar->GetMainCategory ();
	if (pMainCategory != NULL)
	{
		ASSERT_VALID (pMainCategory);
		
		int nIndex = m_wndCategoryCombo.AddString (pMainCategory->GetName ());
		m_wndCategoryCombo.SetItemData (nIndex, (DWORD_PTR) pMainCategory);
		m_wndCategoryCombo.AddString (strSeparator);
	}

	int i = 0;
	BOOL bHasContextCategories = FALSE;

	//----------------------------
	// Add non-context categories:
	//----------------------------
	for (i = 0; i < m_pRibbonBar->GetCategoryCount (); i++)
	{
		CBCGPRibbonCategory* pCategory = m_pRibbonBar->GetCategory (i);
		ASSERT_VALID (pCategory);

		CString strCategoryName;
		if (!m_pRibbonBar->m_CustomizationData.GetTabName(pCategory, strCategoryName))
		{
			strCategoryName = pCategory->GetName ();
		}

		if (pCategory->GetContextID () == 0)
		{
			int nIndex = m_wndCategoryCombo.AddString (strCategoryName);
			m_wndCategoryCombo.SetItemData (nIndex, (DWORD_PTR) pCategory);
		}
		else
		{
			bHasContextCategories = TRUE;
		}
	}

	if (bHasContextCategories)
	{
		//------------------------
		// Add context categories:
		//------------------------
		m_wndCategoryCombo.AddString (strSeparator);

		for (i = 0; i < m_pRibbonBar->GetCategoryCount (); i++)
		{
			CBCGPRibbonCategory* pCategory = m_pRibbonBar->GetCategory (i);
			ASSERT_VALID (pCategory);

			CString strCategoryName;
			if (!m_pRibbonBar->m_CustomizationData.GetTabName(pCategory, strCategoryName))
			{
				strCategoryName = pCategory->GetName ();
			}

			const UINT uiContextID = pCategory->GetContextID ();

			if (uiContextID != 0)
			{
				CString strName;
				CString strContext;

				if (m_pRibbonBar->GetContextName (uiContextID, strContext))
				{
					strName = strContext + _T(" | ") + strCategoryName;
				}
				else
				{
					strName = strCategoryName;
				}

				int nIndex = m_wndCategoryCombo.AddString (strName);
				m_wndCategoryCombo.SetItemData (nIndex, (DWORD_PTR) pCategory);
			}
		}
	}

	if (m_wndCategoryCombo.GetCount () > 0)
	{
		m_nCategory = 0;
		UpdateData (FALSE);

		OnSelendokCategoryCombo ();
	}

	CList<UINT,UINT> lstQACommands;
	m_pRibbonBar->GetQuickAccessCommands (lstQACommands);

	m_wndQATList.FillFromIDs (lstQACommands, FALSE);

	OnSelchangeQATCommands ();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 14
0
//**********************************************************************
BOOL CBCGPRibbonCustomizeRibbonPage::OnInitDialog() 
{
	{
		CBCGPLocalResource localRes;
		CBCGPPropertyPage::OnInitDialog();
	}
	
	ASSERT_VALID (m_pRibbonBar);

	if (!m_pRibbonBar->IsCustomizationEnabled())
	{
		TRACE0("The Ribbon customization is not enabled\n");
		ASSERT(FALSE);
	}

	m_wndRibbonTabsCombo.GetLBText(1, m_strMainTabs);

	m_CustomizationData.CopyFrom(m_pRibbonBar->m_CustomizationData);

	CreateRibbonTree(m_wndRibbonSrcTreePlaceholder, m_wndRibbonTreeSrc);
	CreateRibbonTree(m_wndRibbonTreePlaceholder, m_wndRibbonTreeDest);

	CBCGPStaticLayout* pLayout = (CBCGPStaticLayout*)GetLayout ();
	if (pLayout != NULL)
	{
		pLayout->AddAnchor (IDC_BCGBARRES_CATEGORY, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeHorz, CSize(0, 0), CSize(50, 100));
		pLayout->AddAnchor (m_wndRibbonTreeSrc.GetSafeHwnd(), CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth, CSize(0, 0), CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_KEYBOARD, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_ACCEL_LABEL, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDS_BCGBARRES_ADD, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_REMOVE, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDD_BCGBAR_RES_LABEL1, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_RIBBON_TABS, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeHorz, CSize(50, 100), CSize(50, 100));
		pLayout->AddAnchor (m_wndRibbonTreeDest.GetSafeHwnd(), CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeBoth, CSize(50, 0), CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_MOVEUP, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_MOVEDOWN, CBCGPStaticLayout::e_MoveTypeHorz, CBCGPStaticLayout::e_SizeTypeNone);
		pLayout->AddAnchor (IDC_BCGBARRES_NEW_TAB, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_NEW_GROUP, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_RENAME, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDD_BCGBAR_RES_LABEL2, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
		pLayout->AddAnchor (IDC_BCGBARRES_RESET, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone, CSize(50, 100));
	}

	//-----------------------------------
	// Setup Customize Keyboard controls:
	//-----------------------------------
	if (!m_bIsCustomizeKeyboard || g_pKeyboardManager == NULL)
	{
		if (GetDlgItem (IDC_BCGBARRES_ACCEL_LABEL) != NULL)
		{
			GetDlgItem (IDC_BCGBARRES_ACCEL_LABEL)->ShowWindow (SW_HIDE);
		}

		m_wndKbdCustomize.EnableWindow (FALSE);
		m_wndKbdCustomize.ShowWindow (SW_HIDE);
	}

	m_wndUp.SetStdImage (CBCGPMenuImages::IdArowUpLarge, CBCGPMenuImages::ImageBlack2, CBCGPMenuImages::IdArowUpLarge, CBCGPMenuImages::ImageLtGray);
	m_wndUp.SetWindowText(_T("Up"));
	m_wndUp.SetDrawText(FALSE, FALSE);
	
	m_wndDown.SetStdImage (CBCGPMenuImages::IdArowDownLarge, CBCGPMenuImages::ImageBlack2, CBCGPMenuImages::IdArowDownLarge, CBCGPMenuImages::ImageLtGray);
	m_wndDown.SetWindowText(_T("Down"));
	m_wndDown.SetDrawText(FALSE, FALSE);

	//-----------------------
	// Add custom categories:
	//-----------------------
	int nIndex = 0;

	for (POSITION pos = m_lstCustomCategories.GetHeadPosition (); pos != NULL;)
	{
		CBCGPRibbonCustomGroup* pCustCategory = m_lstCustomCategories.GetNext (pos);
		ASSERT_VALID (pCustCategory);

		m_wndCategoryCombo.InsertString(nIndex, pCustCategory->m_strName);
		m_wndCategoryCombo.SetItemData (nIndex++, (DWORD_PTR) pCustCategory);
	}

	//-------------------
	// Add main category:
	//-------------------
	CBCGPRibbonCategory* pMainCategory = m_pRibbonBar->GetMainCategory ();
	if (pMainCategory != NULL)
	{
		ASSERT_VALID (pMainCategory);
		
		m_wndCategoryCombo.InsertString(nIndex, pMainCategory->GetName ());
		m_wndCategoryCombo.SetItemData (nIndex++, (DWORD_PTR) pMainCategory);
	}

	if (m_wndCategoryCombo.GetCount () > 0)
	{
		m_nCategory = 0;
		UpdateData (FALSE);

		OnSelendokCategoryCombo ();
	}

	//----------------------------------------------------------------------------
	// If ribbon doesn't have context categories, remove them from the comboboxes:
	//----------------------------------------------------------------------------
	if (m_pRibbonBar->GetContextCategoriesCount() == 0)
	{
		m_bNoContextCategories = TRUE;

		m_wndCategoryCombo.DeleteString(m_wndCategoryCombo.GetCount() - 3);
		m_wndCategoryCombo.DeleteString(m_wndCategoryCombo.GetCount() - 1);

		m_wndRibbonTabsCombo.DeleteString(0);
		m_wndRibbonTabsCombo.DeleteString(m_wndRibbonTabsCombo.GetCount() - 1);
	}

	OnSelendokRibbonTabsDest();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 15
0
BOOL CBCGPKeyMapDlg::OnInitDialog() 
{
	CBCGPDialog::OnInitDialog();

	if (AfxGetMainWnd () != NULL && 
		(AfxGetMainWnd ()->GetExStyle () & WS_EX_LAYOUTRTL))
	{
		ModifyStyleEx (0, WS_EX_LAYOUTRTL);
	}

	{
		CBCGPLocalResource locaRes;

		//-----------------
		// Set dialog icon:
		//-----------------
		SetIcon ((HICON) ::LoadImage (
			AfxGetResourceHandle (),
			MAKEINTRESOURCE (IDI_BCGBARRES_HELP),
			IMAGE_ICON,
			::GetSystemMetrics (SM_CXSMICON),
			::GetSystemMetrics (SM_CYSMICON),
			LR_SHARED), FALSE);

		//---------------
		// Setup buttons:
		//---------------
		m_ButtonPrint.m_nFlatStyle = CBCGPButton::BUTTONSTYLE_FLAT;
		m_ButtonCopy.m_nFlatStyle = CBCGPButton::BUTTONSTYLE_FLAT;

		CString strTT;

		if (m_bEnablePrint)
		{
			m_ButtonPrint.SetImage (globalData.Is32BitIcons () ? 
				IDB_BCGBARRES_PRINT32 : IDB_BCGBARRES_PRINT, NULL);
			m_ButtonPrint.GetWindowText (strTT);
			m_ButtonPrint.SetWindowText (_T(""));
			m_ButtonPrint.SetTooltip (strTT);
			m_ButtonPrint.SizeToContent ();
			m_ButtonPrint.m_bDrawFocus = FALSE;
		}
		else
		{
			m_ButtonPrint.ShowWindow (SW_HIDE);
		}

		m_ButtonCopy.SetImage (globalData.Is32BitIcons () ?
			IDB_BCGBARRES_COPY32 : IDB_BCGBARRES_COPY, NULL);
		m_ButtonCopy.GetWindowText (strTT);
		m_ButtonCopy.SetWindowText (_T(""));
		m_ButtonCopy.SetTooltip (strTT);
		m_ButtonCopy.SizeToContent ();
		m_ButtonCopy.m_bDrawFocus = FALSE;

		//-------------
		// Add columns:
		//-------------
		OnSetColumns ();
		SetColumnsWidth ();
	}

	//-------------------------------------------------------------
	// Find all application document templates and fill accelerator
	// tables  combobox by document template data:
	//-------------------------------------------------------------
	CDocManager* pDocManager = AfxGetApp ()->m_pDocManager;
	if (pDocManager != NULL)
	{
		//---------------------------------------
		// Walk all templates in the application:
		//---------------------------------------
		for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;)
		{
			CBCGPMultiDocTemplate* pTemplate = 
				(CBCGPMultiDocTemplate*) pDocManager->GetNextDocTemplate (pos);
			ASSERT_VALID (pTemplate);
			ASSERT_KINDOF (CDocTemplate, pTemplate);

			//-----------------------------------------------------
			// We are interessing CBCGPMultiDocTemplate objects with
			// the shared menu only....
			//-----------------------------------------------------
			if (!pTemplate->IsKindOf (RUNTIME_CLASS (CMultiDocTemplate)) ||
				pTemplate->m_hAccelTable == NULL)
			{
				continue;
			}

			CString strName;
			pTemplate->GetDocString (strName, CDocTemplate::fileNewName);

			int iIndex = m_wndViewTypeList.AddString (strName);
			m_wndViewTypeList.SetItemData (iIndex, (DWORD_PTR) pTemplate);
		}
	}

	//--------------------------
	// Add a default application:
	//--------------------------
	CFrameWnd* pWndMain = DYNAMIC_DOWNCAST (CFrameWnd, m_pWndParentFrame);
	if (pWndMain != NULL && pWndMain->m_hAccelTable != NULL)
	{
		CBCGPLocalResource locaRes;

		CString strName;
		strName.LoadString (IDS_BCGBARRES_DEFAULT_VIEW);

		int iIndex = m_wndViewTypeList.AddString (strName);
		m_wndViewTypeList.SetItemData (iIndex, (DWORD_PTR) NULL);

		m_wndViewTypeList.SetCurSel (iIndex);
		OnSelchangeViewType();
	}

	m_KeymapList.SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

	OnSelchangeViewType ();

	//---------------------------------
	// Initialize commands by category:
	//---------------------------------	
	if (m_pWndRibbonBar == NULL)
	{
		m_pDlgCust = new CBCGPToolbarCustomize(m_pWndParentFrame, TRUE);
		m_pDlgCust->EnableUserDefinedToolbars();
		m_pDlgCust->FillCategoriesComboBox (m_wndCategoryList);
	}
#ifndef BCGP_EXCLUDE_RIBBON
	else
	{
		CBCGPRibbonCategory* pMainCategory = m_pWndRibbonBar->GetMainCategory ();
		if (pMainCategory != NULL)
		{
			ASSERT_VALID (pMainCategory);
			m_wndCategoryList.AddString (pMainCategory->GetName ());
		}
		
		for (int i = 0; i < m_pWndRibbonBar->GetCategoryCount (); i++)
		{
			m_wndCategoryList.AddString(m_pWndRibbonBar->GetCategory (i)->GetName ());
		}
	}
#endif

	m_wndCategoryList.SetCurSel (0);
	OnSelchangeCategory ();

	//----------------------------------
	// Restore window position and size:
	//----------------------------------
	if (GetWorkspace () != NULL)
	{
		CBCGPRegistrySP regSP;
		CBCGPRegistry& reg = regSP.Create (FALSE, TRUE);

		CRect rectPosition;

		if (reg.Open (GetWorkspace ()->GetRegSectionPath (strWindowPlacementRegSection)) &&
			reg.Read (strRectKey, rectPosition))
		{
			MoveWindow (rectPosition);
		}
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 16
0
//**********************************************************************
LRESULT CBCGPRibbonCustomizeRibbonPage::OnSelChangeRibbonTree(WPARAM, LPARAM lp)
{
#ifndef BCGP_EXCLUDE_GRID_CTRL
	if (m_bDontProcessSelChanged)
	{
		return 0;
	}

	m_wndAdd.EnableWindow(FALSE);

	CBCGPGridCtrl* pGrid = (CBCGPGridCtrl*)lp;

	if (pGrid->GetSafeHwnd() == m_wndRibbonTreeDest.GetSafeHwnd())
	{
		m_wndRename.EnableWindow(FALSE);
		m_wndNewTab.EnableWindow(FALSE);
		m_wndNewGroup.EnableWindow(FALSE);
		m_wndRemove.EnableWindow(FALSE);
		m_wndUp.EnableWindow(FALSE);
		m_wndDown.EnableWindow(FALSE);

		m_pSelCategoryDest = NULL;
		m_pSelPanelDest = NULL;
		m_pSelElemDest = NULL;

		CBCGPGridRow* pRow = m_wndRibbonTreeDest.GetCurSel();
		if (pRow == NULL)
		{
			return 0;
		}

		ASSERT_VALID(pRow);

		CObject* lpData = (CObject*)pRow->GetData();
		if (lpData != NULL)
		{
			m_wndNewTab.EnableWindow();

			m_pSelCategoryDest = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, lpData);
			if (m_pSelCategoryDest != NULL)
			{
				m_wndRename.EnableWindow();
				m_wndNewGroup.EnableWindow();

				if (m_pSelCategoryDest->IsCustom())
				{
					m_wndRemove.EnableWindow();
				}

				m_wndUp.EnableWindow(!m_wndRibbonTreeDest.IsSelFirstInGroup());
				m_wndDown.EnableWindow(!m_wndRibbonTreeDest.IsSelLastInGroup());
			}
			else
			{
				m_pSelPanelDest = DYNAMIC_DOWNCAST(CBCGPRibbonPanel, lpData);
				if (m_pSelPanelDest != NULL)
				{
					m_wndRename.EnableWindow();
					m_wndNewGroup.EnableWindow();
					m_wndRemove.EnableWindow();

					m_wndUp.EnableWindow(!m_wndRibbonTreeDest.IsSelFirstInGroup());
					m_wndDown.EnableWindow(!m_wndRibbonTreeDest.IsSelLastInGroup());
				}
				else
				{
					m_pSelElemDest = DYNAMIC_DOWNCAST(CBCGPBaseRibbonElement, lpData);
					if (m_pSelElemDest != NULL)
					{
						m_wndNewGroup.EnableWindow();
						
						if (m_pSelElemDest->IsCustom() && m_pSelElemDest->GetParentPanel() != NULL)
						{
							m_wndRename.EnableWindow();
							m_wndRemove.EnableWindow();

							m_wndUp.EnableWindow(!m_wndRibbonTreeDest.IsSelFirstInGroup());
							m_wndDown.EnableWindow(!m_wndRibbonTreeDest.IsSelLastInGroup());
						}
					}
				}
			}
		}
	}
	else if (pGrid->GetSafeHwnd() == m_wndRibbonTreeSrc.GetSafeHwnd())
	{
		m_pSelCategorySrc = NULL;
		m_pSelPanelSrc = NULL;
		m_pSelElemSrc = NULL;

		CBCGPGridRow* pRow = m_wndRibbonTreeSrc.GetCurSel();
		if (pRow == NULL)
		{
			return 0;
		}

		ASSERT_VALID(pRow);

		CObject* lpData = (CObject*)pRow->GetData();
		if (lpData != NULL)
		{
			m_pSelCategorySrc = DYNAMIC_DOWNCAST(CBCGPRibbonCategory, lpData);
			m_pSelPanelSrc = DYNAMIC_DOWNCAST(CBCGPRibbonPanel, lpData);
			m_pSelElemSrc = DYNAMIC_DOWNCAST(CBCGPBaseRibbonElement, lpData);
		}
	}

	if (m_pSelCategorySrc != NULL)
	{
		m_wndAdd.EnableWindow();
	}
	else if (m_pSelPanelSrc != NULL)
	{
		ASSERT_VALID(m_pSelPanelSrc);

		CBCGPRibbonCategory* pCategory = m_pSelCategoryDest;
		if (pCategory == NULL)
		{
			if (m_pSelPanelDest != NULL)
			{
				pCategory = m_pSelPanelDest->GetParentCategory();
			}
			else if (m_pSelElemDest != NULL)
			{
				pCategory = m_pSelElemDest->GetParentCategory();
			}
		}

		if (pCategory != NULL)
		{
			m_wndAdd.EnableWindow(pCategory != NULL && pCategory->FindPanelByOriginal(m_pSelPanelSrc) == NULL);
		}
	}
	else if (m_pSelElemSrc != NULL)
	{
		ASSERT_VALID(m_pSelElemSrc);

		CBCGPRibbonPanel* pPanel = m_pSelPanelDest;
		if (pPanel == NULL && m_pSelElemDest != NULL)
		{
			pPanel = m_pSelElemDest->GetParentPanel();
		}

		BOOL bCanAdd = FALSE;

		if (pPanel != NULL && pPanel->IsCustom() && pPanel->m_pOriginal == NULL)
		{
			CBCGPRibbonCustomPanel* pCustomPanel = m_CustomizationData.FindCustomPanel(pPanel);
			if (pCustomPanel != NULL)
			{
				ASSERT_VALID(pCustomPanel);

				if (pCustomPanel->FindByID(m_pSelElemSrc->GetID()) == NULL &&
					m_wndRibbonTreeDest.FindElementInPanel(pPanel, m_pSelElemSrc->GetID()) == NULL)
				{
					bCanAdd = TRUE;
				}
			}
		}

		m_wndAdd.EnableWindow(bCanAdd);
	}
#endif
	return 0;
}
Ejemplo n.º 17
0
//*******************************************************************************
HRESULT CBCGPRibbonTabsGroup::accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt)
{
    pvarEndUpAt->vt = VT_EMPTY;

    if (varStart.vt != VT_I4)
    {
        return E_INVALIDARG;
    }

	if (m_pRibbonBar->GetSafeHwnd() == NULL)
    {
        return S_FALSE;
    }

	switch (navDir)
	{
	case NAVDIR_FIRSTCHILD:
		if (varStart.lVal == CHILDID_SELF)
		{
			pvarEndUpAt->vt = VT_I4;
			pvarEndUpAt->lVal = 1;
			return S_OK;	
		}
		break;

	case NAVDIR_LASTCHILD:
		if (varStart.lVal == CHILDID_SELF)
		{
			pvarEndUpAt->vt = VT_I4;
			pvarEndUpAt->lVal = (long)m_arButtons.GetSize();
			return S_OK;
		}
		break;

	case NAVDIR_NEXT:   
	case NAVDIR_RIGHT:
		if (varStart.lVal != CHILDID_SELF)
		{
			pvarEndUpAt->vt = VT_I4;
			pvarEndUpAt->lVal = varStart.lVal + 1;
			
			if (pvarEndUpAt->lVal > m_arButtons.GetSize())
			{
				pvarEndUpAt->vt = VT_EMPTY;
				return S_FALSE;
			}

			return S_OK;
		}
		else
		{
			if (m_pRibbonBar->m_TabElements.GetCount() > 0)
			{
				CBCGPBaseRibbonElement* pTabElement = m_pRibbonBar->m_TabElements.GetButton(0);
				if (pTabElement != NULL)
				{
					ASSERT_VALID(pTabElement);

					pvarEndUpAt->vt = VT_DISPATCH;
					pvarEndUpAt->pdispVal = pTabElement->GetIDispatch(TRUE);

					return S_OK;
				}
			}
			else
			{
				CBCGPRibbonCategory* pCatrgory = m_pRibbonBar->GetActiveCategory();
				if (pCatrgory != NULL)
				{
					ASSERT_VALID(pCatrgory);
					pvarEndUpAt->vt = VT_DISPATCH;
					pvarEndUpAt->pdispVal = pCatrgory->GetIDispatch(TRUE);
					return S_OK;
				}
			}
		}
		break;

	case NAVDIR_PREVIOUS: 
	case NAVDIR_LEFT:
		if (varStart.lVal != CHILDID_SELF)
		{
			pvarEndUpAt->vt = VT_I4;
			pvarEndUpAt->lVal = varStart.lVal - 1;
			
			if (pvarEndUpAt->lVal <= 0)
			{
				pvarEndUpAt->vt = VT_EMPTY;
				return S_FALSE;
			}

			return S_OK;
		}
		else
		{
			if (m_pRibbonBar->m_QAToolbar.IsVisible())
			{
				pvarEndUpAt->vt = VT_DISPATCH;
				pvarEndUpAt->pdispVal = m_pRibbonBar->m_QAToolbar.GetIDispatch(TRUE);

				return S_OK;
			}
			else
			{
				CBCGPRibbonMainButton* pMainButton = m_pRibbonBar->GetMainButton();
				if (pMainButton != NULL)
				{
					ASSERT_VALID(pMainButton);

					pvarEndUpAt->vt = VT_DISPATCH;
					pvarEndUpAt->pdispVal = pMainButton->GetIDispatch(TRUE);

					return S_OK;
				}
			}
		}
		break;
	}

	return S_FALSE;
}