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

CLIM Question



Could someone please give me a hint. The following code does not work
as I expected. I wanted to draw a graph whose nodes are
strings. A node is to be redrawn only when the label (string) changes.
I used CLIM 1.1.


(in-package :clim-user)

(defun graph-test (&optional (stream *standard-output*))
  (macrolet ((make-node (&key name children)
               `(list* ,name ,children))
             (node-name (node)
               `(car ,node))
             (node-children (node)
               `(cdr ,node)))
    (let* ((2a (make-node :name "2A"))
           (2b (make-node :name "2B"))
           (2c (make-node :name "2C"))
           (1a (make-node :name "1A" :children (list 2a 2b)))
           (1b (make-node :name "1B" :children (list 2b 2c)))
           (root (make-node :name "0" :children (list 1a 1b)))
           (graph
             (updating-output (stream :unique-id root)
               (format-graph-from-roots
                (list root)
                #'(lambda (node s)
                    (updating-output (s :cache-value (node-name node)
                                        :cache-test #'string-equal)
                      (write-string (node-name node) s)))
                #'cdr   ;--- #'node-children
                :stream stream))))
      (sleep 2)
      (setf (node-name 1a) "xx")
      (redisplay graph stream)
      (sleep 2)
      (setf (node-name 1b) "yy")
      (redisplay graph stream))))

The effect is that that the first redisplay erroneously erases all the
nodes in the second layer and redisplays only the xx-node. Afterwards
the xx-node is erased an the yy-node is shown.

Is this a CLIM error or is it my misunderstanding of the updating-output
facility?

The following version uses surrounding-output-with-border. 
Weird effects also.

(in-package :clim-user)

(defun graph-test (&optional (stream *standard-output*))
  (macrolet ((make-node (&key name children)
               `(list* ,name ,children))
             (node-name (node)
               `(car ,node))
             (node-children (node)
               `(cdr ,node)))
    (let* ((2a (make-node :name "2A"))
           (2b (make-node :name "2B"))
           (2c (make-node :name "2C"))
           (1a (make-node :name "1A" :children (list 2a 2b)))
           (1b (make-node :name "1B" :children (list 2b 2c)))
           (root (make-node :name "0" :children (list 1a 1b)))
           (graph
             (updating-output (stream :unique-id root)
               (format-graph-from-roots
                (list root)
                #'(lambda (node s)
                    (updating-output (s :cache-value (node-name node)
                                        :cache-test #'string-equal)
                      (surrounding-output-with-border (s)
                         (write-string (node-name node) s))))
                #'cdr   ;--- #'node-children
                :stream stream))))
      (sleep 2)
      (setf (node-name 1a) "xx")
      (redisplay graph stream)
      (sleep 2)
      (setf (node-name 1b) "yy")
      (redisplay graph stream))))


Ralf

PS: I used the Clim Listener from the Demo directory if that matters.