CLIM mail archive

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

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



    Date: Tue, 28 Jul 1992 22:38 EDT
    From: Colin Meldrum <colin@franz.com>


    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 bugs@franz.com, 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
		(language)
	      :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))
	      (terpri)
	      (present "The house burns." '((sentence english) :direction :target))
	      (terpri)
	      (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?

	    Thomas


    Hello,

    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
    package.

There's a bit of confusion here.  In CLIM 1.0/1.1, the package :CLIM is
both the "export" package and the implementation package.  In CLIM 2.0,
the "export" package is :CLIM and the implementation package is
:CLIM-INTERNALS.  Assuming that H. Ruedesheim is using CLIM 1.1, the
IN-PACKAGE form should use :CLIM; if he is useing CLIM 2.0, the
IN-PACKAGE form should use :CLIM-INTERNALS.

    ie 

    (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


References:

Main Index | Thread Index