(FILECREATED " 3-Mar-86 18:20:02" {QV}<NOTECARDS>1.3K>SHRUNKENBROWSER.;13 53370  

      changes to:  (FNS NC.MakeBrowserOverviewWin NC.BrowserOverviewWinRepaintFn 
			NC.BrowserOverviewWinButtonEventFn NC.RedrawBrowserOverviewWin)

      previous date: " 2-Mar-86 16:57:35" {QV}<NOTECARDS>1.3K>SHRUNKENBROWSER.;11)


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT SHRUNKENBROWSERCOMS)

(RPAQQ SHRUNKENBROWSERCOMS ((* * Stuff following is for making and manipulating the tiny attached 
				 shrunken browser window.)
			      (* * These functions are changed from NCINTERFACE)
			      (FNS NC.SetupTitleBarMenu)
			      (* * These functions are changed from NCBROWSERCARD)
			      (FNS NC.BringUpBrowserCard NC.RelayoutBrowserCard 
				   NC.ConnectNodesInBrowser NC.DrawArrowHead)
			      (* * Rest of stuff below is new for NCBROWSERCARD)
			      (GLOBALVARS NC.BrowserOverviewDefaultWidth 
					  NC.BrowserOverviewDefaultHeight 
					  NC.LeastScaleForGraphNodeShrinking)
			      (INITVARS (NC.BrowserOverviewDefaultWidth 75)
					(NC.BrowserOverviewDefaultHeight 75)
					(NC.LeastScaleForGraphNodeShrinking .3))
			      (FNS NC.MakeBrowserOverviewWin NC.MakeBrowserOverviewWinAtLowerLeft 
				   NC.MakeBrowserOverviewWinAtLeftBottom 
				   NC.MakeBrowserOverviewWinAtRightBottom 
				   NC.ReattachBrowserOverviewWinIfNeeded)
			      (FNS NC.DRAWBOX NC.ShrinkGraphToWindow NC.ScaleGraphNode 
				   NC.ComputeOverviewScale NC.RedrawBrowserOverviewWin 
				   NC.DrawWireFrameInOverviewWin NC.BrowserScrollFn 
				   NC.BrowserReshapeFn NC.BrowserOverviewWinRepaintFn 
				   NC.BrowserOverviewWinReshapeFn NC.BrowserOverviewWinMINSIZEFn 
				   NC.BrowserOverviewWinButtonEventFn)))
(* * Stuff following is for making and manipulating the tiny attached shrunken browser window.
)

(* * These functions are changed from NCINTERFACE)

