
298 Chapter 13: Creating a User Interface Service
Creating a New UI Service iTool Developer’s Guide
Return Value
The user interface service routine should return 1 if the action succeeds, or 0
otherwise.
Retrieving Property Information
The oRequester argument to the user interface service function contains an object
reference to the iTool component on which the UI service was invoked. Use this
reference to retrieve any properties of the object that are relevant to the operation
being performed by the user interface.
For example, the standard
ScaleFactor user interface service displays a dialog that
lets the user set the SCALE_FACTOR property of an object. The service uses the
following statement to retrieve the current scale factor from the selected object:
oRequester->GetProperty, SCALE_FACTOR = factor
Retrieving Widget Information
The oUI argument to the user interface service function contains an object reference
to the IDLitUI object associated with the current iTool. You can use this reference to
retrieve the IDL widget identifier of the widget that is the group leader of the iTool
user interface itself (the iTool window); the ID is stored in the GROUP_LEADER
property of the IDLitUI object. Having this widget ID allows you to retrieve screen
geometry information that allows you to calculate the position at which your user
interface should be displayed.
For example, the
ScaleFactor user interface service uses the following code to
calculate the X and Y offsets that will be used to position its own user interface over
the current iTool:
; Retrieve the widget ID of top-level base.
oUI->GetProperty, GROUP_LEADER = groupLeader
IF (WIDGET_INFO(groupleader, /VALID)) THEN BEGIN
geom = WIDGET_INFO(groupLeader, /GEOMETRY)
xoffset = geom.scr_xsize + geom.xoffset - 80
yoffset = geom.yoffset + (geom.ysize - 400)/2
ENDIF
The UI service goes on to use the calculated xoffset and yoffset values when
positioning the IDL widgets that make up the interface displayed by the service.