Sliders.mesa
Written by Darlene Plebon on June 22, 1983 11:45 am
Last Edited by: Beach, June 22, 1983 6:15 pm
Last Edited by: Wyatt, December 1, 1983 11:26 am
DIRECTORY
GraphicsBasic USING [Color, white],
Rope USING [ROPE],
ViewerClasses USING [Viewer, ViewerRec],
ViewerOps USING [DestroyViewer];
Sliders:
CEDAR DEFINITIONS
IMPORTS ViewerOps =
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 =
PROCEDURE [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 =
PROCEDURE [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.
sliderGray: GraphicsBasic.Color = [r: 100, g: 100, b: 100];
Create:
PUBLIC
PROCEDURE [info: ViewerClasses.ViewerRec ← [], sliderProc: SliderProc ←
NIL, filterProc: FilterProc ←
NIL, orientation: SliderOrientation ← vertical, foreground: GraphicsBasic.Color ← sliderGray, background: GraphicsBasic.Color ← GraphicsBasic.white, value: NormalizedSliderValue ← 0.0, clientData:
REF
ANY ←
NIL, paint:
BOOL ←
TRUE]
RETURNS [slider: Slider];
Create 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.
"background" is the color of the background of the slider.
"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:
PUBLIC PROCEDURE [slider: Slider]
RETURNS [contents: NormalizedSliderValue];
GetContents returns the current value of the slider (in the range [0.0, 1.0]).
SetContents:
PUBLIC PROCEDURE [slider: Slider, contents: NormalizedSliderValue];
SetContents sets the value of the slider (in the range [0.0, 1.0]).
Destroy:
PUBLIC PROCEDURE [slider: Slider] =
INLINE {ViewerOps.DestroyViewer[slider]};
Destroy destroys the specified slider viewer.
END.