Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Text on right button collection? Collapse All
Subject Author Date
Robert Webb Nov 6, 2008 - 9:47 PM

I want to put a text label on one of my buttons in the right button collection (right-hand side buttons on same line as ribbon bar tabs), but it only seems to allow icons.  I can set the text but it doesn’t show up.


Any thoughts?

Thanks,

Rob.

Technical Support May 19, 2009 - 1:22 AM

We fixed the [_][o][x] button colors for dark/obsidian Office 2007 themes. The fixes are applied both to menu bar and ribbon bar buttons. The previous text fix is also part of Prof-UIS 2.85. You can drop us an e-mail to the support mail box at this web site so we will provide you with the FTP download.

Robert Webb Nov 17, 2008 - 7:31 PM

Ah thanks!  It did just what I need.


Rob.

Technical Support Nov 17, 2008 - 11:12 AM

Thank you for the very interesting question. The CExtBarButton::RibbonILV_Get() virtual method limits visual informativeness level of all the buttons at right side of the tabs to minimal. So, to make any of these buttons displaying text we need to change its informativeness level to normal. This requires two new small classes: the ribbon button class with constantly having normal informativeness level inside ribbon bar and ribbon command tree node class creating ribbon button object. If you replace the CMainFrame::_InitRibbon_RightButtonsCollection() method in the RibbonBar sample application with the following code, then you will see the About button displaying text:

                                                   class CMyLocalToolBarButton : public CExtRibbonButton
                                                                {
                                                                public:
                                                                                DECLARE_DYNCREATE( CMyLocalToolBarButton );
                                                                                CMyLocalToolBarButton(
                                                                                                CExtRibbonPage * pBar = NULL,
                                                                                                UINT nCmdID = ID_SEPARATOR,
                                                                                                UINT nStyle = 0
                                                                                                ) : CExtRibbonButton( pBar, nCmdID, nStyle )
                                                                                {
                                                                                }
                                                                                virtual INT RibbonILV_Get( INT nType ) const
                                                                                {
                                                                                                ASSERT_VALID( this );
                                                                                                nType;
                                                                                                return __EXT_RIBBON_ILV_SIMPLE_NORMAL;
                                                                                }
                                                                };
                                                                IMPLEMENT_DYNCREATE( CMyLocalToolBarButton, CExtRibbonButton );
                                                                class CMyLocalRibbonNodeWithAlwaysNormalILV : public CExtRibbonNode
                                                                {
                                                                public:
                                                                                CMyLocalRibbonNodeWithAlwaysNormalILV(
                                                                                                UINT nCmdIdBasic = 0L, UINT nCmdIdEffective = 0L, CExtRibbonNode * pParentNode = NULL,
                                                                                                DWORD dwFlags = 0L, __EXT_MFC_SAFE_LPCTSTR strTextInToolbar = NULL,
                                                                                                __EXT_MFC_SAFE_LPCTSTR strTextInMenu = NULL, __EXT_MFC_SAFE_LPCTSTR strTextUser = NULL,
                                                                                                LPARAM lParam = 0L, CExtCmdIcon * pIconCustomized = NULL
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
                                                                                                , INT nTextFieldWidth = 100, INT nDropDownWidth = -2, INT nDropDownHeightMax = 250
#endif
                                                                                                ) : CExtRibbonNode( nCmdIdBasic, nCmdIdEffective, pParentNode, dwFlags,
                                                                                                                                strTextInToolbar, strTextInMenu, strTextUser, lParam, pIconCustomized
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
                                                                                                                                , nTextFieldWidth, nDropDownWidth, nDropDownHeightMax
#endif
                                                                                                )
                                                                                {
                                                                                }
                                                                                CMyLocalRibbonNodeWithAlwaysNormalILV( CExtRibbonNode & other ) : CExtRibbonNode( other )
                                                                                {
                                                                                }
                                                                                virtual CRuntimeClass * _OnRibbonGetButtonRTC()
                                                                                {
                                                                                                ASSERT_VALID( this );
                                                                                                return RUNTIME_CLASS( CMyLocalToolBarButton );
                                                                                }
                                                                };