(DEFINEQ

(NC.SetupTitleBarMenu
  (LAMBDA (Window Card NoteCardType)                         (* rht: "28-Feb-86 12:36")
                                                             (* Setup the title bar menu for the window Window 
							     pertaining to Card specified by ID)

          (* * rht 1/3/85: Now takes optional NoteCardType arg in case need to override the ID's type.
	  Like when ID is of type that inherits from Browser. Also changed "pointer" to "link" everywhere.)



          (* * rht 1/12/85: Added menu for StructEdit type. Just the same except has no InsertLink operation.
	  This needs to be cleaned up and interfaced to Types mechanism.)



          (* * rht 1/15/85: Added "Relayout" item to the browser title bar middle button menu, and made graph and structedit 
	  cards contain only that item on their middle button menus.)



          (* * rht 5/22/85: Took out structedit and structeditbrowser junk.)



          (* * fgh 11/14/85 Updated to handle Card object.)


    (OR NoteCardType (SETQ NoteCardType (NC.RetrieveType Card)))
    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
		(FUNCTION NC.TitleBarButtonEventFn))
	  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
			(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
				      (FUNCTION NC.TitleBarButtonEventFn))))
    (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu)
		  (SELECTQ
		    NoteCardType
		    (Graph (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMenu))
					(type? MENU NC.GraphTitleBarMenu))
				 (SETQ NC.GraphTitleBarMenu
				   (create MENU
					     ITEMS ←(QUOTE
					       ((Edit% Property% List (FUNCTION NC.EditProperties)
								      
					"Brings up an editor for the property list of this card.")
						 (Show% Links (FUNCTION NC.ShowLinks)
							      
					   "Brings up a list of the links to and from this card.")
						 (Title/Sources/FileBoxes
						   (FUNCTION (LAMBDA (TextStream)
						       (NC.AssignTitle TextStream)
						       (NC.AssignSources TextStream)
						       (NC.AddParents TextStream)))
						   
		       "Do all of the operations necessary to file this note card in a file box."
						   (SUBITEMS (Assign% Title (FUNCTION 
									      NC.AssignTitle)
									    
						       "Assigns a (new) title to this note card.")
							     (Designate% Sources
							       (FUNCTION NC.AssignSources)
							       
				       "Designate the source(s) of the information in this card.")
							     (File% in% FileBoxes
							       (FUNCTION NC.AddParents)
							       
						 "File this note card in one or more file boxes.")
							     (Unfile% from% FileBoxes
							       (FUNCTION NC.UnfileNoteCard)
							       
					   "Remove this card from one or more of its file boxes.")
							     (Delete% Source (FUNCTION 
									       NC.DeleteSource)
									     
							"Delete one of the sources of this card.")))
						 (Insert% Link (FUNCTION NC.AddLinkToGraphCard)
							       
						   "Add a node that points to another note card."
							       (SUBITEMS
								 (Insert% Link
								   (FUNCTION NC.AddLinkToGraphCard)
								   
						   "Add a node that points to another note card.")
								 (Add% Global% Link
								   (FUNCTION NC.AddGlobalLinkToCard)
								   
						    "Add a global link emanating from this card.")
								 (Add% Global% Links
								   (FUNCTION 
								     NC.AddGlobalLinksToCard)
								   
						     "Add global links emanating from this card.")))
						 (Close% and% Save
						   (FUNCTION CLOSEW)
						   
					  "Close this note card after saving it in the NoteFile."
						   (SUBITEMS (Close% and% Save
							       (FUNCTION CLOSEW)
							       
					  "Close this note card after saving it in the NoteFile.")
							     (Close% w/o% Saving
							       (FUNCTION NC.QuitWithoutSaving)
							       
		      "Close this note card without saving any changes made since the last Save.")
							     (Save% in% NoteFile
							       (FUNCTION NC.CardSaveFn)
							       
				       "Save this card in the NoteFile but don't close the card.")
							     (Delete% Card (FUNCTION 
									     NC.DeleteNoteCards)
									   
						"Permenantly delete this card from the NoteFile.")))))
					     CENTERFLG ← T
					     MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								     10
								     (QUOTE BOLD)))))
			   NC.GraphTitleBarMenu)
		    (Browser (OR (AND (BOUNDP (QUOTE NC.BrowserTitleBarMenu))
					  (type? MENU NC.BrowserTitleBarMenu))
				   (SETQ NC.BrowserTitleBarMenu
				     (create MENU
					       ITEMS ←(QUOTE
						 ((Edit% Property% List (FUNCTION NC.EditProperties)
									
					"Brings up an editor for the property list of this card.")
						   (Show% Links (FUNCTION NC.ShowLinks)
								
					   "Brings up a list of the links to and from this card.")
						   (Title/Sources/FileBoxes
						     (FUNCTION (LAMBDA (TextStream)
							 (NC.AssignTitle TextStream)
							 (NC.AssignSources TextStream)
							 (NC.AddParents TextStream)))
						     
		       "Do all of the operations necessary to file this note card in a file box."
						     (SUBITEMS (Assign% Title (FUNCTION 
										NC.AssignTitle)
									      
						       "Assigns a (new) title to this note card.")
							       (Designate% Sources
								 (FUNCTION NC.AssignSources)
								 
				       "Designate the source(s) of the information in this card.")
							       (File% in% FileBoxes
								 (FUNCTION NC.AddParents)
								 
						 "File this note card in one or more file boxes.")
							       (Unfile% from% FileBoxes
								 (FUNCTION NC.UnfileNoteCard)
								 
					   "Remove this card from one or more of its file boxes.")
							       (Delete% Source
								 (FUNCTION NC.DeleteSource)
								 
							"Delete one of the sources of this card.")))
						   (Add% Global% Link
						     (FUNCTION NC.AddGlobalLinkToCard)
						     "Add a global link emanating from this card."
						     (SUBITEMS (Add% Global% Link
								 (FUNCTION NC.AddGlobalLinkToCard)
								 
						    "Add a global link emanating from this card.")
							       (Add% Global% Links
								 (FUNCTION NC.AddGlobalLinksToCard)
								 
						     "Add global links emanating from this card.")))
						   (Close% and% Save
						     (FUNCTION CLOSEW)
						     
					  "Close this note card after saving it in the NoteFile."
						     (SUBITEMS (Close% and% Save
								 (FUNCTION CLOSEW)
								 
					  "Close this note card after saving it in the NoteFile.")
							       (Close% w/o% Saving
								 (FUNCTION NC.QuitWithoutSaving)
								 
		      "Close this note card without saving any changes made since the last Save.")
							       (Save% in% NoteFile
								 (FUNCTION NC.CardSaveFn)
								 
				       "Save this card in the NoteFile but don't close the card.")
							       (Delete% Card (FUNCTION 
									       NC.DeleteNoteCards)
									     
						"Permenantly delete this card from the NoteFile.")))))
					       CENTERFLG ← T
					       MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								       10
								       (QUOTE BOLD)))))
			     NC.BrowserTitleBarMenu)
		    (Sketch (OR (AND (BOUNDP (QUOTE NC.SketchTitleBarMenu))
					 (type? MENU NC.SketchTitleBarMenu))
				  (SETQ NC.SketchTitleBarMenu
				    (create MENU
					      ITEMS ←(QUOTE
						((Edit% Property% List (FUNCTION NC.EditProperties)
								       
					"Brings up an editor for the property list of this card.")
						  (Show% Links (FUNCTION NC.ShowLinks)
							       
					   "Brings up a list of the links to and from this card.")
						  (Title/Sources/FileBoxes
						    (FUNCTION (LAMBDA (TextStream)
							(NC.AssignTitle TextStream)
							(NC.AssignSources TextStream)
							(NC.AddParents TextStream)))
						    
		       "Do all of the operations necessary to file this note card in a file box."
						    (SUBITEMS (Assign% Title (FUNCTION 
									       NC.AssignTitle)
									     
						       "Assigns a (new) title to this note card.")
							      (Designate% Sources
								(FUNCTION NC.AssignSources)
								
				       "Designate the source(s) of the information in this card.")
							      (File% in% FileBoxes
								(FUNCTION NC.AddParents)
								
						 "File this note card in one or more file boxes.")
							      (Unfile% from% FileBoxes
								(FUNCTION NC.UnfileNoteCard)
								
					   "Remove this card from one or more of its file boxes.")
							      (Delete% Source (FUNCTION 
										NC.DeleteSource)
									      
							"Delete one of the sources of this card.")))
						  (Insert% Link (FUNCTION NC.AddLinkToSketchCard)
								
						 "Add a link to another card to this sketch/map."
								(SUBITEMS
								  (Insert% Link
								    (FUNCTION 
								      NC.AddLinkToSketchCard)
								    
						 "Add a link to another card to this sketch/map.")
								  (Add% Global% Link
								    (FUNCTION 
								      NC.AddGlobalLinkToCard)
								    
						    "Add a global link emanating from this card.")
								  (Add% Global% Links
								    (FUNCTION 
								      NC.AddGlobalLinksToCard)
								    
						     "Add global links emanating from this card.")))
						  (Close% and% Save
						    (FUNCTION CLOSEW)
						    
					  "Close this note card after saving it in the NoteFile."
						    (SUBITEMS (Close% and% Save
								(FUNCTION CLOSEW)
								
					  "Close this note card after saving it in the NoteFile.")
							      (Close% w/o% Saving
								(FUNCTION NC.QuitWithoutSaving)
								
		      "Close this note card without saving any changes made since the last Save.")
							      (Save% in% NoteFile
								(FUNCTION NC.CardSaveFn)
								
				       "Save this card in the NoteFile but don't close the card.")
							      (Delete% Card (FUNCTION 
									      NC.DeleteNoteCards)
									    
						"Permenantly delete this card from the NoteFile.")))))
					      CENTERFLG ← T
					      MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								      10
								      (QUOTE BOLD)))))
			    NC.SketchTitleBarMenu)
		    NIL))
    (COND
      ((EQ NoteCardType (QUOTE Browser))
	(WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)
		      (OR (AND (BOUNDP (QUOTE NC.BrowserTitleBarMiddleButtonMenu))
				   (type? MENU NC.BrowserTitleBarMiddleButtonMenu)
				   NC.BrowserTitleBarMiddleButtonMenu)
			    (SETQ NC.BrowserTitleBarMiddleButtonMenu
			      (create MENU
					ITEMS ←(QUOTE
					  ((Recompute% Browser (FUNCTION NC.UpdateBrowserCard)
							       
			     "Recomputes this browser to show the current state of the NoteFile.")
					    (Relayout% Graph (FUNCTION NC.RelayoutBrowserCard)
							     
						    "Re-layout the browser, but keep same nodes.")
					    (Reconnect% Nodes (FUNCTION NC.ConnectNodesInBrowser)
							      
	   "Draw all possible links, from currently selected link types, between pairs of nodes.")
					    (Unconnect% Nodes (FUNCTION NC.UnconnectNodesInBrowser)
							      "Undraw all links in the browser.")
					    (Expand% Browser% Node (FUNCTION NC.ExpandBrowserNode)
								   
					      "Expand the graph under one node to a given depth.")
					    (Graph% Edit% Menu (FUNCTION NC.GetGraphEditMenu)
							       "Bring up the graph editor menu.")
					    (Change% Browser% Specs (FUNCTION NC.ChangeBrowserSpecs)
								    
		 "Make changes to some or all of the browser specs, e.g. link types, depth, etc.")
					    (Browser% Overview% Win
					      (FUNCTION NC.MakeBrowserOverviewWin)
					      
					"Attach the browser overview window at top of left edge."
					      (SUBITEMS (Attach% Upper% Left (FUNCTION 
									NC.MakeBrowserOverviewWin)
									     
					"Attach the browser overview window at top of left edge.")
							(Attach% Lower% Left (FUNCTION 
							     NC.MakeBrowserOverviewWinAtLowerLeft)
									     
				     "Attach the browser overview window at bottom of left edge.")
							(Attach% Left% Bottom (FUNCTION 
							    NC.MakeBrowserOverviewWinAtLeftBottom)
									      
				     "Attach the browser overview window at left of bottom edge.")
							(Attach% Right% Bottom
							  (FUNCTION 
							   NC.MakeBrowserOverviewWinAtRightBottom)
							  
				    "Attach the browser overview window at right of bottom edge.")))))
					CENTERFLG ← T
					MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								10
								(QUOTE BOLD)))))))
      ((EQ NoteCardType (QUOTE Graph))
	(WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)
		      (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMiddleButtonMenu))
				   (type? MENU NC.GraphTitleBarMiddleButtonMenu)
				   NC.GraphTitleBarMiddleButtonMenu)
			    (SETQ NC.GraphTitleBarMiddleButtonMenu
			      (create MENU
					ITEMS ←(QUOTE ((Relayout% Graph (FUNCTION 
									    NC.RelayoutGraphCard)
									  
						      "Re-layout the graph, but keep same nodes.")))
					CENTERFLG ← T
					MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								10
								(QUOTE BOLD))))))))))
)
(* * These functions are changed from NCBROWSERCARD)

