MapInfo Pro Developers User Group

Expand all | Collapse all

Add button to Theme Context ribbon tab

  • 1.  Add button to Theme Context ribbon tab

    Posted 11-30-2020 17:01
      |   view attached
    Hi all.

    I'd like to add a button to the THEME context ribbon tab using MapBasic.  Can anyone help me with the correct syntax?  It could just be a simple button, but I would also like to try adding a split button.
    I've written a tool to do a bulk change of the border (pen) for all the range or individual theme styles.  For example, if I want to remove the border for multiple theme classes in one click.  I've attached an example of my tool where the control is in the right-click context menu for the layer in Explorer, but I'd like to add the control to the ribbon tab.



    Thanks in advance.
    Kalu


    ------------------------------
    Kalu Ribush
    Dept. Jobs, Precincts & Regions (VIC)
    Melbourne VIC
    ------------------------------

    Attachment(s)

    zip
    ThemeBorder.zip   87 KB 1 version


  • 2.  RE: Add button to Theme Context ribbon tab

    Posted 12-01-2020 11:40
    Hi Kalu,

    Here is how to do it via Python. The .net code is very similar.

    from MapInfo.Types import ControlType
    button = pro.Ribbon.ContextualTabGroups['LayerTools'].Tabs['TabTheme'].Groups['CustomizeStyleBar'].Controls.Add('Button1','Button', ControlType.Button)
    button.CommandId = 102
    ​

    The main point is that the contextual tabs are in a different collection.
    For MapBasic you would need to use GetCntxtTabGrpsColl().

    -Bob

    ps. I tried via alter buttonpad also but that currently does not support contextual tabs. I will create a backlog item for that.

    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------



  • 3.  RE: Add button to Theme Context ribbon tab

    Posted 12-08-2020 00:50

    Thanks Bob for your reply.

    I had a go at this, but my programming skills don't extend much beyond MapBasic.  I'm trying to make the leap to extending with python, but it's not yet familiar to me.

    Can anyone show me how to incorporate this into my tool (attached in original post).

    Many thanks.



    ------------------------------
    Kalu Ribush
    Dept. Jobs, Precincts & Regions (VIC)
    Melbourne VIC
    ------------------------------



  • 4.  RE: Add button to Theme Context ribbon tab

    Posted 12-08-2020 14:44
      |   view attached
    Hi Kalu,

    @William Wemple created this sample for you​.

    -Bob

    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------

    Attachment(s)

    zip
    AddButtonToThemeTab.zip   2 KB 1 version


  • 5.  RE: Add button to Theme Context ribbon tab

    Posted 12-08-2020 21:17
      |   view attached
    Thanks so much @Bob Fortin and @William Wemple, this sample really helped me.

    I've created a tool which I hope many MapInfo users will find useful.  This tool provides an enhancement which I've wanted to see in MapInfo for many years (there are a couple of posts about this feature in the Ideas Portal).

    The tool allows users to quickly update the border for all polygons styles for range and individual thematics.  For example, the tool allows the user to quickly turn off all borders (something I often want to do) or change all borders to a different line style (e.g. light grey).



    Note this tool only works in MapInfo 2019.3 plus.

    I'm happy to share this on the market place @David Oneill .

    Cheers


    ​​​​​

    ------------------------------
    Kalu Ribush
    Dept. Jobs, Precincts & Regions (VIC)
    Melbourne VIC
    ------------------------------

    Attachment(s)

    zip
    Modify Theme Border.zip   151 KB 1 version


  • 6.  RE: Add button to Theme Context ribbon tab

    Posted 12-10-2020 08:32
    I see I left in two function declares (RibbonContextButtonExists, and RibbonTabExists) from my original test code that made it into your tool code>  :-)

    Cheers

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------



  • 7.  RE: Add button to Theme Context ribbon tab

    Posted 12-13-2020 17:52
      |   view attached
    Hi Bill,
    Thanks for picking that up.
    I've created a tidier version of the tool (which removes those unnecessary lines and fixes a couple of other minor issues), which I've shared a link to with @David Oneill to publish to Market Place.  Also attached for anyone who would like to comment.
    Cheers


    ------------------------------
    Kalu Ribush
    Dept. Jobs, Precincts & Regions (VIC)
    Melbourne VIC
    ------------------------------

    Attachment(s)

    zip
    ModifyThemeBorder.zip   151 KB 1 version