initial framework added
[fp1415-soccerfun.git] / src / StdLibExt / RangeSlider.dcl
diff --git a/src/StdLibExt/RangeSlider.dcl b/src/StdLibExt/RangeSlider.dcl
new file mode 100644 (file)
index 0000000..5c4c987
--- /dev/null
@@ -0,0 +1,53 @@
+definition module RangeSlider\r
+\r
+import StdEnv, StdIO\r
+\r
+/**    A (RangeSlider id dir width range action atts) value describes a control that allows users to select values from the \r
+       given range. The parameters have the following meaning:\r
+       id:             the identification value of the range slider;\r
+       dir:    the direction of the range slider (Horizontal or Vertical);\r
+       width:  the length of the range slider;\r
+       range:  the range {values=[v_0, ..., v_n],index=i}; here i is the 0-based index of the currently selected value, v_i.\r
+                       When the user selects another value, then index will have the corresponding value;\r
+       action: the function that is applied to the current local and process state of the control whenever the user has used\r
+                       the range slider;\r
+       atts:   the standard set of control attributes.\r
+       \r
+       Author: Peter Achten\r
+       E-mail: P.Achten@cs.ru.nl\r
+       Date:   january 2008\r
+       Uses:   Clean 2.2, Object I/O\r
+*/\r
+::     RangeSliderId a\r
+::     RangeSlider a ls pst\r
+       =       RangeSlider (RangeSliderId a) Direction ControlWidth (Range a) (RangeAction a *(ls,pst)) [ControlAttribute *(ls,pst)]\r
+::     Range a\r
+       =       { values        :: ![a]\r
+               , index         :: !RangeIndex\r
+               }\r
+::     RangeIndex\r
+       :== Int\r
+::     RangeAction a st\r
+       :== a -> st -> st\r
+\r
+openRangeSliderId :: !*env -> (!RangeSliderId a,!*env) | Ids env\r
+\r
+instance Controls (RangeSlider a)\r
+\r
+/** getRangeSliderIndex id pSt\r
+               yields (Just index) of the selected value of the indicated range slider if it exists, and Nothing otherwise.\r
+       getRangeSliderValue id pSt\r
+               yields (Maybe (values!!index)) of the indicated range slider if it exists, and Nothing otherwise.\r
+       setRangeSliderIndex id i pSt\r
+               sets the current index value of the indicated range slider to i, and applies the action function to that value\r
+               and the current local and process state.\r
+               If the indicated range slider does not exist, nothing happens.\r
+       setRangeSliderValue id v pSt\r
+               updates the value at the current index of the indicated range slider to v, and applies the action function to \r
+               that value and the current local and process state.\r
+               If the indicated range slider does not exist, nothing happens.\r
+*/\r
+getRangeSliderIndex :: !(RangeSliderId a)        !(PSt .ps) -> (!Maybe RangeIndex,!PSt .ps)\r
+getRangeSliderValue :: !(RangeSliderId a)        !(PSt .ps) -> (!Maybe a,         !PSt .ps)\r
+setRangeSliderIndex :: !(RangeSliderId a) !Index !(PSt .ps) ->                     PSt .ps\r
+setRangeSliderValue :: !(RangeSliderId a) !a     !(PSt .ps) ->                     PSt .ps\r