Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lockFocus error




On 21 Oct 2008, at 10:26 am, DKJ wrote:

Is this a good way of going about it? I subclassed NSView and defined the properties border_colour, fill_colour, and pic. These are initialised to nil. I then implemented drawRect: like this:


- (void)drawRect:(NSRect)rect { if( border_colour ) { [border_colour set]; [NSBezierPath strokeRect:[self bounds]]; } if( fill_colour ) { [fill_colour set]; [NSBezierPath fillRect:[self bounds]]; } if( pic ) [pic drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; }

Now the controller can change the content of the view by assigning values to the properties.


Looks fine.


But it still seems an awful lot has to be decided about the content of the view when the subclassing is done. Or am I missing something simple here?


No, you're not missing anything. An empty NSView draws nothing at all, so of course you have to supply all of the content in your subclass. What would you expect it to do?

--Graham
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >lockFocus error (From: DKJ <email@hidden>)
 >Re: lockFocus error (From: Nick Zitzmann <email@hidden>)
 >Re: lockFocus error (From: DKJ <email@hidden>)
 >Re: lockFocus error (From: Nick Zitzmann <email@hidden>)
 >Re: lockFocus error (From: DKJ <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.