(FILECREATED " 6-Feb-86 23:56:33" {QV}<NOTECARDS>1.3K>FGHPATCH018.;12 72294  

      changes to:  (FNS NC.GetMainCardData NC.PutMainCardData NC.PutTextSubstance 
			NC.PutSketchSubstance NC.ListCardPutFn NC.PutFileSubstance 
			NC.PutGraphSubstance NC.MakeFileBox NC.MarkCardDirty NC.InsertLinkInSketch 
			NC.TranslateWindowPositionToSketchPosition NC.InsertLinkInTextWindow 
			NC.TranslateWindowPositionToTEditPosition NC.InsertLinkInGraph 
			NC.TranslateWindowPositionToGraphPosition NC.PushCopyLinkIcon NC.CardDirtyP 
			NC.UpdateLinkImages NC.QuitCard NC.MakeNoteCard NC.WriteMainCardData 
			NC.AddSketchCard NC.LinkIconDisplayFn NC.FetchLinkIconAttachedBitMap 
			NC.FetchLinkDisplayMode NC.FetchDefaultWidth NC.FetchDefaultHeight 
			NC.FetchLinkAnchorModesSupported NC.DetermineDisplayRegion NC.MakeDummyRegion 
			NC.MakeLink NC.MakeCardTypesList NC.CardTypeRecord NC.ListOfCardTypes 
			NC.AddCardType NC.SubTypesOfCardType NC.DeleteCardType 
			NC.DefaultLinkDisplayMode NC.AskNoteCardType)
		   (VARS FGHPATCH018COMS)
		   (RECORDS Card NoteCardType)
		   (MACROS NC.Inherit)

      previous date: "31-Jan-86 22:05:20" {QV}<NOTECARDS>1.3K>FGHPATCH018.;4)


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

(PRETTYCOMPRINT FGHPATCH018COMS)

(RPAQQ FGHPATCH018COMS ((* * Changes to types mech)
			  (* * From NCCARDS)
			  (* * Delete from NCLINKS obsolete -- NC.DefaultLinkDisplayMode 
			     NC.LinkAnchorModesFromType)
			  (RECORDS Card)
			  (FNS NC.DetermineDisplayRegion NC.MakeDummyRegion NC.CardDirtyP NC.QuitCard 
			       NC.MakeNoteCard NC.MarkCardDirty NC.CollectReferences NC.EditNoteCard)
			  (* * New FNS FOR NCCARDS)
			  (FNS NC.FetchLinkIconAttachedBitMap NC.FetchLinkDisplayMode 
			       NC.FetchDefaultWidth NC.FetchDefaultHeight 
			       NC.FetchLinkAnchorModesSupported)
			  (* * FROM NCDATABASE)
			  (FNS NC.PutMainCardData NC.GetMainCardData)
			  (* * From NCINTERFACE)
			  (FNS NC.AskNoteCardType)
			  (* * From NCLINKS)
			  (FNS NC.DefaultLinkDisplayMode NC.LinkIconDisplayFn NC.MakeLink 
			       NC.LinksSupportedP NC.PushCopyLinkIcon NC.UpdateLinkImages 
			       NC.DelReferencesToCard NC.FetchLinkIconForLink)
			  (* * FROM NCREPAIR)
			  (FNS NC.RobustGetSubstance NC.CollectAndCheckLinks)
			  (* * FROM NCSKETCHCARD)
			  (FNS NC.AddSketchCard NC.InsertLinkInSketch 
			       NC.TranslateWindowPositionToSketchPosition NC.PutSketchSubstance)
			  (* * FROM NCTEXTCARD)
			  (FNS NC.InsertLinkInTextWindow NC.TranslateWindowPositionToTEditPosition 
			       NC.PutTextSubstance)
			  (* * FROM NCGRAPHCARD)
			  (FNS NC.InsertLinkInGraph NC.TranslateWindowPositionToGraphPosition 
			       NC.PutGraphSubstance)
			  (* * FROM NCFILEBOXCARD)
			  (FNS NC.MakeFileBox)
			  (* * FROM NCBROWSERCARD)
			  (FNS NC.QuitBrowserCard NC.PutBrowserSubstance NC.BringUpBrowserCard)
			  (* * from NCLISTCARD)
			  (FNS NC.ListCardPutFn)
			  (* * from NCFILECARD)
			  (FNS NC.PutFileSubstance)))
(* * Changes to types mech)

(* * From NCCARDS)

(* * Delete from NCLINKS obsolete -- NC.DefaultLinkDisplayMode NC.LinkAnchorModesFromType)

