color wellっぽいcell

NSColorWellみたいなNSCellがほしいなーと探せどもみつからず。
で、つくってみた。
単に色を表示するだけです。

#import <Foundation/Foundation.h>


@interface NJColorCell : NSCell {
@private
    
}

@end
@implementation NJColorCell

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }
    
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
	NSRect outsideRect = CGRectInset(cellFrame, 1, 1);
	NSRect insideRect = CGRectInset(cellFrame, 5, 5);
	[NSBezierPath setDefaultLineWidth:1.0];
	[[NSColor darkGrayColor] setStroke];
	[[NSBezierPath bezierPathWithRect:outsideRect] stroke];
	NSGradient* aGradient = [[[NSGradient alloc]
							  initWithColorsAndLocations:
							  [NSColor colorWithCalibratedWhite:1.0 alpha:1.0], (CGFloat)0.0,
							  [NSColor colorWithCalibratedWhite:0.83 alpha:1.0], (CGFloat)0.2,
							  [NSColor colorWithCalibratedWhite:1.0 alpha:1.0], (CGFloat)1.0,
							  nil] autorelease];
	[aGradient drawInRect:outsideRect angle:90.0];
	[[NSColor grayColor] setStroke];
	[[self objectValue] setFill];
	[[NSBezierPath bezierPathWithRect:insideRect] stroke];
	[[NSBezierPath bezierPathWithRect:insideRect] fill];
	
}

@end

NSOutlineViewなんかでの、クリック時はdelegateメソッドの- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
で拾い、delegateクラスでNSColorPanel呼び出しもろもろをゴニョゴニョする方針。
だけどこれだとなんか反応が悪い。何使うのがベストなんでしょうかー?