(FILECREATED " 2-Nov-86 01:12:54" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH133.;2 58227  

      changes to:  (FNS NC.UpdateBrowserCard NC.RelayoutBrowserCard NC.ConnectNodesInBrowser 
			NC.UnconnectNodesInBrowser NC.ExpandBrowserNode NC.ChangeBrowserSpecs 
			NC.MakeBrowserOverviewWin NC.AskBrowserOverviewSpecs NC.RelayoutGraphCard 
			NC.RecomputeLinkIndex NC.ChangeLinkIndexSpecs)
		   (VARS RHTPATCH133COMS)

      previous date: " 2-Nov-86 01:06:53" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH133.;1)


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

(PRETTYCOMPRINT RHTPATCH133COMS)

(RPAQQ RHTPATCH133COMS ((* * Fix to bug #256: wrap browser operations with 
			     NC.ProtectedCardOperation so can't close card while they're going on.)
			  (* * Changes to NCBROWSERCARD)
			  (FNS NC.UpdateBrowserCard NC.RelayoutBrowserCard NC.ConnectNodesInBrowser 
			       NC.UnconnectNodesInBrowser NC.ExpandBrowserNode NC.ChangeBrowserSpecs 
			       NC.MakeBrowserOverviewWin NC.AskBrowserOverviewSpecs)
			  (* * Change to NCCARDS)
			  (FNS NC.QuitCard)
			  (* * Change to NCGRAPHCARD)
			  (FNS NC.AddLinkToGraphCard NC.RelayoutGraphCard)
			  (* * Change to NCLINKINDEXCARD)
			  (FNS NC.RecomputeLinkIndex NC.ChangeLinkIndexSpecs)))
(* * Fix to bug #256: wrap browser operations with NC.ProtectedCardOperation so can't close 
card while they're going on.)

(* * Changes to NCBROWSERCARD)

(DEFINEQ

(NC.UpdateBrowserCard
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: " 2-Nov-86 01:10")

          (* * 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 11/17/85: updated to handle new card and notefile objects.)



          (* * kirk 23Jan86 Changed to use NC.AskYesOrNo)



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



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



          (* * rht 6/10/86: Moved code to delete links legend menu and code to make new browser hash array to after 
	  questioning user about respecifying roots.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Recompute% Browser% Card)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation
		    Card Recompute% Browser% Card
		    (PROG (LinkLabels RootCards RootNodes Lattice LinkIcon Graph GraphNodes 
					NodeLabel BrowserSpecs BrowserFormat DropVirtualNodesFlg 
					Depth SpecialBrowserSpecs OldLabelNodes OldRootCards)
			    (SETQ RootCards (NC.FetchBrowserRoots Card))
			    (SETQ LinkLabels (NC.FetchBrowserLinkLabels 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 Depth (OR (NC.FetchBrowserDepth Card)
						999999))
			    (SETQ SpecialBrowserSpecs (OR (NC.FetchSpecialBrowserSpecs Card)
							      (create SPECIALBROWSERSPECS)))
			    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES)
						  of (SETQ Graph (WINDOWPROP Window
										   (QUOTE GRAPH)))))
                                                             (* Get new roots.)
			    (if (OR (NULL RootCards)
					(NC.AskYesOrNo "Want to respecify roots? " "--" "No" T 
							 Window T NIL))
				then (NC.BrowserFlipRoots Window Card GraphNodes (SETQ 
								OldRootCards RootCards))
				       (SETQ RootCards (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 Card GraphNodes OldRootCards)
				       (COND
					 ((EQ RootCards (QUOTE CANCELLED))
					   (RETURN))))     (* Get rid of the links legend menu attached window.)
			    (for Win in (ATTACHEDWINDOWS Window) when (WINDOWPROP
										Win
										(QUOTE 
										  LINKSLEGENDWINP))
			       do (DETACHWINDOW Win)
				    (CLOSEW Win))          (* Smash the current hash array, putting a fresh one 
							     in its place.)
			    (NC.GetBrowserHashArray Card)
			    (NC.PrintMsg Window T (CHARACTER 13)
					   "Computing browser graph. Please wait. ...")
                                                             (* Compute lattice breadth-first from the roots.)
			    (SETQ Lattice (NC.GrowLinkLattice RootCards NIL LinkLabels Card Depth)
			      )
			    (SETQ RootNodes (for RootCard in RootCards collect (
									      NC.GetBrowserNodeID
											 Card 
											 RootCard)))
			    (NC.SetPropListDirtyFlg Card 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 (NC.DeleteLink (NC.FetchLinkFromLinkIcon LinkIcon)
								T 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)
									Card)))))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
				    (NC.GraphNodeIDRemProp NodeID (QUOTE TouchedFlg))
				    (NC.GraphNodeIDRemProp 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.)
			    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window 
									      DropVirtualNodesFlg))
			    (NC.SetBrowserRoots Card RootCards)
			    (NC.SetBrowserDepth Card Depth)
			    (WINDOWPROP Window (QUOTE GRAPH)
					  Graph)
			    (NC.RelayoutBrowserCard Window T)))))))

