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

Trouble with clipping



   From: Repenning Alexander <ralex@tigger.Colorado.EDU>
   Date: Tue, 15 Jan 91 12:53:27 MST
   X-Mailer: ELM [version 2.3 PL0]

   I'm trying to do some trivial clipping in a window. Although I set the
   clip region of the window using clip-rect no clipping occurs:

   (setq W (oneof *Window*))

   (ask W 
     (clip-rect 0 0 10 10)
     (move-to 1 1)
     (line 100 100)
     (move-to 2 20)
     (prin1 "bla bla bla" W))

   Neither the line not the text gets clipped. What's the point I'm 
   missing here? Does clipping only work for a  subset of graphic
   functions, or is there some means to change the window into a "clippable" 
   mode?

The high-level quickdraw functions which you are calling (move-to,
line) come with source code.  If you look at the source code, you'll
see that these functions each perform a VIEW-FOCUS operation.  Besides
being inefficient when used serially, the view-focus operation will
install the views clip-rect.

To get the effect you want, and achieve efficiency plus, you should
call the quickdraw traps directly, something like the following:
[with-rectangle-arg is defined in quickdraw.lisp, but not exported.]

(setq W (oneof *Window*))

(ask W
  (with-focused-view W                  ;focus once and for all
    (with-rectangle-arg (r 0 0 10 10)
      (_ClipRect :ptr r))
    (_MoveTo :word 1 :word 1)
    (_Line :word 100 :word 100)
    (_MoveTo :word 2 :word 20)
    (prin1 "bla bla bla" W)))

The Quickdraw.lisp sources provide very good examples for how to call
the quickdraw traps directly.  Indeed, this was the original purpose
of the file.

    -andrew