(FILECREATED "26-Mar-86 16:36:02" {QV}<NOTECARDS>1.3K>RHTPATCH034.;4 61338  

      changes to:  (FNS NC.BrowserFixGraphEditMenuFn NC.MakeLinksLegendMenu 
			NC.RedrawBrowserOverviewWin NC.GetGraphEditMenu NC.UpdateBrowserCard 
			NC.ReattachBrowserOverviewWin NC.DrawArrowHead NC.DrawFlowerLink 
			NC.MakeBrowserOverviewWin NC.ShrinkGraphToWindow NC.ScaleGraphNode 
			NC.ComputeOverviewScale NC.DrawWireFrameInOverviewWin 
			NC.BrowserOverviewWinMINSIZEFn NC.BrowserOverviewWinButtonEventFn)
		   (VARS RHTPATCH034COMS)

      previous date: "26-Mar-86 15:34:31" {QV}<NOTECARDS>1.3K>RHTPATCH034.;1)


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

(PRETTYCOMPRINT RHTPATCH034COMS)

(RPAQQ RHTPATCH034COMS ((* * These fixes bring 1.3k browser overviews up to date with 
			     <notecards>1.2k>browseroverviewpatch.;8)
			  (* * This changed from NCINTERFACE)
			  (FNS NC.SetupTitleBarMenu)
			  (* * This changed from NCUTILITIES)
			  (FNS NC.MoveWindowOntoScreen)
			  (* * Following functions are changed in NCBROWSERCARD)
			  (FNS NC.DrawArrowHead NC.DrawFlowerLink NC.BrowserFixGraphEditMenuFn 
			       NC.MakeLinksLegendMenu NC.GetGraphEditMenu NC.UpdateBrowserCard)
			  (FNS NC.MakeBrowserOverviewWin NC.ShrinkGraphToWindow NC.ScaleGraphNode 
			       NC.ComputeOverviewScale NC.RedrawBrowserOverviewWin 
			       NC.DrawWireFrameInOverviewWin NC.BrowserOverviewWinMINSIZEFn 
			       NC.BrowserOverviewWinButtonEventFn)
			  (* * Please DELETE the following functions from NCBROWSERCARD: 
			     NC.MakeBrowserOverviewWinAtLowerLeft 
			     NC.MakeBrowserOverviewWinAtLeftBottom 
			     NC.MakeBrowserOverviewWinAtRightBottom 
			     NC.ReattachBrowserOverviewWinIfNeeded)
			  (* * New stuff for NCBROWSERCARD. Put this in with other browser overview 
			     global vars, functions, etc.)
			  (GLOBALVARS NC.BrowserOverviewSpecsStylesheet 
				      NC.DefaultWhereToAttachOverviewWin 
				      NC.DefaultBrowserOverviewMode NC.OverviewWinMode.Compress 
				      NC.OverviewWinMode.Expand)
			  (VARS (NC.OverviewWinMode.Compress (QUOTE Compress% Overview% Win))
				(NC.OverviewWinMode.Expand (QUOTE Expand% Overview))
				(NC.DefaultBrowserOverviewMode (QUOTE Neither)))
			  (INITVARS (NC.DefaultWhereToAttachOverviewWin (QUOTE (LEFT . TOP)))
				    (NC.BrowserOverviewSpecsStylesheet
				      (CREATE.STYLE (QUOTE TITLE)
						    "Choose browser overview specs"
						    (QUOTE ITEM.TITLES)
						    (QUOTE (Edge Position% on% Edge Mode))
						    (QUOTE ITEM.TITLE.FONT)
						    (FONTCOPY MENUFONT (QUOTE WEIGHT)
							      (QUOTE BOLD))
						    (QUOTE ITEMS)
						    (LIST (create MENU ITEMS ←
								  (QUOTE ((LEFT LEFT 
								      "Position along left edge.")
									  (TOP TOP 
								       "Position along top edge.")
									  (RIGHT RIGHT 
								     "Position along right edge.")
									  (BOTTOM BOTTOM 
								    "Position along bottom edge."))))
							  (create MENU ITEMS ←
								  (QUOTE ((TOP/RIGHT TOP 
							  "Position at top or right end of edge.")
									  (CENTER CENTER 
								    "Position at center of edge.")
									  (BOTTOM/LEFT BOTTOM 
							    "Position at bottom or left of edge."))))
							  (create MENU ITEMS ←
								  (QUOTE ((Compress% Overview% Win
									    Compress% Overview% Win 
			     "Compress the overview window to exactly fit the overview contents.")
									  (Expand% Overview 
										 Expand% Overview 
			      "Expand the overview contents to exactly fill the overview window.")
									  (Neither Neither 
			 "Neither expand the overview contents nor compress the overview window.")))))
						    )))
			  (FNS NC.AskBrowserOverviewSpecs NC.CompressOverviewWin 
			       NC.ReattachBrowserOverviewWin)))
(* * These fixes bring 1.3k browser overviews up to date with 
<notecards>1.2k>browseroverviewpatch.;8)

(* * This changed from NCINTERFACE)