[DECLARE: EVAL@COMPILE 

(ACCESSFNS Card (

          (* * Instance variables of the card object)


		   (UID (fetch (CardObject UID) of DATUM)
			(replace (CardObject UID) of DATUM with NEWVALUE))
		   (NoteFile (LET ((\NF (fetch (CardObject NoteFile) of DATUM)))
			          (COND
				    ((type? NoteFile \NF)
				      \NF)
				    (\NF (replace (CardObject NoteFile) of DATUM
					    with (NC.NoteFileFromNoteFileUID \NF)))))
			     (replace (CardObject NoteFile) of DATUM with NEWVALUE))
		   (Monitor (fetch (CardObject Monitor) of DATUM)
			    (replace (CardObject Monitor) of DATUM with NEWVALUE))
		   (Status (fetch (CardObject Status) of DATUM)
			   (replace (CardObject Status) of DATUM with NEWVALUE))
		   (IndexDirtyFlg (fetch (CardObject IndexDirtyFlg) of DATUM)
				  (replace (CardObject IndexDirtyFlg) of DATUM with NEWVALUE))
		   (IndexLoc (fetch (CardObject IndexLoc) of DATUM)
			     (replace (CardObject IndexLoc) of DATUM with NEWVALUE))
		   (MainLoc (fetch (CardObject MainLoc) of DATUM)
			    (replace (CardObject MainLoc) of DATUM with NEWVALUE))
		   (LinksLoc (fetch (CardObject LinksLoc) of DATUM)
			     (replace (CardObject LinksLoc) of DATUM with NEWVALUE))
		   (PropListLoc (fetch (CardObject PropListLoc) of DATUM)
				(replace (CardObject PropListLoc) of DATUM with NEWVALUE))
		   (TitleLoc (fetch (CardObject TitleLoc) of DATUM)
			     (replace (CardObject TitleLoc) of DATUM with NEWVALUE))
		   (Title (fetch (CardObject Title) of DATUM)
			  (replace (CardObject Title) of DATUM with NEWVALUE))
		   (TitleDirtyFlg (fetch (CardObject TitleDirtyFlg) of DATUM)
				  (replace (CardObject TitleDirtyFlg) of DATUM with NEWVALUE))
		   (Type (fetch (CardObject Type) of DATUM)
			 (replace (CardObject Type) of DATUM with NEWVALUE))
		   (ActiveFlg (fetch (CardObject ActiveFlg) of DATUM)
			      (replace (CardObject ActiveFlg) of DATUM with NEWVALUE))
		   (ActiveCardFlg (fetch (CardObject ActiveFlg) of DATUM)
				  (replace (CardObject ActiveFlg) of DATUM with NEWVALUE))
		   (CardCache (fetch (CardObject CardCache) of DATUM)
			      (replace (CardObject CardCache) of DATUM with NEWVALUE))
		   (UserData (fetch (CardObject UserData) of DATUM)
			     (replace (CardObject UserData) of DATUM with NEWVALUE))
		   (Substance (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			           (AND \Cache (fetch (CardCache Substance) of \Cache)))
			      (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			           (COND
				     (\Cache (replace (CardCache Substance) of \Cache
						with NEWVALUE))
				     (T (replace (CardObject CardCache) of DATUM
					   with (create CardCache
							    Substance ← NEWVALUE))
					NEWVALUE))))
		   (Links (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			       (AND \Cache (fetch (CardCache Links) of \Cache)))
			  (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			       (COND
				 (\Cache (replace (CardCache Links) of \Cache with NEWVALUE))
				 (T (replace (CardObject CardCache) of DATUM
				       with (create CardCache
							Links ← NEWVALUE))
				    NEWVALUE))))
		   (FromLinks (LET ((\Cache (fetch (CardObject CardCache) of DATUM))
				    \Links)
			           (AND \Cache (SETQ \Links (fetch (CardCache Links)
								   of \Cache))
					  (fetch (LinksCache FromLinks) of \Links)))
			      (LET ((\Cache (OR (fetch (CardObject CardCache) of DATUM)
						  (replace (CardObject CardCache) of DATUM
						     with (create CardCache))))
				    \Links)
			           (SETQ \Links (fetch (CardCache Links) of \Cache))
			           (COND
				     (\Links (replace (LinksCache FromLinks) of \Links
						with NEWVALUE))
				     (T (replace (CardCache Links) of \Cache
					   with (create LinksCache
							    FromLinks ← NEWVALUE))
					NEWVALUE))))
		   (ToLinks (LET ((\Cache (fetch (CardObject CardCache) of DATUM))
				  \Links)
			         (AND \Cache (SETQ \Links (fetch (CardCache Links)
								 of \Cache))
					(fetch (LinksCache ToLinks) of \Links)))
			    (LET ((\Cache (OR (fetch (CardObject CardCache) of DATUM)
						(replace (CardObject CardCache) of DATUM
						   with (create CardCache))))
				  \Links)
			         (SETQ \Links (fetch (CardCache Links) of \Cache))
			         (COND
				   (\Links (replace (LinksCache ToLinks) of \Links with 
											 NEWVALUE))
				   (T (replace (CardCache Links) of \Cache
					 with (create LinksCache
							  ToLinks ← NEWVALUE))
				      NEWVALUE))))
		   (GlobalLinks (LET ((\Cache (fetch (CardObject CardCache) of DATUM))
				      \Links)
				     (AND \Cache (SETQ \Links (fetch (CardCache Links)
								     of \Cache))
					    (fetch (LinksCache GlobalLinks) of \Links)))
				(LET ((\Cache (OR (fetch (CardObject CardCache) of DATUM)
						    (replace (CardObject CardCache) of DATUM
						       with (create CardCache))))
				      \Links)
				     (SETQ \Links (fetch (CardCache Links) of \Cache))
				     (COND
				       (\Links (replace (LinksCache GlobalLinks) of \Links
						  with NEWVALUE))
				       (T (replace (CardCache Links) of \Cache
					     with (create LinksCache
							      GlobalLinks ← NEWVALUE))
					  NEWVALUE))))
		   (PropList (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			          (AND \Cache (fetch (CardCache PropList) of \Cache)))
			     (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			          (COND
				    (\Cache (replace (CardCache PropList) of \Cache with 
											 NEWVALUE))
				    (T (replace (CardObject CardCache) of DATUM
					  with (create CardCache
							   PropList ← NEWVALUE))
				       NEWVALUE))))
		   (Region (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			        (AND \Cache (fetch (CardCache Region) of \Cache)))
			   (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			        (COND
				  (\Cache (replace (CardCache Region) of \Cache with NEWVALUE))
				  (T (replace (CardObject CardCache) of DATUM
					with (create CardCache
							 Region ← NEWVALUE))
				     NEWVALUE))))
		   (SavedRegion (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				     (AND \Cache (fetch (CardCache SavedRegion) of \Cache)))
				(LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				     (COND
				       (\Cache (replace (CardCache SavedRegion) of \Cache
						  with NEWVALUE))
				       (T (replace (CardObject CardCache) of DATUM
					     with (create CardCache
							      SavedRegion ← NEWVALUE))
					  NEWVALUE))))
		   (ItemDate (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			          (AND \Cache (fetch (CardCache ItemDate) of \Cache)))
			     (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			          (COND
				    (\Cache (replace (CardCache ItemDate) of \Cache with 
											 NEWVALUE))
				    (T (replace (CardObject CardCache) of DATUM
					  with (create CardCache
							   ItemDate ← NEWVALUE))
				       NEWVALUE))))
		   (LinksDate (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			           (AND \Cache (fetch (CardCache LinksDate) of \Cache)))
			      (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			           (COND
				     (\Cache (replace (CardCache LinksDate) of \Cache
						with NEWVALUE))
				     (T (replace (CardObject CardCache) of DATUM
					   with (create CardCache
							    LinksDate ← NEWVALUE))
					NEWVALUE))))
		   (TitleDate (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			           (AND \Cache (fetch (CardCache TitleDate) of \Cache)))
			      (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
			           (COND
				     (\Cache (replace (CardCache TitleDate) of \Cache
						with NEWVALUE))
				     (T (replace (CardObject CardCache) of DATUM
					   with (create CardCache
							    TitleDate ← NEWVALUE))
					NEWVALUE))))
		   (PropListDate (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				      (AND \Cache (fetch (CardCache PropListDate) of \Cache)))
				 (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				      (COND
					(\Cache (replace (CardCache PropListDate) of \Cache
						   with NEWVALUE))
					(T (replace (CardObject CardCache) of DATUM
					      with (create CardCache
							       PropListDate ← NEWVALUE))
					   NEWVALUE))))
		   (LinksDirtyFlg (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				       (AND \Cache (fetch (CardCache LinksDirtyFlg) of \Cache)))
				  (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				       (COND
					 (\Cache (replace (CardCache LinksDirtyFlg) of \Cache
						    with NEWVALUE))
					 (T (replace (CardObject CardCache) of DATUM
					       with (create CardCache
								LinksDirtyFlg ← NEWVALUE))
					    NEWVALUE))))
		   (PropListDirtyFlg (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				          (AND \Cache (fetch (CardCache PropListDirtyFlg)
							   of \Cache)))
				     (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				          (COND
					    (\Cache (replace (CardCache PropListDirtyFlg)
						       of \Cache with NEWVALUE))
					    (T (replace (CardObject CardCache) of DATUM
						  with (create CardCache
								   PropListDirtyFlg ← NEWVALUE))
					       NEWVALUE))))
		   (SubstanceDirtyFlg (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				           (AND \Cache (fetch (CardCache SubstanceDirtyFlg)
							    of \Cache)))
				      (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				           (COND
					     (\Cache (replace (CardCache SubstanceDirtyFlg)
							of \Cache with NEWVALUE))
					     (T (replace (CardObject CardCache) of DATUM
						   with (create CardCache
								    SubstanceDirtyFlg ← NEWVALUE))
						NEWVALUE))))
		   (NewCardFlg (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				    (AND \Cache (fetch (CardCache NewCardFlg) of \Cache)))
			       (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				    (COND
				      (\Cache (replace (CardCache NewCardFlg) of \Cache
						 with NEWVALUE))
				      (T (replace (CardObject CardCache) of DATUM
					    with (create CardCache
							     NewCardFlg ← NEWVALUE))
					 NEWVALUE))))
		   (BeingDeletedFlg (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				         (AND \Cache (fetch (CardCache BeingDeletedFlg)
							  of \Cache)))
				    (LET ((\Cache (fetch (CardObject CardCache) of DATUM)))
				         (COND
					   (\Cache (replace (CardCache BeingDeletedFlg)
						      of \Cache with NEWVALUE))
					   (T (replace (CardObject CardCache) of DATUM
						 with (create CardCache
								  BeingDeletedFlg ← NEWVALUE))
					      NEWVALUE))))

          (* * Class variables of the card object {class == card type})


		   (SuperType (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			           (NC.GetCardTypeField SuperType NoteCardType)))
		   (LinkDisplayMode (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				         (NC.GetCardTypeField LinkDisplayMode NoteCardType)))
		   (DefaultWidth (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				      (NC.GetCardTypeField DefaultWidth NoteCardType)))
		   (DefaultHeight (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				       (NC.GetCardTypeField DefaultHeight NoteCardType)))
		   (LinkAnchorModesSupported (LET ((NoteCardType (fetch (Card Type) of DATUM)))
					          (NC.GetCardTypeField LinkAnchorModesSupported 
								       NoteCardType)))
		   (LinkIconAttachedBitMap (LET ((NoteCardType (fetch (Card Type) of DATUM)))
					        (NC.GetCardTypeField LinkIconAttachedBitMap 
								     NoteCardType)))

          (* * Methods of the card object {class == card type})


		   (MakeFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			        (NC.GetCardTypeField MakeFn NoteCardType)))
		   (EditFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			        (NC.GetCardTypeField EditFn NoteCardType)))
		   (QuitFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			        (NC.GetCardTypeField QuitFn NoteCardType)))
		   (GetFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			       (NC.GetCardTypeField GetFn NoteCardType)))
		   (PutFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			       (NC.GetCardTypeField PutFn NoteCardType)))
		   (CopyFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			        (NC.GetCardTypeField CopyFn NoteCardType)))
		   (MarkDirtyFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				     (NC.GetCardTypeField MarkDirtyFn NoteCardType)))
		   (DirtyPFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
			          (NC.GetCardTypeField DirtyPFn NoteCardType)))
		   (CollectLinksFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				        (NC.GetCardTypeField CollectLinksFn NoteCardType)))
		   (DeleteLinksFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				       (NC.GetCardTypeField DeleteLinksFn NoteCardType)))
		   (UpdateLinkIconsFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				           (NC.GetCardTypeField UpdateLinkIconsFn NoteCardType)))
		   (InsertLinkFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
				      (NC.GetCardTypeField InsertLinkFn NoteCardType)))
		   (TranslateWindowPositionFn (LET ((NoteCardType (fetch (Card Type) of DATUM)))
					           (NC.GetCardTypeField TranslateWindowPositionFn 
									NoteCardType))))
		  (CREATE (create CardObject))
		  (TYPE? (TYPE? CardObject DATUM)))
]
(DEFINEQ

(NC.DetermineDisplayRegion
  (LAMBDA (Card Region/Position)                             (* fgh: " 5-Feb-86 13:59")

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



          (* * fgh 2/5/86 Changed names DefaultcardWidth to FeatchDefaultWidth ...)


    (LET (DefaultHeight Region)
         (COND
	   ((type? REGION Region/Position)
	     Region/Position)
	   ((POSITIONP Region/Position)
	     (COND
	       ((SETQ Region (NC.FetchRegion Card))
		 (CREATEREGION (fetch (POSITION XCOORD) of Region/Position)
				 (fetch (POSITION YCOORD) of Region/Position)
				 (fetch (REGION WIDTH) of Region)
				 (fetch (REGION HEIGHT) of Region)))
	       (T (CREATEREGION (fetch XCOORD of Region/Position)
				  (fetch YCOORD of Region/Position)
				  (NC.FetchDefaultWidth Card)
				  (NC.FetchDefaultHeight Card)))))
	   ((AND NC.BringUpCardAtOldPosFlg (NC.FetchRegion Card)))
	   (T (COND
		((SETQ Region (NC.FetchRegion Card))
		  (GETBOXREGION (fetch WIDTH of Region)
				  (fetch HEIGHT of Region)
				  (GETMOUSEX)
				  (IDIFFERENCE (GETMOUSEY)
						 (fetch HEIGHT of Region))
				  NIL
				  (CONCAT "Please specify location for Note Card " (NC.FetchTitle
					      Card))))
		(T (GETBOXREGION (NC.FetchDefaultWidth Card)
				   (NC.FetchDefaultHeight Card)
				   (GETMOUSEX)
				   (IDIFFERENCE (GETMOUSEY)
						  (NC.FetchDefaultHeight Card))
				   NIL
				   (CONCAT "Please specify location for Note Card " (NC.FetchTitle
					       Card))))))))))

(NC.MakeDummyRegion
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 13:59")

          (* * Returns a region based at (0 0) with default width and height according to Type.)



          (* * fgh 2/5/86 Changed names DefaultcardWidth to FeatchDefaultWidth ...)


    (CREATEREGION 0 0 (NC.FetchDefaultWidth Card)
		    (NC.FetchDefaultHeight Card))))

