(FILECREATED " 3-Jan-85 23:51:14" {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCCLUSTER.;13 18913  

      changes to:  (FNS CLUSTER.CaseCluster.MakeCardFn CLUSTER.Cluster.MakeCardFn 
			CLUSTER.Cluster.QuitCardFn CLUSTER.Rationale.MakeCardFn 
			CLUSTER.Argument.MakeCardFn CLUSTER.Cluster.EditCardFn 
			CLUSTER.LayoutClusterChildren)
		   (VARS NCCLUSTERCOMS)

      previous date: " 3-Jan-85 03:00:15" {PHYLUM}<NOTECARDS>RELEASE1.1>LIBRARY>NCCLUSTER.;11)


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

(PRETTYCOMPRINT NCCLUSTERCOMS)

(RPAQQ NCCLUSTERCOMS ((* Fns for the Cluster notecard type.)
		      (FNS CLUSTER.Cluster.MakeCardFn CLUSTER.Cluster.EditCardFn 
			   CLUSTER.Cluster.QuitCardFn CLUSTER.RegroupClusterCards 
			   CLUSTER.AddClusterMenuItem CLUSTER.LayoutClusterChildren)
		      (* Fns for the CaseCluster notecard type.)
		      (FNS CLUSTER.CaseCluster.MakeCardFn)
		      (* Makefns for the other notecard types.)
		      (FNS CLUSTER.Facts.MakeCardFn CLUSTER.Rationale.MakeCardFn 
			   CLUSTER.Argument.MakeCardFn)
		      (P (OR (NCP.ValidCardType (QUOTE Cluster))
			     (NCP.CreateCardType (QUOTE Cluster)
						 (QUOTE Text)
						 (QUOTE TEXT)
						 (QUOTE CLUSTER.Cluster.MakeCardFn)
						 (QUOTE CLUSTER.Cluster.EditCardFn)
						 (QUOTE CLUSTER.Cluster.QuitCardFn)
						 NIL NIL NIL NIL NIL NIL NIL NIL (QUOTE Both))))
		      (P (OR (NCP.ValidCardType (QUOTE CaseCluster))
			     (NCP.CreateCardType (QUOTE CaseCluster)
						 (QUOTE Cluster)
						 (QUOTE TEXT)
						 (QUOTE CLUSTER.CaseCluster.MakeCardFn))))
		      (P (OR (NCP.ValidCardType (QUOTE Facts))
			     (NCP.CreateCardType (QUOTE Facts)
						 (QUOTE Text)
						 (QUOTE TEXT)
						 (QUOTE CLUSTER.Facts.MakeCardFn))))
		      (P (OR (NCP.ValidCardType (QUOTE Rationale))
			     (NCP.CreateCardType (QUOTE Rationale)
						 (QUOTE Text)
						 (QUOTE TEXT)
						 (QUOTE CLUSTER.Rationale.MakeCardFn))))
		      (P (OR (NCP.ValidCardType (QUOTE Argument))
			     (NCP.CreateCardType (QUOTE Argument)
						 (QUOTE Browser)
						 (QUOTE GRAPH)
						 (QUOTE CLUSTER.Argument.MakeCardFn))))
		      (VARS (CLUSTER.TypesAndLinkLabelsAndStrings (QUOTE ((Text issues Issues)
									  (Facts facts)
									  (Text decision Decision)
									  (Rationale rationale))))
			    (CLUSTER.FileBoxNames (QUOTE (CasesBox IssuesBox FactsBox DecisionsBox 
								   RationalesBox)))
			    (CLUSTER.ArgumentCardHeight 150)
			    (CLUSTER.ArgumentCardWidth 600))
		      (GLOBALVARS CLUSTER.TypesAndLinkLabelsAndStrings CLUSTER.FileBoxNames 
				  CLUSTER.ArgumentCardHeight CLUSTER.ArgumentCardWidth)
		      (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)))))



