home *** CD-ROM | disk | FTP | other *** search
/ Encyklopedia Omnia / Planeta.iso / data / 0_sigla.dir / 00009_Script_FieldThumbScroll < prev    next >
Text File  |  2000-11-14  |  4KB  |  118 lines

  1. ---------------------------------------
  2. --         HTML ScrollThumb          --
  3. --                                   --
  4. --  Behavior per scrollare un field  --
  5. --  Html tramite un cursore.         --
  6. --  Applicalo al cursore.            --
  7. ---------------------------------------
  8.  
  9.  
  10. property normalCursor, pressedCursor, upArrowSN, downArrowSN,¼
  11.           spaceFromArrows, thumbMinY, thumbMaxY, thumbX, thumbName
  12.  
  13. global gNStesto
  14.  
  15. on beginSprite
  16.   set the cursor of sprite (the currentSpriteNum) to¼
  17.   [member normalCursor, member (normalCursor & "_m")]
  18.   
  19.   resetThumbScroll
  20. end
  21.  
  22.  
  23. on resetThumbScroll
  24.   -- chiamato da beginSprite e ogniqualvolta
  25.   -- cambi il testo nel box HTML.
  26.   set upDisplace =  getAt(the regPoint of member the member of sprite the currentSpriteNum,2)
  27.   set downDisplace = (the height of sprite the currentSpriteNum) - upDisplace
  28.   set thumbMinY = (the bottom of sprite upArrowSN) + upDisplace + spaceFromArrows
  29.   set thumbMaxY = (the top of sprite downArrowSN) - downDisplace - spaceFromArrows
  30.   set thumbX = the locH of sprite the currentSpriteNum
  31.   set the loc of sprite the currentSpriteNum to point(thumbX,thumbMinY)
  32. end
  33.  
  34.  
  35. on mouseDown
  36.   if the frame = marker("hilited") then
  37.     go to frame (marker(-1) + 1)
  38.   end if
  39.   
  40.   hilite line 10000 of field "elenco"
  41.   
  42.   if (the height of member the member of sprite gNStesto) > (the PageHeight of member the member of sprite gNStesto) then
  43.     -- settings iniziali
  44.     set ns = the currentSpriteNum
  45.     set the cursor of sprite (ns) to¼
  46.     [member pressedCursor, member (pressedCursor & "_m")]
  47.     set totalTextHeight = the height of member the member of sprite gNStesto
  48.     set singlePageHeight = the PageHeight of member the member of sprite gNStesto
  49.     set scrollExtent = thumbMaxY - thumbMinY
  50.     set oldY = the locV of sprite ns
  51.     
  52.     set offset = getAt(the clickLoc, 2) - the locV of sprite ns
  53.     
  54.     -- loop sul mouseDown
  55.     repeat while the mousedown
  56.       set newY = mouseV() - offset
  57.       if newY > thumbMaxY then set newY = thumbMaxY
  58.       if newY < thumbMinY then set newY = thumbMinY
  59.       
  60.       -- se necessario...
  61.       if newY <> oldY then
  62.         -- sposta il thumb
  63.         set the loc of sprite ns to point(thumbX, newY)
  64.         set oldY = newY
  65.         
  66.         -- e scrolla il testo
  67.         set newScrollTop = (totalTextHeight - singlePageHeight) * ((newY - thumbMinY)/float(scrollExtent))
  68.         set the scrollTop of member the member of sprite gNStesto to newScrollTop
  69.       end if
  70.       
  71.       updateStage
  72.     end repeat
  73.     
  74.     set the cursor of sprite (ns) to¼
  75.     [member normalCursor, member (normalCursor & "_m")]
  76.   end if
  77. end
  78.  
  79.  
  80. on trackArrowScroll
  81.   -- chiamato dalle freccie per seguire lo scroll
  82.   set totalTextHeight = the height of member the member of sprite gNStesto
  83.   set singlePageHeight = the PageHeight of member the member of sprite gNStesto
  84.   set scrollExtent = thumbMaxY - thumbMinY
  85.   set currentScrollTop = the scrollTop of member the member of sprite gNStesto
  86.   
  87.   set diff = totalTextHeight - singlePageHeight
  88.   if diff <> 0 then
  89.     set newY = thumbMinY + scrollExtent*(currentScrollTop/float(diff))
  90.     -- sposta il thumb
  91.     set the loc of sprite the currentSpriteNum to point(thumbX, newY)
  92.   end if
  93. end
  94.  
  95.  
  96. on getPropertyDescriptionList
  97.   set p_list = [#upArrowSN: [#comment:"N╛ sprite freccia s∙:",¼
  98.                 #format: #integer, #default: 1, #range: [#min:1,#max:120]],¼
  99.                 #downArrowSN: [#comment:"N╛ sprite freccia gi∙:",¼
  100.                 #format: #integer, #default: 1, #range: [#min:1,#max:120]],¼
  101.                 #normalCursor:[#comment:"Cursore normale:",¼
  102.                 #format: #string, #default: "palmo"],¼
  103.                 #pressedCursor:[#comment:"Cursore premuto:",¼
  104.                 #format: #string, #default: "pugno"],¼
  105.                 #spaceFromArrows: [#comment:"Spaziatura tra freccie e thumb:",¼
  106.                 #format: #integer, #default: 2],¼
  107.                 #thumbName:[#comment:"Nome del membro html:",¼
  108.                 #format: #string, #default: "testo"]]
  109.   
  110.   return p_list
  111. end
  112.  
  113.  
  114. on getBehaviorDescription
  115.   set descr = "Behavior per scrollare un field Html tramite un cursore."
  116.   set descr = descr & RETURN & "Applicalo al cursore."
  117.   return descr
  118. end