Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - [solved] Backstage menu items height
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] Backstage menu items height

 Post Reply Post Reply
Author
Message
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Topic: [solved] Backstage menu items height
    Posted: 10 November 2016 at 5:15am
Hello Codejock-Team!
How can i change the height of the items, so that all of them have exactly the same height?
As you can see, those items with a backstage view are higher.
Can you post a patch?

Thank you :-)


Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2016 at 9:47am
Yes, I also have that difference. It depends if it is a link to a backstage page or it is a command.

-cpede
Product: Xtreme ToolkitPro (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2016 at 10:20am
I know that this is the reason, but why?
Have a look at MS Office :-)
Back to Top
Fredrik View Drop Down
Senior Member
Senior Member


Joined: 22 June 2005
Status: Offline
Points: 226
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fredrik Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2016 at 1:18pm
... we had to do a pretty ugly workaround for this and derived our own BackstagePageCommand from CXTPRibbonBackstagePage with a method to post a WM_COMMAND message to main frame with a menu ID. Then we also had to derive a class from CXTPRibbonBackstageView to handle clicking on the command and going there using the arrow keys. Moreover we had to derive our own backstage page themes to handle disabled tabs.... and all this just because we did not get pControl->SetHeight to work. There surely must be an easier way (like CodeJock makes links to commands and backstage pages the same height ;-))

Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (1) Thanks(1)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2016 at 12:33pm
Hello,

You can change height of commands and pages  in method CXTPRibbonBackstageView::RecalcLayout()

    int nCommandHeight = XTP_DPI_Y(16 + 10);
    int nPageHeight = XTP_DPI_Y(30 + 7);

I think it is from Office 2010 backstage.

Upd: I have fixed this by adding new methods to CXTPRibbonBackstagePaintManager and derived CXTPRibbonBackstageViewThemeOffice2013. Now they return appropriate correct values.


Regards,
 Oleksandr Lebed
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 14 November 2016 at 5:24am
Thank you it works :-)
Back to Top
Fredrik View Drop Down
Senior Member
Senior Member


Joined: 22 June 2005
Status: Offline
Points: 226
Post Options Post Options   Thanks (1) Thanks(1)   Quote Fredrik Quote  Post ReplyReply Direct Link To This Post Posted: 14 November 2016 at 7:00am
Great Oleksandr, 

The only problem is that the caption for command items are not aligned with the caption for tabs. The text seems to be off by XTP_DPI_Y(3) pixels...

By the way, if you use the arrow keys to navigate down among the tabs/commands the commands do not get highlighted which they should. Also, I think navigating down (using arrow down) should skip over the separator button. 

Also, it would be nice if the themes could support disabled backstage pages. The only think I had to add for my derived Office 2013 themes was 

   if (!bEnabled)
      clrText = GetXtremeColor(XPCOLOR_GRAYTEXT);

in DrawControl.

Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (1) Thanks(1)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2016 at 4:36pm
Hello Fredrik,

Thank you for relevant proposals and information about issues.

For skipping separator on navigation with keyboard I found next solution
CXTPRibbonBackstageMenuSeparator::CXTPRibbonBackstageMenuSeparator()
{
    SetFlags(GetFlags() | xtpFlagSkipFocus);
}

Relating to disabled menu items - in CXTPRibbonBackstageViewThemeOffice2013::DrawControl() method for text color is better used  m_clrButtonBackSelected as in original theme. But this is not suitable for VS2015 theme which is derived from Office2013. So I whant to add new colors in INI files of these themes.
    if (bEnabled)
    {
        clrText = bHighlighted ? m_clrButtonTextHighlighted : (bActiveTab ? m_clrButtonTextSelected : m_clrButtonTextNormal);
        clrBack = bHighlighted ? m_clrButtonBackHighlighted : (bActiveTab ? m_clrButtonBackSelected : m_clrButtonBackNormal);
    }
    else
    {
        clrText = m_clrButtonBackSelected;    // isn't suitable for VS2015 theme
        clrBack = bHighlighted || bFocused ? m_clrButtonBackHighlighted : m_clrButtonBackNormal;
    }

There are some problems with disabling Command items. I will finish later.

