home *** CD-ROM | disk | FTP | other *** search
- property extentSprite, thumbheight, travelrange, position, offset, tracking, dynamic, proportional, fieldNum, totalHeight, fieldHeight, fieldMem
-
- on getPropertyDescriptionList
- description = [:]
- addProp(description, #dynamic, [#default: 1, #format: #boolean, #comment: "Dynamic:"])
- addProp(description, #fieldNum, [#default: the currentSpriteNum - 3, #format: #integer, #comment: "Scroll which sprite:"])
- addProp(description, #extentSprite, [#default: the currentSpriteNum - 2, #format: #integer, #comment: "Slider Constraint Sprite:"])
- return description
- end
-
- on getBehaviorDescription
- return "Vertical Multiline Textfield Scrollbar"
- end
-
- on beginSprite me
- fnum = me.fieldNum
- fmember = the memberNum of sprite 8
- me.fieldMem = fmember
- viewable = 1.0
- me.totalHeight = float(member(fmember).rect.bottom)
- me.fieldHeight = float(the bottom of sprite fnum - the top of sprite fnum)
- viewable = me.fieldHeight / me.totalHeight
- puppetSprite(me.spriteNum, 1)
- barheight = the bottom of sprite me.extentSprite - the top of sprite me.extentSprite
- me.thumbheight = the height of sprite me.spriteNum
- me.travelrange = barheight - thumbheight
- me.tracking = 0
- me.position = 0.0
- positionThumb(me)
- end
-
- on getAssocMembers
- myPropList = []
- return myPropList
- end
-
- on endSprite me
- puppetSprite(me.spriteNum, 0)
- end
-
- on positionThumb me
- topT = (me.position * me.travelrange) + the top of sprite me.extentSprite
- snum = me.spriteNum
- Trect = rect(the left of sprite snum, topT, the right of sprite snum, topT + me.thumbheight)
- set the rect of sprite snum to Trect
- end
-
- on scrollText me
- member(me.fieldMem).scrollTop = me.position * (me.totalHeight - (me.fieldHeight / 16))
- end
-
- on prepareFrame me
- if me.tracking then
- thumb = me.spriteNum
- extent = me.extentSprite
- v = the mouseV - me.offset
- if v < the top of sprite extent then
- v = the top of sprite extent
- end if
- if v > (the bottom of sprite extent - me.thumbheight) then
- v = the bottom of sprite extent - me.thumbheight
- end if
- me.position = float(v - the top of sprite extent) / float(me.travelrange)
- positionThumb(me)
- if me.dynamic then
- scrollText(me)
- end if
- end if
- end
-
- on mouseDown me
- me.tracking = 1
- me.offset = the mouseV - the top of sprite me.spriteNum
- end
-
- on mouseUp me
- if me.dynamic = 0 then
- scrollText(me)
- end if
- me.tracking = 0
- end
-
- on mouseUpOutSide me
- if me.dynamic = 0 then
- scrollText(me)
- end if
- me.tracking = 0
- end
-
- on scroll_a_line me, amount
- member(me.fieldMem).scrollTop = me.position * me.totalHeight
- change_amount = float(amount) * (float(the textHeight of member the fieldMem of me) / float(me.totalHeight - me.fieldHeight))
- me.position = me.position + change_amount
- if me.position < 0.0 then
- me.position = 0.0
- end if
- if me.position > 1.0 then
- me.position = 1.0
- end if
- positionThumb(me)
- end
-
- on scroll_a_Top me, amount
- extent = me.extentSprite
- (the member of sprite 2).scrollTop = amount
- change_amount = float(amount * travelrange) / float(me.totalHeight)
- me.position = float(change_amount) / float(me.travelrange)
- if me.position < 0.0 then
- me.position = 0.0
- end if
- if me.position > 1.0 then
- me.position = 1.0
- end if
- positionThumb(me)
- end
-