(DEFINEQ

(NC.BringUpBrowserCard
  (LAMBDA (Card Substance Region/Position)                   (* rht: " 2-Mar-86 15:32")

          (* * Given a browser Substance, open a browser window and set it up to be a NoteCard with ID.)



          (* * rht 11/17/84: Now returns window.)



          (* * rht 9/11/85: Now checks for changed link icon display global params.)



          (* * rht 11/17/85: Now handles new card and Notefile objects.)



          (* * rht 2/1/86: Now restores any saved UID user data info stashed on card's prop list.)



          (* * fgh 2/5/86 Added call to NC.ApplySupersFn)



          (* * rht 2/14/86: Now rebuilds browser hash array.)



          (* * rht 2/28/86: Added WINDOWPROP for SCROLLFN and RESHAPEFN.)



          (* * rht 3/2/86: Took out call to NC.FetchBrowserHashArray.)


    (LET ((GraphNodes (fetch (GRAPH GRAPHNODES) of Substance))
	  Window OldUIDToNewUIDHashArray BrowserSavedLinkingInfo)

          (* * Restore any saved UID user data info stashed on card UID's prop list.)


         (if (SETQ BrowserSavedLinkingInfo (NC.FetchBrowserSavedLinkingInfo Card))
	     then (SETQ OldUIDToNewUIDHashArray (HASHARRAY 100 NIL (FUNCTION NC.MakeHashKey)
								 (FUNCTION NC.SameUIDP)))
		    (for BrowserSavedLinkingInfoForNode in BrowserSavedLinkingInfo
		       eachtime (BLOCK) do (for SavedLinkingInfo on (CDR 
								   BrowserSavedLinkingInfoForNode)
						    by (CDDR SavedLinkingInfo)
						    bind (SourceUID ←(
								   NC.NewBrowserNodeUIDFromOldUID
									(CAR 
								   BrowserSavedLinkingInfoForNode)
									GraphNodes 
									OldUIDToNewUIDHashArray))
						    eachtime (BLOCK)
						    do (NC.UIDPutProp SourceUID
									  (
								   NC.NewBrowserNodeUIDFromOldUID
									    (CAR SavedLinkingInfo)
									    GraphNodes 
									  OldUIDToNewUIDHashArray)
									  (CADR SavedLinkingInfo))))
	       )
         (NC.SetBrowserSavedLinkingInfo Card NIL)

          (* * For each graph node corresponding to a notecard, hang the card object off the node id's prop list.)


         (for GraphNode in GraphNodes bind LinkIcon DestCard eachtime (BLOCK)
	    when (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
							       of GraphNode)))
	    do (NC.UIDPutProp (NC.CoerceToGraphNodeID GraphNode)
				  (QUOTE CardObject)
				  (SETQ DestCard (fetch (Link DestinationCard)
						      of (NC.FetchLinkFromLinkIcon LinkIcon)))))

          (* * Make a new browser hash array with the new graph node UIDs.)


         (NC.SetUserDataProp Card (QUOTE BrowserHashArray)
			       NIL)
         (NC.GetBrowserHashArray Card Substance)

          (* * For each graph node, fix the NODEID and DESTNODEID fields of each of its TONODES LinkParameters.)


         (for GraphNode in GraphNodes eachtime (BLOCK)
	    do (for ToNode in (fetch (GRAPHNODE TONODES) of GraphNode)
		    bind (ThisNodeID ←(NC.CoerceToGraphNodeID GraphNode)) eachtime (BLOCK)
		    when (EQ (CAR ToNode)
				 LINKPARAMS)
		    do (LISTPUT ToNode (QUOTE NODEID)
				    ThisNodeID)
			 (LISTPUT ToNode (QUOTE DESTNODEID)
				    (NC.CoerceToGraphNodeID (CADR ToNode)))))

          (* * Bring up card and mess with its window.)


         (SETQ Window (NC.ApplySupersFn EditFn Card Substance Region/Position))
         (NC.SetupTitleBarMenu Window Card (QUOTE Browser))
         (NC.MakeLinksLegendMenu Window (NC.FetchBrowserLinksLegend Card))
                                                             (* Disable the old-style right button grapher editor 
							     menu.)
         (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
		       (FUNCTION NC.BrowserRightButtonFn))
         (WINDOWADDPROP Window (QUOTE SHRINKFN)
			  (FUNCTION NC.GraphCardShrinkFn))
         (WINDOWADDPROP Window (QUOTE REPAINTFN)
			  (FUNCTION NC.BrowserRepaintFn)
			  T)
         (WINDOWPROP Window (QUOTE SCROLLFN)
		       (FUNCTION NC.BrowserScrollFn))
         (WINDOWPROP Window (QUOTE RESHAPEFN)
		       (FUNCTION NC.BrowserReshapeFn))

          (* * I have to hang notecard's Card on window now in case REDISPLAYW runs and tries to get Card from window.)


         (WINDOWPROP Window (QUOTE NoteCardObject)
		       Card)                                 (* Check if link icon display global params have 
							     changed since last time card was up.
							     If so, fix graph nodes and redisplay.)
         (if (NC.GraphLinkIconUpdateCheck Card Window Substance T)
	     then (REDISPLAYW Window))
     Window)))

(NC.RelayoutBrowserCard
  (LAMBDA (Window)                                           (* rht: "28-Feb-86 12:15")

          (* * Called from the middle button of a browser or structeditbrowser card. This lays out and displays the browser, 
	  but does not recompute the nodes.)



          (* * rht 11/17/85: updated to handle new notefile and card objects.)



          (* * rht 2/7/86: Now gets browser format, etc. via fetch/set fns.)



          (* * rht 2/28/86: Added WINDOWPROP for SCROLLFN and RESHAPEFN.)


    (PROG (Card RootCards RootNodeIDs OldToNodePairs Graph GraphNodes BrowserFormat 
		  DropVirtualNodesFlg SpecialBrowserSpecs)
	    (NC.PrintMsg Window T "Laying out graph ...")
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ RootCards (NC.FetchBrowserRoots Card))
	    (SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
					(QUOTE (LATTICE))))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ SpecialBrowserSpecs (OR (CAR (NC.FetchSpecialBrowserSpecs Card))
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Create hash array if haven't already.)
	    (NC.GetBrowserHashArray Card Graph)            (* check graph node size against image box size.)
	    (NC.GraphLinkIconUpdateCheck Card Window Graph NIL)

          (* Save the TONODES values of the nodes so can replace later after LAYOUTGRAPH call. At the same time, throw away 
	  all the link params info in TONODES field.)


	    (SETQ OldToNodePairs (for Node in GraphNodes bind ToNodes eachtime (BLOCK)
				      collect (PROG1 (CONS (fetch (GRAPHNODE NODEID)
								    of Node)
								 (APPEND (SETQ ToNodes
									     (fetch (GRAPHNODE
											TONODES)
										of Node))))
							 (replace (GRAPHNODE TONODES) of Node
							    with (for ToNode in ToNodes
								      collect
								       (if (EQ (CAR ToNode)
										   LINKPARAMS)
									   then (CADR ToNode)
									 else ToNode))))))
	    (SETQ RootNodeIDs (for RootCard in RootCards collect (NC.GetBrowserNodeID
									   Card RootCard)))
	    (NC.SetPropListDirtyFlg Card T)                (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
	    (SETQ Graph (if GraphNodes
			      then (LAYOUTGRAPH GraphNodes
						    (for Node in GraphNodes bind NodeID
						       eachtime (BLOCK)
								  (SETQ NodeID (fetch
								      (GRAPHNODE NODEID)
										    of Node))
						       when
							(OR (AND (NULL (fetch (GRAPHNODE
											FROMNODES)
										of Node))
								     (NOT (LISTP NodeID)))
							      (FMEMB NodeID RootNodeIDs))
						       collect NodeID)
						    (SUBST (QUOTE LATTICE)
							     NC.*Graph*BrowserFormat BrowserFormat)
						    (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS MotherD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS PersonalD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS FamilyD)
						       of SpecialBrowserSpecs))
			    else (create GRAPH)))

          (* Replace the TONODES fields of the Graph nodes by their pre-LAYOUTGRAPH values. Also throw away any nodes that 
	  didn't appear in the old graph.)


	    (if Graph
		then (replace (GRAPH GRAPHNODES) of Graph
			  with (for Node in (fetch (GRAPH GRAPHNODES) of Graph)
				    bind AssocPair eachtime (BLOCK)
				    when (SETQ AssocPair (FASSOC (fetch (GRAPHNODE NODEID)
									  of Node)
								       OldToNodePairs))
				    collect (replace (GRAPHNODE TONODES) of Node
						 with (CDR AssocPair))
					      (if DropVirtualNodesFlg
						  then (replace (GRAPHNODE NODEBORDER)
							    of Node with NIL))
                                                             (* Throw away LINKPARAMS junk from the FromNodes that 
							     LAYOUTGRAPH stuck in.)
					      (replace (GRAPHNODE FROMNODES) of Node
						 with (for FromNode in (fetch (GRAPHNODE
											FROMNODES)
										of Node)
							   eachtime (BLOCK)
							   collect (if (EQ (CAR FromNode)
										 LINKPARAMS)
									 then (CADR FromNode)
								       else FromNode)))
					      Node)))
	    (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
			 (FUNCTION NC.GraphCardMiddleButtonFn)
			 NIL T)

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
	    (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
			  (FUNCTION NC.BrowserRightButtonFn))
	    (WINDOWADDPROP Window (QUOTE REPAINTFN)
			     (FUNCTION NC.BrowserRepaintFn)
			     T)
	    (WINDOWPROP Window (QUOTE SCROLLFN)
			  (FUNCTION NC.BrowserScrollFn))
	    (WINDOWPROP Window (QUOTE RESHAPEFN)
			  (FUNCTION NC.BrowserReshapeFn))
	    (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty Card)
	    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
			(FUNCTION NC.TitleBarButtonEventFn))
		  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
				(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
					      (FUNCTION NC.TitleBarButtonEventFn))))
	    (NC.ClearMsg Window T))))

