(FILECREATED "20-Sep-86 01:26:07" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH109.;5 29500  

      changes to:  (VARS RHTPATCH109COMS)
		   (FNS NC.CardBeingEditedP NC.DelReferencesToCard NC.MakeLinkIndex 
			NC.MakeBrowserCard NC.MakeGraphCard NC.MakeSketchCard NC.MakeNewCardWindow 
			NC.MakeTEditCard NC.MakeFileBox NCP.CoerceToLinkDisplayMode 
			NC.AskLinkIndexSpecs NC.ChangeLinkIndexSpecs NCP.ListOfOpenNoteFiles 
			NCP.OpenNoteFileP)

      previous date: "19-Sep-86 22:53:04" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH109.;1)


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

(PRETTYCOMPRINT RHTPATCH109COMS)

(RPAQQ RHTPATCH109COMS ((* * New fn for NCCARDS)
			  (FNS NC.MakeNewCardWindow)
			  (* * Changes to NCCARDS)
			  (FNS NC.CardBeingEditedP)
			  (* * Changes to NCPROGINT)
			  (FNS NCP.ListOfOpenNoteFiles NCP.OpenNoteFileP NCP.CoerceToLinkDisplayMode)
			  (* * Changes to NCLINKINDEXCARD)
			  (FNS NC.MakeLinkIndex NC.AskLinkIndexSpecs NC.ChangeLinkIndexSpecs 
			       NC.ComputeLinkIndex)
			  (* * Changes to NCTEXTCARD)
			  (FNS NC.MakeTEditCard)
			  (* * Changes to NCFILEBOXCARD)
			  (FNS NC.MakeFileBox)
			  (* * Changes to NCBROWSERCARD)
			  (FNS NC.MakeBrowserCard)
			  (* * Changes to NCGRAPHCARD)
			  (FNS NC.MakeGraphCard)
			  (* * Changes to NCLINKS)
			  (FNS NC.DelReferencesToCard)))
(* * New fn for NCCARDS)

(DEFINEQ

(NC.MakeNewCardWindow
  (LAMBDA (Card Title BorderWidth NoOpenFlg Region/Position)
                                                             (* rht: "20-Sep-86 00:06")

          (* * Creates a window for Card and Title or "Untitled." If Region/Position NIL, then use default display region for
	  Card.)


    (LET ((Window (CREATEW (NC.DetermineDisplayRegion Card Region/Position)
			     (OR Title "Untitled")
			     BorderWidth NoOpenFlg)))
         (WINDOWPROP Window (QUOTE NoteCardObject)
		       Card)
     Window)))
)
(* * Changes to NCCARDS)

