(FILECREATED "13-Jan-85 03:04:05" {ERIS}<LISPCORE>LIBRARY>FILEOBJ.;8 11368  

      changes to:  (FNS FILEOBJ.BUTTON FILEOBJ.GET1 FILEOBJ.FILEINFOS FILEOBJ.TYPE)
		   (VARS FILEOBJCOMS FILEOBJ.PRINTFILE.ICON)

      previous date: " 5-Jan-85 01:10:46" {ERIS}<LISPCORE>LIBRARY>FILEOBJ.;6)


(* Copyright (c) 1984, 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT FILEOBJCOMS)

(RPAQQ FILEOBJCOMS [(FNS FILEOBJ FILEOBJ.BUTTON FILEOBJ.ICON FILEOBJ.LOCK FILEOBJ.PUT 
			 FILEOBJ.FILEPROPS FILEOBJ.FILEINFOS FILEOBJ.SAVE FILEOBJ.DATASTREAM 
			 FILEOBJ.COPY FILEOBJ.GET FILEOBJ.GET1 FILEOBJ.CREATE FILEOBJ.IMAGEBOX 
			 FILEOBJ.DISPLAY FILEOBJ.NAME FILEOBJ.TYPE)
	(VARS FILEOBJ.PRINTFILE.ICON FILEOBJ.TEXTFILE.ICON FILEOBJ.BINARYFILE.ICON
	      (FILEOBJ.IMAGEFNS (IMAGEFNSCREATE (FUNCTION FILEOBJ.DISPLAY)
						(FUNCTION FILEOBJ.IMAGEBOX)
						(FUNCTION FILEOBJ.SAVE)
						(FUNCTION FILEOBJ.GET)
						(FUNCTION FILEOBJ.COPY)
						(FUNCTION FILEOBJ.BUTTON)
						(FUNCTION FILEOBJ.COPYIN])
(DEFINEQ

(FILEOBJ
  [LAMBDA (FILE)                                             (* lmm "29-Dec-84 22:54")
                                                             (* creates a new file object which is a copy of the 
							     contents of FILE, but with printable name FILE's 
							     fullname)
                                                             (* lmm "29-Dec-84 22:18")
    (FILEOBJ.GET1 [FILEOBJ.FILEINFOS (SETQ FILE (OPENSTREAM FILE (QUOTE INPUT)
							    (QUOTE OLD]
		  (GETFILEINFO FILE (QUOTE LENGTH))
		  FILE])

(FILEOBJ.BUTTON
  [LAMBDA (OBJ WINDOWSTREAM SEL RELX RELY WINDOW TEXT BUTTON)
                                                             (* edited: "12-Jan-85 23:27")
                                                             (* act on button event on picture of file)
    (if [NOT (OR (KEYDOWNP (QUOTE LSHIFT))
		 (KEYDOWNP (QUOTE RSHIFT))
		 (KEYDOWNP (QUOTE COPY]
	then (RESETLST (PROG ((LOCK (FILEOBJ.LOCK OBJ)))
			     (SELECTQ [PROG1 (OR [MENU (create MENU
							       ITEMS ←(SELECTQ (FILEOBJ.TYPE OBJ)
									       ((PRESS INTERPRESS)
										 (QUOTE (PUT HARDCOPY)
											))
									       (QUOTE (EDIT PUT 
											 HARDCOPY 
											    LOAD]
						 (RETURN))
					     (OR (OBTAIN.MONITORLOCK LOCK T T)
						 (PROGN (printout (FILEOBJ.PROMPTWINDOW)
								  T "(busy)")
							(RETURN]
				      (PUT                   (* save it away under a name)
					   (PROG ((PW (GETPROMPTWINDOW WINDOW)))
					         (CLEARW PW)
					         (PRIN1 (PROG1 (FILEOBJ.PUT OBJ
									    (OR (PROMPTFORWORD 
										      "Put file:"
											       NIL 
											      NIL PW)
										(RETURN)))
							       (TERPRI PW))
							PW)
					         (PRIN1 "...saved." PW)))
				      (HARDCOPY              (* call editor on file contents)
						(SEND.FILE.TO.PRINTER (FILEOBJ.DATASTREAM OBJ)))
				      (EDIT                  (* call editor on file contents)
					    (TEDIT (FILEOBJ.DATASTREAM OBJ)))
				      (LOAD                  (* call editor on file contents)
					    (LOAD (FILEOBJ.DATASTREAM OBJ)))
				      NIL])

(FILEOBJ.ICON
  [LAMBDA (OBJ)                                              (* lmm " 5-Jan-85 00:38")
    (SELECTQ (FILEOBJ.TYPE OBJ)
	     ((PRESS INTERPRESS)
	       FILEOBJ.PRINTFILE.ICON)
	     ((TEXT TEDIT)
	       FILEOBJ.TEXTFILE.ICON)
	     FILEOBJ.BINARYFILE.ICON])

(FILEOBJ.LOCK
  [LAMBDA (OBJ)                                              (* lmm " 5-Jan-85 01:07")
    (OR (IMAGEOBJPROP OBJ (QUOTE LOCK))
	(LET ((LOCK (CREATE.MONITORLOCK)))
	  (IMAGEOBJPROP OBJ (QUOTE LOCK)
			LOCK)
	  LOCK])

(FILEOBJ.PUT
  [LAMBDA (OBJ NEWNAME)                                      (* lmm "29-Dec-84 22:56")
                                                             (* save contents of OBJ under NEWNAME -
							     invoked by button function)
    (PROG [(NEWSTR (OPENSTREAM NEWNAME (QUOTE OUTPUT)
			       (QUOTE NEW)
			       NIL
			       (FILEOBJ.FILEPROPS OBJ]       (* create new file with the saved file properties)
          (PROG ((STR (FILEOBJ.DATASTREAM OBJ)))
	        (OPENSTREAM STR (QUOTE INPUT))               (* might already be open, but just in case)
	        (COPYBYTES STR NEWSTR 0 -1)                  (* copy all the data)
	    )
          (RETURN (CLOSEF NEWSTR])

(FILEOBJ.FILEPROPS
  [LAMBDA (OBJ)                                              (* lmm "29-Dec-84 22:57")
                                                             (* restore properties of file.
							     This is because {NODIRCORE} may not retain any of the 
							     properties at all)
    (IMAGEOBJPROP OBJ (QUOTE FILEPROPERTIES])

(FILEOBJ.FILEINFOS
  [LAMBDA (FILE)                                             (* edited: "12-Jan-85 22:29")
                                                             (* get relevant properties of a file to save away.)
                                                             (* lmm "29-Dec-84 22:26")
    (PROG (PROPS X TYPE)
          (AND (LITATOM (SETQ X (FULLNAME FILE)))
	       (push PROPS (LIST (QUOTE NAME)
				 X)))
          (AND (SETQ X (GETFILEINFO FILE (QUOTE FILETYPE)))
	       (push PROPS (LIST (QUOTE FILETYPE)
				 X)))
          [COND
	    ((SETQ X (GETFILEINFO FILE (QUOTE CREATIONDATE)))
	      (push PROPS (LIST (QUOTE CREATIONDATE)
				X]
          [COND
	    ((AND (SETQ TYPE (GETFILEINFO FILE (QUOTE TYPE)))
		  (NEQ TYPE (QUOTE ?)))
	      (push PROPS (LIST (QUOTE TYPE)
				TYPE))
	      (COND
		([AND (EQ TYPE (QUOTE TEXT))
		      (SETQ X (GETFILEINFO FILE (QUOTE EOL]
		  (push PROPS (LIST (QUOTE EOL)
				    X]
          (RETURN PROPS])

(FILEOBJ.SAVE
  [LAMBDA (OBJ STREAM)                                       (* lmm "29-Dec-84 22:58")
                                                             (* save contents of OBJ on STREAM.
							     Different from .PUT because it saves all of the 
							     properties and the length too)
    (PROG ((STR (FILEOBJ.DATASTREAM OBJ)))
          (PRINT (FILEOBJ.FILEPROPS OBJ)
		 STREAM)
          (COPYBYTES STR STREAM 0 (SUB1 (PRINT (GETFILEINFO STR (QUOTE LENGTH))
					       STREAM])

(FILEOBJ.DATASTREAM
  [LAMBDA (OBJ)                                              (* lmm "29-Dec-84 22:58")
                                                             (* just return the data stream)
    (IMAGEOBJPROP OBJ (QUOTE OBJECTDATUM])

(FILEOBJ.COPY
  [LAMBDA (OBJ)                                              (* lmm " 5-Jan-85 01:04")
                                                             (* a new object with the same contents.
							     Since the NODIRCORE stream is read only, no reason to 
							     copy the data)
                                                             (* important that they share monitor lock!)
    (FILEOBJ.CREATE (FILEOBJ.DATASTREAM OBJ)
		    (FILEOBJ.FILEPROPS OBJ)
		    (FILEOBJ.LOCK OBJ])

(FILEOBJ.GET
  [LAMBDA (STREAM TEXTSTREAM)                                (* lmm "29-Dec-84 22:59")
                                                             (* restore data from stream as written by FILEOBJ.SAVE)
    (FILEOBJ.GET1 (READ STREAM)
		  (READ STREAM)
		  STREAM])

(FILEOBJ.GET1
  [LAMBDA (PROPS LEN SOURCE)                                 (* edited: "12-Jan-85 23:29")
                                                             (* called by FILEOBJ.GET and FILEOBJ -- create a new 
							     object given properties, a length, and a source for 
							     data)
    (PROG ((STR (OPENSTREAM (QUOTE {NODIRCORE})
			    (QUOTE BOTH)
			    NIL NIL PROPS)))
          (COPYBYTES SOURCE STR 0 (SUB1 LEN))
          (RETURN (FILEOBJ.CREATE STR PROPS])

(FILEOBJ.CREATE
  [LAMBDA (FILESTREAM PROPS LOCK)                            (* lmm " 5-Jan-85 01:03")
                                                             (* create the datatype for file object, remembering the
							     FILEPROPS too)
    (LET ((OBJ (IMAGEOBJCREATE FILESTREAM FILEOBJ.IMAGEFNS)))
      (IMAGEOBJPROP OBJ (QUOTE FILEPROPERTIES)
		    PROPS)
      (AND LOCK (IMAGEOBJPROP OBJ (QUOTE LOCK)
			      LOCK))
      OBJ])

(FILEOBJ.IMAGEBOX
  [LAMBDA (OBJ STREAM)                                       (* lmm " 5-Jan-85 00:21")
                                                             (* the bounding box for the stream.
							     If fileobjects print differently, this will have to 
							     change)
    (LET ((BM (FILEOBJ.ICON OBJ)))
      (create IMAGEBOX
	      XSIZE ←(BITMAPWIDTH BM)
	      YSIZE ←(BITMAPHEIGHT BM)
	      YDESC ← 0
	      XKERN ← 0])

(FILEOBJ.DISPLAY
  [LAMBDA (OBJ STREAM)                                       (* lmm " 5-Jan-85 00:22")
    (BITBLT (FILEOBJ.ICON OBJ)
	    0 0 STREAM (DSPXPOSITION NIL STREAM)
	    (DSPYPOSITION NIL STREAM])

(FILEOBJ.NAME
  [LAMBDA (OBJ)                                              (* lmm "29-Dec-84 23:02")
                                                             (* used by DISPLAY, IMAGEBOX to recall the "saved" 
							     name)
    (for X in (FILEOBJ.FILEPROPS OBJ) when (EQ (CAR (LISTP X))
					       (QUOTE NAME))
       do (RETURN (CADR X)) finally (RETURN "a file"])

(FILEOBJ.TYPE
  [LAMBDA (OBJ)                                              (* edited: "12-Jan-85 22:35")
    (SELECTC (CADR (ASSOC (QUOTE FILETYPE)
			  (FILEOBJ.FILEPROPS OBJ)))
	     (4361                                           (* interpress -- ugh)
		   (QUOTE INTERPRESS))
	     (CADR (ASSOC (QUOTE TYPE)
			  (FILEOBJ.FILEPROPS OBJ])
)

(RPAQ FILEOBJ.PRINTFILE.ICON (READBITMAP))
(16 16
"GON@"
"GOO@"
"F@GH"
"F@EL"
"F@DN"
"F@GN"
"F@@F"
"FCLF"
"FBDF"
"FBDF"
"FOOF"
"FOOF"
"FOOF"
"F@@F"
"GOON"
"GOON")

(RPAQ FILEOBJ.TEXTFILE.ICON (READBITMAP))
(16 16
"GON@"
"GOO@"
"F@GH"
"F@EL"
"F@DN"
"F@GN"
"F@@F"
"F@@F"
"F@@F"
"F@@F"
"F@@F"
"F@@F"
"F@@F"
"F@@F"
"GOON"
"GOON")

(RPAQ FILEOBJ.BINARYFILE.ICON (READBITMAP))
(16 16
"GON@"
"GOO@"
"F@GH"
"F@EL"
"F@DN"
"F@GN"
"F@@F"
"FIBF"
"FDIF"
"FIBF"
"FDIF"
"FIBF"
"FDIF"
"F@@F"
"GOON"
"GOON")

(RPAQ FILEOBJ.IMAGEFNS (IMAGEFNSCREATE (FUNCTION FILEOBJ.DISPLAY)
				       (FUNCTION FILEOBJ.IMAGEBOX)
				       (FUNCTION FILEOBJ.SAVE)
				       (FUNCTION FILEOBJ.GET)
				       (FUNCTION FILEOBJ.COPY)
				       (FUNCTION FILEOBJ.BUTTON)
				       (FUNCTION FILEOBJ.COPYIN)))
(PUTPROPS FILEOBJ COPYRIGHT ("Xerox Corporation" 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1017 10503 (FILEOBJ 1027 . 1614) (FILEOBJ.BUTTON 1616 . 3399) (FILEOBJ.ICON 3401 . 3690
) (FILEOBJ.LOCK 3692 . 3953) (FILEOBJ.PUT 3955 . 4717) (FILEOBJ.FILEPROPS 4719 . 5088) (
FILEOBJ.FILEINFOS 5090 . 6255) (FILEOBJ.SAVE 6257 . 6809) (FILEOBJ.DATASTREAM 6811 . 7073) (
FILEOBJ.COPY 7075 . 7616) (FILEOBJ.GET 7618 . 7921) (FILEOBJ.GET1 7923 . 8461) (FILEOBJ.CREATE 8463 . 
8946) (FILEOBJ.IMAGEBOX 8948 . 9427) (FILEOBJ.DISPLAY 9429 . 9661) (FILEOBJ.NAME 9663 . 10106) (
FILEOBJ.TYPE 10108 . 10501)))))
STOP