Merge remote-tracking branch 'upstream/master' into CPAnimationContext

Conflicts:
	AppKit/CPView.j
This commit is contained in:
cacaodev committed 2014-12-09 22:35:29 +01:00
commit 31449552d1
278 files changed
+20824 -10113

No files matched your search

+2
View File
@@ -5,6 +5,7 @@ Demos
./Aristo
WebSite
.push-package
*.xcodeproj*
*.xcodeproj/*.pbxuser
*.xcodeproj/*.perspectivev3
xcuserdata/
@@ -15,3 +16,4 @@ xcuserdata/
Tests/Manual/**/*.xcodeproj
*.sublime-project
*.sublime-workspace
*.tm_properties
+49 -48
View File
@@ -44,6 +44,7 @@
var CPAlertDelegate_alertShowHelp_ = 1 << 0,
CPAlertDelegate_alertDidEnd_returnCode_ = 1 << 1;
@typedef CPAlertStyle
/*
@global
@group CPAlertStyle
@@ -70,6 +71,54 @@ var bottomHeight = 71;
@end
@implementation _CPAlertThemeView : CPView
+ (CPString)defaultThemeClass
{
return @"alert";
}
+ (CPDictionary)themeAttributes
{
return @{
@"size": CGSizeMake(400.0, 110.0),
@"content-inset": CGInsetMake(15, 15, 15, 50),
@"informative-offset": 6,
@"button-offset": 10,
@"message-text-alignment": CPJustifiedTextAlignment,
@"message-text-color": [CPColor blackColor],
@"message-text-font": [CPFont boldSystemFontOfSize:13.0],
@"message-text-shadow-color": [CPNull null],
@"message-text-shadow-offset": CGSizeMakeZero(),
@"informative-text-alignment": CPJustifiedTextAlignment,
@"informative-text-color": [CPColor blackColor],
@"informative-text-font": [CPFont systemFontOfSize:12.0],
@"informative-text-shadow-color": [CPNull null],
@"informative-text-shadow-offset": CGSizeMakeZero(),
@"image-offset": CGPointMake(15, 12),
@"information-image": [CPNull null],
@"warning-image": [CPNull null],
@"error-image": [CPNull null],
@"help-image": [CPNull null],
@"help-image-left-offset": 15,
@"help-image-pressed": [CPNull null],
@"suppression-button-y-offset": 0.0,
@"suppression-button-x-offset": 0.0,
@"default-elements-margin": 3.0,
@"suppression-button-text-color": [CPColor blackColor],
@"suppression-button-text-font": [CPFont systemFontOfSize:12.0],
@"suppression-button-text-shadow-color": [CPNull null],
@"suppression-button-text-shadow-offset": 0.0,
@"modal-window-button-margin-y": 0.0,
@"modal-window-button-margin-x": 0.0,
@"standard-window-button-margin-y": 0.0,
@"standard-window-button-margin-x": 0.0,
};
}
@end
/*!
@ingroup appkit
@@ -813,51 +862,3 @@ var bottomHeight = 71;
}
@end
@implementation _CPAlertThemeView : CPView
+ (CPString)defaultThemeClass
{
return @"alert";
}
+ (CPDictionary)themeAttributes
{
return @{
@"size": CGSizeMake(400.0, 110.0),
@"content-inset": CGInsetMake(15, 15, 15, 50),
@"informative-offset": 6,
@"button-offset": 10,
@"message-text-alignment": CPJustifiedTextAlignment,
@"message-text-color": [CPColor blackColor],
@"message-text-font": [CPFont boldSystemFontOfSize:13.0],
@"message-text-shadow-color": [CPNull null],
@"message-text-shadow-offset": CGSizeMakeZero(),
@"informative-text-alignment": CPJustifiedTextAlignment,
@"informative-text-color": [CPColor blackColor],
@"informative-text-font": [CPFont systemFontOfSize:12.0],
@"informative-text-shadow-color": [CPNull null],
@"informative-text-shadow-offset": CGSizeMakeZero(),
@"image-offset": CGPointMake(15, 12),
@"information-image": [CPNull null],
@"warning-image": [CPNull null],
@"error-image": [CPNull null],
@"help-image": [CPNull null],
@"help-image-left-offset": 15,
@"help-image-pressed": [CPNull null],
@"suppression-button-y-offset": 0.0,
@"suppression-button-x-offset": 0.0,
@"default-elements-margin": 3.0,
@"suppression-button-text-color": [CPColor blackColor],
@"suppression-button-text-font": [CPFont systemFontOfSize:12.0],
@"suppression-button-text-shadow-color": [CPNull null],
@"suppression-button-text-shadow-offset": 0.0,
@"modal-window-button-margin-y": 0.0,
@"modal-window-button-margin-x": 0.0,
@"standard-window-button-margin-y": 0.0,
@"standard-window-button-margin-x": 0.0,
};
}
@end
+1 -16
View File
@@ -42,25 +42,10 @@ var CPAnimationDelegate_animationShouldStart_ = 1 << 1,
CPAnimationDelegate_animationDidEnd_ = 1 << 3,
CPAnimationDelegate_animationDidStop_ = 1 << 4;
/*
@global
@group CPAnimationCurve
*/
@typedef CPAnimationCurve
CPAnimationEaseInOut = 0;
/*
@global
@group CPAnimationCurve
*/
CPAnimationEaseIn = 1;
/*
@global
@group CPAnimationCurve
*/
CPAnimationEaseOut = 2;
/*
@global
@group CPAnimationCurve
*/
CPAnimationLinear = 3;
ACTUAL_FRAME_RATE = 0;
+7 -3
View File
@@ -37,6 +37,8 @@
@import "CPWindowController.j"
@import "_CPPopoverWindow.j"
@typedef CPModalSession
var CPMainCibFile = @"CPMainCibFile",
CPMainCibFileHumanFriendly = @"Main cib file base name",
CPEventModifierFlags = 0;
@@ -448,7 +450,7 @@ var CPMainCibFile = @"CPMainCibFile",
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
_isActive = YES;
[self _willResignActive];
[self _didBecomeActive];
}
- (void)deactivate
@@ -986,7 +988,9 @@ var CPMainCibFile = @"CPMainCibFile",
return;
}
[aSheet._windowView _enableSheet:YES inWindow:aWindow];
if (![aWindow attachedSheet])
[aSheet._windowView _enableSheet:YES inWindow:aWindow];
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:didEndSelector contextInfo:contextInfo];
}
@@ -1173,7 +1177,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;
+1 -1
View File
@@ -23,7 +23,7 @@
*/
@import <Foundation/CPIndexSet.j>
@import <Foundation/CPPredicate.j>
@import "CPObjectController.j"
@import "CPKeyValueBinding.j"
+3
View File
@@ -24,6 +24,7 @@
@import "CPView.j"
// CPBoxType
@typedef CPBoxType
CPBoxPrimary = 0;
CPBoxSecondary = 1;
CPBoxSeparator = 2;
@@ -31,12 +32,14 @@ CPBoxOldStyle = 3;
CPBoxCustom = 4;
// CPBorderType
@typedef CPBorderType
CPNoBorder = 0;
CPLineBorder = 1;
CPBezelBorder = 2;
CPGrooveBorder = 3;
// CPTitlePosition
@typedef CPTitlePosition
CPNoTitle = 0;
CPAboveTop = 1;
CPAtTop = 2;
+18 -7
View File
@@ -29,8 +29,7 @@
@import "CPWindow_Constants.j"
/* @group CPBezelStyle */
// IB style
@typedef CPBezelStyle
CPRoundedBezelStyle = 1; // Push
CPRegularSquareBezelStyle = 2; // Bevel
CPThickSquareBezelStyle = 3;
@@ -49,6 +48,7 @@ CPHUDBezelStyle = -1;
/* @group CPButtonType */
@typedef CPButtonType
CPMomentaryLightButton = 0;
CPPushOnPushOffButton = 1;
CPToggleButton = 2;
@@ -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];
}
+31 -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,20 @@
- (void)setButtons:(CPArray)buttons
{
for (var i = [_buttons count] - 1; i >= 0; i--)
{
[_buttons[i] removeFromSuperview];
[_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 +231,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 +293,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];
+43 -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.
*/
@@ -230,6 +256,11 @@
return [self scrollToPoint:CGPointMake(bounds.origin.x - deltaX, bounds.origin.y - deltaY)];
}
- (CGRect)documentVisibleRect
{
return [self convertRect:[self bounds] fromView:_documentView];
}
@end
+4 -29
View File
@@ -32,6 +32,7 @@
@import "CPPasteboard.j"
@import "CPView.j"
@class _CPCollectionViewDropIndicator
var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_ = 1 << 0,
CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_ = 1 << 1,
@@ -40,9 +41,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 +57,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 +70,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 +231,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 +465,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 +609,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 +1500,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
+3
View File
@@ -27,6 +27,9 @@
@import "CPView.j"
@class CPSlider
@class _CPColorPanelToolbar
@class _CPColorPanelSwatches
@class _CPColorPanelPreview
@global CPApp
+2
View File
@@ -25,6 +25,8 @@
@import "CPView.j"
@class CPSlider
@class CPColorPanel
@class __CPColorWheel
@global CPColorPickerViewWidth
@global CPColorPickerViewHeight
+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;
+61 -21
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";
@@ -52,17 +61,19 @@ var CPComboBoxTextSubview = @"text",
@implementation CPComboBox : CPTextField
{
CPArray _items;
_CPPopUpList _listDelegate;
CPComboBoxDataSource _dataSource;
BOOL _usesDataSource;
BOOL _completes;
BOOL _canComplete;
int _numberOfVisibleItems;
BOOL _forceSelection;
BOOL _hasVerticalScroller;
CPString _selectedStringValue;
BOOL _popUpButtonCausedResign;
CPArray _items;
_CPPopUpList _listDelegate;
id<CPComboBoxDataSource> _dataSource;
BOOL _usesDataSource;
BOOL _completes;
BOOL _canComplete;
int _numberOfVisibleItems;
BOOL _forceSelection;
BOOL _hasVerticalScroller;
CPString _selectedStringValue;
CGSize _intercellSpacing;
float _itemHeight;
BOOL _popUpButtonCausedResign;
}
+ (CPString)defaultThemeClass
@@ -131,7 +142,9 @@ var CPComboBoxTextSubview = @"text",
return;
_hasVerticalScroller = flag;
[[_listDelegate scrollView] setHasVerticalScroller:flag];
if (_listDelegate)
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
}
- (CGSize)intercellSpacing
@@ -141,7 +154,13 @@ var CPComboBoxTextSubview = @"text",
- (void)setIntercellSpacing:(CGSize)aSize
{
[[_listDelegate tableView] setIntercellSpacing:aSize];
if (_intercellSpacing && CGSizeEqualToSize(aSize, _intercellSpacing))
return;
_intercellSpacing = aSize;
if (_listDelegate)
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
}
- (BOOL)isButtonBordered
@@ -164,10 +183,18 @@ var CPComboBoxTextSubview = @"text",
- (void)setItemHeight:(float)itemHeight
{
[[_listDelegate tableView] setRowHeight:itemHeight];
if (itemHeight === _itemHeight)
return;
// FIXME: This shouldn't be necessary, but CPTableView does not tile after setRowHeight
[[_listDelegate tableView] reloadData];
_itemHeight = itemHeight;
if (_listDelegate)
{
[[_listDelegate tableView] setRowHeight:_itemHeight];
// FIXME: This shouldn't be necessary, but CPTableView does not tile after setRowHeight
[[_listDelegate tableView] reloadData];
}
}
- (int)numberOfVisibleItems
@@ -183,7 +210,7 @@ var CPComboBoxTextSubview = @"text",
#pragma mark Setting a Delegate
- (id /*< CPComboBoxDelegate >*/)delegate
- (id <CPComboBoxDelegate>)delegate
{
return [super delegate];
}
@@ -243,7 +270,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 +278,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 +292,9 @@ var CPComboBoxTextSubview = @"text",
CPLog.warn("Illegal %s data source (%s). Must implement numberOfItemsInComboBox: and comboBox:objectValueForItemAtIndex:", [self className], [aSource description]);
}
else
{
_dataSource = aSource;
}
}
}
@@ -438,6 +469,9 @@ var CPComboBoxTextSubview = @"text",
// Apply our text style to the list
[_listDelegate setFont:[self font]];
[_listDelegate setAlignment:[self alignment]];
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
[[_listDelegate tableView] setRowHeight:_itemHeight];
}
- (int)indexOfItemWithObjectValue:(id)anObject
@@ -829,13 +863,17 @@ var CPComboBoxTextSubview = @"text",
- (void)setFont:(CPFont)aFont
{
[super setFont:aFont];
[_listDelegate setFont:aFont];
if (_listDelegate)
[_listDelegate setFont:aFont];
}
- (void)setAlignment:(CPTextAlignment)alignment
{
[super setAlignment:alignment];
[_listDelegate setAlignment:alignment];
if (_listDelegate)
[_listDelegate setAlignment:alignment];
}
#pragma mark Pop Up Button Layout
@@ -906,7 +944,9 @@ var CPComboBoxTextSubview = @"text",
index = [_dataSource comboBox:self indexOfItemWithStringValue:stringValue]
}
else
{
index = [self indexOfItemWithObjectValue:stringValue];
}
[_listDelegate selectRow:index];
+4
View File
@@ -78,6 +78,8 @@ CPInputOnInputEventFeature = 30;
CPFileAPIFeature = 31;
CPAltEnterTextAreaFeature = 32;
/*
@@ -100,6 +102,7 @@ var USER_AGENT = "",
// default these features to true
PLATFORM_FEATURES[CPInputTypeCanBeChangedFeature] = YES;
PLATFORM_FEATURES[CPInputSetFontOutsideOfDOM] = YES;
PLATFORM_FEATURES[CPAltEnterTextAreaFeature] = YES;
if (typeof window !== "undefined" && typeof window.navigator !== "undefined")
USER_AGENT = window.navigator.userAgent;
@@ -208,6 +211,7 @@ else if (USER_AGENT.indexOf("Gecko") !== -1) // Must follow KHTML check.
// Some day this might be fixed and should be version prefixed. No known fixed version yet.
PLATFORM_FEATURES[CPInput1PxLeftPadding] = YES;
PLATFORM_FEATURES[CPAltEnterTextAreaFeature] = NO;
// This was supposed to be added in Firefox 22, but when testing with the latest beta as of 2013-06-14
// it does not seem to work. It seems to exhibit the CPJavaScriptPasteRequiresEditableTarget problem,
// and in addition doesn't seem to work with our native copy code either.
+102 -6
View File
@@ -42,16 +42,19 @@
@end
@typedef CPTextAlignment
CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
CPJustifiedTextAlignment = 3;
CPNaturalTextAlignment = 4;
@typedef CPControlSize
CPRegularControlSize = 0;
CPSmallControlSize = 1;
CPMiniControlSize = 2;
@typedef CPLineBreakMode
CPLineBreakByWordWrapping = 0;
CPLineBreakByCharWrapping = 1;
CPLineBreakByClipping = 2;
@@ -59,11 +62,13 @@ CPLineBreakByTruncatingHead = 3;
CPLineBreakByTruncatingTail = 4;
CPLineBreakByTruncatingMiddle = 5;
@typedef CPVerticalTextAlignment
CPTopVerticalTextAlignment = 1;
CPCenterVerticalTextAlignment = 2;
CPBottomVerticalTextAlignment = 3;
// Deprecated for use with images, use the CPImageScale constants
@typedef CPImageScaling
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
@@ -73,6 +78,7 @@ CPImageScaleAxesIndependently = 1;
CPImageScaleNone = 2;
CPImageScaleProportionallyUpOrDown = 3;
@typedef CPCellImagePosition
CPNoImage = 0;
CPImageOnly = 1;
CPImageLeft = 2;
@@ -118,6 +124,8 @@ var CPControlBlackColor = [CPColor blackColor];
BOOL _trackingWasWithinFrame;
unsigned _trackingMouseDownFlags;
CGPoint _previousTrackingLocation;
CPControlSize _controlSize;
}
+ (CPDictionary)themeAttributes
@@ -134,6 +142,7 @@ var CPControlBlackColor = [CPColor blackColor];
@"image-scaling": CPScaleToFit,
@"min-size": CGSizeMakeZero(),
@"max-size": CGSizeMake(-1.0, -1.0),
@"nib2cib-adjustment-frame": CGRectMakeZero()
};
}
@@ -189,13 +198,95 @@ 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 (maxSize.width > 0)
frameSize.width = MIN(maxSize.width, frameSize.width);
}
if (minSize.height > 0)
{
frameSize.height = MAX(minSize.height, frameSize.height);
if (maxSize.height > 0)
frameSize.height = MIN(maxSize.height, frameSize.height);
}
[self setFrameSize:frameSize];
}
#pragma mark -
/*!
Sets the receiver's target action.
@@ -927,14 +1018,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";
@@ -961,6 +1053,8 @@ var CPControlValueKey = @"CPControlValueKey",
[self setSendsActionOnEndEditing:[aCoder decodeBoolForKey:CPControlSendsActionOnEndEditingKey]];
[self setFormatter:[aCoder decodeObjectForKey:CPControlFormatterKey]];
[self setControlSize:[aCoder decodeIntForKey:CPControlControlSizeKey]];
}
return self;
@@ -993,6 +1087,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];
}
+23 -16
View File
@@ -29,6 +29,9 @@
@import <Foundation/Foundation.j>
@class CPDatePicker
@class _CPDatePickerMonthView
@class _CPDatePickerHeaderView
@class _CPDatePickerBox
@global CPApp
@global CPSingleDateMode
@@ -63,7 +66,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_CPDatePickerMonthView _monthView;
_CPDatePickerHeaderView _headerView;
_CPDatePickerClock _datePickerClock;
CPBox _box;
_CPDatePickerBox _box;
CPDatePicker _datePicker;
CPInteger _startSelectionIndex;
CPInteger _currentSelectionIndex;
@@ -85,6 +88,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_datePicker = aDatePicker
[self _init];
}
return self;
}
@@ -96,7 +100,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
sizeCalendar = [_datePicker valueForThemeAttribute:@"size-calendar"],
sizeClock = [_datePicker valueForThemeAttribute:@"size-clock"];
_box = [[_DatePickerBox alloc] initWithFrame:CGRectMake(0, 0, sizeCalendar.width, sizeHeader.height + sizeCalendar.height)];
_box = [[_CPDatePickerBox alloc] initWithFrame:CGRectMake(0, 0, sizeCalendar.width, sizeHeader.height + sizeCalendar.height)];
[_box setDatePicker:_datePicker];
_headerView = [[_CPDatePickerHeaderView alloc] initWithFrame:CGRectMake(0, 0, sizeHeader.width, sizeHeader.height) datePicker:_datePicker delegate:self];
@@ -215,6 +219,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[_headerView setHidden:YES];
[_monthView setHidden:YES];
}
[self setFrameSize:[_datePicker frameSize]];
}
@@ -381,9 +387,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 +899,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 +953,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
else
[_delegate _displayNextMonth];
}
_datePicker._invokedByUserEvent = NO;
}
/*! Mouse dragged event
@@ -960,6 +972,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 +1015,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
@@ -1253,19 +1269,11 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
@end
@implementation _DatePickerBox : CPView
@implementation _CPDatePickerBox : CPView
{
CPDatePicker _datePicker @accessors(property=datePicker);
}
- (id)init
{
if (self = [super init])
{
}
return self;
}
- (void)drawRect:(CGRect)aRect
{
[super drawRect:aRect];
@@ -1279,10 +1287,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 +1309,4 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[self setBackgroundColor:[CPColor clearColor]];
}
@end
+356 -192
View File
@@ -31,6 +31,10 @@
@import <Foundation/CPLocale.j>
@class CPDatePicker
@class _CPDatePickerElementTextField
@class _CPDatePickerElementView
@class _CPDatePickerMonthView
@class _CPDatePickerHeaderView
@global CPSingleDateMode
@global CPRangeDateMode
@@ -92,8 +96,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];
}
@@ -133,10 +135,10 @@ var CPZeroKeyCode = 48,
return NO;
}
#pragma mark -
#pragma mark Setter Getter methods
/*! Set the value of the control
@param aDateValue
*/
@@ -145,6 +147,10 @@ var CPZeroKeyCode = 48,
var dateValue = [aDateValue copy];
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
[_datePickerElementView setDateValue:dateValue];
// Be sure to update the stepper value. We don't use -setObjectValue to avoid a binding update.
if (_currentTextField)
_stepper._value = [_currentTextField intValue];
}
/*! Set the widget enabled or not
@@ -217,7 +223,7 @@ var CPZeroKeyCode = 48,
if ([_currentTextField dateType] != CPAMPMDateType)
{
// We update the value of the stepper dependind on the textField
[_stepper setObjectValue:parseInt([_currentTextField stringValue])];
[_stepper setObjectValue:[_currentTextField intValue]];
[_stepper setMaxValue:[_currentTextField maxNumber]];
[_stepper setMinValue:[_currentTextField minNumber]];
@@ -245,11 +251,11 @@ var CPZeroKeyCode = 48,
[self _selectTextField:_firstTextField];
[[self window] makeFirstResponder:_datePicker];
// This gonna update the dateValue with the binding
// Update the dateValue with the binding.
if (isUp)
[_stepper setDoubleValue:parseInt([_currentTextField objectValue]) + 1];
[_stepper setDoubleValue:[_currentTextField intValue] + 1];
else
[_stepper setDoubleValue:parseInt([_currentTextField objectValue]) - 1];
[_stepper setDoubleValue:[_currentTextField intValue] - 1];
return;
}
@@ -257,7 +263,7 @@ var CPZeroKeyCode = 48,
if ([_currentTextField dateType] != CPAMPMDateType)
{
// Make sure to get the good value, especially when we reach the maxDate or minDate
[sender setDoubleValue:parseInt([_currentTextField objectValue])];
[sender setDoubleValue:[_currentTextField intValue]];
}
else
{
@@ -284,7 +290,7 @@ var CPZeroKeyCode = 48,
if (key == CPUpArrowFunctionKey)
{
[_currentTextField _invalidTimer];
[_stepper setDoubleValue:parseInt([_currentTextField objectValue])];
[_stepper setDoubleValue:[_currentTextField intValue]];
[_stepper performClickUp:self];
return YES;
}
@@ -292,7 +298,7 @@ var CPZeroKeyCode = 48,
if (key == CPDownArrowFunctionKey)
{
[_currentTextField _invalidTimer];
[_stepper setDoubleValue:parseInt([_currentTextField objectValue])];
[_stepper setDoubleValue:[_currentTextField intValue]];
[_stepper performClickDown:self];
return YES;
}
@@ -361,7 +367,6 @@ var CPZeroKeyCode = 48,
[_currentTextField setValueForKeyEvent:anEvent];
}
#pragma mark -
#pragma mark Layout methods
@@ -380,14 +385,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)
{
@@ -401,11 +408,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
@@ -516,8 +549,6 @@ var CPZeroKeyCode = 48,
[self addSubview: _textFieldSeparatorThree];
[self addSubview: _textFieldSeparatorFour];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldAMPMChangedNotification:) name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
[self setNeedsLayout];
}
@@ -525,12 +556,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
@@ -593,23 +703,23 @@ var CPZeroKeyCode = 48,
[date _dateWithTimeZone:[_datePicker timeZone]];
if (![_textFieldDay isHidden])
date.setDate([_textFieldDay stringValue]);
date.setDate([_textFieldDay intValue]);
if (![_textFieldMonth isHidden])
date.setMonth(parseInt([_textFieldMonth stringValue]) - 1);
date.setMonth([_textFieldMonth intValue] - 1);
if (![_textFieldYear isHidden])
date.setFullYear([_textFieldYear stringValue]);
date.setFullYear([_textFieldYear intValue]);
if (![_textFieldSecond isHidden])
date.setSeconds([_textFieldSecond stringValue]);
date.setSeconds([_textFieldSecond intValue]);
if (![_textFieldMinute isHidden])
date.setMinutes([_textFieldMinute stringValue]);
date.setMinutes([_textFieldMinute intValue]);
if (![_textFieldHour isHidden])
{
var hour = parseInt([_textFieldHour stringValue]),
var hour = [_textFieldHour intValue],
currentHour = parseInt(date.getHours());
if (hour != currentHour)
@@ -671,7 +781,9 @@ var CPZeroKeyCode = 48,
dateValue.setHours(dateValue.getHours() - 12);
}
[_datePicker setDateValue:dateValue];
_datePicker._invokedByUserEvent = YES;
[_datePicker _setDateValue:dateValue timeInterval:[_datePicker timeInterval]];
_datePicker._invokedByUserEvent = NO;
}
@@ -698,6 +810,7 @@ var CPZeroKeyCode = 48,
[self _updateResponderTextField];
[self _updateHiddenTextFields];
[self _setControlSizes];
[self _sizeToFit];
[self _updatePositions];
@@ -734,183 +847,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
@@ -1009,7 +1140,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)];
@@ -1039,6 +1170,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
@@ -1236,6 +1386,12 @@ var CPMonthDateType = 0,
return self;
}
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
return [_datePicker isEnabled];
}
/*! Set the dateType of the textField
*/
- (void)setDateType:(int)aDateType
@@ -1563,6 +1719,7 @@ var CPMonthDateType = 0,
[self setStringValue:dateValue.getSeconds().toString()];
return;
}
[super setObjectValue:objectValue];
break;
@@ -1589,7 +1746,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;
}
@@ -1687,4 +1846,9 @@ var CPMonthDateType = 0,
return frameSize;
}
- (CGRect)bezelRectForBounds:(CGRect)bounds
{
return CGRectMakeCopy(bounds);
}
@end
+1
View File
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@typedef CPDragOperation
CPDragOperationNone = 0;
CPDragOperationCopy = 1 << 1;
CPDragOperationLink = 1 << 1;
+35
View File
@@ -31,9 +31,14 @@
@import "CPText.j"
@class CPTextField
@class CPWindow
@global CPApp
@typedef DOMEvent
@typedef CPEventType
var _CPEventPeriodicEventPeriod = 0,
_CPEventPeriodicEventTimer = nil,
_CPEventUpperCaseRegex = new RegExp("[A-Z]"),
@@ -68,6 +73,9 @@ var _CPEventPeriodicEventPeriod = 0,
float _deltaX;
float _deltaY;
float _deltaZ;
float _scrollingDeltaX;
float _scrollingDeltaY;
BOOL _hasPreciseScrollingDeltas;
#if PLATFORM(DOM)
BOOL _suppressCappuccinoCut;
@@ -163,7 +171,9 @@ var _CPEventPeriodicEventPeriod = 0,
// Make sure these are 0 rather than nil.
_deltaX = 0;
_scrollingDeltaX = 0;
_deltaY = 0;
_scrollingDeltaY = 0;
_deltaZ = 0;
}
@@ -417,6 +427,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
@@ -174,20 +174,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];
}
}
+2
View File
@@ -29,6 +29,7 @@
@global CPImagesPboardType
@global appkit_tag_dom_elements
@typedef CPImageAlignment
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
CPImageAlignTopLeft = 2;
@@ -178,6 +179,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
- (void)imageDidLoad:(CPNotification)aNotification
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:[self objectValue]];
[self hideOrDisplayContents];
[self setNeedsLayout];
+45 -2
View File
@@ -35,6 +35,7 @@
var exposedBindingsMap = @{},
bindingsMap = @{};
@typedef CPBindingOperationKind
var CPBindingOperationAnd = 0,
CPBindingOperationOr = 1;
@@ -70,6 +71,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 +131,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 +157,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 +174,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 +420,11 @@ var CPBindingOperationAnd = 0,
return [CPBinder class];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return NO;
}
- (CPArray)exposedBindings
{
var exposedBindings = [],
@@ -415,6 +453,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);
+2
View File
@@ -25,11 +25,13 @@
@global CPApp
@typedef CPTickMarkPosition
CPTickMarkBelow = 0;
CPTickMarkAbove = 1;
CPTickMarkLeft = CPTickMarkAbove;
CPTickMarkRight = CPTickMarkBelow;
@typedef CPLevelIndicatorStyle
CPRelevancyLevelIndicatorStyle = 0;
CPContinuousCapacityLevelIndicatorStyle = 1;
CPDiscreteCapacityLevelIndicatorStyle = 2;
+1
View File
@@ -651,6 +651,7 @@ var _CPMenuBarVisible = NO,
if (binder)
{
[binder setValueFor:CPEnabledBinding];
[[_menuWindow _menuView] tile];
return;
}
+1
View File
@@ -24,6 +24,7 @@
@import "_CPMenuManager.j"
@class _CPMenuView
@class CPMenu
@global CPMenuDidAddItemNotification
@global CPMenuDidChangeItemNotification
+3 -1
View File
@@ -25,6 +25,8 @@
@import "CPWindow.j"
@import "_CPMenuManager.j"
@class _CPMenuView
var _CPMenuWindowPool = [],
_CPMenuWindowPoolCapacity = 5,
@@ -410,7 +412,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
{
// Don't return indexes of items that aren't visible.
if (!CGRectContainsPoint([_menuClipView bounds], [_menuClipView convertPoint:aPoint fromView:nil]))
return NO;
return CPNotFound;
return [_menuView itemIndexAtPoint:[_menuView convertPoint:aPoint fromView:nil]];
}
@@ -25,6 +25,7 @@
@class _CPMenuBarWindow
@class _CPMenuView
@class CPMenuItem
@implementation _CPMenuItemMenuBarView : CPView
{
@@ -24,6 +24,9 @@
@import "CPImageView.j"
@import "_CPImageAndTextView.j"
@class CPMenuItem
@implementation _CPMenuItemStandardView : CPView
{
CPMenuItem _menuItem @accessors(property=menuItem);
+1
View File
@@ -26,6 +26,7 @@
@import "_CPMenuItemStandardView.j"
@import "_CPMenuItemMenuBarView.j"
@class CPMenuItem
@global CPApp
/*
+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;
+20
View File
@@ -119,4 +119,24 @@ CPDocModalWindowMask = 1 << 6;
return YES;
}
#pragma mark -
#pragma mark Overrides
/*!
@ignore
*/
- (void)cancelOperation:(id)sender
{
if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]])
return;
[[self firstResponder] tryToPerform:@selector(cancel:) with:self];
}
- (void)cancel:(id)sender
{
[self performClose:sender];
}
@end
+2 -1
View File
@@ -26,6 +26,7 @@
@import <Foundation/CPDictionary.j>
@import <Foundation/CPPropertyListSerialization.j>
@class CPWebScriptObject
CPGeneralPboard = @"CPGeneralPboard";
CPFontPboard = @"CPFontPboard";
@@ -66,7 +67,7 @@ var CPPasteboards = nil,
unsigned _changeCount;
CPString _stateUID;
WebScriptObject _nativePasteboard;
CPWebScriptObject _nativePasteboard;
}
/*
+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
+46 -18
View File
@@ -78,6 +78,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
int _behavior @accessors(getter=behavior);
_CPPopoverWindow _popoverWindow;
CPView _positioningView;
int _implementedDelegateMethods;
}
@@ -191,7 +192,7 @@ Set the behavior of the CPPopover. It can be:
return;
_behavior = aBehavior;
[_popoverWindow setStyleMask:[self styleMaskForBehavior]];
[_popoverWindow setStyleMask:[self _styleMaskForBehavior]];
}
- (void)setDelegate:(id <CPPopoverDelegate>)aDelegate
@@ -236,12 +237,14 @@ Set the behavior of the CPPopover. It can be:
if (!_contentViewController)
[CPException raise:CPInternalInconsistencyException reason:@"contentViewController must not be nil"];
// If the popover is currently closing, do nothing. That is what Cocoa does.
if ([_popoverWindow isClosing])
// If the popover is currently closing or opening, do nothing. That is what Cocoa does.
if ([_popoverWindow isClosing] || [_popoverWindow isOpening])
return;
_positioningView = positioningView;
if (!_popoverWindow)
_popoverWindow = [[_CPPopoverWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:[self styleMaskForBehavior]];
_popoverWindow = [[_CPPopoverWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:[self _styleMaskForBehavior]];
[_popoverWindow setPlatformWindow:[[positioningView window] platformWindow]];
[_popoverWindow setAppearance:_appearance];
@@ -251,18 +254,21 @@ Set the behavior of the CPPopover. It can be:
[_popoverWindow setFrame:[_popoverWindow frameRectForContentRect:[[_contentViewController view] frame]]];
[_popoverWindow setContentView:[_contentViewController view]];
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
[_delegate popoverWillShow:self];
if (![self isShown])
[self _popoverWillShow];
[_popoverWindow positionRelativeToRect:positioningRect ofView:positioningView preferredEdge:preferredEdge];
if (!_animates && _implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
[_delegate popoverDidShow:self];
if (![self isShown])
[self _popoverWindowDidShow];
}
- (unsigned)styleMaskForBehavior
- (unsigned)_styleMaskForBehavior
{
return (_behavior == CPPopoverBehaviorTransient) ? CPClosableOnBlurWindowMask : 0;
if (_behavior == CPPopoverBehaviorApplicationDefined)
return 0;
return CPClosableOnBlurWindowMask
}
/*!
@@ -281,9 +287,9 @@ Set the behavior of the CPPopover. It can be:
if ([_popoverWindow isClosing] || ![self isShown])
return;
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willClose_)
[_delegate popoverWillClose:self];
[self _popoverWillClose];
_positioningView = nil;
[_popoverWindow close];
// popoverDidClose will be sent from popoverWindowDidClose, since
@@ -304,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];
}
@@ -316,7 +321,7 @@ Set the behavior of the CPPopover. It can be:
#pragma mark Delegates
/*! @ignore */
- (BOOL)popoverWindowShouldClose:(_CPPopoverWindow)aPopoverWindow
- (BOOL)_popoverWindowShouldClose
{
[self performClose:self];
@@ -327,19 +332,42 @@ Set the behavior of the CPPopover. It can be:
}
/*! @ignore */
- (void)popoverWindowDidClose:(_CPPopoverWindow)aPopoverWindow
- (void)_popoverWindowDidClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didClose_)
[_delegate popoverDidClose:self];
}
/*! @ignore */
- (void)popoverWindowDidShow:(_CPPopoverWindow)aPopoverWindow
- (void)_popoverWindowDidShow
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
[_delegate popoverDidShow:self];
}
/*! @ignore */
- (BOOL)_popoverShouldClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_shouldClose_)
return [_delegate popoverShouldClose:self];
return YES;
}
/*! @ignore */
- (void)_popoverWillClose
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willClose_)
[_delegate popoverWillClose:self];
}
/*! @ignore */
- (void)_popoverWillShow
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
[_delegate popoverWillShow:self];
}
@end
@implementation CPPopover (Deprecated)
+1
View File
@@ -26,6 +26,7 @@
@import "CPWindow_Constants.j"
@typedef CPProgressIndicatorStyle
/*
@global
@group CPProgressIndicatorStyle
+10 -23
View File
@@ -25,6 +25,8 @@
@import "CPButton.j"
@class CPRadioGroup
@global CPApp
@@ -356,7 +358,7 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
[_selectedRadio setState:CPOffState];
_selectedRadio = aRadio;
[_CPRadioGroupSelectionBinder reverseSetValueForObject:self];
[_CPRadioGroupSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
@@ -407,32 +409,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
+1
View File
@@ -26,6 +26,7 @@
@import "CPEvent.j"
@class CPKeyBinding
@class CPMenu
CPDeleteKeyCode = 8;
CPTabKeyCode = 9;
@@ -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
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
CPRuleEditorPredicateLeftExpression = "CPRuleEditorPredicateLeftExpression";
CPRuleEditorPredicateRightExpression = "CPRuleEditorPredicateRightExpression";
CPRuleEditorPredicateComparisonModifier = "CPRuleEditorPredicateComparisonModifier";
@@ -36,5 +37,6 @@ CPRuleEditorNestingModeList = 1; // Allows a single list, with no nes
CPRuleEditorNestingModeCompound = 2; // Unlimited nesting and compound rows; this is the default
CPRuleEditorNestingModeSimple = 3; // One compound row at the top with subrows beneath it, and no further nesting allowed
@typedef CPRuleEditorRowType
CPRuleEditorRowTypeSimple = 0;
CPRuleEditorRowTypeCompound = 1;
@@ -20,6 +20,8 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@class CPPredicateEditorRowTemplate
@implementation _CPPredicateEditorTree : CPObject
{
CPPredicateEditorRowTemplate template @accessors;
@@ -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
+5 -3
View File
@@ -19,6 +19,8 @@
@import "CPView.j"
@class CPRuleEditor
@implementation _CPRuleEditorViewSlice : CPView
{
CPRuleEditor _ruleEditor;
@@ -61,9 +63,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
+14 -1
View File
@@ -1262,6 +1262,10 @@ Notifies the delegate when the scroll view has finished scrolling.
[self reflectScrolledClipView:_contentView];
}
- (CGRect)documentVisibleRect
{
return [_contentView documentVisibleRect];
}
#pragma mark -
#pragma mark Overrides
@@ -1399,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
+3 -32
View File
@@ -33,6 +33,7 @@
@global CPApp
// CPScroller Constants
@typedef CPScrollerPart
CPScrollerNoPart = 0;
CPScrollerDecrementPage = 1;
CPScrollerKnob = 2;
@@ -44,6 +45,7 @@ CPScrollerKnobSlot = 6;
CPScrollerIncrementArrow = 0;
CPScrollerDecrementArrow = 1;
@typedef CPUsableScrollerParts
CPNoScrollerParts = 0;
CPOnlyScrollerArrows = 1;
CPAllScrollerParts = 2;
@@ -78,7 +80,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
@implementation CPScroller : CPControl
{
CPControlSize _controlSize;
CPUsableScrollerParts _usableParts;
CPArray _partRects;
@@ -172,7 +173,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
{
if (self = [super initWithFrame:aFrame])
{
_controlSize = CPRegularControlSize;
_partRects = [];
[self setFloatValue:0.0];
@@ -243,29 +243,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 +779,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
@end
var CPScrollerControlSizeKey = @"CPScrollerControlSize",
CPScrollerIsVerticalKey = @"CPScrollerIsVerticalKey",
var CPScrollerIsVerticalKey = @"CPScrollerIsVerticalKey",
CPScrollerKnobProportionKey = @"CPScrollerKnobProportion",
CPScrollerStyleKey = @"CPScrollerStyleKey";
@@ -813,10 +789,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 +823,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
+96 -56
View File
@@ -28,6 +28,7 @@
@global CPApp
@typedef CPSegmentSwitchTracking
CPSegmentSwitchTrackingSelectOne = 0;
CPSegmentSwitchTrackingSelectAny = 1;
CPSegmentSwitchTrackingMomentary = 2;
@@ -70,23 +71,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 +91,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 +496,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 +561,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 +585,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 +605,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 +619,6 @@ CPSegmentSwitchTrackingMomentary = 2;
[bezelView setBackgroundColor:bezelColor];
// layout image/title views
var segment = _segments[i],
contentView = [self layoutEphemeralSubviewNamed:@"segment-content-" + i
@@ -651,6 +651,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 +712,6 @@ CPSegmentSwitchTrackingMomentary = 2;
// Update control size
var frame = [self frame];
[self setFrameSize:CGSizeMake(CGRectGetWidth(frame) + delta, CGRectGetHeight(frame))];
// Update segment width
@@ -743,7 +747,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 +757,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 +919,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 +927,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 +971,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
+1 -1
View File
@@ -26,7 +26,7 @@
@import "CPImage.j"
@import "CPView.j"
@typedef CPShadowWeight
CPLightShadow = 0;
CPHeavyShadow = 1;
+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
+2 -1
View File
@@ -25,6 +25,7 @@
@import "CPTabViewItem.j"
@import "CPView.j"
@typedef CPTabViewType
CPTopTabsBezelBorder = 0;
//CPLeftTabsBezelBorder = 1;
CPBottomTabsBezelBorder = 2;
@@ -94,7 +95,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]];
+1 -1
View File
@@ -23,7 +23,7 @@
@import <Foundation/CPObject.j>
@import "CPView.j"
@class CPTabView
/*
The tab is currently selected.
+1
View File
@@ -31,6 +31,7 @@
@global CPTableViewColumnDidResizeNotification
@class _CPTableColumnHeaderView
@class CPTableView
CPTableColumnNoResizing = 0;
CPTableColumnAutoresizingMask = 1 << 0;
+37 -5
View File
@@ -42,6 +42,7 @@
@class CPTableHeaderView
@class CPClipView
@class CPButton
@class _CPDropOperationDrawingView
@global CPApp
@@ -170,7 +171,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
@implementation _CPTableDrawView : CPView
{
CPTableView _tableView;
id _tableView;
}
- (id)initWithTableView:(CPTableView)aTableView
@@ -473,8 +474,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (!_sortDescriptors)
_sortDescriptors = [];
[self _startObservingFirstResponder];
}
/*!
@@ -964,7 +963,7 @@ NOT YET IMPLEMENTED
</pre>
*/
- (void)unfocusedSelectionGradientColors
- (CPColor)unfocusedSelectionGradientColors
{
if (!_unfocusedSourceListSelectionColor)
{
@@ -3950,6 +3949,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 +4455,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 +5124,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 +5183,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 +6031,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];
+332 -169
View File
@@ -31,6 +31,7 @@
@global CPApp
@global CPStringPboardType
@global CPCursor
@protocol CPTextFieldDelegate <CPControlTextEditingDelegate>
@@ -40,15 +41,17 @@
var CPTextFieldDelegate_control_didFailToFormatString_errorDescription_ = 1 << 1;
@typedef CPTextFieldBezelStyle
CPTextFieldSquareBezel = 0; /*! A textfield bezel with squared corners. */
CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */
CPTextFieldDidFocusNotification = @"CPTextFieldDidFocusNotification";
CPTextFieldDidBlurNotification = @"CPTextFieldDidBlurNotification";
var CPTextFieldDOMInputElement = nil,
CPTextFieldDOMPasswordInputElement = nil,
var CPTextFieldDOMCurrentElement = nil,
CPTextFieldDOMTextAreaElement = nil,
CPTextFieldDOMStandardInputElement = nil,
CPTextFieldDOMPasswordInputElement = nil,
CPTextFieldInputOwner = nil,
CPTextFieldTextDidChangeValue = nil,
CPTextFieldInputResigning = NO,
@@ -126,6 +129,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
BOOL _isSelectable;
BOOL _isSecure;
BOOL _willBecomeFirstResponderByClick;
BOOL _invokedByUserEvent;
BOOL _drawsBackground;
@@ -140,7 +144,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
// NS-style Display Properties
CPTextFieldBezelStyle _bezelStyle;
BOOL _isBordered;
CPControlSize _controlSize;
BOOL _usesSingleLineMode;
BOOL _wraps;
BOOL _scrolls;
}
+ (Class)_binderClassForBinding:(CPString)aBinding
@@ -227,98 +233,124 @@ 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
{
if (!CPTextFieldDOMInputElement)
if (!CPTextFieldDOMTextAreaElement)
{
CPTextFieldDOMInputElement = document.createElement("input");
CPTextFieldDOMInputElement.style.position = "absolute";
CPTextFieldDOMInputElement.style.border = "0px";
CPTextFieldDOMInputElement.style.padding = "0px";
CPTextFieldDOMInputElement.style.margin = "0px";
CPTextFieldDOMInputElement.style.whiteSpace = "pre";
CPTextFieldDOMInputElement.style.background = "transparent";
CPTextFieldDOMInputElement.style.outline = "none";
CPTextFieldDOMTextAreaElement = document.createElement("textarea");
CPTextFieldDOMTextAreaElement.style.position = "absolute";
CPTextFieldDOMTextAreaElement.style.border = "0px";
CPTextFieldDOMTextAreaElement.style.padding = "0px";
CPTextFieldDOMTextAreaElement.style.margin = "0px";
CPTextFieldDOMTextAreaElement.style.background = "transparent";
CPTextFieldDOMTextAreaElement.style.outline = "none";
CPTextFieldDOMTextAreaElement.style.resize = "none";
CPTextFieldDOMTextAreaElement.style.overflow = "hidden";
CPTextFieldDOMTextAreaElement.spellcheck = NO;
}
if (!CPTextFieldDOMStandardInputElement)
{
CPTextFieldDOMStandardInputElement = document.createElement("input");
CPTextFieldDOMStandardInputElement.style.position = "absolute";
CPTextFieldDOMStandardInputElement.style.border = "0px";
CPTextFieldDOMStandardInputElement.style.padding = "0px";
CPTextFieldDOMStandardInputElement.style.margin = "0px";
CPTextFieldDOMStandardInputElement.style.whiteSpace = "pre";
CPTextFieldDOMStandardInputElement.style.background = "transparent";
CPTextFieldDOMStandardInputElement.style.outline = "none";
CPTextFieldDOMStandardInputElement.spellcheck = NO;
}
if (!CPTextFieldDOMPasswordInputElement)
{
CPTextFieldDOMPasswordInputElement = document.createElement("input");
CPTextFieldDOMPasswordInputElement.style.position = "absolute";
CPTextFieldDOMPasswordInputElement.style.border = "0px";
CPTextFieldDOMPasswordInputElement.style.padding = "0px";
CPTextFieldDOMPasswordInputElement.style.margin = "0px";
CPTextFieldDOMPasswordInputElement.style.whiteSpace = "pre";
CPTextFieldDOMPasswordInputElement.style.background = "transparent";
CPTextFieldDOMPasswordInputElement.style.outline = "none";
CPTextFieldDOMPasswordInputElement.type = "password";
CPTextFieldDOMPasswordInputElement.spellcheck = NO;
}
if (!CPTextFieldBlurHandler)
{
CPTextFieldBlurHandler = function(anEvent)
{
return CPTextFieldBlurFunction(
anEvent,
CPTextFieldInputOwner,
CPTextFieldInputOwner ? CPTextFieldInputOwner._DOMElement : nil,
CPTextFieldDOMInputElement,
CPTextFieldDOMCurrentElement,
CPTextFieldInputResigning,
@ref(CPTextFieldInputDidBlur));
};
}
if (CPFeatureIsCompatible(CPInputOnInputEventFeature))
if (!CPTextFieldInputFunction)
{
if (!CPFeatureIsCompatible(CPInputOnInputEventFeature))
return;
CPTextFieldInputFunction = function(anEvent)
{
CPTextFieldInputFunction = function(anEvent)
{
if (!CPTextFieldInputOwner)
return;
if (!CPTextFieldInputOwner)
return;
var cappEvent = [CPEvent keyEventWithType:CPKeyUp
location:CGPointMakeZero()
modifierFlags:0
timestamp:[CPEvent currentTimestamp]
windowNumber:[[CPApp keyWindow] windowNumber]
context:nil
characters:nil
charactersIgnoringModifiers:nil
isARepeat:NO
keyCode:nil];
var cappEvent = [CPEvent keyEventWithType:CPKeyUp
location:CGPointMakeZero()
modifierFlags:0
timestamp:[CPEvent currentTimestamp]
windowNumber:[[CPApp keyWindow] windowNumber]
context:nil
characters:nil
charactersIgnoringModifiers:nil
isARepeat:NO
keyCode:nil];
[CPTextFieldInputOwner keyUp:cappEvent];
[CPTextFieldInputOwner keyUp:cappEvent];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
CPTextFieldDOMInputElement.oninput = CPTextFieldInputFunction;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
// FIXME make this not onblur
CPTextFieldDOMInputElement.onblur = CPTextFieldBlurHandler;
CPTextFieldDOMPasswordInputElement.oninput = CPTextFieldInputFunction;
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurHandler;
CPTextFieldDOMStandardInputElement = CPTextFieldDOMInputElement;
CPTextFieldDOMStandardInputElement.oninput = CPTextFieldInputFunction;
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurHandler;
CPTextFieldDOMTextAreaElement.oninput = CPTextFieldInputFunction;
CPTextFieldDOMTextAreaElement.onblur = CPTextFieldBlurHandler;
}
if (CPFeatureIsCompatible(CPInputTypeCanBeChangedFeature))
{
if ([self isSecure])
CPTextFieldDOMInputElement.type = "password";
else
CPTextFieldDOMInputElement.type = "text";
return CPTextFieldDOMInputElement;
}
if ([self isSecure])
{
if (!CPTextFieldDOMPasswordInputElement)
{
CPTextFieldDOMPasswordInputElement = document.createElement("input");
CPTextFieldDOMPasswordInputElement.style.position = "absolute";
CPTextFieldDOMPasswordInputElement.style.border = "0px";
CPTextFieldDOMPasswordInputElement.style.padding = "0px";
CPTextFieldDOMPasswordInputElement.style.margin = "0px";
CPTextFieldDOMPasswordInputElement.style.whiteSpace = "pre";
CPTextFieldDOMPasswordInputElement.style.background = "transparent";
CPTextFieldDOMPasswordInputElement.style.outline = "none";
CPTextFieldDOMPasswordInputElement.type = "password";
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurHandler;
}
CPTextFieldDOMInputElement = CPTextFieldDOMPasswordInputElement;
}
CPTextFieldDOMCurrentElement = CPTextFieldDOMPasswordInputElement;
else if (_usesSingleLineMode)
CPTextFieldDOMCurrentElement = CPTextFieldDOMStandardInputElement;
else
{
CPTextFieldDOMInputElement = CPTextFieldDOMStandardInputElement;
}
CPTextFieldDOMCurrentElement = CPTextFieldDOMTextAreaElement;
return CPTextFieldDOMInputElement;
return CPTextFieldDOMCurrentElement;
}
#endif
@@ -537,6 +569,24 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
return _textFieldBackgroundColor;
}
/*! @ignore */
- (void)_setUsesSingleLineMode:(BOOL)aFlag
{
_usesSingleLineMode = aFlag;
}
/*! @ignore */
- (void)_setWraps:(BOOL)aFlag
{
_wraps = aFlag;
}
/*! @ignore */
- (void)_setScrolls:(BOOL)aFlag
{
_scrolls = aFlag;
}
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
@@ -590,75 +640,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
#if PLATFORM(DOM)
var element = [self _inputElement],
font = [self currentValueForThemeAttribute:@"font"],
lineHeight = [font defaultLineHeightForFont];
[self _setCSSStyleForInputElement];
var element = [self _inputElement];
element.value = _stringValue;
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPThemeStateEditing] cssString];
if (CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM))
element.style.font = [font cssString];
element.style.zIndex = 1000;
switch ([self alignment])
{
case CPCenterTextAlignment:
element.style.textAlign = "center";
break;
case CPRightTextAlignment:
element.style.textAlign = "right";
break;
default:
element.style.textAlign = "left";
}
var contentRect = [self contentRectForBounds:[self bounds]],
verticalAlign = [self currentValueForThemeAttribute:"vertical-alignment"];
switch (verticalAlign)
{
case CPTopVerticalTextAlignment:
var topPoint = CGRectGetMinY(contentRect) + "px";
break;
case CPCenterVerticalTextAlignment:
var topPoint = (CGRectGetMidY(contentRect) - (lineHeight / 2)) + "px";
break;
case CPBottomVerticalTextAlignment:
var topPoint = (CGRectGetMaxY(contentRect) - lineHeight) + "px";
break;
default:
var topPoint = CGRectGetMinY(contentRect) + "px";
break;
}
element.style.top = topPoint;
var left = CGRectGetMinX(contentRect);
// If the browser has a built in left padding, compensate for it. We need the input text to be exactly on top of the original text.
if (CPFeatureIsCompatible(CPInput1PxLeftPadding))
left -= 1;
element.style.left = left + "px";
element.style.width = CGRectGetWidth(contentRect) + "px";
element.style.height = ROUND(lineHeight) + "px";
element.style.lineHeight = ROUND(lineHeight) + "px";
element.style.verticalAlign = "top";
element.style.cursor = "auto";
_DOMElement.appendChild(element);
// The font change above doesn't work for some browsers if the element isn't already appendChild'ed.
if (!CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM))
element.style.font = [font cssString];
CPTextFieldInputIsActive = YES;
if (document.attachEvent)
@@ -696,6 +683,81 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
return YES;
}
/*!
Set the css style for the input element of the textField
@ignore
*/
- (void)_setCSSStyleForInputElement
{
#if PLATFORM(DOM)
var element = [self _inputElement],
font = [self currentValueForThemeAttribute:@"font"],
lineHeight = [font defaultLineHeightForFont],
contentRect = [self contentRectForBounds:[self bounds]],
verticalAlign = [self currentValueForThemeAttribute:"vertical-alignment"],
left = CGRectGetMinX(contentRect);
// If the browser has a built in left padding, compensate for it. We need the input text to be exactly on top of the original text.
if (CPFeatureIsCompatible(CPInput1PxLeftPadding))
left -= 1;
switch (verticalAlign)
{
case CPTopVerticalTextAlignment:
var topPoint = CGRectGetMinY(contentRect) + "px";
break;
case CPCenterVerticalTextAlignment:
var topPoint = (CGRectGetMidY(contentRect) - (lineHeight / 2)) + "px";
break;
case CPBottomVerticalTextAlignment:
var topPoint = (CGRectGetMaxY(contentRect) - lineHeight) + "px";
break;
default:
var topPoint = CGRectGetMinY(contentRect) + "px";
break;
}
if ([self hasThemeState:CPTextFieldStatePlaceholder])
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder] cssString];
else
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPThemeStateEditing] cssString];
switch ([self alignment])
{
case CPCenterTextAlignment:
element.style.textAlign = "center";
break;
case CPRightTextAlignment:
element.style.textAlign = "right";
break;
default:
element.style.textAlign = "left";
}
var isTextArea = element.nodeName.toUpperCase() == "TEXTAREA";
element.style.zIndex = 1000;
element.style.top = topPoint;
element.style.lineHeight = ROUND(lineHeight) + "px";
element.style.height = isTextArea ? CGRectGetHeight(contentRect) + "px" : ROUND(lineHeight) + "px";;
element.style.width = CGRectGetWidth(contentRect) + "px";
element.style.left = left + "px";
element.style.verticalAlign = "top";
element.style.cursor = "auto";
element.style.font = [font cssString];
if (isTextArea)
element.style.whiteSpace = _wraps ? "pre" : "nowrap";
#endif
}
/*! @ignore */
- (BOOL)resignFirstResponder
{
@@ -799,6 +861,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])
@@ -867,6 +949,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
}
- (void)mouseMoved:(CPEvent)anEvent
{
[super mouseMoved:anEvent];
[self _updateCursorForEvent:anEvent];
}
- (void)mouseDown:(CPEvent)anEvent
{
// Don't track! (ever?)
@@ -937,7 +1025,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (newValue !== _stringValue)
{
[self _setStringValue:newValue];
[self _didEdit];
}
@@ -947,13 +1034,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];
}
@@ -1031,7 +1125,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
range = [self selectedRange],
element = [self _inputElement];
element.value = [element.value stringByReplacingCharactersInRange:[self selectedRange] withString:aCharacter];
// we don't need to do this in case of textarea
// or we will end up with 2 carriage returns
if (aCharacter != CPNewlineCharacter || element.nodeName.toUpperCase() != "TEXTAREA" || !CPFeatureIsCompatible(CPAltEnterTextAreaFeature))
element.value = [element.value stringByReplacingCharactersInRange:[self selectedRange] withString:aCharacter];
[self _setStringValue:element.value];
// NOTE: _stringValue is now the current input element value
@@ -1071,6 +1169,27 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[super textDidChange:note];
}
- (void)_updateCursorForEvent:(CPEvent)anEvent
{
var frame = CGRectMakeCopy([self frame]),
contentInset = [self currentValueForThemeAttribute:@"content-inset"];
frame = [[self superview] convertRectToBase:CGRectInsetByInset(frame, contentInset)];
if ([self isEnabled] && ([self isSelectable] || [self isEditable]) && CGRectContainsPoint(frame, [anEvent locationInWindow]))
{
#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.
*/
@@ -1127,12 +1246,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];
@@ -1517,7 +1641,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
var selectedRange = [self selectedRange];
if (selectedRange.length < 1)
if (selectedRange.length === 0)
{
if (selectedRange.location < 1)
return;
@@ -1527,19 +1651,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
@@ -1553,16 +1665,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
@@ -1572,24 +1675,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
@@ -1742,6 +1859,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[contentView setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]];
[contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
}
if (_isEditing)
[self _setCSSStyleForInputElement];
}
- (void)takeValueFromKeyPath:(CPString)aKeyPath ofObjects:(CPArray)objects
@@ -1762,6 +1882,20 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
#pragma mark Overrides
/*!
Sets the text color of the receiver.
@param aColor - A CPColor object.
*/
- (void)setTextColor:(CPColor)aColor
{
// We don't want to change the text-color of the placeHolder of the textField
var placeholderColor = [self valueForThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
[super setTextColor:aColor];
[self setValue:placeholderColor forThemeAttribute:@"text-color" inState:CPTextFieldStatePlaceholder];
}
- (void)viewDidHide
{
[super viewDidHide];
@@ -1808,7 +1942,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];
@@ -1840,7 +1974,11 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
CPTextFieldLineBreakModeKey = "CPTextFieldLineBreakModeKey",
CPTextFieldAlignmentKey = "CPTextFieldAlignmentKey",
CPTextFieldBackgroundColorKey = "CPTextFieldBackgroundColorKey",
CPTextFieldPlaceholderStringKey = "CPTextFieldPlaceholderStringKey";
CPTextFieldPlaceholderStringKey = "CPTextFieldPlaceholderStringKey",
CPTextFieldUsesSingleLineMode = "CPTextFieldUsesSingleLineMode",
CPTextFieldWraps = "CPTextFieldWraps",
CPTextFieldScrolls = "CPTextFieldScrolls";
@implementation CPTextField (CPCoding)
@@ -1866,6 +2004,10 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
[self setAlignment:[aCoder decodeIntForKey:CPTextFieldAlignmentKey]];
[self setPlaceholderString:[aCoder decodeObjectForKey:CPTextFieldPlaceholderStringKey]];
[self _setUsesSingleLineMode:[aCoder decodeBoolForKey:CPTextFieldUsesSingleLineMode]];
[self _setWraps:[aCoder decodeBoolForKey:CPTextFieldWraps]];
[self _setScrolls:[aCoder decodeBoolForKey:CPTextFieldScrolls]];
}
return self;
@@ -1890,6 +2032,10 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
[aCoder encodeInt:[self alignment] forKey:CPTextFieldAlignmentKey];
[aCoder encodeObject:_placeholderString forKey:CPTextFieldPlaceholderStringKey];
[aCoder encodeBool:_usesSingleLineMode forKey:CPTextFieldUsesSingleLineMode];
[aCoder encodeBool:_wraps forKey:CPTextFieldWraps];
[aCoder encodeBool:_scrolls forKey:CPTextFieldScrolls];
}
@end
@@ -1920,6 +2066,23 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
[_source setObjectValue:aValue];
}
- (void)reverseSetValueFor:(CPString)aBinding
{
var destination = [_info objectForKey:CPObservedObjectKey],
keyPath = [_info objectForKey:CPObservedKeyPathKey],
options = [_info objectForKey:CPOptionsKey],
newValue = [self valueForBinding:aBinding],
value = [destination valueForKeyPath:keyPath];
if (CPIsControllerMarker(value) && newValue === nil) return;
newValue = [self reverseTransformValue:newValue withOptions:options];
[self suppressSpecificNotificationFromObject:destination keyPath:keyPath];
[destination setValue:newValue forKeyPath:keyPath];
[self unsuppressSpecificNotificationFromObject:destination keyPath:keyPath];
}
@end
@implementation _CPTextFieldPatternValueBinder : CPValueWithPatternBinding
+24 -20
View File
@@ -26,6 +26,7 @@
@import <Foundation/CPKeyedUnarchiver.j>
@class CPView
@class _CPThemeAttribute
var CPThemesByName = { },
CPThemeDefaultTheme = nil,
@@ -499,25 +500,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
{
@@ -774,7 +778,7 @@ function CPThemeAttributeDecode(aCoder, anAttributeName, aDefaultValue, aTheme,
{
var attribute = [aCoder decodeObjectForKey:key];
if (!attribute.isa || ![attribute isKindOfClass:[_CPThemeAttribute class]])
if (!attribute || !attribute.isa || ![attribute isKindOfClass:[_CPThemeAttribute class]])
{
var themeAttribute = [[_CPThemeAttribute alloc] initWithName:anAttributeName defaultValue:aDefaultValue];
+19 -16
View File
@@ -33,6 +33,9 @@
@import "CPTextField.j"
@import "CPWindow_Constants.j"
@class _CPTokenFieldTokenCloseButton
@class _CPTokenFieldTokenDisclosureButton
@global CPApp
@global CPTextFieldDidFocusNotification
@global CPTextFieldDidBlurNotification
@@ -105,7 +108,7 @@ CPTokenFieldDeleteButtonType = 1;
int _buttonType @accessors(property=buttonType);
id <CPTokenFieldDelegate> _tokenFieldDelegate;
unsigned _implementedDelegateMethods;
unsigned _implementedTokenFieldDelegateMethods;
}
+ (CPCharacterSet)defaultTokenizingCharacterSet
@@ -177,25 +180,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 +1251,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 +1277,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 +1299,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 +1321,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 +1336,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 +1345,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];
+3 -1
View File
@@ -37,6 +37,8 @@ var CPToolbarDelegate_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_
CPToolbarDelegate_toolbarSelectableItemIdentifiers_ = 1 << 4,
CPToolbarDelegate_toolbarWillAddItem_ = 1 << 5;
@typedef CPToolbarDisplayMode
/*
@global
@group CPToolbarDisplayMode
@@ -58,7 +60,7 @@ CPToolbarDisplayModeIconOnly = 2;
*/
CPToolbarDisplayModeLabelOnly = 3;
@typedef CPToolbarSizeMode
CPToolbarSizeModeDefault = 0;
CPToolbarSizeModeRegular = 1;
CPToolbarSizeModeSmall = 2;
+104 -25
View File
@@ -40,9 +40,12 @@
@class CPMenu
@class CPClipView
@class CPScrollView
@class CALayer
@global appkit_tag_dom_elements
@typedef _CPViewFullScreenModeState
#if PLATFORM(DOM)
if (typeof(appkit_tag_dom_elements) !== "undefined" && appkit_tag_dom_elements)
@@ -229,6 +232,8 @@ var CPViewFlags = { },
Function _toolTipFunctionOut;
BOOL _toolTipInstalled;
BOOL _isObserving;
id _animator;
CPDictionary _animationsDictionary;
}
@@ -514,8 +519,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];
@@ -543,14 +552,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;
@@ -583,6 +590,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)
@@ -598,8 +614,6 @@ var CPViewFlags = { },
[aSubview _notifyWindowDidResignKey];
}
[aSubview viewDidMoveToSuperview];
[self didAddSubview:aSubview];
}
@@ -616,6 +630,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;
@@ -640,8 +666,6 @@ var CPViewFlags = { },
[self _notifyViewDidResignFirstResponder];
_superview = nil;
[self _setWindow:nil];
}
/*!
@@ -651,14 +675,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
@@ -733,13 +757,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
@@ -809,6 +830,10 @@ var CPViewFlags = { },
*/
- (void)viewWillMoveToSuperview:(CPView)aView
{
[self _removeObservers];
if (aView)
[self _addObservers];
}
/*!
@@ -827,6 +852,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
@@ -1030,7 +1081,8 @@ var CPViewFlags = { },
else
{
var images = [[_backgroundColor patternImage] imageSlices],
partIndex = 0;
partIndex = 0,
frameSize = aSize;
if (_backgroundType === BackgroundVerticalThreePartImage)
{
@@ -1040,16 +1092,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);
}
}
@@ -1061,16 +1118,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);
}
}
@@ -1811,6 +1873,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
@@ -1821,6 +1886,9 @@ var CPViewFlags = { },
}
else
_DOMElement.style.background = colorCSS;
if (patternImage)
CPDomDisplayServerSetStyleBackgroundSize(_DOMElement, [patternImage size].width + "px", [patternImage size].height + "px");
}
else
{
@@ -1925,18 +1993,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);
}
@@ -1951,18 +2025,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);
}
@@ -2547,7 +2626,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
{
@@ -2942,10 +3021,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)
+1
View File
@@ -210,6 +210,7 @@ var CPViewControllerCachedCibs;
[cibOwner viewControllerDidLoadCib:self];
_isLoading = NO;
_isLazy = NO;
[self _viewDidLoad];
}
else if (_isLazy)
+2 -1
View File
@@ -23,6 +23,7 @@
@import "CPView.j"
@import "CPScrollView.j"
@class CPWebScriptObject
// FIXME: implement these where possible:
/*
@@ -93,7 +94,7 @@ CPWebViewAppKitScrollMaxPollCount = 3;
CPScrollView _scrollView;
CPView _frameView;
IFrame _iframe;
DOMElement _iframe;
CPString _mainFrameURL;
CPArray _backwardStack;
CPArray _forwardStack;
+65 -25
View File
@@ -50,9 +50,14 @@
@class CPMenu
@class CPProgressIndicator
@class CPToolbar
@class CPWindowController
@class _CPWindowFrameAnimation
@global CPApp
@typedef _CPWindowFullPlatformWindowSession
@protocol CPWindowDelegate <CPObject>
@@ -902,6 +907,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)
@@ -961,6 +968,8 @@ CPTexturedBackgroundWindowMask
if (!_isVisible)
return;
[[self contentView] _removeObservers];
if ([self isSheet])
{
// -dw- as in Cocoa, orderOut: detaches the sheet and animates out
@@ -978,6 +987,7 @@ CPTexturedBackgroundWindowMask
[_platformWindow order:CPWindowOut window:self relativeTo:nil];
#endif
[self makeFirstResponder:nil];
[self _updateMainAndKeyWindows];
}
@@ -1131,7 +1141,7 @@ CPTexturedBackgroundWindowMask
*/
- (void)setContentView:(CPView)aView
{
if (_contentView)
if (_contentView && _contentView !== aView)
[_contentView removeFromSuperview];
var bounds = CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame));
@@ -1792,10 +1802,14 @@ CPTexturedBackgroundWindowMask
// even that we just moved it to a new first responder.
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO]
#endif
}
}
return didTabBack;
}
else if ([anEvent charactersIgnoringModifiers] == CPEscapeFunctionKey && [self _processKeyboardUIKey:anEvent])
{
return;
}
[[self firstResponder] keyDown:anEvent];
@@ -1838,6 +1852,12 @@ CPTexturedBackgroundWindowMask
if (_leftMouseDownView !== _firstResponder && [_leftMouseDownView acceptsFirstResponder])
[self makeFirstResponder:_leftMouseDownView];
var keyWindow = [CPApp keyWindow];
// This is only when we move from a platform to another one
if ([keyWindow platformWindow] != [self platformWindow])
[self makeKeyAndOrderFront:self];
[CPApp activateIgnoringOtherApps:YES];
var theWindow = [anEvent window],
@@ -2469,7 +2489,7 @@ CPTexturedBackgroundWindowMask
if (currentWindow === self || currentWindow === menuWindow)
continue;
if ([currentWindow isVisible] && [currentWindow canBecomeKeyWindow])
if ([currentWindow isVisible] && [currentWindow canBecomeKeyWindow] && [currentWindow platformWindow] == [keyWindow platformWindow])
{
[currentWindow makeKeyWindow];
break;
@@ -2671,6 +2691,23 @@ CPTexturedBackgroundWindowMask
[attachedSheet setFrame:sheetFrame display:YES animate:NO];
}
- (void)_previousSheetIsClosedNotification:(CPNotification)aNotification
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPWindowDidEndSheetNotification object:self];
var sheet = _sheetContext[@"nextSheet"],
modalDelegate =_sheetContext[@"nextModalDelegate"],
endSelector = _sheetContext[@"nextEndSelector"],
contextInfo = _sheetContext[@"nextContextInfo"];
// Needed, because when the notification CPWindowDidEndSheetNotification is sent, the sheetContext is not up to date...
setTimeout(function()
{
[sheet._windowView _enableSheet:YES inWindow:self];
[self _attachSheet:sheet modalDelegate:modalDelegate didEndSelector:endSelector contextInfo:contextInfo];
}, 0)
}
/*
Starting point for sheet session, called from CPApplication beginSheet:
*/
@@ -2679,9 +2716,24 @@ CPTexturedBackgroundWindowMask
{
if (_sheetContext)
{
[CPException raise:CPInternalInconsistencyException
reason:@"The target window of beginSheet: already has a sheet, did you forget orderOut: ?"];
return;
// Here we wait till the current sheet is closed
if (_sheetContext[@"isClosing"])
{
// Here we save the next sheet to open
_sheetContext[@"nextSheet"] = aSheet;
_sheetContext[@"nextModalDelegate"] = aModalDelegate;
_sheetContext[@"nextEndSelector"] = didEndSelector;
_sheetContext[@"nextContextInfo"] = contextInfo;
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_previousSheetIsClosedNotification:) name:CPWindowDidEndSheetNotification object:self];
return;
}
else
{
[CPException raise:CPInternalInconsistencyException
reason:@"The target window of beginSheet: already has a sheet, did you forget orderOut: ?"];
return;
}
}
_sheetContext = {
@@ -2733,7 +2785,12 @@ CPTexturedBackgroundWindowMask
*/
- (void)_detachSheetWindow
{
if (_sheetContext["isClosing"])
return;
_sheetContext["isAttached"] = NO;
_sheetContext["isClosing"] = YES;
_sheetContext["opened"] = NO;
// A timer seems to be necessary for the animation to work correctly.
// It would be ideal to block here and spin the event loop, until attach is complete.
@@ -2866,12 +2923,6 @@ CPTexturedBackgroundWindowMask
return;
}
if (_sheetContext["isClosing"])
return;
_sheetContext["opened"] = NO;
_sheetContext["isClosing"] = YES;
// The parent window can be orderedOut to disable the sheet animate out, as in Cocoa
if ([self isVisible])
{
@@ -3018,20 +3069,9 @@ CPTexturedBackgroundWindowMask
if ([selectors count] <= 0)
return NO;
if (character !== CPEscapeFunctionKey)
{
var selector = [selectors objectAtIndex:0];
return [[self firstResponder] tryToPerform:selector with:self];
}
else
{
/*
Cocoa sends complete: for the escape key (instead of the default cancelOperation:). This is also the only action that is not sent directly to the first responder, but through doCommandBySelector. The difference is that doCommandBySelector: will also send the action to the window and application delegates.
*/
[[self firstResponder] doCommandBySelector:@selector(complete:)];
}
var selector = [selectors objectAtIndex:0];
return NO;
return [[self firstResponder] tryToPerform:selector with:self];
}
- (void)_dirtyKeyViewLoop
+2
View File
@@ -81,6 +81,7 @@ CPWindowMinYMargin = 8;
CPWindowHeightSizable = 16;
CPWindowMaxYMargin = 32;
@typedef CPWindowLevel
CPBackgroundWindowLevel = -1;
/*
Default level for windows
@@ -143,6 +144,7 @@ CPDraggingWindowLevel = 500;
*/
CPScreenSaverWindowLevel = 1000;
@typedef CPWindowOrderingMode
/*
The receiver is placed directly in front of the window specified.
@global
+2 -2
View File
@@ -51,7 +51,7 @@
// Not being able to set the action is a fatal error.
if ([_source respondsToSelector:@selector(setAction:)])
objj_msgSend(_source, @selector(setAction:), selector);
[_source setAction:selector];
else
[CPException
@@ -60,7 +60,7 @@
// Not being able to set the target is a fatal error.
if ([_source respondsToSelector:@selector(setTarget:)])
objj_msgSend(_source, @selector(setTarget:), _destination);
[_source setTarget:_destination];
else
[CPException
+2
View File
@@ -22,6 +22,8 @@
@import "CGGeometry.j"
@typedef CGAffineTransform
function CGAffineTransformMake(a, b, c, d, tx, ty)
{
+2
View File
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@typedef CGColorSpace
kCGColorSpaceModelUnknown = -1;
kCGColorSpaceModelMonochrome = 0;
kCGColorSpaceModelRGB = 1;
+1
View File
@@ -25,6 +25,7 @@
@import "CGGeometry.j"
@import "CGPath.j"
@typedef CGContext
kCGLineCapButt = 0;
kCGLineCapRound = 1;
+1
View File
@@ -23,6 +23,7 @@
@import "CGColor.j"
@import "CGColorSpace.j"
@typedef CGGradient
kCGGradientDrawsBeforeStartLocation = 1 << 0;
kCGGradientDrawsAfterEndLocation = 1 << 1;
+2 -1
View File
@@ -23,6 +23,7 @@
@import "CGAffineTransform.j"
@import "CGGeometry.j"
@typedef CGPath
kCGPathElementMoveToPoint = 0;
kCGPathElementAddLineToPoint = 1;
@@ -629,4 +630,4 @@ function CGPathContainsPoint(aPath, aTransform, point, eoFill)
/*!
@}
*/
*/
+3
View File
@@ -27,9 +27,12 @@
@class CPMenu
@class CPPlatformPasteboard
@class CPWindow
@global CPApp
@typedef DOMWindow
var PrimaryPlatformWindow = NULL;
@implementation CPPlatformWindow : CPObject
+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
+23 -11
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)
@@ -1131,7 +1143,7 @@ var PreventScroll = true;
_mouseDownIsRightClick = button == 2 || (CPBrowserIsOperatingSystem(CPMacOperatingSystem) && button == 0 && modifierFlags & CPControlKeyMask);
if (sourceElement.tagName === "INPUT" && sourceElement != _DOMFocusElement)
if ((sourceElement.tagName === "INPUT" || sourceElement.tagName === "TEXTAREA") && sourceElement != _DOMFocusElement)
{
if ([CPPlatform supportsDragAndDrop])
{
@@ -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, 27.0, 7.0, 8.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(8.0, 27.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
+1 -1
View File
@@ -71,7 +71,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
#if PLATFORM(DOM)
DOMElement _DOMImageElement;
DOMELement _DOMTextElement;
DOMElement _DOMTextElement;
DOMElement _DOMTextShadowElement;
#endif
}
+108 -108
View File
@@ -65,6 +65,113 @@ var ListMinimumItems = 3;
var ListColumnIdentifier = @"1";
@implementation _CPPopUpPanel : CPPanel
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
{
if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask])
_constrainsToUsableScreen = NO;
[self _trapNextMouseDown];
return self;
}
/*!
Returns \c YES if the receiver is able to receive input events
even when a modal session is active.
*/
- (BOOL)worksWhenModal
{
return YES;
}
- (void)sendEvent:(CPEvent)anEvent
{
var type = [anEvent type];
if (type === CPLeftMouseDown || type === CPRightMouseDown)
[[self delegate] setListWasClicked:YES];
return [super sendEvent:anEvent];
}
- (void)orderFront:(id)sender
{
[self _trapNextMouseDown];
[super orderFront:sender];
}
- (void)_mouseWasClicked:(CPEvent)anEvent
{
var mouseWindow = [anEvent window],
rect = [[[self delegate] dataSource] bounds],
point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil];
if (mouseWindow != self && !CGRectContainsPoint(rect, point))
[[self delegate] close];
else
[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];
}
@end
@implementation _CPPopUpTableView : CPTableView
{
BOOL _acceptFirstResponder;
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
// We want the autocomplete to remain first responder until we are clicked.
_acceptFirstResponder = NO;
}
return self;
}
- (void)trackMouse:(CPEvent)anEvent
{
if (![self isEnabled])
return;
[[self delegate] setItemWasClicked:YES];
// CPTableView will not track the click if it is not first responder
_acceptFirstResponder = YES;
[[self window] makeFirstResponder:self];
[super trackMouse:anEvent];
}
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_acceptFirstResponder = NO;
[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];
}
- (BOOL)acceptsFirstResponder
{
return _acceptFirstResponder;
}
/*!
Return the column used for the list.
*/
- (CPTableColumn)listColumn
{
return _tableColumns[0];
}
@end
/*!
This class is a controller for a panel that can pop up and display a scrollable list of items in a CPTableView.
It is used by CPComboBox to display the list of choices.
@@ -229,7 +336,7 @@ var ListColumnIdentifier = @"1";
[self listWillPopUp];
[_panel orderFront:nil];
[[aView window] addChildWindow:_panel ordered:CPWindowAbove];
}
#pragma mark Setting Display Attributes
@@ -800,110 +907,3 @@ var _CPPopUpListDataSourceKey = @"_CPPopUpListDataSourceKey",
}
@end
@implementation _CPPopUpTableView : CPTableView
{
BOOL _acceptFirstResponder;
}
- (id)initWithFrame:(CGRect)aFrame
{
if (self = [super initWithFrame:aFrame])
{
// We want the autocomplete to remain first responder until we are clicked.
_acceptFirstResponder = NO;
}
return self;
}
- (void)trackMouse:(CPEvent)anEvent
{
if (![self isEnabled])
return;
[[self delegate] setItemWasClicked:YES];
// CPTableView will not track the click if it is not first responder
_acceptFirstResponder = YES;
[[self window] makeFirstResponder:self];
[super trackMouse:anEvent];
}
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
_acceptFirstResponder = NO;
[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];
}
- (BOOL)acceptsFirstResponder
{
return _acceptFirstResponder;
}
/*!
Return the column used for the list.
*/
- (CPTableColumn)listColumn
{
return _tableColumns[0];
}
@end
@implementation _CPPopUpPanel : CPPanel
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
{
if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask])
_constrainsToUsableScreen = NO;
[self _trapNextMouseDown];
return self;
}
/*!
Returns \c YES if the receiver is able to receive input events
even when a modal session is active.
*/
- (BOOL)worksWhenModal
{
return YES;
}
- (void)sendEvent:(CPEvent)anEvent
{
var type = [anEvent type];
if (type === CPLeftMouseDown || type === CPRightMouseDown)
[[self delegate] setListWasClicked:YES];
return [super sendEvent:anEvent];
}
- (void)orderFront:(id)sender
{
[self _trapNextMouseDown];
[super orderFront:sender];
}
- (void)_mouseWasClicked:(CPEvent)anEvent
{
var mouseWindow = [anEvent window],
rect = [[[self delegate] dataSource] bounds],
point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil];
if (mouseWindow != self && !CGRectContainsPoint(rect, point))
[[self delegate] close];
else
[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];
}
@end
+122 -26
View File
@@ -30,6 +30,9 @@
@class CPPopover
@global CPApp
@global CPPopoverBehaviorSemitransient
@global CPPopoverBehaviorTransient
@global CPPopoverBehaviorApplicationDefined
CPClosableOnBlurWindowMask = 1 << 4;
CPPopoverAppearanceMinimal = 0;
@@ -54,13 +57,19 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
id _targetView @accessors(property=targetView);
int _appearance @accessors(getter=appearance);
BOOL _isClosing @accessors(property=isClosing);
BOOL _isOpening @accessors(property=isOpening);
BOOL _browserAnimates;
BOOL _closeOnBlur;
BOOL _browserAnimates;
BOOL _isObservingFrame;
BOOL _shouldPerformAnimation;
CPInteger _implementedDelegateMethods;
CPWindow _targetWindow;
JSObject _orderOutTransitionFunction;
JSObject _transitionCompleteFunction;
JSObject _orderFrontTransitionFunction;
}
@@ -109,7 +118,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
_browserAnimates = [self browserSupportsAnimation];
_shouldPerformAnimation = YES;
_orderOutTransitionFunction = function() { [self _orderOutRecursively:YES]; };
_isOpening = YES;
[self setStyleMask:aStyleMask];
[self setBecomesKeyOnlyIfNeeded:YES];
@@ -148,13 +157,13 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(popoverWindowShouldClose:)])
if ([_delegate respondsToSelector:@selector(_popoverWindowShouldClose:)])
_implementedDelegateMethods |= _CPPopoverWindow_shouldClose_;
if ([_delegate respondsToSelector:@selector(popoverWindowDidClose:)])
if ([_delegate respondsToSelector:@selector(_popoverWindowDidClose:)])
_implementedDelegateMethods |= _CPPopoverWindow_didClose_;
if ([_delegate respondsToSelector:@selector(popoverWindowDidShow:)])
if ([_delegate respondsToSelector:@selector(_popoverWindowDidShow:)])
_implementedDelegateMethods |= _CPPopoverWindow_didShow_;
}
@@ -372,6 +381,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
if (![targetWindow isFullPlatformWindow])
[[_targetView window] addChildWindow:self ordered:CPWindowAbove];
_targetWindow = targetWindow;
if (!wasVisible)
[self _trapNextMouseDown];
}
@@ -429,6 +440,23 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
#pragma mark -
#pragma mark Overrides
/*!
@ignore
*/
- (void)cancelOperation:(id)sender
{
if ([[CPApp currentEvent] _couldBeKeyEquivalent] && [self performKeyEquivalent:[CPApp currentEvent]])
return;
[self cancel:self];
}
- (void)cancel:(id)sender
{
if (_closeOnBlur)
[[self delegate] performClose:sender];
}
/*!
@ignore
Show animation if necessary.
@@ -450,6 +478,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
{
if (![self isKeyWindow])
{
_isOpening = YES;
[super orderFront:aSender];
if (_animates && _browserAnimates && _shouldPerformAnimation)
@@ -484,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";
@@ -493,10 +525,10 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
[self setCSS3Property:@"Transform" value:@"scale(1.1)"];
[self setCSS3Property:@"Transition" value:CPBrowserCSSProperty('transform') + @" 200ms ease-in"];
var orderFrontTransitionFunction = function()
_orderFrontTransitionFunction = function()
{
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), orderFrontTransitionFunction, YES);
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), _orderFrontTransitionFunction, YES);
#endif
// Now set up the pop-in to normal size transition.
@@ -504,10 +536,10 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
[self setCSS3Property:@"Transform" value:@"scale(1)"];
[self setCSS3Property:@"Transition" value:CPBrowserCSSProperty('transform') + @" 50ms linear"];
var transitionCompleteFunction = function()
_transitionCompleteFunction = function()
{
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), transitionCompleteFunction, YES);
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), _transitionCompleteFunction, YES);
// Make sure to clear these properties when the animation is done. Without this,
// the window becomes blurry in Chrome, presumably because the browser composits
@@ -516,17 +548,18 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
[self setCSS3Property:@"TransformOrigin" value:nil];
[self setCSS3Property:@"Transition" value:nil];
#endif
if (_implementedDelegateMethods & _CPPopoverWindow_didShow_)
[_delegate popoverWindowDidShow:self];
_isOpening = NO;
[_delegate _popoverWindowDidShow];
}
#if PLATFORM(DOM)
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), transitionCompleteFunction, YES);
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), _transitionCompleteFunction, YES);
#endif
};
#if PLATFORM(DOM)
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), orderFrontTransitionFunction, YES);
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), _orderFrontTransitionFunction, YES);
#endif
}, 10); // There are some weird race conditions happening in Chrome 34. If this is set to 0
// the transitionend is randomly not called correctly. Setting the timeout to 10ms is not noticealble for the
@@ -534,6 +567,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
}
else
{
_isOpening = NO;
[self setCSS3Property:@"Transition" value:@""];
#if PLATFORM(DOM)
_DOMElement.style.opacity = 1;
@@ -571,6 +605,19 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
if (_animates && _browserAnimates)
{
if (_isOpening)
{
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), _orderFrontTransitionFunction, YES);
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), _transitionCompleteFunction, YES);
var matrix = [self _currentTransformMatrix],
currentScale = (matrix.split('(')[1]).split(',')[0];
[self setCSS3Property:@"Transform" value:@"scale(" + currentScale + ")"];
#endif
}
// Tell the element to fade out when the opacity changes
[self setCSS3Property:@"Transition" value:@"opacity 250ms linear"];
#if PLATFORM(DOM)
@@ -588,7 +635,8 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
{
// Make absolutely sure no dangling event listeners are left
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty("transitionend"), _orderOutTransitionFunction, YES);
if (_animates && _browserAnimates)
_DOMElement.removeEventListener(CPBrowserStyleProperty("transitionend"), _orderOutTransitionFunction, YES);
#endif
[self _removeFrameObserver];
@@ -597,15 +645,44 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
_shouldPerformAnimation = YES;
_isClosing = NO;
_isOpening = NO;
_targetWindow = nil;
if (_implementedDelegateMethods & _CPPopoverWindow_didClose_)
[_delegate popoverWindowDidClose:self];
[_delegate _popoverWindowDidClose];
}
#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];
for (var i = [childWindows count] - 1; i >= 0; i--)
{
var childWindow = childWindows[i];
if (![childWindow isKindOfClass:[self class]])
continue;
if ([[childWindow delegate] behavior] != CPPopoverBehaviorTransient)
return NO;
if (![self _hasOnlyTransientChild:childWindow])
return NO;
}
return YES;
}
- (void)_mouseWasClicked:(CPEvent)anEvent
{
/*
@@ -614,33 +691,52 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
message to any parent popovers so they have a chance to close
if necessary.
*/
if (![self isVisible])
if (![self isVisible] || !_targetWindow)
return;
var mouseWindow = [anEvent window];
// Consider clicks in child windows to be "inside". This keeps a transient popover from
// closing if e.g. the window containing the menu of a token field is clicked.
if (mouseWindow === self || [mouseWindow _hasAncestorWindow:self])
if (mouseWindow === self || [mouseWindow _hasAncestorWindow:self] || ![self _hasOnlyTransientChild:self])
{
[self _trapNextMouseDown];
}
else
{
// Send _close to the delegate so popoverWillClose is sent to the popover's delegate
if (_closeOnBlur)
[_delegate _close];
switch ([_delegate behavior])
{
case CPPopoverBehaviorSemitransient:
var superview = [_delegate._positioningView superview],
positioningViewFrame = [_delegate._positioningView frame];
// Give a transient parent popover a chance to close
var parent = [self parentWindow];
// Click on the same button
// Or click on a different window (we just care about the parentWindow)
// We use targetWindow bacause parentWindow is set to nil when opening a semi-transient window in a bridgeless window
if (CGRectContainsPoint(positioningViewFrame, [superview convertPointFromBase:[anEvent locationInWindow]])
|| mouseWindow != _targetWindow)
{
[self _trapNextMouseDown];
break;
}
if ([parent isKindOfClass:[self class]])
[parent _mouseWasClicked:anEvent];
[_delegate performClose:self];
break;
case CPPopoverBehaviorTransient:
[_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];
+1
View File
@@ -26,6 +26,7 @@
@import "CPImage.j"
@import "CPView.j"
@class CPToolbar
@global CPApp
CPToolbarItemVisibilityPriorityStandard = 0;
+1 -1
View File
@@ -530,7 +530,7 @@ var sortArrayUsingJSDescriptors = function(a, d)
if (value1 === nil || value1 === cpNull)
o = value2 === nil || value2 === cpNull ? CPOrderedSame : CPOrderedAscending;
else
o = value2 === nil || value2 === cpNull ? CPOrderedDescending : objj_msgSend(value1, dd.s, value2);
o = value2 === nil || value2 === cpNull ? CPOrderedDescending : value1.isa.objj_msgSend1(value1, dd.s, value2);
if (o && !dd.a)
o = -o;
+7 -5
View File
@@ -608,9 +608,11 @@ var concat = Array.prototype.concat,
}
}
else
else {
var anIsa = self.isa;
for (; index < count; ++index)
objj_msgSend([self objectAtIndex:index], aSelector);
anIsa.objj_msgSend0([self objectAtIndex:index], aSelector);
}
}
- (void)enumerateObjectsUsingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
@@ -748,7 +750,7 @@ var concat = Array.prototype.concat,
// passed in is an array, we end up with its contents added instead of itself.
push.call(argumentArray, anObject);
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
return [[self class] arrayWithArray:argumentArray];
}
/*!
@@ -763,7 +765,7 @@ var concat = Array.prototype.concat,
var anArray = anArray.isa === _CPJavaScriptArray ? anArray : [anArray _javaScriptArrayCopy],
argumentArray = concat.call([self _javaScriptArrayCopy], anArray);
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
return [[self class] arrayWithArray:argumentArray];
}
/*
@@ -801,7 +803,7 @@ var concat = Array.prototype.concat,
for (; index < count; ++index)
push.call(argumentArray, [self objectAtIndex:index]);
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
return [[self class] arrayWithArray:argumentArray];
}
// Sorting arrays
+4 -2
View File
@@ -196,8 +196,10 @@ var concat = Array.prototype.concat,
}
else
for (; index < count; ++index)
objj_msgSend(self[index], aSelector);
for (; index < count; ++index) {
var receiver = self[index];
receiver == nil ? nil : receiver.isa.objj_msgSend0(receiver, aSelector);
}
}
- (CPArray)arrayByAddingObject:(id)anObject
+1 -2
View File
@@ -738,8 +738,7 @@
_rangeEntries.splice(entryIndexOfNextEntry - 1 + index, 0, entryCopy);
}
//necessary?
//[self _coalesceRangeEntriesFromIndex:startingEntryIndex toIndex:startingEntryIndex+rangeEntries.length];
[self _coalesceRangeEntriesFromIndex:MAX(0, entryIndexOfNextEntry - 1) toIndex:MIN(entryIndexOfNextEntry + 1, _rangeEntries.length - 1)];
}
/*!
+91 -41
View File
@@ -28,16 +28,19 @@
@import "CPLocale.j"
@class CPNull
@class CPDictionary
@global CPLocaleLanguageCode
@global CPLocaleCountryCode
@typedef CPDateFormatterStyle
CPDateFormatterNoStyle = 0;
CPDateFormatterShortStyle = 1;
CPDateFormatterMediumStyle = 2;
CPDateFormatterLongStyle = 3;
CPDateFormatterFullStyle = 4;
@typedef CPDateFormatterBehavior
CPDateFormatterBehaviorDefault = 0;
CPDateFormatterBehavior10_0 = 1000;
CPDateFormatterBehavior10_4 = 1040;
@@ -189,7 +192,7 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4,
shortStandaloneQuarterSymbols = [CPArray arrayWithObjects:@"Q1", @"Q2", @"Q3", @"Q4"];
_symbols = @{
@"en" : @{
@"root" : @{
@"AMSymbol" : AMSymbol,
@"PMSymbol" : PMSymbol,
@"weekdaySymbols" : weekdaySymbols,
@@ -208,10 +211,8 @@ var defaultDateFormatterBehavior = CPDateFormatterBehavior10_4,
@"shortQuarterSymbols" : shortQuarterSymbols,
@"standaloneQuarterSymbols" : standaloneQuarterSymbols,
@"shortStandaloneQuarterSymbols" : shortStandaloneQuarterSymbols
},
@"fr" : @{},
@"es" : @{},
@"de" : @{}
}
};
_timeZone = [CPTimeZone systemTimeZone];
@@ -220,6 +221,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 +277,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]];
}
+3
View File
@@ -52,6 +52,8 @@
@import "CPArray.j"
@import "CPNumber.j"
@typedef CPDecimal
// Decimal size limits
CPDecimalMaxDigits = 38;
CPDecimalMaxExponent = 127;
@@ -68,6 +70,7 @@ CPCalculationUnderflow = 3;
CPCalculationDivideByZero = 4;
//CPRoundingMode Enum
@typedef CPRoundingMode
CPRoundPlain = 1;
CPRoundDown = 2;
CPRoundUp = 3;
+34 -32
View File
@@ -31,38 +31,6 @@ var CPDictionaryShowNilDeprecationMessage = YES,
CPDictionaryMaxDescriptionRecursion = 10;
/* @ignore */
@implementation _CPDictionaryValueEnumerator : CPEnumerator
{
CPEnumerator _keyEnumerator;
CPDictionary _dictionary;
}
- (id)initWithDictionary:(CPDictionary)aDictionary
{
self = [super init];
if (self)
{
_keyEnumerator = [aDictionary keyEnumerator];
_dictionary = aDictionary;
}
return self;
}
- (id)nextObject
{
var key = [_keyEnumerator nextObject];
if (key === nil)
return nil;
return [_dictionary objectForKey:key];
}
@end
/*!
@class CPDictionary
@ingroup foundation
@@ -801,6 +769,40 @@ var CPDictionaryShowNilDeprecationMessage = YES,
@end
/* @ignore */
@implementation _CPDictionaryValueEnumerator : CPEnumerator
{
CPEnumerator _keyEnumerator;
CPDictionary _dictionary;
}
- (id)initWithDictionary:(CPDictionary)aDictionary
{
self = [super init];
if (self)
{
_keyEnumerator = [aDictionary keyEnumerator];
_dictionary = aDictionary;
}
return self;
}
- (id)nextObject
{
var key = [_keyEnumerator nextObject];
if (key === nil)
return nil;
return [_dictionary objectForKey:key];
}
@end
/*!
@class CPMutableDictionary
@ingroup compatibility
+1
View File
@@ -22,6 +22,7 @@
@import "_CGGeometry.j"
@typedef CPRectEdge
CPMinXEdge = 0;
CPMinYEdge = 1;
CPMaxXEdge = 2;
+1
View File
@@ -23,6 +23,7 @@
@import "CPException.j"
@import "CPObject.j"
@import "CPRunLoop.j"
@import "CPURLRequest.j"
CPJSONPConnectionCallbacks = {};
+9 -9
View File
@@ -108,7 +108,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
switch (accessor[0])
{
case 0:
return objj_msgSend(self, accessor[1]);
return self.isa.objj_msgSend0(self, accessor[1]);
case 1:
// FIXME: We shouldn't be creating a new one every time.
@@ -226,7 +226,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
switch (modifier[0])
{
case 0: return objj_msgSend(self, modifier[1], aValue);
case 0: return self.isa.objj_msgSend1(self, modifier[1], aValue);
case 1: if ([theClass accessInstanceVariablesDirectly])
{
@@ -341,21 +341,21 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
- (CPUInteger)count
{
return objj_msgSend(_target, _countOfSelector);
return _target == nil ? nil : _target.isa.objj_msgSend0(_target, _countOfSelector);
}
- (id)objectAtIndex:(CPUInteger)anIndex
{
if (_objectInAtIndexSelector)
return objj_msgSend(_target, _objectInAtIndexSelector, anIndex);
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _objectInAtIndexSelector, anIndex);
return objj_msgSend(_target, _atIndexesSelector, [CPIndexSet indexSetWithIndex:anIndex])[0];
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _atIndexesSelector, [CPIndexSet indexSetWithIndex:anIndex])[0];
}
- (CPArray)objectsAtIndexes:(CPIndexSet)indexes
{
if (_atIndexesSelector)
return objj_msgSend(_target, _atIndexesSelector, indexes);
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _atIndexesSelector, indexes);
return [super objectsAtIndexes:indexes];
}
@@ -408,17 +408,17 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
- (CPUInteger)count
{
return objj_msgSend(_target, _countOfSelector);
return _target == nil ? nil : _target.isa.objj_msgSend0(_target, _countOfSelector);
}
- (CPEnumerator)objectEnumerator
{
return objj_msgSend(_target, _enumeratorOfSelector);
return _target == nil ? nil : _target.isa.objj_msgSend0(_target, _enumeratorOfSelector);
}
- (id)member:(id)anObject
{
return objj_msgSend(_target, _memberOfSelector, anObject);
return _target == nil ? nil : _target.isa.objj_msgSend1(_target, _memberOfSelector, anObject);
}
- (Class)classForCoder
+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];
Loaded 100 of 278 files, more files were not shown because too many files have changed in this diff. Show more