(NC.ConnectNodesInBrowser
  (LAMBDA (Window)                                           (* rht: " 2-Mar-86 16:53")

          (* * Draw any links, from the current link set, between any pairs of nodes currently being shown in the browser.)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns. Also fixed one last old call to 
	  GETPROPLIST on a NodeID.)



          (* * rht 3/2/86: Added WINDOWPROP for SCROLLFN and RESHAPEFN.)


    (PROG (Card LinkLabels Graph GraphNodes BrowserFormat DropVirtualNodesFlg NodeIDs)
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
	    (SETQ BrowserFormat (NC.FetchBrowserFormat Card))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Create hash array if haven't already.)
	    (NC.GetBrowserHashArray Card Graph)            (* check graph node size against image box size.)
	    (NC.GraphLinkIconUpdateCheck Card Window Graph NIL)
                                                             (* These are the workhorse loops that rebuild the 
							     TONODES of each nonvirtual node.)
                                                             (* First smash all the nodeID's proplists and 
							     accumulate nodeIDs.)
	    (SETQ NodeIDs (for Node in GraphNodes bind NodeID eachtime (BLOCK)
			       when (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL)
								 of Node))
			       collect (NC.SmashGraphNodeIDProps (SETQ NodeID (
									 NC.CoerceToGraphNodeID
									 Node)))
					 NodeID))            (* Throw away duplicates obtained from virtual nodes.)
	    (SETQ NodeIDs (INTERSECTION NodeIDs NodeIDs))

          (* Next accumulate all linktypes on the from node's proplist using the To node's graphnodeID as prop name.
	  We do the analogous thing for backward links, but notice that we ignore backward linktypes that also appear in the 
	  list in their forward version.)


	    (for NodeID in NodeIDs bind RealCard
	       do (for Link in (NC.RetrieveToLinks (SETQ RealCard (
							       NC.CardFromBrowserNodeID NodeID)))
		       bind DestNodeID eachtime (BLOCK) when (NC.LinkLabelP Link LinkLabels)
		       when (FMEMB (SETQ DestNodeID (NC.GetBrowserNodeID Card
										 (fetch
										   (Link 
										  DestinationCard)
										    of Link)))
				       NodeIDs)
		       do (NC.UIDAddProp NodeID DestNodeID (fetch (Link Label) of Link)
					     T))
		    (for Link in (NC.RetrieveFromLinks RealCard) bind SourceNodeID
		       eachtime (BLOCK) when (AND (NC.ReverseLinkLabelP Link LinkLabels)
							  (NOT (NC.LinkLabelP Link LinkLabels)))
		       when (FMEMB (SETQ SourceNodeID (NC.GetBrowserNodeID
					   Card
					   (fetch (Link SourceCard) of Link)))
				       NodeIDs)
		       do (NC.UIDAddProp SourceNodeID NodeID (fetch (Link Label) of Link)
					     T)))
	    (for Node in GraphNodes bind NodeID OldToNodeIDs eachtime (BLOCK)
	       unless (LISTP (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node)))
	       when (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of Node))
	       do                                          (* Accumulate the old NodeIDs, possibly virtual, from 
							     the TONODES list.)
		    (SETQ OldToNodeIDs (for ToNode in (fetch (GRAPHNODE TONODES)
							       of Node)
					    collect (if (EQ (CAR ToNode)
								  LINKPARAMS)
							  then (CADR ToNode)
							else ToNode)))

          (* The trick here is to use a virtual node for this ToNode if one was used before, otherwise just the ToNodeID.
	  Also throw in the label nodes that were in the TONODES list before.)


		    (replace (GRAPHNODE TONODES) of Node
		       with (NCONC (for ToNodeID on (
							 NC.ComputeBrowserSavedLinkingInfoForNode
							      NodeID)
					  by (CDDR ToNodeID) eachtime (BLOCK)
					  collect (OR (for OldToNodeID in OldToNodeIDs
							     thereis (AND (LISTP OldToNodeID)
									      (EQ (CAR ToNodeID)
										    (CAR 
										      OldToNodeID))
									      OldToNodeID))
							  (CAR ToNodeID)))
				       (for ToNodeID in OldToNodeIDs eachtime (BLOCK)
					  unless (NC.SameCardP Card (NC.CardFromBrowserNodeID
								     (NC.CoerceToGraphNodeID 
											 ToNodeID)))
					  collect ToNodeID))))
	    (NC.RebuildFromNodesInGraph GraphNodes)
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
			 (FUNCTION NC.GraphCardMiddleButtonFn)
			 NIL T)

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
	    (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
			  (FUNCTION NC.BrowserRightButtonFn))
	    (WINDOWADDPROP Window (QUOTE REPAINTFN)
			     (FUNCTION NC.BrowserRepaintFn)
			     T)
	    (WINDOWPROP Window (QUOTE SCROLLFN)
			  (FUNCTION NC.BrowserScrollFn))
	    (WINDOWPROP Window (QUOTE RESHAPEFN)
			  (FUNCTION NC.BrowserReshapeFn))
	    (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty Card)
	    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
			(FUNCTION NC.TitleBarButtonEventFn))
		  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
				(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
					      (FUNCTION NC.TitleBarButtonEventFn))))
	    (NC.ClearMsg Window T))))

