A SERVICE OF

logo

Chapter 15: Creating a Custom iTool Widget Interface 365
iTool Developer’s Guide Example: a Custom iTool Interface
example2_wdtool_cleanup
The cleanup routine for our interface is simple; it frees the pointer used to hold the
widget interface’s state structure. The complete code for the cleanup routine is shown
below.
PRO example2_wdtool_cleanup, wChild
; Make sure we have a valid widget ID.
IF (~WIDGET_INFO(wChild, /VALID)) THEN $
RETURN
; Retrieve the pointer to the state structure, and
; free it.
WIDGET_CONTROL, wChild, GET_UVALUE = pState
IF (PTR_VALID(pState)) THEN $
PTR_FREE, pState
END
Discussion
Note that this routine is only called when the widget interface is actually destroyed,
not when the WIDGET_KILL_REQUEST event is processed. See “Handling
Shutdown Events” on page 356 for details.
example2_wdtool_event
The main event-handling routine for our widget interface handles three types of
events that might be generated by the top-level base widget:
WIDGET_KILL_REQUEST (generated when the user requests that the
application be exited).
WIDGET_KBRD_FOCUS (generated when the user selects the application).
WIDGET_BASE (generated when the user resizes the top-level base widget.
A more complicated interface may handle additional events; the techniques used
would be similar to those illustrated here. The complete code for the main event-
handler routine is shown below.
PRO example2_wdtool_event, event
; Retrieve a pointer to the state structure.
wChild = WIDGET_INFO(event.handler, /CHILD)
WIDGET_CONTROL, wChild, GET_UVALUE = pState
CASE TAG_NAMES(event, /STRUCTURE_NAME) OF