(* Fns for the Cluster notecard type.)

(DEFINEQ

(CLUSTER.Cluster.MakeCardFn
  (LAMBDA (ID Title NoDisplayFlg ChildInfos FileBoxes)       (* rht: " 3-Jan-85 20:36")

          (* * Create a cluster with head card ID and one child card for each element of ChildInfos. The elements of 
	  ChildInfos are three-element lists with CAR being the child's type, CADR being the label of the link we'll make to 
	  it, and CADDR being the string to concatenate with the head card's title to make the child's title.
	  If no CADDR then use CAR.)



          (* * rht 1/2/85: No longer shrinks head cluster card. Files new cards in boxes taken from FileBoxes.
	  Creates necessary new links if non-extant.)


    (PROG (ChildIDs Window Region)
          (OR Title (SETQ Title (NCP.AskUser (CONCAT "Title of " (NCP.CardType ID)
						     " card? ")
					     "-- " NIL T NIL T)))
          (SETQ Window (WINDOWP (APPLY* (NCP.CardTypeInheritedFn (QUOTE Text)
								 (QUOTE MakeCardFn))
					ID Title NoDisplayFlg)))
          (NCP.CardTitle ID Title)
          (AND (CAR FileBoxes)
	       (NCP.FileCards ID (CAR FileBoxes)))
          (SETQ ChildIDs (for ChildInfo in ChildInfos as Box in (CDR FileBoxes) bind ChildID 
										     LinkLabel
			    collect (SETQ ChildID (NCP.CreateCard (CAR ChildInfo)
								  (CONCAT Title ": "
									  (OR (CADDR ChildInfo)
									      (CAR ChildInfo)))
								  T NIL NIL))
				    (AND Box (NCP.FileCards ChildID Box))
				    (OR (NCP.ValidLinkLabel (SETQ LinkLabel (CADR ChildInfo)))
					(NCP.CreateLinkLabel LinkLabel))
				    (NCP.LocalGlobalLink LinkLabel ID ChildID NIL (QUOTE Title))
				    (NCP.CardAddText ID (CHARACTER 13))
				    ChildID))
          (NCP.CardProp ID (QUOTE ClusterChildren)
			ChildIDs)
          (if (NOT NoDisplayFlg)
	      then (SETQ Region (WINDOWPROP Window (QUOTE REGION)))
		   (SCREEN.LayoutCardsInSquare (create POSITION
						       XCOORD ←(fetch (POSITION XCOORD)
								  of (SCREEN.WinULCorner Window))
						       YCOORD ←(IDIFFERENCE
							 (IPLUS (fetch (REGION HEIGHT) of Region)
								(fetch (REGION BOTTOM) of Region))
							 (IPLUS (FONTPROP WindowTitleDisplayStream
									  (QUOTE HEIGHT))
								SCREEN.CascadeYSpace)))
					       ChildIDs))
          (AND Window (CLUSTER.AddClusterMenuItem Window))
          (RETURN (OR Window ID)))))

(CLUSTER.Cluster.EditCardFn
  (LAMBDA (ID Substance Region/Position)                     (* rht: " 3-Jan-85 19:55")

          (* * Bring up a cluster card. This causes head card to be shrunken and all child cards to come up cascaded below 
	  it.)



          (* * rht 1/2/85: No longer shrinks header card.)


    (PROG (Window)
          (SETQ Window (APPLY* (NCP.CardTypeInheritedFn (QUOTE Text)
							(QUOTE EditCardFn))
			       ID Substance Region/Position))
          (SCREEN.LayoutCardsInCascade (SCREEN.GetCascadePosition Window)
				       (REVERSE (NCP.CardProp ID (QUOTE ClusterChildren))))
          (RETURN Window))))

(CLUSTER.Cluster.QuitCardFn
  (LAMBDA (IDOrWindow)                                       (* rht: " 3-Jan-85 20:30")

          (* * Close up a cluster card by first expanding it, then closing all children, then closing the head cluster card.)


    (PROG ((ID (if (WINDOWP IDOrWindow)
		   then (NCP.CardFromWindow (EXPANDW IDOrWindow))
		 else (EXPANDW (NCP.CardWindow IDOrWindow))
		      IDOrWindow)))
          (for Card in (NCP.CardProp ID (QUOTE ClusterChildren)) when (NCP.ValidCard Card)
	     do (NCP.DeactivateCards Card))
          (RETURN (APPLY* (NCP.CardTypeInheritedFn (QUOTE Text)
						   (QUOTE QuitCardFn))
			  ID)))))

(CLUSTER.RegroupClusterCards
  (LAMBDA (ClusterCard)                                      (* rht: " 3-Jan-85 00:02")

          (* * Shrink ClusterCard and pull the children of ClusterCard over under it.)



          (* * rht 1/2/85: No longer shrinks header card.)


    (PROG (Window)
          (if (SETQ Window (NCP.CardWindow ClusterCard))
	      then (SCREEN.LayoutCardsInCascade (SCREEN.WinULCorner Window)
						(CONS ClusterCard (REVERSE (NCP.CardProp
									     ClusterCard
									     (QUOTE ClusterChildren)))
						      ))
	    else (NCP.BringUpCard ClusterCard)))))

(CLUSTER.AddClusterMenuItem
  (LAMBDA (Window)                                           (* rht: " 3-Jan-85 00:45")

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


    (NCP.AddTitleBarMenuItems Window (LIST (LIST (QUOTE Layout% Cluster% Children)
						 (QUOTE (FUNCTION CLUSTER.LayoutClusterChildren))
						 "Regroup and layout the elements of this cluster.")))
    ))

(CLUSTER.LayoutClusterChildren
  (LAMBDA (WindowOrTextStream)                               (* rht: " 3-Jan-85 19:56")

          (* * Regroups and lays out the cluster children in some format.)


    (PROG (Window Card Region)
          (SETQ Window (if (WINDOWP WindowOrTextStream)
			   then WindowOrTextStream
			 else (WINDOW.FROM.TEDIT.THING WindowOrTextStream)))
          (SETQ Card (NCP.CardFromWindow Window))
          (SELECTQ (MENU (create MENU
				 ITEMS ←(QUOTE (Layout% In% Square Layout% In% Cascade))))
		   (Layout% In% Square (SETQ Region (WINDOWPROP Window (QUOTE REGION)))
				       (SCREEN.LayoutCardsInSquare
					 (create POSITION
						 XCOORD ←(fetch (POSITION XCOORD)
							    of (SCREEN.WinULCorner Window))
						 YCOORD ←(IDIFFERENCE (IPLUS (fetch (REGION HEIGHT)
										of Region)
									     (fetch (REGION BOTTOM)
										of Region))
								      (IPLUS (FONTPROP 
									 WindowTitleDisplayStream
										       (QUOTE HEIGHT))
									     SCREEN.CascadeYSpace)))
					 (NCP.CardProp Card (QUOTE ClusterChildren))))
		   (Layout% In% Cascade (SCREEN.LayoutCardsInCascade (SCREEN.GetCascadePosition
								       Window)
								     (REVERSE (NCP.CardProp
										Card
										(QUOTE 
										  ClusterChildren)))))
		   NIL))))
)