(NC.DrawArrowHead
  (LAMBDA (X1 Y1 X2 Y2 Width Operation Stream Color MidpointFlg XOffset YOffset)
                                                             (* rht: "28-Feb-86 13:14")

          (* * Draw an arrowhead on the end of the line segment from X1,Y1 to X2,Y2.)



          (* * rht 8/12/85: Added check for whether point is inside clipping region before computing arrow head.)



          (* * rht 2/28/86: Now checks for Scale WINDOWPROP on the window. If so, then multiply that in with Scale.
	  We're probably in a shrunken browser in that case.)


    (PROG ((XDiff (FLOAT (IDIFFERENCE X1 X2)))
	     (YDiff (FLOAT (IDIFFERENCE Y1 Y2)))
	     (Window (WINDOWP (WFROMDS Stream)))
	     (Scale (DSPSCALE NIL Stream))
	     LineLength A11 A12 A21 A22 Tmp1 Tmp2 ClippingRegion ArrowHeadXVal ArrowHeadYVal 
	     ArrowHeadLength WindowScale)
	    (OR XOffset (SETQ XOffset 0))
	    (OR YOffset (SETQ YOffset 0))
	    (if (AND Window (SETQ WindowScale (WINDOWPROP Window (QUOTE Scale))))
		then (SETQ Scale (FTIMES Scale WindowScale)))
	    (SETQ ArrowHeadXVal (FIXR (TIMES NC.ArrowHeadXVal Scale)))
	    (SETQ ArrowHeadYVal (FIXR (TIMES NC.ArrowHeadYVal Scale)))
	    (SETQ ArrowHeadLength (FIXR (TIMES NC.ArrowHeadLength Scale)))
	    (COND
	      (MidpointFlg (SETQ XOffset (PLUS XOffset (DIFFERENCE (QUOTIENT (IPLUS X1 X2)
										     2)
									 X2)))
			   (SETQ YOffset (PLUS YOffset (DIFFERENCE (QUOTIENT (IPLUS Y1 Y2)
										     2)
									 Y2)))))
                                                             (* If the point at which the arrow head will be drawn 
							     isn't inside the clipping region together with a 
							     border, then bail out.)
	    (SETQ ClippingRegion (DSPCLIPPINGREGION NIL Stream))
	    (COND
	      ((AND ClippingRegion (NOT (INSIDEP (CREATEREGION (DIFFERENCE
									 (fetch (REGION LEFT)
									    of ClippingRegion)
									 ArrowHeadLength)
								       (DIFFERENCE
									 (fetch (REGION BOTTOM)
									    of ClippingRegion)
									 ArrowHeadLength)
								       (PLUS (fetch (REGION
											  WIDTH)
										  of ClippingRegion)
									       ArrowHeadLength 
									       ArrowHeadLength)
								       (PLUS (fetch (REGION
											  HEIGHT)
										  of ClippingRegion)
									       ArrowHeadLength 
									       ArrowHeadLength))
						       (PLUS X2 XOffset)
						       (PLUS Y2 YOffset))))
		(RETURN)))
	    (SETQ LineLength (SQRT (PLUS (TIMES XDiff XDiff)
					       (TIMES YDiff YDiff))))
	    (SETQ A11 (QUOTIENT (FLOAT XDiff)
				    LineLength))
	    (SETQ A21 (QUOTIENT (FLOAT YDiff)
				    LineLength))
	    (SETQ A12 (MINUS A21))
	    (SETQ A22 A11)
	    (SETQ Tmp1 (TIMES A11 ArrowHeadXVal))
	    (SETQ Tmp2 (TIMES A21 ArrowHeadXVal))
	    (SETQ X2 (PLUS X2 XOffset))
	    (SETQ Y2 (PLUS Y2 YOffset))
	    (DRAWLINE X2 Y2 (PLUS X2 Tmp1 (TIMES A12 ArrowHeadYVal))
			(PLUS Y2 Tmp2 (TIMES A22 ArrowHeadYVal))
			Width Operation Stream Color)
	    (DRAWLINE X2 Y2 (PLUS X2 Tmp1 (TIMES A12 (MINUS ArrowHeadYVal)))
			(PLUS Y2 Tmp2 (TIMES A22 (MINUS ArrowHeadYVal)))
			Width Operation Stream Color))))
)
(* * Rest of stuff below is new for NCBROWSERCARD)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.BrowserOverviewDefaultWidth NC.BrowserOverviewDefaultHeight 
	    NC.LeastScaleForGraphNodeShrinking)
)

