CLIM mail archive
[Prev][Next][Index][Thread]
Re: use of AND and Or in presentation specs
-
To: clim@BBN.COM
-
Subject: Re: use of AND and Or in presentation specs
-
From: Daniel D Suthers <suthers+@pitt.edu>
-
Date: Tue, 2 Nov 1993 14:02:03 -0500 (EST)
-
Cc: clim-support@lucid.com
CLIM1.1
In partial reply to my question, '(and p1 p2) works in
with-output-as-presentation,
but apparently not in defining commands ...
#|-----------------------------------------------------------------------------
-
Using "and" presentation types ...
Problem: we have two independent presentation hierarchies (one for a
syntactic classification, another for an application-dependent
semantic classification). We want to be able to draw the thing in a
single presentation that is classified in both hierarchies.
Confusion: The manual says presentation type names are "usually"
symbols, but doesn't say when they aren't. It tells us about "and" and
"or" operators for meta-presentation types but doesn't say where these
are legal.
Solution: The following approach appears to work (in CLIM 1.1, Lucid4.0
and MCL2.0):
(with-output-as-presentation
(:stream stream
:object object
:type (list 'and <syntactic-presentation> <semantic-presentation>))
...)
Then a command defined on either of the presentation types (alone) will
highlight the conjunctive presentation.
One apparently CANNOT use conjunctive presentation types in commands, e.g.
one can't do:
(define-test-window-command (BEEP-ON-AB-PRESENTATIONS :menu "Find AB's")
((presentation '(and a b) :gesture :select))
...)
The error occurs at run time in both Lucid and MCL (see end).
To see the error you need to uncomment and evaluate the "Find AB's" command.
------------------------------------------------------------------------------|
#
(in-package :CLIM-USER)
#+:MCL (setq CLIM::*COMMANDS-IN-MENUBAR* nil)
(defvar *root-window* (clim:open-root-window #+:CLX :clx
#+:MCL :mcl
))
(define-application-frame TEST-WINDOW ()
;;
()
(:panes (
(output-pane
:application
:scroll-bars :vertical)
(test-display :application
:display-after-commands nil
:display-function 'display-test
:scroll-bars :both)
(documentation :pointer-documentation)
(menu :command-menu)))
(:layout ((default
(:column :rest
(test-display 17/20)
(output-pane 1/20)
(documentation 1/20)
(menu :rest))))))
(clim:define-presentation-type A ())
(clim:define-presentation-type B ())
;;; This is what we want to AVOID having to do, since there
;;; would be too many combinations of predefined syntactic
;;; presentations with application-dependent semantic
;;; presentations.
;;;
;;; (clim:define-presentation-type AB () :inherit-from '(a b))
(defun RUN-TEST ()
;;
(let ((frame (clim:make-application-frame
'test-window
:parent *root-window*
:width 600
:height 600)))
(clim:run-frame-top-level frame)))
(define-test-window-command (BEEP-ON-A-PRESENTATIONS :menu "Find A's")
((presentation 'A :gesture :select))
(declare (ignore presentation))
(clim:beep)
(format *standard-output* "~%You found an A."))
(define-test-window-command (BEEP-ON-B-PRESENTATIONS :menu "Find B's")
((presentation 'B :gesture :select))
(declare (ignore presentation))
(clim:beep)
(format *standard-output* "~%You found a B."))
;;; This does NOT work, see error at end ...
#|
(define-test-window-command (BEEP-ON-AB-PRESENTATIONS :menu "Find AB's")
((presentation '(and a b) :gesture :select))
(declare (ignore presentation))
(clim:beep)
(format *standard-output* "~%You found an AB."))
|#
(define-test-window-command (DONE :menu "Done") ()
(clim:frame-exit clim:*application-frame*)
)
(defmethod DISPLAY-TEST ((application test-window) stream)
(window-clear stream)
;;
;; Draw some A's
;;
(with-output-as-presentation
(:stream stream :object 'a :type 'A)
(surrounding-output-with-border
(stream :shape ':rectangle)
(draw-text* stream "A" 50 50)))
(with-output-as-presentation
(:stream stream :object 'a :type 'A)
(surrounding-output-with-border
(stream :shape ':rectangle)
(draw-text* stream "A" 300 200)))
;;
;; Draw some B's
;;
(with-output-as-presentation
(:stream stream :object 'b :type 'B)
(surrounding-output-with-border
(stream :shape ':rectangle)
(draw-text* stream "B" 450 350)))
(with-output-as-presentation
(:stream stream :object 'b :type 'B)
(surrounding-output-with-border
(stream :shape ':rectangle)
(draw-text* stream "B" 200 300)))
;;
;; Draw some AandB's.
;;
;; >>>>> THIS IS WHERE WE NEED "AND" THE MOST, especially with <<<<<
;; >>>>> the presentation types being determined at run time. <<<<<
;;
(with-output-as-presentation
(:stream stream :object 'ab :type (list 'and 'a 'b))
(surrounding-output-with-border
(stream :shape ':rectangle)
(draw-text* stream "AandB" 110 90)))
(with-output-as-presentation
(:stream stream :object 'ab :type (list 'and 'a 'b))
(surrounding-output-with-border
(stream :shape ':rectangle)
(draw-text* stream "AandB" 280 180)))
;;
#+:MCL (clim::redisplay-decorations stream))
#|-----------------------------------------------------------------------------
-
;;; For this test, uncomment & evaluate the "Find AB's" command before
running...
> (run-test)
>>Error: No applicable method exists for the generic-function
CLIM::PRESENTATION-TYPEP-METHOD when called with these arguments:
(#<{Instance?} #X119B8266> NIL ("Find AB's" NIL (:COMMAND #)) A)
(:GENERIC-FUNCTION NO-APPLICABLE-METHOD :|dispatch code|):
Required arg 0 (GENERIC-FUNCTION): #<Presentation-Generic-Function
CLIM::PRESENTATION-TYPEP-METHOD (21)>
Rest arg 1 (ARGS): (#<{Instance?} #X119B8266> NIL ("Find AB's" NIL
(:COMMAND #)) A)
:C 0: Try this call again
:A 1: Return to Test Window command level
2: Test Window top level
3: Exit Test Window
4: Abort to Lisp Top Level
-> :B
(:GENERIC-FUNCTION NO-APPLICABLE-METHOD :|dispatch code|) <-
(:GENERIC-FUNCTION NO-APPLICABLE-METHOD :|update trampoline|) <-
(:GENERIC-FUNCTION CLIM::PRESENTATION-TYPEP-METHOD :|dispatch code|) <-
PRESENTATION-TYPEP <- (:INTERNAL (:INTERNAL
(CLIM::PRESENTATION-TYPEP-METHOD #) 0) 0) <- (:INTERNAL EVERY 0) <- MAP
<- EVERY <- (:GENERIC-FUNCTION CLIM::PRESENTATION-TYPEP-METHOD
:|dispatch code|) <- PRESENTATION-TYPEP <-
CLIM::IDENTITY-TRANSLATOR-APPLICABLE-P <-
CLIM::TEST-PRESENTATION-TRANSLATOR-1 <-
PRESENTATION-MATCHES-CONTEXT-TYPE <- (:INTERNAL
FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::TEST) <- (:INTERNAL
FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::MAPPER) <- (METHOD
MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT*
(CLIM::LINEAR-OUTPUT-RECORD T T T)) <- (:GENERIC-FUNCTION
MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT* :|dispatch code|) <-
(:INTERNAL FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::MAPPER) <-
(METHOD MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT*
(CLIM::LINEAR-OUTPUT-RECORD T T T)) <- (:GENERIC-FUNCTION
MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT* :|dispatch code|) <-
(:INTERNAL FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::MAPPER) <-
(METHOD MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT*
(CLIM::LINEAR-OUTPUT-RECORD T T T)) <- (:GENERIC-FUNCTION
MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT* :|dispatch code|) <-
(:INTERNAL FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::MAPPER) <-
(METHOD MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT*
(CLIM::LINEAR-OUTPUT-RECORD T T T)) <- (:GENERIC-FUNCTION
MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT* :|dispatch code|) <-
(:INTERNAL FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::MAPPER) <-
(METHOD MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT*
(CLIM::COORDINATE-SORTED-SET-OUTPUT-RECORD T T T)) <- (:GENERIC-FUNCTION
MAP-OVER-OUTPUT-RECORD-ELEMENTS-CONTAINING-POINT* :|dispatch code|) <-
(:INTERNAL FIND-INNERMOST-APPLICABLE-PRESENTATION CLIM::MAPPER) <-
FIND-INNERMOST-APPLICABLE-PRESENTATION <- (:GENERIC-FUNCTION
FRAME-FIND-INNERMOST-APPLICABLE-PRESENTATION :|dispatch code|) <-
HIGHLIGHT-APPLICABLE-PRESENTATION <-
CLIM::HIGHLIGHT-PRESENTATION-OF-CONTEXT-TYPE <- (:INTERNAL (:INTERNAL
(STREAM-READ-GESTURE #) 0) CLIM::WITH-CURSOR-STATE-BODY) <-
CLIM::WITH-CURSOR-STATE-1 <- (METHOD STREAM-READ-GESTURE
(CLIM::INPUT-PROTOCOL-MIXIN)) <- (:INTERNAL (:INTERNAL (:INTERNAL # 1)
0) CALL-NEXT-METHOD) <- (:INTERNAL (:INTERNAL (STREAM-READ-GESTURE
:AROUND #) 1) 0) <- (METHOD STREAM-READ-GESTURE :AROUND
(BASIC-EXTENDED-INPUT-PROTOCOL)) <- (:COMBINED-METHOD
STREAM-READ-GESTURE) <- (:GENERIC-FUNCTION STREAM-READ-GESTURE
:|dispatch code|) <- (METHOD STREAM-READ-GESTURE
(CLIM::INTERACTIVE-STREAM-MIXIN)) <- (:INTERNAL (:INTERNAL
(STREAM-READ-GESTURE :AROUND #) 0) 0) <- (METHOD STREAM-READ-GESTURE
:AROUND (CLIM::INTERACTIVE-STREAM-MIXIN)) <- (:COMBINED-METHOD
STREAM-READ-GESTURE) <- (:GENERIC-FUNCTION STREAM-READ-GESTURE
:|dispatch code|) <- READ-GESTURE <- READ-TOKEN <- (METHOD
CLIM::ACCEPT-METHOD (T T T T T TEXTUAL-VIEW)) <- (:GENERIC-FUNCTION
CLIM::ACCEPT-METHOD :|dispatch code|) <- (METHOD CLIM::ACCEPT-METHOD
(#<CLIM::PRESENTATION-TYPE-CLASS AND 10186576> T T T T T)) <-
(:GENERIC-FUNCTION CLIM::ACCEPT-METHOD :|dispatch code|) <- (:INTERNAL
(:INTERNAL CLIM::ACCEPT-2 CLIM::WITH-INPUT-EDITING-BODY)
CLIM::BODY-CONTINUATION) <- CLIM::WITH-INPUT-CONTEXT-1 <- (:INTERNAL
CLIM::ACCEPT-2 CLIM::WITH-INPUT-EDITING-BODY) <- (:INTERNAL
CLIM::WITH-INPUT-EDITING-INTERNAL CLIM::BODY-CONTINUATION) <-
CLIM::WITH-INPUT-CONTEXT-1 <- CLIM::WITH-INPUT-EDITING-INTERNAL <-
CLIM::ACCEPT-2 <- (METHOD CLIM::ACCEPT-1 (CLIM::INTERACTIVE-STREAM-MIXIN
T)) <- (:GENERIC-FUNCTION CLIM::ACCEPT-1 :|dispatch code|) <- ACCEPT <-
(:INTERNAL CLIM::MENU-ONLY-READ-REMAINING-ARGUMENTS-FOR-PARTIAL-COMMAND
CLIM::REVERSE-PARSER) <- (:INTERNAL
CLIM::INVOKE-COMMAND-NAME-PARSER-AND-COLLECT-INTERNAL
CLIM::PARSE-AND-COLLECT) <- #:BEEP-ON-B-PRESENTATIONS-COMMAND-PARSER-14
<- CLIM::INVOKE-COMMAND-NAME-PARSER-AND-COLLECT-INTERNAL <- (:INTERNAL
INVOKE-COMMAND-PARSER-AND-COLLECT CLIM::BODY-CONTINUATION) <-
CLIM::WITH-INPUT-CONTEXT-1 <- INVOKE-COMMAND-PARSER-AND-COLLECT <-
(METHOD CLIM::ACCEPT-METHOD (#<CLIM::PRESENTATION-TYPE-CLASS COMMAND
1019087E> T T T T TEXTUAL-VIEW)) <- (:GENERIC-FUNCTION
CLIM::ACCEPT-METHOD :|dispatch code|) <- (:INTERNAL (:INTERNAL
CLIM::ACCEPT-2 CLIM::WITH-INPUT-EDITING-BODY) CLIM::BODY-CONTINUATION)
<- CLIM::WITH-INPUT-CONTEXT-1 <- (:INTERNAL CLIM::ACCEPT-2
CLIM::WITH-INPUT-EDITING-BODY) <- (:INTERNAL (:INTERNAL
CLIM::WITH-INPUT-EDITING-INTERNAL
CLIM::WITH-OUTPUT-RECORDING-OPTIONS-BODY) CLIM::BODY-CONTINUATION) <-
CLIM::WITH-INPUT-CONTEXT-1 <- (:INTERNAL
CLIM::WITH-INPUT-EDITING-INTERNAL
CLIM::WITH-OUTPUT-RECORDING-OPTIONS-BODY) <- (METHOD
CLIM::WITH-OUTPUT-RECORDING-OPTIONS-INTERNAL
(CLIM::BASIC-OUTPUT-RECORDING T T T)) <- (METHOD
CLIM::WITH-OUTPUT-RECORDING-OPTIONS-INTERNAL :AROUND
(CLIM::OUTPUT-AND-RECORDING-PROTOCOL-INTERMEDIARY T T T)) <-
(:COMBINED-METHOD CLIM::WITH-OUTPUT-RECORDING-OPTIONS-INTERNAL) <-
(METHOD CLIM::WITH-OUTPUT-RECORDING-OPTIONS-INTERNAL
(CLIM::ENCAPSULATING-STREAM-MIXIN T T T)) <-
CLIM::WITH-INPUT-EDITING-INTERNAL <- CLIM::ACCEPT-2 <- (METHOD
CLIM::ACCEPT-1 (CLIM::INPUT-PROTOCOL-MIXIN T)) <- (:GENERIC-FUNCTION
CLIM::ACCEPT-1 :|dispatch code|) <- ACCEPT <- READ-COMMAND <- (METHOD
READ-FRAME-COMMAND (APPLICATION-FRAME)) <- (:GENERIC-FUNCTION
READ-FRAME-COMMAND :|dispatch code|) <- DEFAULT-FRAME-TOP-LEVEL <-
(METHOD RUN-FRAME-TOP-LEVEL (APPLICATION-FRAME)) <- (METHOD
RUN-FRAME-TOP-LEVEL :AROUND (APPLICATION-FRAME)) <- (:COMBINED-METHOD
RUN-FRAME-TOP-LEVEL) <- (:GENERIC-FUNCTION RUN-FRAME-TOP-LEVEL
:|dispatch code|) <- RUN-TEST <- EVAL <- SYSTEM:ENTER-TOP-LEVEL
->
------------------------------------------------------------------------------|
#
--------------------------------------------------
Dan Suthers | LRDC, room 505A
suthers+@pitt.edu | 3939 O'Hara Street
(412) 624-7036 office | University of Pittsburgh
(412) 624-9149 fax | Pittsburgh, PA 15260
--------------------------------------------------
Follow-Ups:
Main Index |
Thread Index