home *** CD-ROM | disk | FTP | other *** search
/ Pro One: Netcracker Netscape Navigator / ProOne: Netcracker Netscape Navigator.iso / pc / nc / nc_mm005.geo / 00028_GENERAL+SCROLL LOGIC.ls < prev    next >
Encoding:
Text File  |  1997-03-19  |  11.3 KB  |  524 lines

  1. on init
  2.   Set_ArrowsOn(1, 0)
  3.   Set_ArrowsOn(2, 1)
  4.   SetNumOflines(the number of lines in GetWhichText())
  5.   SetCurrPlace(0)
  6.   if GetNumOflines() > GetMaxLines() then
  7.     SetOptions(GetNumOflines() - GetMaxLines())
  8.     SetIncrement(1.0 * GetSliderHeight() / GetOptions())
  9.     SetTopLoc(the top of sprite GetSliderSprite())
  10.     PlaceSlider()
  11.     set the visible of sprite GetCover_Sprite() to 0
  12.   else
  13.     put GetWhichText() into field "NamesList"
  14.     set the textHeight of field "NamesList" to 14
  15.     set the visible of sprite GetCover_Sprite() to 1
  16.   end if
  17.   initVars()
  18.   set theLocationV to CalcPuppetLoc(1)
  19.   setPuppetLoc(theLocationV, getFldMiddle())
  20. end
  21.  
  22. on initScrollOfNames
  23.   if (GetNumOflines() = 1) and (line 1 of GetWhichText() = EMPTY) then
  24.     setPrevLine(0)
  25.     setPuppetLoc(700, 700)
  26.   else
  27.     setPrevLine(1)
  28.     set theLocationV to CalcPuppetLoc(getPrevLine())
  29.     setPuppetLoc(theLocationV, getFldMiddle())
  30.   end if
  31. end
  32.  
  33. on initScrollVars
  34.   SetSliderSprite(14)
  35.   setThumbSprite(15)
  36.   setLinePuppetSprite(24)
  37.   SetFieldScroll("NamesList")
  38.   setCover_Sprite(22)
  39.   SetMaxLines(10)
  40.   SetSliderHeight(117)
  41.   setNameDownArrow(12)
  42.   setNameUpArrow(11)
  43.   setFldSprite(20)
  44.   calcFldMiddle()
  45. end
  46.  
  47. on checkIfScrollActive
  48.   set the visible of sprite getThumbSprite() to GetNumOflines() > GetMaxLines()
  49.   setSlideEnabled(GetNumOflines() > GetMaxLines())
  50.   return GetNumOflines() > GetMaxLines()
  51. end
  52.  
  53. on setSlideEnabled toEnable
  54.   global SlideEnabled
  55.   set SlideEnabled to toEnable
  56. end
  57.  
  58. on getSlideEnabled
  59.   global SlideEnabled
  60.   return SlideEnabled
  61. end
  62.  
  63. on setCoverSprites coverSprite1, coverSprite2
  64.   global CoverSpriteVec
  65.   set CoverSpriteVec to list()
  66.   repeat with i = 1 to the paramCount
  67.     setAt(CoverSpriteVec, i, param(i))
  68.     set the puppet of sprite param(i) to 1
  69.   end repeat
  70. end
  71.  
  72. on handleCoverSprites toshow
  73.   global CoverSpriteVec
  74.   repeat with i = 1 to count(CoverSpriteVec)
  75.     set the visible of sprite integer(getAt(CoverSpriteVec, i)) to not toshow
  76.   end repeat
  77.   updateStage()
  78. end
  79.  
  80. on SliderActive
  81.   repeat while the stillDown
  82.     set newV to constrainV(GetSliderSprite(), mouseV())
  83.     set the locV of sprite getThumbSprite() to newV
  84.     set newValue to integer((newV - GetTopLoc()) / GetIncrement())
  85.     SetCurrPlace(newValue)
  86.     put line GetCurrPlace() + 1 to GetCurrPlace() + GetMaxLines() of GetWhichText() into field "NamesList"
  87.     checkHiliteOfFld()
  88.     checkArrows()
  89.   end repeat
  90. end
  91.  
  92. on PlaceSlider
  93.   set currentValue to GetCurrPlace()
  94.   set newPlace to GetTopLoc() + integer(GetIncrement() * currentValue)
  95.   set the locV of sprite getThumbSprite() to constrainV(GetSliderSprite(), newPlace)
  96.   put line GetCurrPlace() + 1 to GetCurrPlace() + GetMaxLines() of GetWhichText() into field "NamesList"
  97.   checkHiliteOfFld()
  98.   updateStage()
  99. end
  100.  
  101. on ClickSlider toSub
  102.   if not toSub then
  103.     SetCurrPlace(GetCurrPlace() - GetMaxLines() + 1)
  104.   else
  105.     SetCurrPlace(GetCurrPlace() + GetMaxLines() - 1)
  106.   end if
  107.   if GetCurrPlace() < 0 then
  108.     SetCurrPlace(0)
  109.   else
  110.     if (GetCurrPlace() + GetMaxLines()) > GetNumOflines() then
  111.       SetCurrPlace(GetNumOflines() - GetMaxLines())
  112.     end if
  113.   end if
  114.   PlaceSlider()
  115.   checkArrows()
  116. end
  117.  
  118. on SetStepMeter direction
  119.   set currentValue to GetCurrPlace()
  120.   if (direction = "increase") and (currentValue <> GetOptions()) then
  121.     SetCurrPlace(currentValue + 1)
  122.   else
  123.     if (direction = "decrease") and (currentValue <> 0) then
  124.       SetCurrPlace(currentValue - 1)
  125.     end if
  126.   end if
  127.   PlaceSlider()
  128. end
  129.  
  130. on handleNameUp theSprite
  131.   if get_ArrowsOn(1) then
  132.     set the castNum of sprite theSprite to the number of cast "NameUp_D"
  133.     updateStage()
  134.     NameUp()
  135.     wait(5)
  136.     repeat while the stillDown
  137.       if getName_MoreUp() then
  138.         if rollOver(theSprite) then
  139.           set the castNum of sprite theSprite to the number of cast "NameUp_D"
  140.           updateStage()
  141.           NameUp()
  142.           next repeat
  143.         end if
  144.         set the castNum of sprite theSprite to the number of cast "NameUp"
  145.         updateStage()
  146.       end if
  147.     end repeat
  148.     if getName_MoreUp() then
  149.       set the castNum of sprite theSprite to the number of cast "NameUp"
  150.       updateStage()
  151.     else
  152.       DisableBtn(getNameUpArrow(), "NameUp")
  153.       updateStage()
  154.     end if
  155.   end if
  156. end
  157.  
  158. on NameUp
  159.   if (GetCurrPlace() + GetMaxLines()) > GetNumOflines() then
  160.     SetCurrPlace(GetNumOflines() - GetMaxLines())
  161.   end if
  162.   EnableBtn(getNameDownArrow(), "nameDown")
  163.   setName_MoreDown(1)
  164.   if GetCurrPlace() = 1 then
  165.     DisableBtn(getNameUpArrow(), "nameUp")
  166.     setName_MoreUp(0)
  167.   end if
  168.   updateStage()
  169.   SetCurrPlace(GetCurrPlace() - 1)
  170.   PlaceSlider()
  171. end
  172.  
  173. on handleNameDown theSprite
  174.   if get_ArrowsOn(2) then
  175.     set the castNum of sprite theSprite to the number of cast "nameDown_D"
  176.     updateStage()
  177.     NameDown()
  178.     wait(5)
  179.     repeat while the stillDown
  180.       if getName_MoreDown() then
  181.         if rollOver(theSprite) then
  182.           set the castNum of sprite theSprite to the number of cast "nameDown_D"
  183.           updateStage()
  184.           NameDown()
  185.           next repeat
  186.         end if
  187.         set the castNum of sprite theSprite to the number of cast "nameDown"
  188.         updateStage()
  189.       end if
  190.     end repeat
  191.     if getName_MoreDown() then
  192.       set the castNum of sprite theSprite to the number of cast "nameDown"
  193.       updateStage()
  194.     else
  195.       DisableBtn(getNameDownArrow(), "nameDown")
  196.       updateStage()
  197.     end if
  198.   end if
  199. end
  200.  
  201. on NameDown
  202.   EnableBtn(getNameUpArrow(), "nameUp")
  203.   setName_MoreUp(1)
  204.   if (GetCurrPlace() + 1) >= (GetNumOflines() - GetMaxLines()) then
  205.     DisableBtn(getNameDownArrow(), "nameDown")
  206.     setName_MoreDown(0)
  207.   end if
  208.   updateStage()
  209.   SetCurrPlace(GetCurrPlace() + 1)
  210.   PlaceSlider()
  211. end
  212.  
  213. on initVars
  214.   setName_MoreDown(1)
  215.   setName_MoreUp(0)
  216.   EnableBtn(getNameDownArrow(), "nameDown")
  217. end
  218.  
  219. on setName_MoreDown bool
  220.   global Name_MoreDown
  221.   set Name_MoreDown to bool
  222. end
  223.  
  224. on getName_MoreDown
  225.   global Name_MoreDown
  226.   return Name_MoreDown
  227. end
  228.  
  229. on setName_MoreUp bool
  230.   global Name_MoreUp
  231.   set Name_MoreUp to bool
  232. end
  233.  
  234. on getName_MoreUp
  235.   global Name_MoreUp
  236.   return Name_MoreUp
  237. end
  238.  
  239. on setNameDownArrow bool
  240.   global NameDownArrow
  241.   set NameDownArrow to bool
  242. end
  243.  
  244. on getNameDownArrow
  245.   global NameDownArrow
  246.   return NameDownArrow
  247. end
  248.  
  249. on setNameUpArrow bool
  250.   global NameUpArrow
  251.   set NameUpArrow to bool
  252. end
  253.  
  254. on getNameUpArrow
  255.   global NameUpArrow
  256.   return NameUpArrow
  257. end
  258.  
  259. on checkArrows
  260.   if GetCurrPlace() = 0 then
  261.     DisableBtn(getNameUpArrow(), "nameUp")
  262.     setName_MoreUp(0)
  263.   else
  264.     EnableBtn(getNameUpArrow(), "nameUp")
  265.     setName_MoreUp(1)
  266.   end if
  267.   if GetCurrPlace() >= (GetNumOflines() - GetMaxLines()) then
  268.     DisableBtn(getNameDownArrow(), "nameDown")
  269.     setName_MoreDown(0)
  270.   else
  271.     EnableBtn(getNameDownArrow(), "nameDown")
  272.     setName_MoreDown(1)
  273.   end if
  274.   updateStage()
  275. end
  276.  
  277. on SetSliderSprite int
  278.   global SliderSprite
  279.   set SliderSprite to int
  280. end
  281.  
  282. on GetSliderSprite
  283.   global SliderSprite
  284.   return SliderSprite
  285. end
  286.  
  287. on setCover_Sprite int
  288.   global Cover_Sprite
  289.   set Cover_Sprite to int
  290. end
  291.  
  292. on GetCover_Sprite
  293.   global Cover_Sprite
  294.   return Cover_Sprite
  295. end
  296.  
  297. on setThumbSprite int
  298.   global ThumbSprite
  299.   set ThumbSprite to int
  300. end
  301.  
  302. on getThumbSprite
  303.   global ThumbSprite
  304.   return ThumbSprite
  305. end
  306.  
  307. on SetCurrPlace int
  308.   global CurrPlace
  309.   set CurrPlace to int
  310. end
  311.  
  312. on GetCurrPlace
  313.   global CurrPlace
  314.   return CurrPlace
  315. end
  316.  
  317. on SetSliderHeight int
  318.   global SliderHeight
  319.   set SliderHeight to int
  320. end
  321.  
  322. on GetSliderHeight
  323.   global SliderHeight
  324.   return SliderHeight
  325. end
  326.  
  327. on SetIncrement int
  328.   global Increment
  329.   set Increment to int
  330. end
  331.  
  332. on GetIncrement
  333.   global Increment
  334.   return Increment
  335. end
  336.  
  337. on SetTopLoc int
  338.   global TopLoc
  339.   set TopLoc to int
  340. end
  341.  
  342. on GetTopLoc
  343.   global TopLoc
  344.   return TopLoc
  345. end
  346.  
  347. on SetOptions int
  348.   global options
  349.   set options to int
  350. end
  351.  
  352. on GetOptions
  353.   global options
  354.   return options
  355. end
  356.  
  357. on SetMaxLines int
  358.   global MaxLines
  359.   set MaxLines to int
  360. end
  361.  
  362. on GetMaxLines
  363.   global MaxLines
  364.   return MaxLines
  365. end
  366.  
  367. on SetFieldScroll int
  368.   global FieldScroll
  369.   set FieldScroll to int
  370. end
  371.  
  372. on GetFieldScroll
  373.   global FieldScroll
  374.   return FieldScroll
  375. end
  376.  
  377. on SetNumOflines int
  378.   global numOfLines
  379.   set numOfLines to int
  380. end
  381.  
  382. on GetNumOflines
  383.   global numOfLines
  384.   return numOfLines
  385. end
  386.  
  387. on wait int
  388.   set startTime to the ticks
  389.   repeat while (the ticks - startTime) < int
  390.   end repeat
  391. end
  392.  
  393. on clickScrollFld
  394.   set locH to getAt(the clickLoc, 1)
  395.   set locV to getAt(the clickLoc, 2)
  396.   set RelativeV to integer(locV - the top of sprite getFldSprite())
  397.   set theLine to integer((RelativeV / 14) + 1)
  398.   if line theLine of field "NamesList" <> EMPTY then
  399.     set theLocationV to CalcPuppetLoc(theLine)
  400.     setPuppetLoc(theLocationV, getFldMiddle())
  401.     putLineInFld(theLine)
  402.   end if
  403. end
  404.  
  405. on CalcPuppetLoc lineToPuppet
  406.   return (14 * (lineToPuppet - 1)) + 6 + the top of sprite getFldSprite()
  407. end
  408.  
  409. on setPuppetLoc theLocationV, theLocationH
  410.   set the locV of sprite getLinePuppetSprite() to theLocationV
  411. end
  412.  
  413. on putLineInFld theLine
  414.   setPrevLine(GetCurrPlace() + theLine)
  415.   updateStage()
  416. end
  417.  
  418. on checkHiliteOfFld
  419.   if getPrevLine() <> 0 then
  420.     set lineNumber to getPrevLine()
  421.     if (lineNumber > GetCurrPlace()) and (lineNumber < (GetCurrPlace() + GetMaxLines() + 1)) then
  422.       setPuppetLoc(CalcPuppetLoc(lineNumber - GetCurrPlace()), getFldMiddle())
  423.     else
  424.       setPuppetLoc(700, 700)
  425.     end if
  426.     updateStage()
  427.   end if
  428. end
  429.  
  430. on calcFldMiddle
  431.   global FldMiddle
  432.   set FldMiddle to the left of sprite getFldSprite() + (the width of sprite getFldSprite() / 2)
  433. end
  434.  
  435. on getFldMiddle
  436.   global FldMiddle
  437.   return FldMiddle
  438. end
  439.  
  440. on setFldSprite int
  441.   global FldSprite
  442.   set FldSprite to int
  443. end
  444.  
  445. on getFldSprite
  446.   global FldSprite
  447.   return integer(FldSprite)
  448. end
  449.  
  450. on setLinePuppetSprite int
  451.   global LinePuppetSprite
  452.   set LinePuppetSprite to int
  453. end
  454.  
  455. on getLinePuppetSprite
  456.   global LinePuppetSprite
  457.   return integer(LinePuppetSprite)
  458. end
  459.  
  460. on setPrevLine int
  461.   global PrevLine
  462.   set PrevLine to int
  463. end
  464.  
  465. on getPrevLine
  466.   global PrevLine
  467.   return PrevLine
  468. end
  469.  
  470. on deleteLineFromFld
  471.   global WhichText
  472.   set lineToDelete to getPrevLine()
  473.   if lineToDelete > 0 then
  474.     DeleteLIST(line lineToDelete of WhichText)
  475.     deleteWhichText(lineToDelete)
  476.     put WhichText into field "complete"
  477.     SaveIndexFile()
  478.     setPrevLine(0)
  479.     setPuppetLoc(700, 700)
  480.     reInit()
  481.   end if
  482.   updateStage()
  483. end
  484.  
  485. on deleteWhichText theLine
  486.   global WhichText
  487.   delete line theLine of WhichText
  488. end
  489.  
  490. on reInit
  491.   SetNumOflines(the number of lines in GetWhichText())
  492.   if GetMaxLines() <= (GetNumOflines() - 1) then
  493.     if (GetCurrPlace() + GetMaxLines()) <= GetNumOflines() then
  494.       SetOptions(GetNumOflines() - GetMaxLines())
  495.       SetIncrement(1.0 * GetSliderHeight() / GetOptions())
  496.       PlaceSlider()
  497.       checkArrows()
  498.     else
  499.       SetOptions(GetNumOflines() - GetMaxLines())
  500.       SetIncrement(1.0 * GetSliderHeight() / GetOptions())
  501.       checkArrows()
  502.       put line GetCurrPlace() + 1 to GetCurrPlace() + GetMaxLines() of GetWhichText() into field GetFieldScroll()
  503.       checkHiliteOfFld()
  504.     end if
  505.   else
  506.     SetCurrPlace(0)
  507.     put GetWhichText() into field GetFieldScroll()
  508.     set the visible of sprite GetCover_Sprite() to 1
  509.   end if
  510.   handleScrollCursors(checkIfScrollActive())
  511. end
  512.  
  513. on handleScrollCursors bool
  514.   if bool then
  515.     UpdateCursors(getNameDownArrow(), 3)
  516.     UpdateCursors(getNameUpArrow(), 3)
  517.     UpdateCursors(GetSliderSprite(), 3)
  518.   else
  519.     UpdateCursors(getNameDownArrow(), 1)
  520.     UpdateCursors(getNameUpArrow(), 1)
  521.     UpdateCursors(GetSliderSprite(), 1)
  522.   end if
  523. end
  524.