• 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: Borderless NSWindow contentView problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Borderless NSWindow contentView problem


  • Subject: Re: Borderless NSWindow contentView problem
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 9 Nov 2005 09:57:29 +0100

Am 09.11.2005 um 01:49 schrieb Matt Ball:
- (void)drawRoundRectWithFrame:(NSRect)rect {
	[self lockFocus];
	[[NSColor blueColor] set];
	NSBezierPath *borderRect = [self bezierPathWithRoundRectInRect:rect
radius:6.0 top:YES bottom:YES];
	[borderRect fill];
	[self unlockFocus];
}

That lockFocus/unlockFocus isn't needed. When drawRect is called, your view already has focus. I'm not sure whether it actually hurts, but it definitely doesn't help. Better throw it out. Less code to maintain that way.


- (void)drawRect:(NSRect)rect {
	if(rect.size.width == [self frame].size.width && rect.size.height ==
[self frame].size.height) {
		[self drawRoundRectWithFrame:[self bounds]];
	}
}

Why are you comparing the rect here? That means that, any time you get an update that doesn't draw your entire window, it draws nothing. So, if the OS would just happen to send you three separate drawRect calls (e.g. because your window is spanning multiple screens, or maybe due to some graphics card optimization), you could possibly get nothing at all. Just get rid of the "if".


- (NSBezierPath*)bezierPathWithRoundRectInRect:(NSRect)aRect
radius:(float)radius top:(BOOL)topIsRound bottom:(BOOL)bottomIsRound
{
	NSBezierPath* path = [[NSBezierPath alloc] init];
	NSRect rect = NSInsetRect(aRect, radius, radius);
	[path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(rect),
NSMinY(rect)) radius:radius startAngle:180.0 endAngle:270.0];
	[path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(rect),
NSMinY(rect)) radius:radius startAngle:270.0 endAngle:360.0];
	[path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(rect),
NSMaxY(rect)) radius:radius startAngle:  0.0 endAngle: 90.0];
	[path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(rect),
NSMaxY(rect)) radius:radius startAngle: 90.0 endAngle:180.0];

	[path closePath];
	return [path autorelease];
}

I suppose you've actually tested whether this roundrect-drawing code works? If the above tips don't help, you may want to test whether it works when you just draw a rect instead.


Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Borderless NSWindow contentView problem (From: Matt Ball <email@hidden>)

  • Prev by Date: Re: Reviews of "Advanced Mac OS X Programming"
  • Next by Date: Re: Questiong on NSString sizeWithAttributes
  • Previous by thread: Re: Borderless NSWindow contentView problem
  • Next by thread: NSNumberFormatter forbidding non-digits?
  • Index(es):
    • Date
    • Thread