(FILECREATED " 6-Mar-85 23:41:42" {IVY}<TEDIT>IMAGEOBJ.;17 18920 changes to: (FNS GET.OBJ.FROM.USER) previous date: "20-Feb-85 14:19:25" {IVY}<TEDIT>IMAGEOBJ.;16) (* Copyright (c) 1984, 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT IMAGEOBJCOMS) (RPAQQ IMAGEOBJCOMS ((COMS (* Bit-map image objects) (FNS BITMAPTEDITOBJ BMOBJ.GETFN2 COERCETOBITMAP PROMPTFOREVALED WINDOWTITLEFONT \PRINTBINARYBITMAP \READBINARYBITMAP) (* fns for the bitmap tedit object.) (FNS BMOBJ.BUTTONEVENTINFN BMOBJ.COPYFN BMOBJ.DISPLAYFN BMOBJ.GETFN BMOBJ.IMAGEBOXFN BMOBJ.PUTFN BMOBJ.INIT) (RECORDS BITMAPOBJ) (* make ↑O be a character that inserts an object read from the user.) (GLOBALVARS (BITMAP.OBJ.MENU)) (ADDVARS (BackgroundCopyMenuCommands (SNAP (QUOTE (BITMAPOBJ.SNAPW)) "prompts for an area of the screen to insert.")) (IMAGEOBJGETFNS (BMOBJ.GETFN))) (VARS (BackgroundCopyMenu)) (FNS GET.OBJ.FROM.USER BITMAPOBJ.SNAPW) (DECLARE: DONTEVAL@LOAD DOCOPY (P (BMOBJ.INIT) (TEDIT.SETFUNCTION (CHARCODE ↑O) (FUNCTION GET.OBJ.FROM.USER) TEDIT.READTABLE))) (FILES EDITBITMAP)))) (* Bit-map image objects) (DEFINEQ (BITMAPTEDITOBJ [LAMBDA (BITMAP SCALEFACTOR ROTATION) (* jds "20-Feb-85 14:10") (* returns the tedit obj which gives the functional information for a bitmap object in a tedit file.) (IMAGEOBJCREATE (create BITMAPOBJ BITMAP ← BITMAP BMOBJSCALEFACTOR ←(OR SCALEFACTOR 1) BMOBJROTATION ←(OR ROTATION 0)) BITMAPIMAGEFNS]) (BMOBJ.GETFN2 [LAMBDA (STREAM) (* rrb "17-Jul-84 11:29") (* * reads a bitmap image object from a file. This version stores the binary data rather than the character representation used by READBITMAP.) (PROG ((SCALE (\WIN STREAM)) (ROT (\WIN STREAM))) (RETURN (BITMAPTEDITOBJ (\READBINARYBITMAP STREAM) SCALE ROT]) (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) (* rrb " 1-Feb-84 15:26") (* reset type of function that changes the title font) (DSPFONT FONT WindowTitleDisplayStream]) (\PRINTBINARYBITMAP [LAMBDA (BITMAP STREAM) (* rrb "23-Jul-84 15:16") (* * prints the representation of a bitmap onto STREAM in a form that can be read back by \READBINARYBITMAP.) (PROG ((STREAM (GETSTREAM STREAM (QUOTE OUTPUT))) BMH) (OR (BITMAPP BITMAP) (\ILLEGAL.ARG BITMAP)) (\WOUT STREAM (BITMAPWIDTH BITMAP)) (\WOUT STREAM (SETQ BMH (BITMAPHEIGHT BITMAP))) (\WOUT STREAM (BITSPERPIXEL BITMAP)) (\BOUTS STREAM (fetch (BITMAP BITMAPBASE) of BITMAP) 0 (ITIMES (fetch (BITMAP BITMAPRASTERWIDTH) of BITMAP) BMH BYTESPERWORD)) (RETURN BITMAP]) (\READBINARYBITMAP [LAMBDA (STREAM) (* rrb "23-Jul-84 15:17") (* * reads a bitmap printed on STREAM by \PRINTBINARYBITMAP.) (SETQ STREAM (GETSTREAM STREAM (QUOTE INPUT))) (PROG ((BMW (\WIN STREAM)) (BMH (\WIN STREAM)) (BPP (\WIN STREAM)) BITMAP) (SETQ BITMAP (BITMAPCREATE BMW BMH BPP)) (\BINS STREAM (fetch (BITMAP BITMAPBASE) of BITMAP) 0 (ITIMES (fetch (BITMAP BITMAPRASTERWIDTH) of BITMAP) BMH BYTESPERWORD)) (RETURN BITMAP]) ) (* fns for the bitmap tedit object.) (DEFINEQ (BMOBJ.BUTTONEVENTINFN [LAMBDA (IMAGEOBJ WINDOW) (* rrb "24-Jul-84 18:12") (* * the user has pressed a button inside the bitmap object IMAGEOBJ. Bring up a menu of bitmap edit operations.) (PROG ((OBJ (IMAGEOBJPROP IMAGEOBJ (QUOTE OBJECTDATUM))) NEW.BITMAP COMMAND.MENU COMMAND PREVIOUS.BITMAP NAME TEMP X Y) (SETQ PREVIOUS.BITMAP (BITMAPCOPY (fetch (BITMAPOBJ BITMAP) of OBJ))) (SETQ NEW.BITMAP (SELECTQ [MENU (COND ((type? MENU BITMAP.OBJ.MENU) BITMAP.OBJ.MENU) (T (SETQ BITMAP.OBJ.MENU (create MENU TITLE ← "Operations on bitmaps" ITEMS ←(QUOTE ((HAND.EDIT (QUOTE HAND.EDIT) "Starts the bitmap editor on this bitmap.") (TRIM (QUOTE TRIM) "removes the white space from the edges of the bitmap.") (INVERT.HORIZONTALLY (QUOTE INVERT.HORIZONTALLY) "inverts the bitmap about the vertical midline.") (INVERT.VERTICALLY (QUOTE INVERT.VERTICALLY) "inverts the bitmap about the horizontal midline.") (INVERT.DIAGONALLY (QUOTE INVERT.DIAGONALLY) "inverts the bitmap about the lower left to upper right diagonal.") (ROTATE.BITMAP.LEFT (QUOTE ROTATE.BITMAP.LEFT) "rotates the bitmap 90 degrees counter-clockwise.") (ROTATE.BITMAP.RIGHT (QUOTE ROTATE.BITMAP.RIGHT) "rotates the bitmap 90 degrees clockwise.") (SHIFT.LEFT (QUOTE SHIFT.LEFT) "prompts for a number of bits to add on the right.") (SHIFT.RIGHT (QUOTE SHIFT.RIGHT) "prompts for a number of bits to add on the left.") (SHIFT.DOWN (QUOTE SHIFT.DOWN) "prompts for a number of bits to add on the top.") (SHIFT.UP (QUOTE SHIFT.UP) "prompts for a number of bits to add on the bottom.") (INTERCHANGE.BLACK/WHITE (QUOTE INTERCHANGE.BLACK/WHITE) "changes all black bits to white and all white bits to black.") (ADD.BORDER (QUOTE ADD.BORDER) "adds an arbitrary border in an arbitrary shade."))) CENTERFLG ← T CHANGEOFFSETFLG ←(QUOTE Y) MENUOFFSET ←(create POSITION XCOORD ← -1 YCOORD ← 0] (HAND.EDIT (EDITBM PREVIOUS.BITMAP)) (TRIM (TRIM.BITMAP PREVIOUS.BITMAP)) (INVERT.HORIZONTALLY (INVERT.BITMAP.HORIZONTALLY PREVIOUS.BITMAP)) (INVERT.VERTICALLY (INVERT.BITMAP.VERTICALLY PREVIOUS.BITMAP)) (INVERT.DIAGONALLY (INVERT.BITMAP.DIAGONALLY PREVIOUS.BITMAP)) (ROTATE.BITMAP.LEFT (ROTATE.BITMAP.LEFT PREVIOUS.BITMAP)) (ROTATE.BITMAP.RIGHT (ROTATE.BITMAP.RIGHT PREVIOUS.BITMAP)) (SHIFT.LEFT (INTERACT&SHIFT.BITMAP.LEFT PREVIOUS.BITMAP)) (SHIFT.RIGHT (INTERACT&SHIFT.BITMAP.RIGHT PREVIOUS.BITMAP)) (SHIFT.DOWN (INTERACT&SHIFT.BITMAP.DOWN PREVIOUS.BITMAP)) (SHIFT.UP (INTERACT&SHIFT.BITMAP.UP PREVIOUS.BITMAP)) (INTERCHANGE.BLACK/WHITE (INVERT.BITMAP.B/W PREVIOUS.BITMAP)) (ADD.BORDER (INTERACT&ADD.BORDER.TO.BITMAP PREVIOUS.BITMAP)) (RETURN NIL))) (replace (BITMAPOBJ BITMAP) of OBJ with NEW.BITMAP) (RETURN (QUOTE CHANGED]) (BMOBJ.COPYFN [LAMBDA (IMAGEOBJ) (* rrb " 1-Feb-84 16:00") (* makes a copy of a bitmap image object.) (PROG [(BMOBJ (IMAGEOBJPROP IMAGEOBJ (QUOTE OBJECTDATUM] (RETURN (BITMAPTEDITOBJ (BITMAPCOPY (fetch (BITMAPOBJ BITMAP) of BMOBJ)) (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of BMOBJ) (fetch (BITMAPOBJ BMOBJROTATION) of BMOBJ]) (BMOBJ.DISPLAYFN [LAMBDA (BMOBJ STREAM) (* rmk: "20-Aug-84 14:59") (* display function for a bitmap image object) (SELECTQ (IMAGESTREAMTYPE STREAM) (DISPLAY (* This is being displayed on the screen) (BITBLT (fetch (BITMAPOBJ BITMAP) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM))) 0 0 STREAM (DSPXPOSITION NIL STREAM) (DSPYPOSITION NIL STREAM))) [INTERPRESS (SHOWBITMAP.IP STREAM (fetch (BITMAPOBJ BITMAP) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM))) NIL (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM))) (fetch (BITMAPOBJ BMOBJROTATION) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM] (PRESS (* It's being displayed on a press file) (\WRITEPRESSBITMAP (fetch (BITMAPOBJ BITMAP) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM))) (DSPXPOSITION NIL STREAM) (DSPYPOSITION NIL STREAM) NIL NIL STREAM)) NIL]) (BMOBJ.GETFN [LAMBDA (STREAM) (* rrb "17-Jul-84 11:46") (* this is an old version of the get function for bitmap image objects. It is left around so old tedit documents will still work. 17/7/84) (RESETFORM (INPUT STREAM) (PROG ((FIELDS (READ STREAM)) (BITMAP (READBITMAP))) (RETURN (BITMAPTEDITOBJ BITMAP (CAR FIELDS) (CADR FIELDS]) (BMOBJ.IMAGEBOXFN [LAMBDA (IMAGEOBJ STREAM) (* rmk: "20-Aug-84 15:06") (* size function for a tedit bitmap object.) (PROG ((BMOBJ (IMAGEOBJPROP IMAGEOBJ (QUOTE OBJECTDATUM))) BMW BMH SCALEFACTOR) [SETQ BMW (BITMAPWIDTH (SETQ BMH (fetch (BITMAPOBJ BITMAP) of BMOBJ] (SETQ BMH (BITMAPHEIGHT BMH)) (RETURN (SELECTQ (IMAGESTREAMTYPE STREAM) (DISPLAY (create IMAGEBOX XSIZE ← BMW YSIZE ← BMH YDESC ← 0 XKERN ← 0)) (INTERPRESS (* do scaling and simple rotation) (COND ((MEMB (fetch (BITMAPOBJ BMOBJROTATION) of BMOBJ) (QUOTE (90 270))) (* rotated on edge, switch width and height.) (swap BMW BMH))) (* Interpress uses a complicated approximation for choosing the points-to-micas factor. 35 is a wild stab.) (create IMAGEBOX XSIZE ←(TIMES 35 (SETQ SCALEFACTOR (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of BMOBJ)) BMW) YSIZE ←(TIMES 35 SCALEFACTOR BMH) YDESC ← 0 XKERN ← 0)) (PRESS (* do scaling and simple rotation) (COND ((MEMB (fetch (BITMAPOBJ BMOBJROTATION) of BMOBJ) (QUOTE (90 270))) (* rotated on edge, switch width and height.) (swap BMW BMH))) (* \WRITEPRESSBITMAP uses 32 micas/point as an approximation) (create IMAGEBOX XSIZE ←(FIX (TIMES 32 (SETQ SCALEFACTOR (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of BMOBJ)) BMW)) YSIZE ←(FIX (TIMES 32 SCALEFACTOR BMH)) YDESC ← 0 XKERN ← 0)) NIL]) (BMOBJ.PUTFN [LAMBDA (BMOBJ STREAM) (* rrb "17-Jul-84 11:29") (* Put a description of a bitmap object into the file.) [\WOUT STREAM (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM] [\WOUT STREAM (fetch (BITMAPOBJ BMOBJROTATION) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM] (\PRINTBINARYBITMAP (fetch (BITMAPOBJ BITMAP) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM))) STREAM]) (BMOBJ.INIT [LAMBDA (BITMAP SCALEFACTOR ROTATION) (* jds "20-Feb-85 14:11") (* returns the tedit obj which gives the functional information for a bitmap object in a tedit file.) (SETQ BITMAPIMAGEFNS (IMAGEFNSCREATE (FUNCTION BMOBJ.DISPLAYFN) (FUNCTION BMOBJ.IMAGEBOXFN) (FUNCTION BMOBJ.PUTFN) (FUNCTION BMOBJ.GETFN2) (FUNCTION BMOBJ.COPYFN) (FUNCTION BMOBJ.BUTTONEVENTINFN) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL]) ) [DECLARE: EVAL@COMPILE (RECORD BITMAPOBJ (BITMAP BMOBJSCALEFACTOR BMOBJROTATION)) ] (* make ↑O be a character that inserts an object read from the user.) (DECLARE: DOEVAL@COMPILE DONTCOPY (GLOBALVARS (BITMAP.OBJ.MENU)) ) (ADDTOVAR BackgroundCopyMenuCommands (SNAP (QUOTE (BITMAPOBJ.SNAPW)) "prompts for an area of the screen to insert.")) (ADDTOVAR IMAGEOBJGETFNS (BMOBJ.GETFN)) (RPAQQ BackgroundCopyMenu NIL) (DEFINEQ (GET.OBJ.FROM.USER [LAMBDA (TEXTSTREAM TEXTOBJ) (* jds " 6-Mar-85 22:02") (* 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 STRINGP) (* Atoms and strings get inserted as text.) (AND VAL (TEDIT.INSERT TEXTSTREAM VAL SEL))) (IMAGEOBJ (* IMAGEOBJs get inserted as is) (TEDIT.INSERT.OBJECT VAL TEXTSTREAM (SELECTQ (fetch POINT of SEL) (LEFT (fetch (SELECTION CH#) of SEL)) (RIGHT (fetch (SELECTION CHLIM) of SEL)) NIL))) (COND ((SETQ BM (COERCETOBITMAP VAL)) (* If it can be coerced to a bitmap, do so, then wrap the bitmap up as a nobject) (TEDIT.INSERT.OBJECT (BITMAPTEDITOBJ BM 1 0) TEXTSTREAM (SELECTQ (fetch POINT of SEL) (LEFT (fetch (SELECTION CH#) of SEL)) (RIGHT (fetch (SELECTION CHLIM) of SEL)) NIL))) (T (* Not a bitmap, nor one of the special cases above; complain) (AND VAL (TEDIT.INSERT TEXTSTREAM (MKSTRING VAL) SEL)) (* (TEDIT.PROMPTPRINT TEXTOBJ (CONCAT "Not implemented to have " VAL " in documents yet.") T)) ]) (BITMAPOBJ.SNAPW [LAMBDA NIL (* rrb "16-Jul-84 19:35") (* * makes an image object of a prompted for region of the screen.) (PROG ((REG (GETREGION)) BM) [SETQ BM (BITMAPCREATE (fetch (REGION WIDTH) of REG) (fetch (REGION HEIGHT) of REG) (BITSPERPIXEL (SCREENBITMAP] (BITBLT (SCREENBITMAP) (fetch (REGION LEFT) of REG) (fetch (REGION BOTTOM) of REG) BM 0 0 NIL NIL (QUOTE INPUT) (QUOTE REPLACE)) (COPYINSERT (BITMAPTEDITOBJ BM 1 0)) (RETURN]) ) (DECLARE: DONTEVAL@LOAD DOCOPY (BMOBJ.INIT) (TEDIT.SETFUNCTION (CHARCODE ↑O) (FUNCTION GET.OBJ.FROM.USER) TEDIT.READTABLE) ) (FILESLOAD EDITBITMAP) (PUTPROPS IMAGEOBJ COPYRIGHT ("Xerox Corporation" 1984 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (1298 6457 (BITMAPTEDITOBJ 1308 . 1785) (BMOBJ.GETFN2 1787 . 2209) (COERCETOBITMAP 2211 . 3648) (PROMPTFOREVALED 3650 . 4890) (WINDOWTITLEFONT 4892 . 5168) (\PRINTBINARYBITMAP 5170 . 5879) (\READBINARYBITMAP 5881 . 6455)) (6503 15702 (BMOBJ.BUTTONEVENTINFN 6513 . 10117) (BMOBJ.COPYFN 10119 . 10613) (BMOBJ.DISPLAYFN 10615 . 11868) (BMOBJ.GETFN 11870 . 12320) (BMOBJ.IMAGEBOXFN 12322 . 14407) (BMOBJ.PUTFN 14409 . 14963) (BMOBJ.INIT 14965 . 15700)) (16151 18677 (GET.OBJ.FROM.USER 16161 . 18049 ) (BITMAPOBJ.SNAPW 18051 . 18675))))) STOP