예제 #1
0
void CXTPRibbonGroup::Copy(CXTPRibbonGroup* pGroup)
{
    m_nId = pGroup->m_nId;
    m_nIconId = pGroup->m_nIconId;
    m_bShowOptionButton = pGroup->m_bShowOptionButton;
    m_strCaption = pGroup->m_strCaption;
    m_pGroups = pGroup->m_pGroups;
    m_bControlsGrouping = pGroup->m_bControlsGrouping;
    m_bControlsCentering = pGroup->m_bControlsCentering;
    m_bVisible = pGroup->m_bVisible;

    int nControlPos = m_pControlGroupOption->GetIndex();

    for (int i = 0; i < pGroup->GetCount(); i++)
    {
        CXTPControl* pControl = pGroup->GetAt(i);

        CXTPControl* pClone = m_pParent->GetControls()->AddClone(pControl, nControlPos + i);
        pClone->m_pRibbonGroup = this;
        pClone->SetHideFlag(xtpHideRibbonTab, FALSE);
        m_arrControls.Add(pClone);
        pClone->InternalAddRef();
    }

    m_pControlGroupOption->Copy(pGroup->m_pControlGroupOption, FALSE);
    m_pControlGroupOption->SetHideFlag(xtpHideRibbonTab, FALSE);

    m_pControlGroupPopup->Copy(pGroup->m_pControlGroupPopup, FALSE);
    m_pControlGroupPopup->SetHideFlag(xtpHideRibbonTab, FALSE);
}
BOOL CXTPRibbonBuilder::BuildMainButton(CXTPPropExchange* pPX, CXTPRibbonBar* pRibbonBar)
{
	CString strElementName;
	PX_String(pPX, _T("ELEMENT_NAME"), strElementName);

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

	CXTPControl* pControl = pRibbonBar->AddSystemButton(0);


	CXTPPropExchangeSection pxImage(pPX->GetSection(_T("IMAGE")));
	CXTPPropExchangeSection pxImageId(pxImage->GetSection(_T("ID")));

	int nId = -1;
	PX_Int(&pxImageId, _T("VALUE"), nId);

	if (nId != -1)
	{
		UINT nIcons[] = {(UINT)nId};

		pRibbonBar->GetImageManager()->SetIcons(nId, nIcons, 1, CSize(0, 0), xtpImageNormal);

		pControl->SetID(nId);
	}

	CString strKeys;
	PX_String(pPX, _T("KEYS"), strKeys);
	pControl->SetKeyboardTip(strKeys);


	return TRUE;
}
예제 #3
0
CXTPControl* CXTPRibbonGroup::AddClone(CXTPControl* pClone, int nBefore, BOOL bRecursive)
{
    if (nBefore < 0 || nBefore >= GetCount())
        nBefore = (int)GetCount();

    CXTPControl* pControl = (CXTPControl*)pClone->GetRuntimeClass()->CreateObject();
    ASSERT(pControl);
    if (!pControl)
        return NULL;

    int nControlPos = m_pControlGroupOption->GetIndex() - GetCount() + nBefore;

    GetRibbonBar()->GetControls()->InsertAt(pControl, nControlPos);

    m_arrControls.InsertAt(nBefore, pControl);
    pControl->InternalAddRef();

    pControl->Copy(pClone, bRecursive);


    pControl->m_pRibbonGroup = this;
    pControl->SetHideFlag(xtpHideRibbonTab, !IsVisible());

    return pControl;
}
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;
}
예제 #5
0
void CXTPRibbonGroup::RemoveAt(int nIndex)
{
    if (nIndex >= 0 && nIndex < GetCount())
    {
        CXTPControl* pControl = m_arrControls.GetAt(nIndex);
        pControl->m_pRibbonGroup = NULL;
        m_arrControls.RemoveAt(nIndex);

        GetRibbonBar()->GetControls()->Remove(pControl);
        pControl->InternalRelease();
    }
}
BOOL CXTPRibbonBuilder::BuildTabElements(CXTPPropExchange* pPX, CXTPRibbonBar* pRibbonBar)
{

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

		BuildControl(&pxControl, pControl);

		pRibbonBar->GetControls()->Add(pControl);

		pControl->SetFlags(pControl->GetFlags() | xtpFlagRightAlign);

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

	}


	return TRUE;
}
예제 #7
0
void CXTPRibbonGroup::RemoveAll()
{
    for (int nIndex = (int)m_arrControls.GetSize() - 1; nIndex >= 0; nIndex--)
    {
        CXTPControl* pControl = m_arrControls.GetAt(nIndex);
        pControl->m_pRibbonGroup = NULL;
        m_arrControls.RemoveAt(nIndex);

        m_pParent->GetControls()->Remove(pControl);
        pControl->InternalRelease();
    }
}
예제 #8
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);
	}
}
예제 #9
0
void CXTPRibbonGroup::RepositionControls(CDC* pDC)
{
    CXTPRibbonPaintManager* pPaintManager = GetRibbonBar()->GetRibbonPaintManager();

    int x = m_rcGroup.left + 4;
    int y = m_rcGroup.top + pPaintManager->GetGroupCaptionHeight();

    for (int i = 0; i < GetCount(); i++)
    {
        CXTPControl* pControl = GetAt(i);
        if (!pControl->IsVisible())
            continue;

        CSize sz = pControl->GetSize(pDC);
        pControl->SetRect(CRect(x, y, x + sz.cx, y + sz.cy));

        x += sz.cx;
    }
}
예제 #10
0
CXTPControl* CXTPRibbonGroup::Add(XTPControlType controlType, int nId, LPCTSTR lpszParameter, int nBefore, BOOL bTemporary)
{
    if (nBefore < 0 || nBefore >= GetCount())
        nBefore = (int)GetCount();

    int nControlPos = m_pControlGroupOption->GetIndex() - GetCount() + nBefore;

    CXTPControl* pControl = GetRibbonBar()->GetControls()->Add(controlType, nId, lpszParameter, nControlPos, bTemporary);
    ASSERT(pControl);
    if (!pControl)
        return NULL;

    m_arrControls.InsertAt(nBefore, pControl);
    pControl->InternalAddRef();

    pControl->m_pRibbonGroup = this;
    pControl->SetHideFlag(xtpHideRibbonTab, !IsVisible());

    return pControl;
}
예제 #11
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;
}
예제 #12
0
void CXTPRibbonTabPopupToolBar::OnKeyboardTip(CXTPCommandBarKeyboardTip* pTip)
{
	CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pTip->m_pOwner);
	if (pControl)
	{

		if (pTip->m_bVisible == FALSE && pControl->GetHideFlags() == xtpHideWrap)
		{
			CXTPRibbonGroup* pGroup = pControl->GetRibbonGroup();
			if (pGroup && pGroup->GetControlGroupPopup())
			{
				EnsureVisible(pGroup->GetControlGroupPopup());
				pGroup->GetControlGroupPopup()->OnUnderlineActivate();

				int nIndex = pGroup->IndexOf(pControl);

				CXTPCommandBar* pPopupToolBar = pGroup->GetControlGroupPopup()->GetCommandBar();
				if (pPopupToolBar && pPopupToolBar->IsTrackingMode() && nIndex >= 0 &&
					nIndex < pPopupToolBar->GetControlCount())
				{
					pPopupToolBar->GetControl(nIndex)->OnUnderlineActivate();

				}
			}

			return;
		}

		if (pControl->IsVisible())
		{
			pControl->OnUnderlineActivate();
		}

		return;
	}
}
예제 #13
0
void CXTPRibbonGroup::Draw(CDC* pDC, CRect rcClipBox)
{
    GetRibbonBar()->GetRibbonPaintManager()->DrawGroup(pDC, this);

    BOOL bFirst = TRUE;

    for (int i = 0; i < GetCount(); i++)
    {
        CXTPControl* pControl = GetAt(i);
        if (!pControl->IsVisible())
            continue;

        if (!m_bControlsGrouping && pControl->GetBeginGroup() && !bFirst)
        {
            GetRibbonBar()->GetPaintManager()->
            DrawCommandBarSeparator(pDC, GetRibbonBar(), pControl);
        }

        if (CRect().IntersectRect(rcClipBox, pControl->GetRect()))
        {
            pControl->Draw(pDC);
        }

        bFirst = FALSE;
    }

    if (m_pControlGroupPopup->IsVisible())
    {
        m_pControlGroupPopup->Draw(pDC);
    }

    if (m_pControlGroupOption->IsVisible())
    {
        m_pControlGroupOption->Draw(pDC);
    }
}
예제 #14
0
/////////////////////////////////////////////////////////////////////////////
// 加载扩展菜单
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::AddOwmSubMenu(CString strMainMenu, CString strSubMenu, CString strAction)
{
	CMainFrame* pMainFrame = (CMainFrame*)(theApp.GetMainWnd());
	CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars();
	if(!pCommandBars)
	{
		return FALSE;		
	}
	CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar();
	if(!pMenuBar)
	{
		return FALSE;
	}

	CXTPControls* pControls = pMenuBar->GetControls();
	CXTPControl* pControl = pControls->GetFirst();
	CXTPCommandBar* pMenuBarSub = NULL;
	CXTPControl* pControlExtSub = NULL;
	while(pControl)
	{
		if(pControl->GetCaption() == strMainMenu)
		{
			pMenuBarSub = pControl->GetCommandBar();
			CXTPControls* pControlsSub = pMenuBarSub->GetControls();
			pControl = pControlsSub->GetFirst();
			while(pControl)
			{
				if(pControl->GetCaption() == strSubMenu)
				{
					pControlExtSub = pControl;
					break;
				}
				pControlsSub->GetNext(pControl);
			}			
			break;
		}
		pControls->GetNext(pControl);
	}
	if(pMenuBarSub && !pControlExtSub)
	{
		CExtMenuInfo extMenuInfo;
		extMenuInfo.m_strVciId = m_strId;
		extMenuInfo.m_strMainMenu = strMainMenu;
		extMenuInfo.m_strSubMenu = strSubMenu;
		extMenuInfo.pProc = (TYPEOF_ClientMenu*)OnOwmExtMenuProc;
		extMenuInfo.pUpdateProc = NULL;
		extMenuInfo.nProcType = MENU_PROC_TYPE_PARAM_ID;
		
		int nExMenuId = IDM_OWMCMD+g_nIdOwmExMenu;
		extMenuInfo.m_strAction = strAction;
		extMenuInfo.nId = nExMenuId-IDM_OWMCMD;
		pMainFrame->m_arExtMenuInfo.Add(extMenuInfo);

		CXTPControls* pControlsSub = pMenuBarSub->GetControls();
		CMenu* pMenu = new CMenu();
		pMenu->CreatePopupMenu();
		pMenu->AppendMenu(MF_STRING, nExMenuId, strSubMenu);
		pControlsSub->AddMenuItem(pMenu, 0);
		delete pMenu;

		g_nIdOwmExMenu++;
	}

	return TRUE;
}
예제 #15
0
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;
	}
}
예제 #16
0
BOOL CXTPRibbonGroup::SetButtons(UINT* pButtons, int nCount)
{
    BOOL bSeparator = FALSE;

    CXTPRibbonBar* pRibbonBar = GetRibbonBar();
    CWnd* pSite = pRibbonBar->GetSite();

    for (int i = 0; i < nCount; i++)
    {
        if (pButtons[i] == 0)
            bSeparator = TRUE;
        else
        {
            XTPControlType controlType = xtpControlButton;
            XTPButtonStyle buttonStyle = xtpButtonAutomatic;
            CXTPControl* pControl = NULL;
            UINT nID = pButtons[i];

            XTP_COMMANDBARS_CREATECONTROL cs;

            if (pSite)
            {
                cs.nID = nID;
                cs.pControl = NULL;
                cs.bToolBar = TRUE;
                cs.pMenu = NULL;
                cs.nIndex = i;
                cs.strCaption = pRibbonBar->GetTitle();
                cs.controlType = controlType;
                cs.pCommandBar = pRibbonBar;
                cs.buttonStyle = buttonStyle;

                if (pSite->SendMessage(WM_XTP_BEFORECREATECONTROL, 0, (LPARAM)&cs) != 0)
                {
                    pControl = cs.pControl;
                    controlType = cs.controlType;
                    buttonStyle = cs.buttonStyle;
                    nID = cs.nID;
                }
            }

            int nControlPos = m_pControlGroupOption->GetIndex();

            if (pControl == NULL)
            {
                pControl = pRibbonBar->GetControls()->Add(controlType, nID, NULL, nControlPos);
                if (pControl)
                {
                    pControl->SetStyle(buttonStyle);
                    if (controlType == xtpControlPopup) pControl->SetIconId(nID);
                }
            }
            else pRibbonBar->GetControls()->Add(pControl, nID, NULL, nControlPos);

            if (!pControl)
                continue;

            if (bSeparator)
            {
                pControl->SetBeginGroup(TRUE);
                bSeparator = FALSE;
            }

            m_arrControls.InsertAt(GetCount(), pControl);
            pControl->InternalAddRef();

            pControl->m_pRibbonGroup = this;
            pControl->SetHideFlag(xtpHideRibbonTab, !IsVisible());

            if (pSite)
            {
                cs.pControl = pControl;
                pSite->SendMessage(WM_XTP_AFTERCREATECONTROL, 0, (LPARAM)&cs);
            }
        }
    }
    return TRUE;
}
예제 #17
0
void CXTPRibbonGroup::OnGroupAdded()
{
    CXTPControl* pGroupOption = GetControlGroupOption();

    m_pParent->GetControls()->Add(pGroupOption);
    pGroupOption->InternalAddRef();

    pGroupOption->SetHideFlag(xtpHideRibbonTab, !IsVisible());


    pGroupOption->SetID(GetID());

    CXTPControl* pGroupPopup = (CXTPControl*)GetControlGroupPopup();
    m_pParent->GetControls()->Add(pGroupPopup);
    pGroupPopup->SetCaption(GetCaption());
    pGroupPopup->SetDescription(NULL);

    pGroupPopup->InternalAddRef();

    pGroupPopup->SetHideFlag(xtpHideRibbonTab, !IsVisible());

    CXTPCommandBars* pCommandBars = m_pRibbonBar->GetCommandBars();
    ASSERT(pCommandBars);

    if (pCommandBars && pCommandBars->IsActionsEnabled())
    {
        CXTPControlAction* pAction = pCommandBars->CreateAction(GetID());
        if (pAction->GetCaption().IsEmpty()) pAction->SetCaption(GetCaption());

        pGroupPopup->SetAction(pAction);
        pGroupOption->SetAction(pAction);
    }
}
예제 #18
0
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;
}