• 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: Transparency in NSButtonCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transparency in NSButtonCell


  • Subject: Re: Transparency in NSButtonCell
  • From: Andreas Mayer <email@hidden>
  • Date: Sun, 17 Jul 2005 00:20:34 +0200


Am 16.07.2005 um 23:33 Uhr schrieb Matt Ball:

- (void)drawRect:(NSRect)rect {
        [[NSColor colorWithCalibratedWhite:0.2 alpha:0.7] set];
        NSBezierPath *titlebarRect = [self
bezierPathWithRoundTitlebarRectInRect:rect radius:6.0];
        [titlebarRect fill];
        [titlebarRect release];
        [[NSColor colorWithCalibratedWhite:0.05 alpha:0.7] set];
        NSBezierPath *contentRect = [self
bezierPathWithRoundContentRectInRect:rect radius:6.0];
        [contentRect fill];
        [contentRect release];
}

This is your problem: rect is just the rectangle that is to be redrawn. It's not, in general, the bounding rectangle for the view. So you are drawing your rounded rectangle in whatever space is to be redrawn at the moment.



You could do something like this instead:

- (void)drawRect:(NSRect)rect
{
if (![self path]) {
[self setPath:[self bezierPathWithRoundContentRectInRect: [self bounds] radius:6.0]];
[self setColor:[NSColor colorWithCalibratedWhite:0.05 alpha: 0.7]];
}
[[self color] set];
[[self path] fill];
}


And the title bar I'd add as a separate control.


Also, while this has nothing to do with your problem, convenience methods should always return autoreleased objects.


See http://developer.apple.com/documentation/Cocoa/Conceptual/ MemoryMgmt/Concepts/ObjectOwnership.html

So in ...

- (NSBezierPath*)bezierPathWithRoundTitlebarRectInRect:(NSRect)aRect
radius:(float)radius
{
        NSBezierPath* path = [[NSBezierPath alloc] init];
[...]
        return path;
}

... replace the last line with

return [path autorelease];


Andreas _______________________________________________ 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
  • Follow-Ups:
    • Re: Transparency in NSButtonCell
      • From: Matt Ball <email@hidden>
References: 
 >Transparency in NSButtonCell (From: Matt Ball <email@hidden>)
 >Re: Transparency in NSButtonCell (From: glenn andreas <email@hidden>)
 >Re: Transparency in NSButtonCell (From: Matt Ball <email@hidden>)
 >Re: Transparency in NSButtonCell (From: Matt Ball <email@hidden>)
 >Re: Transparency in NSButtonCell (From: Andreas Mayer <email@hidden>)
 >Re: Transparency in NSButtonCell (From: Matt Ball <email@hidden>)
 >Re: Transparency in NSButtonCell (From: Andreas Mayer <email@hidden>)
 >Re: Transparency in NSButtonCell (From: Matt Ball <email@hidden>)

  • Prev by Date: Re: Transparency in NSButtonCell
  • Next by Date: how to be aware of clicking on dock icon
  • Previous by thread: Re: Transparency in NSButtonCell
  • Next by thread: Re: Transparency in NSButtonCell
  • Index(es):
    • Date
    • Thread