Adding a new RAPID widget
This page will give you a step-by-step description of how to add a new
widget to RAPID, recompile it and generate a new version that can create
GUIs with your new widget. If you create a new widget, we'd appreciate
it if you'd share it with others. Send an email to the
rapid-devel mailing list
so that your widget can be included in the next release.
RAPID relies heavily on the object-oriented features of Ada 95 to reduce
code size. If you are unfamiliar with OO programming, you may want
to do some background reading before continuing.
-
Copy the RAPID sources to a working directory. Since you will be
using RAPID to "bootstrap" itself (i.e. a large portion of the RAPID source
code is generated by RAPID itself), it is important to keep a clean backup
copy of the source code.
-
Decide whether your widget will extend a previous widget, or be totally
new. Most widgets will probably descend from GUI_Widget directly;
however, on occasion, it is beneficial to have intermediate classes.
Buttons are a good example of this. Picture buttons and text buttons
share many properties, and so an abstract Button class is between these
and GUI_Widget. See gui-widget-button.ad[sb] for more detail.
-
Add a name for your new widget to the Keyword enumeration type in gui_enum.ads
-
Add a new "when" clause to the case statement in the function "Allocate_Widget"
in gui_enum.adb. This function allocates a widget of the appropriate
type based on the keyword. At this point, you will need to pick a name
for your new widget package. The convention is Gui.Widget.Widget_Type.Widget_Type.
-
Add a "with" clause at the top of gui_enum.adb for your new package.
-
Add a constant declaration for the new widget to Toolbar.ads
-
Add an entry to Tool_Button_Widget_Names in Toolbar.adb
-
Design a dialog for entering the widget properties using RAPID. Copying
one from another widget is a good place to start.
-
Write your new widget package as a child of Gui.Widget. It is probably
easiest to copy another widget and modify it to fit your needs.
Click
here for more details.
-
Design a picture to go on a button in RAPID. Make sure it is the
same size as label_gif.gif
-
Open tool.gui using RAPID and add a button to the widget selection toolbar.
The action should be: Toolbar.Select_Widget.