2 // NFIPopUpButtonCell.m
5 // Created by Sean Patrick O'Brien on 9/25/06.
6 // Copyright 2006 Sean Patrick O'Brien. All rights reserved.
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]];
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;
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;
35 [rightImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
37 [fillImage setScalesWhenResized:YES];
38 [fillImage setSize:NSMakeSize(fillWidth, [fillImage size].height)];
39 [fillImage compositeToPoint:NSMakePoint(fillX, y) operation:NSCompositeSourceOver];
41 [self drawInteriorWithFrame:cellFrame inView:controlView];