(FILECREATED " 2-May-86 16:18:11" {QV}<NOTECARDS>1.2K>BROWSEROVERVIEWPATCH.;9 80203  

      changes to:  (FNS NC.RedrawBrowserOverviewWin)

      previous date: "21-Mar-86 16:08:29" {QV}<NOTECARDS>1.2K>BROWSEROVERVIEWPATCH.;8)


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

(PRETTYCOMPRINT BROWSEROVERVIEWPATCHCOMS)

(RPAQQ BROWSEROVERVIEWPATCHCOMS ((* * Stuff following is for making and manipulating the tiny 
				      attached browser overview window.)
	(* * These functions are changed from NCINTERFACE)
	(FNS NC.SetupTitleBarMenu)
	(P (SETQ NC.BrowserTitleBarMiddleButtonMenu NIL))
	(* * These functions are changed from NCBROWSERCARD)
	(FNS NC.BringUpBrowserCard NC.RelayoutBrowserCard NC.ConnectNodesInBrowser NC.DrawArrowHead 
	     NC.DrawFlowerLink NC.BrowserFixGraphEditMenuFn NC.MakeLinksLegendMenu 
	     NC.BrowserFixGraphEditMenuFn NC.GetGraphEditMenu NC.UpdateBrowserCard)
	(* * This function changed from NCUTILITIES)
	(FNS NC.MoveWindowOntoScreen)
	(* * Rest of stuff below is new for NCBROWSERCARD)
	(GLOBALVARS NC.BrowserOverviewDefaultWidth NC.BrowserOverviewDefaultHeight 
		    NC.LeastScaleForGraphNodeShrinking NC.BrowserOverviewSpecsStylesheet 
		    NC.DefaultWhereToAttachOverviewWin NC.DefaultBrowserOverviewMode 
		    NC.OverviewWinMode.Compress NC.OverviewWinMode.Expand)
	(VARS (NC.OverviewWinMode.Compress (QUOTE Compress% Overview% Win))
	      (NC.OverviewWinMode.Expand (QUOTE Expand% Overview))
	      (NC.DefaultBrowserOverviewMode (QUOTE Neither)))
	(INITVARS (NC.BrowserOverviewDefaultWidth 75)
		  (NC.BrowserOverviewDefaultHeight 75)
		  (NC.LeastScaleForGraphNodeShrinking .3)
		  (NC.DefaultWhereToAttachOverviewWin (QUOTE (LEFT . TOP)))
		  (NC.BrowserOverviewSpecsStylesheet (CREATE.STYLE
						       (QUOTE TITLE)
						       "Choose browser overview specs"
						       (QUOTE ITEM.TITLES)
						       (QUOTE (Edge Position% on% Edge Mode))
						       (QUOTE ITEM.TITLE.FONT)
						       (FONTCOPY MENUFONT (QUOTE WEIGHT)
								 (QUOTE BOLD))
						       (QUOTE ITEMS)
						       (LIST (create MENU ITEMS ←
								     (QUOTE ((LEFT LEFT 
								      "Position along left edge.")
									     (TOP TOP 
								       "Position along top edge.")
									     (RIGHT RIGHT 
								     "Position along right edge.")
									     (BOTTOM BOTTOM 
								    "Position along bottom edge."))))
							     (create MENU ITEMS ←
								     (QUOTE ((TOP/RIGHT TOP 
							  "Position at top or right end of edge.")
									     (CENTER CENTER 
								    "Position at center of edge.")
									     (BOTTOM/LEFT BOTTOM 
							    "Position at bottom or left of edge."))))
							     (create MENU ITEMS ←
								     (QUOTE ((Compress% Overview% Win
									       
									  Compress% Overview% Win 
			     "Compress the overview window to exactly fit the overview contents.")
									     (Expand% Overview 
										 Expand% Overview 
			      "Expand the overview contents to exactly fill the overview window.")
									     (Neither Neither 
			 "Neither expand the overview contents nor compress the overview window.")))))
						       )))
	(FNS NC.MakeBrowserOverviewWin NC.ReattachBrowserOverviewWin NC.AskBrowserOverviewSpecs)
	(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 NC.CompressOverviewWin)
	))
(* * Stuff following is for making and manipulating the tiny attached browser overview window.
)

(* * These functions are changed from NCINTERFACE)

(DEFINEQ

(NC.SetupTitleBarMenu
  (LAMBDA (Window ID NoteCardType)                           (* rht: "21-Mar-86 01:19")
                                                             (* 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.)



          (* * rht 3/4/86: Added new browser middle button entry for overview window.)


    (PROG NIL
	    (OR NoteCardType (SETQ NoteCardType (NC.FetchType ID)))
	    (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.ShowPointers)
							   
					   "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.ShowPointers)
							      
					   "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.ShowPointers)
							      
					   "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.")
								  (Change% Overview% Specs
								    (FUNCTION 
								      NC.AskBrowserOverviewSpecs)
								    
			      "Change the browser overview specs: where to attach and what mode.")))
						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)))))))))))
)
(SETQ NC.BrowserTitleBarMiddleButtonMenu NIL)
(* * These functions are changed from NCBROWSERCARD)

(DEFINEQ

(NC.BringUpBrowserCard
  (LAMBDA (ID Substance Region/Position)                     (* rht: " 4-Mar-86 21:07")

          (* * 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 3/4/86: Added WINDOWPROP for SCROLLFN and RESHAPEFN.)


    (LET ((Window (NC.BringUpGraphCard ID Substance Region/Position)))
         (NC.SetupTitleBarMenu Window ID (QUOTE Browser))
         (NC.MakeLinksLegendMenu Window (CAR (LISTGET (NC.RetrievePropList ID)
							    (QUOTE BrowserLinksLegend))))
                                                             (* 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 ID on window now in case REDISPLAYW runs and tries to get ID from window.)


         (WINDOWPROP Window (QUOTE NoteCardID)
		       ID)                                   (* 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 ID Window Substance T)
	     then (REDISPLAYW Window))
     Window)))

