NSRectClip

Discussion in 'Mac Programming' started by MrFusion, Feb 28, 2007.

  1. macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #1
    Hey,

    There is not much info that I can find about NSRectClip.
    I have a NSRect given to me by
    Code:
    - (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?
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    The documentation does appear to be sparse. Have you tried saving the Graphics Context state and restoring it.

    So something like:

    Code:
    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!
     
  3. thread starter macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #3
    Thanks, that works.
     

Share This Page