A SERVICE OF

logo

354 Chapter 15: Creating a Custom iTool Widget Interface
Handling Resize Events iTool Developer’s Guide
Handling Resize Events
It is beyond the scope of this chapter to discuss resizing of widget interfaces in
general; see “Widget Sizing” (Chapter 3, Widget Application Programming) for a
discussion of widget sizing issues. This section describes some things you will need
to know in order to make your custom iTool widget interface resize properly.
Generating Resize Events
If you want users to be able to resize the custom iTool interface you are creating, you
must set the TLB_SIZE_EVENTS keyword when creating the top-level widget base
that holds your interface. With this keyword set, when the user resizes the top-level
base, a WIDGET_BASE event is generated, reporting the new width and height of
the base widget.
Handling the Resize Event
The technique used by the standard iTool widget interface to handle resize events for
the top-level base involves storing the current size of the base widget in the widget’s
state structure. The state structure is available to widget event handling and callback
routines in the user value of the first child widget of the top-level base.
The following code, from the event handling routine in the
example2_wdtool.pro
interface definition (developed in “Example: a Custom iTool Interface” on page 360),
uses the value stored in the
basesize field of the state structure, along with the new
size of the base widget, to calculate the change in the size of the base. The changes in
the size are then passed as arguments to the EXAMPLE2_WDTOOL_RESIZE
routine, which handles the actual resizing of the interface elements.
; The top-level base was resized
'WIDGET_BASE': BEGIN
; Compute the size change of the base relative to
; its cached former size.
WIDGET_CONTROL, event.top, TLB_GET_SIZE = newSize
deltaW = newSize[0] - (*pState).basesize[0]
deltaH = newSize[1] - (*pState).basesize[1]
example2_wdtool_resize, pState, deltaW, deltaH
END
Writing a Resize Routine
Writing a resizing routine for your custom iTool user interface may be the most
complicated part of the task. Each interface is different, and resize events must be