(DEFINE-FILE-INFO PACKAGE "IL" READTABLE "INTERLISP" BASE 10)
(FILECREATED "10-May-88 11:06:31" {PEACH}<MACDONALD>COEDS>DWMPATCH004.;7 14968  

      changes to%:  (FNS NC.MakeTEditReadWrite NCP.MakeCardReadOnly NCP.ChangeCardWriteStatus 
                         NC.MakeTextCardReadOnly NC.Don'tDoIt)

      previous date%: " 9-May-88 16:34:16" {PEACH}<MACDONALD>COEDS>DWMPATCH004.;5)


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

(PRETTYCOMPRINT DWMPATCH004COMS)

(RPAQQ DWMPATCH004COMS (

(* ;;; "Add ReadOnly card User interface")

                        (DECLARE%: DONTCOPY (PROPS (DWMPATCH004 MAKEFILE-ENVIRONMENT)
                                                   (DWMPATCH004 FILETYPE)))
                        

(* ;;; "New for NCINTERFACE")

                        (FNS NC.Don'tDoIt NC.MakeCardReadOnly NC.MakeCardReadWrite 
                             NC.ChangeCardWriteStatus)
                        (VARIABLES NC.SafeLeftButtonItems NC.SafeLeftButtonSubItems 
                               NC.SafeMiddleButtonItems NC.SafeMiddleButtonSubItems)
                        

(* ;;; " Changes for NCINTERFACE")

                        (FNS NC.MakeTEditReadOnly NC.MakeTEditReadWrite)
                        (VARS NC.CardOpsItems)
                        

(* ;;; "New for NCPROGINT")

                        (FNS NCP.MakeCardReadOnly NCP.MakeCardReadWrite NCP.ChangeCardWriteStatus)
                        

(* ;;; "Changes for NCTEXTCARD")

                        (FNS NC.MakeTextCardReadOnly)
                        

(* ;;; "Changes for NCGRAPHCARD")

                        (FNS NC.MakeGraphCardReadOnly)
                        

(* ;;; "Changes for NCBROWSERCARD")

                        (FNS NC.MakeBrowserCardReadOnly)
                        

(* ;;; "Changes for NCCARD")

                        (FNS NC.ReadOnlyCardP)))



(* ;;; "Add ReadOnly card User interface")

(DECLARE%: DONTCOPY 

(PUTPROPS DWMPATCH004 MAKEFILE-ENVIRONMENT (:PACKAGE "IL" :READTABLE "INTERLISP" :BASE 10))

(PUTPROPS DWMPATCH004 FILETYPE :TCOMPL)
)



(* ;;; "New for NCINTERFACE")

(DEFINEQ

(NC.Don'tDoIt
  [LAMBDA (Viewer Element OtherParam)                    (* ; "Edited 10-May-88 08:41 by MacDonald")

    'DON'T])

(NC.MakeCardReadOnly
  [LAMBDA (Card MoreSafeItems MoreSafeSubItems)          (* ; "Edited 14-Apr-88 12:49 by MacDonald")
          
          (* ;; "Apply Card's MakeReadOnlyFn")

    (LET (Card-To-Change)
         (COND
            ((SETQ Card-To-Change (OR Card (NCP.SelectCards NC.NoteCardsIconWindow T NIL 
                                                  "Please select card to be made read only")))
             (NCP.ApplyCardTypeFn MakeReadOnlyFn Card-To-Change MoreSafeItems MoreSafeSubItems])

(NC.MakeCardReadWrite
  [LAMBDA (Card)                                         (* ; "Edited 14-Apr-88 12:50 by MacDonald")
          
          (* ;; "Apply Card's MakeReadWriteFn")

    (LET (Card-To-Change)
         (COND
            ((SETQ Card-To-Change (OR Card (NCP.SelectCards NC.NoteCardsIconWindow T NIL 
                                                  "Please select card to be made read write")))
             (NCP.ApplyCardTypeFn MakeReadWriteFn Card-To-Change])

(NC.ChangeCardWriteStatus
  [LAMBDA (Card MoreSafeItems MoreSafeSubITems)          (* ; "Edited 12-Apr-88 09:55 by MacDonald")

    (LET (Card-To-Change)
         (SETQ Card-To-Change (NCP.SelectCards NC.NoteCardsIconWindow T NIL 
                                     "Please select card to be changed"))
         (if Card-To-Change
             then (if (NC.FetchUserDataProp Card-To-Change 'ReadOnly)
                      then (NC.MakeCardReadWrite Card-To-Change)
                    else (NC.MakeCardReadOnly Card-To-Change MoreSafeItems MoreSafeSubITems])
)

(DEFGLOBALVAR NC.SafeLeftButtonItems '(Show% Links Show% Info Designate% FileBoxes |Close and Save|)
   )


(DEFGLOBALVAR NC.SafeLeftButtonSubItems '(|Close and Save| |Close w/o Saving| |Save in NoteFile| 
                                                Indicate% NoteFile) )


(DEFGLOBALVAR NC.SafeMiddleButtonItems '(Put Find Quit Dictionary) )


(DEFGLOBALVAR NC.SafeMiddleButtonSubItems '(Set% Dictionary Get% Synonyms Get% Definitions 
                                                  |Search For Word| FindWord Plain-Text Old-Format)
   )




(* ;;; " Changes for NCINTERFACE")

(DEFINEQ

(NC.MakeTEditReadOnly
  [LAMBDA (Window Safe-Text-Menu-Items Safe-Text-Menu-SubItems)
                                                         (* ; "Edited 14-Apr-88 12:23 by MacDonald")

(* ;;; 
"dwm 4/14/88:  Replace dangerous menu stuff to a call to NC.MakeMenusReadOnly with safe menu items.")

    (LET* ((TxtObj (TEXTOBJ Window)))
          (if (NOT (TEXTPROP TxtObj 'READONLY))
              then (TEXTPROP TxtObj 'READONLY T)
                   (TEXTPROP TxtObj 'SELFN (FUNCTION NC.ReadOnlyTEditSelFn))
                   (replace (TEXTOBJ TXTREADONLY) of TxtObj with T)
                   (UNINTERRUPTABLY
                       (KILL-PROCESS-OF-TEDIT-WINDOW Window) (* ; 
                                                       "make sure TEdit killer won't restart process")

                       (UNMARK-AS-WITHOUT-PROCESS Window))
                   (NC.MakeMenusReadOnly Window Safe-Text-Menu-Items Safe-Text-Menu-SubItems])

(NC.MakeTEditReadWrite
  [LAMBDA (Window)                                       (* ; "Edited 10-May-88 11:03 by MacDonald")

(* ;;; "dwm 5/10/88; Replaced dangerous menu item stuff with a call to NC.MakeMenusReadWrite")

    (LET* ((TxtObj (TEXTOBJ Window))
           (Sel (fetch SEL of TxtObj)))
          (if (TEXTPROP TxtObj 'READONLY)
              then (NC.MakeMenusReadWrite Window)
                   (\SHOWSEL Sel NIL NIL)
                   (replace SET of Sel with NIL)
                   (replace (TEXTOBJ TXTREADONLY) of TxtObj with NIL)
                   (TEXTPROP TxtObj 'READONLY NIL)
                   (MARK-AS-WITHOUT-PROCESS Window 'TEDIT])
)

(RPAQQ NC.CardOpsItems [(| Close | (NC.CloseNoteCards NIL NC.NoteCardsIconWindow)
                               "Delete several note cards."
                               (SUBITEMS (Close% Structure (NC.CloseStructure NIL NIL 
                                                                  NC.NoteCardsIconWindow)
                                                "Close note cards belonging to a structure.")))
                        (| Delete | (NC.DeleteNoteCards NIL T NIL NC.NoteCardsIconWindow)
                               "Delete several note cards."
                               (SUBITEMS (Delete% Structure (NC.DeleteStructure NIL NIL 
                                                                   NC.NoteCardsIconWindow)
                                                "Delete note cards belonging to a structure.")))
                        (| Copy | (NC.CopyCards NIL NIL NIL NIL NC.NoteCardsIconWindow)
                               "Copy note cards to a filebox"
                               (SUBITEMS (Copy% Structure (NC.CopyStructure NIL NIL NIL 
                                                                 NC.NoteCardsIconWindow)
                                                "Copy note cards belonging to a structure.")))
                        (| Move | (NC.MoveCards NIL NIL NIL NIL NC.NoteCardsIconWindow)
                               "Move note cards to a filebox"
                               (SUBITEMS (Move% Structure (NC.MoveStructure NIL NIL NIL 
                                                                 NC.NoteCardsIconWindow)
                                                "Move note cards belonging to a structure.")))
                        (|Change Write Status| (NC.ChangeCardWriteStatus)
                               "Toggle a card's Write permission"
                               (SUBITEMS (|Make Read Only| (NC.MakeCardReadOnly)
                                                "MakeCardReadOnly")
                                      (|Make Read Write| (NC.MakeCardReadWrite)
                                             "MakeCardReadWrite"])



(* ;;; "New for NCPROGINT")

(DEFINEQ

(NCP.MakeCardReadOnly
  [LAMBDA (Card MoreSafeItems MoreSafeSubItems)          (* ; "Edited 10-May-88 10:55 by MacDonald")

    (NC.MakeCardReadOnly Card MoreSafeItems MoreSafeSubItems])

(NCP.MakeCardReadWrite
  [LAMBDA (Card)                                         (* ; "Edited  9-May-88 10:14 by MacDonald")

    (NC.MakeCardReadWrite Card])

(NCP.ChangeCardWriteStatus
  [LAMBDA (Card MoreSafeItems MoreSafeSubITems)          (* ; "Edited 10-May-88 10:57 by MacDonald")

    (NC.ChangeCardWriteStatus Card MoreSafeItems MoreSafeSubITems])
)



(* ;;; "Changes for NCTEXTCARD")

(DEFINEQ

(NC.MakeTextCardReadOnly
  [LAMBDA (Card New-Safe-Items New-Safe-Sub-Items)       (* ; "Edited 10-May-88 11:05 by MacDonald")

(* ;;; "dwm 5/10/88;  Changed from Dangerous menu item logic to safe menu item logic.")

    (DECLARE (GLOBALVARS NC.ShowPropListMenu NC.SafeMiddleButtonItems NC.SafeLeftButtonItems 
                    NC.SafeMiddleButtonSubItems NC.SafeLeftButtonSubItems))
    (LET ((Window (NC.FetchWindow Card))
          PropListEditor
          (TextCard-Safe-Items (APPEND New-Safe-Items NC.SafeMiddleButtonItems NC.SafeLeftButtonItems
                                      ))
          (TextCard-Safe-Sub-Items (APPEND New-Safe-Sub-Items NC.SafeMiddleButtonSubItems 
                                          NC.SafeLeftButtonSubItems)))
         (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 ← '(("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 'ReadOnly T)
                (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP Window)))
                    then (NC.MakeTEditReadOnly PropListEditor)
                         (WINDOWPROP PropListEditor 'TEDIT.MENU NC.ShowPropListMenu))
                (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP Window T)))
                    then (NC.MakeTEditReadOnly PropListEditor))
                (NC.MakeTEditReadOnly Window TextCard-Safe-Items TextCard-Safe-Sub-Items])
)



(* ;;; "Changes for NCGRAPHCARD")

(DEFINEQ

(NC.MakeGraphCardReadOnly
  [LAMBDA (Card New-Safe-Items New-Safe-Sub-Items)       (* ; "Edited 12-Apr-88 12:04 by MacDonald")

(* ;;; "Make a GraphCard Read-Only.")

(* ;;; "dwm 4/12/88:  Add global safe menu items.")

    (DECLARE (GLOBALVARS NC.ShowPropListMenu NC.SafeMiddleButtonItems NC.SafeLeftButtonItems 
                    NC.SafeMiddleButtonSubItems NC.SafeLeftButtonSubItems))
    (LET [(Window (NC.FetchWindow Card))
          PropListEditor
          (Grapher-Safe-Items (APPEND New-Safe-Items NC.SafeMiddleButtonItems NC.SafeLeftButtonItems)
                 )
          (Grapher-Safe-Sub-Items (APPEND New-Safe-Sub-Items NC.SafeMiddleButtonSubItems 
                                         NC.SafeLeftButtonSubItems '(Relayout% Graph]
         (NC.ProtectedCardOperation Card "Make Read-Only" Window (if (NC.CardSomehowDirtyP Card)
                                                                     then (NC.SaveOrRevertGraphCard
                                                                           Card Window))
                (NC.SetUserDataProp Card 'ReadOnly T)
                (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP Window)))
                    then (NC.MakeTEditReadOnly PropListEditor)
                         (WINDOWPROP PropListEditor 'TEDIT.MENU NC.ShowPropListMenu))
                (WINDOWPROP Window 'RIGHTBUTTONFN NIL)
                (NC.MakeMenusReadOnly Window Grapher-Safe-Items Grapher-Safe-Sub-Items])
)



(* ;;; "Changes for NCBROWSERCARD")

(DEFINEQ

(NC.MakeBrowserCardReadOnly
  [LAMBDA (Card New-Safe-Items New-Safe-Sub-Items)       (* ; "Edited 12-Apr-88 12:01 by MacDonald")

(* ;;; "Make a BrowserCard Read-Only.")

(* ;;; "dwm 4/12/88: Add global safe menu items.")

    (DECLARE (GLOBALVARS NC.ShowPropListMenu NC.SafeMiddleButtonItems NC.SafeLeftButtonItems 
                    NC.SafeMiddleButtonSubItems NC.SafeLeftButtonSubItems))
    (LET ((Window (NC.FetchWindow Card))
          PropListEditor
          [Browser-Safe-Items (APPEND New-Safe-Items NC.SafeMiddleButtonItems NC.SafeLeftButtonItems
                                     '(|Browser Overview Win|]
          (Browser-Safe-Sub-Items (APPEND New-Safe-Sub-Items NC.SafeMiddleButtonSubItems 
                                         NC.SafeLeftButtonSubItems)))
         (NC.ProtectedCardOperation Card "Make Read-Only" Window (if (NC.CardSomehowDirtyP Card)
                                                                     then (NC.SaveOrRevertGraphCard
                                                                           Card Window))
                (NC.SetUserDataProp Card 'ReadOnly T)
                (NC.GetGraphEditMenu Window)
                (if (WINDOWP (SETQ PropListEditor (NC.PropListEditorOpenP Window)))
                    then (NC.MakeTEditReadOnly Window)
                         (WINDOWPROP PropListEditor 'TEDIT.MENU NC.ShowPropListMenu))
                (NC.MakeMenusReadOnly Window Browser-Safe-Items Browser-Safe-Sub-Items])
)



(* ;;; "Changes for NCCARD")

(DEFINEQ

(NC.ReadOnlyCardP
  [LAMBDA (Card)                                         (* ; "Edited  8-Apr-88 10:56 by MacDonald")

(* ;;; "Return non-nil if card's notefile is open for read only.  Someday it will get smarter.")

(* ;;; "dwm 03/15/88:  That day is here, now checks Card's ReadOnly property")

    (NC.FetchUserDataProp Card 'ReadOnly])
)
(PUTPROPS DWMPATCH004 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (2182 3952 (NC.Don'tDoIt 2192 . 2332) (NC.MakeCardReadOnly 2334 . 2853) (
NC.MakeCardReadWrite 2855 . 3347) (NC.ChangeCardWriteStatus 3349 . 3950)) (4560 6278 (
NC.MakeTEditReadOnly 4570 . 5557) (NC.MakeTEditReadWrite 5559 . 6276)) (8444 9047 (
NCP.MakeCardReadOnly 8454 . 8656) (NCP.MakeCardReadWrite 8658 . 8831) (NCP.ChangeCardWriteStatus 8833
 . 9045)) (9089 11325 (NC.MakeTextCardReadOnly 9099 . 11323)) (11368 12893 (NC.MakeGraphCardReadOnly 
11378 . 12891)) (12938 14475 (NC.MakeBrowserCardReadOnly 12948 . 14473)) (14513 14885 (
NC.ReadOnlyCardP 14523 . 14883)))))
STOP