(NC.RelayoutBrowserCard
  (LAMBDA (Window)                                           (* rht: " 4-Mar-86 21:04")

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



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


    (PROG (ID RootIDs RootNodes OldToNodePairs Graph GraphNodes PropList BrowserFormat 
		DropVirtualNodesFlg SpecialBrowserSpecs)
	    (NC.PrintMsg Window T "Laying out graph ...")
	    (SETQ ID (NC.IDFromWindow Window))
	    (SETQ PropList (NC.FetchPropList ID))
	    (SETQ RootIDs (MKLIST (CAR (LISTGET PropList (QUOTE BrowserRoots)))))
	    (SETQ BrowserFormat (OR (CAR (LISTGET PropList (QUOTE BrowserFormat)))
					(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 (LISTGET PropList (QUOTE SpecialBrowserSpecs)
								))
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* check graph node size against image box size.)
	    (NC.GraphLinkIconUpdateCheck ID 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 RootNodes (for RootID in RootIDs collect (PACK* ID RootID)))
	    (NC.SetPropListDirtyFlg ID 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
						    (UNION (for Node in GraphNodes
								eachtime (BLOCK)
								when (NULL (fetch (GRAPHNODE
											  FROMNODES)
										  of Node))
								unless (LISTP
									   (fetch (GRAPHNODE NODEID)
									      of Node))
								collect (fetch (GRAPHNODE NODEID)
									     of Node))
							     (INTERSECTION RootNodes GraphNodes))
						    (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 ID (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty ID)
	    (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: " 4-Mar-86 21:05")

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



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


    (PROG (ID LinkLabels Graph GraphNodes PropList BrowserFormat DropVirtualNodesFlg LabelPairs 
		NodeIDs)
	    (SETQ ID (NC.IDFromWindow Window))
	    (SETQ PropList (NC.FetchPropList ID))
	    (SETQ LinkLabels (CAR (LISTGET PropList (QUOTE BrowserLinkLabels))))
	    (SETQ BrowserFormat (CAR (LISTGET PropList (QUOTE BrowserFormat))))
                                                             (* 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)))))
                                                             (* check graph node size against image box size.)
	    (NC.GraphLinkIconUpdateCheck ID 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 (SETPROPLIST (SETQ NodeID (NC.CoerceToGraphNodeID
							    Node))
							NIL)
					 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 RealNodeID
	       do (for Link in (NC.RetrieveToLinks (SETQ RealNodeID
							     (SUBATOM NodeID (ADD1 (NCHARS
											 ID))))
							   PSA.Database)
		       bind DestNodeID eachtime (BLOCK) when (NC.LinkLabelP Link LinkLabels)
		       when (FMEMB (SETQ DestNodeID (PACK* ID (fetch (NOTECARDLINK 
										    DESTINATIONID)
									 of Link)))
				       NodeIDs)
		       do (ADDPROP NodeID DestNodeID (fetch (NOTECARDLINK LINKLABEL)
							    of Link)
				       T))
		    (for Link in (NC.RetrieveFromLinks RealNodeID PSA.Database) bind 
										     SourceNodeID
		       eachtime (BLOCK) when (AND (NC.ReverseLinkLabelP Link LinkLabels)
							  (NOT (NC.LinkLabelP Link LinkLabels)))
		       when (FMEMB (SETQ SourceNodeID (PACK* ID (fetch (NOTECARDLINK 
											 SOURCEID)
									   of Link)))
				       NodeIDs)
		       do (ADDPROP SourceNodeID NodeID (fetch (NOTECARDLINK LINKLABEL)
							      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 in (GETPROPLIST NodeID)
					  by (CDDR ToNodeID) eachtime (BLOCK)
					  collect (OR (FASSOC ToNodeID OldToNodeIDs)
							  ToNodeID))
				       (for ToNodeID in OldToNodeIDs eachtime (BLOCK)
					  unless (EQ ID (SUBATOM (NC.CoerceToGraphNodeID
									 ToNodeID)
								       1
								       (NCHARS ID)))
					  collect ToNodeID))))
	    (NC.RebuildFromNodesInGraph GraphNodes)
	    (SETQ LabelPairs (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 ID (WINDOWPROP Window (QUOTE GRAPH)))
	    (NC.MarkCardDirty ID)
	    (NC.PutProp ID (QUOTE BrowserLinksLegend)
			  (LIST LabelPairs))
	    (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: "20-Mar-86 19:19")

          (* * 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 3/4/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 (AND (DISPLAYSTREAMP Stream)
			    (WINDOWP (WFROMDS Stream))))
	     (Scale (DSPSCALE NIL Stream))
	     WindowScale LineLength A11 A12 A21 A22 Tmp1 Tmp2 ClippingRegion ArrowHeadXVal 
	     ArrowHeadYVal ArrowHeadLength)
	    (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))))

(NC.DrawFlowerLink
  (LAMBDA (X1 Y1 X2 Y2 Brush Dashing Num Stream Width Operation Color)
                                                             (* rht: "21-Mar-86 15:44")

          (* * Draw one link between given points according to given Dashing. If Num is 0, then draw straight line.
	  Otherwise, draw curves above for odd Num and below for even Num, getting wider for bigger values of Num.)



          (* * rht 3/21/86: Now checks for WINDOWPROP of Scale for when we're in a browser overview window.)


    (PROG ((MidpointX (QUOTIENT (IPLUS X1 X2)
				    2))
	     (MidpointY (QUOTIENT (IPLUS Y1 Y2)
				    2))
	     XOffset YOffset Scale Window WindowScale)
	    (COND
	      ((ZEROP Num)
		(DRAWLINE X1 Y1 X2 Y2 Width Operation Stream Color Dashing)
		(AND (NEQ NC.ArrowHeadsInBrowser (QUOTE None))
		       (NC.DrawArrowHead X1 Y1 X2 Y2 Width Operation Stream Color T)))
	      (T                                             (* Check slope of line. If < 45 degrees, then make 
							     spline nodes be vertically removed, otherwise 
							     horizontally removed.)
		 (COND
		   ((GREATERP (ABS (DIFFERENCE X2 X1))
				(ABS (DIFFERENCE Y2 Y1)))
		     (SETQ YOffset (COND
			 ((ODDP Num)
			   (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1 Num)
									     2)))
			 (T (MINUS (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1 Num)
										       2))))))
		     (SETQ XOffset 0))
		   (T (SETQ XOffset (COND
			  ((ODDP Num)
			    (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1 Num)
									      2)))
			  (T (MINUS (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1
											  Num)
											2))))))
		      (SETQ YOffset 0)))
		 (SETQ Scale (DSPSCALE NIL Stream))
		 (SETQ Window (AND (DISPLAYSTREAMP Stream)
				       (WINDOWP (WFROMDS Stream))))
		 (if (AND Window (SETQ WindowScale (WINDOWPROP Window (QUOTE Scale))))
		     then (SETQ Scale (FTIMES Scale WindowScale)))
		 (SETQ XOffset (FIXR (TIMES XOffset Scale)))
		 (SETQ YOffset (FIXR (TIMES YOffset Scale)))
		 (DRAWLINE X1 Y1 (PLUS MidpointX XOffset)
			     (PLUS MidpointY YOffset)
			     Width Operation Stream NIL Dashing)
		 (DRAWLINE (PLUS MidpointX XOffset)
			     (PLUS MidpointY YOffset)
			     X2 Y2 Width Operation Stream NIL Dashing)
		 (AND (NEQ NC.ArrowHeadsInBrowser (QUOTE None))
			(NC.DrawArrowHead X1 Y1 (PLUS MidpointX XOffset)
					    (PLUS MidpointY YOffset)
					    Width Operation Stream Color NIL)))))))