(RPAQ? NC.BrowserOverviewDefaultWidth 75)

(RPAQ? NC.BrowserOverviewDefaultHeight 75)

(RPAQ? NC.LeastScaleForGraphNodeShrinking .3)
(DEFINEQ

(NC.MakeBrowserOverviewWin
  (LAMBDA (BrowserWin Region WhereToAttach)                  (* rht: " 3-Mar-86 18:09")

          (* * Make and attach a little window to contain a shrunken bitmap of the entire browser. If Region arg is passed 
	  then use that as size for overview win, else use defaults.)


    (LET ((OverviewWinWidth (if Region
				then (fetch (REGION WIDTH) of Region)
			      else (OR (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth))
					   NC.BrowserOverviewDefaultWidth)))
	  (OverviewWinHeight (if Region
				 then (fetch (REGION HEIGHT) of Region)
			       else (OR (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight))
					    NC.BrowserOverviewDefaultHeight)))
	  (OverviewWin (OPENWP (WINDOWPROP BrowserWin (QUOTE BrowserOverviewWin)))))
         (if OverviewWin
	     then                                          (* If already have an overview window, then just reuse
							     it.)
		    (NC.ReattachBrowserOverviewWinIfNeeded OverviewWin BrowserWin WhereToAttach)
		    (NC.RedrawBrowserOverviewWin OverviewWin BrowserWin WhereToAttach)
	   else                                            (* Shrink enough so that both width and height will 
							     fit in window.)
		  (SETQ OverviewWin (CREATEW (CREATEREGION (fetch (POSITION XCOORD)
								    of NC.OffScreenPosition)
								 (fetch (POSITION YCOORD)
								    of NC.OffScreenPosition)
								 OverviewWinWidth OverviewWinHeight)))
		  (ATTACHWINDOW OverviewWin BrowserWin (OR (CAR WhereToAttach)
							       (QUOTE LEFT))
				  (OR (CDR WhereToAttach)
					(QUOTE TOP))
				  (QUOTE LOCALCLOSE))
		  (WINDOWDELPROP OverviewWin (QUOTE PASSTOMAINCOMS)
				   (QUOTE SHAPEW))
		  (WINDOWPROP BrowserWin (QUOTE BrowserOverviewWin)
				OverviewWin)
		  (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth)
				OverviewWinWidth)
		  (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight)
				OverviewWinHeight)
		  (WINDOWPROP OverviewWin (QUOTE MINSIZE)
				(FUNCTION NC.BrowserOverviewWinMINSIZEFn))
		  (WINDOWPROP OverviewWin (QUOTE MAXSIZE)
				(CONS (fetch (REGION WIDTH) of (WINDOWREGION OverviewWin))
					(fetch (REGION HEIGHT) of (WINDOWREGION OverviewWin))))
		  (NC.RedrawBrowserOverviewWin OverviewWin BrowserWin)))))

(NC.MakeBrowserOverviewWinAtLowerLeft
  (LAMBDA (Window Region)                                    (* rht: "28-Feb-86 12:34")

          (* * Make a browser win and attach to lower part of left edge.)


    (NC.MakeBrowserOverviewWin Window Region (QUOTE (LEFT . BOTTOM)))))

(NC.MakeBrowserOverviewWinAtLeftBottom
  (LAMBDA (Window Region)                                    (* rht: "28-Feb-86 12:35")

          (* * Make a browser win and attach to left part of bottom edge.)


    (NC.MakeBrowserOverviewWin Window Region (QUOTE (BOTTOM . LEFT)))))

(NC.MakeBrowserOverviewWinAtRightBottom
  (LAMBDA (Window Region)                                    (* rht: "28-Feb-86 12:35")

          (* * Make a browser win and attach to right part of bottom edge.)


    (NC.MakeBrowserOverviewWin Window Region (QUOTE (BOTTOM . RIGHT)))))

