<> <> <> <> <> 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]; <> <<"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]; <> 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.>> <> <> <<"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.