(DEFINEQ

(NC.SetupTitleBarMenu
  (LAMBDA (Window Card NoteCardType)                         (* rht: "26-Mar-86 15:10")
                                                             (* Setup the title bar menu for the window Window 
							     pertaining to Card specified by ID)

          (* * rht 1/3/85: Now takes optional NoteCardType arg in case need to override the ID's type.
	  Like when ID is of type that inherits from Browser. Also changed "pointer" to "link" everywhere.)



          (* * rht 1/12/85: Added menu for StructEdit type. Just the same except has no InsertLink operation.
	  This needs to be cleaned up and interfaced to Types mechanism.)



          (* * rht 1/15/85: Added "Relayout" item to the browser title bar middle button menu, and made graph and structedit 
	  cards contain only that item on their middle button menus.)



          (* * rht 5/22/85: Took out structedit and structeditbrowser junk.)



          (* * fgh 11/14/85 Updated to handle Card object.)


    (OR NoteCardType (SETQ NoteCardType (NC.RetrieveType Card)))
    (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
		(FUNCTION NC.TitleBarButtonEventFn))
	  (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
			(WINDOWPROP Window (QUOTE BUTTONEVENTFN)
				      (FUNCTION NC.TitleBarButtonEventFn))))
    (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu)
		  (SELECTQ
		    NoteCardType
		    (Graph (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMenu))
					(type? MENU NC.GraphTitleBarMenu))
				 (SETQ NC.GraphTitleBarMenu
				   (create MENU
					     ITEMS ←(QUOTE
					       ((Edit% Property% List (FUNCTION NC.EditProperties)
								      
					"Brings up an editor for the property list of this card.")
						 (Show% Links (FUNCTION NC.ShowLinks)
							      
					   "Brings up a list of the links to and from this card.")
						 (Title/Sources/FileBoxes
						   (FUNCTION (LAMBDA (TextStream)
						       (NC.AssignTitle TextStream)
						       (NC.AssignSources TextStream)
						       (NC.AddParents TextStream)))
						   
		       "Do all of the operations necessary to file this note card in a file box."
						   (SUBITEMS (Assign% Title (FUNCTION 
									      NC.AssignTitle)
									    
						       "Assigns a (new) title to this note card.")
							     (Designate% Sources
							       (FUNCTION NC.AssignSources)
							       
				       "Designate the source(s) of the information in this card.")
							     (File% in% FileBoxes
							       (FUNCTION NC.AddParents)
							       
						 "File this note card in one or more file boxes.")
							     (Unfile% from% FileBoxes
							       (FUNCTION NC.UnfileNoteCard)
							       
					   "Remove this card from one or more of its file boxes.")
							     (Delete% Source (FUNCTION 
									       NC.DeleteSource)
									     
							"Delete one of the sources of this card.")))
						 (Insert% Link (FUNCTION NC.AddLinkToGraphCard)
							       
						   "Add a node that points to another note card."
							       (SUBITEMS
								 (Insert% Link
								   (FUNCTION NC.AddLinkToGraphCard)
								   
						   "Add a node that points to another note card.")
								 (Add% Global% Link
								   (FUNCTION NC.AddGlobalLinkToCard)
								   
						    "Add a global link emanating from this card.")
								 (Add% Global% Links
								   (FUNCTION 
								     NC.AddGlobalLinksToCard)
								   
						     "Add global links emanating from this card.")))
						 (Close% and% Save
						   (FUNCTION CLOSEW)
						   
					  "Close this note card after saving it in the NoteFile."
						   (SUBITEMS (Close% and% Save
							       (FUNCTION CLOSEW)
							       
					  "Close this note card after saving it in the NoteFile.")
							     (Close% w/o% Saving
							       (FUNCTION NC.QuitWithoutSaving)
							       
		      "Close this note card without saving any changes made since the last Save.")
							     (Save% in% NoteFile
							       (FUNCTION NC.CardSaveFn)
							       
				       "Save this card in the NoteFile but don't close the card.")
							     (Delete% Card (FUNCTION 
									     NC.DeleteNoteCards)
									   
						"Permenantly delete this card from the NoteFile.")))))
					     CENTERFLG ← T
					     MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								     10
								     (QUOTE BOLD)))))
			   NC.GraphTitleBarMenu)
		    (Browser (OR (AND (BOUNDP (QUOTE NC.BrowserTitleBarMenu))
					  (type? MENU NC.BrowserTitleBarMenu))
				   (SETQ NC.BrowserTitleBarMenu
				     (create MENU
					       ITEMS ←(QUOTE
						 ((Edit% Property% List (FUNCTION NC.EditProperties)
									
					"Brings up an editor for the property list of this card.")
						   (Show% Links (FUNCTION NC.ShowLinks)
								
					   "Brings up a list of the links to and from this card.")
						   (Title/Sources/FileBoxes
						     (FUNCTION (LAMBDA (TextStream)
							 (NC.AssignTitle TextStream)
							 (NC.AssignSources TextStream)
							 (NC.AddParents TextStream)))
						     
		       "Do all of the operations necessary to file this note card in a file box."
						     (SUBITEMS (Assign% Title (FUNCTION 
										NC.AssignTitle)
									      
						       "Assigns a (new) title to this note card.")
							       (Designate% Sources
								 (FUNCTION NC.AssignSources)
								 
				       "Designate the source(s) of the information in this card.")
							       (File% in% FileBoxes
								 (FUNCTION NC.AddParents)
								 
						 "File this note card in one or more file boxes.")
							       (Unfile% from% FileBoxes
								 (FUNCTION NC.UnfileNoteCard)
								 
					   "Remove this card from one or more of its file boxes.")
							       (Delete% Source
								 (FUNCTION NC.DeleteSource)
								 
							"Delete one of the sources of this card.")))
						   (Add% Global% Link
						     (FUNCTION NC.AddGlobalLinkToCard)
						     "Add a global link emanating from this card."
						     (SUBITEMS (Add% Global% Link
								 (FUNCTION NC.AddGlobalLinkToCard)
								 
						    "Add a global link emanating from this card.")
							       (Add% Global% Links
								 (FUNCTION NC.AddGlobalLinksToCard)
								 
						     "Add global links emanating from this card.")))
						   (Close% and% Save
						     (FUNCTION CLOSEW)
						     
					  "Close this note card after saving it in the NoteFile."
						     (SUBITEMS (Close% and% Save
								 (FUNCTION CLOSEW)
								 
					  "Close this note card after saving it in the NoteFile.")
							       (Close% w/o% Saving
								 (FUNCTION NC.QuitWithoutSaving)
								 
		      "Close this note card without saving any changes made since the last Save.")
							       (Save% in% NoteFile
								 (FUNCTION NC.CardSaveFn)
								 
				       "Save this card in the NoteFile but don't close the card.")
							       (Delete% Card (FUNCTION 
									       NC.DeleteNoteCards)
									     
						"Permenantly delete this card from the NoteFile.")))))
					       CENTERFLG ← T
					       MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								       10
								       (QUOTE BOLD)))))
			     NC.BrowserTitleBarMenu)
		    (Sketch (OR (AND (BOUNDP (QUOTE NC.SketchTitleBarMenu))
					 (type? MENU NC.SketchTitleBarMenu))
				  (SETQ NC.SketchTitleBarMenu
				    (create MENU
					      ITEMS ←(QUOTE
						((Edit% Property% List (FUNCTION NC.EditProperties)
								       
					"Brings up an editor for the property list of this card.")
						  (Show% Links (FUNCTION NC.ShowLinks)
							       
					   "Brings up a list of the links to and from this card.")
						  (Title/Sources/FileBoxes
						    (FUNCTION (LAMBDA (TextStream)
							(NC.AssignTitle TextStream)
							(NC.AssignSources TextStream)
							(NC.AddParents TextStream)))
						    
		       "Do all of the operations necessary to file this note card in a file box."
						    (SUBITEMS (Assign% Title (FUNCTION 
									       NC.AssignTitle)
									     
						       "Assigns a (new) title to this note card.")
							      (Designate% Sources
								(FUNCTION NC.AssignSources)
								
				       "Designate the source(s) of the information in this card.")
							      (File% in% FileBoxes
								(FUNCTION NC.AddParents)
								
						 "File this note card in one or more file boxes.")
							      (Unfile% from% FileBoxes
								(FUNCTION NC.UnfileNoteCard)
								
					   "Remove this card from one or more of its file boxes.")
							      (Delete% Source (FUNCTION 
										NC.DeleteSource)
									      
							"Delete one of the sources of this card.")))
						  (Insert% Link (FUNCTION NC.AddLinkToSketchCard)
								
						 "Add a link to another card to this sketch/map."
								(SUBITEMS
								  (Insert% Link
								    (FUNCTION 
								      NC.AddLinkToSketchCard)
								    
						 "Add a link to another card to this sketch/map.")
								  (Add% Global% Link
								    (FUNCTION 
								      NC.AddGlobalLinkToCard)
								    
						    "Add a global link emanating from this card.")
								  (Add% Global% Links
								    (FUNCTION 
								      NC.AddGlobalLinksToCard)
								    
						     "Add global links emanating from this card.")))
						  (Close% and% Save
						    (FUNCTION CLOSEW)
						    
					  "Close this note card after saving it in the NoteFile."
						    (SUBITEMS (Close% and% Save
								(FUNCTION CLOSEW)
								
					  "Close this note card after saving it in the NoteFile.")
							      (Close% w/o% Saving
								(FUNCTION NC.QuitWithoutSaving)
								
		      "Close this note card without saving any changes made since the last Save.")
							      (Save% in% NoteFile
								(FUNCTION NC.CardSaveFn)
								
				       "Save this card in the NoteFile but don't close the card.")
							      (Delete% Card (FUNCTION 
									      NC.DeleteNoteCards)
									    
						"Permenantly delete this card from the NoteFile.")))))
					      CENTERFLG ← T
					      MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								      10
								      (QUOTE BOLD)))))
			    NC.SketchTitleBarMenu)
		    NIL))
    (COND
      ((EQ NoteCardType (QUOTE Browser))
	(WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)
		      (OR (AND (BOUNDP (QUOTE NC.BrowserTitleBarMiddleButtonMenu))
				   (type? MENU NC.BrowserTitleBarMiddleButtonMenu)
				   NC.BrowserTitleBarMiddleButtonMenu)
			    (SETQ NC.BrowserTitleBarMiddleButtonMenu
			      (create MENU
					ITEMS ←(QUOTE ((Recompute% Browser (FUNCTION 
									     NC.UpdateBrowserCard)
									     
			     "Recomputes this browser to show the current state of the NoteFile.")
							  (Relayout% Graph (FUNCTION 
									   NC.RelayoutBrowserCard)
									   
						    "Re-layout the browser, but keep same nodes.")
							  (Reconnect% Nodes (FUNCTION 
									 NC.ConnectNodesInBrowser)
									    
	   "Draw all possible links, from currently selected link types, between pairs of nodes.")
							  (Unconnect% Nodes (FUNCTION 
								       NC.UnconnectNodesInBrowser)
									    
							       "Undraw all links in the browser.")
							  (Expand% Browser% Node
							    (FUNCTION NC.ExpandBrowserNode)
							    
					      "Expand the graph under one node to a given depth.")
							  (Graph% Edit% Menu (FUNCTION 
									      NC.GetGraphEditMenu)
									     
								"Bring up the graph editor menu.")
							  (Change% Browser% Specs
							    (FUNCTION NC.ChangeBrowserSpecs)
							    
		 "Make changes to some or all of the browser specs, e.g. link types, depth, etc.")
							  (Browser% Overview% Win
							    (FUNCTION NC.MakeBrowserOverviewWin)
							    "Attach the browser overview window.")
							  (Change% Overview% Specs
							    (FUNCTION NC.AskBrowserOverviewSpecs)
							    
			      "Change the browser overview specs: where to attach and what mode.")))
					CENTERFLG ← T
					MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								10
								(QUOTE BOLD)))))))
      ((EQ NoteCardType (QUOTE Graph))
	(WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)
		      (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMiddleButtonMenu))
				   (type? MENU NC.GraphTitleBarMiddleButtonMenu)
				   NC.GraphTitleBarMiddleButtonMenu)
			    (SETQ NC.GraphTitleBarMiddleButtonMenu
			      (create MENU
					ITEMS ←(QUOTE ((Relayout% Graph (FUNCTION 
									    NC.RelayoutGraphCard)
									  
						      "Re-layout the graph, but keep same nodes.")))
					CENTERFLG ← T
					MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								10
								(QUOTE BOLD))))))))))
)
(* * This changed from NCUTILITIES)

