(FILECREATED " 8-Mar-85 21:51:27" {IVY}<TEDIT>IMAGEOBJS>HRULE.;12 5783   

      changes to:  (FNS HRULE.CREATE)

      previous date: " 3-Mar-85 16:46:55" {IVY}<TEDIT>IMAGEOBJS>HRULE.;11)


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

(PRETTYCOMPRINT HRULECOMS)

(RPAQQ HRULECOMS [(FNS * HRULEFNS)
		  (INITVARS (HRULE.DEFAULT.WIDTH 2))
		  (VARS (HRULEFNS (QUOTE (HRULE.CREATE HRULE.DISPLAYFN HRULE.GETFN HRULE.IMAGEBOXFN 
						       HRULE.PUTFN HRULE.COPYFN 
						       HRULE.WHENOPERATEDONFN)))
			(HRULE.IMAGEFNS (IMAGEFNSCREATE (FUNCTION HRULE.DISPLAYFN)
							(FUNCTION HRULE.IMAGEBOXFN)
							(FUNCTION HRULE.PUTFN)
							(FUNCTION HRULE.GETFN)
							(FUNCTION HRULE.COPYFN)
							(FUNCTION NILL)
							(FUNCTION NILL)
							(FUNCTION NILL)
							(FUNCTION NILL)
							(FUNCTION NILL)
							(FUNCTION NILL)
							(FUNCTION HRULE.WHENOPERATEDONFN)
							(FUNCTION NILL])

(RPAQQ HRULEFNS (HRULE.CREATE HRULE.DISPLAYFN HRULE.GETFN HRULE.IMAGEBOXFN HRULE.PUTFN HRULE.COPYFN 
			      HRULE.WHENOPERATEDONFN))
(DEFINEQ

(HRULE.CREATE
  [LAMBDA (WIDTH)                                            (* gbn " 6-Jan-85 16:14")
    (PROG (HRULE)
          (if (NOT (NUMBERP WIDTH))
	      then (TEDIT.PROMPTPRINT TEXTOBJ (CONCAT "Non-numeric widths not desirable: " WIDTH)
				      T)
	    else (SETQ HRULE (IMAGEOBJCREATE NIL HRULE.IMAGEFNS))
		 (IMAGEOBJPROP HRULE (QUOTE RULE.WIDTH)
			       (OR WIDTH HRULE.DEFAULT.WIDTH))
		 (RETURN HRULE])

(HRULE.DISPLAYFN
  [LAMBDA (HRULE IMAGE.STREAM)                               (* jds " 1-Mar-85 15:24")
                                                             (* function which displays the bitmap of the hrule on 
							     the display or calls an {inter}press function to draw 
							     the rule on a file)
    (PROG ((WIDTH (IMAGEOBJPROP HRULE (QUOTE RULE.WIDTH)))
	   (BITMAP (IMAGEOBJPROP HRULE (QUOTE BITMAP)))
	   X Y)
          (SELECTQ (IMAGESTREAMTYPE IMAGE.STREAM)
		   (DISPLAY (BITBLT BITMAP NIL NIL IMAGE.STREAM (DSPXPOSITION NIL IMAGE.STREAM)
				    (DSPYPOSITION NIL IMAGE.STREAM)))
		   (PROGN 

          (* since this is a streamtype that we don't know about, use the generic case (which is what press and interpress do 
	  as well))


			  (SETQ X (DSPXPOSITION NIL IMAGE.STREAM))
			  (SETQ Y (DSPYPOSITION NIL IMAGE.STREAM))
			  (DRAWLINE X Y [IPLUS X (fetch XSIZE of (IMAGEOBJPROP HRULE (QUOTE BOUNDBOX]
				    Y
				    (FIXR (FTIMES WIDTH (DSPSCALE NIL IMAGE.STREAM)))
				    (QUOTE PAINT)
				    IMAGE.STREAM])

(HRULE.GETFN
  [LAMBDA (INPUT.STREAM TEXTSTREAM)                          (* gbn "10-Jan-85 02:56")
                                                             (* reads the width and creates an HRULE)
    (HRULE.CREATE (READ INPUT.STREAM])

(HRULE.IMAGEBOXFN
  [LAMBDA (HRULE IMAGE.STREAM CURRENT.X RIGHT.MARGIN)        (* jds " 1-Mar-85 15:59")
                                                             (* returns an imagebox describing the size of the 
							     scaled bitmap)
    (PROG ((RULE.WIDTH (IMAGEOBJPROP HRULE (QUOTE RULE.WIDTH)))
	   (BITMAP (IMAGEOBJPROP HRULE (QUOTE BITMAP)))
	   PAGE.WIDTH HEIGHT BOX)
          (SETQ PAGE.WIDTH (IDIFFERENCE RIGHT.MARGIN CURRENT.X))
          (SETQ BOX (create IMAGEBOX
			    XSIZE ← PAGE.WIDTH
			    YSIZE ← RULE.WIDTH
			    YDESC ← 0
			    XKERN ← 0))
          (COND
	    ((AND [NOT (EQUAL BOX (IMAGEOBJPROP HRULE (QUOTE BOUNDBOX]
		  (EQ (QUOTE DISPLAY)
		      (IMAGESTREAMTYPE IMAGE.STREAM)))       (* the bound box just computed is different from the 
							     cached one, so compute a new image)
	      (SETQ BITMAP (BITMAPCREATE PAGE.WIDTH RULE.WIDTH))
	      (BITBLT NIL NIL NIL BITMAP NIL NIL NIL NIL (QUOTE TEXTURE)
		      (QUOTE REPLACE)
		      BLACKSHADE)
	      (IMAGEOBJPROP HRULE (QUOTE BITMAP)
			    BITMAP)))
          (RETURN BOX])

(HRULE.PUTFN
  [LAMBDA (HRULE OUTPUT.STREAM)                              (* gbn "13-May-84 14:21")
                                                             (* prints only the rule.width to the file, the rest can 
							     be discovered)
    (PRINT (IMAGEOBJPROP HRULE (QUOTE RULE.WIDTH))
	   OUTPUT.STREAM])

(HRULE.COPYFN
  [LAMBDA (IMAGEOBJ FROMSTREAM TOSTREAM)                     (* jds "22-Feb-85 13:56")
                                                             (* This function does not build the bitmap but lets the
							     imageboxfn cache a bitmap)
    (HRULE.CREATE (IMAGEOBJPROP IMAGEOBJ (QUOTE RULE.WIDTH))
		  TOSTREAM])

(HRULE.WHENOPERATEDONFN
  [LAMBDA (A B C C)                                          (* gbn " 6-Jan-85 13:23")
                                                             (* DUMMY)
    ])
)

(RPAQ? HRULE.DEFAULT.WIDTH 2)

(RPAQQ HRULEFNS (HRULE.CREATE HRULE.DISPLAYFN HRULE.GETFN HRULE.IMAGEBOXFN HRULE.PUTFN HRULE.COPYFN 
			      HRULE.WHENOPERATEDONFN))

(RPAQ HRULE.IMAGEFNS (IMAGEFNSCREATE (FUNCTION HRULE.DISPLAYFN)
				     (FUNCTION HRULE.IMAGEBOXFN)
				     (FUNCTION HRULE.PUTFN)
				     (FUNCTION HRULE.GETFN)
				     (FUNCTION HRULE.COPYFN)
				     (FUNCTION NILL)
				     (FUNCTION NILL)
				     (FUNCTION NILL)
				     (FUNCTION NILL)
				     (FUNCTION NILL)
				     (FUNCTION NILL)
				     (FUNCTION HRULE.WHENOPERATEDONFN)
				     (FUNCTION NILL)))
(PUTPROPS HRULE COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1066 5109 (HRULE.CREATE 1076 . 1560) (HRULE.DISPLAYFN 1562 . 2741) (HRULE.GETFN 2743 . 
3003) (HRULE.IMAGEBOXFN 3005 . 4210) (HRULE.PUTFN 4212 . 4543) (HRULE.COPYFN 4545 . 4905) (
HRULE.WHENOPERATEDONFN 4907 . 5107)))))
STOP