#! /usr/dt/bin/dtksh # # This sample shell script demonstrates how the CB_WIDGET and CB_CALL_DATA # convenience environment variables can be referenced within a callback # function. # integer ctemp1 # Initialise the text string in the temperature window at start DispStart() { XmScaleSetValue $SCALE 0 XmTextSetString $TEXT "Move the slider to desired Farenheit value" } # PushButton Callback: Forces the scale to reset to the origin ResetScale() { XmScaleSetValue $SCALE 0 XmTextSetString $TEXT "0 degrees C" } # PushButton Callback: Forces the scale to its minimum value SetScaleMin() { XmScaleSetValue $SCALE -200 XmTextSetString $TEXT "-128 degrees C" } # PushButton Callback: Forces the scale to its maximum value SetScaleMax() { XmScaleSetValue $SCALE 200 XmTextSetString $TEXT "93 degrees C" } # Scale Callback: Invoked when the user interactively modified the scale value ScaleValueChanged() { XmScaleGetValue $CB_WIDGET VALUE let "ctemp1 = ($VALUE - 32) * 5 / 9" XmTextSetString $TEXT "$ctemp1 degrees C" } ######################### Create the Main UI ################################# XtInitialize TOPLEVEL command1 Command1 "$0" "$@" #Next line creates the main box XtCreateManagedWidget FORM form XmForm $TOPLEVEL #Next line creates the top text box XtCreateManagedWidget TEXT text XmText $FORM \ topAttachment:ATTACH_FORM \ topOffset:5 \ leftAttachment:ATTACH_FORM \ leftOffset:90 \ rightAttachment:ATTACH_FORM \ rightOffset:90 # Next line prints a text string under the top text box XtCreateManagedWidget LABEL label XmLabel $FORM \ labelString:"Top box show Centigrade Value, slider is in Farenheit" \ topAttachment:ATTACH_FORM \ topOffset:35 \ leftAttachment:ATTACH_FORM \ leftOffset:70 # Next line prints a text string at the left of the slider bar XtCreateManagedWidget LABEL1 label XmLabel $FORM \ labelString:"-200" \ topAttachment:ATTACH_FORM \ topOffset:45 \ leftAttachment:ATTACH_FORM \ leftOffset:10 # Next line prints a text string at the right of the slider bar XtCreateManagedWidget LABEL1 label XmLabel $FORM \ labelString:"+200" \ topAttachment:ATTACH_FORM \ topOffset:45 \ rightAttachment:ATTACH_FORM \ rightOffset:10 #Next line creates the slider bar XtCreateManagedWidget SCALE scale XmScale $FORM \ showValue:True \ orientation:HORIZONTAL \ maximum:200 \ minimum:-200 \ topAttachment:ATTACH_FORM \ topOffset:50 \ leftAttachment:ATTACH_FORM \ leftOffset:10 \ rightAttachment:ATTACH_FORM \ rightOffset:10 XtAddCallback $SCALE valueChangedCallback ScaleValueChanged XtCreateManagedWidget SEP sep XmSeparator $FORM \ topAttachment:ATTACH_WIDGET \ topWidget:$SCALE \ topOffset:10 \ leftAttachment:ATTACH_FORM \ rightAttachment:ATTACH_FORM XtCreateManagedWidget PB pb XmPushButton $FORM \ labelString:"Reset Scale" \ topAttachment:ATTACH_WIDGET \ topOffset:10 \ topWidget:$SEP \ bottomAttachment:ATTACH_FORM \ bottomOffset:10 \ leftAttachment:ATTACH_POSITION \ leftPosition:10 \ rightAttachment:ATTACH_POSITION \ rightPosition:30 XtAddCallback $PB activateCallback ResetScale XtCreateManagedWidget PB2 pb XmPushButton $FORM \ labelString:"Set Scale Max" \ topAttachment:ATTACH_WIDGET \ topOffset:10 \ topWidget:$SEP \ bottomAttachment:ATTACH_FORM \ bottomOffset:10 \ leftAttachment:ATTACH_POSITION \ leftPosition:40 \ rightAttachment:ATTACH_POSITION \ rightPosition:60 XtAddCallback $PB2 activateCallback SetScaleMax XtCreateManagedWidget PB3 pb XmPushButton $FORM \ labelString:"Set Scale Min" \ topAttachment:ATTACH_WIDGET \ topOffset:10 \ topWidget:$SEP \ bottomAttachment:ATTACH_FORM \ bottomOffset:10 \ leftAttachment:ATTACH_POSITION \ leftPosition:70 \ rightAttachment:ATTACH_POSITION \ rightPosition:90 XtAddCallback $PB3 activateCallback SetScaleMin XtRealizeWidget $TOPLEVEL DispStart XtMainLoop