(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED "19-Oct-88 10:06:18" {DSK}<LISPFILES>STORYBOARD>JRCPATCH027.;6 33457  

      changes to%:  (VARS JRCPATCH027COMS)

      previous date%: "30-Sep-88 17:33:06" {DSK}<LISPFILES>STORYBOARD>JRCPATCH027.;5)


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

(PRETTYCOMPRINT JRCPATCH027COMS)

(RPAQQ JRCPATCH027COMS
       ([DECLARE%: FIRST (P (NC.LoadFileFromDirectories 'NCBROWSERCARD]
        
        (* ;; "jrc 19-oct-88:  various changes to NCBROWSERCARD:")

        
        (* ;; "NC.BrowserAddLink now returns the link that it creates (if there is one).")

        
        (* ;; "NC.ShowBrowserGraph and NC.RelayoutBrowserCard now preserve and replace the WINDOWPROPs that their call to SHOWGRAPH destroys.  NC.ShowBrowserGraph and NC.RelayoutBrowserCard used to replace the WINDOWPROPs with standard BROWSERCARD functions, but if your card was an augmented browser with extra WINDOWPROPs (like a guided tour card), those extra WINDOWPROPs got lost.")

        
        (* ;; "NC.MakeBrowserCard requires a somewhat different fix, though, because, in this case, it was expecting its call to SHOWGRAPH (via NC.RelayoutBrowserCard) to initialize some of the WINDOWPROPs correctly.  Now NC.MakeBrowserCard initializes (some of) those props itself, not requiring SHOWGRAPH to do it.")

        (FNS NC.ShowBrowserGraph NC.BrowserAddLink NC.RelayoutBrowserCard NC.MakeBrowserCard)))
(DECLARE%: FIRST 

(NC.LoadFileFromDirectories 'NCBROWSERCARD)
)



(* ;; "jrc 19-oct-88:  various changes to NCBROWSERCARD:")




(* ;; "NC.BrowserAddLink now returns the link that it creates (if there is one).")




(* ;; 
"NC.ShowBrowserGraph and NC.RelayoutBrowserCard now preserve and replace the WINDOWPROPs that their call to SHOWGRAPH destroys.  NC.ShowBrowserGraph and NC.RelayoutBrowserCard used to replace the WINDOWPROPs with standard BROWSERCARD functions, but if your card was an augmented browser with extra WINDOWPROPs (like a guided tour card), those extra WINDOWPROPs got lost."
)




(* ;; 
"NC.MakeBrowserCard requires a somewhat different fix, though, because, in this case, it was expecting its call to SHOWGRAPH (via NC.RelayoutBrowserCard) to initialize some of the WINDOWPROPs correctly.  Now NC.MakeBrowserCard initializes (some of) those props itself, not requiring SHOWGRAPH to do it."
)

(DEFINEQ

(NC.ShowBrowserGraph
  [LAMBDA (Graph Window)                                     (* ; "Edited 29-Sep-88 10:59 by jrc")

         (* * SHOWGRAPH Graph in Window.)

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

         (* * rht 10/13/87%: Added COPYBUTTONEVENTFN arg to SHOWGRAPH to fix bug reported 
         by John Tang.)

         (* * jrc 28-sep-88 Saves various WINDOWPROPs that SHOWGRAPH seems to smash.
         The original code made assumptions about what the value of each of the 
         WINDOWPROPs was.)

    (LET [(OldRepaintFn (WINDOWPROP Window 'REPAINTFN))
          (OldRightButtonFn (WINDOWPROP Window 'RIGHTBUTTONFN))
          (OldScrollFn (WINDOWPROP Window 'SCROLLFN))
          (OldReshapeFn (WINDOWPROP Window 'RESHAPEFN]
         (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 'RIGHTBUTTONFN OldRightButtonFn)
         (WINDOWPROP Window 'REPAINTFN OldRepaintFn)
         (WINDOWPROP Window 'SCROLLFN OldScrollFn)
         (WINDOWPROP Window 'RESHAPEFN OldReshapeFn)
         (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.TitleBarButtonEventFn))
         (NC.InstallCopyButtonEventFn Window])

(NC.BrowserAddLink
  [LAMBDA (FromNode ToNode Win Graph GlobalLinkFlg LinkType) (* ; "Edited 28-Sep-88 18:54 by jrc")

    (* ;; 
    "Like grapher's ADD/AND/DISPLAY/LINK except has different checks and builds a real NC Link.")

    (* ;; "rht 9/20/85: Added GlobalLinkFlg arg to force the link created to be global.  Currently, it's global anyway if from node is a sketch card, for example.")

    (* ;; "rht 11/17/85: updated for new card and notefile object format.")

    (* ;; "rht 2/7/86: Now sets and gets browser link labels, etc.  via fetch/set fns.")

    (* ;; "rht 1/14/88: Now takes extra LinkType argument and passes to NC.BrowserCreateLink.")

    (* ;; "jrc 8/sep/88: returns link, if one is created. ")

    (PROG ((MaxDashingStylesNum (LENGTH NC.DashingStyles))
           Link Card LabelPairs LabelPair LabelNum ToNodeID FromNodeID OldDestNode LinkParams 
           ReverseLinkParams SavedDeleteLinkFn NumberOfLinks)
          (COND
             ([NOT (AND (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of FromNode))
                        (NC.LinkIconImageObjP (fetch (GRAPHNODE NODELABEL) of ToNode]
              (NC.PrintMsg NIL T 
                     "Can't create link from or to a label node.  Try 'Add Edge' instead.")
              (FLASHW PROMPTWINDOW)
              (RETURN NIL))
             ((SETQ Link (NC.BrowserCreateLink FromNode ToNode Graph Win GlobalLinkFlg LinkType))
                                                             (* ; 
           "We successfully created a link.  Now undraw existing link and redraw with new one added.")
                                                             (* ; 
                                       "First, check whether label for new link is already in graph.")
              (SETQ Card (NC.CoerceToCard Win))
              (SETQ LabelPairs (NC.FetchBrowserLinksLegend Card))
              (SETQ LinkType (fetch (Link Label) of Link))

              (* ;; "If link label hasn't appeared in the graph, make a new dashing number for it and update links legend.")

              (if (NULL (SETQ LabelPair (FASSOC LinkType LabelPairs)))
                  then [SETQ LabelPairs (APPEND LabelPairs (LIST (SETQ LabelPair
                                                                  (CONS LinkType
                                                                        (COND
                                                                           ((ILESSP (SETQ LabelNum
                                                                                     (LENGTH 
                                                                                           LabelPairs
                                                                                            ))
                                                                                   
                                                                                  MaxDashingStylesNum
                                                                                   )
                                                                            (SETQ LabelNum
                                                                             (ADD1 LabelNum)))
                                                                           (T LabelNum]
                       (NC.SetBrowserLinksLegend Card LabelPairs)
                       (NC.MakeLinksLegendMenu Win LabelPairs))
              (SETQ FromNodeID (NC.CoerceToGraphNodeID FromNode))
              (SETQ ToNodeID (NC.CoerceToGraphNodeID ToNode))
              [SETQ NumberOfLinks (PLUS (LENGTH (NC.GraphNodeIDGetProp FromNodeID ToNodeID))
                                        (LENGTH (NC.GraphNodeIDGetProp ToNodeID FromNodeID]
              (SETQ LinkParams (LINKPARAMETERS FromNode ToNode))
              (SETQ ReverseLinkParams (LINKPARAMETERS ToNode FromNode))
              [COND
                 [(OR (ZEROP NumberOfLinks)
                      (AND (NULL LinkParams)
                           (NULL ReverseLinkParams)))
                  (if (OR (FMEMB (fetch (GRAPHNODE NODEID) of FromNode)
                                 (fetch (GRAPHNODE TONODES) of ToNode))
                          (FMEMB (fetch (GRAPHNODE NODEID) of ToNode)
                                 (fetch (GRAPHNODE TONODES) of FromNode)))
                      then                                   (* ; 
                                "There are no links, but there is an edge.  Delete it and redisplay.")
                           (SETQ SavedDeleteLinkFn (fetch (GRAPH GRAPH.DELETELINKFN) of Graph))
                           (replace (GRAPH GRAPH.DELETELINKFN) of Graph with NIL)
                           (DELETE/AND/DISPLAY/LINK FromNode ToNode Win Graph)
                           (NC.PrintMsg NIL T "Replacing existing edge with new link edge.")
                           (FLASHW PROMPTWINDOW))            (* ; 
                                "This is first link between these two nodes so compute dashing here.")
                  (replace (GRAPHNODE TONODES) of FromNode
                     with (CONS [LIST LINKPARAMS (fetch (GRAPHNODE NODEID) of ToNode)
                                      'DRAWLINKFN
                                      (FUNCTION NC.BrowserDrawLinkFn)
                                      'DASHING
                                      (CAR (FNTH NC.DashingStyles (CDR LabelPair]
                                (fetch (GRAPHNODE TONODES) of FromNode)))
                  (replace (GRAPHNODE FROMNODES) of ToNode with (CONS (fetch (GRAPHNODE NODEID)
                                                                         of FromNode)
                                                                      (fetch (GRAPHNODE FROMNODES)
                                                                         of ToNode]
                 [LinkParams                                 (* ; 
                                 "There are multiple links.  And the link params is on the FromNode.")
                        (DISPLAYLINK FromNode ToNode (CONSTANT (create POSITION
                                                                      XCOORD ← 0
                                                                      YCOORD ← 0))
                               Win Graph 1 LinkParams)       (* ; 
                                   "If there was only one link, then change so multi-link indicator.")
                        (if (EQP NumberOfLinks 1)
                            then (RPLACD (CDR LinkParams)
                                        (LIST 'NODEID FromNodeID 'DESTNODEID ToNodeID]
                 (T                                          (* ; 
                                       "There are multiple links.  The Link params is on the ToNode.")
                    (DISPLAYLINK ToNode FromNode (CONSTANT (create POSITION
                                                                  XCOORD ← 0
                                                                  YCOORD ← 0))
                           Win Graph 1 ReverseLinkParams)    (* ; 
                                   "If there was only one link, then change so multi-link indicator.")
                    (if (EQP NumberOfLinks 1)
                        then (RPLACD (CDR ReverseLinkParams)
                                    (LIST 'NODEID ToNodeID 'DESTNODEID FromNodeID]
              (NC.UIDAddProp FromNodeID ToNodeID LabelPair)
              [COND
                 (LinkParams (DISPLAYLINK FromNode ToNode
                                    (CONSTANT (create POSITION
                                                     XCOORD ← 0
                                                     YCOORD ← 0))
                                    Win Graph 1 LinkParams))
                 (ReverseLinkParams (DISPLAYLINK ToNode FromNode
                                           (CONSTANT (create POSITION
                                                            XCOORD ← 0
                                                            YCOORD ← 0))
                                           Win Graph 1 ReverseLinkParams))
                 (T (DISPLAYLINK FromNode ToNode (CONSTANT (create POSITION
                                                                  XCOORD ← 0
                                                                  YCOORD ← 0))
                           Win Graph 1 (LINKPARAMETERS FromNode ToNode]
              (RETURN Link])

(NC.RelayoutBrowserCard
  [LAMBDA (Window)                                           (* ; "Edited 28-Sep-88 18:45 by jrc")

(* ;;; "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")

    (* ;; "rht 7/29/88: No longer calls NC.SetPropListDirtyFlg")

    (* ;; " jrc 28-sep-88: Saves various WINDOWPROPs that SHOWGRAPH seems to smash.  The original code made assumptions about what the value of each of the WINDOWPROPs was.")

    (LET
     ((Card (NC.CoerceToCard Window)))
     (NC.ProtectedCardOperation
      Card "Relayout Browser Card" NIL
      (PROG (RootCards RootNodeIDs OldToNodePairs Graph GraphNodes BrowserFormat DropVirtualNodesFlg
                   SpecialBrowserSpecs OldRepaintFn OldRightButtonFn OldScrollFn OldReshapeFn)
            (NC.PrintMsg Window T "Laying out graph ...")
            (SETQ RootCards (NC.FetchBrowserRoots Card))
            [SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
                                    '(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 '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))
             )

       (* ;; "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 '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)))

(* ;;; "have to preserve windowprops since SHOWGRAPH messes with them")

            (SETQ OldRepaintFn (WINDOWPROP Window 'REPAINTFN))
            (SETQ OldRightButtonFn (WINDOWPROP Window 'RIGHTBUTTONFN))
            (SETQ OldScrollFn (WINDOWPROP Window 'SCROLLFN))
            (SETQ OldReshapeFn (WINDOWPROP Window 'RESHAPEFN))
            (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 'RIGHTBUTTONFN OldRightButtonFn)
            (WINDOWPROP Window 'REPAINTFN OldRepaintFn)
            (WINDOWPROP Window 'SCROLLFN OldScrollFn)
            (WINDOWPROP Window 'RESHAPEFN OldReshapeFn)
            (NC.SetSubstance Card (WINDOWPROP Window 'GRAPH))
            (NC.MarkCardDirty Card)
            (NC.InstallTitleBarButtonEventFn Window (FUNCTION NC.TitleBarButtonEventFn))
            (NC.InstallCopyButtonEventFn Window)
            (NC.ClearMsg Window T])

(NC.MakeBrowserCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited 29-Sep-88 13:13 by jrc")

    (* ;; "Make a browser card with id Card using root at RootID and the link following predictae specified by Predicate.  IF Root and/or ListOfLinkLabels not specified, ask the user.")

    (* ;; "rht 8/3/84: Changed to call NC.AskLinkLabel with its ReverseLinkLabel parameter set to T.")

    (* ;; "fgh 10/2/84 Changed Link Icons to be image objects in NodeLabel of Graph Npodes rather than annotations on graph nodes.")

    (* ;; "rht 10/19/84: Fixed setting up of browser card's prop list in case NoDisplayFlg is T so we have no Window.  Now NC.MakeLinksLegend returns the label pairs.")

    (* ;; "rht 11/27/84: Removed the WINDOWADDPROP call to put NC.GraphCardCloseFn on the CLOSEFN of the window.  This causes trouble.  NC.QuitCard will get put on by NC.MakeNoteCard and that's enough.")

    (* ;; "rht 1/3/85: Now puts a dummy region of the right size if the NoDisplayFlg is on.")

    (* ;; 
    "rht 1/15/85: Put hooks for AddNode, AddLink, etc.  so editing graph edits underlying structure.")

    (* ;; 
   "rht 2/14/85: Added VerticalFlg and made BrowserSpecs get put on browser's proplist in all cases.")

    (* ;; "rht 4/1/85: Now calls NC.AskBrowserSpecs with additional Don'tAskFlg in case of call from Programmer's interface.")

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

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

    (* ;; "rht 5/6/86: Took out call to NC.SetupTitleBarMenu.")

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

    (* ;; "rht 7/10/86: Now passes ListOfLinkLabels to NC.AskBrowserSpecs.")

    (* ;; "rht 9/19/86: Mod to above fix.  Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off windowprop.")

    (* ;; "pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection.  Also added GLOBALVARS statement.")

    (* ;; "pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.")

    (* ;; "rht 12/16/86: Now checks that NC.MakeLink succeeded before creating a real link icon.  If not, then make a standin for a cross file link icon.")

    (* ;; "rg 3/18/87 added NC.CardSelectionOperation wrapper")

    (* ;; "rht 3/20/87: Removed needless call to NC.ActivateCard.")

    (* ;; "rg 4/2/87 changed wrapper to NCP.WithLockedCards and added NC.IfAllCardsFree wrapper")

    (* ;; "rht 5/26/87: Now handles cross-file links properly, i.e.  uses cross-file link standin in cases when GrowLinkLattice wasn't able to follow into the remote notefile.")

    (* ;; "dwm 1/19/88 Sets ReadOnly prop based upon current NF ReadOnly status")

    (* ;; "pmi 2/29/88: Now asks for specs only if none are specified coming in. A browser created from a browser now prompts for everything.  Also added InterestedWindow argument.")

    (* ;; "rht 6/9/88: Added RegionOrPosition arg and passed to NC.MakeNewCardWindow.")

    (* ;; "jrc 29-sep-88.  Added WINDOWPROP calls at end of function -- in the old days, NC.RelayoutBrowserCard added these props, but NC.RelayoutBrowserCard now only preserves the props that are already on the window.  The WINDOWPROP calls are copied from NC.BringUpBrowserCard.")

    (DECLARE (GLOBALVARS NC.SubBoxLinkLabel NC.BrowserContentsLinkLabel NC.SpecialBrowserSpecsFlg 
                    NC.*Graph*BrowserFormat NC.SelectingBrowserSourceMenu))
    (NCP.WithLockedCards
     (PROG ([RootCards (MKLIST (LISTGET ParamList 'ROOTCARDS]
            (ListOfLinkLabels (LISTGET ParamList 'LINKTYPES))
            (BrowserFormat (LISTGET ParamList 'FORMAT))
            (Depth (LISTGET ParamList 'DEPTH))
            (CardType (NC.RetrieveType Card))
            (Don'tAskForRoots (FMEMB 'ROOTCARDS ParamList))
            (Don'tAskForSpecs (OR (FMEMB 'LINKTYPES ParamList)
                                  (FMEMB 'FORMAT ParamList)
                                  (FMEMB 'DEPTH ParamList)))
            Lattice RootNodes Window Graph SpecialBrowserSpecs BrowserSpecs DropVirtualNodesFlg)
           (NC.IfAllCardsFree
            (NC.LockListOfCards RootCards "Make Browser Card")
            (if (NOT NoDisplayFlg)
                then (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")
                                         NIL NIL RegionOrPosition))
                     (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.GraphCardShrinkFn))
                     (SETQ InterestedWindow Window))
            (OR Don'tAskForRoots (SETQ RootCards (NC.SelectNoteCards NIL NIL 
                                                        NC.SelectingBrowserSourceMenu 
                                                        InterestedWindow 
                          "Please shift-select the Cards and/or Boxes the browser should start from."
                                                        T)))
            (COND
               ((EQ RootCards 'DON'T)
                (NC.DeactivateCard Card)
                (CLOSEW Window)
                (RETURN)))
            (NC.HoldTTYProcess)
            [SETQ BrowserSpecs (NC.AskBrowserSpecs InterestedWindow Card ListOfLinkLabels Depth 
                                      BrowserFormat T (if Don'tAskForSpecs
                                                          then 'DONTASK]
            (COND
               ((NULL BrowserSpecs)
                (NC.DeactivateCard Card)
                (CLOSEW Window)
                (RETURN)))
            (SETQ ListOfLinkLabels (CAR BrowserSpecs))
            (SETQ Depth (CADR BrowserSpecs))
            (SETQ BrowserFormat (CADDR BrowserSpecs))        (* ; 
                    "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 (COND
                                         (NC.SpecialBrowserSpecsFlg (NC.AskSpecialBrowserSpecs 
                                                                           InterestedWindow))
                                         (T (create SPECIALBROWSERSPECS]
            (OR NoDisplayFlg (NC.PrintMsg InterestedWindow T (CHARACTER 13)
                                    "Computing browser graph. Please wait. ..."))
                                                             (* ; "Create new browser hash array")
            (NC.GetBrowserHashArray Card)                    (* ; 
                                                "Compute lattice breakdth-first starting from roots.")
            (SETQ Lattice (NC.GrowLinkLattice RootCards NIL ListOfLinkLabels Card Depth))
            (SETQ RootNodes (if RootCards
                                then (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
                                                                               RootCard))
                              else NIL))

            (* ;; 
            "Link destination id information stored in NodeLabel field into a LinkIcon for display")

            (for Node in Lattice bind NodeID (CrossFileLinkModePropList ← (LIST (fetch (Card NoteFile
                                                                                             )
                                                                                   of Card)
                                                                                NIL))
               eachtime (BLOCK)
               do [replace (GRAPHNODE NODELABEL) of Node
                     with (LET (NewLink)
                               (if [AND (NOT (NC.CrossFileLinkCardP (fetch (GRAPHNODE NODELABEL)
                                                                       of Node)))
                                        (SETQ NewLink (NC.MakeLink InterestedWindow 
                                                             NC.BrowserContentsLinkLabel
                                                             (fetch (GRAPHNODE NODELABEL)
                                                                of Node)
                                                             Card NIL NIL NIL NIL NIL
                                                             (NC.ComputeCrossFileLinkMode
                                                              (fetch (GRAPHNODE NODELABEL)
                                                                 of Node)
                                                              CrossFileLinkModePropList 
                                                              InterestedWindow]
                                   then (NC.MakeLinkIcon NewLink)
                                 else (NC.MakeCrossFileLinkIconStandIn (fetch (GRAPHNODE NODELABEL)
                                                                          of Node] 
                                                             (* ; 
                  "Untouch each graph node so that next Recompute will put fresh values on proplist.")
                  (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
                  (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
                         'TouchedFlg)
                  (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
                         'VisitedFlg))
            (SETQ Graph (if (AND Lattice RootNodes)
                            then (LAYOUTGRAPH Lattice RootNodes (SUBST '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)))
            (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
            (OR NoDisplayFlg (NC.PrintMsg InterestedWindow NIL "Done!"))
            (NC.SetSubstance Card Graph)
            (NC.SetBrowserLinkLabels Card (OR ListOfLinkLabels (LIST NC.SubBoxLinkLabel)))
            (NC.SetBrowserRoots Card RootCards)
            (NC.SetBrowserFormat Card BrowserFormat)
            (NC.SetBrowserDepth Card Depth)
            (NC.SetSpecialBrowserSpecs Card SpecialBrowserSpecs)
            (NC.SetUserDataProp Card 'ReadOnly (NC.CardReadOnlyOpenP Card))
            (COND
               (NoDisplayFlg (RETURN Card)))
            (WINDOWPROP Window 'GRAPH Graph)
            (NC.InstallTitleBarLeftMenu Window CardType)
            (NC.InstallTitleBarMiddleMenu Window CardType)
            (NC.RelayoutBrowserCard Window)
            (WINDOWPROP Window 'RIGHTBUTTONFN (FUNCTION NC.BrowserRightButtonFn))
            (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.GraphCardShrinkFn))

            (* ;; "SHOWGRAPH changes this REPAINTFN to REDISPLAYGRAPH, but since NC.RelayoutBrowserCard (now) only preserves props that were already there, it has to be added here.")

            (WINDOWPROP Window 'REPAINTFN (FUNCTION REDISPLAYGRAPH))
            (WINDOWADDPROP Window 'REPAINTFN (FUNCTION NC.BrowserRepaintFn)
                   T)
            (WINDOWPROP Window 'SCROLLFN (FUNCTION NC.BrowserScrollFn))
            (WINDOWPROP Window 'RESHAPEFN (FUNCTION NC.BrowserReshapeFn))
            (RETURN Window])
)
(PUTPROPS JRCPATCH027 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (2440 33374 (NC.ShowBrowserGraph 2450 . 4072) (NC.BrowserAddLink 4074 . 12842) (
NC.RelayoutBrowserCard 12844 . 21199) (NC.MakeBrowserCard 21201 . 33372)))))
STOP