BOOL CXTPRibbonBuilder::BuildGroupControls(CXTPPropExchange* pPX, CXTPRibbonGroup* pRibbonGroup)
{
	CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("ELEMENT")));

	POSITION pos = pEnumerator->GetPosition(0);
	while (pos)
	{
		CXTPPropExchangeSection pxControl(pEnumerator->GetNext(pos));

		CString strElementName;
		PX_String(&pxControl, _T("ELEMENT_NAME"), strElementName);

		CCmdTarget* pElement = CreateElement(strElementName);
		if (pElement == NULL)
			continue;

		CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pElement);

		if (!pControl)
		{
			delete pElement;
			continue;

		}
		CXTPPropExchangeSection pxElements(pxControl->GetSection(_T("ELEMENTS")));
		BuildControlPopupBar(&pxElements, pControl, RUNTIME_CLASS(CXTPPopupBar));

		BuildControl(&pxControl, pControl);

		pRibbonGroup->Add(pControl, pControl->GetID());

	}

	return TRUE;
}
Example #2
0
void CMainFrame::ShowMapButtons(BOOL bShow)
{
	BOOL bMapCtrl = FALSE;
	for (int i=0,cnt=m_pToolbar->GetControlCount(); i<cnt; ++i)
	{
		CXTPControl *pCtrl = m_pToolbar->GetControl(i);
		if (!bMapCtrl && pCtrl->GetID()==IDR_EMPTY)
			bMapCtrl = TRUE;

		if (bMapCtrl)
			pCtrl->SetVisible(bShow);
	}
}
Example #3
0
CXTPControl* CXTPRibbonGroup::FindControl(XTPControlType type, int nId, BOOL bVisible, BOOL bRecursive) const
{
    for (int nIndex = 0; nIndex < GetCount(); nIndex++)
    {
        CXTPControl* pControl = GetAt(nIndex);
        if ((type == xtpControlError || pControl->GetType() == type) &&
                (!bVisible || pControl->IsVisible()) &&
                (nId == -1 || nId == pControl->GetID()))
            return pControl;

        if (bRecursive)
        {
            CXTPCommandBar* pBar = pControl->GetCommandBar();
            if (pBar)
            {
                pControl = pBar->GetControls()->FindControl(type, nId, bVisible, bRecursive);
                if (pControl != NULL) return pControl;
            }
        }
    }
    return NULL;
}
BOOL CXTPRibbonBuilder::BuildMainButtonPopupBar(CXTPPropExchange* pPX, CXTPRibbonBar* pRibbonBar)
{
	if (!pRibbonBar->GetSystemButton())
		return FALSE;

	CXTPCommandBar* pPopupBar = pRibbonBar->GetSystemButton()->GetCommandBar();


	CString strElementName;
	PX_String(pPX, _T("ELEMENT_NAME"), strElementName);

	if (strElementName != _T("Category_Main"))
		return FALSE;

	CString strCaption;
	PX_String(pPX, _T("NAME"), strCaption);

	pRibbonBar->GetSystemButton()->SetCaption(strCaption);


	pPopupBar->SetIconSize(CSize(32, 32));

	m_arrImageLarge.RemoveAll();
	m_arrImageSmall.RemoveAll();

	CXTPPropExchangeSection pxElements(pPX->GetSection(_T("ELEMENTS")));

	CXTPPropExchangeEnumeratorPtr pEnumerator(pxElements->GetEnumerator(_T("ELEMENT")));

	BOOL bBeginGroup = FALSE;

	POSITION pos = pEnumerator->GetPosition(0);
	while (pos)
	{
		CXTPPropExchangeSection pxControl(pEnumerator->GetNext(pos));

		CString strElementName;
		PX_String(&pxControl, _T("ELEMENT_NAME"), strElementName);

		if (strElementName == _T("Separator"))
		{
			bBeginGroup = TRUE;
			continue;
		}


		CCmdTarget* pElement = CreateElement(strElementName);
		if (pElement == NULL)
			continue;

		CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pElement);

		if (!pControl)
		{
			delete pElement;
			continue;
		}

		CXTPPropExchangeSection pxElements(pxControl->GetSection(_T("ELEMENTS")));
		BuildControlPopupBar(&pxElements, pControl, RUNTIME_CLASS(CXTPRibbonSystemPopupBarPage));

		BuildControl(&pxControl, pControl);

		pPopupBar->GetControls()->Add(pControl, pControl->GetID());

		pControl->SetBeginGroup(bBeginGroup);
		bBeginGroup = FALSE;

	}

	CXTPPropExchangeSection pxRecentFileList(pPX->GetSection(_T("RECENT_FILE_LIST")));

	CString strEnabled;
	PX_String(&pxRecentFileList, _T("ENABLE"), strEnabled);
	if (strEnabled == _T("TRUE"))
	{
		CXTPControl* pControl = pPopupBar->GetControls()->Add(new CXTPRibbonControlSystemRecentFileList());

		CString strLabel;
		PX_String(&pxRecentFileList, _T("LABEL"), strLabel);
		pControl->SetCaption(strLabel);
	}


	LoadIcons(pPX);


	return TRUE;
}
void CXTPRibbonBuilder::BuildControlPopupBar(CXTPPropExchange* pPX, CXTPControl*& pParent, CRuntimeClass* pPopupBarClass)
{
	CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("ELEMENT")));

	BOOL bBeginGroup = FALSE;
	BOOL bEmpty = TRUE;

	POSITION pos = pEnumerator->GetPosition(0);
	while (pos)
	{
		CXTPPropExchangeSection pxControl(pEnumerator->GetNext(pos));

		CString strElementName;
		PX_String(&pxControl, _T("ELEMENT_NAME"), strElementName);

		if (strElementName == _T("Separator"))
		{
			bBeginGroup = TRUE;
			continue;
		}


		CCmdTarget* pElement = CreateElement(strElementName);
		if (pElement == NULL)
			continue;

		CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pElement);

		if (!pControl)
		{
			delete pElement;
			continue;
		}

		if (bEmpty)
		{
			CXTPControlPopup* pPopupButton = CXTPControlPopup::CreateControlPopup(xtpControlPopup);

			CXTPPopupBar* pPopupBar = (CXTPPopupBar*)pPopupBarClass->CreateObject();

			if (pPopupBar->IsKindOf(RUNTIME_CLASS(CXTPRibbonSystemPopupBarPage)))
			{
				pPopupBar->SetIconSize(CSize(32, 32));
				pPopupBar->SetWidth(300);
				pPopupBar->SetShowGripper(FALSE);
				pPopupBar->SetDefaultButtonStyle(xtpButtonCaptionAndDescription);
			}


			pPopupButton->SetCommandBar(pPopupBar);
			pPopupBar->InternalRelease();

			pParent->InternalRelease();
			pParent = pPopupButton;

			bEmpty = FALSE;
		}


		BuildControl(&pxControl, pControl);

		pParent->GetCommandBar()->GetControls()->Add(pControl, pControl->GetID());

		pParent->SetBeginGroup(bBeginGroup);
		bBeginGroup = FALSE;
	}
}