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

Re: clipping



dkozak@cray.com (Darryn Kozak) writes:

  I am running MCL 2.0 final.  I can't get clipping regions to work.
  For instance, if I do the following...
 
  (let ((bob (make-instance 'window)))
    (frame-rect bob 20 20 50 50)
    (clip-rect bob 20 20 50 50)
    (move-to bob 20 30)
    (line-to bob 30 100)
    (move-to bob 20 30)
    (format bob "This string should not end with a period."))
 
  ...I would expect both the line and the string to get clipped, but
  they don't.

The clip-rect call does not seem to have any effect, the clip region
remains:
  #<Record :REGION :RGNSIZE 10
	   :RGNBBOX #<Record :RECT :TOP 0 :LEFT 0 :BOTTOM 150 :RIGHT 502>>

The quickdraw calls are clipped correctly in the following code:
(let ((bob (make-instance 'window)))
  (rlet ((r :rect :topLeft #@(20 20) :bottomRight #@(50 50)))
    (with-focused-view bob
      (with-clip-rect r
        (frame-rect bob 20 20 50 50)
        (move-to bob 20 30)
        (line-to bob 30 100)
        (move-to bob 20 30)
        (format bob "This string should not end with a period.")))))

However, since format is not a quickdraw call, the string is not clipped.
The following code corrects both problems:
(let ((bob (make-instance 'window))
      (text "This string should not end with a period."))
  (rlet ((r :rect :topLeft #@(20 20) :bottomRight #@(50 50)))
    (with-focused-view bob
      (with-clip-rect r
        (frame-rect bob 20 20 50 50)
        (move-to bob 20 30)
        (line-to bob 30 100)
        (move-to bob 20 30)
        (with-returned-pstrs ((text-buff text))
          (#_DrawText :ptr text-buff :integer 1 :integer (length text)))))))