CLIM mail archive

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

Re: accepting-values and exit-boxes



    Date: Mon, 24 Aug 1992 17:21 EDT
    From: Jeff Morrill <jmorrill@BBN.COM>

      Date: Mon, 24 Aug 1992 15:47-0400
      From: Scott McKay <SWM@stony-brook.scrc.symbolics.com>
      Subject: accepting-values and exit-boxes
      To: chyde@chesapeake.ads.com, clim@BBN.COM
  
	  Date: Tue, 11 Aug 1992 19:19 EDT
	  From: Clinton Hyde <chyde@chesapeake.ads.com>
  
  
	  is Accepting-values only allowed to have the two exit-boxes :exit and
	  :abort?
  
	  I'd really like to have three, and attach some behavior to them.
  
  
      CLIM 2.0 allows you to extend the types of exit boxes.  The typical
      types are :exit, :abort, and :help.

    Can you elaborate a bit?  For example, I can imagine wanting to:
     1.  have just one choice, :exit
     2.  associate an arbitrary function call with an exit button
	 (I presume that's what :help would do, rather than being a true "exit" button)
     3.  associate a drawing function, rather than a string name, with an exit button,
	 so that the button is graphical rather than textual
     4.  assign the button a pointer documentation string
     5.  put the buttons somewhere else besides the bottom (yikes!)

     6.  I would also like to make the kind of dialog box that is merely a couple
	 of exit boxes, as in:

	 Wait!  You are about to cause a nuclear meltdown.  Do it anyway?
	 OK  Cancel

	 And have the #\Return character activate a default choice.  I don't
	 know if accepting values is the right way to do this or not.

    jeff morrill


The default methods are the following.  They can all be specialized to
do whatever you want, really.  (I realize this is kind of a vague
answer, but I', trying to catch up on all my mail, etc.)

(defmethod frame-manager-default-exit-boxes ((framem standard-frame-manager))
  '((:abort) (:exit)))

(defmethod frame-manager-exit-box-labels 
	   ((framem standard-frame-manager) frame view)
  (declare (ignore frame view))
  '((:exit   "Exit")
    (:abort  "Cancel")))

(defmethod display-exit-boxes ((frame accept-values) stream (view view))
  ;; Do the fresh-line *outside* of the updating-output so that it
  ;; doesn't get repositioned relatively in the X direction if the
  ;; previous line gets longer.  Maybe there should be some better
  ;; way of ensuring this.
  (fresh-line stream)
  (let ((labels (frame-manager-exit-box-labels (frame-manager frame) frame view)))
    (updating-output (stream :unique-id stream :cache-value 'exit-boxes)
      (with-slots (exit-boxes) frame
	(dolist (exit-box exit-boxes)
	  (let* ((value (if (consp exit-box) (car exit-box) exit-box))
		 (label (or (and (consp exit-box) (second exit-box))
			    (second (assoc value labels)))))
	    (with-output-as-presentation (stream value 'accept-values-exit-box)
	      #-CCL-2
	      (write-string label stream)
	      #+CCL-2
	      (if (eq value ':abort)
		  ;; Kludge to print the cloverleaf char in MCL.
		  ;; Needs an accompanying kludge in STREAM-WRITE-CHAR so that
		  ;; #\CommandMark doesn't get lozenged.
		  (progn
		    (with-text-style (stream '(:mac-menu :roman :normal))
		      (write-char #\CommandMark stream))
		    (write-string "-. aborts" stream))
		  (write-string label stream)))
	    (write-string " " stream)))))))


References:

Main Index | Thread Index