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

  1. property regionList, buttonSprite, textSprite, textName, testFieldSprite, testFieldName, sliderSprite, barRect, pageScrollDist, fullScrollDist, currentLine, upArrowSprite, downArrowSprite, goArrowSprites, goTextSprites, goObject, titleNum, termFontSize
  2.  
  3. on new me, fullRegionList, buttonSp, textSp, textFieldName, testFldSprite, testFldName, sliderSp, barRc, upArrow, downArrow, goArrSprites, goTxSprites
  4.   set regionList to duplicate(fullRegionList)
  5.   set buttonSprite to buttonSp
  6.   set textSprite to textSp
  7.   set textName to textFieldName
  8.   set testFieldSprite to testFldSprite
  9.   set testFieldName to testFldName
  10.   set sliderSprite to sliderSp
  11.   set barRect to barRc
  12.   set upArrowSprite to upArrow
  13.   set downArrowSprite to downArrow
  14.   repeat with k in [sliderSprite, upArrowSprite, downArrowSprite, textSprite]
  15.     set the visible of sprite k to 1
  16.   end repeat
  17.   updateStage()
  18.   set currentLine to 0
  19.   set goArrowSprites to duplicate(goArrSprites)
  20.   set goTextSprites to duplicate(goTxSprites)
  21.   set goObject to 0
  22.   set titleNum to 0
  23.   set termFontSize to 18
  24.   set the textSize of member "currentTerm" to termFontSize
  25.   return me
  26. end
  27.  
  28. on death me
  29.   set regionList to 0
  30. end
  31.  
  32. on setupLinkButtons me, newLine
  33.   global gLinkList
  34.   if newLine = currentLine then
  35.     return 
  36.   end if
  37.   set currentLine to newLine
  38.   set termSprite to 13
  39.   set defSprite to 14
  40.   set whichTerm to line currentLine of field textName
  41.   set notFoundFlag to getPos(["Boyle's Law", "cytokine", "Einthoven's triangle", "rib", "tibia"], whichTerm) >= 1
  42.   if not notFoundFlag then
  43.     set dbResult to DBQuery("UPPER(TERM) = '" & toUpper(whichTerm) & "'")
  44.   else
  45.     set dbResult to 0
  46.   end if
  47.   if dbResult = 0 then
  48.     set the visible of sprite termSprite to 0
  49.     updateStage()
  50.     put whichTerm into field "currentTerm"
  51.     set the textSize of member "currentTerm" to termFontSize
  52.     repeat while the height of member "currentTerm" > the textHeight of member "currentTerm"
  53.       set the textSize of member "currentTerm" to the textSize of member "currentTerm" - 1
  54.     end repeat
  55.     set the visible of sprite termSprite to 1
  56.     updateStage()
  57.     if not notFoundFlag then
  58.       put DBGetMemo("DEF") into field "currentDefinition"
  59.     else
  60.       put line getPos(["Boyle's Law", "cytokine", "Einthoven's triangle", "rib", "tibia"], whichTerm) of field "extraDefs" into field "currentDefinition"
  61.     end if
  62.     repeat with k in goArrowSprites
  63.       puppetSprite(k, 1)
  64.     end repeat
  65.     repeat with k = 1 to count(goTextSprites)
  66.       set nextSprite to getAt(goTextSprites, k)
  67.       puppetSprite(nextSprite, 1)
  68.       set the visible of sprite nextSprite to 0
  69.       set the castNum of sprite nextSprite to the number of member ("title" & string(k))
  70.     end repeat
  71.     updateStage()
  72.     if not notFoundFlag then
  73.       set linkList to value(DBGetFieldByName("LINKS"))
  74.     else
  75.       set linkList to value(line getPos(["Boyle's Law", "cytokine", "Einthoven's triangle", "rib", "tibia"], whichTerm) of field "extraLinks")
  76.     end if
  77.     set titleList to []
  78.     if voidp(linkList) or not listp(linkList) then
  79.       set linkList to []
  80.     end if
  81.     sort(linkList)
  82.     if count(linkList) >= 2 then
  83.       repeat with m = 1 to count(linkList) - 1
  84.         repeat with n = m + 1 to count(linkList)
  85.           if getAt(linkList, m) = getAt(linkList, n) then
  86.             deleteAt(linkList, n)
  87.             exit repeat
  88.           end if
  89.         end repeat
  90.       end repeat
  91.     end if
  92.     if count(linkList) >= 1 then
  93.       repeat with m = 1 to count(linkList) - 1
  94.         set nextTerm to getAt(linkList, m)
  95.         set nextOffset to offset(" ", nextTerm)
  96.         if nextOffset >= 1 then
  97.           delete char nextOffset of nextTerm
  98.         end if
  99.         setAt(linkList, m, nextTerm)
  100.       end repeat
  101.     end if
  102.     set gLinkList to duplicate(linkList)
  103.     repeat with k = 1 to count(linkList)
  104.       set nextTitle to getScreenTitle(getAt(linkList, k))
  105.       if length(nextTitle) >= 1 then
  106.         append(titleList, nextTitle)
  107.       end if
  108.     end repeat
  109.     set numTitles to count(titleList)
  110.     if numTitles > count(goTextSprites) then
  111.       set numTitles to count(goTextSprites)
  112.     end if
  113.     repeat with k = 1 to numTitles
  114.       set the text of field ("title" & string(k)) to getAt(titleList, k)
  115.     end repeat
  116.     set firstSprite to getAt(goTextSprites, 1)
  117.     set firstMember to the castNum of sprite firstSprite
  118.     set firstHeight to the height of sprite firstSprite
  119.     set the locH of sprite firstSprite to 343
  120.     if the bottom of sprite defSprite > 215 then
  121.       set the locV of sprite firstSprite to the bottom of sprite defSprite + 50
  122.     else
  123.       set the locV of sprite firstSprite to 243
  124.     end if
  125.     set prevSprite to firstSprite
  126.     repeat with k = 2 to count(titleList)
  127.       if k > count(goTextSprites) then
  128.         exit repeat
  129.       end if
  130.       set nextSprite to getAt(goTextSprites, k)
  131.       set the locH of sprite nextSprite to the locH of sprite prevSprite
  132.       set the locV of sprite nextSprite to the locV of sprite prevSprite + 28
  133.       set prevSprite to nextSprite
  134.     end repeat
  135.     updateStage()
  136.     repeat with k = 1 to numTitles
  137.       set nextSprite to getAt(goArrowSprites, k)
  138.       set textSprite to getAt(goTextSprites, k)
  139.       set the castNum of sprite nextSprite to the number of member "arrowup"
  140.       set nextH to the left of sprite textSprite - (the width of cast "arrowUp" / 2)
  141.       set nextV to (the top of sprite textSprite + the bottom of sprite textSprite) / 2
  142.       set the locH of sprite nextSprite to nextH
  143.       set the locV of sprite nextSprite to nextV
  144.       set the visible of sprite nextSprite to 1
  145.     end repeat
  146.     repeat with k = numTitles + 1 to count(goArrowSprites)
  147.       puppetSprite(getAt(goArrowSprites, k), 0)
  148.       puppetSprite(getAt(goTextSprites, k), 0)
  149.       set the castNum of sprite getAt(goArrowSprites, k) to the number of member "null"
  150.       set the castNum of sprite getAt(goTextSprites, k) to the number of member "null"
  151.     end repeat
  152.     repeat with k = 1 to numTitles
  153.       set the visible of sprite getAt(goTextSprites, k) to 1
  154.     end repeat
  155.     set titleNum to numTitles
  156.     updateStage()
  157.     set goRegionList to []
  158.     repeat with k = 1 to numTitles
  159.       set arrSprite to getAt(goArrowSprites, k)
  160.       set nextH to the locH of sprite arrSprite - 320
  161.       set nextV to the locV of sprite arrSprite - 240
  162.       append(goRegionList, getButtonData("arrowDn", "indexGoAction(" & string(k) & ")", [nextH, nextV]))
  163.     end repeat
  164.     set goObject to 0
  165.     set goObject to new(script "buttonObject", 40, goRegionList)
  166.   else
  167.     set the text of field "currentTerm" to " "
  168.     set the text of field "currentDefinition" to " "
  169.     repeat with k = 1 to count(goArrowSprites)
  170.       set arrSprite to getAt(goArrowSprites, k)
  171.       set textSprite to getAt(goTextSprites, k)
  172.       set the castNum of sprite arrSprite to the number of member "null"
  173.       set the castNum of sprite textSprite to the number of member "null"
  174.       set the puppet of sprite arrSprite to 0
  175.       set the castNum of sprite textSprite to 0
  176.     end repeat
  177.     updateStage()
  178.     set goObject to 0
  179.   end if
  180. end
  181.  
  182. on indGoAction me, whichOne
  183.   global indexWindowObject, gLinkList
  184.   put getAt(gLinkList, whichOne)
  185.   if whichOne <= count(gLinkList) then
  186.     gomovie(getAt(gLinkList, whichOne))
  187.   else
  188.   end if
  189. end
  190.