CExtRibbonNodeRightButtonsCollection * CMainFrame::_InitRibbon_RightButtonsCollection()
{

CExtRibbonNodeRightButtonsCollection * pRibbonNodeRightButtonsCollection =
                                new CExtRibbonNodeRightButtonsCollection;

CExtRibbonNode * pNodeRTL =
                                new CExtRibbonNode(
                                                ID_RTL,
                                                ID_RTL,
                                                NULL,
                                                0L,
                                                _T("Right-To-Left")
                                                );
                VERIFY(
                                pNodeRTL->m_iconSmall.m_bmpNormal.LoadBMP_Resource(
                                                MAKEINTRESOURCE( IDB_RTL )
                                                )
                                );
                pNodeRTL->m_iconSmall.m_bmpNormal.Make32( false );
                pNodeRTL->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), BYTE(0) );
                pRibbonNodeRightButtonsCollection->InsertNode(
                                NULL,
                                pNodeRTL
                                );

CExtRibbonNode * pNodeAppAbout =
                                new CMyLocalRibbonNodeWithAlwaysNormalILV( // new CExtRibbonNode(
                                                ID_APP_ABOUT,
                                                ID_APP_ABOUT,
                                                NULL,
                                                0L,
                                                _T("About")
                                                );
                VERIFY(
                                pNodeAppAbout->m_iconSmall.m_bmpNormal.LoadBMP_Resource(
                                                MAKEINTRESOURCE( ID_APP_ABOUT_16x16 )
                                                )
                                );
                pNodeAppAbout->m_iconSmall.m_bmpNormal.PreMultiplyRGBChannels( false );
                                                                                                                CExtCustomizeCmdScreenTip * pCmdScreenTip = new CExtCustomizeCmdScreenTip;
                                                                                                                pCmdScreenTip->TextMainSet( _T("About") );
                                                                                                                pNodeAppAbout->CmdScreenTipAttach( pCmdScreenTip );
                pRibbonNodeRightButtonsCollection->InsertNode(
                                NULL,
                                pNodeAppAbout
                                );

                return pRibbonNodeRightButtonsCollection;
} 

Robert Webb Apr 23, 2009 - 12:20 AM

One problem remains.  The text on the button in the right button collection is in a colour which doesn’t necessarily show up against the background, most noticeably when using the obsidian (black) themes the text is also black and hard to see.  Ideally the button text should be the same colour as the text on ribbon tabs (other than the current one).  This would always show up well.


The text is also drawn a pixel or two higher than text on the ribbon tabs.  This is not so important, but does look a little odd.


How can I fix these things?


Thanks,


Rob.

Robert Webb May 13, 2009 - 7:25 PM

I’m still waiting for an answer to this.  How do I make text on a button in the right-button-collection (made possible via the fix you supplied above) the same colour as text on non-current ribbon bar tabs?  Currently we have black text on a black background.


Thanks,


Rob.

Technical Support May 16, 2009 - 3:24 PM

We are sorry for the delay with this reply. Please find the following code in the CExtPaintManagerOffice2007_Impl::Ribbon_PaintPushButton() method:

               if( nTextLength > 0 || _ppbd.m_bDropDown )
                        {
                                    CFont * pFont = pTBB->GetBar()->OnGetToolbarFont( false, false );
                                    ASSERT( pFont->GetSafeHandle() != NULL );
                                    CFont * pOldFont = dc.SelectObject( pFont );
                                    int nOldBkMode = dc.SetBkMode( TRANSPARENT );
                                    COLORREF clrText =
                                                _ppbd.m_bEnabled
                                                            ? m_clrRibbonButtonNormal
                                                            : m_clrRibbonButtonDisabled
                                                            ;
and then append the following code immediately after the clrText variable assignment.

                           if(                     ( ! ( _ppbd.m_bHover || _ppbd.m_bPushed ) )
                                                &&        IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_Obsidian) )
                                                )
                                    {
                                                CExtCustomizeCmdTreeNode * pNode = pTBB->GetCmdNode();
                                                if( pNode != NULL )
                                                {
                                                            pNode = pNode->GetParentNode();
                                                            if(                     pNode != NULL
                                                                        &&        pNode->IsKindOf( RUNTIME_CLASS(CExtRibbonNodeRightButtonsCollection) )
                                                                        )
                                                            clrText =
                                                                        _ppbd.m_bEnabled
                                                                                    ? m_clrNcFrameTextActive
                                                                                    : m_clrNcFrameTextInactive
                                                                                    ;
                                                }
                                    }
