DIRECTORY GraphicsBasic USING [Color, white], Rope USING [ROPE], ViewerClasses USING [Viewer, ViewerRec], ViewerOps USING [DestroyViewer]; MySliders: 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] SliderState: TYPE = {inputDisabled, inputEnabled}; SliderValue: TYPE = REAL; -- in range [0.0, 1.0] SliderData: TYPE = REF SliderDataRec; SliderDataRec: TYPE = RECORD [ sliderProc: SliderProc _ NIL, -- client procedure called when slider value changed filterProc: FilterProc _ NIL, -- client procedure for filtering slider updates orientation: SliderOrientation, -- orientation of slider image (horizontal or vertical) foreground: GraphicsBasic.Color, -- color of slider foreground background: GraphicsBasic.Color, -- color of slider background normalizedSliderValue: NormalizedSliderValue _ 0.0, -- in range [0.0, 1.0] mouseValue: SliderValue _ 0.0, -- mouse position in slider sliderValue: SliderValue _ 0.0, -- slider value in viewer screen coordinates maxSliderValue: SliderValue _ 0.0, -- maximum slider value in viewer screen coordinates oldSliderValue: SliderValue _ 0.0, -- previous value in viewer screen coordinates savedSliderValue: SliderValue _ 0.0, -- value to rollback to if operation aborted reason: Reason _ move, -- reason for calling client proc oldReason: Reason _ move, -- reason for calling client proc the last time state: SliderState _ inputDisabled, -- indicates whether mouse input is being accepted clientData: REF ANY ]; SliderProc: TYPE = PROCEDURE [slider: Slider, reason: Reason, value: NormalizedSliderValue, clientData: REF ANY _ NIL]; FilterProc: TYPE = PROCEDURE [value: NormalizedSliderValue, clientData: REF ANY] RETURNS [filteredValue: NormalizedSliderValue]; 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]; GetContents: PUBLIC PROCEDURE [slider: Slider] RETURNS [contents: NormalizedSliderValue]; SetContents: PUBLIC PROCEDURE [slider: Slider, contents: NormalizedSliderValue]; Destroy: PUBLIC PROCEDURE [slider: Slider] = INLINE {ViewerOps.DestroyViewer[slider]}; END. μMySliders.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 Last Edited by: Monier, September 21, 1984 1:44:19 am PDT 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 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 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 returns the current value of the slider (in the range [0.0, 1.0]). SetContents sets the value of the slider (in the range [0.0, 1.0]). Destroy destroys the specified slider viewer. Κλ– "Mesa" style˜Jšœ™Jšœ3™3J™,J™0J™9J˜šΟk ˜ Jšœœ˜#Jšœœœ˜Jšœœ˜(Jšœ œ˜ J˜—šœ œ˜Jšœ ˜—J˜Jšœœ˜J˜Jšœœ Οc˜/J˜Jšœœ˜1J˜Jšœœ˜"J˜Jšœœœž˜;J˜Jšœ œ!˜2Jšœ œœž˜4Jšœ œœ˜&šœœœ˜Jšœœž4˜TJšœœž-˜PJšœ"ž7˜YJšœ"ž˜?Jšœ"ž˜?Jšœ4ž˜JJšœ ž˜;Jšœ!ž,˜MJšœœž4˜WJšœ$ž.˜RJšœ$ž-˜QJšœž!˜