(NC.BrowserFixGraphEditMenuFn
  (LAMBDA (Window)                                           (* rht: " 7-Mar-86 11:20")

          (* * Attach the Graph edit menu to the side of the browser window. Put it below the links legend.)



          (* * rht 9/20/85: Now uses ADDMENU offscreen so it doesn't flash in lower left corner before coming up.)



          (* * rht 3/4/86: Now does some "random" WINDOWPROPS to make reshaping browser not screw up the attached menu.)



          (* * rht 3/7/86: Uses ATTACHMENU to attach the menu.)


    (LET (GraphEditMenu GraphEditMenuWin)
         (SETQ GraphEditMenu (create MENU
					 ITEMS ← NC.GraphEditMenuItems
					 TITLE ← "Editor Menu"
					 WHENSELECTEDFN ←(FUNCTION NC.GraphEditMenuWhenSelectedFn)))
         (PUTMENUPROP GraphEditMenu (QUOTE MAINWINDOW)
			Window)
         (SETQ GraphEditMenuWin (ATTACHMENU GraphEditMenu Window (QUOTE RIGHT)
						(QUOTE BOTTOM)))
                                                             (* Rig so that close of menu won't close browser.)
         (WINDOWDELPROP GraphEditMenuWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE CLOSEW))
         (WINDOWPROP GraphEditMenuWin (QUOTE GRAPHEDITMENUFLG)
		       T)
         (WINDOWADDPROP GraphEditMenuWin (QUOTE CLOSEFN)
			  (FUNCTION (LAMBDA (W)
			      (DETACHWINDOW W)))
			  T))))

(NC.MakeLinksLegendMenu
  (LAMBDA (Win LabelPairs)                                   (* rht: " 7-Mar-86 11:19")

          (* * Build a links legend menu and attach to Win)



          (* * rht 1/10/85: Before starting, kill any old links legend menus for Win.)



          (* * rht 1/13/86: Now holds onto value of PASSTOMAINCOMS windowprop of prompt win and restores after reattaching.)



          (* * rht 1/15/86: Added windowprops MINSIZE and MAXSIZE to fix the bug where reshaping browser screws up links 
	  legend menu.)



          (* * rht 3/4/86: Now calls NC.MoveWindowOntoScreen instead of trying to do that work itself.)



          (* * rht 3/7/86: Now closes prompt window before attaching menu. Uses ATTACHMENU to attach the menu.)


    (PROG (Menu MenuWin PromptWin MainWinPromptInfo PromptWinPASSTOMAINCOMS)
	    (for AttachedWin in (ATTACHEDWINDOWS Win) when (WINDOWPROP AttachedWin
										 (QUOTE 
										  LINKSLEGENDWINP))
	       do (CLOSEW AttachedWin))
	    (SETQ Menu (COND
		(NC.LinkDashingInBrowser (create MENU
						   ITEMS ←(for Pair in LabelPairs
							     join (LIST (CAR Pair)
									    (LIST (QUOTE "  "))))
						   TITLE ←(QUOTE Links)
						   MENUCOLUMNS ← 2))
		(T (create MENU
			     ITEMS ←(for Pair in LabelPairs collect (CAR Pair))
			     TITLE ←(QUOTE Links)
			     MENUCOLUMNS ← 1))))             (* Close the prompt window if open.)
	    (if (SETQ PromptWin (GETPROMPTWINDOW Win NIL NIL T))
		then (CLOSEW PromptWin))                 (* Stick the links legend window at upper right 
							     corner.)
	    (SETQ MenuWin (ATTACHMENU Menu Win (QUOTE RIGHT)
					  (QUOTE TOP)))    (* Rig so that close of menu won't close browser.)
	    (WINDOWDELPROP MenuWin (QUOTE PASSTOMAINCOMS)
			     (QUOTE CLOSEW))
	    (WINDOWADDPROP MenuWin (QUOTE CLOSEFN)
			     (FUNCTION (LAMBDA (W)
				 (DETACHWINDOW W)))
			     T)
	    (WINDOWADDPROP MenuWin (QUOTE REPAINTFN)
			     (QUOTE NC.LinksLegendRepaintFn))
	    (WINDOWADDPROP MenuWin (QUOTE RESHAPEFN)
			     (QUOTE NC.LinksLegendReshapeFn))
	    (WINDOWADDPROP MenuWin (QUOTE LINKSLEGENDWINP)
			     T)
	    (WINDOWPROP Win (QUOTE NCLABELPAIRS)
			  LabelPairs)
	    (NC.MoveWindowOntoScreen Win)
	    (if NC.LinkDashingInBrowser
		then (NC.LinksLegendRepaintFn MenuWin NIL))
	NIL)))

(NC.BrowserFixGraphEditMenuFn
  (LAMBDA (Window)                                           (* rht: " 7-Mar-86 11:20")

          (* * Attach the Graph edit menu to the side of the browser window. Put it below the links legend.)



          (* * rht 9/20/85: Now uses ADDMENU offscreen so it doesn't flash in lower left corner before coming up.)



          (* * rht 3/4/86: Now does some "random" WINDOWPROPS to make reshaping browser not screw up the attached menu.)



          (* * rht 3/7/86: Uses ATTACHMENU to attach the menu.)


    (LET (GraphEditMenu GraphEditMenuWin)
         (SETQ GraphEditMenu (create MENU
					 ITEMS ← NC.GraphEditMenuItems
					 TITLE ← "Editor Menu"
					 WHENSELECTEDFN ←(FUNCTION NC.GraphEditMenuWhenSelectedFn)))
         (PUTMENUPROP GraphEditMenu (QUOTE MAINWINDOW)
			Window)
         (SETQ GraphEditMenuWin (ATTACHMENU GraphEditMenu Window (QUOTE RIGHT)
						(QUOTE BOTTOM)))
                                                             (* Rig so that close of menu won't close browser.)
         (WINDOWDELPROP GraphEditMenuWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE CLOSEW))
         (WINDOWPROP GraphEditMenuWin (QUOTE GRAPHEDITMENUFLG)
		       T)
         (WINDOWADDPROP GraphEditMenuWin (QUOTE CLOSEFN)
			  (FUNCTION (LAMBDA (W)
			      (DETACHWINDOW W)))
			  T))))

(NC.GetGraphEditMenu
  (LAMBDA (Window)                                           (* rht: " 7-Mar-86 11:23")

          (* * Create, if necessary, and bring up the graph editor menu.)


    (PROG ((GraphEditUnfixableMenu (WINDOWPROP Window (QUOTE GRAPHEDITUNFIXABLEMENU)))
	     (GraphEditFixableMenu (WINDOWPROP Window (QUOTE GRAPHEDITFIXABLEMENU)))
	     GraphEditMenuWin)                               (* If menu is already up, then put up a menu without 
							     the FIXMENU option, otherwise, allow user to fix 
							     menu.)
	    (if (for Win in (ATTACHEDWINDOWS Window) thereis (AND (OPENWP Win)
									      (WINDOWPROP
										Win
										(QUOTE 
										 GRAPHEDITMENUFLG))))
		then (OR GraphEditUnfixableMenu
			     (WINDOWPROP Window (QUOTE GRAPHEDITUNFIXABLEMENU)
					   (SETQ GraphEditUnfixableMenu
					     (create MENU
						       ITEMS ← NC.GraphEditMenuItems
						       TITLE ← "Graph Editor Menu"
						       WHENSELECTEDFN ←(FUNCTION 
							 NC.GraphEditMenuWhenSelectedFn)
						       CHANGEOFFSETFLG ← T
						       MENUOFFSET ←(CONS -1 0)))))
		       (PUTMENUPROP GraphEditUnfixableMenu (QUOTE MAINWINDOW)
				      Window)
		       (MENU GraphEditUnfixableMenu)
	      else (OR GraphEditFixableMenu
			   (WINDOWPROP Window (QUOTE GRAPHEDITFIXABLEMENU)
					 (SETQ GraphEditFixableMenu
					   (create MENU
						     ITEMS ← NC.GraphEditUnfixedMenuItems
						     TITLE ← "Graph Editor Menu"
						     WHENSELECTEDFN ←(FUNCTION 
						       NC.GraphEditMenuWhenSelectedFn)
						     CHANGEOFFSETFLG ← T
						     MENUOFFSET ←(CONS -1 0)))))
		     (PUTMENUPROP GraphEditFixableMenu (QUOTE MAINWINDOW)
				    Window)
		     (MENU GraphEditFixableMenu)))))

(NC.UpdateBrowserCard
  (LAMBDA (Window)                                           (* rht: " 7-Mar-86 12:36")

          (* * rht 10/14/84: Added call to DETACHALLWINDOWS to close any existing links legend window and prompt window.
	  Also added call to NC.MakeLinksLegend to make a new attached legend menu.)



          (* * rht 1/15/85: Put hooks for AddNode, AddLink, etc. so editing graph edits underlying structure.)



          (* * rht 2/14/85: Added ability to respecify roots and link labels before recomputing graph.)



          (* * rht 3/8/85: Modified to use new browser props stored on card's proplist as of release 1.2.)



          (* * rht 3/17/85: Now takes OnlyLayoutFlg argument. If set, then don't recompute lattice or ask about root nodes.)



          (* * rht 3/7/86: Now only closes the Links legend menu attached window.)


    (PROG (ID LinkLabels RootIDs RootNodes Lattice LinkIcon Graph GraphNodes NodeLabel PropList 
		BrowserSpecs BrowserFormat DropVirtualNodesFlg Depth SpecialBrowserSpecs LabelPairs 
		OldLabelNodes OldRootIDs)                    (* Get rid of all attached windows except the graph 
							     editor menu if any.)
	    (for Win in (ATTACHEDWINDOWS Window) when (WINDOWPROP Win (QUOTE 
										  LINKSLEGENDWINP))
	       do (DETACHWINDOW Win)
		    (CLOSEW Win))
	    (SETQ ID (NC.IDFromWindow Window))
	    (SETQ PropList (NC.FetchPropList ID))
	    (SETQ LinkLabels (CAR (LISTGET PropList (QUOTE BrowserLinkLabels))))
	    (SETQ RootIDs (MKLIST (CAR (LISTGET PropList (QUOTE BrowserRoots)))))
	    (SETQ BrowserFormat (OR (CAR (LISTGET PropList (QUOTE BrowserFormat)))
					(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 Depth (OR (LISTGET PropList (QUOTE BrowserDepth))
				999999))
	    (SETQ SpecialBrowserSpecs (OR (CAR (LISTGET PropList (QUOTE SpecialBrowserSpecs)
								))
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Get new roots.)
	    (if (OR (NULL RootIDs)
			(NC.YesP (NC.AskUser "Want to respecify roots? " "--" "No" T Window T NIL 
						 T)))
		then (NC.BrowserFlipRoots Window ID GraphNodes (SETQ OldRootIDs RootIDs))
		       (SETQ RootIDs (NC.SelectNoteCards NIL NIL NC.SelectingBrowserSourceMenu 
							     Window NIL (CONCAT 
			    "Please select the Cards and/or Boxes the browser should start from."
										  (CHARACTER 13)
										  
							       "(Current roots are highlighted.)")
							     T))
		       (NC.BrowserFlipRoots Window ID GraphNodes OldRootIDs)
		       (COND
			 ((EQ RootIDs (QUOTE CANCELLED))
			   (RETURN))))
	    (NC.PrintMsg Window T (CHARACTER 13)
			   "Computing browser graph. Please wait. ...")
                                                             (* Compute lattice breadth-first from the roots.)
	    (SETQ Lattice (NC.GrowLinkLattice RootIDs NIL LinkLabels ID PSA.Database Depth))
	    (SETQ RootNodes (for RootID in RootIDs collect (PACK* ID RootID)))
	    (NC.SetPropListDirtyFlg ID T)                  (* Remove all links that are in the old browser graph 
							     but not in the new one)
	    (for Node in GraphNodes bind NodeID Link
	       eachtime (BLOCK)
			  (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
	       unless (FASSOC (OR (CAR NodeID)
					NodeID)
				  Lattice)
	       do (if (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of Node)))
			then (WITH.MONITOR (NC.FetchMonitor PSA.Database)
					     (SETQ Link (NC.FetchLinkFromLinkIcon LinkIcon))
					     (NC.DelToLink Link PSA.Database)
					     (NC.DelFromLink Link PSA.Database T))
		      else                                 (* Collect the label nodes from the old browser.)
			     (SETQ OldLabelNodes (CONS Node OldLabelNodes))))
                                                             (* Create Links for all nodes in the new browser graph
							     but not in the old one.)
	    (for Node in Lattice bind NodeID OldNode eachtime (BLOCK)
	       do (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
		    (COND
		      ((SETQ OldNode (FASSOC NodeID GraphNodes))
			(replace (GRAPHNODE NODELABEL) of Node with (fetch (GRAPHNODE 
											NODELABEL)
									     of OldNode)))
		      (T (replace (GRAPHNODE NODELABEL) of Node
			    with (NC.MakeLinkIcon (NC.MakeLink Window 
								     NC.BrowserContentsLinkLabel
								     (fetch (GRAPHNODE NODELABEL)
									of Node)
								     ID)))))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (REMPROP NodeID (QUOTE TouchedFlg))
		    (REMPROP NodeID (QUOTE VisitedFlg)))
                                                             (* Throw in the label nodes from the old browser.)
	    (SETQ Lattice (NCONC Lattice OldLabelNodes))
                                                             (* For each old label node, take away nonexistent 
							     fromnodes and save the label nodes that no longer have
							     any from nodes.)
	    (for OldLabelNode in OldLabelNodes eachtime (BLOCK)
	       do (replace (GRAPHNODE FROMNODES) of OldLabelNode
		       with (for FromNodeID in (fetch (GRAPHNODE FROMNODES) of OldLabelNode)
				 bind FromNode eachtime (BLOCK) when (SETQ FromNode
									       (FASSOC FromNodeID 
											 Lattice))
				 collect                   (* If the From node isn't a label node, then add to 
							     its Tonode list.)
					   (if (NC.LinkIconImageObjP (fetch (GRAPHNODE 
											NODELABEL)
									    of FromNode))
					       then (replace (GRAPHNODE TONODES) of FromNode
							 with (CONS (fetch (GRAPHNODE NODEID)
									   of OldLabelNode)
									(fetch (GRAPHNODE TONODES)
									   of FromNode))))
					   FromNodeID))      (* For the old label node's ToNodes, just need to 
							     remove any for ToNodes that no longer exist.)
		    (replace (GRAPHNODE TONODES) of OldLabelNode
		       with (for ToNodeID in (fetch (GRAPHNODE TONODES) of OldLabelNode)
				 bind ToNode eachtime (BLOCK) when (SETQ ToNode
									     (FASSOC ToNodeID 
										       Lattice))
				 collect                   (* If the To node isn't a label node, then add to its 
							     FromNode list.)
					   (if (NC.LinkIconImageObjP (fetch (GRAPHNODE 
											NODELABEL)
									    of ToNode))
					       then (replace (GRAPHNODE FROMNODES) of ToNode
							 with (CONS (fetch (GRAPHNODE NODEID)
									   of OldLabelNode)
									(fetch (GRAPHNODE FROMNODES)
									   of ToNode))))
					   ToNodeID)))       (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
	    (SETQ Graph (if (AND Lattice RootNodes)
			      then (LAYOUTGRAPH Lattice (for Node in Lattice bind NodeID
							       eachtime
								(BLOCK)
								(SETQ NodeID
								  (OR (NC.CoerceToGraphNodeID
									  Node)
									(fetch (GRAPHNODE NODEID)
									   of Node)))
							       when
								(OR (FMEMB NodeID RootNodes)
								      (NULL (fetch (GRAPHNODE
											 FROMNODES)
										 of Node)))
							       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)))        (* Build links legend and fix up TONODES in the 
							     graph.)
	    (SETQ LabelPairs (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (NC.PutProp ID (QUOTE BrowserRoots)
			  (LIST RootIDs))
	    (NC.PutProp ID (QUOTE BrowserDepth)
			  Depth)
	    (NC.PutProp ID (QUOTE BrowserLinksLegend)
			  (LIST LabelPairs))
	    (NC.SetPropListDirtyFlg ID T)
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.RelayoutBrowserCard Window))))
)
(* * This function changed from NCUTILITIES)

(DEFINEQ

(NC.MoveWindowOntoScreen
  (LAMBDA (Window)                                           (* rht: " 4-Mar-86 22:44")
                                                             (* Make sure a window and all its attachments are on 
							     the screen.)

          (* * rht 8/28/85: Hacked to handle very big card windows that together with attached windows might be too big to 
	  fit on screen.)



          (* * rht 3/4/86: Changed to use RELMOVEW because otherwise it screws up when there's an attached window on the left
	  or bottom of the window.)


    (PROG (OldWindowRegion NewWindowRegion OldTop OldBottom NewLeft NewTop)
	    (if (AND (WINDOWP Window)
			 (NOT (SUBREGIONP WHOLEDISPLAY (SETQ OldWindowRegion (WINDOWREGION
						  Window)))))
		then (SETQ NewWindowRegion (COPY OldWindowRegion))
		       (SETQ OldTop (fetch (REGION TOP) of NewWindowRegion))
		       (if (GREATERP (fetch (REGION RIGHT) of NewWindowRegion)
					 (fetch (REGION RIGHT) of WHOLEDISPLAY))
			   then (SETQ NewLeft (replace (REGION LEFT) of NewWindowRegion
						     with (DIFFERENCE (fetch (REGION RIGHT)
									     of WHOLEDISPLAY)
									  (fetch (REGION WIDTH)
									     of NewWindowRegion)))))
		       (if (MINUSP (OR NewLeft (fetch (REGION LEFT) of NewWindowRegion)))
			   then (replace (REGION LEFT) of NewWindowRegion with 0))
		       (if (MINUSP (SETQ OldBottom (fetch (REGION BOTTOM) of 
										  NewWindowRegion)))
			   then (replace (REGION BOTTOM) of NewWindowRegion with 0)
				  (SETQ NewTop (PLUS OldTop (MINUS OldBottom))))
		       (if (GREATERP (OR NewTop (fetch (REGION TOP) of NewWindowRegion))
					 (fetch (REGION TOP) of WHOLEDISPLAY))
			   then (replace (REGION BOTTOM) of NewWindowRegion
				     with (DIFFERENCE (fetch (REGION TOP) of WHOLEDISPLAY)
							  (fetch (REGION HEIGHT) of 
										  NewWindowRegion))))
		       (RELMOVEW Window (create POSITION
						    XCOORD ←(DIFFERENCE (fetch (REGION LEFT)
									     of NewWindowRegion)
									  (fetch (REGION LEFT)
									     of OldWindowRegion))
						    YCOORD ←(DIFFERENCE (fetch (REGION BOTTOM)
									     of NewWindowRegion)
									  (fetch (REGION BOTTOM)
									     of OldWindowRegion)))))
      )))
)
(* * Rest of stuff below is new for NCBROWSERCARD)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.BrowserOverviewDefaultWidth NC.BrowserOverviewDefaultHeight 
	    NC.LeastScaleForGraphNodeShrinking NC.BrowserOverviewSpecsStylesheet 
	    NC.DefaultWhereToAttachOverviewWin NC.DefaultBrowserOverviewMode 
	    NC.OverviewWinMode.Compress NC.OverviewWinMode.Expand)
)

(RPAQQ NC.OverviewWinMode.Compress Compress% Overview% Win)

(RPAQQ NC.OverviewWinMode.Expand Expand% Overview)

(RPAQQ NC.DefaultBrowserOverviewMode Neither)

(RPAQ? NC.BrowserOverviewDefaultWidth 75)

(RPAQ? NC.BrowserOverviewDefaultHeight 75)

(RPAQ? NC.LeastScaleForGraphNodeShrinking .3)

(RPAQ? NC.DefaultWhereToAttachOverviewWin (QUOTE (LEFT . TOP)))

(RPAQ? NC.BrowserOverviewSpecsStylesheet (CREATE.STYLE (QUOTE TITLE)
							 "Choose browser overview specs"
							 (QUOTE ITEM.TITLES)
							 (QUOTE (Edge Position% on% Edge Mode))
							 (QUOTE ITEM.TITLE.FONT)
							 (FONTCOPY MENUFONT (QUOTE WEIGHT)
								   (QUOTE BOLD))
							 (QUOTE ITEMS)
							 (LIST (create MENU ITEMS ←
								       (QUOTE ((LEFT LEFT 
								      "Position along left edge.")
									       (TOP TOP 
								       "Position along top edge.")
									       (RIGHT RIGHT 
								     "Position along right edge.")
									       (BOTTOM BOTTOM 
								    "Position along bottom edge."))))
							       (create MENU ITEMS ←
								       (QUOTE ((TOP/RIGHT TOP 
							  "Position at top or right end of edge.")
									       (CENTER CENTER 
								    "Position at center of edge.")
									       (BOTTOM/LEFT BOTTOM 
							    "Position at bottom or left of edge."))))
							       (create MENU ITEMS ←
								       (QUOTE ((
Compress% Overview% Win Compress% Overview% Win 
			"Compress the overview window to exactly fit the overview contents.")
									       (Expand% Overview
										 Expand% Overview 
			      "Expand the overview contents to exactly fill the overview window.")
									       (Neither Neither 
			 "Neither expand the overview contents nor compress the overview window.")))))
							 ))
(DEFINEQ

(NC.MakeBrowserOverviewWin
  (LAMBDA (BrowserWin Region)                                (* rht: "21-Mar-86 01:23")

          (* * 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.)



          (* * rht 3/7/86: Now uses stylesheet to figure out where to attach.)


    (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))))
	  (WhereToAttach (OR (WINDOWPROP BrowserWin (QUOTE WHERETOATTACHOVERVIEWWIN))
			       NC.DefaultWhereToAttachOverviewWin)))
         (if OverviewWin
	   else                                            (* Make a new overview window.)
		  (SETQ OverviewWin (CREATEW (CREATEREGION (fetch (POSITION XCOORD)
								    of NC.OffScreenPosition)
								 (fetch (POSITION YCOORD)
								    of NC.OffScreenPosition)
								 OverviewWinWidth OverviewWinHeight)))
		  (WINDOWPROP BrowserWin (QUOTE BrowserOverviewWin)
				OverviewWin))
         (NC.ReattachBrowserOverviewWin OverviewWin BrowserWin WhereToAttach)
         (NC.RedrawBrowserOverviewWin OverviewWin BrowserWin))))

(NC.ReattachBrowserOverviewWin
  (LAMBDA (OverviewWin BrowserWin WhereToAttach)             (* rht: "20-Mar-86 22:58")

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



          (* * rht 3/7/86: No longer checks. Just reattaches.)


    (LET ((Width (fetch (REGION WIDTH) of (WINDOWREGION OverviewWin)))
	  (Height (fetch (REGION HEIGHT) of (WINDOWREGION OverviewWin))))
         (DETACHWINDOW OverviewWin)
         (ATTACHWINDOW OverviewWin BrowserWin (OR (CAR WhereToAttach)
						      (QUOTE LEFT))
			 (OR (CDR WhereToAttach)
			       (QUOTE TOP))
			 (QUOTE LOCALCLOSE))
         (WINDOWDELPROP OverviewWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE SHAPEW))
         (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth)
		       Width)
         (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight)
		       Height)
         (WINDOWPROP OverviewWin (QUOTE MINSIZE)
		       (FUNCTION NC.BrowserOverviewWinMINSIZEFn))
         (WINDOWPROP OverviewWin (QUOTE MAXSIZE)
		       (CONS Width Height)))))

(NC.AskBrowserOverviewSpecs
  (LAMBDA (BrowserWin)                                       (* rht: "21-Mar-86 01:33")

          (* * Put up stylesheet to get mode and where to attach overview win.)


    (LET ((WhereLastAttached (OR (WINDOWPROP BrowserWin (QUOTE WHERETOATTACHOVERVIEWWIN))
				   NC.DefaultWhereToAttachOverviewWin))
	  (LastMode (OR (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE))
			  NC.DefaultBrowserOverviewMode))
	  OverviewSpecsResults)
         (STYLE.PROP NC.BrowserOverviewSpecsStylesheet (QUOTE SELECTIONS)
		       (LIST (CAR WhereLastAttached)
			       (SELECTQ (CDR WhereLastAttached)
					  ((TOP RIGHT)
					    (QUOTE TOP/RIGHT))
					  ((LEFT BOTTOM)
					    (QUOTE BOTTOM/LEFT))
					  (QUOTE CENTER))
			       LastMode))
         (STYLE.PROP NC.BrowserOverviewSpecsStylesheet (QUOTE POSITION)
		       (create POSITION
				 XCOORD ←(fetch (REGION LEFT) of (WINDOWPROP BrowserWin
										   (QUOTE REGION)))
				 YCOORD ←(fetch (REGION TOP) of (WINDOWREGION BrowserWin))))
         (if (SETQ OverviewSpecsResults (STYLESHEET NC.BrowserOverviewSpecsStylesheet))
	     then (WINDOWPROP BrowserWin (QUOTE WHERETOATTACHOVERVIEWWIN)
				  (CONS (CAR OverviewSpecsResults)
					  (CADR OverviewSpecsResults)))
		    (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE)
				  (CADDR OverviewSpecsResults))
	   else NIL))))
)
(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: "21-Mar-86 00:30")

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



          (* * rht 3/18/86: Now does more intelligent copy of Graph structure, preserving virtual node eq-ness.)



          (* * rht 3/21/86: Now handles XScale and YScale.)


    (LET ((GraphWindow (MAINWINDOW Window))
	  (Scales (NC.ComputeOverviewScale Graph Window))
	  (ShrunkenGraph (create GRAPH using Graph))
	  Scale XScale YScale)
         (if (EQ (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE))
		     NC.OverviewWinMode.Expand)
	     then (SETQ XScale (CAR Scales))
		    (SETQ YScale (CDR Scales))
		    (SETQ Scale (FMIN XScale YScale))
	   else (SETQ Scale (SETQ XScale (SETQ YScale (FMIN (CAR Scales)
								      (CDR Scales))))))
                                                             (* Shrink the graphnodes.)
         (replace (GRAPH GRAPHNODES) of ShrunkenGraph with (for GraphNode
								    in (fetch (GRAPH GRAPHNODES)
									    of ShrunkenGraph)
								    eachtime (BLOCK)
								    collect (NC.ScaleGraphNode
										(create GRAPHNODE
										   using GraphNode)
										Scale XScale YScale 
										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 XScale)
		       XScale)
         (WINDOWPROP Window (QUOTE YScale)
		       YScale)
         (WINDOWPROP Window (QUOTE GRAPH)
		       ShrunkenGraph))))

