(FILECREATED "16-Sep-87 10:27:53" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH065.;1 6942   

      changes to:  (VARS PMIPATCH065COMS)
		   (FNS NC.QuitCard)

      previous date: "16-Sep-87 10:22:42" {QV}<NOTECARDS>1.3K>LIBRARY>PMIPATCH065.;1)


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

(PRETTYCOMPRINT PMIPATCH065COMS)

(RPAQQ PMIPATCH065COMS ((* * pmi 9/16/87: Undoes previous fix to this function. Needed to get 
			     NCLOGGER working. It depends on getting the CardObject off of the Window 
			     passed in as CardIdentifier.)
			  (* * Changed in NCCARDS)
			  (FNS NC.QuitCard)))
(* * pmi 9/16/87: Undoes previous fix to this function. Needed to get NCLOGGER working. It 
depends on getting the CardObject off of the Window passed in as CardIdentifier.)

(* * Changed in NCCARDS)

(DEFINEQ

(NC.QuitCard
  (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg DontRecacheFlg InterestedWindow OperationMsg 
			  QuietFlg Don'tDeactivateFlg)       (* pmi: "16-Sep-87 10:21")

          (* * Force note card specified by ID to quit or stop)



          (* * rht 2/9/85: New arg DontSaveFlg prevents NC.CardSaveFn from being called. Used when aborting a card.
	  This is NOT equivalent to NC.QuitWithoutSaving.)



          (* * rht 6/25/85: Now moves card off screen before saving if NC.CloseCardsOffScreenFlg is non-nil.)



          (* * rht 6/25/85: Brought the insure proper filing check back here from NC.CardSaveFn. Bails out if user cancelled 
	  operation inside of NC.InsureProperFiling)



          (* * fgh 11/11/85: Updated to handle CardID and CardInfo objects.)



          (* * fgh 1/16/86 Put in code to insure that if one of the TopLevelCards is quit then it is reactivated immedialtely
	  to make sure it stays cached for fast access.)



          (* * fgh 2/5/86 Added call to NC.ApplyFn)



          (* * fgh 5/2/86 Added DontRecacheFlg arg)



          (* * fgh 6/9/86 Added code to check to make sure other operations are not in progress. And DontCheckOpInProgressFlg
	  arg to match)



          (* * fgh 6/26/86 Added InterestedWindow & OperationMsg arg.)



          (* * rht 7/2/86: Now bails out if notefile is readonly, user confirms, but we're supposed to write down changes.)



          (* * rht 7/13/86: Now takes QuietFlg arg.)



          (* * rht 7/14/86: Call NC.DeactivateCard from here instead of in card type QuitFn. Take a Don'tDeactivateFlg as 
	  well.)



          (* * rht 10/7/86: Now removes DELETEME imageobj's from card substance.)



          (* * rht 11/2/86: Now returns DON'T if operation in progress.)



          (* * rht 11/13/86: Now closes open proplist editor if any before saving.)



          (* * rg 3/4/87 rewritten to use new NC.ProtectedCardOperation, removed DontCheckOpInProgressFlg arg)



          (* * rht 3/24/87: Now calls NC.CoerceToInterestedWindow and passes InterestedWindow to NC.InsureProperFiling.)



          (* * rht 4/24/87: Fixed a vmem leak: when CallCloseWFlg is nil it doesn't clear CardObject windowprop.)



          (* * pmi 9/16/87: Undoes previous fix to this function. Needed to get NCLOGGER working. It depends on getting the 
	  CardObject off of the Window passed in as CardIdentifier.)


    (DECLARE (GLOBALVARS NC.RemoveDELETEMEImageObjsFromCardFlg))
    (LET ((Card (NC.CoerceToCard CardIdentifier))
	  Window ReadOnlyCardFlg)
         (NC.ProtectedCardOperation
	   Card "Close Card" InterestedWindow
	   (PROG NIL
	           (SETQ ReadOnlyCardFlg (NC.ReadOnlyCardP Card))
                                                             (* The window not being open should mean that it's 
							     shrunken. If so, expand it.)
	           (SETQ Window (NC.FetchWindow Card))
	           (OR InterestedWindow (SETQ InterestedWindow (NC.CoerceToInterestedWindow
			     Card)))
	           (COND
		     ((AND Window (NOT (OPENWP Window)))
		       (EXPANDW Window)))

          (* * if proper filing says don't quit then get out)


	           (OR DontSaveFlg ReadOnlyCardFlg (COND
			   ((EQ (NC.InsureProperFiling Card InterestedWindow)
				  (QUOTE DON'T))
			     (RETURN (QUOTE DON'T)))))

          (* * If card is readonly but we've made changes that we're supposed to save, then get user confirmation and bail 
	  out.)


	           (if (AND (NOT DontSaveFlg)
				(NOT Don'tDeactivateFlg)
				ReadOnlyCardFlg
				(NC.CardSomehowDirtyP Card)
				(NULL QuietFlg)
				(NOT (PROGN (NC.PrintMsg InterestedWindow T 
					       "Card has been changed, but notefile is readonly."
							       (CHARACTER 13))
						(NC.AskYesOrNo 
							"Want to quit anyway, flushing changes? "
								 NIL
								 (QUOTE Yes)
								 NIL InterestedWindow))))
		       then (RETURN (QUOTE DON'T)))

          (* * Otherwise go ahead and quit)


	           (RETURN (PROGN                        (* Close open proplist editor if any.)
				      (AND Window (LET ((PropListEditorWindow (
									   NC.PropListEditorOpenP
										  Window)))
						         (AND PropListEditorWindow (CLOSEW 
									     PropListEditorWindow))))
				      (COND
					((AND Window NC.CloseCardsOffScreenFlg)
					  (COND
					    ((NOT (NC.FetchSavedRegion Card))
					      (NC.SetSavedRegion Card (WINDOWPROP Window
										      (QUOTE REGION)
										      ))))
					  (MOVEW Window 1500 1500)))
				      (OR DontSaveFlg (if ReadOnlyCardFlg
							    then (NC.TurnOffDirtyFlgs Card)
							  else
							   (AND 
							    NC.RemoveDELETEMEImageObjsFromCardFlg
								  (
							       NC.RemoveDELETEMEImageObjsFromCard
								    Card
								    (FUNCTION NC.DELETEMEImageObjP))
								  )
							   (NC.CardSaveFn Card (OR 
									NC.CloseCardsOffScreenFlg 
										       QuietFlg)
									    InterestedWindow 
									    OperationMsg)))
				      (AND Window (WINDOWDELPROP Window (QUOTE CLOSEFN)
								     (FUNCTION NC.QuitCard)))
				      (PROG1 (NC.ApplyFn QuitFn Card)

          (* * (AND Window (WINDOWPROP Window (QUOTE NoteCardObject) NIL)))


					       (AND CallCloseWFlg Window (CLOSEW Window))
					       (OR Don'tDeactivateFlg (NC.DeactivateCard Card))

          (* * if this is one of the top level cards, then make sure it stays cached)


					       (if (AND (NC.TopLevelCardP Card)
							    (NULL DontRecacheFlg)
							    (NULL Don'tDeactivateFlg))
						   then (NCP.ActivateCards Card))))))))))
)
(PUTPROPS PMIPATCH065 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (828 6860 (NC.QuitCard 838 . 6858)))))
STOP