• 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: Matt Ball <email@hidden>
  • Date: Sat, 16 Jul 2005 17:35:47 -0400

Also, I should add that it does this to every button in my custom view
(I have a close button also, although that isn't a subclass), not just
my custom button.

- Matt Ball

On 7/16/05, Matt Ball <email@hidden> wrote:
> Well, here's some code:
>
> MBDashboardView.m
>
> - (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];
> }
>
> - (NSBezierPath*)bezierPathWithRoundTitlebarRectInRect:(NSRect)aRect
> radius:(float)radius
> {
>         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 appendBezierPathWithRect:NSMakeRect(NSMinX(aRect),
> NSMinY(aRect) + 6, aRect.size.width, 13)];
>
>         [path closePath];
>         return path;
> }
>
> - (NSBezierPath*)bezierPathWithRoundContentRectInRect:(NSRect)aRect
> radius:(float)radius
> {
>        NSBezierPath* path = [[NSBezierPath alloc] init];
>         NSRect rect = NSInsetRect(aRect, radius, radius);
>         [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 appendBezierPathWithRect:NSMakeRect(NSMinX(aRect),
> NSMinY(aRect) + 19, aRect.size.width, NSMaxY(aRect) - radius - 19)];
>
>         [path closePath];
>         return path;
> }
>
> MBDashboardButtonCell.m
>
> - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
> {
>         NSImage *leftImage;
>         NSImage *middleImage;
>         NSImage *rightImage;
>         if(![self isHighlighted]) {
>                 leftImage = [NSImage imageNamed:@"dashboardButton-left-normal"];
>                 middleImage = [NSImage
> imageNamed:@"dashboardButton-center-normal"];
>                 rightImage = [NSImage
> imageNamed:@"dashboardButton-right-normal"];
>         }
>         else {
>                 leftImage = [NSImage
> imageNamed:@"dashboardButton-left-pressed"];
>                 middleImage = [NSImage
> imageNamed:@"dashboardButton-center-pressed"];
>                 rightImage = [NSImage
> imageNamed:@"dashboardButton-right-pressed"];
>         }
>         [leftImage compositeToPoint:NSZeroPoint
> operation:NSCompositeSourceOver fraction:1.0];
>         [middleImage drawInRect:NSMakeRect([leftImage size].width, 0,
> cellFrame.size.width - [leftImage size].width - [rightImage
> size].width, [middleImage size].height)
> fromRect:NSMakeRect(0,0,[middleImage size].width, [middleImage
> size].height) operation:NSCompositeSourceOver fraction:1.0];
>
>         [rightImage compositeToPoint:NSMakePoint(cellFrame.size.width -
> [rightImage size].width, 0) operation:NSCompositeSourceOver
> fraction:1.0];
> }
>
> - Matt Ball
>
> On 7/16/05, Andreas Mayer <email@hidden> wrote:
> >
> > Am 16.07.2005 um 22:27 Uhr schrieb Matt Ball:
> >
> > > I have an NSWindow subclass with a custom NSView in it that draws the
> > > required BezierPaths.
> >
> > What bezier paths would that be?
> >
> > > Inside that view, I have my button. Somehow, the
> > > button is drawing the entire view as its background.
> >
> > Sorry, no idea what the reason might be.
> >
> > I'm doing something similar (I think) with no problems:
> >
> > http://www.harmless.de/images/adjust-window.png
> >
> >
> > 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
> >
>
 _______________________________________________
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: Re: Transparency in NSButtonCell
  • Previous by thread: Re: Transparency in NSButtonCell
  • Next by thread: Re: Transparency in NSButtonCell
  • Index(es):
    • Date
    • Thread