(* Fns for the CaseCluster notecard type.)

(DEFINEQ

(CLUSTER.CaseCluster.MakeCardFn
  (LAMBDA (ID Title NoDisplayFlg)                            (* rht: " 3-Jan-85 20:17")

          (* * Create a case cluster card. Done by passing proper info triples through to Cluster's MakeCardFn.)



          (* * rht 1/2/85: Now also passes to the cluster makecardfn a list of fileboxes to file the cluster children in.
	  The method of searching for fileboxes is klugey. We need to invent a new I.S.opr for "for" to do this.)


    (PROG (FileBoxes)
          (OR Title (SETQ Title (NCP.AskUser (CONCAT "Title of " (NCP.CardType ID)
						     " card? ")
					     "-- " NIL T NIL T)))
          (SETQ FileBoxes (for ID# from 1 to (NCP.MaxIDNum) bind ID Match (FileBoxNames ←(COPY 
									     CLUSTER.FileBoxNames))
								 (NumFileBoxes ←(LENGTH 
									     CLUSTER.FileBoxNames))
			     when (AND (NCP.ValidID (SETQ ID (NC.IDFromNumber ID#)))
				       (NCP.FileBoxP ID)
				       (SETQ Match (FMEMB (MKATOM (NCP.CardTitle ID))
							  FileBoxNames)))
			     do (DSUBST ID (CAR Match)
					FileBoxNames)
				(AND (ZEROP (SETQ NumFileBoxes (SUB1 NumFileBoxes)))
				     (RETURN FileBoxNames))
			     finally (RETURN FileBoxNames)))
          (RETURN (APPLY* (NCP.CardTypeFn (QUOTE Cluster)
					  (QUOTE MakeCardFn))
			  ID Title NoDisplayFlg CLUSTER.TypesAndLinkLabelsAndStrings
			  (for Box in FileBoxes
			     collect (if (NCP.ValidID Box)
					 then Box
				       else (AND (FMEMB (MKATOM (NCP.AskUser (CONCAT 
							 "Want to create new filebox with name '"
										     Box "'? ")
									     "--" NIL T))
							(QUOTE (y Y yes Yes YES)))
						 (NCP.CreateFileBox Box T NIL NIL (
								      NCP.GetContentsFileBox))))))))))
)



(* Makefns for the other notecard types.)

(DEFINEQ

(CLUSTER.Facts.MakeCardFn
  (LAMBDA (ID Title NoDisplayFlg)                            (* rht: " 7-Nov-84 19:42")

          (* * Create a Facts card. Just like a Text card except throws in some initial text.)


    (PROG (ReturnValue)
          (SETQ ReturnValue (APPLY* (NCP.CardTypeFn (QUOTE Text)
						    (QUOTE MakeCardFn))
				    ID Title NoDisplayFlg))
          (NCP.CardAddText ID (CONCAT "LEGAL FACTS" (CHARACTER 13)
				      (CHARACTER 13)
				      (CHARACTER 13)
				      "REAL FACTS"
				      (CHARACTER 13)
				      (CHARACTER 13)))
          (RETURN ReturnValue))))

(CLUSTER.Rationale.MakeCardFn
  (LAMBDA (ID Title NoDisplayFlg)                            (* rht: " 3-Jan-85 20:35")

          (* * Create a Rationale card. Just like a text card except starts with an initial link to a fresh Argument card.)


    (PROG (ReturnValue)
          (SETQ ReturnValue (APPLY* (NCP.CardTypeFn (QUOTE Text)
						    (QUOTE MakeCardFn))
				    ID Title NoDisplayFlg))
          (OR (NCP.ValidLinkLabel (QUOTE Argument))
	      (NCP.CreateLinkLabel (QUOTE Argument)))
          (NCP.LocalGlobalLink (QUOTE Argument)
			       ID
			       (NCP.CreateCard (QUOTE Argument)
					       (CONCAT Title ":Argument1")
					       T)
			       NIL
			       (QUOTE Title))
          (RETURN ReturnValue))))

(CLUSTER.Argument.MakeCardFn
  (LAMBDA (ID Title NoDisplayFlg)                            (* rht: " 3-Jan-85 23:41")

          (* * Create an Argument card. Just like a Browser card except builds some initial structure.)


    (PROG (DecisionRuleCard RuleSupportCard1 RuleSupportCard2 LegalStatusRuleCard)
          (OR (NCP.ValidLinkLabel (QUOTE Support))
	      (NCP.CreateLinkLabel (QUOTE Support)))
          (OR (NCP.ValidLinkLabel (QUOTE Status))
	      (NCP.CreateLinkLabel (QUOTE Status)))
          (SETQ DecisionRuleCard (NCP.CreateTextCard (CONCAT Title ":" "Decision-Rule")
						     T))
          (SETQ RuleSupportCard1 (NCP.CreateTextCard (CONCAT Title ":" "Rule-Support")
						     T))
          (SETQ RuleSupportCard2 (NCP.CreateTextCard (CONCAT Title ":" "Legal-Status-Rule" ":" 
							     "Rule-Support")
						     T))
          (SETQ LegalStatusRuleCard (NCP.CreateTextCard (CONCAT Title ":" "Legal-Status-Rule")
							T))
          (NCP.CardAddText DecisionRuleCard (CONCAT "LEGAL CONTEXT" (CHARACTER 13)))
          (NCP.LocalGlobalLink (QUOTE Status)
			       DecisionRuleCard LegalStatusRuleCard NIL (QUOTE Title))
          (NCP.CardAddText DecisionRuleCard (CONCAT (CHARACTER 13)
						    (CHARACTER 13)
						    "OPERATIVE FACTS"
						    (CHARACTER 13)
						    (CHARACTER 13)
						    "DECISION"
						    (CHARACTER 13)
						    (CHARACTER 13)
						    "SUPPORT"
						    (CHARACTER 13)))
          (NCP.LocalGlobalLink (QUOTE Support)
			       DecisionRuleCard RuleSupportCard1 NIL (QUOTE Title))
          (NCP.CardAddText DecisionRuleCard (CONCAT (CHARACTER 13)))
          (NCP.CardAddText LegalStatusRuleCard (CONCAT "LEGAL CONTEXT" (CHARACTER 13)
						       (CHARACTER 13)
						       "OPERATIVE FACTS"
						       (CHARACTER 13)
						       (CHARACTER 13)
						       "LEGAL STATUS"
						       (CHARACTER 13)
						       (CHARACTER 13)
						       "SUPPORT"
						       (CHARACTER 13)))
          (NCP.LocalGlobalLink (QUOTE Support)
			       LegalStatusRuleCard RuleSupportCard2 NIL (QUOTE Title))
          (NCP.CardAddText LegalStatusRuleCard (CONCAT (CHARACTER 13)))
          (NCP.CardAddText RuleSupportCard1 (CONCAT "PRINCIPLE" (CHARACTER 13)
						    (CHARACTER 13)
						    "REFERENCE"
						    (CHARACTER 13)
						    (CHARACTER 13)
						    "STATUTE"
						    (CHARACTER 13)
						    (CHARACTER 13)
						    "CASE PRECEDENT"
						    (CHARACTER 13)
						    (CHARACTER 13)))
          (NCP.CardAddText RuleSupportCard2 (CONCAT "PRINCIPLE" (CHARACTER 13)
						    (CHARACTER 13)
						    "REFERENCE"
						    (CHARACTER 13)
						    (CHARACTER 13)
						    "STATUTE"
						    (CHARACTER 13)
						    (CHARACTER 13)
						    "CASE PRECEDENT"
						    (CHARACTER 13)
						    (CHARACTER 13)))
          (SETQ WindowOrID (APPLY* (NCP.CardTypeFn (QUOTE Browser)
						   (QUOTE MakeCardFn))
				   ID Title NoDisplayFlg (LIST DecisionRuleCard (QUOTE (Support
											 Status)))))
          (if (WINDOWP WindowOrID)
	      then (SETQ Region (WINDOWPROP WindowOrID (QUOTE REGION)))
		   (SHAPEW WindowOrID (create REGION
					      HEIGHT ← CLUSTER.ArgumentCardHeight
					      WIDTH ← CLUSTER.ArgumentCardWidth
					      LEFT ←(fetch (REGION LEFT) of Region)
					      BOTTOM ←(IPLUS (fetch (REGION BOTTOM) of Region)
							     (IDIFFERENCE (fetch (REGION HEIGHT)
									     of Region)
									  CLUSTER.ArgumentCardHeight))
					      ))
		   (SCROLLBYREPAINTFN WindowOrID 0.0 0.0)
	    else (NC.SetRegion WindowOrID
			       (create REGION
				       HEIGHT ← CLUSTER.ArgumentCardHeight
				       WIDTH ← CLUSTER.ArgumentCardWidth
				       LEFT ← 0
				       BOTTOM ← 0)))
          (RETURN WindowOrID))))
)
(OR (NCP.ValidCardType (QUOTE Cluster))
    (NCP.CreateCardType (QUOTE Cluster)
			(QUOTE Text)
			(QUOTE TEXT)
			(QUOTE CLUSTER.Cluster.MakeCardFn)
			(QUOTE CLUSTER.Cluster.EditCardFn)
			(QUOTE CLUSTER.Cluster.QuitCardFn)
			NIL NIL NIL NIL NIL NIL NIL NIL (QUOTE Both)))
(OR (NCP.ValidCardType (QUOTE CaseCluster))
    (NCP.CreateCardType (QUOTE CaseCluster)
			(QUOTE Cluster)
			(QUOTE TEXT)
			(QUOTE CLUSTER.CaseCluster.MakeCardFn)))
(OR (NCP.ValidCardType (QUOTE Facts))
    (NCP.CreateCardType (QUOTE Facts)
			(QUOTE Text)
			(QUOTE TEXT)
			(QUOTE CLUSTER.Facts.MakeCardFn)))
(OR (NCP.ValidCardType (QUOTE Rationale))
    (NCP.CreateCardType (QUOTE Rationale)
			(QUOTE Text)
			(QUOTE TEXT)
			(QUOTE CLUSTER.Rationale.MakeCardFn)))
(OR (NCP.ValidCardType (QUOTE Argument))
    (NCP.CreateCardType (QUOTE Argument)
			(QUOTE Browser)
			(QUOTE GRAPH)
			(QUOTE CLUSTER.Argument.MakeCardFn)))

(RPAQQ CLUSTER.TypesAndLinkLabelsAndStrings ((Text issues Issues)
					     (Facts facts)
					     (Text decision Decision)
					     (Rationale rationale)))

(RPAQQ CLUSTER.FileBoxNames (CasesBox IssuesBox FactsBox DecisionsBox RationalesBox))

(RPAQQ CLUSTER.ArgumentCardHeight 150)

(RPAQQ CLUSTER.ArgumentCardWidth 600)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS CLUSTER.TypesAndLinkLabelsAndStrings CLUSTER.FileBoxNames CLUSTER.ArgumentCardHeight 
	    CLUSTER.ArgumentCardWidth)
)
(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 NCCLUSTER COPYRIGHT ("Xerox Corporation" 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2910 9523 (CLUSTER.Cluster.MakeCardFn 2920 . 5528) (CLUSTER.Cluster.EditCardFn 5530 . 
6233) (CLUSTER.Cluster.QuitCardFn 6235 . 6973) (CLUSTER.RegroupClusterCards 6975 . 7628) (
CLUSTER.AddClusterMenuItem 7630 . 8068) (CLUSTER.LayoutClusterChildren 8070 . 9521)) (9575 11525 (
CLUSTER.CaseCluster.MakeCardFn 9585 . 11523)) (11576 17212 (CLUSTER.Facts.MakeCardFn 11586 . 12242) (
CLUSTER.Rationale.MakeCardFn 12244 . 13054) (CLUSTER.Argument.MakeCardFn 13056 . 17210)))))
STOP