(NC.ReattachBrowserOverviewWinIfNeeded
  (LAMBDA (OverviewWin BrowserWin WhereToAttach)             (* rht: "28-Feb-86 12:58")

          (* * Check to see if OverviewWin is attached at correct place. If not, detach and reattach.)


    (LET ((WhereAttached (WINDOWPROP OverviewWin (QUOTE WHEREATTACHED))))
         (if (NOT (EQUAL WhereAttached WhereToAttach))
	     then (DETACHWINDOW OverviewWin)
		    (ATTACHWINDOW OverviewWin BrowserWin (OR (CAR WhereToAttach)
								 (QUOTE LEFT))
				    (OR (CDR WhereToAttach)
					  (QUOTE TOP))
				    (QUOTE LOCALCLOSE))
		    (WINDOWDELPROP OverviewWin (QUOTE PASSTOMAINCOMS)
				     (QUOTE SHAPEW))))))
)
(DEFINEQ

(NC.DRAWBOX
  (LAMBDA (Left Bottom Width Height LineWidth Operation Stream)
                                                             (* rht: "27-Feb-86 22:34")

          (* * This really SHOULD be in Interlisp. The one in Koto takes no Operation arg.)


    (DRAWLINE Left Bottom (PLUS Left Width)
		Bottom LineWidth Operation Stream)
    (DRAWLINE (PLUS Left Width)
		Bottom
		(PLUS Left Width)
		(PLUS Bottom Height)
		LineWidth Operation Stream)
    (DRAWLINE (PLUS Left Width)
		(PLUS Bottom Height)
		Left
		(PLUS Bottom Height)
		LineWidth Operation Stream)
    (DRAWLINE Left (PLUS Bottom Height)
		Left Bottom LineWidth Operation Stream)))

(NC.ShrinkGraphToWindow
  (LAMBDA (Graph Window)                                     (* rht: "28-Feb-86 13:05")

          (* * Bitblt's into Window a shrunken bitmap of the graph just big enough to fit.)


    (LET ((GraphWindow (MAINWINDOW Window))
	  (Scale (NC.ComputeOverviewScale Graph Window))
	  (ShrunkenGraph (COPY Graph)))                    (* Shrink the graphnodes.)
         (for GraphNode in (fetch (GRAPH GRAPHNODES) of ShrunkenGraph) eachtime (BLOCK)
	    do (NC.ScaleGraphNode GraphNode Scale GraphWindow))
                                                             (* Display the graph, but temporarily scale the 
							     arrowhead global vars. Will this work compiled?)
         (SHOWGRAPH ShrunkenGraph Window)
         (WINDOWPROP Window (QUOTE Scale)
		       Scale)
         (WINDOWPROP Window (QUOTE GRAPH)
		       ShrunkenGraph))))

(NC.ScaleGraphNode
  (LAMBDA (GraphNode Scale BrowserWin)                       (* rht: "28-Feb-86 01:26")

          (* * Change the position and node label according to Scale.)


    (LET ((OldWidth (fetch (GRAPHNODE NODEWIDTH) of GraphNode))
	  (OldHeight (fetch (GRAPHNODE NODEHEIGHT) of GraphNode))
	  (OldPosition (fetch (GRAPHNODE NODEPOSITION) of GraphNode))
	  NewWidth NewHeight NewBitmap OldBitmap NodeLabel)
         (replace (GRAPHNODE NODEWIDTH) of GraphNode with (SETQ NewWidth
								  (FIX (FTIMES Scale OldWidth))))
         (replace (GRAPHNODE NODEHEIGHT) of GraphNode with (SETQ NewHeight
								   (FIX (FTIMES Scale OldHeight)))
		    )
         (replace (GRAPHNODE NODEPOSITION) of GraphNode
	    with (create POSITION
			     XCOORD ←(FIX (FTIMES Scale (fetch (POSITION XCOORD)
							       of OldPosition)))
			     YCOORD ←(FIX (FTIMES Scale (fetch (POSITION YCOORD)
							       of OldPosition)))))
         (if (LESSP Scale NC.LeastScaleForGraphNodeShrinking)
	     then                                          (* At this scale no need to shrink node label.
							     Just show shaded box.)
		    (SETQ NewBitmap (BITMAPCREATE NewWidth NewHeight))
		    (BLTSHADE GRAYSHADE NewBitmap NIL NIL NewWidth NewHeight)
	   else                                            (* Shrink node label.)
		  (if (SETQ OldBitmap (fetch (GRAPHNODE NODELABELBITMAP) of GraphNode))
		    else (SETQ OldBitmap (BITMAPCREATE OldWidth OldHeight))
			   (SETQ NodeLabel (fetch (GRAPHNODE NODELABEL) of GraphNode))
			   (if (IMAGEOBJP NodeLabel)
			       then (NC.LinkIconDisplayFn NodeLabel (DSPCREATE OldBitmap))
			     else (PRIN1 NodeLabel (DSPCREATE OldBitmap))))
		  (SETQ NewBitmap (SCALEBITMAP OldBitmap Scale)))
         (replace (GRAPHNODE NODELABELBITMAP) of GraphNode with NewBitmap))))

(NC.ComputeOverviewScale
  (LAMBDA (Graph OverviewWin)                                (* rht: "27-Feb-86 12:03")

          (* * Figure out the scale necessary to shrink Graph into OverviewWin.)


    (LET ((GraphRegion (GRAPHREGION Graph)))
         (FMIN (FQUOTIENT (WINDOWPROP OverviewWin (QUOTE WIDTH))
			      (fetch (REGION WIDTH) of GraphRegion))
		 (FQUOTIENT (WINDOWPROP OverviewWin (QUOTE HEIGHT))
			      (fetch (REGION HEIGHT) of GraphRegion))
		 1))))

(NC.RedrawBrowserOverviewWin
  (LAMBDA (OverviewWin BrowserWin)                           (* rht: " 3-Mar-86 14:36")

          (* * The contents of the browser window have changed. Redraw the overview win.)


    (NC.ShrinkGraphToWindow (WINDOWPROP BrowserWin (QUOTE GRAPH))
			      OverviewWin)
    (WINDOWPROP OverviewWin (QUOTE REPAINTFN)
		  (FUNCTION NC.BrowserOverviewWinRepaintFn))
    (WINDOWPROP OverviewWin (QUOTE RESHAPEFN)
		  (FUNCTION NC.BrowserOverviewWinReshapeFn))
    (WINDOWPROP OverviewWin (QUOTE BUTTONEVENTFN)
		  (FUNCTION NC.BrowserOverviewWinButtonEventFn))
    (NC.DrawWireFrameInOverviewWin OverviewWin BrowserWin)))

(NC.DrawWireFrameInOverviewWin
  (LAMBDA (OverviewWin BrowserWin)                           (* rht: "27-Feb-86 22:44")

          (* * Draw a wire frame in the overview win whose size and position within the overview correspond to the size and 
	  position of BrowserWin relative to entire graph.)


    (LET ((WireFrame (for Num in (DSPCLIPPINGREGION NIL BrowserWin)
			bind (Scale ←(WINDOWPROP OverviewWin (QUOTE Scale)))
			collect (FIX (FTIMES Scale Num)))))
                                                             (* Draw the wire frame out on the overview window.)
         (NC.DRAWBOX (fetch (REGION LEFT) of WireFrame)
		       (fetch (REGION BOTTOM) of WireFrame)
		       (fetch (REGION WIDTH) of WireFrame)
		       (fetch (REGION HEIGHT) of WireFrame)
		       1
		       (QUOTE INVERT)
		       OverviewWin)                          (* Stash the new wire frame on windowprop.)
         (WINDOWPROP OverviewWin (QUOTE LastWireFrame)
		       WireFrame))))

(NC.BrowserScrollFn
  (LAMBDA (WINDOW XDELTA YDELTA CONTINUOUSFLG)               (* rht: "27-Feb-86 22:49")

          (* * If there's an overview win, then update its wire frame.)


    (LET ((OverviewWin (WINDOWPROP WINDOW (QUOTE BrowserOverviewWin))))
         (if (OPENWP OverviewWin)
	     then (NC.DrawWireFrameInOverviewWin OverviewWin WINDOW)
		    (SCROLLBYREPAINTFN WINDOW XDELTA YDELTA CONTINUOUSFLG)
		    (NC.DrawWireFrameInOverviewWin OverviewWin WINDOW)
	   else (SCROLLBYREPAINTFN WINDOW XDELTA YDELTA CONTINUOUSFLG)))))

(NC.BrowserReshapeFn
  (LAMBDA (Window OldWinBitmap OldWinRegion)                 (* rht: "27-Feb-86 22:48")

          (* * If there's an overview win, then update its wire frame.)


    (LET ((OverviewWin (WINDOWPROP Window (QUOTE BrowserOverviewWin))))
         (if (OPENWP OverviewWin)
	     then (NC.DrawWireFrameInOverviewWin OverviewWin Window)
		    (RESHAPEBYREPAINTFN Window OldWinBitmap OldWinRegion)
		    (NC.DrawWireFrameInOverviewWin OverviewWin Window)
	   else (RESHAPEBYREPAINTFN Window OldWinBitmap OldWinRegion)))))

(NC.BrowserOverviewWinRepaintFn
  (LAMBDA (OverviewWin Region)                               (* rht: " 3-Mar-86 17:57")

          (* * Recomputes overview.)


    (NC.RedrawBrowserOverviewWin OverviewWin (MAINWINDOW OverviewWin))))

(NC.BrowserOverviewWinReshapeFn
  (LAMBDA (OverviewWin OldWinBitmap OldWinRegion)            (* rht: "28-Feb-86 12:39")

          (* * When overview win is reshaped, we need to recompute its contents from scratch. We detach and reattach in case 
	  user pulled it away from browser edge.)


    (LET ((BrowserWin (MAINWINDOW OverviewWin))
	  (WhereAttached (WINDOWPROP OverviewWin (QUOTE WHEREATTACHED))))
         (DETACHWINDOW OverviewWin)
         (ATTACHWINDOW OverviewWin BrowserWin (OR (CAR WhereAttached)
						      (QUOTE LEFT))
			 (OR (CDR WhereAttached)
			       (QUOTE TOP))
			 (QUOTE LOCALCLOSE))
         (WINDOWDELPROP OverviewWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE SHAPEW))
         (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth)
		       (fetch (REGION WIDTH) of (WINDOWREGION OverviewWin)))
         (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight)
		       (fetch (REGION HEIGHT) of (WINDOWREGION OverviewWin)))
         (WINDOWPROP OverviewWin (QUOTE MAXSIZE)
		       (CONS (fetch (REGION WIDTH) of (WINDOWREGION OverviewWin))
			       (fetch (REGION HEIGHT) of (WINDOWREGION OverviewWin))))
         (NC.RedrawBrowserOverviewWin OverviewWin BrowserWin))))

(NC.BrowserOverviewWinMINSIZEFn
  (LAMBDA (OverviewWin)                                      (* rht: "28-Feb-86 12:54")

          (* * This horrible kludge is so that ATTACHEDWINDOWS sees a different value for MINSIZE depending on whether we're 
	  reshaping the whole browser or just the overview win. In the former case, we want the MINSIZE to be the current 
	  size of the overview win. In the latter, we want it at some small value so user can reduce size of overview win.)


    (LET (Stkpos)
         (PROG1 (if (OR (NULL (SETQ Stkpos (STKPOS (QUOTE SHAPEW))))
			      (NEQ OverviewWin (STKARG (QUOTE WINDOW)
							   (QUOTE SHAPEW)))
			      (SETQ Stkpos (STKPOS (QUOTE RESHAPEALLWINDOWS)
						       NIL NIL Stkpos)))
		      then (LET ((BrowserWin (MAINWINDOW OverviewWin)))
			          (CONS (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth))
					  (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight))))
		    else (QUOTE (20 . 20)))
		  (RELSTK Stkpos)))))

