(FILECREATED "30-Nov-87 15:59:21" {QV}<NOTECARDS>1.3KNEXT>NCGRAPHCARD.;5 46825  

      changes to:  (FNS NC.GraphNodeLinkIconUpdate NC.UpdateLinkImagesInGraph NC.RelayoutGraphCard 
			NC.GraphCardLeftButtonFn)

      previous date: " 2-Sep-87 13:37:54" {QV}<NOTECARDS>1.3KNEXT>NCGRAPHCARD.;4)


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

(PRETTYCOMPRINT NCGRAPHCARDCOMS)

(RPAQQ NCGRAPHCARDCOMS [[DECLARE: DONTEVAL@LOAD FIRST (P (NC.LoadFileFromDirectories (QUOTE GRAPHER)
										       (QUOTE 
									     LISPUSERSDIRECTORIES))
							   (NC.LoadFileFromDirectories (QUOTE 
										     GRAPHERPATCH))
							   (NC.LoadFileFromDirectories (QUOTE HGRAPH)
										       (QUOTE 
									     LISPUSERSDIRECTORIES]
	(FILES NCTYPESMECH)
	(FNS NCAddStub.GraphCard)
	(GLOBALVARS NC.GraphCardIcon NC.ShrunkenGraphIconBM NC.ShrunkenGraphIconMask 
		    NC.ShrunkenGraphIconTemplate NC.UseDeletedLinkIconIndicatorsFlg TEDIT.ICON.FONT)
	[DECLARE: DONTEVAL@LOAD (VARS (ScalableLinkParameters (QUOTE (LINEWIDTH]
	(* * Basic functions.)
	(FNS NC.MakeGraphCard NC.BringUpGraphCard NC.RelayoutGraphCard NC.CollectReferencesInGraph 
	     NC.GraphCardCloseFn NC.GraphCardLeftButtonFn NC.GraphCardMiddleButtonFn 
	     NC.GraphCopySubstance NC.MarkGraphDirty NC.GraphDirtyP NC.GraphNodeLinkIconUpdate 
	     NC.GetGraphSubstance NC.PutGraphSubstance NC.UpdateLinkImagesInGraph 
	     NC.DelReferencesToCardFromGraph NC.GraphChangeLabelFn)
	(* * Hooks into Grapher for NoteCards applications)
	(FNS NC.GRAPHERCOPYBUTTONEVENTFN NC.InsideGrapherNodeP NC.GraphAddNodeFn NC.GraphDeleteNodeFn 
	     NC.GraphAddLinkFn NC.GraphDeleteLinkFn NC.GraphMoveNodeFn NC.GraphFontChangeFn 
	     NC.GraphRemoveNode NC.TrackCursorInGrapherWindow)
	(* * This stuff supports the "push-copy" method of copying links in NC)
	(FNS NC.TranslateWindowPositionToGraphPosition NC.InsertLinkInGraph)
	(* * Stuff for shrinking graphs and browsers.)
	(DECLARE: DONTEVAL@LOAD (BITMAPS NC.ShrunkenGraphIconBM NC.ShrunkenGraphIconMask 
					 NC.GraphCardIcon))
	(FNS NC.GraphCardShrinkFn)
	[DECLARE: DONTEVAL@LOAD (VARS (NC.ShrunkenGraphIconTemplate (create TITLEDICON ICON ← 
									   NC.ShrunkenGraphIconBM 
									    MASK ← 
									 NC.ShrunkenGraphIconMask 
									    TITLEREG ←
									    (QUOTE (16 4 64 77]
	(* * Stuff for making copies of graphs for making imageobj's.)
	(FNS NC.MakeExternalGraphCopy)
	(* * Add the Graph card to the cardtypes list.)
	(FNS NC.AddGraphCard)
	(DECLARE: DONTEVAL@LOAD (P (NC.AddGraphCard])
(DECLARE: DONTEVAL@LOAD FIRST 
(NC.LoadFileFromDirectories (QUOTE GRAPHER)
			    (QUOTE LISPUSERSDIRECTORIES))
(NC.LoadFileFromDirectories (QUOTE GRAPHERPATCH))
(NC.LoadFileFromDirectories (QUOTE HGRAPH)
			    (QUOTE LISPUSERSDIRECTORIES))
)
(FILESLOAD NCTYPESMECH)
(DEFINEQ

(NCAddStub.GraphCard
  [LAMBDA NIL                                                (* rht: " 7-Nov-86 16:33")

          (* * kirk 18Jun86 Add the Graph card stub)



          (* * rht 11/7/86: Fixed typo, changing a QUOTE to BQUOTE.)


    (DECLARE (GLOBALVARS NC.GraphCardIcon))
    (NC.AddCardTypeStub (QUOTE Graph)
			  (QUOTE NoteCard)
			  (QUOTE NCGRAPHCARD)
			  NIL
			  (BQUOTE ((DisplayedInMenuFlg T)
				     (LinkIconAttachedBitMap , NC.GraphCardIcon])
)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.GraphCardIcon NC.ShrunkenGraphIconBM NC.ShrunkenGraphIconMask 
	    NC.ShrunkenGraphIconTemplate NC.UseDeletedLinkIconIndicatorsFlg TEDIT.ICON.FONT)
)
(DECLARE: DONTEVAL@LOAD 

(RPAQQ ScalableLinkParameters (LINEWIDTH))
)
(* * Basic functions.)

(DEFINEQ

(NC.MakeGraphCard
  [LAMBDA (Card Title NoDisplayFlg)                          (* pmi: "23-Jun-87 17:32")

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



          (* * pmi 6/23/87: Added the GRAPH.CHANGELABELFN NC.GraphChangeLabelFn to the Graph being created, which will then 
	  mark the substance dirty when a label is changed.)


    (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)
				 GRAPH.CHANGELABELFN ← (FUNCTION NC.GraphChangeLabelFn)))
         (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.TitleBarButtonEventFn))
	     (NC.InstallTitleBarLeftMenu Window CardType)
	     (NC.InstallTitleBarMiddleMenu Window CardType)))
         (OR Window Card])

(NC.BringUpGraphCard
  [LAMBDA (Card Substance RegionOrPosition)                  (* Randy.Gobbel "10-Dec-86 16:57")

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



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



          (* * rht 5/5/86: Now calls NC.InstallTitleBarButtonEventFn, NC.InstallTitleBarLeftMenu, and 
	  NC.InstallTitleBarMiddleMenu instead of NC.SetupTitleBarMenu.)



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



          (* * rht 11/16/86: Now moves window to RegionOrPosition if already up.)


    (LET (Region Title GraphWindow IconWindow CardType)
         (COND
	   ((SETQ GraphWindow (NC.FetchWindow Card))
	     (AND (WINDOWP (WINDOWPROP GraphWindow (QUOTE ICONFOR)))
		    (SETQ GraphWindow (EXPANDW GraphWindow)))
	     (TOTOPW GraphWindow)
	     (if RegionOrPosition
		 then (SHAPEW GraphWindow (NC.DetermineDisplayRegion Card RegionOrPosition)))
	     (RPTQ 2 (FLASHW GraphWindow)))
	   (T (SETQ GraphWindow (SHOWGRAPH Substance (CREATEW (NC.DetermineDisplayRegion
								      Card RegionOrPosition)
								    (NC.RetrieveTitle Card))
					       (FUNCTION NC.GraphCardLeftButtonFn)
					       (FUNCTION NC.GraphCardMiddleButtonFn)
					       NIL T (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN)))
	      (SETQ CardType (NC.RetrieveType Card))
	      (WINDOWADDPROP GraphWindow (QUOTE SHRINKFN)
			       (FUNCTION NC.GraphCardShrinkFn))
	      (NC.InstallTitleBarButtonEventFn GraphWindow (FUNCTION NC.TitleBarButtonEventFn))
	      (NC.InstallTitleBarLeftMenu GraphWindow CardType)
	      (NC.InstallTitleBarMiddleMenu GraphWindow CardType)))
     GraphWindow])

(NC.RelayoutGraphCard
  [LAMBDA (Win)                                              (* pmi: "21-Jul-87 18:42")

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



          (* * rg 3/4/87 rewritten for new version of NC.ProtectedCardOperation)



          (* * pmi 7/21/87: Made sure LAYOUTGRAPH is getting a list for ROOTIDS.)


    (LET ((Card (NC.CoerceToCard Win)))
         (NC.ProtectedCardOperation
	   Card "Relayout Graph Card" NIL
	   (LET ((Graph (WINDOWPROP Win (QUOTE GRAPH)))
		 GraphNodes)
	        (if (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of Graph))
		    then (SETQ Graph (LAYOUTGRAPH
			       GraphNodes
			       [MKLIST (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.TitleBarButtonEventFn])

(NC.CollectReferencesInGraph
  [LAMBDA (Card CheckAndDeleteFlg ReturnLinkIconsFlg ReturnLocationsFlg)
                                                             (* rht: " 1-Jun-87 22:11")

          (* * Return a list of all links or link icons in graph substance Substance. If CheckAndDeleteFlg, then delete any 
	  links found that are not valid links.)



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



          (* * rht 5/26/87: Changed to match reduced functionality of NC.ValidLinkP, now have to check that destination of 
	  ActualLink is a valid card.)


    (DECLARE (GLOBALVARS NC.DeletedLinkImageObject))
    (LET ((Substance (NC.FetchSubstance Card))
	  ActualLink DirtyFlg Links LinkIcon CollectItem)
         [SETQ Links (for GraphNode in (fetch (GRAPH GRAPHNODES) of Substance)
			  when (COND
				   ((NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE
											NODELABEL)
										of GraphNode)))
				     (SETQ ActualLink (NC.FetchLinkFromLinkIcon LinkIcon))
				     (COND
				       ((NULL CheckAndDeleteFlg))
				       ((AND (LISTP CheckAndDeleteFlg)
					       (FMEMB (fetch (Link DestinationCard) of 
										       ActualLink)
							CheckAndDeleteFlg)))
				       [(AND (NC.ValidLinkP ActualLink)
					       (NC.ValidCardP (fetch (Link DestinationCard)
								   of ActualLink]
				       (T (replace (GRAPHNODE NODELABEL) of GraphNode
					     with NC.DeletedLinkImageObject)
					  (SETQ DirtyFlg T)
					  NIL)))
				   (T NIL))
			  collect (PROGN (SETQ CollectItem (COND
						 (ReturnLinkIconsFlg LinkIcon)
						 (T ActualLink)))
					     (COND
					       ((NULL ReturnLocationsFlg)
						 CollectItem)
					       (T (CONS CollectItem (fetch (GRAPHNODE NODELABEL)
									 of GraphNode]
         (CONS Links DirtyFlg])

(NC.GraphCardCloseFn
  [LAMBDA (CardIdentifier)                                   (* rht: "16-Oct-86 16:56")
                                                             (* Called when a grapher-based note card is being 
							     closed. Writes graph to database and does other clean 
							     up functions)

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



          (* * rht 10/16/86: Removed call to NC.DeactivateCard.)


    (LET (Window (Card (NC.CoerceToCard CardIdentifier)))
         (SETQ Window (NC.FetchWindow Card))
         (AND Window (for AttachedWindow in (ALLATTACHEDWINDOWS Window)
			  do (DETACHWINDOW AttachedWindow)
			       (CLOSEW AttachedWindow)))
         (AND Window (REMOVEPROMPTWINDOW Window])

(NC.GraphCardLeftButtonFn
  [LAMBDA (GraphNode GraphWindow)                            (* Randy.Gobbel " 4-Nov-87 14:16")

          (* * If this is a node containing a link icon, then do: IF Selection in progress, then pressing a node gets its 
	  destination ID if its actually a note card node. Otherwise, bring up the note card pointed to by the node.)



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



          (* * fgh 11/14/85 Isn't this obsolete??????)



          (* * rht&pmi 11/14/86: No longer does stupid pushcopy stuff.)



          (* * rg 11/4/87 added ReadOnly to NC.EditNoteCard call)


    (LET ((LinkIcon (fetch (GRAPHNODE NODELABEL) of GraphNode)))
         (if [AND (NC.LinkIconImageObjP LinkIcon)
		      (NOT (OR (KEYDOWNP (QUOTE LSHIFT))
				   (KEYDOWNP (QUOTE RSHIFT))
				   (KEYDOWNP (QUOTE CTRL))
				   (KEYDOWNP (QUOTE COPY))
				   (KEYDOWNP (QUOTE DELETE))
				   (KEYDOWNP (QUOTE MOVE]
	     then [LET [(Card (fetch (Link DestinationCard) of (NC.FetchLinkFromLinkIcon
								       LinkIcon]
		         (NC.EditNoteCard Card (fetch (NoteFile ReadOnlyFlg)
						    of (fetch (Card NoteFile) of Card]
	   else NIL])

(NC.GraphCardMiddleButtonFn
  [LAMBDA (GraphNode GraphWindow)                            (* Randy.Gobbel "14-Nov-86 16:42")

          (* IF Selection in progress, then pressing a node gets its destination ID if its actually a note card node.
	  Otherwise, jump to normal button processing for an link icon)



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



          (* * fgh 11/14/85 Isn't this obsolete????????)



          (* * rht&pmi 11/14/86: No longer does stupid NC.SpecialBrowserMiddleButtonFn stuff.)


    (LET ((LinkIcon (fetch (GRAPHNODE NODELABEL) of GraphNode)))
         (if [AND (NC.LinkIconImageObjP LinkIcon)
		      (NOT (OR (KEYDOWNP (QUOTE LSHIFT))
				   (KEYDOWNP (QUOTE RSHIFT))
				   (KEYDOWNP (QUOTE CTRL))
				   (KEYDOWNP (QUOTE COPY))
				   (KEYDOWNP (QUOTE DELETE))
				   (KEYDOWNP (QUOTE MOVE]
	     then (NC.LinkIconMiddleButtonFn LinkIcon GraphWindow)
	   else NIL])

(NC.GraphCopySubstance
  (LAMBDA (Card FromStream ToStream Length)                  (* rht: "23-Jan-86 12:12")

          (* * Copy a graph substance from FromStream to ToStream.)



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



          (* * fgh 11/20/85 NoteCards now handles the start and end ptrs -- passing the from ptrs as args and properly 
	  setting the to ptrs.)



          (* * fgh 11/21/85 Now passes length instead of start and end ptrs.)



          (* * Copy the bytes)


    (LET* ((FromStartPtr (GETFILEPTR FromStream))
	   (FromEndPtr (PLUS Length FromStartPtr)))
          (COPYBYTES FromStream ToStream FromStartPtr FromEndPtr))
    T))

(NC.MarkGraphDirty
  (LAMBDA (Card ResetFlg)                                    (* fgh: "14-Nov-85 21:25")

          (* * Mark or unmark graph as having been changed -- Sorry no can do!!!)


    NIL))

(NC.GraphDirtyP
  (LAMBDA (Graph)                                            (* rht: " 1-Feb-85 15:39")

          (* * A graph is always considered to be dirty since we can't tell whether its changed or not.)



          (* * rht 2/1/85: For now we can't tell by looking at graph substance whether we're dirty or not.
	  Leave it up to the SubstanceDirtyFlg on the card.)


    NIL))

(NC.GraphNodeLinkIconUpdate
  [LAMBDA (Window GraphNode)                                 (* rht: "29-Oct-87 11:59")

          (* * Check whether the image box size agrees with graphnode size. If not, update graph node.
	  REDISPLAYW should eventually happen to the graph after calling this.)



          (* * rht&pmi 2/6/87: Now includes BorderSize in calculation of graph node label size. This is important for virtual
	  nodes.)



          (* * rht 10/29/87: Now handles pointer icons as well as link icons.)


    (LET ((LinkIcon (fetch (GRAPHNODE NODELABEL) of GraphNode))
	  [BorderSize (TIMES 2 (GRAPHNODE/BORDER/WIDTH (fetch (GRAPHNODE NODEBORDER)
							      of GraphNode]
	  (GraphNodeWidth (fetch (GRAPHNODE NODEWIDTH) of GraphNode))
	  (GraphNodeHeight (fetch (GRAPHNODE NODEHEIGHT) of GraphNode))
	  ImageBox XSize YSize)
         (if [OR [AND (NC.LinkIconImageObjP LinkIcon)
			    (SETQ ImageBox (NC.LinkIconImageBoxFn LinkIcon (WINDOWPROP
									Window
									(QUOTE DSP]
		     (AND (NC.PointerIconImageObjP LinkIcon)
			    (SETQ ImageBox (NC.PointerIconImageBoxFn LinkIcon
									 (WINDOWPROP Window
										       (QUOTE
											 DSP]
	     then (SETQ XSize (fetch (IMAGEBOX XSIZE) of ImageBox))
		    (SETQ YSize (fetch (IMAGEBOX YSIZE) of ImageBox))
		    (if [AND GraphNodeWidth (NOT (EQUAL XSize (DIFFERENCE GraphNodeWidth 
										    BorderSize]
			then (replace (GRAPHNODE NODEWIDTH) of GraphNode
				  with (PLUS XSize BorderSize)))
		    (if [AND GraphNodeHeight (NOT (EQUAL YSize (DIFFERENCE GraphNodeHeight 
										     BorderSize]
			then (replace (GRAPHNODE NODEHEIGHT) of GraphNode
				  with (PLUS YSize BorderSize])

(NC.GetGraphSubstance
  (LAMBDA (Card Length Stream VersionNum)                    (* fgh: "25-May-86 18:04")

          (* * Read the Graph)



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



          (* * fgh 11/20/85 NoteCards now passes start and end ptrs down.)



          (* * fgh 11/21/85 Now passes length instead of start and end ptrs.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * rht 2/7/86: Now uses READGRAPH instead of HREAD)



          (* * rht 2/28/86: Added special handling for old version -1 style. I.e. pre 1.3k.)



          (* * fgh 5/1/86 Can't have negative version numbers, so changed old style versions to be 255.0)



          (* * fgh 5/25/86 Undid preceeding change. Turns out -1 never came from file only passed as Arg from converter.)


    (if (EQP VersionNum -1)
	then (HREAD Stream)
      else (READGRAPH Stream))))

(NC.PutGraphSubstance
  (LAMBDA (Card Stream)                                      (* rht: "14-Feb-86 18:09")
                                                             (* Put Graph in card ID onto DatabaseStream)

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



          (* * fgh 11/20/85 NoteCards now takes care of setting the start and end pointers for the substance.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * fgh 2/6/86 Now returns a version number)



          (* * rht 2/7/86: Now uses DUMPGRAPH rather than HPRINT)


    (LET ((Graph (NC.FetchSubstance Card)))                (* Clean up BITMAPS in Graph data structure)
         (for GraphNode in (fetch GRAPHNODES of Graph) do (replace (GRAPHNODE 
										  NODELABELBITMAP)
								       of GraphNode with NIL))
                                                             (* Write data stucture)
         (DUMPGRAPH Graph Stream)
     0)))

(NC.UpdateLinkImagesInGraph
  [LAMBDA (SourceCard DestinationCard)                       (* rht: "29-Oct-87 12:02")
                                                             (* Update all the NoteCard links that point to 
							     DestinationID from the graph card specified by 
							     SourceCardID)

          (* * rht 2/15/85: Added hack to redraw links into and out of the affected node. This is in case it has changed 
	  size. Note the calls to internal grapher functions!)



          (* * rht 10/3/85: Threw away above mentioned code. It was screwing up the link-params info for the affected nodes.)



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



          (* * rht 10/29/87: Now handles pointer icons as well as link icons.)


    (LET (Window Graph GraphNodes LinkIcon OldAddLinkFn OldDeleteLinkFn)
         (SETQ Window (NC.FetchWindow SourceCard))
         (SETQ Graph (NC.FetchSubstance SourceCard))
         (for GraphNode in (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of Graph))
	    when [OR [AND (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE 
											NODELABEL)
									    of GraphNode)))
				(NC.SameCardP DestinationCard (fetch (Link DestinationCard)
								   of (NC.FetchLinkFromLinkIcon
									  LinkIcon]
			 (AND (NC.PointerIconImageObjP LinkIcon)
				(NC.SameCardP DestinationCard (fetch (NCPointer DestinationCard)
								   of (
								   NC.FetchPointerFromPointerIcon
									  LinkIcon]
	    do                                             (* Update the size of the graph node if doesn't agree 
							     with image box.)
		 (NC.GraphNodeLinkIconUpdate Window GraphNode))
         (REDISPLAYW Window])

(NC.DelReferencesToCardFromGraph
  [LAMBDA (SourceCard LinkOrDestinationCard Don'tCreateDeletedImageObjFlg)
                                                             (* rht: " 4-Nov-86 20:58")
                                                             (* Delete from the graph specified by Graph all link 
							     icon nodes whose DESTINATIONID is eq to DestinationID)

          (* * rht 11/17/84: Now only redisplays graph if ID is both active *and* has a window.)



          (* * kirk 14Nov85: deleted use of LinkID)



          (* * rht 4/30/86: Now uses value of NC.UseDeletedLinkIconIndicators to determine whether to delete node or replace 
	  with Deleted indicator.)



          (* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)


    (DECLARE (GLOBALVARS NC.UseDeletedLinkIconIndicatorsFlg NC.DeletedLinkImageObject))
    (LET ((ImageBox (NC.DeletedLinkImageBoxFn NC.DeletedLinkImageObject))
	  LinkIcon
	  (LinkFlg (type? Link LinkOrDestinationCard))
	  DestinationCard Graph)
         (COND
	   [LinkFlg (OR (NC.CardP SourceCard)
			  (SETQ SourceCard (fetch (Link SourceCard) of LinkOrDestinationCard]
	   (T (SETQ DestinationCard LinkOrDestinationCard)))
         (SETQ Graph (NC.FetchSubstance SourceCard))
         (for GraphNode in (fetch (GRAPH GRAPHNODES) of Graph)
	    when [AND (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of GraphNode)))
			  (COND
			    (LinkFlg (NC.SameLinkP LinkOrDestinationCard (NC.FetchLinkFromLinkIcon
						       LinkIcon)))
			    (T (NC.SameCardP (fetch (Link DestinationCard) of (
									 NC.FetchLinkFromLinkIcon
										      LinkIcon))
					       DestinationCard]
	    do (if (AND NC.UseDeletedLinkIconIndicatorsFlg (NOT Don'tCreateDeletedImageObjFlg)
			      )
		     then (replace (GRAPHNODE NODELABEL) of GraphNode with 
									NC.DeletedLinkImageObject)
			    (replace (GRAPHNODE NODEWIDTH) of GraphNode
			       with (fetch (IMAGEBOX XSIZE) of ImageBox))
			    (replace (GRAPHNODE NODEHEIGHT) of GraphNode
			       with (fetch (IMAGEBOX YSIZE) of ImageBox))
		   else (NC.GraphRemoveNode GraphNode Graph (NC.FetchWindow SourceCard)
						T)))
         (COND
	   ((AND (NC.ActiveCardP SourceCard)
		   (NC.FetchWindow SourceCard))
	     (REDISPLAYGRAPH (NC.FetchWindow SourceCard])

(NC.GraphChangeLabelFn
  [LAMBDA (Graph Window Node)                                (* pmi: "23-Jun-87 17:32")

          (* * pmi 6/23/87: Created to mark the card as dirty and prompt for the node label -
	  needed to make sure substance is marked dirty when a label is changed.)


    (LET ((GraphID (NC.CoerceToCard Window)))
         (NC.MarkCardDirty GraphID)
         (PROMPTINWINDOW "Node label?                  "])
)
(* * Hooks into Grapher for NoteCards applications)

(DEFINEQ

(NC.GRAPHERCOPYBUTTONEVENTFN
  (LAMBDA (Window)                                           (* rht: "15-Jul-86 18:12")

          (* * Handle a COPYBUTTONEVENT in a NC Grapher window. If the button is down over a node and the TTY PROCESS is a 
	  selecting cards process, process it as such, otherwise do the standard grapher copy button event fn of 
	  copyinserting he whole graph.)



          (* * fgh 6/30/86 First created.)



          (* * rht 7/15/86: Now calls NC.MakeExternalGraphCopy to smash NC links.)


    (LET ((Graph (WINDOWPROP Window (QUOTE GRAPH)))
	  InNode PositionAndLastState TTYWindow (Position (CONS 0 0)))
         (if (NOT (AND (WINDOWP (SETQ TTYWindow (PROCESSPROP (TTY.PROCESS)
									 (QUOTE WINDOW))))
			     (WINDOWPROP TTYWindow (QUOTE SelectingCards))))
	     then 

          (* * The current TTY PROCESS is not a selecting cards process -- insert a copy of the graph with the nc links 
	  smashed.)


		    (COPYINSERT (GRAPHEROBJ (NC.MakeExternalGraphCopy Graph)))
	   else 

          (* * We want to handle this special for NoteCards to allow shift-select of link icons in the graph)



          (* * First track the cursor until its let up)


		  (SETQ PositionAndLastState (NC.TrackCursorInGrapherWindow Window Graph)) 

          (* * Cursor up -- determine what to do)


		  (if (NULL (CAR PositionAndLastState))
		      then 

          (* * Let up outside the window -- get out of here)


			     NIL
		    else 

          (* * Find the node the mouse was when the buttons were let up -- if any)


			   (SETQ InNode (for GraphNode in (fetch (GRAPH GRAPHNODES)
								   of Graph)
					     thereis (NC.InsideGrapherNodeP
							 (PROGN (replace (POSITION XCOORD)
								     of Position
								     with (LASTMOUSEX Window))
								  (replace (POSITION YCOORD)
								     of Position
								     with (LASTMOUSEY Window))
								  Position)
							 GraphNode)))
			   (if (OR (NULL InNode)
				       (NULL (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL)
									  of InNode))))
			       then 

          (* * Let up innside the window, but not in a node. Or the Node is not a LinkIcon node. Do the standard COPYINSERTFN
	  for GRAPHER)


				      (COPYINSERT (GRAPHEROBJ (NC.MakeExternalGraphCopy Graph)))
			     else 

          (* * Let up inside a node, must want to select it.)


				    (COPYINSERT (fetch (GRAPHNODE NODELABEL) of InNode))))))))

(NC.InsideGrapherNodeP
  [LAMBDA (Position Node)                                    (* Randy.Gobbel "19-Nov-86 14:31")

          (* * Is position inside of graphernode Node)



          (* * fgh 6/30/86 First created.)



          (* * rg 11/19/86 Bug fix: Node was being referred to as GraphNode)


    (LET ((Left (GN/LEFT Node))
	  (Bottom (GN/BOTTOM Node)))
         (AND (GEQ (fetch (POSITION XCOORD) of Position)
		       Left)
		(LEQ (fetch (POSITION XCOORD) of Position)
		       (PLUS Left (fetch (GRAPHNODE NODEWIDTH) of Node)))
		(GEQ (fetch (POSITION YCOORD) of Position)
		       Bottom)
		(LEQ (fetch (POSITION YCOORD) of Position)
		       (PLUS Bottom (fetch (GRAPHNODE NODEHEIGHT) of Node)))
		Node])

(NC.GraphAddNodeFn
  (LAMBDA (Graph Window)                                     (* fgh: "18-Nov-85 00:19")

          (* * Add a node, normal or link, to a graph)



          (* * rht 11/9/84: Now checks result of NC.MakeLink before building link.)


    (PROG (LinkLabel Link (GraphCard (NC.CoerceToCard Window)))
	    (RETURN (COND
			((NULL (SETQ Link (WINDOWPROP Window (QUOTE NoteCardInsertingLink)
							    NIL)))
			  (NC.MarkCardDirty GraphCard)
			  (DEFAULT.ADDNODEFN Graph Window))
			((OR (type? Link Link)
			       (AND (SETQ LinkLabel (NC.AskLinkLabel Window NIL NIL T T))
				      (SETQ Link (NC.MakeLink Window LinkLabel))))
			  (NC.MarkCardDirty GraphCard)
			  (NODECREATE (for bind NodeID unless (FASSOC (SETQ NodeID
										  (GENSYM))
										(fetch
										  (GRAPH GRAPHNODES)
										   of Graph))
					   do (RETURN NodeID))
					(NC.MakeLinkIcon Link)
					(CURSORPOSITION NIL Window))))))))

(NC.GraphDeleteNodeFn
  [LAMBDA (Node Graph Window)                                (* rht: "13-May-87 12:32")

          (* * Just mark the card as dirty.)



          (* * rht 4/30/86: Now makes sure there's a window first.)



          (* * rht 5/13/87: Now deletes link if node is a link icon.)


    (LET ((GraphNodeLabel (fetch (GRAPHNODE NODELABEL) of Node)))
         (AND Window (NC.MarkCardDirty (NC.CoerceToCard Window)))
         (if (NC.LinkIconImageObjP GraphNodeLabel)
	     then (NC.DeleteLink (NC.FetchLinkFromLinkIcon GraphNodeLabel)
				     NIL T])

(NC.GraphAddLinkFn
  (LAMBDA (From To Graph Window)                             (* rht: "15-Nov-85 16:05")

          (* * Just mark the card as dirty.)


    (PROG ((GraphID (NC.CoerceToCard Window)))
	    (NC.MarkCardDirty GraphID))))

(NC.GraphDeleteLinkFn
  (LAMBDA (From To Graph Window)                             (* rht: "30-Apr-86 15:04")

          (* * Just mark the card as dirty.)



          (* * rht 4/30/86: Now makes sure there's a window first.)


    (AND Window (NC.MarkCardDirty (NC.CoerceToCard Window)))))

(NC.GraphMoveNodeFn
  (LAMBDA (Node Newpos Graph Window)                         (* rht: "15-Nov-85 16:05")

          (* * Just mark the card as dirty.)


    (PROG ((GraphID (NC.CoerceToCard Window)))
	    (NC.MarkCardDirty GraphID))))

(NC.GraphFontChangeFn
  (LAMBDA (How Node Graph Window)                            (* rht: "15-Nov-85 16:05")

          (* * Just mark the card as dirty.)


    (PROG ((GraphID (NC.CoerceToCard Window)))
	    (NC.MarkCardDirty GraphID))))

(NC.GraphRemoveNode
  (LAMBDA (Node Graph Window QuietFlg)                       (* rht: "30-Apr-86 16:19")

          (* * Remove this node from the graph. This code taken from Grapher's EDITDELETENODE)



          (* * rht 4/30/86: Added QuietFlg and other minor fixes.)


    (for ToNode in (TOLINKS Node) bind OtherNode
       do                                                  (* Undisplay links.)
	    (SETQ OtherNode (GETNODEFROMID (if (EQ (CAR ToNode)
							   LINKPARAMS)
						   then (CADR ToNode)
						 else ToNode)
					       (fetch (GRAPH GRAPHNODES) of Graph)))
	    (AND Window (NC.DisplayGraphLinksBetween Node OtherNode Window Graph))
	    (GRAPHDELETELINK Node OtherNode Graph Window))
    (for FromNode in (FROMLINKS Node) bind OtherNode
       do                                                  (* Undisplay links.)
	    (SETQ OtherNode (GETNODEFROMID (if (EQ (CAR FromNode)
							   LINKPARAMS)
						   then (CADR FromNode)
						 else FromNode)
					       (fetch (GRAPH GRAPHNODES) of Graph)))
	    (AND Window (NC.DisplayGraphLinksBetween OtherNode Node Window Graph))
	    (GRAPHDELETELINK OtherNode Node Graph Window))
    (AND Window (DISPLAYNODE Node (CONSTANT (create POSITION
							    XCOORD ← 0
							    YCOORD ← 0))
				 Window Graph))
    (GRAPHDELETENODE Node Graph Window)
    (OR QuietFlg (NC.PrintMsg NIL T "Node " (fetch (GRAPHNODE NODELABEL) of Node)
				  " removed."))
    Node))

(NC.TrackCursorInGrapherWindow
  (LAMBDA (Window Graph)                                     (* fgh: "30-Jun-86 13:44")

          (* * Follow the cursor around a graph window inverting nodes that its in until the mouse buttons are let up.)



          (* * fgh 6/30/86 First created.)


    (LET (Buttons NewInNode InNode (Position (CONS 0 0))
		  (DS (WINDOWPROP Window (QUOTE DSP))))
         (until (MOUSESTATE UP)
	    do 

          (* * Track the cursor until the mouse is up)


		 (SETQ Buttons LASTMOUSEBUTTONS)
		 (SETQ InNode NewInNode) 

          (* * Figure out if in a node)


		 (SETQ NewInNode (for GraphNode in (fetch (GRAPH GRAPHNODES) of Graph)
				      thereis (NC.InsideGrapherNodeP (PROGN
									   (replace (POSITION
											XCOORD)
									      of Position
									      with (LASTMOUSEX
										       Window))
									   (replace (POSITION
											YCOORD)
									      of Position
									      with (LASTMOUSEY
										       Window))
									   Position)
									 GraphNode)))

          (* * Uninvert the old node, invert the new node.)


		 (if (NEQ InNode NewInNode)
		     then (AND InNode (FLIPNODE InNode DS))
			    (AND NewInNode (FLIPNODE NewInNode DS))))

          (* * Univert anything that needs it)


         (AND NewInNode (FLIPNODE NewInNode DS))

          (* * Return a record of the mouse location at button up and the last mouse button that were dowen before let up)


         (CONS (CONS (LASTMOUSEX Window)
			 (LASTMOUSEY Window))
		 Buttons))))
)
(* * This stuff supports the "push-copy" method of copying links in NC)

(DEFINEQ

(NC.TranslateWindowPositionToGraphPosition
  (LAMBDA (Card Window WindowPositionX WindowPositionY)      (* fgh: " 6-Feb-86 22:15")

          (* * fgh 2/6/86 Added Card argument.)


    (create POSITION
	      XCOORD ← WindowPositionX
	      YCOORD ← WindowPositionY)))

(NC.InsertLinkInGraph
  (LAMBDA (Card GraphWindow Link Position)                   (* fgh: " 6-Feb-86 22:14")

          (* * Insert a Link in GraphWindow at Position)



          (* * fgh 2/6/86 Added Card argument)


    (PROG (Node (Graph (WINDOWPROP GraphWindow (QUOTE GRAPH))))
	    (WINDOWPROP GraphWindow (QUOTE NoteCardInsertingLink)
			  Link)
	    (OR (SETQ Node (GRAPHADDNODE Graph GraphWindow))
		  (RETURN))
	    (replace (GRAPHNODE NODEPOSITION) of Node with Position)
	    (MEASUREGRAPHNODE Node)
	    (PRINTDISPLAYNODE Node (CONSTANT (create POSITION
							   XCOORD ← 0
							   YCOORD ← 0))
				GraphWindow
				(DSPCLIPPINGREGION NIL GraphWindow))
	    (WINDOWPROP GraphWindow (QUOTE NoteCardInsertingLink)
			  NIL))))
)
(* * Stuff for shrinking graphs and browsers.)

(DECLARE: DONTEVAL@LOAD 

(RPAQ NC.ShrunkenGraphIconBM (READBITMAP))
(87 95
"AOOOOOOOOOOOOOOOOOOOOL@@"
"GOOOOOOOOOOOOOOOOOOOOL@@"
"OKMHOHNCHNCHNCHNCHNCHN@@"
"OOOOOOOOOOOOOOOOOOOOON@@"
"ONJJCLGALGALGALGALGALF@@"
"LOOOOOOOOOOOOOOOOOOOON@@"
"LCOJCLGALGALGALGALGALF@@"
"L@OOOOOOOOOOOOOOOOOOON@@"
"L@COOOOOOOOOOOOOOOOOON@@"
"L@@NGALGALGALGALGALGAL@@"
"L@@GOCLOCLOCLOCLOCLOCN@@"
"L@@ANAHFAHFAHFAHFAHFAN@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LCH@L@@@@@@@@@@@@@@@@N@@"
"LA@@L@@@@@@@@@@@@@@@@N@@"
"L@H@L@@@@@@@@@@@@@@@@N@@"
"L@D@L@@@@@@@@@@@@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"AOOOOOOOOOOOOOOOOOOOON@@"
"@OOOOOOOOOOOOOOOOOOOON@@"
"@GOOOOOOOOOOOOOOOOOOON@@"
"@COOOOOOOOOOOOOOOOOOON@@"
"@AOOOOOOOOOOOOOOOOOOON@@"
"@@OOOOOOOOOOOOOOOOOOON@@"
"@@COOOOOOOOOOOOOOOOOON@@")

(RPAQ NC.GraphCardIcon (READBITMAP))
(21 18
"OOOOOH@@"
"H@@@@H@@"
"H@@@@H@@"
"H@N@@H@@"
"H@J@@H@@"
"HAJ@@H@@"
"HBO@@H@@"
"HD@KHH@@"
"KH@FHH@@"
"JH@BHH@@"
"JH@CHH@@"
"KL@@@H@@"
"HBN@@H@@"
"HAJ@@H@@"
"H@J@@H@@"
"H@N@@H@@"
"H@@@@H@@"
"OOOOOH@@")
)
(DEFINEQ

(NC.GraphCardShrinkFn
  [LAMBDA (W)                                                (* Randy.Gobbel "19-Nov-86 15:02")

          (* * Check to make sure that icon's title agrees with card title. If not, retitle the icon.
	  If this is first shrink then create a new icon and fill in title.)



          (* * rg 11/19/86 Added GLOBALVARS declaration)


    (DECLARE (GLOBALVARS TEDIT.ICON.FONT NC.ShrunkenGraphIconTemplate))
    (LET ((OldIconTitle (WINDOWPROP W (QUOTE GRAPH.ICON.TITLE)))
	  (Icon (WINDOWPROP W (QUOTE ICON)))
	  (Card (NC.CoerceToCard W))
	  IconTitle BM IconTemplate BMHeight BMHalfHeight TitleRegion)
         (SETQ IconTitle (CONCAT "NC: " (NC.RetrieveTitle Card)))
         [COND
	   ((NOT Icon)
	     (WINDOWPROP W (QUOTE ICON)
			   (SETQ Icon (TITLEDICONW NC.ShrunkenGraphIconTemplate IconTitle 
						       TEDIT.ICON.FONT NIL T]
         (COND
	   ((NOT (EQUAL OldIconTitle IconTitle))
	     (WINDOWPROP W (QUOTE GRAPH.ICON.TITLE)
			   IconTitle)
	     (ICONTITLE IconTitle TitleRegion NIL Icon])
)
(DECLARE: DONTEVAL@LOAD 

(RPAQ NC.ShrunkenGraphIconTemplate (create TITLEDICON ICON ← NC.ShrunkenGraphIconBM MASK ← 
					     NC.ShrunkenGraphIconMask TITLEREG ←
					     (QUOTE (16 4 64 77))))
)
(* * Stuff for making copies of graphs for making imageobj's.)

(DEFINEQ

(NC.MakeExternalGraphCopy
  (LAMBDA (Graph)                                            (* rht: "24-Mar-86 15:50")

          (* * Make a copy of Graph in which each link icon nodelabel has been replaced by a copy of itself and MoveNodeFn, 
	  etc. are replaced by NIL.)



          (* * rht 3/24/86: Now creates new graphnodes via "using" instead of "copying" to preserve EQness of UIDs.)


    (create GRAPH
	      DIRECTEDFLG ← (fetch (GRAPH DIRECTEDFLG) of Graph)
	      SIDESFLG ← (fetch (GRAPH SIDESFLG) of Graph)
	      GRAPHNODES ← (for GraphNode in (fetch (GRAPH GRAPHNODES) of Graph)
				bind Box NewNode Label
				collect (LET (NewLinkIcon)
					       (PROG1 (SETQ NewNode
							  (create GRAPHNODE
							     using
							      GraphNode NODELABEL ←
							      (if (NC.LinkIconImageObjP
								      (SETQ Label
									(fetch (GRAPHNODE NODELABEL)
									   of GraphNode)))
								  then (SETQ NewLinkIcon
									   (NC.LinkIconCopyFn
									     Label))
								else (COPY Label))))
							(if NewLinkIcon
							    then (SETQ Box
								     (
								 NC.ExternalPutLinkIconImageBoxFn
								       NewLinkIcon NIL NIL NIL))
								   (replace (GRAPHNODE NODEHEIGHT)
								      of NewNode
								      with (fetch (IMAGEBOX
											YSIZE)
										of Box))
								   (replace (GRAPHNODE NODEWIDTH)
								      of NewNode
								      with (fetch (IMAGEBOX
											XSIZE)
										of Box)))))))))
)
(* * Add the Graph card to the cardtypes list.)

(DEFINEQ

(NC.AddGraphCard
  [LAMBDA NIL                                                (* pmi: "26-May-87 10:59")

          (* * fgh 11/14/85: Updated to conform to merge of substance and card types.)



          (* * fgh 2/17/86 Added attached bitmap field.)



          (* * rht 4/7/86: Added middle button menu items.)



          (* * pmi 5/26/87: Changed default card size as requested by Cathy Marshall.)


    (NC.AddCardType (QUOTE Graph)
		      (QUOTE NoteCard)
		      [BQUOTE ((MakeFn , (FUNCTION NC.MakeGraphCard))
				 (EditFn , (FUNCTION NC.BringUpGraphCard))
				 (QuitFn , (FUNCTION NC.GraphCardCloseFn))
				 (GetFn , (FUNCTION NC.GetGraphSubstance))
				 (PutFn , (FUNCTION NC.PutGraphSubstance))
				 (CopyFn , (FUNCTION NC.GraphCopySubstance))
				 (MarkDirtyFn , (FUNCTION NC.MarkGraphDirty))
				 (DirtyPFn , (FUNCTION NC.GraphDirtyP))
				 (CollectLinksFn , (FUNCTION NC.CollectReferencesInGraph))
				 (DeleteLinksFn , (FUNCTION NC.DelReferencesToCardFromGraph))
				 (UpdateLinkIconsFn , (FUNCTION NC.UpdateLinkImagesInGraph))
				 (InsertLinkFn , (FUNCTION NC.InsertLinkInGraph))
				 (TranslateWindowPositionFn , (FUNCTION 
							NC.TranslateWindowPositionToGraphPosition]
		      (BQUOTE ((LinkDisplayMode Title)
				 (DisplayedInMenuFlg , T)
				 (DefaultWidth 500)
				 (DefaultHeight 330)
				 (LinkAnchorModesSupported T)
				 (LinkIconAttachedBitMap , NC.GraphCardIcon)
				 (MiddleButtonMenuItems , (QUOTE ((Relayout% Graph
								       (FUNCTION 
									 NC.RelayoutGraphCard)
								       
						      "Re-layout the graph, but keep same nodes."])
)
(DECLARE: DONTEVAL@LOAD 
(NC.AddGraphCard)
)
(PUTPROPS NCGRAPHCARD COPYRIGHT ("Xerox Corporation" 1985 1986 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2821 3342 (NCAddStub.GraphCard 2831 . 3340)) (3648 25260 (NC.MakeGraphCard 3658 . 5794)
 (NC.BringUpGraphCard 5796 . 7685) (NC.RelayoutGraphCard 7687 . 9866) (NC.CollectReferencesInGraph 
9868 . 11851) (NC.GraphCardCloseFn 11853 . 12672) (NC.GraphCardLeftButtonFn 12674 . 13991) (
NC.GraphCardMiddleButtonFn 13993 . 15030) (NC.GraphCopySubstance 15032 . 15753) (NC.MarkGraphDirty 
15755 . 15968) (NC.GraphDirtyP 15970 . 16375) (NC.GraphNodeLinkIconUpdate 16377 . 18288) (
NC.GetGraphSubstance 18290 . 19290) (NC.PutGraphSubstance 19292 . 20360) (NC.UpdateLinkImagesInGraph 
20362 . 22212) (NC.DelReferencesToCardFromGraph 22214 . 24805) (NC.GraphChangeLabelFn 24807 . 25258)) 
(25319 35064 (NC.GRAPHERCOPYBUTTONEVENTFN 25329 . 28047) (NC.InsideGrapherNodeP 28049 . 28889) (
NC.GraphAddNodeFn 28891 . 29962) (NC.GraphDeleteNodeFn 29964 . 30593) (NC.GraphAddLinkFn 30595 . 30855
) (NC.GraphDeleteLinkFn 30857 . 31176) (NC.GraphMoveNodeFn 31178 . 31439) (NC.GraphFontChangeFn 31441
 . 31704) (NC.GraphRemoveNode 31706 . 33351) (NC.TrackCursorInGrapherWindow 33353 . 35062)) (35143 
36290 (NC.TranslateWindowPositionToGraphPosition 35153 . 35446) (NC.InsertLinkInGraph 35448 . 36288)) 
(41851 42997 (NC.GraphCardShrinkFn 41861 . 42995)) (43270 44931 (NC.MakeExternalGraphCopy 43280 . 
44929)) (44986 46688 (NC.AddGraphCard 44996 . 46686)))))
STOP