(FILECREATED "24-Apr-85 01:14:00" {PHYLUM}<NOTECARDS>RELEASE1.2>NCSTRUCTEDITCARD.;4 8155   

      changes to:  (FNS NC.AddStructEditCard)

      previous date: " 8-Apr-85 20:09:35" {PHYLUM}<NOTECARDS>RELEASE1.2>NCSTRUCTEDITCARD.;3)


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

(PRETTYCOMPRINT NCSTRUCTEDITCARDCOMS)

(RPAQQ NCSTRUCTEDITCARDCOMS ((E (SETQ NC.SystemDate (DATE))
				(UNMARKASCHANGED (QUOTE NC.SystemDate)
						 (QUOTE VARS)))
			     (VARS NC.SystemDate)
			     (P (UNMARKASCHANGED (QUOTE NC.SystemDate)
						 (QUOTE VARS)))
			     (* * Struct Editor Stuff)
			     (FILES NCGRAPHSUBSTANCE NCGRAPHCARD)
			     (FNS NC.MakeStructEditCard NC.FixStructEditTitleBarMenu 
				  NC.StructEditAddNodeFn NC.StructEditAddLinkFn 
				  NC.StructEditDeleteNodeFn NC.StructEditDeleteLinkFn)
			     (FNS NC.AddStructEditCard)
			     (P (NC.AddStructEditCard))))

(RPAQQ NC.SystemDate "24-Apr-85 01:14:00")
(UNMARKASCHANGED (QUOTE NC.SystemDate)
		 (QUOTE VARS))
(* * Struct Editor Stuff)

