user manual

Chapter 15: Creating a Custom iTool Widget Interface 363
iTool Developer’s Guide Example: a Custom iTool Interface
Discussion
The FILENAME message and the rest of the callback routine are discussed in
“Example Callback Routine” on page 352.
example2_wdtool_resize
The widget resizing routine for our example interface is shown below. It accepts
three arguments: a pointer to the widget interface state structure, an integer
representing the change in width (in pixels), and an integer representing the change in
height (also in pixels).
Note
Widget resizing code depends almost entirely on the structure and layout of the
widget interface you are creating. While this example may give you ideas about
how to resize your interface, you will need to change it — probably substantially —
to suit the needs of your interface.
PRO example2_wdtool_resize, pState, deltaW, deltaH
; Retrieve the original geometry (prior to the resize)
; of the iTool draw and toolbar widgets.
drawgeom = WIDGET_INFO((*pState).wDraw, /GEOMETRY)
toolbarGeom = WIDGET_INFO((*pState).wToolbar, /GEOMETRY)
; Compute the updated dimensions of the visible portion
; of the draw widget.
newVisW = (drawgeom.xsize + deltaW)
newVisH = (drawgeom.ysize + deltaH)
; Check whether UPDATE is turned on, and save the value.
isUpdate = WIDGET_INFO((*pState).wBase, /UPDATE)
; Under Unix, UPDATE must be turned on or windows will
; not resize properly. Turn UPDATE off under Windows
; to prevent window flashing.
IF (!VERSION.OS_FAMILY EQ 'Windows') THEN BEGIN
IF (isUpdate) THEN $
WIDGET_CONTROL, (*pState).wBase, UPDATE = 0
ENDIF ELSE BEGIN
; On Unix make sure update is on.
IF (~isUpdate) THEN $
WIDGET_CONTROL, (*pState).wBase, /UPDATE
ENDELSE
; Update the draw widget dimensions.
IF (newVisW NE drawgeom.xsize || newVisH ne drawgeom.ysize) $