home *** CD-ROM | disk | FTP | other *** search
/ Digitální fotografie a video / Digitalni-fotografie-a-video-covermount.bin / Aplikace / Servis / Rejstrik.dxr / 00078_scrollbar.ls < prev    next >
Encoding:
Text File  |  1998-05-19  |  3.5 KB  |  108 lines

  1. property extentSprite, thumbheight, travelrange, position, offset, tracking, dynamic, proportional, fieldNum, totalHeight, fieldHeight, fieldMem
  2. global Posledni_klik
  3.  
  4. on getPropertyDescriptionList
  5.   set description to [:]
  6.   addProp(description, #dynamic, [#default: 1, #format: #boolean, #comment: "Dynamic:"])
  7.   addProp(description, #fieldNum, [#default: the currentSpriteNum - 3, #format: #integer, #comment: "Scroll which sprite:"])
  8.   addProp(description, #extentSprite, [#default: the currentSpriteNum - 2, #format: #integer, #comment: "Slider Constraint Sprite:"])
  9.   return description
  10. end
  11.  
  12. on getBehaviorDescription
  13.   return "Vertical Multiline Textfield Scrollbar"
  14. end
  15.  
  16. on beginSprite me
  17.   set fnum to the fieldNum of me
  18.   set fmember to the memberNum of sprite the fieldNum of me
  19.   set the fieldMem of me to fmember
  20.   set viewable to 1.0
  21.   set the totalHeight of me to float(the bottom of the rect of member fmember)
  22.   set the fieldHeight of me to float(the bottom of sprite fnum - the top of sprite fnum)
  23.   set viewable to the fieldHeight of me / the totalHeight of me
  24.   puppetSprite(the spriteNum of me, 1)
  25.   set barheight to the bottom of sprite the extentSprite of me - the top of sprite the extentSprite of me
  26.   set the thumbheight of me to the height of sprite the spriteNum of me
  27.   set the travelrange of me to barheight - thumbheight
  28.   set the tracking of me to 0
  29.   set the position of me to 0.0
  30.   positionThumb(me)
  31.   scrollText(me)
  32. end
  33.  
  34. on getAssocMembers
  35.   set myPropList to []
  36.   return myPropList
  37. end
  38.  
  39. on mouseEnter me
  40.   set the cursor of sprite the spriteNum of me to [member "ruka_1", member "ruka_2"]
  41. end
  42.  
  43. on endSprite me
  44.   puppetSprite(the spriteNum of me, 0)
  45. end
  46.  
  47. on positionThumb me
  48.   set topT to (the position of me * the travelrange of me) + the top of sprite the extentSprite of me
  49.   set snum to the spriteNum of me
  50.   set Trect to rect(the left of sprite snum, topT, the right of sprite snum, topT + the thumbheight of me)
  51.   set the rect of sprite snum to Trect
  52. end
  53.  
  54. on scrollText me
  55.   set the scrollTop of member the fieldMem of me to the position of me * (the totalHeight of me - the fieldHeight of me)
  56. end
  57.  
  58. on prepareFrame me
  59.   if the tracking of me then
  60.     set thumb to the spriteNum of me
  61.     set extent to the extentSprite of me
  62.     set V to the mouseV - the offset of me
  63.     if V < the top of sprite extent then
  64.       set V to the top of sprite extent
  65.     end if
  66.     if V > (the bottom of sprite extent - the thumbheight of me) then
  67.       set V to the bottom of sprite extent - the thumbheight of me
  68.     end if
  69.     set the position of me to float(V - the top of sprite extent) / float(the travelrange of me)
  70.     positionThumb(me)
  71.     if the dynamic of me then
  72.       scrollText(me)
  73.     end if
  74.   end if
  75. end
  76.  
  77. on mouseDown me
  78.   set the tracking of me to 1
  79.   set the offset of me to the mouseV - the top of sprite the spriteNum of me
  80. end
  81.  
  82. on mouseUp me
  83.   if the dynamic of me = 0 then
  84.     scrollText(me)
  85.   end if
  86.   set the tracking of me to 0
  87. end
  88.  
  89. on mouseUpOutSide me
  90.   if the dynamic of me = 0 then
  91.     scrollText(me)
  92.   end if
  93.   set the tracking of me to 0
  94. end
  95.  
  96. on scroll_a_line me, amount
  97.   set the scrollTop of member the fieldMem of me to the position of me * (the totalHeight of me - the fieldHeight of me)
  98.   set change_amount to float(amount) * (float(the textHeight of member the fieldMem of me) / float(the totalHeight of me - the fieldHeight of me))
  99.   set the position of me to the position of me + change_amount
  100.   if the position of me < 0.0 then
  101.     set the position of me to 0.0
  102.   end if
  103.   if the position of me > 1.0 then
  104.     set the position of me to 1.0
  105.   end if
  106.   positionThumb(me)
  107. end
  108.