A SERVICE OF

logo

Chapter 14: Creating a User Interface Panel 325
iTool Developer’s Guide Example: A Simple UI Panel
The example uses the GetTool method of the IDLitUI object to retrieve an
object reference to the iTool with which the panel is associated. This reference
is later used to retrieve a reference to the IDLitOperation object that performs
the
Rotate Left operation, placing it in the variable oRotate.
•If the
Rotate Left operation is available to the iTool, the example places the
Rotate button on the user interface panel. It also establishes an observer to
watch for changes in the availability of the
Rotate Left operation, which
will change based on the item selected. The callback routine uses the messages
received by this observer to sensitize and desensitize the
Rotate button as
necessary.
The example packages important information in a state structure, and assigns
this structure to the user value of the first child widget of the panel widget. The
event-handling and callback routines will retrieve this state structure and use
the information contained therein.
Panel Event Handler Routine
The event-handler routine (beginning with the line PRO Example4_panel_event,
event
) receives widget events generated by the widgets that make up the user
interface panel, and acts accordingly.
PRO Example4_panel_event, event
; Retrieve the widget ID of the first child widget of
; the UI panel.
wChild = WIDGET_INFO(event.handler, /CHILD)
; Retrieve the state structure from the user value of
; the first child widget.
WIDGET_CONTROL, wChild, GET_UVALUE = state
; Retrieve the user value of the widget that generated
; the event.
WIDGET_CONTROL, event.id, GET_UVALUE = uvalue
; Now do the work for each panel item.
SWITCH STRUPCASE(uvalue) OF
'ROTATE': BEGIN
; Apply the Rotate Left operation to the selected item.
success = state.oUI->DoAction(state.idRotate)
RETURN
END
'HIDE': BEGIN
; Hide the selected item.
;