(FILECREATED " 2-May-86 16:16:27" {QV}<NOTECARDS>1.3K>FGHPATCH030.;2 9692   

      changes to:  (FNS NC.ShowLinks NC.InsureLinkDisplayMode NC.DelReferencesToCardFromShowLinks 
			NC.LinkIconWhenDeletedFn NC.DeleteLink)
		   (VARS FGHPATCH030COMS)

      previous date: " 2-May-86 12:51:48" {QV}<NOTECARDS>1.3K>FGHPATCH030.;1)


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

(PRETTYCOMPRINT FGHPATCH030COMS)

(RPAQQ FGHPATCH030COMS ((* * Fixes to allow deleteing of links from ShowLinks editor.)
			  (* * NOTE: SHOULD RECOMPILE ENTIRE SYSTEM TO TAKE CARE OF CHANGES TO Link 
			     DATATYPE. NOT ABSOLUTELY NECESSARY, BUT ADVISED.)
			  (* * New fns for NCLINKS)
			  (FNS NC.InsureLinkDisplayMode NC.DelReferencesToCardFromShowLinks)
			  (* * Redefined from NCLINKS)
			  (FNS NC.ShowLinks NC.LinkIconWhenDeletedFn NC.DeleteLink)
			  (* * Redefined from NCLINKS)
			  (RECORDS Link)))
(* * Fixes to allow deleteing of links from ShowLinks editor.)

(* * NOTE: SHOULD RECOMPILE ENTIRE SYSTEM TO TAKE CARE OF CHANGES TO Link DATATYPE. NOT 
ABSOLUTELY NECESSARY, BUT ADVISED.)

(* * New fns for NCLINKS)

(DEFINEQ

(NC.InsureLinkDisplayMode
  (LAMBDA (LinkDisplayMode)                                  (* fgh: " 2-May-86 15:58")

          (* * Return the recordized form of the LinkDisplayMode argument.)



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


    (COND
      ((type? LINKDISPLAYMODE LinkDisplayMode)
	LinkDisplayMode)
      (T (SELECTQ LinkDisplayMode
		    (Title (create LINKDISPLAYMODE
				     SHOWTITLEFLG ← T))
		    (Icon (create LINKDISPLAYMODE
				    ATTACHBITMAPFLG ← T))
		    (Label (create LINKDISPLAYMODE
				     SHOWLINKTYPEFLG ← T))
		    (Both (create LINKDISPLAYMODE
				    SHOWTITLEFLG ← T
				    SHOWLINKTYPEFLG ← T))
		    (create LINKDISPLAYMODE
			      ATTACHBITMAPFLG ← T))))))

(NC.DelReferencesToCardFromShowLinks
  (LAMBDA (Card Link)                                        (* fgh: " 2-May-86 16:07")

          (* * Delete any references to link from the show links editor above Card, if any)



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


    (LET (Window Substance OldSel)
         (if (SETQ Window (NC.FetchWindow Card))
	     then (for AttachedWindow in (ALLATTACHEDWINDOWS Window)
		       when (WINDOWPROP AttachedWindow (QUOTE ShowLinks))
		       do (for LinkIconPair in (TEDIT.LIST.OF.OBJECTS (TEXTOBJ
										(SETQ Substance
										  (TEXTSTREAM
										    AttachedWindow)))
									      (FUNCTION 
									     NC.LinkIconImageObjP))
			       when (NC.SameLinkP Link (NC.FetchLinkFromLinkIcon (CAR 
										     LinkIconPair)))
			       do (replace (IMAGEOBJ IMAGEOBJFNS) of (CAR LinkIconPair)
				       with NC.NoDeleteImageFns)
                                                             (* WHENDELETEDFN taken care of earlier in delete 
							     cycle)
				    (SETQ OldSel (TEDIT.GETSEL Substance))
				    (TEDIT.DELETE Substance (CADR LinkIconPair)
						    1)
				    (TEDIT.INSERT.OBJECT NC.DeletedLinkImageObject Substance
							   (CADR LinkIconPair))
				    (TEDIT.SETSEL Substance OldSel)))))))
)
(* * Redefined from NCLINKS)

