(FILECREATED "20-Nov-86 11:33:56" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH161.;6 16077  

      changes to:  (VARS RHTPATCH161COMS NC.CrossFileLinkIcon)
		   (FNS NC.AddCrossFileLink NC.LinkIconMiddleButtonFn NC.LinkIconLeftButtonFn 
			NC.TraverseLink NC.LinkIconButtonEventInFn)

      previous date: "18-Nov-86 18:53:27" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH161.;1)


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

(PRETTYCOMPRINT RHTPATCH161COMS)

(RPAQQ RHTPATCH161COMS ((* * Fix for the "vanishing" link icon problem when title of a cross file 
			     link card changes. Also rips version number off file name hint stored in 
			     crossfile link cards.)
			  (* * New functions for NCLINKS)
			  (FNS NC.LinkIconLeftButtonFn NC.TraverseLink)
			  (* * Changes to NCLINKS)
			  (FNS NC.LinkIconButtonEventInFn NC.LinkIconMiddleButtonFn)
			  (* * New things for NCCROSSFILELINKS)
			  (GLOBALVARS NC.CrossFileLinkIcon)
			  (BITMAPS NC.CrossFileLinkIcon)
			  (* * Change to NCCROSSFILELINKS)
			  (FNS NC.GetCrossFileLinkDestCard NC.CreateCrossFileLinkCard 
			       NC.AddCrossFileLink)
			  (* * Don't integrate the following. It's just for the purposes of this 
			     patch file.)
			  (P (NC.AddCrossFileLink))))
(* * Fix for the "vanishing" link icon problem when title of a cross file link card changes. 
Also rips version number off file name hint stored in crossfile link cards.)

(* * New functions for NCLINKS)