(DEFINEQ

(NC.MoveWindowOntoScreen
  (LAMBDA (Window)                                           (* rht: "26-Mar-86 15:23")
                                                             (* Make sure a window and all its attachments are on 
							     the screen.)

          (* * rht 8/28/85: Hacked to handle very big card windows that together with attached windows might be too big to 
	  fit on screen.)



          (* * kirk 12Feb86 Added room for scroll bars.)



          (* * rht 3/4/86: Changed to use RELMOVEW because otherwise it screws up when there's an attached window on the left
	  or bottom of the window.)


    (PROG (WindowRegion OldTop OldBottom NewLeft NewTop)
	    (COND
	      ((AND (WINDOWP Window)
		      (NOT (SUBREGIONP WHOLEDISPLAY (SETQ WindowRegion (WINDOWREGION Window)))
			     ))
		(SETQ OldTop (fetch (REGION TOP) of WindowRegion))
		(if (GREATERP (fetch (REGION RIGHT) of WindowRegion)
				  (fetch (REGION RIGHT) of WHOLEDISPLAY))
		    then (SETQ NewLeft (replace (REGION LEFT) of WindowRegion
					      with (DIFFERENCE (fetch (REGION RIGHT)
								      of WHOLEDISPLAY)
								   (fetch (REGION WIDTH)
								      of WindowRegion)))))
		(if (MINUSP (OR NewLeft (fetch (REGION LEFT) of WindowRegion)))
		    then (replace (REGION LEFT) of WindowRegion with 20))
		(if (MINUSP (SETQ OldBottom (fetch (REGION BOTTOM) of WindowRegion)))
		    then (replace (REGION BOTTOM) of WindowRegion with 20)
			   (SETQ NewTop (PLUS OldTop (MINUS OldBottom))))
		(if (GREATERP (OR NewTop (fetch (REGION TOP) of WindowRegion))
				  (fetch (REGION TOP) of WHOLEDISPLAY))
		    then (replace (REGION BOTTOM) of WindowRegion
			      with (DIFFERENCE (fetch (REGION TOP) of WHOLEDISPLAY)
						   (fetch (REGION HEIGHT) of WindowRegion))))
		(RELMOVEW Window (create POSITION
					     XCOORD ←(DIFFERENCE (fetch (REGION LEFT)
								      of NewWindowRegion)
								   (fetch (REGION LEFT)
								      of OldWindowRegion))
					     YCOORD ←(DIFFERENCE (fetch (REGION BOTTOM)
								      of NewWindowRegion)
								   (fetch (REGION BOTTOM)
								      of OldWindowRegion)))))))))
)
(* * Following functions are changed in NCBROWSERCARD)

(DEFINEQ

(NC.DrawArrowHead
  (LAMBDA (X1 Y1 X2 Y2 Width Operation Stream Color MidpointFlg XOffset YOffset)
                                                             (* rht: "26-Mar-86 15:45")

          (* * Draw an arrowhead on the end of the line segment from X1,Y1 to X2,Y2.)



          (* * rht 8/12/85: Added check for whether point is inside clipping region before computing arrow head.)



          (* * rht 2/28/86: Now checks for Scale WINDOWPROP on the window. If so, then multiply that in with Scale.
	  We're probably in a shrunken browser in that case.)


    (PROG ((XDiff (FLOAT (IDIFFERENCE X1 X2)))
	     (YDiff (FLOAT (IDIFFERENCE Y1 Y2)))
	     (Window (AND (DISPLAYSTREAMP Stream)
			    (WINDOWP (WFROMDS Stream))))
	     (Scale (DSPSCALE NIL Stream))
	     WindowScale LineLength A11 A12 A21 A22 Tmp1 Tmp2 ClippingRegion ArrowHeadXVal 
	     ArrowHeadYVal ArrowHeadLength)
	    (OR XOffset (SETQ XOffset 0))
	    (OR YOffset (SETQ YOffset 0))
	    (if (AND Window (SETQ WindowScale (WINDOWPROP Window (QUOTE Scale))))
		then (SETQ Scale (FTIMES Scale WindowScale)))
	    (SETQ ArrowHeadXVal (FIXR (TIMES NC.ArrowHeadXVal Scale)))
	    (SETQ ArrowHeadYVal (FIXR (TIMES NC.ArrowHeadYVal Scale)))
	    (SETQ ArrowHeadLength (FIXR (TIMES NC.ArrowHeadLength Scale)))
	    (COND
	      (MidpointFlg (SETQ XOffset (PLUS XOffset (DIFFERENCE (QUOTIENT (IPLUS X1 X2)
										     2)
									 X2)))
			   (SETQ YOffset (PLUS YOffset (DIFFERENCE (QUOTIENT (IPLUS Y1 Y2)
										     2)
									 Y2)))))
                                                             (* If the point at which the arrow head will be drawn 
							     isn't inside the clipping region together with a 
							     border, then bail out.)
	    (SETQ ClippingRegion (DSPCLIPPINGREGION NIL Stream))
	    (COND
	      ((AND ClippingRegion (NOT (INSIDEP (CREATEREGION (DIFFERENCE
									 (fetch (REGION LEFT)
									    of ClippingRegion)
									 ArrowHeadLength)
								       (DIFFERENCE
									 (fetch (REGION BOTTOM)
									    of ClippingRegion)
									 ArrowHeadLength)
								       (PLUS (fetch (REGION
											  WIDTH)
										  of ClippingRegion)
									       ArrowHeadLength 
									       ArrowHeadLength)
								       (PLUS (fetch (REGION
											  HEIGHT)
										  of ClippingRegion)
									       ArrowHeadLength 
									       ArrowHeadLength))
						       (PLUS X2 XOffset)
						       (PLUS Y2 YOffset))))
		(RETURN)))
	    (SETQ LineLength (SQRT (PLUS (TIMES XDiff XDiff)
					       (TIMES YDiff YDiff))))
	    (SETQ A11 (QUOTIENT (FLOAT XDiff)
				    LineLength))
	    (SETQ A21 (QUOTIENT (FLOAT YDiff)
				    LineLength))
	    (SETQ A12 (MINUS A21))
	    (SETQ A22 A11)
	    (SETQ Tmp1 (TIMES A11 ArrowHeadXVal))
	    (SETQ Tmp2 (TIMES A21 ArrowHeadXVal))
	    (SETQ X2 (PLUS X2 XOffset))
	    (SETQ Y2 (PLUS Y2 YOffset))
	    (DRAWLINE X2 Y2 (PLUS X2 Tmp1 (TIMES A12 ArrowHeadYVal))
			(PLUS Y2 Tmp2 (TIMES A22 ArrowHeadYVal))
			Width Operation Stream Color)
	    (DRAWLINE X2 Y2 (PLUS X2 Tmp1 (TIMES A12 (MINUS ArrowHeadYVal)))
			(PLUS Y2 Tmp2 (TIMES A22 (MINUS ArrowHeadYVal)))
			Width Operation Stream Color))))

(NC.DrawFlowerLink
  (LAMBDA (X1 Y1 X2 Y2 Brush Dashing Num Win Width Operation Color)
                                                             (* rht: "26-Mar-86 15:45")

          (* * Draw one link between given points according to given Dashing. If Num is 0, then draw straight line.
	  Otherwise, draw curves above for odd Num and below for even Num, getting wider for bigger values of Num.)



          (* * rht 3/21/86: Now checks for WINDOWPROP of Scale for when we're in a browser overview window.)


    (PROG ((MidpointX (QUOTIENT (IPLUS X1 X2)
				    2))
	     (MidpointY (QUOTIENT (IPLUS Y1 Y2)
				    2))
	     XOffset YOffset Scale Window WindowScale)
	    (COND
	      ((ZEROP Num)
		(DRAWLINE X1 Y1 X2 Y2 Width Operation Win Color Dashing)
		(AND (NEQ NC.ArrowHeadsInBrowser (QUOTE None))
		       (NC.DrawArrowHead X1 Y1 X2 Y2 Width Operation Win Color T)))
	      (T                                             (* Check slope of line. If < 45 degrees, then make 
							     spline nodes be vertically removed, otherwise 
							     horizontally removed.)
		 (COND
		   ((GREATERP (ABS (DIFFERENCE X2 X1))
				(ABS (DIFFERENCE Y2 Y1)))
		     (SETQ YOffset (COND
			 ((ODDP Num)
			   (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1 Num)
									     2)))
			 (T (MINUS (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1 Num)
										       2))))))
		     (SETQ XOffset 0))
		   (T (SETQ XOffset (COND
			  ((ODDP Num)
			    (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1 Num)
									      2)))
			  (T (MINUS (TIMES NC.GraphFlowerLinkSeparation (QUOTIENT (ADD1
											  Num)
											2))))))
		      (SETQ YOffset 0)))
		 (SETQ Scale (DSPSCALE NIL Win))
		 (SETQ Window (AND (DISPLAYSTREAMP Stream)
				       (WINDOWP (WFROMDS Stream))))
		 (if (AND Window (SETQ WindowScale (WINDOWPROP Window (QUOTE Scale))))
		     then (SETQ Scale (FTIMES Scale WindowScale)))
		 (SETQ XOffset (FIXR (TIMES XOffset Scale)))
		 (SETQ YOffset (FIXR (TIMES YOffset Scale)))
		 (DRAWLINE X1 Y1 (PLUS MidpointX XOffset)
			     (PLUS MidpointY YOffset)
			     Width Operation Win NIL Dashing)
		 (DRAWLINE (PLUS MidpointX XOffset)
			     (PLUS MidpointY YOffset)
			     X2 Y2 Width Operation Win NIL Dashing)
		 (AND (NEQ NC.ArrowHeadsInBrowser (QUOTE None))
			(NC.DrawArrowHead X1 Y1 (PLUS MidpointX XOffset)
					    (PLUS MidpointY YOffset)
					    Width Operation Win Color NIL)))))))

