26 var _CPColorWellDidBecomeExclusiveNotification =
@"_CPColorWellDidBecomeExclusiveNotification";
44 + (Class)_binderClassForBinding:(
CPString)theBinding
49 return [
super _binderClassForBinding:theBinding];
60 forKeys:[@"bezel-inset", @"bezel-color", @"content-inset", @"content-border-inset", @"content-border-color"]];
63 - (void)_reverseSetBinding
65 var binderClass = [[
self class] _binderClassForBinding:CPValueBinding],
66 theBinding = [binderClass getBinding:CPValueBinding forObject:self];
68 [theBinding reverseSetValueFor:@"color"];
71 - (id)initWithFrame:(CGRect)aFrame
81 [
self _registerForNotifications];
87 - (void)_registerForNotifications
93 selector:@selector(colorWellDidBecomeExclusive:)
94 name:_CPColorWellDidBecomeExclusiveNotification
99 selector:@selector(colorPanelWillClose:)
100 name:CPWindowWillCloseNotification
107 - (void)setBordered:(BOOL)shouldBeBordered
109 if (shouldBeBordered)
138 if (_color == aColor)
150 - (void)takeColorFrom:(
id)aSender
161 - (void)activate:(BOOL)shouldBeExclusive
163 if (shouldBeExclusive)
178 name:CPColorPanelColorDidChangeNotification
187 if (![
self isActive])
194 name:CPColorPanelColorDidChangeNotification
215 if (
self != [aNotification
object])
224 - (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
228 if (!mouseIsUp || !CGRectContainsPoint([
self bounds], aPoint) || ![
self isEnabled])
235 [colorPanel setColor:_color];
236 [colorPanel orderFront:self];
239 - (CGRect)contentRectForBounds:(CGRect)bounds
243 return _CGRectInsetByInset(bounds, contentInset);
246 - (CGRect)bezelRectForBounds:(CGRect)bounds
250 return _CGRectInsetByInset(bounds, bezelInset);
253 - (CGRect)contentBorderRectForBounds:(CGRect)bounds
257 return _CGRectInsetByInset(bounds, contentBorderInset);
260 - (CGRect)rectForEphemeralSubviewNamed:(
CPString)aName
268 case "content-border-view":
277 var view = [[
CPView alloc] initWithFrame:_CGRectMakeZero()];
279 [view setHitTests:NO];
284 - (void)layoutSubviews
297 [contentView setBackgroundColor:_color];
312 - (void)_updatePlaceholdersWithOptions:(
CPDictionary)options
316 [
self _setPlaceholder:placeholderColor forMarker:CPMultipleValuesMarker isDefault:YES];
317 [
self _setPlaceholder:placeholderColor forMarker:CPNoSelectionMarker isDefault:YES];
318 [
self _setPlaceholder:placeholderColor forMarker:CPNotApplicableMarker isDefault:YES];
319 [
self _setPlaceholder:placeholderColor forMarker:CPNullMarker isDefault:YES];
324 var destination = [_info objectForKey:CPObservedObjectKey],
325 keyPath = [_info objectForKey:CPObservedKeyPathKey],
326 options = [_info objectForKey:CPOptionsKey],
327 newValue = [destination valueForKeyPath:keyPath],
335 reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
338 newValue = [
self _placeholderForMarker:newValue];
345 [_source setColor:newValue];
366 _color = [aCoder decodeObjectForKey:CPColorWellColorKey];
367 [
self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
369 [
self _registerForNotifications];
383 [aCoder encodeObject:_color forKey:CPColorWellColorKey];
384 [aCoder encodeObject:[
self isBordered] forKey:CPColorWellBorderedKey];