mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-25 17:45:36 +00:00
Merge branch 'refs/heads/master' into fix-doxygen-config
This commit is contained in:
commit
d16f2b54fe
176 files changed
+6867
-929
No files matched your search
@@ -16,3 +16,4 @@ xcuserdata/
|
||||
Tests/Manual/**/*.xcodeproj
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
*.tm_properties
|
||||
+49
-48
@@ -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
@@ -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;
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
@import "CPWindowController.j"
|
||||
@import "_CPPopoverWindow.j"
|
||||
|
||||
@typedef CPModalSession
|
||||
|
||||
var CPMainCibFile = @"CPMainCibFile",
|
||||
CPMainCibFileHumanFriendly = @"Main cib file base name",
|
||||
CPEventModifierFlags = 0;
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
@import <Foundation/CPIndexSet.j>
|
||||
|
||||
@import <Foundation/CPPredicate.j>
|
||||
@import "CPObjectController.j"
|
||||
@import "CPKeyValueBinding.j"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -133,7 +133,11 @@
|
||||
- (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];
|
||||
|
||||
@@ -230,10 +234,11 @@
|
||||
{
|
||||
var button = buttonsNotHidden[count];
|
||||
|
||||
[button removeFromSuperview];
|
||||
|
||||
if ([button isHidden])
|
||||
{
|
||||
[button removeFromSuperview];
|
||||
[buttonsNotHidden removeObject:button];
|
||||
}
|
||||
}
|
||||
|
||||
var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1,
|
||||
|
||||
@@ -46,75 +46,12 @@
|
||||
return;
|
||||
|
||||
if (_documentView)
|
||||
{
|
||||
[self _removeObserverDocumentView:_documentView];
|
||||
[_documentView removeFromSuperview];
|
||||
}
|
||||
|
||||
_documentView = aView;
|
||||
|
||||
if (_documentView)
|
||||
{
|
||||
[self addSubview:_documentView];
|
||||
[self _observeDocumentView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_observeDocumentView
|
||||
{
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[_documentView setPostsFrameChangedNotifications:YES];
|
||||
[_documentView setPostsBoundsChangedNotifications:YES];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(viewFrameChanged:)
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:_documentView];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(viewBoundsChanged:)
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
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];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -275,7 +212,6 @@ var CPClipViewDocumentViewKey = @"CPScrollViewDocumentView";
|
||||
// Don't call setDocumentView: here. It calls addSubview:, but it's A) not necessary since the
|
||||
// view hierarchy is fully encoded and B) dangerous if the subview is not fully decoded.
|
||||
_documentView = [aCoder decodeObjectForKey:CPClipViewDocumentViewKey];
|
||||
[self _observeDocumentView];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPSlider
|
||||
@class _CPColorPanelToolbar
|
||||
@class _CPColorPanelSwatches
|
||||
@class _CPColorPanelPreview
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPSlider
|
||||
@class CPColorPanel
|
||||
@class __CPColorWheel
|
||||
|
||||
@global CPColorPickerViewWidth
|
||||
@global CPColorPickerViewHeight
|
||||
|
||||
+110
-69
@@ -53,6 +53,11 @@ CPComboBoxWillPopUpNotification = @"CPComboBoxWillPopUpNotification";
|
||||
|
||||
CPComboBoxStateButtonBordered = CPThemeState("button-bordered");
|
||||
|
||||
var CPComboBoxDelegate_comboBoxSelectionIsChanging_ = 1 << 0,
|
||||
CPComboBoxDelegate_comboBoxSelectionDidChange_ = 1 << 1,
|
||||
CPComboBoxDelegate_comboBoxWillPopUp_ = 1 << 2,
|
||||
CPComboBoxDelegate_comboBoxWillDismiss_ = 1 << 3;
|
||||
|
||||
var CPComboBoxTextSubview = @"text",
|
||||
CPComboBoxButtonSubview = @"button",
|
||||
CPComboBoxDefaultNumberOfVisibleItems = 5,
|
||||
@@ -61,19 +66,20 @@ 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;
|
||||
CGSize _intercellSpacing;
|
||||
float _itemHeight;
|
||||
BOOL _popUpButtonCausedResign;
|
||||
BOOL _canComplete;
|
||||
BOOL _completes;
|
||||
BOOL _forceSelection;
|
||||
BOOL _hasVerticalScroller;
|
||||
BOOL _popUpButtonCausedResign;
|
||||
BOOL _usesDataSource;
|
||||
CGSize _intercellSpacing;
|
||||
CPArray _items;
|
||||
id<CPComboBoxDataSource> _dataSource;
|
||||
CPInteger _implementedDelegateComboBoxMethods;
|
||||
CPString _selectedStringValue;
|
||||
float _itemHeight;
|
||||
int _numberOfVisibleItems;
|
||||
_CPPopUpList _listDelegate;
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -228,41 +234,21 @@ var CPComboBoxTextSubview = @"text",
|
||||
if (aDelegate === delegate)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
if (delegate)
|
||||
{
|
||||
[defaultCenter removeObserver:delegate name:CPComboBoxSelectionIsChangingNotification object:self];
|
||||
[defaultCenter removeObserver:delegate name:CPComboBoxSelectionDidChangeNotification object:self];
|
||||
[defaultCenter removeObserver:delegate name:CPComboBoxWillDismissNotification object:self];
|
||||
[defaultCenter removeObserver:delegate name:CPComboBoxWillPopUpNotification object:self];
|
||||
}
|
||||
_implementedDelegateComboBoxMethods = 0;
|
||||
|
||||
if (aDelegate)
|
||||
{
|
||||
if ([aDelegate respondsToSelector:@selector(comboBoxSelectionIsChanging:)])
|
||||
[defaultCenter addObserver:delegate
|
||||
selector:@selector(comboBoxSelectionIsChanging:)
|
||||
name:CPComboBoxSelectionIsChangingNotification
|
||||
object:self];
|
||||
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxSelectionIsChanging_;
|
||||
|
||||
if ([aDelegate respondsToSelector:@selector(comboBoxSelectionDidChange:)])
|
||||
[defaultCenter addObserver:delegate
|
||||
selector:@selector(comboBoxSelectionDidChange:)
|
||||
name:CPComboBoxSelectionDidChangeNotification
|
||||
object:self];
|
||||
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxSelectionDidChange_;
|
||||
|
||||
if ([aDelegate respondsToSelector:@selector(comboBoxWillPopUp:)])
|
||||
[defaultCenter addObserver:delegate
|
||||
selector:@selector(comboBoxWillPopUp:)
|
||||
name:CPComboBoxWillPopUpNotification
|
||||
object:self];
|
||||
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxWillPopUp_;
|
||||
|
||||
if ([aDelegate respondsToSelector:@selector(comboBoxWillDismiss:)])
|
||||
[defaultCenter addObserver:delegate
|
||||
selector:@selector(comboBoxWillDissmis:)
|
||||
name:CPComboBoxWillDismissNotification
|
||||
object:self];
|
||||
_implementedDelegateComboBoxMethods |= CPComboBoxDelegate_comboBoxWillDismiss_;
|
||||
}
|
||||
|
||||
[super setDelegate:aDelegate];
|
||||
@@ -412,49 +398,57 @@ var CPComboBoxTextSubview = @"text",
|
||||
if (_listDelegate === aDelegate)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
if (_listDelegate)
|
||||
{
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListWillPopUpNotification object:_listDelegate];
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListWillDismissNotification object:_listDelegate];
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListDidDismissNotification object:_listDelegate];
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListItemWasClickedNotification object:_listDelegate];
|
||||
|
||||
var oldTableView = [_listDelegate tableView];
|
||||
|
||||
if (oldTableView)
|
||||
{
|
||||
[defaultCenter removeObserver:self name:CPTableViewSelectionIsChangingNotification object:oldTableView];
|
||||
[defaultCenter removeObserver:self name:CPTableViewSelectionDidChangeNotification object:oldTableView];
|
||||
}
|
||||
}
|
||||
[self _removeObserversForListDelegate:_listDelegate];
|
||||
|
||||
_listDelegate = aDelegate;
|
||||
|
||||
// We only add the observers if the CPComboBox is displayed
|
||||
if ([self window])
|
||||
[self _addObserversForListDelegate:_listDelegate]
|
||||
|
||||
// Apply our text style to the list
|
||||
[_listDelegate setFont:[self font]];
|
||||
[_listDelegate setAlignment:[self alignment]];
|
||||
|
||||
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
|
||||
|
||||
if (_intercellSpacing)
|
||||
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
|
||||
|
||||
if (_itemHeight)
|
||||
[[_listDelegate tableView] setRowHeight:_itemHeight];
|
||||
}
|
||||
|
||||
- (void)_addObserversForListDelegate:(_CPPopUpList)aDelegate
|
||||
{
|
||||
if (!aDelegate)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(comboBoxWillPopUp:)
|
||||
name:_CPPopUpListWillPopUpNotification
|
||||
object:_listDelegate];
|
||||
object:aDelegate];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(comboBoxWillDismiss:)
|
||||
name:_CPPopUpListWillDismissNotification
|
||||
object:_listDelegate];
|
||||
object:aDelegate];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(listDidDismiss:)
|
||||
name:_CPPopUpListDidDismissNotification
|
||||
object:_listDelegate];
|
||||
object:aDelegate];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(itemWasClicked:)
|
||||
name:_CPPopUpListItemWasClickedNotification
|
||||
object:_listDelegate];
|
||||
object:aDelegate];
|
||||
|
||||
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
|
||||
[[aDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
|
||||
|
||||
var tableView = [_listDelegate tableView];
|
||||
var tableView = [aDelegate tableView];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(comboBoxSelectionIsChanging:)
|
||||
@@ -465,13 +459,27 @@ var CPComboBoxTextSubview = @"text",
|
||||
selector:@selector(comboBoxSelectionDidChange:)
|
||||
name:CPTableViewSelectionDidChangeNotification
|
||||
object:tableView];
|
||||
}
|
||||
|
||||
// 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];
|
||||
- (void)_removeObserversForListDelegate:(_CPPopUpList)aDelegate
|
||||
{
|
||||
if (!aDelegate)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListWillPopUpNotification object:aDelegate];
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListWillDismissNotification object:aDelegate];
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListDidDismissNotification object:aDelegate];
|
||||
[defaultCenter removeObserver:self name:_CPPopUpListItemWasClickedNotification object:aDelegate];
|
||||
|
||||
var oldTableView = [aDelegate tableView];
|
||||
|
||||
if (oldTableView)
|
||||
{
|
||||
[defaultCenter removeObserver:self name:CPTableViewSelectionIsChangingNotification object:oldTableView];
|
||||
[defaultCenter removeObserver:self name:CPTableViewSelectionDidChangeNotification object:oldTableView];
|
||||
}
|
||||
}
|
||||
|
||||
- (int)indexOfItemWithObjectValue:(id)anObject
|
||||
@@ -516,8 +524,6 @@ var CPComboBoxTextSubview = @"text",
|
||||
if (!_listDelegate)
|
||||
[self setListDelegate:[[_CPPopUpList alloc] initWithDataSource:self]];
|
||||
|
||||
[self _selectMatchingItem];
|
||||
|
||||
// Note the offset here is 1 less than the focus ring width because the outer edge
|
||||
// of the focus ring is very transparent and it looks better if the list is closer.
|
||||
if (CPComboBoxFocusRingWidth < 0)
|
||||
@@ -528,6 +534,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
}
|
||||
|
||||
[_listDelegate popUpRelativeToRect:[self _borderFrame] view:self offset:CPComboBoxFocusRingWidth - 1];
|
||||
[self _selectMatchingItem];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
@@ -998,6 +1005,28 @@ var CPComboBoxTextSubview = @"text",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Observers method
|
||||
|
||||
- (void)_addObservers
|
||||
{
|
||||
if (_isObserving)
|
||||
return;
|
||||
|
||||
[super _addObservers];
|
||||
[self _addObserversForListDelegate:_listDelegate];
|
||||
}
|
||||
|
||||
- (void)_removeObservers
|
||||
{
|
||||
if (!_isObserving)
|
||||
return;
|
||||
|
||||
[super _removeObservers];
|
||||
[self _removeObserversForListDelegate:_listDelegate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPComboBox (CPComboBoxDelegate)
|
||||
@@ -1005,24 +1034,36 @@ var CPComboBoxTextSubview = @"text",
|
||||
/*! @ignore */
|
||||
- (void)comboBoxSelectionIsChanging:(CPNotification)aNotification
|
||||
{
|
||||
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxSelectionIsChanging_)
|
||||
[_delegate comboBoxSelectionIsChanging:[[CPNotification alloc] initWithName:CPComboBoxSelectionIsChangingNotification object:self userInfo:nil]];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxSelectionIsChangingNotification object:self];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (void)comboBoxSelectionDidChange:(CPNotification)aNotification
|
||||
{
|
||||
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxSelectionDidChange_)
|
||||
[_delegate comboBoxSelectionDidChange:[[CPNotification alloc] initWithName:CPComboBoxSelectionDidChangeNotification object:self userInfo:nil]];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxSelectionDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (void)comboBoxWillPopUp:(CPNotification)aNotification
|
||||
{
|
||||
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxWillPopUp_)
|
||||
[_delegate comboBoxWillPopUp:[[CPNotification alloc] initWithName:CPComboBoxWillPopUpNotification object:self userInfo:nil]];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxWillPopUpNotification object:self];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (void)comboBoxWillDismiss:(CPNotification)aNotification
|
||||
{
|
||||
if (_implementedDelegateComboBoxMethods & CPComboBoxDelegate_comboBoxWillDismiss_)
|
||||
[_delegate comboBoxWillDismiss:[[CPNotification alloc] initWithName:CPComboBoxWillDismissNotification object:self userInfo:nil]];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPComboBoxWillDismissNotification object:self];
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
+17
-1
@@ -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;
|
||||
@@ -260,10 +266,20 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
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 = minSize.height;
|
||||
{
|
||||
frameSize.height = MAX(minSize.height, frameSize.height);
|
||||
|
||||
if (maxSize.height > 0)
|
||||
frameSize.height = MIN(maxSize.height, frameSize.height);
|
||||
}
|
||||
|
||||
[self setFrameSize:frameSize];
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ Cursor support by browser:
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "CPImage.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -97,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];
|
||||
@@ -1266,7 +1269,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
@end
|
||||
|
||||
|
||||
@implementation _DatePickerBox : CPView
|
||||
@implementation _CPDatePickerBox : CPView
|
||||
{
|
||||
CPDatePicker _datePicker @accessors(property=datePicker);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
@import <Foundation/CPLocale.j>
|
||||
|
||||
@class CPDatePicker
|
||||
@class _CPDatePickerElementTextField
|
||||
@class _CPDatePickerElementView
|
||||
@class _CPDatePickerMonthView
|
||||
@class _CPDatePickerHeaderView
|
||||
|
||||
@global CPSingleDateMode
|
||||
@global CPRangeDateMode
|
||||
@@ -334,10 +338,11 @@ var CPZeroKeyCode = 48,
|
||||
if ([anEvent keyCode] == CPReturnKeyCode)
|
||||
{
|
||||
[_currentTextField _endEditing];
|
||||
return YES;
|
||||
|
||||
return [super performKeyEquivalent:anEvent];
|
||||
}
|
||||
|
||||
return NO;
|
||||
return [super performKeyEquivalent:anEvent];
|
||||
}
|
||||
|
||||
/*! KeyDown event
|
||||
@@ -1771,6 +1776,7 @@ var CPMonthDateType = 0,
|
||||
- (void)makeSelectable
|
||||
{
|
||||
[self setThemeState:CPThemeStateSelected];
|
||||
[_datePicker setThemeState:CPThemeStateEditing];
|
||||
}
|
||||
|
||||
/*! Unsert the theme CPThemeStateSelected
|
||||
@@ -1779,6 +1785,7 @@ var CPMonthDateType = 0,
|
||||
{
|
||||
_firstEvent = YES;
|
||||
[self unsetThemeState:CPThemeStateSelected];
|
||||
[_datePicker unsetThemeState:CPThemeStateEditing];
|
||||
}
|
||||
|
||||
|
||||
@@ -1847,4 +1854,4 @@ var CPMonthDateType = 0,
|
||||
return CGRectMakeCopy(bounds);
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
@@ -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;
|
||||
|
||||
@@ -31,9 +31,15 @@
|
||||
@import "CPText.j"
|
||||
|
||||
@class CPTextField
|
||||
@class CPWindow
|
||||
@class CPGraphicsContext
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef DOMEvent
|
||||
@typedef CPEventType
|
||||
|
||||
|
||||
var _CPEventPeriodicEventPeriod = 0,
|
||||
_CPEventPeriodicEventTimer = nil,
|
||||
_CPEventUpperCaseRegex = new RegExp("[A-Z]"),
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
@global CPImagesPboardType
|
||||
@global appkit_tag_dom_elements
|
||||
|
||||
@typedef CPImageAlignment
|
||||
CPImageAlignCenter = 0;
|
||||
CPImageAlignTop = 1;
|
||||
CPImageAlignTopLeft = 2;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
var exposedBindingsMap = @{},
|
||||
bindingsMap = @{};
|
||||
|
||||
@typedef CPBindingOperationKind
|
||||
var CPBindingOperationAnd = 0,
|
||||
CPBindingOperationOr = 1;
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef CPTickMarkPosition
|
||||
CPTickMarkBelow = 0;
|
||||
CPTickMarkAbove = 1;
|
||||
CPTickMarkLeft = CPTickMarkAbove;
|
||||
CPTickMarkRight = CPTickMarkBelow;
|
||||
|
||||
@typedef CPLevelIndicatorStyle
|
||||
CPRelevancyLevelIndicatorStyle = 0;
|
||||
CPContinuousCapacityLevelIndicatorStyle = 1;
|
||||
CPDiscreteCapacityLevelIndicatorStyle = 2;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
@import "_CPMenuManager.j"
|
||||
|
||||
@class _CPMenuView
|
||||
@class CPMenu
|
||||
|
||||
@global CPMenuDidAddItemNotification
|
||||
@global CPMenuDidChangeItemNotification
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import "_CPMenuItemStandardView.j"
|
||||
@import "_CPMenuItemMenuBarView.j"
|
||||
|
||||
@class CPMenuItem
|
||||
@global CPApp
|
||||
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import "CPWindow_Constants.j"
|
||||
|
||||
|
||||
@typedef CPProgressIndicatorStyle
|
||||
/*
|
||||
@global
|
||||
@group CPProgressIndicatorStyle
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
@import "CPButton.j"
|
||||
|
||||
@class CPRadioGroup
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import "CPEvent.j"
|
||||
|
||||
@class CPKeyBinding
|
||||
@class CPMenu
|
||||
|
||||
CPDeleteKeyCode = 8;
|
||||
CPTabKeyCode = 9;
|
||||
|
||||
@@ -2207,7 +2207,7 @@ TODO: implement
|
||||
indexOfDropLine = FLOOR(y / _sliceHeight),
|
||||
numberOfRows = [self numberOfRows];
|
||||
|
||||
if (indexOfDropLine < 0 || indexOfDropLine > numberOfRows || (indexOfDropLine >= [_draggingRows firstIndex] && indexOfDropLine <= [_draggingRows lastIndex] + 1))
|
||||
if (indexOfDropLine <= 0 || indexOfDropLine > numberOfRows || (indexOfDropLine >= [_draggingRows firstIndex] && indexOfDropLine <= [_draggingRows lastIndex] + 1))
|
||||
{
|
||||
if (_subviewIndexOfDropLine !== CPNotFound && indexOfDropLine !== _subviewIndexOfDropLine)
|
||||
[self _clearDropLine];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPRuleEditor
|
||||
|
||||
@implementation _CPRuleEditorViewSlice : CPView
|
||||
{
|
||||
CPRuleEditor _ruleEditor;
|
||||
|
||||
@@ -122,8 +122,8 @@
|
||||
{
|
||||
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]),
|
||||
width = [title sizeWithFont:font].width + 35, // 35 for right arrows + margins
|
||||
rect = CGRectMake(0, 0, width, [_ruleEditor rowHeight]),
|
||||
popup = [[CPPopUpButton alloc] initWithFrame:rect];
|
||||
|
||||
[popup setValue:font forThemeAttribute:@"font"];
|
||||
@@ -315,8 +315,14 @@
|
||||
{
|
||||
[ruleView setControlSize:CPSmallControlSize];
|
||||
|
||||
var minSize = [ruleView currentValueForThemeAttribute:@"min-size"],
|
||||
frame = [ruleView frame];
|
||||
|
||||
// Force controls to their minimum size
|
||||
frame.size.height = minSize.height;
|
||||
[ruleView setFrame:frame];
|
||||
|
||||
[_ruleOptionViews addObject:ruleView];
|
||||
var frame = [ruleView frame];
|
||||
[_ruleOptionInitialViewFrames addObject:frame];
|
||||
[_ruleOptionFrames addObject:frame];
|
||||
|
||||
|
||||
+31
-5
@@ -264,11 +264,6 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
_delegate = nil;
|
||||
_scrollTimer = nil;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didReceiveDefaultStyleChange:)
|
||||
name:CPScrollerStyleGlobalChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -1270,6 +1265,37 @@ Notifies the delegate when the scroll view has finished scrolling.
|
||||
#pragma mark -
|
||||
#pragma mark Overrides
|
||||
|
||||
|
||||
- (void)_removeObservers
|
||||
{
|
||||
if (!_isObserving)
|
||||
return;
|
||||
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self
|
||||
name:CPScrollerStyleGlobalChangeNotification
|
||||
object:nil];
|
||||
|
||||
[super _removeObservers];
|
||||
}
|
||||
|
||||
- (void)_addObservers
|
||||
{
|
||||
if (_isObserving)
|
||||
return;
|
||||
|
||||
//Make sure to have the last global style for the scroller
|
||||
[self _didReceiveDefaultStyleChange:nil];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didReceiveDefaultStyleChange:)
|
||||
name:CPScrollerStyleGlobalChangeNotification
|
||||
object:nil];
|
||||
|
||||
[super _addObservers];
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
[super drawRect:aRect];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef CPSegmentSwitchTracking
|
||||
CPSegmentSwitchTrackingSelectOne = 0;
|
||||
CPSegmentSwitchTrackingSelectAny = 1;
|
||||
CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
@import "CPImage.j"
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
@typedef CPShadowWeight
|
||||
CPLightShadow = 0;
|
||||
CPHeavyShadow = 1;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
@import "CPTabViewItem.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@typedef CPTabViewType
|
||||
CPTopTabsBezelBorder = 0;
|
||||
//CPLeftTabsBezelBorder = 1;
|
||||
CPBottomTabsBezelBorder = 2;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPTabView
|
||||
|
||||
/*
|
||||
The tab is currently selected.
|
||||
|
||||
+2
-16
@@ -28,9 +28,8 @@
|
||||
|
||||
@import "CPTextField.j"
|
||||
|
||||
@global CPTableViewColumnDidResizeNotification
|
||||
|
||||
@class _CPTableColumnHeaderView
|
||||
@class CPTableView
|
||||
|
||||
CPTableColumnNoResizing = 0;
|
||||
CPTableColumnAutoresizingMask = 1 << 0;
|
||||
@@ -185,7 +184,7 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
[tableView tile];
|
||||
|
||||
if (!_disableResizingPosting)
|
||||
[self _postDidResizeNotificationWithOldWidth:oldWidth];
|
||||
[[self tableView] _didResizeTableColumn:self oldWidth:oldWidth];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,19 +537,6 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
return _headerToolTip;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_postDidResizeNotificationWithOldWidth:(float)oldWidth
|
||||
{
|
||||
[[self tableView] _didResizeTableColumn:self];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPTableViewColumnDidResizeNotification
|
||||
object:[self tableView]
|
||||
userInfo:@{ @"CPTableColumn": self, @"CPOldWidth": oldWidth }];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTableColumnValueBinder : CPBinder
|
||||
|
||||
@@ -625,7 +625,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
- (void)stopResizingTableColumn:(CPInteger)aColumnIndex at:(CGPoint)aPoint
|
||||
{
|
||||
var tableColumn = [[_tableView tableColumns] objectAtIndex:aColumnIndex];
|
||||
[tableColumn _postDidResizeNotificationWithOldWidth:_columnOldWidth];
|
||||
[_tableView _didResizeTableColumn:tableColumn oldWidth:_columnOldWidth];
|
||||
[tableColumn setDisableResizingPosting:NO];
|
||||
[_tableView setDisableAutomaticResizing:NO];
|
||||
|
||||
|
||||
+93
-91
@@ -42,6 +42,7 @@
|
||||
@class CPTableHeaderView
|
||||
@class CPClipView
|
||||
@class CPButton
|
||||
@class _CPDropOperationDrawingView
|
||||
|
||||
@global CPApp
|
||||
|
||||
@@ -80,10 +81,12 @@ var CPTableViewDelegate_selectionShouldChangeInTableView_
|
||||
CPTableViewDelegate_tableView_typeSelectStringForTableColumn_row_ = 1 << 17,
|
||||
CPTableViewDelegate_tableView_willDisplayView_forTableColumn_row_ = 1 << 18,
|
||||
CPTableViewDelegate_tableView_willRemoveView_forTableColumn_row_ = 1 << 19,
|
||||
CPTableViewDelegate_tableViewSelectionDidChange_ = 1 << 20,
|
||||
CPTableViewDelegate_tableViewSelectionIsChanging_ = 1 << 21,
|
||||
CPTableViewDelegate_tableViewMenuForTableColumn_row_ = 1 << 22,
|
||||
CPTableViewDelegate_tableView_shouldReorderColumn_toColumn_ = 1 << 23;
|
||||
CPTableViewDelegate_tableViewColumnDidMove_ = 1 << 20,
|
||||
CPTableViewDelegate_tableViewColumnDidResize_ = 1 << 21,
|
||||
CPTableViewDelegate_tableViewSelectionDidChange_ = 1 << 22,
|
||||
CPTableViewDelegate_tableViewSelectionIsChanging_ = 1 << 23,
|
||||
CPTableViewDelegate_tableViewMenuForTableColumn_row_ = 1 << 24,
|
||||
CPTableViewDelegate_tableView_shouldReorderColumn_toColumn_ = 1 << 25;
|
||||
|
||||
//CPTableViewDraggingDestinationFeedbackStyles
|
||||
CPTableViewDraggingDestinationFeedbackStyleNone = -1;
|
||||
@@ -170,7 +173,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
@implementation _CPTableDrawView : CPView
|
||||
{
|
||||
CPTableView _tableView;
|
||||
id _tableView;
|
||||
}
|
||||
|
||||
- (id)initWithTableView:(CPTableView)aTableView
|
||||
@@ -320,6 +323,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
CPTableColumn _draggedColumn;
|
||||
CPArray _differedColumnDataToRemove;
|
||||
|
||||
CPView _observedClipView;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1166,6 +1171,9 @@ NOT YET IMPLEMENTED
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPTableViewColumnDidMoveNotification
|
||||
object:self
|
||||
userInfo:@{ @"CPOldColumn": fromIndex, @"CPNewColumn": toIndex }];
|
||||
|
||||
if (_implementedDelegateMethods & CPTableViewDelegate_tableViewColumnDidMove_)
|
||||
[_delegate tableViewColumnDidMove:[[CPNotification alloc] initWithName:CPTableViewColumnDidMoveNotification object:self userInfo:@{ @"CPOldColumn": fromIndex, @"CPNewColumn": toIndex }]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1244,9 +1252,17 @@ NOT YET IMPLEMENTED
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_didResizeTableColumn:(CPTableColumn)theColumn
|
||||
- (void)_didResizeTableColumn:(CPTableColumn)theColumn oldWidth:(int)oldWidth
|
||||
{
|
||||
[self _autosave];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPTableViewColumnDidResizeNotification
|
||||
object:self
|
||||
userInfo:@{ @"CPTableColumn": theColumn, @"CPOldWidth": oldWidth }];
|
||||
|
||||
if (_implementedDelegateMethods & CPTableViewDelegate_tableViewColumnDidResize_)
|
||||
[_delegate tableViewColumnDidResize:[[CPNotification alloc] initWithName:CPTableViewColumnDidResizeNotification object:self userInfo:@{ @"CPTableColumn": theColumn, @"CPOldWidth": oldWidth }]];
|
||||
}
|
||||
|
||||
//Selecting Columns and Rows
|
||||
@@ -2859,35 +2875,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
if (_delegate)
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(tableViewColumnDidMove:)])
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPTableViewColumnDidMoveNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewColumnDidResize:)])
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPTableViewColumnDidResizeNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewSelectionDidChange:)])
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPTableViewSelectionDidChangeNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewSelectionIsChanging:)])
|
||||
[defaultCenter
|
||||
removeObserver:_delegate
|
||||
name:CPTableViewSelectionIsChangingNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
@@ -2962,32 +2949,16 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldReorderColumn_toColumn_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewColumnDidMove:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(tableViewColumnDidMove:)
|
||||
name:CPTableViewColumnDidMoveNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableViewColumnDidMove_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewColumnDidResize:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(tableViewColumnDidResize:)
|
||||
name:CPTableViewColumnDidResizeNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableViewColumnDidResize_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewSelectionDidChange:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(tableViewSelectionDidChange:)
|
||||
name:CPTableViewSelectionDidChangeNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableViewSelectionDidChange_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(tableViewSelectionIsChanging:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(tableViewSelectionIsChanging:)
|
||||
name:CPTableViewSelectionIsChangingNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTableViewDelegate_tableViewSelectionIsChanging_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -4454,41 +4425,15 @@ 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];
|
||||
|
||||
if (superview)
|
||||
{
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:superview];
|
||||
|
||||
[defaultCenter
|
||||
removeObserver:self
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
object:superview];
|
||||
}
|
||||
|
||||
if ([aView isKindOfClass:[CPClipView class]])
|
||||
_observedClipView = aView;
|
||||
else
|
||||
{
|
||||
[aView setPostsFrameChangedNotifications:YES];
|
||||
[aView setPostsBoundsChangedNotifications:YES];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(superviewFrameChanged:)
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:aView];
|
||||
|
||||
[defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(superviewBoundsChanged:)
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
object:aView];
|
||||
[self _stopObservingClipView];
|
||||
_observedClipView = nil;
|
||||
}
|
||||
|
||||
[super viewWillMoveToSuperview:aView];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -5070,6 +5015,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
postNotificationName:CPTableViewSelectionIsChangingNotification
|
||||
object:self
|
||||
userInfo:nil];
|
||||
|
||||
if (_implementedDelegateMethods & CPTableViewDelegate_tableViewSelectionIsChanging_)
|
||||
[_delegate tableViewSelectionIsChanging:[[CPNotification alloc] initWithName:CPTableViewSelectionIsChangingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -5081,6 +5029,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
postNotificationName:CPTableViewSelectionDidChangeNotification
|
||||
object:self
|
||||
userInfo:nil];
|
||||
|
||||
if (_implementedDelegateMethods & CPTableViewDelegate_tableViewSelectionDidChange_)
|
||||
[_delegate tableViewSelectionDidChange:[[CPNotification alloc] initWithName:CPTableViewSelectionDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -5138,8 +5089,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
if (!_isObserving)
|
||||
return;
|
||||
|
||||
[self _stopObservingClipView];
|
||||
[super _removeObservers];
|
||||
[self _stopObservingFirstResponder];
|
||||
}
|
||||
|
||||
- (void)_addObservers
|
||||
@@ -5147,13 +5098,64 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
if (_isObserving)
|
||||
return;
|
||||
|
||||
[self _startObservingClipView];
|
||||
[super _addObservers];
|
||||
[self _startObservingFirstResponder];
|
||||
}
|
||||
|
||||
- (void)_startObservingFirstResponder
|
||||
/*!
|
||||
Called when the receiver is about to be moved to a new window.
|
||||
@param aWindow the window to which the receiver will be moved.
|
||||
*/
|
||||
- (void)viewWillMoveToWindow:(CPWindow)aWindow
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_firstResponderDidChange:) name:_CPWindowDidChangeFirstResponderNotification object:[self window]];
|
||||
[super viewWillMoveToWindow:aWindow];
|
||||
|
||||
[self _stopObservingFirstResponder];
|
||||
|
||||
if (aWindow)
|
||||
[self _startObservingFirstResponderForWindow:aWindow];
|
||||
}
|
||||
|
||||
- (void)_startObservingClipView
|
||||
{
|
||||
if (!_observedClipView)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[_observedClipView setPostsFrameChangedNotifications:YES];
|
||||
[_observedClipView setPostsBoundsChangedNotifications:YES];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(superviewFrameChanged:)
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:_observedClipView];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(superviewBoundsChanged:)
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
object:_observedClipView];
|
||||
}
|
||||
|
||||
- (void)_stopObservingClipView
|
||||
{
|
||||
if (!_observedClipView)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter removeObserver:self
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:_observedClipView];
|
||||
|
||||
[defaultCenter removeObserver:self
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
object:_observedClipView];
|
||||
}
|
||||
|
||||
- (void)_startObservingFirstResponderForWindow:(CPWindow)aWindow
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_firstResponderDidChange:) name:_CPWindowDidChangeFirstResponderNotification object:aWindow];
|
||||
}
|
||||
|
||||
- (void)_stopObservingFirstResponder
|
||||
|
||||
+238
-169
@@ -38,18 +38,25 @@
|
||||
|
||||
@end
|
||||
|
||||
var CPTextFieldDelegate_control_didFailToFormatString_errorDescription_ = 1 << 1,
|
||||
CPTextFieldDelegate_controlTextDidBeginEditing_ = 1 << 2,
|
||||
CPTextFieldDelegate_controlTextDidChange_ = 1 << 3,
|
||||
CPTextFieldDelegate_controlTextDidEndEditing_ = 1 << 4,
|
||||
CPTextFieldDelegate_controlTextDidFocus_ = 1 << 5,
|
||||
CPTextFieldDelegate_controlTextDidBlur_ = 1 << 6;
|
||||
|
||||
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,
|
||||
@@ -142,6 +149,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// NS-style Display Properties
|
||||
CPTextFieldBezelStyle _bezelStyle;
|
||||
BOOL _isBordered;
|
||||
BOOL _usesSingleLineMode;
|
||||
BOOL _wraps;
|
||||
BOOL _scrolls;
|
||||
}
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)aBinding
|
||||
@@ -240,101 +250,112 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self _sizeToControlSize];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#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
|
||||
|
||||
@@ -350,8 +371,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
_sendActionOn = CPKeyUpMask | CPKeyDownMask;
|
||||
|
||||
[self setValue:CPLeftTextAlignment forThemeAttribute:@"alignment"];
|
||||
|
||||
[self _updateCursor];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -373,8 +392,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (shouldBeEditable)
|
||||
_isSelectable = YES;
|
||||
|
||||
[self _updateCursor];
|
||||
|
||||
if (_isEditable)
|
||||
[self setThemeState:CPThemeStateEditable];
|
||||
else
|
||||
@@ -405,7 +422,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)setEnabled:(BOOL)shouldBeEnabled
|
||||
{
|
||||
[super setEnabled:shouldBeEnabled];
|
||||
[self _updateCursor];
|
||||
|
||||
// We only allow first responder status if the field is enabled.
|
||||
if (!shouldBeEnabled && [[self window] firstResponder] === self)
|
||||
@@ -419,8 +435,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)setSelectable:(BOOL)aFlag
|
||||
{
|
||||
_isSelectable = aFlag;
|
||||
|
||||
[self _updateCursor];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -560,6 +574,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
|
||||
{
|
||||
@@ -615,28 +647,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
[self _setCSSStyleForInputElement];
|
||||
|
||||
var element = [self _inputElement],
|
||||
font = [self currentValueForThemeAttribute:@"font"],
|
||||
contentRect = [self contentRectForBounds:[self bounds]],
|
||||
left = CGRectGetMinX(contentRect);
|
||||
|
||||
var element = [self _inputElement];
|
||||
element.value = _stringValue;
|
||||
|
||||
// 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.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)
|
||||
@@ -680,37 +694,18 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
*/
|
||||
- (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"];
|
||||
|
||||
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];
|
||||
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 (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";
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
@@ -731,12 +726,41 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
break;
|
||||
}
|
||||
|
||||
element.style.top = topPoint;
|
||||
element.style.height = ROUND(lineHeight) + "px";
|
||||
element.style.lineHeight = ROUND(lineHeight) + "px";
|
||||
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 */
|
||||
@@ -858,7 +882,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
[super _addObservers];
|
||||
|
||||
if ([self window] === self)
|
||||
if ([[self window] firstResponder] === self)
|
||||
[self _setObserveWindowKeyNotifications:YES];
|
||||
}
|
||||
|
||||
@@ -930,6 +954,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?)
|
||||
@@ -1100,7 +1130,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
|
||||
@@ -1118,6 +1152,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if ([note object] != self)
|
||||
return;
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidBlur_)
|
||||
[_delegate controlTextDidBlur:note];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotification:note];
|
||||
}
|
||||
|
||||
@@ -1127,6 +1164,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if ([note object] != self)
|
||||
return;
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidFocus_)
|
||||
[_delegate controlTextDidFocus:note];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotification:note];
|
||||
}
|
||||
|
||||
@@ -1137,12 +1177,44 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
[self _continuouslyReverseSetBinding];
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidChange_)
|
||||
[_delegate controlTextDidChange:note];
|
||||
|
||||
[super textDidChange:note];
|
||||
}
|
||||
|
||||
- (void)_updateCursor
|
||||
- (void)textDidBeginEditing:(CPNotification)note
|
||||
{
|
||||
if ([self isEnabled] && ([self isSelectable] || [self isEditable]))
|
||||
//this looks to prevent false propagation of notifications for other objects
|
||||
if ([note object] != self)
|
||||
return;
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidBeginEditing_)
|
||||
[_delegate controlTextDidBeginEditing:[[CPNotification alloc] initWithName:CPControlTextDidBeginEditingNotification object:self userInfo:@{"CPFieldEditor": [note object]}]]
|
||||
|
||||
[super textDidBeginEditing:note];
|
||||
}
|
||||
|
||||
- (void)textDidEndEditing:(CPNotification)note
|
||||
{
|
||||
//this looks to prevent false propagation of notifications for other objects
|
||||
if ([note object] != self)
|
||||
return;
|
||||
|
||||
[super textDidEndEditing:note];
|
||||
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_controlTextDidEndEditing_)
|
||||
[_delegate controlTextDidEndEditing: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";
|
||||
@@ -1679,17 +1751,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)setDelegate:(id <CPTextFieldDelegate>)aDelegate
|
||||
{
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
//unsubscribe the existing delegate if it exists
|
||||
if (_delegate)
|
||||
{
|
||||
[defaultCenter removeObserver:_delegate name:CPControlTextDidBeginEditingNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPControlTextDidChangeNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPControlTextDidEndEditingNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPTextFieldDidFocusNotification object:self];
|
||||
[defaultCenter removeObserver:_delegate name:CPTextFieldDidBlurNotification object:self];
|
||||
}
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
@@ -1698,40 +1761,19 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_control_didFailToFormatString_errorDescription_
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidBeginEditing:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(controlTextDidBeginEditing:)
|
||||
name:CPControlTextDidBeginEditingNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_controlTextDidBeginEditing_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidChange:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(controlTextDidChange:)
|
||||
name:CPControlTextDidChangeNotification
|
||||
object:self];
|
||||
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_controlTextDidChange_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidEndEditing:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(controlTextDidEndEditing:)
|
||||
name:CPControlTextDidEndEditingNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_controlTextDidEndEditing_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidFocus:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(controlTextDidFocus:)
|
||||
name:CPTextFieldDidFocusNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_controlTextDidFocus_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidBlur:)])
|
||||
[defaultCenter
|
||||
addObserver:_delegate
|
||||
selector:@selector(controlTextDidBlur:)
|
||||
name:CPTextFieldDidBlurNotification
|
||||
object:self];
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_controlTextDidBlur_;
|
||||
}
|
||||
|
||||
- (id)delegate
|
||||
@@ -1940,7 +1982,11 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
CPTextFieldLineBreakModeKey = "CPTextFieldLineBreakModeKey",
|
||||
CPTextFieldAlignmentKey = "CPTextFieldAlignmentKey",
|
||||
CPTextFieldBackgroundColorKey = "CPTextFieldBackgroundColorKey",
|
||||
CPTextFieldPlaceholderStringKey = "CPTextFieldPlaceholderStringKey";
|
||||
CPTextFieldPlaceholderStringKey = "CPTextFieldPlaceholderStringKey",
|
||||
CPTextFieldUsesSingleLineMode = "CPTextFieldUsesSingleLineMode",
|
||||
CPTextFieldWraps = "CPTextFieldWraps",
|
||||
CPTextFieldScrolls = "CPTextFieldScrolls";
|
||||
|
||||
|
||||
@implementation CPTextField (CPCoding)
|
||||
|
||||
@@ -1967,7 +2013,9 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
|
||||
[self setPlaceholderString:[aCoder decodeObjectForKey:CPTextFieldPlaceholderStringKey]];
|
||||
|
||||
[self _updateCursor];
|
||||
[self _setUsesSingleLineMode:[aCoder decodeBoolForKey:CPTextFieldUsesSingleLineMode]];
|
||||
[self _setWraps:[aCoder decodeBoolForKey:CPTextFieldWraps]];
|
||||
[self _setScrolls:[aCoder decodeBoolForKey:CPTextFieldScrolls]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -1992,6 +2040,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
|
||||
@@ -2022,6 +2074,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
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import <Foundation/CPKeyedUnarchiver.j>
|
||||
|
||||
@class CPView
|
||||
@class _CPThemeAttribute
|
||||
|
||||
var CPThemesByName = { },
|
||||
CPThemeDefaultTheme = nil,
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
@import "CPTextField.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
|
||||
@class _CPTokenFieldTokenCloseButton
|
||||
@class _CPTokenFieldTokenDisclosureButton
|
||||
|
||||
@global CPApp
|
||||
@global CPTextFieldDidFocusNotification
|
||||
@global CPTextFieldDidBlurNotification
|
||||
|
||||
+3
-1
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
@@ -172,6 +175,7 @@ var CPViewFlags = { },
|
||||
BOOL _postsBoundsChangedNotifications;
|
||||
BOOL _inhibitFrameAndBoundsChangedNotifications;
|
||||
BOOL _inLiveResize;
|
||||
BOOL _isSuperviewAClipView;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMElement _DOMElement;
|
||||
@@ -821,6 +825,8 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (void)viewWillMoveToSuperview:(CPView)aView
|
||||
{
|
||||
_isSuperviewAClipView = [aView isKindOfClass:[CPClipView class]];
|
||||
|
||||
[self _removeObservers];
|
||||
|
||||
if (aView)
|
||||
@@ -952,6 +958,9 @@ var CPViewFlags = { },
|
||||
|
||||
if (_postsFrameChangedNotifications)
|
||||
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
|
||||
|
||||
if (_isSuperviewAClipView)
|
||||
[[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1014,6 +1023,9 @@ var CPViewFlags = { },
|
||||
if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
|
||||
|
||||
if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var transform = _superview ? _superview._boundsTransform : NULL;
|
||||
|
||||
@@ -1173,6 +1185,9 @@ var CPViewFlags = { },
|
||||
|
||||
if (_postsFrameChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
|
||||
|
||||
if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[[self superview] viewFrameChanged:[[CPNotification alloc] initWithName:CPViewFrameDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1207,6 +1222,9 @@ var CPViewFlags = { },
|
||||
|
||||
if (_postsBoundsChangedNotifications)
|
||||
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
|
||||
|
||||
if (_isSuperviewAClipView)
|
||||
[[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1269,6 +1287,9 @@ var CPViewFlags = { },
|
||||
|
||||
if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
|
||||
|
||||
if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1307,6 +1328,9 @@ var CPViewFlags = { },
|
||||
|
||||
if (_postsBoundsChangedNotifications && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[CachedNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
|
||||
|
||||
if (_isSuperviewAClipView && !_inhibitFrameAndBoundsChangedNotifications)
|
||||
[[self superview] viewBoundsChanged:[[CPNotification alloc] initWithName:CPViewBoundsDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ var CPViewControllerCachedCibs;
|
||||
[cibOwner viewControllerDidLoadCib:self];
|
||||
|
||||
_isLoading = NO;
|
||||
_isLazy = NO;
|
||||
[self _viewDidLoad];
|
||||
}
|
||||
else if (_isLazy)
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
+76
-15
@@ -50,9 +50,15 @@
|
||||
|
||||
@class CPMenu
|
||||
@class CPProgressIndicator
|
||||
@class CPToolbar
|
||||
@class CPWindowController
|
||||
@class _CPWindowFrameAnimation
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef _CPWindowFullPlatformWindowSession
|
||||
|
||||
|
||||
@protocol CPWindowDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
@@ -901,18 +907,21 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
- (void)_orderFront
|
||||
{
|
||||
[[self contentView] _addObservers];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// -dw- if a sheet is clicked, the parent window should come up too
|
||||
if (_isSheet)
|
||||
[_parentView orderFront:self];
|
||||
|
||||
if (!_isVisible)
|
||||
[self _setFrame:_frame display:YES animate:NO constrainWidth:YES constrainHeight:YES];
|
||||
// Save the boolean since it will be updated in the method order:window:relativeTo:
|
||||
var wasVisible = _isVisible;
|
||||
|
||||
[_platformWindow orderFront:self];
|
||||
[_platformWindow order:CPWindowAbove window:self relativeTo:nil];
|
||||
|
||||
// setFrame is set after ordering the window as this method can send some notifications
|
||||
if (!wasVisible)
|
||||
[self _setFrame:_frame display:YES animate:NO constrainWidth:YES constrainHeight:YES];
|
||||
#endif
|
||||
|
||||
if (!CPApp._keyWindow)
|
||||
@@ -933,6 +942,23 @@ CPTexturedBackgroundWindowMask
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Called when the window is displayed in the DOM
|
||||
*/
|
||||
- (void)_windowWillBeAddedToTheDOM
|
||||
{
|
||||
[[self contentView] _addObservers];
|
||||
}
|
||||
|
||||
/*
|
||||
Called when the window is removed in the DOM
|
||||
*/
|
||||
- (void)_windowWillBeRemovedFromTheDOM
|
||||
{
|
||||
[[self contentView] _removeObservers];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Makes the receiver the last window in the screen ordering.
|
||||
@param aSender the object that requested this
|
||||
@@ -962,8 +988,6 @@ CPTexturedBackgroundWindowMask
|
||||
if (!_isVisible)
|
||||
return;
|
||||
|
||||
[[self contentView] _removeObservers];
|
||||
|
||||
if ([self isSheet])
|
||||
{
|
||||
// -dw- as in Cocoa, orderOut: detaches the sheet and animates out
|
||||
@@ -1846,6 +1870,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],
|
||||
@@ -2477,7 +2507,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;
|
||||
@@ -2679,6 +2709,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:
|
||||
*/
|
||||
@@ -2687,9 +2734,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 = {
|
||||
@@ -2741,7 +2803,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.
|
||||
@@ -2874,12 +2941,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])
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
@import "CGGeometry.j"
|
||||
|
||||
@typedef CGAffineTransform
|
||||
|
||||
|
||||
function CGAffineTransformMake(a, b, c, d, tx, ty)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@typedef CGColorSpace
|
||||
|
||||
kCGColorSpaceModelUnknown = -1;
|
||||
kCGColorSpaceModelMonochrome = 0;
|
||||
kCGColorSpaceModelRGB = 1;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
@import "CGGeometry.j"
|
||||
@import "CGPath.j"
|
||||
|
||||
@typedef CGContext
|
||||
|
||||
kCGLineCapButt = 0;
|
||||
kCGLineCapRound = 1;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
@import "CGColor.j"
|
||||
@import "CGColorSpace.j"
|
||||
|
||||
@typedef CGGradient
|
||||
|
||||
kCGGradientDrawsBeforeStartLocation = 1 << 0;
|
||||
kCGGradientDrawsAfterEndLocation = 1 << 1;
|
||||
|
||||
@@ -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)
|
||||
|
||||
/*!
|
||||
@}
|
||||
*/
|
||||
*/
|
||||
@@ -27,9 +27,12 @@
|
||||
|
||||
@class CPMenu
|
||||
@class CPPlatformPasteboard
|
||||
@class CPWindow
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef DOMWindow
|
||||
|
||||
var PrimaryPlatformWindow = NULL;
|
||||
|
||||
@implementation CPPlatformWindow : CPObject
|
||||
|
||||
@@ -1143,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])
|
||||
{
|
||||
@@ -1299,7 +1299,10 @@ var PreventScroll = true;
|
||||
// When ordering out, ignore otherWindow, simply remove aWindow from its level.
|
||||
// If layer is nil, this will be a no-op.
|
||||
if (orderingMode === CPWindowOut)
|
||||
{
|
||||
[aWindow _windowWillBeRemovedFromTheDOM];
|
||||
return [layer removeWindow:aWindow];
|
||||
}
|
||||
|
||||
/*
|
||||
If aWindow is a child of otherWindow and is not yet visible,
|
||||
@@ -1345,6 +1348,8 @@ var PreventScroll = true;
|
||||
if (otherWindow)
|
||||
insertionIndex = orderingMode === CPWindowAbove ? otherWindow._index + 1 : otherWindow._index;
|
||||
|
||||
[aWindow _windowWillBeAddedToTheDOM];
|
||||
|
||||
// Place the window at the appropriate index.
|
||||
[layer insertWindow:aWindow atIndex:insertionIndex];
|
||||
|
||||
@@ -1395,6 +1400,9 @@ var PreventScroll = true;
|
||||
|
||||
var index = ordering === CPWindowAbove ? parent._index + 1 : parent._index;
|
||||
|
||||
if (!childWasVisible)
|
||||
[child _windowWillBeAddedToTheDOM];
|
||||
|
||||
[aLayer insertWindow:child atIndex:index];
|
||||
|
||||
if (!childWasVisible)
|
||||
|
||||
@@ -1258,6 +1258,19 @@ var themedButtonValues = nil,
|
||||
["textfield-bezel-square-disabled-8.png", 6.0, 6.0]
|
||||
]),
|
||||
|
||||
bezelFocusedColor = PatternColor(
|
||||
[
|
||||
["textfield-bezel-square-focused-0.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-focused-1.png", 1.0, 6.0],
|
||||
["textfield-bezel-square-focused-2.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-focused-3.png", 6.0, 1.0],
|
||||
["textfield-bezel-square-focused-4.png", 1.0, 1.0],
|
||||
["textfield-bezel-square-focused-5.png", 6.0, 1.0],
|
||||
["textfield-bezel-square-focused-6.png", 6.0, 6.0],
|
||||
["textfield-bezel-square-focused-7.png", 1.0, 6.0],
|
||||
["textfield-bezel-square-focused-8.png", 6.0, 6.0]
|
||||
]),
|
||||
|
||||
bezelColorDatePickerTextField = PatternColor(
|
||||
[
|
||||
[@"datepicker-date-segment-0.png", 4.0, 18.0],
|
||||
@@ -1268,6 +1281,7 @@ var themedButtonValues = nil,
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelFocusedColor, [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
|
||||
[@"font", [CPFont boldSystemFontOfSize:13.0]],
|
||||
@@ -1275,8 +1289,10 @@ var themedButtonValues = nil,
|
||||
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 3.0), CPThemeStateNormal],
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 5.0), CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 5.0), [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"bezel-inset", CGInsetMake(0.0, -3.0, 0.0, -3.0), CPThemeStateBezeled],
|
||||
[@"bezel-inset", CGInsetMake(0.0, -3.0, 0.0, -3.0), [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
|
||||
@@ -1301,10 +1317,12 @@ var themedButtonValues = nil,
|
||||
// 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]],
|
||||
[@"content-inset", CGInsetMake(5.0, 0.0, 0.0, 5.0), [CPThemeStateControlSizeSmall, CPThemeStateEditing, CPThemeStateBezeled]],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 16.0), CPThemeStateControlSizeSmall],
|
||||
[@"date-hour-margin", 5.0, CPThemeStateControlSizeSmall],
|
||||
[@"stepper-margin", 3.0, CPThemeStateControlSizeSmall],
|
||||
[@"stepper-margin", 3.0, [CPThemeStateControlSizeSmall, CPThemeStateEditing]],
|
||||
|
||||
[@"min-size", CGSizeMake(0, 26.0), CPThemeStateControlSizeSmall],
|
||||
[@"max-size", CGSizeMake(-1.0, 26.0), CPThemeStateControlSizeSmall],
|
||||
@@ -1313,10 +1331,12 @@ var themedButtonValues = nil,
|
||||
// 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]],
|
||||
[@"content-inset", CGInsetMake(4.0, 0.0, 0.0, 4.0), [CPThemeStateControlSizeMini, CPThemeStateEditing, CPThemeStateBezeled]],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 12.0), CPThemeStateControlSizeMini],
|
||||
[@"date-hour-margin", 2.0, CPThemeStateControlSizeMini],
|
||||
[@"stepper-margin", 2.0, CPThemeStateControlSizeMini],
|
||||
[@"stepper-margin", 2.0, [CPThemeStateControlSizeMini, CPThemeStateEditing]],
|
||||
|
||||
[@"min-size", CGSizeMake(0, 22.0), CPThemeStateControlSizeMini],
|
||||
[@"max-size", CGSizeMake(-1.0, 22.0), CPThemeStateControlSizeMini],
|
||||
@@ -1820,8 +1840,8 @@ var themedButtonValues = nil,
|
||||
|
||||
// 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],
|
||||
[@"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],
|
||||
|
||||
@@ -374,7 +374,7 @@ var themedButtonValues = nil,
|
||||
[@"font", [CPFont boldSystemFontOfSize:11.0]],
|
||||
|
||||
[@"min-size", CGSizeMake(32.0, 20.0), CPThemeStateControlSizeSmall],
|
||||
[@"max-size", CGSizeMake(1.0, 20.0), CPThemeStateControlSizeSmall],
|
||||
[@"max-size", CGSizeMake(-1.0, 20.0), CPThemeStateControlSizeSmall],
|
||||
[@"nib2cib-adjustment-frame", CGRectMake(3.0, 4.0, -6.0, 0.0), CPThemeStateControlSizeSmall],
|
||||
|
||||
// CPThemeStateControlSizeMini
|
||||
@@ -386,7 +386,7 @@ var themedButtonValues = nil,
|
||||
|
||||
[@"min-size", CGSizeMake(32.0, 16.0), CPThemeStateControlSizeMini],
|
||||
[@"max-size", CGSizeMake(-1.0, 16.0), CPThemeStateControlSizeMini],
|
||||
[@"nib2cib-adjustment-frame", CGRectMake(1.0, 10.0, -3.0, 0.0), CPThemeStateControlSizeMini]
|
||||
[@"nib2cib-adjustment-frame", CGRectMake(1.0, 10.0, -3.0, 0.0), CPThemeStateControlSizeMini]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themeValues forView:button];
|
||||
@@ -824,6 +824,14 @@ var themedButtonValues = nil,
|
||||
height: 4.0
|
||||
}),
|
||||
|
||||
bezelFocusedColor = PatternColor(
|
||||
"textfield-bezel-square-focused{position}.png",
|
||||
{
|
||||
positions: "#",
|
||||
width: 9.0,
|
||||
height: 9.0
|
||||
}),
|
||||
|
||||
bezelColorDatePickerTextField = PatternColor(
|
||||
[
|
||||
[@"datepicker-date-segment-0.png", 4.0, 18.0],
|
||||
@@ -835,14 +843,17 @@ var themedButtonValues = nil,
|
||||
[
|
||||
[@"bezel-color", bezelColor["@"], CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelColor["disabled"], [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
[@"bezel-color", bezelFocusedColor, [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize]],
|
||||
[@"text-color", [CPColor colorWithWhite:0.2 alpha:0.5], CPThemeStateDisabled],
|
||||
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 3.0), CPThemeStateNormal],
|
||||
[@"content-inset", CGInsetMake(3.0, 0.0, 0.0, 3.0), CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(6.0, 0.0, 0.0, 6.0), [CPThemeStateNormal, CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"bezel-inset", CGInsetMake(3.0, 0.0, 3.0, 0.0), CPThemeStateBezeled],
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0, 0.0, -3.0), [CPThemeStateNormal, CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
|
||||
@@ -859,6 +870,7 @@ var themedButtonValues = nil,
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 18.0)],
|
||||
[@"date-hour-margin", 7.0],
|
||||
[@"stepper-margin", 5.0],
|
||||
[@"stepper-margin", 2.0, CPThemeStateEditing],
|
||||
|
||||
[@"min-size", CGSizeMake(0, 29.0)],
|
||||
[@"max-size", CGSizeMake(-1.0, 29.0)],
|
||||
@@ -867,10 +879,12 @@ var themedButtonValues = nil,
|
||||
// CPThemeStateControlSizeSmall
|
||||
[@"content-inset", CGInsetMake(5.0, 0.0, 0.0, 3.0), [CPThemeStateControlSizeSmall, CPThemeStateNormal]],
|
||||
[@"content-inset", CGInsetMake(2.0, 0.0, 0.0, 3.0), [CPThemeStateControlSizeSmall, CPThemeStateBezeled]],
|
||||
[@"content-inset", CGInsetMake(5.0, 0.0, 0.0, 6.0), [CPThemeStateControlSizeSmall, CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 16.0), CPThemeStateControlSizeSmall],
|
||||
[@"date-hour-margin", 5.0, CPThemeStateControlSizeSmall],
|
||||
[@"stepper-margin", 3.0, CPThemeStateControlSizeSmall],
|
||||
[@"stepper-margin", 0.0, [CPThemeStateControlSizeSmall, CPThemeStateEditing]],
|
||||
|
||||
[@"min-size", CGSizeMake(0, 26.0), CPThemeStateControlSizeSmall],
|
||||
[@"max-size", CGSizeMake(-1.0, 26.0), CPThemeStateControlSizeSmall],
|
||||
@@ -879,10 +893,12 @@ var themedButtonValues = nil,
|
||||
// CPThemeStateControlSizeMini
|
||||
[@"content-inset", CGInsetMake(3.0, 0.0, 0.0, 3.0), [CPThemeStateControlSizeMini, CPThemeStateNormal]],
|
||||
[@"content-inset", CGInsetMake(1.0, 0.0, 0.0, 3.0), [CPThemeStateControlSizeMini, CPThemeStateBezeled]],
|
||||
[@"content-inset", CGInsetMake(4.0, 0.0, 0.0, 6.0), [CPThemeStateControlSizeMini, CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 12.0), CPThemeStateControlSizeMini],
|
||||
[@"date-hour-margin", 2.0, CPThemeStateControlSizeMini],
|
||||
[@"stepper-margin", 2.0, CPThemeStateControlSizeMini],
|
||||
[@"stepper-margin", -1.0, [CPThemeStateControlSizeMini, CPThemeStateEditing]],
|
||||
|
||||
[@"min-size", CGSizeMake(0, 22.0), CPThemeStateControlSizeMini],
|
||||
[@"max-size", CGSizeMake(-1.0, 22.0), CPThemeStateControlSizeMini],
|
||||
@@ -1312,9 +1328,9 @@ var themedButtonValues = nil,
|
||||
[@"bezel-inset", CGInsetMake(3.0, 5.0, 3.0, 4.0), [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
|
||||
// The right border inset has to make room for the focus ring and popup button
|
||||
[@"content-inset", CGInsetMake(9.0, 26.0, 7.0, 10.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
|
||||
[@"content-inset", CGInsetMake(9.0, 26.0, 7.0, 10.0), CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(9.0, 24.0, 7.0, 10.0), [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
[@"content-inset", CGInsetMake(9.0, 30.0, 7.0, 10.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
|
||||
[@"content-inset", CGInsetMake(9.0, 30.0, 7.0, 10.0), CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(9.0, 28.0, 7.0, 10.0), [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"popup-button-size", CGSizeMake(21.0, 23.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
|
||||
[@"popup-button-size", CGSizeMake(17.0, 23.0), CPThemeStateBezeled],
|
||||
|
||||
@@ -71,7 +71,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMElement _DOMImageElement;
|
||||
DOMELement _DOMTextElement;
|
||||
DOMElement _DOMTextElement;
|
||||
DOMElement _DOMTextShadowElement;
|
||||
#endif
|
||||
}
|
||||
|
||||
+125
-111
@@ -65,6 +65,126 @@ 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)_mouseWasClicked:(CPEvent)anEvent
|
||||
{
|
||||
// This is needed, when the user close the list with the key enter
|
||||
if (![self isVisible])
|
||||
{
|
||||
[CPApp sendEvent:anEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
var mouseWindow = [anEvent window],
|
||||
rect = CGRectInsetByInset([[[self delegate] dataSource] bounds], [[[self delegate] dataSource] currentValueForThemeAttribute:@"content-inset"]),
|
||||
point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
|
||||
// If we click somewhere else than the comboBox or the panel we close the panel
|
||||
if (mouseWindow != self && !CGRectContainsPoint(rect, point))
|
||||
{
|
||||
[[self delegate] close];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we click on the panel, the app will know what to do
|
||||
if (mouseWindow == self)
|
||||
[CPApp sendEvent:anEvent];
|
||||
|
||||
// If we click on the comboBox field, we will trap the next mouse down
|
||||
if (CGRectContainsPoint(rect, point))
|
||||
[self _trapNextMouseDown];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)_trapNextMouseDown
|
||||
{
|
||||
// Dequeue the event and mouseWasClicked will do what it needs to do
|
||||
[CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:YES];
|
||||
}
|
||||
|
||||
@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.
|
||||
@@ -216,6 +336,11 @@ var ListColumnIdentifier = @"1";
|
||||
if ([_panel isVisible])
|
||||
return;
|
||||
|
||||
[self listWillPopUp];
|
||||
|
||||
[_panel _trapNextMouseDown];
|
||||
[[aView window] addChildWindow:_panel ordered:CPWindowAbove];
|
||||
|
||||
var rowRect = [_tableView rectOfRow:[self numberOfRowsInTableView:_tableView] - 1],
|
||||
frame = CGRectMake(0, 0, MAX(_listWidth, CGRectGetWidth(aRect)), CGRectGetMaxY(rowRect));
|
||||
|
||||
@@ -226,10 +351,6 @@ var ListColumnIdentifier = @"1";
|
||||
[_scrollView setFrameSize:CGSizeMakeCopy(frame.size)];
|
||||
[_tableView setEnabled:[_dataSource numberOfItemsInList:self] > 0];
|
||||
[self scrollItemAtIndexToTop:[_tableView selectedRow]];
|
||||
|
||||
[self listWillPopUp];
|
||||
|
||||
[[aView window] addChildWindow:_panel ordered:CPWindowAbove];
|
||||
}
|
||||
|
||||
#pragma mark Setting Display Attributes
|
||||
@@ -800,110 +921,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
|
||||
@@ -64,6 +64,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
BOOL _isObservingFrame;
|
||||
BOOL _shouldPerformAnimation;
|
||||
CPInteger _implementedDelegateMethods;
|
||||
CGRect _targetRect;
|
||||
CPWindow _targetWindow;
|
||||
JSObject _orderOutTransitionFunction;
|
||||
JSObject _transitionCompleteFunction;
|
||||
@@ -206,8 +207,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
if (![_targetView window])
|
||||
return;
|
||||
|
||||
var point = [self computeOriginFromRect:[_targetView bounds] ofView:_targetView preferredEdge:[_windowView preferredEdge]];
|
||||
|
||||
var point = [self computeOriginFromRect:_targetRect ofView:_targetView preferredEdge:[_windowView preferredEdge]];
|
||||
[self setFrameOrigin:point];
|
||||
}
|
||||
}
|
||||
@@ -362,7 +362,6 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
[self setFrameOrigin:point];
|
||||
[_windowView showCursor];
|
||||
[_windowView setNeedsDisplay:YES];
|
||||
[self makeKeyAndOrderFront:nil];
|
||||
|
||||
if (positioningView !== _targetView)
|
||||
{
|
||||
@@ -371,6 +370,9 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
_targetView = positioningView;
|
||||
}
|
||||
|
||||
_targetRect = aRect;
|
||||
[self makeKeyAndOrderFront:nil];
|
||||
|
||||
/*
|
||||
If _targetView's window is not a full platform window,
|
||||
add us as a child, because when we close we are detached from
|
||||
@@ -417,7 +419,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
|
||||
if ([self isVisible])
|
||||
{
|
||||
var point = [self computeOriginFromRect:[_targetView bounds] ofView:_targetView preferredEdge:[_windowView preferredEdge]];
|
||||
var point = [self computeOriginFromRect:_targetRect ofView:_targetView preferredEdge:[_windowView preferredEdge]];
|
||||
[self setFrameOrigin:point];
|
||||
}
|
||||
}
|
||||
@@ -581,10 +583,12 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
|
||||
- (void)_orderFront
|
||||
{
|
||||
if (![self isVisible])
|
||||
[self _addFrameObserver];
|
||||
var wasVisible = [self isVisible];
|
||||
|
||||
[super _orderFront];
|
||||
|
||||
if (!wasVisible)
|
||||
[self _addFrameObserver];
|
||||
}
|
||||
|
||||
- (void)_parentDidOrderInChild
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@import "CPImage.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@class CPToolbar
|
||||
@global CPApp
|
||||
|
||||
CPToolbarItemVisibilityPriorityStandard = 0;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
@param aType the structure or object type
|
||||
@param anObject the object to be encoded
|
||||
*/
|
||||
- (void)encodeValueOfObjCType:(CPString)aType at:(id)anObject
|
||||
- (void)encodeValueOfObjJType:(CPString)aType at:(id)anObject
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
@@ -74,24 +74,36 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0));
|
||||
|
||||
- (id)initWithTimeIntervalSinceNow:(CPTimeInterval)seconds
|
||||
{
|
||||
if (!_isNumberType(seconds))
|
||||
CPLog.warn(@"The parameter of the method initWithTimeIntervalSinceNow: should be an integer or a float");
|
||||
|
||||
self = new Date((new Date()).getTime() + seconds * 1000);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithTimeIntervalSince1970:(CPTimeInterval)seconds
|
||||
{
|
||||
if (!_isNumberType(seconds))
|
||||
CPLog.warn(@"The parameter of the method initWithTimeIntervalSince1970: should be an integer or a float");
|
||||
|
||||
self = new Date(seconds * 1000);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithTimeIntervalSinceReferenceDate:(CPTimeInterval)seconds
|
||||
{
|
||||
if (!_isNumberType(seconds))
|
||||
CPLog.warn(@"The parameter of the method initWithTimeIntervalSinceReferenceDate: should be an integer or a float");
|
||||
|
||||
self = [self initWithTimeInterval:seconds sinceDate:CPDateReferenceDate];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithTimeInterval:(CPTimeInterval)seconds sinceDate:(CPDate)refDate
|
||||
{
|
||||
if (!_isNumberType(seconds))
|
||||
CPLog.warn(@"The parameter of the method initWithTimeInterval:sinceDate: should be an integer or a float");
|
||||
|
||||
self = new Date(refDate.getTime() + seconds * 1000);
|
||||
return self;
|
||||
}
|
||||
@@ -275,3 +287,11 @@ Date.parseISO8601 = function (date)
|
||||
};
|
||||
|
||||
Date.prototype.isa = CPDate;
|
||||
|
||||
function _isNumberType(value)
|
||||
{
|
||||
if (typeof value === 'number')
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
+97
-26
@@ -24,31 +24,52 @@
|
||||
@import "CPObject.j"
|
||||
@import "CPString.j"
|
||||
|
||||
CPCappuccinoErrorDomain = CPCocoaErrorDomain = @"CPCappuccinoErrorDomain";
|
||||
// CPPOSIXErrorDomain = @"CPPOSIXErrorDomain";
|
||||
// CPOSStatusErrorDomain = @"CPOSStatusErrorDomain";
|
||||
CPCappuccinoErrorDomain = kCFErrorDomainCappuccino;
|
||||
CPCocoaErrorDomain = kCFErrorDomainCappuccino; // compat
|
||||
|
||||
CPUnderlyingErrorKey = @"CPUnderlyingErrorKey";
|
||||
CPUnderlyingErrorKey = kCFErrorUnderlyingErrorKey;
|
||||
|
||||
CPLocalizedDescriptionKey = @"CPLocalizedDescriptionKey";
|
||||
CPLocalizedFailureReasonErrorKey = @"CPLocalizedFailureReasonErrorKey";
|
||||
CPLocalizedRecoverySuggestionErrorKey = @"CPLocalizedRecoverySuggestionErrorKey";
|
||||
CPLocalizedDescriptionKey = kCFErrorLocalizedDescriptionKey;
|
||||
CPLocalizedFailureReasonErrorKey = kCFErrorLocalizedFailureReasonKey;
|
||||
CPLocalizedRecoverySuggestionErrorKey = kCFErrorLocalizedRecoverySuggestionKey;
|
||||
CPLocalizedRecoveryOptionsErrorKey = @"CPLocalizedRecoveryOptionsErrorKey";
|
||||
CPRecoveryAttempterErrorKey = @"CPRecoveryAttempterErrorKey";
|
||||
CPHelpAnchorErrorKey = @"CPHelpAnchorErrorKey";
|
||||
|
||||
CPStringEncodingErrorKey = @"CPStringEncodingErrorKey";
|
||||
CPURLErrorKey = @"CPURLErrorKey";
|
||||
CPFilePathErrorKey = @"CPFilePathErrorKey";
|
||||
CPURLErrorKey = kCFErrorURLKey;
|
||||
CPFilePathErrorKey = kCFErrorFilePathKey;
|
||||
|
||||
/*!
|
||||
@class CPError
|
||||
@ingroup foundation
|
||||
@brief Used for encapsulating, presenting, and recovery from errors.
|
||||
|
||||
CPError is toll-free bridged with CFError() methods.
|
||||
|
||||
An example of initializing a CPError:
|
||||
<pre>
|
||||
|
||||
var userInfo = @{CPLocalizedDescriptionKey: @"A localized error description",
|
||||
CPLocalizedFailureReasonErrorKey: @"A localized failure reason",
|
||||
CPUnderlyingErrorKey: @"An underlying error message"},
|
||||
|
||||
err = [CPError errorWithDomain:CPCappuccinoErrorDomain code:-10 userInfo:userInfo];
|
||||
</pre>
|
||||
*/
|
||||
@implementation CPError : CPObject
|
||||
{
|
||||
CPInteger _code @accessors(property=code, readonly);
|
||||
CPString _domain @accessors(property=domain, readonly);
|
||||
CPDictionary _userInfo @accessors(property=userInfo, readonly);
|
||||
}
|
||||
|
||||
+ (id)alloc
|
||||
{
|
||||
var obj = new CFError();
|
||||
obj.isa = [self class];
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
+ (id)errorWithDomain:(CPString)aDomain code:(CPInteger)aCode userInfo:(CPDictionary)aDict
|
||||
{
|
||||
return [[CPError alloc] initWithDomain:aDomain code:aCode userInfo:aDict];
|
||||
@@ -56,44 +77,94 @@ CPFilePathErrorKey = @"CPFilePathErrorKey";
|
||||
|
||||
- (id)initWithDomain:(CPString)aDomain code:(CPInteger)aCode userInfo:(CPDictionary)aDict
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_domain = aDomain;
|
||||
_code = aCode;
|
||||
_userInfo = aDict;
|
||||
}
|
||||
|
||||
return self;
|
||||
var result = new CFError(aDomain, aCode, aDict);
|
||||
result.isa = [self class];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (CPInteger)code
|
||||
{
|
||||
return self.code();
|
||||
}
|
||||
|
||||
- (CPString)userInfo
|
||||
{
|
||||
return self.userInfo();
|
||||
}
|
||||
|
||||
- (CPString)domain
|
||||
{
|
||||
return self.domain();
|
||||
}
|
||||
|
||||
/*!
|
||||
By default this method returns the object in the user info dictionary for the key
|
||||
CPLocalizedDescriptionKey. If the user info dictionary doesn’t contain a value for
|
||||
CPLocalizedDescriptionKey, a default string is constructed from the domain and code.
|
||||
*/
|
||||
- (CPString)localizedDescription
|
||||
{
|
||||
return [_userInfo objectForKey:CPLocalizedDescriptionKey];
|
||||
return self.description();
|
||||
}
|
||||
|
||||
- (CPString)localizedFailureReason
|
||||
{
|
||||
return [_userInfo objectForKey:CPLocalizedFailureReasonErrorKey];
|
||||
return self.failureReason();
|
||||
}
|
||||
|
||||
- (CPArray)localizedRecoveryOptions
|
||||
{
|
||||
return [_userInfo objectForKey:CPLocalizedRecoveryOptionsErrorKey];
|
||||
var userInfo = self.userInfo(),
|
||||
recoveryOptions = userInfo.valueForKey(CPLocalizedRecoveryOptionsErrorKey);
|
||||
|
||||
return recoveryOptions;
|
||||
}
|
||||
|
||||
- (CPString)localizedRecoverySuggestion
|
||||
{
|
||||
return [_userInfo objectForKey:CPLocalizedRecoverySuggestionErrorKey];
|
||||
return self.recoverySuggestion();
|
||||
}
|
||||
|
||||
- (id)recoveryAttempter
|
||||
{
|
||||
return [_userInfo objectForKey:CPRecoveryAttempterErrorKey];
|
||||
var userInfo = self.userInfo(),
|
||||
recoveryAttempter = userInfo.valueForKey(CPRecoveryAttempterErrorKey);
|
||||
|
||||
return recoveryAttempter;
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [CPString stringWithFormat:@"Error Domain=%@ Code=%d UserInfo=%p %@", _domain, _code, _userInfo, [self localizedDescription]];
|
||||
return [CPString stringWithFormat:@"Error Domain=%@ Code=%d \"%@\" UserInfo=%@", self.domain(), self.code(), self.description(), self.userInfo()];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPErrorCodeKey = @"CPErrorCodeKey",
|
||||
CPErrorDomainKey = @"CPErrorDomainKey",
|
||||
CPErrorUserInfoKey = @"CPErrorUserInfoKey";
|
||||
|
||||
@implementation CPError (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
var code = [aCoder decodeIntForKey:CPErrorCodeKey],
|
||||
domain = [aCoder decodeObjectForKey:CPErrorDomainKey],
|
||||
userInfo = [aCoder decodeObjectForKey:CPErrorUserInfoKey];
|
||||
|
||||
return [self initWithDomain:domain
|
||||
code:code
|
||||
userInfo:userInfo];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:self.domain() forKey:CPErrorDomainKey];
|
||||
[aCoder encodeObject:self.code() forKey:CPErrorCodeKey];
|
||||
[aCoder encodeObject:self.userInfo() forKey:CPErrorUserInfoKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
CFError.prototype.isa = CPError;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
@import "_CGGeometry.j"
|
||||
|
||||
@typedef CPRectEdge
|
||||
CPMinXEdge = 0;
|
||||
CPMinYEdge = 1;
|
||||
CPMaxXEdge = 2;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
@import "CPException.j"
|
||||
@import "CPObject.j"
|
||||
@import "CPRunLoop.j"
|
||||
@import "CPURLRequest.j"
|
||||
|
||||
CPJSONPConnectionCallbacks = {};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
@import "CPNull.j"
|
||||
@import "CPSet.j"
|
||||
|
||||
@class _CPNotificationRegistry
|
||||
|
||||
var CPNotificationDefaultCenter = nil;
|
||||
|
||||
/*!
|
||||
@@ -68,7 +70,8 @@ var CPNotificationDefaultCenter = nil;
|
||||
_namedRegistries = @{};
|
||||
_unnamedRegistry = [[_CPNotificationRegistry alloc] init];
|
||||
}
|
||||
return self;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -81,9 +84,36 @@ var CPNotificationDefaultCenter = nil;
|
||||
*/
|
||||
- (void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject
|
||||
{
|
||||
var registry,
|
||||
var registry = [self _registryForNotificationName:aNotificationName],
|
||||
observer = [[_CPNotificationObserver alloc] initWithObserver:anObserver selector:aSelector];
|
||||
|
||||
[registry addObserver:observer object:anObject];
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds an entry to the receiver’s dispatch table with a block, and optional criteria: notification name and sender.
|
||||
@param aNotificationName the name of the notification the observer wants to watch
|
||||
@param anObject the object in the notification the observer wants to watch
|
||||
@param queue is ignored for the moment
|
||||
@param block the block to be executed when the notification is received.
|
||||
*/
|
||||
- (id <CPObject>)addObserverForName:(CPString)aNotificationName object:(id)anObject queue:(id)queue usingBlock:(Function)block
|
||||
{
|
||||
var registry = [self _registryForNotificationName:aNotificationName],
|
||||
observer = [[_CPNotificationObserver alloc] initWithBlock:block];
|
||||
|
||||
[registry addObserver:observer object:anObject];
|
||||
|
||||
return observer;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (_CPNotificationRegistry)_registryForNotificationName:(CPString)aNotificationName
|
||||
{
|
||||
var registry;
|
||||
|
||||
if (aNotificationName == nil)
|
||||
registry = _unnamedRegistry;
|
||||
else if (!(registry = [_namedRegistries objectForKey:aNotificationName]))
|
||||
@@ -92,7 +122,7 @@ var CPNotificationDefaultCenter = nil;
|
||||
[_namedRegistries setObject:registry forKey:aNotificationName];
|
||||
}
|
||||
|
||||
[registry addObserver:observer object:anObject];
|
||||
return registry;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -233,7 +263,8 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
observersEnumerator = [observers objectEnumerator];
|
||||
|
||||
while ((observer = [observersEnumerator nextObject]) !== nil)
|
||||
if ([observer observer] == anObserver)
|
||||
if ([observer observer] == anObserver ||
|
||||
([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block]))
|
||||
[observers removeObject:observer];
|
||||
|
||||
if (![observers count])
|
||||
@@ -248,7 +279,8 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
observersEnumerator = [observers objectEnumerator];
|
||||
|
||||
while ((observer = [observersEnumerator nextObject]) !== nil)
|
||||
if ([observer observer] == anObserver)
|
||||
if ([observer observer] == anObserver ||
|
||||
([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block]))
|
||||
[observers removeObject:observer];
|
||||
|
||||
if (![observers count])
|
||||
@@ -312,8 +344,9 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
/* @ignore */
|
||||
@implementation _CPNotificationObserver : CPObject
|
||||
{
|
||||
id _observer;
|
||||
SEL _selector;
|
||||
id _observer;
|
||||
Function _block;
|
||||
SEL _selector;
|
||||
}
|
||||
|
||||
- (id)initWithObserver:(id)anObserver selector:(SEL)aSelector
|
||||
@@ -327,13 +360,34 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithBlock:(Function)aBlock
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
_block = aBlock;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)observer
|
||||
{
|
||||
return _observer;
|
||||
}
|
||||
|
||||
- (id)block
|
||||
{
|
||||
return _block;
|
||||
}
|
||||
|
||||
- (void)postNotification:(CPNotification)aNotification
|
||||
{
|
||||
if (_block)
|
||||
{
|
||||
_block(aNotification);
|
||||
return;
|
||||
}
|
||||
|
||||
[_observer performSelector:_selector withObject:aNotification];
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
@import "CPFormatter.j"
|
||||
@import "CPDecimalNumber.j"
|
||||
|
||||
|
||||
@typedef CPNumberFormatterStyle
|
||||
CPNumberFormatterNoStyle = 0;
|
||||
CPNumberFormatterDecimalStyle = 1;
|
||||
CPNumberFormatterCurrencyStyle = 2;
|
||||
@@ -32,6 +32,7 @@ CPNumberFormatterPercentStyle = 3;
|
||||
CPNumberFormatterScientificStyle = 4;
|
||||
CPNumberFormatterSpellOutStyle = 5;
|
||||
|
||||
@typedef CPNumberFormatterRoundingMode
|
||||
CPNumberFormatterRoundCeiling = CPRoundUp;
|
||||
CPNumberFormatterRoundFloor = CPRoundDown;
|
||||
CPNumberFormatterRoundDown = CPRoundDown;
|
||||
|
||||
@@ -62,6 +62,8 @@ CPLog(@"Got some class: %@", inst);
|
||||
@todo document KVC usage.
|
||||
*/
|
||||
|
||||
@import "_CPTypeDefinitions.j"
|
||||
|
||||
@class CPString
|
||||
@class CPException
|
||||
|
||||
@@ -104,7 +106,7 @@ CPLog(@"Got some class: %@", inst);
|
||||
|
||||
@implementation CPObject <CPObject>
|
||||
{
|
||||
Class isa;
|
||||
id isa;
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
|
||||
@@ -117,10 +117,11 @@ CPOperationQueuePriorityVeryHigh = 8;
|
||||
[self willChangeValueForKey:@"isExecuting"];
|
||||
_executing = NO;
|
||||
[self didChangeValueForKey:@"isExecuting"];
|
||||
[self willChangeValueForKey:@"isFinished"];
|
||||
_finished = YES;
|
||||
[self didChangeValueForKey:@"isFinished"];
|
||||
}
|
||||
|
||||
[self willChangeValueForKey:@"isFinished"];
|
||||
_finished = YES;
|
||||
[self didChangeValueForKey:@"isFinished"];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -70,7 +70,7 @@ var cpOperationMainQueue = nil;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var op = [_operations objectAtIndex:i];
|
||||
if ([op isReady] && ![op isCancelled] && ![op isFinished] && ![op isExecuting])
|
||||
if ([op isReady] && ![op isFinished] && ![op isExecuting])
|
||||
{
|
||||
[op start];
|
||||
}
|
||||
@@ -260,7 +260,7 @@ var cpOperationMainQueue = nil;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var op = [ops objectAtIndex:i];
|
||||
if ([op isReady] && ![op isCancelled] && ![op isFinished] && ![op isExecuting])
|
||||
if ([op isReady] && ![op isFinished] && ![op isExecuting])
|
||||
{
|
||||
[op start];
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
@import "_CPPredicate.j"
|
||||
|
||||
|
||||
var CPComparisonPredicateModifier,
|
||||
CPPredicateOperatorType;
|
||||
@typedef CPComparisonPredicateModifier
|
||||
@typedef CPPredicateOperatorType
|
||||
|
||||
/*!
|
||||
@ingroup foundation
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
@import "CPArray.j"
|
||||
@import "_CPPredicate.j"
|
||||
|
||||
var CPCompoundPredicateType;
|
||||
@typedef CPCompoundPredicateType
|
||||
|
||||
/*!
|
||||
@class CPCompoundPredicate
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
@{
|
||||
*/
|
||||
|
||||
@typedef CPRange
|
||||
|
||||
/*!
|
||||
Makes a CPRange.
|
||||
@param location the location for new range
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
@import "CPDate.j"
|
||||
@import "CPLocale.j"
|
||||
|
||||
@class CPData
|
||||
|
||||
CPTimeZoneNameStyleStandard = 0;
|
||||
CPTimeZoneNameStyleShortStandard = 1;
|
||||
CPTimeZoneNameStyleDaylightSaving = 2;
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
@import "CPURLRequest.j"
|
||||
@import "CPURLResponse.j"
|
||||
|
||||
@typedef HTTPRequest
|
||||
|
||||
var CPURLConnectionDelegate = nil;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
/*
|
||||
* The CPURL Error Domain
|
||||
*/
|
||||
CPURLErrorDomain = @"CPURLErrorDomain";
|
||||
|
||||
/*
|
||||
* CPURL UserInfo Error Keys
|
||||
*/
|
||||
CPURLErrorFailingURLErrorKey = @"CPErrorFailingURLKey";
|
||||
CPURLErrorFailingURLStringErrorKey = @"CPURLErrorFailingURLStringKey";
|
||||
|
||||
/*
|
||||
* CPURL Error Codes
|
||||
*/
|
||||
CPURLErrorUnknown = -1;
|
||||
CPURLErrorCancelled = kCFURLErrorCancelled;
|
||||
CPURLErrorBadURL = kCFURLErrorBadURL;
|
||||
CPURLErrorTimedOut = kCFURLErrorTimedOut;
|
||||
CPURLErrorUnsupportedURL = kCFURLErrorUnsupportedURL;
|
||||
CPURLErrorCannotFindHost = kCFURLErrorCannotFindHost;
|
||||
CPURLErrorCannotConnectToHost = kCFURLErrorCannotConnectToHost;
|
||||
CPURLErrorNetworkConnectionLost = kCFURLErrorNetworkConnectionLost;
|
||||
CPURLErrorDNSLookupFailed = kCFURLErrorDNSLookupFailed;
|
||||
CPURLErrorHTTPTooManyRedirects = kCFURLErrorHTTPTooManyRedirects;
|
||||
CPURLErrorResourceUnavailable = kCFURLErrorResourceUnavailable;
|
||||
CPURLErrorNotConnectedToInternet = kCFURLErrorNotConnectedToInternet;
|
||||
CPURLErrorRedirectToNonExistentLocation = kCFURLErrorRedirectToNonExistentLocation;
|
||||
CPURLErrorBadServerResponse = kCFURLErrorBadServerResponse;
|
||||
CPURLErrorUserCancelledAuthentication = kCFURLErrorUserCancelledAuthentication;
|
||||
CPURLErrorUserAuthenticationRequired = kCFURLErrorUserAuthenticationRequired;
|
||||
CPURLErrorZeroByteResource = kCFURLErrorZeroByteResource;
|
||||
CPURLErrorCannotDecodeRawData = kCFURLErrorCannotDecodeRawData;
|
||||
CPURLErrorCannotDecodeContentData = kCFURLErrorCannotDecodeContentData;
|
||||
CPURLErrorCannotParseResponse = kCFURLErrorCannotParseResponse;
|
||||
CPURLErrorFileDoesNotExist = kCFURLErrorFileDoesNotExist;
|
||||
CPURLErrorFileIsDirectory = kCFURLErrorFileIsDirectory;
|
||||
CPURLErrorNoPermissionsToReadFile = kCFURLErrorNoPermissionsToReadFile;
|
||||
CPURLErrorDataLengthExceedsMaximum = kCFURLErrorDataLengthExceedsMaximum;
|
||||
@@ -50,7 +50,7 @@ var _CPUndoGroupingPool = [],
|
||||
/* @ignore */
|
||||
@implementation _CPUndoGrouping : CPObject
|
||||
{
|
||||
_CPUndoGrouping _parent;
|
||||
id _parent;
|
||||
CPMutableArray _invocations;
|
||||
CPString _actionName;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
@import "CPObject.j"
|
||||
@import "CPString.j"
|
||||
|
||||
@typedef CPUserSessionStatus
|
||||
CPUserSessionUndeterminedStatus = 0;
|
||||
CPUserSessionLoggedInStatus = 1;
|
||||
CPUserSessionLoggedOutStatus = 2;
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
@import "CPUndoManager.j"
|
||||
@import "CPURL.j"
|
||||
@import "CPURLConnection.j"
|
||||
@import "CPURLError.j"
|
||||
@import "CPURLRequest.j"
|
||||
@import "CPURLResponse.j"
|
||||
@import "CPUserDefaults.j"
|
||||
|
||||
@@ -26,6 +26,12 @@ CGGeometry is not a part of Foundation. The reason _CGGeometry.j exists, and is
|
||||
|
||||
*/
|
||||
|
||||
@typedef CGPoint
|
||||
@typedef CGSize
|
||||
@typedef CGRect
|
||||
@typedef CGInset
|
||||
|
||||
|
||||
function CGPointMake(x, y)
|
||||
{
|
||||
return { x:x, y:y };
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* _CPTypeDefintions.j
|
||||
* Foundation
|
||||
*
|
||||
* Created by Antoine Mercadal.
|
||||
* Copyright 2014, Antoine Mercadal.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
@typedef Class
|
||||
@typedef CPInteger
|
||||
@typedef CPUInteger
|
||||
@typedef DOMElement
|
||||
@typedef JSObject
|
||||
@typedef CPMethodSignature
|
||||
@typedef CPPropertyListFormat
|
||||
@typedef CPTimeInterval
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* CFError.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Andrew Hankinson.
|
||||
* Copyright 2014, Andrew Hankinson.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
GLOBAL(kCFErrorLocalizedDescriptionKey) = "CPLocalizedDescription";
|
||||
GLOBAL(kCFErrorLocalizedFailureReasonKey) = "CPLocalizedFailureReason";
|
||||
GLOBAL(kCFErrorLocalizedRecoverySuggestionKey) = "CPLocalizedRecoverySuggestion";
|
||||
GLOBAL(kCFErrorDescriptionKey) = "CPDescription";
|
||||
GLOBAL(kCFErrorUnderlyingErrorKey) = "CPUnderlyingError";
|
||||
|
||||
GLOBAL(kCFErrorURLKey) = "CPURL";
|
||||
GLOBAL(kCFErrorFilePathKey) = "CPFilePath";
|
||||
|
||||
// GLOBAL(kCFErrorDomainPOSIX) = "";
|
||||
// GLOBAL(kCFErrorDomainOSStatus) = "";
|
||||
// GLOBAL(kCFErrorDomainMach) = "";
|
||||
GLOBAL(kCFErrorDomainCappuccino) = "CPCappuccinoErrorDomain";
|
||||
GLOBAL(kCFErrorDomainCocoa) = kCFErrorDomainCappuccino;
|
||||
|
||||
|
||||
GLOBAL(CFError) = function(/* CFString */ domain, /* int */ code, /* CFDictionary */ userInfo)
|
||||
{
|
||||
this._domain = domain || NULL;
|
||||
this._code = code || 0;
|
||||
this._userInfo = userInfo || new CFDictionary();
|
||||
this._UID = objj_generateObjectUID();
|
||||
};
|
||||
|
||||
CFError.prototype.domain = function()
|
||||
{
|
||||
return this._domain;
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFError.prototype.domain);
|
||||
|
||||
CFError.prototype.code = function()
|
||||
{
|
||||
return this._code;
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFError.prototype.code);
|
||||
|
||||
/*
|
||||
This follows the same logic to generate a description as the "real" CFError.
|
||||
*/
|
||||
CFError.prototype.description = function()
|
||||
{
|
||||
var localizedDesc = this._userInfo.valueForKey(kCFErrorLocalizedDescriptionKey);
|
||||
if (localizedDesc)
|
||||
return localizedDesc;
|
||||
|
||||
var reason = this._userInfo.valueForKey(kCFErrorLocalizedFailureReasonKey);
|
||||
if (reason)
|
||||
{
|
||||
var operationFailedStr = "The operation couldn\u2019t be completed. " + reason;
|
||||
return operationFailedStr;
|
||||
}
|
||||
|
||||
// @TODO Add the bundle localized domain handler.
|
||||
var result = "",
|
||||
desc = this._userInfo.valueForKey(kCFErrorDescriptionKey);
|
||||
if (desc)
|
||||
{
|
||||
// we have a description key.
|
||||
var result = "The operation couldn\u2019t be completed. (error " + this._code + " - " + desc + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
// just use error and code;
|
||||
var result = "The operation couldn\u2019t be completed. (error " + this._code + ")";
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFError.prototype.description);
|
||||
|
||||
CFError.prototype.failureReason = function()
|
||||
{
|
||||
return this._userInfo.valueForKey(kCFErrorLocalizedFailureReasonKey);
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFError.prototype.failureReason);
|
||||
|
||||
CFError.prototype.recoverySuggestion = function()
|
||||
{
|
||||
return this._userInfo.valueForKey(kCFErrorLocalizedRecoverySuggestionKey);
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFError.prototype.recoverySuggestion);
|
||||
|
||||
CFError.prototype.userInfo = function ()
|
||||
{
|
||||
return this._userInfo;
|
||||
};
|
||||
|
||||
DISPLAY_NAME(CFError.prototype.userInfo);
|
||||
|
||||
/*
|
||||
CFError Bridge Functions
|
||||
The "Create" and "Copy" in the function names do not have any meaning
|
||||
in Cappuccino; they are bridged here for compatibility reasons only.
|
||||
*/
|
||||
GLOBAL(CFErrorCreate) = function(/* String */ domain, /*int */ code, /* CFDictionary */ userInfo)
|
||||
{
|
||||
return new CFError(domain, code, userInfo);
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorCreateWithUserInfoKeysAndValues) = function(/* String */ domain, /* int */ code, /* array */ userInfoKeys, /* array */ userInfoValues, /* int */ numUserInfoValues)
|
||||
{
|
||||
var userInfo = new CFMutableDictionary();
|
||||
while (numUserInfoValues--)
|
||||
userInfo.setValueForKey(userInfoKeys[numUserInfoValues], userInfoValues[numUserInfoValues]);
|
||||
|
||||
return new CFError(domain, code, userInfo);
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorGetCode) = function(/* CFError */ err)
|
||||
{
|
||||
return err.code();
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorGetDomain) = function(/* CFError */ err)
|
||||
{
|
||||
return err.domain();
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorCopyDescription) = function(/* CFError */ err)
|
||||
{
|
||||
return err.description();
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorCopyUserInfo) = function(/* CFError */ err)
|
||||
{
|
||||
return err.userInfo();
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorCopyFailureReason) = function(/* CFError */ err)
|
||||
{
|
||||
return err.failureReason();
|
||||
};
|
||||
|
||||
GLOBAL(CFErrorCopyRecoverySuggestion) = function(/* CFError */err)
|
||||
{
|
||||
return err.recoverySuggestion();
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
GLOBAL(kCFURLErrorUnknown) = -998;
|
||||
GLOBAL(kCFURLErrorCancelled) = -999;
|
||||
GLOBAL(kCFURLErrorBadURL) = -1000;
|
||||
GLOBAL(kCFURLErrorTimedOut) = -1001;
|
||||
GLOBAL(kCFURLErrorUnsupportedURL) = -1002;
|
||||
GLOBAL(kCFURLErrorCannotFindHost) = -1003;
|
||||
GLOBAL(kCFURLErrorCannotConnectToHost) = -1004;
|
||||
GLOBAL(kCFURLErrorNetworkConnectionLost) = -1005;
|
||||
GLOBAL(kCFURLErrorDNSLookupFailed) = -1006;
|
||||
GLOBAL(kCFURLErrorHTTPTooManyRedirects) = -1007;
|
||||
GLOBAL(kCFURLErrorResourceUnavailable) = -1008;
|
||||
GLOBAL(kCFURLErrorNotConnectedToInternet) = -1009;
|
||||
GLOBAL(kCFURLErrorRedirectToNonExistentLocation) = -1010;
|
||||
GLOBAL(kCFURLErrorBadServerResponse) = -1011;
|
||||
GLOBAL(kCFURLErrorUserCancelledAuthentication) = -1012;
|
||||
GLOBAL(kCFURLErrorUserAuthenticationRequired) = -1013;
|
||||
GLOBAL(kCFURLErrorZeroByteResource) = -1014;
|
||||
GLOBAL(kCFURLErrorCannotDecodeRawData) = -1015;
|
||||
GLOBAL(kCFURLErrorCannotDecodeContentData) = -1016;
|
||||
GLOBAL(kCFURLErrorCannotParseResponse) = -1017;
|
||||
GLOBAL(kCFURLErrorRequestBodyStreamExhausted) = -1021;
|
||||
GLOBAL(kCFURLErrorFileDoesNotExist) = -1100;
|
||||
GLOBAL(kCFURLErrorFileIsDirectory) = -1101;
|
||||
GLOBAL(kCFURLErrorNoPermissionsToReadFile) = -1102;
|
||||
GLOBAL(kCFURLErrorDataLengthExceedsMaximum) = -1103;
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "CFHTTPRequest.js"
|
||||
#include "CFPropertyList.js"
|
||||
#include "CFDictionary.js"
|
||||
#include "CFError.js"
|
||||
#include "CFNetworkErrors.js"
|
||||
#include "CFData.js"
|
||||
#include "CFURL.js"
|
||||
#include "MarkedStream.js"
|
||||
|
||||
@@ -353,6 +353,11 @@ ProtocolDef.prototype.getClassMethod = function(name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var TypeDef = function(name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// methodDef = {"types": types, "name": selector}
|
||||
var MethodDef = function(name, types)
|
||||
{
|
||||
@@ -369,7 +374,7 @@ var wordPrefixOperators = exports.acorn.makePredicate("delete in instanceof new
|
||||
var isLogicalBinary = exports.acorn.makePredicate("LogicalExpression BinaryExpression");
|
||||
var isInInstanceof = exports.acorn.makePredicate("in instanceof");
|
||||
|
||||
var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, /*unsigned*/ pass, /* Dictionary */ classDefs, /* Dictionary */ protocolDefs)
|
||||
var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, /*unsigned*/ pass, /* Dictionary */ classDefs, /* Dictionary */ protocolDefs, /* Dictionary */ typeDefs)
|
||||
{
|
||||
this.source = aString;
|
||||
this.URL = new CFURL(aURL);
|
||||
@@ -399,6 +404,7 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*
|
||||
this.flags = flags | ObjJAcornCompiler.Flags.IncludeDebugSymbols;
|
||||
this.classDefs = classDefs ? classDefs : Object.create(null);
|
||||
this.protocolDefs = protocolDefs ? protocolDefs : Object.create(null);
|
||||
this.typeDefs = typeDefs ? typeDefs : Object.create(null);
|
||||
this.lastPos = 0;
|
||||
if (currentCompilerFlags & ObjJAcornCompiler.Flags.Generate)
|
||||
this.generate = true;
|
||||
@@ -415,9 +421,9 @@ exports.ObjJAcornCompiler.compileToExecutable = function(/*String*/ aString, /*C
|
||||
return new ObjJAcornCompiler(aString, aURL, flags, 2).executable();
|
||||
}
|
||||
|
||||
exports.ObjJAcornCompiler.compileToIMBuffer = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, classDefs, protocolDefs)
|
||||
exports.ObjJAcornCompiler.compileToIMBuffer = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, classDefs, protocolDefs, typeDefs)
|
||||
{
|
||||
return new ObjJAcornCompiler(aString, aURL, flags, 2, classDefs, protocolDefs).IMBuffer();
|
||||
return new ObjJAcornCompiler(aString, aURL, flags, 2, classDefs, protocolDefs, typeDefs).IMBuffer();
|
||||
}
|
||||
|
||||
exports.ObjJAcornCompiler.compileFileDependencies = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags)
|
||||
@@ -581,6 +587,31 @@ ObjJAcornCompiler.prototype.getProtocolDef = function(/* String */ aProtocolName
|
||||
// protocolDef = {"name": protocolName, "protocols": Object.create(null), "required": Object.create(null), "optional": Object.create(null)};
|
||||
}
|
||||
|
||||
ObjJAcornCompiler.prototype.getTypeDef = function(/* String */ aTypeDefName)
|
||||
{
|
||||
if (!aTypeDefName)
|
||||
return null;
|
||||
|
||||
var t = this.typeDefs[aTypeDefName];
|
||||
|
||||
if (t)
|
||||
return t;
|
||||
|
||||
if (typeof objj_getTypeDef === 'function')
|
||||
{
|
||||
var aTypeDef = objj_getTypeDef(aTypeDefName);
|
||||
if (aTypeDef)
|
||||
{
|
||||
var typeDefName = typeDef_getName(aTypeDef)
|
||||
t = new TypeDef(typeDefName);
|
||||
this.typeDefs[typeDefName] = t;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
ObjJAcornCompiler.methodDefsFromMethodList = function(/* Array */ methodList)
|
||||
{
|
||||
var methodSize = methodList.length,
|
||||
@@ -1643,6 +1674,9 @@ ClassDeclarationStatement: function(node, st, c) {
|
||||
compiler.cmBuffer = new StringBuffer();
|
||||
compiler.classBodyBuffer = new StringBuffer(); // TODO: Check if this is needed
|
||||
|
||||
if (compiler.getTypeDef(className))
|
||||
throw compiler.error_message(className + " is already declared as a type", node.classname);
|
||||
|
||||
if (!generate) saveJSBuffer.concat(compiler.source.substring(compiler.lastPos, node.start));
|
||||
|
||||
// First we declare the class
|
||||
@@ -1715,12 +1749,19 @@ ClassDeclarationStatement: function(node, st, c) {
|
||||
{
|
||||
var ivarDecl = node.ivardeclarations[i],
|
||||
ivarType = ivarDecl.ivartype ? ivarDecl.ivartype.name : null,
|
||||
ivarTypeIsClass = ivarDecl.ivartype ? ivarDecl.ivartype.typeisclass : false,
|
||||
ivarName = ivarDecl.id.name,
|
||||
ivar = {"type": ivarType, "name": ivarName},
|
||||
accessors = ivarDecl.accessors;
|
||||
|
||||
if (ivars[ivarName])
|
||||
throw compiler.error_message("Instance variable '" + ivarName + "'is already declared for class " + className, ivarDecl.id);
|
||||
throw compiler.error_message("Instance variable '" + ivarName + "' is already declared for class " + className, ivarDecl.id);
|
||||
|
||||
var isTypeDefined = !ivarTypeIsClass || typeof global[ivarType] !== "undefined" || typeof window[ivarType] !== "undefined"
|
||||
|| compiler.getClassDef(ivarType) || compiler.getTypeDef(ivarType) || ivarType == classDef.name;
|
||||
|
||||
if (!isTypeDefined)
|
||||
compiler.addWarning(createMessage("Unknown type '" + ivarType + "' for ivar '" + ivarName + "'", ivarDecl.id, compiler.source));
|
||||
|
||||
if (firstIvarDeclaration)
|
||||
{
|
||||
@@ -1824,7 +1865,7 @@ ClassDeclarationStatement: function(node, st, c) {
|
||||
|
||||
// Remove all @accessors or we will get a recursive loop in infinity
|
||||
var b = getterSetterBuffer.toString().replace(/@accessors(\(.*\))?/g, "");
|
||||
var imBuffer = ObjJAcornCompiler.compileToIMBuffer(b, "Accessors", compiler.flags, compiler.classDefs, compiler.protocolDefs);
|
||||
var imBuffer = ObjJAcornCompiler.compileToIMBuffer(b, "Accessors", compiler.flags, compiler.classDefs, compiler.protocolDefs, compiler.typeDefs);
|
||||
|
||||
// Add the accessors methods first to instance method buffer.
|
||||
// This will allow manually added set and get methods to override the compiler generated
|
||||
@@ -2340,9 +2381,9 @@ Reference: function(node, st, c) {
|
||||
buffer.concat(" "); // Add an extra space if it looks something like this: "return(<expression>)". No space between return and expression.
|
||||
}
|
||||
buffer.concat("function(__input) { if (arguments.length) return ");
|
||||
buffer.concat(node.element.name);
|
||||
c(node.element, st, "Expression");
|
||||
buffer.concat(" = __input; return ");
|
||||
buffer.concat(node.element.name);
|
||||
c(node.element, st, "Expression");
|
||||
buffer.concat("; }");
|
||||
if (!generate) compiler.lastPos = node.end;
|
||||
},
|
||||
@@ -2371,6 +2412,10 @@ ClassStatement: function(node, st, c) {
|
||||
compiler.jsBuffer.concat("//");
|
||||
}
|
||||
var className = node.id.name;
|
||||
|
||||
if (compiler.getTypeDef(className))
|
||||
throw compiler.error_message(className + " is already declared as a type", node.id);
|
||||
|
||||
if (!compiler.getClassDef(className)) {
|
||||
classDef = new ClassDef(false, className);
|
||||
compiler.classDefs[className] = classDef;
|
||||
@@ -2393,5 +2438,42 @@ PreprocessStatement: function(node, st, c) {
|
||||
compiler.lastPos = node.start;
|
||||
compiler.jsBuffer.concat("//");
|
||||
}
|
||||
},
|
||||
TypeDefStatement: function(node, st, c) {
|
||||
|
||||
var compiler = st.compiler,
|
||||
generate = compiler.generate,
|
||||
buffer = compiler.jsBuffer,
|
||||
typeDefName = node.typedefname.name,
|
||||
typeDef = compiler.getTypeDef(typeDefName),
|
||||
typeDefScope = new Scope(st);
|
||||
|
||||
if (typeDef)
|
||||
throw compiler.error_message("Duplicate type definition " + typeDefName, node.typedefname);
|
||||
|
||||
if (compiler.getClassDef(typeDefName))
|
||||
throw compiler.error_message(typeDefName + " is already declared as class", node.typedefname);
|
||||
|
||||
compiler.imBuffer = new StringBuffer();
|
||||
compiler.cmBuffer = new StringBuffer();
|
||||
|
||||
if (!generate)
|
||||
buffer.concat(compiler.source.substring(compiler.lastPos, node.start));
|
||||
|
||||
buffer.concat("{var the_typedef = objj_allocateTypeDef(\"" + typeDefName + "\");");
|
||||
|
||||
typeDef = new TypeDef(typeDefName);
|
||||
compiler.typeDefs[typeDefName] = typeDef;
|
||||
typeDefScope.typeDef = typeDef;
|
||||
|
||||
buffer.concat("\nobjj_registerTypeDef(the_typedef);\n");
|
||||
|
||||
buffer.concat("}");
|
||||
|
||||
compiler.jsBuffer = buffer;
|
||||
|
||||
// Skip the "@end"
|
||||
if (!generate)
|
||||
compiler.lastPos = node.end;
|
||||
}
|
||||
});
|
||||
@@ -37,7 +37,7 @@ if (!Object.create)
|
||||
// This is for IE8 support. It doesn't have the Object.keys function.
|
||||
if (!Object.keys)
|
||||
{
|
||||
Object.keys = (function ()
|
||||
Object.keys = (function()
|
||||
{
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
|
||||
|
||||
@@ -100,6 +100,11 @@ GLOBAL(objj_object) = function()
|
||||
this._UID = -1;
|
||||
}
|
||||
|
||||
GLOBAL(objj_typeDef) = function(/*String*/ aName)
|
||||
{
|
||||
this.name = aName;
|
||||
}
|
||||
|
||||
// Working with Classes
|
||||
|
||||
GLOBAL(class_getName) = function(/*Class*/ aClass)
|
||||
@@ -440,6 +445,26 @@ GLOBAL(protocol_addProtocol) = function(/*Protocol*/ proto, /*Protocol*/ additio
|
||||
(proto.protocol_list || (proto.protocol_list = [])).push(addition);
|
||||
}
|
||||
|
||||
|
||||
var REGISTERED_TYPEDEFS = Object.create(null);
|
||||
|
||||
GLOBAL(objj_allocateTypeDef) = function(/*String*/ aName)
|
||||
{
|
||||
var typeDef = new objj_typeDef(aName);
|
||||
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
GLOBAL(objj_registerTypeDef) = function(/*TypeDef*/ typeDef)
|
||||
{
|
||||
REGISTERED_TYPEDEFS[typeDef.name] = typeDef;
|
||||
}
|
||||
|
||||
GLOBAL(typeDef_getName) = function(/*TypeDef*/ typeDef)
|
||||
{
|
||||
return typeDef.name;
|
||||
}
|
||||
|
||||
var _class_initialize = function(/*Class*/ aClass)
|
||||
{
|
||||
var meta = GETMETA(aClass);
|
||||
@@ -619,6 +644,7 @@ GLOBAL(objj_resetRegisterClasses) = function()
|
||||
|
||||
REGISTERED_CLASSES = Object.create(null);
|
||||
REGISTERED_PROTOCOLS = Object.create(null);
|
||||
REGISTERED_TYPEDEFS = Object.create(null);
|
||||
|
||||
resetBundle();
|
||||
}
|
||||
@@ -751,6 +777,13 @@ GLOBAL(objj_getProtocol) = function(/*String*/ aName)
|
||||
return REGISTERED_PROTOCOLS[aName];
|
||||
}
|
||||
|
||||
// Working with typeDef
|
||||
|
||||
GLOBAL(objj_getTypeDef) = function(/*String*/ aName)
|
||||
{
|
||||
return REGISTERED_TYPEDEFS[aName];
|
||||
}
|
||||
|
||||
// Working with Instance Variables
|
||||
|
||||
GLOBAL(ivar_getName) = function(anIvar)
|
||||
|
||||
+49
-29
@@ -375,12 +375,15 @@ if (typeof exports != "undefined" && !exports.acorn) {
|
||||
var _ref = {keyword: "ref"}, _deref = {keyword: "deref"};
|
||||
var _protocol = {keyword: "protocol"}, _optional = {keyword: "optional"}, _required = {keyword: "required"};
|
||||
var _interface = {keyword: "interface"};
|
||||
var _typedef = {keyword: "typedef"};
|
||||
|
||||
// Objective-J keywords
|
||||
|
||||
var _filename = {keyword: "filename"}, _unsigned = {keyword: "unsigned", okAsIdent: true}, _signed = {keyword: "signed", okAsIdent: true};
|
||||
var _byte = {keyword: "byte", okAsIdent: true}, _char = {keyword: "char", okAsIdent: true}, _short = {keyword: "short", okAsIdent: true};
|
||||
var _int = {keyword: "int", okAsIdent: true}, _long = {keyword: "long", okAsIdent: true}, _id = {keyword: "id", okAsIdent: true};
|
||||
var _boolean = {keyword: "BOOL", okAsIdent: true}, _SEL = {keyword: "SEL", okAsIdent: true}, _float = {keyword: "float", okAsIdent: true};
|
||||
var _double = {keyword: "double", okAsIdent: true};
|
||||
var _preprocess = {keyword: "#"};
|
||||
|
||||
// Preprocessor keywords
|
||||
@@ -415,14 +418,15 @@ if (typeof exports != "undefined" && !exports.acorn) {
|
||||
// Map Objective-J keyword names to token types.
|
||||
|
||||
var keywordTypesObjJ = {"IBAction": _action, "IBOutlet": _outlet, "unsigned": _unsigned, "signed": _signed, "byte": _byte, "char": _char,
|
||||
"short": _short, "int": _int, "long": _long, "id": _id };
|
||||
"short": _short, "int": _int, "long": _long, "id": _id, "float": _float, "BOOL": _boolean, "SEL": _SEL,
|
||||
"double": _double};
|
||||
|
||||
// Map Objective-J "@" keyword names to token types.
|
||||
|
||||
var objJAtKeywordTypes = {"implementation": _implementation, "outlet": _outlet, "accessors": _accessors, "end": _end,
|
||||
"import": _import, "action": _action, "selector": _selector, "class": _class, "global": _global,
|
||||
"ref": _ref, "deref": _deref, "protocol": _protocol, "optional": _optional, "required": _required,
|
||||
"interface": _interface};
|
||||
"interface": _interface, "typedef": _typedef};
|
||||
|
||||
// Map Preprocessor keyword names to token types.
|
||||
|
||||
@@ -547,7 +551,7 @@ if (typeof exports != "undefined" && !exports.acorn) {
|
||||
|
||||
// The Objective-J keywords.
|
||||
|
||||
var isKeywordObjJ = makePredicate("IBAction IBOutlet byte char short int long unsigned signed id");
|
||||
var isKeywordObjJ = makePredicate("IBAction IBOutlet byte char short int long float unsigned signed id BOOL SEL double");
|
||||
|
||||
// The preprocessor keywords.
|
||||
|
||||
@@ -662,6 +666,7 @@ var preprocessTokens = [_preIf, _preIfdef, _preIfndef, _preElse, _preElseIf, _pr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tokVal = val;
|
||||
lastTokCommentsAfter = tokCommentsAfter;
|
||||
lastTokSpacesAfter = tokSpacesAfter;
|
||||
@@ -2277,6 +2282,15 @@ var preIfLevel = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
// This is a Objective-J statement
|
||||
case _typedef:
|
||||
if (options.objj) {
|
||||
next();
|
||||
node.typedefname = parseIdent(true);
|
||||
return finishNode(node, "TypeDefStatement");
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// The indentation is one step to the right here to make sure it
|
||||
@@ -2317,6 +2331,7 @@ var preIfLevel = 0;
|
||||
if (outlet)
|
||||
decl.outlet = outlet;
|
||||
decl.ivartype = type;
|
||||
// print("keyword: " + type.name + " is class " + type.typeisclass)
|
||||
decl.id = parseIdent();
|
||||
if (strict && isStrictBadIdWord(decl.id.name))
|
||||
raise(decl.id.start, "Binding " + decl.id.name + " in strict mode");
|
||||
@@ -3021,6 +3036,7 @@ var preIfLevel = 0;
|
||||
node.typeisclass = true;
|
||||
next();
|
||||
} else {
|
||||
node.typeisclass = false;
|
||||
node.name = tokType.keyword;
|
||||
// Do nothing more if it is 'void'
|
||||
if (!eat(_void)) {
|
||||
@@ -3043,32 +3059,36 @@ var preIfLevel = 0;
|
||||
} else {
|
||||
// Now check if it is some basic type or an approved combination of basic types
|
||||
var nextKeyWord;
|
||||
if (eat(_signed) || eat(_unsigned))
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
if (eat(_char) || eat(_byte) || eat(_short)) {
|
||||
if (nextKeyWord)
|
||||
node.name += " " + nextKeyWord;
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
} else {
|
||||
if (eat(_int)) {
|
||||
if (nextKeyWord)
|
||||
node.name += " " + nextKeyWord;
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
}
|
||||
if (eat(_long)) {
|
||||
if (nextKeyWord)
|
||||
node.name += " " + nextKeyWord;
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
if (eat(_long)) {
|
||||
node.name += " " + nextKeyWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!nextKeyWord) {
|
||||
// It must be a class name if it was not a basic type. // FIXME: This is not true
|
||||
node.name = (!options.forbidReserved && tokType.keyword) || unexpected();
|
||||
node.typeisclass = true;
|
||||
next();
|
||||
if (eat(_float) || eat(_boolean) || eat(_SEL) || eat(_double))
|
||||
nextKeyWord = tokType.keyword;
|
||||
else {
|
||||
if (eat(_signed) || eat(_unsigned))
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
if (eat(_char) || eat(_byte) || eat(_short)) {
|
||||
if (nextKeyWord)
|
||||
node.name += " " + nextKeyWord;
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
} else {
|
||||
if (eat(_int)) {
|
||||
if (nextKeyWord)
|
||||
node.name += " " + nextKeyWord;
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
}
|
||||
if (eat(_long)) {
|
||||
if (nextKeyWord)
|
||||
node.name += " " + nextKeyWord;
|
||||
nextKeyWord = tokType.keyword || true;
|
||||
if (eat(_long)) {
|
||||
node.name += " " + nextKeyWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!nextKeyWord) {
|
||||
// It must be a class name if it was not a basic type. // FIXME: This is not true
|
||||
node.name = (!options.forbidReserved && tokType.keyword) || unexpected();
|
||||
node.typeisclass = true;
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,6 +221,8 @@ if (!exports.acorn) {
|
||||
}
|
||||
}
|
||||
|
||||
exports.TypeDefStatement = ignore;
|
||||
|
||||
exports.MethodDeclarationStatement = function(node, st, c) {
|
||||
var body = node.body;
|
||||
if (body)
|
||||
|
||||
Loaded 100 of 176 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user