(FILECREATED "14-MAR-83 00:22:16" {PHYLUM}<BLUEBONNET>HELPGRAPH.;9 19681  

      changes to:  (FNS DisplayHelpNode)

      previous date: "10-MAR-83 15:25:31" {PHYLUM}<BLUEBONNET>HELPGRAPH.;8)


(* Copyright (c) 1983 by Xerox Corporation)

(PRETTYCOMPRINT HELPGRAPHCOMS)

(RPAQQ HELPGRAPHCOMS ((VARS HelpGraph HelpGraphFont (HelpWindow NIL))
	(RECORDS HELPNODE)
	(FNS AlreadyDefined CreateHelpNode DisplayHelpGraph DisplayHelpNode DrawBox DrawBoxOnSheet 
	     DrawLineOnSheet EHN EHelpGraph EditHelpGraph EditHelpNode GetDrawings GetFlashRegion 
	     GetHelpNode GetSlotToEdit GetTextFromUser GetWindowRegion HandleHelpGraphMenu 
	     MenuItemsFromHelpNode ParseDrawMenu ReadString SearchHelp ShowHelpGraph)))

(RPAQQ HelpGraph ({HELPNODE}#3,163740 {HELPNODE}#3,163710 {HELPNODE}#3,163660 {HELPNODE}#3,163630 
				      {HELPNODE}#3,163600
				      {HELPNODE}#3,163550 {HELPNODE}#3,163520 {HELPNODE}#3,163470 
				      {HELPNODE}#3,163440
				      {HELPNODE}#3,163410 {HELPNODE}#3,163360 {HELPNODE}#3,163330 
				      {HELPNODE}#3,163300))

(RPAQQ HelpGraphFont {FONTDESCRIPTOR}#1,107036)

(RPAQQ HelpWindow NIL)
[DECLARE: EVAL@COMPILE 

(DATATYPE HELPNODE (PARENTS CHILDREN BITMAP BITMAPREGION BEFOREDISPLAYPROC AFTERDISPLAYPROC TEXT 
			    KEYWORDS TITLE NODENAME FLASHREGIONS OVERLAYLIST)
		   KEYWORDS ←(QUOTE (*DEFAULT*)))
]
(/DECLAREDATATYPE (QUOTE HELPNODE)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER 
				  POINTER POINTER POINTER)))
(DEFINEQ

(AlreadyDefined
  [LAMBDA (node)                                             (* dmr: "28-FEB-83 18:53")
                                                             (* return T if this graphNode is already defined in the 
							     HelpGraph)
    (for elt in HelpGraph when (EQUAL node:NODELABEL elt:NAME) do (RETURN T) finally NIL])

(CreateHelpNode
  [LAMBDA (name childNodes parentNodes)                      (* edited: " 4-MAR-83 10:06")
                                                             (* Fill in the slots of a helpnode.)
    (PROG (node r b)
          (node←(create HELPNODE))
          (PRIN1 "
Creating ")
          (PRIN1 name)
          (TERPRI)
          (PRIN1 "What is this node's window title? ")
          (node:TITLE←(ReadString))
          (TERPRI)
          (node:NODENAME←name)
          (if [MENU (create MENU
			    ITEMS ←(QUOTE (("Have own bitmap" T)
					    ("Get bitmap from screen" NIL]
	      then (PRIN1 " ... the name of that bitmap is: ")
		   node:BITMAP←(EVAL (READ))
	    else r←(GETREGION)
		 b←(BITMAPCREATE r:WIDTH r:HEIGHT)
		 (BITBLT (SCREENBITMAP)
			 r:LEFT r:BOTTOM b)                  (* Initialize the bm and the region that describes it.)
		 node:BITMAP←b
		 node:BITMAPREGION←(create REGION
					   LEFT ← 0
					   BOTTOM ← 0
					   WIDTH ← r:WIDTH
					   HEIGHT ← r:HEIGHT))
          (node:PARENTS←parentNodes)
          (node:CHILDREN←childNodes)
          (HelpGraph← < ! HelpGraph node>)
          (RETURN node])

(DisplayHelpGraph
  [LAMBDA NIL                                                (* edited: " 2-MAR-83 16:37")
    (DisplayHelpNode HelpGraph:1])

(DisplayHelpNode
  [LAMBDA (helpnode)                                         (* edited: "14-MAR-83 00:20")
                                                             (* Look at the fields of a helpnode and display them on 
							     the screen.)
    (PROG (menu helpMenu)
          [if HelpWindow=NIL
	      then HelpWindow←(CREATEW (create REGION
					       LEFT ← 500
					       WIDTH ← 500
					       HEIGHT ← 483
					       BOTTOM ← 324))
		   HelpGraphFont←(FONTCREATE (QUOTE TIMESROMAN)
					     12
					     (QUOTE BOLD))
		   (DSPFONT HelpGraphFont (WINDOWPROP HelpWindow (QUOTE DSP)))
		   (WINDOWPROP HelpWindow (QUOTE RIGHTBUTTONFN)
			       (FUNCTION (LAMBDA NIL NIL]
          (CLEARW HelpWindow)
          (if helpnode:BITMAP~=NIL
	      then [if helpnode:BITMAPREGION=NIL
		       then (helpnode:BITMAPREGION←(create REGION
							   LEFT ← 0
							   BOTTOM ← 0
							   HEIGHT ←(WINDOWPROP HelpWindow
									       (QUOTE HEIGHT))
							   WIDTH ←(WINDOWPROP HelpWindow
									      (QUOTE WIDTH]
		   (BITBLT helpnode:BITMAP NIL NIL HelpWindow helpnode:BITMAPREGION:LEFT 
			   helpnode:BITMAPREGION:BOTTOM helpnode:BITMAPREGION:WIDTH 
			   helpnode:BITMAPREGION:HEIGHT))
          (WINDOWPROP HelpWindow (QUOTE TITLE)
		      helpnode:TITLE)                        (* put the value of the currently displayed helpnode 
							     onto the prop list of the window)
          (WINDOWPROP HelpWindow (QUOTE CurrentHelpNode)
		      helpnode)                              (* Display the text. The text is stored as 
							     ((<pos> text) ...))
          (for t in helpnode:TEXT
	     do (DSPXPOSITION t:1:XCOORD HelpWindow)
		(DSPYPOSITION t:1:YCOORD HelpWindow)
		(PRIN1 t:2 HelpWindow))
          (if helpnode:OVERLAYLIST~=NIL
	      then (for line in helpnode:OVERLAYLIST
		      do (DRAWLINE line:1 line:2 line:3 line:4 1 NIL HelpWindow)))
                                                             (* create the menu to move up or down the help graph)
          (menu←(WINDOWPROP HelpWindow (QUOTE HelpMenu)))
          (if menu
	      then (DELETEMENU (WINDOWPROP HelpWindow (QUOTE HelpMenu))
			       T))
          (helpMenu←(create MENU
			    MENUFONT ← HelpGraphFont
			    ITEMS ←(MenuItemsFromHelpNode helpnode)
			    WHENSELECTEDFN ←(QUOTE HandleHelpGraphMenu)
			    TITLE ← "More Available Help"
			    CENTERFLG ← T))
          (ADDMENU helpMenu NIL (create POSITION
					XCOORD ←(fetch LEFT of (WINDOWPROP HelpWindow (QUOTE REGION)))
					YCOORD ←((fetch BOTTOM of (WINDOWPROP HelpWindow
									      (QUOTE REGION)))
					 -helpMenu:IMAGEHEIGHT)))
                                                             (* turn off the RIGHTBUTTON inside of the menu)
          (WINDOWPROP (WFROMMENU helpMenu)
		      (QUOTE RIGHTBUTTONFN)
		      (QUOTE [LAMBDA NIL NIL]))
          (WINDOWPROP HelpWindow (QUOTE HelpMenu)
		      helpMenu)                              (* flash the regions in the flashregions list, if any)
          [if helpnode:FLASHREGIONS
	      then (for i from 1 to 4 do (for region in helpnode:FLASHREGIONS
					    do (BITBLT HelpWindow region:LEFT region:BOTTOM 
						       HelpWindow region:LEFT region:BOTTOM 
						       region:WIDTH region:HEIGHT (QUOTE INVERT))
					       (DISMISS 100]
                                                             (* The after display hook.)
          (if helpnode:AFTERDISPLAYPROC
	      then (EVAL helpnode:AFTERDISPLAYPROC])

(DrawBox
  [LAMBDA (region width window operation)                    (* edited: "13-JAN-83 13:48")
    (PROG NIL
          (DRAWLINE region:LEFT region:BOTTOM region:LEFT+region:WIDTH region:BOTTOM width operation 
		    window)
          (DRAWTO region:LEFT+region:WIDTH region:BOTTOM+region:HEIGHT width operation window)
          (DRAWTO region:LEFT region:BOTTOM+region:HEIGHT width operation window)
          (DRAWTO region:LEFT region:BOTTOM width operation window])

(DrawBoxOnSheet
  [LAMBDA (window)                                           (* edited: " 3-MAR-83 08:46")
    (PROG NIL                                                (* User wants to draw a line.
							     Let him.)
          (boxRegion←(GetWindowRegion window))
          (DrawBox boxRegion 1 window)
          (RETURN <<boxRegion:LEFT boxRegion:BOTTOM boxRegion:LEFT+boxRegion:WIDTH boxRegion:BOTTOM>
		    <boxRegion:LEFT boxRegion:BOTTOM boxRegion:LEFT 
		      boxRegion:BOTTOM+boxRegion:HEIGHT> <boxRegion:LEFT 
							   boxRegion:BOTTOM+boxRegion:HEIGHT 
							   boxRegion:LEFT+boxRegion:WIDTH 
							   boxRegion:BOTTOM+boxRegion:HEIGHT>
		    <boxRegion:LEFT+boxRegion:WIDTH boxRegion:BOTTOM+boxRegion:HEIGHT 
		      boxRegion:LEFT+boxRegion:WIDTH boxRegion:BOTTOM>>])

(DrawLineOnSheet
  [LAMBDA (window)                                           (* edited: " 3-MAR-83 08:07")
    (PROG ((lastPoint NIL))                                  (* User wants to draw a line.
							     Let him.)
          (until ~(MOUSESTATE UP) do NIL)                    (* he has now dropped one end of the line.)
          (pt1← <(LASTMOUSEX window) !(LASTMOUSEY window)
		  >)
          (until (MOUSESTATE UP)
	     do                                              (* Erase the last line if it is there...)
		(if lastPoint~=NIL
		    then (DRAWLINE pt1:XCOORD pt1:YCOORD lastPoint:XCOORD lastPoint:YCOORD 1
				   (QUOTE INVERT)
				   window))                  (* get the new point)
		(pt2← <(LASTMOUSEX window) !(LASTMOUSEY window)
			>)
		(DRAWLINE pt1:XCOORD pt1:YCOORD pt2:XCOORD pt2:YCOORD 1 NIL window)
		(lastPoint←pt2))
          (RETURN <<pt1:XCOORD pt1:YCOORD pt2:XCOORD pt2:YCOORD>>])

(EHN
  [LAMBDA NIL                                                (* edited: " 3-MAR-83 12:37")
    (EditHelpNode (WINDOWPROP HelpWindow (QUOTE CurrentHelpNode])

(EHelpGraph
  [LAMBDA NIL                                                (* edited: " 3-MAR-83 07:28")
    (PROG NIL
          (MENU (create MENU
			ITEMS ←(for elt in HelpGraph collect <elt:TITLE elt:NODENAME>)
			TITLE ← "Edit Help Graph Menu"
			WHENSELECTEDFN ←(QUOTE (LAMBDA (X)
						       (EditHelpNode (GetHelpNode (CADR X])

(EditHelpGraph
  [LAMBDA (font)                                             (* edited: " 8-MAR-83 19:28")
    (PROG (graph nodeList)
          (SETQ nodeList (for node in HelpGraph collect (NODECREATE (fetch NODENAME of node)
								    (fetch NODENAME of node)
								    NIL
								    (for x
								       in (fetch PARENTS
									     of node)
								       collect x)
								    (for x
								       in (fetch CHILDREN
									     of node)
								       collect x)
								    font)))
          [EDITGRAPH1 (SETQ W (SHOWGRAPH (LAYOUTFOREST nodeList (fetch NODENAME of (CAR HelpGraph))
						       NIL font]
          (SETQ HelpGraph (for elt in list when (NOT (AlreadyDefined elt HelpGraph)) collect
										      (foo])

(EditHelpNode
  [LAMBDA (node)                                             (* edited: "10-MAR-83 11:08")
                                                             (* Fill in the slots of a helpnode.)
    (PROG (r b)
          (PRIN1 "Editing helpnode: ")
          (PRIN1 node:NODENAME)
          (TERPRI)
          (while T
	     do ((SELECTQ (GetSlotToEdit)
			  (QUIT (RETURN node))
			  (PARENTS (TERPRI)
				   (PRIN1 "Current parent's list = ")
				   (PRIN1 node:PARENTS)
				   (TERPRI)
				   (PRIN1 "Parents list? ")
				   node:PARENTS←
				   (READ))
			  (CHILDREN (TERPRI)
				    (PRIN1 "Children list? ")
				    (PRIN1 "Current children list = ")
				    (PRIN1 node:CHILDREN)
				    (TERPRI)
				    node:CHILDREN←
				    (READ))
			  (BITMAP (PRIN1 node:BITMAP)
				  node:BITMAPREGION←NIL
				  (if [MENU (create MENU
						    ITEMS ←(QUOTE (("Have own bitmap" T)
								    ("Get bitmap from screen" NIL]
				      then (PRIN1 " ... the name of that bitmap is: ")
					   node:BITMAP←(EVAL (READ))
				    else r←(GETREGION)
					 b←(BITMAPCREATE r:WIDTH r:HEIGHT)
					 (BITBLT (SCREENBITMAP)
						 r:LEFT r:BOTTOM b)
					 node:BITMAP←b
					 node:BITMAPREGION←(create REGION
								   LEFT ← 0
								   BOTTOM ← 0
								   WIDTH ← r:WIDTH
								   HEIGHT ← r:HEIGHT)))
			  (BITMAPREGION b←node:BITMAP node:BITMAPREGION←
					(GETBOXREGION node:BITMAPREGION:WIDTH 
						      node:BITMAPREGION:HEIGHT
						      (if node:BITMAPREGION=NIL
							  then 0
							else node:BITMAPREGION:LEFT)
						      (if node:BITMAPREGION=NIL
							  then 0
							else node:BITMAPREGION:WIDTH)
						      HelpWindow))
			  (RESETBITMAPREGION (PRIN1 "Bitmap moved back to lower left corner.")
					     (TERPRI)
					     node:BITMAPREGION:LEFT←0 node:BITMAPREGION:BOTTOM←0)
			  (BEFOREDISPLAYPROC (PRIN1 "What would you like for the BEFOREDISPLAYPROC? ")
					     node:BEFOREDISPLAYPROC←
					     (READ))
			  (AFTERDISPLAYPROC (PRIN1 "What would you like for the AFTERDISPLAYPROC? ")
					    node:AFTERDISPLAYPROC←
					    (READ))
			  (NEWTEXT (TERPRI)
				   (PRIN1 "New text? ")
				   node:TEXT←
				   (GetTextFromUser))
			  (ADDTEXT (PRIN1 "Adding text to existing text")
				   node:TEXT← < ! node:TEXT ! (GetTextFromUser)
				   >)
			  [KEYWORDS (TERPRI)
				    (PRIN1 "New keywords? ")
				    (if node:KEYWORDS
					then (ev (fetch KEYWORDS of node))
				      else (node:KEYWORDS←(READ]
			  (TITLE (TERPRI)
				 (PRIN1 "New Node Window Title: ")
				 node:TITLE←
				 (ReadString))
			  (NODENAME node:NODENAME←name)
			  (ADDLINES node:OVERLAYLIST← < ! node:OVERLAYLIST ! (GetDrawings)
				    >)
			  (NEWLINES node:OVERLAYLIST← (GetDrawings))
			  (ADDFLASHREGION node:FLASHREGIONS← < ! node:OVERLAYLIST ! (GetFlashRegion)
					  >)
			  (NEWFLASHREGIONS node:FLASHREGIONS← (GetFlashRegion))
			  (PRIN1 "Default -- strange selection "))
		 (DisplayHelpNode node)))
          (TERPRI)
          (RETURN node])

(GetDrawings
  [LAMBDA NIL                                                (* edited: " 3-MAR-83 08:00")
    (MENU (create MENU
		  WHENSELECTEDFN ←(QUOTE ParseDrawMenu)
		  ITEMS ←(QUOTE (("Line" DRAWLINE 
					 "If you select this, you can draw a line on the window")
				  ("Box" DRAWBOX "Draws a box on the helpnode window.")))
		  CENTERFLG ← T])

(GetFlashRegion
  [LAMBDA NIL                                                (* edited: " 3-MAR-83 09:02")
    (PROG (tmp)
          (TERPRI PROMPTWINDOW)
          (PRIN1 "Select a region to have flashed during helpnode display" PROMPTWINDOW)
          (tmp← <(GetWindowRegion HelpWindow)
		  >)                                         (* check to see if the region is on the window, if not, 
							     then return NIL)
          (if [INTERSECTREGIONS tmp:1 (DSPCLIPPINGREGION NIL (WINDOWPROP HelpWindow (QUOTE DSP]
	      then (RETURN tmp)
	    else (RETURN NIL])

(GetHelpNode
  [LAMBDA (name)                                             (* DMR: " 1-MAR-83 12:45")
    (for x in HelpGraph
       when (EQUAL name x:NODENAME) or (EQUAL name x) do (RETURN x])

(GetSlotToEdit
  [LAMBDA NIL                                                (* edited: " 4-MAR-83 10:14")
    (MENU (create MENU
		  ITEMS ←(QUOTE (("Parents" (QUOTE PARENTS))
				  ("Children" (QUOTE CHILDREN))
				  ("Bitmap" (QUOTE BITMAP))
				  ("Bitmap Region" (QUOTE BITMAPREGION))
				  ("Reset Bitmap Region" (QUOTE RESETBITMAPREGION))
				  ("Before DisplayProc" (QUOTE BEFOREDISPLAYPROC))
				  ("AfterDisplayProc" (QUOTE AFTERDISPLAYPROC))
				  ("Add Text" (QUOTE ADDTEXT))
				  ("Replace existing text" (QUOTE NEWTEXT))
				  ("Keywords" (QUOTE KEYWORDS))
				  ("Window Title" (QUOTE TITLE))
				  ("Node name" (QUOTE NODENAME))
				  ("Add Flash Region" (QUOTE ADDFLASHREGION))
				  ("Replace Flash Regions" (QUOTE NEWFLASHREGIONS))
				  ("Add drawings" (QUOTE ADDLINES))
				  ("Replace drawings" (QUOTE NEWLINES))
				  ("Quit" (QUOTE QUIT])

(GetTextFromUser
  [LAMBDA NIL                                                (* edited: " 2-MAR-83 16:44")
                                                             (* Return a list of (position text) pairs)
    (while T bind txt
       collect (TERPRI)
	       (PRIN1 "Enter a line of text: ")
	       (txt←(ReadString))
	       (TERPRI)
	       (if (UNPACK txt)=NIL
		   then (RETURN $$VAL))
	       (PRIN1 "Point to a display position")
	       (<(GETPOSITION HelpWindow)
		 txt>])

(GetWindowRegion
  [LAMBDA (window)                                           (* edited: "15-DEC-82 08:43")
                                                             (* Return a region in window coords)
    (PROG NIL
          (r←(GETREGION))
          (wRegion←(WINDOWPROP window (QUOTE REGION)))
          (clippingRegion←(DSPCLIPPINGREGION NIL window))    (* Get relative window coords.)
          (r:LEFT←r:LEFT-wRegion:LEFT)
          (r:BOTTOM←r:BOTTOM-wRegion:BOTTOM)                 (* Make absolute coords.)
          (r:LEFT←r:LEFT+clippingRegion:LEFT)
          (r:BOTTOM←r:BOTTOM+clippingRegion:BOTTOM)
          (RETURN r])

(HandleHelpGraphMenu
  [LAMBDA (item)                                             (* DMR: " 1-MAR-83 12:55")
                                                             (* Given a menu item, do the correct thing...)
    (PROG name
          (name←item:2)
          (DisplayHelpNode (GetHelpNode name])

(MenuItemsFromHelpNode
  [LAMBDA (node)                                             (* edited: " 3-MAR-83 09:43")
                                                             (* return a list of items suitable for a menu given a 
							     helpnode)
    (PROG NIL

          (* Collect all of the parent nodes which have legal definitions. Do this filter because we may refer to a helpnode
	  which hasn't been defined yet.)


          (parentNodes←(for x in node:PARENTS when (GetHelpNode x) collect <(GetHelpNode x):TITLE
									     (GetHelpNode x)
									     :NODENAME>))
          (childNodes←(for x in node:CHILDREN when (GetHelpNode x) collect <(GetHelpNode x):TITLE
									     (GetHelpNode x)
									     :NODENAME>))
          (RETURN < ! parentNodes ! childNodes>])

(ParseDrawMenu
  [LAMBDA (args)                                             (* edited: " 3-MAR-83 07:52")
    (SELECTQ args:2
	     (DRAWLINE (DrawLineOnSheet HelpWindow))
	     (DRAWBOX (DrawBoxOnSheet HelpWindow))
	     (PRINT "This shouldn't happen to a nice guy like you."])

(ReadString
  [LAMBDA NIL                                                (* edited: " 2-MAR-83 16:58")
    (PROG ((x (COPYREADTABLE)))
          (SETBRK <(CHARCODE SPACE) > 0 x)
          (CLEARBUF)
          (RETURN (RSTRING NIL x])

(SearchHelp
  [LAMBDA (keywords)                                         (* edited: " 4-MAR-83 15:31")

          (* Bring up the BlueBonnet help window with an appropriate node in the graph. Input is a list of keywords...
	  presumably atoms from the user's plan ... that describes what he needs to know.)


    (if ~(for node in HelpGraph do (if (INTERSECTION keywords node:KEYWORDS)
				       then (DisplayHelpNode node)
					    (RETURN T)))
	then (DisplayHelpNode HelpGraph:1])

(ShowHelpGraph
  [LAMBDA (font)                                             (* dmr: "28-FEB-83 18:23")
    (PROG (graph nodeList)
          (nodeList←(for node in HelpGraph collect (NODECREATE node:NODENAME node:NODENAME NIL
							       (for x in node:PARENTS collect x:1)
							       (for x in node:CHILDREN collect x:1)
							       font)))
          (SHOWGRAPH (LAYOUTFOREST nodeList HelpGraph:1:NODENAME NIL font])
)
(PUTPROPS HELPGRAPH COPYRIGHT ("Xerox Corporation" 1983))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1516 19601 (AlreadyDefined 1526 . 1897) (CreateHelpNode 1899 . 3087) (DisplayHelpGraph 
3089 . 3244) (DisplayHelpNode 3246 . 6889) (DrawBox 6891 . 7374) (DrawBoxOnSheet 7376 . 8178) (
DrawLineOnSheet 8180 . 9141) (EHN 9143 . 9316) (EHelpGraph 9318 . 9683) (EditHelpGraph 9685 . 10529) (
EditHelpNode 10531 . 13613) (GetDrawings 13615 . 13977) (GetFlashRegion 13979 . 14574) (GetHelpNode 
14576 . 14797) (GetSlotToEdit 14799 . 15673) (GetTextFromUser 15675 . 16199) (GetWindowRegion 16201 . 
16860) (HandleHelpGraphMenu 16862 . 17184) (MenuItemsFromHelpNode 17186 . 18054) (ParseDrawMenu 18056
 . 18350) (ReadString 18352 . 18593) (SearchHelp 18595 . 19130) (ShowHelpGraph 19132 . 19599)))))
STOP