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 » RibbonNodeSmall question Collapse All
Subject Author Date
tera tera Nov 25, 2008 - 2:39 AM

Hello.


I made a large icon of 32x32 for ribbonnodeLarge.

Even if I set an icon of 32x32 in RibbonNodeSmall.

Is the icon done displaying compactedly of?

Technical Support Nov 26, 2008 - 10:55 AM

If you have only a 32x32 icon, then you can create a very smoothly resized 16x16 version of this icon using highest quality resizing algorithms provided by the CExtBitmap class and not based on Win32 API. Here is the part of the CMainFrame::_InitRibbonNode_Home_Clipboard() method in the RibbonBar sample application which initializes the always big Paste ribbon button and loads the 32x32 ID_EDIT_PASTE_BIG bitmap icon into it:

. . .
CExtRibbonNode * pNodePaste =
                        new CExtRibbonNode( ID_EDIT_PASTE, 0, NULL, 0, _T("Paste") );
            pNodePaste->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’V’) ) ), false );
            pNodePaste->RibbonILE_RuleArrayGet().RemoveAll();
            VERIFY( pNodePaste->m_iconBig.m_bmpNormal.LoadBMP_Resource( MAKEINTRESOURCE(ID_EDIT_PASTE_BIG) ) );
            pNodePaste->m_iconBig.m_bmpNormal.Make32();
            pNodePaste->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );
                                                                                    pCmdScreenTip = new CExtCustomizeCmdScreenTip;
                                                                                    pCmdScreenTip->CaptionMainSet( _T("Paste") );
                                                                                    pCmdScreenTip->TextMainSet( _T("Paste the contents\nof the Clipboard.") );
                                                                                    pCmdScreenTip->BmpMainGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_EDIT_PASTE_BIG) );
                                                                                    pCmdScreenTip->BmpMainGet().Make32();
                                                                                    pCmdScreenTip->BmpMainGet().AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );
                                                                                    pCmdScreenTip->CaptionSecondarySet( _T("Press F1 for more help.") );
                                                                                    pCmdScreenTip->BmpSecondaryGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_APP_ABOUT_16x16) );
                                                                                    pCmdScreenTip->BmpSecondaryGet().PreMultiplyRGBChannels( false );
                                                                                    pNodePaste->CmdScreenTipAttach( pCmdScreenTip );
                                                                                    pCmdScreenTip = new CExtCustomizeCmdScreenTip;
                                                                                    pCmdScreenTip->CaptionMainSet( _T("Paste") );
                                                                                    pCmdScreenTip->TextMainSet( _T("Click here for more options such as\npasting only the values or\nformatting.") );
                                                                                    pCmdScreenTip->BmpMainGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_EDIT_PASTE_BIG) );
                                                                                    pCmdScreenTip->BmpMainGet().Make32();
                                                                                    pCmdScreenTip->BmpMainGet().AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );
                                                                                    pCmdScreenTip->CaptionSecondarySet( _T("Press F1 for more help.") );
                                                                                    pCmdScreenTip->BmpSecondaryGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_APP_ABOUT_16x16) );
                                                                                    pCmdScreenTip->BmpSecondaryGet().PreMultiplyRGBChannels( false );
                                                                                    pNodePaste->CmdScreenTipAttach( pCmdScreenTip, false );
. . .

We can change this code and enable small icon state of this button without creating the 16x16 icon for it:

 CExtRibbonNode * pNodePaste =
                        new CExtRibbonNode( ID_EDIT_PASTE, 0, NULL, 0, _T("Paste") );
            pNodePaste->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’V’) ) ), false );

// THIS LINE WAS COMMENTED: it disables all the button states excepting big state with 32x32 icon
// pNodePaste->RibbonILE_RuleArrayGet().RemoveAll();
// THIS LINE WAS COMMENTED =======================================================================

            VERIFY( pNodePaste->m_iconBig.m_bmpNormal.LoadBMP_Resource( MAKEINTRESOURCE(ID_EDIT_PASTE_BIG) ) );
            pNodePaste->m_iconBig.m_bmpNormal.Make32();
            pNodePaste->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

// THESE LINES WERE ADDED: creation of 16x16 icon from already loaded 32x32 icon =================
            pNodePaste->m_iconSmall = pNodePaste->m_iconBig;              // copy image surface
CExtBitmap::Filter _filter( CExtBitmap::Filter::lanczos );        // use extremely smooth scaling
            pNodePaste->m_iconSmall.m_bmpNormal.Scale( 16, 16, _filter ); // do bitmap scaling
// THESE LINES WERE ADDED ========================================================================

            pCmdScreenTip = new CExtCustomizeCmdScreenTip;
                                                                                    pCmdScreenTip->CaptionMainSet( _T("Paste") );
                                                                                    pCmdScreenTip->TextMainSet( _T("Paste the contents\nof the Clipboard.") );
                                                                                    pCmdScreenTip->BmpMainGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_EDIT_PASTE_BIG) );
                                                                                    pCmdScreenTip->BmpMainGet().Make32();
                                                                                    pCmdScreenTip->BmpMainGet().AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );
                                                                                    pCmdScreenTip->CaptionSecondarySet( _T("Press F1 for more help.") );
                                                                                    pCmdScreenTip->BmpSecondaryGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_APP_ABOUT_16x16) );
                                                                                    pCmdScreenTip->BmpSecondaryGet().PreMultiplyRGBChannels( false );
                                                                                    pNodePaste->CmdScreenTipAttach( pCmdScreenTip );
                                                                                    pCmdScreenTip = new CExtCustomizeCmdScreenTip;
                                                                                    pCmdScreenTip->CaptionMainSet( _T("Paste") );
                                                                                    pCmdScreenTip->TextMainSet( _T("Click here for more options such as\npasting only the values or\nformatting.") );
                                                                                    pCmdScreenTip->BmpMainGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_EDIT_PASTE_BIG) );
                                                                                    pCmdScreenTip->BmpMainGet().Make32();
                                                                                    pCmdScreenTip->BmpMainGet().AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );
                                                                                    pCmdScreenTip->CaptionSecondarySet( _T("Press F1 for more help.") );
                                                                                    pCmdScreenTip->BmpSecondaryGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_APP_ABOUT_16x16) );
                                                                                    pCmdScreenTip->BmpSecondaryGet().PreMultiplyRGBChannels( false );
                                                                                    pNodePaste->CmdScreenTipAttach( pCmdScreenTip, false );
            pRibbonGroup->InsertNode(
                        NULL,
                        pNodePaste
                        );

Technical Support Nov 25, 2008 - 12:34 PM

For ribbon buttons use 16x16 icons in small layout without text and normal layout with text on right. The 32x32 icons are used only in the large layout with text at bottom. If you need something else, you should use custom ribbon button and ribbon node classes.

tera tera Nov 25, 2008 - 10:11 PM

Hello.


Can RibbonMenu display 32*32 icons at Small size (16*16 size)?