/* _mslider001.pkg - jun '98 - by Marc Barilley This package provides a horizontal double slider, i.e. a basic control, which allows to choose a pair of values on a predifined scale. There are several flags to define the look : . SLIDER_LEFT_FIXED : fixes the left cursor . SLIDER_RIGHT_FIXED : fixes the right cursor . SLIDER_INTER_FIXED : fixes the space between the two cursors . SLIDER_DRAW_SCALE : draws the scale . SLIDER_DRAW_VALUE : draws the values above each cursor . SLIDER_BUTTON : draws fine tuning buttons on each end of the bar . SLIDER_HIDDEN : hide the slider . SLIDER_UNHIDDEN : show the slider . SLIDER_NORMAL : shortcut for SLIDER_DRAW_SCALE|SLIDER_DRAW_VALUE|SLIDER_BUTTON All the features can be dynamically changed. USER callable functions . _CRslider [channel Chn, father ObjWin, font ObjFont, x I, y I, w I, h I, interval_color I, mini F, maxi F, left F, right F, callback fun [F F] I, flags I] ObjSlider constructs the slider according to the parameters. . _DSslider [ObjSlider] I destroys the slider . _CPslider [ObjSlider ObjSlider] ObjSlider makes a copy of the second in the first slider, except for attributes, which control the internal behaviour of the slider Returns its first argument . _SETsliderPrecisionStep [ObjSlider F] ObjSlider sets the step for buttons . _SETsliderColor [ObjSlider I] ObjSlider sets the color of the interval . _SETsliderBackColor [ObjSlider I] ObjSlider sets the color of the background . _SETsliderCursorColor [ObjSlider I] ObjSlider sets the color of the cursors . _SETsliderMax [ObjSlider F] ObjSlider sets the upper limit of the scale . _SETsliderMin [ObjSlider F] ObjSlider sets the lower limit of the scale . _SETsliderFont [ObjSlider ObjFont] ObjSlider sets the font for the scale and the values . _SETsliderLeft [ObjSlider F] ObjSlider sets the position for the left cursor . _SETsliderRight [ObjSlider F] ObjSlider sets the position for the right cursor . _SETsliderFlags [ObjSlider I] ObjSlider sets the flags . _SETsliderPrecisionMark [ObjSlider I] Slider indicates how many decimals are to be shown Every "_GET" function exists too. . _SHOWslider [ObjSlider I] ObjSlider shows or hides the slider. flag can be either SLIDER_HIDDEN or SLIDER_UNHIDDEN files needed : locked/lib/const.pkg locked/lib/_mlistlib001.pkg */ var SLIDER_NORMAL = 0b00111000;; var SLIDER_LEFT_FIXED = 0b00000001;; var SLIDER_RIGHT_FIXED = 0b00000010;; var SLIDER_INTER_FIXED = 0b00000100;; var SLIDER_DRAW_SCALE = 0b00001000;; var SLIDER_DRAW_VALUE = 0b00010000;; var SLIDER_BUTTON = 0b00100000;; var SLIDER_HIDDEN = 0b01000000;; var SLIDER_UNHIDDEN = 0b10000000;; /* login structure : slider window */ struct ObjSlider= [ chSlider : Chn, winSlider : ObjWin, barwinSlider : ObjWin, ulwinSlider : ObjWin, dlwinSlider : ObjWin, urwinSlider : ObjWin, drwinSlider : ObjWin, backSlider : ObjBitmap, backBarSlider : ObjBitmap, backUlSlider : ObjBitmap, backDlSlider : ObjBitmap, backUrSlider : ObjBitmap, backDrSlider : ObjBitmap, fontSlider : ObjFont, xSlider : I, ySlider : I, wSlider : I, hSlider : I, colorSlider : I, bcolorSlider : I, ccolorSlider : I, flagsSlider : I, moveSlider : fun [ObjSlider F F] I, stepSlider : F, minSlider : F, maxSlider : F, lSlider : F, rSlider : F, pmarkSlider : I, leftDownSlider : I, rightDownSlider : I, timerSlider : Timer ] mkSlider;; fun dec2 (l)= if l==nil then ('0)::nil else if (hd l) == '. then tl l else if (hd l) == '0 then dec2 tl l else l;; fun dec1 (s, n, d)= if s==nil then nil else if n<=0 then if d then nil else let hd s -> c in if c == '. then c::(dec1 tl s 0 1) else c::(dec1 tl s 0 0) else let hd s -> c in if c == '. then c::(dec1 tl s n 1) else if d then c::(dec1 tl s n-1 1) else c::(dec1 tl s n 0);; /* if (s==nil) || (n==0) then nil else let hd s -> c in if c == '. then c::(dec1 tl s n 1) else if d then c::(dec1 tl s n-1 1) else c::(dec1 tl s n 0);; */ fun deci (s, n)= let mirror dec1 s n 0 -> l in mirror dec2 l;; fun drawBevel (bitmap, x, y, w, h, t, c, o)= let if o then 0 else 0xe9e9e9 -> c1 in let if o then 0xe9e9e9 else 0 -> c2 in { let t -> i in while i > 0 do { _DRAWline bitmap w+x-i y+i w+x-i h+y-i DRAW_SOLID 1 c1; _DRAWline bitmap w+x-i h+y-i x+i h+y-i DRAW_SOLID 1 c1; set i = i - 1 }; let t -> i in while i > 0 do { _DRAWline bitmap x+i h+y-i x+i y+i DRAW_SOLID 1 c2; _DRAWline bitmap x+i y+i w+x-i y+i DRAW_SOLID 1 c2; set i = i - 1 } };; fun drawPanel (bitmap, x, y, w, h, t, c, o)= _DRAWrectangle bitmap x+t y+t w-t h-t DRAW_SOLID 1 c DRAW_SOLID c; drawBevel bitmap x y w h t c o;; /* bar window */ fun rflPaintBarSlider (w, s)= let _GETwindowPositionSize s.barwinSlider -> [x y w h] in let (ftoi (itof w)*.(s.lSlider-.s.minSlider) /. (s.maxSlider-.s.minSlider)) -> x1 in let (ftoi (itof w)*.(s.rSlider-.s.minSlider) /. (s.maxSlider-.s.minSlider)) -> x2 in { _DRAWrectangle s.backBarSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backBarSlider 0 0 x1-4 h-1 2 s.bcolorSlider 0; drawPanel s.backBarSlider x2+4 0 w-x2-4 h-1 2 s.bcolorSlider 0; if x1==x2 then drawPanel s.backBarSlider x1-3 0 6 h-1 1 s.ccolorSlider 1 else { drawPanel s.backBarSlider x1+4 0 x2-x1-8 h-1 2 s.colorSlider 0; drawPanel s.backBarSlider x1-3 0 6 h-1 1 s.ccolorSlider 1; drawPanel s.backBarSlider x2-3 0 6 h-1 1 s.ccolorSlider 1; }; }; _BLTbitmap s.barwinSlider s.backBarSlider 0 0;; fun rflClickBarSlider (w, s, x, y, b)= if b==1 then set s.leftDownSlider = 1 else if b==2 then set s.rightDownSlider = 1 else nil;; fun rflUnclickBarSlider (w, s, x, y, b)= let _GETwindowPositionSize w -> [xbar ybar wbar hbar] in if (x>wbar) || (x<0) || (y>hbar) || (y<0) then nil else { let (itof x)*.(s.maxSlider-.s.minSlider)/.(itof wbar)+.s.minSlider -> new in if s.leftDownSlider then { if s.flagsSlider & SLIDER_LEFT_FIXED then nil else if s.flagsSlider & SLIDER_INTER_FIXED then let s.rSlider -. s.lSlider -> inter in if s.rSlider +. new -. s.lSlider >. s.maxSlider then { set s.rSlider = s.maxSlider; set s.lSlider = s.maxSlider -. inter; } else { set s.lSlider = new; set s.rSlider = new -. inter; } /* if s.rSlider +. new -. s.lSlider >. s.maxSlider then { set s.lSlider = s.lSlider +. s.maxSlider -. s.rSlider; set s.rSlider = s.maxSlider; } else { set s.rSlider = s.rSlider +. new -. s.lSlider; set s.lSlider = new; } */ else if x==0 then set s.lSlider = s.minSlider else if new >. s.rSlider then set s.lSlider = s.rSlider else set s.lSlider = new; set s.leftDownSlider=0; _PAINTwindow s.winSlider; exec s.moveSlider with [s s.lSlider s.rSlider]; } else if s.rightDownSlider then { if s.flagsSlider & SLIDER_RIGHT_FIXED then nil else if s.flagsSlider & SLIDER_INTER_FIXED then let s.rSlider -. s.lSlider -> inter in if s.lSlider +. new -. s.rSlider <. s.minSlider then { set s.lSlider = s.minSlider; set s.rSlider = s.minSlider +. inter; } else { set s.rSlider = new; set s.lSlider = new +. inter; } /* if s.lSlider +. new -. s.rSlider <. s.minSlider then { set s.rSlider = s.rSlider +. s.minSlider -. s.lSlider; set s.lSlider = s.minSlider; } else { set s.lSlider = s.lSlider +. new -. s.rSlider; set s.rSlider = new; } */ else if x==wbar then set s.rSlider = s.maxSlider else if new <. s.lSlider then set s.rSlider = s.lSlider else set s.rSlider = new; set s.rightDownSlider=0; _PAINTwindow s.winSlider; exec s.moveSlider with [s s.lSlider s.rSlider]; } else nil; };; /* buttons */ fun rflTimerSlider (t, i, s)= if i==0 then if s.flagsSlider & SLIDER_LEFT_FIXED then _deltimer s.timerSlider else { if s.flagsSlider & SLIDER_INTER_FIXED then if s.rSlider +. s.stepSlider >. s.maxSlider then let s.rSlider -. s.lSlider -> inter in { set s.rSlider = s.maxSlider; set s.lSlider = s.maxSlider -. inter; _deltimer s.timerSlider; } else { set s.rSlider = s.rSlider +. s.stepSlider; set s.lSlider = s.lSlider +. s.stepSlider; 0 } else if s.lSlider +. s.stepSlider >. s.rSlider then { set s.lSlider = s.rSlider; _deltimer s.timerSlider; } else { set s.lSlider = s.lSlider +. s.stepSlider; 0 }; _PAINTwindow s.winSlider; 0 } else if i==1 then if s.flagsSlider & SLIDER_LEFT_FIXED then _deltimer s.timerSlider else { if s.flagsSlider & SLIDER_INTER_FIXED then if s.lSlider -. s.stepSlider <. s.minSlider then let s.rSlider -. s.lSlider -> inter in { set s.rSlider = s.minSlider +. inter; set s.lSlider = s.minSlider; _deltimer s.timerSlider; } else { set s.rSlider = s.rSlider -. s.stepSlider; set s.lSlider = s.lSlider -. s.stepSlider; 0 } else if s.lSlider <. s.minSlider then { set s.lSlider = s.minSlider; _deltimer s.timerSlider; } else { set s.lSlider = s.lSlider -. s.stepSlider; 0 }; _PAINTwindow s.winSlider; 0 } else if i==2 then if s.flagsSlider & SLIDER_RIGHT_FIXED then _deltimer s.timerSlider else { if s.flagsSlider & SLIDER_INTER_FIXED then if s.rSlider +. s.stepSlider >. s.maxSlider then let s.rSlider -. s.lSlider -> inter in { set s.rSlider = s.maxSlider; set s.lSlider = s.maxSlider -. inter; _deltimer s.timerSlider; } else { set s.rSlider = s.rSlider +. s.stepSlider; set s.lSlider = s.lSlider +. s.stepSlider; 0 } else if s.rSlider +. s.stepSlider >. s.maxSlider then { set s.rSlider = s.maxSlider; _deltimer s.timerSlider; } else { set s.rSlider = s.rSlider +. s.stepSlider; 0 }; _PAINTwindow s.winSlider; 0 } else if i==3 then if s.flagsSlider & SLIDER_RIGHT_FIXED then _deltimer s.timerSlider else { if s.flagsSlider & SLIDER_INTER_FIXED then if s.lSlider -. s.stepSlider <. s.minSlider then let s.rSlider -. s.lSlider -> inter in { set s.rSlider = s.minSlider +. inter; set s.lSlider = s.minSlider; _deltimer s.timerSlider; } else { set s.rSlider = s.rSlider -. s.stepSlider; set s.lSlider = s.lSlider -. s.stepSlider; 0 } else if s.rSlider <. s.lSlider then { set s.rSlider = s.lSlider; _deltimer s.timerSlider; } else { set s.rSlider = s.rSlider -. s.stepSlider; 0 }; _PAINTwindow s.winSlider; 0 } else 0;; fun rflPaintButtonSlider (wn, s)= if wn==s.ulwinSlider then _BLTbitmap wn s.backUlSlider 0 0 else if wn==s.dlwinSlider then _BLTbitmap wn s.backDlSlider 0 0 else if wn==s.urwinSlider then _BLTbitmap wn s.backUrSlider 0 0 else _BLTbitmap wn s.backDrSlider 0 0;; fun rflClickButtonSlider (wn, s, x, y, b)= if b==1 then { let _GETwindowPositionSize wn -> [_ _ w h] in if wn==s.ulwinSlider then { _DRAWrectangle s.backUlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUlSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backUlSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 "<"; set s.timerSlider = _rfltimer _starttimer s.chSlider 100 mkfun3 @rflTimerSlider s 1; rflTimerSlider s.timerSlider 1 s; } else if wn==s.dlwinSlider then { _DRAWrectangle s.backDlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDlSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backDlSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 ">"; set s.timerSlider = _rfltimer _starttimer s.chSlider 100 mkfun3 @rflTimerSlider s 0; rflTimerSlider s.timerSlider 0 s; } else if wn==s.urwinSlider then { _DRAWrectangle s.backUrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUrSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backUrSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 ">"; set s.timerSlider = _rfltimer _starttimer s.chSlider 100 mkfun3 @rflTimerSlider s 2; rflTimerSlider s.timerSlider 2 s; } else { _DRAWrectangle s.backDrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDrSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backDrSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 "<"; set s.timerSlider = _rfltimer _starttimer s.chSlider 100 mkfun3 @rflTimerSlider s 3; rflTimerSlider s.timerSlider 3 s; }; _PAINTwindow s.winSlider; } else nil;; fun rflUnclickButtonSlider (wn, s, x, y, b)= if b==1 then { let _GETwindowPositionSize wn -> [_ _ w h] in if wn==s.ulwinSlider then { _DRAWrectangle s.backUlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUlSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backUlSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 "<"; _deltimer s.timerSlider; } else if wn==s.dlwinSlider then { _DRAWrectangle s.backDlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDlSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backDlSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 ">"; _deltimer s.timerSlider; } else if wn==s.urwinSlider then { _DRAWrectangle s.backUrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUrSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backUrSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 ">"; _deltimer s.timerSlider; } else { _DRAWrectangle s.backDrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDrSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backDrSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 "<"; _deltimer s.timerSlider; }; _PAINTwindow wn; exec s.moveSlider with [s s.lSlider s.rSlider]; } else nil;; fun rflCursorMoveButtonSlider (wn, s, x, y, b)= if b==1 then let _GETwindowPositionSize wn -> [_ _ w h] in { if (x<0) || (x>w) || (y<0) || (y>h) then if wn==s.ulwinSlider then { _DRAWrectangle s.backUlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUlSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backUlSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 "<"; } else if wn==s.dlwinSlider then { _DRAWrectangle s.backDlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDlSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backDlSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 ">"; } else if wn==s.urwinSlider then { _DRAWrectangle s.backUrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUrSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backUrSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 ">"; } else { _DRAWrectangle s.backDrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDrSlider 0 0 w h 2 s.bcolorSlider 1; _DRAWtext s.backDrSlider s.fontSlider 5 1 TD_TOP|TD_LEFT 0 "<"; } else if wn==s.ulwinSlider then { _DRAWrectangle s.backUlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUlSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backUlSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 "<"; } else if wn==s.dlwinSlider then { _DRAWrectangle s.backDlSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDlSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backDlSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 ">"; } else if wn==s.urwinSlider then { _DRAWrectangle s.backUrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backUrSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backUrSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 ">"; } else { _DRAWrectangle s.backDrSlider 0 0 w h DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; drawPanel s.backDrSlider 0 0 w h 2 s.bcolorSlider 0; _DRAWtext s.backDrSlider s.fontSlider 6 1 TD_TOP|TD_LEFT 0 "<"; }; _PAINTwindow wn } else nil;; /* main window */ fun rflPaintSlider (w, s)= if s.flagsSlider & SLIDER_HIDDEN then nil else { _DRAWrectangle s.backSlider 0 0 s.wSlider s.hSlider DRAW_SOLID 1 s.bcolorSlider DRAW_SOLID s.bcolorSlider; let _GETwindowPositionSize s.barwinSlider -> [xbar ybar wbar hbar] in let xbar+(ftoi (itof wbar)*.(s.lSlider-.s.minSlider) /. (s.maxSlider-.s.minSlider)) -> x1 in let xbar+(ftoi (itof wbar)*.(s.rSlider-.s.minSlider) /. (s.maxSlider-.s.minSlider)) -> x2 in { if s.flagsSlider & SLIDER_DRAW_SCALE then let if s.flagsSlider & SLIDER_DRAW_VALUE then 2*s.hSlider/3 else s.hSlider/2 -> ytext in let _GETstringSize s.fontSlider listtostr deci strtolist ftoa (s.maxSlider -. s.stepSlider) s.pmarkSlider -> [textspace _] in let 5+textspace -> textspace in { _DRAWline s.backSlider xbar ytext xbar ytext+3 DRAW_SOLID 1 0; _DRAWtext s.backSlider s.fontSlider xbar (ytext+5) TD_TOP|TD_LEFT 0 listtostr deci strtolist ftoa s.minSlider s.pmarkSlider; let (itof textspace)*.(s.maxSlider-.s.minSlider)/.(itof wbar) -> step in let s.minSlider+.step -> grad in let xbar+textspace -> i in { while i < xbar+wbar-textspace do { _DRAWline s.backSlider i ytext i ytext+3 DRAW_SOLID 1 0; _DRAWtext s.backSlider s.fontSlider i (ytext+5) TD_TOP|TD_CENTER 0 listtostr deci strtolist ftoa grad s.pmarkSlider; set grad = grad +. step; set i = i + textspace; }; if i+textspace > xbar+wbar then nil else { _DRAWline s.backSlider i ytext i ytext+3 DRAW_SOLID 1 0; _DRAWtext s.backSlider s.fontSlider i (ytext+5) TD_TOP|TD_CENTER 0 listtostr deci strtolist ftoa grad s.pmarkSlider; } }; _DRAWline s.backSlider xbar+wbar ytext xbar+wbar ytext+3 DRAW_SOLID 1 0; _DRAWtext s.backSlider s.fontSlider xbar+wbar (ytext+5) TD_TOP|TD_RIGHT 0 listtostr deci strtolist ftoa s.maxSlider s.pmarkSlider; } else nil; if !strcmp (ftoa s.rSlider) (ftoa s.lSlider) then if s.flagsSlider & SLIDER_DRAW_VALUE then let listtostr deci strtolist ftoa s.lSlider s.pmarkSlider -> text in let _GETstringSize s.fontSlider text -> [htext wtext] in if x1+(wtext/2) > xbar+wbar then _DRAWtext s.backSlider s.fontSlider x1 0 TD_TOP|TD_RIGHT 0 text else if x1-(wtext/2) < xbar then _DRAWtext s.backSlider s.fontSlider x1 0 TD_TOP|TD_LEFT 0 text else _DRAWtext s.backSlider s.fontSlider x1 0 TD_TOP|TD_CENTER 0 text else nil else if s.flagsSlider & SLIDER_DRAW_VALUE then { let listtostr deci strtolist ftoa s.lSlider s.pmarkSlider -> text in let _GETstringSize s.fontSlider text -> [htext wtext] in if x1-wtext < xbar then _DRAWtext s.backSlider s.fontSlider xbar 0 TD_TOP|TD_LEFT 0 text else _DRAWtext s.backSlider s.fontSlider x1 0 TD_TOP|TD_RIGHT 0 text; let listtostr deci strtolist ftoa s.rSlider s.pmarkSlider -> text in let _GETstringSize s.fontSlider text -> [htext wtext] in if x2+wtext > xbar+wbar then _DRAWtext s.backSlider s.fontSlider xbar+wbar 0 TD_TOP|TD_RIGHT 0 text else _DRAWtext s.backSlider s.fontSlider x2 0 TD_TOP|TD_LEFT 0 text; } else nil }; _BLTbitmap s.winSlider s.backSlider 0 0; _PAINTwindow s.ulwinSlider; _PAINTwindow s.dlwinSlider; _PAINTwindow s.urwinSlider; _PAINTwindow s.drwinSlider; _PAINTwindow s.barwinSlider };; fun rflDestroySlider (w, s)= _DSbitmap s.backSlider; _DSbitmap s.backBarSlider; _DSbitmap s.backUlSlider; _DSbitmap s.backDlSlider; _DSbitmap s.backUrSlider; _DSbitmap s.backDrSlider; _deltimer s.timerSlider;; /* USER callable functions */ fun _SETsliderPrecisionStep (s, i)= if i==nil then s else { set s.stepSlider=i; s };; fun _SETsliderColor (s, c)= if c==nil then s else { set s.colorSlider=c; _PAINTwindow s.winSlider; s };; fun _SETsliderBackColor (s, c)= if c==nil then s else { set s.bcolorSlider=c; _PAINTwindow s.winSlider; s };; fun _SETsliderCursorColor (s, c)= if c==nil then s else { set s.ccolorSlider=c; _PAINTwindow s.winSlider; s };; fun _SETsliderMax (s, maxi)= if maxi==nil then s else { set s.maxSlider=maxi; if s.lSlider>.s.maxSlider then set s.lSlider = s.maxSlider else nil; if s.rSlider>.s.maxSlider then set s.rSlider= s.maxSlider else nil; _PAINTwindow s.winSlider; s };; fun _SETsliderMin (s, mini)= if mini==nil then s else { set s.minSlider=mini; if s.lSlider<.s.minSlider then set s.lSlider = s.minSlider else nil; if s.rSlider<.s.minSlider then set s.rSlider= s.minSlider else nil; _PAINTwindow s.winSlider; s };; fun _SETsliderFont (s, font)= set s.fontSlider=font; _PAINTwindow s.winSlider; s;; fun _SETsliderLeft (s, i)= if i==nil then s else { if i<.s.minSlider then set s.lSlider = s.minSlider else set s.lSlider=i; _PAINTwindow s.winSlider; s };; fun _SETsliderRight (s, i)= if i==nil then s else { if i>.s.maxSlider then set s.rSlider= s.maxSlider else set s.rSlider=i; _PAINTwindow s.winSlider; s };; fun _SETsliderFlags (s, f)= if f==nil then s else { set s.flagsSlider=f; _PAINTwindow s.winSlider; s };; fun _SETsliderPrecisionMark (s, f)= if f==nil then s else { set s.pmarkSlider=f; _PAINTwindow s.winSlider; s };; fun _CBslider (s, f)= set s.moveSlider = f; s;; fun _SHOWslider (s, f)= if f==SLIDER_HIDDEN then { set s.flagsSlider = s.flagsSlider | SLIDER_HIDDEN; _SHOWwindow s.barwinSlider WINDOW_HIDDEN; _SHOWwindow s.ulwinSlider WINDOW_HIDDEN; _SHOWwindow s.dlwinSlider WINDOW_HIDDEN; _SHOWwindow s.urwinSlider WINDOW_HIDDEN; _SHOWwindow s.drwinSlider WINDOW_HIDDEN; _SHOWwindow s.winSlider WINDOW_HIDDEN } else if f==SLIDER_UNHIDDEN then { set s.flagsSlider = s.flagsSlider & ~SLIDER_HIDDEN; _SHOWwindow s.barwinSlider WINDOW_UNHIDDEN; _SHOWwindow s.ulwinSlider WINDOW_UNHIDDEN; _SHOWwindow s.dlwinSlider WINDOW_UNHIDDEN; _SHOWwindow s.urwinSlider WINDOW_UNHIDDEN; _SHOWwindow s.drwinSlider WINDOW_UNHIDDEN; _SHOWwindow s.winSlider WINDOW_UNHIDDEN } else nil; s;; fun _GETsliderPrecisionStep (s)= s.stepSlider;; fun _GETsliderColor (s)= s.colorSlider;; fun _GETsliderBackColor (s)= s.bcolorSlider;; fun _GETsliderCursorColor (s)= s.ccolorSlider;; fun _GETsliderMax (s)= s.maxSlider;; fun _GETsliderMin (s)= s.minSlider;; fun _GETsliderFont (s)= s.fontSlider;; fun _GETsliderLeft (s)= s.lSlider;; fun _GETsliderRight (s)= s.rSlider;; fun _GETsliderFlags (s)= s.flagsSlider;; fun _GETsliderPrecisionMark (s)= s.pmarkSlider;; fun _GETsliderCallback (s, f)= s.moveSlider;; fun _CPslider (dest, source)= set dest.fontSlider = source.fontSlider; set dest.wSlider = source.wSlider; set dest.hSlider = source.hSlider; set dest.colorSlider = source.colorSlider; set dest.bcolorSlider = source.bcolorSlider; set dest.ccolorSlider = source.ccolorSlider; set dest.flagsSlider = source.flagsSlider; set dest.stepSlider = source.stepSlider; set dest.minSlider = source.minSlider; set dest.maxSlider = source.maxSlider; set dest.lSlider = source.lSlider; set dest.rSlider = source.rSlider; set dest.pmarkSlider = source.pmarkSlider; _PAINTwindow dest.winSlider; dest;; fun _DSslider (s)= _DSbitmap s.backSlider; _DSbitmap s.backBarSlider; _DSbitmap s.backUlSlider; _DSbitmap s.backDlSlider; _DSbitmap s.backUrSlider; _DSbitmap s.backDrSlider; _deltimer s.timerSlider; _DSwindow s.barwinSlider; _DSwindow s.ulwinSlider; _DSwindow s.dlwinSlider; _DSwindow s.urwinSlider; _DSwindow s.drwinSlider; _DSwindow s.winSlider; _fooS "_DSslider"; 0;; fun _CRslider (chn, father, font, x, y, w, h, color, mini, maxi, left, right, move, flags)= if (chn==nil) || (father==nil) || (x==nil) || (y==nil) || (w==nil) || (h==nil) || (w<=0) || (h<=0) || (color==nil) || (mini==nil) || (maxi==nil) || (!strcmp (ftoa mini) (ftoa maxi)) || (left==nil) || (right==nil) || (left>.right) || (right<.left) || (flags==nil) then nil else { if mini>.maxi then let mini -> temp in { set mini=maxi; set maxi=temp } else nil; let _CRwindow chn father x y w h WN_NOBORDER|WN_CHILD|(if flags&SLIDER_HIDDEN then WN_HIDDEN else 0) "Slider" -> wn in let if flags & SLIDER_BUTTON then 18 else 0 -> xbar in let if flags & SLIDER_DRAW_VALUE then h/3+1 else 0 -> ybar in let if flags & SLIDER_BUTTON then w-36 else w -> wbar in let if (flags & (SLIDER_DRAW_SCALE|SLIDER_DRAW_VALUE))==(SLIDER_DRAW_SCALE|SLIDER_DRAW_VALUE) then h/3-1 else if (flags & SLIDER_DRAW_VALUE) then 2*h/3-1 else if (flags & SLIDER_DRAW_SCALE) then h/2-1 else h -> hbar in let _CRwindow chn wn xbar ybar wbar hbar WN_NOBORDER|WN_CHILD "Slider Bar" -> barwn in let _FILLbitmap _CRbitmap chn w h 0xbfbfbf -> back in let _FILLbitmap _CRbitmap chn wbar hbar 0xbfbfbf -> backBar in let if font==nil then _CRfont chn 12 0 0 "Arial" else font -> font in let mkSlider [ chn wn barwn nil nil nil nil back backBar nil nil nil nil font x y w h color 0xbfbfbf 0x00ff00 flags move (maxi-.mini)/.(itof w) mini maxi left right 2 0 0 nil] -> s in { if flags & SLIDER_BUTTON then { set s.backUlSlider = _FILLbitmap _CRbitmap chn 15 13 0xbfbfbf; set s.ulwinSlider = _CRwindow chn wn 1 h/2-13 15 13 WN_NOBORDER|WN_CHILD "Upper Left Button"; _CBwinClick s.ulwinSlider @rflClickButtonSlider s; _CBwinUnclick s.ulwinSlider @rflUnclickButtonSlider s; _CBcursorMove s.ulwinSlider @rflCursorMoveButtonSlider s; _CBwinPaint s.ulwinSlider @rflPaintButtonSlider s; rflUnclickButtonSlider s.ulwinSlider s 0 0 1; set s.backDlSlider = _FILLbitmap _CRbitmap chn 15 13 0xbfbfbf; set s.dlwinSlider = _CRwindow chn wn 1 h/2 15 13 WN_NOBORDER|WN_CHILD "Lower Left Button"; _CBwinClick s.dlwinSlider @rflClickButtonSlider s; _CBwinUnclick s.dlwinSlider @rflUnclickButtonSlider s; _CBcursorMove s.dlwinSlider @rflCursorMoveButtonSlider s; _CBwinPaint s.dlwinSlider @rflPaintButtonSlider s; rflUnclickButtonSlider s.dlwinSlider s 0 0 1; set s.backUrSlider = _FILLbitmap _CRbitmap chn 15 13 0xbfbfbf; set s.urwinSlider = _CRwindow chn wn xbar+wbar+3 h/2-13 15 13 WN_NOBORDER|WN_CHILD "Upper Right Button"; _CBwinClick s.urwinSlider @rflClickButtonSlider s; _CBwinUnclick s.urwinSlider @rflUnclickButtonSlider s; _CBcursorMove s.urwinSlider @rflCursorMoveButtonSlider s; _CBwinPaint s.urwinSlider @rflPaintButtonSlider s; rflUnclickButtonSlider s.urwinSlider s 0 0 1; set s.backDrSlider = _FILLbitmap _CRbitmap chn 15 13 0xbfbfbf; set s.drwinSlider = _CRwindow chn wn xbar+wbar+3 h/2 15 13 WN_NOBORDER|WN_CHILD "Lower Right Button"; _CBwinClick s.drwinSlider @rflClickButtonSlider s; _CBwinUnclick s.drwinSlider @rflUnclickButtonSlider s; _CBcursorMove s.drwinSlider @rflCursorMoveButtonSlider s; _CBwinPaint s.drwinSlider @rflPaintButtonSlider s; rflUnclickButtonSlider s.drwinSlider s 0 0 1; } else nil; _CBwinDestroy wn @rflDestroySlider s; _CBwinPaint wn @rflPaintSlider s; _CBwinPaint barwn @rflPaintBarSlider s; _CBwinClick barwn @rflClickBarSlider s; _CBwinUnclick barwn @rflUnclickBarSlider s; _PAINTwindow wn; s } };; /* fun destroy (w, x)= _closemachine;; fun main ()= let _CBwinDestroy _CRwindow _channel nil 5 5 300 70 WN_NORMAL "Slider" @destroy 0 -> wn in let _CRslider _channel wn nil 5 5 210 60 0xff0000 itof 0 itof 106 itof 20 itof 60 nil SLIDER_NORMAL|SLIDER_DRAW_VALUE|SLIDER_BUTTON|SLIDER_INTER_FIXED -> slider in { _SETsliderPrecisionMark slider 3; _SETsliderPrecisionStep slider atof "0.05"; };; */