Splitter Gadget as Slider Example
Posted: Sun May 20, 2007 10:12 am
Playing around with the splitter gadget, I thought it could come in useful as a slider as well.
The buttons could also be used in combination like in the example.
Code: Select all
;
; Splitter Gadget as Slider by Electrochrisso, PB4 2007
;
CreateImage(0,20,100)
Procedure SetGadgets()
Shared Value
Value=100-GetGadgetState(2)
SetGadgetText(3,Str(Value))
SetGadgetColor(3,#PB_Gadget_BackColor,RGB(200,100,Value*2))
StartDrawing(ImageOutput(0))
Box(0,0,20,100,RGB(0,0,0))
Box(0,100-Value,20,Value,RGB(255,0,0))
StopDrawing()
SetGadgetState(4,ImageID(0))
EndProcedure
If OpenWindow(0, 0, 0, 200, 150, "Splitter as Slider",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(0, 0, 0, 0, 0, "Up")
ButtonGadget(1, 0, 0, 0, 0, "Dn")
SplitterGadget(2, 5, 5, 25, 107, 0, 1, #PB_Splitter_Separator)
TextGadget(3, 60, 52, 20, 13, Str(GetGadgetState(2)),#PB_Text_Center )
ImageGadget(4,35,8,20,100,ImageID(0))
SetGadgets()
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EventGadgetID = EventGadget()
If EventGadgetID=2
SetGadgets()
EndIf
If EventGadgetID=0
SetGadgetState(2,0)
SetGadgets()
EndIf
If EventGadgetID=1
SetGadgetState(2,107)
SetGadgets()
EndIf
EndSelect
Until Event=#PB_Event_CloseWindow
EndIf
EndIf
End