home *** CD-ROM | disk | FTP | other *** search
- property ancestor
- property EntryChannel
- property TopicsDisplay
- property DestinationsDisplay
- property TopicsSlider, GoToSlider
- property GoToButton
- property WorkshopList
- property Destination
- property currentKey
- property currentTopic
- property topicIndex, workshopIndex
- property TopicsHilite, GoToHilite
- property FindCommandList
- property IDToNameMapping
- property theFindList
- property longNameMapping
- global debugging
-
- on Birth me, theChannelObject, theName, thePageInfo
- set the ancestor of me to Birth( script "Master Page Template", theChannelObject, theName, thePageInfo, true, true )
-
- set GoToButton to FindButton( me, "Goto" )
-
- set TopicsRect to FindButton( me, "Topics" )
- set the immediate of TopicsRect to true
-
- set DestsRect to FindButton( me, "Dests" )
- set the immediate of DestsRect to true
-
- set TopicsHilite to FindDisplay( me, "TopicsHilite" )
- SetCastName( TopicsHilite, "TopicsHilite" )
-
- set GoToHilite to FindDisplay( me, "GoToHilite" )
- SetCastName( GoToHilite, "GoToHilite" )
-
- set WorkshopList to []
- set Destination to ""
- set currentKey to ""
- set currentTopic to ""
- set TopicIndex to 0
-
- set TopicsSlider to FindButton( me, "TopicsSlider" )
- set the trackable of TopicsSlider to true
- set the trackRect of topicsSlider to rect( 439, 156, 439, 232 )
-
- set GoToSlider to FindButton( me, "GoToSlider" )
- set the trackable of GoToSlider to true
- set the trackRect of GoToSlider to rect( 439, 321, 439, 397 )
-
- set theCluster to GetAt( the ButtonList of me, 3 )
- repeat with i = 1 to 4
- set thisButton to GetAt( the buttonlist of theCluster, i )
- --put "setting button" && the name of thisButton && "to true"
- set the repeatable of thisButton to true
- set the repeatrate of thisButton to 5
- end repeat
-
- set PageTopics to FindButton( me, "PageTopics" )
- set the repeatable of PageTopics to true
- set the repeatrate of PageTopics to 5
- set PageGoto to FindButton( me, "PageGoTo" )
- set the repeatable of PageGoto to true
- set the repeatrate of PageGoto to 5
-
- set EntryChannel to FindDisplay( me, "EntryChannel" )
- set TopicsDisplay to FindDisplay( me, "TopicsChannel" )
- set DestinationsDisplay to FindDisplay( me, "DestinationsChannel" )
-
- if the channel of TopicsDisplay <> 8 or the channel of DestinationsDisplay <> 9 then
- alert( "Entry, Topics and Destinations Channels not at 7, 8 and 9 --" && the channel of TopicsDisplay && the channel of DestinationsDisplay )
- return
- end if
-
- set the puppet of sprite 7 to false
- set the puppet of sprite 8 to false
- set the puppet of sprite 9 to false
-
- -- jump to a frame that contains scrolling text sprites
- -- Director won't let us puppet scrolling text boxes into sprites occupied by bitmaps
- go to frame "find"
-
- SetCastName( EntryChannel, "Entry" )
- move( EntryChannel, point( 170, 78 ) )
- setink( EntryChannel, #Transparent )
- Set the editable of sprite the channel of entryChannel to true
- set the text of cast "Entry" of castlib "Shared" to ""
- set the font of member "Entry" of castlib "Shared" to "Geneva"
- set the fontsize of member "Entry" of castlib "Shared" to 12
- set the text of cast "Destinations" of castlib "Shared" to " "
-
- set longNameMapping to value( the text of cast "longnames" of castlib "Find" )
- if voidp( longNameMapping ) then
- beep 2
- put "bad longNameMapping"
- end if
-
- ScrollTo( "Topics", 0 )
- ScrollTo( "Destinations", 0 )
-
- LoadList me
-
- Show me
- return me
- end
-
- on Leave me
- set the puppet of sprite 7 to true
- set the puppet of sprite 8 to true
- set the puppet of sprite 9 to true
- Set the editable of sprite the channel of entryChannel to false
- go to frame 2
- Leave the ancestor of me
- end
-
-
- on ConstrainScroll theCastName, theTop, theSpriteHeight
- if theTop < 0 then set theTop to 0
- if ( the height of cast theCastName - thetop ) < theSpriteHeight then
- set thetop to the height of cast theCastName - theSpriteHeight
- end if
- return theTop
- end
-
- on ScrollTo theCastName, theTop
- set the scrolltop of cast theCastName of castlib "Shared" to theTop
- end
-
- on UpdateSlider theSlider, theChannel, theCastName
- set workingHeight to the height of cast theCastName of castlib "Shared" - the height of sprite theChannel
- set thePerc to float( float(the scrolltop of cast theCastName of castlib "Shared") / float( workingHeight ) )
- if thePerc > 1.0 then
- set thePerc to 1
- end if
- set theRect to the trackrect of theSlider
- set barHeight to the bottom of theRect - the top of theRect
- --put thePerc && barHeight * thePerc
-
- set thePoint to duplicate(the location of theSlider)
- setat( thePoint, 2, integer(barHeight * thePerc) + the top of the trackrect of theSlider )
- --put "updating slider to point" && thePoint
- Move( theSlider, thePoint )
- end
-
- on DoSlider theSlider, theChannel, theCastName
- set theLocV to GetAt( the location of theSlider, 2 )
- set theRect to the trackrect of theSlider
- set thePerc to float( float( theLocV - the top of theRect ) / float( the bottom of theRect - the top of theRect ) )
- set workingHeight to the height of cast theCastName of castlib "Shared" - the height of sprite theChannel
- --put thePerc && workingHeight * thePerc
- ScrollTo( theCastName, workingHeight * thePerc )
- end
-
- on ScrollAndUpdate me, theCastName, theslider, theChannel, direction
- Hide( TopicsHilite )
- UpdateStage
- ScrollByLine( cast theCastName of castlib "Shared", direction )
- if currenttopic <> "" then
- ShowTopicsHilite( me, topicIndex )
- end if
- UpdateSlider( theslider, theChannel, theCastName )
- end
-
-
- on ShowHilite me, theCastName, Index, theChannel, theHilite
- set theScrollTop to the scrolltop of cast theCastName of castlib "Shared"
- set theV to linePosToLocV(member theCastName of castlib "Shared", Index)
- if theV >= theScrollTop and theV < theScrollTop + 125 then
- set theV to theV + ( the top of sprite theChannel - theScrollTop )
- set thePoint to Point( 296, theV )
- else
- set thePoint to Point( 296, -1000 )
- end if
- Move( theHilite, thePoint )
- end
-
- on ShowTopicsHilite me
- ShowHilite( me, "Topics", TopicIndex, the channel of TopicsDisplay, TopicsHilite )
- end
-
- on ShowGoToHilite me
- ShowHilite( me, "Destinations", WorkshopIndex, the channel of DestinationsDisplay, GoToHilite )
- end
-
- on SelectWorkshop me
- ShowGoToHilite me
- SetState( GoToButton, "Enabled", true )
- end
-
- on ShowWorkshops me
- set Workshoplist to GetAProp( theFindList, CurrentTopic )
- --put "workshoplist" && workshoplist
- set WorkshopIndex to 0
- Set Desination to ""
- set workshops to ""
- set FindCommandList to []
- set the text of cast "Destinations" of castlib "Shared" to ""
- if not voidp( workshoplist ) then
- Hide( GoToHilite )
- repeat with i = 1 to count(Workshoplist)
- set shortName to GetPropAt(Workshoplist, i)
- --put "shortname" && shortname
- set NameInfo to getprop( longnamemapping, shortname )
- set longName to getat( nameinfo, 2 )
- set GotoName to getat( nameinfo, 1 )
- put longName & RETURN after workshops
- set thisWorkshopCommand to [#GoToPage, GotoName]
- add(FindCommandList, [thisWorkshopCommand] )
- set teachmelist to getat(Workshoplist, i)
- --put "teachmelist" && teachmelist
- repeat with j = 1 to count(teachmelist)
- set teachMeID to getat(teachmelist, j)
- --put teachMeId
- set teachMename to GetaProp( IDToNameMapping, teachMeID )
- if teachMeName <> 0 then
- --put teachMeId && teachMename
- add(FindCommandList, [thisWorkshopCommand, [#CommandList, teachMeID]] )
- put " " & teachMeName & RETURN after workshops
- else
- if debugging = true then beep
- --put "cant find teach me id" && teachMeID && "in workshop" && shortName
- end if
- end repeat
- end repeat
-
- set the text of cast "Destinations" of castlib "Shared" to workshops
- set the font of member cast "Destinations" of castlib "Shared" to "Geneva"
- set the fontsize of member cast "Destinations" of castlib "Shared" to 12
-
- if count(workshoplist) = 1 then
- set workshopindex to 1
- SelectWorkshop me
- else
- SetState( GoToButton, "Disabled", true )
- end if
-
- else
- SetState( GoToButton, "Disabled", true )
- end if
- end
-
- on ScrollByPageAndUpdate me, theslider, thechannel, thecastname, theamount
- Hide( TopicsHilite )
- scrollByPage( member thecastname of castlib "Shared", theamount )
- if currenttopic <> "" then
- ShowTopicsHilite( me, topicIndex )
- end if
- UpdateSlider( theslider, thechannel, thecastname )
- end
-
- on ChangePage me, theElementID, theValue1, theValue2
-
- ChangePage( the ancestor of me, theElementID, theValue1, theValue2 )
-
- case theElementID of
- "TopicsUp":
- ScrollAndUpdate( me, "Topics", topicsslider, the channel of TopicsDisplay, -1 )
- "TopicsDown":
- ScrollAndUpdate( me, "Topics", topicsslider, the channel of TopicsDisplay, 1 )
- "GoToUp":
- ScrollAndUpdate( me, "Destinations", gotoslider, the channel of DestinationsDisplay, -1 )
- "GoToDown":
- ScrollAndUpdate( me, "Destinations", gotoslider, the channel of DestinationsDisplay, 1 )
-
- "TopicsSlider":
- DoSlider( topicsslider, the channel of TopicsDisplay, "Topics" )
- ShowTopicsHilite me, topicIndex
-
- "GoToSlider":
- DoSlider( GoToSlider, the channel of DestinationsDisplay, "Destinations" )
-
- "TopicsHit":
- set TopicIndex to the mouseline
- set CurrentTopic to line TopicIndex of the text of cast "Topics" of castlib "Shared"
- set the text of cast "Entry" of Castlib "Shared" to CurrentTopic
- set the selstart to 0
- set the selend to the number of chars in CurrentTopic
-
- ShowTopicsHilite me
- ShowWorkshops me
-
- "PageTopics":
- if the mousev > the bottom of the buttonrect of topicsslider then
- scrollByPageAndUpdate( me, topicsslider, the channel of TopicsDisplay, "Topics", 1 )
- else
- scrollByPageAndUpdate( me, topicsslider, the channel of TopicsDisplay, "Topics", -1 )
- end if
-
- "PageGoTo":
- if the mousev > the bottom of the buttonrect of gotoslider then
- scrollByPageAndUpdate( me, gotoslider, the channel of DestinationsDisplay, "Destinations", 1 )
- else
- scrollByPageAndUpdate( me, gotoslider, the channel of DestinationsDisplay, "Destinations", -1 )
- end if
-
- "DestsHit":
- set WorkshopIndex to the mouseline
- SelectWorkshop( me )
-
- "Done":
- QueueCommand( [[#GoBack]] )
-
- "GoTo":
- if the runmode = "author" then alert string(FindCommandList) --MACK 04.15.02
- if the runmode = "author" then alert string(workshopindex) --MACK 04.15.02
-
- if workshopindex > count(FindCommandList) or workshopindex = -1 then --MACK 04.15.02
- nothing --MACK 04.15.02
- else --MACK 04.15.02
- put( GetAt(FindCommandList, workshopindex) )
- QueueCommand( GetAt(FindCommandList, workshopindex) )
- end if --MACK 04.15.02
-
- end case
- end
-
- on PageIdle me
- PageIdle the ancestor of me
-
- set theKey to the text of cast "entry" of castlib "Shared"
- if theKey <> CurrentKey then
- --set theKey to UpShift( theKey )
- put theKey
- set currentkey to theKey
-
- set topicindex to FindPosNear( theFindList, theKey )
- if topicIndex > count( theFindList ) then set topicindex to count( theFindList )
- set matchword to GetPropAt( theFindList, topicindex )
-
- --put "found" && TopicIndex && MatchWord
-
- if TopicIndex > 0 and currentTopic <> MatchWord then
- set currentTopic to MatchWord
-
- -- scroll selection to center of topics
- set theV to linePosToLocV(member "Topics" of castlib "Shared", TopicIndex)
- --put "index" && TopicIndex && "locv" && theV
- ScrollTo( "topics", ConstrainScroll( "topics", theV - ( 4 * lineheight(cast "topics" of castlib "Shared", 1) ), 125 ) )
- UpdateSlider( topicsSlider, the channel of TopicsDisplay, "Topics" )
-
- -- show the hilite at the proper location
- ShowTopicsHilite( me, TopicIndex )
- ShowWorkshops me
-
- return
- end if
-
- end if
- end
-
- on LoadList me
- set tempstring1 to the text of cast "master1" of castlib "Find"
- set tempString2 to the text of cast "master2" of castlib "Find"
- put tempString2 after tempString1
-
- set theFindList to value(tempString1)
-
- set tempstring1 to ""
- set tempstring2 to ""
- if not listp(theFindList) then
- beep 3
- put "bad find list"
- end if
- sort theFindList
-
- set IDtoNameMapping to value(the text of cast "IDToName" of castlib "Find")
- if not listp(IDtoNameMapping) then
- beep
- put "bad ID To Name Mapping list"
- end if
- sort( IDtoNameMapping )
- end
-
- on ShowFindList
- repeat with i = 1 to count(theFindList)
- set thisKeyword to GetPropAt(theFindList, i)
- set thisWorkshopList to GetAt(theFindList, i)
- put i && thisKeyword && thisWorkshopList
- end repeat
- end
-
-