NSGraphicsContext
NSGraphicsContext
- Subject: NSGraphicsContext
- From: email@hidden
- Date: Sat, 10 May 2003 20:28:02 -0400
How are the graphics contexts provided? Does each window supply one, or
each view? The reason I ask is that I think I am doing wasteful things:
This is what my view's drawRect method does:
- (void)drawRect:(NSRect)rect
{
if (!_viewGraphicsContext)
{
_viewGraphicsContext = [NSGraphicsContext currentContext];
_viewGraphicsContextRef = (CGContextRef)[_viewGraphicsContext
graphicsPort];
}
[_viewGraphicsContext saveGraphicsState];
//Make the scale proper
NSAffineTransform* scaleTransform = [NSAffineTransform transform];
[scaleTransform scaleBy: (_DEVICE_TO_SIMULATION_SCALE)];
[scaleTransform concat];
//do drawing
[_viewGraphicsContext restoreGraphicsState];
}
Each time, I set the scale, even if it has not changed. I would like to
simply set the scale once, but I don't have a clear idea of how this
would effect other drawing in other places in the window and so on. I'm
not sure what the graphics context _viewGraphicsContext points to,
meaning I don't know what else has access to it (other views?), so I am
reluctant to just change the state and leave it. In other words, what
is a good way to setup the state of my view and simply recall the state
each time? Could I create a copy of the context, set the state, and
then make it the current context each time? Thank you.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.