(NC.CardDirtyP
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 20:01")

          (* * Return T if card ID has been changed.)



          (* * rht 2/1/85: Now also checks flag on prop list.)



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



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


    (OR (NC.ApplyFn DirtyPFn Card)
	  (NC.FetchSubstanceDirtyFlg Card))))

(NC.QuitCard
  (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg)         (* fgh: " 5-Feb-86 20:02")

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


    (PROG ((Card (NC.CoerceToCard CardIdentifier))
	     Window)
	    (SETQ Window (NC.FetchWindow Card))          (* The window not being open should mean that it's 
							     shrunken. If so, expand it.)
	    (COND
	      ((NOT (OPENWP Window))
		(EXPANDW Window)))
	    (OR DontSaveFlg (COND
		    ((EQ (NC.InsureProperFiling Card)
			   (QUOTE CANCELLED))
		      (RETURN (QUOTE DON'T)))))
	    (COND
	      ((AND Window NC.CloseCardsOffScreenFlg)
		(COND
		  ((NOT (NC.FetchSavedRegion Card))
		    (NC.SetSavedRegion Card (WINDOWPROP Window (QUOTE REGION)))))
		(MOVEW Window 1500 1500)))
	    (OR DontSaveFlg (NC.CardSaveFn Card NC.CloseCardsOffScreenFlg))
	    (AND Window (WINDOWDELPROP Window (QUOTE CLOSEFN)
					   (FUNCTION NC.QuitCard)))
	    (RETURN (PROG1 (NC.ApplyFn QuitFn Card)
			       (AND CallCloseWFlg Window (CLOSEW Window))

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


			       (if (NC.TopLevelCardP Card)
				   then (NCP.ActivateCards Card)))))))

(NC.MakeNoteCard
  (LAMBDA (NoteCardType NoteFile Title NoDisplayFlg TypeSpecificArgs Card)
                                                             (* fgh: " 5-Feb-86 20:03")
                                                             (* Make a new note card of type NoteCardType.
							     If type note specified, ask the user.)

          (* * rht 2/1/85: Added call to NC.MarkCardDirty.)



          (* * fgh 10/15/85 Added extra DatabaseStream argument for use by caching mechanism)



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



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


    (LET (ReturnValue Window)
         (COND
	   ((SETQ NoteCardType (OR NoteCardType (NC.AskNoteCardType (fetch (NoteFile Menu)
									     of NoteFile))))
	     (SETQ Card (OR (PROGN (type? Card Card)
					 Card)
				(NC.GetNewCard NoteFile)))
	     (NC.SetNewCardFlg Card T)
	     (NC.ActivateCard Card)
	     (NC.SetType Card NoteCardType)
	     (COND
	       ((OR (NULL (ERSETQ (SETQ ReturnValue (NC.ApplyFn MakeFn Card Title 
									NoDisplayFlg TypeSpecificArgs)
					  )))
		      (NULL ReturnValue))
		 (NC.SetStatus Card (QUOTE DELETED))
		 (NC.DeactivateCard Card T))
	       (T (SETQ Window (WINDOWP ReturnValue))
		  (COND
		    ((NULL (NC.RetrieveTitle Card))
		      (SETQ Title (NC.SetTitle Card (SETQ Title (COND
						       ((STRINGP Title)
							 Title)
						       ((AND Title (OR (LITATOM Title)
									   (NUMBERP Title)))
							 (MKSTRING Title))
						       (T "Untitled")))))
		      (AND Window (WINDOWPROP Window (QUOTE TITLE)
						  Title)))
		    (T (NC.SetTitle Card (MKSTRING (NC.RetrieveTitle Card)))))
		  (COND
		    (Window (WINDOWADDPROP Window (QUOTE CLOSEFN)
					     (FUNCTION NC.QuitCard)
					     (QUOTE FIRST))
			    (WINDOWPROP Window (QUOTE NoteCardObject)
					  Card)
			    (WINDOWPROP Window (QUOTE OldCopyButtonEventFn)
					  (WINDOWPROP Window (QUOTE COPYBUTTONEVENTFN)
							(FUNCTION NC.CopyButtonEventFn)))))
		  (NC.SetTitleDirtyFlg Card T)             (* Reset the type in case of recursive calls change 
							     the type. Always want the highest level type in a 
							     recursive descent)
		  (NC.SetType Card NoteCardType)           (* Insure that a link ptr is set up during the first 
							     save)
		  (NC.SetLinksDirtyFlg Card T)
		  (NC.SetPropListDirtyFlg Card T)          (* Mark that substance is dirty.)
		  (NC.MarkCardDirty Card T)))
	     ReturnValue)))))

(NC.MarkCardDirty
  (LAMBDA (Card ResetFlg)                                    (* fgh: " 6-Feb-86 22:03")
                                                             (* Mark card specified by ID as being DIRTY and 
							     needing to be writtent to the database)

          (* * rht 2/1/85: Now also sets/resets property on ID indicating substance dirty.)



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



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


    (NC.ApplyFn MarkDirtyFn Card ResetFlg)
    (NC.SetSubstanceDirtyFlg Card (NOT ResetFlg))))

(NC.CollectReferences
  (LAMBDA (Card CheckAndDeleteFlg ReturnLinkIconsFlg ReturnLocationsFlg)
                                                             (* fgh: " 5-Feb-86 19:54")

          (* * Collect all the links in a card specified by ID. RETURNS the CONS of a list of link identifiers {described 
	  below} and a dirtyflg that is non-NIL if the Substance of ID has been modified {i.e., when a non-valid link is 
	  found and CheckAndDeleteFlg is NIL}. IF CheckAndDeleteFlg is non-NIL checks for valid links and deletes those that 
	  are not valid. If ReturnLinkIconsFlg is NIL, returns link icons. Otherwise, returns links. If ReturnLinkIconsFlg is
	  NIL, returns just the links/link icons. Otherwise, returns the CONS of link/link icon and the type-specific 
	  location of the link icon in the card.)



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



          (* * rht 12/19/85: Fixed to handle types with no CollectReferencesFn defined.)



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


    (COND
      ((NC.ActiveCardP Card)
	(NC.ApplyFn CollectLinksFn Card CheckAndDeleteFlg ReturnLinkIconsFlg ReturnLocationsFlg))
      (T (NC.ReportError "NC.CollectReferences" (CONCAT "Attempt to call with inactive card:  " 
							    Card))))))

(NC.EditNoteCard
  (LAMBDA (Card Region/Position)                             (* fgh: " 5-Feb-86 19:49")

          (* * Bring the already created NoteCard specified by ID onto the screen at Region or Position specified by 
	  Region/Position)



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



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


    (RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
		(LET (NoteCardType Window Substance)
		     (COND
		       ((NC.ActiveCardP Card)
			 (SETQ Substance (NC.FetchSubstance Card)))
		       (T (NC.GetNoteCard Card)
			  (SETQ Substance (NC.FetchSubstance Card))))
		     (SETQ NoteCardType (NC.RetrieveType Card))
		     (COND
		       ((WINDOWP (SETQ Window (NC.ApplyFn EditFn Card Substance Region/Position)))
			 (WINDOWADDPROP Window (QUOTE CLOSEFN)
					  (FUNCTION NC.QuitCard)
					  (QUOTE FIRST))
			 (WINDOWPROP Window (QUOTE NoteCardObject)
				       Card)
			 (WINDOWPROP Window (QUOTE OldCopyButtonEventFn)
				       (WINDOWPROP Window (QUOTE COPYBUTTONEVENTFN)
						     (FUNCTION NC.CopyButtonEventFn)))))
		 Window))))
)
(* * New FNS FOR NCCARDS)

(DEFINEQ

(NC.FetchLinkIconAttachedBitMap
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 13:40")

          (* * Return the default link icon attached bit map corresponding to Card)



          (* * fgh 2/5/86 First created.)


    (fetch (Card LinkIconAttachedBitMap) of Card)))

(NC.FetchLinkDisplayMode
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 13:40")

          (* * Fetch the default link display mode corresponding to Card)



          (* * fgh 2/5/86 First created.)


    (fetch (Card LinkDisplayMode) of Card)))

(NC.FetchDefaultWidth
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 13:42")

          (* * Fetch the default width corresponding to Card)



          (* * fgh 2/5/86 First created.)


    (fetch (Card DefaultWidth) of Card)))

(NC.FetchDefaultHeight
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 13:43")

          (* * Fetch default height corresponding to Card)



          (* * fgh 2/5/86 First created.)


    (fetch (Card DefaultHeight) of Card)))