(NC.BrowserFixGraphEditMenuFn
  (LAMBDA (Window)                                           (* rht: "26-Mar-86 16:30")

          (* * Attach the Graph edit menu to the side of the browser window. Put it below the links legend.)



          (* * rht 9/20/85: Now uses ADDMENU offscreen so it doesn't flash in lower left corner before coming up.)



          (* * rht 3/3/86: Now does some "random" WINDOWPROPS to make reshaping browser not screw up the attached menu.)



          (* * rht 3/7/86: Uses ATTACHMENU to attach the menu.)


    (LET (GraphEditMenu GraphEditMenuWin)
         (SETQ GraphEditMenu (create MENU
					 ITEMS ← NC.GraphEditMenuItems
					 TITLE ← "Editor Menu"
					 WHENSELECTEDFN ←(FUNCTION NC.GraphEditMenuWhenSelectedFn)))
         (PUTMENUPROP GraphEditMenu (QUOTE MAINWINDOW)
			Window)
         (SETQ GraphEditMenuWin (ATTACHMENU GraphEditMenu Window (QUOTE RIGHT)
						(QUOTE BOTTOM)))
                                                             (* Rig so that close of menu won't close browser.)
         (WINDOWDELPROP GraphEditMenuWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE CLOSEW))
         (WINDOWPROP GraphEditMenuWin (QUOTE GRAPHEDITMENUFLG)
		       T)
         (WINDOWADDPROP GraphEditMenuWin (QUOTE CLOSEFN)
			  (FUNCTION (LAMBDA (W)
			      (DETACHWINDOW W)))
			  T))))

(NC.MakeLinksLegendMenu
  (LAMBDA (Win LabelPairs)                                   (* rht: "26-Mar-86 16:30")

          (* * Build a links legend menu and attach to Win)



          (* * rht 1/10/85: Before starting, kill any old links legend menus for Win.)



          (* * rht 1/13/86: Now holds onto value of PASSTOMAINCOMS windowprop of prompt win and restores after reattaching.)



          (* * rht 1/15/86: Added windowprops MINSIZE and MAXSIZE to fix the bug where reshaping browser screws up links 
	  legend menu.)



          (* * rht 3/7/86: Now closes prompt window before attaching menu. Uses ATTACHMENU to attach the menu.)


    (LET (Menu MenuWin PromptWin MainWinPromptInfo PromptWinPASSTOMAINCOMS)
         (for AttachedWin in (ATTACHEDWINDOWS Win) when (WINDOWPROP AttachedWin
									      (QUOTE 
										  LINKSLEGENDWINP))
	    do (CLOSEW AttachedWin))
         (SETQ Menu (COND
	     (NC.LinkDashingInBrowser (create MENU
						ITEMS ←(for Pair in LabelPairs
							  join (LIST (CAR Pair)
									 (LIST (QUOTE "  "))))
						TITLE ←(QUOTE Links)
						MENUCOLUMNS ← 2))
	     (T (create MENU
			  ITEMS ←(for Pair in LabelPairs collect (CAR Pair))
			  TITLE ←(QUOTE Links)
			  MENUCOLUMNS ← 1))))                (* Close the prompt window if open.)
         (if (SETQ PromptWin (GETPROMPTWINDOW Win NIL NIL T))
	     then (CLOSEW PromptWin))                    (* Stick the links legend window at upper right 
							     corner.)
         (SETQ MenuWin (ATTACHMENU Menu Win (QUOTE RIGHT)
				       (QUOTE TOP)))       (* Rig so that close of menu won't close browser.)
         (WINDOWDELPROP MenuWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE CLOSEW))
         (WINDOWADDPROP MenuWin (QUOTE CLOSEFN)
			  (FUNCTION (LAMBDA (W)
			      (DETACHWINDOW W)))
			  T)
         (WINDOWADDPROP MenuWin (QUOTE REPAINTFN)
			  (QUOTE NC.LinksLegendRepaintFn))
         (WINDOWADDPROP MenuWin (QUOTE RESHAPEFN)
			  (QUOTE NC.LinksLegendReshapeFn))
         (WINDOWADDPROP MenuWin (QUOTE LINKSLEGENDWINP)
			  T)
         (WINDOWPROP Win (QUOTE NCLABELPAIRS)
		       LabelPairs)
         (NC.MoveWindowOntoScreen Win)
         (if NC.LinkDashingInBrowser
	     then (NC.LinksLegendRepaintFn MenuWin NIL)))))

(NC.GetGraphEditMenu
  (LAMBDA (Window)                                           (* rht: "26-Mar-86 16:10")

          (* * Create, if necessary, and bring up the graph editor menu.)


    (PROG ((GraphEditUnfixableMenu (WINDOWPROP Window (QUOTE GRAPHEDITUNFIXABLEMENU)))
	     (GraphEditFixableMenu (WINDOWPROP Window (QUOTE GRAPHEDITFIXABLEMENU)))
	     GraphEditMenuWin)                               (* If menu is already up, then put up a menu without 
							     the FIXMENU option, otherwise, allow user to fix 
							     menu.)
	    (if (for Win in (ATTACHEDWINDOWS Window) thereis (AND (OPENWP Win)
									      (WINDOWPROP
										Win
										(QUOTE 
										 GRAPHEDITMENUFLG))))
		then (OR GraphEditUnfixableMenu
			     (WINDOWPROP Window (QUOTE GRAPHEDITUNFIXABLEMENU)
					   (SETQ GraphEditUnfixableMenu
					     (create MENU
						       ITEMS ← NC.GraphEditMenuItems
						       TITLE ← "Graph Editor Menu"
						       WHENSELECTEDFN ←(FUNCTION 
							 NC.GraphEditMenuWhenSelectedFn)
						       CHANGEOFFSETFLG ← T
						       MENUOFFSET ←(CONS -1 0)))))
		       (PUTMENUPROP GraphEditUnfixableMenu (QUOTE MAINWINDOW)
				      Window)
		       (MENU GraphEditUnfixableMenu)
	      else (OR GraphEditFixableMenu
			   (WINDOWPROP Window (QUOTE GRAPHEDITFIXABLEMENU)
					 (SETQ GraphEditFixableMenu
					   (create MENU
						     ITEMS ← NC.GraphEditUnfixedMenuItems
						     TITLE ← "Graph Editor Menu"
						     WHENSELECTEDFN ←(FUNCTION 
						       NC.GraphEditMenuWhenSelectedFn)
						     CHANGEOFFSETFLG ← T
						     MENUOFFSET ←(CONS -1 0)))))
		     (PUTMENUPROP GraphEditFixableMenu (QUOTE MAINWINDOW)
				    Window)
		     (MENU GraphEditFixableMenu)))))

(NC.UpdateBrowserCard
  (LAMBDA (Window)                                           (* rht: "26-Mar-86 16:12")

          (* * rht 10/14/84: Added call to DETACHALLWINDOWS to close any existing links legend window and prompt window.
	  Also added call to NC.MakeLinksLegend to make a new attached legend menu.)



          (* * rht 1/15/85: Put hooks for AddNode, AddLink, etc. so editing graph edits underlying structure.)



          (* * rht 2/14/85: Added ability to respecify roots and link labels before recomputing graph.)



          (* * rht 3/8/85: Modified to use new browser props stored on card's proplist as of release 1.2.)



          (* * rht 3/17/85: Now takes OnlyLayoutFlg argument. If set, then don't recompute lattice or ask about root nodes.)



          (* * rht 11/17/85: updated to handle new card and notefile objects.)



          (* * kirk 23Jan86 Changed to use NC.AskYesOrNo)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns.)



          (* * rht 3/7/86: Now only closes the Links legend menu attached window.)


    (PROG (Card LinkLabels RootCards RootNodes Lattice LinkIcon Graph GraphNodes NodeLabel 
		  BrowserSpecs BrowserFormat DropVirtualNodesFlg Depth SpecialBrowserSpecs 
		  OldLabelNodes OldRootCards)                (* Get rid of the links legend menu attached window.)
	    (for Win in (ATTACHEDWINDOWS Window) when (WINDOWPROP Win (QUOTE 
										  LINKSLEGENDWINP))
	       do (DETACHWINDOW Win)
		    (CLOSEW Win))
	    (SETQ Card (NC.CoerceToCard Window))
	    (SETQ RootCards (NC.FetchBrowserRoots Card))
	    (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
	    (SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
					(QUOTE (LATTICE))))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ Depth (OR (NC.FetchBrowserDepth Card)
				999999))
	    (SETQ SpecialBrowserSpecs (OR (NC.FetchSpecialBrowserSpecs Card)
					      (create SPECIALBROWSERSPECS)))
	    (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph (WINDOWPROP
								    Window
								    (QUOTE GRAPH)))))
                                                             (* Smash the current hash array, putting a fresh one 
							     in its place.)
	    (NC.GetBrowserHashArray Card)                  (* Get new roots.)
	    (if (OR (NULL RootCards)
			(NC.AskYesOrNo "Want to respecify roots? " "--" "No" T Window T NIL))
		then (NC.BrowserFlipRoots Window Card GraphNodes (SETQ OldRootCards RootCards))
		       (SETQ RootCards (NC.SelectNoteCards NIL NIL NC.SelectingBrowserSourceMenu 
							       Window NIL (CONCAT 
			    "Please select the Cards and/or Boxes the browser should start from."
										    (CHARACTER
										      13)
										    
							       "(Current roots are highlighted.)")
							       T))
		       (NC.BrowserFlipRoots Window Card GraphNodes OldRootCards)
		       (COND
			 ((EQ RootCards (QUOTE CANCELLED))
			   (RETURN))))
	    (NC.PrintMsg Window T (CHARACTER 13)
			   "Computing browser graph. Please wait. ...")
                                                             (* Compute lattice breadth-first from the roots.)
	    (SETQ Lattice (NC.GrowLinkLattice RootCards NIL LinkLabels Card Depth))
	    (SETQ RootNodes (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
											 RootCard)))
	    (NC.SetPropListDirtyFlg Card T)                (* Remove all links that are in the old browser graph 
							     but not in the new one)
	    (for Node in GraphNodes bind NodeID Link
	       eachtime (BLOCK)
			  (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
	       unless (FASSOC (OR (CAR NodeID)
					NodeID)
				  Lattice)
	       do (if (NC.LinkIconImageObjP (SETQ LinkIcon (fetch (GRAPHNODE NODELABEL)
								      of Node)))
			then (NC.DeleteLink (NC.FetchLinkFromLinkIcon LinkIcon)
						T T)
		      else                                 (* Collect the label nodes from the old browser.)
			     (SETQ OldLabelNodes (CONS Node OldLabelNodes))))
                                                             (* Create Links for all nodes in the new browser graph
							     but not in the old one.)
	    (for Node in Lattice bind NodeID OldNode eachtime (BLOCK)
	       do (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
		    (COND
		      ((SETQ OldNode (FASSOC NodeID GraphNodes))
			(replace (GRAPHNODE NODELABEL) of Node with (fetch (GRAPHNODE 
											NODELABEL)
									     of OldNode)))
		      (T (replace (GRAPHNODE NODELABEL) of Node
			    with (NC.MakeLinkIcon (NC.MakeLink Window 
								     NC.BrowserContentsLinkLabel
								     (fetch (GRAPHNODE NODELABEL)
									of Node)
								     Card)))))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (NC.UIDRemProp NodeID (QUOTE TouchedFlg))
		    (NC.UIDRemProp NodeID (QUOTE VisitedFlg)))
                                                             (* Throw in the label nodes from the old browser.)
	    (SETQ Lattice (NCONC Lattice OldLabelNodes))
                                                             (* For each old label node, take away nonexistent 
							     fromnodes and save the label nodes that no longer have
							     any from nodes.)
	    (for OldLabelNode in OldLabelNodes eachtime (BLOCK)
	       do (replace (GRAPHNODE FROMNODES) of OldLabelNode
		       with (for FromNodeID in (fetch (GRAPHNODE FROMNODES) of OldLabelNode)
				 bind FromNode eachtime (BLOCK) when (SETQ FromNode
									       (FASSOC FromNodeID 
											 Lattice))
				 collect                   (* If the From node isn't a label node, then add to 
							     its Tonode list.)
					   (if (NC.LinkIconImageObjP (fetch (GRAPHNODE 
											NODELABEL)
									    of FromNode))
					       then (replace (GRAPHNODE TONODES) of FromNode
							 with (CONS (fetch (GRAPHNODE NODEID)
									   of OldLabelNode)
									(fetch (GRAPHNODE TONODES)
									   of FromNode))))
					   FromNodeID))      (* For the old label node's ToNodes, just need to 
							     remove any for ToNodes that no longer exist.)
		    (replace (GRAPHNODE TONODES) of OldLabelNode
		       with (for ToNodeID in (fetch (GRAPHNODE TONODES) of OldLabelNode)
				 bind ToNode eachtime (BLOCK) when (SETQ ToNode
									     (FASSOC ToNodeID 
										       Lattice))
				 collect                   (* If the To node isn't a label node, then add to its 
							     FromNode list.)
					   (if (NC.LinkIconImageObjP (fetch (GRAPHNODE 
											NODELABEL)
									    of ToNode))
					       then (replace (GRAPHNODE FROMNODES) of ToNode
							 with (CONS (fetch (GRAPHNODE NODEID)
									   of OldLabelNode)
									(fetch (GRAPHNODE FROMNODES)
									   of ToNode))))
					   ToNodeID)))       (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
	    (SETQ Graph (if (AND Lattice RootNodes)
			      then (LAYOUTGRAPH Lattice (for Node in Lattice bind NodeID
							       eachtime
								(BLOCK)
								(SETQ NodeID
								  (OR (NC.CoerceToGraphNodeID
									  Node)
									(fetch (GRAPHNODE NODEID)
									   of Node)))
							       when
								(OR (FMEMB NodeID RootNodes)
								      (NULL (fetch (GRAPHNODE
											 FROMNODES)
										 of Node)))
							       collect NodeID)
						    (SUBST (QUOTE LATTICE)
							     NC.*Graph*BrowserFormat BrowserFormat)
						    (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS MotherD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS PersonalD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS FamilyD)
						       of SpecialBrowserSpecs))
			    else (create GRAPH)))        (* Build links legend and fix up TONODES in the 
							     graph.)
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (NC.SetBrowserRoots Card RootCards)
	    (NC.SetBrowserDepth Card Depth)
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.RelayoutBrowserCard Window))))
)
(DEFINEQ

(NC.MakeBrowserOverviewWin
  (LAMBDA (BrowserWin Region)                                (* rht: "21-Mar-86 01:23")

          (* * Make and attach a little window to contain a shrunken bitmap of the entire browser. If Region arg is passed 
	  then use that as size for overview win, else use defaults.)



          (* * rht 3/7/86: Now uses stylesheet to figure out where to attach.)


    (LET ((OverviewWinWidth (if Region
				then (fetch (REGION WIDTH) of Region)
			      else (OR (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth))
					   NC.BrowserOverviewDefaultWidth)))
	  (OverviewWinHeight (if Region
				 then (fetch (REGION HEIGHT) of Region)
			       else (OR (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight))
					    NC.BrowserOverviewDefaultHeight)))
	  (OverviewWin (OPENWP (WINDOWPROP BrowserWin (QUOTE BrowserOverviewWin))))
	  (WhereToAttach (OR (WINDOWPROP BrowserWin (QUOTE WHERETOATTACHOVERVIEWWIN))
			       NC.DefaultWhereToAttachOverviewWin)))
         (if OverviewWin
	   else                                            (* Make a new overview window.)
		  (SETQ OverviewWin (CREATEW (CREATEREGION (fetch (POSITION XCOORD)
								    of NC.OffScreenPosition)
								 (fetch (POSITION YCOORD)
								    of NC.OffScreenPosition)
								 OverviewWinWidth OverviewWinHeight)))
		  (WINDOWPROP BrowserWin (QUOTE BrowserOverviewWin)
				OverviewWin))
         (NC.ReattachBrowserOverviewWin OverviewWin BrowserWin WhereToAttach)
         (NC.RedrawBrowserOverviewWin OverviewWin BrowserWin))))

