ITT Rule IDL Version 7.0 User Manual Page 357

  • Download
  • Add to my manuals
  • Print
  • Page
    / 430
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 356
Chapter 15: Creating a Custom iTool Widget Interface 357
iTool Developer’s Guide Handling Shutdown Events
Your code should not assume that the top-level base widget will actually be
destroyed, because the user may decide to cancel the close operation. Since the
process of actually destroying the widget hierarchy is divorced from the generation of
the WIDGET_KILL_REQUEST event, you may also need to supply a cleanup
routine that is invoked only when the widget hierarchy is actually destroyed.
Writing a Cleanup Routine
A cleanup routine is necessary if your widget interface uses heap variables (pointers
or objects) to store information about itself — the heap variables will need to be
cleaned up separately when the interface itself is destroyed. The following code, from
the cleanup routine in the
example2_wdtool.pro interface definition (developed
in Example: a Custom iTool Interface” on page 360), frees the pointer used to store
the widget interface’s state structure.
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
Calling the Cleanup Routine
The final step is to specify when the cleanup routine should be called. Since the user
can cancel out of the shutdown operation, the cleanup routine should only be called
when the widget hierarchy is actually destroyed, not when the
WIDGET_KILL_REQUEST event is handled. We accomplish this by specifying the
cleanup routine as the value of the KILL_NOTIFY keyword to the WIDGET_BASE
function.
In the standard iTool widget interface and in our example code, we set the
KILL_NOTIFY keyword on the first child widget of the top-level base widget. The
following statement, near the end of the interface definition routine, specifies the
name of the cleanup routine in the
example2_wdtool.pro interface definition
(developed in “Example: a Custom iTool Interface” on page 360):
WIDGET_CONTROL, wChild, KILL_NOTIFY = "example2_wdtool_cleanup"
Page view 356
1 2 ... 352 353 354 355 356 357 358 359 360 361 362 ... 429 430

Comments to this Manuals

No comments