MapInfo Pro Developers User Group

RIBBONLib: Support for Wrap- and StackPanel

  • 1.  RIBBONLib: Support for Wrap- and StackPanel

    Posted 10 days ago

    Last year I wrote a small post on working with Wrap- and StackPanels when building your ribbon interface. At that point I gave a few examples using .NET.

    Over Christmas I decided to implement these controls using the MapBasic library RIBBONLib that can be found on Githup as part of the mbLibrary.

    And now you can use these two panels instead of DropDownMenuGroups when you are building either DropDownMenus or SplitButtons. The benefit of the panels is that you can organise your controls horisontal in these which gives you room for more controls.

    The benefit of the WrapPanel versus the StackPanel is that the WrapPanel automatically wraps the control onto a new line.

    Here is is an example of how controls in a WrapPanel can look. I have specified a width of the panel and also a width of the individual controls that make sure they have similar widths. The width of the controls is not only defined by the icon size but also by the caption text of the controls.

    And here is the sample code that creates the SplitButton with the WrapPanel above.

    '**Adding a new SplitButton to the HOME tab next the the Open Table control
    nCtrlIdx = RBNGroupInsertControlAfter("favmapSplitButton", "Favorite Maps", "", ControlType_SplitButton
                  , "TabHome", "HomeFile", "OpenTableButton")
    If nCtrlIdx > 0 Then
       Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE, "", PATH_IMAGES & "BaseMap_32x32.png")
       Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "MENUOpenBaseMap")

       Call RBNControlSetDefaultLeftMargin(0)


       '**Adding a WrapPanel to the new SplitButton
       nCtrlIdx = RBNSplitButtonAddControl("favmapPanelA", "Info Tools", ControlType_WrapPanel
                     , "TabHome", "HomeFile", "favmapSplitButton")
       Call RBNControlSetOrientationIdx(nCtrlIdx, Orient_Horizontal)
       Call RBNControlSetWidthIdx(nCtrlIdx, 290)


       '**Adding Controls to the WrapPanel
       nCtrlIdx = RBNSplitButtonGroupAddControl("openBaseMap1", "Base Map Color", "T", ControlType_Button
                     , "TabHome", "HomeFile", "favmapSplitButton", "favmapPanelA")
       If nCtrlIdx > 0 Then
          Call RBNControlSetToolTipIdx(nCtrlIdx, "Open Base Map Color", "", "")
          Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE, "", PATH_IMAGES & "BaseMap_32x32.png")
          Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "MENUOpenBaseMap") Call RBNControlSetWidthIdx(nCtrlIdx, 70)
       End If

       nCtrlIdx = RBNSplitButtonGroupAddControl("openBaseMap2", "Base Map Grey", "T", ControlType_Button
                      , "TabHome", "HomeFile", "favmapSplitButton", "favmapPanelA")
       If nCtrlIdx > 0 Then
          Call RBNControlSetToolTipIdx(nCtrlIdx, "Open Base Map Grey", "", "")
          Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE, "", PATH_IMAGES & "BaseMap_Grey_32x32.png")
          Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "MENUOpenBaseMap")
          Call RBNControlSetWidthIdx(nCtrlIdx, 70)
       End If


       nCtrlIdx = RBNSplitButtonGroupAddControl("openBaseMap3", "Base Map Subdued", "T", ControlType_Button
                      , "TabHome", "HomeFile", "favmapSplitButton", "favmapPanelA")
       If nCtrlIdx > 0 Then
          Call RBNControlSetToolTipIdx(nCtrlIdx, "Open Base Map Subdued", "", "")
          Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE, "", PATH_IMAGES & "BaseMap_Subdued_32x32.png")
          Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "MENUOpenBaseMap")
          Call RBNControlSetWidthIdx(nCtrlIdx, 70)
       End If

       'Adding another 4 controls to the WrapPanel in the same way...


       
    Call RBNControlSetDefaultLeftMargin(4)
    End If

    I hope this is useful for those of you building the interface of your application using MapBasic and the RIBBONLib. If you have any questions, do ask away!



    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------