(NC.ShrinkGraphToWindow
  (LAMBDA (Graph Window)                                     (* rht: "21-Mar-86 00:30")

          (* * Bitblt's into Window a shrunken bitmap of the graph just big enough to fit.)



          (* * rht 3/18/86: Now does more intelligent copy of Graph structure, preserving virtual node eq-ness.)



          (* * rht 3/21/86: Now handles XScale and YScale.)


    (LET ((GraphWindow (MAINWINDOW Window))
	  (Scales (NC.ComputeOverviewScale Graph Window))
	  (ShrunkenGraph (create GRAPH using Graph))
	  Scale XScale YScale)
         (if (EQ (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE))
		     NC.OverviewWinMode.Expand)
	     then (SETQ XScale (CAR Scales))
		    (SETQ YScale (CDR Scales))
		    (SETQ Scale (FMIN XScale YScale))
	   else (SETQ Scale (SETQ XScale (SETQ YScale (FMIN (CAR Scales)
								      (CDR Scales))))))
                                                             (* Shrink the graphnodes.)
         (replace (GRAPH GRAPHNODES) of ShrunkenGraph with (for GraphNode
								    in (fetch (GRAPH GRAPHNODES)
									    of ShrunkenGraph)
								    eachtime (BLOCK)
								    collect (NC.ScaleGraphNode
										(create GRAPHNODE
										   using GraphNode)
										Scale XScale YScale 
										GraphWindow)))
                                                             (* Display the graph, but temporarily scale the 
							     arrowhead global vars. Will this work compiled?)
         (SHOWGRAPH ShrunkenGraph Window)
         (WINDOWPROP Window (QUOTE Scale)
		       Scale)
         (WINDOWPROP Window (QUOTE XScale)
		       XScale)
         (WINDOWPROP Window (QUOTE YScale)
		       YScale)
         (WINDOWPROP Window (QUOTE GRAPH)
		       ShrunkenGraph))))