(NC.ScaleGraphNode
  (LAMBDA (GraphNode Scale XScale YScale BrowserWin)         (* rht: "21-Mar-86 00:20")

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



          (* * rht 3/14/86: Now smashes NODELABEL field of graph node with bitmap rather than NODELABELBITMAP field.)



          (* * rht 3/18/86: Now returns GraphNode.)



          (* * rht 3/21/86: Now scales position using XScale and YScale. But note that new node size still governed by Scale.
	  This is because SCALEBITMAP only takes single 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 XScale (fetch (POSITION XCOORD)
								of OldPosition)))
			     YCOORD ←(FIX (FTIMES YScale (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 NODELABEL) of GraphNode with NewBitmap)
         (replace (GRAPHNODE NODELABELBITMAP) of GraphNode with NIL)
     GraphNode)))

(NC.ComputeOverviewScale
  (LAMBDA (Graph OverviewWin)                                (* rht: "21-Mar-86 00:13")

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



          (* * rht 3/21/86: Now returns both XScale and YScale.)


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

(NC.RedrawBrowserOverviewWin
  (LAMBDA (OverviewWin BrowserWin)                           (* rht: " 2-May-86 16:14")

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



          (* * rht 3/20/86: Now compresses to fit overview if necessary.)


    (NC.ShrinkGraphToWindow (WINDOWPROP BrowserWin (QUOTE GRAPH))
			      OverviewWin)
    (if (EQ (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE))
		NC.OverviewWinMode.Compress)
	then (WINDOWPROP OverviewWin (QUOTE RESHAPEFN)
			     NIL)
	       (NC.CompressOverviewWin OverviewWin BrowserWin))
    (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: "21-Mar-86 00:35")

          (* * 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.)



          (* * rht 3/21/86: Now handles XScale and YScale.)


    (LET ((BrowserClippingRegion (DSPCLIPPINGREGION NIL BrowserWin))
	  (XScale (WINDOWPROP OverviewWin (QUOTE XScale)))
	  (YScale (WINDOWPROP OverviewWin (QUOTE YScale)))
	  WireFrame)
         (SETQ WireFrame (CREATEREGION (FIX (FTIMES XScale (fetch (REGION LEFT)
								      of BrowserClippingRegion)))
					   (FIX (FTIMES YScale (fetch (REGION BOTTOM)
								      of BrowserClippingRegion)))
					   (FIX (FTIMES XScale (fetch (REGION WIDTH)
								      of BrowserClippingRegion)))
					   (FIX (FTIMES YScale (fetch (REGION HEIGHT)
								      of BrowserClippingRegion)))))
                                                             (* 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: "20-Mar-86 21:58")

          (* * 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)))
         (NC.RedrawBrowserOverviewWin OverviewWin BrowserWin)
         (NC.ReattachBrowserOverviewWin OverviewWin BrowserWin (WINDOWPROP OverviewWin
									       (QUOTE WHEREATTACHED)
									       )))))

