• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: lockFocus error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lockFocus error


  • Subject: Re: lockFocus error
  • From: DKJ <email@hidden>
  • Date: Mon, 20 Oct 2008 16:26:18 -0700

On 20 Oct, 2008, at 09:15, Nick Zitzmann wrote:
you do all your drawing in -drawRect:, and call -setNeedsDisplay: & friends when you need to refresh part of the view.

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.

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?
_______________________________________________


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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: lockFocus error
      • From: Graham Cox <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>)

  • Prev by Date: Re: Return and Enter don't "behave" in Text Field (Newb)
  • Next by Date: Re: lockFocus error
  • Previous by thread: Re: lockFocus error
  • Next by thread: Re: lockFocus error
  • Index(es):
    • Date
    • Thread