user manual

Chapter 14: Creating a User Interface Panel 323
iTool Developer’s Guide Example: A Simple UI Panel
distribution. Run the example procedure by entering example4_panel at the IDL
command prompt or view the file in an IDL Editor window by entering
.EDIT
example4_panel.pro.
Panel Creation Routine
The user interface panel creation routine (beginning with the line
PRO Example4_panel, wPanel, oUI) does the work of displaying the IDL
widgets that make up the UI panel display.
PRO Example4_panel, wPanel, oUI
; Set the title used on the panel's tab.
WIDGET_CONTROL, wPanel, BASE_SET_TITLE = 'Example Panel'
; Specify the event handler
WIDGET_CONTROL, wPanel, EVENT_PRO = "Example4_panel_event"
; Register the panel with the user interface object.
strObserverIdentifier = oUI->RegisterWidget(wPanel, "Panel", $
'Example4_panel_callback')
; Register to receive selection events on visualizations.
oUI->AddOnNotifyObserver, strObserverIdentifier, $
'Visualization'
; Retrieve a reference to the current iTool.
oTool = oUI->GetTool()
; Create a base widget to hold the contents of the panel.
wBase = WIDGET_BASE(wPanel, /COLUMN, SPACE = 5, /ALIGN_LEFT)
; Create panel contents.
wLabel = WIDGET_LABEL(wBase, VALUE = "Choose an Action:", $
/ALIGN_LEFT)
; Get the Operation ID of the rotate operation. If the operation
; exists, create the "Rotate Item" button and monitor whether
; the operation is available for the selected item.
opID = 'Operations/Operations/Rotate/RotateLeft'
oRotate = oTool->GetByIdentifier(opID)
IF (OBJ_VALID(oRotate)) THEN BEGIN
idRotate = oRotate->GetFullIdentifier()
wRotate = WIDGET_BUTTON(wBase, VALUE = "Rotate Item", $
UVALUE="ROTATE")
; Monitor for availablity of the Rotate operation.