(NC.ScaleGraphNode
  (LAMBDA (GraphNode Scale XScale YScale BrowserWin)         (* rht: "21-Mar-86 00:20")

          (* * Change the position and node label according to Scale.)



          (* * rht 3/14/86: Now smashes NODELABEL field of graph node with bitmap rather than NODELABELBITMAP field.)



          (* * rht 3/18/86: Now returns GraphNode.)



          (* * rht 3/21/86: Now scales position using XScale and YScale. But note that new node size still governed by Scale.
	  This is because SCALEBITMAP only takes single scale.)


    (LET ((OldWidth (fetch (GRAPHNODE NODEWIDTH) of GraphNode))
	  (OldHeight (fetch (GRAPHNODE NODEHEIGHT) of GraphNode))
	  (OldPosition (fetch (GRAPHNODE NODEPOSITION) of GraphNode))
	  NewWidth NewHeight NewBitmap OldBitmap NodeLabel)
         (replace (GRAPHNODE NODEWIDTH) of GraphNode with (SETQ NewWidth
								  (FIX (FTIMES Scale OldWidth))))
         (replace (GRAPHNODE NODEHEIGHT) of GraphNode with (SETQ NewHeight
								   (FIX (FTIMES Scale OldHeight)))
		    )
         (replace (GRAPHNODE NODEPOSITION) of GraphNode
	    with (create POSITION
			     XCOORD ←(FIX (FTIMES XScale (fetch (POSITION XCOORD)
								of OldPosition)))
			     YCOORD ←(FIX (FTIMES YScale (fetch (POSITION YCOORD)
								of OldPosition)))))
         (if (LESSP Scale NC.LeastScaleForGraphNodeShrinking)
	     then                                          (* At this scale no need to shrink node label.
							     Just show shaded box.)
		    (SETQ NewBitmap (BITMAPCREATE NewWidth NewHeight))
		    (BLTSHADE GRAYSHADE NewBitmap NIL NIL NewWidth NewHeight)
	   else                                            (* Shrink node label.)
		  (if (SETQ OldBitmap (fetch (GRAPHNODE NODELABELBITMAP) of GraphNode))
		    else (SETQ OldBitmap (BITMAPCREATE OldWidth OldHeight))
			   (SETQ NodeLabel (fetch (GRAPHNODE NODELABEL) of GraphNode))
			   (if (IMAGEOBJP NodeLabel)
			       then (NC.LinkIconDisplayFn NodeLabel (DSPCREATE OldBitmap))
			     else (PRIN1 NodeLabel (DSPCREATE OldBitmap))))
		  (SETQ NewBitmap (SCALEBITMAP OldBitmap Scale)))
         (replace (GRAPHNODE NODELABEL) of GraphNode with NewBitmap)
         (replace (GRAPHNODE NODELABELBITMAP) of GraphNode with NIL)
     GraphNode)))

(NC.ComputeOverviewScale
  (LAMBDA (Graph OverviewWin)                                (* rht: "21-Mar-86 00:13")

          (* * Figure out the scale necessary to shrink Graph into OverviewWin.)



          (* * rht 3/21/86: Now returns both XScale and YScale.)


    (LET ((GraphRegion (GRAPHREGION Graph)))
         (CONS (FMIN (FQUOTIENT (WINDOWPROP OverviewWin (QUOTE WIDTH))
				      (fetch (REGION WIDTH) of GraphRegion))
			 1)
		 (FMIN (FQUOTIENT (WINDOWPROP OverviewWin (QUOTE HEIGHT))
				      (fetch (REGION HEIGHT) of GraphRegion))
			 1)))))

