(FILECREATED "11-OCT-83 18:19:31" {PHYLUM}<LISPCORE>LIBRARY>BITMAPOBJ.;2 11905  

      changes to:  (VARS BITMAPOBJCOMS)

      previous date: "28-AUG-83 13:13:28" {PHYLUM}<LISPCORE>LIBRARY>BITMAPOBJ.;1)


(* Copyright (c) 1983 by Xerox Corporation)

(PRETTYCOMPRINT BITMAPOBJCOMS)

(RPAQQ BITMAPOBJCOMS ((FNS BITMAPTEDITOBJ UPDATEBITMAPOBJ COERCETOBITMAP PROMPTFOREVALED 
			   WINDOWTITLEFONT \WOUT)
		      (* fns for the bitmap tedit object.)
		      (FNS BMOBJ.COPYFN BMOBJ.DELETEFN BMOBJ.DISPLAYFN BMOBJ.EDITFN BMOBJ.GETFN 
			   BMOBJ.INSERTFN BMOBJ.PUTFN BMOBJ.SHOWSELFN BMOBJ.SIZEFN)
		      (RECORDS BITMAPOBJ TEDITUSEROBJ)
		      (* make ↑O be a character that inserts an object read from the user. and ↑P be 
			 the character to edit them.)
		      (FNS GET.OBJ.FROM.USER)
		      (P (TEDIT.SETFUNCTION 15 (FUNCTION GET.OBJ.FROM.USER)
					    TEDIT.READTABLE)
			 (TEDIT.SETFUNCTION 16 (FUNCTION TEDIT.EDIT.OBJECT)
					    TEDIT.READTABLE))
		      (FILES EDITBITMAP)))
