Overview of Creating an iTool Interface
This section provides a brief outline of the steps necessary to create a custom iTool interface. The topics introduced here are discussed in greater detail in later sections of this chapter.
To create a custom iTool interface, you will do the following:
Create or Choose an iTool
The interface you will create is the interface to an iTool. While you may choose to create a new interface to an existing iTool, it is more likely that you will be creating an interface to a custom iTool that you have defined. Even if you simply want to insert an iTool draw window into an existing widget interface, you will probably want to specify which of the standard iTool operations, menu items, and toolbars are included — this means creating and registering a new iTool definition routine. See Creating an iTool for a complete description of the process of creating your own iTool.
Create the Widget Interface
You will use traditional IDL widget programming techniques to create the interface used by your iTool. iTool components such as menus, toolbars, status bars, and iTool draw windows are encapsulated in a special set of compound widgets that you can add to your interface just like other widgets.
Note
iTool compound widgets are not exactly like other compound widgets. They do not generate widget events, and you cannot get or set their values using the WIDGET_CONTROL routine.
Create Event Handlers
While you do not need to handle the widget events that are internal to the iTool compound widgets, you will need to create event handlers for any other widgets you include in your interface. You will also need to provide event-handling code for the following:
- Resizing of the iTool compound widgets. This is generally accomplished by calling the _RESIZE procedure associated with the compound widget.
- Destruction of the iTool. In order to properly shut down the iTool system when your iTool exits, you must call the iTools shutdown service in addition to freeing any pointers used by the widget interface.
- Focus changes. The iTool system needs to know which iTool is currently selected. When your user interface receives the keyboard focus, you must call the iTools set-as-current-tool service to alert the system that the iTool associated with your interface has become the current tool.
Create Callback Routines
Callback routines handle messages delivered by the iTool messaging system to your user interface. The number and type of callbacks your interface needs to handle will depend on the features your user interface implements.
Create a Cleanup Routine
If your custom interface uses pointers or other variables that require explicit cleanup when the application exits, you must provide a cleanup routine and specify it as the routine to be called when the widgets are destroyed.
Create an iTool User Interface Object
iTools communicate with their user interfaces via a user interface object. Your interface definition routine will need to create an interface object, register the widgets with the object, and add the widget interface as an observer of the user interface object.
Create an iTool Launch Routine
After creating the user interface definition routine, you will need to create an iTool launch routine that does the following (in addition to any other work):