(FILECREATED " 8-Dec-86 19:24:31" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH163.;4 11655  

      changes to:  (FNS NC.ChooseTopLevelCard NCP.AddSpecialCard)

      previous date: "20-Nov-86 15:18:15" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH163.;1)


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

(PRETTYCOMPRINT RHTPATCH163COMS)

(RPAQQ RHTPATCH163COMS ((* * This stuff is so that users can add entries to the "ShowBox" entry on 
			     the notefile menu. Also renamed "ShowBox" to be "ShowCards")
			  (* * New functions for NCPROGINT)
			  (FNS NCP.AddSpecialCard NCP.RemoveSpecialCard)
			  (* * Changes for NCINTERFACE)
			  (FNS NC.ChooseTopLevelCard NC.SetUpNoteFileInterface 
			       NC.NoteFileMenuWhenSelectedFn)))
(* * This stuff is so that users can add entries to the "ShowBox" entry on the notefile menu. 
Also renamed "ShowBox" to be "ShowCards")

(* * New functions for NCPROGINT)

(DEFINEQ

(NCP.AddSpecialCard
  (LAMBDA (Card)                                             (* rht: "23-Nov-86 13:33")

          (* * Adds this card to list of special cards hung off notefile's "SpecialCards" user data prop unless it's already 
	  there.)


    (LET ((NoteFile (NCP.CardNoteFile Card)))
         (if (for SpecialCard in (NCP.NoteFileProp NoteFile (QUOTE SpecialCards))
		  never (NCP.SameCardP Card SpecialCard))
	     then (NC.NoteFileAddProp NoteFile (QUOTE SpecialCards)
					  Card)))))

(NCP.RemoveSpecialCard
  (LAMBDA (Card)                                             (* rht: "20-Nov-86 15:07")

          (* * Removes this card from list of special cards hung off notefile's "SpecialCards" user data prop.)


    (NC.NoteFileDelProp (fetch (Card NoteFile) of Card)
			  (QUOTE SpecialCards)
			  Card
			  (FUNCTION NC.SameCardP))))
)
(* * Changes for NCINTERFACE)

(DEFINEQ

(NC.ChooseTopLevelCard
  (LAMBDA (NoteFile)                                         (* rht: " 8-Dec-86 19:10")

          (* Let the user choose one of the top level cards. Top level cards are specified by globalvar NC.TopLevelCards 
	  which is a list of IDs)



          (* * fgh 11/14/85 Updated to handle NoteFile object and per NoteFile menus.)



          (* * kirk 6May86 Deleted SETQ of undeclared Menu var in the last expression)



          (* * rht 11/20/86: Now looks on "SpecialCards" prop of notefile for other cards to make available from ShowCards 
	  menu.)


    (LET ((NoteFileMenu (fetch (NoteFile Menu) of NoteFile))
	  Menu W Z)
         (SETQ Menu (create MENU
				ITEMS ←(for Card in (APPEND (NC.FetchTopLevelCards NoteFile)
								  (NC.NoteFileProp NoteFile
										     (QUOTE 
										     SpecialCards)))
					  when (NC.ValidCardP Card) collect
									 (LIST (NC.RetrieveTitle
										   Card)
										 Card))
				CENTERFLG ← T
				MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
							10
							(QUOTE BOLD))
				WHENSELECTEDFN ←(FUNCTION (LAMBDA (Item Button Menu)
				    (NC.EditNoteCard (CADR Item))))))
         (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NoteFileMenu)
						   2))
				     NoteFileMenu))
         (SETQ Z (WINDOWPROP (WFROMMENU NoteFileMenu)
				 (QUOTE REGION)))
         (replace (MENU MENUPOSITION) of Menu with (create
							     POSITION
							     XCOORD ←(IPLUS (fetch (REGION LEFT)
										 of W)
									      (fetch (REGION LEFT)
										 of Z))
							     YCOORD ←(IPLUS
							       (fetch (REGION TOP) of W)
							       (fetch (REGION BOTTOM) of Z)
							       (IMINUS (fetch (MENU IMAGEHEIGHT)
									    of Menu)))))
         (MENU Menu))))

(NC.SetUpNoteFileInterface
  (LAMBDA (NoteFile Position)                                (* rht: "20-Nov-86 15:17")

          (* * 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.)


    (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)))
         (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))))

(NC.NoteFileMenuWhenSelectedFn
  (LAMBDA (Item Menu Button)                                 (* rht: "20-Nov-86 15:17")
                                                             (* Function called when one of the items in the top 
							     level menu is chosen.)

          (* * fgh 11/14/85 Updated to handle NoteFile object and per NoteFile menus.)



          (* * kirk 18Jun86 Adopted to new smaller NoteFile icon)



          (* * fgh 6/26/86 Added lock to prevent conflicting operations.)



          (* * rht 7/5/86: Now greys NewCards menu item if readonly notefile.)



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


    (LET ((Window (WFROMMENU Menu))
	  NoteFile)
         (SETQ NoteFile (WINDOWPROP Window (QUOTE NoteFile)))
         (RESETLST (RESETSAVE (SHADEITEM Item Menu GRAYSHADE)
				  (LIST (QUOTE SHADEITEM)
					  Item Menu (if (AND (EQ (CAR Item)
								       (QUOTE NewCards))
								 (NC.ReadOnlyNoteFileP NoteFile))
							then GRAYSHADE
						      else WHITESHADE)))
		     (if (NULL (NC.NoteFileOpenP NoteFile))
			 then (NC.PrintMsg Window T "Can't." (CHARACTER 13)
					       (fetch (NoteFile FullFileName) of NoteFile)
					       " is not open."
					       (CHARACTER 13))
		       elseif (PROCESSP (NC.NoteFileProp NoteFile (QUOTE ProcessInProgress)))
			 then (NC.PrintOperationInProgressMsg Window (CAR Item)
								  (NC.NoteFileProp NoteFile
										     (QUOTE 
									      OperationInProgress)))
				NIL
		       else (SELECTQ (CAR Item)
					 (NewCards (COND
						     ((EQ Button (QUOTE LEFT))
						       (NC.MakeNoteCard NC.DefaultCardType NoteFile)
						       )
						     (T (NC.MakeNoteCard NIL NoteFile))))
					 (ShowCards (COND
						      ((EQ Button (QUOTE LEFT))
							(NC.EditNoteCard (fetch (NoteFile 
									      TableOfContentsCard)
									      of NoteFile)))
						      (T (NC.ChooseTopLevelCard NoteFile))))
					 NIL))))))
)
(PUTPROPS RHTPATCH163 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (926 1878 (NCP.AddSpecialCard 936 . 1493) (NCP.RemoveSpecialCard 1495 . 1876)) (1915 
11573 (NC.ChooseTopLevelCard 1925 . 3910) (NC.SetUpNoteFileInterface 3912 . 9395) (
NC.NoteFileMenuWhenSelectedFn 9397 . 11571)))))
STOP