CLIM mail archive

[Prev][Next][Index][Thread]

menu-choose



   Date: Tue, 20 Oct 92 11:35:49 -0500
   From: "Peter N. Saurugger" <sauruggerpn@phibred.com>

   I am trying to create a menu which displays only a subset of 
   the items to choose from on the screen, but allows the user to
   scroll through this list (usual Mac/windows/etc. style)

   I am using CLIM 1.1 / SPARC /ACL

   The problem is that, although a vertical scroll-bar is 
   displayed in the window, it is not functional, and the :n-rows 
   keyword value is obviously overridden (It displays all 26 items 
   instead of only 7). If I leave out the :n-columns keyword, the 
   menu is displayed four columns wide, so as to accomodate all 
   menu-items within 7 rows - which is what I'd expect. Here is 
   the code:

   (setq item-list-1 '(a b c d e f g h i j k l m n o p q r s t u v 
   w x y z))

   (defun menu-choose-1 (item-list &rest keys)
     (menu-choose item-list :n-columns 1 
		  :n-rows 7 
		  :associated-window
		  (frame-top-level-window *my-app*)))

   (menu-choose-1 item-list-1)

   Did I miss something? Is there another way of doing this short 
   of writing my own menu-choose function?

The sizing parameters you are supplying are being passed to the table
formatter to control the layout of the menu items.  They are not used
to size the menu window.  Instead, the menu-choose code sizes the
window to fit the output.  There is mechanism in the substrate to
control the width and height of the menu window, but due to an
apparent oversight, there is no way for the user to control it.

So, you can do what you suggested and write your own version of
menu-choose, or you can do something like the (Lucid-specific) kludge
I am including below.  The function size-menu-appropriately is called
by the menu-choose-from-drawer code.  The basic ideas is that you can
intercept that call and fiddle with the :WIDTH and :HEIGHT options.

Sorry that I can't offer something better than this...

================================================================
(in-package :clim-user)

(defvar *default-menu-width* nil)
(defvar *default-menu-height* nil)

;;; Intercept the menu-sizing operation, imposing a default
;;; width and height constraint.
(lcl:defadvice (clim::size-menu-appropriately size-menu) 
    (menu &rest args &key width height)
  (unless width (setq width *default-menu-width*))
  (unless height (setq height *default-menu-height*))
  (lcl:apply-advice-continue menu :width width :height height args))

(defun menu-choose-1 (item-list win &rest keys)
  ;; Show only the first 7 lines
  (let ((*default-menu-height* (* (stream-line-height win) 7)))
    (menu-choose item-list :n-columns 1 
		 :n-rows 7 
		 :associated-window win)))

0,,


Main Index | Thread Index