user manual

Chapter 15: Creating a Custom iTool Widget Interface 375
iTool Developer’s Guide Example: a Custom iTool Interface
oUI->AddOnNotifyObserver, myID, oTool->GetFullIdentifier()
; Specify how to handle destruction of the widget interface.
WIDGET_CONTROL, wChild, KILL_NOTIFY = "example2_wdtool_cleanup"
; Display the iTool widget interface.
WIDGET_CONTROL, wBase, /MAP
; Start event processing.
XMANAGER, 'example2_wdtool', wBase, /NO_BLOCK
END
Discussion
Most of the important sections of this routine have been discussed in previous
sections. There are, however, a few additional points worth noting:
We use the user value of the first child of the top-level base (
wChild) to store
a pointer to the widget interface’s state structure. This allows us to easily
retrieve the state structure in event-handler routines without the need to use the
user value of the top-level base.
The state structure contains the widget IDs of all of the widgets we need access
to in our event-handler routines, as well as object references to the iTool and
user interface object, the current dimensions of the base widget, and the title.
You may find it useful to cache other information in the state structure as well.
Some actions, such as retrieving the actual size of the top-level base widget,
can only be performed after the widget hierarchy has been realized. To prevent
flashing after realization but before we are ready to begin event processing, we
set the MAP keyword equal to 0 (zero) before realizing the widgets and back to
1 (one) just before our call to XMANAGER begins processing events.
iTool Class Definition Routine Discussion
The class definition routine creates a new iTool class based on the IDLitToolbase
class. The Init method simply unregisters operations and manipulators we do not
want to appear in the menus and toolbars of our new interface.
Example Code
This iTool class is defined in the file
example2tool__define.pro in the
examples/doc/itools subdirectory of the IDL distribution. Run the example
procedure by entering
example2tool__define at the IDL command prompt or