(FILECREATED "13-May-87 11:04:54" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH259.;2 12781  

      changes to:  (FNS NC.EditNoteCard NC.InstallCopyButtonEventFn NC.ShowBrowserGraph)
		   (VARS RHTPATCH259COMS)

      previous date: "13-May-87 11:03:24" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH259.;1)


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

(PRETTYCOMPRINT RHTPATCH259COMS)

(RPAQQ RHTPATCH259COMS ((DECLARE: FIRST (P (NC.LoadFileFromDirectories (QUOTE NCBROWSERCARD))))
			  (* * Fixes bug reported by John Tang whereby browser title bars can't be 
			     selected following Reconnect, Relayout, etc.)
			  (* * New function for NCINTERFACE)
			  (FNS NC.InstallCopyButtonEventFn)
			  (* * Change to NCCARDS)
			  (FNS NC.EditNoteCard)
			  (* * Change to NCBROWSERCARD)
			  (FNS NC.RelayoutBrowserCard NC.ShowBrowserGraph)))
(DECLARE: FIRST 
(NC.LoadFileFromDirectories (QUOTE NCBROWSERCARD))
)
(* * Fixes bug reported by John Tang whereby browser title bars can't be selected following 
Reconnect, Relayout, etc.)

(* * New function for NCINTERFACE)

(DEFINEQ

(NC.InstallCopyButtonEventFn
  (LAMBDA (Window)                                           (* rht: "13-May-87 10:52")

          (* * Save the current COPYBUTTONEVENTFN and stash ours.)


    (OR (EQ (WINDOWPROP Window (QUOTE COPYBUTTONEVENTFN))
		(FUNCTION NC.CopyButtonEventFn))
	  (WINDOWPROP Window (QUOTE OldCopyButtonEventFn)
			(WINDOWPROP Window (QUOTE COPYBUTTONEVENTFN)
				      (FUNCTION NC.CopyButtonEventFn))))))
)
(* * Change to NCCARDS)

