porting simple applications to the ribbon interface using
TRANSCRIPT
![Page 1: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/1.jpg)
Porting simple applications to the ribbon interface using MapBasic
Peter Horsbøll MøllerOctober 2017
![Page 2: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/2.jpg)
Agenda:
1. Concepts of the ribbon interface
2. Control types available
3. Taking advantage of the Tools window
4. Integrate a tool in the ribbon interface
5. Resources
![Page 3: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/3.jpg)
“The ribbon interface makes it easier to discover features and functions of MapInfo Pro”
![Page 4: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/4.jpg)
1. Concepts of the ribbon interface
![Page 5: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/5.jpg)
Ribbon: The Main Ribbon Interface from which all Ribbon controls inherit.
Ribbon Tab: Individual member of Ribbon Tab Collection (e.g.: HOME, TABLE, MAP, SPATIAL, etc.).
Ribbon Tab Group: Group of Ribbon controls under a specific Ribbon Tab that are typically related tasks (e.g.: File, Clipboard, Windows, etc.).
Ribbon Button Control: the actual control (e.g.: Tool Button or Split Button, etc.) that reside within the Ribbon Tab Group.
![Page 6: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/6.jpg)
Working with the .NET SDK from MapBasic
It helps if you try to adopt an “Object Orientated” approach.
First, you need to get the MapInfo Pro instance (or object).From the MapInfo Pro instance, you can get the Ribbon instance.The Ribbon instance has a collection of Tab Groups.Each Tab Group has a collection of Controls.
A control, as well as the other instances the Ribbon, the Tabs and the Groups, have properties such as captions and icons that can be set.
![Page 7: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/7.jpg)
2. Control types available
![Page 8: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/8.jpg)
Button Control
SplitButton Control
Button Controls
Gallery Control
GalleryItem Controls
![Page 9: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/9.jpg)
ToolButton Control DropDownButton Control
Button Controls
![Page 10: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/10.jpg)
3. Taking advantage of the Tools window
![Page 11: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/11.jpg)
Tools window on the HOME tab
![Page 12: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/12.jpg)
Tools window as a dockable window
![Page 13: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/13.jpg)
Tool window – Addin procedures
Each tool can publish information
Sub procedures:•Sub AddIn_About•Sub AddIn_Help•Sub AddIn_DefaultCommand
Functions:•Function AddIn_Name()•Function AddIn_Description()•Function AddIn_Version()•Function AddIn_ImageUri()•Function AddIn_DefaultCommandText()
Help File Aboutbox End
Description
Version
Image
NameDefault Command
activated thru
double click
![Page 14: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/14.jpg)
4. Integrate a tool in the ribbon interface
![Page 15: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/15.jpg)
Running an old application
You can run older applications in the new 64 bit MapInfo ProMany of these will work and get loadedSome will be only loaded into the Tools Window, others also into the LEGACY tab
![Page 16: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/16.jpg)
Definition files
Typically, you have used a number of standard definition files in your MapBasic application:• MapBasic.def: Constants for MapBasic functions like TableInfo() etc.• Menu.def: Constants for MapInfo Pro menu commands• Icons.def: Constants for icons used in MapInfo Pro
When building an application for the ribbon interface in MapInfo Pro you will need to include a few more:• IMapInfoPro.def: Declaration for the .NET API methods• Enums.def: Constants used in the .NET API such as control types etc.
![Page 17: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/17.jpg)
![Page 18: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/18.jpg)
![Page 19: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/19.jpg)
Includes and Declares
Include the new definition files:Include "IMapInfoPro.def"
Include "Enums.def"
Declare the Tools window procedures/function you want to use:Declare Sub AddIn_About
Declare Function AddIn_Name() As String
Declare Function AddIn_Description() As String
Declare Function AddIn_Version() As String
Declare Function AddIn_ImageUri() As String
Declare the EndHandler used to remove controls from the ribbonDeclare Sub EndHandler
![Page 20: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/20.jpg)
Modular level variables
'IMapInfoPro:
Dim mtsMapInfoApplication as This
'The Ribbon:
Dim mtsRibbon as This
'The Tab Collection of the Ribbon:
Dim mtsRibbonTabColl as This
'The Control Collection of the group:
Dim mtsGroupControlColl As This
'The Button we are adding:
Dim mtsBtn As This
![Page 21: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/21.jpg)
Let’s build the interface:
Sub Main
'We need this to get resources, like icons, from .NET assemblies
Call RegisterUriParser(New_GenericUriParser(1), "pack", -1)
'Get the IMapInfoPro instance
mtsMapInfoApplication = SystemInfo(SYS_INFO_IMAPINFOAPPLICATION)
'Get the Ribbon from the MapInfo Pro instance
mtsRibbon = GetRibbon(mtsMapInfoApplication)
'Get the Ribbon Tab Collection from the Ribbon instance
mtsRibbonTabColl = GetTabsColl(mtsRibbon)
Getting the .NET instances
![Page 22: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/22.jpg)
Still preparing to build the interface:
'Get the Ribbon Tab named "TabSpatial" from the Ribbon Tab Collection
Dim tsRibbonTab As This
tsRibbonTab =GetRbnTabCollItemStr(mtsRibbonTabColl, "TabSpatial")
'Get the ribbon group collection.
Dim tsRibbonGroupColl As This
tsRibbonGroupColl = GetRbnTabGrps(tsRibbonTab)
'Get the ribbon group "SpatialCreateBar" from the ribbon group collection
Dim tsRibbonGroup As This
tsRibbonGroup = GetRbnCtrlGrpCollItemStr(tsRibbonGroupColl
, "SpatialCreateBar")
Adding controls to the Ribbon
![Page 23: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/23.jpg)
Let’s add a control/button:
'Get Group controls collection
mtsGroupControlColl = GetRbnCtrlGrpCtrls(tsRibbonGroup)
'Now add a button to the group's controls collection with a name
', caption, and enumerated ControlType
mtsBtn = MICtrlCollAddStrStrInt(mtsGroupControlColl, "btnConnectDots“
, "Connect The Dots", ControlType_Button)
'Set command to the button
call SetRbnBtnCtrlCallingHandler(mtsBtn, "ConnectTheDots")
Adding controls to the Ribbon
![Page 24: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/24.jpg)
Let’s add a tooltip to the control/button:
'Create & Set the button tooltip
Dim tsToolTip As This
tsToolTip = New_MapInfoRibbonToolTip()
Call SetMIRbnToolTipToolTipDescription(tsToolTip, "Connect The Dots")
Call SetMIRbnToolTipToolTipText(tsToolTip, "Creates a polygon or polyline
from the points selected")
Call SetMIRbnToolTipToolTipDisabledText(tsToolTip, "Make sure to select
records from a layer")
Call SetRbnBtnCtrlToolTip(mtsBtn, tsToolTip)
Adding controls to the Ribbon
![Page 25: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/25.jpg)
Adding icons and setting the size of the control:
'Set the button icon
Call SetRbnBtnCtrlSmallIcon(mtsBtn, New_Uri("pack://application:, , ,
/MapInfo.StyleResources;component/Images/Spatial/segmenting_16x16.png",
0))
Call SetRbnBtnCtrlLargeIcon(mtsBtn, New_Uri("pack://application:, , ,
/MapInfo.StyleResources;component/Images/Spatial/segmenting_32x32.png",
0))
'Set the size of the button
Call SetRbnBtnCtrlIsLarge(mtsBtn, TRUE)
Adding controls to the Ribbon
![Page 26: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/26.jpg)
Removing the control from the ribbon on exit:
Sub EndHandler
Dim bRemoved As Logical
OnError Goto HandleError
bRemoved = MICtrlCollRemove(mtsGroupControlColl, mtsBtn)
mtsBtn = NULL_PTR
Exit Sub
HandleError:
Note "EndHandler: " + Error$()
Resume Next
End Sub
Adding a Clean up to the EndHandler
![Page 27: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/27.jpg)
Let’s add the procedures and functions for the Tools window:
Sub AddIn_About
Call About
End Function
Function AddIn_Name() As String
AddIn_Name = "Connect The Dots"
End Function
Function AddIn_Description() As String
AddIn_Description = "Creates a polygon or polyline from the points
selected in the layer the points are selected from."
End Function
Integrating into the Tools window
![Page 28: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/28.jpg)
Function AddIn_Version() As String
AddIn_Version = "2.0"
End Function
Function AddIn_ImageUri() As String
AddIn_ImageUri = "pack://application:, , ,
/MapInfo.StyleResources;component/Images/Spatial/segmenting_16x16.png"
End Function
Integrating into the Tools window
![Page 29: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/29.jpg)
![Page 30: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/30.jpg)
![Page 31: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/31.jpg)
![Page 32: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/32.jpg)
Include Files
Addin sub/function declares
![Page 33: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/33.jpg)
Global ribbon variables
Getting the ribbon elements
![Page 34: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/34.jpg)
Adding a control to the ribbon
Specifying the handler
Adding Tooltip
Specifying icons
![Page 35: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/35.jpg)
EndHandler to remove controls
![Page 36: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/36.jpg)
Addin subs and functions
![Page 37: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/37.jpg)
https://github.com/PeterHorsbollMoller/mbConnectTheDots
![Page 38: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/38.jpg)
“Even though most MapBasic applications will run in 64 bit, spending some time integrating them into the ribbon will be worth the while”
![Page 39: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/39.jpg)
4. Resources
![Page 40: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/40.jpg)
• Li360 Community• The MapBasic Topic• The MapInfo Pro Developer Group• How to customize the MapInfo Pro ribbon interface
document, find it in the MapInfo Pro Developer Group
• Attend the upcoming MapBasic webinar in November• Look at the MapBasic samples that ship with MapBasic 16.0• Look at applications from the Community Download page
You have come this far and now you want to learn more?
![Page 41: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/41.jpg)
• Get started, give it a try and ask for help on the Li360 Community, <<go to the Li360 Community>>
• Consider looking into using the RIBBONLib module?
• Watch this video: Getting started with the RIBBONLibMapBasic library <<Find it here on Li360>>
• Consider using .NET to customize the ribbon?
What could my next steps be?
![Page 42: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/42.jpg)
![Page 43: Porting simple applications to the ribbon interface using](https://reader031.vdocuments.mx/reader031/viewer/2022012411/616b50eb360512544c26f3c6/html5/thumbnails/43.jpg)
What did he just talk about?
We looked at the structure and elements of the ribbon and what control types you have access to.
We investigated the new tools window and how to integrate your tools into this and finally we ported a very basic tool to the ribbon interface.