(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED "19-Sep-88 14:26:41" {QV}<NOTECARDS>1.3LNEXT>PMIPATCH112.;2 23260  

      changes to%:  (FNS NC.NoteFileIconButtonEventFn NC.ResetNoteFileInterface 
                         NC.SetUpNoteFileInterface)
                    (VARS PMIPATCH112COMS)

      previous date%: "16-Sep-88 17:02:06" {QV}<NOTECARDS>1.3LNEXT>PMIPATCH112.;1)


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

(PRETTYCOMPRINT PMIPATCH112COMS)

(RPAQQ PMIPATCH112COMS (

(* ;;; "New file")

                        (DECLARE%: DONTCOPY (PROPS (PMIPATCH112 MAKEFILE-ENVIRONMENT)
                                                   (PMIPATCH112 FILETYPE)))
                        
                        (* ;; "pmi 9/19/88: Now shades text of disabled menu items on notefile icons, instead of their backgrounds.")

                        
                        (* ;; "Changed in NCINTERFACE")

                        (FNS NC.NoteFileIconButtonEventFn NC.ResetNoteFileInterface 
                             NC.SetUpNoteFileInterface)))



(* ;;; "New file")

(DECLARE%: DONTCOPY 

(PUTPROPS PMIPATCH112 MAKEFILE-ENVIRONMENT (:PACKAGE "INTERLISP" :READTABLE "INTERLISP"))

(PUTPROPS PMIPATCH112 FILETYPE :BCOMPL)
)



(* ;; 
"pmi 9/19/88: Now shades text of disabled menu items on notefile icons, instead of their backgrounds."
)




(* ;; "Changed in NCINTERFACE")