(DEFINEQ

(NC.EditNoteCard
  (LAMBDA (Card RegionOrPosition TypeSpecificArgs)           (* rht: "13-May-87 11:04")

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



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



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



          (* * kirk 15May86 Added call to NC.AttachNoteFileName)



          (* * rht 7/13/86: Added TypeSpecificArgs arg.)



          (* * kef 7/16/86: Added NC.ObtainCardEditPermission.)



          (* * kef 8/7/86: Added check to make sure that applying the EditFn worked. If not, then release those write locks, 
	  thus keeping the writelock count consistent.)



          (* * fgh 8/30/86 Converted APPLY* to NC.ApplyFn.)



          (* * rht 10/6/86: Added checks before doing WINDOWPROP calls in case there was a recursive call to 
	  NC.EditNoteCard.)



          (* * rg 3/30/87 added NC.ProtectedCardOperation wrapper)



          (* * rht 5/13/87: Added call to new NC.InstallCopyButtonEventFn.)


    (DECLARE (GLOBALVARS NC.ShowNoteFileOnCards))
    (NC.ProtectedCardOperation Card "Edit NoteCard" NIL (RESETSAVE (CURSOR WAITINGCURSOR))
			       (PROG (NoteCardType Window Substance EditResult)
				       (COND
					 ((AND (NC.ActiveCardP Card)
						 (NC.ObtainEditPermission Card))
					   (SETQ Substance (NC.FetchSubstance Card)))
					 ((NC.ObtainEditPermission Card)
					   (NC.GetNoteCard Card)
					   (SETQ Substance (NC.FetchSubstance Card)))
					 (T (RETURN (NC.CardPartBusy Card
									 (QUOTE (SUBSTANCE TOLINKS 
										    GLOBALTOLINKS 
											 PROPLIST)))))
					 )
				       (SETQ NoteCardType (NC.RetrieveType Card))
				       (COND
					 ((AND (SETQ EditResult
						   (ERSETQ (NC.ApplyFn EditFn Card Substance 
									 RegionOrPosition 
									 TypeSpecificArgs)))
						 (WINDOWP (SETQ Window (CAR EditResult))))
					   (WINDOWADDPROP Window (QUOTE CLOSEFN)
							    (FUNCTION NC.QuitCard)
							    (QUOTE FIRST))
					   (OR (NC.CardP (WINDOWPROP Window (QUOTE 
										   NoteCardObject)))
						 (WINDOWPROP Window (QUOTE NoteCardObject)
							       Card))
					   (NC.InstallCopyButtonEventFn Window)
					   (if NC.ShowNoteFileOnCards
					       then (NC.AttachNoteFileName Window)))
					 (T                  (* At this point, we've obtain the write locks but the
							     edit failed, so we'd better release them)
					    (for CardPart in (QUOTE (SUBSTANCE TOLINKS 
										    GLOBALTOLINKS 
										     PROPLIST))
					       do (NC.ApplyFn ReleaseWritePermissionFn Card 
								CardPart))
					    (RETURN)))
				       (RETURN Window)))))
)
(* * Change to NCBROWSERCARD)

(DEFINEQ

(NC.RelayoutBrowserCard
  (LAMBDA (Window)                                           (* rht: "13-May-87 10:54")

          (* * Called from the middle button of a browser or structeditbrowser card. This lays out and displays the browser, 
	  but does not recompute the nodes.)



          (* * rht 11/17/85: updated to handle new notefile and card objects.)



          (* * rht 2/7/86: Now gets browser format, etc. via fetch/set fns.)



          (* * rht 2/28/86: Added WINDOWPROP for SCROLLFN and RESHAPEFN.)



          (* * rht 5/8/86: Added calls to rig title bar properly.)



          (* * fgh 6/30/86 Added NC.GRAPHERCOPYBUTTONEVENTFN to SHOWGRAPH call)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)



          (* * rg 3/4/87 rewritten for new version of NC.ProtectedCardOperation, removed DontCheckOpInProgressFlg)


    (LET ((Card (NC.CoerceToCard Window)))
         (NC.ProtectedCardOperation
	   Card "Relayout Browser Card" NIL
	   (PROG (RootCards RootNodeIDs OldToNodePairs Graph GraphNodes BrowserFormat 
			      DropVirtualNodesFlg SpecialBrowserSpecs)
	           (NC.PrintMsg Window T "Laying out graph ...")
	           (SETQ RootCards (NC.FetchBrowserRoots Card))
	           (SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
					       (QUOTE (LATTICE))))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	           (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		       then (SETQ DropVirtualNodesFlg T))
	           (SETQ SpecialBrowserSpecs (OR (CAR (NC.FetchSpecialBrowserSpecs Card))
						     (create SPECIALBROWSERSPECS)))
	           (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph
									 (WINDOWPROP Window
										       (QUOTE
											 GRAPH)))))
                                                             (* Create hash array if haven't already.)
	           (NC.GetBrowserHashArray Card Graph)     (* check graph node size against image box size.)
	           (NC.GraphLinkIconUpdateCheck Card Window Graph NIL)

          (* Save the TONODES values of the nodes so can replace later after LAYOUTGRAPH call. At the same time, throw away 
	  all the link params info in TONODES field.)


	           (SETQ OldToNodePairs (for Node in GraphNodes bind ToNodes eachtime
										      (BLOCK)
					     collect
					      (PROG1 (CONS (fetch (GRAPHNODE NODEID)
								  of Node)
							       (APPEND (SETQ ToNodes
									   (fetch (GRAPHNODE 
											  TONODES)
									      of Node))))
						       (replace (GRAPHNODE TONODES) of Node
							  with (for ToNode in ToNodes
								    collect
								     (if (EQ (CAR ToNode)
										 LINKPARAMS)
									 then (CADR ToNode)
								       else ToNode))))))
	           (SETQ RootNodeIDs (for RootCard in RootCards collect (NC.GetBrowserNodeID
										  Card RootCard)))
	           (NC.SetPropListDirtyFlg Card T)         (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
	           (SETQ Graph (if GraphNodes
				     then (LAYOUTGRAPH
					      GraphNodes
					      (for Node in GraphNodes bind NodeID
						 eachtime (BLOCK)
							    (SETQ NodeID (fetch (GRAPHNODE NODEID)
									      of Node))
						 when (OR (AND (NULL (fetch (GRAPHNODE
											FROMNODES)
										of Node))
								     (NOT (LISTP NodeID)))
							      (FMEMB NodeID RootNodeIDs))
						 collect NodeID)
					      (SUBST (QUOTE LATTICE)
						       NC.*Graph*BrowserFormat BrowserFormat)
					      (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
					      (fetch (SPECIALBROWSERSPECS MotherD) of 
									      SpecialBrowserSpecs)
					      (fetch (SPECIALBROWSERSPECS PersonalD) of 
									      SpecialBrowserSpecs)
					      (fetch (SPECIALBROWSERSPECS FamilyD) of 
									      SpecialBrowserSpecs))
				   else (create GRAPH)))

          (* Replace the TONODES fields of the Graph nodes by their pre-LAYOUTGRAPH values. Also throw away any nodes that 
	  didn't appear in the old graph.)


	           (if Graph
		       then (replace (GRAPH GRAPHNODES) of Graph
				 with (for Node in (fetch (GRAPH GRAPHNODES) of Graph)
					   bind AssocPair eachtime (BLOCK)
					   when (SETQ AssocPair (FASSOC (fetch (GRAPHNODE
											 NODEID)
										 of Node)
									      OldToNodePairs))
					   collect (replace (GRAPHNODE TONODES) of Node
							with (CDR AssocPair))
						     (if DropVirtualNodesFlg
							 then (replace (GRAPHNODE NODEBORDER)
								   of Node with NIL))
                                                             (* Throw away LINKPARAMS junk from the FromNodes that 
							     LAYOUTGRAPH stuck in.)
						     (replace (GRAPHNODE FROMNODES) of Node
							with (for FromNode
								  in (fetch (GRAPHNODE FROMNODES)
									  of Node)
								  eachtime (BLOCK)
								  collect
								   (if (EQ (CAR FromNode)
									       LINKPARAMS)
								       then (CADR FromNode)
								     else FromNode)))
						     Node)))
	           (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
				(FUNCTION NC.GraphCardMiddleButtonFn)
				NIL T (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN))

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
	           (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
				 (FUNCTION NC.BrowserRightButtonFn))
	           (WINDOWADDPROP Window (QUOTE REPAINTFN)
				    (FUNCTION NC.BrowserRepaintFn)
				    T)
	           (WINDOWPROP Window (QUOTE SCROLLFN)
				 (FUNCTION NC.BrowserScrollFn))
	           (WINDOWPROP Window (QUOTE RESHAPEFN)
				 (FUNCTION NC.BrowserReshapeFn))
	           (NC.SetSubstance Card (WINDOWPROP Window (QUOTE GRAPH)))
	           (NC.MarkCardDirty Card)
	           (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.TitleBarButtonEventFn))
	           (NC.InstallCopyButtonEventFn Window)
	           (NC.ClearMsg Window T))))))

(NC.ShowBrowserGraph
  (LAMBDA (Graph Window)                                     (* rht: "13-May-87 11:00")

          (* * SHOWGRAPH Graph in Window.)



          (* * rht 5/13/87: Added call to NC.InstallCopyButtonEventFn.)


    (SHOWGRAPH Graph Window (FUNCTION NC.GraphCardLeftButtonFn)
		 (FUNCTION NC.GraphCardMiddleButtonFn)
		 NIL T)

          (* * Have to reset windowprops since SHOWGRAPH messes with them.)

                                                             (* Disable the old-style right button grapher editor 
							     menu.)
    (WINDOWPROP Window (QUOTE RIGHTBUTTONFN)
		  (FUNCTION NC.BrowserRightButtonFn))
    (WINDOWADDPROP Window (QUOTE REPAINTFN)
		     (FUNCTION NC.BrowserRepaintFn)
		     T)
    (WINDOWPROP Window (QUOTE SCROLLFN)
		  (FUNCTION NC.BrowserScrollFn))
    (WINDOWPROP Window (QUOTE RESHAPEFN)
		  (FUNCTION NC.BrowserReshapeFn))
    (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.TitleBarButtonEventFn))
    (NC.InstallCopyButtonEventFn Window)))
)
(PUTPROPS RHTPATCH259 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1089 1578 (NC.InstallCopyButtonEventFn 1099 . 1576)) (1609 4584 (NC.EditNoteCard 1619
 . 4582)) (4621 12699 (NC.RelayoutBrowserCard 4631 . 11586) (NC.ShowBrowserGraph 11588 . 12697)))))
STOP