user manual
Chapter 13: Creating a User Interface Service 299
iTool Developer’s Guide Creating a New UI Service
Displaying the User Interface
If the user interface being displayed by the UI service is simple, it may be convenient
to include the code for creating it directly in the definition of the user interface
service itself. For example, the following is the complete definition of the
HourGlassCursor user interface service:
FUNCTION IDLitUIHourGlass, oUI, oRequester
WIDGET_CONTROL, /HOURGLASS
RETURN, 1
END
As you can see, no information about the IDLitUI object or the selected iTool
component is used, and the displayed item itself is very simple.
In most cases, the user interface service is significantly more complex. In these cases
it is often useful to separate the routine that creates the service’s user interface from
the code that displays it. For example, the user interface for the ScaleFactor service is
displayed by the following statement:
result = IDLitwdScaleFactor(GROUP_LEADER = groupLeader, $
FACTOR = factor, XOFFSET = xoffset, YOFFSET = yoffset)
IF result EQ 1 THEN RETURN, 0
This statement calls another function — IDLitwdScaleFactor — to actually display
the required user interface elements, supplying the information retrieved by other
portions of the user interface service routine. The IDLitwdScaleFactor function
returns the scale factor value selected by the user, or returns the value 1 (indicating no
scaling) if the value supplied by the user is invalid. If the returned scale factor is 1
(either because the user entered 1 as the value, or because the entered value was not a
valid value), no scaling will be performed, so the UI service itself returns the failure
value (integer 0). The process of creating user interface elements is discussed in
greater detail in “Creating Supporting User Interface Elements” on page 300.
Setting Property Information
If the user has selected a new value for any of the object’s properties, that value must
be changed on the object by a call to the SetProperty method. In our example, if the
user sets a new scale factor, the following statement updates the property value,
notifies the selected object that the value has changed, and inserts the change into the
undo-redo transaction buffer:
oRequester->SetProperty, SCALE_FACTOR = result
Note that not every user interface will modify properties of the selected object.