(DEFINEQ

(NC.ShowLinks
  (LAMBDA (TextStream)                                       (* fgh: " 2-May-86 16:01")
                                                             (* Open an inspector for the links for note card 
							     specified by TextStream above the window for the note 
							     card.)

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



          (* * fgh 5/2/86 Included calls to NC.InsureLinkDisplayMode to handle litatom link display modes.
	  Added InsdiePropListEditor and Reverse indicators to UserData field of Links in show links editor.
	  Also added ShowLinks property onto the editor window so other functions can detect that a window is a show links 
	  window.)


    (LET (Links EditWindow (Card (NC.CoerceToCard (WINDOW.FROM.TEDIT.THING TextStream))))
         (SETQ Links (NCONC (for Link in (NC.FetchToLinks Card)
				   join (LIST (COND
						    ((EQ (fetch (Link AnchorMode) of Link)
							   (QUOTE GlobalGlobal))
						      "Global TO")
						    (T "TO"))
						  (LIST (create Link
							     using
							      Link DisplayMode ←(create 
										  LINKDISPLAYMODE
										   copying
										    (
									 NC.InsureLinkDisplayMode
										      (fetch
											(Link 
										      DisplayMode)
											 of Link))
										    SHOWTITLEFLG ← T 
										  SHOWLINKTYPEFLG ← T)
							      UserData ←(QUOTE (InsidePropListEditor
										   T))))))
				(for Link in (NC.FetchFromLinks Card)
				   join (LIST "FROM"
						  (LIST (create Link
							     using
							      Link DisplayMode ←(create 
										  LINKDISPLAYMODE
										   copying
										    (
									 NC.InsureLinkDisplayMode
										      (fetch
											(Link 
										      DisplayMode)
											 of Link))
										    SHOWTITLEFLG ← T 
										  SHOWLINKTYPEFLG ← T)
							      SourceCard ←(fetch (Link 
										  DestinationCard)
									     of Link)
							      DestinationCard ←(fetch (Link 
										       SourceCard)
										  of Link)
							      UserData ←(QUOTE (InsidePropListEditor
										   T Reversed T)))))))
	   )
         (WINDOWPROP (SETQ EditWindow (NC.OpenPropListEditor TextStream Links "List of Links" T 
								   T))
		       (QUOTE ShowLinks)
		       T)
     EditWindow)))

(NC.LinkIconWhenDeletedFn
  (LAMBDA (ImageObject Stream)                               (* fgh: " 2-May-86 15:59")

          (* * When deleting a link icon image object from a card, make sure the link information on the source and 
	  destinmation cards get updated. When deleting a link image object from a prop list editor, just inform the user 
	  that this is a useless operation.)



          (* * rht 11/19/84: Now handles the case when a move is in progress. True if the old link is cached on the ImageObj.
	  Also changed so that SourceID is computed from ImageObject rather than from Stream. Similarly for the window.)



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



          (* * fgh 5/2/86 Added code to handle deleting of links from ShowLinks editors.)


    (LET (Link SourceCard DestinationCard LinkType Window OldLink)
         (SETQ Link (NC.FetchLinkFromLinkIcon ImageObject))
         (COND
	   ((SETQ OldLink (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMoved)))
	     (NC.DelFromLink OldLink)
	     (NC.DelToLink OldLink)
	     (replace (Link UID) of OldLink with -1)
	     (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMoved)
			     NIL))
	   (T 

          (* * if this is reversed source/dest {i.e., a From link} inside the show links editor, then return it to its 
	  original direction)


	      (if (AND (IMAGEOBJPROP ImageObject (QUOTE InsidePropListEditor))
			   (LISTGET (fetch (Link UserData) of Link)
				      (QUOTE Reversed)))
		  then (SETQ Link (create Link using Link SourceCard ←(fetch (Link 
										  DestinationCard)
										 of Link)
							     DestinationCard ←(fetch (Link 
										       SourceCard)
										 of Link))))

          (* * Then just delete the link)


	      (SETQ DestinationCard (fetch (Link DestinationCard) of Link))
	      (NC.CheckForOrphanDelete SourceCard DestinationCard)
	      (NC.DeleteLink Link)
	      (replace (Link UID) of Link with -1))))))

(NC.DeleteLink
  (LAMBDA (Link NoOrphanHookFlg Don'tDelLinkIconFlg)         (* fgh: " 2-May-86 15:59")

          (* * Delete a link with the option of not putting an orphan hook in case of last filing link.
	  Also option of not deleting link icon from the source card's substance.)



          (* * fgh 5/2/86 Included calls to NC.DelReferencesToCardFromShowLinks in order to clean up ShowLinks windows when 
	  links are deleted.)


    (LET ((SourceCard (fetch (Link SourceCard) of Link)))
         (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
		       (OR Don'tDelLinkIconFlg (NC.DelReferencesToCard SourceCard Link))
		       (NC.DelFromLink Link NoOrphanHookFlg)
		       (NC.DelToLink Link)
		       (NC.DelReferencesToCardFromShowLinks SourceCard Link)
		       (NC.DelReferencesToCardFromShowLinks (fetch (Link DestinationCard)
								 of Link)
							      Link)

          (* * This UID replacement is worrisome. Does it mean that link deletion can't be undone?)


		       (replace (Link UID) of Link with -1)))))
)
(* * Redefined from NCLINKS)

[DECLARE: EVAL@COMPILE 

(DATATYPE Link (UID SourceCard DestinationCard AnchorMode Label DisplayMode UserData))
]
(/DECLAREDATATYPE (QUOTE Link)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER))
		  (QUOTE ((Link 0 POINTER)
			  (Link 2 POINTER)
			  (Link 4 POINTER)
			  (Link 6 POINTER)
			  (Link 8 POINTER)
			  (Link 10 POINTER)
			  (Link 12 POINTER)))
		  (QUOTE 14))
(PUTPROPS FGHPATCH030 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1153 3340 (NC.InsureLinkDisplayMode 1163 . 1911) (NC.DelReferencesToCardFromShowLinks 
1913 . 3338)) (3376 9175 (NC.ShowLinks 3386 . 5890) (NC.LinkIconWhenDeletedFn 5892 . 8026) (
NC.DeleteLink 8028 . 9173)))))
STOP