(NC.FetchLinkAnchorModesSupported
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 13:45")

          (* * Fetch the link anchor modes supported of Card)


    (fetch (Card LinkAnchorModesSupported) of Card)))
)
(* * FROM NCDATABASE)

(DEFINEQ

(NC.PutMainCardData
  (LAMBDA (Card UpdateUpdateListFlg UseOldDateFlg)           (* fgh: " 6-Feb-86 22:50")

          (* * Write note card specified by ID to the database specified by Database stream)



          (* * rht 7/9/85: Now puts out date after identifier. If UseOldDateFlg is non-nil, then use old date, otherwise use 
	  current date.)



          (* * rht 11/10/85: Updated to handle NoteFile and Card scheme.)



          (* * fgh 11/20/85 Added call to NC.WriteCardPartHeader and the mechanism to write the start and end pointers of the
	  substance before calling the card type's putfn.)



          (* * kirk 29Nov85 Renamed from NC.PutNoteCard)



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



          (* * fgh 2/6/86 Added support for version numbers on the substance put fn.)


    (LET ((NoteFile (fetch (Card NoteFile) of Card)))
         (WITH.MONITOR (NC.FetchMonitor NoteFile)
		       (LET ((Stream (fetch (NoteFile Stream) of NoteFile))
			     DataLoc CardType StartSubstanceLoc SubstanceVersion)

          (* * Record update date on update list if necessary.)


			    (AND UpdateUpdateListFlg (NC.UpdateUpdateList Card))

          (* * First write out the card part header)


			    (SETFILEPTR Stream (SETQ DataLoc (GETEOFPTR Stream)))
			    (NC.WriteCardPartHeader Card NC.ItemIdentifier
						      (COND
							(UseOldDateFlg (NC.FetchItemDate Card))
							(T (NC.SetItemDate Card (DATE)))))

          (* * write out the type and region)


			    (NC.WriteCardType NoteFile (SETQ CardType (NC.RetrieveType Card)))
			    (NC.WriteRegion Card)

          (* * Write out the dummy length pointer for and version byte the actual substance)


			    (SETQ StartSubstanceLoc (GETFILEPTR Stream))
			    (NC.WritePtr Stream 0 4)

          (* * Write out the substance of the card.)


			    (SETQ SubstanceVersion (NC.ApplyFn PutFn Card Stream))

          (* * Update the length pointer at beginning of substance Subtract four so that length is the length of the actual 
	  substance and doesn't include the length pointer and version byte maintained here. Also updated the version number 
	  returned by the put fn.)


			    (SETFILEPTR Stream StartSubstanceLoc)
			    (NC.WritePtr Stream (DIFFERENCE (DIFFERENCE (GETEOFPTR Stream)
									    StartSubstanceLoc)
							      4)
					 3)
			    (SETQ SubstanceVersion (OR SubstanceVersion 0))
			    (NC.WritePtr Stream SubstanceVersion 1)

          (* * Update the length field at the beginning of the card info)


			    (SETFILEPTR Stream DataLoc)
			    (NC.WritePtr Stream (DIFFERENCE (GETEOFPTR Stream)
							      DataLoc)
					 3)
			    (SETFILEPTR Stream -1)

          (* * Now update the Index to reflect the new data just written. Done last in case the substance putting bombed for 
	  some reason.)


			    (replace (Card Status) of Card with (QUOTE ACTIVE))
			    (NC.SetMainLoc Card DataLoc)
			Card)))))

(NC.GetMainCardData
  (LAMBDA (Card)                                             (* fgh: " 6-Feb-86 23:41")

          (* Get a note card from the database. If IncludeDeletedCardsFlg is NIL, then return immediately if card is deleted 
	  or free. Otherwise, get dekleted but not free cards.)



          (* * rht 1/31/85: Now reads pointers from index array rather than file.)



          (* * rht 7/9/85: Now gets date if notefile has newer data format.)



          (* * rht 11/10/85 Updated to handle new Card scheme and NoteFile objects.)



          (* * fgh 11/20/85 Added call to NC.ReadCardPartHeader and put in code to read Start and End pointers before calling
	  card type's getfn.)



          (* * kirk 27Nov85 abstracted this function out of NC.GetNoteCard)



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



          (* * fgh 2/6/86 Added support for version numbers on the substance get fn.)


    (LET ((NoteFile (fetch (Card NoteFile) of Card)))
         (WITH.MONITOR (NC.FetchMonitor NoteFile)
		       (PROG ((Stream (fetch (NoteFile Stream) of NoteFile))
				Length SubstanceVersion)
			       (AND (NEQ (fetch (Card Status) of Card)
					     (QUOTE ACTIVE))
				      (RETURN NIL))

          (* * Get Substance)


			       (SETFILEPTR Stream (fetch (Card MainLoc) of Card))

          (* * Read the header info)


			       (NC.SetItemDate Card (NC.ReadCardPartHeader Card NC.ItemIdentifier)
						 )

          (* * read card type and region)


			       (NC.SetType Card (NC.ReadCardType NoteFile))
			       (NC.SetRegion Card (NC.ReadRegion NoteFile))

          (* * Read the length of substance, then call the substance get fn)


			       (SETQ Length (NC.ReadPtr Stream 3))
			       (SETQ SubstanceVersion (NC.GetPtr Stream 1))
			       (NC.SetSubstance Card (NC.ApplyFn GetFn Card Length SubstanceVersion)
						  )
			       (RETURN Card))))))
)
(* * From NCINTERFACE)

(DEFINEQ

(NC.AskNoteCardType
  (LAMBDA (ManinMenuOrRegion)                                (* fgh: "31-Jan-86 18:40")
                                                             (* Ask user to choose a note card type)

          (* * rht 1/12/85: Now takes an optional Region argument dictating where to place the NoteCardTypeMenu.
	  If NIL, then uses MainMenu.)



          (* * fgh 11/16/85 Updated to take a MainMenu arg in place of using the NC.MainMenu globalvar.)


    (PROG (W Z (Font (FONTCREATE (QUOTE HELVETICA)
				     10
				     (QUOTE BOLD))))
	    (OR (AND (BOUNDP (QUOTE NC.NoteCardTypeMenu))
			 (type? MENU NC.NoteCardTypeMenu))
		  (SETQ NC.NoteCardTypeMenu (create MENU
							ITEMS ←(NC.ListOfCardTypes T)
							CENTERFLG ← NIL
							TITLE ← "Type?"
							MENUFONT ← Font
							ITEMHEIGHT ←(IPLUS (FONTPROP
									       Font
									       (QUOTE HEIGHT))
									     1))))
	    (replace MENUPOSITION of NC.NoteCardTypeMenu
	       with (COND
			((REGIONP ManinMenuOrRegion)
			  (CONS (fetch (REGION LEFT) of ManinMenuOrRegion)
				  (IPLUS (fetch (REGION BOTTOM) of ManinMenuOrRegion)
					   (fetch (REGION HEIGHT) of ManinMenuOrRegion)
					   (IMINUS (fetch (MENU IMAGEHEIGHT) of 
									      NC.NoteCardTypeMenu)))))
			(T (CONS (IPLUS (fetch (REGION LEFT) of (SETQ Z
									  (WINDOWPROP (WFROMMENU
											  
										ManinMenuOrRegion)
											(QUOTE
											  REGION))))
					    (fetch (REGION LEFT)
					       of (SETQ W
						      (MENUITEMREGION
							(CAR (NTH (fetch (MENU ITEMS)
									 of ManinMenuOrRegion)
								      1))
							ManinMenuOrRegion))))
				   (IPLUS (fetch (REGION BOTTOM) of Z)
					    (fetch (REGION TOP) of W)
					    (IMINUS (fetch (MENU IMAGEHEIGHT) of 
									      NC.NoteCardTypeMenu)))))
			))
	    (RETURN (MENU NC.NoteCardTypeMenu)))))
)
(* * From NCLINKS)

(DEFINEQ

(NC.DefaultLinkDisplayMode
  (LAMBDA (Card)                                             (* fgh: "31-Jan-86 20:42")

          (* * RETURN the default NoteCard link display mode for the card -
	  SourceID. Default display mode is determined by the card type of SourceID.)



          (* * fgh 1/31/86 Updated to handle the card type hash table)


    (bind NoteCardType DisplayMode CardType until (EQ NoteCardType (QUOTE NoteCard))
       first (SETQ NoteCardType (NC.RetrieveType Card)) do (COND
								     ((SETQ DisplayMode
									 (fetch (NoteCardType
										    LinkDisplayMode)
									    of (SETQ CardType
										   (
										NC.CardTypeRecord
										     NoteCardType))))
								       (RETURN (COND
										   ((ATOM 
										      DisplayMode)
										     (
									    NC.MakeNewDisplayMode
										       DisplayMode))
										   (T DisplayMode))))
								     (T (SETQ NoteCardType
									  (fetch (NoteCardType
										     SuperType)
									     of CardType))))
       finally (RETURN (NC.MakeNewDisplayMode (QUOTE Icon))))))

(NC.LinkIconDisplayFn
  (LAMBDA (ImageObj ImageStream STREAMTYPE TEXTSTREAM SCALE)
                                                             (* fgh: " 5-Feb-86 13:56")

          (* * Display a link icon)



          (* * rht 11/13/84: Made width of box lines also scale dependent.)



          (* * rht 12/4/84: Hacked so type-dependent icons come out optionally to left of text.)



          (* * rht 2/9/85: Changed to use new display mode format.)



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


    (PROG (YSize XSize Left Bottom TitleDisplayMode LinkDisplayMode AttachBitmapFlg DisplayType 
		   Window Card Title Label BoxLeft BoxBottom BoxWidth BoxHeight TextLeft TextBaseLine 
		   ImageBox (Scale (DSPSCALE NIL ImageStream))
		   (Link (NC.FetchLinkFromLinkIcon ImageObj))
		   (Font NC.LinkIconFont)
		   TypeIcon OldBox)

          (* * Determine what type of Display to do)


	    (SETQ DisplayType (fetch (Link DisplayMode) of Link))
	    (SETQ Card (fetch (Link DestinationCard) of Link))
	    (SETQ TitleDisplayMode (fetch (LINKDISPLAYMODE SHOWTITLEFLG) of DisplayType))
	    (SETQ LinkDisplayMode (fetch (LINKDISPLAYMODE SHOWLINKTYPEFLG) of DisplayType))
	    (SETQ AttachBitmapFlg (fetch (LINKDISPLAYMODE ATTACHBITMAPFLG) of DisplayType))
	    (SETQ Title (SELECTQ TitleDisplayMode
				     (SOURCE (NC.RetrieveTitle (SETQ Card (fetch (Link 
										       SourceCard)
										 of Link))))
				     (FLOAT (AND NC.LinkIconShowTitleFlg (NC.RetrieveTitle
						       Card)))
				     (NIL NIL)
				     (NC.RetrieveTitle Card)))
	    (SETQ Label (AND (COND
				   ((EQ LinkDisplayMode (QUOTE FLOAT))
				     NC.LinkIconShowLinkTypeFlg)
				   (T LinkDisplayMode))
				 (fetch (Link Label) of Link)))
	    (SETQ TypeIcon (AND (COND
				      ((EQ AttachBitmapFlg (QUOTE FLOAT))
					NC.LinkIconAttachBitmapFlg)
				      (T AttachBitmapFlg))
				    (NC.FetchLinkIconAttachedBitMap Card)))
                                                             (* If there's nothing to print, then put out a tiny 
							     uninformative icon.)
	    (COND
	      ((AND (NULL Label)
		      (NULL Title)
		      (NULL TypeIcon))
		(SETQ TypeIcon NC.TypelessIcon)))

          (* * Get the image box info for this icon)


	    (SETQ ImageBox (OR (SETQ OldBox (IMAGEOBJPROP ImageObj (QUOTE BOUNDBOX)))
				   (NC.LinkIconImageBoxFn ImageObj ImageStream NIL NIL NIL 
							    DisplayType Title Label)))
	    (SETQ XSize (fetch (IMAGEBOX XSIZE) of ImageBox))
	    (SETQ YSize (fetch (IMAGEBOX YSIZE) of ImageBox))
	    (SETQ Bottom (IDIFFERENCE (DSPYPOSITION NIL ImageStream)
					  (fetch (IMAGEBOX YDESC) of ImageBox)))
	    (SETQ Left (DSPXPOSITION NIL ImageStream))

          (* * Put out the icon bitmap for the appropriate type.)


	    (COND
	      (TypeIcon (SELECTQ (OR STREAMTYPE (SETQ STREAMTYPE (IMAGESTREAMTYPE ImageStream)
					   ))
				   (DISPLAY (BITBLT TypeIcon 0 0 ImageStream (IPLUS Scale Left)
						      (IPLUS Scale Bottom)))
				   (PRESS (\WRITEPRESSBITMAP TypeIcon (IPLUS Scale Left)
							       (IPLUS Scale Bottom)
							       NIL NIL ImageStream))
				   (INTERPRESS (MOVETO (IPLUS Scale Left)
							 (IPLUS Scale Bottom)
							 ImageStream)
					       (SHOWBITMAP.IP ImageStream TypeIcon NIL NIL NIL))
				   (NC.ReportError "NC.LinkIconDisplayFn" (CONCAT STREAMTYPE 
					       " is not a stream type that Notecards knows about")))))
                                                             (* Get out if nothing to print but icon.)
	    (AND (NULL Title)
		   (NULL Label)
		   (RETURN))

          (* * Draw a box around the border of the link icon)


	    (SETQ BoxLeft (IPLUS (COND
				       (TypeIcon (TIMES Scale (BITMAPWIDTH TypeIcon)))
				       (T Scale))
				     Left))
	    (SETQ BoxBottom (IPLUS Scale Bottom))
	    (SETQ BoxWidth (IDIFFERENCE XSize (TIMES Scale (PLUS 4 (COND
									   (TypeIcon (BITMAPWIDTH
										       TypeIcon))
									   (T 0))))))
	    (SETQ BoxHeight (IDIFFERENCE YSize (TIMES Scale 4)))
	    (MOVETO BoxLeft BoxBottom ImageStream)
	    (RELDRAWTO BoxWidth 0 Scale NIL ImageStream)
	    (RELDRAWTO 0 BoxHeight Scale NIL ImageStream)
	    (RELDRAWTO (MINUS BoxWidth)
			 0 Scale NIL ImageStream)
	    (OR TypeIcon (DRAWTO BoxLeft BoxBottom Scale NIL ImageStream))

          (* * Enter the appropriate text.)


	    (SETQ TextLeft (IPLUS BoxLeft (TIMES Scale 5)))
	    (SETQ TextBaseLine (IPLUS Bottom (TIMES Scale 3)
					  (FONTPROP Font (QUOTE DESCENT))))
	    (DSPXPOSITION TextLeft ImageStream)
	    (DSPYPOSITION TextBaseLine ImageStream)
	    (DSPFONT (PROG1 (DSPFONT Font ImageStream)
				(AND Label (PRIN1 (CONCAT "<" Label ">")
						      ImageStream))
				(AND Label Title (PRIN1 " " ImageStream))
				(AND Title (PRIN1 Title ImageStream)))
		       ImageStream))))

(NC.MakeLink
  (LAMBDA (Window LinkLabel DestinationCard SourceCard DisplayMode AnchorMode Message NoDisplayFlg 
		  LinkToInsertAfter)                         (* fgh: " 5-Feb-86 13:57")

          (* * Make a link from (OR Window SourceCard) to DestinationCard with linklabel of LinkLabel)



          (* * rht 1/12/85: If need to create a new card, then now shows card type menu near window of SourceID.)



          (* * rht 1/13/85: Added extra args Message and NoDisplayFlg.)



          (* * rht 3/26/85: Added LinkToInsertAfter arg which should be NIL or a link to insert the new To link after.
	  If NIL, then insert at front of ToLinks.)



          (* * kirk 9/23/85: took out GETPROMPTWINDOW call for asknotecardtype)



          (* * kirk: 14Nov85: changed NC.CoerceToID to to NC.CoerceToCard)



          (* * fgh 11/16/85 Changed from PROG to LET and used COND to contyrol returnmed value.)



          (* * fgh 2/5/86 Changed call DefaultLinkDisplayMode to FetchLinkDisplayMode)


    (LET (Link Type)
         (OR SourceCard (SETQ SourceCard (NC.CoerceToCard Window)))
         (OR Window (SETQ Window (NC.FetchWindow SourceCard)))
         (OR Message (SETQ Message "Please select the Card or Box to be linked to."))
         (OR DestinationCard (SETQ DestinationCard (NC.SelectNoteCards
		   T
		   (FUNCTION (LAMBDA (Card)
		       (COND
			 ((NOT (NC.SameCardP Card SourceCard))
			   T)
			 (T (NC.PrintMsg Window T "A Card/Box cannot link to itself. "
					   (CHARACTER 13)
					   "Selection ignored."
					   (CHARACTER 13))
			    NIL))))
		   NC.SelectingSingleCardMenu SourceCard NIL Message)))
         (COND
	   ((EQ DestinationCard (QUOTE *New% Card*))
	     (SETQ DestinationCard (AND (SETQ Type (NC.AskNoteCardType (WINDOWREGION Window)
									       ))
					    (NC.CoerceToCard (NC.MakeNoteCard
								 Type
								 (fetch (Card NoteFile)
								    of SourceCard)
								 NIL NoDisplayFlg))))))
         (COND
	   (DestinationCard (SETQ Link (create Link
						   UID ←(NC.MakeUID)
						   SourceCard ← SourceCard
						   DestinationCard ← DestinationCard
						   AnchorMode ← AnchorMode
						   Label ← LinkLabel
						   DisplayMode ←(OR DisplayMode (
									NC.FetchLinkDisplayMode
									SourceCard))))
			    (NC.AddToLink Link LinkToInsertAfter)
			    (NC.AddFromLink Link)
			    Link)
	   (T NIL)))))

(NC.LinksSupportedP
  (LAMBDA (Card AnchorModesList)                             (* fgh: " 5-Feb-86 14:08")

          (* * Are all of the anchor modes supporterd by the card Card)



          (* * fgh 2/5/86 Changed call to LinkAnchorModesFromType to NC.FetchLinkAnchorModesSupported)


    (LET ((SupportedAnchorModes (NC.FetchLinkAnchorModesSupported Card)))
         (COND
	   ((EQ SupportedAnchorModes T))
	   ((NULL SupportedAnchorModes)
	     NIL)
	   (T (SETQ SupportedAnchorModes (MKLIST SupportedAnchorModes))
	      (for AnchorMode in AnchorModesList always (FMEMB AnchorMode 
								       SupportedAnchorModes)))))))

(NC.PushCopyLinkIcon
  (LAMBDA (LinkIcon Window)                                  (* fgh: " 6-Feb-86 22:29")

          (* * Do a push-copy of LinkIcon from Window)



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


    (LET (Card NewLinkIcon ScreenPosition NewWindow WindowPositionX WindowPositionY InsertPos)
         (SETQ ScreenPosition (GETPOSITION))
         (SETQ NewWindow (WHICHW ScreenPosition))
         (SETQ WindowPositionX (LASTMOUSEX NewWindow))
         (SETQ WindowPositionY (LASTMOUSEY NewWindow))
         (COND
	   ((AND (WINDOWP NewWindow)
		   (SETQ Card (NC.CoerceToCard NewWindow)))
	     (SETQ InsertPos (NC.ApplyFn TranslateWindowPositionFn Card WindowPositionX 
					   WindowPositionY))
	     (SETQ NewLinkIcon (APPLY* (IMAGEOBJPROP LinkIcon (QUOTE COPYFN))
					   LinkIcon))
	     (AND (NEQ (APPLY* (IMAGEOBJPROP LinkIcon (QUOTE WHENCOPIEDFN))
				     LinkIcon
				     (WINDOWPROP NewWindow (QUOTE DSP))
				     (WINDOWPROP Window (QUOTE TEXTSTREAM))
				     (WINDOWPROP NewWindow (QUOTE TEXTSTREAM)))
			   (QUOTE DON'T))
		    (NC.ApplyFn InsertLinkFn Card NewWindow (NC.FetchLinkFromLinkIcon NewLinkIcon)
				InsertPos))))
     NIL)))

(NC.UpdateLinkImages
  (LAMBDA (SourceWindowOrCard DestinationCard)               (* fgh: " 5-Feb-86 20:01")

          (* * Update the Link Image Objects in SourceCard that point to DestinationID)



          (* * rht 10/2/85: Now checks if card's window was shrunk. If so, unshrink, modify and reshrink.)



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



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


    (LET (SourceWindow SourceCard NoteCardType ShrunkenWin)
         (COND
	   ((WINDOWP SourceWindowOrCard)
	     (SETQ SourceWindow SourceWindowOrCard)
	     (SETQ SourceCard (NC.CoerceToCard SourceWindowOrCard)))
	   (T (SETQ SourceWindow (NC.FetchWindow SourceWindowOrCard))
	      (SETQ SourceCard SourceWindowOrCard)))
         (COND
	   ((SETQ ShrunkenWin (NC.GetShrunkenWin SourceWindow))
	     (EXPANDW ShrunkenWin)))
         (SETQ NoteCardType (NC.RetrieveType SourceCard))
         (NC.ApplyFn UpdateLinkIconsFn SourceCard DestinationCard)
         (COND
	   (ShrunkenWin (SHRINKW SourceWindow)))
     NIL)))

(NC.DelReferencesToCard
  (LAMBDA (SourceCard LinkOrDestinationCard)                 (* fgh: " 5-Feb-86 19:51")
                                                             (* 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)


    (PROG (NoteCardType Substance)
	    (COND
	      ((NC.ActiveCardP SourceCard)
		(SETQ NoteCardType (NC.RetrieveType SourceCard))
		(SETQ Substance (NC.FetchSubstance SourceCard))
		(NC.ApplyFn DeleteLinksFn SourceCard LinkOrDestinationCard))
	      (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
			       (if (NC.ValidCardP (NC.GetNoteCard SourceCard))
				   then (SETQ NoteCardType (NC.RetrieveType SourceCard))
					  (SETQ Substance (NC.FetchSubstance SourceCard))
					  (NC.ApplyFn DeleteLinksFn SourceCard LinkOrDestinationCard)
					  (NC.PutMainCardData SourceCard)
					  (NC.DeactivateCard SourceCard)))))
	    (NC.DelReferencesToCardFromGlobalList SourceCard LinkOrDestinationCard))))

(NC.FetchLinkIconForLink
  (LAMBDA (Link)                                             (* fgh: " 5-Feb-86 19:52")

          (* * Find the Link Icon corresponding to Link)



          (* * kirk 14Nov85: deleted use of LinkID and PSA.Database)



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


    (LET ((SourceCard (fetch (Link SourceCard) of Link)))
         (for LinkIcon in (CAR (NC.ApplyFn CollectLinksFn SourceCard NIL T))
	    thereis (if (NC.SameLinkP Link (NC.FetchLinkFromLinkIcon LinkIcon))
			  then LinkIcon)))))
)
(* * FROM NCREPAIR)

(DEFINEQ

(NC.RobustGetSubstance
  (LAMBDA (Card CardType Length)                             (* fgh: " 5-Feb-86 19:46")

          (* * Try to get substance robustly. RESETVAR prevents breaks. Returns either substance or nil if unsuccessful.)



          (* * rht 12/1/85: Updated to use card and notefile format.)



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


    (RESETVAR HELPFLAG NIL (NLSETQ (NC.ApplyFn GetFn Card Length)))))

(NC.CollectAndCheckLinks
  (LAMBDA (Card NoteFile ListOfValidCards)                   (* fgh: " 5-Feb-86 19:56")

          (* Return the list of all of the NoteCardLinks in the substance of NoteCard ID. Check each link to make sure it is 
	  legal. If not legal delete it from the substance.)



          (* * rht 11/23/85: updated to handle new notefile and card object formats.)



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

                                                             (* Assumes that the Card is already an active 
							     NoteCard)
    (PROG (Links DirtyFlg ActualLink GlobalLinks LinkIcon LinksDirtyFlg)
                                                             (* Collect the links. Check the validity of each link 
							     and delete it if it is not a valid link.)
	    (COND
	      ((SETQ Links (NC.ApplyFn CollectLinks Card T))
		(SETQ DirtyFlg (CDR Links))
		(SETQ Links (CAR Links))))

          (* * Process the GlobalLinks as well .... same for all substance types)


	    (SETQ Links (NCONC Links (for Link
					    in
					     (SETQ GlobalLinks
					       (for GlobalLink in (NC.FetchGlobalLinks Card)
						  eachtime (BLOCK)
						  when (COND
							   ((AND (LISTP ListOfValidCards)
								   (for ValidCard in 
										 ListOfValidCards
								      thereis
								       (NC.SameCardP
									 (fetch (Link 
										  DestinationCard)
									    of GlobalLink)
									 ValidCard))))
							   ((NC.ValidLinkP GlobalLink))
							   (T (SETQ LinksDirtyFlg T)
							      NIL))
						  collect GlobalLink))
					    eachtime (BLOCK) collect Link)))
	    (NC.SetGlobalLinks Card GlobalLinks)

          (* * Update list of valid cards with good links returned from Collect references)


	    (AND (LISTP ListOfValidCards)
		   (NCONC ListOfValidCards (for Link in Links eachtime (BLOCK)
						collect (fetch (Link DestinationCard)
							     of Link))))

          (* * Write out the card or links if it has been modified)


	    (AND DirtyFlg (NC.PutMainCardData Card))
	    (AND LinksDirtyFlg (NC.PutLinks Card))
	    (RETURN Links))))
)
(* * FROM NCSKETCHCARD)

(DEFINEQ

(NC.AddSketchCard
  (LAMBDA NIL                                                (* fgh: " 5-Feb-86 13:59")

          (* * fgh 11/14/85: Updated to conform to merging of cardTypes and SubstanceTypes.)



          (* * Added LinkIconAttachedBitMap field.)


    (NC.AddCardType (QUOTE Sketch)
		      (QUOTE NoteCard)
		      (BQUOTE ((MakeFn , (FUNCTION NC.MakeSketchCard))
				 (EditFn , (FUNCTION NC.BringUpSketchCard))
				 (QuitFn , (FUNCTION NC.SketchCardCloseFn))
				 (GetFn , (FUNCTION (LAMBDA (Card Region)
					    (LET ((Value (NC.GetSketchSubstance Card)))
					         (NC.SetScale Card (CADR Value))
					         (NC.SetRegionViewed Card (CADDR Value))
					         (CAR Value)))))
				 (PutFn , (FUNCTION NC.PutSketchSubstance))
				 (CopyFn , (FUNCTION NC.SketchCopySubstance))
				 (MarkDirtyFn , (FUNCTION NC.MarkSketchDirty))
				 (DirtyPFn , (FUNCTION NC.SketchDirtyP))
				 (CollectLinksFn , (FUNCTION NC.CollectReferencesInSketch))
				 (DeleteLinksFn , (FUNCTION NC.DelReferencesToCardFromSketch))
				 (UpdateLinkIconsFn , (FUNCTION NC.UpdateLinkImagesInSketch))
				 (InsertLinkFn , (FUNCTION NC.InsertLinkInSketch))
				 (TranslateWindowPositionFn , (FUNCTION 
						       NC.TranslateWindowPositionToSketchPosition))))
		      (BQUOTE ((DefaultWidth 400)
				 (DefaultHeight 350)
				 (LinkAnchorModesSupported T)
				 (LinkDisplayMode Title)
				 (DisplayedInMenuFlg T)
				 (LinkIconAttachedBitMap , NC.SketchCardIcon))))))

(NC.InsertLinkInSketch
  (LAMBDA (Card SketchWindow Link SketchWindowPosition)      (* fgh: " 6-Feb-86 22:09")

          (* * rht 8/20/85: Rewritten to use Richard's sketch programmer's interface. Eliminates references to sketch 
	  records.)



          (* * rht 10/1/85: Now checks that chosen position is actually within sketch, otherwise aborts by deleting link.)



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


    (LET ((LinkIcon (NC.MakeLinkIcon Link))
	  (Scale (SKETCHW.SCALE SketchWindow))
	  SketchIcon Size Position)
         (SETQ Size (IMAGEBOXSIZE LinkIcon))
         (SETQ Position (OR (POSITIONP SketchWindowPosition)
				(GETBOXPOSITION (fetch (IMAGEBOX XSIZE) of Size)
						  (fetch (IMAGEBOX YSIZE) of Size)
						  NIL NIL SketchWindow)))
         (if (INSIDEP (DSPCLIPPINGREGION NIL SketchWindow)
			  Position)
	     then (SETQ SketchIcon (SKETCH.IMAGE.OBJECT.ELEMENT LinkIcon Scale Position))
		    (SKETCH.ADD.ELEMENT SketchIcon SketchWindow)
		    SketchIcon
	   else (NCP.DeleteLinks Link)
		  NIL))))

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

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


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

(NC.PutSketchSubstance
  (LAMBDA (Card)                                             (* fgh: " 6-Feb-86 22:55")

          (* Put the sketch substance for card ID to the database. Store the global sketch descriptor, the scale and region 
	  viewed for ID and any cached bit maps.)



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



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


    (LET ((Substance (NC.FetchSubstance Card))
	  (Window (NC.FetchWindow Card))
	  (Stream (fetch (NoteFile Stream) of (fetch (Card NoteFile) of Card)))
	  SketchSpecs)
         (HPRINT Substance Stream NIL T)
         (PRINT (OR (AND Window (SCALE.FROM.SKW Window))
			(NC.FetchScale Card))
		  Stream)
         (PRINT (OR (AND Window (SK.REGION.VIEWED Window))
			(NC.FetchRegionViewed Card))
		  Stream)
         (COND
	   ((AND Window (SETQ SketchSpecs (LOCALSPECS.FROM.VIEWER Window)))
	     (MAPSKETCHSPECS SketchSpecs (FUNCTION NC.PutCachedMap)
			       Stream)))
         (PRINT (QUOTE ###ENDSKETCH###)
		  Stream)
     0)))
)
(* * FROM NCTEXTCARD)

(DEFINEQ

(NC.InsertLinkInTextWindow
  (LAMBDA (Card TextWindow LinkOrLinkLabel CharacterPosition)
                                                             (* fgh: " 6-Feb-86 22:12")

          (* * Given a Window and a Link, insert the Link at CharacterPosition in the TextStream of Window)



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


    (PROG ((TextStream (WINDOWPROP TextWindow (QUOTE TEXTSTREAM))))
	    (RETURN (NC.InsertLinkInText TextStream LinkOrLinkLabel NIL NIL NIL CharacterPosition)
		      ))))

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

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


    (PROG (TextObj)
	    (COND
	      ((AND (WINDOWP Window)
		      (type? TEXTOBJ (SETQ TextObj (WINDOWPROP Window (QUOTE TEXTOBJ)))))
		(RETURN (fetch (SELECTION CH#) of (TEDIT.SELECT WindowPositionX 
									WindowPositionY TextObj
									(fetch (TEXTOBJ 
										      MOUSEREGION)
									   of TextObj)
									NIL NIL Window))))))))

(NC.PutTextSubstance
  (LAMBDA (Card)                                             (* fgh: " 6-Feb-86 22:54")
                                                             (* Put text substance from card ID on the database 
							     file)

          (* * rht 9/13/85: Now doesn't try to write piece table at all if substance has zero length.)



          (* * fgh 11/13/85 Updated to handle NoteFile, Card objects.)



          (* * fgh 11/20/85 removed code to handle start and end pointers)



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


    (LET ((Substance (NC.FetchSubstance Card))
	  (Stream (fetch (NoteFile Stream) of (fetch (Card NoteFile) of Card)))
	  StartPtr)

          (* * Save the location of the start of this text stream.)


         (SETQ StartPtr (GETFILEPTR Stream))

          (* * The write down the text stream)


         (COND
	   ((NOT (ZEROP (fetch (TEXTOBJ TEXTLEN) of (TEXTOBJ Substance))))
	     (TEDIT.PUT.PCTB (TEXTOBJ Substance)
			       Stream)))

          (* * fix up the file absolute pointerts to be file textstream relative pointers.)


         (if (TEDIT.FORMATTEDFILEP Substance)
	     then (SETFILEPTR Stream (IDIFFERENCE (SETQ EOFPtr (GETEOFPTR Stream))
							8))
		    (SETQ StartFormatPtr (\DWIN Stream))
		    (SETFILEPTR Stream (IDIFFERENCE EOFPtr 8))
		    (\DWOUT Stream (DIFFERENCE StartFormatPtr StartPtr)))

          (* * Set stream file ptr to eof.)


         (SETFILEPTR Stream -1)
     0)))
)
(* * FROM NCGRAPHCARD)

(DEFINEQ

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

(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.PutGraphSubstance
  (LAMBDA (Card)                                             (* fgh: " 6-Feb-86 22:59")
                                                             (* 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.)



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


    (LET ((Graph (NC.FetchSubstance Card))
	  (Stream (fetch (NoteFile Stream) of (fetch (Card NoteFile) of 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)
         (HPRINT Graph Stream)
     0)))
)
(* * FROM NCFILEBOXCARD)

(DEFINEQ

(NC.MakeFileBox
  (LAMBDA (Card Title DontDisplay)                           (* fgh: " 6-Feb-86 22:36")
                                                             (* Make up a blank contents card, hook it to the user 
							     specified parent contents cards, and display it.)

          (* * rht 12/2/84: In DontDisplay 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.)


    (LET (Window TextStream (Spacer (CONCAT (CHARACTER 13)
					      (CHARACTER 13))))
         (SETQ TextStream (OPENTEXTSTREAM ""))
         (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)))
         (NC.SetSubstance Card TextStream)
         (NC.SetRegion Card (CREATEREGION 0 0 (NC.FetchDefaultWidth Card)
					      (NC.FetchDefaultHeight Card)))
         (COND
	   (DontDisplay Card)
	   (T (SETQ Window (CREATEW (NC.DetermineDisplayRegion Card NIL)
					(NC.SetTitle Card (OR Title "Untitled"))))
	      (WINDOWPROP Window (QUOTE NoteCardsLeftButtonMenu)
			    (NC.MakeTEditLeftMenu (NC.RetrieveType Card)))
	      (WINDOWPROP Window (QUOTE NoteCardsMiddleButtonMenu)
			    (NC.MakeTEditMiddleMenu))      (* Display the card)
	      (WINDOWADDPROP Window (QUOTE SHRINKFN)
			       (FUNCTION NC.TextCardShrinkFn))
	      (TEDIT TextStream Window NIL (LIST (QUOTE FONT)
						     NC.DefaultFont
						     (QUOTE TITLEMENUFN)
						     (FUNCTION NC.TEditMenuFn)))
	      (until (WINDOWPROP Window (QUOTE TEXTSTREAM)) do (BLOCK))
	      (NC.ActivateCard Card)
	      (COND
		(NC.AlphabetizedFileBoxChildrenFlg (NCP.CardProp Card (QUOTE OrderingFn)
								   (FUNCTION NC.IDAlphOrder))))
	      (COND
		((GETPROMPTWINDOW Window NIL NIL T)
		  (PROG1 (DISMISS 1000)
			   (NC.ClearMsg (GETPROMPTWINDOW Window NIL NIL T)
					  T))))
	      Window)))))
)
(* * FROM NCBROWSERCARD)

(DEFINEQ

(NC.QuitBrowserCard
  (LAMBDA (CardIdentifier)                                   (* fgh: " 5-Feb-86 19:41")

          (* * Browser card is being closed. We need to convert the format of the browser roots.)



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


    (LET ((Card (NC.CoerceToCard CardIdentifier)))

          (* * For each browser root, convert from Card object to cardUID/notefileUID cons pair format.)


         (NC.PutProp Card (QUOTE BrowserRoots)
		       (LIST (for BrowserRoot in (MKLIST (CAR (NC.GetProp Card
										      (QUOTE 
										     BrowserRoots))))
				  eachtime (BLOCK) collect (CONS (fetch (Card UID)
									    of Card)
									 (fetch (NoteFile UID)
									    of (fetch
										   (Card NoteFile)
										    of Card))))))
         (NC.ApplySupersFn QuitFn Card))))

(NC.PutBrowserSubstance
  (LAMBDA (Card)                                             (* fgh: " 5-Feb-86 19:41")

          (* * For each BrowserUID, clear its UID prop list. Otherwise HPRINT will die in PutGraphSubstance.)



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


    (LET ((Browser (NC.FetchSubstance Card)))
         (for GraphNode in (fetch (GRAPH GRAPHNODES) of Browser) eachtime (BLOCK)
	    when (SETQ NodeID (NC.CoerceToGraphNodeID GraphNode)) do (NC.UIDSetPropList
									       NodeID NIL))
         (NC.ApplySupersFn PutFn Card))))

(NC.BringUpBrowserCard
  (LAMBDA (Card Substance Region/Position)                   (* fgh: " 5-Feb-86 19:48")

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



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



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



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



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


    (LET ((Window (NC.ApplySupersFn EditFn Card Substance Region/Position)))
         (NC.SetupTitleBarMenu Window Card (QUOTE Browser))
         (NC.MakeLinksLegendMenu Window (CAR (LISTGET (NC.RetrievePropList Card)
							    (QUOTE BrowserLinksLegend))))
                                                             (* Disable the old-style right button grapher editor 
							     menu.)
         (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
		       (FUNCTION NC.BrowserRightButtonFn))
         (WINDOWADDPROP Window (QUOTE SHRINKFN)
			  (FUNCTION NC.GraphCardShrinkFn))
         (WINDOWADDPROP Window (QUOTE REPAINTFN)
			  (FUNCTION NC.BrowserRepaintFn)
			  T)

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


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

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


         (for GraphNode in (fetch (GRAPH GRAPHNODES) of Substance) bind LinkIcon
	    eachtime (BLOCK) when (NC.LinkIconImageObjP (SETQ LinkIcon (fetch
								    (GRAPHNODE NODELABEL)
										    of GraphNode)))
	    do (NC.UIDPutProp (NC.CoerceToGraphNodeID GraphNode)
				  (QUOTE CardObject)
				  (fetch (Link DestinationCard) of (NC.FetchLinkFromLinkIcon
									 LinkIcon))))
     Window)))
)
(* * from NCLISTCARD)

(DEFINEQ

(NC.ListCardPutFn
  (LAMBDA (Card)                                             (* fgh: " 6-Feb-86 22:57")
                                                             (* Put list substance)

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



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


    (LET ((Substance (NC.FetchSubstance Card))
	  (Stream (fetch (NoteFile Stream) of (fetch (Card NoteFile) of Card))))
         (PRINT Substance Stream)
     0)))
)
(* * from NCFILECARD)

(DEFINEQ

(NC.PutFileSubstance
  (LAMBDA (Card DatabaseStream)                              (* fgh: " 6-Feb-86 22:58")

          (* * Put a file designator onto DatabaseStream)



          (* * fgh 12/17/85 Updated for 1.3)



          (* * Save the file for this file card)



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


    (NC.FileCardPutFile Card DatabaseStream)

          (* * Save the file card stuff in the NoteFile)


    (PRINT (NC.FetchSubstance Card)
	     DatabaseStream)
    0))
)
(PUTPROPS FGHPATCH018 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (18196 28897 (NC.DetermineDisplayRegion 18206 . 19893) (NC.MakeDummyRegion 19895 . 20305
) (NC.CardDirtyP 20307 . 20756) (NC.QuitCard 20758 . 22932) (NC.MakeNoteCard 22934 . 25709) (
NC.MarkCardDirty 25711 . 26322) (NC.CollectReferences 26324 . 27660) (NC.EditNoteCard 27662 . 28895)) 
(28930 30409 (NC.FetchLinkIconAttachedBitMap 28940 . 29267) (NC.FetchLinkDisplayMode 29269 . 29572) (
NC.FetchDefaultWidth 29574 . 29859) (NC.FetchDefaultHeight 29861 . 30145) (
NC.FetchLinkAnchorModesSupported 30147 . 30407)) (30438 35674 (NC.PutMainCardData 30448 . 33612) (
NC.GetMainCardData 33614 . 35672)) (35704 37813 (NC.AskNoteCardType 35714 . 37811)) (37839 52058 (
NC.DefaultLinkDisplayMode 37849 . 39054) (NC.LinkIconDisplayFn 39056 . 44463) (NC.MakeLink 44465 . 
47031) (NC.LinksSupportedP 47033 . 47720) (NC.PushCopyLinkIcon 47722 . 49040) (NC.UpdateLinkImages 
49042 . 50180) (NC.DelReferencesToCard 50182 . 51463) (NC.FetchLinkIconForLink 51465 . 52056)) (52085 
54919 (NC.RobustGetSubstance 52095 . 52556) (NC.CollectAndCheckLinks 52558 . 54917)) (54950 59253 (
NC.AddSketchCard 54960 . 56528) (NC.InsertLinkInSketch 56530 . 57682) (
NC.TranslateWindowPositionToSketchPosition 57684 . 57970) (NC.PutSketchSubstance 57972 . 59251)) (
59282 62083 (NC.InsertLinkInTextWindow 59292 . 59838) (NC.TranslateWindowPositionToTEditPosition 59840
 . 60441) (NC.PutTextSubstance 60443 . 62081)) (62113 64281 (NC.InsertLinkInGraph 62123 . 62955) (
NC.TranslateWindowPositionToGraphPosition 62957 . 63242) (NC.PutGraphSubstance 63244 . 64279)) (64313 
67042 (NC.MakeFileBox 64323 . 67040)) (67074 71020 (NC.QuitBrowserCard 67084 . 68012) (
NC.PutBrowserSubstance 68014 . 68643) (NC.BringUpBrowserCard 68645 . 71018)) (71049 71631 (
NC.ListCardPutFn 71059 . 71629)) (71660 72212 (NC.PutFileSubstance 71670 . 72210)))))
STOP