on initScroll BarSprt, UpSprt, ThumbSprt, DwnSprt, FirstSp, LastSp
global ScrollData
set ScrollData to BarSprt & "," & UpSprt & "," & DwnSprt & "," & ThumbSprt & "," & FirstSp & "," & LastSp & "," & the locV of sprite FirstSp & "," & GetGroupWidth(FirstSp, LastSp) - 15
puppetSprite(ThumbSprt, 1)
puppetAll(FirstSp, LastSp, 1)
end
on endscroll
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set UpSprt to integer(item 2 of ScrollData)
set DwnSprt to integer(item 3 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
set FirstSp to integer(item 5 of ScrollData)
set LastSp to integer(item 6 of ScrollData)
set FirstPos to integer(item 7 of ScrollData)
set WidthOfAll to integer(item 8 of ScrollData)
puppetSprite(ThumbSprt, 0)
puppetAll(FirstSp, LastSp, 0)
end
on puppetAll FirstSp, LastSp, BooleanVal
repeat with i = FirstSp to LastSp
puppetSprite(i, BooleanVal)
end repeat
end
on OffsetAll FirstSp, LastSp, IntValue
repeat with i = FirstSp to LastSp
set the locV of sprite i to the locV of sprite i + IntValue
end repeat
end
on CursorAll FirstSp, LastSp, Curs
repeat with i = FirstSp to LastSp
set the cursor of sprite i to Curs
end repeat
end
on GetGroupWidth FirstSp, LastSp
set TheTopOfAll to the top of sprite FirstSp
set TheBottomOfAll to the bottom of sprite FirstSp
repeat with i = FirstSp to LastSp
if the top of sprite i < TheTopOfAll then
set TheTopOfAll to the top of sprite i
end if
if the bottom of sprite i > TheBottomOfAll then
set TheBottomOfAll to the bottom of sprite i
end if
end repeat
return TheBottomOfAll - TheTopOfAll
end
on SetScrollTo Part, Total
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set UpSprt to integer(item 2 of ScrollData)
set DwnSprt to integer(item 3 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
set FirstSp to integer(item 5 of ScrollData)
set LastSp to integer(item 6 of ScrollData)
set FirstPos to integer(item 7 of ScrollData)
set WidthOfAll to integer(item 8 of ScrollData)
if Total = "Pixels" then
set Total to WidthOfAll
end if
if Part > Total then
set Part to Total
end if
if Part < 0 then
set Part to 0
end if
set Origin to the top of sprite BarSprt
set max to the height of sprite BarSprt - the height of sprite ThumbSprt
set HalfThumb to the height of sprite ThumbSprt / 2
set Temp to max * Part
set Temp to (Temp / Total) + Origin + HalfThumb
set the locV of sprite ThumbSprt to Temp
set Temp to WidthOfAll * Part
set Temp to Temp / Total
set Delta to FirstPos - the locV of sprite FirstSp - Temp
OffsetAll(FirstSp, LastSp, Delta)
updateStage()
end
on SetScrollBar Part, Total
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set UpSprt to integer(item 2 of ScrollData)
set DwnSprt to integer(item 3 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
set FirstSp to integer(item 5 of ScrollData)
set LastSp to integer(item 6 of ScrollData)
set FirstPos to integer(item 7 of ScrollData)
set WidthOfAll to integer(item 8 of ScrollData)
if Total = "Pixels" then
set Total to WidthOfAll
end if
if Part > Total then
set Part to Total
end if
if Part < 0 then
set Part to 0
end if
set Origin to the top of sprite BarSprt
set max to the height of sprite BarSprt - the height of sprite ThumbSprt
set HalfThumb to the height of sprite ThumbSprt / 2
set Temp to max * Part
set Temp to (Temp / Total) + Origin + HalfThumb
set the locV of sprite ThumbSprt to Temp
end
on SetScrollingData Part, Total
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set UpSprt to integer(item 2 of ScrollData)
set DwnSprt to integer(item 3 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
set FirstSp to integer(item 5 of ScrollData)
set LastSp to integer(item 6 of ScrollData)
set FirstPos to integer(item 7 of ScrollData)
set WidthOfAll to integer(item 8 of ScrollData)
if Total = "Pixels" then
set Total to WidthOfAll
end if
if Part > Total then
set Part to Total
end if
if Part < 0 then
set Part to 0
end if
set Temp to WidthOfAll * Part
set Temp to Temp / Total
set Delta to FirstPos - the locV of sprite FirstSp - Temp
OffsetAll(FirstSp, LastSp, Delta)
end
on GetScroll Total
global ScrollData
set FirstSp to integer(item 5 of ScrollData)
set FirstPos to integer(item 7 of ScrollData)
set WidthOfAll to integer(item 8 of ScrollData)
if Total = "Pixels" then
set Total to WidthOfAll
end if
set Temp to (FirstPos - the locV of sprite FirstSp) * Total
set Temp to Temp / WidthOfAll
return Temp
end
on GetScrollbarMax
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
return the height of sprite BarSprt - the height of sprite ThumbSprt
end
on SetScrollFromMouse
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
SetScrollTo(the mouseV - the top of sprite BarSprt - (the height of sprite ThumbSprt / 2), the height of sprite BarSprt - the height of sprite ThumbSprt)
end
on ScrollDown x
set Curr to GetScroll("pixels")
SetScrollTo(Curr + x, "pixels")
end
on ScrollUp x
set Curr to GetScroll("pixels")
SetScrollTo(Curr - x, "pixels")
end
on HandleThumb
repeat while not (the mouseUp)
SetScrollFromMouse()
end repeat
end
on HandleScrollDown x
repeat while not (the mouseUp)
ScrollDown(x)
end repeat
end
on HandleScrollUp x
repeat while not (the mouseUp)
ScrollUp(x)
end repeat
end
on DragItems
global ScrollData
set BarSprt to integer(item 1 of ScrollData)
set ThumbSprt to integer(item 4 of ScrollData)
set FirstSp to integer(item 5 of ScrollData)
set FirstPos to integer(item 7 of ScrollData)
set SaveMouse to the mouseV
set StPt to FirstPos - the locV of sprite FirstSp + SaveMouse
repeat while not (the mouseUp)
set SaveOld to SaveMouse
set SaveMouse to the mouseV
SetScrollTo(StPt - SaveMouse, "pixels")
end repeat
set ExitFlag to 0
set Delta to SaveMouse - SaveOld
repeat while (Delta <> 0) and the mouseUp
set SaveMouse to SaveMouse + Delta
SetScrollTo(StPt - SaveMouse, "pixels")
set Delta to 4 * Delta / 5
if Delta = 1 then
set Delta to 0
end if
end repeat
end
on ThumbPressed
global ScrollData
set ThumbSprt to integer(item 4 of ScrollData)
set NormalIcon to the number of member "Thumb"
set HilitedIcon to the number of member "PressedThumb"
if (HilitedIcon <> -1) and (NormalIcon <> -1) then
set the castNum of sprite ThumbSprt to HilitedIcon
end if
HandleThumb()
if NormalIcon <> -1 then
set the castNum of sprite ThumbSprt to NormalIcon
end if
end
on DownArrowPressed x
global ScrollData
set DwnSprt to integer(item 3 of ScrollData)
set NormalIcon to the number of member "DownArrow"
set HilitedIcon to the number of member "PressedDownArrow"
if (HilitedIcon <> -1) and (NormalIcon <> -1) then
set the castNum of sprite DwnSprt to HilitedIcon
end if
HandleScrollDown(x)
if NormalIcon <> -1 then
set the castNum of sprite DwnSprt to NormalIcon
end if
end
on UpArrowPressed x
global ScrollData
set UpSprt to integer(item 2 of ScrollData)
set NormalIcon to the number of member "UpArrow"
set HilitedIcon to the number of member "PressedUpArrow"
if (HilitedIcon <> -1) and (NormalIcon <> -1) then