(FILECREATED "15-JUL-83 15:58:30" {PHYLUM}<LISPUSERS>READNUMBER.;9 9714 changes to: (FNS NUMBERPAD.READ) previous date: " 7-FEB-83 16:14:30" {PHYLUM}<LISPUSERS>READNUMBER.;8) (* Copyright (c) 1982, 1983 by Xerox Corporation) (PRETTYCOMPRINT READNUMBERCOMS) (RPAQQ READNUMBERCOMS ((FNS \READNUMBER.FLASHAREA RNUMBER NUMBERPAD.READ CREATE.NUMBERPAD.READER REGIONONSCREEN DISPLAY/NUMBER/READER/TOTAL NUMBER.READER.HANDLER NUMBERPAD.HELDFN \READNUMBER.OUTLINEREGION))) (DEFINEQ (\READNUMBER.FLASHAREA [LAMBDA (LFT BTM WDTH HGHT WIN) (* rrb "28-JUN-82 19:17") (* flashes a region of a window.) (BITBLT NIL NIL NIL WIN LFT BTM WDTH HGHT (QUOTE TEXTURE) (QUOTE INVERT) BLACKSHADE) (DISMISS 60) (BITBLT NIL NIL NIL WIN LFT BTM WDTH HGHT (QUOTE TEXTURE) (QUOTE INVERT) BLACKSHADE]) (RNUMBER [LAMBDA (MSG POSITION MSGFONT DIGITFONT) (* rrb "28-JUN-82 19:26") (* creates a numberpad window menu and lets the user enter a number.) (* it is substantially more efficient to save the NUMBERPAD/READER and call NUMBERPAD.READ directly.) (NUMBERPAD.READ (CREATE.NUMBERPAD.READER MSG POSITION MSGFONT DIGITFONT]) (NUMBERPAD.READ [LAMBDA (NUMBERPAD/READER) (* rrb "15-JUL-83 15:58") (* allows the user to enter a number with the numberpad.) (* position the number pad near the current reading location.) (PROG (ANSWER) (WINDOWPROP NUMBERPAD/READER (QUOTE TOTAL) 0) (OPENW NUMBERPAD/READER) (DISPLAY/NUMBER/READER/TOTAL NUMBERPAD/READER) (* start a mouse process in case this one is it.) (SPAWN.MOUSE) (* wait for the menu handler to set that it is finished.) (until (WINDOWPROP NUMBERPAD/READER (QUOTE FINISHEDFLG) NIL) do (\BACKGROUND)) (CLOSEW NUMBERPAD/READER) (RETURN (WINDOWPROP NUMBERPAD/READER (QUOTE TOTAL]) (CREATE.NUMBERPAD.READER [LAMBDA (MSG WPOSITION MSGFONT DIGITFONT) (* rrb " 7-FEB-83 16:13") (* creates a window menu that displays the digits in a numberpad and lets the user enter a number. It also includes a backspace and a enter) (PROG ((NUMBER/READER/MAXDIGITS 6) WIN READERWIDTH PADLEFT TOTALREGION [DIGITFONT (OR DIGITFONT (FONTCREATE (QUOTE GACHA) 12 (QUOTE BOLD] [MSGFONT (OR MSGFONT (FONTCREATE (QUOTE GACHA) 12 (QUOTE BOLD] NUMBERPAD TOTALWIDTH) [SETQ NUMBERPAD (create MENU ITEMS ←(QUOTE (- % clr 1 2 3 4 5 6 7 8 9 bs 0 ok)) MENUCOLUMNS ← 3 CENTERFLG ← T MENUFONT ← DIGITFONT WHENHELDFN ←(FUNCTION NUMBERPAD.HELDFN) WHENSELECTEDFN ←(FUNCTION NUMBER.READER.HANDLER) MENUOUTLINESIZE ← 2 ITEMHEIGHT ←(IPLUS 2 (FONTPROP DIGITFONT (QUOTE HEIGHT] (* leave room for three lines at the top and the number at the left.) (SETQ WIN (CREATEW [REGIONONSCREEN WPOSITION [WIDTHIFWINDOW (SETQ READERWIDTH (IPLUS [SETQ PADLEFT (IPLUS 12 (SETQ TOTALWIDTH (ITIMES (ADD1 NUMBER/READER/MAXDIGITS) (CHARWIDTH (CHARCODE 0) DIGITFONT] (fetch (MENU IMAGEWIDTH) of NUMBERPAD] (HEIGHTIFWINDOW (IPLUS (COND [MSG (* if there is a msg, leave room for it at the top.) (ITIMES (IPLUS (IQUOTIENT (STRINGWIDTH MSG MSGFONT) READERWIDTH) 2) (FONTPROP MSGFONT (QUOTE HEIGHT] (T 0)) (fetch (MENU IMAGEHEIGHT) of NUMBERPAD] NIL NIL T)) [COND (MSG (* if there is a msg, print it at the top.) (MOVETOUPPERLEFT WIN) (DSPFONT MSGFONT WIN) (COND [(LISTP MSG) (PROG ((RMARG (DSPRIGHTMARGIN NIL WIN))) (for X in MSG do (COND ((IGREATERP (IPLUS (DSPXPOSITION NIL WIN) (STRINGWIDTH X WIN)) RMARG) (TERPRI WIN))) (PRIN3 X WIN) (SPACES 1 WIN] (T (PRIN1 MSG WIN] (OPENW WIN) (* window is opened because of bug in ADDMENU that it doesn't work unless window is open.) (ADDMENU NUMBERPAD WIN (create POSITION XCOORD ← PADLEFT YCOORD ← 0)) [WINDOWPROP WIN (QUOTE TOTALREG) (SETQ TOTALREGION (create REGION LEFT ← 6 BOTTOM ←(IQUOTIENT (fetch (MENU IMAGEHEIGHT) of NUMBERPAD) 2) WIDTH ← TOTALWIDTH HEIGHT ←(FONTPROP DIGITFONT (QUOTE HEIGHT] (\READNUMBER.OUTLINEREGION TOTALREGION WIN 2) (DSPFONT DIGITFONT WIN) (WINDOWPROP WIN (QUOTE TOTAL) 0) (WINDOWPROP WIN (QUOTE MAXDIGITS) NUMBER/READER/MAXDIGITS) (DISPLAY/NUMBER/READER/TOTAL WIN) (CLOSEW WIN) (RETURN WIN]) (REGIONONSCREEN [LAMBDA (POS WIDTH HEIGHT) (* rrb "28-JUN-82 18:58") (* returns the region WIDTH by HEIGHT that is nearest to POS or the cursor position while still being on the screen.) (PROG (LEFT BOTTOM) (COND ((POSITIONP POS) (SETQ LEFT (fetch (POSITION XCOORD) of POS)) (SETQ BOTTOM (fetch (POSITION YCOORD) of POS))) (T (GETMOUSESTATE) (SETQ LEFT LASTMOUSEX) (SETQ BOTTOM LASTMOUSEY))) [COND ((IGREATERP (IPLUS LEFT WIDTH) SCREENWIDTH) (SETQ LEFT (IMAX 0 (IDIFFERENCE SCREENWIDTH WIDTH] [COND ((IGREATERP (IPLUS BOTTOM HEIGHT) SCREENHEIGHT) (SETQ BOTTOM (IMAX 0 (IDIFFERENCE SCREENHEIGHT HEIGHT] (RETURN (create REGION LEFT ← LEFT BOTTOM ← BOTTOM WIDTH ← WIDTH HEIGHT ← HEIGHT]) (DISPLAY/NUMBER/READER/TOTAL [LAMBDA (WIN) (* rrb "19-MAY-82 16:05") (* displays the number total in the box in the window.) (PROG [(TOTALREG (WINDOWPROP WIN (QUOTE TOTALREG] (DSPFILL TOTALREG WHITESHADE (QUOTE REPLACE) WIN) (CENTERPRINTINREGION (WINDOWPROP WIN (QUOTE TOTAL)) TOTALREG WIN]) (NUMBER.READER.HANDLER [LAMBDA (DIGIT MENU BUTTON) (* edited: "29-SEP-82 10:01") (* selected fn for a numberpad reader. adds the digit to the current total and updates the display.) (PROG (TOTAL (WIN (WFROMMENU MENU))) (SETQ TOTAL (WINDOWPROP WIN (QUOTE TOTAL))) [WINDOWPROP WIN (QUOTE TOTAL) (SELECTQ DIGIT (bs (IQUOTIENT TOTAL 10)) (clr 0) (- (IMINUS TOTAL)) (% (* empty key) TOTAL) (ok (WINDOWPROP WIN (QUOTE FINISHEDFLG) T) (RETURN)) (COND ((EQ (WINDOWPROP WIN (QUOTE MAXDIGITS)) (NCHARS (ABS TOTAL))) (* don't take any more.) (\READNUMBER.FLASHAREA 0 0 1000 1000 WIN) TOTAL) ((IGEQ TOTAL 0) (IPLUS (ITIMES TOTAL 10) DIGIT)) (T (IDIFFERENCE (ITIMES TOTAL 10) DIGIT] (DISPLAY/NUMBER/READER/TOTAL WIN]) (NUMBERPAD.HELDFN [LAMBDA (ITEM MENU BUTTON) (* rrb "26-MAY-82 18:01") (* prints the help information for a numberpad.) (PROMPTPRINT (SELECTQ ITEM (bs "Will erase the last digit entered.") (ok "Indicates that you are through entering the number.") (clr "Will reset the total to 0") (- " will change the sign of the total") (% "doesn't do anything.") "Will put this digit on the right of the total."]) (\READNUMBER.OUTLINEREGION [LAMBDA (REG WIN OUTLINESIZE) (* rrb "19-MAY-82 15:26") (* puts a black outline around REG.) (PROG ((N (OR (FIXP OUTLINESIZE) 2))) (BITBLT NIL NIL NIL WIN (IDIFFERENCE (fetch LEFT of REG) N) (IDIFFERENCE (fetch BOTTOM of REG) N) (IPLUS (fetch WIDTH of REG) (ITIMES N 2)) (IPLUS (fetch HEIGHT of REG) (ITIMES N 2)) (QUOTE TEXTURE) (QUOTE REPLACE) BLACKSHADE) (BITBLT NIL NIL NIL WIN (fetch LEFT of REG) (fetch BOTTOM of REG) (fetch WIDTH of REG) (fetch HEIGHT of REG) (QUOTE TEXTURE) (QUOTE REPLACE) (DSPTEXTURE NIL WIN]) ) (PUTPROPS READNUMBER COPYRIGHT ("Xerox Corporation" 1982 1983)) (DECLARE: DONTCOPY (FILEMAP (NIL (511 9628 (\READNUMBER.FLASHAREA 521 . 953) (RNUMBER 955 . 1480) (NUMBERPAD.READ 1482 . 2463) (CREATE.NUMBERPAD.READER 2465 . 5690) (REGIONONSCREEN 5692 . 6670) (DISPLAY/NUMBER/READER/TOTAL 6672 . 7122) (NUMBER.READER.HANDLER 7124 . 8259) (NUMBERPAD.HELDFN 8261 . 8803) ( \READNUMBER.OUTLINEREGION 8805 . 9626))))) STOP