Now the text inside the ribbon buttons displayed as part of the right buttons collection has the correct color. We tested this issue using the ID_RTL button displayed near the about button in the right buttons collection in the RibbonBar sample application. We made this button displaying text and used it in our tests. This ribbon button is already initialized with text to display in toolbar/ribbon bar in the CMainFrame::_InitRibbon_RightButtonsCollection() method:
CExtRibbonNode * pNodeRTL =
                        new CExtRibbonNode(
                                    ID_RTL,
                                    ID_RTL,
                                    NULL,
                                    0L,
                                    _T("Right-To-Left")
                                    );

Now what we did to make this button displaying the _T("Right-To-Left") text near the small RTL icon:

1) We need to declared the following classes in the MainFrm.h file:
class CMyRibbonButtonAlwaysDisplayingText : public CExtRibbonButton
{
public:
            DECLARE_DYNCREATE( CMyRibbonButtonAlwaysDisplayingText );
            CMyRibbonButtonAlwaysDisplayingText(
                        CExtRibbonPage * pBar = NULL,
                        UINT nCmdID = ID_SEPARATOR,
                        UINT nStyle = 0
                        )
                        : CExtRibbonButton( pBar, nCmdID, nStyle )
            {
            }
            virtual INT RibbonILV_Get(
                        INT nType = 0 // -1 min, 0 current, 1 - max
                        ) const
            {
                        ASSERT_VALID( this );
                        nType;
                        return __EXT_RIBBON_ILV_SIMPLE_NORMAL;
            }
};

class CMyRibbonNodeAlwaysDisplayingText : public CExtRibbonNode
{
public:
            DECLARE_SERIAL( CMyRibbonNodeAlwaysDisplayingText );
            CMyRibbonNodeAlwaysDisplayingText(
                        UINT nCmdIdBasic = 0L,
                        UINT nCmdIdEffective = 0L,
                        CExtRibbonNode * pParentNode = NULL,
                        DWORD dwFlags = 0L,
                        __EXT_MFC_SAFE_LPCTSTR strTextInToolbar = NULL,
                        __EXT_MFC_SAFE_LPCTSTR strTextInMenu = NULL,
                        __EXT_MFC_SAFE_LPCTSTR strTextUser = NULL,
                        LPARAM lParam = 0L,
                        CExtCmdIcon * pIconCustomized = NULL
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
                        ,
                        INT nTextFieldWidth = 100,
                        INT nDropDownWidth = -2, // (-1) - auto calc, (-2) - same as button area
                        INT nDropDownHeightMax = 250
#endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
                        )
                        : CExtRibbonNode(
                                    nCmdIdBasic, nCmdIdEffective, pParentNode, dwFlags,
                                    strTextInToolbar, strTextInMenu, strTextUser,
                                    lParam, pIconCustomized
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
                                    , nTextFieldWidth, nDropDownWidth, nDropDownHeightMax
#endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
                        )
            {
            }
            virtual CRuntimeClass * _OnRibbonGetButtonRTC()
            {
                        ASSERT_VALID( this );
                        return RUNTIME_CLASS(CMyRibbonButtonAlwaysDisplayingText);
            }
};


2) Then we put the following two lines into the MainFrm.cpp file:
IMPLEMENT_DYNCREATE( CMyRibbonButtonAlwaysDisplayingText, CExtRibbonButton );
IMPLEMENT_SERIAL( CMyRibbonNodeAlwaysDisplayingText, CExtRibbonNode, VERSIONABLE_SCHEMA|1 );


3) Then we should modify the code lines of the CMainFrame::_InitRibbon_RightButtonsCollection() method meant above to make them using the CMyRibbonNodeAlwaysDisplayingText class type for the ID_RTL ribbon button:
CExtRibbonNode * pNodeRTL =
                        new CMyRibbonNodeAlwaysDisplayingText(
                                    ID_RTL,
                                    ID_RTL,
                                    NULL,
                                    0L,
                                    _T("Right-To-Left")
                                    );


4) Finally, we compiled the Prof-UIS library with the text color fix meant above, rebuilt the RibbonBar sample application and run it.




Robert Webb May 17, 2009 - 9:33 PM

Excellent, thanks!


So this will be a permenant part of Prof-UIS now I hope?


Also, could you do the same for the MDI buttons on that same row (level wth ribbon tabs)?  They also come out black on black and are hard to see with the obsidian theme.


Thanks,

Rob.