(FILECREATED " 8-May-86 11:12:55" {PHYLUM}<PAPERWORKS>STU.;1 7225   

      changes to:  (VARS STUCOMS)
		   (FNS TRACK.BITMAP))


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

(PRETTYCOMPRINT STUCOMS)

(RPAQQ STUCOMS ((FNS TRACK.BITMAP SK.TRACK.BITMAP1)))
(DEFINEQ

(TRACK.BITMAP
  [LAMBDA (W BITMAP BUFFER.BITMAP WIDTH HEIGHT OPERATION XOFFSET YOFFSET)
                                                             (* rrb " 8-May-86 11:12")

          (* tracks BITMAP until a button goes down and comes up. Returns a list of (ongrid? position) so that caller can 
	  know whether the point chosen was on a grid or not.)

                                                             (* there is other code in BIGFONT that is probably 
							     better for this.)
    (PROG [DOWN LEFT BOTTOM NEW.LEFT NEW.BOTTOM GRID.LEFT GRID.BOTTOM ONGRID? NEARPOS
		  (DSP (WINDOWPROP W (QUOTE DSP]
	    (OR XOFFSET (SETQ XOFFSET 0))
	    (OR YOFFSET (SETQ YOFFSET 0))
	    (TOTOPW W)
	    (RETURN (until (AND DOWN (LASTMOUSESTATE UP))
			 do (GETMOUSESTATE)
			      (COND
				((LASTMOUSESTATE (NOT UP))
				  (SETQ DOWN T)))
			      (SETQ NEW.LEFT (LASTMOUSEX DSP))
			      (SETQ NEW.BOTTOM (LASTMOUSEY DSP))
			      [COND
				((OR (NEQ NEW.LEFT LEFT)
				       (NEQ NEW.BOTTOM BOTTOM))
                                                             (* cursor changed position check if grid pt moved.)
				  (SETQ LEFT NEW.LEFT)
				  (SETQ BOTTOM NEW.BOTTOM)
				  (COND
				    ((OR (NEQ NEW.LEFT GRID.LEFT)
					   (NEQ NEW.BOTTOM GRID.BOTTOM))
                                                             (* grid location changed, move the text image.)
				      [COND
					(GRID.LEFT (BITBLT BUFFER.BITMAP 0 0 W (IPLUS GRID.LEFT 
											  XOFFSET)
							     (IPLUS GRID.BOTTOM YOFFSET)
							     WIDTH HEIGHT (QUOTE INPUT)
							     (QUOTE REPLACE]
				      (SETQ GRID.LEFT NEW.LEFT)
				      (SETQ GRID.BOTTOM NEW.BOTTOM)
				      (BITBLT W (IPLUS GRID.LEFT XOFFSET)
						(IPLUS GRID.BOTTOM YOFFSET)
						BUFFER.BITMAP 0 0 NIL NIL (QUOTE INPUT)
						(QUOTE REPLACE))
				      (BITBLT BITMAP 0 0 DSP (IPLUS GRID.LEFT XOFFSET)
						(IPLUS GRID.BOTTOM YOFFSET)
						WIDTH HEIGHT (QUOTE INPUT)
						OPERATION]
			 finally                           (* restore screen)
				   (BITBLT BUFFER.BITMAP 0 0 W (IPLUS GRID.LEFT XOFFSET)
					     (IPLUS GRID.BOTTOM YOFFSET)
					     WIDTH HEIGHT (QUOTE INPUT)
					     (QUOTE REPLACE))
                                                             (* return the position if any part of the bitmap is 
							     visible.)
				   (RETURN (create POSITION
						       XCOORD ← GRID.LEFT
						       YCOORD ← GRID.BOTTOM])

(SK.TRACK.BITMAP1
  [LAMBDA (W BITMAP BUFFER.BITMAP WIDTH HEIGHT OPERATION XOFFSET YOFFSET)
                                                             (* rrb "27-Sep-85 19:12")

          (* tracks BITMAP until a button goes down and comes up. Returns a list of (ongrid? position) so that caller can 
	  know whether the point chosen was on a grid or not.)

                                                             (* there is other code in BIGFONT that is probably 
							     better for this.)
    (PROG (DOWN LEFT BOTTOM NEW.LEFT NEW.BOTTOM GRID.LEFT GRID.BOTTOM ONGRID? NEARPOS
		  (DSP (WINDOWPROP W (QUOTE DSP)))
		  (USEGRID (WINDOWPROP W (QUOTE USEGRID)))
		  (GRID (SK.GRIDFACTOR W))
		  (SCALE (WINDOW.SCALE W))
		  (HOTSPOTCACHE (SK.HOTSPOT.CACHE W)))
	    (OR XOFFSET (SETQ XOFFSET 0))
	    (OR YOFFSET (SETQ YOFFSET 0))
	    (TOTOPW W)
	    (RETURN (until (AND DOWN (LASTMOUSESTATE UP))
			 do (GETMOUSESTATE)
			      (COND
				((LASTMOUSESTATE (NOT UP))
				  (SETQ DOWN T)))
			      (SETQ NEW.LEFT (LASTMOUSEX DSP))
			      (SETQ NEW.BOTTOM (LASTMOUSEY DSP))
			      [COND
				((OR (NEQ NEW.LEFT LEFT)
				       (NEQ NEW.BOTTOM BOTTOM))
                                                             (* cursor changed position check if grid pt moved.)
				  (SKETCHW.UPDATE.LOCATORS W)
				  (SETQ LEFT NEW.LEFT)
				  (SETQ BOTTOM NEW.BOTTOM)
				  [COND
				    ((AND HOTSPOTCACHE (LASTMOUSESTATE MIDDLE)
					    (SETQ NEARPOS (NEAREST.HOT.SPOT HOTSPOTCACHE NEW.LEFT 
										NEW.BOTTOM)))
                                                             (* on middle, pick the closest point)
				      (SETQ ONGRID? NIL)
				      (SETQ NEW.LEFT (fetch (POSITION XCOORD) of NEARPOS))
				      (SETQ NEW.BOTTOM (fetch (POSITION YCOORD) of NEARPOS)))
				    ((SETQ ONGRID? (COND
					  ((LASTMOUSESTATE RIGHT)
                                                             (* if right is down, flip sense of using grid)
					    (NOT USEGRID))
					  (T                 (* otherwise use the grid if told to.)
					     USEGRID)))
				      (SETQ NEW.LEFT (MAP.WINDOW.ONTO.GRID NEW.LEFT SCALE GRID))
				      (SETQ NEW.BOTTOM (MAP.WINDOW.ONTO.GRID NEW.BOTTOM SCALE 
										 GRID]
				  (COND
				    ((OR (NEQ NEW.LEFT GRID.LEFT)
					   (NEQ NEW.BOTTOM GRID.BOTTOM))
                                                             (* grid location changed, move the text image.)
				      [COND
					(GRID.LEFT (BITBLT BUFFER.BITMAP 0 0 W (IPLUS GRID.LEFT 
											  XOFFSET)
							     (IPLUS GRID.BOTTOM YOFFSET)
							     WIDTH HEIGHT (QUOTE INPUT)
							     (QUOTE REPLACE]
				      (SETQ GRID.LEFT NEW.LEFT)
				      (SETQ GRID.BOTTOM NEW.BOTTOM)
				      (BITBLT W (IPLUS GRID.LEFT XOFFSET)
						(IPLUS GRID.BOTTOM YOFFSET)
						BUFFER.BITMAP 0 0 NIL NIL (QUOTE INPUT)
						(QUOTE REPLACE))
				      (BITBLT BITMAP 0 0 DSP (IPLUS GRID.LEFT XOFFSET)
						(IPLUS GRID.BOTTOM YOFFSET)
						WIDTH HEIGHT (QUOTE INPUT)
						OPERATION]
			 finally                           (* restore screen)
				   (BITBLT BUFFER.BITMAP 0 0 W (IPLUS GRID.LEFT XOFFSET)
					     (IPLUS GRID.BOTTOM YOFFSET)
					     WIDTH HEIGHT (QUOTE INPUT)
					     (QUOTE REPLACE))
                                                             (* return the position if any part of the bitmap is 
							     visible.)
				   (RETURN (AND (INTERSECTREGIONS (DSPCLIPPINGREGION NIL DSP)
									(CREATEREGION (IPLUS
											  LEFT 
											  XOFFSET)
											(IPLUS
											  BOTTOM 
											  YOFFSET)
											WIDTH HEIGHT))
						    (create INPUTPT
							      INPUT.ONGRID? ← ONGRID?
							      INPUT.POSITION ←(create POSITION
											XCOORD ← 
											GRID.LEFT
											YCOORD ← 
										      GRID.BOTTOM])
)
(PUTPROPS STU COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (288 7151 (TRACK.BITMAP 298 . 2974) (SK.TRACK.BITMAP1 2976 . 7149)))))
STOP