(FILECREATED "12-Dec-86 11:19:54" {QV}<NOTECARDS>1.3K>NEXT>PMIPATCH011.;1 21073 changes to: (VARS PMIPATCH011COMS)) (* Copyright (c) 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT PMIPATCH011COMS) (RPAQQ PMIPATCH011COMS ((* * Fixes Bug %#281: Opening a new NoteFile should prompt the user for placement of its menu.) (* * Change to NCDATABASE) (FNS NC.OpenNoteFile) (* * Change to NCINTERFACE) (FNS NC.SetUpNoteFileInterface))) (* * Fixes Bug %#281: Opening a new NoteFile should prompt the user for placement of its menu. ) (* * Change to NCDATABASE) (DEFINEQ (NC.OpenNoteFile (LAMBDA (NoteFileOrFileName NoteFilesHashArray Don'tCacheTypesAndTitlesFlg Don'tCreateFlg ConvertNoConfirmFlg Don'tCreateArrayFlg Can'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg InterestedWindow PublicOrPrivate Don'tCheckOperationsInProgressFlg MenuPosition QuietFlg ReadOnlyFlg Don'tCheckForTruncationFlg) (* pmi: "12-Dec-86 10:50") (* * fgh 5/23/86 Renamed to NC.OpenNoteFile from NC.OpenDatabaseFile. Total revamp to implement device vector.) (* * kef 7/18/86: Inserted a call to stuff the UID into the NoteFile because BuildHashArray needed it.) (* * kef 7/21/86: Moved up the install of the NoteFile into the NoteFileHashArray to before the building of the NoteFile's hash array. The reason is that the remote multi client build hash array function needs to get a list of UIDs, and in order to do this, it needs to grab a Courier stream for the NoteFile given only the UID. It can only do this if the UID is registered in the NoteFilesHashArray.) (* * fgh 8/31/86 Updated to account for changes made to system since 5/23/86 revamp. Changes reimplemented include: (fgh 6/8/86 Added code to insure that two files with SameUIDP would never be open at once.) (fgh 6/25/86 Added contention locks -- NC.ProtectedNoteFileOperation, Don'tCheckOperationInProgressFlg etc.) (fgh 6/27/86 Added MenuPsotion arg to pass to SetUpNoteFileInterface) (kirk 15Jul86 Added call to NC.SetUpNoteFileInterface if already open)) (* * fgh 9/1/86 Reimplemented ReadOnly NoteFile open.) (* * fgh 9/4/86 Put in default for NoteFilesHashArray which is NC.NoteFilesHashArray) (* * kirk/rht 8/29/86: Now resets Name after conversion from version 2 to version3.) (* * rht 10/29/86: Changed "aborted" to "canceled" in message.) (* * rht 10/31/86: Added Don'tCheckForTruncationFlg arg.) (* * rht&pmi 11/21/86: Took away the protection from around the AFTER call to open events fns.) (* * pmi 12/12/86: Added InterestedWindow argument to NC.SetUpNoteFileInterface so that it can print a prompt to the user about placing the NoteFile menu.) (DECLARE (GLOBALVARS NC.OpenNoteFileFns NC.LastNoteFileOpened)) (* * If the value returned is not a NoteFile, let the user know there's been some problem.) (PROG (NoteFile FileName ReturnValue CriticalUIDs) (* * Figure out the name of the file containing the NoteFile) (if (NULL (SETQ FileName (COND ((type? NoteFile NoteFileOrFileName) (fetch (NoteFile FullFileName) of NoteFileOrFileName)) (NoteFileOrFileName) (T (NC.DatabaseFileName "Name of NoteFile to open:" " -- " T NIL NIL InterestedWindow))))) then (RETURN)) (* SETQ FileName (OR (FULLNAME FileName) FileName)) (* * Create a NoteFile object or use existing notefile object if there is one for this file name.) (SETQ NoteFile (if (type? NoteFile NoteFileOrFileName) then NoteFileOrFileName else (OR (NC.NoteFileFromFileName FileName) (create NoteFile)))) (replace (NoteFile FullFileName) of NoteFile with FileName) (replace (NoteFile ReadOnlyFlg) of NoteFile with ReadOnlyFlg) (* * If there is no interested window, see if the menu window can be used.) (if (AND (NULL InterestedWindow) (fetch (NoteFile Menu) of NoteFile)) then (SETQ InterestedWindow (WFROMMENU (fetch (NoteFile Menu) of NoteFile))) ) (* * Figure out the appropriate device vector from the file name.) (NC.InstallDeviceVectorInNoteFile NoteFile PublicOrPrivate) (* * If this is an open NoteFIle, just bring up its menu.) (if (NC.NoteFileOpenP NoteFile) then (OR Don'tCreateInterfaceFlg (NC.SetUpNoteFileInterface NoteFile MenuPosition InterestedWindow)) (* bring up or create notefile icon if needed) (RETURN NIL)) (* * Notify user.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Opening NoteFile: " FileName " ..." (CHARACTER 13))) (* * Check to see if this NoteFile is busy doing something else) (if (AND (NULL Don'tCheckOperationsInProgressFlg) (PROCESSP (NC.NoteFileProp NoteFile (QUOTE ProcessInProgress)))) then (NC.PrintOperationInProgressMsg InterestedWindow (QUOTE Open% NoteFile) (NC.NoteFileProp NoteFile (QUOTE OperationInProgress))) (RETURN NIL)) (* * Run rest of function with contention lock.) (SETQ ReturnValue (NC.ProtectedNoteFileOperation NoteFile Open% NoteFile (PROG NIL (* * Run through OpenNoteFileFns with param of BEFORE. Exit if any returns DON'T) (if (for Function in NC.OpenNoteFileFns thereis (OR (EQ Function (QUOTE DON'T)) (EQ (QUOTE DON'T) (APPLY* Function FileName NoteFile (QUOTE BEFORE))))) then (if (WINDOWP InterestedWindow) then (NC.PrintMsg InterestedWindow NIL "Open canceled for NoteFile " FileName "." (CHARACTER 13)) (NC.ClearMsg InterestedWindow T)) (RETURN)) (* * Call the device specific OpenNoteFileFn, which returns a list of special UIDs) (if (NULL (ERSETQ (SETQ ReturnValue (APPLY* (fetch (NoteFile OpenNoteFileFn) of NoteFile) NoteFile InterestedWindow Don'tCheckForTruncationFlg)))) then (SETQ ReturnValue (QUOTE NoteFileOpenFailed))) (* * Process error returns from the OpenNoteFileFn) (if (NOT (LITATOM ReturnValue)) then (* * OpenNoteFileFn returned correctly) (SETQ CriticalUIDs ReturnValue) else (* * Error, process it.) (SETQ ReturnValue (OR (SELECTQ ReturnValue (NoteFileNotFound ( NC.ProcessNoteFileNotFoundError NoteFile NoteFilesHashArray Don'tCacheTypesAndTitlesFlg Don'tCreateFlg ConvertNoConfirmFlg Don'tCreateArrayFlg Can'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg InterestedWindow PublicOrPrivate Don'tCheckOperationsInProgressFlg MenuPosition QuietFlg ReadOnlyFlg Don'tCheckForTruncationFlg)) (NoteFileNeedsConversion ( NC.ProcessNoteFileNeedsConversionError NoteFile NoteFilesHashArray Don'tCacheTypesAndTitlesFlg Don'tCreateFlg ConvertNoConfirmFlg Don'tCreateArrayFlg Can'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg InterestedWindow PublicOrPrivate Don'tCheckOperationsInProgressFlg MenuPosition QuietFlg ReadOnlyFlg Don'tCheckForTruncationFlg)) (NoteFileNeedsTruncation ( NC.ProcessNoteFileNeedsTruncationError NoteFile NoteFilesHashArray Don'tCacheTypesAndTitlesFlg Don'tCreateFlg ConvertNoConfirmFlg Don'tCreateArrayFlg Can'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg InterestedWindow PublicOrPrivate Don'tCheckOperationsInProgressFlg MenuPosition QuietFlg ReadOnlyFlg Don'tCheckForTruncationFlg)) (NoteFileAlreadyOpen (ERSETQ (NC.ReportError NIL (CONCAT (fetch (NoteFile FullFileName) of NoteFile) " is already open for exclusive access. Open failed.")))) (NoteFileOpenFailed (ERSETQ (NC.ReportError NIL (CONCAT "Open of " (fetch (NoteFile FullFileName) of NoteFile) " failed for unknown reason.")))) (NoteFileHeaderBad (ERSETQ (NC.ReportError NIL (CONCAT "Header of NoteFile " (fetch (NoteFile FullFileName) of NoteFile) " is bad. Contact a NoteCards wizard.")))) (PROGN (ERSETQ (NC.ReportError NIL (CONCAT "Unknown error code (" ReturnValue ") returned by OpenNoteFileFn for NoteFile " FileName))))) ReturnValue)) (* * notify the user. if there's been a problem) (if (AND (NOT (type? NoteFile ReturnValue)) (WINDOWP InterestedWindow)) then (NC.PrintMsg InterestedWindow NIL "Open canceled for NoteFile " FileName "." (CHARACTER 13)) (NC.ClearMsg InterestedWindow T)) (* * return whatever the error processing returned.) (RETURN ReturnValue)) (SETQ ReturnValue) (* * Make sure there is no other open NF with this UID.) (LET (NF) (if (AND (SETQ NF (GETHASH (fetch (NoteFileCriticalUIDs NoteFile) of CriticalUIDs) NC.NoteFilesHashArray)) (NEQ (fetch (NoteFile FullFileName) of NoteFile) (fetch (NoteFile FullFileName) of NF)) (NC.NoteFileOpenP NF)) then (FLASHW PROMPTWINDOW) (NC.PrintMsg PROMPTWINDOW T "Couldn't open " FileName (CHARACTER 13) "because " (fetch (NoteFile FullFileName) of NF) " is already open " (CHARACTER 13) "and has the same UID.") (NC.CloseNoteFile NoteFile InterestedWindow T T) (RETURN NIL))) (* * If needed, build a hash array by calling the device specific BuilHashArrayFn.) (replace (NoteFile UID) of NoteFile with (fetch (NoteFileCriticalUIDs NoteFile) of CriticalUIDs)) (* * Store this NoteFile object in the appropriate NoteFile hash array) (NC.StoreNoteFileInHashArray NoteFile (OR NoteFilesHashArray NC.NoteFilesHashArray)) (if (NOT Don'tCreateArrayFlg) then (OR QuietFlg (NC.PrintMsg InterestedWindow T "Opening NoteFile: " FileName (CHARACTER 13) "Building index array ..." (CHARACTER 13))) (if (OR (NULL (ERSETQ (SETQ ReturnValue (APPLY* (fetch (NoteFile BuildHashArrayFn) of NoteFile) NoteFile QuietFlg InterestedWindow (CONCAT "Opening NoteFile " (fetch (NoteFile FullFileName) of NoteFile) (CHARACTER 13)))))) (NOT (type? NoteFile ReturnValue))) then (* * Error during building of hash array) (ERSETQ (NC.ReportError NIL (CONCAT "Build Hash Array failed for NoteFile " (fetch (NoteFile FullFileName) of NoteFile) " because " ReturnValue))) (RETURN))) (* * Set up critical UIDs in NoteFile object using the values returned from OpenNoteFileFn.) (NC.InstallCriticalUIDsInNoteFile NoteFile CriticalUIDs) (* * if needed, cache the special cards) (if (NOT Don'tGetSpecialCardsFlg) then (NC.GetSpecialCards NoteFile QuietFlg InterestedWindow (CONCAT "Opening NoteFile: " (fetch (NoteFile FullFileName) of NoteFile) (CHARACTER 13)))) (* * If needed, start the titles and types caching process) (if (NOT Don'tCacheTypesAndTitlesFlg) then (replace (NoteFile CachingProcess) of NoteFile with (ADD.PROCESS (LIST (FUNCTION NC.CacheTypesAndTitles) NoteFile)))) (* * If needed, open up a NoteFile interface.) (if (NOT Don'tCreateInterfaceFlg) then (NC.SetUpNoteFileInterface NoteFile MenuPosition InterestedWindow)) (* * Record this as the last NF opened.) (SETQ NC.LastNoteFileOpened NoteFile) (RETURN NoteFile)))) (if (type? NoteFile ReturnValue) then (* * Run through OpenNoteFIleFns with param of AFTER. Stop if any returns DON'T) (for Function in NC.OpenNoteFileFns thereis (EQ (QUOTE DON'T) (APPLY* Function FileName NoteFile (QUOTE AFTER)))) (* * Go home, returning NoteFile) (if (NULL QuietFlg) then (NC.PrintMsg InterestedWindow T "Opening NoteFile: " FileName (CHARACTER 13) "Done." (CHARACTER 13)) (NC.ClearMsg InterestedWindow T)) (RETURN NoteFile) else (* * Bail out if open was unsuccessful.) (RETURN NIL))))) ) (* * Change to NCINTERFACE) (DEFINEQ (NC.SetUpNoteFileInterface (LAMBDA (NoteFile Position InterestedWindow) (* pmi: "12-Dec-86 10:50") (* * 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.) (LET ((Font (FONTCREATE (QUOTE HELVETICA) 10 (QUOTE BOLD))) (TitleFont (FONTCREATE (QUOTE HELVETICA) 12 (QUOTE BOLD))) NoteFileMenuWindow NoteFileMenu FullFileName) (* Main Menu) (SETQ FullFileName (fetch (NoteFile FullFileName) of NoteFile)) (if (SETQ NoteFileMenu (fetch (NoteFile Menu) of NoteFile)) then (replace (MENU WHENSELECTEDFN) of NoteFileMenu with (if (NC.NoteFileOpenP NoteFile) then (FUNCTION NC.NoteFileMenuWhenSelectedFn) else (FUNCTION NC.ClosedNoteFileMenuWhenSelectedFn))) (replace (MENU TITLE) of NoteFileMenu with (CONCAT (if ( NC.ReadOnlyNoteFileP NoteFile) then "RO: " else "") (FILENAMEFIELD FullFileName (QUOTE NAME)) ";" (FILENAMEFIELD FullFileName (QUOTE VERSION))) ) (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) (AND (WFROMMENU NoteFileMenu) (REDISPLAYW (WFROMMENU NoteFileMenu))) else (SETQ NoteFileMenu (create MENU ITEMS ←(QUOTE ((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 ←(if (NC.NoteFileOpenP NoteFile) then (FUNCTION NC.NoteFileMenuWhenSelectedFn) else (FUNCTION NC.ClosedNoteFileMenuWhenSelectedFn)) CENTERFLG ← T MENUBORDERSIZE ← 1 MENUOUTLINESIZE ← 2 MENUCOLUMNS ← 2 MENUFONT ← Font TITLE ←(CONCAT (if (NC.ReadOnlyNoteFileP NoteFile) then "RO: " else "") (FILENAMEFIELD FullFileName (QUOTE NAME)) ";" (FILENAMEFIELD FullFileName (QUOTE VERSION))) ITEMHEIGHT ←(IPLUS 6 (FONTPROP Font (QUOTE HEIGHT))) ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE NewCards) Font) 10) MENUTITLEFONT ← TitleFont)) (* Prompt the user to place the new notefile menu) (NC.PrintMsg InterestedWindow T "Please place the menu for notefile " FullFileName)) (for Item in (fetch (MENU ITEMS) of NoteFileMenu) do (SHADEITEM Item NoteFileMenu (if (NC.NoteFileOpenP NoteFile) then WHITESHADE else GRAYSHADE))) (* Shade NewCards if readonly notefile.) (if (NC.ReadOnlyNoteFileP NoteFile) then (for Item in (fetch (MENU ITEMS) of NoteFileMenu) when (EQ (CAR Item) (QUOTE NewCards)) do (SHADEITEM Item NoteFileMenu GRAYSHADE))) (if (WINDOWP (SETQ NoteFileMenuWindow (WFROMMENU NoteFileMenu))) then (FLASHWINDOW NoteFileMenuWindow) else (SETQ NoteFileMenuWindow (ADDMENU NoteFileMenu NIL (OR Position (GETMENUPROP NoteFileMenu (QUOTE OldPosition)) (GETBOXPOSITION (fetch (REGION WIDTH) of (MENUREGION NoteFileMenu)) (fetch (REGION HEIGHT) of (MENUREGION NoteFileMenu))))) )) (WINDOWPROP NoteFileMenuWindow (QUOTE NoteFile) NoteFile) (replace (NoteFile Menu) of NoteFile with NoteFileMenu) (WINDOWPROP NoteFileMenuWindow (QUOTE RESHAPEFN) (QUOTE DON'T)) (WINDOWPROP NoteFileMenuWindow (QUOTE BUTTONEVENTFN) (FUNCTION NC.NoteFileIconButtonEventFn)) (WINDOWPROP NoteFileMenuWindow (QUOTE SHRINKFN) (QUOTE DON'T)) (WINDOWADDPROP NoteFileMenuWindow (QUOTE CLOSEFN) (FUNCTION (LAMBDA (Window) (PUTMENUPROP (CAR (WINDOWPROP Window (QUOTE MENU))) (QUOTE OldPosition) (WINDOWPOSITION Window))))) (NC.MoveWindowOntoScreen NoteFileMenuWindow)))) ) (PUTPROPS PMIPATCH011 COPYRIGHT ("Xerox Corporation" 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (635 15083 (NC.OpenNoteFile 645 . 15081)) (15118 20991 (NC.SetUpNoteFileInterface 15128 . 20989))))) STOP