CLIM mail archive


Re: [spr6202] Question about defining presentation types with parameters and options

Your problem report has been assigned a tracking id of spr6202,
so please use this id in the subject line of any mail related to
it so that we may better track communication on your inquiry.
Also, please cc, so your questions can be answered
if I am unavailable.

	Hi there,

	Consider the following small example:

	;;; -*- Mode: Common-Lisp; Package: CLIM-USER; -*-

	(define-presentation-type sentence
	  :options (direction)
	  :inherit-from 'string)

	(define-presentation-method accept
	    ((type sentence) stream (view textual-view) &key)
	  (with-input-editing (stream) (read-line stream)))

	(define-presentation-method present
	    (object (type sentence) stream (view textual-view) &key)
	  (format stream "~a" object))

	(define-presentation-method presentation-typep
	    (object (type sentence))
	  (and (typep object 'standard-presentation)
	       (let ((ptype (presentation-type object)))
		 (and (listp ptype)
		      (equal ptype (list 'sentence language)))))

	(define-presentation-method presentation-subtypep
	    ((type sentence) putative-supertype)
	  (let (language1)
	    (with-presentation-type-parameters (sentence type)
	      (setf language1 language))
	    (with-presentation-type-parameters (sentence putative-supertype)
	      (if (eq language1 language)
		  (values t t)
		(values nil t)))))

	(defun test ()
	  (present "Das Haus brennt" '((sentence german) :direction :source))
	  (present "The house burns." '((sentence english) :direction :target))
	  (accept '((sentence german) :direction :source)))

	Here is my question:
	Call the function test inside an application frame's interactor pane.
	The inner call to ACCEPT accepts both the german and the english sentence.
	How could I change my code, so that only german sentences are accepted?



It seems that Scott McKay should have answered your problem though his
bug fix should be in the clim-internals package rather than the clim


(in-package :clim-internals)

(defun identity-translator-applicable-p (presentation context-type)
  (let* ((type (presentation-type presentation))
	 (type-name (presentation-type-name type))
	 (object (presentation-object presentation)))
    (with-presentation-type-decoded (context-name context-parameters) context-type
      (if (eq type-name 'blank-area)
	  (eq context-name 'blank-area)
	;; Let MENU-ITEM-IDENTITY take care of pure menu items
	(unless (and (eq type-name 'menu-item)
		     (eq context-name 'menu-item))
	  ;; Either the types definitely match, or the types nominally match
	  ;; and the object must be validated.
	  (or (presentation-subtypep type context-type)
	      (and (not (null context-parameters))
		   (presentation-typep object context-type))))))))

Hope this has fixed your problem adequately.

Colin Meldrum, Franz Inc.	1995 University Avenue, Suite 275         
colin@Franz.COM (internet)	Berkeley, CA 94704                       
uunet!franz!colin (uucp)	Phone: (510) 548-3600; FAX: (510) 548-8253


Main Index | Thread Index