CLIM mail archive

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

Re: Utilities



    Date: Wed, 7 Nov 90 20:09 PST
    From: TYSON@sunset.ai.sri.com (Mabry Tyson)

    Thanks a lot for your reply!  

    Re reading a command or form, I thought there was a presentation type
    for command-or-form (but I haven't tried it).  The problem was how to
    redefine the toplevel READ-FRAME-COMMAND properly to use it.

Well, READ-FRAME-COMMAND is generic on the frame so you can make it do
anything you want.  (Of course, at the very bottom it must call
READ-GESTURE (i.e., go blocked for input) or else many things will fail.

    FYI, here's the code I was talking about.  You can look it over to see anything
    that I did wrong because the documentation or my understanding is lacking.
    I think I reported both bugs I had in the highlighting menu stuff already.

    ;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10; Package: CLIM-LIBRARY -*-

    (in-package :clim-library)

    (defun frame-port (frame)
       (slot-value (frame-manager frame) 'ws::port))

What was wrong with using (CLIM:PORT frame)?

    (defun socket-sheet (frame)
      (ws:frame-manager-prop frame :socket-sheet))

    (defun raise-frame (frame)   ; Use instead of SELECT
	(clim-shared:raise-mirror (frame-port frame)
				  (socket-sheet frame)))

    (defun bury-frame (frame)
	(clim-shared:bury-mirror (frame-port frame)
				 (socket-sheet frame)))
  

What was wrong with CLIM:ENABLE-FRAME or CLIM:DISABLE-FRAME?

    (defun set-title (frame title)  ; This only sets the title on frames
      (let ((port (frame-port frame))
	    (sheet (socket-sheet frame)))
	(clim-shared:install-mirror-settings port sheet :title title)
	(clim-shared:update-mirror-region port sheet)
	title))

Yes, there should be a better way of changing the title dynamically.

    ;;; This one really ought to be easier to do
    (defun clear-history (stream)
      (let ((output-record (slot-value stream 'clim-internals::output-record)))
      (clear-output-record output-record)
      (clim-internals::erase-viewport stream)
      stream
      ))

There is a function CLIM:WINDOW-CLEAR which does the above.  Probably not
the best name...

    (export '(frame-port
	      socket-sheet
	      raise-frame
	      bury-frame
	      set-title
	      clear-history))

    ;;; -*- Mode: LISP; Syntax: Common-lisp; Base: 10; Package: CLIM-LIBRARY -*-

    (in-package :clim-library)

    ;;; An Implementation of Highlighting menus for CLIM

    [...]

    ;;; Object will either be
    ;;;   (string :value object &key default-style) for a special choice
    ;;; or 
    ;;;   (item :value item)  where item is a member of items
    (defmethod HIGHLIGHTING-MENU-ITEM-PRINTER ((menu highlighting-menu) object stream)
      (if (not (consp object))
	  (princ object stream)
	  (let ((plist-value (getf (cdr object) :value)))
	    (with-text-face
		((with-slots (item-list highlighted-items test) menu
		   (cond ((member plist-value highlighted-items :test test)
			  :bold)
			 ((member plist-value item-list :test test)
			  :roman)
			 (t :italic))))
	      (if (stringp (car object))
		  (present (car object) stream)
		  (write (car object) stream))))))

There are several bugs in the above function:

1) You call PRINC and WRITE, which don't work to CLIM streams because
there's no stream integration between standard CL streams and CLIM
streams.  Use [CLIM:]FORMAT ~A or ~S, which we've made basically
"compatible."  In the Genera version of CLIM, this is less of an issue
because Symbolics worked on this quite a bit.  It will, however, continue
to be an issue for the near term in other Lisps.

2) You forgot to pass off STREAM as an arg to the with-text-face macro.

3) You forgot that STREAM is a keyword argument to PRESENT.  Try
(present (car object) T :stream stream).


    (defmethod HIGHLIGHTING-MENU-CHOOSE ((menu highlighting-menu))
      (with-slots (item-list highlighted-items test special-choices superior label) menu
	 (loop do
	   (let ((value
		  (menu-choose
		   (nconc (loop for item in item-list
     ;			    collect `(,item :value ,item
     ; Try this one as a temporary hack   )
				collect `(,(if (member item highlighted-items :test test)
					       (format nil "> ~A" item)
					       (format nil "  ~A" item))
					       :value ,item
     ; This didn't work either... Sigh
     ;					    ;;This is to overcome not being
     ;					    ;; able to use the :PRINTER arg
     ;					    ;; to MENU-CHOOSE
     ;					    ,@(when (member item highlighted-items
     ;							    :test test)
     ;						`(:default-style
     ;						     ,(intern-text-style
     ;						       nil :bold nil)))
						))
			  special-choices)
			       :associated-window superior
			       :label label
			       :unique-id (list menu item-list highlighted-items special-choices)
			       :unique-id-test #'(lambda (id1 id2)
						   (highlighting-menu-id-equal menu id1 id2))
			       :cache-value (list menu item-list highlighted-items special-choices)
			       :cache-value-test #'(lambda (id1 id2)
						     (highlighting-menu-id-equal menu id1 id2))
     ; This didn't work
     ;			   :printer #'(lambda (object stream)
     ;					(highlighting-menu-item-printer menu object stream))
			       )))
	  (unless (member value item-list :test test)
	    (return value))
	  (if (member value highlighted-items :test test)
	      (setf highlighted-items
		    (remove value highlighted-items :test test))
	      (push value highlighted-items))))))


    ;;; -*- Mode: LISP; Syntax: Common-lisp; Base: 10; Package: CLIM-LIBRARY -*-

    ;;; How to generate some pop up windows in CLIM
    ;;; ACCEPTING-VALUES does take an arg that might make this easier but
    ;;; it isn't really documented.

If you say :own-window T you'll get the AVV in its own window.  If you say 
:OWN-WINDOW '(:right-margin hspace :bottom-margin vspace) you'll get that amount
of additional space (where hspace and vspace can be the same things you'd
pass off as :INTER-LINE-SPACING or :INTER-COLUMN-SPACING to
FORMATTING-TABLE).

   [...]


    ;;; Dependent on Lucid CL resources here....

If you're going to be dependent on resources, you should probably be
dependent upon the resources already in CLIM (ci::defresource, etc.)
because they, at least, are portable.

    [...]


0,,


Main Index | Thread Index