PDA

View Full Version : NSRectClip




MrFusion
Feb 28, 2007, 03:00 AM
Hey,

There is not much info that I can find about NSRectClip.
I have a NSRect given to me by

- (void)drawRect:(NSRect)rect

In this rect, I determine my own NSRect to draw in, which works fine. But after this I want to make extra drawings in the larger "rect". So I am looking for an undo for NSRectClip, or some way to set the drawingarea back to its original area.

Is this possible?



robbieduncan
Feb 28, 2007, 04:01 AM
The documentation does appear to be sparse. Have you tried saving the Graphics Context state and restoring it.

So something like:


NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context saveGraphicsState];

// Do your NSRectClip and drawing....

[context restoreGraphicsState];

// Do more drawing


Note I'm on a PC at work so can't test this...


Edit to add: that should work. It is actually in the conceptual documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/GraphicsContexts/chapter_3_section_3.html#//apple_ref/doc/uid/TP40003290-CH203-BCIIADBC)!

MrFusion
Feb 28, 2007, 05:32 AM
The documentation does appear to be sparse. Have you tried saving the Graphics Context state and restoring it.

So something like:


NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context saveGraphicsState];

// Do your NSRectClip and drawing....

[context restoreGraphicsState];

// Do more drawing


Note I'm on a PC at work so can't test this...


Edit to add: that should work. It is actually in the conceptual documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/GraphicsContexts/chapter_3_section_3.html#//apple_ref/doc/uid/TP40003290-CH203-BCIIADBC)!

Thanks, that works.