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

Re: Q: Why does print change another window's origin?

On Thu, 7 Jul 1994 Rob Browning writes:
> I have a routine that focuses on *current-view* (which is at the time bound
> to a print window), calls #_SetOrigin to offset all the drawing, and then
> draws some things with the usual traps (#_LineTo etc.).

> If I place any print calls (usually for debugging purposes), like (print
> "Hello") after the call to #_SetOrigin, but before the drawing calls, the
> origin is reset to the normal (0 0) position.

> 1) Why is that?
The problem is not caused by the debugging outputTo change the view origin,
it is the result of using the setorigin trap rather than setting
the view origin slot for the view. 
Use (setf (slot-value window 'ccl::view-origin point))
rather than (with-focused-view window (#_setOrigin :long point))

Alternatively you can use the quickdraw library routine
(set-origin window  h &optional v)
or the underlying routine
(set-view-scroll-position view h v nil))

2) Is there an easy way to send debugging output to the listener without
affecting *current-view*?  (Would without-interrupts and evel-enqueue be a
good approach?)

Yes, when you use setf, the debugging output has no effect.

The code at the end of this message demonstrates the problem.


(defclass test-win (window) nil)
(defparameter *win* (make-instance 'test-win))
(defparameter *debug* t)

(defmethod view-draw-contents ((window test-win))
  (let (origin)
    (with-focused-view window
      (with-port (wptr window)
        (#_moveTo :long #@(0 0))
        (setq origin (view-origin window))
        (when *debug* (print (point-string (view-origin window))))
        (#_lineTo :long #@(150 150)))

;; show the default view origin
(with-focused-view *win* 
  (print-db (point-string (slot-value *win* 'ccl::view-origin))))
"#@(0 0)"

;; use setf to change the view origin to #@(100 100)
(with-focused-view *win* 
  (setf (slot-value *win* 'ccl::view-origin) #@(100 100))
  (print-db (point-string (slot-value *win* 'ccl::view-origin))))
"#@(100 100)"
;; now try to use set-origin to change it to #@(50 50)
(with-focused-view *win* 
  (with-port (wptr *win*)
    (#_setOrigin :long #@(50 50))
    (print-db (point-string (slot-value *win* 'ccl::view-origin)))))
"#@(100 100)"

;; the origin remains unchanged!