(FILECREATED "30-Mar-87 23:03:53" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH232.;1 8503   

      changes to:  (VARS RHTPATCH232COMS)
		   (FNS NC.GETPROMPTWINDOW))


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

(PRETTYCOMPRINT RHTPATCH232COMS)

(RPAQQ RHTPATCH232COMS ((* * More ATTACHEDWINDOWS hacking. This time to get the unstacking and 
			     restacking of attachedwindows right during reshaping of the prompt 
			     window.)
			  (* * Change to NCINTERFACE)
			  (FNS NC.GETPROMPTWINDOW)))
(* * More ATTACHEDWINDOWS hacking. This time to get the unstacking and restacking of 
attachedwindows right during reshaping of the prompt window.)

(* * Change to NCINTERFACE)

(DEFINEQ

(NC.GETPROMPTWINDOW
  (LAMBDA (MAINWINDOW #LINES FONT DONTCREATE MINWIDTH)     (* rht: "30-Mar-87 23:03")

          (* makes sure that MAINWINDOW has an attached promptwindow and returns it. If one already exists, it is shaped to 
	  be at least #LINES high. If FONT is NIL, the font of the main window is used for the promptwindow.)



          (* * fgh 6/6/86 Adapted from system GETPROMPTWINDOW. Added MINWIDTH arg.)



          (* * rht 7/2/86: Now attaches prompt window on right if near right edge of screen.)



          (* * rht 7/4/86: Yanked out PositionOnEdge localvar. Put code in place.)



          (* * rht 3/21/87: AttachWindowPositionOnEdge to attach prompt window is left if possible, then center, then right.
	  Also doesn't let prompt window be wider than screen.)



          (* * rht 3/30/87: More ATTACHEDWINDOWS hacking. This time to get the unstacking and restacking of attachedwindows 
	  right during reshaping of the prompt window.)


    (DECLARE (GLOBALVARS WBorder))
    (AND MINWIDTH (SETQ MINWIDTH (MIN (DIFFERENCE SCREENWIDTH (TIMES WBorder 2))
					    MINWIDTH)))
    (PROG ((PWINDOWPROP (WINDOWPROP MAINWINDOW (QUOTE PROMPTWINDOW)))
	     (PWINDOWMINWIDTH (WINDOWPROP MAINWINDOW (QUOTE PROMPTWINDOWMINWIDTH)))
	     (MAINWINDOWREGION (WINDOWPROP MAINWINDOW (QUOTE REGION)))
	     PWINDOW PWINDOWREGION WIDTH HEIGHT OBSCUREDHEIGHT PWINDOW.PWINDOW PWinWidth 
	     AttachWindowPositionOnEdge)
	    (SETQ PWinWidth (WIDTHIFWINDOW (OR MINWIDTH PWINDOWMINWIDTH 1)))
	    (SETQ AttachWindowPositionOnEdge (COND
		((LEQ (PLUS (fetch (REGION LEFT) of MAINWINDOWREGION)
				PWinWidth)
			SCREENWIDTH)
		  (QUOTE LEFT))
		((LEQ (PLUS (fetch (REGION LEFT) of MAINWINDOWREGION)
				(LRSH (PLUS PWinWidth (fetch (REGION WIDTH) of 
										 MAINWINDOWREGION))
					1))
			SCREENWIDTH)
		  (QUOTE CENTER))
		(T (QUOTE RIGHT))))
	    (COND
	      (DONTCREATE (RETURN (CAR PWINDOWPROP)))
	      (PWINDOWPROP (SETQ PWINDOW (CAR PWINDOWPROP))
			   (COND
			     ((NOT (OPENWP PWINDOW))
			       (ATTACHWINDOW PWINDOW MAINWINDOW (QUOTE TOP)
					       AttachWindowPositionOnEdge
					       (QUOTE LOCALCLOSE))))
			   (if (SETQ PWINDOW.PWINDOW (WINDOWPROP PWINDOW (QUOTE PROMPTWINDOW))
				   )
			       then                        (* This prompt window has a prompt window of its own.
							     Close and detach it.)
				      (REMOVEWINDOW (CAR PWINDOW.PWINDOW)))
			   (WINDOWPROP PWINDOW (QUOTE MAXSIZE)
					 (CONS 64000 64000))
			   (WINDOWPROP PWINDOW (QUOTE MINSIZE)
					 (CONS 1 1))
			   (SETQ HEIGHT (HEIGHTIFWINDOW (TIMES (OR #LINES (CDR PWINDOWPROP)
									   1)
								     (FONTPROP (DSPFONT NIL 
											  PWINDOW)
										 (QUOTE HEIGHT)))))
			   (SETQ WIDTH (MAX PWinWidth (fetch (REGION WIDTH) of 
										 MAINWINDOWREGION)))
			   (SETQ PWINDOWREGION (WINDOWPROP PWINDOW (QUOTE REGION)))
			   (COND
			     ((OR (NOT (EQP HEIGHT (fetch (REGION HEIGHT) of PWINDOWREGION))
					   )
				    (NOT (EQP WIDTH (fetch (REGION WIDTH) of PWINDOWREGION))))
                                                             (* Window exists, but not right size.
							     Keep windows detached during reshaping in case 
							     AttachWindowPositionOnEdge has changed.)

          (* * Need to distinguish among the windows attached to MAINWINDOW between those attached before PWINDOW and those 
	  attached after. The latter need to be reattached at AttachWindowPositionOnEdge after PWINDOW is reshaped.)


			       (LET ((DescriptionList (for Win in (ATTACHEDWINDOWS MAINWINDOW)
							 bind WA
							 when (EQ (QUOTE TOP)
								      (CAR (SETQ WA
									       (WINDOWPROP
										 Win
										 (QUOTE 
										    WHEREATTACHED)))))
							 collect 
                                                             (* Detach attached windows at the top of the main Win 
							     and retuirn a list describing their attachment.)
								   (PROG1
								     (LIST Win (CDR WA)
									     (WINDOWPROP
									       Win
									       (QUOTE 
										   PASSTOMAINCOMS)))
								     (DETACHWINDOW Win)))))
                                                             (* Have to smash these to let SHAPEW work.)
				    (WINDOWPROP PWINDOW (QUOTE MAXSIZE)
						  NIL)
				    (WINDOWPROP PWINDOW (QUOTE MINSIZE)
						  NIL)
				    (WINDOWPROP PWINDOW (QUOTE PASSTOMAINCOMS)
						  NIL)
				    (WINDOWPROP PWINDOW (QUOTE OPENFN)
						  NIL)
				    (SHAPEW PWINDOW
					      (create REGION
						 using PWINDOWREGION HEIGHT ← HEIGHT WIDTH ← WIDTH))

          (* * Now reattach all the windows in order to their old locations, except that PWINDOW and those after it should be
	  attached at AttachWindowPositionOnEdge.)


				    (for WindowDescription in DescriptionList bind SeenPWINDOW
				       do (LET ((Win (CAR WindowDescription)))
					         (if (EQ Win PWINDOW)
						     then (SETQ SeenPWINDOW T))
					         (ATTACHWINDOW Win MAINWINDOW (QUOTE TOP)
								 (if SeenPWINDOW
								     then 
								       AttachWindowPositionOnEdge
								   else (CADR WindowDescription)))
					         (WINDOWPROP Win (QUOTE PASSTOMAINCOMS)
							       (CADDR WindowDescription)))))
			       (RPLACD PWINDOWPROP #LINES)
                                                             (* Fall through to check visibility)
			       )))
	      (T (SETQ PWINDOW (CREATEW (create REGION
						      LEFT ← 0
						      BOTTOM ← 0
						      WIDTH ←(MAX PWinWidth (fetch (REGION WIDTH)
										 of 
										 MAINWINDOWREGION))
						      HEIGHT ←(SETQ HEIGHT
							(HEIGHTIFWINDOW
							  (TIMES (OR #LINES (SETQ #LINES 1))
								   (FONTPROP (OR FONT
										     (SETQ FONT
										       (DSPFONT
											 NIL 
										       MAINWINDOW)))
									       (QUOTE HEIGHT))))))
					    NIL NIL T))
		 (DSPSCROLL T PWINDOW)
		 (DSPFONT FONT PWINDOW)
		 (WINDOWPROP PWINDOW (QUOTE PAGEFULLFN)
			       (QUOTE NILL))
		 (ATTACHWINDOW PWINDOW MAINWINDOW (QUOTE TOP)
				 AttachWindowPositionOnEdge
				 (QUOTE LOCALCLOSE))
		 (WINDOWPROP MAINWINDOW (QUOTE PROMPTWINDOW)
			       (CONS PWINDOW #LINES))
		 (WINDOWPROP PWINDOW (QUOTE OPENFN)
			       (FUNCTION \PROMPTWINDOW.OPENFN))))
	    (COND
	      ((ILESSP (SETQ OBSCUREDHEIGHT (IDIFFERENCE SCREENHEIGHT
							       (fetch (REGION TOP)
								  of (WINDOWPROP PWINDOW
										     (QUOTE REGION))
									)))
			 0)                                  (* Promptwindow off screen at top, so slip window 
							     group down to make it visible)
		(RELMOVEW MAINWINDOW (create POSITION
						 XCOORD ← 0
						 YCOORD ← OBSCUREDHEIGHT))))
	    (WINDOWPROP PWINDOW (QUOTE MINSIZE)
			  (CONS 1 HEIGHT))
	    (WINDOWPROP PWINDOW (QUOTE MAXSIZE)
			  (CONS 64000 HEIGHT))
	    (WINDOWPROP MAINWINDOW (QUOTE PROMPTWINDOWMINWIDTH)
			  (OR MINWIDTH 1))
	    (OPENW PWINDOW)
	    (RETURN PWINDOW))))
)
(PUTPROPS RHTPATCH232 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (711 8421 (NC.GETPROMPTWINDOW 721 . 8419)))))
STOP