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

Q: most efficient way to get port?

I was trying to find the most efficient way to access the visRgn of the
current GraphPort.  It this the best choice?  (Assume that the port is
already set.)

  (let ((grafptr (#_NewPtr 4)))
    (#_GetPort grafptr)

    (let ((visrgn (pref (%get-ptr grafptr 0) :grafport.visrgn)))
        ;; Do something with visrgn here...

    (#_DisposePtr grafptr)))

Is there a way to do this with rlet?

I suppose if I had a view I could just use (wptr view), but I wanted
something that would always work to get the current port.

I wanted this code because at update time, the visrgn should reflect the
exact area of the screen that a view needs to update.

In general I'm having a little trouble understanding when you can use rlet
and (rref, href, or pref) and when you have to drop down to %get-xxx.  Also
I haven't completely understood how you know when rlet will allocate a
handle or a pointer, and when you need to manually dereference these (with
%get-xxx) for a traps' arguments.