(FILECREATED "23-Nov-87 14:13:57" {QV}<NOTECARDS>1.3KNEXT>RGPATCH066.;1 18207  

      changes to:  (VARS RGPATCH066COMS)
		   (FNS NC.ShowLinks NC.OpenPropListEditor NC.EditPropList NC.MakeTextCardReadOnly 
			NC.MakeTextCardReadWrite))


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

(PRETTYCOMPRINT RGPATCH066COMS)

(RPAQQ RGPATCH066COMS ((* * RG 11/23/87 now ShowLinks is only read-only if card is read-only)
			 (* * changes to NCCARDS)
			 (FNS NC.ShowLinks NC.OpenPropListEditor NC.EditPropList)
			 (* * changes to NCTEXTCARD)
			 (FNS NC.MakeTextCardReadOnly NC.MakeTextCardReadWrite)))
(* * RG 11/23/87 now ShowLinks is only read-only if card is read-only)

(* * changes to NCCARDS)

(DEFINEQ

(NC.ShowLinks
  [LAMBDA (CardIdentifier)                                   (* Randy.Gobbel "23-Nov-87 14:11")
                                                             (* 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.)



          (* * rht 8/11/86: Now passes non-nil ShowLinksFlg to NC.OpenPropListEditor.)



          (* * rg 4/6/87 removed NC.ProtectedCardOperation wrapper.)



          (* * pmi 6/19/87: Now places each link's UID on the corresponding link created for the inspector.
	  Checks for the validity of each link's source and destination cards and deletes links that are bad 
	  (half-links.))



          (* * rht 9/30/87: Now takes arbitrary CardIdentifier as arg.)



          (* * rg 11/23/87 now only opens prop list editor read-only if card is read-only)


    (LET ((Card (NC.CoerceToCard CardIdentifier))
	  Links EditWindow)
         [SETQ Links (NCONC [for Link in (NC.FetchToLinks Card)
				   when (if (NC.ValidCardP (fetch (Link DestinationCard)
								    of Link))
					      then         (* The link is good, include it in the show links 
							     window.)
						     T
					    else           (* The link is bad, delete it and don't include it in 
							     the show links window.)
						   (NC.DeleteLink Link)
						   NIL)
				   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))
							      UID ← (fetch (Link UID) of Link]
				(for Link in (NC.FetchFromLinks Card)
				   when (if (NC.ValidCardP (fetch (Link SourceCard)
								    of Link))
					      then         (* The link is good, include it in the show links 
							     window.)
						     T
					    else           (* The link is bad, delete it and don't include it in 
							     the show links window.)
						   (NC.DeleteLink Link)
						   NIL)
				   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))
							      UID ← (fetch (Link UID) of Link]
         (WINDOWPROP (SETQ EditWindow (NC.OpenPropListEditor (NC.FetchWindow Card)
								   Links "List of Links"
								   (NC.FetchUserDataProp
								     Card
								     (QUOTE ReadOnly))
								   T T))
		       (QUOTE ShowLinks)
		       T)
     EditWindow])

(NC.OpenPropListEditor
  [LAMBDA (WindowOrTextStream PropList Title ShowOnlyFlg MakeImageObjFlg ShowLinksFlg)
                                                             (* Randy.Gobbel "23-Nov-87 13:56")
                                                             (* Open a property list editor above the card 
							     specified by TextStream , which is either a TextStream
							     or a Window)

          (* * rht 8/11/86: Now takes ShowLinksFlg arg and passes to NC.PropListEditorOpenP so that we don't bail out if 
	  there's an open proplist not of our type.)



          (* * rht 11/13/86: Now hangs Card object off prop list editor's window so that we can get to the card from the 
	  proplist editor at close time.)



          (* * rht 12/11/86: Now only breaks out list if we're under ShowLinks.)



          (* * rht 9/30/87: Now allows reuse of ShowLinks editor window.)



          (* * rg 11/23/87 passes ShowLinksFlg to NC.EditPropList)


    (PROG ((Window (WINDOW.FROM.TEDIT.THING WindowOrTextStream))
	     (SystemProperties (QUOTE (ID Updates ItemDate LinksDate PropsDate TitleDate)))
	     EditWindow CardUID Card)                        (* Make sure there is no prop list editor already 
							     there. Okay, however, to reuse ShowLinks editor.)
	    (if (AND (SETQ EditWindow (NC.PropListEditorOpenP Window ShowLinksFlg))
			 (NOT ShowLinksFlg))
		then (RETURN))
	    [SETQ CardUID (fetch (Card UID) of (SETQ Card (NC.CoerceToCard Window]
                                                             (* FOR each prop/value pair with LISTP value.
							     Make a series of individual prop/value pairs 
							     corresponding to the elements of the LISTP)
	    [SETQ PropList (for Item on PropList by (CDDR Item)
				join (COND
					 ((AND (LISTP (CADR Item))
						 (type? Link (CAADR Item)))
					   (for Element in (CADR Item)
					      collect (create PropListItem
								  PropertyName ← (CAR Item)
								  Value ← Element
								  OriginalListFlg ← T
								  AllowEditFlg ← NIL
								  AllowSelectFlg ← NIL
								  ButtonFn ← NIL)))
					 (T (LIST (create PropListItem
							      PropertyName ← (CAR Item)
							      Value ← (CADR Item)
							      OriginalListFlg ← NIL
							      AllowEditFlg ← NIL
							      AllowSelectFlg ← NIL
							      ButtonFn ← NIL]
                                                             (* If specified, translate all NOTECARDLINK values 
							     into Image Objects for display.)
	    [AND MakeImageObjFlg (for Item in PropList bind LinkIcon
				      when (type? Link (fetch (PropListItem Value)
							      of Item))
				      do (replace (PropListItem Value) of Item
					      with (SETQ LinkIcon (NC.MakeLinkIcon
							 (fetch (PropListItem Value) of Item)))
						     (IMAGEOBJPROP LinkIcon (QUOTE 
									     InsidePropListEditor)
								     T]
                                                             (* Indicate which properties can be edited by user.)
	    [for Item in PropList do (COND
					     ((FMEMB (fetch (PropListItem PropertyName)
							  of Item)
						       SystemProperties)
					       (replace (PropListItem AllowEditFlg) of Item
						  with T)
					       (replace (PropListItem AllowSelectFlg) of Item
						  with T))
					     (ShowOnlyFlg (replace (PropListItem AllowEditFlg)
							     of Item with NIL)
							  (replace (PropListItem AllowSelectFlg)
							     of Item with T))
					     (T (replace (PropListItem AllowEditFlg) of Item
						   with NIL)
						(replace (PropListItem AllowSelectFlg)
						   of Item with NIL]
                                                             (* Call the prop list editor)
	    (OR (WINDOWP EditWindow)
		  (ATTACHWINDOW (SETQ EditWindow (CREATEW (CREATEREGION 1000 2000 100 100)
								(OR Title "Edit Property List")
								NIL T))
				  Window
				  (QUOTE TOP)
				  (QUOTE JUSTIFY)
				  (QUOTE LOCALCLOSE)))
	    (WINDOWADDPROP EditWindow (QUOTE CLOSEFN)
			     (FUNCTION FREEATTACHEDWINDOW)
			     T)
	    (WINDOWPROP EditWindow (QUOTE PropListEditor)
			  (COND
			    (ShowOnlyFlg (QUOTE ShowOnly))
			    (T T)))
	    (WINDOWPROP EditWindow (QUOTE SavedCardObject)
			  Card)
	    (NC.EditPropList PropList EditWindow ShowOnlyFlg ShowLinksFlg)
	    (RETURN EditWindow])

(NC.EditPropList
  [LAMBDA (propList window showOnlyFlg showLinksFlg)         (* Randy.Gobbel "23-Nov-87 13:56")

          (* * propList is a list of RECORDS of type PropListItem)



          (* * Edit a property list using the TEDIT menu-based editor. The var window is the window to use.
	  If none supplied, get one from user.)



          (* * rht 4/11/86: Now stashes length of propList on WINDOWPROP.)



          (* * rht 8/12/86: Moved code to add NC.ClosePropListEditor on CLOSEFN from NC.OpenPropListEditor to here so that it
	  can before TEDIT.DEACTIVATE.WINDOW on the CLOSEFN list.)



          (* * rht 1/16/87: Now stashes prop names on windowprop rather than number of props.)



          (* * pmi 3/25/87: Added NC.MenuFont to all menus)



          (* * rg 11/19/87 menu items put on global vars (for make read-only))



          (* * rht/rg 11/20/87 Now kills any existing edit process in editW before starting new one.)



          (* * rg 11/23/87 added showLinksFlg arg)


    (DECLARE (GLOBALVARS NC.MenuFont NC.ShowPropListMenu NC.EditPropListMenu))
    (PROG (menuStream textObj editW button editProcess (font (FONTCREATE (QUOTE HELVETICA)
									     8))
			(CH# 1)
			(ENDCH# 1))                          (* Init the editList and the propFnsList)
                                                             (* Create a TEDITMenu that reflects the structure of 
							     the proplist)
	    [SETQ menuStream
	      (\TEXTMENU.DOC.CREATE
		(for X in propList
		   join (NCONC [LIST (LIST (QUOTE MB.BUTTON)
						   (MKSTRING (fetch (PropListItem PropertyName)
								  of X))
						   (OR (fetch (PropListItem ButtonFn)
							    of X)
							 (FUNCTION NC.EditPropButtonFN]
				   (COND
				     [(NOT (IMAGEOBJP (fetch (PropListItem Value) of X)))
				       (COND
					 ((fetch (PropListItem AllowEditFlg) of X)
					   (LIST (LIST (QUOTE MB.TEXT)
							   (CONCAT (CHARACTER 9)
								     "  ["
								     (MKSTRING (fetch
										   (PropListItem
										     Value)
										    of X))
								     "]"
								     (CHARACTER 13))
							   font)))
					 (T (LIST (LIST (QUOTE MB.TEXT)
							    (CHARACTER 9)
							    font)
						    (LIST (QUOTE MB.INSERT)
							    (MKSTRING (fetch (PropListItem Value)
									   of X)))
						    (LIST (QUOTE MB.TEXT)
							    (CHARACTER 13)
							    font]
				     (T (LIST (LIST (QUOTE MB.TEXT)
							(CHARACTER 9)
							font)
						(LIST (QUOTE MB.INSERT))
						(LIST (QUOTE MB.TEXT)
							(CHARACTER 13)
							font]
	    (SETQ textObj (TEXTOBJ menuStream))          (* Go back and insert the ImageObjects into their 
							     value fields.)
	    (SETQ CH# 0)
	    [for prop in propList when (OR (IMAGEOBJP (fetch (PropListItem Value)
								   of prop))
						   (NULL (fetch (PropListItem AllowEditFlg)
							      of prop)))
	       do (MBUTTON.FIND.NEXT.FIELD textObj (SETQ CH# (ADD1 CH#)))
		    (SETQ CH# (fetch CH# of (fetch SCRATCHSEL of textObj)))
		    (COND
		      ((IMAGEOBJP (CADR prop))
			(TEDIT.INSERT.OBJECT (fetch (PropListItem Value) of prop)
					       menuStream CH#]
	    (SETQ CH# 0)
	    (for prop in propList
	       do (SETQ button (MBUTTON.FIND.NEXT.BUTTON textObj (ADD1 CH#)))
		    (SETQ CH# (CDR button))              (* If the buttonProtect flag is on, protect the 
							     button)
		    (AND (fetch (PropListItem AllowSelectFlg) of prop)
			   (IMAGEOBJPROP (CAR button)
					   (QUOTE EditPropListNoDelete)
					   T)))              (* Set up window and window title)
	    [SETQ editW (COND
		(window window)
		(T (CREATEW (GETREGION)
			      "Edit Property List"]          (* Point to the proplist being edited so we can update
							     it when this menu is closed.
							     (See NC.CloseEditPropListWindow))
	    (WINDOWPROP editW (QUOTE PROPERTYLIST.BEING.EDITED)
			  propList)
	    (WINDOWPROP editW (QUOTE PROPERTYLIST.PROPNAMES)
			  (for Item in propList collect (CAR Item)))
                                                             (* Set the right margin to very-far-away.
							     Prevents stuff from wrapping around)
	    (TEDIT.PARALOOKS textObj [QUOTE (RIGHTMARGIN 1000 TABS (50 (80 . LEFT]
			       1
			       (GETFILEINFO menuStream (QUOTE LENGTH)))
                                                             (* Set the first tab so the fields will line up 
							     correctly)
                                                             (* Set selection to the top -- make it look pretty)
	    (replace (SELECTION SET) of (fetch (TEXTOBJ SEL) of textObj) with NIL)
                                                             (* Kill any existing tedit process.
							     Notice we have to do WINDOWPROP because calling 
							     TEXTSTREAM breaks if window doesn't have one.)
	    (LET [(OldTextStream (WINDOWPROP editW (QUOTE TEXTSTREAM]
	         (if (TEXTSTREAMP OldTextStream)
		     then (TEDIT.KILL OldTextStream)))
	    [SETQ editProcess (TEDIT menuStream editW NIL (LIST (QUOTE MENU)
								      (COND
									((OR showOnlyFlg 
									       showLinksFlg)
									  NC.ShowPropListMenu)
									(T NC.EditPropListMenu]
	    (until (TEDIT-PROCESS-P editProcess) do (BLOCK))
	    (if showOnlyFlg
		then (NC.MakeTEditReadOnly editW))
	    (WINDOWADDPROP editW (QUOTE CLOSEFN)
			     (FUNCTION NC.ClosePropListEditor)
			     T])
)
(* * changes to NCTEXTCARD)

(DEFINEQ

(NC.MakeTextCardReadOnly
  [LAMBDA (Card)                                             (* Randy.Gobbel "23-Nov-87 14:11")
    (DECLARE (GLOBALVARS NC.ShowPropListMenu))
    (LET ((Window (NC.FetchWindow Card))
	  PropListEditor)
         (NC.ProtectedCardOperation Card "Make Read-Only" Window
				    (if (NC.CardSomehowDirtyP Card)
					then (ALLOW.BUTTON.EVENTS)
					       (if (MENU (create MENU
								       TITLE ← "Card has been edited"
								       ITEMS ←
								       (QUOTE (("Save Changes"
										    T 
							"Save edited version of card in NoteFile")
										  ("Revert" NIL 
					     "Discard edits, refetch card contents from NoteFile")))
								       CENTERFLG ← T))
						   then (NC.CardSaveFn Card NIL Window)
						 else (NC.RevertTextCard Card)))
				    (NC.SetUserDataProp Card (QUOTE ReadOnly)
							  T)
				    (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP
							 Window)))
					then (NC.MakeTEditReadOnly PropListEditor)
					       (WINDOWPROP PropListEditor (QUOTE TEDIT.MENU)
							     NC.ShowPropListMenu))
				    (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP
							 Window T)))
					then (NC.MakeTEditReadOnly PropListEditor))
				    (NC.MakeTEditReadOnly Window
							    (QUOTE (Assign% Title Title/FileBoxes 
										Add% Global% Link 
										    Insert% Links 
										 Put% Cards% Here 
										  Restart% Editor))
							    (QUOTE (Delete% Card])

(NC.MakeTextCardReadWrite
  [LAMBDA (Card)                                             (* Randy.Gobbel "23-Nov-87 14:11")
    (DECLARE (GLOBALVARS NC.EditPropListMenu))
    (LET ((Window (NC.FetchWindow Card))
	  PropListEditor)
         (NC.ProtectedCardOperation Card "Make Read-Write" Window (if (WINDOWP (SETQ 
										   PropListEditor
										     (
									   NC.PropListEditorOpenP
										       Window)))
								      then (NC.MakeTEditReadWrite
									       PropListEditor)
									     (WINDOWPROP
									       PropListEditor
									       (QUOTE TEDIT.MENU)
									       NC.EditPropListMenu))
				    (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP
							 Window T)))
					then (NC.MakeTEditReadWrite PropListEditor))
				    (NC.MakeTEditReadWrite Window)
				    (NC.SetUserDataProp Card (QUOTE ReadOnly)
							  NIL])
)
(PUTPROPS RGPATCH066 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (735 15534 (NC.ShowLinks 745 . 4695) (NC.OpenPropListEditor 4697 . 9473) (
NC.EditPropList 9475 . 15532)) (15569 18126 (NC.MakeTextCardReadOnly 15579 . 17165) (
NC.MakeTextCardReadWrite 17167 . 18124)))))
STOP