26 var _CPColorWellDidBecomeExclusiveNotification =
@"_CPColorWellDidBecomeExclusiveNotification";
43 + (Class)_binderClassForBinding:(
CPString)aBinding
45 if (aBinding == CPValueBinding)
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
205 if (![
self isActive])
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])
255 [colorPanel setColor:_color];
256 [colorPanel orderFront:self];
259 - (CGRect)contentRectForBounds:(CGRect)bounds
261 var contentInset = [
self currentValueForThemeAttribute:@"content-inset"];
263 return CGRectInsetByInset(
bounds, contentInset);
266 - (CGRect)bezelRectForBounds:(CGRect)bounds
268 var bezelInset = [
self currentValueForThemeAttribute:@"bezel-inset"];
270 return CGRectInsetByInset(
bounds, bezelInset);
273 - (CGRect)contentBorderRectForBounds:(CGRect)bounds
275 var contentBorderInset = [
self currentValueForThemeAttribute:@"content-border-inset"];
277 return CGRectInsetByInset(
bounds, contentBorderInset);
280 - (CGRect)rectForEphemeralSubviewNamed:(
CPString)aName
288 case "content-border-view":
297 var view = [[
CPView alloc] initWithFrame:CGRectMakeZero()];
299 [view setHitTests:NO];
304 - (void)layoutSubviews
310 [bezelView setBackgroundColor:[
self currentValueForThemeAttribute:@"bezel-color"]];
317 [contentView setBackgroundColor:_color];
323 [contentBorderView setBackgroundColor:[
self currentValueForThemeAttribute:@"content-border-color"]];
328 #pragma mark Observers method 330 - (void)_addObservers
335 [
super _addObservers];
336 [
self _registerNotifications];
339 - (void)_removeObservers
344 [
super _removeObservers];
345 [
self _removeNotifications];
354 - (void)_updatePlaceholdersWithOptions:(
CPDictionary)options
358 [
self _setPlaceholder:placeholderColor forMarker:CPMultipleValuesMarker isDefault:YES];
359 [
self _setPlaceholder:placeholderColor forMarker:CPNoSelectionMarker isDefault:YES];
360 [
self _setPlaceholder:placeholderColor forMarker:CPNotApplicableMarker isDefault:YES];
361 [
self _setPlaceholder:placeholderColor forMarker:CPNullMarker isDefault:YES];
366 return [_source color];
369 - (void)setValue:(
id)aValue forBinding:(
CPString)theBinding
371 [_source setColor:aValue];
374 - (void)setPlaceholderValue:(
id)aValue withMarker:(
CPString)aMarker forBinding:(
CPString)aBinding
376 [_source setColor:aValue];
397 _color = [aCoder decodeObjectForKey:CPColorWellColorKey];
398 [
self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
412 [aCoder encodeObject:_color forKey:CPColorWellColorKey];
413 [aCoder encodeObject:[
self isBordered] forKey:CPColorWellBorderedKey];
BOOL setThemeState:(ThemeState aState)
CPColorPanel sharedColorPanel()
An object representation of nil.
CGRect contentRectForBounds:(CGRect bounds)
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.
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)
CPPlatformWindow platformWindow()
void encodeWithCoder:(CPCoder aCoder)
CPView layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:(CPString aViewName, [positioned] CPWindowOrderingMode anOrderingMode, [relativeToEphemeralSubviewNamed] CPString relativeToViewName)
CGRect rectForEphemeralSubviewNamed:(CPString aViewName)