Sliders.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
Written by Darlene Plebon on June 22, 1983 11:45 am
Last Edited by: Beach, June 22, 1983 6:15 pm
Doug Wyatt, March 29, 1985 2:35:00 pm PST
DIRECTORY
Imager USING [Color],
Rope USING [ROPE],
ViewerClasses USING [Viewer, ViewerRec];
Sliders: CEDAR DEFINITIONS
= BEGIN OPEN ViewerClasses;
Slider: TYPE = Viewer; -- A slider is a viewer
SliderOrientation: TYPE = {horizontal, vertical};
Reason: TYPE = {move, set, abort};
NormalizedSliderValue: TYPE = REAL; -- in range [0.0, 1.0]
SliderProc: TYPE = PROC [slider: Slider,
reason: Reason, value: NormalizedSliderValue, clientData: REF ANY ¬ NIL];
SliderProc is the type of the client supplied procedure which is called when the slider's value is changed by mouse input. This routine is called on red down, then periodically while the red mouse button is held down provided the mouse coordinates have changed, and upon release of the button. The client procedure is also called on an abort, which occurs when the red button is released while the cursor is outside the slider (off a side of the slider not off one of its ends), or when the yellow or blue mouse button is pressed while red is still down. Driving the cursor off either end of the slider does not cause an abort, but rather sets the slider to its maximum or minimum value as appropriate.
"slider" is the slider viewer being updated.
"reason" is the reason the client procedure is being called.
$Move - new slider value while red down.
$Set - red up, new slider value.
$Abort - an abort has just occurred causing the slider value to be reset to the value it had prior to red down.
"value" is the (new) slider value in the range [0.0, 1.0].
"clientData" is optional information for use by the client.
FilterProc: TYPE = PROC [value: NormalizedSliderValue, clientData: REF ANY]
RETURNS [filteredValue: NormalizedSliderValue];
FilterProc is the type of an optional client supplied procedure which is called whenever the slider value is changed by mouse input. This procedure is used to filter the slider value before feedback is provided on the slider. It can be used to make the slider move in discrete jumps, for example.
Create: PROC [info: ViewerClasses.ViewerRec ¬ [],
sliderProc: SliderProc ¬ NIL,
filterProc: FilterProc ¬ NIL,
orientation: SliderOrientation ¬ vertical,
foreground: Imager.Color ¬ NIL,
background: Imager.Color ¬ NIL,
value: NormalizedSliderValue ¬ 0.0,
clientData: REF ANY ¬ NIL,
paint: BOOL ¬ TRUE
] RETURNS [slider: Slider];
... creates a slider viewer.
"sliderProc" is a client procedure which is called when the slider's value is changed by mouse input.
"filterProc" is a client procedure which is called to filter slider value updates.
"orientation" is the orientation of the slider.
vertical - slide up to increase the value, down to decrease it.
horizontal - slide right to increase the value, left to decrease it.
"foreground" is the color of the foreground of the slider; default is medium gray.
"background" is the color of the background of the slider; default is white.
"value" is the initial value of the slider. Slider values are in the range [0.0, 1.0].
"clientData" is optional information for use by the client. Returned when the client proc is called.
GetContents: PROC [slider: Slider] RETURNS [contents: NormalizedSliderValue];
... returns the current value of the slider (in the range [0.0, 1.0]).
SetContents: PROC [slider: Slider, contents: NormalizedSliderValue];
... sets the value of the slider (in the range [0.0, 1.0]).
Destroy: PROC [slider: Slider];
... destroys the specified slider viewer.
END.