;;; -*- Lisp -*-
;;;
;;; **********************************************************************
;;; This code was written as part of the Spice Lisp project at
;;; Carnegie-Mellon University, and has been placed in the public domain.
;;; Spice Lisp is currently incomplete and under active development. If
;;; you want to use this code or any part of Spice Lisp, please contact
;;; Scott Fahlman (FAHLMAN@CMUC).
;;; **********************************************************************
;;;
;;; The menu choice facility for Spice Lisp.
;;; Written by Jim Muller.
;;;
(defvar *italic-font*)
(defun menu-choose-init ()
;; For now, don't do fancy things that eat physical memory.
(setq *italic-font* *current-font*)
(setq *default-menu-choose-in-window* *full-window*))
;;; User settable parameters to the choice functions.
(defvar *default-menu-choose-position-x* nil
"This is the default x place to put the upper left hand corner of a choice
menu. Nil indicates the current mouse pointer position.")
(defvar *default-menu-choose-position-y* nil
"This is the default y place to put the upper left hand corner of a choice
menu. Nil indicates the current mouse pointer position.")
;;; This actually gets initialized in menu-choose-init, so that the value
;;; of the port is correct for the current lisp.
(defvar *default-menu-choose-in-window* *full-window*
"This is the default window to use as origin when choosing x-y position of
menu.")
(defvar *default-menu-choose-ncolumns* 1
"This is the default shape for choice windows. It is either a number of
columns to use or :square.")
(defvar *default-menu-choose-items-justified* :center
"The default is for items to be centered in their columns. Left and right
justification are also possible with :left and :right.")
;;; Internal specials.
(defvar *menu-viewport* () "The menu viewport object.")
(defvar *menu-window* () "The menu window object. Used for deletion.")
(defvar *menu-cols* () "A list of the columns (vectors of item structures)
which represents the menu.")
(defvar *menu-inside-width*)
(defvar *menu-width*)
(defvar *menu-column-width*)
(defvar *menu-height*)
(defvar *menu-title-height*)
(defvar *menu-in-viewport*)
;;; These correspond to the obvious parameters to the choice functions.
(defvar *menu-items*)
(defvar *menu-position-x*)
(defvar *menu-position-y*)
(defvar *menu-in-window*)
(defvar *menu-stay-in-place*)
(defvar *menu-title*)
(defvar *menu-title-font*)
(defvar *menu-items-justified*)
(defvar *menu-default-item*)
(defvar *menu-ncolumns*)
(defvar *menu-spacing*)
(defvar *menu-font*)
(defvar *menu-label-font*)
(defvar *menu-abort-value*)
(proclaim '(special *user-font*))
(proclaim '(special *user-viewport*))
;;; Get the height of the font in pixels from accent.
(defmacro font-height (font)
`(multiple-value-bind (n ps r c w h) (font-size ,font)
(declare (ignore n ps r c w))
h))
;;; Until someone actually builds a table of the things or something.
(defun italic-font (font)
(declare (ignore font))
*italic-font*)
;;; Get the width of the string in pixels from accent. Leave 4 for inset space.
(defmacro font-string-width (string font)
`(let* ((string ,string))
(font-string-size ,font string 0 (length string))))
(defparameter *lisp-keytran-file* "lisp.keytran"
"The keytran file that Lisp (not Hemlock) uses.")
(defparameter *mouse-buttons* '(:left :middle :right)
"The mouse buttons available on the Perq.")
(defmacro mouse-button (cmd)
`(case ,cmd (83 :left) (82 :middle) (84 :right)))
(defparameter *mouse-button-press-cmds* '(83 82 84)
"Left, middle, and right mouse buttons on Perq under current keytran file.")
(defparameter *control-g-cmd* 77 "Control G in current keytran file.")
(defparameter border-width 5 "Width in pixels of a sapphire window border.")
(defconstant screen-black 0 "Passed as FUNCT to some accent functions.")
(defconstant screen-white 1 "Passed as FUNCT to some accent functions.")
(defconstant screen-inverse 2 "Passed as FUNCT to some accent functions.")
(defparameter screen-right 767 "Far right pixel on the Perq screen.")
(defparameter screen-bottom 1023 "Far bottom pixel on the Perq screen.")
(defun print-menu (x stream depth)
(declare (ignore depth))
(format stream "#