(NC.RelayoutBrowserCard
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: " 2-Nov-86 01:10")

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



          (* * rht 5/8/86: Added calls to rig title bar properly.)



          (* * fgh 6/30/86 Added NC.GRAPHERCOPYBUTTONEVENTFN to SHOWGRAPH call)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Relayout% Browser% Card)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation
		    Card Relayout% Browser% Card
		    (PROG (RootCards RootNodeIDs OldToNodePairs Graph GraphNodes BrowserFormat 
				       DropVirtualNodesFlg SpecialBrowserSpecs)
			    (NC.PrintMsg Window T "Laying out graph ...")
			    (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 (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN))

          (* * 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)
			    (NC.InstallTitleBarButtonEventFn Window (FUNCTION 
								 NC.GraphTitleBarButtonEventFn))
			    (NC.ClearMsg Window T)))))))

(NC.ConnectNodesInBrowser
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: " 2-Nov-86 01:11")

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



          (* * fgh 5/21/86 Updated reinstallation of title bar menus after SHOWGRAPH to use new title bar menu mechanism.)



          (* * rht 6/10/86: Now calls NC.ShowBrowserGraph.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Reconnect% Browser% Card)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation
		    Card Reconnect% Browser% Card
		    (PROG (LinkLabels Graph GraphNodes BrowserFormat DropVirtualNodesFlg NodeIDs)
			    (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))
                                                             (* Display the graph.)
			    (NC.ShowBrowserGraph Graph Window)
			    (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
			    (NC.MarkCardDirty Card)
			    (NC.ClearMsg Window T)))))))

(NC.UnconnectNodesInBrowser
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: " 2-Nov-86 01:11")

          (* * Remove all the links in the browser.)



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



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



          (* * fgh 5/21/86 Updated reinstallation of title bar menus after SHOWGRAPH to use new title bar menu mechanism.)



          (* * rht 6/10/86: Now calls NC.ShowBrowserGraph.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Unconnect% Browser% Card)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation Card Unconnect% Browser% Card
					     (PROG (Graph GraphNodes BrowserFormat 
							    DropVirtualNodesFlg)
						     (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)))))
                                                             (* smash all the nodeID's proplists and TONODES 
							     fields.)
						     (for Node in GraphNodes bind NodeID
							unless (PROGN
								   (BLOCK)
								   (LISTP (SETQ NodeID
									      (fetch (GRAPHNODE
											 NODEID)
										 of Node))))
							do (NC.SmashGraphNodeIDProps NodeID)
							     (replace (GRAPHNODE TONODES)
								of Node with NIL)
							     (replace (GRAPHNODE FROMNODES)
								of Node with NIL))
						     (NC.MakeLinksLegend Graph Window 
									   DropVirtualNodesFlg)
                                                             (* Display the graph.)
						     (NC.ShowBrowserGraph Graph Window)
						     (NC.SetSubstance Card (WINDOWPROP
									  Window
									  (QUOTE GRAPH)))
						     (NC.MarkCardDirty Card)
						     (NC.SetBrowserLinksLegend Card NIL)
						     (NC.ClearMsg Window T)))))))