(FILESLOAD NCGRAPHSUBSTANCE NCGRAPHCARD)
(DEFINEQ

(NC.MakeStructEditCard
  (LAMBDA (ID Title NoDisplayFlg)                            (* rht: " 3-Feb-85 23:50")

          (* * Creates a StructEdit card. Alot like a graph card except that it allows editing of underlying NC structure, and
	  doesn't allow an "insertlink" operation in title bar menu.)


    (PROG (ReturnValue Graph)
          (SETQ ReturnValue (APPLY* (NCP.CardTypeFn (QUOTE Graph)
						    (QUOTE MakeCardFn))
				    ID Title NoDisplayFlg))
          (SETQ Graph (NC.FetchSubstance ID))
          (replace (GRAPH GRAPH.ADDNODEFN) of Graph with (FUNCTION NC.StructEditAddNodeFn))
          (replace (GRAPH GRAPH.DELETENODEFN) of Graph with (FUNCTION NC.StructEditDeleteNodeFn))
          (replace (GRAPH GRAPH.ADDLINKFN) of Graph with (FUNCTION NC.StructEditAddLinkFn))
          (replace (GRAPH GRAPH.DELETELINKFN) of Graph with (FUNCTION NC.StructEditDeleteLinkFn))
          (replace (GRAPH GRAPH.MOVENODEFN) of Graph with (FUNCTION NC.GraphMoveNodeFn))
          (replace (GRAPH GRAPH.FONTCHANGEFN) of Graph with (FUNCTION NC.GraphFontChangeFn))
          (RETURN ReturnValue))))

(NC.FixStructEditTitleBarMenu
  (LAMBDA (Window)                                           (* rht: "12-Jan-85 12:56")

          (* * Remove the InsertLink item from the Window's title bar menu.)


    (PROG ((Menu (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu)))
	   MenuItems)
          (SETQ MenuItems (fetch (MENU ITEMS) of Menu))
          (replace (MENU ITEMS) of Menu with (for Item in MenuItems when (EQ (CAR Item)
									     (QUOTE Insert% Link))
						do (RETURN (LSUBST NIL Item MenuItems)))))))

(NC.StructEditAddNodeFn
  (LAMBDA (Graph Window)                                     (* rht: " 8-Apr-85 17:58")

          (* * Called by grapher when user creates a new node. Returns new node or nil.)


    (PROG ((Link (NC.MakeLink Window NC.BrowserContentsLinkLabel NIL NIL NIL NIL 
			      "Please select existing Card or Box or create a new one."
			      T))
	   (GraphID (NC.IDFromWindow Window))
	   GraphNodeID ID Title)
          (COND
	    (Link (COND
		    ((FASSOC (SETQ GraphNodeID (PACK* GraphID (SETQ ID (fetch (NOTECARDLINK 
										    DESTINATIONID)
									  of Link))))
			     (fetch (GRAPH GRAPHNODES) of Graph))
		      (NC.PrintMsg Window T "Node for card '" (NC.FetchTitle ID)
				   "' already in graph.")
		      (NCP.DeleteLinks Link)
		      (RETURN NIL))
		    ((AND (NC.FetchNewCardFlg ID)
			  (SETQ Title (NC.AskUser "Title of new card: " "--" NIL T Window)))
		      (NC.SetTitle ID Title)))
		  (NC.MarkCardDirty GraphID)
		  (RETURN (NODECREATE GraphNodeID (NC.MakeLinkIcon Link)
				      (CURSORPOSITION NIL Window))))))))

(NC.StructEditAddLinkFn
  (LAMBDA (FromNode ToNode Graph Window)                     (* rht: " 3-Feb-85 23:27")

          (* * Called by grapher when user creates a new link.)


    (PROG ((GraphID (NC.IDFromWindow Window))
	   SourceID SourceType DestinationID LinkLabel StartingIDChar)
          (NC.MarkCardDirty GraphID)
          (SETQ StartingIDChar (ADD1 (NCHARS GraphID)))
          (SETQ SourceID (SUBATOM (fetch (GRAPHNODE NODEID) of FromNode)
				  StartingIDChar))
          (SETQ DestinationID (SUBATOM (fetch (GRAPHNODE NODEID) of ToNode)
				       StartingIDChar))
          (SETQ LinkLabel (COND
	      ((EQ (SETQ SourceType (NC.FetchType SourceID))
		   (QUOTE FileBox))
		(COND
		  ((EQ (NC.FetchType DestinationID)
		       (QUOTE FileBox))
		    NC.SubBoxLinkLabel)
		  (T NC.FiledCardLinkLabel)))
	      (T (NC.AskLinkLabel Window NIL NIL T))))
          (COND
	    ((EQ (NCP.CardTypeSubstance SourceType)
		 (QUOTE TEXT))
	      (NCP.LocalGlobalLink LinkLabel SourceID DestinationID))
	    (T (NCP.GlobalGlobalLink LinkLabel SourceID DestinationID))))))

(NC.StructEditDeleteNodeFn
  (LAMBDA (Node Graph Window)                                (* rht: " 3-Feb-85 23:28")

          (* * Called by grapher when user deletes a node.)


    (PROG ((GraphID (NC.IDFromWindow Window))
	   ID StartingIDChar)
          (SETQ StartingIDChar (ADD1 (NCHARS GraphID)))
          (SETQ ID (SUBATOM (fetch (GRAPHNODE NODEID) of Node)
			    StartingIDChar))
          (NC.MarkCardDirty GraphID)
          (COND
	    ((AND (NCP.ValidID ID)
		  (NC.YesP (NC.AskUser (CONCAT "Want to delete the " (NC.FetchTitle ID)
					       " card? ")
				       "--"
				       (QUOTE Yes)
				       T Window)))
	      (NCP.DeleteCards ID)
	      (NC.PrintMsg Window NIL "Done."))))))

(NC.StructEditDeleteLinkFn
  (LAMBDA (FromNode ToNode Graph Window)                     (* rht: " 6-Feb-85 14:56")

          (* * Called by grapher when user deletes a link.)


    (PROG ((GraphID (NC.IDFromWindow Window))
	   SourceID SourceType DestinationID LinkLabel StartingIDChar Link Links)
          (SETQ StartingIDChar (ADD1 (NCHARS GraphID)))
          (SETQ SourceID (SUBATOM (fetch (GRAPHNODE NODEID) of FromNode)
				  StartingIDChar))
          (SETQ DestinationID (SUBATOM (fetch (GRAPHNODE NODEID) of ToNode)
				       StartingIDChar))
          (SETQ Links (NCP.GetLinks SourceID DestinationID))
          (OR Links (RETURN NIL))
          (NC.MarkCardDirty GraphID)
          (SETQ Link (COND
	      ((CDR Links)
		(MENU (create MENU
			      ITEMS ←(for Link in Links collect (LIST (fetch (NOTECARDLINK LINKLABEL)
									 of Link)
								      Link))
			      TITLE ← "Which link to delete?")))
	      (T (CAR Links))))
          (COND
	    ((AND Link (NC.YesP (NC.AskUser (CONCAT "Want to delete the " (fetch (NOTECARDLINK 
											LINKLABEL)
									     of Link)
						    " link between "
						    (NC.FetchTitle SourceID)
						    " and "
						    (NC.FetchTitle DestinationID)
						    "? ")
					    "--"
					    (QUOTE Yes)
					    T Window)))
	      (NCP.DeleteLinks Link)
	      (NC.PrintMsg Window NIL "Done."))))))
)
(DEFINEQ

(NC.AddStructEditCard
  (LAMBDA NIL                                                (* rht: "24-Apr-85 01:10")
    (NC.AddCardType (QUOTE StructEdit)
		    (QUOTE Graph)
		    (QUOTE GRAPH)
		    (BQUOTE ((MakeCardFn , (FUNCTION NC.MakeStructEditCard))))
		    (BQUOTE ((CardDisplayedInMenuFlg , NIL))))))
)
(NC.AddStructEditCard)
(PUTPROPS NCSTRUCTEDITCARD COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1082 7692 (NC.MakeStructEditCard 1092 . 2343) (NC.FixStructEditTitleBarMenu 2345 . 2949
) (NC.StructEditAddNodeFn 2951 . 4136) (NC.StructEditAddLinkFn 4138 . 5351) (NC.StructEditDeleteNodeFn
 5353 . 6147) (NC.StructEditDeleteLinkFn 6149 . 7690)) (7693 8045 (NC.AddStructEditCard 7703 . 8043)))
))
STOP