(DEFINEQ

(NC.CardBeingEditedP
  (LAMBDA (Card)                                             (* rht: "20-Sep-86 01:25")

          (* * Returns the editing process if Card is currently on the screen and being edited.)



          (* * rht 9/19/86: This function is bogus because graph cards don't have processes. What gives?)


    (LET ((Window (NC.FetchWindow Card)))
         (AND (NC.ActiveCardP Card)
		(WINDOWP Window)
		(PROCESSP (WINDOWPROP Window (QUOTE PROCESS)))))))
)
(* * Changes to NCPROGINT)

(DEFINEQ

(NCP.ListOfOpenNoteFiles
  (LAMBDA NIL                                                (* rht: "19-Sep-86 22:52")

          (* * Return list of all currently open notefiles.)



          (* * rht 9/19/86: Fixed to return only notefiles currently open, not all that were ever open.)


    (for NoteFile in (NC.ListOfNoteFiles) when (NCP.OpenNoteFileP NoteFile) collect
										       NoteFile)))

(NCP.OpenNoteFileP
  (LAMBDA (NoteFile)                                         (* rht: "19-Sep-86 22:50")

          (* * Non-nil if NoteFile is an open notefile.)



          (* * rht 9/19/86: Fixed to return nil if notefile has no stream.)


    (LET (Stream)
         (AND (type? NoteFile NoteFile)
		(SETQ Stream (fetch (NoteFile Stream) of NoteFile))
		(OPENP Stream)))))

(NCP.CoerceToLinkDisplayMode
  (LAMBDA (Thing)                                            (* rht: "20-Sep-86 00:17")

          (* * Thing can be a cardtype, link, atom, list or LINKDISPLAYMODE record.)



          (* * Fixed so that returns non-nil, if Thing is already a linkdisplaymode.)


    (if (type? LINKDISPLAYMODE Thing)
	then Thing
      else (LET ((DisplayMode (COND
				  ((FMEMB Thing NCP.LinkDisplayModes)
				    (NC.MakeNewDisplayMode Thing))
				  ((LISTP Thing)
				    (create LINKDISPLAYMODE
					      SHOWTITLEFLG ←(CAR Thing)
					      SHOWLINKTYPEFLG ←(CADR Thing)
					      ATTACHBITMAPFLG ←(CADDR Thing)))
				  ((NCP.ValidLinkP Thing)
				    (NCP.LinkDisplayMode Thing))
				  ((NCP.CardTypeP Thing)
				    (NC.MakeNewDisplayMode (NCP.CardTypeVar Thing (QUOTE 
										  LinkDisplayMode))))
				  (T Thing))))
	          (if (type? LINKDISPLAYMODE DisplayMode)
		      then DisplayMode
		    else NIL)))))
)
(* * Changes to NCLINKINDEXCARD)

(DEFINEQ

(NC.MakeLinkIndex
  (LAMBDA (Card Title NoDisplayFlg SpecialArgsList)          (* rht: "20-Sep-86 00:29")

          (* * Gather all instances of a given set of linktypes, printing the titles of cards at the from and to ends of the 
	  link.)



          (* * rht 10/24/84: Now callable from Programmer's interface. If NoDisplayFlg it non-nil, then will build LinkIndex 
	  invisibly. If SpecialArgsList is non-nil, then should be list of (<linklabels> <backpointersP>))



          (* * rht 9/21/85: Now uses stylesheet for LinkIndexSpecs. Broke out workhorse code into the function 
	  NC.ComputeLinkIndex)



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



          (* * rht 4/11/86: Took out call to NCP.AddTitleBarMenuItems. Now done in NC.AddLinkIndexCard.
	  Also changed to call NC.ApplySuper.)



          (* * rht 9/5/86: Now bails out properly if user aborts in stylesheet.)



          (* * rht 9/19/86: Now passes IndexCard rather than Window to NC.AskLinkIndexSpecs. Added call to NC.HoldTTYProcess 
	  to keep linkindexspecs on top.)


    (PROG ((LinkLabels (CAR SpecialArgsList))
	     (BackLinksFlg (CADR SpecialArgsList))
	     Window LinkIndexSpecs)
	    (SPAWN.MOUSE)
	    (SETQ Window (WINDOWP (NC.ApplySupersFn MakeFn Card (CONCAT "Link Index: "
									      (DATE))
							NoDisplayFlg)))
	    (if (NOT NoDisplayFlg)
		then (NC.HoldTTYProcess)
		       (SETQ LinkIndexSpecs (NC.AskLinkIndexSpecs Card LinkLabels BackLinksFlg T))
		       (if (NULL LinkIndexSpecs)
			   then (NC.DeleteNoteCards Card T NIL NIL T T)
				  (RETURN NIL))
		       (SETQ LinkLabels (CAR LinkIndexSpecs))
		       (SETQ BackLinksFlg (CADR LinkIndexSpecs)))
	    (NC.ComputeLinkIndex Card LinkLabels BackLinksFlg)
	    (RETURN (if NoDisplayFlg
			  then Card
			else (NC.ClearMsg Window T)
			       Window)))))

(NC.AskLinkIndexSpecs
  (LAMBDA (Card OldLinkLabels OldBackLinksFlg CreatingLinkIndexFlg)
                                                             (* rht: "19-Sep-86 23:04")

          (* * Puts up the stylesheet asking user about link types, and whether to create back links.
	  This is modeled on NC.AskBrowserSpecs.)



          (* * fgh 11/17/85 Updated to use NoteFile rather than PSA.Database)



          (* * rht 9/19/86: Now takes Card arg rather than MainWindow.)


    (LET ((MainWindow (NC.FetchWindow Card))
	  (NoteFile (fetch (Card NoteFile) of Card))
	  LinkLabels Position Choices ReverseFlg)
         (SETQ LinkLabels (NC.RetrieveLinkLabels NoteFile T))
         (SETQ Position (AND (WINDOWP MainWindow)
				 (create POSITION
					   XCOORD ←(fetch (REGION LEFT) of (WINDOWPROP
										 MainWindow
										 (QUOTE REGION)))
					   YCOORD ←(fetch (REGION TOP) of (WINDOWREGION 
										       MainWindow)))))
                                                             (* The stylesheet is in a global var.
							     We only need to provide its position, items, and 
							     selections.)
         (STYLE.PROP NC.LinkIndexSpecsStylesheet (QUOTE POSITION)
		       Position)
         (STYLE.PROP NC.LinkIndexSpecsStylesheet (QUOTE ITEMS)
		       (LIST (create MENU
					 ITEMS ← LinkLabels)
			       (create MENU
					 ITEMS ←(for Link in LinkLabels
						   collect (PACK* (QUOTE ←)
								      Link)))
			       (create MENU
					 ITEMS ←(QUOTE (Yes No)))))
         (STYLE.PROP NC.LinkIndexSpecsStylesheet (QUOTE SELECTIONS)
		       (LIST (for Label in OldLinkLabels when (NEQ (NTHCHAR Label 1)
									     (QUOTE ←))
				  collect Label)
			       (for Label in OldLinkLabels when (EQ (NTHCHAR Label 1)
									    (QUOTE ←))
				  collect Label)
			       (COND
				 (OldBackLinksFlg (QUOTE Yes))
				 (T (QUOTE No)))))
         (SETQ Choices (STYLESHEET NC.LinkIndexSpecsStylesheet))
         (COND
	   (Choices (LIST (APPEND (CAR Choices)
				      (CADR Choices))
			    (COND
			      ((EQ (CADDR Choices)
				     (QUOTE Yes))
				T)
			      (T NIL))))
	   (CreatingLinkIndexFlg NIL)
	   (T (LIST OldLinkLabels OldBackLinksFlg))))))

(NC.ChangeLinkIndexSpecs
  (LAMBDA (WindowOrTextStream)                               (* rht: "19-Sep-86 23:08")

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


    (LET ((Card (NC.CoerceToCard WindowOrTextStream))
	  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))))

(NC.ComputeLinkIndex
  (LAMBDA (IndexCard LinkLabels BackLinksFlg)                (* kirk: " 9-Sep-86 15:13")

          (* * This is the workhorse. Walks through all links, gathering those with label in LinkLabels and creating back 
	  links if BackLinksP is non-nil.)



          (* * kirk 9/9/86 Deleted obsolete param from NC.RetrieveToLinks)


    (LET ((Window (NC.FetchWindow IndexCard))
	  (NoteFile (fetch (Card NoteFile) of IndexCard))
	  TextStream SortedWinners LastCard)
         (RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
		     (SETQ TextStream (NC.FetchSubstance IndexCard))
		     (NC.AppendStringToStream TextStream (CONCAT 
								"Sorted link index compiled on: "
								     (DATE)
								     (CHARACTER 13)
								     " for linktypes: "
								     (CAR LinkLabels)))
		     (COND
		       (LinkLabels (for Label in (CDR LinkLabels)
				      do (NC.AppendStringToStream TextStream (CONCAT ", " Label)
								      ))
				   (NC.AppendStringToStream TextStream (CONCAT (CHARACTER
										     13)
										   (CHARACTER
										     13)))
				   (NC.PrintMsg Window T "Gathering links ... ")

          (* * Find all cards with instances of a desired link label, record whether they were active, sort them, print their
	  titles to the stream, and deactivate the ones that weren't active.)


				   (SETQ SortedWinners
				     (SORT (NC.MapCards
					       NoteFile
					       (FUNCTION (LAMBDA (Card PredicateResult)
						   (LIST (NC.RetrieveTitle Card)
							   Card PredicateResult)))
					       (FUNCTION (LAMBDA (Card)
						   (LET (ToLinks FromLinks)
						        (if (OR (for Link
								       in (SETQ ToLinks
									      (NC.RetrieveToLinks
										Card))
								       thereis (NC.LinkLabelP
										   Link LinkLabels))
								    (for Link
								       in (SETQ FromLinks
									      (NC.RetrieveFromLinks
										Card))
								       thereis (
									     NC.ReverseLinkLabelP
										   Link LinkLabels)))
							    then (LIST ToLinks FromLinks))))))
					     T))
				   (for WinnerList in SortedWinners
				      do (NC.AppendLinkIndexEntry TextStream IndexCard WinnerList 
								      LinkLabels BackLinksFlg))
				   (NC.PrintMsg Window NIL "Done!" (CHARACTER 13))))
		     (NC.PutProp IndexCard (QUOTE LinkIndexLinkLabels)
				   (LIST LinkLabels))
		     (NC.PutProp IndexCard (QUOTE LinkIndexBackLinksFlg)
				   BackLinksFlg)
		     (NC.SetPropListDirtyFlg IndexCard T)))))
)
(* * Changes to NCTEXTCARD)

(DEFINEQ

(NC.MakeTEditCard
  (LAMBDA (Card Title NoDisplayFlg ParamList)                (* rht: "19-Sep-86 23:46")
                                                             (* Make up a blank text card and display it.)

          (* * rht 9/10/85: Fixed call to NC.MakeTEditPropsList so prompt window gets fixed up before card is brought up.)



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



          (* * rht 4/11/86: Now passes type to NC.MakeTEditMiddleMenu.)



          (* * rht 5/6/86: Now calls NC.InstallTitleBarLeftMenu and NC.InstallTextTitleBarMiddleMenu.)



          (* * rht 9/8/86: No longer hangs Card off NoteCardObject windowprop. THis is done in NC.MakeNoteCard.)



          (* * rht 9/19/86: Mod to above fix. Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off 
	  windowprop. Also takes ParamList arg.)


    (LET (TextStream Window Type)
         (COND
	   (NoDisplayFlg (SETQ TextStream (OPENTEXTSTREAM "" NIL NIL NIL
							      (NC.MakeTEditPropsList
								NIL
								(LISTGET ParamList (QUOTE 
								 Don'tAttachUserSpecifiedPropsFlg)))))
			 (NC.SetSubstance Card TextStream)
			 (STREAMPROP TextStream (QUOTE NoteCardObject)
				       Card)
			 Card)
	   (T (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")
						     NIL T))
	      (SETQ Type (NC.RetrieveType Card))
	      (NC.InstallTitleBarLeftMenu Window Type)
	      (NC.InstallTextTitleBarMiddleMenu Window Type)
	      (WINDOWADDPROP Window (QUOTE SHRINKFN)
			       (FUNCTION NC.TextCardShrinkFn))
	      (TEDIT NIL Window NIL (NC.MakeTEditPropsList Window))
	      (until (WINDOWPROP Window (QUOTE TEXTSTREAM)) do (BLOCK))
	      (SETQ TextStream (WINDOWPROP Window (QUOTE TEXTSTREAM)))
	      (NC.SetSubstance Card TextStream)
	      (STREAMPROP TextStream (QUOTE NoteCardObject)
			    Card)
	      Window)))))
)
(* * Changes to NCFILEBOXCARD)

(DEFINEQ

(NC.MakeFileBox
  (LAMBDA (Card Title NoDisplayFlg ParamList)                (* rht: "19-Sep-86 23:55")
                                                             (* Make up a blank contents card, hook it to the user 
							     specified parent contents cards, and display it.)

          (* * rht 12/2/84: In NoDisplayFlg case, changed to return ID rather than TextStream.)



          (* * rht 12/8/84: Massive shaving. Took out code to force filing now (at creation time))



          (* * rht 9/11/85: Took out insertion of spacer when no markers.)



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



          (* * fgh 2/6/86 Chaged calls to NC.FetchDefaultHeight & NC.FetchDefaultWidth)



          (* * fgh 2/6/86 Removed bug where NC.ClearMsg was deleteing card immediately.)



          (* * rht 4/11/86: Now passes Type and Window to NC.MakeTEditLeftMenu.)



          (* * rht 8/2/86: Now lets NC.MakeTEditPropsList build the props to be passed to TEDIT.)



          (* * rht 9/8/86: Now doesn't create window before calling TEDIT to avoid stupid prompt win popping up.)



          (* * rht 9/19/86: Now applies supertype's MakeFn to cut out redundant code.)


    (LET ((Spacer (CONCAT (CHARACTER 13)
			    (CHARACTER 13)))
	  Window TextStream Type)
         (SETQ Window (WINDOWP (NC.ApplySupersFn MakeFn Card (CONCAT "Link Index: " (DATE))
						     NoDisplayFlg
						     (if ParamList
							 then (LISTPUT ParamList (QUOTE 
								 Don'tAttachUserSpecifiedPropsFlg)
									   T)
						       else (QUOTE (
Don'tAttachUserSpecifiedPropsFlg T))))))
         (SETQ TextStream (NC.FetchSubstance Card))
         (COND
	   (NC.MarkersInFileBoxesFlg (TEDIT.INSERT.OBJECT (NC.MakePlaceMarker 
									     NC.SubBoxMarkerLabel)
							    TextStream 1)
				     (TEDIT.INSERT TextStream Spacer 2)
				     (TEDIT.INSERT.OBJECT (NC.MakePlaceMarker 
									  NC.FiledCardMarkerLabel)
							    TextStream 4)
				     (TEDIT.INSERT TextStream Spacer 5)))
         (if NC.AlphabetizedFileBoxChildrenFlg
	     then (NCP.CardProp Card (QUOTE OrderingFn)
				    (FUNCTION NC.IDAlphOrder)))
         (if NoDisplayFlg
	     then Card
	   else Window))))
)
(* * Changes to NCBROWSERCARD)

(DEFINEQ

(NC.MakeBrowserCard
  (LAMBDA (Card Title NoDisplayFlg ParamList)                (* rht: "20-Sep-86 00:34")

          (* Make a browser card with id Card using root at RootID and the link following predictae specified by Predicate.
	  IF Root and/or ListOfLinkLabels not specified, ask the user.)



          (* * rht 8/3/84: Changed to call NC.AskLinkLabel with its ReverseLinkLabel parameter set to T.)



          (* * fgh 10/2/84 Changed Link Icons to be image objects in NodeLabel of Graph Npodes rather than annotations on 
	  graph nodes.)



          (* * rht 10/19/84: Fixed setting up of browser card's prop list in case NoDisplayFlg is T so we have no Window.
	  Now NC.MakeLinksLegend returns the label pairs.)



          (* * rht 11/27/84: Removed the WINDOWADDPROP call to put NC.GraphCardCloseFn on the CLOSEFN of the window.
	  This causes trouble. NC.QuitCard will get put on by NC.MakeNoteCard and that's enough.)



          (* * rht 1/3/85: Now puts a dummy region of the right size if the NoDisplayFlg is on.)



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



          (* * rht 2/14/85: Added VerticalFlg and made BrowserSpecs get put on browser's proplist in all cases.)



          (* * rht 4/1/85: Now calls NC.AskBrowserSpecs with additional Don'tAskFlg in case of call from Programmer's 
	  interface.)



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



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



          (* * rht 5/6/86: Took out call to NC.SetupTitleBarMenu.)



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



          (* * rht 7/10/86: Now passes ListOfLinkLabels to NC.AskBrowserSpecs.)



          (* * rht 9/19/86: Mod to above fix. Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off 
	  windowprop.)


    (PROG ((RootCards (MKLIST (LISTGET ParamList (QUOTE ROOTCARDS))))
	     (ListOfLinkLabels (LISTGET ParamList (QUOTE LINKTYPES)))
	     (BrowserFormat (LISTGET ParamList (QUOTE FORMAT)))
	     (Depth (LISTGET ParamList (QUOTE DEPTH)))
	     (CardType (NC.RetrieveType Card))
	     Lattice RootNodes Window Graph SpecialBrowserSpecs BrowserSpecs DropVirtualNodesFlg)
	    (NC.ActivateCard Card)
	    (COND
	      ((NULL NoDisplayFlg)
		(SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")))
		(WINDOWADDPROP Window (QUOTE SHRINKFN)
				 (FUNCTION NC.GraphCardShrinkFn))))
	    (if (NULL RootCards)
		then (SETQ RootCards (if NoDisplayFlg
					     then (LIST NIL)
					   else (NC.SelectNoteCards NIL NIL 
								    NC.SelectingBrowserSourceMenu 
									Window NIL 
			    "Please select the Cards and/or Boxes the browser should start from."
									T))))
	    (COND
	      ((EQ RootCards (QUOTE CANCELLED))
		(NC.DeactivateCard Card)
		(CLOSEW Window)
		(RETURN)))
	    (NC.HoldTTYProcess)
	    (SETQ BrowserSpecs (NC.AskBrowserSpecs Window Card ListOfLinkLabels Depth 
						       BrowserFormat T (if (OR ParamList 
										   NoDisplayFlg)
									   then (QUOTE DONTASK))))
	    (COND
	      ((NULL BrowserSpecs)
		(NC.DeactivateCard Card)
		(CLOSEW Window)
		(RETURN)))
	    (SETQ ListOfLinkLabels (CAR BrowserSpecs))
	    (SETQ Depth (CADR BrowserSpecs))
	    (SETQ BrowserFormat (CADDR BrowserSpecs))    (* 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 (COND
		(NC.SpecialBrowserSpecsFlg (NC.AskSpecialBrowserSpecs Window))
		(T (create SPECIALBROWSERSPECS))))
	    (OR NoDisplayFlg (NC.PrintMsg Window T (CHARACTER 13)
					      "Computing browser graph. Please wait. ..."))
                                                             (* Create new browser hash array)
	    (NC.GetBrowserHashArray Card)                  (* Compute lattice breakdth-first starting from 
							     roots.)
	    (SETQ Lattice (NC.GrowLinkLattice RootCards NIL ListOfLinkLabels Card Depth))
	    (SETQ RootNodes (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
											 RootCard)))
	    (OR NoDisplayFlg (WINDOWPROP Window (QUOTE NoteCardObject)
					     Card))

          (* * Link destination id information stored in NodeLabel field into a LinkIcon for display)


	    (for Node in Lattice bind NodeID eachtime (BLOCK)
	       do (replace (GRAPHNODE NODELABEL) of Node
		       with (NC.MakeLinkIcon (NC.MakeLink Window NC.BrowserContentsLinkLabel
								(fetch (GRAPHNODE NODELABEL)
								   of Node)
								Card NIL)))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
		    (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
					     (QUOTE TouchedFlg))
		    (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
					     (QUOTE VisitedFlg)))
	    (SETQ Graph (if (AND Lattice RootNodes)
			      then (LAYOUTGRAPH Lattice RootNodes (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)))
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (OR NoDisplayFlg (NC.PrintMsg Window NIL "Done!"))
	    (NC.SetSubstance Card Graph)
	    (NC.SetBrowserLinkLabels Card (OR ListOfLinkLabels (LIST NC.SubBoxLinkLabel)))
	    (NC.SetBrowserRoots Card RootCards)
	    (NC.SetBrowserFormat Card BrowserFormat)
	    (NC.SetBrowserDepth Card Depth)
	    (NC.SetSpecialBrowserSpecs Card SpecialBrowserSpecs)
	    (COND
	      (NoDisplayFlg (RETURN Card)))
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.InstallTitleBarLeftMenu Window CardType)
	    (NC.InstallGraphTitleBarMiddleMenu Window CardType)
	    (NC.RelayoutBrowserCard Window)
	    (RETURN Window))))
)
(* * Changes to NCGRAPHCARD)

(DEFINEQ

(NC.MakeGraphCard
  (LAMBDA (Card Title NoDisplayFlg)                          (* rht: "20-Sep-86 00:35")

          (* * Creates a StructEdit card. Alot like a graph card except that it allows editing of underlying NC structure, 
	  and doesn't allow an "insertlink" operation in title bar menu.)



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



          (* * rht 5/5/86: Replaced call to NC.SetupTitleBarMenu with Install calls.)



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



          (* * rht 9/19/86: Mod to above fix. Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off 
	  windowprop.)


    (LET (Window Graph CardType)
         (SETQ Graph (create GRAPH
				 GRAPH.ADDNODEFN ←(FUNCTION NC.GraphAddNodeFn)
				 GRAPH.DELETENODEFN ←(FUNCTION NC.GraphDeleteNodeFn)
				 GRAPH.ADDLINKFN ←(FUNCTION NC.GraphAddLinkFn)
				 GRAPH.DELETELINKFN ←(FUNCTION NC.GraphDeleteLinkFn)
				 GRAPH.MOVENODEFN ←(FUNCTION NC.GraphMoveNodeFn)
				 GRAPH.FONTCHANGEFN ←(FUNCTION NC.GraphFontChangeFn)))
         (NC.SetSubstance Card Graph)
         (COND
	   ((NOT NoDisplayFlg)
	     (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")))
	     (SETQ CardType (NC.RetrieveType Card))
	     (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
			  (FUNCTION NC.GraphCardMiddleButtonFn)
			  T T (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN))
	     (WINDOWADDPROP Window (QUOTE SHRINKFN)
			      (FUNCTION NC.GraphCardShrinkFn))
	     (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.GraphTitleBarButtonEventFn))
	     (NC.InstallTitleBarLeftMenu Window CardType)
	     (NC.InstallGraphTitleBarMiddleMenu Window CardType)))
         (OR Window Card))))
)
(* * Changes to NCLINKS)

(DEFINEQ

(NC.DelReferencesToCard
  (LAMBDA (SourceCard LinkOrDestinationCard)                 (* rht: "20-Sep-86 01:19")
                                                             (* The card specified by DestinationID is being 
							     deleted. Remove all references to it from the card 
							     specified by SourceCard)

          (* * kirk: 13Nov85: deleted use of DatabaseStream)



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



          (* * kef 7/31/86: Added wrapping of write lock grabbing so that deactivating the card preserves the nesting of 
	  write lock ownership.)



          (* * kef 8/5/86: Added putting of Main Card data in ActiveP case. This is so that if subsequent other people bring 
	  up the card, they will see the fact that link card was deleted.)



          (* * kef 8/7/86: Now requires that the card is being edited rather than just Active to thwart direct write through 
	  to NoteFile.)



          (* * rht 8/11/86 Added ShrunkenFlg so that SourceCard is reshrunk afterwards if necessary.)



          (* * fgh 8/30/86 Changed APPLY* to NC.ApplyFn. Appears there might be trouble here since we don't appear to wait if
	  we can't get all the write permission locks. I am assuming for now that this is being taken care of at a higher 
	  level.)



          (* * rht 9/19/86: It was testing NC.BeingEditedP to decide whether had to obtain write permission, etc. I think 
	  NC.ActiveCardP is enough. NC.BeingEditedP is bogus anyway as it doesn't work on card's whose editors don't have 
	  processes like graph cards.)


    (LET ((ShrunkenFlg (NC.GetShrunkenWin SourceCard))
	  NoteCardType Substance)
         (COND
	   ((NC.ActiveCardP SourceCard)
	     (SETQ NoteCardType (NC.RetrieveType SourceCard))
	     (SETQ Substance (NC.FetchSubstance SourceCard))
	     (NC.ApplyFn DeleteLinksFn SourceCard LinkOrDestinationCard)
	     (NC.PutMainCardData SourceCard))
	   (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
			    (if (NC.ValidCardP (NC.GetNoteCard SourceCard))
				then (RESETLST (RESETSAVE (for CardPart
								   in (QUOTE (SUBSTANCE TOLINKS 
										    GLOBALTOLINKS 
											 PROPLIST))
								   do (NC.ApplyFn 
									  ObtainWritePermissionFn 
										    SourceCard 
										    CardPart))
								(BQUOTE (NC.DeactivateCard , 
										       SourceCard)))
						   (SETQ NoteCardType (NC.RetrieveType SourceCard)
						     )
						   (SETQ Substance (NC.FetchSubstance SourceCard))
						   (NC.ApplyFn DeleteLinksFn SourceCard 
							       LinkOrDestinationCard)
						   (NC.PutMainCardData SourceCard))))))
         (NC.DelReferencesToCardFromGlobalList SourceCard LinkOrDestinationCard)
         (AND ShrunkenFlg (SHRINKW (NC.FetchWindow SourceCard))))))
)
(PUTPROPS RHTPATCH109 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1376 1953 (NC.MakeNewCardWindow 1386 . 1951)) (1985 2508 (NC.CardBeingEditedP 1995 . 
2506)) (2542 4457 (NCP.ListOfOpenNoteFiles 2552 . 2989) (NCP.OpenNoteFileP 2991 . 3409) (
NCP.CoerceToLinkDisplayMode 3411 . 4455)) (4497 12910 (NC.MakeLinkIndex 4507 . 6514) (
NC.AskLinkIndexSpecs 6516 . 8986) (NC.ChangeLinkIndexSpecs 8988 . 10170) (NC.ComputeLinkIndex 10172 . 
12908)) (12945 14990 (NC.MakeTEditCard 12955 . 14988)) (15028 17409 (NC.MakeFileBox 15038 . 17407)) (
17447 24458 (NC.MakeBrowserCard 17457 . 24456)) (24494 26394 (NC.MakeGraphCard 24504 . 26392)) (26426 
29418 (NC.DelReferencesToCard 26436 . 29416)))))
STOP