(NC.ExpandBrowserNode
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: " 2-Nov-86 01:11")

          (* * Ask user to choose a node in the browser and recompute the part of the lattice under that node to the given 
	  depth. And relayout the graph. The code is just a modification of the NC.UpdateBrowserCard code.)



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



          (* * rht 6/10/86: No longer does relayout after expand. Uses NC.LayoutNewBrowserNodes to compute proper locations 
	  of new nodes. Also calls NC.ShowBrowserGraph.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Expand% Node% of% Browser% Card)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation
		    Card Expand% Node% of% Browser% Card
		    (PROG (NodeToExpand LinkLabels RootCards RootNodes Lattice LinkIcon 
					  OldToNodePairs Graph GraphNodes NodeLabel OldNode Link 
					  BrowserSpecs BrowserFormat DropVirtualNodesFlg Depth 
					  SpecialBrowserSpecs SavedLabelNodes NewNodes)
			    (SETQ RootCards (NC.FetchBrowserRoots Card))
			    (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 SpecialBrowserSpecs (OR (NC.FetchSpecialBrowserSpecs Card)
							      (create SPECIALBROWSERSPECS)))
			    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES)
						  of (SETQ Graph (WINDOWPROP Window
										   (QUOTE GRAPH)))))
                                                             (* If there aren't any nodes in graph, then get out 
							     pronto.)
			    (if (NULL GraphNodes)
				then (NC.PrintMsg Window T "No nodes to expand.")
				       (DISMISS 1000)
				       (NC.ClearMsg Window T)
				       (RETURN NIL))       (* Create hash array if haven't already.)
			    (NC.GetBrowserHashArray Card Graph)
			    (NC.PrintMsg Window T "Pick node to expand." (CHARACTER 13))
                                                             (* Note call to the grapher function READ/NODE to 
							     select a graph node.)
			    (SETQ NodeToExpand (READ/NODE GraphNodes Window))
                                                             (* Can't expand a label node.)
			    (if (NOT (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL)
								    of NodeToExpand)))
				then (NC.PrintMsg NIL T "Sorry, can't expand a label node.")
				       (FLASHW PROMPTWINDOW)
				       (NC.ClearMsg Window T)
				       (RETURN))
			    (SETQ Depth (MKATOM (NC.AskUser 
							"Depth to expand (type integer or INF): "
								  "--" 1 T Window NIL NIL T)))
			    (COND
			      ((EQ Depth (QUOTE INF))
				(SETQ Depth MAX.FIXP))
			      ((NOT (AND (FIXP Depth)
					     (GREATERP Depth 0)))
				(NC.PrintMsg Window T 
					       "Depth must be an integer greater than 0 or INF.")
				(RETURN)))
			    (NC.PrintMsg Window T (CHARACTER 13)
					   "Augmenting browser graph. Please wait. ...")
                                                             (* Save the nodes pointed to by the chosen node that 
							     are label nodes. GrowLinkLattice will trash those, so 
							     we restore afterwards.)
			    (SETQ SavedLabelNodes (for ToNode in (fetch (GRAPHNODE TONODES)
									  of NodeToExpand)
						       eachtime (BLOCK)
						       when (AND (NOT (EQ (CAR ToNode)
										  LINKPARAMS))
								     (NOT (NC.LinkIconImageObjP
									      ToNode)))
						       collect ToNode))
                                                             (* Increase link lattice from chosen node to given 
							     depth.)
			    (SETQ Lattice (NC.GrowLinkLattice (LIST (NC.CardFromBrowserNodeID
									    (fetch (GRAPHNODE
										       NODEID)
									       of NodeToExpand)))
								  (APPEND GraphNodes)
								  LinkLabels Card Depth))
			    (AND SavedLabelNodes (replace (GRAPHNODE TONODES) of NodeToExpand
						      with (APPEND SavedLabelNodes
								       (fetch (GRAPHNODE TONODES)
									  of NodeToExpand))))
			    (SETQ RootNodes (for RootCard in RootCards collect (
									      NC.GetBrowserNodeID
											 Card 
											 RootCard)))
			    (NC.SetPropListDirtyFlg Card T)
                                                             (* Create Links for all nodes in the new browser graph
							     but not in the old one.)
			    (for Node in Lattice bind NodeID
			       do (COND
				      ((SETQ OldNode (FASSOC (SETQ NodeID
								   (OR (NC.CoerceToGraphNodeID
									   Node)
									 (fetch (GRAPHNODE NODEID)
									    of Node)))
								 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)
									Card)))
                                                             (* Make a list of all new nodes.)
					 (push NewNodes Node)))
                                                             (* Throw away virtual node info.)
				    (AND NodeID (replace (GRAPHNODE NODEID) of Node
						     with NodeID))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
				    (NC.GraphNodeIDRemProp NodeID (QUOTE TouchedFlg))
				    (NC.GraphNodeIDRemProp NodeID (QUOTE VisitedFlg)) 
                                                             (* Smash all the unnecessary junk off existing nodes, 
							     letting LAYOUTGRAPH and NC.MakeLinksLegend recompute.)
				    (replace (GRAPHNODE TONODES) of Node
				       with (for ToNode in (fetch (GRAPHNODE TONODES)
								    of Node)
						 bind ToNodeID eachtime (BLOCK)
						 collect (if (SETQ ToNodeID (
								     NC.CoerceToGraphNodeID ToNode))
							       then
                                                             (* Throw away link parameterlist info.)
                                                             (* Throw away link dashing info.)
								(NC.GraphNodeIDPutProp
								  NodeID ToNodeID
								  (for LabelPair
								     in (NC.GraphNodeIDGetProp
									    NodeID ToNodeID)
								     collect (OR (CAR LabelPair)
										     LabelPair)))
								(NC.GraphNodeIDPutProp
								  ToNodeID NodeID
								  (for LabelPair
								     in (NC.GraphNodeIDGetProp
									    ToNodeID NodeID)
								     collect (OR (CAR LabelPair)
										     LabelPair)))
								ToNodeID
							     else ToNode))))
                                                             (* LAYOUTGRAPH doesn't like duplicate nodes.
							     These get created when virtual nodes are turned into 
							     regular nodes.)
			    (SETQ Lattice (NC.RemoveDuplicateNodesFromGraph Lattice))
			    (NC.RebuildFromNodesInGraph Lattice)
			    (AND NewNodes (NC.LayoutNewBrowserNodes NodeToExpand NewNodes 
									BrowserFormat 
									SpecialBrowserSpecs))
			    (replace (GRAPH GRAPHNODES) of Graph with Lattice)
                                                             (* Build links legend and fix up TONODES in the 
							     graph.)
			    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window 
									      DropVirtualNodesFlg))
			    (WINDOWPROP Window (QUOTE GRAPH)
					  Graph)             (* Display the graph.)
			    (NC.ShowBrowserGraph Graph Window)
			    (NC.SetSubstance Card Graph)
			    (NC.MarkCardDirty Card)
			    (NC.ClearMsg Window T)))))))

