Merge branch 'refs/heads/master' into NEW--CPTextView

This commit is contained in:
Andrew Hankinson
2014-10-30 14:35:47 -04:00
120 changed files with 10488 additions and 9264 deletions
+1
View File
@@ -5,6 +5,7 @@ Demos
./Aristo
WebSite
.push-package
*.xcodeproj*
*.xcodeproj/*.pbxuser
*.xcodeproj/*.perspectivev3
xcuserdata/
+2 -2
View File
@@ -448,7 +448,7 @@ var CPMainCibFile = @"CPMainCibFile",
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
_isActive = YES;
[self _willResignActive];
[self _didBecomeActive];
}
- (void)deactivate
@@ -1173,7 +1173,7 @@ var CPMainCibFile = @"CPMainCibFile",
[[self keyWindow] orderFront:self];
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
else if ([self mainMenu])
[[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
+16 -5
View File
@@ -108,7 +108,6 @@ CPButtonImageOffset = 3.0;
// NS-style Display Properties
CPBezelStyle _bezelStyle;
CPControlSize _controlSize;
CPString _keyEquivalent;
unsigned _keyEquivalentModifierMask;
@@ -189,8 +188,6 @@ CPButtonImageOffset = 3.0;
- (void)_init
{
_controlSize = CPRegularControlSize;
_keyEquivalent = @"";
_keyEquivalentModifierMask = 0;
@@ -201,6 +198,20 @@ CPButtonImageOffset = 3.0;
[self setButtonType:CPMomentaryPushInButton];
}
#pragma mark -
#pragma mark Control Size
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
if ([self isBordered])
[self _sizeToControlSize];
}
#pragma mark -
// Setting the state
/*!
Returns a Boolean value indicating whether the button allows a mixed state.
@@ -654,10 +665,10 @@ CPButtonImageOffset = 3.0;
*/
- (void)sizeToFit
{
[self layoutSubviews];
[self setFrameSize:[self _minimumFrameSize]];
[self layoutSubviews];
if ([self ephemeralSubviewNamed:@"content-view"])
[self layoutSubviews];
}
+27 -4
View File
@@ -26,7 +26,10 @@
@class CPSplitView
@global CPPopUpButtonStatePullsDown
@global CPKeyValueChangeOldKey
@global CPKeyValueChangeNewKey
@global CPKeyValueObservingOptionNew
@global CPKeyValueObservingOptionOld
@implementation CPButtonBar : CPView
{
@@ -129,10 +132,16 @@
- (void)setButtons:(CPArray)buttons
{
for (var i = [_buttons count] - 1; i >= 0; i--)
[_buttons[i] removeObserver:self forKeyPath:@"hidden"];
_buttons = [CPArray arrayWithArray:buttons];
for (var i = 0, count = [_buttons count]; i < count; i++)
for (var i = [_buttons count] - 1; i >= 0; i--)
{
[_buttons[i] addObserver:self forKeyPath:@"hidden" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:nil];
[_buttons[i] setBordered:YES];
}
[self setNeedsLayout];
}
@@ -218,8 +227,14 @@
count = [buttonsNotHidden count];
while (count--)
if ([buttonsNotHidden[count] isHidden])
[buttonsNotHidden removeObject:buttonsNotHidden[count]];
{
var button = buttonsNotHidden[count];
[button removeFromSuperview];
if ([button isHidden])
[buttonsNotHidden removeObject:button];
}
var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1,
bounds = [self bounds],
@@ -274,6 +289,14 @@
}
}
- (void)observeValueForKeyPath:(CPString)keyPath ofObject:(id)object change:(CPDictionary)change context:(id)context
{
if ([change objectForKey:CPKeyValueChangeOldKey] == [change objectForKey:CPKeyValueChangeNewKey])
return;
[self setNeedsLayout];
}
- (void)setFrameSize:(CGSize)aSize
{
[super setFrameSize:aSize];
+38 -12
View File
@@ -47,18 +47,7 @@
if (_documentView)
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:CPViewFrameDidChangeNotification
object:_documentView];
[defaultCenter
removeObserver:self
name:CPViewBoundsDidChangeNotification
object:_documentView];
[self _removeObserverDocumentView:_documentView];
[_documentView removeFromSuperview];
}
@@ -91,6 +80,43 @@
object:_documentView];
}
- (void)_removeObserverDocumentView:(CPView)aDocumentView
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:CPViewFrameDidChangeNotification
object:_documentView];
[defaultCenter
removeObserver:self
name:CPViewBoundsDidChangeNotification
object:_documentView];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
if (_documentView)
[self _observeDocumentView];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
if (_documentView)
[self _removeObserverDocumentView:_documentView];
}
/*!
Returns the document view.
*/
+3 -29
View File
@@ -40,9 +40,8 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_ = 1 << 4,
CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_ = 1 << 5,
CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_ = 1 << 6,
CPCollectionViewDelegate_collectionViewDidChangeSelection_ = 1 << 7,
CPCollectionViewDelegate_collectionView_menuForItemAtIndex_ = 1 << 8,
CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset = 1 << 9;
CPCollectionViewDelegate_collectionView_menuForItemAtIndex_ = 1 << 7,
CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset = 1 << 8;
@protocol CPCollectionViewDelegate <CPObject>
@@ -57,7 +56,6 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
- (CPMenu)collectionView:(CPCollectionView)collectionView menuForItemAtIndex:(CPInteger)anIndex;
- (CPView)collectionView:(CPCollectionView)collectionView dragginViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
- (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
- (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
@end
@@ -71,10 +69,6 @@ var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_
@par Delegate Methods
@delegate - (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
DEPRECATED: Please do not use.
@param collectionView the collection view who's selection changed
@delegate - (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
Called when the user double-clicks on an item in the collection view.
@param collectionView the collection view that received the double-click
@@ -236,9 +230,6 @@ var HORIZONTAL_MARGIN = 2;
if ([_delegate respondsToSelector:@selector(collectionView:didDoubleClickOnItemAtIndex:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_;
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionViewDidChangeSelection_;
if ([_delegate respondsToSelector:@selector(collectionView:menuForItemAtIndex:)])
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_menuForItemAtIndex_;
@@ -473,12 +464,6 @@ var HORIZONTAL_MARGIN = 2;
var binderClass = [[self class] _binderClassForBinding:@"selectionIndexes"];
[[binderClass getBinding:@"selectionIndexes" forObject:self] reverseSetValueFor:@"selectionIndexes"];
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
{
CPLog.warn("The delegate method collectionViewDidChangeSelection: is deprecated and will be removed in a future version, please bind to selectionIndexes instead.");
[_delegate collectionViewDidChangeSelection:self];
}
}
/*!
@@ -623,7 +608,7 @@ var HORIZONTAL_MARGIN = 2;
height = MAX(height, numberOfRows * (_minItemSize.height + _verticalMargin));
var itemSizeHeight = FLOOR(height / numberOfRows);
var itemSizeHeight = FLOOR(height / numberOfRows) - _verticalMargin;
if (maxItemSizeHeight > 0)
itemSizeHeight = MIN(itemSizeHeight, maxItemSizeHeight);
@@ -1514,17 +1499,6 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
return [_delegate collectionView:self didDoubleClickOnItemAtIndex:index];
}
/*!
@ignore
Call delegate collectionViewDidChangeSelection
*/
- (void)_sendDelegateCollectionViewDidChangeSelection:(CPCollectionView)collectionView
{
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionViewDidChangeSelection_))
return;
return [_delegate collectionViewDidChangeSelection:self];
}
/*!
@ignore
+39 -5
View File
@@ -86,14 +86,12 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
_active = NO;
_color = [CPColor whiteColor];
[self setBordered:YES];
[self _registerForNotifications];
}
return self;
}
- (void)_registerForNotifications
- (void)_registerNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
@@ -110,6 +108,22 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
- (void)_removeNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:_CPColorWellDidBecomeExclusiveNotification
object:nil];
[defaultCenter
removeObserver:self
name:CPWindowWillCloseNotification
object:[CPColorPanel sharedColorPanel]];
}
/*!
Sets whether the color well is bordered.
*/
@@ -312,6 +326,28 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
[contentBorderView setBackgroundColor:[self currentValueForThemeAttribute:@"content-border-color"]];
}
#pragma mark -
#pragma mark Observers method
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _registerNotifications];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _removeNotifications];
}
@end
@implementation CPColorWellValueBinder : CPBinder
@@ -363,8 +399,6 @@ var CPColorWellColorKey = "CPColorWellColorKey",
_active = NO;
_color = [aCoder decodeObjectForKey:CPColorWellColorKey];
[self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
[self _registerForNotifications];
}
return self;
+18 -3
View File
@@ -36,6 +36,15 @@
@end
@protocol CPComboBoxDataSource <CPObject>
@optional
- (CPString)comboBox:(CPComboBox)aComboBox completedString:(CPString)uncompletedString;
- (id)comboBox:(CPComboBox)aComboBox objectValueForItemAtIndex:(int)index;
- (int)comboBox:(CPComboBox)aComboBox indexOfItemWithStringValue:(CPString)stringValue;
- (int)numberOfItemsInComboBox:(CPComboBox)aComboBox;
@end
CPComboBoxSelectionDidChangeNotification = @"CPComboBoxSelectionDidChangeNotification";
CPComboBoxSelectionIsChangingNotification = @"CPComboBoxSelectionIsChangingNotification";
@@ -183,7 +192,7 @@ var CPComboBoxTextSubview = @"text",
#pragma mark Setting a Delegate
- (id /*< CPComboBoxDelegate >*/)delegate
- (id <CPComboBoxDelegate>)delegate
{
return [super delegate];
}
@@ -243,7 +252,7 @@ var CPComboBoxTextSubview = @"text",
#pragma mark Setting a Data Source
- (id /*< CPComboBoxDataSource >*/)dataSource
- (id <CPComboBoxDataSource>)dataSource
{
if (!_usesDataSource)
[self _dataSourceWarningForMethod:_cmd condition:NO];
@@ -251,10 +260,12 @@ var CPComboBoxTextSubview = @"text",
return _dataSource;
}
- (void)setDataSource:(id /*< CPComboBoxDataSource >*/)aSource
- (void)setDataSource:(id <CPComboBoxDataSource>)aSource
{
if (!_usesDataSource)
{
[self _dataSourceWarningForMethod:_cmd condition:NO];
}
else if (_dataSource !== aSource)
{
if (![aSource respondsToSelector:@selector(numberOfItemsInComboBox:)] ||
@@ -263,7 +274,9 @@ var CPComboBoxTextSubview = @"text",
CPLog.warn("Illegal %s data source (%s). Must implement numberOfItemsInComboBox: and comboBox:objectValueForItemAtIndex:", [self className], [aSource description]);
}
else
{
_dataSource = aSource;
}
}
}
@@ -906,7 +919,9 @@ var CPComboBoxTextSubview = @"text",
index = [_dataSource comboBox:self indexOfItemWithStringValue:stringValue]
}
else
{
index = [self indexOfItemWithObjectValue:stringValue];
}
[_listDelegate selectRow:index];
+86 -6
View File
@@ -128,6 +128,8 @@ var CPControlBlackColor = [CPColor blackColor];
BOOL _trackingWasWithinFrame;
unsigned _trackingMouseDownFlags;
CGPoint _previousTrackingLocation;
CPControlSize _controlSize;
}
+ (CPDictionary)themeAttributes
@@ -144,6 +146,7 @@ var CPControlBlackColor = [CPColor blackColor];
@"image-scaling": CPScaleToFit,
@"min-size": CGSizeMakeZero(),
@"max-size": CGSizeMake(-1.0, -1.0),
@"nib2cib-adjustment-frame": CGRectMakeZero()
};
}
@@ -199,13 +202,85 @@ var CPControlBlackColor = [CPColor blackColor];
if (self)
{
_sendActionOn = CPLeftMouseUpMask;
_sendActionOn = CPLeftMouseUpMask;
_trackingMouseDownFlags = 0;
}
return self;
}
#pragma mark -
#pragma mark Control Size
/*!
Returns the control's control size
*/
- (CPControlSize)controlSize
{
return _controlSize;
}
/*!
Sets the control's size.
@param aControlSize the control's size
*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if (_controlSize === aControlSize)
return;
[self unsetThemeState:[self _controlSizeThemeState]];
_controlSize = aControlSize;
[self setThemeState:[self _controlSizeThemeState]];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
/*!
Gets the current theme state according to the current controlSize.
@return a CPThemeState
*/
- (ThemeState)_controlSizeThemeState
{
switch(_controlSize)
{
case CPSmallControlSize:
return CPThemeStateControlSizeSmall;
case CPMiniControlSize:
return CPThemeStateControlSizeMini;
case CPRegularControlSize:
default:
return CPThemeStateControlSizeRegular;
}
}
/*!
@ignore
Change frame size according to the theme control size theme constraints
Basically for height to min-size.
*/
- (void)_sizeToControlSize
{
var frameSize = [self frameSize],
minSize = [self currentValueForThemeAttribute:@"min-size"],
maxSize = [self currentValueForThemeAttribute:@"max-size"];
if (minSize.width > 0)
frameSize.width = MAX(minSize.width, frameSize.width);
if (minSize.height > 0)
frameSize.height = minSize.height;
[self setFrameSize:frameSize];
}
#pragma mark -
/*!
Sets the receiver's target action.
@@ -937,14 +1012,15 @@ var CPControlBlackColor = [CPColor blackColor];
@end
var CPControlValueKey = @"CPControlValueKey",
var CPControlActionKey = @"CPControlActionKey",
CPControlControlSizeKey = @"CPControlControlSizeKey",
CPControlControlStateKey = @"CPControlControlStateKey",
CPControlIsEnabledKey = @"CPControlIsEnabledKey",
CPControlTargetKey = @"CPControlTargetKey",
CPControlActionKey = @"CPControlActionKey",
CPControlSendActionOnKey = @"CPControlSendActionOnKey",
CPControlFormatterKey = @"CPControlFormatterKey",
CPControlIsEnabledKey = @"CPControlIsEnabledKey",
CPControlSendActionOnKey = @"CPControlSendActionOnKey",
CPControlSendsActionOnEndEditingKey = @"CPControlSendsActionOnEndEditingKey",
CPControlTargetKey = @"CPControlTargetKey",
CPControlValueKey = @"CPControlValueKey",
__Deprecated__CPImageViewImageKey = @"CPImageViewImageKey";
@@ -971,6 +1047,8 @@ var CPControlValueKey = @"CPControlValueKey",
[self setSendsActionOnEndEditing:[aCoder decodeBoolForKey:CPControlSendsActionOnEndEditingKey]];
[self setFormatter:[aCoder decodeObjectForKey:CPControlFormatterKey]];
[self setControlSize:[aCoder decodeIntForKey:CPControlControlSizeKey]];
}
return self;
@@ -1003,6 +1081,8 @@ var CPControlValueKey = @"CPControlValueKey",
if (_formatter !== nil)
[aCoder encodeObject:_formatter forKey:CPControlFormatterKey];
[aCoder encodeInt:_controlSize forKey:CPControlControlSizeKey];
}
@end
+40 -12
View File
@@ -28,7 +28,6 @@
@import <Foundation/CPArray.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPDate.j>
@import <Foundation/CPDateFormatter.j>
@import <Foundation/CPLocale.j>
@import <Foundation/CPTimeZone.j>
@@ -76,6 +75,7 @@ CPEraDatePickerElementFlag = 0x0100;
CPInteger _datePickerStyle @accessors(property=datePickerStyle);
CPInteger _timeInterval @accessors(property=timeInterval);
BOOL _invokedByUserEvent;
_CPDatePickerTextField _datePickerTextfield;
_CPDatePickerCalendar _datePickerCalendar;
unsigned _implementedCDatePickerDelegateMethods;
@@ -207,14 +207,10 @@ CPEraDatePickerElementFlag = 0x0100;
_locale = [CPLocale currentLocale];
_datePickerTextfield = [[_CPDatePickerTextField alloc] initWithFrame:[self bounds] withDatePicker:self];
[_datePickerTextfield setDateValue:_dateValue];
[self addSubview:_datePickerTextfield];
_datePickerCalendar = [[_CPDatePickerCalendar alloc] initWithFrame:[self bounds] withDatePicker:self];
[_datePickerCalendar setDateValue:_dateValue];
[_datePickerCalendar setHidden:YES];
[self addSubview:_datePickerCalendar];
// We might have been unarchived in a disabled state.
[_datePickerTextfield setEnabled:[self isEnabled]];
@@ -224,6 +220,18 @@ CPEraDatePickerElementFlag = 0x0100;
}
#pragma mark -
#pragma mark Control Size
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
if ([self datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [self datePickerStyle] == CPTextFieldDatePickerStyle)
[self _sizeToControlSize];
}
#pragma mark -
#pragma mark Delegate methods
@@ -252,15 +260,26 @@ CPEraDatePickerElementFlag = 0x0100;
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
{
[_datePickerTextfield setHidden:NO];
[_datePickerCalendar setHidden:YES];
if (![_datePickerTextfield superview])
[self addSubview:_datePickerTextfield];
if ([_datePickerCalendar superview])
[_datePickerCalendar removeFromSuperview];
[_datePickerTextfield setControlSize:[self controlSize]];
[_datePickerTextfield setNeedsLayout];
[_datePickerTextfield setNeedsDisplay:YES];
}
else
{
[_datePickerCalendar setHidden:NO];
[_datePickerTextfield setHidden:YES];
if (![_datePickerCalendar superview])
[self addSubview:_datePickerCalendar];
if ([_datePickerTextfield superview])
[_datePickerTextfield removeFromSuperview];
[_datePickerCalendar setNeedsLayout];
[_datePickerCalendar setNeedsDisplay:YES];
}
}
@@ -275,11 +294,14 @@ CPEraDatePickerElementFlag = 0x0100;
return _dateValue
}
/*! Set the objectValue ofhe datePier. It has to be a CPDate
/*! Set the objectValue of the datePicker. It has to be a CPDate
@param aDateValue the dateValue
*/
- (void)setObjectValue:(CPDate)aValue
{
if (![aValue isKindOfClass:[CPDate class]])
return;
[self setDateValue:aValue];
}
@@ -291,6 +313,7 @@ CPEraDatePickerElementFlag = 0x0100;
if (aDateValue == nil)
return;
_invokedByUserEvent = NO;
[self _setDateValue:aDateValue timeInterval:_timeInterval];
}
@@ -338,7 +361,8 @@ CPEraDatePickerElementFlag = 0x0100;
_timeInterval = (_datePickerMode == CPSingleDateMode)? 0 : aTimeInterval;
[self didChangeValueForKey:@"timeInterval"];
[self sendAction:[self action] to:[self target]];
if (_invokedByUserEvent)
[self sendAction:[self action] to:[self target]];
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
[_datePickerTextfield setDateValue:_dateValue];
@@ -377,6 +401,8 @@ CPEraDatePickerElementFlag = 0x0100;
{
_datePickerStyle = aDatePickerStyle;
[self setControlSize:[self controlSize]];
[self setNeedsDisplay:YES];
[self setNeedsLayout];
}
@@ -537,6 +563,7 @@ CPEraDatePickerElementFlag = 0x0100;
return NO;
[_datePickerTextfield _selectTextFieldWithFlags:[[CPApp currentEvent] modifierFlags]];
return YES;
}
@@ -644,12 +671,13 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
_timeInterval = [aCoder decodeDoubleForKey:CPIntervalKey];
_datePickerMode = [aCoder decodeIntForKey:CPDatePickerModeKey];
_datePickerElements = [aCoder decodeIntForKey:CPDatePickerElementsKey];
_datePickerStyle = [aCoder decodeIntForKey:CPDatePickerStyleKey];
[self setDatePickerStyle:[aCoder decodeIntForKey:CPDatePickerStyleKey]];
_locale = [aCoder decodeObjectForKey:CPLocaleKey];
_dateValue = [aCoder decodeObjectForKey:CPDateValueKey];
_backgroundColor = [aCoder decodeObjectForKey:CPBackgroundColorKey];
_drawsBackground = [aCoder decodeBoolForKey:CPDrawsBackgroundKey];
_isBordered = [aCoder decodeBoolForKey:CPBorderedKey];
[self _init];
}
+17 -13
View File
@@ -85,6 +85,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_datePicker = aDatePicker
[self _init];
}
return self;
}
@@ -215,6 +216,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[_headerView setHidden:YES];
[_monthView setHidden:YES];
}
[self setFrameSize:[_datePicker frameSize]];
}
@@ -381,9 +384,11 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[_previousButton setTarget:aDelegate];
[_previousButton setAction:@selector(_clickArrowPrevious:)];
[_previousButton setContinuous:YES];
[_nextButton setTarget:aDelegate];
[_nextButton setAction:@selector(_clickArrowNext:)];
[_nextButton setContinuous:YES];
[_currentButton setTarget:aDelegate];
[_currentButton setAction:@selector(_currentMonth:)];
@@ -891,6 +896,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_indexDayTile = -1;
_eventDragged = nil
_datePicker._invokedByUserEvent = YES;
// Check if we have to change or not the month of the component
if ([dayTile date].getMonth() == _date.getMonth())
{
@@ -943,6 +950,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
else
[_delegate _displayNextMonth];
}
_datePicker._invokedByUserEvent = NO;
}
/*! Mouse dragged event
@@ -960,6 +969,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_indexDayTile = [self indexOfTileForEvent:anEvent];
_eventDragged = anEvent;
_datePicker._invokedByUserEvent = YES;
if ([_datePicker datePickerMode] == CPSingleDateMode)
{
// Check if we have to change or not the month of the component
@@ -1001,6 +1012,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:_clickDate] timeInterval:[dateTile timeIntervalSinceDate:dateValueAtMidnight]];
}
}
_datePicker._invokedByUserEvent = NO;
}
- (void)mouseUp:(CPEvent)anEvent
@@ -1258,14 +1271,6 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
CPDatePicker _datePicker @accessors(property=datePicker);
}
- (id)init
{
if (self = [super init])
{
}
return self;
}
- (void)drawRect:(CGRect)aRect
{
[super drawRect:aRect];
@@ -1279,10 +1284,10 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
CGContextSetStrokeColor(context, [_datePicker valueForThemeAttribute:@"border-color" inState:[_datePicker themeState]]);
CGContextSetLineWidth(context, [_datePicker valueForThemeAttribute:@"border-width"]);
CGContextMoveToPoint(context, borderWidth,borderWidth);
CGContextAddLineToPoint(context, aRect.size.width - borderWidth,borderWidth);
CGContextAddLineToPoint(context, aRect.size.width - borderWidth,aRect.size.height - borderWidth);
CGContextAddLineToPoint(context, borderWidth,aRect.size.height - borderWidth);
CGContextMoveToPoint(context, borderWidth, borderWidth);
CGContextAddLineToPoint(context, aRect.size.width - borderWidth, borderWidth);
CGContextAddLineToPoint(context, aRect.size.width - borderWidth, aRect.size.height - borderWidth);
CGContextAddLineToPoint(context, borderWidth, aRect.size.height - borderWidth);
CGContextAddLineToPoint(context, borderWidth,borderWidth);
CGContextStrokePath(context);
@@ -1301,5 +1306,4 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[self setBackgroundColor:[CPColor clearColor]];
}
@end
+334 -179
View File
@@ -92,8 +92,6 @@ var CPZeroKeyCode = 48,
[_stepper setAction:@selector(_clickStepper:)];
[self addSubview:_stepper];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldBecomeFirstResponder:) name:CPDatePickerElementTextFieldBecomeFirstResponder object:self];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -365,7 +363,6 @@ var CPZeroKeyCode = 48,
[_currentTextField setValueForKeyEvent:anEvent];
}
#pragma mark -
#pragma mark Layout methods
@@ -384,14 +381,16 @@ var CPZeroKeyCode = 48,
// Check the mode to display or not the stepper
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle)
{
frameSize = CGSizeMake(CGRectGetWidth([_datePicker frame]) - CGRectGetWidth([_stepper frame]) - [_datePicker valueForThemeAttribute:@"stepper-margin"], CGRectGetHeight([_datePicker frame]));
[_stepper setHidden:NO];
[_stepper setControlSize:[_datePicker controlSize]];
frameSize = CGSizeMake(CGRectGetWidth([_datePicker frame]) - CGRectGetWidth([_stepper frame]) - [_datePicker currentValueForThemeAttribute:@"stepper-margin"], CGRectGetHeight([_datePicker frame]));
frameSize.width -= bezelInset.left;
frameSize.height -= bezelInset.top + bezelInset.bottom;
[_datePickerElementView setFrameSize:frameSize];
[_datePickerElementView setFrameOrigin:CGPointMake(bezelInset.left, bezelInset.top)];
[_stepper setHidden:NO];
}
else if ([_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
{
@@ -405,11 +404,37 @@ var CPZeroKeyCode = 48,
[_stepper setHidden:YES];
}
[_stepper setFrameOrigin:CGPointMake(CGRectGetMaxX([_datePickerElementView frame]) + [_datePicker valueForThemeAttribute:@"stepper-margin"], bezelInset.top + CGRectGetHeight([_datePickerElementView frame]) / 2 - CGRectGetHeight([_stepper frame]) / 2)];
[_stepper setFrameOrigin:CGPointMake(CGRectGetMaxX([_datePickerElementView frame]) + [_datePicker currentValueForThemeAttribute:@"stepper-margin"], bezelInset.top + CGRectGetHeight([_datePickerElementView frame]) / 2 - CGRectGetHeight([_stepper frame]) / 2)];
[_datePickerElementView setControlSize:[_datePicker controlSize]];
[_datePickerElementView setNeedsLayout];
}
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPDatePickerElementTextFieldBecomeFirstResponder object:self];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldBecomeFirstResponder:) name:CPDatePickerElementTextFieldBecomeFirstResponder object:self];
}
@end
@@ -520,8 +545,6 @@ var CPZeroKeyCode = 48,
[self addSubview: _textFieldSeparatorThree];
[self addSubview: _textFieldSeparatorFour];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldAMPMChangedNotification:) name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
[self setNeedsLayout];
}
@@ -529,12 +552,91 @@ var CPZeroKeyCode = 48,
#pragma mark -
#pragma mark Responder methods
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
return NO;
// This is needed to accept to be firstResponder when nothing is selected.
// This element needs to be first responder when the CPDatePicker is in the CPTableView
// When clicking on a row of a CPTableView where there isn't a date element, the CPTableView will ask this element to know if it can becomes or not a firstResponder.
return [_datePicker isEnabled] && ![self superview]._currentTextField;
}
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldAMPMChangedNotification:) name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
}
#pragma mark -
#pragma mark Mouse event
- (BOOL)continueTracking:(CGPoint)lastPoint at:(CGPoint)aPoint
{
[self _selectTextFieldForPoint:aPoint];
return YES;
}
- (BOOL)startTrackingAt:(CGPoint)aPoint
{
[self _selectTextFieldForPoint:aPoint];
return YES;
}
- (void)_selectTextFieldForPoint:(CGPoint)aPoint
{
var textField = [self _textFieldForPoint:aPoint],
superview = [self superview];
if (!textField || [superview._currentTextField] == textField)
return;
[[CPNotificationCenter defaultCenter] postNotificationName:CPDatePickerElementTextFieldBecomeFirstResponder object:superview userInfo:[CPDictionary dictionaryWithObject:textField forKey:@"textField"]];
}
- (_CPDatePickerElementTextField)_textFieldForPoint:(CGPoint)aPoint
{
if (![_textFieldDay isHidden] && CGRectContainsPoint([_textFieldDay frame], aPoint))
return _textFieldDay;
if (![_textFieldMonth isHidden] && CGRectContainsPoint([_textFieldMonth frame], aPoint))
return _textFieldMonth;
if (![_textFieldYear isHidden] && CGRectContainsPoint([_textFieldYear frame], aPoint))
return _textFieldYear;
if (![_textFieldHour isHidden] && CGRectContainsPoint([_textFieldHour frame], aPoint))
return _textFieldHour;
if (![_textFieldMinute isHidden] && CGRectContainsPoint([_textFieldMinute frame], aPoint))
return _textFieldMinute;
if (![_textFieldSecond isHidden] && CGRectContainsPoint([_textFieldSecond frame], aPoint))
return _textFieldSecond;
if (![_textFieldPMAM isHidden] && CGRectContainsPoint([_textFieldPMAM frame], aPoint))
return _textFieldPMAM;
return nil;
}
#pragma mark -
#pragma mark Setter Getter methods
@@ -675,7 +777,9 @@ var CPZeroKeyCode = 48,
dateValue.setHours(dateValue.getHours() - 12);
}
[_datePicker setDateValue:dateValue];
_datePicker._invokedByUserEvent = YES;
[_datePicker _setDateValue:dateValue timeInterval:[_datePicker timeInterval]];
_datePicker._invokedByUserEvent = NO;
}
@@ -702,6 +806,7 @@ var CPZeroKeyCode = 48,
[self _updateResponderTextField];
[self _updateHiddenTextFields];
[self _setControlSizes];
[self _sizeToFit];
[self _updatePositions];
@@ -738,183 +843,201 @@ var CPZeroKeyCode = 48,
*/
- (void)_themeTextFields
{
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldDay setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldDay setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldDay setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldDay setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldDay setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
var disabledTextColor = [_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled],
disabledTextFieldBezelColor = [_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled],
disabledTextShadowColor = [_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled],
disabledTextShadowOffset = [_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled],
normalSeparatorContentInset = [_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateNormal],
normalTextFieldBezelColor = [_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal],
normalTextFieldContentInset = [_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal],
normalTextShadowColor = [_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal],
normalTextShadowOffset = [_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal],
selectedSeparatorContentInset = [_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateSelected],
selectedTextColor = [_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected],
selectedTextFieldBezelColor = [_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected],
selectedTextFieldContentInset = [_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected],
selectedTextShadowColor = [_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected],
selectedTextShadowOffset = [_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected],
textColor = [_datePicker textColor],
textFieldMinSize = [_datePicker currentValueForThemeAttribute:@"min-size-datepicker-textfield"],
textFont = [_datePicker textFont];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldMonth setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldMonth setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldMonth setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldDay setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldDay setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldDay setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldDay setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldDay setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldDay setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldDay setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldDay setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldDay setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldDay setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldDay setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldDay setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldDay setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldDay setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldDay setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldDay setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldDay setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldDay setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldYear setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldYear setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldYear setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldYear setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldYear setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldMonth setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldMonth setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldMonth setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldMonth setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldMonth setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldMonth setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldMonth setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldMonth setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldMonth setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldMonth setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldMonth setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldMonth setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldMonth setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldMonth setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldHour setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldHour setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldHour setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldHour setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldHour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldYear setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldYear setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldYear setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldYear setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldYear setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldYear setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldYear setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldYear setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldYear setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldYear setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldYear setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldYear setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldYear setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldYear setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldYear setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldYear setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldYear setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldYear setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldMinute setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldMinute setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldMinute setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldHour setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldHour setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldHour setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldHour setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldHour setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldHour setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldHour setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldHour setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldHour setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldHour setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldHour setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldHour setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldHour setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldHour setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldHour setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldHour setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldHour setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldHour setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldSecond setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldSecond setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSecond setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldMinute setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldMinute setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldMinute setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldMinute setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldMinute setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldMinute setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldMinute setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldMinute setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldMinute setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldMinute setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldMinute setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldMinute setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldMinute setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldMinute setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"min-size-datepicker-textfield"] forThemeAttribute:@"min-size"];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateSelected] forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateNormal] forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"datepicker-textfield-bezel-color" inState:CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldSecond setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSecond setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSecond setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldSecond setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldSecond setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldSecond setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldSecond setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldSecond setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldSecond setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSecond setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSecond setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSecond setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSecond setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSecond setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorOne setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:textFieldMinSize forThemeAttribute:@"min-size"];
[_textFieldPMAM setValue:normalTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:selectedTextFieldContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:selectedTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:selectedTextColor forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:selectedTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:selectedTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateSelected];
[_textFieldPMAM setValue:normalTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldPMAM setValue:disabledTextFieldBezelColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldPMAM setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorTwo setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:normalSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:selectedSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorOne setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorOne setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorOne setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorThree setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:normalSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:selectedSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorTwo setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorTwo setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorTwo setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateNormal] forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"content-inset-datepicker-textfield-separator" inState:CPThemeStateSelected] forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorFour setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:[_datePicker textColor] forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:[_datePicker textFont] forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"text-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:[_datePicker valueForThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:normalSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:selectedSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorThree setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorThree setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorThree setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:normalSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:selectedSeparatorContentInset forThemeAttribute:@"content-inset" inState:CPThemeStateSelected];
[_textFieldSeparatorFour setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:normalTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:normalTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateNormal];
[_textFieldSeparatorFour setValue:textFont forThemeAttribute:@"font" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:disabledTextColor forThemeAttribute:@"text-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:disabledTextShadowColor forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
[_textFieldSeparatorFour setValue:disabledTextShadowOffset forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
}
/*! Hide or not the textField depending on the datePickerElements flag
@@ -1013,7 +1136,7 @@ var CPZeroKeyCode = 48,
if ([_textFieldMonth isHidden])
[_textFieldHour setFrameOrigin:CGPointMake(horizontalInset, verticalInset)];
else
[_textFieldHour setFrameOrigin:CGPointMake(CGRectGetMaxX([_textFieldYear frame]) + [_datePicker valueForThemeAttribute:@"date-hour-margin"],verticalInset)];
[_textFieldHour setFrameOrigin:CGPointMake(CGRectGetMaxX([_textFieldYear frame]) + [_datePicker currentValueForThemeAttribute:@"date-hour-margin"], verticalInset)];
[_textFieldSeparatorThree setFrameOrigin:CGPointMake(CGRectGetMaxX([_textFieldHour frame]) + separatorContentInset.left, verticalInset)];
[_textFieldMinute setFrameOrigin:CGPointMake(CGRectGetMaxX([_textFieldSeparatorThree frame]) + separatorContentInset.right, verticalInset)];
@@ -1043,6 +1166,25 @@ var CPZeroKeyCode = 48,
[_textFieldPMAM sizeToFit];
}
/*! Size to fit all of the textFields
*/
- (void)_setControlSizes
{
var controlSize = [_datePicker controlSize];
[_textFieldDay setControlSize:controlSize];
[_textFieldMonth setControlSize:controlSize];
[_textFieldYear setControlSize:controlSize];
[_textFieldHour setControlSize:controlSize];
[_textFieldMinute setControlSize:controlSize];
[_textFieldSecond setControlSize:controlSize];
[_textFieldSeparatorOne setControlSize:controlSize];
[_textFieldSeparatorTwo setControlSize:controlSize];
[_textFieldSeparatorThree setControlSize:controlSize];
[_textFieldSeparatorFour setControlSize:controlSize];
[_textFieldPMAM setControlSize:controlSize];
}
#pragma mark -
#pragma mark Responder methods
@@ -1240,6 +1382,12 @@ var CPMonthDateType = 0,
return self;
}
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
return [_datePicker isEnabled];
}
/*! Set the dateType of the textField
*/
- (void)setDateType:(int)aDateType
@@ -1594,7 +1742,9 @@ var CPMonthDateType = 0,
newDateValue.setSeconds(newDateValue.getSeconds() + secondsFromGMT - secondsFromGMTTimeZone);
}
[_datePicker setDateValue:newDateValue];
_datePicker._invokedByUserEvent = YES;
[_datePicker _setDateValue:newDateValue timeInterval:[_datePicker timeInterval]];
_datePicker._invokedByUserEvent = NO;
}
@@ -1692,4 +1842,9 @@ var CPMonthDateType = 0,
return frameSize;
}
@end
- (CGRect)bezelRectForBounds:(CGRect)bounds
{
return CGRectMakeCopy(bounds);
}
@end
+30
View File
@@ -70,6 +70,9 @@ var _CPEventPeriodicEventPeriod = 0,
float _deltaX;
float _deltaY;
float _deltaZ;
float _scrollingDeltaX;
float _scrollingDeltaY;
BOOL _hasPreciseScrollingDeltas;
#if PLATFORM(DOM)
BOOL _suppressCappuccinoCut;
@@ -165,7 +168,9 @@ var _CPEventPeriodicEventPeriod = 0,
// Make sure these are 0 rather than nil.
_deltaX = 0;
_scrollingDeltaX = 0;
_deltaY = 0;
_scrollingDeltaY = 0;
_deltaZ = 0;
}
@@ -419,6 +424,31 @@ var _CPEventPeriodicEventPeriod = 0,
return _deltaZ;
}
- (BOOL)hasPreciseScrollingDeltas
{
return !!_hasPreciseScrollingDeltas;
}
/*!
Returns the change in points on the x-axis for a mouse movement, unless hasPreciseScrollingDeltas is NO,
in which case the change is measured in number of "lines" or "rows" and needs to be multiplied as appropriate
to get change in pixels.
*/
- (float)scrollingDeltaX
{
return _scrollingDeltaX;
}
/*!
Returns the change in points on the y-axis for a mouse movement, unless hasPreciseScrollingDeltas is NO,
in which case the change is measured in number of "lines" or "columns" and needs to be multiplied as appropriate
to get change in pixels.
*/
- (float)scrollingDeltaY
{
return _scrollingDeltaY;
}
- (BOOL)_triggersKeyEquivalent:(CPString)aKeyEquivalent withModifierMask:aKeyEquivalentModifierMask
{
if (!aKeyEquivalent)
+4 -4
View File
@@ -175,20 +175,20 @@ following:
return _CPFontSystemFontSize;
}
+ (float)systemFontSizeForControlSize:(CPControlSize)aSize
+ (CPFont)systemFontForControlSize:(CPControlSize)aSize
{
// TODO These sizes should be themable or made less arbitrary in some other way.
switch (aSize)
{
case CPSmallControlSize:
return _CPFontSystemFontSize - 1;
return [self systemFontOfSize:_CPFontSystemFontSize - 1];
case CPMiniControlSize:
return _CPFontSystemFontSize - 2;
return [self systemFontOfSize:_CPFontSystemFontSize - 2];
case CPRegularControlSize:
default:
return _CPFontSystemFontSize;
return [self systemFontOfSize:_CPFontSystemFontSize];
}
}
+1
View File
@@ -178,6 +178,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
- (void)imageDidLoad:(CPNotification)aNotification
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:[self objectValue]];
[self hideOrDisplayContents];
[self setNeedsLayout];
+44 -2
View File
@@ -70,6 +70,20 @@ var CPBindingOperationAnd = 0,
return [[bindingsMap objectForKey:[anObject UID]] objectForKey:aBinding];
}
+ (void)_reverseSetValueFromExclusiveBinderForObject:(id)anObject
{
var bindersByBindingName = [bindingsMap objectForKey:[anObject UID]];
[bindersByBindingName enumerateKeysAndObjectsUsingBlock:function(binding, binder, stop)
{
if ([binder isKindOfClass:[self class]])
{
[binder reverseSetValueFor:binding];
stop(YES);
}
}];
}
+ (CPDictionary)infoForBinding:(CPString)aBinding forObject:(id)anObject
{
var theBinding = [self getBinding:aBinding forObject:anObject];
@@ -116,7 +130,7 @@ var CPBindingOperationAnd = 0,
count = allKeys.length;
while (count--)
[anObject unbind:[bindings objectForKey:allKeys[count]]];
[anObject unbind:allKeys[count]];
[bindingsMap removeObjectForKey:[anObject UID]];
}
@@ -142,7 +156,7 @@ var CPBindingOperationAnd = 0,
[self _updatePlaceholdersWithOptions:options forBinding:aName];
[aDestination addObserver:self forKeyPath:aKeyPath options:CPKeyValueObservingOptionNew context:aBinding];
[aDestination addObserver:self forKeyPath:aKeyPath options:0 context:aBinding];
var bindings = [bindingsMap objectForKey:[_source UID]];
@@ -159,6 +173,24 @@ var CPBindingOperationAnd = 0,
return self;
}
+ (BOOL)isBindingAllowed:(CPString)aBinding forObject:(id)anObject
{
if ([[anObject class] isBindingExclusive:aBinding])
{
var bindingsForObject = [bindingsMap objectForKey:[anObject UID]],
allBindings = [bindingsForObject allKeys],
count = [allBindings count];
while(count--)
{
if ([[anObject class] isBindingExclusive:allBindings[count]])
return NO;
}
}
return YES;
}
- (void)raiseIfNotApplicable:(id)aValue forKeyPath:(CPString)keyPath options:(CPDictionary)options
{
if (aValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
@@ -387,6 +419,11 @@ var CPBindingOperationAnd = 0,
return [CPBinder class];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return NO;
}
- (CPArray)exposedBindings
{
var exposedBindings = [],
@@ -415,6 +452,11 @@ var CPBindingOperationAnd = 0,
if (!anObject || !aKeyPath)
return CPLog.error("Invalid object or path on " + self + " for " + aBinding);
if (![CPBinder isBindingAllowed:aBinding forObject:self])
{
CPLog.warn([self description] + " : cannot bind " + aBinding + " because another binding with the same functionality is already in use.");
return;
}
//if (![[self exposedBindings] containsObject:aBinding])
// CPLog.warn("No binding exposed on " + self + " for " + aBinding);
+1
View File
@@ -651,6 +651,7 @@ var _CPMenuBarVisible = NO,
if (binder)
{
[binder setValueFor:CPEnabledBinding];
[[_menuWindow _menuView] tile];
return;
}
+17 -12
View File
@@ -459,13 +459,13 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
- (BOOL)isEqual:(id)anObject
{
if ([anObject class] === [self class])
{
if (anObject._observer === _observer && [anObject._keyPath isEqual:_keyPath] && [anObject._object isEqual:_object])
return YES;
}
if (self === anObject)
return YES;
return NO;
if (!anObject || [anObject class] !== [self class] || anObject._observer !== _observer || anObject._keyPath !== _keyPath || anObject._object !== _object)
return NO;
return YES;
}
- (void)observeValueForKeyPath:(CPString)aKeyPath ofObject:(id)anObject change:(CPDictionary)change context:(id)context
@@ -808,15 +808,20 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
- (void)removeObserver:(id)anObject forKeyPath:(CPString)aKeyPath
{
var proxy = [[_CPObservationProxy alloc] initWithKeyPath:aKeyPath observer:anObject object:self],
index = [_observationProxies indexOfObject:proxy];
[_observationProxies enumerateObjectsUsingBlock:function(aProxy, idx, stop)
{
if (aProxy._object === self && aProxy._keyPath == aKeyPath && aProxy._observer === anObject)
{
var observedObjects = _observedObjectsByKeyPath[aKeyPath];
var observedObjects = _observedObjectsByKeyPath[aKeyPath];
[observedObjects removeObserver:[_observationProxies objectAtIndex:index] forKeyPath:aKeyPath];
[observedObjects removeObserver:aProxy forKeyPath:aKeyPath];
[_observationProxies removeObjectAtIndex:idx];
[_observationProxies removeObjectAtIndex:index];
_observedObjectsByKeyPath[aKeyPath] = nil;
_observedObjectsByKeyPath[aKeyPath] = nil;
stop(YES);
}
}];
}
@end
+323 -215
View File
@@ -186,6 +186,9 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
id _dropItem;
BOOL _coalesceSelectionNotificationState;
CPArray _pendingItemToClean;
CPArray _itemAddedDuringLastLoading;
}
- (id)initWithFrame:(CGRect)aFrame
@@ -346,7 +349,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
if (!anItem)
return YES;
var itemInfo = _itemInfosForItems[[anItem UID]];
var itemInfo = [self _itemInfosForItem:anItem];
if (!itemInfo)
return NO;
@@ -379,7 +382,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
if (!anItem)
return YES;
var itemInfo = _itemInfosForItems[[anItem UID]];
var itemInfo = [self _itemInfosForItem:anItem];
if (!itemInfo)
return NO;
@@ -387,6 +390,107 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
return itemInfo.isExpanded;
}
/*!
Returns the item at a given row index. If no item exists nil is returned.
@param aRow - The row index you want to find the item at.
@return id - The item at a given index.
*/
- (id)itemAtRow:(CPInteger)aRow
{
return _itemsForRows[aRow] || nil;
}
/*!
Returns the row of a given item
@param anItem - The item you want to find the row of.
@return int - The row index of a given item.
*/
- (CPInteger)rowForItem:(id)anItem
{
if (!anItem)
return _rootItemInfo.row;
var itemInfo = [self _itemInfosForItem:anItem];
if (!itemInfo)
return CPNotFound;
return itemInfo.row;
}
/*!
Returns the indentation level of a given item. If the item is nil (the top
level root item) CPNotFound is returned. Indentation levels are zero
based, thus items that are not indented return 0.
@param anItem - The item you want the indentation level for.
@return int - the indentation level of anItem.
*/
- (CPInteger)levelForItem:(id)anItem
{
if (!anItem)
return _rootItemInfo.level;
var itemInfo = [self _itemInfosForItem:anItem];
if (!itemInfo)
return CPNotFound;
return itemInfo.level;
}
/*!
Returns the indentation level for a given row. If the row is invalid
CPNotFound is returned. Rows that are not indented return 0.
@param aRow - the row of the receiver
@return int - the indentation level of aRow.
*/
- (CPInteger)levelForRow:(CPInteger)aRow
{
var item = [self itemAtRow:aRow];
if (!item && aRow >= 0)
item = [CPObject new];
return [self levelForItem:item];
}
/*!
@ignore
Return the itemInfos for the given item.
The method returns only itemInfo for displayed items
*/
- (Object)_itemInfosForItem:(id)anItem
{
var itemInfo = _itemInfosForItems[[anItem UID]];
if (!itemInfo || [self _parentIsCollapsed:[self parentForItem:anItem]])
return nil;
return itemInfo;
}
/*!
@ignore
Return a boolean to know if one parent of the given item is collapsed or not
*/
- (BOOL)_parentIsCollapsed:(id)anItem
{
var parentItem = [self parentForItem:anItem],
itemInfo = _itemInfosForItems[[anItem UID]];
if (!itemInfo)
return NO;
if (!itemInfo.isExpanded)
return YES;
return [self _parentIsCollapsed:parentItem];
}
/*!
Expands a given item.
@@ -423,6 +527,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
// selection notifications so that exactly one IsChanging and one
// DidChange is sent as needed, for the totality of the operation.
var isTopLevel = NO;
if (!_coalesceSelectionNotificationState)
{
isTopLevel = YES;
@@ -442,6 +547,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
// Shift selection indexes below so that the same items remain selected.
var rowCountDelta = [self numberOfRows] - previousRowCount;
if (rowCountDelta)
{
var selection = [self selectedRowIndexes],
@@ -531,6 +637,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
[self _setSelectedRowIndexes:selection]; // _noteSelectionDidChange will be suppressed.
}
}
itemInfo.isExpanded = NO;
[self reloadItem:anItem reloadChildren:YES];
@@ -562,42 +669,205 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
*/
- (void)reloadItem:(id)anItem reloadChildren:(BOOL)shouldReloadChildren
{
_pendingItemToClean = [];
_itemAddedDuringLastLoading = [];
if (!!shouldReloadChildren || !anItem)
_loadItemInfoForItem(self, anItem);
[self _loadItemInfoForItem:anItem intermediate:NO];
else
_reloadItem(self, anItem);
[self _reloadItem:anItem];
[self _cleanPendingItem];
[super reloadData];
}
/*!
Returns the item at a given row index. If no item exists nil is returned.
@param aRow - The row index you want to find the item at.
@return id - The item at a given index.
*/
- (id)itemAtRow:(CPInteger)aRow
{
return _itemsForRows[aRow] || nil;
}
/*!
Returns the row of a given item
@param anItem - The item you want to find the row of.
@return int - The row index of a given item.
*/
- (CPInteger)rowForItem:(id)anItem
- (void)_reloadItem:(id)anItem
{
if (!anItem)
return _rootItemInfo.row;
return;
// Get the existing info if it exists.
var itemUID = [anItem UID],
itemInfo = _itemInfosForItems[itemUID];
// If we're not in the tree, then just bail.
if (!itemInfo)
return [];
// See if the item itself can be swapped out.
var parent = itemInfo.parent,
parentItemInfo = parent ? _itemInfosForItems[[parent UID]] : _rootItemInfo,
parentChildren = parentItemInfo.children,
index = [parentChildren indexOfObjectIdenticalTo:anItem],
newItem = [_outlineViewDataSource outlineView:self child:index ofItem:parent];
if (anItem !== newItem)
{
_itemInfosForItems[[anItem UID]] = nil;
_itemInfosForItems[[newItem UID]] = itemInfo;
parentChildren[index] = newItem;
_itemsForRows[itemInfo.row] = newItem;
}
itemInfo.isExpandable = [_outlineViewDataSource outlineView:self isItemExpandable:newItem];
itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded;
itemInfo.shouldShowOutlineDisclosureControl = [self _sendDelegateShouldShowOutlineDisclosureControlForItem:newItem];
}
- (void)_addPendingItemsFromPreviousItems:(CPArray)previousItems forItemInfo:(Object)itemInfo
{
if (!itemInfo)
return;
var children = itemInfo.children;
for (var i = [previousItems count] - 1; i >= 0; i--)
{
var item = previousItems[i];
if (![children containsObject:item])
[self _addPendingItem:item];
}
}
- (void)_addPendingItem:(id)anItem
{
var itemInfo = _itemInfosForItems[[anItem UID]];
if (!itemInfo)
return CPNotFound;
return;
return itemInfo.row;
var children = itemInfo.children;
for (var i = [children count]; i >= 0; i--)
{
var child = children[i];
[self _addPendingItem:child];
}
[_pendingItemToClean addObject:anItem];
}
- (void)_cleanPendingItem
{
for (var i = [_pendingItemToClean count]; i >= 0; i--)
{
var item = _pendingItemToClean[i];
if (![_itemAddedDuringLastLoading containsObject:item])
delete _itemInfosForItems[[item UID]];
}
_pendingItemToClean = [];
_itemAddedDuringLastLoading = [];
}
- (CPArray)_loadItemInfoForItem:(id)anItem intermediate:(BOOL)isIntermediate
{
if (!anItem)
{
var itemInfo = _rootItemInfo;
}
else
{
// Get the existing info if it exists.
var itemUID = [anItem UID],
itemInfo = _itemInfosForItems[itemUID];
// If we're not in the tree, then just bail.
if (!itemInfo)
return [];
itemInfo.isExpandable = [_outlineViewDataSource outlineView:self isItemExpandable:anItem];
itemInfo.shouldShowOutlineDisclosureControl = [self _sendDelegateShouldShowOutlineDisclosureControlForItem:anItem];
// If we were previously expanded, but now no longer expandable, "de-expand".
// NOTE: we are *not* collapsing, thus no notification is posted.
if (!itemInfo.isExpandable && itemInfo.isExpanded)
{
itemInfo.isExpanded = NO;
itemInfo.children = [];
}
}
// The root item does not count as a descendant.
var weight = itemInfo.weight,
descendants = anItem ? [anItem] : [];
[_itemAddedDuringLastLoading addObject:anItem];
if (itemInfo.isExpanded && [self _sendDataSourceShouldDeferDisplayingChildrenOfItem:anItem])
{
var index = 0,
count = [_outlineViewDataSource outlineView:self numberOfChildrenOfItem:anItem],
level = itemInfo.level + 1,
previousChildren = itemInfo.children;
itemInfo.children = [];
for (; index < count; ++index)
{
var childItem = [_outlineViewDataSource outlineView:self child:index ofItem:anItem],
childItemInfo = _itemInfosForItems[[childItem UID]];
if (!childItemInfo)
{
childItemInfo = { isExpanded:NO, isExpandable:NO, shouldShowOutlineDisclosureControl:YES, children:[], weight:1 };
_itemInfosForItems[[childItem UID]] = childItemInfo;
}
itemInfo.children[index] = childItem;
var childDescendants = [self _loadItemInfoForItem:childItem intermediate:YES];
childItemInfo.parent = anItem;
childItemInfo.level = level;
descendants = descendants.concat(childDescendants);
}
// Here we clean the itemInfos dictionary
// Some items could have been removed at this point, we don't need to keep a ref of them anymore
[self _addPendingItemsFromPreviousItems:previousChildren forItemInfo:itemInfo];
}
itemInfo.weight = descendants.length;
if (!isIntermediate)
{
// row = -1 is the root item, so just go to row 0 since it is ignored.
var index = MAX(itemInfo.row, 0);
descendants.unshift(index, weight);
_itemsForRows.splice.apply(_itemsForRows, descendants);
var count = _itemsForRows.length;
for (; index < count; ++index)
_itemInfosForItems[[_itemsForRows[index] UID]].row = index;
var deltaWeight = itemInfo.weight - weight;
if (deltaWeight !== 0)
{
var parent = itemInfo.parent;
while (parent)
{
var parentItemInfo = _itemInfosForItems[[parent UID]];
parentItemInfo.weight += deltaWeight;
parent = parentItemInfo.parent;
}
if (anItem)
_rootItemInfo.weight += deltaWeight;
}
}
return descendants;
}
/*!
@@ -627,39 +897,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
return _outlineTableColumn;
}
/*!
Returns the indentation level of a given item. If the item is nil (the top
level root item) CPNotFound is returned. Indentation levels are zero
based, thus items that are not indented return 0.
@param anItem - The item you want the indentation level for.
@return int - the indentation level of anItem.
*/
- (CPInteger)levelForItem:(id)anItem
{
if (!anItem)
return _rootItemInfo.level;
var itemInfo = _itemInfosForItems[[anItem UID]];
if (!itemInfo)
return CPNotFound;
return itemInfo.level;
}
/*!
Returns the indentation level for a given row. If the row is invalid
CPNotFound is returned. Rows that are not indented return 0.
@param aRow - the row of the receiver
@return int - the indentation level of aRow.
*/
- (CPInteger)levelForRow:(CPInteger)aRow
{
return [self levelForItem:[self itemAtRow:aRow]];
}
/*!
Sets the number of pixels to indent an item at each indentation level.
@@ -770,6 +1007,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
- (CGRect)frameOfOutlineDisclosureControlAtRow:(CPInteger)aRow
{
var theItem = [self itemAtRow:aRow];
if (![self isExpandable:theItem] || ![self _shouldShowOutlineDisclosureControlForItem:theItem])
return CGRectMakeZero();
@@ -1042,17 +1280,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
CPLog.warn("outlineView:dataViewForTableColumn:item: is deprecated. You should use -outlineView:viewForTableColumn:item: where you can request the view with -makeViewWithIdentifier:owner:");
}
- (BOOL)_sendDelegateDeleteKeyPressed
{
if ([[self delegate] respondsToSelector: @selector(outlineViewDeleteKeyPressed:)])
{
[[self delegate] outlineViewDeleteKeyPressed:self];
return YES;
}
return NO;
}
/*!
Returns the delegate object for the outlineview.
*/
@@ -1611,6 +1838,33 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
[super keyDown:anEvent];
}
- (BOOL)_sendDelegateDeleteKeyPressed
{
if ([[self delegate] respondsToSelector: @selector(outlineViewDeleteKeyPressed:)])
{
[[self delegate] outlineViewDeleteKeyPressed:self];
return YES;
}
return NO;
}
- (BOOL)_sendDelegateShouldShowOutlineDisclosureControlForItem:(id)anItem
{
if (!(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_))
return YES;
return [_outlineViewDelegate outlineView:self shouldShowOutlineDisclosureControlForItem:anItem];
}
- (BOOL)_sendDataSourceShouldDeferDisplayingChildrenOfItem:(id)anItem
{
if (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_))
return YES;
return [_outlineViewDataSource outlineView:self shouldDeferDisplayingChildrenOfItem:anItem];
}
- (CPView)_sendDelegateViewForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
{
return [_outlineViewDelegate outlineView:self viewForTableColumn:aTableColumn item:[self itemAtRow:aRow]];
@@ -1666,152 +1920,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
@end
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem)
{
if (!anItem)
return;
with (anOutlineView)
{
// Get the existing info if it exists.
var itemInfosForItems = _itemInfosForItems,
dataSource = _outlineViewDataSource,
itemUID = [anItem UID],
itemInfo = itemInfosForItems[itemUID];
// If we're not in the tree, then just bail.
if (!itemInfo)
return [];
// See if the item itself can be swapped out.
var parent = itemInfo.parent,
parentItemInfo = parent ? itemInfosForItems[[parent UID]] : _rootItemInfo,
parentChildren = parentItemInfo.children,
index = [parentChildren indexOfObjectIdenticalTo:anItem],
newItem = [dataSource outlineView:anOutlineView child:index ofItem:parent];
if (anItem !== newItem)
{
itemInfosForItems[[anItem UID]] = nil;
itemInfosForItems[[newItem UID]] = itemInfo;
parentChildren[index] = newItem;
_itemsForRows[itemInfo.row] = newItem;
}
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem];
itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded;
itemInfo.shouldShowOutlineDisclosureControl = !(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_) || [_outlineViewDelegate outlineView:self shouldShowOutlineDisclosureControlForItem:newItem];
}
};
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate)
{
with (anOutlineView)
{
var itemInfosForItems = _itemInfosForItems,
dataSource = _outlineViewDataSource;
if (!anItem)
var itemInfo = _rootItemInfo;
else
{
// Get the existing info if it exists.
var itemUID = [anItem UID],
itemInfo = itemInfosForItems[itemUID];
// If we're not in the tree, then just bail.
if (!itemInfo)
return [];
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem];
itemInfo.shouldShowOutlineDisclosureControl = !(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_) || [_outlineViewDelegate outlineView:self shouldShowOutlineDisclosureControlForItem:anItem];
// If we were previously expanded, but now no longer expandable, "de-expand".
// NOTE: we are *not* collapsing, thus no notification is posted.
if (!itemInfo.isExpandable && itemInfo.isExpanded)
{
itemInfo.isExpanded = NO;
itemInfo.children = [];
}
}
// The root item does not count as a descendant.
var weight = itemInfo.weight,
descendants = anItem ? [anItem] : [];
if (itemInfo.isExpanded && (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_) ||
![dataSource outlineView:anOutlineView shouldDeferDisplayingChildrenOfItem:anItem]))
{
var index = 0,
count = [dataSource outlineView:anOutlineView numberOfChildrenOfItem:anItem],
level = itemInfo.level + 1;
itemInfo.children = [];
for (; index < count; ++index)
{
var childItem = [dataSource outlineView:anOutlineView child:index ofItem:anItem],
childItemInfo = itemInfosForItems[[childItem UID]];
if (!childItemInfo)
{
childItemInfo = { isExpanded:NO, isExpandable:NO, shouldShowOutlineDisclosureControl:YES, children:[], weight:1 };
itemInfosForItems[[childItem UID]] = childItemInfo;
}
itemInfo.children[index] = childItem;
var childDescendants = _loadItemInfoForItem(anOutlineView, childItem, YES);
childItemInfo.parent = anItem;
childItemInfo.level = level;
descendants = descendants.concat(childDescendants);
}
}
itemInfo.weight = descendants.length;
if (!isIntermediate)
{
// row = -1 is the root item, so just go to row 0 since it is ignored.
var index = MAX(itemInfo.row, 0),
itemsForRows = _itemsForRows;
descendants.unshift(index, weight);
itemsForRows.splice.apply(itemsForRows, descendants);
var count = itemsForRows.length;
for (; index < count; ++index)
itemInfosForItems[[itemsForRows[index] UID]].row = index;
var deltaWeight = itemInfo.weight - weight;
if (deltaWeight !== 0)
{
var parent = itemInfo.parent;
while (parent)
{
var parentItemInfo = itemInfosForItems[[parent UID]];
parentItemInfo.weight += deltaWeight;
parent = parentItemInfo.parent;
}
if (anItem)
_rootItemInfo.weight += deltaWeight;
}
}
}//end of with
return descendants;
};
@implementation _CPOutlineViewTableViewDataSource : CPObject
{
CPObject _outlineView;
+14 -31
View File
@@ -26,8 +26,6 @@
@import "CPMenu.j"
@import "CPMenuItem.j"
var VISIBLE_MARGIN = 7.0;
CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
/*!
@@ -773,13 +771,6 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
[[self selectedItem] setState:CPOffState];
}
- (void)_reverseSetBinding
{
[_CPPopUpButtonSelectionBinder reverseSetValueForObject:self];
[super _reverseSetBinding];
}
@end
@implementation CPPopUpButton (BindingSupport)
@@ -802,6 +793,20 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectedIndexBinding ||
aBinding == CPSelectedTagBinding ||
aBinding == CPSelectedValueBinding);
}
- (void)_reverseSetBinding
{
[_CPPopUpButtonSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
[super _reverseSetBinding];
}
@end
@implementation _CPPopUpButtonContentBinder : CPBinder
@@ -931,30 +936,8 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
@end
var binderForObject = {};
@implementation _CPPopUpButtonSelectionBinder : CPBinder
{
CPString _selectionBinding @accessors;
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
binderForObject[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = binderForObject[[aSource UID]];
[binder reverseSetValueFor:[binder _selectionBinding]];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
+13 -7
View File
@@ -246,9 +246,7 @@ Set the behavior of the CPPopover. It can be:
if (!_popoverWindow)
_popoverWindow = [[_CPPopoverWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:[self _styleMaskForBehavior]];
if (_positioningView != positioningView)
[_popoverWindow setPlatformWindow:[[positioningView window] platformWindow]];
[_popoverWindow setPlatformWindow:[[positioningView window] platformWindow]];
[_popoverWindow setAppearance:_appearance];
[_popoverWindow setAnimates:_animates];
[_popoverWindow setDelegate:self];
@@ -262,7 +260,7 @@ Set the behavior of the CPPopover. It can be:
[_popoverWindow positionRelativeToRect:positioningRect ofView:positioningView preferredEdge:preferredEdge];
if (![self isShown])
[self _popoverDidShow];
[self _popoverWindowDidShow];
}
- (unsigned)_styleMaskForBehavior
@@ -312,9 +310,8 @@ Set the behavior of the CPPopover. It can be:
if ([_popoverWindow isClosing])
return;
if (_implementedDelegateMethods & CPPopoverDelegate_popover_shouldClose_)
if (![_delegate popoverShouldClose:self])
return;
if (![self _popoverShouldClose])
return;
[self _close];
}
@@ -348,6 +345,15 @@ Set the behavior of the CPPopover. It can be:
[_delegate popoverDidShow:self];
}
/*! @ignore */
- (BOOL)_popoverShouldClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_shouldClose_)
return [_delegate popoverShouldClose:self];
return YES;
}
/*! @ignore */
- (void)_popoverWillClose
{
+8 -23
View File
@@ -356,7 +356,7 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
[_selectedRadio setState:CPOffState];
_selectedRadio = aRadio;
[_CPRadioGroupSelectionBinder reverseSetValueForObject:self];
[_CPRadioGroupSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
@@ -407,32 +407,17 @@ var CPRadioGroupRadiosKey = @"CPRadioGroupRadiosKey",
return [super _binderClassForBinding:aBinding];
}
@end
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectedIndexBinding ||
aBinding == CPSelectedTagBinding ||
aBinding == CPSelectedValueBinding);
}
var binderForObject = {};
@end
@implementation _CPRadioGroupSelectionBinder : CPBinder
{
CPString _selectionBinding @accessors;
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
binderForObject[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = binderForObject[[aSource UID]];
[binder reverseSetValueFor:[binder _selectionBinding]];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
@@ -708,7 +708,10 @@ CPTransformableAttributeType = 1800;
view = [[CPCheckBox alloc] initWithFrame:CGRectMake(0, 0, 50, 26)];
}
else if (attributeType == CPDateAttributeType)
{
view = [[CPDatePicker alloc] initWithFrame:CGRectMake(0, 0, 180, 26)];
[view setDatePickerElements:CPYearMonthDayDatePickerElementFlag];
}
else
return nil;
+27 -5
View File
@@ -147,8 +147,10 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
@"slice-bottom-border-color": [CPNull null],
@"slice-last-bottom-border-color": [CPNull null],
@"font": [CPNull null],
@"font-color": [CPNull null],
@"add-image": [CPNull null],
@"remove-image": [CPNull null],
@"vertical-alignment": [CPNull null]
};
}
@@ -159,7 +161,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
{
_slices = [[CPMutableArray alloc] init];
_sliceHeight = 26.;
_sliceHeight = 26.0;
_nestingMode = CPRuleEditorNestingModeSimple; // 10.5 default is CPRuleEditorNestingModeCompound
_editable = YES;
_allowsEmptyCompoundRows = NO;
@@ -1885,14 +1887,34 @@ TODO: implement
return [self valueForThemeAttribute:@"font"];
}
- (CPImage)_addImage
- (CPColor)_fontColor
{
return [self valueForThemeAttribute:@"add-image"];
return [self valueForThemeAttribute:@"font-color"];
}
- (CPImage)_removeImage
- (CPImage)_imageAdd
{
return [self valueForThemeAttribute:@"remove-image"];
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateNormal];
}
- (CPImage)_imageAddHighlighted
{
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateHighlighted];
}
- (CPImage)_imageRemove
{
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateNormal];
}
- (CPImage)_imageRemoveHighlighted
{
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateHighlighted];
}
- (CPVerticalTextAlignment)_verticalAlignment
{
return [self valueForThemeAttribute:@"vertical-alignment"];
}
- (CPString)_toolTipForAddCompoundRowButton
@@ -1,203 +0,0 @@
/*
* Created by cacaodev@gmail.com.
* Copyright (c) 2011 Pear, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPBezierPath.j"
@import "CPPopUpButton.j"
@class _CPRuleEditorViewSlice
var GRADIENT_START_COLOR = "#fcfcfc",
GRADIENT_END_COLOR = "#dfdfdf",
BORDER_COLOR = "#BDBDBD";
var GRADIENT_NORMAL,
GRADIENT_HIGHLIGHTED,
GRADIENT_PROPERTY;
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
{
GRADIENT_NORMAL = "-webkit-gradient(linear, left top, left bottom, from(" + GRADIENT_START_COLOR + "), to(" + GRADIENT_END_COLOR + "))",
GRADIENT_HIGHLIGHTED = "-webkit-gradient(linear, left top, left bottom, from(" + GRADIENT_END_COLOR + "), to(" + GRADIENT_START_COLOR + "))";
GRADIENT_PROPERTY = "background";
}
else if (CPBrowserIsEngine(CPGeckoBrowserEngine))
{
GRADIENT_NORMAL = "-moz-linear-gradient(top, " + GRADIENT_START_COLOR + ", " + GRADIENT_END_COLOR + ")",
GRADIENT_HIGHLIGHTED = "-moz-linear-gradient(top, " + GRADIENT_END_COLOR + ", " + GRADIENT_START_COLOR + ")";
GRADIENT_PROPERTY = "background";
}
else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
GRADIENT_NORMAL = "progid:DXImageTransform.Microsoft.gradient(startColorstr='" + GRADIENT_START_COLOR + "', endColorstr='" + GRADIENT_END_COLOR + "')";
GRADIENT_HIGHLIGHTED = "progid:DXImageTransform.Microsoft.gradient(startColorstr='" + GRADIENT_END_COLOR + "', endColorstr='" + GRADIENT_START_COLOR + "')";
GRADIENT_PROPERTY = "filter";
}else
{
GRADIENT_NORMAL = GRADIENT_START_COLOR;
GRADIENT_HIGHLIGHTED = GRADIENT_END_COLOR;
GRADIENT_PROPERTY = "background";
}
@implementation _CPRuleEditorPopUpButton : CPPopUpButton
{
CPInteger radius;
}
- (void)_sharedInit
{
[self setBordered:NO];
#if PLATFORM(DOM)
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
[self _sharedInit];
return self;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
[self _sharedInit];
return self;
}
- (CPView)hitTest:(CGPoint)point
{
if (!CGRectContainsPoint([self frame], point) || ![self sliceIsEditable])
return nil;
return self;
}
- (BOOL)sliceIsEditable
{
var superview = [self superview];
return ![superview isKindOfClass:[_CPRuleEditorViewSlice]] || [superview isEditable];
}
- (void)trackMouse:(CPEvent)theEvent
{
if (![self sliceIsEditable])
return;
[super trackMouse:theEvent];
}
- (CGRect)contentRectForBounds:(CGRect)bounds
{
var contentRect = [super contentRectForBounds:bounds];
contentRect.origin.x += radius;
contentRect.size.width -= 2 * radius;
return contentRect;
}
- (void)layoutSubviews
{
#if PLATFORM(DOM)
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
style.borderRadius = radiusCSS;
#endif
[super layoutSubviews];
}
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds],
arrow_width = FLOOR(CGRectGetHeight(bounds) / 3.5);
CGContextTranslateCTM(context, CGRectGetWidth(bounds) - radius - arrow_width, CGRectGetHeight(bounds) / 2);
var arrowsPath = [CPBezierPath bezierPath];
[arrowsPath moveToPoint:CGPointMake(0, 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width, 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width / 2, arrow_width + 1)];
[arrowsPath closePath];
CGContextSetFillColor(context, [CPColor colorWithWhite:101 / 255 alpha:1]);
[arrowsPath fill];
CGContextScaleCTM(context, 1 , -1);
[arrowsPath fill];
}
@end
@implementation _CPRuleEditorButton : CPButton
{
CPInteger radius;
}
- (void)_sharedInit
{
[self setBordered:NO];
#if PLATFORM(DOM)
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
[self _sharedInit];
return self;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
[self _sharedInit];
return self;
}
- (void)layoutSubviews
{
#if PLATFORM(DOM)
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
style.borderRadius = radiusCSS;
style[GRADIENT_PROPERTY] = ([self isHighlighted]) ? GRADIENT_HIGHLIGHTED : GRADIENT_NORMAL;
#endif
[super layoutSubviews];
}
@end
+3 -3
View File
@@ -61,9 +61,9 @@
- (void)drawRect:(CGRect)rect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds],
maxX = CGRectGetWidth(bounds),
maxY = CGRectGetHeight(bounds);
bounds = [self bounds],
maxX = CGRectGetWidth(bounds),
maxY = CGRectGetHeight(bounds);
// Draw background
if ([self _isSelected])
+90 -86
View File
@@ -19,24 +19,27 @@
@import "CPRuleEditor_Constants.j"
@import "_CPRuleEditorViewSlice.j"
@import "_CPRuleEditorPopUpButton.j"
@import "CPButton.j"
@import "CPDatePicker.j"
@import "CPPopUpButton.j"
@global CPApp
var CONTROL_HEIGHT = 16.,
BUTTON_HEIGHT = 16.;
@global CPMiniControlSize
@global CPSmallControlSize
@implementation _CPRuleEditorViewSliceRow : _CPRuleEditorViewSlice
{
CPMutableArray _ruleOptionViews;
CPMutableArray _ruleOptionFrames;
CPMutableArray _correspondingRuleItems;
CPMutableArray _ruleOptionInitialViewFrames;
CPButton _addButton;
CPButton _subtractButton;
CPButton _addButton;
CPButton _subtractButton;
CPMutableArray _correspondingRuleItems;
CPMutableArray _ruleOptionFrames;
CPMutableArray _ruleOptionInitialViewFrames;
CPMutableArray _ruleOptionViews;
CPRuleEditorRowType _rowType @accessors;
CPRuleEditorRowType _plusButtonRowType;
CPRuleEditorRowType _rowType @accessors;
CPRuleEditorRowType _plusButtonRowType;
}
- (id)initWithFrame:(CGRect)frame ruleEditorView:(id)editor
@@ -49,34 +52,33 @@ var CONTROL_HEIGHT = 16.,
- (void)_initShared
{
_correspondingRuleItems = [[CPMutableArray alloc] init];
_ruleOptionFrames = [[CPMutableArray alloc] init];
_ruleOptionInitialViewFrames = [[CPMutableArray alloc] init];
_ruleOptionViews = [[CPMutableArray alloc] init];
_editable = [_ruleEditor isEditable];
_correspondingRuleItems = [[CPMutableArray alloc] init];
_ruleOptionFrames = [[CPMutableArray alloc] init];
_ruleOptionInitialViewFrames = [[CPMutableArray alloc] init];
_ruleOptionViews = [[CPMutableArray alloc] init];
_editable = [_ruleEditor isEditable];
_addButton = [self _createAddRowButton];
_subtractButton = [self _createDeleteRowButton];
_addButton = [self _createAddRowButton];
_subtractButton = [self _createDeleteRowButton];
[_addButton setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
[_subtractButton setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
[_addButton setHidden:!_editable];
[_subtractButton setHidden:!_editable];
[self addSubview:_addButton];
[self addSubview:_subtractButton];
[self setAutoresizingMask:CPViewWidthSizable];
var center = [CPNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(_textDidChange:) name:CPControlTextDidChangeNotification object:nil];
}
- (CPButton)_createRowButton
{
var button = [[_CPRuleEditorButton alloc] initWithFrame:CGRectMakeZero()];
[button setFont:[CPFont boldFontWithName:@"Apple Symbol" size:12.0]];
[button setTextColor:[CPColor colorWithWhite:150 / 255 alpha:1]];
var button = [[CPButton alloc] initWithFrame:CGRectMakeZero()];
[button setFont:[_ruleEditor font]];
[button setTextColor:[_ruleEditor _fontColor]];
[button setAlignment:CPCenterTextAlignment];
[button setAutoresizingMask:CPViewMinXMargin];
[button setButtonType:CPMomentaryChangeButton];
[button setBordered:NO];
[button setHidden:!_editable];
[button setImagePosition:CPImageOnly];
return button;
@@ -86,7 +88,10 @@ var CONTROL_HEIGHT = 16.,
{
var button = [self _createRowButton];
[button setImage:[_ruleEditor _addImage]];
[button setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
[button setValue:[_ruleEditor _imageAdd] forThemeAttribute:@"image" inState:CPThemeStateNormal];
[button setValue:[_ruleEditor _imageAddHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
[button setAction:@selector(_addOption:)];
[button setTarget:self];
@@ -97,7 +102,10 @@ var CONTROL_HEIGHT = 16.,
{
var button = [self _createRowButton];
[button setImage:[_ruleEditor _removeImage]];
[button setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
[button setValue:[_ruleEditor _imageRemove] forThemeAttribute:@"image" inState:CPThemeStateNormal];
[button setValue:[_ruleEditor _imageRemoveHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
[button setAction:@selector(_deleteOption:)];
[button setTarget:self];
@@ -107,20 +115,17 @@ var CONTROL_HEIGHT = 16.,
- (CPMenuItem)_createMenuItemWithTitle:(CPString )title
{
title = [[_ruleEditor standardLocalizer] localizedStringForString:title];
var mItem = [[CPMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
return mItem;
return [[CPMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
}
- (CPPopUpButton)_createPopUpButtonWithItems:(CPArray)itemsArray selectedItemIndex:(int)index
{
var title = [[itemsArray objectAtIndex:index] title],
font = [_ruleEditor font],
width = [title sizeWithFont:font].width + 20,
rect = CGRectMake(0, 0, (width - width % 40) + 80, CONTROL_HEIGHT),
var title = [[itemsArray objectAtIndex:index] title],
font = [_ruleEditor font],
width = [title sizeWithFont:font].width + 20,
rect = CGRectMake(0, 0, (width - width % 40) + 80, [_ruleEditor rowHeight]),
popup = [[CPPopUpButton alloc] initWithFrame:rect];
popup = [[_CPRuleEditorPopUpButton alloc] initWithFrame:rect];
[popup setTextColor:[CPColor colorWithWhite:101 / 255 alpha:1]];
[popup setValue:font forThemeAttribute:@"font"];
var count = [itemsArray count];
@@ -137,17 +142,17 @@ var CONTROL_HEIGHT = 16.,
return [CPMenuItem separatorItem];
}
- (_CPRuleEditorTextField)_createStaticTextFieldWithStringValue:(CPString)text
- (CPTextField)_createStaticTextFieldWithStringValue:(CPString)text
{
var textField = [[_CPRuleEditorTextField alloc] initWithFrame:CGRectMakeZero()],
ruleEditorFont = [_ruleEditor font],
font = [CPFont fontWithName:[ruleEditorFont familyName] size:[ruleEditorFont size] + 2],
localizedText = [[_ruleEditor standardLocalizer] localizedStringForString:text],
size = [localizedText sizeWithFont:font];
[textField setFrameSize:CGSizeMake(size.width + 4, CONTROL_HEIGHT + 2)];
var textField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()],
ruleEditorFont = [_ruleEditor font],
font = [CPFont fontWithName:[ruleEditorFont familyName] size:[ruleEditorFont size] + 2],
localizedText = [[_ruleEditor standardLocalizer] localizedStringForString:text],
size = [localizedText sizeWithFont:font];
[textField setFrameSize:CGSizeMake(size.width + 4, [_ruleEditor rowHeight])];
[textField setValue:font forThemeAttribute:@"font"];
[textField setValue:[_ruleEditor _verticalAlignment] forThemeAttribute:@"vertical-alignment"];
[textField setStringValue:localizedText];
return textField;
@@ -159,6 +164,7 @@ var CONTROL_HEIGHT = 16.,
[self setNeedsDisplay:YES];
var type = _plusButtonRowType;
if ([_ruleEditor nestingMode] == CPRuleEditorNestingModeCompound && ([[CPApp currentEvent] modifierFlags] & CPAlternateKeyMask))
type = CPRuleEditorRowTypeCompound;
@@ -170,12 +176,12 @@ var CONTROL_HEIGHT = 16.,
[_ruleEditor _deleteSlice:self];
}
- (void)_ruleOptionPopupChangedAction:(CPMenuItem )sender
- (void)_ruleOptionPopupChangedAction:(CPMenuItem)sender
{
var layoutdict = [sender representedObject],
newItem = [layoutdict objectForKey:@"item"],
var layoutdict = [sender representedObject],
newItem = [layoutdict objectForKey:@"item"],
indexInCriteria = [layoutdict objectForKey:@"indexInCriteria"],
oldItem = [_correspondingRuleItems objectAtIndex:indexInCriteria];
oldItem = [_correspondingRuleItems objectAtIndex:indexInCriteria];
if (![newItem isEqual:oldItem])
{
@@ -307,6 +313,8 @@ var CONTROL_HEIGHT = 16.,
if (ruleView != nil)
{
[ruleView setControlSize:CPSmallControlSize];
[_ruleOptionViews addObject:ruleView];
var frame = [ruleView frame];
[_ruleOptionInitialViewFrames addObject:frame];
@@ -331,8 +339,6 @@ var CONTROL_HEIGHT = 16.,
var aView = [_ruleOptionViews objectAtIndex:firstResponderIndex];
[[self window] makeFirstResponder:aView]; // This is not working. bug in CPPopUpButton firstResponder ?
}
//[self setNeedsDisplay:YES];
}
- (void)_updateEnabledStateForSubviews
@@ -350,14 +356,15 @@ var CONTROL_HEIGHT = 16.,
var optionViewOriginX,
leftHorizontalPadding,
leftButtonMinX,
rowHeight = [_ruleEditor rowHeight],
count = [_ruleOptionViews count],
sliceFrame = [self frame],
rowHeight = [_ruleEditor rowHeight],
count = [_ruleOptionViews count],
sliceFrame = [self frame],
image = [_ruleEditor _imageAdd],
buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - BUTTON_HEIGHT - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - BUTTON_HEIGHT) / 2 - 2, BUTTON_HEIGHT, BUTTON_HEIGHT);
buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - [image size].width - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - [image size].height) / 2 - 1, [image size].width, [image size].height);
[_addButton setFrame:buttonFrame];
buttonFrame.origin.x -= BUTTON_HEIGHT + [self _rowButtonsInterviewHorizontalPadding];
buttonFrame.origin.x -= [image size].width + [self _rowButtonsInterviewHorizontalPadding];
[_subtractButton setFrame:buttonFrame];
if (widthChanged)
@@ -372,7 +379,8 @@ var CONTROL_HEIGHT = 16.,
var ruleOptionView = _ruleOptionViews[i],
optionFrame = _ruleOptionFrames[i];
optionFrame.origin.y = (rowHeight - CGRectGetHeight(optionFrame)) / 2 - 2;
// Use a pixel correction to align controls
optionFrame.origin.y = (rowHeight - CGRectGetHeight(optionFrame)) / 2;
if (widthChanged)
{
@@ -481,6 +489,26 @@ var CONTROL_HEIGHT = 16.,
[self layoutSubviews];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_textDidChange:) name:CPControlTextDidChangeNotification object:nil];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:nil];
}
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
@@ -488,8 +516,9 @@ var CONTROL_HEIGHT = 16.,
- (BOOL)_isRulePopup:(CPView)view
{
if ([view isKindOfClass:[_CPRuleEditorPopUpButton class]])
if ([view isKindOfClass:[CPPopUpButton class]])
return YES;
return NO;
}
@@ -506,28 +535,3 @@ var CONTROL_HEIGHT = 16.,
}
@end
@implementation _CPRuleEditorTextField : CPTextField
{
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[self setDrawsBackground:NO];
}
return self;
}
- (CPView)hitTest:(CGPoint)point
{
if (!CGRectContainsPoint([self frame], point))
return nil;
return [self superview];
}
@end
+10 -1
View File
@@ -1403,7 +1403,16 @@ Notifies the delegate when the scroll view has finished scrolling.
if (![_horizontalScroller isHidden] || ![_verticalScroller isHidden])
_timerScrollersHide = [CPTimer scheduledTimerWithTimeInterval:CPScrollViewFadeOutTime target:self selector:@selector(_hideScrollers:) userInfo:nil repeats:NO];
[self _respondToScrollWheelEventWithDeltaX:[anEvent deltaX] deltaY:[anEvent deltaY]];
var deltaX = [anEvent scrollingDeltaX],
deltaY = [anEvent scrollingDeltaY];
if (![anEvent hasPreciseScrollingDeltas])
{
deltaX *= (_horizontalLineScroll || 1.0);
deltaY *= (_verticalLineScroll || 1.0);
}
[self _respondToScrollWheelEventWithDeltaX:deltaX deltaY:deltaY];
}
- (void)scrollPageUp:(id)sender
+1 -32
View File
@@ -78,7 +78,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
@implementation CPScroller : CPControl
{
CPControlSize _controlSize;
CPUsableScrollerParts _usableParts;
CPArray _partRects;
@@ -172,7 +171,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
{
if (self = [super initWithFrame:aFrame])
{
_controlSize = CPRegularControlSize;
_partRects = [];
[self setFloatValue:0.0];
@@ -243,29 +241,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
[super setObjectValue:MIN(1.0, MAX(0.0, +aValue))];
}
/*!
Returns the scroller's control size
*/
- (CPControlSize)controlSize
{
return _controlSize;
}
/*!
Sets the scroller's size.
@param aControlSize the scroller's size
*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if (_controlSize == aControlSize)
return;
_controlSize = aControlSize;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
/*!
Return's the knob's proportion
*/
@@ -802,8 +777,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
@end
var CPScrollerControlSizeKey = @"CPScrollerControlSize",
CPScrollerIsVerticalKey = @"CPScrollerIsVerticalKey",
var CPScrollerIsVerticalKey = @"CPScrollerIsVerticalKey",
CPScrollerKnobProportionKey = @"CPScrollerKnobProportion",
CPScrollerStyleKey = @"CPScrollerStyleKey";
@@ -813,10 +787,6 @@ var CPScrollerControlSizeKey = @"CPScrollerControlSize",
{
if (self = [super initWithCoder:aCoder])
{
_controlSize = CPRegularControlSize;
if ([aCoder containsValueForKey:CPScrollerControlSizeKey])
_controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey];
_knobProportion = 1.0;
if ([aCoder containsValueForKey:CPScrollerKnobProportionKey])
@@ -851,7 +821,6 @@ var CPScrollerControlSizeKey = @"CPScrollerControlSize",
{
[super encodeWithCoder:aCoder];
[aCoder encodeInt:_controlSize forKey:CPScrollerControlSizeKey];
[aCoder encodeInt:_isVertical forKey:CPScrollerIsVerticalKey];
[aCoder encodeFloat:_knobProportion forKey:CPScrollerKnobProportionKey];
[aCoder encodeInt:_style forKey:CPScrollerStyleKey];
+18 -6
View File
@@ -119,16 +119,28 @@ var RECENT_SEARCH_PREFIX = @" ";
_canResignFirstResponder = YES;
}
- (void)viewWillMoveToSuperview:(CPView)aView
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
[super viewWillMoveToSuperview:aView];
if (!_isObserving)
return;
[super _removeObservers];
// First we remove any observer that may have been in place to avoid memory leakage.
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:self];
}
// Register the observe here if we need to.
if (aView)
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
}
// Managing Buttons
+95 -56
View File
@@ -70,23 +70,9 @@ CPSegmentSwitchTrackingMomentary = 2;
@"center-segment-bezel-color": [CPNull null],
@"divider-bezel-color": [CPNull null],
@"divider-thickness": 1.0,
@"default-height": 24.0,
};
}
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([self _isSelectionBinding:aBinding])
return [_CPSegmentedControlBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)_isSelectionBinding:(CPString)aBinding
{
return (aBinding === CPSelectedIndexBinding || aBinding === CPSelectedLabelBinding || aBinding === CPSelectedTagBinding);
}
- (id)initWithFrame:(CGRect)aRect
{
_segments = [];
@@ -104,17 +90,14 @@ CPSegmentSwitchTrackingMomentary = 2;
return self;
}
- (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
/*!
Sets the control's size.
@param aControlSize the control's size
*/
- (void)setControlSize:(CPControlSize)aControlSize
{
if ([[self class] _isSelectionBinding:aBinding] && _trackingMode !== CPSegmentSwitchTrackingSelectOne)
CPLog.warn("Binding " + aBinding + " needs CPSegmentSwitchTrackingSelectOne tracking mode");
else
[super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
}
- (void)_reverseSetBinding
{
[_CPSegmentedControlBinder reverseSetValueForObject:self];
[super setControlSize:aControlSize];
[self _sizeToControlSize];
}
/*!
@@ -512,7 +495,7 @@ CPSegmentSwitchTrackingMomentary = 2;
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
{
var height = [self currentValueForThemeAttribute:@"default-height"],
var height = [self currentValueForThemeAttribute:@"min-size"].height,
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"],
bounds = [self bounds];
@@ -577,10 +560,17 @@ CPSegmentSwitchTrackingMomentary = 2;
return;
var themeState = _themeStates[0],
isDisabled = [self hasThemeState:CPThemeStateDisabled];
isDisabled = [self hasThemeState:CPThemeStateDisabled],
isControlSizeSmall = [self hasThemeState:CPThemeStateControlSizeSmall],
isControlSizeMini = [self hasThemeState:CPThemeStateControlSizeMini];
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
if (isControlSizeSmall)
themeState = themeState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
themeState = themeState.and(CPThemeStateControlSizeMini);
var leftCapColor = [self valueForThemeAttribute:@"left-segment-bezel-color"
inState:themeState],
@@ -594,6 +584,11 @@ CPSegmentSwitchTrackingMomentary = 2;
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
if (isControlSizeSmall)
themeState = themeState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
themeState = themeState.and(CPThemeStateControlSizeMini);
var rightCapColor = [self valueForThemeAttribute:@"right-segment-bezel-color"
inState:themeState],
@@ -609,6 +604,11 @@ CPSegmentSwitchTrackingMomentary = 2;
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
if (isControlSizeSmall)
themeState = themeState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
themeState = themeState.and(CPThemeStateControlSizeMini);
var bezelColor = [self valueForThemeAttribute:@"center-segment-bezel-color"
inState:themeState],
@@ -618,7 +618,6 @@ CPSegmentSwitchTrackingMomentary = 2;
[bezelView setBackgroundColor:bezelColor];
// layout image/title views
var segment = _segments[i],
contentView = [self layoutEphemeralSubviewNamed:@"segment-content-" + i
@@ -651,6 +650,11 @@ CPSegmentSwitchTrackingMomentary = 2;
borderState = isDisabled ? borderState.and(CPThemeStateDisabled) : borderState;
if (isControlSizeSmall)
borderState = borderState.and(CPThemeStateControlSizeSmall);
else if (isControlSizeMini)
borderState = borderState.and(CPThemeStateControlSizeMini);
var borderColor = [self valueForThemeAttribute:@"divider-bezel-color"
inState:borderState],
@@ -707,7 +711,6 @@ CPSegmentSwitchTrackingMomentary = 2;
// Update control size
var frame = [self frame];
[self setFrameSize:CGSizeMake(CGRectGetWidth(frame) + delta, CGRectGetHeight(frame))];
// Update segment width
@@ -743,7 +746,7 @@ CPSegmentSwitchTrackingMomentary = 2;
- (CGRect)bezelFrameForSegment:(unsigned)aSegment
{
var height = [self currentValueForThemeAttribute:@"default-height"],
var height = [self currentValueForThemeAttribute:@"min-size"].height,
bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"],
width = [self widthForSegment:aSegment],
left = [self _leftOffsetForSegment:aSegment];
@@ -753,7 +756,7 @@ CPSegmentSwitchTrackingMomentary = 2;
- (CGRect)contentFrameForSegment:(unsigned)aSegment
{
var height = [self currentValueForThemeAttribute:@"default-height"],
var height = [self currentValueForThemeAttribute:@"min-size"].height,
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
width = [self widthForSegment:aSegment],
left = [self _leftOffsetForSegment:aSegment];
@@ -915,8 +918,7 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
else
_trackingMode = CPSegmentSwitchTrackingSelectOne;
// HACK
// Here we update the themeStates array for each segments to know if there are selected or not
for (var i = 0; i < _segments.length; i++)
_themeStates[i] = [_segments[i] selected] ? CPThemeStateSelected : CPThemeStateNormal;
@@ -924,12 +926,32 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
for (var i = 0; i < _segments.length; i++)
[self tileWithChangedSegment:i];
var difference = MAX(originalWidth - [self frame].size.width, 0.0),
remainingWidth = FLOOR(difference / _segments.length);
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"],
dividerExtraSpace = ([_segments count] - 1) * thickness,
difference = MAX(originalWidth - [self frame].size.width - dividerExtraSpace, 0.0),
remainingWidth = FLOOR(difference / _segments.length),
widthOfAllSegments = 0;
for (var i = 0; i < _segments.length; i++)
{
[self setWidth:[_segments[i] width] + remainingWidth forSegment:i];
widthOfAllSegments += [_segments[i] width];
}
// Here we handle the leftovers pixel, and we will add one pixel to each segment cell till we have the same size as the originalSize.
// This is needed to have a perfect/same alignment between our application and xCode.
var leftOversPixel = originalWidth - (widthOfAllSegments + dividerExtraSpace);
// Make sure we don't make an out of range
if (leftOversPixel < _segments.length - 1)
{
for (var i = 0; i < leftOversPixel; i++)
{
[self setWidth:[_segments[i] width] + 1 forSegment:i];
}
}
[self setFrameSize:CGSizeMake(originalWidth, [self frame].size.height)];
[self tileWithChangedSegment:0];
}
@@ -948,31 +970,48 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
@end
var CPSegmentedControlBindersMap = {},
CPSegmentedControlNoSelectionPlaceholder = "CPSegmentedControlNoSelectionPlaceholder";
@implementation CPSegmentedControl (BindingSupport)
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([self _isSelectionBinding:aBinding])
return [_CPSegmentedControlBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)_isSelectionBinding:(CPString)aBinding
{
return (aBinding === CPSelectedIndexBinding || aBinding === CPSelectedLabelBinding || aBinding === CPSelectedTagBinding);
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return [self _isSelectionBinding:aBinding];
}
- (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
{
if ([[self class] _isSelectionBinding:aBinding] && _trackingMode !== CPSegmentSwitchTrackingSelectOne)
{
CPLog.warn("Binding " + aBinding + " needs CPSegmentSwitchTrackingSelectOne tracking mode");
return;
}
[super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
}
- (void)_reverseSetBinding
{
[_CPSegmentedControlBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
var CPSegmentedControlNoSelectionPlaceholder = "CPSegmentedControlNoSelectionPlaceholder";
@implementation _CPSegmentedControlBinder : CPBinder
{
CPString _selectionBinding @accessors(readonly, getter=selectionBinding);
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = CPSegmentedControlBindersMap[[aSource UID]];
[binder reverseSetValueFor:[binder selectionBinding]];
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
CPSegmentedControlBindersMap[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
+21 -13
View File
@@ -138,9 +138,16 @@
[self setContinuous:_autorepeat];
[self addSubview:_buttonDown];
[self _sizeToFit];
[self setNeedsLayout];
}
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
[self _sizeToFit];
}
#pragma mark -
#pragma mark Superclass overrides
@@ -159,8 +166,8 @@
- (void)setFrame:(CGRect)aFrame
{
var upSize = [self valueForThemeAttribute:@"up-button-size"],
downSize = [self valueForThemeAttribute:@"down-button-size"],
var upSize = [self currentValueForThemeAttribute:@"up-button-size"],
downSize = [self currentValueForThemeAttribute:@"down-button-size"],
minSize = CGSizeMake(upSize.width, upSize.height + downSize.height),
frame = CGRectMakeCopy(aFrame);
@@ -172,21 +179,22 @@
/*! @ignore */
- (void)layoutSubviews
{
var aFrame = [self frame],
upSize = [self valueForThemeAttribute:@"up-button-size"],
downSize = [self valueForThemeAttribute:@"down-button-size"],
upFrame = CGRectMake(aFrame.size.width - upSize.width, 0, upSize.width, upSize.height),
downFrame = CGRectMake(aFrame.size.width - downSize.width, upSize.height, downSize.width, downSize.height);
var controlSizeThemeState = [self _controlSizeThemeState],
aFrame = [self frame],
upSize = [self valueForThemeAttribute:@"up-button-size" inState:controlSizeThemeState],
downSize = [self valueForThemeAttribute:@"down-button-size" inState:controlSizeThemeState],
upFrame = CGRectMake(0, 0, upSize.width, upSize.height),
downFrame = CGRectMake(0, upSize.height, downSize.width, downSize.height);
[_buttonUp setFrame:upFrame];
[_buttonDown setFrame:downFrame];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[controlSizeThemeState, CPThemeStateBordered]] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[controlSizeThemeState, CPThemeStateBordered]] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[controlSizeThemeState, CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
}
- (void)_sizeToFit
+1 -1
View File
@@ -94,7 +94,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
_tabs = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[_tabs setHitTests:NO];
var height = [_tabs valueForThemeAttribute:@"default-height"];
var height = [_tabs valueForThemeAttribute:@"min-size"].height;
[_tabs setFrameSize:CGSizeMake(0, height)];
_box = [[CPBox alloc] initWithFrame:[self bounds]];
+35 -4
View File
@@ -473,8 +473,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (!_sortDescriptors)
_sortDescriptors = [];
[self _startObservingFirstResponder];
}
/*!
@@ -964,7 +962,7 @@ NOT YET IMPLEMENTED
</pre>
*/
- (void)unfocusedSelectionGradientColors
- (CPColor)unfocusedSelectionGradientColors
{
if (!_unfocusedSourceListSelectionColor)
{
@@ -3950,6 +3948,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
// FIXME: yuck!
var identifier = [aDataView identifier];
if ([aDataView hasThemeState:CPThemeStateSelectedDataView])
[aDataView unsetThemeState:CPThemeStateSelectedDataView];
if (!_cachedDataViews[identifier])
_cachedDataViews[identifier] = [aDataView];
else
@@ -4453,6 +4454,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
*/
- (void)viewWillMoveToSuperview:(CPView)aView
{
[super viewWillMoveToSuperview:aView];
var superview = [self superview],
defaultCenter = [CPNotificationCenter defaultCenter];
@@ -5120,11 +5123,34 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
var hit = [super hitTest:aPoint];
if ([[CPApp currentEvent] type] == CPLeftMouseDown && [hit acceptsFirstResponder] && ![self isRowSelected:[self rowForView:hit]])
{
if (_selectionHighlightStyle == CPTableViewSelectionHighlightStyleNone)
return hit;
return self;
}
return hit;
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _stopObservingFirstResponder];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _startObservingFirstResponder];
}
- (void)_startObservingFirstResponder
{
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_firstResponderDidChange:) name:_CPWindowDidChangeFirstResponderNotification object:[self window]];
@@ -5156,7 +5182,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
// This makes sure the theming effects of a focused table remain in effect even as cells are being edited in it.
[self _notifyViewDidBecomeFirstResponder];
if (_editingRow !== CPNotFound && [responder isKindOfClass:[CPTextField class]] && ![responder isBezeled])
if (_editingRow !== CPNotFound && [responder isKindOfClass:[CPTextField class]] && ![responder isBezeled] && [responder isEditable])
{
[responder setBezeled:YES];
[self _registerForEndEditingNote:responder];
@@ -6004,6 +6030,11 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
{
[super encodeWithCoder:aCoder];
// We do this in order to avoid encoding the _tableDrawView, which
// should just automatically be created programmatically as needed.
if (_tableDrawView)
[_tableDrawView removeFromSuperview];
[aCoder encodeObject:_dataSource forKey:CPTableViewDataSourceKey];
[aCoder encodeObject:_delegate forKey:CPTableViewDelegateKey];
+101 -36
View File
@@ -31,6 +31,7 @@
@global CPApp
@global CPStringPboardType
@global CPCursor
@protocol CPTextFieldDelegate <CPControlTextEditingDelegate>
@@ -126,6 +127,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
BOOL _isSelectable;
BOOL _isSecure;
BOOL _willBecomeFirstResponderByClick;
BOOL _invokedByUserEvent;
BOOL _drawsBackground;
@@ -140,7 +142,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
// NS-style Display Properties
CPTextFieldBezelStyle _bezelStyle;
BOOL _isBordered;
CPControlSize _controlSize;
}
+ (Class)_binderClassForBinding:(CPString)aBinding
@@ -227,6 +228,21 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
};
}
#pragma mark -
#pragma mark Control Size
- (void)setControlSize:(CPControlSize)aControlSize
{
[super setControlSize:aControlSize];
if ([self isBezeled])
[self _sizeToControlSize];
}
#pragma mark -
#if PLATFORM(DOM)
- (DOMElement)_inputElement
{
@@ -334,6 +350,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
_sendActionOn = CPKeyUpMask | CPKeyDownMask;
[self setValue:CPLeftTextAlignment forThemeAttribute:@"alignment"];
[self _updateCursor];
}
return self;
@@ -355,6 +373,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (shouldBeEditable)
_isSelectable = YES;
[self _updateCursor];
if (_isEditable)
[self setThemeState:CPThemeStateEditable];
else
@@ -385,6 +405,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
- (void)setEnabled:(BOOL)shouldBeEnabled
{
[super setEnabled:shouldBeEnabled];
[self _updateCursor];
// We only allow first responder status if the field is enabled.
if (!shouldBeEnabled && [[self window] firstResponder] === self)
@@ -398,6 +419,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
- (void)setSelectable:(BOOL)aFlag
{
_isSelectable = aFlag;
[self _updateCursor];
}
/*!
@@ -819,6 +842,26 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
}
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _setObserveWindowKeyNotifications:NO];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
if ([self window] === self)
[self _setObserveWindowKeyNotifications:YES];
}
- (void)_windowDidResignKey:(CPNotification)aNotification
{
if (![[self window] isKeyWindow])
@@ -957,7 +1000,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (newValue !== _stringValue)
{
[self _setStringValue:newValue];
[self _didEdit];
}
@@ -967,13 +1009,20 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
- (void)keyDown:(CPEvent)anEvent
{
if (!([self isEnabled] && [self isEditable]))
return;
// CPTextField uses an HTML input element to take the input so we need to
// propagate the dom event so the element is updated. This has to be done
// before interpretKeyEvents: though so individual commands have a chance
// to override this (escape to clear the text in a search field for example).
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
// Set a flag so that key handling methods (such as deleteBackward:)
// know they were invoked from a user event.
_invokedByUserEvent = !!anEvent._DOMEvent;
[self interpretKeyEvents:[anEvent]];
_invokedByUserEvent = NO;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
@@ -1091,6 +1140,22 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[super textDidChange:note];
}
- (void)_updateCursor
{
if ([self isEnabled] && ([self isSelectable] || [self isEditable]))
{
#if PLATFORM(DOM)
self._DOMElement.style.cursor = "text";
#endif
}
else
{
#if PLATFORM(DOM)
self._DOMElement.style.cursor = "default";
#endif
}
}
/*!
Returns the string in the text field.
*/
@@ -1147,12 +1212,17 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
}
- (void)setObjectValue:(id)aValue
{
[self _setObjectValue:aValue useFormatter:YES];
}
- (void)_setObjectValue:(id)aValue useFormatter:(BOOL)useFormatter
{
[super setObjectValue:aValue];
var formatter = [self formatter];
if (formatter)
if (useFormatter && formatter)
{
// If there is a formatter, make sure the object value can be formatted successfully
var formattedString = [self hasThemeState:CPThemeStateEditing] ? [formatter editingStringForObjectValue:aValue] : [formatter stringForObjectValue:aValue];
@@ -1537,7 +1607,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
var selectedRange = [self selectedRange];
if (selectedRange.length < 1)
if (selectedRange.length === 0)
{
if (selectedRange.location < 1)
return;
@@ -1547,19 +1617,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
selectedRange.length += 1;
}
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
[self setStringValue:newValue];
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
[self _didEdit];
#if PLATFORM(DOM)
// Since we just performed the deletion manually, we don't need the browser to do anything else.
// (Previously we would allow the event to propagate for the browser to delete 1 character only,
// and we'd delete the rest manually. But this meant that if deleteBackward: was called without
// it being a browser backspace event, 1 character would be left behind.)
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
#endif
[self _replaceCharactersInRange:selectedRange withCharacters:@""];
}
- (void)delete:(id)sender
@@ -1573,16 +1631,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (selectedRange.length < 1)
return;
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
[self setStringValue:newValue];
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
[self _didEdit];
#if PLATFORM(DOM)
// Since we just performed the deletion manually, we don't need the browser to do anything else.
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
#endif
[self _replaceCharactersInRange:selectedRange withCharacters:@""];
}
- (void)deleteForward:(id)sender
@@ -1592,24 +1641,38 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
var selectedRange = [self selectedRange];
if (selectedRange.length < 1)
if (selectedRange.length === 0)
{
if (selectedRange.location + 1 >= _stringValue.length)
if (selectedRange.location >= _stringValue.length)
return;
// Delete a single element forward from the insertion point if there's no selection.
selectedRange.length += 1;
}
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
[self _replaceCharactersInRange:selectedRange withCharacters:@""];
}
[self setStringValue:newValue];
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
[self _didEdit];
- (void)_replaceCharactersInRange:(CPRange)range withCharacters:(CPString)characters
{
var newValue = [_stringValue stringByReplacingCharactersInRange:range withString:characters];
if (_invokedByUserEvent)
{
[self _setStringValue:newValue];
}
else
{
[self _setObjectValue:newValue useFormatter:NO];
[self setSelectedRange:CPMakeRange(range.location, 0)];
#if PLATFORM(DOM)
// Since we just performed the deletion manually, we don't need the browser to do anything else.
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
// Since we just performed the deletion manually, we don't need the browser to do anything else.
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
#endif
}
[self _didEdit];
}
#pragma mark Setting the Delegate
@@ -1845,7 +1908,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (!wind)
return NO;
var frame = [self convertRectToBase:[self bounds]],
var frame = [self convertRectToBase:[self contentRectForBounds:[self bounds]]],
usableRect = [[wind platformWindow] usableContentFrame];
frame.origin = [wind convertBaseToGlobal:frame.origin];
@@ -1903,6 +1966,8 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
[self setAlignment:[aCoder decodeIntForKey:CPTextFieldAlignmentKey]];
[self setPlaceholderString:[aCoder decodeObjectForKey:CPTextFieldPlaceholderStringKey]];
[self _updateCursor];
}
return self;
+22 -19
View File
@@ -499,25 +499,28 @@ function CPThemeState()
@end
CPThemeStateNormal = CPThemeState("normal");
CPThemeStateDisabled = CPThemeState("disabled");
CPThemeStateHovered = CPThemeState("hovered");
CPThemeStateHighlighted = CPThemeState("highlighted");
CPThemeStateSelected = CPThemeState("selected");
CPThemeStateTableDataView = CPThemeState("tableDataView");
CPThemeStateSelectedDataView = CPThemeState("selectedTableDataView");
CPThemeStateGroupRow = CPThemeState("CPThemeStateGroupRow");
CPThemeStateBezeled = CPThemeState("bezeled");
CPThemeStateBordered = CPThemeState("bordered");
CPThemeStateEditable = CPThemeState("editable");
CPThemeStateEditing = CPThemeState("editing");
CPThemeStateVertical = CPThemeState("vertical");
CPThemeStateDefault = CPThemeState("default");
CPThemeStateCircular = CPThemeState("circular");
CPThemeStateAutocompleting = CPThemeState("autocompleting");
CPThemeStateFirstResponder = CPThemeState("firstResponder");
CPThemeStateMainWindow = CPThemeState("mainWindow");
CPThemeStateKeyWindow = CPThemeState("keyWindow");
CPThemeStateNormal = CPThemeState("normal");
CPThemeStateDisabled = CPThemeState("disabled");
CPThemeStateHovered = CPThemeState("hovered");
CPThemeStateHighlighted = CPThemeState("highlighted");
CPThemeStateSelected = CPThemeState("selected");
CPThemeStateTableDataView = CPThemeState("tableDataView");
CPThemeStateSelectedDataView = CPThemeState("selectedTableDataView");
CPThemeStateGroupRow = CPThemeState("CPThemeStateGroupRow");
CPThemeStateBezeled = CPThemeState("bezeled");
CPThemeStateBordered = CPThemeState("bordered");
CPThemeStateEditable = CPThemeState("editable");
CPThemeStateEditing = CPThemeState("editing");
CPThemeStateVertical = CPThemeState("vertical");
CPThemeStateDefault = CPThemeState("default");
CPThemeStateCircular = CPThemeState("circular");
CPThemeStateAutocompleting = CPThemeState("autocompleting");
CPThemeStateFirstResponder = CPThemeState("firstResponder");
CPThemeStateMainWindow = CPThemeState("mainWindow");
CPThemeStateKeyWindow = CPThemeState("keyWindow");
CPThemeStateControlSizeRegular = CPThemeState("controlSizeRegular");
CPThemeStateControlSizeSmall = CPThemeState("controlSizeSmall");
CPThemeStateControlSizeMini = CPThemeState("controlSizeMini");
@implementation _CPThemeAttribute : CPObject
{
+16 -16
View File
@@ -105,7 +105,7 @@ CPTokenFieldDeleteButtonType = 1;
int _buttonType @accessors(property=buttonType);
id <CPTokenFieldDelegate> _tokenFieldDelegate;
unsigned _implementedDelegateMethods;
unsigned _implementedTokenFieldDelegateMethods;
}
+ (CPCharacterSet)defaultTokenizingCharacterSet
@@ -177,25 +177,25 @@ CPTokenFieldDeleteButtonType = 1;
return;
_tokenFieldDelegate = aDelegate;
_implementedDelegateMethods = 0;
_implementedTokenFieldDelegateMethods = 0;
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:hasMenuForRepresentedObject:)])
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_;
_implementedTokenFieldDelegateMethods |= CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_;
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:)])
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_;
_implementedTokenFieldDelegateMethods |= CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_;
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:shouldAddObjects:atIndex:)])
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_;
_implementedTokenFieldDelegateMethods |= CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_;
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:menuForRepresentedObject:)])
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_menuForRepresentedObject_;
_implementedTokenFieldDelegateMethods |= CPTokenFieldDelegate_tokenField_menuForRepresentedObject_;
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:displayStringForRepresentedObject:)])
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_;
_implementedTokenFieldDelegateMethods |= CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_;
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:representedObjectForEditingString:)])
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_representedObjectForEditingString_;
_implementedTokenFieldDelegateMethods |= CPTokenFieldDelegate_tokenField_representedObjectForEditingString_;
[super setDelegate:_tokenFieldDelegate];
}
@@ -1248,7 +1248,7 @@ CPTokenFieldDeleteButtonType = 1;
*/
- (CPArray)_completionsForSubstring:(CPString)substring indexOfToken:(int)tokenIndex indexOfSelectedItem:(int)selectedIndex
{
if (!(_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_))
if (!(_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_))
return [];
return [_tokenFieldDelegate tokenField:self completionsForSubstring:substring indexOfToken:tokenIndex indexOfSelectedItem:selectedIndex];
@@ -1274,7 +1274,7 @@ CPTokenFieldDeleteButtonType = 1;
*/
- (CPString)_displayStringForRepresentedObject:(id)representedObject
{
if (_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_)
if (_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_)
{
var stringForRepresentedObject = [_tokenFieldDelegate tokenField:self displayStringForRepresentedObject:representedObject];
@@ -1296,7 +1296,7 @@ CPTokenFieldDeleteButtonType = 1;
*/
- (CPArray)_shouldAddObjects:(CPArray)tokens atIndex:(int)index
{
if (_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_)
if (_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_)
{
var approvedObjects = [_tokenFieldDelegate tokenField:self shouldAddObjects:tokens atIndex:index];
@@ -1318,7 +1318,7 @@ CPTokenFieldDeleteButtonType = 1;
*/
- (id)_representedObjectForEditingString:(CPString)aString
{
if (_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_representedObjectForEditingString_)
if (_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_representedObjectForEditingString_)
{
var token = [_tokenFieldDelegate tokenField:self representedObjectForEditingString:aString];
@@ -1333,8 +1333,8 @@ CPTokenFieldDeleteButtonType = 1;
- (BOOL)_hasMenuForRepresentedObject:(id)aRepresentedObject
{
if ((_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_) &&
(_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_menuForRepresentedObject_))
if ((_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_) &&
(_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_menuForRepresentedObject_))
return [_tokenFieldDelegate tokenField:self hasMenuForRepresentedObject:aRepresentedObject];
return NO;
@@ -1342,8 +1342,8 @@ CPTokenFieldDeleteButtonType = 1;
- (CPMenu)_menuForRepresentedObject:(id)aRepresentedObject
{
if ((_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_) &&
(_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_menuForRepresentedObject_))
if ((_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_) &&
(_implementedTokenFieldDelegateMethods & CPTokenFieldDelegate_tokenField_menuForRepresentedObject_))
{
var hasMenu = [_tokenFieldDelegate tokenField:self hasMenuForRepresentedObject:aRepresentedObject];
+101 -25
View File
@@ -228,6 +228,8 @@ var CPViewFlags = { },
Function _toolTipFunctionIn;
Function _toolTipFunctionOut;
BOOL _toolTipInstalled;
BOOL _isObserving;
}
/*
@@ -508,8 +510,12 @@ var CPViewFlags = { },
[CPException raise:CPInvalidArgumentException reason:"can't insert a subview in duplicate (probably partially decoded)"];
#endif
// Notify the subview that it will be moving.
[aSubview viewWillMoveToSuperview:self];
// We will have to adjust the z-index of all views starting at this index.
var count = _subviews.length;
var count = _subviews.length,
lastWindow;
// Dirty the key view loop, in case the window wants to auto recalculate it
[[self window] _dirtyKeyViewLoop];
@@ -537,14 +543,12 @@ var CPViewFlags = { },
}
else
{
var superview = aSubview._superview;
lastWindow = [superview window];
// Remove the view from its previous superview.
[aSubview removeFromSuperview];
// Set the subview's window to our own.
[aSubview _setWindow:_window];
// Notify the subview that it will be moving.
[aSubview viewWillMoveToSuperview:self];
[aSubview _removeFromSuperview];
// Set ourselves as the superview.
aSubview._superview = self;
@@ -577,6 +581,15 @@ var CPViewFlags = { },
if (![aSubview isHidden] && [self isHiddenOrHasHiddenAncestor])
[aSubview _notifyViewDidHide];
[aSubview viewDidMoveToSuperview];
// Set the subview's window to our own.
if (_window)
[aSubview _setWindow:_window];
if (!_window && lastWindow)
[aSubview _setWindow:nil];
// This method might be called before we are fully unarchived, in which case the theme state isn't set up yet
// and none of the below matters anyhow.
if (_themeState)
@@ -592,8 +605,6 @@ var CPViewFlags = { },
[aSubview _notifyWindowDidResignKey];
}
[aSubview viewDidMoveToSuperview];
[self didAddSubview:aSubview];
}
@@ -610,6 +621,18 @@ var CPViewFlags = { },
Does nothing if there's no container view.
*/
- (void)removeFromSuperview
{
var superview = _superview;
[self viewWillMoveToSuperview:nil];
[self _removeFromSuperview];
[self viewDidMoveToSuperview];
if (superview)
[self _setWindow:nil];
}
- (void)_removeFromSuperview
{
if (!_superview)
return;
@@ -634,8 +657,6 @@ var CPViewFlags = { },
[self _notifyViewDidResignFirstResponder];
_superview = nil;
[self _setWindow:nil];
}
/*!
@@ -645,14 +666,14 @@ var CPViewFlags = { },
*/
- (void)replaceSubview:(CPView)aSubview with:(CPView)aView
{
if (aSubview._superview !== self)
if (aSubview._superview !== self || aSubview === aView)
return;
var index = [_subviews indexOfObjectIdenticalTo:aSubview];
[aSubview removeFromSuperview];
[self _insertSubview:aView atIndex:index];
[aSubview removeFromSuperview];
}
- (void)setSubviews:(CPArray)newSubviews
@@ -727,13 +748,10 @@ var CPViewFlags = { },
/* @ignore */
- (void)_setWindow:(CPWindow)aWindow
{
if (_window === aWindow)
return;
[[self window] _dirtyKeyViewLoop];
// Clear out first responder if we're the first responder and leaving.
if ([_window firstResponder] === self)
if ([_window firstResponder] === self && _window != aWindow)
[_window makeFirstResponder:nil];
// Notify the view and its subviews
@@ -803,6 +821,10 @@ var CPViewFlags = { },
*/
- (void)viewWillMoveToSuperview:(CPView)aView
{
[self _removeObservers];
if (aView)
[self _addObservers];
}
/*!
@@ -821,6 +843,32 @@ var CPViewFlags = { },
{
}
- (void)_removeObservers
{
if (!_isObserving)
return;
var count = [_subviews count];
while (count--)
[_subviews[count] _removeObservers];
_isObserving = NO;
}
- (void)_addObservers
{
if (_isObserving)
return;
var count = [_subviews count];
while (count--)
[_subviews[count] _addObservers];
_isObserving = YES;
}
/*!
Returns the menu item containing the receiver or one of its ancestor views.
@return a menu item, or \c nil if the view or one of its ancestors wasn't found
@@ -1024,7 +1072,8 @@ var CPViewFlags = { },
else
{
var images = [[_backgroundColor patternImage] imageSlices],
partIndex = 0;
partIndex = 0,
frameSize = aSize;
if (_backgroundType === BackgroundVerticalThreePartImage)
{
@@ -1034,16 +1083,21 @@ var CPViewFlags = { },
// Make sure to repeat the top and bottom pieces horizontally if they're not the exact width needed.
if (top)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", top + "px");
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, top);
partIndex++;
}
if (_DOMImageSizes[1])
{
var height = frameSize.height - top - bottom;
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", height + "px");
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, size.height - top - bottom);
partIndex++;
}
if (bottom)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", bottom + "px");
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width, bottom);
}
}
@@ -1055,16 +1109,21 @@ var CPViewFlags = { },
// Make sure to repeat the left and right pieces vertically if they're not the exact height needed.
if (left)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], left + "px", frameSize.height + "px");
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], left, size.height);
partIndex++;
}
if (_DOMImageSizes[1])
{
var width = (frameSize.width - left - right);
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], width + "px", frameSize.height + "px");
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], size.width - left - right, size.height);
partIndex++;
}
if (right)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], right + "px", frameSize.height + "px");
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], right, size.height);
}
}
@@ -1805,6 +1864,9 @@ var CPViewFlags = { },
_DOMElement.style.background = "";
_DOMImageParts[0].style.background = [_backgroundColor cssString];
if (patternImage)
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[0], [patternImage size].width + "px", [patternImage size].height + "px");
if (CPFeatureIsCompatible(CPOpacityRequiresFilterFeature))
_DOMImageParts[0].style.filter = "alpha(opacity=" + [_backgroundColor alphaComponent] * 100 + ")";
else
@@ -1815,6 +1877,9 @@ var CPViewFlags = { },
}
else
_DOMElement.style.background = colorCSS;
if (patternImage)
CPDomDisplayServerSetStyleBackgroundSize(_DOMElement, [patternImage size].width + "px", [patternImage size].height + "px");
}
else
{
@@ -1919,18 +1984,24 @@ var CPViewFlags = { },
// Make sure to repeat the top and bottom pieces horizontally if they're not the exact width needed.
if (top)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", top + "px");
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, top);
partIndex++;
}
if (_DOMImageSizes[1])
{
var height = frameSize.height - top - bottom;
//_DOMImageParts[partIndex].style.backgroundSize = frameSize.width + "px " + height + "px";
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", height + "px");
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, top);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, frameSize.height - top - bottom);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, height);
partIndex++;
}
if (bottom)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], frameSize.width + "px", bottom + "px");
CPDOMDisplayServerSetStyleLeftBottom(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width, bottom);
}
@@ -1945,18 +2016,23 @@ var CPViewFlags = { },
// Make sure to repeat the left and right pieces vertically if they're not the exact height needed.
if (left)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], left + "px", frameSize.height + "px");
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], left, frameSize.height);
partIndex++;
}
if (_DOMImageSizes[1])
{
var width = (frameSize.width - left - right);
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], width + "px", frameSize.height + "px");
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[partIndex], NULL, left, 0.0);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], frameSize.width - left - right, frameSize.height);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], width, frameSize.height);
partIndex++;
}
if (right)
{
CPDomDisplayServerSetStyleBackgroundSize(_DOMImageParts[partIndex], right + "px", frameSize.height + "px");
CPDOMDisplayServerSetStyleRightTop(_DOMImageParts[partIndex], NULL, 0.0, 0.0);
CPDOMDisplayServerSetStyleSize(_DOMImageParts[partIndex], right, frameSize.height);
}
@@ -2541,7 +2617,7 @@ setBoundsOrigin:
/*!
Scrolls the nearest ancestor CPClipView a minimum amount so \c aRect can become visible.
@param aRect the area to become visible
@return <codeYES if any scrolling occurred, \c NO otherwise.
@return \c YES if any scrolling occurred, \c NO otherwise.
*/
- (BOOL)scrollRectToVisible:(CGRect)aRect
{
@@ -2936,10 +3012,10 @@ setBoundsOrigin:
- (BOOL)unsetThemeState:(ThemeState)aState
{
if (aState && aState.isa && [aState isKindOfClass:CPArray])
if (aState && aState.isa && [aState isKindOfClass:CPArray])
aState = CPThemeState.apply(null, aState);
var oldThemeState = _themeState
var oldThemeState = _themeState;
_themeState = _themeState.without(aState);
if (oldThemeState === _themeState)
+5
View File
@@ -901,6 +901,8 @@ CPTexturedBackgroundWindowMask
- (void)_orderFront
{
[[self contentView] _addObservers];
#if PLATFORM(DOM)
// -dw- if a sheet is clicked, the parent window should come up too
if (_isSheet)
@@ -960,6 +962,8 @@ CPTexturedBackgroundWindowMask
if (!_isVisible)
return;
[[self contentView] _removeObservers];
if ([self isSheet])
{
// -dw- as in Cocoa, orderOut: detaches the sheet and animates out
@@ -977,6 +981,7 @@ CPTexturedBackgroundWindowMask
[_platformWindow order:CPWindowOut window:self relativeTo:nil];
#endif
[self makeFirstResponder:nil];
[self _updateMainAndKeyWindows];
}
+6
View File
@@ -80,6 +80,9 @@ aDOMElement.style.bottom = ROUND(____p.y) + "px";
aDOMElement.width = MAX(0.0, ROUND(aWidth));\
aDOMElement.height = MAX(0.0, ROUND(aHeight));
#define CPDomDisplayServerSetStyleBackgroundSize(aDOMElement, aWidth, aHeight)\
aDOMElement.style.backgroundSize = aWidth + ' ' + aHeight;
#define CPDOMDisplayServerAppendChild(aParentElement, aChildElement) aParentElement.appendChild(aChildElement)
#define CPDOMDisplayServerInsertBefore(aParentElement, aChildElement, aBeforeElement) aParentElement.insertBefore(aChildElement, aBeforeElement)
@@ -126,6 +129,9 @@ aDOMElement.style.bottom = ROUND(____p.y) + "px";
CPDOMDisplayServerInstructions[__index + 2] = aWidth;\
CPDOMDisplayServerInstructions[__index + 3] = aHeight;
#define CPDomDisplayServerSetStyleBackgroundSize(aDOMElement, aWidth, aHeight)\
aDOMElement.style.backgroundSize = aWidth + ' ' + aHeight;
#define CPDOMDisplayServerAppendChild(aParentElement, aChildElement)\
if (aChildElement.CPDOMDisplayContext) aChildElement.CPDOMDisplayContext[SetStyleOrigin] = -1;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = AppendChild;\
+1 -1
View File
@@ -151,7 +151,7 @@ var DOMFixedWidthSpanElement = nil,
else if (CPFeatureIsCompatible(CPJavaScriptTextContentFeature))
span.textContent = aString;
return CGSizeMake(span.clientWidth, span.clientHeight);
return CGSizeMake(span.clientWidth + 1, span.clientHeight);
}
+ (CPDictionary)metricsOfFont:(CPFont)aFont
+22 -10
View File
@@ -203,6 +203,10 @@ var ModifierKeyCodes = [
var resizeTimer = nil;
var PreventScroll = true;
// When scrolling with an old-style scroll wheel with discete steps ('clicks'), the scroll amount can indicate how many "lines" to
// scroll.
#define SCROLLWHEEL_LINE_PIXELS 6.0
#if PLATFORM(DOM)
@implementation CPPlatformWindow (DOM)
@@ -917,9 +921,22 @@ var PreventScroll = true;
// We lag 1 event behind without this timeout.
setTimeout(function()
{
// Find the scroll delta
var deltaX = _DOMScrollingElement.scrollLeft - 150,
deltaY = (_DOMScrollingElement.scrollTop - 150) || (aDOMEvent.deltaY === undefined ? 0 : aDOMEvent.deltaY);
if (aDOMEvent.deltaMode !== undefined && aDOMEvent.deltaMode !== 0)
{
event._hasPreciseScrollingDeltas = NO;
event._scrollingDeltaX = aDOMEvent.deltaX;
event._scrollingDeltaY = aDOMEvent.deltaY;
event._deltaX = aDOMEvent.deltaX * SCROLLWHEEL_LINE_PIXELS;
event._deltaY = aDOMEvent.deltaY * SCROLLWHEEL_LINE_PIXELS;
}
else
{
event._hasPreciseScrollingDeltas = YES;
event._scrollingDeltaX = (_DOMScrollingElement.scrollLeft - 150) || aDOMEvent.deltaX || 0;
event._scrollingDeltaY = (_DOMScrollingElement.scrollTop - 150) || aDOMEvent.deltaY || 0;
event._deltaX = event._scrollingDeltaX;
event._deltaY = event._scrollingDeltaY;
}
// If we scroll super with momentum,
// there are so many events going off that
@@ -930,13 +947,8 @@ var PreventScroll = true;
//
// We get free performance boost if we skip sending these events,
// as sending a scroll event with no deltas doesn't do anything.
if (deltaX || deltaY)
{
event._deltaX = deltaX;
event._deltaY = deltaY;
if (event._deltaX || event._deltaY)
[CPApp sendEvent:event];
}
// We set StopDOMEventPropagation = NO on line 1008
//if (StopDOMEventPropagation)
@@ -1268,7 +1280,7 @@ var PreventScroll = true;
insertionIndex = _windowLevels[middle] > aLevel ? middle : middle + 1
[_windowLevels insertObject:aLevel atIndex:insertionIndex];
layer._DOMElement.style.zIndex = aLevel;
layer._DOMElement.style.zIndex = aLevel + 1; // adding one avoids negative zIndices. These have been causing issues in Chrome
_DOMBodyElement.appendChild(layer._DOMElement);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

+625 -107
View File
@@ -419,6 +419,25 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
smallBezelColor = PatternColor(
"{style}button-bezel{state}{position}.png",
{
styles: ["", "default"],
states: ["", "highlighted", "disabled"],
width: 3.0,
height: 20.0,
orientation: PatternIsHorizontal
}),
miniBezelColor = PatternColor(
"{style}button-bezel{state}{position}.png",
{
styles: ["", "default"],
states: ["", "highlighted", "disabled"],
width: 3.0,
height: 16.0,
orientation: PatternIsHorizontal
}),
defaultBezelColor = PatternColor(
[
["default-button-bezel-left.png", 4.0, 24.0],
@@ -505,13 +524,61 @@ var themedButtonValues = nil,
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], [CPThemeStateBordered, CPThemeStateDisabled]],
[@"text-shadow-offset", CGSizeMake(0.0, 1.0), CPThemeStateBordered],
[@"line-break-mode", CPLineBreakByTruncatingTail],
[@"bezel-color", bezelColor, CPThemeStateBordered],
[@"bezel-color", highlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color", disabledBezelColor, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color", defaultBezelColor, [CPThemeStateBordered, CPThemeStateDefault]],
[@"bezel-color", defaultHighlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted, CPThemeStateDefault]],
[@"bezel-color", defaultDisabledBezelColor, [CPThemeStateBordered, CPThemeStateDefault, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0.0, 7.0, 0.0, 7.0), CPThemeStateBordered],
[@"bezel-color", bezelColor, CPThemeStateBordered],
[@"bezel-color", highlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color", disabledBezelColor, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color", defaultBezelColor, [CPThemeStateBordered, CPThemeStateDefault]],
[@"bezel-color", defaultHighlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted, CPThemeStateDefault]],
[@"bezel-color", defaultDisabledBezelColor, [CPThemeStateBordered, CPThemeStateDefault, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0.0, 7.0, 0.0, 7.0), CPThemeStateBordered],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, 2.0, 0.0, 0.0), CPThemeStateBordered],
// RoundRect CPThemeStateControlSizeSmall
[@"bezel-color",
smallBezelColor["@"]["@"],
[CPThemeStateControlSizeSmall, CPThemeStateBordered]],
[@"bezel-color",
smallBezelColor["@"]["highlighted"],
[CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color",
smallBezelColor["@"]["disabled"],
[CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color",
smallBezelColor["default"]["@"],
[CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateDefault]],
[@"bezel-color",
smallBezelColor["default"]["highlighted"],
[CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateHighlighted, CPThemeStateDefault]],
[@"bezel-color",
smallBezelColor["default"]["disabled"],
[CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateDefault, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0.0, 5.0, 0.0, 5.0), [CPThemeStateControlSizeSmall, CPThemeStateBordered]],
[@"nib2cib-adjustment-frame", CGRectMake(-3.0, 5.0, 0.0, 0.0), [CPThemeStateControlSizeSmall, CPThemeStateBordered]],
// RoundRect CPThemeStateControlSizeMini
[@"bezel-color",
miniBezelColor["@"]["@"],
[CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"bezel-color",
miniBezelColor["@"]["highlighted"],
[CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color",
miniBezelColor["@"]["disabled"],
[CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color",
miniBezelColor["default"]["@"],
[CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateDefault]],
[@"bezel-color",
miniBezelColor["default"]["highlighted"],
[CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateHighlighted, CPThemeStateDefault]],
[@"bezel-color",
miniBezelColor["default"]["disabled"],
[CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateDefault, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0.0, 2.0, 2.0, 2.0), [CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"nib2cib-adjustment-frame", CGRectMake(0.0, 13.0, 0.0, 0.0), [CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"bezel-color", roundedBezelColor, [CPThemeStateBordered, CPButtonStateBezelStyleRounded]],
[@"bezel-color", roundedHighlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted, CPButtonStateBezelStyleRounded]],
@@ -528,6 +595,10 @@ var themedButtonValues = nil,
[@"min-size", CGSizeMake(0.0, 24.0)],
[@"max-size", CGSizeMake(-1.0, 24.0)],
[@"min-size", CGSizeMake(0.0, 20.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1.0, 20.0), CPThemeStateControlSizeSmall],
[@"min-size", CGSizeMake(0.0, 16.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1.0, 16.0), CPThemeStateControlSizeMini],
[@"image-offset", CPButtonImageOffset]
];
@@ -569,7 +640,7 @@ var themedButtonValues = nil,
+ (CPPopUpButton)themedPopUpButton
{
var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 24.0) pullsDown:NO],
color = PatternColor(
regularColor = PatternColor(
[
["popup-bezel-left.png", 3.0, 24.0],
["popup-bezel-center.png", 1.0, 24.0],
@@ -577,7 +648,7 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
disabledColor = PatternColor(
regularDisabledColor = PatternColor(
[
["popup-bezel-disabled-left.png", 3.0, 24.0],
["popup-bezel-disabled-center.png", 1.0, 24.0],
@@ -585,21 +656,64 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
smallColor = PatternColor(
"popup-bezel{state}{position}.png",
{
states: ["", "disabled"],
width: 3.0,
height: 20.0,
rightWidth: 19.0,
orientation: PatternIsHorizontal
}),
miniColor = PatternColor(
"popup-bezel{state}{position}.png",
{
states: ["", "disabled"],
width: 3.0,
height: 16.0,
rightWidth: 15.0,
orientation: PatternIsHorizontal
}),
themeValues =
[
[@"bezel-color", color, CPThemeStateBordered],
[@"bezel-color", disabledColor, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color", regularColor, CPThemeStateBordered],
[@"bezel-color", regularDisabledColor, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0, 21.0 + 5.0, 0, 5.0), CPThemeStateBordered],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
[@"content-inset", CGInsetMake(0, 22.0 + 5.0, 0, 5.0), CPThemeStateBordered],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], [CPThemeStateBordered, CPThemeStateDisabled]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:0.6], [CPThemeStateBordered, CPThemeStateDisabled]],
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], [CPThemeStateBordered, CPThemeStateDisabled]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:0.6], [CPThemeStateBordered, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(32.0, 24.0)],
[@"max-size", CGSizeMake(-1.0, 24.0)]
[@"min-size", CGSizeMake(32.0, 24.0)],
[@"max-size", CGSizeMake(-1.0, 24.0)],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, 0.0, -5.0, 0.0)],
// CPThemeStateControlSizeSmall
[@"bezel-color", smallColor["@"], [CPThemeStateControlSizeSmall, CPThemeStateBordered]],
[@"bezel-color", smallColor["disabled"], [CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0, 17.0 + 4.0, 0, 4.0), [CPThemeStateControlSizeSmall, CPThemeStateBordered]],
[@"font", [CPFont boldSystemFontOfSize:11.0]],
[@"min-size", CGSizeMake(32.0, 20.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1.0, 20.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(3.0, 3.0, -6.0, 0.0), CPThemeStateControlSizeSmall],
// CPThemeStateControlSizeMini
[@"bezel-color", miniColor["@"], [CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"bezel-color", miniColor["disabled"], [CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateDisabled]],
[@"content-inset", CGInsetMake(0, 15.0 + 4.0, 2.0, 4.0), [CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"font", [CPFont boldSystemFontOfSize:9.0]],
[@"min-size", CGSizeMake(32.0, 16.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1.0, 16.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(1.0, 9.0, -3.0, 0.0), CPThemeStateControlSizeMini],
];
[self registerThemeValues:themeValues forView:button];
@@ -1001,7 +1115,26 @@ var themedButtonValues = nil,
[@"text-shadow-color", [CPColor whiteColor], [CPThemeStateTableDataView, CPThemeStateGroupRow]],
[@"text-shadow-offset", CGSizeMake(0,1), [CPThemeStateTableDataView, CPThemeStateGroupRow]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:0.0 alpha:0.6], [CPThemeStateTableDataView, CPThemeStateGroupRow, CPThemeStateSelectedDataView]],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], [CPThemeStateTableDataView, CPThemeStateGroupRow]]
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], [CPThemeStateTableDataView, CPThemeStateGroupRow]],
[@"min-size", CGSizeMake(-1.0, 29.0)],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, 0.0, -4.0, 0.0)],
[@"nib2cib-adjustment-frame", CGRectMake(-3.0, -3.0, 6.0, 0.0), CPThemeStateBezeled],
// CPThemeStateControlSizeSmall
[@"content-inset", CGInsetMake(7.0, 7.0, 5.0, 8.0), [CPThemeStateControlSizeSmall, CPThemeStateBezeled]],
[@"content-inset", CGInsetMake(7.0, 7.0, 5.0, 8.0), [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPThemeStateEditing]],
[@"min-size", CGSizeMake(-1.0, 25.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, 0.0, -4.0, 0.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(-3.0, 4.0, 6.0, 7.0), [CPThemeStateControlSizeSmall, CPThemeStateBezeled]],
// CPThemeStateControlSizeMini
[@"content-inset", CGInsetMake(6.0, 7.0, 5.0, 7.0), [CPThemeStateControlSizeMini, CPThemeStateBezeled]],
[@"content-inset", CGInsetMake(6.0, 7.0, 5.0, 7.0), [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPThemeStateEditing]],
[@"min-size", CGSizeMake(-1.0, 22.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, 0.0, -4.0, 0.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(-3.0, 4.0, 6.0, 7.0), [CPThemeStateControlSizeMini, CPThemeStateBezeled]],
];
[self registerThemeValues:themedTextFieldValues forView:textfield];
@@ -1134,23 +1267,21 @@ var themedButtonValues = nil,
themeValues =
[
[@"bezel-color", bezelColor, CPThemeStateBezeled],
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
[@"bezel-color", bezelColor, CPThemeStateBezeled],
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
[@"font", [CPFont boldSystemFontOfSize:13.0]],
[@"text-color", [CPColor colorWithWhite:0.2 alpha:0.8]],
[@"text-color", textDisabledColor, CPThemeStateDisabled],
[@"text-color", textDisabledColor, CPThemeStateDisabled],
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 3.0), CPThemeStateNormal],
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 5.0), CPThemeStateBezeled],
[@"bezel-inset", CGInsetMake(0.0, -3.0, 0.0, -3.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 3.0), CPThemeStateNormal],
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 5.0), CPThemeStateBezeled],
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
[@"datepicker-textfield-bezel-color", [CPColor clearColor], [CPThemeStateNormal, CPThemeStateDisabled]],
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, [CPThemeStateSelected, CPThemeStateDisabled]],
[@"bezel-inset", CGInsetMake(0.0, -3.0, 0.0, -3.0), CPThemeStateBezeled],
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 18.0)],
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
[@"datepicker-textfield-bezel-color", [CPColor clearColor], [CPThemeStateNormal, CPThemeStateDisabled]],
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, [CPThemeStateSelected, CPThemeStateDisabled]],
[@"separator-content-inset", CGInsetMake(0.0, -2.0, 0.0, -1.0)],
@@ -1159,11 +1290,37 @@ var themedButtonValues = nil,
[@"content-inset-datepicker-textfield", CGInsetMake(2.0, 2.0, 0.0, 1.0), CPThemeStateSelected],
[@"content-inset-datepicker-textfield-separator", CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateSelected],
[@"date-hour-margin", 7.0],
[@"stepper-margin", 2.0],
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 18.0)],
[@"date-hour-margin", 7.0],
[@"stepper-margin", 2.0],
[@"min-size", CGSizeMake(0.0, 29.0)],
[@"max-size", CGSizeMake(-1.0, 29.0)]
[@"min-size", CGSizeMake(0, 29.0)],
[@"max-size", CGSizeMake(-1.0, 29.0)],
[@"nib2cib-adjustment-frame", CGRectMake(0.0, 4.0, -3.0, 0.0)],
// CPThemeStateControlSizeSmall
[@"content-inset", CGInsetMake(5.0, 0.0, 0.0, 5.0), [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"content-inset", CGInsetMake(5.0, 0.0, 0.0, 5.0), [CPThemeStateControlSizeSmall, CPThemeStateBezeled]],
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 16.0), CPThemeStateControlSizeSmall],
[@"date-hour-margin", 5.0, CPThemeStateControlSizeSmall],
[@"stepper-margin", 3.0, CPThemeStateControlSizeSmall],
[@"min-size", CGSizeMake(0, 26.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1.0, 26.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(1.0, 6.0, -3.0, 0.0), CPThemeStateControlSizeSmall],
// CPThemeStateControlSizeMini
[@"content-inset", CGInsetMake(4.0, 0.0, 0.0, 4.0), [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"content-inset", CGInsetMake(4.0, 0.0, 0.0, 4.0), [CPThemeStateControlSizeMini, CPThemeStateBezeled]],
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 12.0), CPThemeStateControlSizeMini],
[@"date-hour-margin", 2.0, CPThemeStateControlSizeMini],
[@"stepper-margin", 2.0, CPThemeStateControlSizeMini],
[@"min-size", CGSizeMake(0, 22.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1.0, 22.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(0.0, 9.0, -3.0, 0.0), CPThemeStateControlSizeMini]
];
[datePicker setDatePickerStyle:CPTextFieldDatePickerStyle];
@@ -1523,7 +1680,7 @@ var themedButtonValues = nil,
{
var combo = [[CPComboBox alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 29.0)],
bezelColor = PatternColor(
regularBezelColor = PatternColor(
[
["combobox-bezel-left.png", 6.0, 29.0],
["combobox-bezel-center.png", 1.0, 29.0],
@@ -1531,7 +1688,7 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
bezelFocusedColor = PatternColor(
regularBezelFocusedColor = PatternColor(
[
["combobox-bezel-focused-left.png", 6.0, 29.0],
["combobox-bezel-focused-center.png", 1.0, 29.0],
@@ -1539,7 +1696,7 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
bezelDisabledColor = PatternColor(
regularBezelDisabledColor = PatternColor(
[
["combobox-bezel-disabled-left.png", 6.0, 29.0],
["combobox-bezel-disabled-center.png", 1.0, 29.0],
@@ -1547,7 +1704,7 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
bezelNoBorderColor = PatternColor(
regularBezelNoBorderColor = PatternColor(
[
["combobox-bezel-no-border-left.png", 6.0, 29.0],
["combobox-bezel-no-border-center.png", 1.0, 29.0],
@@ -1555,7 +1712,7 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
bezelNoBorderFocusedColor = PatternColor(
regularBezelNoBorderFocusedColor = PatternColor(
[
["combobox-bezel-no-border-focused-left.png", 6.0, 29.0],
["combobox-bezel-no-border-focused-center.png", 1.0, 29.0],
@@ -1563,7 +1720,7 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
bezelNoBorderDisabledColor = PatternColor(
regularBezelNoBorderDisabledColor = PatternColor(
[
["combobox-bezel-no-border-disabled-left.png", 6.0, 29.0],
["combobox-bezel-no-border-disabled-center.png", 1.0, 29.0],
@@ -1571,31 +1728,134 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
smallBezelColor = PatternColor(
"combobox-bezel{state}{position}.png",
{
states: ["", "disabled"],
width: 4.0,
height: 20.0,
rightWidth: 19.0,
orientation: PatternIsHorizontal
}),
smallBezelFocusedColor = PatternColor(
"combobox-bezel-focused{position}.png",
{
width: 8.0,
height: 26.0,
rightWidth: 23.0,
orientation: PatternIsHorizontal
}),
smallBezelNoBorderColor = PatternColor(
"combobox-bezel-no-border{state}{position}.png",
{
states: ["", "disabled"],
width: 4.0,
height: 20.0,
rightWidth: 19.0,
orientation: PatternIsHorizontal
}),
smallBezelNoBorderFocusedColor = PatternColor(
"combobox-bezel-no-border-focused{position}.png",
{
width: 8.0,
height: 26.0,
rightWidth: 23.0,
orientation: PatternIsHorizontal
}),
miniBezelColor = PatternColor(
"combobox-bezel{state}{position}.png",
{
states: ["", "disabled"],
width: 4.0,
height: 17.5,
rightWidth: 17.0,
orientation: PatternIsHorizontal
}),
miniBezelFocusedColor = PatternColor(
"combobox-bezel-focused{position}.png",
{
width: 6.0,
height: 22.0,
rightWidth: 19.0,
orientation: PatternIsHorizontal
}),
miniBezelNoBorderColor = PatternColor(
"combobox-bezel-no-border{state}{position}.png",
{
states: ["", "disabled"],
width: 4.0,
height: 17.5,
rightWidth: 17.0,
orientation: PatternIsHorizontal
}),
miniBezelNoBorderFocusedColor = PatternColor(
"combobox-bezel-no-border-focused{position}.png",
{
width: 6.0,
height: 22.0,
rightWidth: 19.0,
orientation: PatternIsHorizontal
}),
overrides =
[
[@"bezel-color", bezelColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"bezel-color", bezelFocusedColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateEditing]],
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateDisabled]],
[@"bezel-color", regularBezelColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"bezel-color", regularBezelFocusedColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateEditing]],
[@"bezel-color", regularBezelDisabledColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateDisabled]],
[@"bezel-color", bezelNoBorderColor, CPThemeStateBezeled],
[@"bezel-color", bezelNoBorderFocusedColor, [CPThemeStateBezeled, CPThemeStateEditing]],
[@"bezel-color", bezelNoBorderDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
[@"bezel-color", regularBezelNoBorderColor, CPThemeStateBezeled],
[@"bezel-color", regularBezelNoBorderFocusedColor, [CPThemeStateBezeled, CPThemeStateEditing]],
[@"bezel-color", regularBezelNoBorderDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
[@"border-inset", CGInsetMake(3.0, 3.0, 3.0, 3.0), CPThemeStateBezeled],
[@"border-inset", CGInsetMake(3.0, 3.0, 3.0, 3.0), CPThemeStateBezeled],
[@"bezel-inset", CGInsetMake(0.0, 1.0, 1.0, 1.0), [CPThemeStateBezeled, CPThemeStateEditing]],
[@"bezel-inset", CGInsetMake(0.0, 1.0, 1.0, 1.0), [CPThemeStateBezeled, CPThemeStateEditing]],
// The right border inset has to make room for the focus ring and popup button
[@"content-inset", CGInsetMake(8.0, 27.0, 7.0, 8.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"content-inset", CGInsetMake(8.0, 24.0, 7.0, 8.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(8.0, 24.0, 7.0, 8.0), [CPThemeStateBezeled, CPThemeStateEditing]],
[@"content-inset", CGInsetMake(8.0, 27.0, 7.0, 8.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"content-inset", CGInsetMake(8.0, 24.0, 7.0, 8.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(8.0, 24.0, 7.0, 8.0), [CPThemeStateBezeled, CPThemeStateEditing]],
[@"popup-button-size", CGSizeMake(21.0, 23.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"popup-button-size", CGSizeMake(17.0, 23.0), CPThemeStateBezeled],
[@"popup-button-size", CGSizeMake(21.0, 23.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"popup-button-size", CGSizeMake(17.0, 23.0), CPThemeStateBezeled],
// Because combo box uses a three-part bezel, the height is fixed
[@"min-size", CGSizeMake(0, 29.0)],
[@"max-size", CGSizeMake(-1, 29.0)]
[@"min-size", CGSizeMake(0, 29.0)],
[@"max-size", CGSizeMake(-1, 29.0)],
[@"nib2cib-adjustment-frame", CGRectMake(-3.0, 0.0, 3.0, 0.0)],
// CPThemeStateControlSizeSmall
[@"bezel-color", smallBezelColor["@"], [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"bezel-color", smallBezelFocusedColor, [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateEditing]],
[@"bezel-color", smallBezelColor["disabled"], [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateDisabled]],
[@"bezel-color", smallBezelNoBorderColor["@"], [CPThemeStateControlSizeSmall, CPThemeStateBezeled]],
[@"bezel-color", smallBezelNoBorderFocusedColor, [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPThemeStateEditing]],
[@"bezel-color", smallBezelNoBorderColor["disabled"], [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(0, 26.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1, 26.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(-2.0, -1.0, 1.0, 0.0), CPThemeStateControlSizeSmall],
// CPThemeStateControlSizeMini
[@"bezel-color", miniBezelColor["@"], [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
[@"bezel-color", miniBezelFocusedColor, [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateEditing]],
[@"bezel-color", miniBezelColor["disabled"], [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateDisabled]],
[@"bezel-color", miniBezelNoBorderColor["@"], [CPThemeStateControlSizeMini, CPThemeStateBezeled]],
[@"bezel-color", miniBezelNoBorderFocusedColor, [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPThemeStateEditing]],
[@"bezel-color", miniBezelNoBorderColor["disabled"], [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(0, 22.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1, 22.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(-2.0, -1.0, 2.0, 0.0), CPThemeStateControlSizeMini],
];
[self registerThemeValues:overrides forView:combo inherit:themedTextFieldValues];
@@ -1607,31 +1867,70 @@ var themedButtonValues = nil,
{
var button = [CPRadio radioWithTitle:@"Hello Friend!"],
imageNormal = PatternImage("radio-image.png", 17.0, 17.0),
imageSelected = PatternImage("radio-image-selected.png", 17.0, 17.0),
imageSelectedHighlighted = PatternImage("radio-image-selected-highlighted.png", 17.0, 17.0),
imageSelectedDisabled = PatternImage("radio-image-selected-disabled.png", 17.0, 17.0),
imageDisabled = PatternImage("radio-image-disabled.png", 17.0, 17.0),
imageHighlighted = PatternImage("radio-image-highlighted.png", 17.0, 17.0),
regularImageNormal = PatternImage("radio-image.png", 17.0, 17.0),
regularImageSelected = PatternImage("radio-image-selected.png", 17.0, 17.0),
regularImageSelectedHighlighted = PatternImage("radio-image-selected-highlighted.png", 17.0, 17.0),
regularImageSelectedDisabled = PatternImage("radio-image-selected-disabled.png", 17.0, 17.0),
regularImageDisabled = PatternImage("radio-image-disabled.png", 17.0, 17.0),
regularImageHighlighted = PatternImage("radio-image-highlighted.png", 17.0, 17.0),
smallImageNormal = PatternImage("radio-image.png", 15.0, 15.0),
smallImageSelected = PatternImage("radio-image-selected.png", 15.0, 15.0),
smallImageSelectedHighlighted = PatternImage("radio-image-selected-highlighted.png", 15.0, 15.0),
smallImageSelectedDisabled = PatternImage("radio-image-selected.png", 15.0, 15.0),
smallImageDisabled = PatternImage("radio-image.png", 15.0, 15.0),
smallImageHighlighted = PatternImage("radio-image-highlighted.png", 15.0, 15.0),
miniImageNormal = PatternImage("radio-image.png", 14.0, 14.0),
miniImageSelected = PatternImage("radio-image-selected.png", 14.0, 14.0),
miniImageSelectedHighlighted = PatternImage("radio-image-selected-highlighted.png", 14.0, 14.0),
miniImageSelectedDisabled = PatternImage("radio-image-selected.png", 14.0, 14.0),
miniImageDisabled = PatternImage("radio-image.png", 14.0, 14.0),
miniImageHighlighted = PatternImage("radio-image-highlighted.png", 14.0, 14.0);
themeValues =
[
[@"alignment", CPLeftTextAlignment, CPThemeStateNormal],
[@"content-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
[@"alignment", CPLeftTextAlignment, CPThemeStateNormal],
[@"content-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
[@"image", imageNormal, CPThemeStateNormal],
[@"image", imageSelected, CPThemeStateSelected],
[@"image", imageSelectedHighlighted, [CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", imageHighlighted, CPThemeStateHighlighted],
[@"image", imageDisabled, CPThemeStateDisabled],
[@"image", imageSelectedDisabled, [CPThemeStateSelected, CPThemeStateDisabled]],
[@"image-offset", CPRadioImageOffset],
[@"image", regularImageNormal, CPThemeStateNormal],
[@"image", regularImageSelected, CPThemeStateSelected],
[@"image", regularImageSelectedHighlighted, [CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", regularImageHighlighted, CPThemeStateHighlighted],
[@"image", regularImageDisabled, CPThemeStateDisabled],
[@"image", regularImageSelectedDisabled, [CPThemeStateSelected, CPThemeStateDisabled]],
[@"image-offset", CPRadioImageOffset],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
[@"min-size", CGSizeMake(0.0, 17.0)],
[@"max-size", CGSizeMake(-1.0, -1.0)]
[@"min-size", CGSizeMake(0.0, 17.0)],
[@"max-size", CGSizeMake(-1.0, -1.0)],
[@"nib2cib-adjustment-frame", CGRectMake(0.0, -2.0, 0.0, 0.0)],
// CPThemeStateControlSizeSmall
[@"image", smallImageNormal, [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"image", smallImageSelected, [CPThemeStateControlSizeSmall, CPThemeStateSelected]],
[@"image", smallImageSelectedHighlighted, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", smallImageHighlighted, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted]],
[@"image", smallImageDisabled, [CPThemeStateControlSizeSmall, CPThemeStateDisabled]],
[@"image", smallImageSelectedDisabled, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(0, 15.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1, 15.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, -3.0, 0.0, 0.0), CPThemeStateControlSizeSmall],
// CPThemeStateControlSizeMini
[@"image", miniImageNormal, [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"image", miniImageSelected, [CPThemeStateControlSizeMini, CPThemeStateSelected]],
[@"image", miniImageSelectedHighlighted, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", miniImageHighlighted, [CPThemeStateControlSizeMini, CPThemeStateHighlighted]],
[@"image", miniImageDisabled, [CPThemeStateControlSizeMini, CPThemeStateDisabled]],
[@"image", miniImageSelectedDisabled, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(0, 14.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1, 14.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(4.0, -3.0, 0.0, 0.0), CPThemeStateControlSizeMini],
];
[self registerThemeValues:themeValues forView:button];
@@ -1643,31 +1942,70 @@ var themedButtonValues = nil,
{
var button = [CPCheckBox checkBoxWithTitle:@"Another Option"],
imageNormal = PatternImage("check-box-image.png", 15.0, 16.0),
imageSelected = PatternImage("check-box-image-selected.png", 15.0, 16.0),
imageSelectedHighlighted = PatternImage("check-box-image-selected-highlighted.png", 15.0, 16.0),
imageSelectedDisabled = PatternImage("check-box-image-selected-disabled.png", 15.0, 16.0),
imageDisabled = PatternImage("check-box-image-disabled.png", 15.0, 16.0),
imageHighlighted = PatternImage("check-box-image-highlighted.png", 15.0, 16.0),
regularImageNormal = PatternImage("check-box-image.png", 15.0, 16.0),
regularImageSelected = PatternImage("check-box-image-selected.png", 15.0, 16.0),
regularImageSelectedHighlighted = PatternImage("check-box-image-selected-highlighted.png", 15.0, 16.0),
regularImageSelectedDisabled = PatternImage("check-box-image-selected-disabled.png", 15.0, 16.0),
regularImageDisabled = PatternImage("check-box-image-disabled.png", 15.0, 16.0),
regularImageHighlighted = PatternImage("check-box-image-highlighted.png", 15.0, 16.0),
smallImageNormal = PatternImage("check-box-image.png", 15.0, 16.0),
smallImageSelected = PatternImage("check-box-image-selected.png", 15.0, 16.0),
smallImageSelectedHighlighted = PatternImage("check-box-image-selected-highlighted.png", 15.0, 16.0),
smallImageSelectedDisabled = PatternImage("check-box-image-selected.png", 15.0, 16.0),
smallImageDisabled = PatternImage("check-box-image.png", 15.0, 16.0),
smallImageHighlighted = PatternImage("check-box-image-highlighted.png", 15.0, 16.0),
miniImageNormal = PatternImage("check-box-image.png", 13.0, 14.0),
miniImageSelected = PatternImage("check-box-image-selected.png", 13.0, 14.0),
miniImageSelectedHighlighted = PatternImage("check-box-image-selected-highlighted.png", 13.0, 14.0),
miniImageSelectedDisabled = PatternImage("check-box-image-selected.png", 13.0, 14.0),
miniImageDisabled = PatternImage("check-box-image.png", 13.0, 14.0),
miniImageHighlighted = PatternImage("check-box-image-highlighted.png", 13.0, 14.0),
themeValues =
[
[@"alignment", CPLeftTextAlignment, CPThemeStateNormal],
[@"content-inset", CGInsetMakeZero(), CPThemeStateNormal],
[@"alignment", CPLeftTextAlignment, CPThemeStateNormal],
[@"content-inset", CGInsetMakeZero(), CPThemeStateNormal],
[@"image", imageNormal, CPThemeStateNormal],
[@"image", imageSelected, CPThemeStateSelected],
[@"image", imageSelectedHighlighted, [CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", imageHighlighted, CPThemeStateHighlighted],
[@"image", imageDisabled, CPThemeStateDisabled],
[@"image", imageSelectedDisabled, [CPThemeStateSelected, CPThemeStateDisabled]],
[@"image-offset", CPCheckBoxImageOffset],
[@"image", regularImageNormal, CPThemeStateNormal],
[@"image", regularImageSelected, CPThemeStateSelected],
[@"image", regularImageSelectedHighlighted, [CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", regularImageHighlighted, CPThemeStateHighlighted],
[@"image", regularImageDisabled, CPThemeStateDisabled],
[@"image", regularImageSelectedDisabled, [CPThemeStateSelected, CPThemeStateDisabled]],
[@"image-offset", CPCheckBoxImageOffset],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
[@"min-size", CGSizeMake(0.0, 17.0)],
[@"max-size", CGSizeMake(-1.0, -1.0)]
[@"min-size", CGSizeMake(0.0, 17.0)],
[@"max-size", CGSizeMake(-1.0, -1.0)],
[@"nib2cib-adjustment-frame", CGRectMake(3.0, 0.0, 0.0, 0.0)],
// CPThemeStateControlSizeSmall
[@"image", smallImageNormal, [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"image", smallImageSelected, [CPThemeStateControlSizeSmall, CPThemeStateSelected]],
[@"image", smallImageSelectedHighlighted, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", smallImageHighlighted, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted]],
[@"image", smallImageDisabled, [CPThemeStateControlSizeSmall, CPThemeStateDisabled]],
[@"image", smallImageSelectedDisabled, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(16.0, 16.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1.0, -1.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(4.0, 0.0, 15.0, 0.0), CPThemeStateControlSizeSmall],
// CPThemeStateControlSizeMini
[@"image", miniImageNormal, [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"image", miniImageSelected, [CPThemeStateControlSizeMini, CPThemeStateSelected]],
[@"image", miniImageSelectedHighlighted, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateHighlighted]],
[@"image", miniImageHighlighted, [CPThemeStateControlSizeMini, CPThemeStateHighlighted]],
[@"image", miniImageDisabled, [CPThemeStateControlSizeMini, CPThemeStateDisabled]],
[@"image", miniImageSelectedDisabled, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateDisabled]],
[@"min-size", CGSizeMake(13.0, 14.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1.0, -1.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(5.0, 0.0, 15.0, 0.0), CPThemeStateControlSizeMini],
];
[button setThemeState:CPThemeStateSelected];
@@ -1751,6 +2089,52 @@ var themedButtonValues = nil,
pushedHighlightedLeftBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-left.png", 4.0, 24.0),
pushedHighlightedRightBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-right.png", 4.0, 24.0);
var smallCenterBezelColor = PatternColor("segmented-control-bezel-center.png", 1.0, 20.0),
smallDividerBezelColor = PatternColor("segmented-control-bezel-divider.png", 1.0, 20.0),
smallCenterHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-center.png", 1.0, 20.0),
smallDividerHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-divider.png", 1.0, 20.0),
smallLeftHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-left.png", 4.0, 20.0),
smallRightHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-right.png", 4.0, 20.0),
smallInactiveCenterBezelColor = PatternColor("segmented-control-bezel-disabled-center.png", 1.0, 20.0),
smallInactiveDividerBezelColor = PatternColor("segmented-control-bezel-disabled-divider.png", 1.0, 20.0),
smallInactiveLeftBezelColor = PatternColor("segmented-control-bezel-disabled-left.png", 4.0, 20.0),
smallInactiveRightBezelColor = PatternColor("segmented-control-bezel-disabled-right.png", 4.0, 20.0),
smallInactiveHighlightedCenterBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-center.png", 1.0, 20.0),
smallInactiveHighlightedDividerBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-divider.png", 1.0, 20.0),
smallInactiveHighlightedLeftBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-left.png", 4.0, 20.0),
smallInactiveHighlightedRightBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-right.png", 4.0, 20.0),
smallLeftBezelColor = PatternColor("segmented-control-bezel-left.png", 4.0, 20.0),
smallRightBezelColor = PatternColor("segmented-control-bezel-right.png", 4.0, 20.0),
smallPushedCenterBezelColor = PatternColor("segmented-control-bezel-pushed-center.png", 1.0, 20.0),
smallPushedLeftBezelColor = PatternColor("segmented-control-bezel-pushed-left.png", 4.0, 20.0),
smallPushedRightBezelColor = PatternColor("segmented-control-bezel-pushed-right.png", 4.0, 20.0),
smallPushedHighlightedCenterBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-center.png", 1.0, 20.0),
smallPushedHighlightedLeftBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-left.png", 4.0, 20.0),
smallPushedHighlightedRightBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-right.png", 4.0, 20.0);
var miniCenterBezelColor = PatternColor("segmented-control-bezel-center.png", 1.0, 15.0),
miniDividerBezelColor = PatternColor("segmented-control-bezel-divider.png", 1.0, 15.0),
miniCenterHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-center.png", 1.0, 15.0),
miniDividerHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-divider.png", 1.0, 15.0),
miniLeftHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-left.png", 4.0, 15.0),
miniRightHighlightedBezelColor = PatternColor("segmented-control-bezel-highlighted-right.png", 4.0, 15.0),
miniInactiveCenterBezelColor = PatternColor("segmented-control-bezel-disabled-center.png", 1.0, 15.0),
miniInactiveDividerBezelColor = PatternColor("segmented-control-bezel-disabled-divider.png", 1.0, 15.0),
miniInactiveLeftBezelColor = PatternColor("segmented-control-bezel-disabled-left.png", 4.0, 15.0),
miniInactiveRightBezelColor = PatternColor("segmented-control-bezel-disabled-right.png", 4.0, 15.0),
miniInactiveHighlightedCenterBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-center.png", 1.0, 15.0),
miniInactiveHighlightedDividerBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-divider.png", 1.0, 15.0),
miniInactiveHighlightedLeftBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-left.png", 4.0, 15.0),
miniInactiveHighlightedRightBezelColor = PatternColor("segmented-control-bezel-highlighted-disabled-right.png", 4.0, 15.0),
miniLeftBezelColor = PatternColor("segmented-control-bezel-left.png", 4.0, 15.0),
miniRightBezelColor = PatternColor("segmented-control-bezel-right.png", 4.0, 15.0),
miniPushedCenterBezelColor = PatternColor("segmented-control-bezel-pushed-center.png", 1.0, 15.0),
miniPushedLeftBezelColor = PatternColor("segmented-control-bezel-pushed-left.png", 4.0, 15.0),
miniPushedRightBezelColor = PatternColor("segmented-control-bezel-pushed-right.png", 4.0, 15.0),
miniPushedHighlightedCenterBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-center.png", 1.0, 15.0),
miniPushedHighlightedLeftBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-left.png", 4.0, 15.0),
miniPushedHighlightedRightBezelColor = PatternColor("segmented-control-bezel-pushed-highlighted-right.png", 4.0, 15.0);
themedSegmentedControlValues =
[
[@"center-segment-bezel-color", centerBezelColor, CPThemeStateNormal],
@@ -1779,9 +2163,75 @@ var themedButtonValues = nil,
[@"right-segment-bezel-color", pushedRightBezelColor, CPThemeStateHighlighted],
[@"right-segment-bezel-color", pushedHighlightedRightBezelColor, [CPThemeStateHighlighted, CPThemeStateSelected]],
[@"center-segment-bezel-color", smallCenterBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"center-segment-bezel-color", smallInactiveCenterBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateDisabled]],
[@"center-segment-bezel-color", smallInactiveHighlightedCenterBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateDisabled]],
[@"center-segment-bezel-color", smallCenterHighlightedBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected]],
[@"center-segment-bezel-color", smallPushedCenterBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted]],
[@"center-segment-bezel-color", smallPushedHighlightedCenterBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted, CPThemeStateSelected]],
[@"divider-bezel-color", smallDividerBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"divider-bezel-color", smallInactiveDividerBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateDisabled]],
[@"divider-bezel-color", smallInactiveHighlightedDividerBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateDisabled]],
[@"divider-bezel-color", smallDividerHighlightedBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected]],
[@"left-segment-bezel-color", smallLeftBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"left-segment-bezel-color", smallInactiveLeftBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateDisabled]],
[@"left-segment-bezel-color", smallInactiveHighlightedLeftBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateDisabled]],
[@"left-segment-bezel-color", smallLeftHighlightedBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected]],
[@"left-segment-bezel-color", smallPushedLeftBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted]],
[@"left-segment-bezel-color", smallPushedHighlightedLeftBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted, CPThemeStateSelected]],
[@"right-segment-bezel-color", smallRightBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
[@"right-segment-bezel-color", smallInactiveRightBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateDisabled]],
[@"right-segment-bezel-color", smallInactiveHighlightedRightBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected, CPThemeStateDisabled]],
[@"right-segment-bezel-color", smallRightHighlightedBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateSelected]],
[@"right-segment-bezel-color", smallPushedRightBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted]],
[@"right-segment-bezel-color", smallPushedHighlightedRightBezelColor, [CPThemeStateControlSizeSmall, CPThemeStateHighlighted, CPThemeStateSelected]],
[@"center-segment-bezel-color", miniCenterBezelColor, [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"center-segment-bezel-color", miniInactiveCenterBezelColor, [CPThemeStateControlSizeMini, CPThemeStateDisabled]],
[@"center-segment-bezel-color", miniInactiveHighlightedCenterBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateDisabled]],
[@"center-segment-bezel-color", miniCenterHighlightedBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected]],
[@"center-segment-bezel-color", miniPushedCenterBezelColor, [CPThemeStateControlSizeMini, CPThemeStateHighlighted]],
[@"center-segment-bezel-color", miniPushedHighlightedCenterBezelColor, [CPThemeStateControlSizeMini, CPThemeStateHighlighted, CPThemeStateSelected]],
[@"divider-bezel-color", miniDividerBezelColor, [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"divider-bezel-color", miniInactiveDividerBezelColor, [CPThemeStateControlSizeMini, CPThemeStateDisabled]],
[@"divider-bezel-color", miniInactiveHighlightedDividerBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateDisabled]],
[@"divider-bezel-color", miniDividerHighlightedBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected]],
[@"left-segment-bezel-color", miniLeftBezelColor, [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"left-segment-bezel-color", miniInactiveLeftBezelColor, [CPThemeStateControlSizeMini, CPThemeStateDisabled]],
[@"left-segment-bezel-color", miniInactiveHighlightedLeftBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateDisabled]],
[@"left-segment-bezel-color", miniLeftHighlightedBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected]],
[@"left-segment-bezel-color", miniPushedLeftBezelColor, [CPThemeStateControlSizeMini, CPThemeStateHighlighted]],
[@"left-segment-bezel-color", miniPushedHighlightedLeftBezelColor, [CPThemeStateControlSizeMini, CPThemeStateHighlighted, CPThemeStateSelected]],
[@"right-segment-bezel-color", miniRightBezelColor, [CPThemeStateControlSizeMini, CPThemeStateNormal]],
[@"right-segment-bezel-color", miniInactiveRightBezelColor, [CPThemeStateControlSizeMini, CPThemeStateDisabled]],
[@"right-segment-bezel-color", miniInactiveHighlightedRightBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected, CPThemeStateDisabled]],
[@"right-segment-bezel-color", miniRightHighlightedBezelColor, [CPThemeStateControlSizeMini, CPThemeStateSelected]],
[@"right-segment-bezel-color", miniPushedRightBezelColor, [CPThemeStateControlSizeMini, CPThemeStateHighlighted]],
[@"right-segment-bezel-color", miniPushedHighlightedRightBezelColor, [CPThemeStateControlSizeMini, CPThemeStateHighlighted, CPThemeStateSelected]],
[@"content-inset", CGInsetMake(0.0, 4.0, 0.0, 4.0), CPThemeStateNormal],
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
[@"min-size", CGSizeMake(-1.0, 24.0)],
[@"max-size", CGSizeMake(-1.0, 24.0)],
[@"nib2cib-adjustment-frame", CGRectMake(1.0, 1.0, -3.0, 0.0)],
[@"min-size", CGSizeMake(-1.0, 20.0), CPThemeStateControlSizeSmall],
[@"max-size", CGSizeMake(-1.0, 20.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(2.0, 0.0, -4.0, 0.0), CPThemeStateControlSizeSmall],
[@"min-size", CGSizeMake(-1.0, 15.0), CPThemeStateControlSizeMini],
[@"max-size", CGSizeMake(-1.0, 15.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(1.0, 0.0, -2.0, 0.0), CPThemeStateControlSizeMini],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], CPThemeStateDisabled],
@@ -1790,8 +2240,7 @@ var themedButtonValues = nil,
[@"text-shadow-offset", CGSizeMake(0.0, 1.0)],
[@"line-break-mode", CPLineBreakByTruncatingTail],
[@"divider-thickness", 1.0],
[@"default-height", 25.0]
[@"divider-thickness", 1.0]
];
[self registerThemeValues:themedSegmentedControlValues forView:segmentedControl];
@@ -2256,17 +2705,82 @@ var themedButtonValues = nil,
],
PatternIsHorizontal),
smallBezelUp = PatternColor(
"stepper-bezel-big{state}-up{position}.png",
{
states: ["", "highlighted", "disabled"],
width: 3.0,
height: 11.0,
centerWidth: 11.0,
orientation: PatternIsHorizontal
}),
smallBezelDown = PatternColor(
"stepper-bezel-big{state}-down{position}.png",
{
states: ["", "highlighted", "disabled"],
width: 3.0,
height: 10.0,
centerWidth: 11.0,
orientation: PatternIsHorizontal
}),
miniBezelUp = PatternColor(
"stepper-bezel-big{state}-up{position}.png",
{
states: ["", "highlighted", "disabled"],
width: 2.0,
height: 8.0,
centerWidth: 8.0,
orientation: PatternIsHorizontal
}),
miniBezelDown = PatternColor(
"stepper-bezel-big{state}-down{position}.png",
{
states: ["", "highlighted", "disabled"],
width: 2.0,
height: 7.0,
centerWidth: 8.0,
orientation: PatternIsHorizontal
}),
themeValues =
[
[@"bezel-color-up-button", bezelUp, CPThemeStateBordered],
[@"bezel-color-down-button", bezelDown, CPThemeStateBordered],
[@"bezel-color-up-button", bezelUpDisabled, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-down-button", bezelDownDisabled, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-up-button", bezelUpHighlighted, [CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color-down-button", bezelDownHighlighted, [CPThemeStateBordered, CPThemeStateHighlighted]],
[@"min-size", CGSizeMake(25.0, 25.0)],
[@"bezel-color-up-button", bezelUp, CPThemeStateBordered],
[@"bezel-color-down-button", bezelDown, CPThemeStateBordered],
[@"bezel-color-up-button", bezelUpDisabled, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-down-button", bezelDownDisabled, [CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-up-button", bezelUpHighlighted, [CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color-down-button", bezelDownHighlighted, [CPThemeStateBordered, CPThemeStateHighlighted]],
[@"up-button-size", CGSizeMake(19.0, 13.0)],
[@"down-button-size", CGSizeMake(19.0, 12.0)]
[@"down-button-size", CGSizeMake(19.0, 12.0)],
[@"nib2cib-adjustment-frame", CGRectMake(3.0, -25.0, 0.0, 0.0)],
// CPThemeStateControlSizeSmall
[@"bezel-color-up-button", smallBezelUp["@"], [CPThemeStateControlSizeSmall, CPThemeStateBordered]],
[@"bezel-color-down-button", smallBezelDown["@"], [CPThemeStateControlSizeSmall, CPThemeStateBordered]],
[@"bezel-color-up-button", smallBezelUp["disabled"], [CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-down-button", smallBezelDown["disabled"], [CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-up-button", smallBezelUp["highlighted"], [CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color-down-button", smallBezelDown["highlighted"], [CPThemeStateControlSizeSmall, CPThemeStateBordered, CPThemeStateHighlighted]],
[@"up-button-size", CGSizeMake(17.0, 11.0), CPThemeStateControlSizeSmall],
[@"down-button-size", CGSizeMake(17.0, 10.0), CPThemeStateControlSizeSmall],
[@"nib2cib-adjustment-frame", CGRectMake(3.0, -21.0, 0.0, 0.0), CPThemeStateControlSizeSmall],
// CPThemeStateControlSizeMini
[@"bezel-color-up-button", miniBezelUp["@"], [CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"bezel-color-down-button", miniBezelDown["@"], [CPThemeStateControlSizeMini, CPThemeStateBordered]],
[@"bezel-color-up-button", miniBezelUp["disabled"], [CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-down-button", miniBezelDown["disabled"], [CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateDisabled]],
[@"bezel-color-up-button", miniBezelUp["highlighted"], [CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateHighlighted]],
[@"bezel-color-down-button", miniBezelDown["highlighted"], [CPThemeStateControlSizeMini, CPThemeStateBordered, CPThemeStateHighlighted]],
[@"up-button-size", CGSizeMake(12.0, 8.0), CPThemeStateControlSizeMini],
[@"down-button-size", CGSizeMake(12.0, 7.0), CPThemeStateControlSizeMini],
[@"nib2cib-adjustment-frame", CGRectMake(3.0, -14.0, 0.0, 0.0), CPThemeStateControlSizeMini],
];
[self registerThemeValues:themeValues forView:stepper];
@@ -2296,7 +2810,8 @@ var themedButtonValues = nil,
[@"slice-last-bottom-border-color", sliceLastBottomBorderColor],
[@"font", [CPFont systemFontOfSize:10.0]],
[@"add-image", addImage],
[@"remove-image", removeImage]
[@"remove-image", removeImage],
[@"vertical-alignment", CPCenterVerticalTextAlignment]
];
[self registerThemeValues:ruleEditorThemedValues forView:ruleEditor];
@@ -2704,6 +3219,7 @@ var themedButtonValues = nil,
}),
closeButtonImage = PatternImage(@"window-standard-close-button.png", 16, 16),
closeButtonImageInactive = PatternImage(@"window-standard-close-button-inactive.png", 16, 16),
closeButtonImageHighlighted = PatternImage(@"window-standard-button-highlighted.png",16, 16),
unsavedButtonImage = PatternImage(@"window-standard-button-unsaved.png",16, 16),
unsavedButtonImageHighlighted = PatternImage(@"window-standard-close-button-unsaved-highlighted.png",16, 16),
@@ -2736,7 +3252,9 @@ var themedButtonValues = nil,
[@"unsaved-image-button" ,unsavedButtonImage],
[@"unsaved-image-highlighted-button" ,unsavedButtonImageHighlighted],
[@"close-image-button" ,closeButtonImage],
[@"close-image-button" ,closeButtonImageInactive, CPThemeStateNormal],
[@"close-image-button" ,closeButtonImage, CPThemeStateKeyWindow],
[@"close-image-button" ,closeButtonImage, CPThemeStateMainWindow],
[@"close-image-highlighted-button" ,closeButtonImageHighlighted],
[@"minimize-image-button" ,minimizeButtonImage],
[@"minimize-image-highlighted-button" ,minimizeButtonImageHighlighted],
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

File diff suppressed because it is too large Load Diff
+17 -8
View File
@@ -513,6 +513,9 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
{
// We are watching opacity, so this triggers the next transition
#if PLATFORM(DOM)
// We force the style to recalculate the values, this is needed to avoid a transition issue
// More information here : https://code.google.com/p/chromium/issues/detail?id=388082
[self _currentTransformMatrix];
_DOMElement.style.opacity = 1;
_DOMElement.style.height = frame.size.height + @"px";
_DOMElement.style.width = frame.size.width + @"px";
@@ -608,7 +611,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), _orderFrontTransitionFunction, YES);
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), _transitionCompleteFunction, YES);
var matrix = window.getComputedStyle(_DOMElement, null)[CPBrowserStyleProperty(@"transform")],
var matrix = [self _currentTransformMatrix],
currentScale = (matrix.split('(')[1]).split(',')[0];
[self setCSS3Property:@"Transform" value:@"scale(" + currentScale + ")"];
@@ -652,6 +655,13 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
#pragma mark -
#pragma mark Private
- (CPString)_currentTransformMatrix
{
#if PLATFORM(DOM)
return window.getComputedStyle(_DOMElement, null)[CPBrowserStyleProperty(@"transform")];
#endif
}
- (BOOL)_hasOnlyTransientChild:(_CPPopoverWindow)aWindow
{
var childWindows = [aWindow childWindows];
@@ -710,24 +720,23 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
break;
}
[_delegate close];
[_delegate performClose:self];
break;
case CPPopoverBehaviorTransient:
[_delegate close];
break;
case CPPopoverBehaviorApplicationDefined:
[self _trapNextMouseDown];
[_delegate performClose:self];
break;
}
if ([self isVisible])
[self _trapNextMouseDown];
}
}
- (void)_trapNextMouseDown
{
// Don't dequeue the event so clicks in controls will work
[CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:NO];
[CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask | CPRightMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:NO];
}
@end
-1
View File
@@ -181,7 +181,6 @@ var _CPToolTipHeight = 24.0,
_content = [CPTextField labelWithTitle:aString];
[_content setFont:[CPFont systemFontOfSize:_CPToolTipFontSize]]
[_content setLineBreakMode:CPLineBreakByCharWrapping];
[_content setAlignment:CPJustifiedTextAlignment];
[_content setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_content setFrameOrigin:CGPointMake(0.0, 0.0)];
[_content setFrameSize:textFrameSize];
+88 -41
View File
@@ -189,7 +189,7 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4,
shortStandaloneQuarterSymbols = [CPArray arrayWithObjects:@"Q1", @"Q2", @"Q3", @"Q4"];
_symbols = @{
@"en" : @{
@"root" : @{
@"AMSymbol" : AMSymbol,
@"PMSymbol" : PMSymbol,
@"weekdaySymbols" : weekdaySymbols,
@@ -208,10 +208,8 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4,
@"shortQuarterSymbols" : shortQuarterSymbols,
@"standaloneQuarterSymbols" : standaloneQuarterSymbols,
@"shortStandaloneQuarterSymbols" : shortStandaloneQuarterSymbols
},
@"fr" : @{},
@"es" : @{},
@"de" : @{}
}
};
_timeZone = [CPTimeZone systemTimeZone];
@@ -220,6 +218,55 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4,
}
#pragma mark -
#pragma mark Setter Getter Helper
/*! Return symbols for the given language code
*/
- (CPDictionary)symbolsForLanguageCode:(CPString)languageCode
{
var languageSymbols = [_symbols valueForKey:languageCode];
if (!languageSymbols)
{
languageSymbols = [self symbolsForLanguageCode:@"root"];
[self setSymbols:languageSymbols forLanguageCode:languageCode];
}
return languageSymbols;
}
/*! Set the symbols for the given language code
*/
- (void)setSymbols:(CPDictionary)symbols forLanguageCode:(CPString)languageCode
{
[_symbols setValue:symbols forKey:languageCode];
}
/*! Return a symbol specified by the given key for the given language code
*/
- (id)symbolForKey:(CPString)aKey languageCode:(CPString)languageCode
{
var languageSymbols = [self symbolsForLanguageCode:languageCode],
symbol = [languageSymbols valueForKey:aKey];
if (!symbol)
{
symbol = [self symbolForKey:aKey languageCode:@"root"];
[self setSymbol:symbol forKey:aKey languageCode:languageCode];
}
return symbol;
}
/*! Set the symbol specified by the given key for the given language code
*/
- (void)setSymbol:(CPString)aSymbol forKey:(CPString)aKey languageCode:(CPString)languageCode
{
var languageSymbols = [self symbolsForLanguageCode:languageCode];
[languageSymbols setValue:aSymbol forKey:aKey];
}
#pragma mark -
#pragma mark Setter Getter
@@ -227,252 +274,252 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4,
*/
- (CPString)AMSymbol
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"AMSymbol"];
return [self symbolForKey:@"AMSymbol" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the AMSymbol
*/
- (void)setAMSymbol:(CPString)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"AMSymbol"];
[self setSymbol:aValue forKey:@"AMSymbol" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return a PMSymbol
*/
- (CPString)PMSymbol
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"PMSymbol"];
return [self symbolForKey:@"PMSymbol" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the PMSymbol
*/
- (void)setPMSymbol:(CPString)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"PMSymbol"];
[self setSymbol:aValue forKey:@"PMSymbol" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the weekdaySymbols
*/
- (CPArray)weekdaySymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"weekdaySymbols"];
return [self symbolForKey:@"weekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the weekdaySymbols
*/
- (void)setWeekdaySymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"weekdaySymbols"];
[self setSymbol:aValue forKey:@"weekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return a shortWeekdaySymbols
*/
- (CPArray)shortWeekdaySymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"shortWeekdaySymbols"];
return [self symbolForKey:@"shortWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the shortWeekdaySymbols
*/
- (void)setShortWeekdaySymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"shortWeekdaySymbols"];
[self setSymbol:aValue forKey:@"shortWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return veryShortWeekdaySymbols
*/
- (CPArray)veryShortWeekdaySymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"veryShortWeekdaySymbols"];
return [self symbolForKey:@"veryShortWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the veryShortWeekdaySymbols
*/
- (void)setVeryShortWeekdaySymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"veryShortWeekdaySymbols"];
[self setSymbol:aValue forKey:@"veryShortWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the standaloneWeekdaySymbols
*/
- (CPArray)standaloneWeekdaySymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"standaloneWeekdaySymbols"];
return [self symbolForKey:@"standaloneWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the standaloneWeekdaySymbols
*/
- (void)setStandaloneWeekdaySymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"standaloneWeekdaySymbols"];
[self setSymbol:aValue forKey:@"standaloneWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the shortStandaloneWeekdaySymbols
*/
- (CPArray)shortStandaloneWeekdaySymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"shortStandaloneWeekdaySymbols"];
return [self symbolForKey:@"shortStandaloneWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the shortStandaloneWeekdaySymbols
*/
- (void)setShortStandaloneWeekdaySymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"shortStandaloneWeekdaySymbols"];
[self setSymbol:aValue forKey:@"shortStandaloneWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the veryShortStandaloneWeekdaySymbols
*/
- (CPArray)veryShortStandaloneWeekdaySymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"veryShortStandaloneWeekdaySymbols"];
return [self symbolForKey:@"veryShortStandaloneWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the veryShortStandaloneWeekdaySymbols
*/
- (void)setVeryShortStandaloneWeekdaySymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"veryShortStandaloneWeekdaySymbols"];
[self setSymbol:aValue forKey:@"veryShortStandaloneWeekdaySymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the monthSymbols
*/
- (CPArray)monthSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"monthSymbols"];
return [self symbolForKey:@"monthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the monthSymbols
*/
- (void)setMonthSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"monthSymbols"];
[self setSymbol:aValue forKey:@"monthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return a shortMonthSymbols
*/
- (CPArray)shortMonthSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"shortMonthSymbols"];
return [self symbolForKey:@"shortMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the shortMonthSymbols
*/
- (void)setShortMonthSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"shortMonthSymbols"];
[self setSymbol:aValue forKey:@"shortMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return veryShortMonthSymbols
*/
- (CPArray)veryShortMonthSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"veryShortMonthSymbols"];
return [self symbolForKey:@"veryShortMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the veryShortMonthSymbols
*/
- (void)setVeryShortMonthSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"veryShortMonthSymbols"];
[self setSymbol:aValue forKey:@"veryShortMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return standaloneMonthSymbols
*/
- (CPArray)standaloneMonthSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"standaloneMonthSymbols"];
return [self symbolForKey:@"standaloneMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the standaloneMonthSymbols
*/
- (void)setStandaloneMonthSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"standaloneMonthSymbols"];
[self setSymbol:aValue forKey:@"standaloneMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the shortStandaloneMonthSymbols
*/
- (CPArray)shortStandaloneMonthSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"shortStandaloneMonthSymbols"];
return [self symbolForKey:@"shortStandaloneMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the shortStandaloneMonthSymbols
*/
- (void)setShortStandaloneMonthSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"shortStandaloneMonthSymbols"];
[self setSymbol:aValue forKey:@"shortStandaloneMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the veryShortStandaloneMonthSymbols
*/
- (CPArray)veryShortStandaloneMonthSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"veryShortStandaloneMonthSymbols"];
return [self symbolForKey:@"veryShortStandaloneMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the veryShortStandaloneMonthSymbols
*/
- (void)setVeryShortStandaloneMonthSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"veryShortStandaloneMonthSymbols"];
[self setSymbol:aValue forKey:@"veryShortStandaloneMonthSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the quarterSymbols
*/
- (CPArray)quarterSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"quarterSymbols"];
return [self symbolForKey:@"quarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the quarterSymbols
*/
- (void)setQuarterSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"quarterSymbols"];
[self setSymbol:aValue forKey:@"quarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the shortQuarterSymbols
*/
- (CPArray)shortQuarterSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"shortQuarterSymbols"];
return [self symbolForKey:@"shortQuarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the shortQuarterSymbols
*/
- (void)setShortQuarterSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"shortQuarterSymbols"];
[self setSymbol:aValue forKey:@"shortQuarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the standaloneQuarterSymbols
*/
- (CPArray)standaloneQuarterSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"standaloneQuarterSymbols"];
return [self symbolForKey:@"standaloneQuarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the standaloneQuarterSymbols
*/
- (void)setStandaloneQuarterSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"standaloneQuarterSymbols"];
[self setSymbol:aValue forKey:@"standaloneQuarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Return the shortStandaloneQuarterSymbols
*/
- (CPArray)shortStandaloneQuarterSymbols
{
return [[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] valueForKey:@"shortStandaloneQuarterSymbols"];
return [self symbolForKey:@"shortStandaloneQuarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
/*! Set the shortStandaloneQuarterSymbols
*/
- (void)setShortStandaloneQuarterSymbols:(CPArray)aValue
{
[[_symbols valueForKey:[_locale objectForKey:CPLocaleLanguageCode]] setValue:aValue forKey:@"shortStandaloneQuarterSymbols"];
[self setSymbol:aValue forKey:@"shortStandaloneQuarterSymbols" languageCode:[_locale objectForKey:CPLocaleLanguageCode]];
}
+172 -93
View File
@@ -327,6 +327,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
Class _nativeClass;
CPDictionary _changesForKey;
CPDictionary _nestingForKey;
CPDictionary _minOptionsForKey;
Object _observersForKey;
int _observersForKeyLength;
CPSet _replacedKeys;
@@ -354,6 +355,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
_observersForKey = {};
_changesForKey = {};
_nestingForKey = {};
_minOptionsForKey = {};
_observersForKeyLength = 0;
[self _replaceClass];
@@ -767,12 +769,20 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
if (options & CPKeyValueObservingOptionInitial)
{
var newValue = [_targetObject valueForKeyPath:aPath];
var changes;
if (newValue === nil || newValue === undefined)
newValue = [CPNull null];
if (options & CPKeyValueObservingOptionNew)
{
var newValue = [_targetObject valueForKeyPath:aPath];
if (newValue == nil)
newValue = [CPNull null];
changes = @{ CPKeyValueChangeKindKey: CPKeyValueChangeSetting, CPKeyValueChangeNewKey: newValue };
} else {
changes = @{ CPKeyValueChangeKindKey: CPKeyValueChangeSetting };
}
var changes = @{ CPKeyValueChangeNewKey: newValue };
[anObserver observeValueForKeyPath:aPath ofObject:_targetObject change:changes context:aContext];
}
}
@@ -819,7 +829,9 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
- (void)_sendNotificationsForKey:(CPString)aKey changeOptions:(CPDictionary)changeOptions isBefore:(BOOL)isBefore
{
var changes = _changesForKey[aKey];
var changes = _changesForKey[aKey],
observers = [_observersForKey[aKey] allValues],
observersMinimumOptions = 0;
if (isBefore)
{
@@ -838,61 +850,78 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
_nestingForKey[aKey] = 1;
// Get the combined minimum of the ...Old and ...New options for all observers
var count = observers ? observers.length : 0;
while (count--)
{
var observerInfo = observers[count];
observersMinimumOptions |= observerInfo.options & kvoNewAndOld;
}
_minOptionsForKey[aKey] = observersMinimumOptions;
changes = changeOptions;
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
if (setMutationKind)
if (observersMinimumOptions & CPKeyValueObservingOptionOld)
{
var setMutationObjects = [changes[_CPKeyValueChangeSetMutationObjectsKey] copy],
setExistingObjects = [[_targetObject valueForKey: aKey] copy];
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
if (setMutationKind == CPKeyValueMinusSetMutation)
if (setMutationKind)
{
[setExistingObjects intersectSet: setMutationObjects];
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
var setMutationObjects = [changes[_CPKeyValueChangeSetMutationObjectsKey] copy],
setExistingObjects = [[_targetObject valueForKey: aKey] copy];
if (setMutationKind == CPKeyValueMinusSetMutation)
{
[setExistingObjects intersectSet: setMutationObjects];
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
}
else if (setMutationKind === CPKeyValueIntersectSetMutation || setMutationKind === CPKeyValueSetSetMutation)
{
[setExistingObjects minusSet: setMutationObjects];
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
}
//for unordered to-many relationships (CPSet) even new values can only be calculated before!!!
if (setMutationKind === CPKeyValueUnionSetMutation || setMutationKind === CPKeyValueSetSetMutation)
{
[setMutationObjects minusSet: setExistingObjects];
//hide new value (for CPKeyValueObservingOptionPrior messages)
//as long as "didChangeValue..." is not yet called!
changes[_CPKeyValueChangeSetMutationNewValueKey] = setMutationObjects;
}
}
else if (setMutationKind === CPKeyValueIntersectSetMutation || setMutationKind === CPKeyValueSetSetMutation)
else if (indexes)
{
[setExistingObjects minusSet: setMutationObjects];
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
var type = [changes objectForKey:CPKeyValueChangeKindKey];
// for ordered to-many relationships, oldvalue is only sensible for replace and remove
if (type === CPKeyValueChangeReplacement || type === CPKeyValueChangeRemoval)
{
//FIXME: do we need to go through and replace "" with CPNull?
var newValues = [[_targetObject mutableArrayValueForKeyPath:aKey] objectsAtIndexes:indexes];
[changes setValue:newValues forKey:CPKeyValueChangeOldKey];
}
}
else
{
var oldValue = [_targetObject valueForKey:aKey];
if (oldValue === nil || oldValue === undefined)
oldValue = [CPNull null];
[changes setObject:oldValue forKey:CPKeyValueChangeOldKey];
}
//for unordered to-many relationships (CPSet) even new values can only be calculated before!!!
if (setMutationKind === CPKeyValueUnionSetMutation || setMutationKind === CPKeyValueSetSetMutation)
{
[setMutationObjects minusSet: setExistingObjects];
//hide new value (for CPKeyValueObservingOptionPrior messages)
//as long as "didChangeValue..." is not yet called!
changes[_CPKeyValueChangeSetMutationNewValueKey] = setMutationObjects;
}
}
else if (indexes)
{
var type = [changes objectForKey:CPKeyValueChangeKindKey];
// for ordered to-many relationships, oldvalue is only sensible for replace and remove
if (type === CPKeyValueChangeReplacement || type === CPKeyValueChangeRemoval)
{
//FIXME: do we need to go through and replace "" with CPNull?
var newValues = [[_targetObject mutableArrayValueForKeyPath:aKey] objectsAtIndexes:indexes];
[changes setValue:newValues forKey:CPKeyValueChangeOldKey];
}
}
else
{
var oldValue = [_targetObject valueForKey:aKey];
if (oldValue === nil || oldValue === undefined)
oldValue = [CPNull null];
[changes setObject:oldValue forKey:CPKeyValueChangeOldKey];
}
[changes setObject:1 forKey:CPKeyValueChangeNotificationIsPriorKey];
_changesForKey[aKey] = changes;
// Clear ...New option as it should never be sent for a ...Prior option
observersMinimumOptions &= ~CPKeyValueObservingOptionNew;
}
else
{
@@ -927,55 +956,97 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
[changes removeObjectForKey:CPKeyValueChangeNotificationIsPriorKey];
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
observersMinimumOptions = _minOptionsForKey[aKey];
if (setMutationKind)
if (observersMinimumOptions & CPKeyValueObservingOptionNew)
{
//old and new values for unordered to-many relationships can only be calculated before
//set recalculated hidden new value as soon as "didChangeValue..." is called!
var newValue = changes[_CPKeyValueChangeSetMutationNewValueKey];
[changes setValue:newValue forKey:CPKeyValueChangeNewKey];
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
//delete hidden values
delete changes[_CPKeyValueChangeSetMutationNewValueKey];
delete changes[_CPKeyValueChangeSetMutationObjectsKey];
delete changes[_CPKeyValueChangeSetMutationKindKey];
}
else if (indexes)
{
var type = [changes objectForKey:CPKeyValueChangeKindKey];
// for ordered to-many relationships, newvalue is only sensible for replace and insert
if (type == CPKeyValueChangeReplacement || type == CPKeyValueChangeInsertion)
if (setMutationKind)
{
//FIXME: do we need to go through and replace "" with CPNull?
var newValues = [[_targetObject mutableArrayValueForKeyPath:aKey] objectsAtIndexes:indexes];
[changes setValue:newValues forKey:CPKeyValueChangeNewKey];
//old and new values for unordered to-many relationships can only be calculated before
//set recalculated hidden new value as soon as "didChangeValue..." is called!
var newValue = changes[_CPKeyValueChangeSetMutationNewValueKey];
[changes setValue:newValue forKey:CPKeyValueChangeNewKey];
//delete hidden values
delete changes[_CPKeyValueChangeSetMutationNewValueKey];
delete changes[_CPKeyValueChangeSetMutationObjectsKey];
delete changes[_CPKeyValueChangeSetMutationKindKey];
}
else if (indexes)
{
var type = [changes objectForKey:CPKeyValueChangeKindKey];
// for ordered to-many relationships, newvalue is only sensible for replace and insert
if (type == CPKeyValueChangeReplacement || type == CPKeyValueChangeInsertion)
{
//FIXME: do we need to go through and replace "" with CPNull?
var newValues = [[_targetObject mutableArrayValueForKeyPath:aKey] objectsAtIndexes:indexes];
[changes setValue:newValues forKey:CPKeyValueChangeNewKey];
}
}
else
{
var newValue = [_targetObject valueForKey:aKey];
if (newValue === nil || newValue === undefined)
newValue = [CPNull null];
[changes setObject:newValue forKey:CPKeyValueChangeNewKey];
}
}
delete _minOptionsForKey[aKey];
delete _changesForKey[aKey];
}
var count = observers ? observers.length : 0,
changesCache = {};
while (count--)
{
var observerInfo = observers[count],
options = observerInfo.options,
onlyNewAndOldOptions = options & kvoNewAndOld,
observerChanges = nil;
if (isBefore)
{
// Only send 'observeValueForKeyPath:' for '...Prior' option when handling 'willChangeValue...'
if (options & CPKeyValueObservingOptionPrior)
{
observerChanges = changes;
// The new values are not yet created in the change dictionary so remove ...New option to get a working cache below
onlyNewAndOldOptions &= ~CPKeyValueObservingOptionNew;
}
}
else
{
var newValue = [_targetObject valueForKey:aKey];
if (newValue === nil || newValue === undefined)
newValue = [CPNull null];
[changes setObject:newValue forKey:CPKeyValueChangeNewKey];
observerChanges = changes;
}
delete _changesForKey[aKey];
}
var observers = [_observersForKey[aKey] allValues],
count = observers ? observers.length : 0;
while (count--)
{
var observerInfo = observers[count];
if (!isBefore || (observerInfo.options & CPKeyValueObservingOptionPrior))
[observerInfo.observer observeValueForKeyPath:aKey ofObject:_targetObject change:changes context:observerInfo.context];
if (observerChanges)
{
// Don't change the 'change' dictionary when the observer wants the minimum options.
// The ...New option is remved above for the ...Prior case
if (onlyNewAndOldOptions !== observersMinimumOptions)
{
// Use a subset of the 'change' dictionary. First try to find it in the cache
observerChanges = changesCache[onlyNewAndOldOptions];
if (!observerChanges)
{
// Not in the cache. Build a new dictionary and store it in the cache
changesCache[onlyNewAndOldOptions] = observerChanges = [changes mutableCopy];
if (!(onlyNewAndOldOptions & CPKeyValueObservingOptionOld))
[observerChanges removeObjectForKey:CPKeyValueChangeOldKey];
if (!(onlyNewAndOldOptions & CPKeyValueObservingOptionNew))
[observerChanges removeObjectForKey:CPKeyValueChangeNewKey];
}
}
[observerInfo.observer observeValueForKeyPath:aKey ofObject:_targetObject change:observerChanges context:observerInfo.context];
}
}
var dependentKeysMap = _nativeClass[DependentKeysKey];
@@ -1226,13 +1297,21 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
{
if (aKeyPath === _firstPart)
{
var oldValue = [_value valueForKeyPath:_secondPart],
newValue = [_object valueForKeyPath:_firstPart + "." + _secondPart],
pathChanges = @{
CPKeyValueChangeNewKey: newValue ? newValue : [CPNull null],
CPKeyValueChangeOldKey: oldValue ? oldValue : [CPNull null],
CPKeyValueChangeKindKey: CPKeyValueChangeSetting,
};
var pathChanges = [CPMutableDictionary dictionaryWithObject:CPKeyValueChangeSetting forKey:CPKeyValueChangeKindKey];
if (_options & CPKeyValueObservingOptionOld)
{
var oldValue = [_value valueForKeyPath:_secondPart];
[pathChanges setObject:oldValue != null ? oldValue : [CPNull null] forKey:CPKeyValueChangeOldKey];
}
if (_options & CPKeyValueObservingOptionNew)
{
var newValue = [_object valueForKeyPath:_firstPart + "." + _secondPart];
[pathChanges setObject:newValue != null ? newValue : [CPNull null] forKey:CPKeyValueChangeNewKey];
}
[_observer observeValueForKeyPath:_firstPart + "." + _secondPart ofObject:_object change:pathChanges context:_context];
+18 -3
View File
@@ -345,6 +345,7 @@ var CPStringUIDs = new CFMutableDictionary(),
specified mask which can be a combination of:
<pre>
CPCaseInsensitiveSearch
CPDiacriticInsensitiveSearch
CPLiteralSearch
CPBackwardsSearch
CPAnchoredSearch
@@ -366,6 +367,7 @@ var CPStringUIDs = new CFMutableDictionary(),
options specified in the specified mask which can be a combination of:
<pre>
CPCaseInsensitiveSearch
CPDiacriticInsensitiveSearch
CPLiteralSearch
CPBackwardsSearch
CPAnchoredSearch
@@ -393,6 +395,11 @@ var CPStringUIDs = new CFMutableDictionary(),
string = string.toLowerCase();
aString = aString.toLowerCase();
}
if (aMask & CPDiacriticInsensitiveSearch)
{
string = string.stripDiacritics();
aString = aString.stripDiacritics();
}
if (aMask & CPBackwardsSearch)
{
@@ -682,6 +689,14 @@ var CPStringNull = [CPNull null];
return self.toUpperCase();
}
/*!
Returns a copy of the string stripped of diacritical marks.
*/
- (CPString)stripDiacritics
{
return self.stripDiacritics();
}
/*!
Returns the text as a floating point value.
*/
@@ -948,9 +963,9 @@ var CPStringNull = [CPNull null];
@end
var diacritics = [[192,198],[224,230],[231,231],[232,235],[236,239],[242,246],[249,252]], // Basic Latin ; Latin-1 Supplement.
normalized = [65,97,99,101,105,111,117];
var diacritics = [[192,198],[200,203],[204,207],[210,214],[217,220],[224,230],
[231,231],[232,235],[236,239],[242,246],[249,252]], // Basic Latin ; Latin-1 Supplement.
normalized = [65,69,73,79,85,97,99,101,105,111,117];
String.prototype.stripDiacritics = function()
{
+1 -1
View File
@@ -535,7 +535,7 @@ var StandardUserDefaults;
*/
- (void)setFloat:(float)aValue forKey:(CPString)aKey
{
if ([aValue respondsToSelector:@selector(aValue)])
if ([aValue respondsToSelector:@selector(floatValue)])
aValue = [aValue floatValue];
[self setObject:parseFloat(aValue) forKey:aKey];
+28 -7
View File
@@ -383,7 +383,7 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*
this.tokens = exports.acorn.parse(aString);
}
catch (e) {
if (e.lineStart)
if (e.lineStart != null)
{
var message = this.prettifyMessage(e, "ERROR");
#ifdef BROWSER
@@ -1705,6 +1705,8 @@ ClassDeclarationStatement: function(node, st, c) {
compiler.currentSuperMetaClass = "objj_getMetaClass(\"" + className + "\").super_class";
var firstIvarDeclaration = true,
ivars = classDef.ivars,
classDefIvars = [],
hasAccessors = false;
// Then we add all ivars
@@ -1714,7 +1716,6 @@ ClassDeclarationStatement: function(node, st, c) {
var ivarDecl = node.ivardeclarations[i],
ivarType = ivarDecl.ivartype ? ivarDecl.ivartype.name : null,
ivarName = ivarDecl.id.name,
ivars = classDef.ivars,
ivar = {"type": ivarType, "name": ivarName},
accessors = ivarDecl.accessors;
@@ -1736,7 +1737,10 @@ ClassDeclarationStatement: function(node, st, c) {
if (ivarDecl.outlet)
ivar.outlet = true;
ivars[ivarName] = ivar;
// Store the classDef ivars into array and add them later when accessors are created to prevent ivar duplicate error when generating accessors
classDefIvars.push(ivar);
if (!classScope.ivars)
classScope.ivars = Object.create(null);
classScope.ivars[ivarName] = {type: "ivar", name: ivarName, node: ivarDecl.id, ivar: ivar};
@@ -1774,7 +1778,8 @@ ClassDeclarationStatement: function(node, st, c) {
var getterSetterBuffer = new StringBuffer();
// Add the class declaration to compile accessors correctly
getterSetterBuffer.concat(compiler.source.substring(node.start, node.endOfIvars));
// Remove all protocols from class declaration
getterSetterBuffer.concat(compiler.source.substring(node.start, node.endOfIvars).replace(/<.*>/g, ""));
getterSetterBuffer.concat("\n");
for (var i = 0; i < node.ivardeclarations.length; ++i)
@@ -1826,7 +1831,16 @@ ClassDeclarationStatement: function(node, st, c) {
compiler.imBuffer.concat(imBuffer);
}
// We will store the classDef first after accessors are done so we don't get a duplicate class error
// We will store the ivars into the classDef first after accessors are done so we don't get a duplicate ivars error when generating accessors
for (var ivarSize = classDefIvars.length, i = 0; i < ivarSize; i++) {
var ivar = classDefIvars[i],
ivarName = ivar.name;
// Store the ivar into the classDef
ivars[ivarName] = ivar;
}
// We will store the classDef first after accessors are done so we don't get a duplicate class error when generating accessors
compiler.classDefs[className] = classDef;
var bodies = node.body,
@@ -1880,8 +1894,15 @@ ClassDeclarationStatement: function(node, st, c) {
// Lookup the protocolDefs for the protocols
var protocolDefs = [];
for (var i = 0, size = protocols.length; i < size; i++)
protocolDefs.push(compiler.getProtocolDef(protocols[i].name));
for (var i = 0, size = protocols.length; i < size; i++) {
var protocol = protocols[i],
protocolDef = compiler.getProtocolDef(protocol.name);
if (!protocolDef)
throw compiler.error_message("Cannot find protocol declaration for '" + protocol.name + "'", protocol);
protocolDefs.push(protocolDef);
}
var unimplementedMethods = classDef.listOfNotImplementedMethodsForProtocols(protocolDefs);
+85
View File
@@ -10,6 +10,9 @@
CPArray observations;
int aCount @accessors;
CPArray nameValues @accessors;
CPArray depValues @accessors;
}
- (CPArray)makeTestArray
@@ -19,6 +22,22 @@
[Employee employeeWithName:@"Tom" department:[Department departmentWithName:@"CommonJS"]]];
}
- (CPArray)makeTestArrayMany
{
var a = [[Employee employeeWithName:@"Francisco" department:[Department departmentWithName:@"Cappuccino"]],
[Employee employeeWithName:@"Ross" department:[Department departmentWithName:@"Cappuccino"]],
[Employee employeeWithName:@"Tom" department:[Department departmentWithName:@"CommonJS"]]];
var i = 10000;
while (i--)
{
[a addObject:[Employee employeeWithName:@"Martin" + i department:[Department departmentWithName:@"Magic Lightning"]]];
}
return a;
}
- (void)initControllerWithSimpleArray
{
// Copy the array to allow the original to be reused.
@@ -1054,6 +1073,54 @@
[self assert:[1, 2, 3] equals:[arrayController1 arrangedObjects] message:"normal selection"];
}
/*!
Test that bindings are not generation any change dictionary with Old or New values as a observer
*/
- (void)testCreationOfOldAndNeChangeDictionaryinObserverProtocol
{
[self initControllerWithContentBinding];
var arrayController = [self arrayController];
[self bind:@"nameValues" toObject:arrayController withKeyPath:@"arrangedObjects.name" options:nil];
countGetName = 0;
[self setItemsArray:[]];
[self assert:0 equals:countGetName];
countGetName = 0;
[self setItemsArray:[self makeTestArray]];
[self assert:3 equals:countGetName message:@"3 items in array and one '.name' bindings should make 3 accesses to the name property not " + countGetName + " times"];
}
/*!
Test the speed of set an big array when the old was an empty.
Also test the speed when an empty array is set and the old is an big
*/
- (void)testPerformance
{
[self initControllerWithContentBinding];
var arrayController = [self arrayController];
[self bind:@"nameValues" toObject:arrayController withKeyPath:@"arrangedObjects.name" options:nil];
[self bind:@"depValues" toObject:arrayController withKeyPath:@"arrangedObjects.department" options:nil];
[self setItemsArray:[]];
var bigArray = [self makeTestArrayMany];
var d = new Date();
[self setItemsArray:bigArray];
var dd = new Date();
[self setItemsArray:[]];
var ddd = new Date();
CPLog.warn("\n" + [self className] + " Performance tests");
CPLog.warn("EmptyArray -> BigArray (" + [bigArray count] + "): " + (dd - d) + "ms.");
CPLog.warn("BigArray (" + [bigArray count] + ") -> EmptyArray: " + (ddd - dd) + "ms.");
}
- (void)observeValueForKeyPath:keyPath
ofObject:anActivity
change:change
@@ -1099,8 +1166,20 @@
[_contentArray replaceObjectAtIndex:index withObject:anObject];
}
- (void)setItemsArray:(CPArray)newValue
{
[self setValue:newValue forKey:@"contentArray"];
}
- (CPArray)itemsArray
{
return [self valueForKey:@"contentArray"];
}
@end
var countGetName;
@implementation Employee : CPObject
{
CPString _name @accessors(property=name);
@@ -1128,6 +1207,12 @@
return [CPString stringWithFormat:@"<Employee %@>", [self name]];
}
- (CPString)name
{
countGetName++;
return _name;
}
@end
@implementation Department : CPObject
-38
View File
@@ -13,12 +13,6 @@
_globalResults = nil;
}
// delegate method
- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView
{
_globalResults = "selection changed: " + [[aCollectionView selectionIndexes] count];
}
- (void)testItemPrototypeActuallyReturnsTheItemPrototype
{
var itemPrototype = [[CPCollectionViewItem alloc] init];
@@ -57,38 +51,6 @@
[self assert:[collectionView reloadContentCallCount] equals:reloadContentCount + 1 message:@"subsequent calls to setContent should have called reloadContent once"];
}
- (void)testCallCollectionViewDidChangeSelectionDelegateMethod
{
var content1 = ["a", "b", "c"],
content2 = ["d", "e", "f"];
[_collectionView setSelectable:YES];
[_collectionView setDelegate:self];
[_collectionView setContent:content1];
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
// the first time the delegate does get called
[self assert:"selection changed: 1" equals:_globalResults];
_globalResults = nil;
// setContent: by itself should not affect the selection.
[_collectionView setContent:content1];
[self assert:nil equals:_globalResults];
// Manually clear the selection.
[_collectionView setSelectionIndexes:[CPIndexSet indexSet]];
_globalResults = nil;
// now lets change the contents
[_collectionView setContent:content2];
// we set the selection to 0 again, but on the NEW content
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
[self assert:"selection changed: 1" equals:_globalResults];
_globalResults = nil;
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]];
[self assert:"selection changed: 1" equals:_globalResults];
}
- (void)testSelectionIndexes
{
[_collectionView setSelectionIndexes:[CPIndexSet indexSetWithIndex:0]];
+2
View File
@@ -21,6 +21,8 @@
[self assert:0 equals:[anEvent deltaX] message:"default event delta X should be 0"];
[self assert:0 equals:[anEvent deltaY] message:"default event delta Y should be 0"];
[self assert:0 equals:[anEvent deltaZ] message:"default event delta Z should be 0"];
[self assert:0 equals:[anEvent scrollingDeltaX] message:"default event scrolling delta X should be 0"];
[self assert:0 equals:[anEvent scrollingDeltaY] message:"default event scrolling delta Y should be 0"];
}
- (void)testDescription
+45
View File
@@ -315,6 +315,51 @@
[self assert:0 equals:[control objectValueSetterCount] message:@"-setObjectValue should not be called"];
}
- (void)testMultipleBindingsToArrayControllerSelection
{
var control1 = [[TextField alloc] init],
control2 = [[TextField alloc] init],
cheese1 = [BindingTester testerWithCheese:@"roblochon"],
cheese2 = [BindingTester testerWithCheese:@"brie"],
ac = [[CPArrayController alloc] initWithContent:@[cheese1, cheese2]],
oc = [[CPObjectController alloc] init];
// This tests fails only if multiple controls are bound BEFORE the object controller
[control1 bind:CPValueBinding toObject:oc withKeyPath:@"selection.cheese" options:nil];
[control2 bind:CPValueBinding toObject:oc withKeyPath:@"selection.cheese" options:nil];
[oc bind:CPContentBinding toObject:ac withKeyPath:@"selection" options:nil];
[ac setSelectionIndex:0];
[self assert:@"roblochon" equals:[control1 objectValue] message:@"control1 objectValue is wrong"];
[self assert:@"roblochon" equals:[control2 objectValue] message:@"control2 objectValue is wrong"];
[ac setSelectionIndex:1];
[self assert:@"brie" equals:[control1 objectValue] message:@"control1 objectValue is wrong"];
[self assert:@"brie" equals:[control2 objectValue] message:@"control2 objectValue is wrong"];
}
- (void)testExclusiveBindings
{
var segmented = [[CPSegmentedControl alloc] initWithFrame:CGRectMakeZero()];
[segmented setSegmentCount:3];
var model = [BindingTester testerWithCheese:2];
[segmented bind:CPSelectedIndexBinding toObject:model withKeyPath:@"cheese" options:nil];
// Try to bind another binding (mutually exclusive) to the same value.
[segmented bind:CPSelectedTagBinding toObject:model withKeyPath:@"cheese" options:nil];
[self assertNotNull:[segmented infoForBinding:CPSelectedIndexBinding]];
// Check that the source is not binded with the CPSelectedTagBinding
[self assertNull:[segmented infoForBinding:CPSelectedTagBinding]];
}
@end
@implementation TextField : CPTextField
+62
View File
@@ -209,6 +209,68 @@
[self assertTrue:[outlineView isItemExpanded:".1"] message:".1 is still expanded, cannot collapse"];
}
- (void)testRowForItem
{
[self assert:2 equals:[outlineView rowForItem:@".1.2"] message:".1.2 row number is wrong"];
[self assert:6 equals:[outlineView rowForItem:@".3"] message:".3 row number is wrong"];
[outlineView collapseItem:".1"];
[self assert:CPNotFound equals:[outlineView rowForItem:@".1.2"] message:".1.2 row number is wrong"];
[self assert:2 equals:[outlineView rowForItem:@".3"] message:".3 row number is wrong"];
[outlineView expandItem:".1"];
[self assert:2 equals:[outlineView rowForItem:@".1.2"] message:".1.2 row number is wrong"];
[self assert:6 equals:[outlineView rowForItem:@".3"] message:".3 row is number wrong"];
}
- (void)testItemAtRow
{
[self assert:@".1.2" equals:[outlineView itemAtRow:2] message:"itemAtRow 2 is wrong"];
[self assert:@".3" equals:[outlineView itemAtRow:6] message:"itemAtRow 6 is wrong"];
[self assert:nil equals:[outlineView itemAtRow:8] message:"itemAtRow 8 is wrong"];
[outlineView collapseItem:".1"];
[self assert:@".3" equals:[outlineView itemAtRow:2] message:"itemAtRow 2 is wrong"];
[self assert:nil equals:[outlineView itemAtRow:5] message:"itemAtRow 5 is wrong"];
[outlineView expandItem:".1"];
[self assert:@".1.2" equals:[outlineView itemAtRow:2] message:"itemAtRow 2 is wrong"];
[self assert:@".3" equals:[outlineView itemAtRow:6] message:"itemAtRow 6 is wrong"];
[self assert:nil equals:[outlineView itemAtRow:8] message:".itemAtRow 8 is wrong"];
}
- (void)testItemIsExpanded
{
[self assert:YES equals:[outlineView isItemExpanded:@".1.2"] message:".1.2 expanded value is wrong"];
[self assert:YES equals:[outlineView isItemExpanded:@".3"] message:".3 expanded value is wrong"];
[outlineView collapseItem:".1"];
[self assert:NO equals:[outlineView isItemExpanded:@".1.2"] message:".1.2 expanded value is wrong"];
[self assert:YES equals:[outlineView isItemExpanded:@".3"] message:".3 expanded value is wrong"];
[outlineView expandItem:".1"];
[self assert:YES equals:[outlineView isItemExpanded:@".1.2"] message:".1.2 expanded value is wrong"];
[self assert:YES equals:[outlineView isItemExpanded:@".3"] message:".3 expanded value is wrong"];
}
- (void)testLevelForItem
{
[self assert:1 equals:[outlineView levelForItem:@".1.2"] message:".1.2 level value is wrong"];
[self assert:0 equals:[outlineView levelForItem:@".3"] message:".3 level value is wrong"];
[outlineView collapseItem:".1"];
[self assert:CPNotFound equals:[outlineView levelForItem:@".1.2"] message:".1.2 level value is wrong"];
[self assert:0 equals:[outlineView levelForItem:@".3"] message:".3 level value is wrong"];
[outlineView expandItem:".1"];
[self assert:1 equals:[outlineView levelForItem:@".1.2"] message:".1.2 level value is wrong"];
[self assert:0 equals:[outlineView levelForItem:@".3"] message:".3 level value is wrong"];
}
- (void)testLevelForRow
{
[self assert:2 equals:[outlineView levelForRow:3] message:"levelForRow 2 is wrong"];
[self assert:0 equals:[outlineView levelForRow:6] message:"levelForRow 6 is wrong"];
[outlineView collapseItem:".1"];
[self assert:0 equals:[outlineView levelForRow:2] message:"levelForRow 2 is wrong"];
[self assert:CPNotFound equals:[outlineView levelForRow:4] message:"levelForRow 4 is wrong"];
[outlineView expandItem:".1"];
[self assert:2 equals:[outlineView levelForRow:3] message:"levelForRow 2 is wrong"];
[self assert:0 equals:[outlineView levelForRow:6] message:"levelForRow 0 is wrong"];
}
/*!
Test that the outline view archives properly.
*/
+83
View File
@@ -4,8 +4,33 @@
@implementation CPTokenFieldTest : OJTestCase
{
CPWindow _theWindow;
CPTokenField _tokenField;
TestDelegateTokenField _delegate;
}
- (void)setUp
{
_theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1024.0, 768.0)
styleMask:CPWindowNotSizable];
_tokenField = [CPTokenField new];
_delegate = [TestDelegateTokenField new];
[_tokenField setDelegate:_delegate];
[[_theWindow contentView] addSubview:_tokenField];
}
- (void)tearDown
{
}
#pragma mark -
#pragma mark Test creation
- (void)testArchiving
{
var tokenField = [CPTokenField new];
@@ -28,4 +53,62 @@
[[aWindow contentView] addSubview:tokenField];
}
#pragma mark -
#pragma mark Test objectValue and stringValue
/*!
This is totally different than cocoa
*/
- (void)testSetObjectValueWithString
{
[_tokenField setObjectValue:@"Alexandre"];
[self assert:[_tokenField stringValue] equals:""];
}
- (void)testObjectValueWithArrayOfStrings
{
[_tokenField setObjectValue:[@"Alexandre", @"Antoine"]];
[self assert:[_tokenField objectValue] equals:[@"Alexandre", @"Antoine"]];
}
- (void)testStringValueWithArrayOfStrings
{
[_tokenField setObjectValue:[@"Alexandre", @"Antoine"]];
[self assert:[_tokenField stringValue] equals:@"Alexandre,Antoine"];
}
#pragma mark -
#pragma mark Delegate methods
- (void)testDelegateDisplayStringForRepresentedObject
{
[_tokenField setObjectValue:[@"Alexandre", @"Antoine"]];
[self assert:[_delegate representedObjects] equals:[@"Alexandre", @"Antoine"]];
}
@end
@implementation TestDelegateTokenField : CPObject <CPTokenFieldDelegate>
{
CPArray _representedObjects @accessors(property=representedObjects);
}
- (id)init
{
if (self = [super init])
{
_representedObjects = [];
}
return self;
}
- (CPString)tokenField:(CPTokenField)tokenField displayStringForRepresentedObject:(id)representedObject
{
[_representedObjects addObject:representedObject];
return representedObject;
}
@end
+222
View File
@@ -4,14 +4,33 @@
[CPApplication sharedApplication]
var methodCalled;
@implementation CPViewTest : OJTestCase
{
CPView view;
CPView view1;
CPView view2;
CPView view3;
CPWindow window;
}
- (void)setUp
{
window = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1000.0, 1000.0) styleMask:CPWindowNotSizable];
view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
view1 = [[CPResponderView alloc] initWithFrame:CGRectMakeZero()];
view2 = [[CPResponderView alloc] initWithFrame:CGRectMakeZero()];
view3 = [[CPResponderView alloc] initWithFrame:CGRectMakeZero()];
[view1 setIdentifier:@"view1"];
[view2 setIdentifier:@"view2"];
[view3 setIdentifier:@"view3"];
methodCalled = [];
[super setUp];
}
@@ -446,10 +465,213 @@
[self assertFalse:[subview hasThemeState:CPThemeStateFirstResponder]];
}
- (void)testWhenAddedSubviewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewWithoutWindowMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2"];
[view1 addSubview:view2];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewTwiceMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[[window contentView] addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenRemovedSubviewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1"];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewThenRemovedSubviewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
methodCalled = [];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewThenRemovedSubviewWithoutWindowMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1"];
[view1 addSubview:view2];
methodCalled = [];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2",@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", "viewDidMoveToWindow_view1"];
[view1 addSubview:view2];
[[window contentView] addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenRemovedMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", "viewDidMoveToWindow_view1"];
[view1 addSubview:view2];
[[window contentView] addSubview:view1];
methodCalled = [];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenAddedTheViewToAnotherViewWithoutWindowMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", @"viewWillMoveToWindow_view1", @"viewDidMoveToWindow_view1", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", @"viewWillMoveToWindow_view1", @"viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[view2 addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedOneSubviewsWithSetSubviewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] setSubviews:[view1]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsWithSetSubviewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1", @"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2"];
[[window contentView] setSubviews:[view1, view2]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenSetSubviewsWithOneViewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2"];
[[window contentView] setSubviews:[view1, view2]];
methodCalled = [];
[[window contentView] setSubviews:[view1]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenSetSubviewsWithTwoViewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", @"viewWillMoveToSuperview_view3", @"viewDidMoveToSuperview_view3", "viewWillMoveToWindow_view3", "viewDidMoveToWindow_view3"];
[[window contentView] setSubviews:[view1, view2]];
methodCalled = [];
[[window contentView] setSubviews:[view1, view3]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenReplacedViewWithSameViewMethodCalled
{
var expectedRestult = [];
[[window contentView] addSubview:view1];
methodCalled = [];
[[window contentView] replaceSubview:view1 with:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenReplacedViewWithOtherViewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
methodCalled = [];
[[window contentView] replaceSubview:view1 with:view2];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenReplacedViewWithOtherAddedViewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[[window contentView] addSubview:view2];
methodCalled = [];
[[window contentView] replaceSubview:view1 with:view2];
[self assert:expectedRestult equals:methodCalled];
}
@end
@implementation CPResponderView : CPView
- (void)viewDidMoveToSuperview
{
var string = @"viewDidMoveToSuperview_" + [self identifier];
[methodCalled addObject:string];
}
- (void)viewDidMoveToWindow
{
var string = @"viewDidMoveToWindow_" + [self identifier];
[methodCalled addObject:string];
}
- (void)viewWillMoveToSuperview:(CPView)newSuperview
{
var string = @"viewWillMoveToSuperview_" + [self identifier];
[methodCalled addObject:string];
}
- (void)viewWillMoveToWindow:(CPWindow)newWindow
{
var string = @"viewWillMoveToWindow_" + [self identifier];
[methodCalled addObject:string];
}
- (BOOL)acceptsFirstResponder
{
return YES;
+135
View File
@@ -35,6 +35,7 @@
{
CPDate _date;
CPDateFormatter _dateFormatter;
CPDateFormatter _nonEnDateFormatter;
}
- (void)setUp
@@ -45,6 +46,9 @@
[_dateFormatter setTimeStyle:CPDateFormatterShortStyle];
[_dateFormatter setLocale:[[CPLocale alloc] initWithLocaleIdentifier:@"en_US"]];
[_dateFormatter setTimeZone:[CPTimeZone timeZoneWithAbbreviation:@"PDT"]];
_nonEnDateFormatter = [[CPDateFormatter alloc] init];
[_nonEnDateFormatter setLocale:[[CPLocale alloc] initWithLocaleIdentifier:@"pt"]];
}
@@ -1219,4 +1223,135 @@
[self assert:error equals:@"The value \"ezr 12\" is invalid."];
}
#pragma mark -
#pragma mark non-en locales
// Unless we have full locale support any non-supported locale should return the english values as they are the only defined ones at the moment.
- (void)testGetNonEnAMSymbol
{
var enValue = [_dateFormatter AMSymbol],
value = [_nonEnDateFormatter AMSymbol];
[self assert:enValue equals:value];
}
- (void)testGetNonEnPMSymbol
{
var enValue = [_dateFormatter PMSymbol],
value = [_nonEnDateFormatter PMSymbol];
[self assert:enValue equals:value];
}
- (void)testGetNonEnWeekdaySymbols
{
var enValue = [_dateFormatter weekdaySymbols],
value = [_nonEnDateFormatter weekdaySymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnShortWeekdaySymbols
{
var enValue = [_dateFormatter shortWeekdaySymbols],
value = [_nonEnDateFormatter shortWeekdaySymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnVeryShortWeekdaySymbols
{
var enValue = [_dateFormatter veryShortWeekdaySymbols],
value = [_nonEnDateFormatter veryShortWeekdaySymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnStandaloneWeekdaySymbols
{
var enValue = [_dateFormatter standaloneWeekdaySymbols],
value = [_nonEnDateFormatter standaloneWeekdaySymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnShortStandaloneWeekdaySymbols
{
var enValue = [_dateFormatter shortStandaloneWeekdaySymbols],
value = [_nonEnDateFormatter shortStandaloneWeekdaySymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnVeryShortStandaloneWeekdaySymbols
{
var enValue = [_dateFormatter veryShortStandaloneWeekdaySymbols],
value = [_nonEnDateFormatter veryShortStandaloneWeekdaySymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnMonthSymbols
{
var enValue = [_dateFormatter monthSymbols],
value = [_nonEnDateFormatter monthSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnShortMonthSymbols
{
var enValue = [_dateFormatter shortMonthSymbols],
value = [_nonEnDateFormatter shortMonthSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnVeryShortMonthSymbols
{
var enValue = [_dateFormatter veryShortMonthSymbols],
value = [_nonEnDateFormatter veryShortMonthSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnStandaloneMonthSymbols
{
var enValue = [_dateFormatter standaloneMonthSymbols],
value = [_nonEnDateFormatter standaloneMonthSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnShortStandaloneMonthSymbols
{
var enValue = [_dateFormatter shortStandaloneMonthSymbols],
value = [_nonEnDateFormatter shortStandaloneMonthSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnVeryShortStandaloneMonthSymbols
{
var enValue = [_dateFormatter veryShortStandaloneMonthSymbols],
value = [_nonEnDateFormatter veryShortStandaloneMonthSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnQuarterSymbols
{
var enValue = [_dateFormatter quarterSymbols],
value = [_nonEnDateFormatter quarterSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnShortQuarterSymbols
{
var enValue = [_dateFormatter shortQuarterSymbols],
value = [_nonEnDateFormatter shortQuarterSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnStandaloneQuarterSymbols
{
var enValue = [_dateFormatter standaloneQuarterSymbols],
value = [_nonEnDateFormatter standaloneQuarterSymbols];
[self assert:enValue equals:value];
}
- (void)testGetNonEnShortStandaloneQuarterSymbols
{
var enValue = [_dateFormatter shortStandaloneQuarterSymbols],
value = [_nonEnDateFormatter shortStandaloneQuarterSymbols];
[self assert:enValue equals:value];
}
@end
+89 -31
View File
@@ -29,7 +29,7 @@
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:@"testAddObserver"];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testAddObserver"];
[bob setValue:@"bob" forKey:@"name"];
@@ -42,7 +42,7 @@
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:@"testUnobservedKey"];
[bob addObserver:self forKeyPath:@"name" options:0 context:@"testUnobservedKey"];
[bob setValue:@"555" forKey:@"phoneNumber"];
@@ -54,8 +54,8 @@
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:@"testAddTwoObservers"];
[bob addObserver:[CPObject new] forKeyPath:@"name" options:nil context:@"testAddTwoObservers"];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testAddTwoObservers"];
[bob addObserver:[CPObject new] forKeyPath:@"name" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testAddTwoObservers"];
[bob setValue:@"bob" forKey:@"name"];
@@ -68,7 +68,7 @@
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"phoneNumber" options:nil context:@"testDirectIVarObservation"];
[bob addObserver:self forKeyPath:@"phoneNumber" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testDirectIVarObservation"];
[bob setValue:@"555" forKey:@"phoneNumber"];
@@ -81,8 +81,8 @@
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:@"testRemoveObserver"];
[bob addObserver:[CPString new] forKeyPath:@"name" options:nil context:@"testRemoveObserver"];
[bob addObserver:self forKeyPath:@"name" options:0 context:@"testRemoveObserver"];
[bob addObserver:[CPString new] forKeyPath:@"name" options:0 context:@"testRemoveObserver"];
[bob removeObserver:self forKeyPath:@"name"];
@@ -96,8 +96,8 @@
bob = [[PersonTester alloc] init];
obj = [CPString new];
[bob addObserver:self forKeyPath:@"name" options:nil context:@"testRemoveOtherObserver"];
[bob addObserver:obj forKeyPath:@"name" options:nil context:@"testRemoveOtherObserver"];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testRemoveOtherObserver"];
[bob addObserver:obj forKeyPath:@"name" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testRemoveOtherObserver"];
[bob removeObserver:obj forKeyPath:@"name"];
@@ -113,8 +113,8 @@
obj = [CPArray new];
obj2 = [CPString new];
[bob addObserver:obj forKeyPath:@"name" options:nil context:@"testRemoveAllObservers"];
[bob addObserver:obj2 forKeyPath:@"name" options:nil context:@"testRemoveAllObservers"];
[bob addObserver:obj forKeyPath:@"name" options:0 context:@"testRemoveAllObservers"];
[bob addObserver:obj2 forKeyPath:@"name" options:0 context:@"testRemoveAllObservers"];
[bob removeObserver:obj forKeyPath:@"name"];
[bob removeObserver:obj2 forKeyPath:@"name"];
@@ -133,7 +133,7 @@
[dict addObserver:self
forKeyPath:@"dictionaryKey"
options:nil
options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld
context:@"testDictionary"];
[dict setObject:@"Jo Bob Ray" forKey:@"dictionaryKey"];
@@ -147,7 +147,20 @@
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionPrior context:@"testPriorObservationOption"];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionPrior | CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testPriorObservationOption"];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue:_sawPriorObservation message:@"asked for CPKeyValueObservingOptionPrior but did not recieve corresponding notification"];
}
- (void)testPriorObservationOptionNoOld
{
_sawPriorObservation = NO;
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionPrior | CPKeyValueObservingOptionNew context:@"testPriorObservationOptionNoOld"];
[bob setValue:@"bob" forKey:@"name"];
@@ -162,7 +175,23 @@
bob.name = "paul";
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionInitial context:@"testInitialObservationOption"];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionInitial | CPKeyValueObservingOptionNew context:@"testInitialObservationOption"];
[bob removeObserver:self forKeyPath:@"name"];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue:_sawInitialObservation message:@"asked for CPKeyValueObservingOptionInitial but did not recieve corresponding notification"];
}
- (void)testInitialObservationOptionNoNew
{
_sawInitialObservation = NO;
bob = [[PersonTester alloc] init];
bob.name = "paul";
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionInitial context:@"testInitialObservationOptionNoNew"];
[bob removeObserver:self forKeyPath:@"name"];
[bob setValue:@"bob" forKey:@"name"];
@@ -178,8 +207,8 @@
bob.name = "paul";
[bob addObserver:self forKeyPath:@"bobName" options:0 context:@"testDependentKeyObservation"];
[bob addObserver:self forKeyPath:@"twiceRemoved" options:0 context:@"testDependentKeyObservation2"];
[bob addObserver:self forKeyPath:@"bobName" options:CPKeyValueObservingOptionOld context:@"testDependentKeyObservation"];
[bob addObserver:self forKeyPath:@"twiceRemoved" options:CPKeyValueObservingOptionOld context:@"testDependentKeyObservation2"];
[bob setValue:@"bob" forKey:@"name"];
@@ -194,7 +223,7 @@
[cs101 setTeacher:bob];
[cs101 addObserver:self forKeyPath:@"teacher.name" options:0 context:@"testMultipartKey"];
[cs101 addObserver:self forKeyPath:@"teacher.name" options:CPKeyValueObservingOptionNew context:@"testMultipartKey"];
[bob setName:@"bob"];
@@ -209,7 +238,7 @@
[bob setValue:focus forKey:@"car"];
[bob addObserver:self forKeyPath:@"self.car.thisCar.model" options:0 context:@"testMultiPartKeysWhereValuesEvaluateToSelf"];
[bob addObserver:self forKeyPath:@"self.car.thisCar.model" options:CPKeyValueObservingOptionNew context:@"testMultiPartKeysWhereValuesEvaluateToSelf"];
[focus setValue:@"ford focus" forKey:@"model"];
@@ -225,7 +254,7 @@
[cs101 setTeacher:bob];
[bob setValue:focus forKey:@"car"];
[cs101 addObserver:self forKeyPath:@"teacher.car.model" options:0 context:@"testThreePartKey"];
[cs101 addObserver:self forKeyPath:@"teacher.car.model" options:CPKeyValueObservingOptionNew context:@"testThreePartKey"];
[focus setValue:@"ford focus" forKey:@"model"];
[self assertTrue: _sawObservation message:@"Never recieved an observation"];
@@ -240,7 +269,7 @@
[cs101 setTeacher:bob];
[focus setValue:@"2000" forKey:@"year"];
[cs101 addObserver:self forKeyPath:@"teacher.car.year" options:0 context:@"testThreePartKeyPart2"];
[cs101 addObserver:self forKeyPath:@"teacher.car.year" options:CPKeyValueObservingOptionNew context:@"testThreePartKeyPart2"];
[bob setValue:focus forKey:@"car"];
@@ -290,7 +319,7 @@
[a setValue:[E new] forKeyPath:@"b.c.d.e"];
[a setValue:[F new] forKeyPath:@"b.c.d.e.f"];
[a addObserver:self forKeyPath:@"b.c.d.e.f" options:0 context:@"testCrazyKeyPathChanges"];
[a addObserver:self forKeyPath:@"b.c.d.e.f" options:CPKeyValueObservingOptionNew context:@"testCrazyKeyPathChanges"];
var newD = [D new];
@@ -311,7 +340,7 @@
[a setValue:[E new] forKeyPath:@"b.c.d.e"];
[a setValue:[F new] forKeyPath:@"b.c.d.e.f"];
[a addObserver:self forKeyPath:@"b.c.d.e.f" options:0 context:@"testCrazyKeyPathChanges2"];
[a addObserver:self forKeyPath:@"b.c.d.e.f" options:CPKeyValueObservingOptionNew context:@"testCrazyKeyPathChanges2"];
[a setValue:nil forKeyPath:@"b.c"];
@@ -328,7 +357,7 @@
[a setValue:[E new] forKeyPath:@"b.c.d.e"];
[a setValue:[F new] forKeyPath:@"b.c.d.e.f"];
[a addObserver:self forKeyPath:@"b.c.d.e.f" options:0 context:@"testCrazyKeyPathChanges3"];
[a addObserver:self forKeyPath:@"b.c.d.e.f" options:CPKeyValueObservingOptionNew context:@"testCrazyKeyPathChanges3"];
[a setValue:7 forKeyPath:@"b.c.d.e.f"];
@@ -341,7 +370,7 @@
[tester setValue:[1, 2, 3, 4] forKey:@"managedObjects"];
[tester addObserver:self forKeyPath:@"managedObjects" options:0 context:@"testInsertIntoToManyProperty"];
[tester addObserver:self forKeyPath:@"managedObjects" options:CPKeyValueObservingOptionNew context:@"testInsertIntoToManyProperty"];
[tester insertObject:5 inManagedObjectsAtIndex:4];
@@ -354,7 +383,7 @@
[tester setValue:[1, 2, 3, 4] forKey:@"managedObjects"];
[tester addObserver:self forKeyPath:@"managedObjects" options:0 context:@"testRemoveFromToManyProperty"];
[tester addObserver:self forKeyPath:@"managedObjects" options:CPKeyValueObservingOptionOld context:@"testRemoveFromToManyProperty"];
[tester removeObjectFromManagedObjectsAtIndex:0];
@@ -367,7 +396,7 @@
tester.tester = [ToManyTester new];
[tester.tester setValue:[1, 2, 3, 4] forKey:@"managedObjects"];
[tester addObserver:self forKeyPath:@"tester.managedObjects" options:0 context:@"testInsertIntoToManyPropertyIndirectly"];
[tester addObserver:self forKeyPath:@"tester.managedObjects" options:CPKeyValueObservingOptionNew context:@"testInsertIntoToManyPropertyIndirectly"];
[tester.tester insertObject:5 inManagedObjectsAtIndex:4];
@@ -381,7 +410,7 @@
tester.tester = [ToManyTester new];
[tester.tester setValue:[1, 2, 3, 4] forKey:@"subviews"];
[tester addObserver:self forKeyPath:@"tester.subviews" options:0 context:@"testInsertIntoArrayPropertyIndirectly"];
[tester addObserver:self forKeyPath:@"tester.subviews" options:CPKeyValueObservingOptionNew context:@"testInsertIntoArrayPropertyIndirectly"];
[tester.tester insertSubview:5 atIndex:4];
@@ -395,7 +424,7 @@
tester.tester = [ToManyTester new];
[tester.tester setValue:[1, 2, 3, 4] forKey:@"subviews"];
[tester addObserver:self forKeyPath:@"tester.subviews" options:0 context:@"testChangeTopLevelObject"];
[tester addObserver:self forKeyPath:@"tester.subviews" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:@"testChangeTopLevelObject"];
var newTesterTester = [ToManyTester new];
[newTesterTester setValue:[5, 6, 7, 8] forKey:@"subviews"];
@@ -554,7 +583,24 @@
if (!_sawPriorObservation)
{
[self assertTrue:prior message:@"Have not been sent the prior notification, but it should have been sent"];
[self assertTrue:oldValue == [CPNull null] message:@"Shoudl be no initial value"];
[self assertTrue:oldValue == [CPNull null] message:@"Should be no initial value"];
[self assertFalse:newValue message:@"Should be no object for the new value key on the prior notification"];
_sawPriorObservation = YES;
}
else
{
[self assertFalse:prior message:@"there should be no value for the notification is prior key, that notification was already sent"];
[self assertTrue:newValue == "set_bob" message:@"newValue should be: set_bob was: " + newValue];
}
break;
case "testPriorObservationOptionNoOld":
var prior = [changes objectForKey:CPKeyValueChangeNotificationIsPriorKey];
if (!_sawPriorObservation)
{
[self assertTrue:prior message:@"Have not been sent the prior notification, but it should have been sent"];
[self assertTrue:oldValue == nil message:@"Should be no old value"];
[self assertFalse:newValue message:@"Should be no object for the new value key on the prior notification"];
_sawPriorObservation = YES;
}
@@ -568,8 +614,20 @@
case "testInitialObservationOption":
if (!_sawInitialObservation)
{
[self assertTrue:newValue == "paul" message:@"Expected old value to be: paul was: " + oldValue];
[self assertFalse:oldValue message:@"Should be no value for new change key on initial observation"];
[self assertTrue:newValue == "paul" message:@"Expected new value to be: paul was: " + newValue];
[self assertTrue:oldValue == nil message:@"Should be no value for old change key on initial observation"];
_sawInitialObservation = YES;
}
else
[self assertFalse:YES message:@"Should never have received this notification"];
break;
case "testInitialObservationOptionNoNew":
if (!_sawInitialObservation)
{
[self assertTrue:newValue == nil message:@"New value should not be included"];
[self assertTrue:oldValue == nil message:@"Should be no value for old change key on initial observation"];
_sawInitialObservation = YES;
}
else
+236 -4
View File
@@ -2,6 +2,7 @@
@import <Foundation/CPKeyValueCoding.j>
@import <Foundation/CPKeyValueObserving.j>
var _getCheeseCounter;
@implementation CPKeyValueObservingTest : OJTestCase
{
@@ -9,6 +10,12 @@
id _lastObject;
CPDictionary _lastChange;
id _lastContext;
CPString _secondLastKeyPath;
id _secondLastObject;
CPDictionary _secondLastChange;
id _secondLastContext;
}
- (Class)objectWithMethods:(CPString)aMethodName, ...
@@ -26,9 +33,10 @@
return [theClass new];
}
- (void)setup
- (void)setUp
{
_lastKeyPath = _lastObject = _lastChange = _lastContext = nil;
_lastKeyPath = _lastObject = _lastChange = _lastContext = _secondLastKeyPath = _secondLastObject = _secondLastChange = _secondLastContext = nil;
_getCheeseCounter = 0;
}
- (void)testInitialObserving
@@ -38,18 +46,210 @@
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:[CPDictionary dictionaryWithObject:@"CHEESE!" forKey:CPKeyValueChangeNewKey] equals:_lastChange];
[self assert:@{CPKeyValueChangeNewKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
}
- (void)testInitialObservingNoNew
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionInitial context:nil];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
}
- (void)testSettingObservingPrior
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionPrior context:nil];
[tester setValue:@"NEW CHEESE!" forKey:@"cheese"];
[self assert:@"cheese" equals:_secondLastKeyPath];
[self assert:tester equals:_secondLastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting, CPKeyValueChangeNotificationIsPriorKey: 1} equals:_secondLastChange];
[self assert:nil equals:_secondLastContext];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
[self assert:0 equals:_getCheeseCounter message:@"Get method should never be called"];
}
- (void)testSettingObservingPriorPlusMoreObservers
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionPrior context:nil];
var observerWithOld = [[AnotherObserver alloc] init];
[tester addObserver:observerWithOld forKeyPath:@"cheese" options:CPKeyValueObservingOptionPrior | CPKeyValueObservingOptionOld context:nil];
var observerWithNew = [[AnotherObserver alloc] init];
[tester addObserver:observerWithNew forKeyPath:@"cheese" options:CPKeyValueObservingOptionPrior | CPKeyValueObservingOptionNew context:nil];
var observerWithNewAndOld = [[AnotherObserver alloc] init];
[tester addObserver:observerWithNewAndOld forKeyPath:@"cheese" options:CPKeyValueObservingOptionPrior | CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:nil];
[tester setValue:@"NEW CHEESE!" forKey:@"cheese"];
[self assert:@"cheese" equals:_secondLastKeyPath];
[self assert:tester equals:_secondLastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting, CPKeyValueChangeNotificationIsPriorKey: 1} equals:_secondLastChange];
[self assert:nil equals:_secondLastContext];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
[self assert:@"cheese" equals:observerWithOld._secondLastKeyPath];
[self assert:tester equals:observerWithOld._secondLastObject];
[self assert:@{CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting, CPKeyValueChangeNotificationIsPriorKey: 1} equals:observerWithOld._secondLastChange];
[self assert:nil equals:observerWithOld._secondLastContext];
[self assert:@"cheese" equals:observerWithOld._lastKeyPath];
[self assert:tester equals:observerWithOld._lastObject];
[self assert:@{CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:observerWithOld._lastChange];
[self assert:nil equals:observerWithOld._lastContext];
[self assert:@"cheese" equals:observerWithNew._secondLastKeyPath];
[self assert:tester equals:observerWithNew._secondLastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting, CPKeyValueChangeNotificationIsPriorKey: 1} equals:observerWithNew._secondLastChange];
[self assert:nil equals:observerWithNew._secondLastContext];
[self assert:@"cheese" equals:observerWithNew._lastKeyPath];
[self assert:tester equals:observerWithNew._lastObject];
[self assert:@{CPKeyValueChangeNewKey: @"NEW CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:observerWithNew._lastChange];
[self assert:nil equals:observerWithNew._lastContext];
[self assert:@"cheese" equals:observerWithNewAndOld._secondLastKeyPath];
[self assert:tester equals:observerWithNewAndOld._secondLastObject];
[self assert:@{CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting, CPKeyValueChangeNotificationIsPriorKey: 1} equals:observerWithNewAndOld._secondLastChange];
[self assert:nil equals:observerWithNewAndOld._secondLastContext];
[self assert:@"cheese" equals:observerWithNewAndOld._lastKeyPath];
[self assert:tester equals:observerWithNewAndOld._lastObject];
[self assert:@{CPKeyValueChangeNewKey: @"NEW CHEESE!", CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:observerWithNewAndOld._lastChange];
[self assert:nil equals:observerWithNewAndOld._lastContext];
[self assert:2 equals:_getCheeseCounter message:@"Get method should only be called twice, not " + _getCheeseCounter + " times"];
}
- (void)testSettingObserving
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:0 context:nil];
[tester setValue:@"NEW CHEESE!" forKey:@"cheese"];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
[self assert:0 equals:_getCheeseCounter message:@"Get method should never be called"];
}
- (void)testSettingObservingNewPlusAnotherObserverWithNoNew
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionNew context:nil];
var anotherObserver = [[AnotherObserver alloc] init];
[tester addObserver:anotherObserver forKeyPath:@"cheese" options:0 context:nil];
[tester setValue:@"NEW CHEESE!" forKey:@"cheese"];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeNewKey: @"NEW CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
[self assert:@"cheese" equals:anotherObserver._lastKeyPath];
[self assert:tester equals:anotherObserver._lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:anotherObserver._lastChange];
[self assert:nil equals:anotherObserver._lastContext];
[self assert:1 equals:_getCheeseCounter message:@"Get method should only be called once, not " + _getCheeseCounter + " times"];
}
- (void)testSettingObservingOldPlusAnotherObserverWithNoOld
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionOld context:nil];
var anotherObserver = [[AnotherObserver alloc] init];
[tester addObserver:anotherObserver forKeyPath:@"cheese" options:0 context:nil];
[tester setValue:@"NEW CHEESE!" forKey:@"cheese"];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
[self assert:@"cheese" equals:anotherObserver._lastKeyPath];
[self assert:tester equals:anotherObserver._lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:anotherObserver._lastChange];
[self assert:nil equals:anotherObserver._lastContext];
[self assert:1 equals:_getCheeseCounter message:@"Get method should only be called once, not " + _getCheeseCounter + " times"];
}
- (void)testSettingObservingNewAndOldPlusMoreObserversWithOnlyNewOrOld
{
var tester = [ObservingTester testerWithCheese:@"CHEESE!"];
[tester addObserver:self forKeyPath:@"cheese" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld context:nil];
var anotherObserver = [[AnotherObserver alloc] init];
[tester addObserver:anotherObserver forKeyPath:@"cheese" options:CPKeyValueObservingOptionOld context:nil];
var yetAnotherObserver = [[AnotherObserver alloc] init];
[tester addObserver:yetAnotherObserver forKeyPath:@"cheese" options:CPKeyValueObservingOptionNew context:nil];
var noNewOrOldObserver = [[AnotherObserver alloc] init];
[tester addObserver:noNewOrOldObserver forKeyPath:@"cheese" options:0 context:nil];
[tester setValue:@"NEW CHEESE!" forKey:@"cheese"];
[self assert:@"cheese" equals:_lastKeyPath];
[self assert:tester equals:_lastObject];
[self assert:@{CPKeyValueChangeNewKey: @"NEW CHEESE!", CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:_lastChange];
[self assert:nil equals:_lastContext];
[self assert:@"cheese" equals:anotherObserver._lastKeyPath];
[self assert:tester equals:anotherObserver._lastObject];
[self assert:@{CPKeyValueChangeOldKey: @"CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:anotherObserver._lastChange];
[self assert:nil equals:anotherObserver._lastContext];
[self assert:@"cheese" equals:yetAnotherObserver._lastKeyPath];
[self assert:tester equals:yetAnotherObserver._lastObject];
[self assert:@{CPKeyValueChangeNewKey: @"NEW CHEESE!", CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:yetAnotherObserver._lastChange];
[self assert:nil equals:yetAnotherObserver._lastContext];
[self assert:@"cheese" equals:noNewOrOldObserver._lastKeyPath];
[self assert:tester equals:noNewOrOldObserver._lastObject];
[self assert:@{CPKeyValueChangeKindKey: CPKeyValueChangeSetting} equals:noNewOrOldObserver._lastChange];
[self assert:nil equals:noNewOrOldObserver._lastContext];
[self assert:2 equals:_getCheeseCounter message:@"Get method should only be called twice even with many observers, not " + _getCheeseCounter + " times"];
}
- (void)observeValueForKeyPath:(CPString)aKeyPath
ofObject:(id)anObject
change:(CPDictionary)aChange
context:(id)aContext
{
_secondLastKeyPath = _lastKeyPath;
_secondLastObject = _lastObject;
_secondLastChange = _lastChange;
_secondLastContext = _lastContext;
_lastKeyPath = aKeyPath;
_lastObject = anObject;
_lastChange = aChange;
_lastChange = [aChange copy];
_lastContext = aContext;
}
@@ -244,6 +444,7 @@
- (id)cheese
{
_getCheeseCounter++;
return cheese;
}
@@ -280,3 +481,34 @@
}
@end
@implementation AnotherObserver : CPObject
{
CPString _lastKeyPath;
id _lastObject;
CPDictionary _lastChange;
id _lastContext;
CPString _secondLastKeyPath;
id _secondLastObject;
CPDictionary _secondLastChange;
id _secondLastContext;
}
- (void)observeValueForKeyPath:(CPString)aKeyPath
ofObject:(id)anObject
change:(CPDictionary)aChange
context:(id)aContext
{
_secondLastKeyPath = _lastKeyPath;
_secondLastObject = _lastObject;
_secondLastChange = _lastChange;
_secondLastContext = _lastContext;
_lastKeyPath = aKeyPath;
_lastObject = anObject;
_lastChange = [aChange copy];
_lastContext = aContext;
}
@end
+7
View File
@@ -572,4 +572,11 @@
[self assertThrows:function () { [@"Objective-J" compare:[CPNull null]] }];
}
- (void)testStripDiacritics
{
[self assert:[@"áa ée íi óo úu" stripDiacritics] equals:@"aa ee ii oo uu"];
[self assert:[@"ÁA ÉE ÍI ÓO ÚU" stripDiacritics] equals:@"AA EE II OO UU"];
[self assert:[@"Å Ã Ê í ö û" stripDiacritics] equals:@"A A E i o u"];
}
@end
@@ -0,0 +1,33 @@
/*
* AppController.j
* CPControlSize
*
* Created Christophe Serafin <christophe.serafin@gmail.com> You on August 11, 2014.
* Copyright 2014, All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@implementation AppController : CPObject
{
@outlet CPWindow theWindow;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
}
@end
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>CPControlSize</string>
<key>CPBundleVersion</key>
<string>1.0</string>
<key>CPHumanReadableCopyright</key>
<string>Copyright © 2014, All rights reserved.</string>
<key>CPDefaultTheme</key>
<string>Aristo2</string>
</dict>
</plist>
+184
View File
@@ -0,0 +1,184 @@
/*
* Jakefile
* CPControlSize
*
* Created by You on August 11, 2014.
* Copyright 2014, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os"),
projectName = "CPControlSize";
app (projectName, function(task)
{
ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks";
if (configuration === "Debug")
ENV["OBJJ_INCLUDE_PATHS"] = FILE.join(ENV["OBJJ_INCLUDE_PATHS"], configuration);
task.setBuildIntermediatesPath(FILE.join("Build", "CPControlSize.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPControlSize");
task.setIdentifier("com.yourcompany.CPControlSize");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPControlSize");
task.setSources(new FileList("**/*.j").exclude(FILE.join("Build", "**")).exclude(FILE.join("Frameworks", "Source", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", [projectName], function()
{
printResults(configuration);
});
task ("build", ["default"], function()
{
updateApplicationSize();
});
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", projectName, "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", projectName, "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", projectName));
OS.system(["press", "-f", FILE.join("Build", "Release", projectName), FILE.join("Build", "Deployment", projectName)]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", projectName));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", projectName), FILE.join("Build", "Desktop", projectName, "CPControlSize.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", projectName, "CPControlSize.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, projectName));
print("----------------------------");
}
function updateApplicationSize()
{
print("Calculating application file sizes...");
var contents = FILE.read(FILE.join("Build", ENV["CONFIGURATION"], projectName, "Info.plist"), { charset:"UTF-8" }),
format = CFPropertyList.sniffedFormatOfString(contents),
plist = CFPropertyList.propertyListFromString(contents),
totalBytes = {executable:0, data:0, mhtml:0};
// Get the size of all framework executables and sprite data
var frameworksDir = "Frameworks";
if (ENV["CONFIGURATION"] === "Debug")
frameworksDir = FILE.join(frameworksDir, "Debug");
var frameworks = FILE.list(frameworksDir);
frameworks.forEach(function(framework)
{
if (framework !== "Source")
addBundleFileSizes(FILE.join(frameworksDir, framework), totalBytes);
});
// Read in the default theme name, and attempt to get its size
var themeName = plist.valueForKey("CPDefaultTheme") || "Aristo2",
themePath = nil;
if (themeName === "Aristo" || themeName === "Aristo2")
themePath = FILE.join(frameworksDir, "AppKit", "Resources", themeName + ".blend");
else
themePath = FILE.join("Frameworks", "Resources", themeName + ".blend");
if (FILE.isDirectory(themePath))
addBundleFileSizes(themePath, totalBytes);
// Add sizes for the app
addBundleFileSizes(FILE.join("Build", ENV["CONFIGURATION"], projectName), totalBytes);
print("Executables: " + totalBytes.executable + ", sprite data: " + totalBytes.data + ", total: " + (totalBytes.executable + totalBytes.data));
var dict = new CFMutableDictionary();
dict.setValueForKey("executable", totalBytes.executable);
dict.setValueForKey("data", totalBytes.data);
dict.setValueForKey("mhtml", totalBytes.mhtml);
plist.setValueForKey("CPApplicationSize", dict);
FILE.write(FILE.join("Build", ENV["CONFIGURATION"], projectName, "Info.plist"), CFPropertyList.stringFromPropertyList(plist, format), { charset:"UTF-8" });
}
function addBundleFileSizes(bundlePath, totalBytes)
{
var bundleName = FILE.basename(bundlePath),
environment = bundleName === "Foundation" ? "Objj" : "Browser",
bundlePath = FILE.join(bundlePath, environment + ".environment");
if (FILE.isDirectory(bundlePath))
{
var filename = bundleName + ".sj",
filePath = new FILE.Path(FILE.join(bundlePath, filename));
if (filePath.exists())
totalBytes.executable += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "dataURLs.txt"));
if (filePath.exists())
totalBytes.data += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLData.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLPaths.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,537 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1050" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="450" id="451"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="507" height="529"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
<view key="contentView" id="372">
<rect key="frame" x="0.0" y="0.0" width="507" height="529"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<popUpButton verticalHuggingPriority="750" id="x4W-un-0cD">
<rect key="frame" x="34" y="457" width="75" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="twp-s2-LmJ">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="fcN-Dl-IQ8">
<items>
<menuItem title="Item 1" id="hrm-kY-Djl"/>
<menuItem title="Item 2" id="vN5-gl-vNC"/>
<menuItem title="Item 3" id="UBd-Gc-0Ky"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<popUpButton verticalHuggingPriority="750" id="8xe-Ws-gbi">
<rect key="frame" x="203" y="462" width="76" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="fnw-t6-xXN">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
<menu key="menu" title="OtherViews" id="M83-F4-gI5">
<items>
<menuItem title="Item 1" id="9zU-LS-gn9"/>
<menuItem title="Item 2" id="rCx-5v-XF6"/>
<menuItem title="Item 3" id="fp3-dt-Bwk"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<popUpButton verticalHuggingPriority="750" id="GrQ-cT-p98">
<rect key="frame" x="374" y="469" width="73" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="oG3-q6-b8X">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="miniSystem"/>
<menu key="menu" title="OtherViews" id="4Se-lq-nBs">
<items>
<menuItem title="Item 1" id="Vgs-PF-l1C"/>
<menuItem title="Item 2" id="9Re-nD-oss"/>
<menuItem title="Item 3" id="p8l-4o-Rh9"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<textField verticalHuggingPriority="750" id="duZ-4B-IHi">
<rect key="frame" x="36" y="419" width="96" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="uNM-6c-a5P">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="vYT-ma-Xce">
<rect key="frame" x="206" y="423" width="96" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="FYM-U3-I2Q">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="BGc-LU-OEi">
<rect key="frame" x="34" y="494" width="81" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Regular size" id="NcJ-HR-XZI">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="twC-Ez-Cvs">
<rect key="frame" x="204" y="497" width="67" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Small size" id="6uG-ec-HEA">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="dCc-cq-MO7">
<rect key="frame" x="373" y="500" width="60" height="11"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Mini size" id="mx4-66-yGt">
<font key="font" metaFont="miniSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="Baf-Et-cEO">
<rect key="frame" x="375" y="426" width="96" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="8VU-QE-dZY">
<font key="font" metaFont="miniSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<datePicker verticalHuggingPriority="750" id="pNn-Yt-Kof">
<rect key="frame" x="36" y="328" width="113" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" borderStyle="bezel" alignment="left" id="T5R-AB-cuN">
<font key="font" metaFont="system"/>
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific">
<data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ
AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg
DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ
HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g
KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ
OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg
Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ
VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg
Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ
cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg
f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</data>
</timeZone>
</calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</datePickerCell>
</datePicker>
<datePicker verticalHuggingPriority="750" id="WXE-xa-O7P">
<rect key="frame" x="206" y="333" width="113" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" controlSize="small" borderStyle="bezel" alignment="left" id="Qb0-X9-0KQ">
<font key="font" metaFont="smallSystem"/>
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific">
<data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ
AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg
DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ
HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g
KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ
OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg
Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ
VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg
Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ
cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg
f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</data>
</timeZone>
</calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</datePickerCell>
</datePicker>
<datePicker verticalHuggingPriority="750" id="WeD-S8-Zxs">
<rect key="frame" x="375" y="338" width="113" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" controlSize="mini" borderStyle="bezel" alignment="left" id="635-rQ-aDe">
<font key="font" metaFont="miniSystem"/>
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific">
<data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ
AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg
DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ
HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g
KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ
OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg
Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ
VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg
Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ
cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg
f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</data>
</timeZone>
</calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</datePickerCell>
</datePicker>
<datePicker verticalHuggingPriority="750" id="ULi-zW-Q5q">
<rect key="frame" x="36" y="281" width="113" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" borderStyle="bezel" alignment="left" datePickerStyle="textField" id="RCm-sN-nrQ">
<font key="font" metaFont="system"/>
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific">
<data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ
AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg
DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ
HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g
KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ
OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg
Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ
VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg
Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ
cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg
f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</data>
</timeZone>
</calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</datePickerCell>
</datePicker>
<datePicker verticalHuggingPriority="750" id="fx1-CP-l9m">
<rect key="frame" x="206" y="285" width="113" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" controlSize="small" borderStyle="bezel" alignment="left" datePickerStyle="textField" id="0fE-Wg-6b6">
<font key="font" metaFont="smallSystem"/>
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific">
<data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ
AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg
DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ
HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g
KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ
OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg
Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ
VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg
Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ
cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg
f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</data>
</timeZone>
</calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</datePickerCell>
</datePicker>
<datePicker verticalHuggingPriority="750" id="dwU-8f-1Ek">
<rect key="frame" x="375" y="287" width="110" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<datePickerCell key="cell" controlSize="mini" borderStyle="bezel" alignment="left" datePickerStyle="textField" id="O65-rh-JeL">
<font key="font" metaFont="miniSystem"/>
<calendarDate key="date" timeIntervalSinceReferenceDate="-595929600" calendarFormat="%Y-%m-%d %H:%M:%S %z">
<!--1982-02-12 08:00:00 -0800-->
<timeZone key="timeZone" name="US/Pacific">
<data key="data">
VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ
AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg
DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ
HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g
KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ
OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg
Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ
VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg
Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ
cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg
f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA
AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
</data>
</timeZone>
</calendarDate>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</datePickerCell>
</datePicker>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="Pf5-bX-XNM">
<rect key="frame" x="33" y="374" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="UBb-vf-dHD"/>
</stepper>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="fX5-Cx-kra">
<rect key="frame" x="204" y="381" width="15" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" controlSize="small" continuous="YES" alignment="left" maxValue="100" id="s3t-dy-wPz"/>
</stepper>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="eJ6-cs-745">
<rect key="frame" x="373" y="388" width="13" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" controlSize="mini" continuous="YES" alignment="left" maxValue="100" id="RqJ-YK-TXI"/>
</stepper>
<button verticalHuggingPriority="750" id="qeW-JF-8PA">
<rect key="frame" x="30" y="192" width="82" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="r33-XP-TYJ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="bUw-8W-83b">
<rect key="frame" x="201" y="196" width="82" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iFL-tR-EKi">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="mtR-eh-GXS">
<rect key="frame" x="374" y="204" width="82" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Ebs-LH-Vnq">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
</button>
<button id="utt-sX-YI9">
<rect key="frame" x="34" y="238" width="81" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Check" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="plS-mh-316">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button id="5tT-da-cbF">
<rect key="frame" x="203" y="237" width="75" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Check" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="OGk-WN-tAu">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<button id="wmA-RV-jeJ">
<rect key="frame" x="371" y="237" width="63" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Check" bezelStyle="regularSquare" imagePosition="left" controlSize="mini" inset="2" id="ro6-1L-HbO">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="OuO-8D-Jv1">
<rect key="frame" x="36" y="155" width="110" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="squareTextured" title="Textured Button" bezelStyle="texturedSquare" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="SNT-aA-bDy">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="eG9-13-wdi">
<rect key="frame" x="206" y="160" width="110" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="squareTextured" title="Textured Button" bezelStyle="texturedSquare" imagePosition="overlaps" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="xJm-nS-cPR">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="7FL-7D-m2j">
<rect key="frame" x="375" y="163" width="110" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="squareTextured" title="Textured Button" bezelStyle="texturedSquare" imagePosition="overlaps" alignment="center" controlSize="mini" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="np3-qE-wIc">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="pqa-mo-oK1">
<rect key="frame" x="36" y="117" width="115" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" title="Round Textured" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rpo-yw-hd8">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="Mv6-Iy-X4h">
<rect key="frame" x="206" y="122" width="115" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" title="Round Textured" bezelStyle="texturedRounded" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="PQW-Lc-Dm5">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" id="O3l-BH-NXK">
<rect key="frame" x="375" y="125" width="115" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" title="Round Textured" bezelStyle="texturedRounded" alignment="center" controlSize="mini" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="fzh-RR-war">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
</button>
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="eUQ-61-gJI">
<rect key="frame" x="36" y="67" width="70" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<size key="cellSize" width="70" height="21"/>
<size key="intercellSpacing" width="4" height="2"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" inset="2" id="b9B-FK-ORL">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<cells>
<column>
<buttonCell type="radio" title="Radio" imagePosition="left" alignment="left" state="on" tag="1" inset="2" id="yPV-N3-l7E">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<buttonCell type="radio" title="Radio" imagePosition="left" alignment="left" inset="2" id="Cqa-N2-FKj">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</column>
</cells>
</matrix>
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="IGX-cm-xbF">
<rect key="frame" x="206" y="73" width="63" height="38"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<size key="cellSize" width="63" height="18"/>
<size key="intercellSpacing" width="4" height="2"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="small" inset="2" id="Wc0-ah-hD0">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<cells>
<column>
<buttonCell type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="small" state="on" tag="1" inset="2" id="maf-wx-fVJ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<buttonCell type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="small" inset="2" id="rxl-U7-ML4">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</column>
</cells>
</matrix>
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="SLm-Fm-NnP">
<rect key="frame" x="375" y="73" width="57" height="38"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<size key="cellSize" width="57" height="18"/>
<size key="intercellSpacing" width="4" height="2"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="mini" inset="2" id="CQl-UO-ilA">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
<cells>
<column>
<buttonCell type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="mini" state="on" tag="1" inset="2" id="9IN-el-UsO">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
<buttonCell type="radio" title="Radio" imagePosition="left" alignment="left" controlSize="mini" inset="2" id="4PO-03-gDn">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
</column>
</cells>
</matrix>
<comboBox verticalHuggingPriority="750" id="yfb-qa-Ypy">
<rect key="frame" x="36" y="35" width="99" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="7lM-32-tfT">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</comboBoxCell>
</comboBox>
<comboBox verticalHuggingPriority="750" id="aGP-Sw-SGa">
<rect key="frame" x="206" y="38" width="99" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<comboBoxCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="1HS-Qg-oau">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</comboBoxCell>
</comboBox>
<comboBox verticalHuggingPriority="750" id="Sub-ME-hYL">
<rect key="frame" x="375" y="41" width="99" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<comboBoxCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="6Ao-lo-5FY">
<font key="font" metaFont="miniSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</comboBoxCell>
</comboBox>
</subviews>
</view>
</window>
<customObject id="450" customClass="AppController">
<connections>
<outlet property="theWindow" destination="371" id="459"/>
</connections>
</customObject>
</objects>
</document>
+191
View File
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="en">
<!--
index-debug.html
CPControlSize
Created by You on August 11, 2014.
Copyright 2014, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPControlSize</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks"];
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: -1000;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
+161
View File
@@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<!--
index.html
CPControlSize
Created by You on August 11, 2014.
Copyright 2014, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPControlSize</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: -1000;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPControlSize
*
* Created by You on August 11, 2014.
* Copyright 2014, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
File diff suppressed because one or more lines are too long
+51 -6
View File
@@ -61,12 +61,12 @@ var randomFromTo = function(from, to)
[recordField setObjectValue:record];
}
- (void)setDate1:(id)sender
- (@action)setDate1:(id)sender
{
[self setDate:dateField1];
}
- (void)setDate2:(id)sender
- (@action)setDate2:(id)sender
{
[self setDate:dateField2];
}
@@ -78,26 +78,71 @@ var randomFromTo = function(from, to)
[field setObjectValue:date];
}
- (void)objectValue1:(id)sender
- (@action)objectValue1:(id)sender
{
CPLog.info("Date 1: %s", [[dateField1 objectValue] description]);
}
- (void)objectValue2:(id)sender
- (@action)objectValue2:(id)sender
{
CPLog.info("Date 2: %s", [[dateField2 objectValue] description]);
}
- (void)setNil:(id)sender
- (@action)setNil:(id)sender
{
[dateField1 setStringValue:nil]; // should log a warning and do nothing
}
- (void)setEmptyOK:(id)sender
- (@action)setEmptyOK:(id)sender
{
[[dateField2 formatter] setEmptyIsValid:[sender state] === CPOnState];
}
- (@action)deleteBackward1:(id)sender
{
[dateField1 deleteBackward:self];
}
- (@action)deleteBackward2:(id)sender
{
[dateField2 deleteBackward:self];
}
- (@action)deleteBackward3:(id)sender
{
[textField deleteBackward:self];
}
- (@action)deleteForward1:(id)sender
{
[dateField1 deleteForward:self];
}
- (@action)deleteForward2:(id)sender
{
[dateField2 deleteForward:self];
}
- (@action)deleteForward3:(id)sender
{
[textField deleteForward:self];
}
- (@action)delete1:(id)sender
{
[dateField1 delete:self];
}
- (@action)delete2:(id)sender
{
[dateField2 delete:self];
}
- (@action)delete3:(id)sender
{
[textField delete:self];
}
- (void)controlTextDidChange:(CPNotification)aNotification
{
var field = [aNotification object],
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,35 @@
/*
* AppController.j
* CPMenuTest
*
* Created by Daniel Boehringer 2014.
* Verifies that enabled bindings actually work for menu items
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var mainMenu = [CPApp mainMenu];
while ([mainMenu numberOfItems] > 0)
[mainMenu removeItemAtIndex:0];
var item = [mainMenu insertItemWithTitle:@"My enabled state is bound to the checkbox below" action:nil keyEquivalent:nil atIndex:0];
[CPMenu setMenuBarVisible:YES];
var button= [[CPCheckBox alloc] initWithFrame:CGRectMake(30,30,100,25)];
[item bind: CPEnabledBinding toObject:button withKeyPath:"objectValue" options: nil];
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
[contentView addSubview: button];
[theWindow orderFront:self];
}
@end
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>CPMenuTest</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
@@ -0,0 +1,93 @@
/*
* Jakefile
* CPMenuTest
*
* Created by Alexander Ljungberg on August 31, 2010.
* Copyright 2010, WireLoad, LLC All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("CPMenuTest", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "CPMenuTest.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPMenuTest");
task.setIdentifier("com.yourcompany.CPMenuTest");
task.setVersion("1.0");
task.setAuthor("WireLoad, LLC");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPMenuTest");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["CPMenuTest"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "CPMenuTest", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "CPMenuTest", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "CPMenuTest"));
OS.system(["press", "-f", FILE.join("Build", "Release", "CPMenuTest"), FILE.join("Build", "Deployment", "CPMenuTest")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "CPMenuTest"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPMenuTest"), FILE.join("Build", "Desktop", "CPMenuTest", "CPMenuTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "CPMenuTest", "CPMenuTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPMenuTest"));
print("----------------------------");
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,103 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
CPMenuTest
Created by Alexander Ljungberg on August 31, 2010.
Copyright 2010, WireLoad, LLC All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPMenuTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPMenuTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino-project.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
@@ -0,0 +1,78 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
CPMenuTest
Created by Alexander Ljungberg on August 31, 2010.
Copyright 2010, WireLoad, LLC All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPMenuTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPMenuTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino-project.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPMenuTest
*
* Created by Alexander Ljungberg on August 31, 2010.
* Copyright 2010, WireLoad, LLC All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
@@ -41,7 +41,7 @@
[self updateAddTemplateButton];
[window setBackgroundColor:[CPColor colorWithHexString:@"f3f4f5"]];
[window setFullBridge:YES];
[window setFullPlatformWindow:YES];
}
- (IBAction)predicateEditorAction:(id)sender
@@ -123,6 +123,14 @@
}
else if (type == 3)
template = [[CPPredicateEditorRowTemplate alloc] initWithLeftExpressions:leftExpressions rightExpressionAttributeType:CPDateAttributeType modifier:0 operators:operators options:0];
else if (type == 4)
template = [[CPPredicateEditorRowTemplate alloc] initWithLeftExpressions:leftExpressions rightExpressionAttributeType:CPBooleanAttributeType modifier:0 operators:operators options:0];
else if (type == 5)
{
var expressions = [CPArray arrayWithObjects:[CPExpression expressionForConstantValue:@"Apple"], [CPExpression expressionForConstantValue:@"Microsoft"], [CPExpression expressionForConstantValue:@"Linux"]]
template = [[CPPredicateEditorRowTemplate alloc] initWithLeftExpressions:leftExpressions rightExpressions:expressions modifier:0 operators:operators options:0];
}
var templates = [[predicateEditor rowTemplates] arrayByAddingObject:template];
[predicateEditor setRowTemplates:templates];
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"/>
@@ -734,15 +734,17 @@
<popUpButton verticalHuggingPriority="750" id="1274">
<rect key="frame" x="6" y="145" width="223" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Strings" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="1277" id="1275">
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="1275">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="1276">
<items>
<menuItem title="Strings" state="on" id="1277"/>
<menuItem title="Strings" id="1277"/>
<menuItem title="Numbers" id="1278"/>
<menuItem title="Constant Values" id="1279"/>
<menuItem title="Dates" id="9Za-l5-lSK"/>
<menuItem title="Booleans" id="Nuh-0m-Oqs"/>
<menuItem title="Choice" id="Ia8-PU-zQd"/>
</items>
</menu>
</popUpButtonCell>
@@ -928,4 +930,4 @@
</declaredKeys>
</objectController>
</objects>
</document>
</document>
@@ -6,6 +6,8 @@
* Copyright 2012, Your Company All rights reserved.
*/
CPLogRegister(CPLogConsole)
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
@@ -30,10 +32,10 @@
- (id)newObject
{
var randIndex = FLOOR(RAND()*3),
randLabel = ["un", "deux", "trois", nil][FLOOR(RAND()*4)],
randTag = FLOOR(RAND()*3);
var randIndex = FLOOR(RAND() * 3),
randLabel = ["Label1", "Label2", "Label3", nil][FLOOR(RAND() * 4)],
randTag = FLOOR(RAND() * 3);
return [CPDictionary dictionaryWithObjectsAndKeys:randIndex, @"index", randLabel, @"label", randTag, @"tag"];
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+5
View File
@@ -50,8 +50,13 @@
[shadowLabel setFrame:CGRectMake(15, CGRectGetMaxY([textField frame]) + 10, 300, 18)];
[championOfLightLabel setFrame:CGRectMake(15, CGRectGetMaxY([shadowLabel frame]) + 2, 300, 18)];
var selectableLabel = [CPTextField labelWithTitle:@"This text should be selectable and you should see the selectable cursor."];
[selectableLabel setSelectable:YES];
[selectableLabel setFrame:CGRectMake(15, CGRectGetMaxY([championOfLightLabel frame]) + 8, 600, 18)];
[contentView addSubview:shadowLabel];
[contentView addSubview:championOfLightLabel];
[contentView addSubview:selectableLabel];
var jumpLabel = [CPTextField labelWithTitle:@"The text of these text fields should not move ('jump') when a field becomes the first responder. Labels on the right should replicate the input."];
+2
View File
@@ -6,5 +6,7 @@
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>nib2cibAlignment</string>
<key>CPDefaultTheme</key>
<string>Aristo2</string>
</dict>
</plist>
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,11 @@
@implementation Class
{
}
@end
@implementation Class (Accessors)
{
Type ivar @accessors;
}
@end
@@ -0,0 +1,13 @@
var the_class=objj_allocateClassPair(Nil,"Class"),meta_class=the_class.isa;
objj_registerClassPair(the_class);
var the_class=objj_getClass("Class");
if(!the_class){
throw new SyntaxError("*** Could not find definition for class \"Class\"");
}
var meta_class=the_class.isa;
class_addIvars(the_class,[new objj_ivar("ivar")]);
class_addMethods(the_class,[new objj_method(sel_getUid("ivar"),function $Class__ivar(_1,_2){
return _1.ivar;
},["Type"]),new objj_method(sel_getUid("setIvar:"),function $Class__setIvar_(_3,_4,_5){
_3.ivar=_5;
},["void","Type"])]);
@@ -6,6 +6,7 @@ var FILENAMES = [
"Class/root-class",
"Class/root-class-one-ivar",
"Class/root-class-multiple-ivars",
"Class/accessors",
"Messages/no-parameters",
"Messages/one-parameter",

Some files were not shown because too many files have changed in this diff Show More