initial framework added
[fp1415-soccerfun.git] / src / StdLibExt / RangeSlider.dcl
1 definition module RangeSlider
2
3 import StdEnv, StdIO
4
5 /** A (RangeSlider id dir width range action atts) value describes a control that allows users to select values from the
6 given range. The parameters have the following meaning:
7 id: the identification value of the range slider;
8 dir: the direction of the range slider (Horizontal or Vertical);
9 width: the length of the range slider;
10 range: the range {values=[v_0, ..., v_n],index=i}; here i is the 0-based index of the currently selected value, v_i.
11 When the user selects another value, then index will have the corresponding value;
12 action: the function that is applied to the current local and process state of the control whenever the user has used
13 the range slider;
14 atts: the standard set of control attributes.
15
16 Author: Peter Achten
17 E-mail: P.Achten@cs.ru.nl
18 Date: january 2008
19 Uses: Clean 2.2, Object I/O
20 */
21 :: RangeSliderId a
22 :: RangeSlider a ls pst
23 = RangeSlider (RangeSliderId a) Direction ControlWidth (Range a) (RangeAction a *(ls,pst)) [ControlAttribute *(ls,pst)]
24 :: Range a
25 = { values :: ![a]
26 , index :: !RangeIndex
27 }
28 :: RangeIndex
29 :== Int
30 :: RangeAction a st
31 :== a -> st -> st
32
33 openRangeSliderId :: !*env -> (!RangeSliderId a,!*env) | Ids env
34
35 instance Controls (RangeSlider a)
36
37 /** getRangeSliderIndex id pSt
38 yields (Just index) of the selected value of the indicated range slider if it exists, and Nothing otherwise.
39 getRangeSliderValue id pSt
40 yields (Maybe (values!!index)) of the indicated range slider if it exists, and Nothing otherwise.
41 setRangeSliderIndex id i pSt
42 sets the current index value of the indicated range slider to i, and applies the action function to that value
43 and the current local and process state.
44 If the indicated range slider does not exist, nothing happens.
45 setRangeSliderValue id v pSt
46 updates the value at the current index of the indicated range slider to v, and applies the action function to
47 that value and the current local and process state.
48 If the indicated range slider does not exist, nothing happens.
49 */
50 getRangeSliderIndex :: !(RangeSliderId a) !(PSt .ps) -> (!Maybe RangeIndex,!PSt .ps)
51 getRangeSliderValue :: !(RangeSliderId a) !(PSt .ps) -> (!Maybe a, !PSt .ps)
52 setRangeSliderIndex :: !(RangeSliderId a) !Index !(PSt .ps) -> PSt .ps
53 setRangeSliderValue :: !(RangeSliderId a) !a !(PSt .ps) -> PSt .ps