BOOL CXTPRibbonControlTab::OnSetPopup(BOOL bPopup)
{
	m_bPopup = bPopup;
	if (bPopup)
	{
		ASSERT(GetSelectedItem());
		CXTPRibbonTab* pSelectedTab = (CXTPRibbonTab*)GetSelectedItem();
		if (!pSelectedTab || !GetRibbonBar()->IsRibbonMinimized())
		{
			m_bPopup = FALSE;
			return FALSE;
		}

		if (m_pCommandBar)
			m_pCommandBar->InternalRelease();

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

		m_pCommandBar = GetRibbonBar()->CreateTabPopupToolBar(pSelectedTab);
		m_pCommandBar->SetCommandBars(pCommandBars);

		m_pCommandBar->EnableCustomization(FALSE);
		m_pCommandBar->Popup(this, IsKeyboardSelected(GetSelected()));
	}
	else if (m_pCommandBar)
	{
		ASSERT(m_pCommandBar);
		m_pCommandBar->SetTrackingMode(FALSE);
	}
	RedrawParent();
	return TRUE;
}
Ejemplo n.º 2
0
void CXTPRibbonGroup::SetVisible(BOOL bVisible)
{
    if (m_bVisible != bVisible)
    {
        m_bVisible = bVisible;

        GetRibbonBar()->RebuildControls(GetRibbonBar()->GetSelectedTab());
        GetRibbonBar()->OnRecalcLayout();
    }
}
Ejemplo n.º 3
0
int CXTPRibbonGroup::GetMinimumWidth(CDC* pDC)
{
    CXTPFontDC fnt(pDC, &GetRibbonBar()->GetRibbonPaintManager()->m_fontGroupCaption);
    CSize sz = pDC->GetTextExtent(m_strCaption);

    if (m_bShowOptionButton)
        sz.cx += GetRibbonBar()->GetRibbonPaintManager()->GetGroupCaptionHeight();

    return sz.cx;
}
Ejemplo n.º 4
0
void CXTPRibbonGroupControlPopup::Copy(CXTPControl* pControl, BOOL bRecursive)
{
    CXTPControlButton::Copy(pControl, bRecursive);

    if (m_pParent && pControl->GetParent() && GetRibbonBar() != ((CXTPRibbonGroupControlPopup*)pControl)->GetRibbonBar())
    {
        m_pPopupGroup = GetRibbonBar()->FindGroup(GetID());
    }
    else
    {
        m_pPopupGroup = ((CXTPRibbonGroupControlPopup*)pControl)->m_pPopupGroup;
    }
}
Ejemplo n.º 5
0
void CXTPRibbonGroup::SetRect(CRect rc)
{
    m_rcGroup = rc;

    if (m_bReduced)
    {
        CRect rcEntry(rc.left, rc.top, rc.right, rc.bottom);
        m_pControlGroupPopup->SetHideFlag(xtpHideWrap, FALSE);
        m_pControlGroupPopup->SetRect(rcEntry);
        m_pControlGroupPopup->SetWrap(TRUE);
    }
    else
    {
        m_pControlGroupPopup->SetHideFlag(xtpHideWrap, TRUE);
    }

    if (!m_bShowOptionButton)
    {
        m_pControlGroupOption->SetHideFlag(xtpHideGeneric, TRUE);
    }
    else if (m_bReduced)
    {
        m_pControlGroupOption->SetHideFlag(xtpHideWrap, TRUE);

    }
    else
    {
        int nHeight = GetRibbonBar()->GetRibbonPaintManager()->GetGroupCaptionHeight();
        m_pControlGroupOption->SetWrap(TRUE);
        m_pControlGroupOption->SetHideFlag(xtpHideGeneric, FALSE);
        m_pControlGroupOption->SetHideFlag(xtpHideWrap, FALSE);
        m_pControlGroupOption->SetRect(CRect(rc.right - nHeight - 1, rc.bottom - nHeight, rc.right - 3, rc.bottom - 3));
    }
}
Ejemplo n.º 6
0
void CMainFrame::RebrandMenuItems()
{
	bool bClassic = GetApp()->RevertToClassicUI();

	if(bClassic)
	{		
		for (int i=0; i<m_Impl.GetMenuBar()->GetCount(); i++)
		{
			CMFCToolBarMenuButton* pHeaderButton = DYNAMIC_DOWNCAST(CMFCToolBarMenuButton, m_Impl.GetMenuBar()->GetMenuItem(i));
			RebrandSubMenu(pHeaderButton);
		}
	}
	else
	{
		// Update application name in menus
		UINT menuIds[] = { ID_AUTO_OPTIONS, ID_APP_ABOUT, ID_KEYBOARD_SHORTCUTS };
		CStdString sText;
		for (int i = 0; i < _countof(menuIds); ++i)
		{
			CMFCRibbonBaseElement* pElement = GetRibbonBar()->FindByID(menuIds[i]);
			if (pElement == NULL)
				continue;
			CMFCRibbonButton* pButton = DYNAMIC_DOWNCAST(CMFCRibbonButton, pElement);
			if (pButton == NULL)
				continue;

			CStdString sText = pButton->GetText();
			pButton->SetText(InsertAppTitle(sText));

		}
	}
}
Ejemplo n.º 7
0
BOOL CXTPRibbonGroup::IsVisible() const
{
    if (m_pRibbonBar != m_pParent)
        return m_bVisible;

    return GetRibbonBar()->GetSelectedTab() == GetParentTab() && m_bVisible;
}
Ejemplo n.º 8
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  CXTPRibbonControlTab::OnSetSelected(int bSelected)
{
	if (bSelected == m_bSelected)
		return FALSE;

	if (IsKeyboardSelected(bSelected) && !GetRibbonBar()->IsRibbonMinimized())
		m_pParent->SetPopuped(-1);

	m_bSelected = bSelected;

	m_pParent->OnControlSelected(bSelected, this);

	if (IsKeyboardSelected(bSelected))
	{
		SetFocused(TRUE);
	}

	if (!bSelected)
	{
		SetFocused(FALSE);
		PerformMouseMove(m_pParent->GetSafeHwnd(), CPoint(-1, -1));
	}
	else
	{
		AccessibleNotifyWinEvent(EVENT_OBJECT_FOCUS , GetParent()->GetSafeHwnd(), GetID(), GetCurSel() + 1);
	}

	return TRUE;
}
Ejemplo n.º 10
0
BOOL CXTPRibbonGroup::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
    if (nCode == CN_EVENT && nID == XTP_CN_REDRAWPARENT)
    {
        GetRibbonBar()->Redraw(0, FALSE);
        return TRUE;
    }
    return CCmdTarget::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CXTPRibbonControlTab::SetSelectedItem(CXTPTabManagerItem* pItem)
{
	if (!m_pParent->GetSafeHwnd())
	{
		CXTPTabManager::SetSelectedItem(pItem);
		return;
	}

	if (!IsFocused() && pItem && !GetRibbonBar()->IsRibbonMinimized())
		m_pParent->GetCommandBars()->ClosePopups();

	if (m_pSelected == pItem)
		return;

	if (m_pParent->GetCommandBars()->m_keyboardTips.nLevel > 1)
		m_pParent->GetCommandBars()->HideKeyboardTips();

	CXTPRibbonTab* pTab = (CXTPRibbonTab*)pItem;

	CXTPRibbonBar* pRibbonBar = GetRibbonBar();

	if (pRibbonBar->OnTabChanging(pTab))
		return;

	pRibbonBar->LockRedraw();

	pRibbonBar->RebuildControls(pTab);

	CXTPTabManager::SetSelectedItem(pTab);

	pRibbonBar->OnIdleUpdateCmdUI(0, 0);

	pRibbonBar->UnlockRedraw();

	pRibbonBar->OnTabChanged(pTab);

	NotifySite(CBN_XTP_EXECUTE);

	if (pItem)
	{
		AccessibleNotifyWinEvent(EVENT_OBJECT_FOCUS , GetParent()->GetSafeHwnd(), GetID(), pItem->GetIndex() + 1);
	}
}
Ejemplo n.º 12
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();
    }
}
void CXTPRibbonControlTab::OnItemClick(CXTPTabManagerItem* pItem)
{
	CXTPRibbonBar* pRibbonBar = GetRibbonBar();

	if (pRibbonBar->IsCustomizable() && pRibbonBar->IsCustomizeMode())
	{
		CXTPRibbonTab* pTab = (CXTPRibbonTab*)pItem;
		pRibbonBar->GetCommandBars()->SetDragControl(pTab);
	}

	CXTPTabManager::OnItemClick(pItem);
}
Ejemplo n.º 14
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);
    }
}
void CXTPRibbonControlTab::ShowPopupBar(BOOL bKeyboard)
{
	if (!GetSelectedItem())
		return;

	CXTPRibbonBar* pRibbonBar = GetRibbonBar();
	if (!pRibbonBar->IsRibbonMinimized())
		return;

	if (pRibbonBar->m_nPopuped == m_nIndex)
	{
		pRibbonBar->m_nPopuped = -1;
		if (m_pCommandBar) m_pCommandBar->SetTrackingMode(FALSE);
	}

	pRibbonBar->SetTrackingMode(TRUE, FALSE);
	pRibbonBar->SetPopuped(m_nIndex, bKeyboard);
}
Ejemplo n.º 16
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;
    }
}
Ejemplo n.º 17
0
void CMainFrame::OnUpdateRenderingSet(CCmdUI* pCmdUI)
{
	CStdString selectedRenderingSet = RenderingSet::GetCurrentRenderingSet();
	// TODO STASH THESE ?? unless updated :)
	std::vector<std::wstring> vecRenderingSets;
	RenderingSet::GetRenderingSetList(vecRenderingSets);

	Ribbon::PopulateRenderingSetList(GetRibbonBar());

	CStdString sItem = Ribbon::GetRenderingSetNameByID(pCmdUI->m_nID);
	if (sItem.IsEmpty() || std::find(vecRenderingSets.begin(), vecRenderingSets.end(), sItem) == vecRenderingSets.end())
	{
		pCmdUI->Enable(FALSE);
	}
	else
	{
		pCmdUI->Enable();
		pCmdUI->SetCheck(sItem.Compare(selectedRenderingSet) == 0);
	}
}
Ejemplo n.º 18
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;
}
Ejemplo n.º 19
0
CXTPControl* CXTPRibbonGroup::InsertAt(CXTPControl* pControl, int nBefore)
{
    ASSERT(pControl);
    if (!pControl)
        return NULL;

    if (nBefore < 0 || nBefore >= GetCount())
        nBefore = (int)GetCount();

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

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

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

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

    return pControl;
}
BOOL CXTPRibbonControlTab::OnHookKeyDown(UINT nChar, LPARAM /*lParam*/)
{
	if (!IsFocused())
		return FALSE;

	UINT nCharLayout(nChar);
	CXTPDrawHelpers::KeyToLayout(m_pParent, nCharLayout);

	if (nCharLayout == VK_UP || nCharLayout == VK_DOWN || nCharLayout == VK_LEFT || nCharLayout == VK_RIGHT)
	{
		m_pParent->HideKeyboardTips();
	}

	if (nCharLayout == VK_LEFT && FindNextFocusable(GetCurSel(), -1))
	{
		if (PerformKeyDown(m_pParent->GetSafeHwnd(), nChar))
			return TRUE;
	}

	if (nCharLayout == VK_RIGHT && FindNextFocusable(GetCurSel(), +1))
	{
		if (PerformKeyDown(m_pParent->GetSafeHwnd(), nChar))
			return TRUE;
	}


	if (nCharLayout == VK_DOWN)
	{
		m_pParent->SetSelected(m_pControls->GetNext(CXTPControl::GetIndex(), +1), TRUE_KEYBOARD_NEXT);
		return TRUE;
	}

	if (nCharLayout == VK_RETURN || nCharLayout == VK_SPACE && GetRibbonBar()->IsRibbonMinimized())
	{
		ShowPopupBar(TRUE);
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 21
0
BOOL CXTPRibbonGroup::LoadToolBar(UINT nIDResource, BOOL bLoadIcons)
{
    LPCTSTR lpszResourceName = MAKEINTRESOURCE(nIDResource);

    struct CToolBarData
    {
        WORD wVersion;
        WORD wWidth;
        WORD wHeight;
        WORD wItemCount;
        WORD* items()
        {
            return (WORD*)(this + 1);
        }
    };

    ASSERT_VALID(this);
    ASSERT(lpszResourceName != NULL);
    if (!lpszResourceName)
        return FALSE;

    // determine location of the bitmap in resource fork
    HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_TOOLBAR);
    if (!hInst)
        return FALSE;

    HRSRC hRsrc = ::FindResource(hInst, lpszResourceName, RT_TOOLBAR);
    if (hRsrc == NULL)
        return FALSE;

    HGLOBAL hGlobal = LoadResource(hInst, hRsrc);
    if (hGlobal == NULL)
        return FALSE;

    CToolBarData* pData = (CToolBarData*)LockResource(hGlobal);
    if (pData == NULL)
        return FALSE;

    ASSERT(pData->wVersion == 1);

    int i;
    UINT* pItems = new UINT[pData->wItemCount];

    for (i = 0; i < pData->wItemCount; i++)
        pItems[i] = pData->items()[i];

    BOOL bResult = SetButtons(pItems, pData->wItemCount);

    if (bLoadIcons)
    {
        CXTPImageManager* pImageManager = GetRibbonBar()->GetImageManager();

        if (!pImageManager->SetIcons(nIDResource, pItems,
                                     pData->wItemCount, CSize(pData->wWidth, pData->wHeight)))
            bResult = FALSE;
    }

    delete[] pItems;

    UnlockResource(hGlobal);
    FreeResource(hGlobal);


    return bResult;
}
Ejemplo n.º 22
0
bool CMainFrame::SetupToolbars()
{
	CString strCustomize;
	BOOL bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	// Enable toolbar and docking window menu replacement
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// enable quick (Alt+drag) toolbar customization
	CMFCToolBar::EnableQuickCustomization();

	if (CMFCToolBar::GetUserImages() == NULL)
	{
		// load user-defined toolbar images
		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
		{
			m_UserImages.SetImageSize(CSize(16, 16), FALSE);
			CMFCToolBar::SetUserImages(&m_UserImages);
		}
	}

	// enable menu personalization (most-recently used commands)
	// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
	CList<UINT, UINT> lstBasicCommands;

	lstBasicCommands.AddTail(ID_FILE_NEW);
	lstBasicCommands.AddTail(ID_FILE_OPEN);
	lstBasicCommands.AddTail(ID_FILE_RAW_SAVE);
	lstBasicCommands.AddTail(ID_FILE_PRINT);
	lstBasicCommands.AddTail(ID_FILE_PRINT_ORIGINAL);
	lstBasicCommands.AddTail(ID_FILE_PRINT_MODIFIED);
	lstBasicCommands.AddTail(ID_FILE_PRINT_REDLINE);
	lstBasicCommands.AddTail(ID_APP_EXIT);
	lstBasicCommands.AddTail(ID_EDIT_CUT);
	lstBasicCommands.AddTail(ID_EDIT_PASTE);
	lstBasicCommands.AddTail(ID_EDIT_UNDO);
	lstBasicCommands.AddTail(ID_APP_ABOUT);
	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
	lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);

	lstBasicCommands.AddTail(ID_FILE_NEW				   );
	lstBasicCommands.AddTail(ID_FILE_OPEN				   );
	lstBasicCommands.AddTail(ID_FILE_CLOSE				   );
	lstBasicCommands.AddTail(ID_SAVE_WDF				   );
	lstBasicCommands.AddTail(ID_FILE_PROPERTIES			   );
	lstBasicCommands.AddTail(ID_PRINT_COMPOSITE			   );
	lstBasicCommands.AddTail(ID_MAIL_TO					   );
	lstBasicCommands.AddTail(ID_SEND_REDLINEASTRACKCHANGES );
	lstBasicCommands.AddTail(ID_PROGRAM_PREFERENCES		   );
	lstBasicCommands.AddTail(ID_EDIT_OPTIONS			   );
	lstBasicCommands.AddTail(ID_AUTO_OPTIONS			   );
	lstBasicCommands.AddTail(ID_APP_EXIT				   );
	lstBasicCommands.AddTail(ID_EDIT_COPY				   );
	lstBasicCommands.AddTail(ID_EDIT_SELECT_ALL			   );
	lstBasicCommands.AddTail(ID_EDIT_FIND				   );
	lstBasicCommands.AddTail(ID_EDIT_REDLINE			   );
	lstBasicCommands.AddTail(ID_EDIT_REDLINE_TRACK		   );
	lstBasicCommands.AddTail(ID_VIEW_DOC_SUMMARY		   );
	lstBasicCommands.AddTail(ID_SHOW_ORIGINAL			   );
	lstBasicCommands.AddTail(ID_SHOW_MODIFIED			   );
	lstBasicCommands.AddTail(ID_SHOW_NO_DOCS			   );
	lstBasicCommands.AddTail(ID_SHOW_ALL_DOCS			   );
	lstBasicCommands.AddTail(ID_ZOOM_200				   );
	lstBasicCommands.AddTail(ID_ZOOM_150				   );
	lstBasicCommands.AddTail(ID_ZOOM_100				   );
	lstBasicCommands.AddTail(ID_ZOOM_75					   );
	lstBasicCommands.AddTail(ID_ZOOM_50					   );
	lstBasicCommands.AddTail(ID_ZOOM_20					   );
	lstBasicCommands.AddTail(ID_VIEW_TOGGLE				   );
	lstBasicCommands.AddTail(ID_HELP_FINDER				   );
	lstBasicCommands.AddTail(ID_WEB_HOME_PAGE			   );
	lstBasicCommands.AddTail(ID_KEYBOARD_SHORTCUTS		   );

	CMFCToolBar::SetBasicCommands(lstBasicCommands);

	CMFCRibbonQuickAccessToolBarDefaultState* qaToolBarState = new CMFCRibbonQuickAccessToolBarDefaultState();
	qaToolBarState->AddCommand(ID_FILE_NEW, true);
	qaToolBarState->AddCommand(ID_FILE_OPEN, true);
	qaToolBarState->AddCommand(ID_FILE_RAW_SAVE, true);
	qaToolBarState->AddCommand(ID_SAVE_AS, true);

	if (GetRibbonBar())
		GetRibbonBar()->SetQuickAccessDefaultState(*qaToolBarState);

	return true;
}
Ejemplo n.º 23
0
void CMainFrame::OnUpdateRenderingSets(CCmdUI *pCmdUI)
{
	pCmdUI->Enable(TRUE);
	Ribbon::PopulateRenderingSetList(GetRibbonBar());
}
BOOL CXTPRibbonControlTab::IsMouseLocked() const
{
	return GetRibbonBar()->GetCommandBars()->GetMouseManager()->IsMouseLocked();
}
Ejemplo n.º 25
0
CRect CXTPRibbonGroup::GetCaptionRect() const
{
    CRect rcCaption(m_rcGroup);
    rcCaption.top = rcCaption.bottom - GetRibbonBar()->GetRibbonPaintManager()->GetGroupCaptionHeight();
    return rcCaption;
}
Ejemplo n.º 26
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;
}
CXTPTabPaintManager* CXTPRibbonControlTab::GetPaintManager() const
{
	return GetRibbonBar()->GetTabPaintManager();
}