(DEFINEQ

(BITMAPTEDITOBJ
  [LAMBDA (BITMAP SCALEFACTOR ROTATION)                      (* rrb "26-AUG-83 11:15")
                                                             (* returns the tedit obj which gives the functional 
							     information for a bitmap object in a tedit file.)
    (create BITMAPOBJ
	    TEDITOBJ ←(create TEDITOBJ
			      SIZEFN ←(FUNCTION BMOBJ.SIZEFN)
			      XSIZE ←(BITMAPWIDTH BITMAP)
			      YSIZE ←(BITMAPHEIGHT BITMAP)
			      YDESC ← 0
			      YASC ←(BITMAPHEIGHT BITMAP)
			      SELFN ←(FUNCTION NILL)
			      BITS ← BITMAP
			      EXTENDFN ←(FUNCTION NILL)
			      SELSHOWFN ←(FUNCTION BMOBJ.SHOWSELFN)
			      SELFINALFN ←(FUNCTION NILL)
			      DISPLAYFN ←(FUNCTION BMOBJ.DISPLAYFN)
			      INSERTFN ←(FUNCTION BMOBJ.INSERTFN)
			      DELETEFN ←(FUNCTION BMOBJ.DELETEFN)
			      COPYFN ←(FUNCTION BMOBJ.COPYFN)
			      GETFN ←(FUNCTION BMOBJ.GETFN)
			      PUTFN ←(FUNCTION BMOBJ.PUTFN)
			      MOVEFN ←(FUNCTION NILL)
			      EDITFN ←(FUNCTION BMOBJ.EDITFN))
	    BITMAP ← BITMAP
	    BMOBJSCALEFACTOR ←(OR SCALEFACTOR 1)
	    BMOBJROTATION ←(OR ROTATION 0])

(UPDATEBITMAPOBJ
  [LAMBDA (BMOBJ)                                            (* rrb "19-AUG-83 17:36")
                                                             (* updates the TEXTOBJ fields of the tedit bitmap object
							     from the bitmap field.)
    (PROG ((BITMAP (fetch (BITMAPOBJ BITMAP) of BMOBJ))
	   (TEOBJ (fetch (BITMAPOBJ TEDITOBJ) of BMOBJ)))
          (replace (TEDITOBJ XSIZE) of TEOBJ with (BITMAPWIDTH BITMAP))
          (replace (TEDITOBJ YSIZE) of TEOBJ with (BITMAPHEIGHT BITMAP))
          (replace (TEDITOBJ YASC) of TEOBJ with (BITMAPHEIGHT BITMAP))
          (RETURN BMOBJ])

(COERCETOBITMAP
  [LAMBDA (BMSPEC)                                           (* rrb "26-AUG-83 12:55")
                                                             (* tries to interpret X as a spec for a bitmap.)
    (PROG (BM CR)
          (RETURN (COND
		    ((BITMAPP BMSPEC)
		      BMSPEC)
		    [(LITATOM BMSPEC)                        (* use value.)
		      (COND
			((BITMAPP (EVALV BMSPEC (QUOTE COERCETOBITMAP]
		    ((REGIONP BMSPEC)                        (* if BMSPEC is a region, treat it as a region of the 
							     screen.)
		      [SETQ BM (BITMAPCREATE (fetch (REGION WIDTH) of BMSPEC)
					     (fetch (REGION HEIGHT) of BMSPEC)
					     (BITSPERPIXEL (SCREENBITMAP]
		      (BITBLT (SCREENBITMAP)
			      (fetch (REGION LEFT) of BMSPEC)
			      (fetch (REGION BOTTOM) of BMSPEC)
			      BM 0 0 NIL NIL (QUOTE INPUT)
			      (QUOTE REPLACE))
		      BM)
		    ((WINDOWP BMSPEC)
		      [SETQ BM (BITMAPCREATE (WINDOWPROP BMSPEC (QUOTE WIDTH))
					     (WINDOWPROP BMSPEC (QUOTE HEIGHT]
                                                             (* open the window and bring it to the top.)
		      (TOTOPW BMSPEC)
		      (SETQ CR (DSPCLIPPINGREGION NIL BMSPEC))
		      (BITBLT BMSPEC (fetch LEFT of CR)
			      (fetch BOTTOM of CR)
			      BM 0 0 (fetch WIDTH of CR)
			      (fetch HEIGHT of CR))
		      BM])

(PROMPTFOREVALED
  [LAMBDA (MSG WHERE FONT MINWIDTH MINHEIGHT)                (* rrb "17-AUG-83 18:20")

          (* opens a window with MSG in the title and returns the result of evaluating a READ from that window.
	  (PROMPTFOREVALED "HOW'S THIS?" (QUOTE (600 . 600)) NIL 100))


    (PROG [NEWVALUE WIN (FONT (OR FONT (FONTCREATE (QUOTE HELVETICA)
						   12
						   (QUOTE BOLD]
          (RESETFORM (WINDOWTITLEFONT FONT)
		     (SETQ WIN
		       (CREATEW [COND
				  ((REGIONP WHERE)
				    WHERE)
				  (T (CREATEREGION (COND
						     (WHERE (fetch (POSITION XCOORD) of WHERE))
						     (T LASTMOUSEX))
						   (COND
						     (WHERE (fetch (POSITION YCOORD) of WHERE))
						     (T LASTMOUSEY))
						   (WIDTHIFWINDOW (MAX (STRINGWIDTH MSG FONT)
								       (OR MINWIDTH 0))
								  8)
						   (HEIGHTIFWINDOW
						     (MAX (ITIMES (FONTPROP (DEFAULTFONT
									      (QUOTE DISPLAY))
									    (QUOTE HEIGHT))
								  3)
							  (OR MINHEIGHT 0))
						     T 8]
				MSG 8))
		     (CLEARW WIN))
          [RESETFORM (TTYDISPLAYSTREAM WIN)
		     (SETQ NEWVALUE (CAR (ERSETQ (LISPX (LISPXREAD T T)
							(QUOTE >]
          (CLOSEW WIN)
          (RETURN NEWVALUE])

(WINDOWTITLEFONT
  [LAMBDA (FONT)                                             (* reset type of functin that changes the title font)
    (DSPFONT FONT WindowTitleDisplayStream])

(\WOUT
  [LAMBDA (STREAM WORD)                                      (* rrb "19-AUG-83 17:51")
    (BOUT STREAM (LRSH WORD 8))
    (BOUT STREAM (LOGAND WORD 255])
)



(* fns for the bitmap tedit object.)

(DEFINEQ

(BMOBJ.COPYFN
  [LAMBDA (BMOBJ)                                            (* rrb "17-AUG-83 14:29")
    BMOBJ])

(BMOBJ.DELETEFN
  [LAMBDA (ANNO STREAM PIECE)                                (* rrb "17-AUG-83 14:28")
                                                             (* deletefn for a bitmap tedit object)
    NIL])

(BMOBJ.DISPLAYFN
  [LAMBDA (BMOBJ STREAM MODE)                                (* rrb "26-AUG-83 11:55")
                                                             (* display function for a bitmap tedit object)
    (SELECTQ MODE
	     ((DISPLAY NIL)                                  (* This is being displayed on the screen)
	       (BITBLT (fetch (BITMAPOBJ BITMAP) of BMOBJ)
		       0 0 STREAM (DSPXPOSITION NIL STREAM)
		       (DSPYPOSITION NIL STREAM)))
	     (INTERPRESS (SHOWBITMAP.IP STREAM (fetch (BITMAPOBJ BITMAP) of BMOBJ)
					NIL
					(fetch (BITMAPOBJ BMOBJSCALEFACTOR) of BMOBJ)
					(fetch (BITMAPOBJ BMOBJROTATION) of BMOBJ)))
	     ((PRESS HARDCOPY)                               (* It's being displayed on a press file)
	       (PROMPTPRINT "Not implemented yet to PRESS bitmaps"))
	     NIL])

(BMOBJ.EDITFN
  [LAMBDA (OBJ)                                              (* rrb "19-AUG-83 17:36")
                                                             (* calls the bitmap editor on the bitmap of a tedit 
							     bitmap object.)
                                                             (* FOR NOW always creates a new bitmap)
    (replace (BITMAPOBJ BITMAP) of OBJ with (EDIT.BITMAP.REAL (fetch (BITMAPOBJ BITMAP) of OBJ)))
    (UPDATEBITMAPOBJ OBJ])

(BMOBJ.GETFN
  [LAMBDA (STREAM)                                           (* rrb "26-AUG-83 11:16")
                                                             (* Get a description of a bitmap object from the file.)
    (RESETFORM (INPUT STREAM)
	       (PROG ((FIELDS (READ STREAM))
		      (BITMAP (READBITMAP)))
		     (RETURN (BITMAPTEDITOBJ BITMAP (CAR FIELDS)
					     (CADR FIELDS])

(BMOBJ.INSERTFN
  [LAMBDA (ANNO CH)                                          (* rrb "17-AUG-83 14:27")
                                                             (* insertfn for a bitmap tedit object)
    NIL])

(BMOBJ.PUTFN
  [LAMBDA (BMOBJ STREAM)                                     (* rrb "26-AUG-83 11:16")
                                                             (* Put a description of a bitmap object into the file.)
    (RESETFORM (OUTPUT STREAM)
	       (PRINT (LIST (FETCH (BITMAPOBJ BMOBJSCALEFACTOR) OF BMOBJ)
			    (FETCH (BITMAPOBJ BMOBJROTATION) OF BMOBJ))
		      STREAM)
	       (PRINTBITMAP (FETCH (BITMAPOBJ BITMAP) OF BMOBJ])

(BMOBJ.SHOWSELFN
  [LAMBDA (ANNO SEL ON DS)                                   (* rrb "17-AUG-83 12:47")
                                                             (* Highlight this bitmap)
    ])

(BMOBJ.SIZEFN
  [LAMBDA (BMOBJ MODE)                                       (* rrb "26-AUG-83 14:58")
                                                             (* size function for a tedit bitmap object.)
    (PROG ((BM (fetch (BITMAPOBJ BITMAP) of BMOBJ))
	   (TDEDITOBJ (fetch (BITMAPOBJ TEDITOBJ) of BMOBJ))
	   ROTATION SCALEFACTOR ASCENT (POINTSTOMICASFACTOR 32))
          (RETURN (SELECTQ MODE
			   ((NIL DISPLAY)
			     (replace XSIZE of TDEDITOBJ with (BITMAPWIDTH BM))
			     (replace YSIZE of TDEDITOBJ with (BITMAPHEIGHT BM))
			     (replace YDESC of TDEDITOBJ with 0)
			     (replace YASC of TDEDITOBJ with (BITMAPHEIGHT BM)))
			   [(INTERPRESS PRESS HARDCOPY)      (* do scaling and simple rotation)
			     (replace YDESC of TDEDITOBJ with 0)
			     (replace YASC of TDEDITOBJ
				with (replace YSIZE of TDEDITOBJ
					with (TIMES POINTSTOMICASFACTOR (SETQ SCALEFACTOR
						      (fetch (BITMAPOBJ BMOBJSCALEFACTOR)
							 of BMOBJ))
						    (COND
						      ((MEMB (SETQ ROTATION (fetch (BITMAPOBJ 
										    BMOBJROTATION)
									       of BMOBJ))
							     (QUOTE (0 180)))
							(replace XSIZE of TDEDITOBJ
							   with (TIMES POINTSTOMICASFACTOR 
								       SCALEFACTOR (BITMAPWIDTH
									 BM)))
							(BITMAPHEIGHT BM))
						      (T (replace XSIZE of TDEDITOBJ
							    with (TIMES POINTSTOMICASFACTOR 
									SCALEFACTOR (BITMAPHEIGHT
									  BM)))
							 (BITMAPWIDTH BM]
			   NIL])
)
[DECLARE: EVAL@COMPILE 

(RECORD BITMAPOBJ (TEDITOBJ BITMAP BMOBJSCALEFACTOR BMOBJROTATION))

(RECORD TEDITUSEROBJ (TEDITOBJ . TEDITUSEROBJFIELDS))
]



(* make ↑O be a character that inserts an object read from the user. and ↑P be the character to
 edit them.)

(DEFINEQ

(GET.OBJ.FROM.USER
  [LAMBDA (TEXTSTREAM TEXTOBJ)                               (* rrb "26-AUG-83 12:56")
                                                             (* reads an expression from the user and puts the result
							     into the textstream.)
    (ERSETQ (PROG ((VAL (PROMPTFOREVALED "Form to eval:"))
		   (SEL (fetch (TEXTOBJ SEL) of TEXTOBJ))
		   BM)
	          (SELECTQ (TYPENAME VAL)
			   ((LITATOM STRING)
			     (AND VAL (TEDIT.INSERT TEXTSTREAM VAL SEL)))
			   (COND
			     ((SETQ BM (COERCETOBITMAP VAL))
			       (TEDIT.INSERT.OBJECT (BITMAPTEDITOBJ BM 1 0)
						    TEXTSTREAM
						    (fetch (SELECTION CH#) of SEL)))
			     (T (printout PROMPTWINDOW "Not implemented to have " VAL 
					  " in documents yet."])
)
(TEDIT.SETFUNCTION 15 (FUNCTION GET.OBJ.FROM.USER)
		   TEDIT.READTABLE)
(TEDIT.SETFUNCTION 16 (FUNCTION TEDIT.EDIT.OBJECT)
		   TEDIT.READTABLE)
(FILESLOAD EDITBITMAP)
(PUTPROPS BITMAPOBJ COPYRIGHT ("Xerox Corporation" 1983))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (995 5855 (BITMAPTEDITOBJ 1005 . 2138) (UPDATEBITMAPOBJ 2140 . 2815) (COERCETOBITMAP 
2817 . 4254) (PROMPTFOREVALED 4256 . 5496) (WINDOWTITLEFONT 5498 . 5682) (\WOUT 5684 . 5853)) (5901 
10572 (BMOBJ.COPYFN 5911 . 6031) (BMOBJ.DELETEFN 6033 . 6257) (BMOBJ.DISPLAYFN 6259 . 7126) (
BMOBJ.EDITFN 7128 . 7640) (BMOBJ.GETFN 7642 . 8049) (BMOBJ.INSERTFN 8051 . 8275) (BMOBJ.PUTFN 8277 . 
8752) (BMOBJ.SHOWSELFN 8754 . 8963) (BMOBJ.SIZEFN 8965 . 10570)) (10848 11656 (GET.OBJ.FROM.USER 10858
 . 11654)))))
STOP