(FILECREATED "10-Dec-84 17:37:49" {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCCHAIN.;7 7907   

      changes to:  (VARS NCCHAINCOMS)

      previous date: " 2-Dec-84 13:23:53" {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCCHAIN.;6)


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

(PRETTYCOMPRINT NCCHAINCOMS)

(RPAQQ NCCHAINCOMS ((FNS CHAIN.MakeChain CHAIN.AddChainMenuItem CHAIN.EditCardFn CHAIN.MakeCardFn 
			 CHAIN.PlaceNewChainCard CHAIN.AddMakeChainProcess)
		    (P (OR (NCP.ValidCardType (QUOTE Chain))
			   (NCP.CreateCardType (QUOTE Chain)
					       (QUOTE Text)
					       (QUOTE TEXT)
					       (QUOTE CHAIN.MakeCardFn)
					       (QUOTE CHAIN.EditCardFn))))
		    (P (PRINTOUT T "Loading {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCSCREEN.DCOM" T)
		       (IF (NOT (LOAD? (QUOTE {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCSCREEN.DCOM)))
			   THEN
			   (PRINTOUT T "Already Loaded" T)))))
(DEFINEQ

(CHAIN.MakeChain
  (LAMBDA (Window)                                           (* rht: " 1-Dec-84 17:08")

          (* * comment)


    (PROG (ID CardTitle Menu ChainCards ChainWindows (ChainNum 0)
	      (Font (FONTCREATE (QUOTE HELVETICA)
				12
				(QUOTE BOLD)))
	      (TitleFont (FONTCREATE (QUOTE HELVETICA)
				     10
				     (QUOTE BOLD))))
          (OR (NCP.ValidLinkLabel (QUOTE ChainNext))
	      (NCP.CreateLinkLabel (QUOTE ChainNext)))
          (OR (NCP.ValidLinkLabel (QUOTE ChainPrevious))
	      (NCP.CreateLinkLabel (QUOTE ChainPrevious)))
          (OR (NCP.ValidLinkLabel (QUOTE ChainElement))
	      (NCP.CreateLinkLabel (QUOTE ChainElement)))
          (SETQ ID (NCP.WhichCard Window))
          (SETQ CardTitle (NCP.CardTitle ID))
          (SETQ Menu (create MENU
			     ITEMS ←(QUOTE ((NextChainCard (QUOTE NextChainCard)
							   "Bring up next card in chain.")
					     (Done (QUOTE Done)
						   "Indicates that this operation is completed.")))
			     TITLE ← "Creating Chain Cards"
			     CENTERFLG ← T
			     MENUCOLUMNS ← 2
			     MENUFONT ← Font
			     ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			     MENUTITLEFONT ← TitleFont
			     MENUPOSITION ←(SCREEN.WinULCorner Window)))
          (for bind MenuResult ChainCard PreviousChainCard
	     do (SELECTQ (MENU Menu NIL T)
			 (NextChainCard (NCP.PrintMsg Window T 
						      "Move or copy text into the chain card.")
					(SETQ ChainNum (ADD1 ChainNum))
					(SETQ ChainCard (NCP.CreateTextCard (CONCAT CardTitle ": #" 
										    ChainNum)
									    T NIL NIL))
					(push ChainCards ChainCard)
					(push ChainWindows (CHAIN.PlaceNewChainCard ChainCard Window 
										    ChainWindows))
                                                             (* Build links to previous chain card and from head 
							     card.)
					(if PreviousChainCard
					    then (NCP.LocalGlobalLink (QUOTE ChainNext)
								      PreviousChainCard ChainCard
								      (QUOTE END)
								      (QUOTE Label))
						 (NCP.LocalGlobalLink (QUOTE ChainPrevious)
								      ChainCard PreviousChainCard
								      (QUOTE START)
								      (QUOTE Label))
						 (NCP.CardAddText ChainCard (CHARACTER 13))
					  else (NCP.LocalGlobalLink (QUOTE ChainPrevious)
								    ChainCard ID (QUOTE START)
								    (QUOTE Label))
					       (NCP.CardAddText ChainCard (CHARACTER 13)))
					(NCP.LocalGlobalLink (QUOTE ChainElement)
							     ID ChainCard (QUOTE END)
							     (QUOTE Title))
					(SETQ PreviousChainCard ChainCard))
			 (Done (if PreviousChainCard
				   then (NCP.LocalGlobalLink (QUOTE ChainNext)
							     PreviousChainCard ID (QUOTE END)
							     (QUOTE Label)))
			       (NCP.ClearMsg Window T)
			       (RETURN NIL))
			 NIL)))))

(CHAIN.AddChainMenuItem
  (LAMBDA (Window)                                           (* rht: " 1-Dec-84 16:55")

          (* * Add the chain menu item to the left button menu of Window.)


    (PROG ((MenuItems (fetch (MENU ITEMS) of (WINDOWPROP Window (QUOTE NoteCardsLeftButtonMenu)))))
          (replace (MENU ITEMS) of (WINDOWPROP Window (QUOTE NoteCardsLeftButtonMenu))
	     with (APPEND MenuItems (LIST (LIST (QUOTE Make% Chain)
						(QUOTE (FUNCTION CHAIN.AddMakeChainProcess))
						"Construct a chain of cards from this card.")))))))

(CHAIN.EditCardFn
  (LAMBDA (ID Substance Region/Position)                     (* rht: "26-Nov-84 12:46")

          (* * Bring up the card, but in addition, add the chain item to the left button menu.)


    (PROG (Window)
          (SETQ Window (APPLY* (NCP.CardTypeInheritedFn (QUOTE Text)
							(QUOTE EditCardFn))
			       ID Substance Region/Position))
          (CHAIN.AddChainMenuItem Window)
          (RETURN Window))))

(CHAIN.MakeCardFn
  (LAMBDA (ID Title NoDisplayFlg)                            (* rht: "28-Nov-84 11:34")

          (* * The MakeCardFn for a Chain notecard. It simply builds a standard text card and then adds an item to the 
	  left-button menu.)


    (PROG (Window)
          (OR Title (SETQ Title (NC.AskUser (CONCAT "Title of " (NCP.CardType ID)
						    " card? ")
					    "-- " NIL T NIL T)))
          (NCP.CardTitle ID Title)
          (SETQ Window (WINDOWP (APPLY* (NCP.CardTypeInheritedFn (QUOTE Text)
								 (QUOTE MakeCardFn))
					ID Title NoDisplayFlg)))
          (AND Window (CHAIN.AddChainMenuItem Window))
          (RETURN (OR Window ID)))))

(CHAIN.PlaceNewChainCard
  (LAMBDA (ChainCard HeadWin ChainWins)                      (* rht: " 1-Dec-84 16:39")

          (* * Bring up and place the new ChainCard someplace appropriate relative to the head of the chain, HeadWin, and the 
	  previous chain windows, ChainWins.)


    (PROG (PreviousChainWin)
          (SCREEN.MoveCardToPos ChainCard (if (AND (SETQ PreviousChainWin (CAR ChainWins))
						   (OPENWP PreviousChainWin))
					      then (SCREEN.WinLLCorner PreviousChainWin)
					    else (SCREEN.WinURCorner HeadWin)))
          (RETURN (NCP.CardWindow ChainCard)))))

(CHAIN.AddMakeChainProcess
  (LAMBDA (WindowOrTextStream)                               (* rht: " 1-Dec-84 17:10")

          (* * Forks a process to run the CHAIN.MakeChain function. Hooks a closefn onto window to kill process if window 
	  closes before process returns.)


    (PROG (Window)
          (SETQ Window (if (WINDOWP WindowOrTextStream)
			   then WindowOrTextStream
			 else (WINDOW.FROM.TEDIT.THING WindowOrTextStream)))
          (WINDOWADDPROP Window (QUOTE DependentProcHandles)
			 (ADD.PROCESS (BQUOTE (CHAIN.MakeChain , Window))))
          (WINDOWADDPROP Window (QUOTE CLOSEFN)
			 (FUNCTION (LAMBDA (Window)
			     (for ProcHandle in (WINDOWPROP Window (QUOTE DependentProcHandles))
				do (AND (PROCESSP ProcHandle)
					(DEL.PROCESS ProcHandle)))))))))
)
(OR (NCP.ValidCardType (QUOTE Chain))
    (NCP.CreateCardType (QUOTE Chain)
			(QUOTE Text)
			(QUOTE TEXT)
			(QUOTE CHAIN.MakeCardFn)
			(QUOTE CHAIN.EditCardFn)))
(PRINTOUT T "Loading {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCSCREEN.DCOM" T)
(IF (NOT (LOAD? (QUOTE {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCSCREEN.DCOM)))
    THEN
    (PRINTOUT T "Already Loaded" T))
(PUTPROPS NCCHAIN COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (926 7462 (CHAIN.MakeChain 936 . 4055) (CHAIN.AddChainMenuItem 4057 . 4687) (
CHAIN.EditCardFn 4689 . 5164) (CHAIN.MakeCardFn 5166 . 5916) (CHAIN.PlaceNewChainCard 5918 . 6571) (
CHAIN.AddMakeChainProcess 6573 . 7460)))))
STOP