
366 Chapter 15: Creating a Custom iTool Widget Interface
Example: a Custom iTool Interface iTool Developer’s Guide
; Destroy the widget.
'WIDGET_KILL_REQUEST': BEGIN
; Get the shutdown service and call DoAction.
; This code must be here, and not in the _cleanup routine,
; because the tool may not actually be killed. (For example
; the user may be asked if they want to save, and they may
; hit "Cancel" instead.)
IF OBJ_VALID((*pState).oUI) THEN BEGIN
oTool = (*pState).oUI->GetTool()
oShutdown = oTool->GetService('SHUTDOWN')
void=(*pState).oUI->DoAction(oShutdown->getFullIdentifier())
ENDIF
END
; Focus change.
'WIDGET_KBRD_FOCUS': BEGIN
; If the iTool is gaining the focus, Get the set current tool
; service and call DoAction.
IF (event.enter && OBJ_VALID((*pState).oUI)) THEN BEGIN
oTool = (*pState).oUI->GetTool()
oSetCurrent = oTool->GetService('SET_AS_CURRENT_TOOL')
void = oTool->DoAction(oSetCurrent->GetFullIdentifier())
ENDIF
END
; 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
ELSE: ; Do nothing
ENDCASE
END
Discussion
Two of the three events handled in this routine are discussed in earlier sections of this
chapter. See “Handling Resize Events” on page 354 for details on the
WIDGET_BASE event and “Handling Shutdown Events” on page 356 for details on
the WIDGET_KILL_REQUEST event.