link slider
August 14, 1996; Gregg M. Townsend
Requires: Version 9 graphics
See also: evmux.icn
This file is in the public domain.
These procedures implement slider using the "evmux" event multiplexor instead of the usual vidget library. slider(win, proc, arg, x, y, w, h, lb, iv, ub) creates a slider. slidervalue(h, v) modifies a slider's value. ____________________________________________________________ slider(win, proc, arg, x, y, w, h, lb, iv, ub) establishes a slider and returns a handle for use with slidervalue(). x,y,w,h give the dimensions of the slider. The slider runs vertically or horizontally depending on which of w and h is larger. 20 makes a nice width (or height). lb and ub give the range of real values represented by the slider; lb is the left or bottom end. iv is the initial value. proc(win, arg, value) is called as the slider is dragged to different positions. slidervalue(h, v) changes the position of the slider h to reflect value v. The underlying action procedure is not called. ____________________________________________________________ Example: A simple color picker record color(red, green, blue) global win, spot ... Fg(win, spot := NewColor(win)) Color(win, spot, "gray50") FillArc(win, 10, 10, 100, 100) Fg(win, "black") h1 := slider(win, setcolor, 1, 110, 10, 20, 100, 0, 32767, 65535) h2 := slider(win, setcolor, 2, 140, 10, 20, 100, 0, 32767, 65535) h3 := slider(win, setcolor, 3, 170, 10, 20, 100, 0, 32767, 65535) ... procedure setcolor(win, n, v) static fg initial fg := color(32767, 32767, 32767) fg[n] := v Color(win, spot, fg.red || "," || fg.green || "," || fg.blue) end Draw a filled circle in a mutable color that is initially gray. Draw three parallel, vertical sliders of size 20 x 100. Their values run from 0 to 65535 and they are each initialized at the midpoint. (The values are only used internally; the sliders are unlabeled.) When one of the sliders is moved, call setcolor(win, n, v). n, from the "arg" value when it was built, identifies the slider. v is the new value of the slider. Setcolor uses the resulting color triple to set the color of the mutable color "spot". Additional calls every slidervalue(h1 | h2 | h3, 32767) every setcolor(win, 1 to 3, 32767) would reset the original gray color. Note that explicit calls to setcolor are needed because slidervalue does not call it.