Also I found incorrect calculation size of separator's line  in  CXTPRibbonBackstageViewThemeOffice2013::DrawControl 
    if (pView->IsMenuSeparator(pControl))
    {
        CRect rcControl(pControl->GetRect());
        rcControl.left += XTP_DPI_X(26);
        rcControl.right -= XTP_DPI_X(26);
        //rcControl.top += XTP_DPI_Y(10);
        //rcControl.bottom -= XTP_DPI_Y(10);
        rcControl.top += rcControl.Height()/2;
        rcControl.bottom = rcControl.top + XTP_DPI_Y(1);

        pDC->FillSolidRect(rcControl, m_clrButtonBackSelected);
        return;
    }
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (1) Thanks(1)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 18 November 2016 at 7:54am
I found that disabling commands doesn't work on creation backstage (it is enabled again on updating), to disable command we need to disable Action
   CXTPRibbonBackstageCommand* pCommand = pView->AddCommand(ID_APP_OPTIONS);
    //pCommand->SetEnabled(FALSE);    // doesn't work
    GetCommandBars()->GetActions()->FindAction(ID_APP_OPTIONS)->SetEnabled(FALSE);

    CXTPRibbonBackstageTab* pTabRecent = pView->AddTab(&m_pageRecent, ID_BACKSTAGE_RECENT);
    pTabRecent->SetEnabled(FALSE);    //works correct
    GetCommandBars()->GetActions()->FindAction(ID_BACKSTAGE_RECENT)->SetEnabled(FALSE);    //works correct

So full method DrawControl with fixes is below. But I will add new key-values in INI files for  disabled text and background because they are different for DarkGray Office2013 themes and for VisualStudio2015
void CXTPRibbonBackstageViewThemeOffice2013::DrawControl(CDC *pDC, CXTPRibbonBackstageView *pView, CXTPControl *pControl)
{
    if (!pControl->IsVisible())
        return;

    if (pView->IsMenuSeparator(pControl))
    {
        CRect rcControl(pControl->GetRect());
        rcControl.left += m_nTextGap + m_nCommandGap;
        rcControl.right -= m_nTextGap + m_nCommandGap;
        rcControl.top += rcControl.Height()/2;
        rcControl.bottom = rcControl.top + XTP_DPI_Y(1);

        pDC->FillSolidRect(rcControl, m_clrButtonBackSelected);
        return;
    }

    BOOL bEnabled     = pControl->GetEnabled();
    BOOL bActiveTab   = pView->IsActiveTab(pControl);
    BOOL bHighlighted = pView->IsHighlightedControl(pControl);
    BOOL bFocused     = pView->IsFocusedControl(pControl);

    if (pView->IsCommand(pControl))
    {
        bHighlighted = bFocused || bHighlighted;
    }

    CRect rcControl(pControl->GetRect());
    COLORREF clrText, clrBack;

    if (bEnabled)
    {
        clrText = bHighlighted ? m_clrButtonTextHighlighted : (bActiveTab ? m_clrButtonTextSelected : m_clrButtonTextNormal);
        clrBack = bHighlighted ? m_clrButtonBackHighlighted : (bActiveTab ? m_clrButtonBackSelected : m_clrButtonBackNormal);
    }
    else
    {
        clrText = m_clrButtonBackSelected;    // isn't suitable for VS2015 theme
        clrBack = bHighlighted || bFocused ? m_clrButtonBackHighlighted : m_clrButtonBackNormal;
    }

    pDC->FillSolidRect(rcControl, clrBack);
    
    CRect rcText(rcControl);
    rcText.DeflateRect(m_nTextGap + m_nCommandGap, XTP_DPI_Y(2), XTP_DPI_X(2), XTP_DPI_Y(2));

    CXTPFontDC font(pDC, &pView->m_fntCommand);
    pDC->SetTextColor(clrText);
    pDC->DrawText(pControl->GetCaption(), rcText, DT_HIDEPREFIX | DT_VCENTER | DT_SINGLELINE);
}
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 21 November 2016 at 5:39am
Gaps between buttons in menu (tabs) of backstage are added in
void CXTPRibbonBackstageView::RecalcLayout()
{
    ....
    for (i = 0; i < GetControlCount(); i++)
    {
        CXTPControl* pControl = GetControl(i);
        if (!pControl->IsVisible())
            continue;

        if (IsCommand(pControl))
        {
            pControl->SetRect(CRect(m_pPaintManager->m_nCommandGap, top, 
                m_nMenuWidth - m_pPaintManager->m_nCommandGap, top + nCommandHeight));
            top += nCommandHeight + XTP_DPI_Y(2);
        }
        else if(IsMenuSeparator(pControl))
        {
            if(!m_pPaintManager->m_nMenuSeparatorHeight)
                continue;
            
            pControl->SetRect(CRect(0, top, m_nMenuWidth, top + m_pPaintManager->m_nMenuSeparatorHeight));
            top += m_pPaintManager->m_nMenuSeparatorHeight + XTP_DPI_Y(1);
        }
        else
        {
            pControl->SetRect(CRect(0, top, m_nMenuWidth, top + nPageHeight));
            top += nPageHeight + XTP_DPI_Y(1);
        }
    }
    ....
}
It is also inherited from Office2010 theme. I have added appropriate methods to backstage paint manager to getting correct gap size. For Office2013 and VS2015 it is 0.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.