I have tried to code such with the help of the code archives, but its really slow and buggy as the canvas has to be 8000+ pixel in height, which is crazy!
There has to be another way by only creating some image buttons and simply change the images displayed onto them when needed. *still thinking....
app=CreateWindow("Database",0,0,640,480,0,17)
; create 2 parent panels
panel1=CreatePanel(5,5,230,450,app)
scrollpanel1=CreateVScrollpanel(105,7900,panel1,20,160,160,160)
; put some example crap on the scrollpanels
For t=0 To 120
CreateButton(t,10,10+t*64,64,64,VScrollpanelPanel(scrollpanel1))
Next
; main loop
quit=False
Repeat
WaitEvent()
If EventID()=$803 quit=True
; if you don't include these, you can't scroll!
VScrollpanelEvents (scrollpanel1)
Until quit
; clean-up
FreeBank scrollpanel1
; bye!
End
; returns the actual panelhandle of the scrollpanel..
Function VScrollpanelPanel(bank)
Return PeekInt(bank,4)
End Function
Function VScrollpanelEvents(bank)
canvas=PeekInt(bank,8)
If EventSource()=canvas
If EventID()=$201
PokeByte bank,19,1 ; drag=true
PokeShort bank,20,MouseY() ; start coord.
EndIf
If EventID()=$202
PokeByte bank,19,0 ; drag=false
EndIf
If PeekByte(bank,19) ; drag ?
If EventID()=$203
y=MouseY()
panel=PeekInt(bank,4)
oldy=PeekShort(bank,20)
ycoord=GadgetY(panel)+y-oldy
ycoord=Limit(ycoord,-PeekShort(bank,14)+PeekShort(bank,22),0)
SetGadgetShape panel,GadgetX(panel),ycoord,GadgetWidth(panel),GadgetHeight(panel)
PokeShort bank,20,y
EndIf
EndIf
EndIf
End Function
Function CreateVScrollpanel(width,height,parent,dragwidth,r,g,b)
If width*height=0 Break"Incorrect dimensions!"
If height<GadgetHeight(parent) Break"Panel height-bigger than parent-height!"
If Not parent Break"Parent missing"
If Not dragwidth Break"Dragbar zero"
r=Limit(r,0,255)
g=Limit(g,0,255)
b=Limit(b,0,255)
; adr name size
; 00 ID 4 bytes <- reserved for an optional 4-chars ID check! not used right now..
; 04 panel 1 int (4 bytes)
; 08 dragcanvas 1 Int (4 bytes)
; 12 width 1 short (2 bytes)
; 14 height 1 short (2 bytes)
; 16 r 1 byte
; 17 g 1 byte
; 18 b 1 byte
; 19 dragstatus 1 byte
; 20 dragY 1 short (2 bytes)
; 22 parntheight 1 short (2 bytes)
bank=CreateBank(24)
panel=CreatePanel(0,0,width,height,parent)
SetPanelColor panel,r,g,b
canvas=CreateCanvas(width-dragwidth,0,dragwidth,height,panel)
SetCanvas canvas
ClsColor r,g,b:Cls
For y=2 To height-1 Step 4
For x=2 To dragwidth-1 Step 4
xo=(y Mod 8)/4
Bcolor r*1.3,g*1.3,b*1.3
Plot x+xo,y
Bcolor r*0.7,g*0.7,b*0.7
Plot x+xo+1,y+1
Next
Next
Bcolor r*1.3,g*1.3,b*1.3
Line 0,0,0,height-2
Line 0,0,dragwidth-2,0
Bcolor r*0.7,g*0.7,b*0.7
Line dragwidth-1,1,dragwidth-1,height-2
Line 1,height-1,dragwidth-2,height-1
FlipCanvas canvas
PokeInt bank,4,panel
PokeInt bank,8,canvas
PokeShort bank,12,width
PokeShort bank,14,height
PokeByte bank,16,r
PokeByte bank,17,g
PokeByte bank,18,b
PokeShort bank,22,GadgetHeight (parent)
Return bank
End Function
; misc. needed global functions.. some useful, some just for the lazy coder (SetCanvas) :)
Function Limit(value,minvalue,maxvalue)
If value<minvalue Return minvalue
If value>maxvalue Return maxvalue
Return value
End Function
Function Break(s$)
Notify s$
End
End Function
Function Bcolor(r,g,b)
r=Limit(r,0,255)
g=Limit(g,0,255)
b=Limit(b,0,255)
Color r,g,b
End Function
Function SetCanvas(bla)
SetBuffer CanvasBuffer(bla)
End Function