Getting info from outside drawRect
Getting info from outside drawRect
- Subject: Getting info from outside drawRect
- From: Chad Armstrong <email@hidden>
- Date: Wed, 20 Mar 2002 01:06:41 -0700
I'm trying to draw some items (mostly lines) in a customized subclass
NSView. However, when I try and use data members which are in the class
with the drawRect function, the items won't draw. For the app I'm
trying to design, I will want to import several pieces of information,
such as the location of points and an array of NSPoint information.
What modifications do I need to make so things will draw correctly? I
have two classes, one for the Controller and another for the View.
Here is my example drawRect code. This draws correctly, but if I have
my own defined 'bounds' variable, delcared in the MyView.h file.
- (void)drawRect:(NSRect)rect
{
NSRect myBounds = [self bounds];
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
[[NSColor whiteColor] set];
[NSBezierPath fillRect:myBounds];
// Draw x and y axes
[[NSColor lightGrayColor] set];
[NSBezierPath strokeLineFromPoint: NSMakePoint(0,
(myBounds.size.height/2.0)) toPoint:NSMakePoint(myBounds.size.width,
(myBounds.size.height/2.0))];
[NSBezierPath strokeLineFromPoint:
NSMakePoint((myBounds.size.width/2.0), 0)
toPoint:NSMakePoint((myBounds.size.width/2.0), myBounds.size.height)];
[self drawLine];
// Draw border around the view
[[NSColor blackColor] set];
[NSBezierPath strokeRect:myBounds];
}
Any ideas?
Chad Armstrong
email@hidden
_______________________________________________
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.