(DEFINE-FILE-INFO PACKAGE "IL" READTABLE "INTERLISP" BASE 10)
(FILECREATED "29-Feb-88 17:44:10" {QV}<NOTECARDS>1.3LNEXT>DWMPATCH002.;5 20074  

      changes to%:  (VARS DWMPATCH002COMS)

      previous date%: "28-Jan-88 08:12:08" {QV}<NOTECARDS>1.3LNEXT>DWMPATCH002.;1)


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

(PRETTYCOMPRINT DWMPATCH002COMS)

(RPAQQ DWMPATCH002COMS (
          
          (* ;; "dwm 01/08/88 changes for read only browser cards")

                        (P (NC.LoadFileFromDirectories 'NCGRAPHCARD)
                           (NC.LoadFileFromDirectories 'NCBROWSERCARD))
                        
          
          (* ;; "rg 2/25/88 Lyricized, integrated w/ other patches")

                        
          
          (* ;; "changes to NCGRAPHCARD")

                        (FNS NC.GetGraphEditMenu NC.MakeBrowserCard)
                        
          
          (* ;; "new for NCGRAPHCARD")

                        (FNS NC.SaveOrRevertGraphCard)
                        
          
          (* ;; "new for NCBROWSERCARD")

                        (FNS NC.MakeBrowserCardReadOnly NC.MakeBrowserCardReadWrite)
                        [P (NC.RecomputeCardType 'Browser
                                  `((MakeReadOnlyFn ,(FUNCTION NC.MakeBrowserCardReadOnly))
                                    (MakeReadWriteFn ,(FUNCTION NC.MakeBrowserCardReadWrite]
                        (PROP (FILETYPE MAKEFILE-ENVIRONMENT)
                              DWMPATCH002)))



(* ;; "dwm 01/08/88 changes for read only browser cards")

(NC.LoadFileFromDirectories 'NCGRAPHCARD)
(NC.LoadFileFromDirectories 'NCBROWSERCARD)



(* ;; "rg 2/25/88 Lyricized, integrated w/ other patches")




(* ;; "changes to NCGRAPHCARD")

(DEFINEQ

(NC.GetGraphEditMenu
  [LAMBDA (Window)                                       (* ; "Edited 28-Jan-88 07:47 by MacDonald")
          
          (* ;; "Create, if necessary, and bring up the graph editor menu.")
          
          (* ;; "pmi 3/25/87: Added NC.MenuFont to all menus")
          
          (* ;; 
          "rht 1/14/88: Now ensures that both menus are computed rather than just the one needed.")
          
          (* ;; "dwm 1/27/88: Added ReadOnly stuff")

    (DECLARE (GLOBALVARS NC.MenuFont NC.GraphEditMenuItems NC.GraphEditUnfixedMenuItems))
    (LET [(GraphEditUnfixableMenu (WINDOWPROP Window 'GRAPHEDITUNFIXABLEMENU))
          (GraphEditFixableMenu (WINDOWPROP Window 'GRAPHEDITFIXABLEMENU]
         [OR GraphEditUnfixableMenu (WINDOWPROP Window 'GRAPHEDITUNFIXABLEMENU
                                           (SETQ GraphEditUnfixableMenu
                                            (create MENU
                                                   ITEMS ← NC.GraphEditMenuItems
                                                   TITLE ← "Editor Menu"
                                                   WHENSELECTEDFN ← (FUNCTION 
                                                                     NC.GraphEditMenuWhenSelectedFn)
                                                   CHANGEOFFSETFLG ← T
                                                   CENTERFLG ← T
                                                   MENUOFFSET ← (CONS -1 0)
                                                   MENUFONT ← NC.MenuFont
                                                   ITEMHEIGHT ← (IPLUS (FONTPROP NC.MenuFont
                                                                              'HEIGHT)
                                                                       1]
         [OR GraphEditFixableMenu (WINDOWPROP Window 'GRAPHEDITFIXABLEMENU
                                         (SETQ GraphEditFixableMenu
                                          (create MENU using GraphEditUnfixableMenu ITEMS ← 
                                                             NC.GraphEditUnfixedMenuItems]
          
          (* ;; "If menu is already up, then put up a menu without the FIXMENU option, otherwise, allow user to fix menu.")

         (if [SETQ GraphEditFixedMenuWin (for Win in (ATTACHEDWINDOWS Window)
                                            thereis (AND (OPENWP Win)
                                                         (WINDOWPROP Win 'GRAPHEDITMENUFLG]
             then (if (NC.FetchUserDataProp Card 'ReadOnly)
                      then (REMOVEWINDOW GraphEditFixedMenuWin)
                           (WINDOWPROP Window 'RIGHTBUTTONFN NIL)
                    else (PUTMENUPROP GraphEditUnfixableMenu 'MAINWINDOW Window)
                         (MENU GraphEditUnfixableMenu))
           else (if (NC.FetchUserDataProp Card 'ReadOnly)
                    then (WINDOWPROP Window 'RIGHTBUTTONFN NIL)
                  else (PUTMENUPROP GraphEditFixableMenu 'MAINWINDOW Window)
                       (MENU GraphEditFixableMenu])

(NC.MakeBrowserCard
  [LAMBDA (Card Title NoDisplayFlg ParamList)            (* ; "Edited 19-Jan-88 07:26 by MacDonald")
          
          (* 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)

    (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))
            Lattice RootNodes Window Graph SpecialBrowserSpecs BrowserSpecs DropVirtualNodesFlg)
           (NC.IfAllCardsFree
            (NC.LockListOfCards RootCards "Make Browser Card")
            [COND
               ((NULL NoDisplayFlg)
                (SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")))
                (WINDOWADDPROP Window 'SHRINKFN (FUNCTION NC.GraphCardShrinkFn]
            [if (NULL RootCards)
                then (SETQ RootCards (if NoDisplayFlg
                                         then (LIST NIL)
                                       else (NC.SelectNoteCards NIL NIL NC.SelectingBrowserSourceMenu 
                                                   Window 
                          "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 Window Card ListOfLinkLabels Depth BrowserFormat T
                                      (if (OR ParamList NoDisplayFlg)
                                          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 Window
                                                                           ))
                                         (T (create SPECIALBROWSERSPECS]
            (OR NoDisplayFlg (NC.PrintMsg Window 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 (for RootCard in RootCards collect (NC.GetBrowserNodeID Card RootCard)))
            (OR NoDisplayFlg (WINDOWPROP Window 'NoteCardObject Card))
          
          (* * 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 Window NC.BrowserContentsLinkLabel
                                                             (fetch (GRAPHNODE NODELABEL)
                                                                of Node)
                                                             Card NIL NIL NIL NIL NIL
                                                             (NC.ComputeCrossFileLinkMode
                                                              (fetch (GRAPHNODE NODELABEL)
                                                                 of Node)
                                                              CrossFileLinkModePropList Window]
                                   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 Window 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)
            (RETURN Window])
)



(* ;; "new for NCGRAPHCARD")

(DEFINEQ

(NC.SaveOrRevertGraphCard
  [LAMBDA (Card Window)                                  (* ; "Edited 27-Jan-88 08:04 by MacDonald")

    (ALLOW.BUTTON.EVENTS)
    (if (MENU (create MENU
                     TITLE ← "Card has been edited"
                     ITEMS ← '(("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.GetNoteCard Card)
           (SHOWGRAPH (NC.FetchSubstance Card)
                  Window
                  (FUNCTION NC.GraphCardLeftButtonFn)
                  (FUNCTION NC.GraphCardMiddleButtonFn)
                  NIL T (FUNCTION NC.GRAPHERCOPYBUTTONEVENTFN))
           (NC.MarkCardDirty Card T])
)



(* ;; "new for NCBROWSERCARD")

(DEFINEQ

(NC.MakeBrowserCardReadOnly
  [LAMBDA (Card)                                         (* ; "Edited 27-Jan-88 14:54 by MacDonald")
          
          (* * Make a BrowserCard Read-Only.)

    (DECLARE (GLOBALVARS NC.ShowPropListMenu))
    (LET ((Window (NC.FetchWindow Card))
          PropListEditor)
         (NC.ProtectedCardOperation Card "Make Read-Only" Window (if (NC.CardSomehowDirtyP Card)
                                                                     then (NC.SaveOrRevertGraphCard
                                                                           Card Window))
                (NC.SetUserDataProp Card 'ReadOnly T)
                (NC.GetGraphEditMenu Window)
                (SETQ NC.BrowserSafeItems '(Show% Links Show% Info Designate% FileBoxes 
                                                  |Close and Save| |Browser Overview Win|))
                (SETQ NC.BrowserSafeSubItems '(|Close and Save| |Close w/o Saving| |Save in NoteFile| 
                                                     Indicate% NoteFile))
                (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP Window)))
                    then (NC.MakeTEditReadOnly Window)
                         (WINDOWPROP PropListEditor 'TEDIT.MENU NC.ShowPropListMenu))
                (NC.MakeMenusReadOnly Window NC.BrowserSafeItems NC.BrowserSafeSubItems])

(NC.MakeBrowserCardReadWrite
  [LAMBDA (Card)                                         (* ; "Edited 27-Jan-88 14:56 by MacDonald")
          
          (* * dwm |1/6/88| coerce Read/Write on a browser card)

    (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
                                                                                  'TEDIT.MENU 
                                                                                  NC.EditPropListMenu
                                                                                  ))
                (NC.SetUserDataProp Card 'ReadOnly NIL)
                (WINDOWPROP Window 'RIGHTBUTTONFN (FUNCTION NC.BrowserRightButtonFn))
                (NC.MakeMenusReadWrite Window])
)
[NC.RecomputeCardType 'Browser `((MakeReadOnlyFn ,(FUNCTION NC.MakeBrowserCardReadOnly))
                                 (MakeReadWriteFn ,(FUNCTION NC.MakeBrowserCardReadWrite]

(PUTPROPS DWMPATCH002 FILETYPE :TCOMPL)

(PUTPROPS DWMPATCH002 MAKEFILE-ENVIRONMENT (:PACKAGE "IL" :READTABLE "INTERLISP" :BASE 10))
(PUTPROPS DWMPATCH002 COPYRIGHT ("Xerox Corporation" 1987 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1801 15821 (NC.GetGraphEditMenu 1811 . 4993) (NC.MakeBrowserCard 4995 . 15819)) (15859 
16722 (NC.SaveOrRevertGraphCard 15869 . 16720)) (16762 19665 (NC.MakeBrowserCardReadOnly 16772 . 18174
) (NC.MakeBrowserCardReadWrite 18176 . 19663)))))
STOP