CLIM mail archive

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

Application of execute-frame-command and menu-choose question



    Date: Mon, 2 Dec 1991 11:53 EST
    From: Curt Eggemeyer <curt@eraserhead.jpl.nasa.gov>

    Question 1) How do I manually invoke execute-frame-command with a command and
    a *unsupplied-argument*?

    Assuming your using the CLIM package.

    ex: No arguments for command called do-it it is just,

	    (execute-frame-command *application-frame* '(com-do-it))

	    This works!

    whereas if another command called do-it-with-an-arg, when I try

	    (execute-frame-command *my-application-frame*
		    (list 'com-do-it-with-an-arg *unsupplied-argument*))

	    Nothing happens, except that I get #:unsupplied-argument as a
    return value!#@$%^$%  I am sort of emulating a presentation-to-command
    translator for my menu-choose items.

*UNSUPPLIED-ARGUMENT* is a marker used to tell the command *reader*
that more arguments need to be read for the command.  It is not in
EXECUTE-FRAME-COMMAND's contract to read any more command arguments,
it just dutifully executes whatever command you give it.

If you really mean to do this, you should specialize EXECUTE-FRAME-COMMAND
to read an unsupplied arguments.  There is probably a better way to do
what you want, but I cannot tell from this.

    Question 2)  Is there a way to have non-selectable items in menu-choose
    menus and if so how to you do it?  I like to have menu section labels (which I
    emulate now by using different text style) in my menus grouping specific items,
    plus spacing around items in which I use a blank string as an item.  But
    unfortunately these items are still highlighting.  Or am I stuck with doing
    it differently by using accepting-values with its own window which I find is
    a bit too slow for me?

There is a special kind of command table menu item called a :DIVIDER.  I
don't know if it is documented.  It's intention is to draw a dividing
line in the command menu at that point, but it would be reasonable to
extend its behavior as I have done below.

--------
(in-package :clim)
(defun display-command-table-menu (command-table stream
				   &key max-width max-height
					n-rows n-columns
					inter-column-spacing inter-row-spacing 
					(cell-align-x ':left) (cell-align-y ':top)
					no-initial-spacing move-cursor)
  (unless (or max-width max-height)
    (multiple-value-bind (width height)
	#+Silica (let ((region (sheet-region stream)))
		   (values (bounding-rectangle-width region)
			   (bounding-rectangle-height region)))
	#-Silica (window-inside-size stream)
	(unless max-width (setf max-width width))
	(unless max-height (setf max-height height))))
  (let ((menu (slot-value (find-command-table command-table) 'menu)))
    (if (zerop (count-if #'(lambda (x) (not (null (first x)))) menu))
	(with-text-face (:italic stream)
	  (write-string "[No menu items]" stream))
        (formatting-item-list (stream :max-width max-width :max-height max-height
				      :n-rows n-rows :n-columns n-columns
				      :inter-column-spacing inter-column-spacing
				      :inter-row-spacing inter-row-spacing
				      :no-initial-spacing no-initial-spacing
				      :move-cursor move-cursor)
	  (dovector (element menu)
	    (cond ((eql (command-menu-item-type (third element)) :divider)
		   (TYPECASE (FIRST ELEMENT)
		     (STRING
		       (FORMATTING-CELL (STREAM :ALIGN-X CELL-ALIGN-X :ALIGN-Y CELL-ALIGN-Y)
			 (WRITE-STRING (FIRST ELEMENT) STREAM)))
		     (NULL
		       ;;--- Draw a dividing line
		       )))
		  ((first element)
		   (formatting-cell (stream :align-x cell-align-x :align-y cell-align-y)
		     (present element 'command-menu-element
			      :stream stream :single-box t)))))))))

0,,

References:

Main Index | Thread Index