Don't link with Carbon.framework.
[MacTF.git] / iLifeControls / NFIPopUpButtonCell.m
blobdffae11a3004c1078d3527dd3bf013ead3b4eedf
1 //
2 //  NFIPopUpButtonCell.m
3 //  iLife PopUp Button
4 //
5 //  Created by Sean Patrick O'Brien on 9/25/06.
6 //  Copyright 2006 Sean Patrick O'Brien. All rights reserved.
7 //
9 #import "NFIPopUpButtonCell.h"
10 #import "NSImage+FrameworkImage.h"
12 @implementation NFIPopUpButtonCell
14 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
16         NSString *state = [self isEnabled] ? ([self isHighlighted] ? @"P" : @"N") : @"D";
17         NSImage *leftImage = [NSImage frameworkImageNamed:[NSString stringWithFormat:@"PopUpLeft%@.tiff", state]];
18         NSImage *fillImage = [NSImage frameworkImageNamed:[NSString stringWithFormat:@"PopUpFill%@", state]];
19         NSImage *rightImage = [NSImage frameworkImageNamed:[NSString stringWithFormat:@"PopUpRight%@", state]];
20                                 
21         NSSize size = [leftImage size];
22         float addX = size.width / 2.0;
23         float y = NSMaxY(cellFrame) - (cellFrame.size.height-size.height)/2.0;
24         float x = cellFrame.origin.x+addX;
25         float fillX = x + size.width;
26         float fillWidth = cellFrame.size.width - size.width - addX;
27         
28         [leftImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
30         size = [rightImage size];
31         addX = size.width / 2.0;
32         x = NSMaxX(cellFrame) - size.width - addX;
33         fillWidth -= size.width+addX;
34         
35         [rightImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
36         
37         [fillImage setScalesWhenResized:YES];
38         [fillImage setSize:NSMakeSize(fillWidth, [fillImage size].height)];
39         [fillImage compositeToPoint:NSMakePoint(fillX, y) operation:NSCompositeSourceOver];
40         
41         [self drawInteriorWithFrame:cellFrame inView:controlView];
44 @end