(NC.ChangeBrowserSpecs
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: " 2-Nov-86 01:11")

          (* * Change the values of the various browser specs including link types, browser format, search depth, etc.)



          (* * rht 11/17/85: Updated for new card and notefile objects.)



          (* * rht 2/7/86: Now sets and gets browser link labels, etc. via fetch/set fns.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Browser% Specs)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation Card Browser% Specs
					     (PROG (LinkLabels RootNodes BrowserSpecs BrowserFormat 
								 Depth)
						     (SETQ LinkLabels (NC.FetchBrowserLinkLabels
							 Card))
						     (SETQ BrowserFormat (NC.FetchBrowserFormat
							 Card))
						     (SETQ Depth (NC.FetchBrowserDepth Card))
						     (SETQ BrowserSpecs
						       (NC.AskBrowserSpecs Window Card LinkLabels 
									     Depth BrowserFormat))
						     (SETQ LinkLabels (CAR BrowserSpecs))
						     (SETQ Depth (CADR BrowserSpecs))
						     (SETQ BrowserFormat (CADDR BrowserSpecs))
						     (NC.SetPropListDirtyFlg Card T)
						     (NC.SetBrowserLinkLabels Card LinkLabels)
						     (NC.SetBrowserFormat Card BrowserFormat)
						     (NC.SetBrowserDepth Card Depth)
						     (NC.ClearMsg Window T)))))))

(NC.MakeBrowserOverviewWin
  (LAMBDA (BrowserWin Region DontCheckOpInProgressFlg)       (* rht: " 2-Nov-86 01:11")

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



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard BrowserWin))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg BrowserWin (QUOTE Build% Browser% Overview)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation Card Build% Browser% Overview
					     (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.AskBrowserOverviewSpecs
  (LAMBDA (BrowserWin DontCheckOpInProgressFlg)              (* rht: " 2-Nov-86 01:12")

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



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard BrowserWin))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg BrowserWin (QUOTE Browser% Overview% Specs)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation Card Browser% Overview% Specs
					     (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)))))))
)
(* * Change to NCCARDS)

