(FILECREATED "24-May-84 11:24:29" {DSK}IMAGEOBJ.;3 18096 changes to: (FNS GET.OBJ.FROM.USER) previous date: "21-May-84 17:38:54" {DSK}IMAGEOBJ.;2) (* Copyright (c) 1984 by Xerox Corporation) (PRETTYCOMPRINT IMAGEOBJCOMS) (RPAQQ IMAGEOBJCOMS [(FILES TEDITCOMMAND) (COMS (* Main IMAGEOBJ Support) (RECORDS IMAGEOBJ IMAGEFNS IMAGEBOX) (FNS DEVICENAMEFROMSTREAM IMAGEBOX IMAGEFNSCREATE IMAGEFNSP IMAGEOBJCREATE IMAGEOBJP IMAGEOBJPROP \IMAGEUSERPROP) *) (COMS (* An example: Bitmaps) (FNS BITMAPTEDITOBJ COERCETOBITMAP PROMPTFOREVALED WINDOWTITLEFONT) (* 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. and ↑P be the character to edit them.) (FNS GET.OBJ.FROM.USER) (DECLARE: DONTEVAL@LOAD DOCOPY (P (TEDIT.SETFUNCTION 15 (FUNCTION GET.OBJ.FROM.USER) TEDIT.READTABLE) (TEDIT.SETFUNCTION 16 (FUNCTION TEDIT.EDIT.OBJECT) TEDIT.READTABLE))) (FILES EDITBITMAP)) (DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDVARS (NLAMA) (NLAML) (LAMA IMAGEOBJPROP]) (FILESLOAD TEDITCOMMAND) (* Main IMAGEOBJ Support) [DECLARE: EVAL@COMPILE (DATATYPE IMAGEOBJ (OBJECTDATUM IMAGEOBJPLIST IMAGEOBJFNS)) (DATATYPE IMAGEFNS (DISPLAYFN IMAGEBOXFN PUTFN GETFN COPYFN BUTTONEVENTINFN COPYBUTTONEVENTINFN WHENMOVEDFN WHENINSERTEDFN WHENDELETEDFN WHENCOPIEDFN WHENOPERATEDONFN PREPRINTFN)) (RECORD IMAGEBOX (XSIZE YSIZE YDESC XKERN)) ] (/DECLAREDATATYPE (QUOTE IMAGEOBJ) (QUOTE (POINTER POINTER POINTER))) (/DECLAREDATATYPE (QUOTE IMAGEFNS) (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER))) (DEFINEQ (DEVICENAMEFROMSTREAM [LAMBDA (STRM) (* jds "22-Feb-84 15:15") (* returns the name of the device of a stream) (COND ((type? INTERPRESSDATA (fetch IMAGEDATA of STRM)) (QUOTE INTERPRESS)) (T (fetch (FDEV DEVICENAME) of (fetch (STREAM DEVICE) of STRM]) (IMAGEBOX [LAMBDA (OBJ STREAM MODE) (* jds " 8-Feb-84 10:48") (APPLY* (IMAGEOBJPROP OBJ (QUOTE IMAGEBOXFN)) OBJ STREAM MODE]) (IMAGEFNSCREATE [LAMBDA (DISPLAYFN IMAGEBOXFN PUTFN GETFN COPYFN BUTTONEVENTINFN COPYBUTTONEVENTINFN WHENMOVEDFN WHENINSERTEDFN WHENDELETEDFN WHENCOPIEDFN WHENOPERATEDONFN PREPRINTFN) (* jds " 1-Mar-84 16:06") (* returns a structure which contains the image functions for a type of image object.) (create IMAGEFNS DISPLAYFN ← DISPLAYFN IMAGEBOXFN ← IMAGEBOXFN PUTFN ← PUTFN GETFN ← GETFN COPYFN ← COPYFN BUTTONEVENTINFN ← BUTTONEVENTINFN COPYBUTTONEVENTINFN ← COPYBUTTONEVENTINFN WHENMOVEDFN ← WHENMOVEDFN WHENINSERTEDFN ← WHENINSERTEDFN WHENDELETEDFN ← WHENDELETEDFN WHENCOPIEDFN ← WHENCOPIEDFN WHENOPERATEDONFN ← WHENOPERATEDONFN PREPRINTFN ← PREPRINTFN]) (IMAGEFNSP (LAMBDA (X) (* rrb " 1-Feb-84 11:13") (* is X an IMAGEFNS?) (AND (type? IMAGEFNS X) X))) (IMAGEOBJCREATE [LAMBDA (OBJECTDATUM IMAGEFNS) (* jds " 8-Feb-84 10:20") (* returns an image object) (OR (IMAGEFNSP IMAGEFNS) (\ILLEGAL.ARG IMAGEFNS)) (* Make sure he handed us a valid set of fn references) (create IMAGEOBJ OBJECTDATUM ← OBJECTDATUM IMAGEOBJPLIST ← NIL IMAGEOBJFNS ← IMAGEFNS]) (IMAGEOBJP [LAMBDA (X) (* rrb " 1-Feb-84 16:22") (* is X an IMAGEOBJ?) (AND (type? IMAGEOBJ X) X]) (IMAGEOBJPROP [LAMBDA NARGS (* jds " 1-Mar-84 16:06") (* accesses and sets properties of an IMAGEOBJ.) (SELECTQ NARGS ((0 1) (\ILLEGAL.ARG NIL)) (PROG ((IMAGEOBJ (ARG NARGS 1)) (PROP (ARG NARGS 2)) (VAL (ARG NARGS 3)) (SET? (NEQ NARGS 2)) IMAGEFNS) (COND ((NOT (IMAGEOBJP IMAGEOBJ)) (\ILLEGAL.ARG IMAGEOBJ))) (SETQ IMAGEFNS (fetch (IMAGEOBJ IMAGEOBJFNS) of IMAGEOBJ)) (RETURN (SELECTQ PROP [OBJECTDATUM (PROG1 (fetch (IMAGEOBJ OBJECTDATUM) of IMAGEOBJ) (COND (SET? (replace (IMAGEOBJ OBJECTDATUM) of IMAGEOBJ with VAL] [DISPLAYFN (PROG1 (fetch (IMAGEFNS DISPLAYFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS DISPLAYFN) of IMAGEFNS with VAL] [IMAGEBOXFN (PROG1 (fetch (IMAGEFNS IMAGEBOXFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS IMAGEBOXFN) of IMAGEFNS with VAL] [PUTFN (PROG1 (fetch (IMAGEFNS PUTFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS PUTFN) of IMAGEFNS with VAL] [GETFN (PROG1 (fetch (IMAGEFNS GETFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS GETFN) of IMAGEFNS with VAL] [COPYFN (PROG1 (fetch (IMAGEFNS COPYFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS COPYFN) of IMAGEFNS with VAL] [BUTTONEVENTINFN (PROG1 (fetch (IMAGEFNS BUTTONEVENTINFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS BUTTONEVENTINFN) of IMAGEFNS with VAL] [COPYBUTTONEVENTINFN (PROG1 (fetch (IMAGEFNS COPYBUTTONEVENTINFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS COPYBUTTONEVENTINFN) of IMAGEFNS with VAL] [WHENMOVEDFN (PROG1 (fetch (IMAGEFNS WHENMOVEDFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS WHENMOVEDFN) of IMAGEFNS with VAL] [WHENINSERTEDFN (PROG1 (fetch (IMAGEFNS WHENINSERTEDFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS WHENINSERTEDFN) of IMAGEFNS with VAL] [WHENDELETEDFN (PROG1 (fetch (IMAGEFNS WHENDELETEDFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS WHENDELETEDFN) of IMAGEFNS with VAL] [WHENCOPIEDFN (PROG1 (fetch (IMAGEFNS WHENCOPIEDFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS WHENCOPIEDFN) of IMAGEFNS with VAL] [WHENOPERATEDONFN (PROG1 (fetch (IMAGEFNS WHENOPERATEDONFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS WHENOPERATEDONFN) of IMAGEFNS with VAL] [PREPRINTFN (PROG1 (fetch (IMAGEFNS PREPRINTFN) of IMAGEFNS) (COND (SET? (replace (IMAGEFNS PREPRINTFN) of IMAGEFNS with VAL] (\IMAGEUSERPROP IMAGEOBJ PROP VAL SET?]) (\IMAGEUSERPROP (LAMBDA (IMAGEOBJ PROP VAL SET?) (* rrb " 1-Feb-84 11:44") (* reads and sets the values of properties on an IMAGEOBJ) (PROG ((PLIST (fetch (IMAGEOBJ IMAGEOBJPLIST) of IMAGEOBJ))) (RETURN (PROG1 (LISTGET PLIST PROP) (COND (SET? (COND (PLIST (LISTPUT PLIST PROP VAL)) (T (replace (IMAGEOBJ IMAGEOBJPLIST) of IMAGEOBJ with (LIST PROP VAL))))))))))) ) (RPAQQ * NOBIND) (* An example: Bitmaps) (DEFINEQ (BITMAPTEDITOBJ [LAMBDA (BITMAP SCALEFACTOR ROTATION) (* jds " 1-Mar-84 16:22") (* 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.GETFN) (FUNCTION BMOBJ.COPYFN) (FUNCTION BMOBJ.BUTTONEVENTINFN) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL) (FUNCTION NILL]) (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]) ) (* fns for the bitmap tedit object.) (DEFINEQ (BMOBJ.BUTTONEVENTINFN [LAMBDA (IMAGEOBJ WINDOW) (* rrb " 1-Feb-84 16:11") (* the user has pressed a button inside the bitmap object IMAGEOBJ. Call the bitmap editor.) (* FOR NOW always creates a new bitmap) (PROG [(OBJ (IMAGEOBJPROP IMAGEOBJ (QUOTE OBJECTDATUM] (RETURN (replace (BITMAPOBJ BITMAP) of OBJ with (EDIT.BITMAP.REAL (fetch (BITMAPOBJ BITMAP) of OBJ]) (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) (* jds "22-Feb-84 17:41") (* 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) (PROMPTPRINT "Not implemented yet to PRESS bitmaps")) NIL]) (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.IMAGEBOXFN [LAMBDA (IMAGEOBJ STREAM) (* jds "22-Feb-84 17:42") (* size function for a tedit bitmap object.) (PROG ((BMOBJ (IMAGEOBJPROP IMAGEOBJ (QUOTE OBJECTDATUM))) BMW BMH SCALEFACTOR (POINTSTOMICASFACTOR 35)) [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 PRESS) (* do scaling and simple rotation) [COND ((MEMB (fetch (BITMAPOBJ BMOBJROTATION) of BMOBJ) (QUOTE (90 270))) (* rotated on edge, switch width and height.) (SETQ BMW (PROG1 BMH (SETQ BMH BMW] (create IMAGEBOX XSIZE ←(TIMES POINTSTOMICASFACTOR (SETQ SCALEFACTOR (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of BMOBJ)) BMW) YSIZE ←(TIMES POINTSTOMICASFACTOR SCALEFACTOR BMH) YDESC ← 0 XKERN ← 0)) NIL]) (BMOBJ.PUTFN [LAMBDA (BMOBJ STREAM) (* jds "22-Feb-84 14:37") (* Put a description of a bitmap object into the file.) (RESETFORM (OUTPUT STREAM) (PRINT [LIST (fetch (BITMAPOBJ BMOBJSCALEFACTOR) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM))) (fetch (BITMAPOBJ BMOBJROTATION) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM] STREAM) (PRINTBITMAP (fetch (BITMAPOBJ BITMAP) of (IMAGEOBJPROP BMOBJ (QUOTE OBJECTDATUM]) ) [DECLARE: EVAL@COMPILE (RECORD BITMAPOBJ (BITMAP BMOBJSCALEFACTOR BMOBJROTATION)) ] (* 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) (* jds "21-May-84 16:53") (* 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 (TEDIT.PROMPTPRINT TEXTOBJ (CONCAT "Not implemented to have " VAL " in documents yet.") T]) ) (DECLARE: DONTEVAL@LOAD DOCOPY (TEDIT.SETFUNCTION 15 (FUNCTION GET.OBJ.FROM.USER) TEDIT.READTABLE) (TEDIT.SETFUNCTION 16 (FUNCTION TEDIT.EDIT.OBJECT) TEDIT.READTABLE) ) (FILESLOAD EDITBITMAP) (DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS (ADDTOVAR NLAMA ) (ADDTOVAR NLAML ) (ADDTOVAR LAMA IMAGEOBJPROP) ) (PUTPROPS IMAGEOBJ COPYRIGHT ("Xerox Corporation" 1984)) (DECLARE: DONTCOPY (FILEMAP (NIL (2024 8114 (DEVICENAMEFROMSTREAM 2034 . 2447) (IMAGEBOX 2449 . 2630) (IMAGEFNSCREATE 2632 . 3523) (IMAGEFNSP 3525 . 3628) (IMAGEOBJCREATE 3630 . 4091) (IMAGEOBJP 4093 . 4323) ( IMAGEOBJPROP 4325 . 7742) (\IMAGEUSERPROP 7744 . 8112)) (8169 12118 (BITMAPTEDITOBJ 8179 . 9157) ( COERCETOBITMAP 9159 . 10596) (PROMPTFOREVALED 10598 . 11838) (WINDOWTITLEFONT 11840 . 12116)) (12164 16630 (BMOBJ.BUTTONEVENTINFN 12174 . 12781) (BMOBJ.COPYFN 12783 . 13277) (BMOBJ.DISPLAYFN 13279 . 14384) (BMOBJ.GETFN 14386 . 14793) (BMOBJ.IMAGEBOXFN 14795 . 16005) (BMOBJ.PUTFN 16007 . 16628)) ( 16838 17670 (GET.OBJ.FROM.USER 16848 . 17668))))) STOP