26 var _CPColorWellDidBecomeExclusiveNotification =
@"_CPColorWellDidBecomeExclusiveNotification";
43 + (Class)_binderClassForBinding:(
CPString)aBinding
48 return [
super _binderClassForBinding:aBinding];
59 @"bezel-inset": CGInsetMakeZero(),
61 @"content-inset": CGInsetMake(3.0, 3.0, 3.0, 3.0),
62 @"content-border-inset": CGInsetMakeZero(),
67 - (void)_reverseSetBinding
69 var binderClass = [[
self class] _binderClassForBinding:CPValueBinding],
70 theBinding = [binderClass getBinding:CPValueBinding forObject:self];
72 [theBinding reverseSetValueFor:@"color"];
75 - (id)initWithFrame:(CGRect)aFrame
89 - (void)_registerNotifications
95 selector:@selector(colorWellDidBecomeExclusive:)
96 name:_CPColorWellDidBecomeExclusiveNotification
101 selector:@selector(colorPanelWillClose:)
102 name:CPWindowWillCloseNotification
106 - (void)_removeNotifications
112 name:_CPColorWellDidBecomeExclusiveNotification
117 name:CPWindowWillCloseNotification
125 - (void)setBordered:(BOOL)shouldBeBordered
127 if (shouldBeBordered)
138 return [
self hasThemeState:CPThemeStateBordered];
156 if (_color == aColor)
168 - (void)takeColorFrom:(
id)aSender
179 - (void)activate:(BOOL)shouldBeExclusive
181 if (shouldBeExclusive)
196 name:CPColorPanelColorDidChangeNotification
212 name:CPColorPanelColorDidChangeNotification
233 if (
self != [aNotification
object])
242 - (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
246 if (!mouseIsUp || !CGRectContainsPoint([
self bounds], aPoint) || ![
self isEnabled])
253 [colorPanel setColor:_color];
254 [colorPanel orderFront:self];
257 - (CGRect)contentRectForBounds:(CGRect)bounds
259 var contentInset = [
self currentValueForThemeAttribute:@"content-inset"];
261 return CGRectInsetByInset(
bounds, contentInset);
264 - (CGRect)bezelRectForBounds:(CGRect)bounds
266 var bezelInset = [
self currentValueForThemeAttribute:@"bezel-inset"];
268 return CGRectInsetByInset(
bounds, bezelInset);
271 - (CGRect)contentBorderRectForBounds:(CGRect)bounds
273 var contentBorderInset = [
self currentValueForThemeAttribute:@"content-border-inset"];
275 return CGRectInsetByInset(
bounds, contentBorderInset);
278 - (CGRect)rectForEphemeralSubviewNamed:(
CPString)aName
286 case "content-border-view":
295 var view = [[
CPView alloc] initWithFrame:CGRectMakeZero()];
297 [view setHitTests:NO];
308 [bezelView setBackgroundColor:[
self currentValueForThemeAttribute:@"bezel-color"]];
315 [contentView setBackgroundColor:_color];
321 [contentBorderView setBackgroundColor:[
self currentValueForThemeAttribute:@"content-border-color"]];
326 #pragma mark Observers method 328 - (void)_addObservers
333 [
super _addObservers];
334 [
self _registerNotifications];
337 - (void)_removeObservers
342 [
super _removeObservers];
343 [
self _removeNotifications];
352 - (void)_updatePlaceholdersWithOptions:(
CPDictionary)options
356 [
self _setPlaceholder:placeholderColor forMarker:CPMultipleValuesMarker isDefault:YES];
357 [
self _setPlaceholder:placeholderColor forMarker:CPNoSelectionMarker isDefault:YES];
358 [
self _setPlaceholder:placeholderColor forMarker:CPNotApplicableMarker isDefault:YES];
359 [
self _setPlaceholder:placeholderColor forMarker:CPNullMarker isDefault:YES];
364 return [_source color];
367 - (void)setValue:(
id)aValue forBinding:(
CPString)theBinding
369 [_source setColor:aValue];
372 - (void)setPlaceholderValue:(
id)aValue withMarker:(
CPString)aMarker forBinding:(
CPString)aBinding
374 [_source setColor:aValue];
395 _color = [aCoder decodeObjectForKey:CPColorWellColorKey];
396 [
self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
410 [aCoder encodeObject:_color forKey:CPColorWellColorKey];
411 [aCoder encodeObject:[
self isBordered] forKey:CPColorWellBorderedKey];
BOOL setThemeState:(ThemeState aState)
CPColorPanel sharedColorPanel()
An object representation of nil.
CGRect contentRectForBounds:(CGRect bounds)
CPString defaultThemeClass()
void setColor:(CPColor aColor)
void setBordered:(BOOL shouldBeBordered)
void addObserver:selector:name:object:(id anObserver, [selector] SEL aSelector, [name] CPString aNotificationName, [object] id anObject)
id initWithFrame:(CGRect aFrame)
void postNotificationName:object:(CPString aNotificationName, [object] id anObject)
CGRect bezelRectForBounds:(CGRect bounds)
CGRect contentBorderRectForBounds:(CGRect bounds)
CPNotificationCenter defaultCenter()
A mutable key-value pair collection.
void takeColorFrom:(id aSender)
An immutable string (collection of characters).
BOOL sendAction:to:(SEL anAction, [to] id anObject)
var CPColorWellBorderedKey
id initWithCoder:(CPCoder aCoder)
void activate:(BOOL shouldBeExclusive)
A notification that can be posted to a CPNotificationCenter.
CPDictionary themeAttributes()
void highlight:(BOOL shouldHighlight)
Defines methods for use when archiving & restoring (enc/decoding).
BOOL unsetThemeState:(ThemeState aState)
Sends messages (CPNotification) between objects.
void removeObserver:name:object:(id anObserver, [name] CPString aNotificationName, [object] id anObject)
void encodeWithCoder:(CPCoder aCoder)
CPView layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:(CPString aViewName, [positioned] CPWindowOrderingMode anOrderingMode, [relativeToEphemeralSubviewNamed] CPString relativeToViewName)
CGRect rectForEphemeralSubviewNamed:(CPString aViewName)