(DEFINEQ

(NC.QuitCard
  (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg DontRecacheFlg DontCheckOpInProgressFlg 
			  InterestedWindow OperationMsg QuietFlg Don'tDeactivateFlg)
                                                             (* rht: " 2-Nov-86 00:34")

          (* * Force note card specified by ID to quit or stop)



          (* * rht 2/9/85: New arg DontSaveFlg prevents NC.CardSaveFn from being called. Used when aborting a card.
	  This is NOT equivalent to NC.QuitWithoutSaving.)



          (* * rht 6/25/85: Now moves card off screen before saving if NC.CloseCardsOffScreenFlg is non-nil.)



          (* * rht 6/25/85: Brought the insure proper filing check back here from NC.CardSaveFn. Bails out if user cancelled 
	  operation inside of NC.InsureProperFiling)



          (* * fgh 11/11/85: Updated to handle CardID and CardInfo objects.)



          (* * fgh 1/16/86 Put in code to insure that if one of the TopLevelCards is quit then it is reactivated immedialtely
	  to make sure it stays cached for fast access.)



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



          (* * fgh 5/2/86 Added DontRecacheFlg arg)



          (* * fgh 6/9/86 Added code to check to make sure other operations are not in progress. And DontCheckOpInProgressFlg
	  arg to match)



          (* * fgh 6/26/86 Added InterestedWindow & OperationMsg arg.)



          (* * rht 7/2/86: Now bails out if notefile is readonly, user confirms, but we're supposed to write down changes.)



          (* * rht 7/13/86: Now takes QuietFlg arg.)



          (* * rht 7/14/86: Call NC.DeactivateCard from here instead of in card type QuitFn. Take a Don'tDeactivateFlg as 
	  well.)



          (* * rht 10/7/86: Now removes DELETEME imageobj's from card substance.)



          (* * rht 11/2/86: Now returns DON'T if operation in progress.)


    (DECLARE (GLOBALVARS NC.RemoveDELETEMEImageObjsFromCardFlg))
    (PROG ((Card (NC.CoerceToCard CardIdentifier))
	     Window OperationInProgress ReadOnlyCardFlg)
	    (SETQ Window (NC.FetchWindow Card))
	    (OR InterestedWindow (SETQ InterestedWindow Window))
	    (SETQ ReadOnlyCardFlg (NC.ReadOnlyCardP Card))
                                                             (* The window not being open should mean that it's 
							     shrunken. If so, expand it.)
	    (COND
	      ((AND Window (NOT (OPENWP Window)))
		(EXPANDW Window)))

          (* * if in the middle of some other operation, get out of here.)


	    (if (AND (NULL DontCheckOpInProgressFlg)
			 (SETQ OperationInProgress (NC.OperationInProgress Card)))
		then (NC.PrintOperationInProgressMsg Window "Close Card" OperationInProgress)
		       (RETURN (QUOTE DON'T)))

          (* * if proper filing says don't quit then get out)


	    (OR DontSaveFlg ReadOnlyCardFlg (COND
		    ((EQ (NC.InsureProperFiling Card)
			   (QUOTE CANCELLED))
		      (RETURN (QUOTE DON'T)))))

          (* * If card is readonly but we've made changes that we're supposed to save, then get user confirmation and bail 
	  out.)


	    (if (AND (NOT DontSaveFlg)
			 (NOT Don'tDeactivateFlg)
			 ReadOnlyCardFlg
			 (NC.CardSomehowDirtyP Card)
			 (NULL QuietFlg)
			 (NOT (PROGN (NC.PrintMsg InterestedWindow T 
					       "Card has been changed, but notefile is readonly."
							(CHARACTER 13))
					 (NC.AskYesOrNo "Want to quit anyway, flushing changes? " 
							  NIL (QUOTE Yes)
							  NIL InterestedWindow))))
		then (RETURN (QUOTE DON'T)))

          (* * Otherwise go ahead and quit)


	    (RETURN (NC.ProtectedCardOperation Card Close% Card (COND
						   ((AND Window NC.CloseCardsOffScreenFlg)
						     (COND
						       ((NOT (NC.FetchSavedRegion Card))
							 (NC.SetSavedRegion Card
									      (WINDOWPROP
										Window
										(QUOTE REGION)))))
						     (MOVEW Window 1500 1500)))
						 (OR DontSaveFlg
						       (if ReadOnlyCardFlg
							   then (NC.TurnOffDirtyFlgs Card)
							 else (AND 
							    NC.RemoveDELETEMEImageObjsFromCardFlg
								       (
							       NC.RemoveDELETEMEImageObjsFromCard
									 Card
									 (FUNCTION 
									   NC.DELETEMEImageObjP)))
								(NC.CardSaveFn Card
										 (OR 
									NC.CloseCardsOffScreenFlg 
										       QuietFlg)
										 NIL InterestedWindow 
										 OperationMsg)))
						 (AND Window (WINDOWDELPROP
							  Window
							  (QUOTE CLOSEFN)
							  (FUNCTION NC.QuitCard)))
						 (PROG1 (NC.ApplyFn QuitFn Card)
							  (AND CallCloseWFlg Window (CLOSEW
								   Window))
							  (OR Don'tDeactivateFlg (
								  NC.DeactivateCard Card))

          (* * if this is one of the top level cards, then make sure it stays cached)


							  (if (AND (NC.TopLevelCardP Card)
								       (NULL DontRecacheFlg)
								       (NULL Don'tDeactivateFlg))
							      then (NCP.ActivateCards Card))))))))
)
(* * Change to NCGRAPHCARD)

(DEFINEQ

(NC.AddLinkToGraphCard
  (LAMBDA (Window LinkOrLinkLabel DestinationCard)           (* rht: " 2-Nov-86 00:41")
                                                             (* Add a NOTECARD link to a graph card.
							     Pass the fact that this is a link-add to 
							     NC.GraphAddNodeFn via the NoteCardInsertingLink window
							     property)

          (* * rht 4/7/86: Now can handle insertion of multiple links by accepting label and/or destination card args.
	  Either or both can be nil.)



          (* * rht 11/2/86: Now checks result of NC.MakeLink before proceeding.)


    (LET ((Link (if (type? Link LinkOrLinkLabel)
		    then LinkOrLinkLabel
		  else (NC.MakeLink Window LinkOrLinkLabel DestinationCard))))
         (if Link
	     then (WINDOWPROP Window (QUOTE NoteCardInsertingLink)
				  Link)
		    (EDITADDNODE Window)))))

(NC.RelayoutGraphCard
  (LAMBDA (Win DontCheckOpInProgressFlg)                     (* rht: " 2-Nov-86 01:12")

          (* * Relayout the graph by making roots out of all nodes without FROMNODES.)



          (* * rht 8/15/86: Now uses proper COPYBUTTONEVENTFN in the SHOWGRAPH call.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard Win))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Win (QUOTE Relayout% Graph% Card)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation
		    Card Relayout% Graph% Card
		    (LET ((Graph (WINDOWPROP Win (QUOTE GRAPH)))
			  GraphNodes)
		         (if (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of Graph))
			     then (SETQ Graph (LAYOUTGRAPH
					GraphNodes
					(OR (for Node in GraphNodes
						 when (NULL (fetch (GRAPHNODE FROMNODES)
								   of Node))
						 collect (fetch (GRAPHNODE NODEID) of Node))
					      (fetch (GRAPHNODE NODEID) of (CAR GraphNodes)))
					(QUOTE Lattice)))
				    (replace (GRAPH GRAPH.ADDNODEFN) of Graph
				       with (FUNCTION NC.GraphAddNodeFn))
				    (replace (GRAPH GRAPH.DELETENODEFN) of Graph
				       with (FUNCTION NC.GraphDeleteNodeFn))
				    (replace (GRAPH GRAPH.ADDLINKFN) of Graph
				       with (FUNCTION NC.GraphAddLinkFn))
				    (replace (GRAPH GRAPH.DELETELINKFN) of Graph
				       with (FUNCTION NC.GraphDeleteLinkFn))
				    (replace (GRAPH GRAPH.MOVENODEFN) of Graph
				       with (FUNCTION NC.GraphMoveNodeFn))
				    (replace (GRAPH GRAPH.FONTCHANGEFN) of Graph
				       with (FUNCTION NC.GraphFontChangeFn))
				    (SHOWGRAPH Graph Win (FUNCTION NC.GraphCardLeftButtonFn)
						 (FUNCTION NC.GraphCardMiddleButtonFn)
						 NIL T (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN))
				    (NC.InstallTitleBarButtonEventFn Win (FUNCTION 
								    NC.GraphTitleBarButtonEventFn)))))
	       ))))
)
(* * Change to NCLINKINDEXCARD)

(DEFINEQ

(NC.RecomputeLinkIndex
  (LAMBDA (WindowOrTextStream DontCheckOpInProgressFlg)      (* rht: " 2-Nov-86 01:12")

          (* * Recompute the contents of the link index card. Modeled after NC.UpdateBrowserCard.)



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



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard WindowOrTextStream))
	  Window OperationInProgress)
         (SETQ Window (NC.FetchWindow Card))

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Recompute% LinkIndex)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation Card Recompute% LinkIndex
					     (PROG (LinkLabels BackLinksFlg PropList BrowserSpecs 
								 TextStream)
						     (SETQ TextStream (TEXTSTREAM 
									       WindowOrTextStream))
						     (SETQ PropList (NC.FetchPropList Card))
						     (SETQ LinkLabels (CAR (LISTGET
										 PropList
										 (QUOTE 
									      LinkIndexLinkLabels))))
						     (SETQ BackLinksFlg (LISTGET PropList
										     (QUOTE 
									    LinkIndexBackLinksFlg)))
						     (NC.PrintMsg Window T 
							"Clearing old contents of link index ..."
								    (CHARACTER 13))
						     (TEDIT.DELETE TextStream
								     (TEDIT.SETSEL
								       TextStream 1
								       (fetch (TEXTOBJ TEXTLEN)
									  of (TEXTOBJ TextStream))
								       ))
						     (NC.PrintMsg Window NIL "Done." (CHARACTER
								      13))
						     (NC.ComputeLinkIndex Card LinkLabels 
									    BackLinksFlg)
						     (NC.ClearMsg Window T)))))))

(NC.ChangeLinkIndexSpecs
  (LAMBDA (WindowOrTextStream DontCheckOpInProgressFlg)      (* rht: " 2-Nov-86 01:12")

          (* * Change the values of the various link index specs including link types and back links flag.)



          (* * rht 9/19/86: Changed to pass Card rather than Window to NC.AskLinkIndexSpecs.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)


    (LET ((Card (NC.CoerceToCard WindowOrTextStream))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg (NC.FetchWindow Card)
						      (QUOTE LinkIndex% Specs)
						      OperationInProgress)
		    NIL
	   else (NC.ProtectedCardOperation Card LinkIndex% Specs
					     (LET (LinkLabels BackLinksFlg PropList LinkIndexSpecs)
					          (SETQ PropList (NC.FetchPropList Card))
					          (SETQ LinkLabels (CAR (LISTGET PropList
										       (QUOTE
											 
									      LinkIndexLinkLabels))))
					          (SETQ BackLinksFlg (LISTGET PropList
										  (QUOTE 
									    LinkIndexBackLinksFlg)))
					          (SETQ LinkIndexSpecs (NC.AskLinkIndexSpecs
						      Card LinkLabels BackLinksFlg))
					          (SETQ LinkLabels (CAR LinkIndexSpecs))
					          (SETQ BackLinksFlg (CADR LinkIndexSpecs))
					          (NC.SetPropListDirtyFlg Card T)
					          (NC.PutProp Card (QUOTE LinkIndexLinkLabels)
								(LIST LinkLabels))
					          (NC.PutProp Card (QUOTE LinkIndexBackLinksFlg)
								BackLinksFlg)
					          (NC.ClearMsg (NC.FetchWindow Card)
								 T)))))))
)
(PUTPROPS RHTPATCH133 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1421 45464 (NC.UpdateBrowserCard 1431 . 12321) (NC.RelayoutBrowserCard 12323 . 19458) (
NC.ConnectNodesInBrowser 19460 . 26372) (NC.UnconnectNodesInBrowser 26374 . 29222) (
NC.ExpandBrowserNode 29224 . 38309) (NC.ChangeBrowserSpecs 38311 . 40169) (NC.MakeBrowserOverviewWin 
40171 . 42874) (NC.AskBrowserOverviewSpecs 42876 . 45462)) (45495 50802 (NC.QuitCard 45505 . 50800)) (
50837 54193 (NC.AddLinkToGraphCard 50847 . 51776) (NC.RelayoutGraphCard 51778 . 54191)) (54232 58145 (
NC.RecomputeLinkIndex 54242 . 56224) (NC.ChangeLinkIndexSpecs 56226 . 58143)))))
STOP