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 General Discussion » Slider in RibbonPage Collapse All
Subject Author Date
Vincent Frouhar Feb 19, 2008 - 12:58 PM

I would like to add a slider to cammand controls in a RibbonPage. I know there is a CExtBarSliderButton, which can be placed on the CExtToolControlBar. Since RibbonPage inherets from CExtToolControlBar, is there a way to use the same mechanism?

Thanks.
Vincent

Technical Support Feb 21, 2008 - 5:49 AM

You can put CExtBarSliderButton and any other CExtBarButton-derived objects into a ribbon as well as into a toolbar. But in the case of a slider or a scroll bar button, you should use an adopted version of the CExtBarSliderButton class (see the CRibbonSliderOrScrollBarButton class in the source code below) and you should create and use a ribbon node class which inserts an adopted button class into the ribbon (see the CExtRibbonNodeSliderOrScrollBar class in the source code below):

/////////////////////////////////////////////////////////////////////////////
// CRibbonSliderOrScrollBarButton declaration

class __PROF_UIS_API CRibbonSliderOrScrollBarButton : public CExtBarSliderButton
{
public:
      DECLARE_DYNCREATE( CRibbonSliderOrScrollBarButton );
      CRibbonSliderOrScrollBarButton(
            CExtToolControlBar * pBar = NULL,
            UINT nCmdID = ID_SEPARATOR,
            UINT nStyle = 0,
            ULONG nScrollTotalRange = 0L,
            ULONG nScrollPos = 0L,
            ULONG nScrollPageSize = 0L,
            INT nScrollButtonExtentH = 0,
            INT nScrollButtonExtentV = 0,
            INT nScrollControlExtentH = 50,
            INT nScrollControlExtentV = 50
            )
            : CExtBarSliderButton(
                  pBar,
                  nCmdID,
                  nStyle,
                  nScrollTotalRange,
                  nScrollPos,
                  nScrollPageSize,
                  nScrollButtonExtentH,
                  nScrollButtonExtentV,
                  nScrollControlExtentH,
                  nScrollControlExtentV
                  )
      {
      }
      virtual bool IsNoRibbonLayout() const;
      virtual INT RibbonILV_Get(
            INT nType = 0 // -1 min, 0 current, 1 - max
            ) const;
      virtual CSize RibbonILV_CalcSize(
            CDC & dc,
            INT nILV = -1 // -1 use current visual level
            ) const;
}; // class CRibbonSliderOrScrollBarButton

/////////////////////////////////////////////////////////////////////////////
// CExtRibbonNodeSliderOrScrollBar declaration

class __PROF_UIS_API CExtRibbonNodeSliderOrScrollBar : public CExtRibbonNode
{
public:
      DECLARE_SERIAL( CExtRibbonNodeSliderOrScrollBar );
      CExtRibbonNodeSliderOrScrollBar(
            UINT nCmdIdBasic = 0L,
            CExtRibbonNode * pParentNode = NULL,
            LPARAM lParam = 0L
            );
      CExtRibbonNodeSliderOrScrollBar(
            CExtRibbonNodeSliderOrScrollBar & other
            );
      virtual ~CExtRibbonNodeSliderOrScrollBar();
      virtual CRuntimeClass * _OnRibbonGetButtonRTC();
      virtual INT RibbonILV_Get(
            INT nType = 0 // -1 min, 0 current, 1 - max
            ) const;
protected:
      virtual void _InitMembers();
public:
      virtual bool OnGetCommandsListBoxInfo(
            CExtCustomizeCommandListBox * pLB, // IN (optional)
            CExtCustomizeSite * pSite = NULL, // IN (optional)
            CExtCmdItem * pCmdItem = NULL, // IN (optional)
            CExtSafeString * pStrLbText = NULL, // OUT (optional)
            CExtCmdIcon * pLbIcon = NULL, // OUT (optional)
            INT nDesiredIconWidth = 16, // IN (optional)
            INT nDesiredIconHeight = 16 // IN (optional)
            );

}; // class CExtRibbonNodeSliderOrScrollBar

