home *** CD-ROM | disk | FTP | other *** search
/ The Dynamic Human Version 2.0 / DH2_CD2.ISO / pc / files / index.dxr / 00043_indexScrollWindow.ls < prev    next >
Encoding:
Text File  |  1997-11-18  |  3.8 KB  |  97 lines

  1. on indexScrollWindow whichDirection, dontMoveSlider
  2.   global indexWindowObject
  3.   set whichField to the textName of indexWindowObject
  4.   set fullScrollDist to the fullScrollDist of indexWindowObject
  5.   set pageScrollDist to the pageScrollDist of indexWindowObject
  6.   set theLineHeight to the textHeight of field whichField
  7.   set maxScrollTop to fullScrollDist
  8.   set linesPerPage to (pageScrollDist + (theLineHeight / 2)) / theLineHeight
  9.   set oldScrollTop to the scrollTop of member whichField
  10.   if whichDirection = "pageUp" then
  11.     set newTop to the scrollTop of member whichField - pageScrollDist
  12.     if newTop < 0 then
  13.       set newTop to 0
  14.     end if
  15.     set the scrollTop of member whichField to newTop
  16.   else
  17.     if whichDirection = "pageDown" then
  18.       set distLeft to maxScrollTop - the scrollTop of member whichField
  19.       set linesLeft to (distLeft + (theLineHeight / 2)) / theLineHeight
  20.       set maxLines to (maxScrollTop + (theLineHeight / 2)) / theLineHeight
  21.       if linesLeft >= linesPerPage then
  22.         set the scrollTop of member whichField to the scrollTop of member whichField + pageScrollDist
  23.       else
  24.         set the scrollTop of member whichField to maxScrollTop
  25.       end if
  26.     else
  27.       if integerp(whichDirection) then
  28.         if whichDirection <= 0 then
  29.           set newTop to the scrollTop of member whichField + (whichDirection * theLineHeight)
  30.         else
  31.           set nextHeight to oldScrollTop + (whichDirection * theLineHeight)
  32.           if nextHeight <= maxScrollTop then
  33.             set newTop to the scrollTop of member whichField + (whichDirection * theLineHeight)
  34.           else
  35.             set newTop to the scrollTop of member whichField + (maxScrollTop - oldScrollTop)
  36.           end if
  37.         end if
  38.       else
  39.         if whichDirection > 1 then
  40.           set whichDirection to 1.0
  41.         end if
  42.         set whichLine to integer(whichDirection * maxScrollTop / theLineHeight) + 1
  43.         set currentLine to (oldScrollTop / theLineHeight) + 1
  44.         set newTop to the scrollTop of member whichField + ((whichLine - currentLine) * theLineHeight)
  45.       end if
  46.       if newTop < 0 then
  47.         set newTop to 0
  48.       end if
  49.       set the scrollTop of member whichField to newTop
  50.     end if
  51.   end if
  52.   set the currentLine of indexWindowObject to 0
  53.   if dontMoveSlider then
  54.     return 
  55.   end if
  56.   indexResetSlider()
  57. end
  58.  
  59. on indexResetSlider
  60.   global indexWindowObject
  61.   set whichField to the textName of indexWindowObject
  62.   set fullScrollDist to the fullScrollDist of indexWindowObject
  63.   set pageScrollDist to the pageScrollDist of indexWindowObject
  64.   set maxScrollTop to fullScrollDist
  65.   if maxScrollTop <= 0 then
  66.     set maxScrollTop to 1
  67.   end if
  68.   set newScrollTop to the scrollTop of member whichField
  69.   set sliderSprite to the sliderSprite of indexWindowObject
  70.   set barRect to the barRect of indexWindowObject
  71.   puppetSprite(sliderSprite, 1)
  72.   set sliderHeight to the height of sprite sliderSprite
  73.   set sliderMinV to getAt(barRect, 2) + (sliderHeight / 2)
  74.   set sliderMaxV to getAt(barRect, 4) - (sliderHeight / 2) - 1
  75.   set sliderRange to sliderMaxV - sliderMinV
  76.   set newV to sliderMinV + (newScrollTop * sliderRange / maxScrollTop)
  77.   if newV < sliderMinV then
  78.     set newV to sliderMinV
  79.   else
  80.     if newV > sliderMaxV then
  81.       set newV to sliderMaxV
  82.     end if
  83.   end if
  84.   if fullScrollDist <= 0 then
  85.     set the visible of sprite sliderSprite to 0
  86.     set the visible of sprite the upArrowSprite of indexWindowObject to 0
  87.     set the visible of sprite the downArrowSprite of indexWindowObject to 0
  88.   else
  89.     set the visible of sprite sliderSprite to 1
  90.     set the locV of sprite sliderSprite to newV
  91.     set the visible of sprite the upArrowSprite of indexWindowObject to 1
  92.     set the visible of sprite the downArrowSprite of indexWindowObject to 1
  93.   end if
  94.   updateStage()
  95.   indexUpdateSliderRect()
  96. end
  97.