(FILECREATED "19-Nov-85 12:22:23" {ERIS}<IRIS>GREGCO>KEYOBJ.;3 10904  

      changes to:  (FNS KEYOBJ.BUTTONEVENTINFN KEYOBJ.CREATE)

      previous date: "28-Jan-85 01:34:31" {ERIS}<LISP>KOTO>LISPUSERS>KEYOBJ.;1)


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

(PRETTYCOMPRINT KEYOBJCOMS)

(RPAQQ KEYOBJCOMS ((FNS KEYOBJ.BUTTONEVENTINFN KEYOBJ.COPYFN KEYOBJ.CREATE KEYOBJ.DISPLAYFN 
			  KEYOBJ.GETFN KEYOBJ.IMAGEBOXFN KEYOBJ.IMAGESTREAMTYPE KEYOBJ.INSTALL.BITMAP 
			  KEYOBJ.PUTFN KEYOBJ.WHENOPERATEDONFN TYPEA)
		     [VARS (KEYOBJ.IMAGEFNS (IMAGEFNSCREATE (FUNCTION KEYOBJ.DISPLAYFN)
							    (FUNCTION KEYOBJ.IMAGEBOXFN)
							    (FUNCTION KEYOBJ.PUTFN)
							    (FUNCTION KEYOBJ.GETFN)
							    (FUNCTION KEYOBJ.COPYFN)
							    (FUNCTION KEYOBJ.BUTTONEVENTINFN)
							    (FUNCTION NILL)
							    (FUNCTION NILL)
							    (FUNCTION NILL)
							    (FUNCTION NILL)
							    (FUNCTION NILL)
							    (FUNCTION NILL)
							    (FUNCTION NILL]
		     (INITVARS (KEYOBJ.FONT (FONTCREATE (QUOTE HELVETICA)
							10)))
		     (BITMAPS KEYOBJ.TEMPLATE)))
(DEFINEQ

(KEYOBJ.BUTTONEVENTINFN
  [LAMBDA (KEYOBJ WINDOWSTREAM SEL RELX RELY WINDOW TEXTSTREAM BUTTON)
                                                             (* gbn "19-Nov-85 12:21")

          (* * gets called when the "key" goes down. sends the down transition, inverts the bitmap of the key, when the mouse
	  comes up, uninverts the picture and sends the up transition)



          (* * NOTE: inside buttoneventinfn's the origin is the left bottom of the imageobj)


    (PROG ((KEYNUMBER (IMAGEOBJPROP KEYOBJ (QUOTE KEYNUMBER)))
	     (ABORTABLE (IMAGEOBJPROP KEYOBJ (QUOTE ABORTABLE)))
	     (IMAGEBOX (IMAGEOBJPROP KEYOBJ (QUOTE IMAGEBOX)))
	     X Y)
	    (IMAGEOBJPROP KEYOBJ (QUOTE STATE)
			    (QUOTE DOWN))
	    (IMAGEOBJPROP KEYOBJ (QUOTE WINDOW)
			    (fetch \WINDOW of (TEXTOBJ TEXTSTREAM)))
	    (KEYOBJ.DISPLAYFN KEYOBJ WINDOWSTREAM NIL NIL T)
	    (if ABORTABLE
		then                                       (* since this is an abortable key don't send any 
							     transitions until the key comes up)
		       NIL
	      else                                         (* send the down transition)
		     (\DECODETRANSITION KEYNUMBER T))
	    (while (MOUSESTATE (OR LEFT MIDDLE RIGHT)) do NIL)
	    (IMAGEOBJPROP KEYOBJ (QUOTE STATE)
			    (QUOTE UP))
	    (KEYOBJ.DISPLAYFN KEYOBJ WINDOWSTREAM NIL NIL T)
	    (SETQ X (LASTMOUSEX WINDOW))
	    (SETQ Y (LASTMOUSEY WINDOW))
	    (if (AND (ILEQ X (fetch XSIZE of IMAGEBOX))
			 (IGEQ X 0)
			 (ILEQ Y (fetch YSIZE of IMAGEBOX))
			 (IGEQ Y 0))
		then 

          (* only send the transition if the mouse is still in the region. This is not consistent with the key metaphor, 
	  however, the menu functionality is useful)


		       (if ABORTABLE
			   then                            (* now send the saved down transition)
				  (\DECODETRANSITION KEYNUMBER T))
		       (\DECODETRANSITION KEYNUMBER))
	    (RETURN (QUOTE DON'T])

(KEYOBJ.COPYFN
  [LAMBDA (IMAGEOBJ FROMSTREAM TOSTREAM)                     (* jds "10-Jan-85 01:03")

          (* * shouldn't be called)

                                                             (* (SHOULDNT "why are you copying a keyobj?"))
    (KEYOBJ.CREATE (IMAGEOBJPROP IMAGEOBJ (QUOTE KEYNAME))
		   TOSTREAM])

(KEYOBJ.CREATE
  [LAMBDA (KEYNAME KEYLABEL ABORTABLE)                       (* gbn "19-Nov-85 12:05")
    (PROG ((KEYOBJ (IMAGEOBJCREATE NIL KEYOBJ.IMAGEFNS))
	     BITMAP
	     (KEYLABEL (OR KEYLABEL KEYNAME))
	     DS)
	    (IMAGEOBJPROP KEYOBJ (QUOTE STATE)
			    (QUOTE UP))
	    (IMAGEOBJPROP KEYOBJ (QUOTE KEYNUMBER)
			    (\KEYNAMETONUMBER KEYNAME))
	    (IMAGEOBJPROP KEYOBJ (QUOTE KEYNAME)
			    KEYNAME)
	    (IMAGEOBJPROP KEYOBJ (QUOTE KEYLABEL)
			    KEYLABEL)
	    (IMAGEOBJPROP KEYOBJ (QUOTE ABORTABLE)
			    ABORTABLE)
	    (KEYOBJ.INSTALL.BITMAP KEYOBJ)
	    (SETQ BITMAP (IMAGEOBJPROP KEYOBJ (QUOTE BITMAP)))
	    (IMAGEOBJPROP KEYOBJ (QUOTE IMAGEBOX)
			    (create IMAGEBOX
				      XSIZE ←(BITMAPWIDTH BITMAP)
				      YSIZE ←(BITMAPHEIGHT BITMAP)
				      YDESC ← 0
				      XKERN ← 0))
	    (RETURN KEYOBJ])

(KEYOBJ.DISPLAYFN
  [LAMBDA (KEYOBJ IMAGE.STREAM MODE TEXTSTREAM OFFSETS0?)    (* jds "10-Jan-85 01:02")
                                                             (* 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 [[SOURCETYPE (SELECTQ (IMAGEOBJPROP KEYOBJ (QUOTE STATE))
				(UP (QUOTE INPUT))
				(DOWN (QUOTE INVERT))
				(ERROR "Illegal state in KEYOBJ" (IMAGEOBJPROP KEYOBJ (QUOTE STATE]
	   (BITMAP (IMAGEOBJPROP KEYOBJ (QUOTE BITMAP]       (* (IMAGE.STREAM (IMAGEOBJPROP KEYOBJ 
							     (QUOTE WINDOW))))
          (SELECTQ (IMAGESTREAMTYPE IMAGE.STREAM)
		   [DISPLAY 

          (* (PROMPTPRINT (CONCAT (IMAGEOBJPROP KEYOBJ (QUOTE STATE)) "CLIP " (DSPCLIPPINGREGION NIL IMAGE.STREAM) " OFFSETS" 
	  (DSPXOFFSET NIL IMAGE.STREAM) " " (DSPYOFFSET NIL IMAGE.STREAM) " X AND Y POS " (DSPXPOSITION NIL IMAGE.STREAM) " " 
	  (DSPYPOSITION NIL IMAGE.STREAM))) (INVERTW IMAGE.STREAM))


			    (if OFFSETS0?
				then (BITBLT BITMAP NIL NIL IMAGE.STREAM 0 0 NIL NIL SOURCETYPE
					     (QUOTE REPLACE))
			      else (BITBLT BITMAP NIL NIL IMAGE.STREAM (DSPXPOSITION NIL IMAGE.STREAM)
					   (DSPYPOSITION NIL IMAGE.STREAM)
					   NIL NIL SOURCETYPE (QUOTE REPLACE]
		   (ERROR "NO OTHER STREAMS DEFINED FOR KEYOBJ.DISPLAYFN"])

(KEYOBJ.GETFN
  [LAMBDA (INPUT.STREAM TEXTSTREAM)                          (* gbn "27-Jan-85 23:36")

          (* * just reads the keyname and calls keyobj.create)


    (KEYOBJ.CREATE (READ INPUT.STREAM)
		   (READ INPUT.STREAM])

(KEYOBJ.IMAGEBOXFN
  [LAMBDA (KEYOBJ IMAGE.STREAM CURRENT.X RIGHT.MARGIN)       (* gbn " 9-Jan-85 21:35")

          (* * since all keyobjs have constant dimensions, they are cached as the imagebox prop)


    (IMAGEOBJPROP KEYOBJ (QUOTE IMAGEBOX])

(KEYOBJ.IMAGESTREAMTYPE
  [LAMBDA (STREAM)                                           (* gbn "13-May-84 12:38")
                                                             (* hack until imagestreamtype works)
    (if (STKPOS (QUOTE TEDIT.HARDCOPY))
	then (QUOTE INTERPRESS)
      else (QUOTE DISPLAY])

(KEYOBJ.INSTALL.BITMAP
  (LAMBDA (KEYOBJ)                                           (* edited: "18-Jan-85 18:52")

          (* * Takes an imageobj and installs the image according to the size and label on the props)


    (PROG ((BITMAP (BITMAPCOPY KEYOBJ.TEMPLATE))
	   (KEYLABEL (IMAGEOBJPROP KEYOBJ (QUOTE KEYLABEL)))
	   DS QUARTER)
          (SETQ DS (DSPCREATE BITMAP))
          (DSPFONT KEYOBJ.FONT DS)
          (if (LISTP KEYLABEL)
	      then                                           (* this is supposed to have two labels, one on top of 
							     the other)
		   (SETQ QUARTER (IQUOTIENT (BITMAPHEIGHT BITMAP)
					    4))
		   (CENTERPRINTINREGION (CADR KEYLABEL)
					(SETQ REGION
					  (create REGION
						  LEFT ← 0
						  BOTTOM ← QUARTER
						  WIDTH ← (BITMAPWIDTH BITMAP)
						  HEIGHT ← QUARTER))
					DS)
		   (replace BOTTOM of REGION with (ITIMES 2 QUARTER))
		   (CENTERPRINTINREGION (CAR KEYLABEL)
					REGION DS)
	    else (CENTERPRINTINREGION KEYLABEL (create REGION
						       LEFT ← 0
						       BOTTOM ← 0
						       WIDTH ← (BITMAPWIDTH BITMAP)
						       HEIGHT ← (BITMAPHEIGHT BITMAP))
				      DS))
          (CLOSEF DS)
          (IMAGEOBJPROP KEYOBJ (QUOTE BITMAP)
			BITMAP)
          (RETURN KEYOBJ))))

(KEYOBJ.PUTFN
  [LAMBDA (KEYOBJ OUTPUT.STREAM)                             (* gbn "27-Jan-85 23:35")
                                                             (* prints only the rule.width to the file, the rest can
							     be discovered)
    (PRINT (IMAGEOBJPROP KEYOBJ (QUOTE KEYNAME))
	   OUTPUT.STREAM)
    (PRINT (IMAGEOBJPROP KEYOBJ (QUOTE KEYLABEL))
	   OUTPUT.STREAM])

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

(TYPEA
  [LAMBDA NIL                                                (* gbn " 9-Jan-85 21:09")
                                                             (* fakes typing an A)
    (\DT 46 T)
    (\DT 46 NIL])
)

(RPAQ KEYOBJ.IMAGEFNS (IMAGEFNSCREATE (FUNCTION KEYOBJ.DISPLAYFN)
					(FUNCTION KEYOBJ.IMAGEBOXFN)
					(FUNCTION KEYOBJ.PUTFN)
					(FUNCTION KEYOBJ.GETFN)
					(FUNCTION KEYOBJ.COPYFN)
					(FUNCTION KEYOBJ.BU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