(NC.RedrawBrowserOverviewWin
  (LAMBDA (OverviewWin BrowserWin)                           (* rht: "26-Mar-86 16:26")

          (* * The contents of the browser window have changed. Redraw the overview win.)



          (* * rht 3/20/86: Now compresses to fit overview if necessary.)


    (NC.ShrinkGraphToWindow (WINDOWPROP BrowserWin (QUOTE GRAPH))
			      OverviewWin)
    (if (EQ (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE))
		NC.OverviewWinMode.Compress)
	then (WINDOWPROP OverviewWin (QUOTE RESHAPEFN)
			     NIL)
	       (NC.CompressOverviewWin OverviewWin BrowserWin))
    (WINDOWPROP OverviewWin (QUOTE REPAINTFN)
		  (FUNCTION NC.BrowserOverviewWinRepaintFn))
    (WINDOWPROP OverviewWin (QUOTE RESHAPEFN)
		  (FUNCTION NC.BrowserOverviewWinReshapeFn))
    (WINDOWPROP OverviewWin (QUOTE BUTTONEVENTFN)
		  (FUNCTION NC.BrowserOverviewWinButtonEventFn))
    (NC.DrawWireFrameInOverviewWin OverviewWin BrowserWin)))

(NC.DrawWireFrameInOverviewWin
  (LAMBDA (OverviewWin BrowserWin)                           (* rht: "21-Mar-86 00:35")

          (* * Draw a wire frame in the overview win whose size and position within the overview correspond to the size and 
	  position of BrowserWin relative to entire graph.)



          (* * rht 3/21/86: Now handles XScale and YScale.)


    (LET ((BrowserClippingRegion (DSPCLIPPINGREGION NIL BrowserWin))
	  (XScale (WINDOWPROP OverviewWin (QUOTE XScale)))
	  (YScale (WINDOWPROP OverviewWin (QUOTE YScale)))
	  WireFrame)
         (SETQ WireFrame (CREATEREGION (FIX (FTIMES XScale (fetch (REGION LEFT)
								      of BrowserClippingRegion)))
					   (FIX (FTIMES YScale (fetch (REGION BOTTOM)
								      of BrowserClippingRegion)))
					   (FIX (FTIMES XScale (fetch (REGION WIDTH)
								      of BrowserClippingRegion)))
					   (FIX (FTIMES YScale (fetch (REGION HEIGHT)
								      of BrowserClippingRegion)))))
                                                             (* Draw the wire frame out on the overview window.)
         (NC.DRAWBOX (fetch (REGION LEFT) of WireFrame)
		       (fetch (REGION BOTTOM) of WireFrame)
		       (fetch (REGION WIDTH) of WireFrame)
		       (fetch (REGION HEIGHT) of WireFrame)
		       1
		       (QUOTE INVERT)
		       OverviewWin)                          (* Stash the new wire frame on windowprop.)
         (WINDOWPROP OverviewWin (QUOTE LastWireFrame)
		       WireFrame))))

(NC.BrowserOverviewWinMINSIZEFn
  (LAMBDA (OverviewWin)                                      (* rht: "21-Mar-86 15:17")

          (* * This horrible kludge is so that ATTACHEDWINDOWS sees a different value for MINSIZE depending on whether we're 
	  reshaping the whole browser or just the overview win. In the former case, we want the MINSIZE to be the current 
	  size of the overview win. In the latter, we want it at some small value so user can reduce size of overview win.)


    (LET (Stkpos)
         (PROG1 (if (OR (NULL (SETQ Stkpos (STKPOS (QUOTE SHAPEW))))
			      (NEQ OverviewWin (STKARG (QUOTE WINDOW)
							   (QUOTE SHAPEW)))
			      (SETQ Stkpos (STKPOS (QUOTE RESHAPEALLWINDOWS)
						       NIL NIL Stkpos)))
		      then (LET ((BrowserWin (MAINWINDOW OverviewWin)))
			          (CONS (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth))
					  (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight))))
		    else (QUOTE (5 . 5)))
		  (RELSTK Stkpos)))))

(NC.BrowserOverviewWinButtonEventFn
  (LAMBDA (OverviewWin)                                      (* rht: "21-Mar-86 00:43")

          (* * Called when user buttons in browser overview window. bring cursor to nearest corner of wire frame and let him 
	  reposition wire frame.)



          (* * rht 3/15/86 Now allows moves of wire frame that increase scrolling region.)



          (* * rht 3/21/86: Now handles XScale and YScale.)


    (LET ((LastWireFrame (WINDOWPROP OverviewWin (QUOTE LastWireFrame)))
	  NewRegion XScaleReciprocal YScaleReciprocal BrowserWin OldDisplayRegion NewLeft NewBottom)
         (SETQ NewRegion (GETBOXREGION (fetch (REGION WIDTH) of LastWireFrame)
					   (fetch (REGION HEIGHT) of LastWireFrame)
					   (PLUS (DSPXOFFSET NIL OverviewWin)
						   (fetch (REGION LEFT) of LastWireFrame))
					   (PLUS (DSPYOFFSET NIL OverviewWin)
						   (fetch (REGION BOTTOM) of LastWireFrame))
					   OverviewWin "Please position browser overview wire frame.")
	   )
         (if (REGIONSINTERSECTP NewRegion (DSPCLIPPINGREGION NIL OverviewWin))
	     then (SETQ BrowserWin (MAINWINDOW OverviewWin))
		    (SETQ XScaleReciprocal (FQUOTIENT 1 (WINDOWPROP OverviewWin (QUOTE XScale)
									  )))
		    (SETQ YScaleReciprocal (FQUOTIENT 1 (WINDOWPROP OverviewWin (QUOTE YScale)
									  )))
                                                             (* Where browser used to be.)
		    (SETQ OldDisplayRegion (DSPCLIPPINGREGION NIL BrowserWin)) 
                                                             (* First make sure browser win's EXTENT is big 
							     enough.)
		    (WINDOWPROP BrowserWin (QUOTE EXTENT)
				  (UNIONREGIONS (WINDOWPROP BrowserWin (QUOTE EXTENT))
						  (CREATEREGION
						    (SETQ NewLeft
						      (FIX (FTIMES (fetch (REGION LEFT)
									  of NewRegion)
								       XScaleReciprocal)))
						    (SETQ NewBottom
						      (FIX (FTIMES (fetch (REGION BOTTOM)
									  of NewRegion)
								       YScaleReciprocal)))
						    (fetch (REGION WIDTH) of OldDisplayRegion)
						    (fetch (REGION HEIGHT) of OldDisplayRegion))))
                                                             (* Scroll browser to new region.)
		    (SCROLLW BrowserWin (DIFFERENCE (fetch (REGION LEFT) of OldDisplayRegion)
							NewLeft)
			       (DIFFERENCE (fetch (REGION BOTTOM) of OldDisplayRegion)
					     NewBottom))))))
)
(* * Please DELETE the following functions from NCBROWSERCARD: 
NC.MakeBrowserOverviewWinAtLowerLeft NC.MakeBrowserOverviewWinAtLeftBottom 
NC.MakeBrowserOverviewWinAtRightBottom NC.ReattachBrowserOverviewWinIfNeeded)

(* * New stuff for NCBROWSERCARD. Put this in with other browser overview global vars, 
functions, etc.)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.BrowserOverviewSpecsStylesheet NC.DefaultWhereToAttachOverviewWin 
	    NC.DefaultBrowserOverviewMode NC.OverviewWinMode.Compress NC.OverviewWinMode.Expand)
)

(RPAQQ NC.OverviewWinMode.Compress Compress% Overview% Win)

(RPAQQ NC.OverviewWinMode.Expand Expand% Overview)

(RPAQQ NC.DefaultBrowserOverviewMode Neither)

(RPAQ? NC.DefaultWhereToAttachOverviewWin (QUOTE (LEFT . TOP)))