(DEFINEQ

(NC.NoteFileIconButtonEventFn
  [LAMBDA (Window)                                           (* ; "Edited 19-Sep-88 14:09 by pmi")

    (* ;; "Bring up NoteFile Menues")

    (* ;; "kirk 15Jul86 Adjusted title size check for change in font")

    (* ;; 
   "rht 11/23/86: Now calls NC.NoteFileIconMiddleButtonFn to put up a menu of middle button options.")

    (* ;; "pmi 3/20/87: Overhauled to have NewCards and ShowCards middlebutton menus appear when buttoned DOWN, instead of after the button comes back up.")

    (* ;; "pmi 4/3/87: Now unshades NewCards item during card creation to indicate that multiple cards may be created at the same time.")

    (* ;; "rg 11/4/87 calls NC.EditNoteCard w/ ReadOnly if NoteFile is read-only")

    (* ;; "pmi 2/23/88: Now passes Window as InterestedWindow argument to NC.MakeNoteCard.")

    (* ;; "pmi 9/12/88: Now uses NCP.GrayShade instead of GRAYSHADE to indicate the disabled state of a menu item. Also uses BLACKSHADE instead of GRAYSHADE to shade the menu items when they are selected.")

    (* ;; "pmi 9/19/88: Now shades text of disabled menu items on notefile icons, instead of their backgrounds.")

    (DECLARE (GLOBALVARS BLACKSHADE NCP.GrayShade))
    (LET
     (NoteFile Menu)
     (if (MOUSESTATE UP)
       else
       (TOTOPW Window)
       (LET
        [(Menu (CAR (WINDOWPROP Window 'MENU]                (* ; "title bar")
        (SETQ NoteFile (WINDOWPROP Window 'NoteFile))
        (for Item in (fetch (MENU ITEMS) of Menu) when (INSIDEP (MENUITEMREGION Item Menu)
                                                              (LASTMOUSEX Window)
                                                              (LASTMOUSEY Window))
           do (RESETLST
                  (RESETSAVE (SHADEITEM Item Menu BLACKSHADE)
                         (if (NULL (NC.NoteFileOpenP NoteFile))
                             then (LIST 'NEWSHADEITEM Item Menu NCP.GrayShade NIL 'ERASE)
                           elseif (AND (EQ (CAR Item)
                                           'NewCards)
                                       (NC.ReadOnlyNoteFileP NoteFile))
                             then (LIST 'NEWSHADEITEM Item Menu NCP.GrayShade NIL 'ERASE)
                           else (LIST 'SHADEITEM Item Menu WHITESHADE)))
                  (if (NULL (NC.NoteFileOpenP NoteFile))
                      then 

(* ;;; "If the NoteFile is not open, just print a message and return")

                           (FLASHW Window)
                           (NC.PrintMsg Window T (fetch (NoteFile FullFileName) of NoteFile)
                                  " is not an open notefile.")
                           (DISMISS 1000)
                           (NC.ClearMsg Window T)
                    elseif (PROCESSP (NC.NoteFileProp NoteFile 'ProcessInProgress))
                      then 

(* ;;; "This will probably be overhauled with Randy G.'s concurrancy fixes")

                           (NC.PrintOperationInProgressMsg Window (CAR Item)
                                  (NC.NoteFileProp NoteFile 'OperationInProgress))
                           NIL
                    else (SELECTQ (CAR Item)
                             (NewCards (if (NC.ReadOnlyNoteFileP NoteFile)
                                           then (FLASHW Window)
                                                (NC.PrintMsg Window T 
                                                   "Can't create a new card in a Read-Only notefile."
                                                       )
                                                (DISMISS 1000)
                                                (NC.ClearMsg Window T)
                                         elseif (LASTMOUSESTATE LEFT)
                                           then 

                                              (* ;; "For the left button, don't do anything until the button comes back up.  Otherwise, things happen too soon.")

                                                (UNTILMOUSESTATE UP)
                                                (if (INSIDEP (MENUITEMREGION Item Menu)
                                                           (LASTMOUSEX Window)
                                                           (LASTMOUSEY Window))
                                                    then (SHADEITEM Item Menu WHITESHADE)
                                                         (NC.MakeNoteCard NC.DefaultCardType NoteFile
                                                                NIL NIL NIL NIL Window))
                                         else (SHADEITEM Item Menu WHITESHADE)
                                              (NC.MakeNoteCard NIL NoteFile NIL NIL NIL NIL Window)))
                             (ShowCards (if (LASTMOUSESTATE LEFT)
                                            then 

                                              (* ;; "For the left button, don't do anything until the button comes back up.  Otherwise, things happen too soon.")

                                                 (UNTILMOUSESTATE UP)
                                                 (if (INSIDEP (MENUITEMREGION Item Menu)
                                                            (LASTMOUSEX Window)
                                                            (LASTMOUSEY Window))
                                                     then (NC.EditNoteCard (fetch (NoteFile 
                                                                                  TableOfContentsCard
                                                                                         )
                                                                              of NoteFile)
                                                                 (fetch (NoteFile ReadOnlyFlg)
                                                                    of NoteFile)))
                                          else (NC.ChooseTopLevelCard NoteFile)))
                             NIL)))
              (RETURN) finally (if (LASTMOUSESTATE MIDDLE)
                                   then (NC.NoteFileIconMiddleButtonFn Window NoteFile)
                                 elseif (NULL (WINDOWPROP Window 'BusyOperation))
                                   then (RESETLST
                                            (RESETSAVE (WINDOWPROP Window 'BusyOperation "Operation")
                                                   `(WINDOWPROP ,Window BusyOperation NIL))
                                            (NC.NoteFileOperations NoteFile))
                                 else (NC.PrintMsg NIL NIL (CHARACTER 13)
                                             (WINDOWPROP Window 'BusyOperation)
                                             " in progress.  Please wait."])

(NC.ResetNoteFileInterface
  [LAMBDA (NoteFile)                                         (* ; "Edited 19-Sep-88 14:11 by pmi")

(* ;;; "Close up the control menu for a NoteFile")

    (* ;; "rht 5/1/86: Now does nothing if NC.NoteFileMenuLingerFlg is non-nil.")

    (* ;; "rht 5/6/86: Now smashes WhenSelectedFn and shades menu items if NC.NoteFileMenuLingerFlg is non-nil.")

    (* ;; "pmi 2/18/87: Now deletes 'RO:' in title of NoteFile menu if NoteFile was open Read-only")

    (* ;; "pmi 3/20/87: Removed WhenSelectedFn when overhauling to have NewCards and ShowCards middlebutton menus appear when buttoned DOWN, instead of after the button comes back up.  Everything is now done in the ButtonEventFn.")

    (* ;; "pmi 5/1/87: Inserted call to NC.ClearMsg before the NoteFile's icon is deleted.  Added Window arg to DELETEMENU call.  Also commented out the code that deletes the NoteFile's menu and removes the NoteFile from its window if NC.NoteFileMenuLingerFlg is NIL.  That way if the NoteFile is reopened, it will remember the position for its icon.")

    (* ;; "pmi 9/12/88: Now uses NCP.GrayShade instead of GRAYSHADE for shading menu items.")

    (* ;; "pmi 9/19/88: Now shades text of disabled menu items on notefile icons, instead of their backgrounds.")

    (DECLARE (GLOBALVARS NC.NoteFileMenuLingerFlg NCP.GrayShade))
    (LET ((Menu (fetch (NoteFile Menu) of NoteFile))
          Window FullFileName)
         (if Menu
             then (SETQ Window (WFROMMENU Menu))
                  (if NC.NoteFileMenuLingerFlg
                      then [for Item in (fetch (MENU ITEMS) of Menu)
                              do (if (NC.NoteFileOpenP NoteFile)
                                     then (SHADEITEM Item Menu WHITESHADE)
                                   else (NEWSHADEITEM Item Menu NCP.GrayShade NIL 'ERASE]
                           (if (NC.ReadOnlyNoteFileP NoteFile)
                               then (SETQ FullFileName (fetch (NoteFile FullFileName) of NoteFile))
                                    [replace (MENU TITLE) of Menu with (CONCAT (FILENAMEFIELD
                                                                                FullFileName
                                                                                'NAME)
                                                                              ";"
                                                                              (FILENAMEFIELD
                                                                               FullFileName
                                                                               'VERSION]
                                    (replace (MENU IMAGE) of Menu with NIL) 

                                    (* ;; 
            "KLUDGE.  Fetching the image height forces the menu package to recompute the menu image.")

                                    (fetch (MENU IMAGEHEIGHT) of Menu) 

                                    (* ;; 
             "further KLUDGE.  Have to smash MENUGRID to prevent menu image from being shifted over.")

                                    (replace (MENU MENUGRID) of Menu
                                       with (LIST 2 2 (fetch (MENU ITEMWIDTH) of Menu)
                                                  (fetch (MENU ITEMHEIGHT) of Menu)))
                                    (for Item in (fetch (MENU ITEMS) of Menu)
                                       when (EQ (CAR Item)
                                                'NewCards) do (NEWSHADEITEM Item Menu NCP.GrayShade 
                                                                     NIL 'ERASE))
                                    (AND Window (REDISPLAYW Window)))
                    else (NC.ClearMsg Window T)
                         (WINDOWPROP Window 'CLOSEFN NIL)
                         (DELETEMENU Menu T Window])

(NC.SetUpNoteFileInterface
  [LAMBDA (NoteFile Position InterestedWindow Don'tCreateInterfaceFlg)
                                                             (* ; "Edited 19-Sep-88 14:10 by pmi")

(* ;;; "Create the NoteCards control menu for a NoteFile")

    (* ;; "kirk 13Jan85 Decreased the size of the NoteFile Menu")

    (* ;; "fgh 1/22/86 Fixed the ghost box size when position menu.")

    (* ;; 
    "rht 5/6/86: Now restores the menu's WhenSelectedFn and ungrays its items if already existed.")

    (* ;; "fgh 6/27/86 Added position argument")

    (* ;; "rht 7/5/86: Now shades NewCards if readonly notefile.")

    (* ;; "fgh 7/6/86 Will now set up menu correctly even if NF is closed.")

    (* ;; "rht 7/13/86: Was ignoring the Position arg.  No longer.")

    (* ;; "rht 11/20/86: Changed name from ShowBox to ShowCards.")

    (* ;; " pmi 12/12/86: Added InterestedWindow argument so that we can print a prompt to the user about placing a newly created NoteFile menu.")

    (* ;; "pmi 3/20/87: Removed WhenSelectedFn when overhauling to have NewCards and ShowCards middlebutton menus appear when buttoned DOWN, instead of after the button comes back up.  Everything is now done in the ButtonEventFn.")

    (* ;; "pmi 5/6/87: Moved prompt for position of icon to better place.  Also added MENUOFFSET to NoteFile menu for Lyric.")

    (* ;; "pmi 5/19/87: Now stores the menu as a property of the fullfilename of the notefile.  We might lose our pointer to the notefile object if another one gets created with the same UID, but we would like to keep a pointer to the menu.")

    (* ;; "pmi 5/28/87: Now returns the NoteFile Interface window.")

    (* ;; "rg 12/15/87: fixes up menu grid so redisplay works when notefile is reopened.")

    (* ;; "pmi 12/17/87 Added Don'tCreateInterfaceFlg argument in response to suggestion by dsj.  Now can be called to update the notefile interface and won't automatically create a new one if it doesn't already exist.")

    (* ;; "pmi 1/11/88: moved rg's last patch so that it applies to both new and preexisting notefile icon menus.")

    (* ;; "pmi 8/29/88: No longer tries to set windowprops on NIL window, which were ending up on the Mouse TTY window.")

    (* ;; "pmi 9/12/88: Now uses NCP.GrayShade instead of GRAYSHADE for shading menu items.")

    (* ;; "pmi 9/19/88: Now shades text of disabled menu items on notefile icons, instead of their backgrounds.")

    (DECLARE (GLOBALVARS NCP.GrayShade))
    (LET ((Font (FONTCREATE 'HELVETICA 10 'BOLD))
          (TitleFont (FONTCREATE 'HELVETICA 12 'BOLD))
          NoteFileMenuWindow NoteFileMenu FullFileName)      (* ; "Main Menu")
         (SETQ FullFileName (fetch (NoteFile FullFileName) of NoteFile))
         [if (SETQ NoteFileMenu (OR (NC.GetNoteFileMenu NoteFile)
                                    (NC.GetNoteFileMenu FullFileName)))
             then [replace (MENU TITLE) of NoteFileMenu with (CONCAT (if (NC.ReadOnlyNoteFileP 
                                                                                NoteFile)
                                                                         then "RO: "
                                                                       else "")
                                                                    (FILENAMEFIELD FullFileName
                                                                           'NAME)
                                                                    ";"
                                                                    (FILENAMEFIELD FullFileName
                                                                           'VERSION]
           else (SETQ NoteFileMenu
                 (create MENU
                        ITEMS ← '((NewCards NIL 
                           "Create a new Text card (left button) or other card type (middle button)."
                                         )
                                  (ShowCards NIL "Bring up one of the special cards."))
                        WHENSELECTEDFN ← (FUNCTION NILL)
                        CENTERFLG ← T
                        MENUBORDERSIZE ← 1
                        MENUOUTLINESIZE ← 2
                        MENUCOLUMNS ← 2
                        MENUFONT ← Font
                        TITLE ← (CONCAT (if (NC.ReadOnlyNoteFileP NoteFile)
                                            then "RO: "
                                          else "")
                                       (FILENAMEFIELD FullFileName 'NAME)
                                       ";"
                                       (FILENAMEFIELD FullFileName 'VERSION))
                        ITEMHEIGHT ← (IPLUS 6 (FONTPROP Font 'HEIGHT))
                        ITEMWIDTH ← (IPLUS (STRINGWIDTH 'NewCards Font)
                                           10)
                        MENUTITLEFONT ← TitleFont
                        MENUOFFSET ← (CONS 0 0]
         (replace (MENU IMAGE) of NoteFileMenu with NIL)     (* ; 
            "KLUDGE.  Fetching the image height forces the menu package to recompute the menu image.")
         (fetch (MENU IMAGEHEIGHT) of NoteFileMenu)          (* ; 
             "further KLUDGE.  Have to smash MENUGRID to prevent menu image from being shifted over.")
         (replace (MENU MENUGRID) of NoteFileMenu with (LIST 2 2 (fetch (MENU ITEMWIDTH) of 
                                                                                         NoteFileMenu
                                                                        )
                                                             (fetch (MENU ITEMHEIGHT) of NoteFileMenu
                                                                    )))
         (AND (WFROMMENU NoteFileMenu)
              (REDISPLAYW (WFROMMENU NoteFileMenu)))
         [for Item in (fetch (MENU ITEMS) of NoteFileMenu)
            do (if (NC.NoteFileOpenP NoteFile)
                   then (SHADEITEM Item NoteFileMenu WHITESHADE)
                 else (NEWSHADEITEM Item NoteFileMenu NCP.GrayShade NIL 'ERASE]
                                                             (* ; 
                                                             "Shade NewCards if readonly notefile.")
         [if (NC.ReadOnlyNoteFileP NoteFile)
             then (for Item in (fetch (MENU ITEMS) of NoteFileMenu) when (EQ (CAR Item)
                                                                             'NewCards)
                     do (NEWSHADEITEM Item NoteFileMenu NCP.GrayShade NIL 'ERASE]
         [if (WINDOWP (SETQ NoteFileMenuWindow (WFROMMENU NoteFileMenu)))
             then (FLASHWINDOW NoteFileMenuWindow)
           else                                              (* ; 
                                     "Don't create a new NoteFile interface if we were asked not to.")
                (OR Don'tCreateInterfaceFlg (SETQ NoteFileMenuWindow
                                             (ADDMENU NoteFileMenu NIL
                                                    (if Position
                                                      elseif (GETMENUPROP NoteFileMenu 'OldPosition)
                                                      else   (* ; 
                                                     "Prompt the user to place the new notefile menu")
                                                           (NC.PrintMsg InterestedWindow T 
                                                                "Please place the menu for notefile "
                                                                  FullFileName)
                                                           [SETQ Position (GETBOXPOSITION
                                                                           (fetch (REGION WIDTH)
                                                                              of (MENUREGION 
                                                                                        NoteFileMenu)
                                                                                  )
                                                                           (fetch (REGION HEIGHT)
                                                                              of (MENUREGION 
                                                                                        NoteFileMenu]
                                                           (NC.ClearMsg InterestedWindow T)
                                                           Position]
         (if (WINDOWP NoteFileMenuWindow)
             then (WINDOWPROP NoteFileMenuWindow 'NoteFile NoteFile)
                  (WINDOWPROP NoteFileMenuWindow 'RESHAPEFN 'DON'T)
                  (WINDOWPROP NoteFileMenuWindow 'BUTTONEVENTFN (FUNCTION 
                                                                 NC.NoteFileIconButtonEventFn))
                  (WINDOWPROP NoteFileMenuWindow 'SHRINKFN 'DON'T)
                  (WINDOWPROP NoteFileMenuWindow 'SCROLLFN NIL)
                  (WINDOWPROP NoteFileMenuWindow 'NOSCROLLBARS T) 

                  (* ;; "Make sure default menu WhenSelectedFn is not called")

                  (WINDOWPROP NoteFileMenuWindow 'CURSORINFN NIL)
                  (WINDOWPROP NoteFileMenuWindow 'CURSOROUTFN NIL)
                  (WINDOWPROP NoteFileMenuWindow 'CURSORMOVEDFN NIL) 

                  (* ;; "")

                  [WINDOWADDPROP NoteFileMenuWindow 'CLOSEFN (FUNCTION (LAMBDA (Window)
                                                                         (PUTMENUPROP
                                                                          (CAR (WINDOWPROP
                                                                                Window
                                                                                'MENU))
                                                                          'OldPosition
                                                                          (WINDOWPOSITION Window]
                  (NC.MoveWindowOntoScreen NoteFileMenuWindow))
         (replace (NoteFile Menu) of NoteFile with NoteFileMenu)
         (PUTPROP FullFileName 'Menu NoteFileMenu)
         NoteFileMenuWindow])
)
(PUTPROPS PMIPATCH112 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1486 23177 (NC.NoteFileIconButtonEventFn 1496 . 8514) (NC.ResetNoteFileInterface 8516
 . 12607) (NC.SetUpNoteFileInterface 12609 . 23175)))))
STOP