CLIM mail archive
[Prev][Next][Index][Thread]
Redisplay of a changing (and growing) list
Date: Tue, 7 Jan 1992 08:28 EST
From: waarbau@tycho.ncsc.mil (William (Bill) A. Arbaugh)
Here is more on Bill Arbaugh's question.
Here's some "working" code (minus any possible typos :-).
I didn't include it all originally as I have
to type the code in by hand as this (tycho) is standalone.
What I think is happening. Elements 1 - 5 get displayed on the INITIAL
display of the frame. They immediately disappear (probably because
the call to redisplay in draw-display). I remember things similiar to
this in dw, and if I remember correctly the problem was typically
related to the stream.
(define-application-frame test ()
((pane-list :initform (list 1 2 3 4 5)
:accessor pane-list)
(pane-rec :accessor pane-rec))
(:panes ((display-pane :application
:display-after-commands T
:display-function 'draw-display
:scroll-bars :vertical
:end-of-page-action :scroll)
(interactor :interactor)
(menu :command-menu)))
(:layout ((normal (:column :rest
(display-pane .7)
(menu :compute)
(interactor :rest))))))
;; initialize the output record for our pane
(defmethod run-frame-top-level :before ((frame test))
(with-slots (pane-list) frame
(let ((stream (get-frame-pane frame 'display-pane)))
(setf (pane-rec frame)
(updating-output (stream)
(do* ((elements (pane-list frame)(cdr elements))
(count 0 (1+ count))
(element (first elements)(first elements)))
((null elements))
(updating-output (stream :unique-id count
:cache-value element)
(format stream "Element ~D" element)
(terpri stream))))))))
;; the redisplay method for the pane
(defmethod draw-display ((frame test) stream)
(redisplay (pane-rec frame) stream))
;; define a command to add items to the list
(define-test-command (com-test :menu "test")
()
(with-slots (pane-list) *application-frame*
(setf pane-list (append pane-list (list (accept 'integer))))))
Here is a working version of the program. I made DISPLAY-PANE be a real
incremental redisplay pane, got rid of the :BEFORE method (since the
initial redisplay will happen before the first command is read), and got
rid of any explicit call to REDISPLAY (because the default CLIM command
loop will do that for incremental redisplay panes). I also got rid of
the PANE-REC slot from the frame; if it is important to be able to get
your hands on the redisplay output record for the pane, the following
idiom will work:
(let ((redisplay-record
(let ((history (output-recording-stream-output-record stream)))
(when history
;; There should be only one output record in a pane that
;; uses :INCREMENTAL-REDISPLAY T
(unless (zerop (output-record-element-count history))
(output-record-element history 0))))))
...)
--------
(define-application-frame test ()
((pane-list :initform (list 1 2 3 4 5)
:accessor pane-list))
(:panes ((display-pane :application
:incremental-redisplay t
:display-function 'draw-display
:scroll-bars :vertical
:end-of-page-action :scroll)
(interactor :interactor)
(menu :command-menu)))
(:layout ((normal (:column :rest
(display-pane .7)
(menu :compute)
(interactor :rest))))))
(defmethod draw-display ((frame test) stream)
(with-slots (pane-list) frame
(do* ((elements (pane-list frame)(cdr elements))
(count 0 (1+ count))
(element (first elements)(first elements)))
((null elements))
(updating-output (stream :unique-id count
:cache-value element)
(format stream "Element ~D" element)
(terpri stream)))))
(define-test-command (com-test :menu "test")
()
(with-slots (pane-list) *application-frame*
(setf pane-list (append pane-list (list (accept 'integer))))))
Follow-Ups:
Main Index |
Thread Index