Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
-
Upload
peter-horsboll-moller -
Category
Technology
-
view
399 -
download
6
Transcript of Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
![Page 1: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/1.jpg)
Getting started with the Ribbon Library
Peter Horsbøll MøllerNovember 2016
![Page 2: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/2.jpg)
This will help you getting started with the Ribbon Library to develop MapBasic applications for the new ribbon based MapInfo Pro 64 bit.
![Page 3: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/3.jpg)
Prerequisites:
Download and install:- MapInfo Pro 16.0 64 bit
Get it >>>- MapBasic 16.0
Get it >>>
![Page 4: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/4.jpg)
The Ribbon library is a custom made MapBasic module which is part of the broader mbLibrary.It makes it easier to integrate the most common controls into the Ribbon using MapBasic.
![Page 5: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/5.jpg)
Get the MapBasic Library - mbLibraryYou can get the MapBasic Library from Github.com:
Github.com:• https://github.com/PeterHorsbollMoller/mbLibrary
![Page 6: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/6.jpg)
Get the Ribbon Example ApplicationYou can get the Ribbon Example Application from:
Github.com:• https://github.com/PeterHorsbollMoller/mbRibbonExample
Community Download:• http://communitydownloads.pbinsight.com/code-exchange/
download/ribbon-library-for-mapbasic
![Page 7: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/7.jpg)
Unzip the Ribbon Library
Sample Application
Sample tables
Icons for the ribbon
Full source code
![Page 8: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/8.jpg)
Running the RibbonExample
![Page 9: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/9.jpg)
”How can I use the Ribbon Library in my own MapBasic project?
![Page 10: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/10.jpg)
Create a new file structure
Create a new base folder
Create a sub folder for your MapBasic source code
Base folder
Source code
![Page 11: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/11.jpg)
Add the mbLibrary modules
Copy the Library folder from the RibbonExample to your source code folder
Or better: Copy the files and folders from the folder mbLibrary from the MapBasic Library to the Library folder here
Base folder
Source code
Library
![Page 12: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/12.jpg)
Use your preferred text editor to create a new Mapbasic source code file for your application
Save it to the mbcode folder as type .mb, eg. MyFirstRibbonApp.mb
Insert these lines as a start:
Create a main source code file (.mb)
Include the RibbonLib header file
Include some MapBasic header files
Will show the new Notification
![Page 13: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/13.jpg)
Adding an EndHandler
To make sure your application tidy up after itself, add an EndHandler to your application
Compile with MapBasic 16.0
Call the EndHandler of the RibbonLib
![Page 14: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/14.jpg)
Use your text editor to create a new Mapbasic Project file for your application
Save it to the mbcode folder as type .mbp, eg. MyFirstRibbonApp.mbp
Insert these lines as a start:
Link with MapBasic 16.0
Create a MapBasic Project file (.mbp)
Name of final MapBasic application
Compiled libraries to be included
Your compiled module
![Page 15: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/15.jpg)
Run the application in MapInfo Pro x64
![Page 16: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/16.jpg)
”How do I create a new Tab and add a Group to it?”
![Page 17: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/17.jpg)
Add a new Tab to the Ribbon
1. Check if the Tab already exists2. If not, add it
Adding the new Tab
Does it already exist?
Internal name of the tab
Caption of the tab, shown on the ribbon
![Page 18: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/18.jpg)
Run the application in MapInfo Pro x64
![Page 19: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/19.jpg)
1. Check if the Group already exists2. If not, add it
Add a Group to the Tab
Adding the new Group
Does it already exist?
Internal name of the group
Caption of the group, shown on the ribbon
![Page 20: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/20.jpg)
Run the application in MapInfo Pro x64
![Page 21: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/21.jpg)
How do I add a Button to my new Group?
![Page 22: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/22.jpg)
Adding a button to a group
First you add a new button to the group
Then you set the look and behaviour of the button, such as caption, tooltips and icon
Modular level arrays
Adding a new button
Defining its look and behaviour
Getting its Control ID for later use
![Page 23: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/23.jpg)
The handler of the button
This handler is designed to manage several buttons calling it as it determines the ID of the button clicked by the user
Get the ID and calculate the item number
Now do the work
Requires MAPPERLib
![Page 24: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/24.jpg)
Adding the MAPPERLib module
Include the header file in your source code
And include the compiled module in your MapBasic project file
Include MAPPERLib.def
Include MAPPERLib.mbo
![Page 25: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/25.jpg)
Run the application in MapInfo Pro x64
![Page 26: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/26.jpg)
Adding multiple buttons
Add more elements to the arrays
Loop the elements
![Page 27: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/27.jpg)
Run the application in MapInfo Pro x64
![Page 28: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/28.jpg)
”Can I use my own images on the buttons?”
![Page 29: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/29.jpg)
Using custom images
You can refer to internal MapInfo images, see the MapBasic User Guide, Glossary, List of Embedded images for a list of all images
You can also refer to individual image files on disk, eg. in a sub folder of the application directory
Currently you can only refer to images in an asssembly if it’s located in the MapInfo Pro installation folder. We are looking into improving this.
Internal MapInfo image
Image file on disk
![Page 30: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/30.jpg)
Defines for Internal images
In the mbLibraries folder in a a file called MI_ICONS_X64.def you can find defines for the internal images of MapInfo Pro 64 bit.
The file is included in the source code for the Ribbon Sample application in the Library folder
![Page 31: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/31.jpg)
Can I also make a Button checkable? Or even modify the image on the Button?
![Page 32: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/32.jpg)
Create a Button and make it toggleableAny Button can be checked so there isn’t a special CheckButton control
Use a modular variable to hold the index of the buttonLet’s remember the index of the control
Set the Control to be ”toggleable”
![Page 33: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/33.jpg)
Create the handler and let it toggle the buttonWe are using two modular variables. One to hold the current state of the button and another to hold the index of the button
Change the state of the button (checked/unchecked)
Here we change the Tooltip and the image of the button
![Page 34: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/34.jpg)
”Can I hide controls, groups and tabs? Can I select a certain tab?”
![Page 35: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/35.jpg)
Hiding elements
You can change the visibility of the elements on the Ribbon.
Hide a tab
Hide a group on a tab
Show a control using the index
Hide a control using the names
![Page 36: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/36.jpg)
Selecting tabs
You can select tabs to give these focus.
This could be useful if you load a tool and want to make sure the user notices that you created some tools on a certain tab
![Page 37: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/37.jpg)
What about splitbuttons? Can I create these, too?
![Page 38: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/38.jpg)
Add a SplitButton with a SplitButtonGroup
Start by adding a SplitButton control.
Then set the icon of the SplitButton to match the icon of the first button to add to it later.
Also set the handler of the SplitButton to match the handler of the first button, too. This will be the default action of the SplitButton
Finally, you can add a SplitButtonGroup Adding the SplitButton
Adding a SplitButtonGroup
Set icons
Set handler
![Page 39: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/39.jpg)
Adding buttons to the SplitButtonGroup
And then you can add the buttons to the SplitButtonGroup
This is similar to adding buttons to a Group on a Tab
Adding the Buttons
Specify icons, tooltips and handlers
ControlID – needed in the handler
![Page 40: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/40.jpg)
The handler/subprocedure
The the ID of the control
Did the user use the initial button or did he select one from the list?
![Page 41: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/41.jpg)
Run the application in MapInfo Pro x64
![Page 42: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/42.jpg)
Can you talk a bit about Context menus?
![Page 43: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/43.jpg)
Working with Context menus – Alter Menu
Context menus, aka. right click menus, are not new to the Ribbon interface.
You can use the classic Alter Menu statement to add menu items to an existing context menu.
![Page 44: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/44.jpg)
Working with Context menus - RibbonLib
You can also use the RibbonLib to add ContextMenuItem controls to Context menus – and add images to these as well.
![Page 45: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/45.jpg)
But the Map Mini Toolbar can’t be modified, right?
![Page 46: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/46.jpg)
Adding to the Map Mini Toolbar
You can alos add controls, buttons or toolbuttons, to the map mini toolbar to make certain tools easy accessible for the user when working in a map window
![Page 47: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/47.jpg)
Inserting a StackPanel
Adding a Tool_Button
Specifying a built-in command
![Page 48: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/48.jpg)
”How can I easily integrate my application in the Tools window?”
![Page 49: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/49.jpg)
Tool Manager – Addin procedures
Each tool can publish information
Sub •AddIn_About•AddIn_Help•AddIn_DefaultCommand
Function •AddIn_Name()•AddIn_Description()•AddIn_Version()•AddIn_ImageUri()
Help File Aboutbox End
Description
Version
Image
Name
Default Command activated thru double click
![Page 50: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/50.jpg)
The ProgramInfo module
These standard subprocedures and functions have been added to the ProgramInfo module
Include the header file for this module in your application module
Include the ProgramInfo.def file
![Page 51: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/51.jpg)
Configure the ProgramInfo module
Specify the values for ProgramInfo to use in the dialogs
You can use the functions from ProgramInfo to get to the values, such as the application name via PRGIGetApplicationName()
Specifying values for ProgramInfo
Use functions from ProgramInfo to get to the values
![Page 52: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/52.jpg)
Include compiled modules in your projectYou need to include several extra compiled modules in the MapBasic project file
Reading/writing configuration filesManaging files and foldersWorking with map windowsAboutbox and programinformationHandling strings i different languagesWorking with strings
![Page 53: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/53.jpg)
Run the application in MapInfo Pro x64
![Page 54: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/54.jpg)
Do I really have to use the RibbonLib for integrating my application into the Ribbon?
![Page 55: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/55.jpg)
Other options
The RibbonLib helps you integrate your application into the Ribbon interface using only MapBasic (and some .NET methods).
You can achieve the same by using the methods declared in IMapInfoPro.Def
Or by using the MapInfo Pro .NET API from a .NET language such as C#
Our partner, AGIS, has developed a visual Ribbon Designer SDK which lets you do this in a visual designer.
![Page 56: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/56.jpg)
What did he just talk about?
![Page 57: Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016](https://reader035.fdocuments.in/reader035/viewer/2022062523/587ac9dc1a28ab760f8b5467/html5/thumbnails/57.jpg)
Summary
We have looked at• Getting the RibbonLib• Creating a MapBasic project• Creating Tabs and Groups• Creating Buttons• Using your own images• Creating checkable Buttons• Hiding Tabs, Groups and Controls• Creating SplitButtons• Working with Context Menus• Modifying the Map Mini Toolbar• The new Tools window• Other options for designing the interface