Some time in the past someone expressed interest in sliders. Below is some demo slider code. Just basic has some graphics issues (at least in my mind) but one probably could make sliders for servo control and such.
nomainwin
WindowWidth = 568
WindowHeight = 380
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.btnStart, "Start", [btnStartClick], UL, 422, 21, 122, 25
button #main.btnStop, "Stop", [btnStopClick], UL, 422, 61, 122, 25
button #main.btnRnd, "Randomize", [btnRndClick], UL, 422, 101, 122, 25
button #main.btnQuit, "Quit", [btnQuitClick], UL, 414, 306, 122, 25
graphicbox #main.graph1, 14, 16, 240, 100
graphicbox #main.graph2, 14, 126, 240, 100
graphicbox #main.graph3, 14, 236, 240, 100
graphicbox #main.dial1, 294, 16, 25, 100
graphicbox #main.dial2, 270, 161, 100, 25
graphicbox #main.dial3, 270, 236, 100, 100
statictext #main.lbl1, "100", 326, 56, 30, 20
statictext #main.lbl2, "100", 310, 141, 30, 20
statictext #main.lbl3, "100", 310, 216, 30, 20
open "slider type controls" for dialog as #main
print #main.graph1,"down; fill white; flush"
print #main.graph2,"down; fill white; flush"
print #main.graph3,"down; fill white; flush"
print #main.dial1,"down; fill white; flush"
print #main.dial2,"down; fill white; flush"
print #main.dial3,"down; fill white; flush"
print #main, "trapclose [quit.main]"
print #main.dial1,"when leftButtonUp [setDial1]"
print #main.dial2,"when leftButtonUp [setDial2]"
print #main.dial3,"when leftButtonUp [setDial3]"
print #main, "font ms_sans_serif 10"
dim a(3)
for i = 1 to 3
handle$= "#main.graph";i
#handle$, "down"
a(i)=int(100*rnd(1))
y = 100 - a(i)
#handle$, "color ";word$("red green blue",i)
#handle$, "line 0 ";y;" 240 ";y
next
#main.dial3, "fill white; color blue; place 50 50; circle 35"
da = 45 'degrees
rr = 43
for i = 0 to 10
ai = i*10
f1 = ai/100*(180+2*da)-da
f2 = f1 *3.1415926/180
x1 = 50 + rr*cos(f2)
y1 = 50 - rr*sin(f2)
#main.dial3, "size ";int(i*.7)+2;";set ";x1;" ";y1
next
rr = 35
#main.dial3, "size 1; getbmp dial3 0 0 100 100"
gosub [drawDials]
wait
[setDial1]
a(1) = 100 - MouseY
if timerEnabled = 0 then gosub [drawDials]
wait
[setDial2]
a(2) = MouseX
if timerEnabled = 0 then gosub [drawDials]
wait
[setDial3]
'to get angle from MouseX, MouseY - ???
dx = MouseX - 50
dy = 50 - MouseY
a = atan2(dx, dy) '0..360
if a>270 then a = a-360 '-90..270
'-45..225 -> 0..100
select case
case a<-45
a2 = 0
case a>225
a2 = 100
case else
a2 = (a+45)/270*100
end select
a(3) = a2
if timerEnabled = 0 then gosub [drawDials]
wait
[quit.main]
timer 0
Close #main
END
[btnRndClick]
for i = 1 to 3
a(i)=int(100*rnd(1))
next
if timerEnabled = 0 then gosub [drawDials]
wait
[drawDials]
for i = 1 to 3
handle$= "#main.lbl";i
#handle$, a(i)
y = 100 - a(i)
select case i
case 1
#main.dial1, "fill white; backcolor red; color red; place 0 100; boxfilled 25 ";y
' print "0 ";y;" 25 100"
case 2
#main.dial2, "fill white; color green; line 0 20 100 0"
x = 100-y 'reverce one more time
i0 = 20*(1-x/100)
for i1 = i0 to 20
xx = (20-i1)/20*100
#main.dial2, "line ";xx;" ";i1;" ";x;" ";i1
next
' print "0 ";y;" 25 100"
case 3
f1 = a(i)/100*(180+2*da)-da
f2 = f1 *3.1415926/180
x1 = 50 + rr*cos(f2)
y1 = 50 - rr*sin(f2)
#main.dial3, "discard; drawbmp dial3 0 0"
#main.dial3, "line 50 50 ";x1;" ";y1
end select
next i
return
[nextTimer]
timer 0
for i = 1 to 3
a(i)=a(i)+int(5*rnd(1))-2
if a(i)>100 then a(i)=100
if a(i)<0 then a(i)=0
handle$= "#main.graph";i
#handle$, "getbmp tmpBmp 0 0 239 100"
#handle$, "drawbmp tmpBmp 1 0"
#handle$, "color white; line 0 0 0 100; discard"
y = 100 - a(i)
#handle$, "color ";word$("red green blue",i)
#handle$, "set 0 ";y
next
gosub [drawDials]
timer 100, [nextTimer]
wait
[btnStartClick] 'Perform action for the button named 'btnStart'
'Insert your own code here
timer 0
timerEnabled = 1
timer 100, [nextTimer]
wait
[btnStopClick] 'Perform action for the button named 'btnStop'
'Insert your own code here
timer 0
timerEnabled = 0
wait
[btnQuitClick] 'Perform action for the button named 'btnQuit'
goto [quit.main]
wait
'*****************************************
function atan2(x,y) 'returns 0..360 degrees
if abs(x)<0.001 then atan2 = 90+(y<0)*180 : exit function
pi = 3.1415925
tan = y/x
atn = atn(tan)
select case
case x>0 and y>0
atan2 = atn/pi*180
case x<=0
atn = atn + pi
atan2 = atn/pi*180
case else
atn = atn + 2*pi
atan2 = atn/pi*180
end select
end function
nomainwin
'on error goto [exitclicked]
WindowWidth = 1000
WindowHeight = 600
dim SliderLocation(8,3) 'X co-ordinate of top left of slider background
dim SliderColor$(8,3) 'drawing colour of each slider track
dim LampLocation(8) 'drawing position for each lamp
dim GroupBoxLocation(8) ' drawing position top left og grey box aruond lamp and 3 sliders
dim ColorVal(8,3) '0-255 value of each slider
dim Color$(3) '"Red" "Green" "Blue"
dim SliderPosY(8,3) 'Y co-ordinate of centre of slider button
SliderWidth=30
LampRadius=40
Color$(1) ="red"
Color$(2) = "green"
Color$(3) = "blue"
for x=1 to 8
LampLocation(x) = ((x-1)*120)+60
GroupBoxLocation(x) = LampLocation(x) - 52
SliderLocation(x,1) = LampLocation(x) - 45
SliderLocation(x,2) = LampLocation(x) - 10
SliderLocation(x,3) = LampLocation(x) + 25
SliderColor$(x,1) = "red"
SliderColor$(x,2) = "green"
SliderColor$(x,3) = "blue"
next x
button #main.exit, "Exit", [exitClicked], UL, 350, 510,200,50
for x =1 to 8
for y = 1 to 3
ColorVal(x,y) = 127
SliderPosY(x,y) = (255 - ColorVal(x,y))+ 210
next y
next x
graphicbox #main.graph, 10, 10, 970, 490
'Com=16000 'set inputr and output comms buffer
'open "com1:9600,n,8,1,ds0" for random as #comport
open "Ryger FOOTLIGHT DMX PC Interface" for window as #main
' Add a trapclose statement
Print #main, "Trapclose [exitClicked]"
print #main.graph, "down ; fill green"
print #main, "font ms_sans_serif 0 16"
for x=1 to 8
print #main.graph,"place ";GroupBoxLocation(x);" 18"
print #main.graph,"backcolor lightgray"
print #main.graph,"boxfilled ";GroupBoxLocation(x)+104;" 482"
print #main.graph,"place ";GroupBoxLocation(x)+25;" 40"
print #main.graph, "\ParCan ";x
print #main.graph, "place ";LampLocation(x);" 100"
print #main.graph, "backcolor ";ColorVal(x,1);" ";ColorVal(x,2);" ";ColorVal(x,3)
print #main.graph, "circlefilled ";LampRadius
for y = 1 to 3
'draw slider backgound
print #main.graph, "place ";SliderLocation(x,y);" 210"
print #main.graph, "backcolor darkgray"
print #main.graph, "boxfilled ";SliderLocation(x,y)+20;" 475"
'drawcoloured lines on sliders
print #main.graph, "place ";SliderLocation(x,y)+8;" 210"
print #main.graph, "backcolor ";Color$(y)
print #main.graph, "boxfilled ";SliderLocation(x,y)+12;" 475"
'print slider values above sliders
print #main.graph, "backcolor white"
print #main.graph, "place ";SliderLocation(x,y)-2;" 190"
print #main.graph, "\";ColorVal(x,y)
'draw slider buttons
print #main.graph, "place ";SliderLocation(x,y);" ";SliderPosY(x,y)-5
print #main.graph, "backcolor ";Color$(y)
print #main.graph, "boxfilled ";SliderLocation(x,y)+20;" ";SliderPosY(x,y)+5
next y
next x
' now flush the entire background picture once only.
' This picture will persist but will have the sliders centered
Print #main.graph, "flush"
'now start the mouse event
print #main.graph, "when leftButtonMove [moveslider]"
print #main.graph, "when leftButtonUp [moveslider]"
'now start the repeating timed drawing loop
'the loop has been changed to draw all sliders
'every 1000 ms
timer 1000, [drawSliders]
wait
[moveslider]
select case
case (MouseX > 15 ) and (MouseX < 35)
SliderArrayMain=1
SliderArraySub=1
case (MouseX > 50 ) and (MouseX < 70)
SliderArrayMain=1
SliderArraySub=2
case (MouseX > 85 ) and (MouseX < 105)
SliderArrayMain=1
SliderArraySub=3
case (MouseX > 135 ) and (MouseX < 155)
SliderArrayMain=2
SliderArraySub=1
case (MouseX > 170 ) and (MouseX < 190)
SliderArrayMain=2
SliderArraySub=2
case (MouseX > 205 ) and (MouseX < 225)
SliderArrayMain=2
SliderArraySub=3
case (MouseX > 255 ) and (MouseX < 275)
SliderArrayMain=3
SliderArraySub=1
case (MouseX > 290 ) and (MouseX < 310)
SliderArrayMain=3
SliderArraySub=2
case (MouseX > 325 ) and (MouseX < 345)
SliderArrayMain=3
SliderArraySub=3
case (MouseX > 375 ) and (MouseX < 395)
SliderArrayMain=4
SliderArraySub=1
case (MouseX > 410 ) and (MouseX < 430)
SliderArrayMain=4
SliderArraySub=2
case (MouseX > 445 ) and (MouseX < 465)
SliderArrayMain=4
SliderArraySub=3
case (MouseX > 495 ) and (MouseX < 505)
SliderArrayMain=5
SliderArraySub=1
case (MouseX > 530 ) and (MouseX < 550)
SliderArrayMain=5
SliderArraySub=2
case (MouseX > 565 ) and (MouseX < 585)
SliderArrayMain=5
SliderArraySub=3
case (MouseX > 615 ) and (MouseX < 635)
SliderArrayMain=6
SliderArraySub=1
case (MouseX > 650 ) and (MouseX < 670)
SliderArrayMain=6
SliderArraySub=2
case (MouseX > 685 ) and (MouseX < 705)
SliderArrayMain=6
SliderArraySub=3
case (MouseX > 735 ) and (MouseX < 755)
SliderArrayMain=7
SliderArraySub=1
case (MouseX > 770 ) and (MouseX < 790)
SliderArrayMain=7
SliderArraySub=2
case (MouseX > 805 ) and (MouseX < 825)
SliderArrayMain=7
SliderArraySub=3
case (MouseX > 855 ) and (MouseX < 875)
SliderArrayMain=8
SliderArraySub=1
case (MouseX > 890 ) and (MouseX < 910)
SliderArrayMain=8
SliderArraySub=2
case (MouseX > 925 ) and (MouseX < 945)
SliderArrayMain=8
SliderArraySub=3
end select
PosY=MouseY
if PosY>470 Then PosY=470
if PosY<215 Then PosY=215
ColorVal(SliderArrayMain,SliderArraySub)= 470-PosY
SliderPosY(SliderArrayMain,SliderArraySub)=PosY
[drawSliders]
'discard all previous slider drawing
print #main.graph, "discard"
for Ma=1 to 8
for Su=1 to 3
'draw slider backgound
print #main.graph, "place ";SliderLocation(Ma,Su);" 210"
print #main.graph, "backcolor darkgray"
print #main.graph, "boxfilled ";SliderLocation(Ma,Su)+20;" 475"
'drawcoloured lines on sliders
print #main.graph, "place ";SliderLocation(Ma,Su)+8;" 210"
print #main.graph, "backcolor ";Color$(Su)
print #main.graph, "boxfilled ";SliderLocation(Ma,Su)+12;" 475"
'print slider values above sliders
print #main.graph, "backcolor white"
print #main.graph, "color white"
print #main.graph, "place ";SliderLocation(Ma,Su)-2;" 190"
print #main.graph, "\";ColorVal(Ma,Su)
print #main.graph, "color black"
print #main.graph, "place ";SliderLocation(Ma,Su)-2;" 190"
print #main.graph, "\";ColorVal(Ma,Su)
'draw slider buttons
print #main.graph, "place ";SliderLocation(Ma,Su);" ";SliderPosY(Ma,Su)-5
print #main.graph, "backcolor ";Color$(Su)
print #main.graph, "boxfilled ";SliderLocation(Ma,Su)+20;" ";SliderPosY(Ma,Su)+5
'draw circles
print #main.graph, "place ";LampLocation(Ma);" 100"
print #main.graph, "backcolor ";ColorVal(Ma,1);" ";ColorVal(Ma,2);" ";ColorVal(Ma,3)
print #main.graph, "circlefilled ";LampRadius
next Su
next Ma
wait
[exitClicked]
timer 0
close #main
end