home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Magazine 28 Bonus / CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin / data / shared.dir / 03027_Script_INDEX < prev    next >
Text File  |  1996-06-21  |  4KB  |  95 lines

  1. -- --------------------------------------------------------------------------------------
  2. -- Handler initializeIndex 
  3.  
  4. on initializeIndex
  5.   global visitedIndicator
  6.   set visitedIndicator = 4
  7. end 
  8.  
  9. -- --------------------------------------------------------------------------------------
  10. -- Handler doClickIndexList gets the buttonIndex of the button clicked, adds the button
  11. -- to the list of clicked buttons for the given list, and calls the routine to do
  12. -- what should be done for the clicked button.
  13.  
  14. on doClickIndexList whichList, buttonBar, numVItems, numHItems
  15.   if (numHItems = 0) then -- 1 dimensional vertical button bar
  16.     set whichButton = getVButtonIndex(buttonBar, numVItems, the mouseV)
  17.   else if (numVItems = 0) then -- 1 dimensional horizontal button bar
  18.     set whichButton = getHButtonIndex(buttonBar, numHItems, the mouseV)
  19.   else -- two dimensional button bar
  20.     set whichButton = getVHButtonIndex(buttonBar, numVItems, numHItems, the mouseV, the mouseH)
  21.   end if
  22.   
  23.   updateVisitedSections(whichList, whichButton)
  24.   processClickedIndexButton(whichList, whichButton)
  25. end
  26.  
  27. -- --------------------------------------------------------------------------------------
  28. -- Handler processClickedIndexButton goes to the proper section for the button clicked.
  29.  
  30. on processClickedIndexButton whichList, whichButton
  31.   --  goSection(line whichButton of field ("Index List" && whichList), 1)
  32. end
  33.  
  34. -- --------------------------------------------------------------------------------------
  35. -- Handler updateVisitedSections maintains a list of items that have been selected and
  36. -- visited from the index. This information is stored in the field "index visited sections"
  37. -- where each line of the field corresponds to another list in the index.
  38.  
  39. on updateVisitedSections whichList, whichButton
  40.   -- check if the button clicked is already listed as one of the sections visited.
  41.   -- to check this, check if the button's index is already contained in the line for
  42.   -- the given index list. This checking is a bit tricky. The simple "contains" command
  43.   -- cannot be used because then if the list already contains the number "11", the number
  44.   -- "1" will not be added to the list. Instead, check if the word "1" is contained in the
  45.   -- the list. This way, the number may be duplicated (if it was the first button clicked) but
  46.   -- duplicated only once and at most, 1 button can be duplicated once.
  47.   
  48.   if not(line whichList of field "index visited sections" contains (" " & string(whichButton) & " ")) then
  49.     put whichButton & " " after line whichList of field "index visited sections"
  50.   end if
  51. end
  52.  
  53. -- --------------------------------------------------------------------------------------
  54. -- Handler hiliteVisitedSections is called when entering the index.  It hilites the
  55. -- sections that have already been visited.
  56.  
  57. on hiliteVisitedSections whichList
  58.   global visitedIndicator
  59.   
  60.   puppetSprite visitedIndicator, TRUE
  61.   set the trails of sprite visitedIndicator = TRUE
  62.   
  63.   set locations = field ("index list" && whichList && "locations")
  64.   set visitedSections = line whichList of field "index visited sections"
  65.   
  66.   repeat with i = 1 to the number of words in visitedSections
  67.     set currentSection = value(word i of visitedSections)
  68.     set sectionH = value(item 1 of line currentSection of locations)
  69.     set sectionV = value(item 2 of line currentSection of locations)
  70.     set the locH of sprite visitedIndicator = sectionH
  71.     set the locV of sprite visitedIndicator = sectionV
  72.     updateStage
  73.   end repeat
  74.   
  75.   set the trails of sprite visitedIndicator = FALSE
  76.   puppetSprite visitedIndicator, FALSE
  77. end
  78.  
  79. -- --------------------------------------------------------------------------------------
  80. -- Handler doClickIndexTopics is called when the user clicks on an index topic.
  81.  
  82. on doClickIndexTopics topicsSprite, numItems
  83.   set whichList = getHButtonIndex(topicsSprite, numItems, the mouseH)
  84.   puppetSprite topicsSprite, TRUE
  85.   set the castNum of sprite topicsSprite = the number of cast ("indexHiliteSeg"&string(whichList))
  86.   showIndexList(whichList)
  87.   hiliteVisitedSections(whichList)
  88. end
  89.  
  90. -- --------------------------------------------------------------------------------------
  91. -- Handler showIndexList shows the list of items in the clicked index topic.
  92.  
  93. on showIndexList whichList
  94.   goFrame ("List" & whichList, "dissolve, pixels", 4)
  95. end