(NC.BrowserOverviewWinMINSIZEFn
  (LAMBDA (OverviewWin)                                      (* rht: "21-Mar-86 15:17")

          (* * 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 (5 . 5)))
		  (RELSTK Stkpos)))))

(NC.BrowserOverviewWinButtonEventFn
  (LAMBDA (OverviewWin)                                      (* rht: "21-Mar-86 00:43")

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



          (* * rht 3/15/86 Now allows moves of wire frame that increase scrolling region.)



          (* * rht 3/21/86: Now handles XScale and YScale.)


    (LET ((LastWireFrame (WINDOWPROP OverviewWin (QUOTE LastWireFrame)))
	  NewRegion XScaleReciprocal YScaleReciprocal BrowserWin OldDisplayRegion NewLeft NewBottom)
         (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 XScaleReciprocal (FQUOTIENT 1 (WINDOWPROP OverviewWin (QUOTE XScale)
									  )))
		    (SETQ YScaleReciprocal (FQUOTIENT 1 (WINDOWPROP OverviewWin (QUOTE YScale)
									  )))
                                                             (* Where browser used to be.)
		    (SETQ OldDisplayRegion (DSPCLIPPINGREGION NIL BrowserWin)) 
                                                             (* First make sure browser win's EXTENT is big 
							     enough.)
		    (WINDOWPROP BrowserWin (QUOTE EXTENT)
				  (UNIONREGIONS (WINDOWPROP BrowserWin (QUOTE EXTENT))
						  (CREATEREGION
						    (SETQ NewLeft
						      (FIX (FTIMES (fetch (REGION LEFT)
									  of NewRegion)
								       XScaleReciprocal)))
						    (SETQ NewBottom
						      (FIX (FTIMES (fetch (REGION BOTTOM)
									  of NewRegion)
								       YScaleReciprocal)))
						    (fetch (REGION WIDTH) of OldDisplayRegion)
						    (fetch (REGION HEIGHT) of OldDisplayRegion))))
                                                             (* Scroll browser to new region.)
		    (SCROLLW BrowserWin (DIFFERENCE (fetch (REGION LEFT) of OldDisplayRegion)
							NewLeft)
			       (DIFFERENCE (fetch (REGION BOTTOM) of OldDisplayRegion)
					     NewBottom))))))