(DEFINEQ

(NC.LinkIconLeftButtonFn
  (LAMBDA (LinkIcon Window)                                  (* rht: "18-Nov-86 18:47")

          (* * Left button has been pressed in the link icon. For now, just traverse the link.)


    (NC.TraverseLink LinkIcon Window)))

(NC.TraverseLink
  (LAMBDA (LinkIcon Window)                                  (* rht: "18-Nov-86 18:47")

          (* * Follow the link to the card at the other end. For now, amounts to editing the destination card.)


    (LET ((Card (fetch (Link DestinationCard) of (NC.FetchLinkFromLinkIcon LinkIcon)))
	  OldTitle)
         (SETQ OldTitle (NC.RetrieveTitle Card))
         (NC.EditNoteCard Card)

          (* * We're under TEdit, so if title was changed by EditFn, then be sure link icon gets redisplayed.)


         (if (STREQUAL OldTitle (NC.RetrieveTitle Card))
	     then (QUOTE DON'T)
	   else (QUOTE CHANGED)))))
)
(* * Changes to NCLINKS)

(DEFINEQ

(NC.LinkIconButtonEventInFn
  (LAMBDA (ImageObject Window)                               (* rht: "18-Nov-86 18:48")
                                                             (* If the guy buttons inside a link image object)

          (* * fgh 6/3/86 Removed hot region, removed push copy link icon.)



          (* * fgh 6/29/86 Put back in a hot region.)



          (* * rht 11/18/86: Now calls NC.LinkIconLeftButtonFn rather than hardwiring in the call to NC.EditNoteCard.)


    (LET ((Window (COND
		    ((WINDOWP Window)
		      Window)
		    ((DISPLAYSTREAMP Window)
		      (WFROMDS Window))
		    ((TEXTSTREAMP Window)
		      (WINDOW.FROM.TEDIT.THING Window))
		    (T NIL)))
	  (ClippingRegion (DSPCLIPPINGREGION NIL Window))
	  (Link (NC.FetchLinkFromLinkIcon ImageObject))
	  HotRegion MouseButtonState TTYWindow ClippingRegionWidth)

          (* * Figure out the hot region -- basically the clipping region minus a few pts at right and left to allow for 
	  TEdit selection of icon.)


         (SETQ HotRegion (if (GREATERP (SETQ ClippingRegionWidth (fetch (REGION WIDTH)
									    of ClippingRegion))
					     24)
			       then                        (* There's at least 10 pts between the two 7pt cold 
							     regions at left and right.)
				      (CREATEREGION (PLUS (fetch (REGION LEFT) of 
										   ClippingRegion)
							      7)
						      (fetch (REGION BOTTOM) of ClippingRegion)
						      (DIFFERENCE (fetch (REGION WIDTH)
								       of ClippingRegion)
								    14)
						      (fetch (REGION HEIGHT) of ClippingRegion))
			     elseif (AND (LESSP ClippingRegionWidth 9))
			       then                        (* if link icon width less than 9 then no cold 
							     regions)
				      ClippingRegion
			     else                          (* Divide into 4ths and give 1/4 at each edge as cold 
							     regions.)
				    (CREATEREGION (PLUS (fetch (REGION LEFT) of 
										   ClippingRegion)
							    (TIMES .25 ClippingRegionWidth))
						    (fetch (REGION BOTTOM) of ClippingRegion)
						    (QUOTIENT ClippingRegionWidth 2)
						    (fetch (REGION HEIGHT) of ClippingRegion))))
         (COND
	   ((NOT (INSIDEP HotRegion (LASTMOUSEX Window)
			      (LASTMOUSEY Window)))

          (* * If in the link icon, but not in the hot region -- want to select the link icon.)


	     NIL)
	   (T 

          (* * Otherwise, invert the window and wait until the mouse is up or the cursor moves out of the link icon.)


	      (RESETLST (RESETSAVE (INVERTW Window))
			  (until (OR (MOUSESTATE UP)
					 (NOT (INSIDEP HotRegion (LASTMOUSEX Window)
							   (LASTMOUSEY Window))))
			     do (SETQ MouseButtonState LASTMOUSEBUTTONS)))

          (* * If user let up inside the link icon, then call the appropriate function.)


	      (COND
		((AND (INSIDEP HotRegion (LASTMOUSEX Window)
				   (LASTMOUSEY Window))
			MouseButtonState)

          (* * User let up inside the link icon.)


		  (COND
		    ((OR (KEYDOWNP (QUOTE LSHIFT))
			   (KEYDOWNP (QUOTE RSHIFT))
			   (KEYDOWNP (QUOTE CTRL))
			   (KEYDOWNP (QUOTE COPY))
			   (KEYDOWNP (QUOTE DELETE))
			   (KEYDOWNP (QUOTE MOVE)))      (* Copy or move or delete key is down, just do 
							     selection)
		      NIL)
		    ((ZEROP (LOGXOR MouseButtonState 4))
                                                             (* The left button was down, call the left button fn.)
		      (NC.LinkIconLeftButtonFn ImageObject Window))
		    ((OR (ZEROP (LOGXOR MouseButtonState 1))
			   (ZEROP (LOGXOR MouseButtonState 6)))
                                                             (* The middle button was down, call the middle button 
							     fn.)
		      (NC.LinkIconMiddleButtonFn ImageObject Window))
		    ((ZEROP (LOGXOR MouseButtonState 2))
                                                             (* The right button was down, allow selection)
		      NIL)
		    (T                                       (* Hmmm, don't know know, allow selectin)
		       NIL)))
		((AND (INSIDEP ClippingRegion (LASTMOUSEX Window)
				   (LASTMOUSEY Window))
			(NOT (INSIDEP HotRegion (LASTMOUSEX Window)
					  (LASTMOUSEY Window))))

          (* * User let up outside the hot region but inside the link icon -- select the link icon)


		  NIL)
		(T 

          (* * User let up outside the link icon -- don't select the link icon)


		   (QUOTE DON'T))))))))

(NC.LinkIconMiddleButtonFn
  (LAMBDA (LinkIcon Window)                                  (* rht: "19-Nov-86 23:56")
                                                             (* Middle button has been pressed in the Notecard 
							     pointer. Bring up menu of choices for manipulating 
							     this pointer.)

          (* * rht 11/18/86: Now calls NC.TraverseLink rather than NC.EditNoteCard.)


    (DECLARE (GLOBALVARS NC.LinkIconMiddleButtonMenu))
    (LET ((Card (fetch (Link DestinationCard) of (NC.FetchLinkFromLinkIcon LinkIcon))))
         (if (NC.CardP (NC.CoerceToCard Window))
	     then (SELECTQ (MENU (COND
					 ((AND (BOUNDP (QUOTE NC.LinkIconMiddleButtonMenu))
						 (type? MENU NC.LinkIconMiddleButtonMenu)
						 NC.LinkIconMiddleButtonMenu))
					 (T (SETQ NC.LinkIconMiddleButtonMenu
					      (create MENU
							ITEMS ←(QUOTE ((Bring% Up% Card/Box
									    (QUOTE Edit)
									    
					     "Bring up the note card pointed to by this pointer.")
									  (Change% Link% Type
									    (QUOTE Relabel)
									    
							      "Change the label of this pointer.")
									  (Change% Card% Title
									    (QUOTE Retitle)
									    
							   "Change the destination card's title.")
									  (Change% Display% Mode
									    (QUOTE Display)
									    
				      "Change the type of information displayed in this pointer.")))
							CENTERFLG ← T
							TITLE ← "Link Ops")))))
			       (Edit (NC.TraverseLink LinkIcon Window))
			       (Display (NC.ChangeLinkDisplayMode LinkIcon Window))
			       (Relabel (NC.RelabelLink LinkIcon Window))
			       (Retitle (NC.ChangeCardTitleFromLinkIcon LinkIcon Window))
			       NIL)
	   else NIL))))
)
(* * New things for NCCROSSFILELINKS)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.CrossFileLinkIcon)
)

(RPAQ NC.CrossFileLinkIcon (READBITMAP))
(21 18
"OOOOOH@@"
"H@@@@H@@"
"H@@@@H@@"
"H@CH@H@@"
"H@AL@H@@"
"H@@N@H@@"
"H@@G@H@@"
"IOOOHH@@"
"IOOOLH@@"
"IOOOHH@@"
"H@@G@H@@"
"H@@N@H@@"
"H@AL@H@@"
"H@CH@H@@"
"H@@@@H@@"
"H@@@@H@@"
"H@@@@H@@"
"OOOOOH@@")
(* * Change to NCCROSSFILELINKS)

(DEFINEQ

(NC.GetCrossFileLinkDestCard
  (LAMBDA (CrossFileLinkCard)                                (* rht: "19-Nov-86 19:30")

          (* * Find the notefile corresponding to this crossfilelink and try to open it if not already open.
	  Then look for the card in there having the given UID. Return NIL if failed for any reason.)



          (* * rht 11/10/86: Make sure CrossFileLinkCard is cached before fetching substance.)



          (* * rht 11/19/86: Now rips off version number from destination notefile hint.)


    (LET ((Title (NC.FetchTitle CrossFileLinkCard))
	  (SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
	  Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName 
	  InterestedWindow WasOpenFlg)
         (if (NOT (NC.ActiveCardP CrossFileLinkCard))
	     then (NC.GetNoteCard CrossFileLinkCard))
         (SETQ Substance (NC.FetchSubstance CrossFileLinkCard))
         (SETQ DestCardUID (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID) of 
											Substance))
         (SETQ DestNoteFileUID (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
				    of Substance))
         (SETQ DestFileHint (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint)
				 of Substance))
         (SETQ InterestedWindow (WFROMMENU (fetch (NoteFile Menu) of SourceNoteFile)))
         (SETQ DestNoteFile (NC.NoteFileFromNoteFileUID DestNoteFileUID))
         (SETQ DestFileName (OR (AND (type? NoteFile DestNoteFile)
					   (fetch (NoteFile FullFileName) of DestNoteFile))
				    DestFileHint))
         (if (OR (SETQ WasOpenFlg (NCP.OpenNoteFileP DestNoteFile))
		     (NC.AskYesOrNo (CONCAT "Trying to follow cross-file link to " Title "."
						(CHARACTER 13)
						"Okay to try opening " DestFileName "? ")
				      NIL "Yes" T InterestedWindow NIL NIL))
	     then (for while DestFileName bind Card NewFileName
		       do (if (OR (NCP.OpenNoteFileP DestNoteFile)
					(NCP.OpenNoteFileP (SETQ DestNoteFile
							       (NC.OpenNoteFile (OR DestNoteFile 
										     DestFileName)
										  NIL NIL NIL NIL NIL 
										  NIL NIL NIL 
										 InterestedWindow))))
				then (if (SETQ Card (NC.CardFromUID DestCardUID DestNoteFile))
					   then (if (NOT (EQUAL (SETQ NewFileName
									  (fetch (NoteFile 
										     FullFileName)
									     of DestNoteFile))
									(FULLNAME
									  (fetch (
CrossFileLinkSubstance CrossFileLinkDestFileHint) of Substance))))
						      then (replace (CrossFileLinkSubstance
									  CrossFileLinkDestFileHint)
								of Substance
								with (PACKFILENAME (QUOTE
											 VERSION)
										       NIL
										       (QUOTE
											 BODY)
										       NewFileName))
							     (NC.MarkCardDirty CrossFileLinkCard))
						  (RETURN Card)
					 else (NC.PrintMsg InterestedWindow T 
							     "Couldn't find destination card in "
							       DestFileName "." (CHARACTER 13))
						(OR WasOpenFlg (NC.AbortSession DestNoteFile 
										 InterestedWindow T)))
			      else (NC.PrintMsg InterestedWindow T "Couldn't open " DestFileName 
						    "."
						    (CHARACTER 13)))
			    (SETQ DestFileName (SETQ DestNoteFile NIL))
			    (AND (NC.AskYesOrNo "Want to try opening a different notefile? " T 
						    "Yes"
						    NIL InterestedWindow)
				   (SETQ DestFileName (NC.AskUser "File name to try opening: " 
								      NIL NIL T InterestedWindow))))))
    ))

(NC.CreateCrossFileLinkCard
  (LAMBDA (SourceCard DestCard TwoWayFlg)                    (* rht: "19-Nov-86 19:30")

          (* * Create a cross file link card in SourceCard's notefile.)



          (* * rht 11/19/86: Now rips off version number from destination notefile hint.)


    (LET ((DestNoteFile (fetch (Card NoteFile) of DestCard))
	  CrossFileLinkCard)
         (SETQ CrossFileLinkCard (NC.MakeNoteCard (QUOTE CrossFileLink)
						      (fetch (Card NoteFile) of SourceCard)
						      (NC.FetchTitle DestCard)
						      T
						      (create CrossFileLinkSubstance
								CrossFileLinkDestCardUID ←(fetch
								  (Card UID) of DestCard)
								CrossFileLinkDestNoteFileUID ←(fetch
								  (NoteFile UID) of DestNoteFile)
								CrossFileLinkDestFileHint ←(
								  PACKFILENAME (QUOTE VERSION)
										 NIL
										 (QUOTE BODY)
										 (fetch
										   (NoteFile 
										     FullFileName)
										    of DestNoteFile)
										 )
								CrossFileLinkTwoWayFlg ← TwoWayFlg)))
                                                             (* Indicate that card was just created.)
         (NC.SetUserDataProp CrossFileLinkCard (QUOTE JustCreatedFlg)
			       T)
     CrossFileLinkCard)))

(NC.AddCrossFileLink
  (LAMBDA NIL                                                (* rht: "20-Nov-86 00:04")

          (* * rht 11/19/86: Added LinkIconAttachedBitMap field.)


    (DECLARE (GLOBALVARS NC.CrossFileLinkIcon))
    (NC.AddCardType (QUOTE CrossFileLink)
		      (QUOTE NoteCard)
		      (BQUOTE ((MakeFn , (FUNCTION NC.CrossFileLinkMakeFn))
				 (EditFn , (FUNCTION NC.CrossFileLinkEditFn))
				 (GetFn , (FUNCTION NC.CrossFileLinkGetFn))
				 (PutFn , (FUNCTION NC.CrossFileLinkPutFn))
				 (CopyFn , (FUNCTION NC.CrossFileLinkCopyFn))
				 (MarkDirtyFn , (FUNCTION NILL))
				 (DirtyPFn , (FUNCTION NILL))
				 (QuitFn , (FUNCTION NILL))
				 (DeleteLinksFn , (FUNCTION NILL))
				 (InsertLinkFn , (FUNCTION NILL))
				 (CollectLinksFn , (FUNCTION NILL))
				 (UpdateLinkIconsFn , (FUNCTION NILL))
				 (TranslateWindowPositionFn , (FUNCTION NILL))))
		      (BQUOTE ((LinkAnchorModesSupported NIL)
				 (LinkDisplayMode , (NC.InsureLinkDisplayMode (QUOTE Title)))
				 (LinkIconAttachedBitMap , NC.CrossFileLinkIcon))))))
)
(* * Don't integrate the following. It's just for the purposes of this patch file.)

(NC.AddCrossFileLink)
(PUTPROPS RHTPATCH161 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1464 2438 (NC.LinkIconLeftButtonFn 1474 . 1741) (NC.TraverseLink 1743 . 2436)) (2470 
9205 (NC.LinkIconButtonEventInFn 2480 . 7361) (NC.LinkIconMiddleButtonFn 7363 . 9203)) (9608 15883 (
NC.GetCrossFileLinkDestCard 9618 . 13404) (NC.CreateCrossFileLinkCard 13406 . 14741) (
NC.AddCrossFileLink 14743 . 15881)))))
STOP