(NC.BrowserOverviewWinButtonEventFn
  (LAMBDA (OverviewWin)                                      (* rht: " 3-Mar-86 17:58")

          (* * Called when user buttons in browser overview window. bring cursor to nearest corner of wire frame and let him 
	  reposition wire frame.)


    (LET ((LastWireFrame (WINDOWPROP OverviewWin (QUOTE LastWireFrame)))
	  NewRegion ScaleReciprocal BrowserWin OldDisplayRegion)
         (SETQ NewRegion (GETBOXREGION (fetch (REGION WIDTH) of LastWireFrame)
					   (fetch (REGION HEIGHT) of LastWireFrame)
					   (PLUS (DSPXOFFSET NIL OverviewWin)
						   (fetch (REGION LEFT) of LastWireFrame))
					   (PLUS (DSPYOFFSET NIL OverviewWin)
						   (fetch (REGION BOTTOM) of LastWireFrame))
					   OverviewWin "Please position browser overview wire frame.")
	   )
         (if (REGIONSINTERSECTP NewRegion (DSPCLIPPINGREGION NIL OverviewWin))
	     then (SETQ BrowserWin (MAINWINDOW OverviewWin))
		    (SETQ ScaleReciprocal (FQUOTIENT 1 (WINDOWPROP OverviewWin (QUOTE Scale)))
		      )                                      (* Where browser used to be.)
		    (SETQ OldDisplayRegion (DSPCLIPPINGREGION NIL BrowserWin)) 
                                                             (* Scroll browser to new region.)
		    (SCROLLW BrowserWin (DIFFERENCE (fetch (REGION LEFT) of OldDisplayRegion)
							(FIX (FTIMES (fetch (REGION LEFT)
									    of NewRegion)
									 ScaleReciprocal)))
			       (DIFFERENCE (fetch (REGION BOTTOM) of OldDisplayRegion)
					     (FIX (FTIMES (fetch (REGION BOTTOM) of NewRegion)
							      ScaleReciprocal))))))))
)
(PUTPROPS SHRUNKENBROWSER COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1905 15515 (NC.SetupTitleBarMenu 1915 . 15513)) (15575 37051 (NC.BringUpBrowserCard 
15585 . 20560) (NC.RelayoutBrowserCard 20562 . 26914) (NC.ConnectNodesInBrowser 26916 . 33496) (
NC.DrawArrowHead 33498 . 37049)) (37409 41550 (NC.MakeBrowserOverviewWin 37419 . 39913) (
NC.MakeBrowserOverviewWinAtLowerLeft 39915 . 40209) (NC.MakeBrowserOverviewWinAtLeftBottom 40211 . 
40507) (NC.MakeBrowserOverviewWinAtRightBottom 40509 . 40808) (NC.ReattachBrowserOverviewWinIfNeeded 
40810 . 41548)) (41551 53284 (NC.DRAWBOX 41561 . 42273) (NC.ShrinkGraphToWindow 42275 . 43227) (
NC.ScaleGraphNode 43229 . 45311) (NC.ComputeOverviewScale 45313 . 45839) (NC.RedrawBrowserOverviewWin 
45841 . 46550) (NC.DrawWireFrameInOverviewWin 46552 . 47632) (NC.BrowserScrollFn 47634 . 48222) (
NC.BrowserReshapeFn 48224 . 48811) (NC.BrowserOverviewWinRepaintFn 48813 . 49065) (
NC.BrowserOverviewWinReshapeFn 49067 . 50406) (NC.BrowserOverviewWinMINSIZEFn 50408 . 51494) (
NC.BrowserOverviewWinButtonEventFn 51496 . 53282)))))
STOP