(NC.CompressOverviewWin
  (LAMBDA (OverviewWin GraphWin)                             (* rht: "21-Mar-86 16:03")

          (* * Reshape OverviewWin so it just holds its contents plus the wire frame.)



          (* * rht 3/21/86: Massive rewrite. Notice ugly use of constant 7 in width of NewRegion. This seems necessary 
	  empirically to keep overview from shrinking with successive redisplays.)


    (LET ((CurCLIPPINGRegion (DSPCLIPPINGREGION NIL OverviewWin))
	  (CurRegion (WINDOWREGION OverviewWin))
	  (WireFrameRegion (WINDOWPROP OverviewWin (QUOTE LastWireFrame)))
	  (GraphRegion (GRAPHREGION (WINDOWPROP OverviewWin (QUOTE GRAPH))))
	  (OverviewWinBorder (WINDOWPROP OverviewWin (QUOTE BORDER)))
	  NewRegion)
         (SETQ NewRegion (create REGION using GraphRegion WIDTH ←(PLUS 7 (fetch
										 (REGION WIDTH)
										    of GraphRegion))
				     ))
         (if (OR (NULL WireFrameRegion)
		     (AND (NOT (EQUAL NewRegion CurCLIPPINGRegion))
			    (REGIONSINTERSECTP WireFrameRegion NewRegion))
		     (PROG1 (SUBREGIONP CurCLIPPINGRegion WireFrameRegion)
			      (SETQ NewRegion (EXTENDREGION NewRegion (INTERSECTREGIONS 
										  WireFrameRegion 
										CurCLIPPINGRegion)))))
	     then (SHAPEW OverviewWin (CREATEREGION (fetch (REGION LEFT) of CurRegion)
							  (fetch (REGION BOTTOM) of CurRegion)
							  (PLUS (TIMES 2 OverviewWinBorder)
								  (fetch (REGION WIDTH)
								     of NewRegion))
							  (PLUS (TIMES 2 OverviewWinBorder)
								  (fetch (REGION HEIGHT)
								     of NewRegion))))
		    (NC.ReattachBrowserOverviewWin OverviewWin GraphWin (WINDOWPROP GraphWin
											(QUOTE
											  
									 WHERETOATTACHOVERVIEWWIN)))))
    ))
)
(PUTPROPS BROWSEROVERVIEWPATCH COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (3759 17092 (NC.SetupTitleBarMenu 3769 . 17090)) (17198 54762 (NC.BringUpBrowserCard 
17208 . 19111) (NC.RelayoutBrowserCard 19113 . 25238) (NC.ConnectNodesInBrowser 25240 . 31553) (
NC.DrawArrowHead 31555 . 35150) (NC.DrawFlowerLink 35152 . 37923) (NC.BrowserFixGraphEditMenuFn 37925
 . 39340) (NC.MakeLinksLegendMenu 39342 . 41922) (NC.BrowserFixGraphEditMenuFn 41924 . 43339) (
NC.GetGraphEditMenu 43341 . 45222) (NC.UpdateBrowserCard 45224 . 54760)) (54814 57391 (
NC.MoveWindowOntoScreen 54824 . 57389)) (59537 63931 (NC.MakeBrowserOverviewWin 59547 . 61238) (
NC.ReattachBrowserOverviewWin 61240 . 62414) (NC.AskBrowserOverviewSpecs 62416 . 63929)) (63932 80112 
(NC.DRAWBOX 63942 . 64654) (NC.ShrinkGraphToWindow 64656 . 66598) (NC.ScaleGraphNode 66600 . 69140) (
NC.ComputeOverviewScale 69142 . 69771) (NC.RedrawBrowserOverviewWin 69773 . 70804) (
NC.DrawWireFrameInOverviewWin 70806 . 72435) (NC.BrowserScrollFn 72437 . 73025) (NC.BrowserReshapeFn 
73027 . 73614) (NC.BrowserOverviewWinRepaintFn 73616 . 73868) (NC.BrowserOverviewWinReshapeFn 73870 . 
74455) (NC.BrowserOverviewWinMINSIZEFn 74457 . 75541) (NC.BrowserOverviewWinButtonEventFn 75543 . 
78204) (NC.CompressOverviewWin 78206 . 80110)))))
STOP