Upload
pitney-bowes
View
983
Download
7
Tags:
Embed Size (px)
Citation preview
Getting started with the Ribbon Library
Peter Horsbøll MøllerMarch 2015
This will help you getting started with the Ribbon Library to develop MapBasicapplications for the new ribbon based MapInfo Pro 64 bit.
Prerequisites:
Download and install:- MapInfo Pro 12.5 64 bit
Get it >>>- MapBasic 12.5.1
Get it >>>
Get the Ribbon Library
You can get the Ribbon Library from:
Github.com:• https://github.com/PeterHorsbollMoller/mbRibbonExample
Community Download:• http://communitydownloads.pbinsight.com/code-exchange/download/ribbon-
library-for-mapbasic
Unzip the Ribbon Library
Sample Application
Sample tables
Icons for the ribbon
Full source code
Running the RibbonExample
”How can I use the Ribbon Library in my own MapBasic project?
Create a new file structure
Create a new base folder
Create a sub folder for your MapBasic source code
Base folder
Source code
Create a file structure
Copy the Library folder from the RibbonExample to your source codefolder
Base folder
Source code
Library
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:
Compile with MapBasic 12.5.1
Create a main source code file (.mb)
Include the RibbonLib header file
Include some MapBasic header files
Will show the new Notification
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 12.5.1
Create a MapBasic Project file (.mbp)
Name of final MapBasic application
Compiled libraries to be included
Your compiled module
Run the application in MapInfo Pro x64
Adding an EndHandler
To make sure your application tidy up after itself, add an EndHandler to your application
Call the EndHandler of the RibbonLib
”How do I create a new Tab and adda Group to it?”
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?
Run the application in MapInfo Pro x64
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?
Run the application in MapInfo Pro x64
How do I add a Button to my new Group?
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
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
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
Run the application in MapInfo Pro x64
Adding multiple buttons
Add more elements to
the arrays
Loop the elements
Run the application in MapInfo Pro x64
What about splitbuttons? Can I create these, too?
Add a SplitButton with a SplitButtonGroup
I’m adding a new SplitButton control
I’m setting the icon of the SplitButton to match the icons of the first button I’lladd to it later
And I’m setting the handler of the SplitButton to match the handler of the first button, too
Finally I add a SplitButtonGroupAdding the SplitButton
Adding a SplitButtonGroup
Set icons
Set handler
Adding buttons to the SplitButtonGroup
And then we 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
The handler/subprocedure
The the ID of the control
Did the user use the initial
button or did he select one
from the list?
Run the application in MapInfo Pro x64
”How can I easily add the standard buttons to the Tools window?”
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
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
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
Include compiled modules in your project
You need to include several extra compiled modules in the MapBasicproject file
Reading/writing configuration files
Managing files and folders
Working with map windows
Aboutbox and programinformation
Aboutbox and programinformation
Working with strings
Run the application in MapInfo Pro x64
”Can I use my own images on the buttons?”
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
Internal MapInfo image
Image file on disk
Defines for Internal images
I have created defines for the internal images of MapInfo Pro 64 bit in a file called MI_ICONS_X64.def.
The file is included in the source code for this sample application in the Library folder and it will also be included with the RibbonLibrary Sample Application later.
”Are you sharing the source code for this sample application?”
Get the source code for the sample application
I have shared the source code on the Danish Pitney Bowes Software blog.
Get it here:http://blogs.pitneybowes.dk/files/2015/03/MyFirstRibbonApp.zip
Have fun!
Questions?
Peter Horsbøll Møller | [email protected]