(FILECREATED " 5-Sep-84 18:53:29" {ERIS}<TEDIT>IMAGEOBJ.;29 18324 changes to: (FNS GET.OBJ.FROM.USER) previous date: "20-Aug-84 15:07:07" {ERIS}<TEDIT>IMAGEOBJ.;28) (* Copyright (c) 1984 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) (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."))) (VARS (BackgroundCopyMenu)) (FNS GET.OBJ.FROM.USER BITMAPOBJ.SNAPW) (DECLARE: DONTEVAL@LOAD DOCOPY (P (TEDIT.SETFUNCTION (CHARCODE ↑O) (FUNCTION GET.OBJ.FROM.USER) TEDIT.READTABLE))) (FILES EDITBITMAP)))) (* Bit-map image objects) (DEFINEQ (BITMAPTEDITOBJ [LAMBDA (BITMAP SCALEFACTOR ROTATION) (* rrb "17-Jul-84 11:38") (* 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)) (COND ((IMAGEFNSP BITMAPIMAGEFNS)) (T (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]) (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]) ) [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.")) (RPAQQ BackgroundCopyMenu NIL) (DEFINEQ (GET.OBJ.FROM.USER [LAMBDA (TEXTSTREAM TEXTOBJ) (* jds " 5-Sep-84 17:47") (* 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) (* 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 (ADD1 (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 (ADD1 (fetch (SELECTION CHLIM) of SEL))) NIL))) (T (* Not a bitmap, nor one of the special cases above; complain) (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 (TEDIT.SETFUNCTION (CHARCODE ↑O) (FUNCTION GET.OBJ.FROM.USER) TEDIT.READTABLE) ) (FILESLOAD EDITBITMAP) (PUTPROPS IMAGEOBJ COPYRIGHT ("Xerox Corporation" 1984)) (DECLARE: DONTCOPY (FILEMAP (NIL (1217 6866 (BITMAPTEDITOBJ 1227 . 2194) (BMOBJ.GETFN2 2196 . 2618) (COERCETOBITMAP 2620 . 4057) (PROMPTFOREVALED 4059 . 5299) (WINDOWTITLEFONT 5301 . 5577) (\PRINTBINARYBITMAP 5579 . 6288) (\READBINARYBITMAP 6290 . 6864)) (6912 15374 (BMOBJ.BUTTONEVENTINFN 6922 . 10526) (BMOBJ.COPYFN 10528 . 11022) (BMOBJ.DISPLAYFN 11024 . 12277) (BMOBJ.GETFN 12279 . 12729) (BMOBJ.IMAGEBOXFN 12731 . 14816) (BMOBJ.PUTFN 14818 . 15372)) (15778 18099 (GET.OBJ.FROM.USER 15788 . 17471) (BITMAPOBJ.SNAPW 17473 . 18097))))) STOP