(RPAQ? NC.BrowserOverviewSpecsStylesheet (CREATE.STYLE (QUOTE TITLE)
							 "Choose browser overview specs"
							 (QUOTE ITEM.TITLES)
							 (QUOTE (Edge Position% on% Edge Mode))
							 (QUOTE ITEM.TITLE.FONT)
							 (FONTCOPY MENUFONT (QUOTE WEIGHT)
								   (QUOTE BOLD))
							 (QUOTE ITEMS)
							 (LIST (create MENU ITEMS ←
								       (QUOTE ((LEFT LEFT 
								      "Position along left edge.")
									       (TOP TOP 
								       "Position along top edge.")
									       (RIGHT RIGHT 
								     "Position along right edge.")
									       (BOTTOM BOTTOM 
								    "Position along bottom edge."))))
							       (create MENU ITEMS ←
								       (QUOTE ((TOP/RIGHT TOP 
							  "Position at top or right end of edge.")
									       (CENTER CENTER 
								    "Position at center of edge.")
									       (BOTTOM/LEFT BOTTOM 
							    "Position at bottom or left of edge."))))
							       (create MENU ITEMS ←
								       (QUOTE ((
Compress% Overview% Win Compress% Overview% Win 
			"Compress the overview window to exactly fit the overview contents.")
									       (Expand% Overview
										 Expand% Overview 
			      "Expand the overview contents to exactly fill the overview window.")
									       (Neither Neither 
			 "Neither expand the overview contents nor compress the overview window.")))))
							 ))
(DEFINEQ

(NC.AskBrowserOverviewSpecs
  (LAMBDA (BrowserWin)                                       (* rht: "21-Mar-86 01:33")

          (* * Put up stylesheet to get mode and where to attach overview win.)


    (LET ((WhereLastAttached (OR (WINDOWPROP BrowserWin (QUOTE WHERETOATTACHOVERVIEWWIN))
				   NC.DefaultWhereToAttachOverviewWin))
	  (LastMode (OR (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE))
			  NC.DefaultBrowserOverviewMode))
	  OverviewSpecsResults)
         (STYLE.PROP NC.BrowserOverviewSpecsStylesheet (QUOTE SELECTIONS)
		       (LIST (CAR WhereLastAttached)
			       (SELECTQ (CDR WhereLastAttached)
					  ((TOP RIGHT)
					    (QUOTE TOP/RIGHT))
					  ((LEFT BOTTOM)
					    (QUOTE BOTTOM/LEFT))
					  (QUOTE CENTER))
			       LastMode))
         (STYLE.PROP NC.BrowserOverviewSpecsStylesheet (QUOTE POSITION)
		       (create POSITION
				 XCOORD ←(fetch (REGION LEFT) of (WINDOWPROP BrowserWin
										   (QUOTE REGION)))
				 YCOORD ←(fetch (REGION TOP) of (WINDOWREGION BrowserWin))))
         (if (SETQ OverviewSpecsResults (STYLESHEET NC.BrowserOverviewSpecsStylesheet))
	     then (WINDOWPROP BrowserWin (QUOTE WHERETOATTACHOVERVIEWWIN)
				  (CONS (CAR OverviewSpecsResults)
					  (CADR OverviewSpecsResults)))
		    (WINDOWPROP BrowserWin (QUOTE OVERVIEWWINMODE)
				  (CADDR OverviewSpecsResults))
	   else NIL))))

(NC.CompressOverviewWin
  (LAMBDA (OverviewWin GraphWin)                             (* rht: "21-Mar-86 16:03")

          (* * Reshape OverviewWin so it just holds its contents plus the wire frame.)



          (* * rht 3/21/86: Massive rewrite. Notice ugly use of constant 7 in width of NewRegion. This seems necessary 
	  empirically to keep overview from shrinking with successive redisplays.)


    (LET ((CurCLIPPINGRegion (DSPCLIPPINGREGION NIL OverviewWin))
	  (CurRegion (WINDOWREGION OverviewWin))
	  (WireFrameRegion (WINDOWPROP OverviewWin (QUOTE LastWireFrame)))
	  (GraphRegion (GRAPHREGION (WINDOWPROP OverviewWin (QUOTE GRAPH))))
	  (OverviewWinBorder (WINDOWPROP OverviewWin (QUOTE BORDER)))
	  NewRegion)
         (SETQ NewRegion (create REGION using GraphRegion WIDTH ←(PLUS 7 (fetch
										 (REGION WIDTH)
										    of GraphRegion))
				     ))
         (if (OR (NULL WireFrameRegion)
		     (AND (NOT (EQUAL NewRegion CurCLIPPINGRegion))
			    (REGIONSINTERSECTP WireFrameRegion NewRegion))
		     (PROG1 (SUBREGIONP CurCLIPPINGRegion WireFrameRegion)
			      (SETQ NewRegion (EXTENDREGION NewRegion (INTERSECTREGIONS 
										  WireFrameRegion 
										CurCLIPPINGRegion)))))
	     then (SHAPEW OverviewWin (CREATEREGION (fetch (REGION LEFT) of CurRegion)
							  (fetch (REGION BOTTOM) of CurRegion)
							  (PLUS (TIMES 2 OverviewWinBorder)
								  (fetch (REGION WIDTH)
								     of NewRegion))
							  (PLUS (TIMES 2 OverviewWinBorder)
								  (fetch (REGION HEIGHT)
								     of NewRegion))))
		    (NC.ReattachBrowserOverviewWin OverviewWin GraphWin (WINDOWPROP GraphWin
										      (QUOTE 
									 WHERETOATTACHOVERVIEWWIN)))))
    ))

(NC.ReattachBrowserOverviewWin
  (LAMBDA (OverviewWin BrowserWin WhereToAttach)             (* rht: "20-Mar-86 22:58")

          (* * Check to see if OverviewWin is attached at correct place. If not, detach and reattach.)



          (* * rht 3/7/86: No longer checks. Just reattaches.)


    (LET ((Width (fetch (REGION WIDTH) of (WINDOWREGION OverviewWin)))
	  (Height (fetch (REGION HEIGHT) of (WINDOWREGION OverviewWin))))
         (DETACHWINDOW OverviewWin)
         (ATTACHWINDOW OverviewWin BrowserWin (OR (CAR WhereToAttach)
						      (QUOTE LEFT))
			 (OR (CDR WhereToAttach)
			       (QUOTE TOP))
			 (QUOTE LOCALCLOSE))
         (WINDOWDELPROP OverviewWin (QUOTE PASSTOMAINCOMS)
			  (QUOTE SHAPEW))
         (WINDOWPROP BrowserWin (QUOTE OverviewWinWidth)
		       Width)
         (WINDOWPROP BrowserWin (QUOTE OverviewWinHeight)
		       Height)
         (WINDOWPROP OverviewWin (QUOTE MINSIZE)
		       (FUNCTION NC.BrowserOverviewWinMINSIZEFn))
         (WINDOWPROP OverviewWin (QUOTE MAXSIZE)
		       (CONS Width Height)))))
)
(PUTPROPS RHTPATCH034 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (3927 17079 (NC.SetupTitleBarMenu 3937 . 17077)) (17122 19586 (NC.MoveWindowOntoScreen 
17132 . 19584)) (19648 41259 (NC.DrawArrowHead 19658 . 23254) (NC.DrawFlowerLink 23256 . 26006) (
NC.BrowserFixGraphEditMenuFn 26008 . 27423) (NC.MakeLinksLegendMenu 27425 . 29928) (
NC.GetGraphEditMenu 29930 . 31811) (NC.UpdateBrowserCard 31813 . 41257)) (41260 54493 (
NC.MakeBrowserOverviewWin 41270 . 42961) (NC.ShrinkGraphToWindow 42963 . 44905) (NC.ScaleGraphNode 
44907 . 47447) (NC.ComputeOverviewScale 47449 . 48078) (NC.RedrawBrowserOverviewWin 48080 . 49111) (
NC.DrawWireFrameInOverviewWin 49113 . 50742) (NC.BrowserOverviewWinMINSIZEFn 50744 . 51828) (
NC.BrowserOverviewWinButtonEventFn 51830 . 54491)) (56661 61256 (NC.AskBrowserOverviewSpecs 56671 . 
58184) (NC.CompressOverviewWin 58186 . 60078) (NC.ReattachBrowserOverviewWin 60080 . 61254)))))
STOP