<> <> <> DIRECTORY GraphicsBasic USING [Color, white], Rope USING [ROPE], ViewerClasses USING [Viewer, ViewerRec], ViewerOps USING [DestroyViewer]; Sliders: CEDAR DEFINITIONS IMPORTS GraphicsBasic, 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]; <> <<"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]; <> 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]; <> <<"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.>> <> <> <<"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]; <> SetContents: PUBLIC PROCEDURE [slider: Slider, contents: NormalizedSliderValue]; <> Destroy: PUBLIC PROCEDURE [slider: Slider] = INLINE {ViewerOps.DestroyViewer[slider]}; <> END.