/////////////////////////////////////////////////////////////////////////////
// CRibbonSliderOrScrollBarButton implementation

IMPLEMENT_DYNCREATE( CRibbonSliderOrScrollBarButton, CExtBarSliderButton )
            
bool CRibbonSliderOrScrollBarButton::IsNoRibbonLayout() const
{
      ASSERT_VALID( this );
      return true;
}

INT CRibbonSliderOrScrollBarButton::RibbonILV_Get(
      INT nType // = 0 // -1 min, 0 current, 1 - max
      ) const
{
      ASSERT_VALID( this );
      nType;
      return __EXT_RIBBON_ILV_SIMPLE_NORMAL;
}

CSize CRibbonSliderOrScrollBarButton::RibbonILV_CalcSize(
      CDC & dc,
      INT nILV // = -1 // -1 use current visual level
      ) const
{
      ASSERT_VALID( this );
      nILV;
      return
            ( const_cast < CRibbonSliderOrScrollBarButton * > ( this ) )
            -> CalculateLayout( dc, CSize(0,0), IsHorzBarOrientation() );
}

/////////////////////////////////////////////////////////////////////////////
// CExtRibbonNodeSliderOrScrollBar implementation

IMPLEMENT_SERIAL( CExtRibbonNodeSliderOrScrollBar, CExtRibbonNode, VERSIONABLE_SCHEMA|1 );

CExtRibbonNodeSliderOrScrollBar::CExtRibbonNodeSliderOrScrollBar(
      UINT nCmdIdBasic, // = 0L
      CExtRibbonNode * pParentNode, // = NULL
      LPARAM lParam // = 0L
      )
      : CExtRibbonNode(
            nCmdIdBasic,
            nCmdIdBasic,
            pParentNode,
            0,
            _T(""),
            _T(""),
            _T(""),
            lParam
            )
{
}

CExtRibbonNodeSliderOrScrollBar::CExtRibbonNodeSliderOrScrollBar(
      CExtRibbonNodeSliderOrScrollBar & other
      )
      : CExtRibbonNode( other )
{
      RibbonILE_RuleArrayGet().RemoveAll();
}

CExtRibbonNodeSliderOrScrollBar::~CExtRibbonNodeSliderOrScrollBar()
{
}

bool CExtRibbonNodeSliderOrScrollBar::OnGetCommandsListBoxInfo(
      CExtCustomizeCommandListBox * pLB, // IN (optional)
      CExtCustomizeSite * pSite, // = NULL // IN (optional)
      CExtCmdItem * pCmdItem, // = NULL // IN (optional)
      CExtSafeString * pStrLbText, // = NULL // OUT (optional)
      CExtCmdIcon * pLbIcon, // = NULL // OUT (optional)
      INT nDesiredIconWidth, // = 16 // IN (optional)
      INT nDesiredIconHeight // = 16 // IN (optional)
      )
{
      ASSERT_VALID( this );
      pLB;
      pSite;
      pCmdItem;
      pStrLbText;
      pLbIcon;
      nDesiredIconWidth;
      nDesiredIconHeight;
      return false;
}

void CExtRibbonNodeSliderOrScrollBar::_InitMembers()
{
      ASSERT_VALID( this );
      CExtRibbonNode::_InitMembers();
      arrRule.RemoveAll();
}

CRuntimeClass * CExtRibbonNodeSliderOrScrollBar::_OnRibbonGetButtonRTC()
{
      ASSERT_VALID( this );
      _InitMembers();
      return RUNTIME_CLASS( CRibbonSliderOrScrollBarButton );
}

INT CExtRibbonNodeSliderOrScrollBar::RibbonILV_Get(
      INT nType // = 0 // -1 min, 0 current, 1 - max
      ) const
{
      ASSERT_VALID( this );
      nType;
      return __EXT_RIBBON_ILV_SIMPLE_NORMAL;
}