Hier mal n einfaches Beispiel:
Links: Einträge, Rechts Scroller.
Scroller gedrückt halten und verschieben ^^
Später köntne man dnan noch mehr funktionen einbauen:
Code: Alles auswählen
InitSprite()
OpenWindow(0, 0, 0, 800, 600, "Screen", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
#Size = 100
Global Dim Text.s(#Size)
For n = 0 To #Size
Text(n) = "Eintrag "+Str(n)
Next
Repeat
ClearScreen(0)
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingMode(1|4)
ItemHeight = TextHeight("|")
ViewItems = 20
ViewHeight = ItemHeight * ViewItems
Items = ArraySize(Text())+1
Height = ItemHeight * Items
BoxHeight = ViewHeight*ViewHeight/Height
If Move
BoxY = SaveBoxY + WindowMouseY(0)-SaveMouseY
Start = Height*BoxY/ViewHeight/TextHeight("|")
If Start < 0 : BoxY = 0 : Start = 0 : EndIf
If Start > Items-20 : BoxY = ViewHeight-BoxHeight : Start = Items-20 : EndIf
EndIf
Box(100, 100, 400, TextHeight("|")*20, $FFFFFF)
Box(470, 100, 30, TextHeight("|")*20, $FFFFFF)
For n = 0 To 19
DrawText(100, 100+n*TextHeight(Text(n+Start)), Text(n+Start), $808080)
Next
DrawingMode(1)
Box(470, 100+BoxY, 30, BoxHeight, $C0C0C0)
StopDrawing()
FlipBuffers()
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
Case 513 ; Anschlag
If WindowMouseX(0) > 470 And WindowMouseX(0) < 500 And WindowMouseY(0) > 100+BoxY And WindowMouseY(0)< 100+BoxY+BoxHeight
SaveMouseY = WindowMouseY(0)
SaveBoxY = BoxY
Move = #True
EndIf
Case 514 ; Loslassen
Move = #False
EndSelect
ForEver