mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-24 19:30:42 +00:00
Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows
Possible regression from #fe260a8 Regression: -reloadData does not reload views any more even if the table is empty (see CPOutlineViewCibTest). BUG: -removeTableColumn: error. Conflicts: AppKit/CPOutlineView.j AppKit/CPTableHeaderView.j AppKit/CPTableView.j
This commit is contained in:
@@ -11,5 +11,7 @@ xcuserdata/
|
||||
!*.xcodeproj/project.pbxproj
|
||||
*.xCodeSupport/
|
||||
*.XcodeSupport/
|
||||
*XcodeSupport/
|
||||
Tests/Manual/**/*.xcodeproj
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
install: ./bootstrap.sh --quiet --noprompt --directory ./narwhal
|
||||
install: ./bootstrap.sh --noprompt --directory ./narwhal
|
||||
script: jake test
|
||||
env: PATH="$TRAVIS_BUILD_DIR/narwhal/bin:$PATH" CAPP_BUILD="$TRAVIS_BUILD_DIR/Build" NARWHAL_ENGINE=rhino
|
||||
|
||||
+152
-45
@@ -41,6 +41,9 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
var CPAlertDelegate_alertShowHelp_ = 1 << 0,
|
||||
CPAlertDelegate_alertDidEnd_returnCode_ = 1 << 1;
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPAlertStyle
|
||||
@@ -59,6 +62,14 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
var bottomHeight = 71;
|
||||
|
||||
@protocol CPAlertDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)alertShowHelp:(CPAlert)alert;
|
||||
- (void)alertDidEnd:(CPAlert)theAlert returnCode:(int)returnCode;
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
|
||||
@@ -83,31 +94,33 @@ var bottomHeight = 71;
|
||||
*/
|
||||
@implementation CPAlert : CPObject
|
||||
{
|
||||
BOOL _showHelp @accessors(property=showsHelp);
|
||||
BOOL _showSuppressionButton @accessors(property=showsSuppressionButton);
|
||||
BOOL _showHelp @accessors(property=showsHelp);
|
||||
BOOL _showSuppressionButton @accessors(property=showsSuppressionButton);
|
||||
|
||||
CPAlertStyle _alertStyle @accessors(property=alertStyle);
|
||||
CPString _title @accessors(property=title);
|
||||
CPView _accessoryView @accessors(property=accessoryView);
|
||||
CPImage _icon @accessors(property=icon);
|
||||
CPAlertStyle _alertStyle @accessors(property=alertStyle);
|
||||
CPString _title @accessors(property=title);
|
||||
CPView _accessoryView @accessors(property=accessoryView);
|
||||
CPImage _icon @accessors(property=icon);
|
||||
|
||||
CPArray _buttons @accessors(property=buttons, readonly);
|
||||
CPCheckBox _suppressionButton @accessors(property=suppressionButton, readonly);
|
||||
CPArray _buttons @accessors(property=buttons, readonly);
|
||||
CPCheckBox _suppressionButton @accessors(property=suppressionButton, readonly);
|
||||
|
||||
id _delegate @accessors(property=delegate);
|
||||
id _modalDelegate;
|
||||
SEL _didEndSelector;
|
||||
id <CPAlertDelegate> _delegate @accessors(property=delegate);
|
||||
id _modalDelegate;
|
||||
SEL _didEndSelector @accessors(property=didEndSelector);
|
||||
Function _didEndBlock;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
_CPAlertThemeView _themeView @accessors(property=themeView, readonly);
|
||||
CPWindow _window @accessors(property=window, readonly);
|
||||
int _defaultWindowStyle;
|
||||
_CPAlertThemeView _themeView @accessors(property=themeView, readonly);
|
||||
CPWindow _window @accessors(property=window, readonly);
|
||||
int _defaultWindowStyle;
|
||||
|
||||
CPImageView _alertImageView;
|
||||
CPTextField _informativeLabel;
|
||||
CPTextField _messageLabel;
|
||||
CPButton _alertHelpButton;
|
||||
CPImageView _alertImageView;
|
||||
CPTextField _informativeLabel;
|
||||
CPTextField _messageLabel;
|
||||
CPButton _alertHelpButton;
|
||||
|
||||
BOOL _needsLayout;
|
||||
BOOL _needsLayout;
|
||||
}
|
||||
|
||||
#pragma mark Creating Alerts
|
||||
@@ -186,6 +199,30 @@ var bottomHeight = 71;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate
|
||||
|
||||
/*!
|
||||
Set the delegate of the receiver
|
||||
@param aDelegate the delegate object for the alert.
|
||||
*/
|
||||
- (void)setDelegate:(id <CPAlertDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(alertShowHelp:)])
|
||||
_implementedDelegateMethods |= CPAlertDelegate_alertShowHelp_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
|
||||
_implementedDelegateMethods |= CPAlertDelegate_alertDidEnd_returnCode_;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Accessors
|
||||
|
||||
- (CPTheme)theme
|
||||
@@ -218,22 +255,21 @@ var bottomHeight = 71;
|
||||
[_themeView setValue:aValue forThemeAttribute:aName];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(CPThemeState)aState
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(ThemeState)aState
|
||||
{
|
||||
[_themeView setValue:aValue forThemeAttribute:aName inState:aState];
|
||||
}
|
||||
|
||||
|
||||
/*! @deprecated
|
||||
*/
|
||||
- (void)setWindowStyle:(int)aStyle
|
||||
/*! @deprecated */
|
||||
- (void)setWindowStyle:(int)style
|
||||
{
|
||||
CPLog.warn("DEPRECATED: setWindowStyle: is deprecated. use setTheme: instead");
|
||||
[self setTheme:(aStyle === CPHUDBackgroundWindowMask) ? [CPTheme defaultHudTheme] : [CPTheme defaultTheme]];
|
||||
|
||||
[self setTheme:(style === CPHUDBackgroundWindowMask) ? [CPTheme defaultHudTheme] : [CPTheme defaultTheme]];
|
||||
}
|
||||
|
||||
/*! @deprecated
|
||||
*/
|
||||
/*! @deprecated */
|
||||
- (int)windowStyle
|
||||
{
|
||||
CPLog.warn("DEPRECATED: windowStyle: is deprecated. use theme instead");
|
||||
@@ -242,18 +278,19 @@ var bottomHeight = 71;
|
||||
|
||||
|
||||
/*!
|
||||
set the text of the alert's message
|
||||
Set the text of the alert's message.
|
||||
|
||||
@param aText CPString containing the text
|
||||
*/
|
||||
- (void)setMessageText:(CPString)aText
|
||||
- (void)setMessageText:(CPString)text
|
||||
{
|
||||
[_messageLabel setStringValue:aText];
|
||||
[_messageLabel setStringValue:text];
|
||||
_needsLayout = YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
return the content of the message text
|
||||
Return the content of the message text.
|
||||
|
||||
@return CPString containing the message text
|
||||
*/
|
||||
- (CPString)messageText
|
||||
@@ -262,13 +299,13 @@ var bottomHeight = 71;
|
||||
}
|
||||
|
||||
/*!
|
||||
set the text of the alert's informative text
|
||||
Set the text of the alert's informative text.
|
||||
|
||||
@param aText CPString containing the informative text
|
||||
*/
|
||||
- (void)setInformativeText:(CPString)aText
|
||||
- (void)setInformativeText:(CPString)text
|
||||
{
|
||||
[_informativeLabel setStringValue:aText];
|
||||
[_informativeLabel setStringValue:text];
|
||||
_needsLayout = YES;
|
||||
}
|
||||
|
||||
@@ -285,6 +322,7 @@ var bottomHeight = 71;
|
||||
/*!
|
||||
Sets the title of the alert window.
|
||||
This API is not present in Cocoa.
|
||||
|
||||
@param aTitle CPString containing the window title
|
||||
*/
|
||||
- (void)setTitle:(CPString)aTitle
|
||||
@@ -294,7 +332,7 @@ var bottomHeight = 71;
|
||||
}
|
||||
|
||||
/*!
|
||||
set the accessory view
|
||||
Set the accessory view.
|
||||
|
||||
@param aView the accessory view
|
||||
*/
|
||||
@@ -305,7 +343,7 @@ var bottomHeight = 71;
|
||||
}
|
||||
|
||||
/*!
|
||||
set if alert shows the suppression button
|
||||
Set if the alert shows the suppression button.
|
||||
|
||||
@param shouldShowSuppressionButton YES or NO
|
||||
*/
|
||||
@@ -596,6 +634,17 @@ var bottomHeight = 71;
|
||||
[CPApp runModalForWindow:_window];
|
||||
}
|
||||
|
||||
/*!
|
||||
The same as \c runModal, but executes the code in \c block when the
|
||||
alert is dismissed.
|
||||
*/
|
||||
- (void)runModalWithDidEndBlock:(Function /*(CPAlert alert, int returnCode)*/)block
|
||||
{
|
||||
_didEndBlock = block;
|
||||
|
||||
[self runModal];
|
||||
}
|
||||
|
||||
/*!
|
||||
Runs the receiver modally as an alert sheet attached to a specified window.
|
||||
|
||||
@@ -630,6 +679,20 @@ var bottomHeight = 71;
|
||||
[self beginSheetModalForWindow:aWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
Runs the receiver modally as an alert sheet attached to a specified window.
|
||||
Executes the code in \c block when the alert is dismissed.
|
||||
|
||||
@param window The parent window for the sheet.
|
||||
@param block Code block to execute on dismissal
|
||||
*/
|
||||
- (void)beginSheetModalForWindow:(CPWindow)aWindow didEndBlock:(Function /*(CPAlert alert, int returnCode)*/)block
|
||||
{
|
||||
_didEndBlock = block;
|
||||
|
||||
[self beginSheetModalForWindow:aWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
|
||||
/*!
|
||||
@@ -642,6 +705,7 @@ var bottomHeight = 71;
|
||||
|
||||
_window = [[CPPanel alloc] initWithContentRect:frame styleMask:forceStyle || _defaultWindowStyle];
|
||||
[_window setLevel:CPStatusWindowLevel];
|
||||
[_window setPlatformWindow:[[CPApp keyWindow] platformWindow]];
|
||||
|
||||
if (_title)
|
||||
[_window setTitle:_title];
|
||||
@@ -668,8 +732,7 @@ var bottomHeight = 71;
|
||||
*/
|
||||
- (@action)_showHelp:(id)aSender
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(alertShowHelp:)])
|
||||
[_delegate alertShowHelp:self];
|
||||
[self _sendDelegateAlertShowHelp];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -696,18 +759,62 @@ var bottomHeight = 71;
|
||||
*/
|
||||
- (void)_alertDidEnd:(CPWindow)aWindow returnCode:(int)returnCode contextInfo:(id)contextInfo
|
||||
{
|
||||
if (_didEndSelector)
|
||||
objj_msgSend(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
|
||||
if (_didEndBlock)
|
||||
{
|
||||
if (typeof(_didEndBlock) === "function")
|
||||
_didEndBlock(self, returnCode);
|
||||
else
|
||||
CPLog.warn("%s: didEnd block is not a function", [self description]);
|
||||
|
||||
_modalDelegate = nil;
|
||||
_didEndSelector = nil;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
|
||||
[_delegate alertDidEnd:self returnCode:returnCode];
|
||||
// didEnd blocks are transient
|
||||
_didEndBlock = nil;
|
||||
}
|
||||
else if (_modalDelegate)
|
||||
{
|
||||
if (_didEndSelector)
|
||||
objj_msgSend(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
|
||||
}
|
||||
else if (_delegate)
|
||||
{
|
||||
if (_didEndSelector)
|
||||
objj_msgSend(_delegate, _didEndSelector, self, returnCode);
|
||||
else
|
||||
[self _sendDelegateAlertDidEndReturnCode:returnCode];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPAlert (CPAlertDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate alertDidEnd:returnCode
|
||||
*/
|
||||
- (void)_sendDelegateAlertDidEndReturnCode:(int)returnCode
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPAlertDelegate_alertDidEnd_returnCode_))
|
||||
return;
|
||||
|
||||
[_delegate alertDidEnd:self returnCode:returnCode];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate alertShowHelp:
|
||||
*/
|
||||
- (BOOL)_sendDelegateAlertShowHelp
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPAlertDelegate_alertShowHelp_))
|
||||
return YES;
|
||||
|
||||
return [_delegate alertShowHelp:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation _CPAlertThemeView : CPView
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -715,7 +822,7 @@ var bottomHeight = 71;
|
||||
return @"alert";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"size": CGSizeMake(400.0, 110.0),
|
||||
|
||||
+112
-17
@@ -26,6 +26,22 @@
|
||||
@import "CAMediaTimingFunction.j"
|
||||
|
||||
|
||||
@protocol CPAnimationDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)animationShouldStart:(CPAnimation)animation;
|
||||
- (float)animation:(CPAnimation)animation valueForProgress:(float)progress;
|
||||
- (void)animationDidEnd:(CPAnimation)animation;
|
||||
- (void)animationDidStop:(CPAnimation)animation;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPAnimationDelegate_animationShouldStart_ = 1 << 1,
|
||||
CPAnimationDelegate_animation_valueForProgress_ = 1 << 2,
|
||||
CPAnimationDelegate_animationDidEnd_ = 1 << 3,
|
||||
CPAnimationDelegate_animationDidStop_ = 1 << 4;
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPAnimationCurve
|
||||
@@ -80,17 +96,18 @@ ACTUAL_FRAME_RATE = 0;
|
||||
*/
|
||||
@implementation CPAnimation : CPObject
|
||||
{
|
||||
CPTimeInterval _lastTime;
|
||||
CPTimeInterval _duration;
|
||||
CPTimeInterval _lastTime;
|
||||
CPTimeInterval _duration;
|
||||
|
||||
CPAnimationCurve _animationCurve;
|
||||
CAMediaTimingFunction _timingFunction;
|
||||
CPAnimationCurve _animationCurve;
|
||||
CAMediaTimingFunction _timingFunction;
|
||||
|
||||
float _frameRate;
|
||||
float _progress;
|
||||
float _frameRate;
|
||||
float _progress;
|
||||
|
||||
id _delegate;
|
||||
CPTimer _timer;
|
||||
id <CPAnimationDelegate> _delegate;
|
||||
CPTimer _timer;
|
||||
unsigned _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -214,9 +231,25 @@ ACTUAL_FRAME_RATE = 0;
|
||||
Sets the animation's delegate.
|
||||
@param aDelegate the new delegate
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPAnimationDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animationShouldStart:)])
|
||||
_implementedDelegateMethods |= CPAnimationDelegate_animationShouldStart_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animationDidEnd:)])
|
||||
_implementedDelegateMethods |= CPAnimationDelegate_animationDidEnd_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animationDidStop:)])
|
||||
_implementedDelegateMethods |= CPAnimationDelegate_animationDidStop_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
|
||||
_implementedDelegateMethods |= CPAnimationDelegate_animation_valueForProgress_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -227,7 +260,7 @@ ACTUAL_FRAME_RATE = 0;
|
||||
- (void)startAnimation
|
||||
{
|
||||
// If we're already animating, or our delegate stops us, animate.
|
||||
if (_timer || _delegate && [_delegate respondsToSelector:@selector(animationShouldStart:)] && ![_delegate animationShouldStart:self])
|
||||
if (_timer || ![self _sendDelegateAnimationShouldStart])
|
||||
return;
|
||||
|
||||
if (_progress === 1.0)
|
||||
@@ -236,7 +269,9 @@ ACTUAL_FRAME_RATE = 0;
|
||||
ACTUAL_FRAME_RATE = 0;
|
||||
_lastTime = new Date();
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
var timerInterval = _frameRate <= 0.0 ? 0.0001 : 1.0 / _frameRate;
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -258,8 +293,7 @@ ACTUAL_FRAME_RATE = 0;
|
||||
[_timer invalidate];
|
||||
_timer = nil;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animationDidEnd:)])
|
||||
[_delegate animationDidEnd:self];
|
||||
[self _sendDelegateAnimationDidEnd];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,8 +308,7 @@ ACTUAL_FRAME_RATE = 0;
|
||||
[_timer invalidate];
|
||||
_timer = nil;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animationDidStop:)])
|
||||
[_delegate animationDidStop:self];
|
||||
[self _sendDelegateAnimationDidStop];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -311,8 +344,8 @@ ACTUAL_FRAME_RATE = 0;
|
||||
{
|
||||
var t = [self currentProgress];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
|
||||
return [_delegate animation:self valueForProgress:t];
|
||||
if ([self _delegateRespondsToAnimationValueForProgress])
|
||||
return [self _sendDelegateAnimationValueForProgress:t];
|
||||
|
||||
if (_animationCurve == CPAnimationLinear)
|
||||
return t;
|
||||
@@ -328,6 +361,68 @@ ACTUAL_FRAME_RATE = 0;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPAnimation (CPAnimationDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Check if the delegate responds to animation:valueForProgress:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToAnimationValueForProgress
|
||||
{
|
||||
return _implementedDelegateMethods & CPAnimationDelegate_animation_valueForProgress_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate animationShouldStart:
|
||||
*/
|
||||
- (BOOL)_sendDelegateAnimationShouldStart
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPAnimationDelegate_animationShouldStart_))
|
||||
return YES;
|
||||
|
||||
return [_delegate animationShouldStart:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate animation:valueForProgress:
|
||||
*/
|
||||
- (float)_sendDelegateAnimationValueForProgress:(float)aProgress
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPAnimationDelegate_animation_valueForProgress_))
|
||||
return aProgress;
|
||||
|
||||
return [_delegate animation:self valueForProgress:aProgress];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate animationDidEnd:
|
||||
*/
|
||||
- (void)_sendDelegateAnimationDidEnd
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPAnimationDelegate_animationDidEnd_))
|
||||
return;
|
||||
|
||||
[_delegate animationDidEnd:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate animationDidStop:
|
||||
*/
|
||||
- (void)_sendDelegateAnimationDidStop
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPAnimationDelegate_animationDidStop_))
|
||||
return;
|
||||
|
||||
[_delegate animationDidStop:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// currently used function to determine time
|
||||
// 1:1 conversion to js from webkit source files
|
||||
// UnitBezier.h, WebCore_animation_AnimationBase.cpp
|
||||
|
||||
+42
-65
@@ -22,6 +22,7 @@
|
||||
|
||||
@import <Foundation/CPBundle.j>
|
||||
|
||||
@import "CPApplication_Constants.j"
|
||||
@import "CPCompatibility.j"
|
||||
@import "CPColorPanel.j"
|
||||
@import "CPCursor.j"
|
||||
@@ -34,28 +35,26 @@
|
||||
@import "CPPanel.j"
|
||||
@import "CPPlatform.j"
|
||||
@import "CPWindowController.j"
|
||||
@import "_CPPopoverWindow.j"
|
||||
|
||||
var CPMainCibFile = @"CPMainCibFile",
|
||||
CPMainCibFileHumanFriendly = @"Main cib file base name",
|
||||
CPEventModifierFlags = 0;
|
||||
|
||||
CPApp = nil;
|
||||
|
||||
CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification";
|
||||
CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification";
|
||||
CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification";
|
||||
CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification";
|
||||
CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification";
|
||||
CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification";
|
||||
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
|
||||
@protocol CPApplicationDelegate <CPObject>
|
||||
|
||||
CPTerminateNow = YES;
|
||||
CPTerminateCancel = NO;
|
||||
CPTerminateLater = -1; // not currently supported
|
||||
@optional
|
||||
- (void)applicationDidBecomeActive:(CPNotification)aNotification;
|
||||
- (void)applicationDidChangeScreenParameters:(CPNotification)aNotification;
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification;
|
||||
- (void)applicationDidResignActive:(CPNotification)aNotification;
|
||||
- (void)applicationWillBecomeActive:(CPNotification)aNotification;
|
||||
- (void)applicationWillFinishLaunching:(CPNotification)aNotification;
|
||||
- (void)applicationWillResignActive:(CPNotification)aNotification;
|
||||
- (void)applicationWillTerminate:(CPNotification)aNotification;
|
||||
|
||||
CPRunStoppedResponse = -1000;
|
||||
CPRunAbortedResponse = -1001;
|
||||
CPRunContinuesResponse = -1002;
|
||||
@end
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -84,36 +83,36 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
@implementation CPApplication : CPResponder
|
||||
{
|
||||
CPArray _eventListeners;
|
||||
int _eventListenerInsertionIndex;
|
||||
CPArray _eventListeners;
|
||||
int _eventListenerInsertionIndex;
|
||||
|
||||
CPEvent _currentEvent;
|
||||
CPWindow _lastMouseMoveWindow;
|
||||
CPEvent _currentEvent;
|
||||
CPWindow _lastMouseMoveWindow;
|
||||
|
||||
CPArray _windows;
|
||||
CPWindow _keyWindow;
|
||||
CPWindow _mainWindow;
|
||||
CPWindow _previousKeyWindow;
|
||||
CPWindow _previousMainWindow;
|
||||
CPArray _windows;
|
||||
CPWindow _keyWindow;
|
||||
CPWindow _mainWindow;
|
||||
CPWindow _previousKeyWindow;
|
||||
CPWindow _previousMainWindow;
|
||||
|
||||
CPDocumentController _documentController;
|
||||
CPDocumentController _documentController;
|
||||
|
||||
CPModalSession _currentSession;
|
||||
CPModalSession _currentSession;
|
||||
|
||||
//
|
||||
id _delegate;
|
||||
BOOL _finishedLaunching;
|
||||
BOOL _isActive;
|
||||
id <CPApplicationDelegate> _delegate;
|
||||
BOOL _finishedLaunching;
|
||||
BOOL _isActive;
|
||||
|
||||
CPDictionary _namedArgs;
|
||||
CPArray _args;
|
||||
CPString _fullArgsString;
|
||||
CPDictionary _namedArgs;
|
||||
CPArray _args;
|
||||
CPString _fullArgsString;
|
||||
|
||||
CPImage _applicationIconImage;
|
||||
CPImage _applicationIconImage;
|
||||
|
||||
CPPanel _aboutPanel;
|
||||
CPPanel _aboutPanel;
|
||||
|
||||
CPThemeBlend _themeBlend @accessors(property=themeBlend);
|
||||
CPThemeBlend _themeBlend @accessors(property=themeBlend);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -159,7 +158,7 @@ CPRunContinuesResponse = -1002;
|
||||
react to these events.
|
||||
@param aDelegate the delegate object
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPApplicationDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate == aDelegate)
|
||||
return;
|
||||
@@ -173,7 +172,8 @@ CPRunContinuesResponse = -1002;
|
||||
CPApplicationDidBecomeActiveNotification, @selector(applicationDidBecomeActive:),
|
||||
CPApplicationWillResignActiveNotification, @selector(applicationWillResignActive:),
|
||||
CPApplicationDidResignActiveNotification, @selector(applicationDidResignActive:),
|
||||
CPApplicationWillTerminateNotification, @selector(applicationWillTerminate:)
|
||||
CPApplicationWillTerminateNotification, @selector(applicationWillTerminate:),
|
||||
CPApplicationDidChangeScreenParametersNotification, @selector(applicationDidChangeScreenParameters:)
|
||||
],
|
||||
count = [delegateNotifications count];
|
||||
|
||||
@@ -586,8 +586,8 @@ CPRunContinuesResponse = -1002;
|
||||
/* @ignore */
|
||||
- (BOOL)_handleKeyEquivalent:(CPEvent)anEvent
|
||||
{
|
||||
return [[self keyWindow] performKeyEquivalent:anEvent] ||
|
||||
[[self mainMenu] performKeyEquivalent:anEvent];
|
||||
return [[self keyWindow] performKeyEquivalent:anEvent] ||
|
||||
[[self mainMenu] performKeyEquivalent:anEvent];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -601,33 +601,10 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
var theWindow = [anEvent window];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var willPropagate = [[theWindow platformWindow] _willPropagateCurrentDOMEvent];
|
||||
|
||||
// temporarily pretend we won't propagate the event. we'll restore the saved value later
|
||||
// we do this outside the if so that changes user code might make in _handleKeyEquiv. are preserved
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
#endif
|
||||
|
||||
// Check if this is a candidate for key equivalent...
|
||||
if ([anEvent _couldBeKeyEquivalent] && [self _handleKeyEquivalent:anEvent])
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var characters = [anEvent characters],
|
||||
modifierFlags = [anEvent modifierFlags];
|
||||
|
||||
// Unconditionally propagate on these keys to solve browser copy paste bugs
|
||||
if ((characters == "c" || characters == "x" || characters == "v") && (modifierFlags & CPPlatformActionKeyMask))
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
#endif
|
||||
|
||||
// The key equivalent was handled.
|
||||
return;
|
||||
}
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// if we make it this far, then restore the original willPropagate value
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:willPropagate];
|
||||
#endif
|
||||
|
||||
if ([anEvent type] == CPMouseMoved)
|
||||
{
|
||||
@@ -1380,8 +1357,8 @@ var _CPAppBootstrapperActions = nil;
|
||||
if (mainCibFile)
|
||||
{
|
||||
[mainBundle loadCibFile:mainCibFile
|
||||
externalNameTable:@{ CPCibOwner: CPApp }
|
||||
loadDelegate:self];
|
||||
externalNameTable:@{ CPCibOwner: CPApp }
|
||||
loadDelegate:self];
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -1458,7 +1435,7 @@ var _CPAppBootstrapperActions = nil;
|
||||
|
||||
+ (void)cibDidFailToLoad:(CPCib)aCib
|
||||
{
|
||||
throw new Error("Could not load main cib file (Did you forget to nib2cib it?).");
|
||||
throw new Error("Could not load main cib file. Did you forget to nib2cib it?");
|
||||
}
|
||||
|
||||
+ (void)reset
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* CPApplication_Constants.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Aparajita Fishman.
|
||||
* Copyright 2013 The Cappuccino Project
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
CPApp = nil;
|
||||
|
||||
CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification";
|
||||
CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification";
|
||||
CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification";
|
||||
CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification";
|
||||
CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification";
|
||||
CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification";
|
||||
CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification";
|
||||
CPApplicationDidChangeScreenParametersNotification = @"CPApplicationDidChangeScreenParametersNotification";
|
||||
|
||||
CPTerminateNow = YES;
|
||||
CPTerminateCancel = NO;
|
||||
CPTerminateLater = -1; // not currently supported
|
||||
|
||||
CPRunStoppedResponse = -1000;
|
||||
CPRunAbortedResponse = -1001;
|
||||
CPRunContinuesResponse = -1002;
|
||||
@@ -147,6 +147,8 @@ var DefaultLineWidth = 1.0;
|
||||
{
|
||||
_path = CGPathCreateMutable();
|
||||
_lineWidth = [[self class] defaultLineWidth];
|
||||
_lineDashesPhase = 0;
|
||||
_lineDashes = [];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ CPBelowBottom = 6;
|
||||
return @"box";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"background-color": [CPNull null],
|
||||
|
||||
+267
-80
@@ -20,6 +20,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPIndexSet.j>
|
||||
|
||||
@import "CPControl.j"
|
||||
@@ -30,40 +31,86 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
@protocol CPBrowserDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)browser:(CPBrowser)browser acceptDrop:(id)info atRow:(CPInteger)row column:(CPInteger)column dropOperation:(CPTableViewDropOperation)dropOperation;
|
||||
- (BOOL)browser:(CPBrowser)browser canDragRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column withEvent:(CPEvent )event;
|
||||
- (BOOL)browser:(CPBrowser)browser isLeafItem:(id)item;
|
||||
- (BOOL)browser:(CPBrowser)browser shouldSelectRowIndexes:(CPIndexSet)anIndexSet inColumn:(CPInteger)column;
|
||||
- (BOOL)browser:(CPBrowser)browser writeRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column toPasteboard:(CPPasteboard)pasteboard;
|
||||
- (CPDragOperation)browser:(CPBrowser)browser validateDrop:(id)info proposedRow:(CPInteger)row column:(CPInteger)column dropOperation:(CPTableViewDropOperation)dropOperation;
|
||||
- (CPImage)browser:(CPBrowser)browser imageValueForItem:(id)anItem;
|
||||
- (CPImage)browser:(CPBrowser)browser draggingImageForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
|
||||
- (CPImage)browser:(CPBrowser)browser imageValueForItem:(id)item;
|
||||
- (CPIndexSet)browser:(CPBrowser)browser selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes inColumn:(CPInteger)column;
|
||||
- (CPInteger)browser:(CPBrowser)browser numberOfChildrenOfItem:(id)item;
|
||||
- (CPView)browser:(CPBrowser)browser draggingViewForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)column withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
|
||||
- (id)browser:(CPBrowser)browser child:(CPInteger)index ofItem:(id)item;
|
||||
- (id)browser:(CPBrowser)browser objectValueForItem:(id)item;
|
||||
- (id)rootItemForBrowser:(CPBrowser)browser;
|
||||
- (void)browser:(CPBrowser)browser didChangeLastColumn:(CPInteger)oldLastColumn toColumn:(CPInteger)column;
|
||||
- (void)browser:(CPBrowser)browser didResizeColumn:(CPInteger)column;
|
||||
- (void)browserSelectionIsChanging:(CPBrowser)browser;
|
||||
- (void)browserSelectionDidChange:(CPBrowser)browser;
|
||||
|
||||
@end
|
||||
|
||||
var CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_ = 1 << 1,
|
||||
CPBrowserDelegate_browser_canDragRowsWithIndexes_inColumn_withEvent_ = 1 << 2,
|
||||
CPBrowserDelegate_browser_isLeafItem_ = 1 << 3,
|
||||
CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_ = 1 << 4,
|
||||
CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_ = 1 << 5,
|
||||
CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_ = 1 << 6,
|
||||
CPBrowserDelegate_browser_imageValueForItem_ = 1 << 7,
|
||||
CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_ = 1 << 8,
|
||||
CPBrowserDelegate_browser_imageValueForItem_ = 1 << 9,
|
||||
CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_ = 1 << 10,
|
||||
CPBrowserDelegate_browser_numberOfChildrenOfItem_ = 1 << 11,
|
||||
CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_ = 1 << 12,
|
||||
CPBrowserDelegate_browser_child_ofItem_ = 1 << 13,
|
||||
CPBrowserDelegate_browser_objectValueForItem_ = 1 << 14,
|
||||
CPBrowserDelegate_rootItemForBrowser_ = 1 << 15,
|
||||
CPBrowserDelegate_browser_didChangeLastColumn_toColumn_ = 1 << 16,
|
||||
CPBrowserDelegate_browser_didResizeColumn_ = 1 << 17,
|
||||
CPBrowserDelegate_browserSelectionIsChanging_ = 1 << 18,
|
||||
CPBrowserDelegate_browserSelectionDidChange_ = 1 << 19;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPBrowser
|
||||
*/
|
||||
@implementation CPBrowser : CPControl
|
||||
{
|
||||
id _delegate;
|
||||
CPString _pathSeparator;
|
||||
id <CPBrowserDelegate> _delegate;
|
||||
CPString _pathSeparator;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
CPView _contentView;
|
||||
CPScrollView _horizontalScrollView;
|
||||
CPView _prototypeView;
|
||||
CPView _contentView;
|
||||
CPScrollView _horizontalScrollView;
|
||||
CPView _prototypeView;
|
||||
|
||||
CPArray _tableViews;
|
||||
CPArray _tableDelegates;
|
||||
CPArray _tableViews;
|
||||
CPArray _tableDelegates;
|
||||
|
||||
id _rootItem;
|
||||
id _rootItem;
|
||||
|
||||
BOOL _delegateSupportsImages;
|
||||
BOOL _delegateSupportsImages;
|
||||
|
||||
SEL _doubleAction @accessors(property=doubleAction);
|
||||
SEL _doubleAction @accessors(property=doubleAction);
|
||||
|
||||
BOOL _allowsMultipleSelection;
|
||||
BOOL _allowsEmptySelection;
|
||||
BOOL _allowsMultipleSelection;
|
||||
BOOL _allowsEmptySelection;
|
||||
|
||||
Class _tableViewClass @accessors(property=tableViewClass);
|
||||
Class _tableViewClass @accessors(property=tableViewClass);
|
||||
|
||||
float _rowHeight;
|
||||
float _imageWidth;
|
||||
float _leafWidth;
|
||||
float _minColumnWidth;
|
||||
float _defaultColumnWidth @accessors(property=defaultColumnWidth);
|
||||
float _rowHeight;
|
||||
float _imageWidth;
|
||||
float _leafWidth;
|
||||
float _minColumnWidth;
|
||||
float _defaultColumnWidth @accessors(property=defaultColumnWidth);
|
||||
|
||||
CPArray _columnWidths;
|
||||
CPArray _columnWidths;
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -71,7 +118,7 @@
|
||||
return "browser";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"image-control-resize": [CPNull null],
|
||||
@@ -137,10 +184,74 @@
|
||||
[CPKeyedArchiver archivedDataWithRootObject:_prototypeView]];
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)anObject
|
||||
- (void)setDelegate:(id <CPBrowserDelegate>)anObject
|
||||
{
|
||||
if (_delegate === anObject)
|
||||
return;
|
||||
|
||||
_delegate = anObject;
|
||||
_delegateSupportsImages = [_delegate respondsToSelector:@selector(browser:imageValueForItem:)];
|
||||
_implementedDelegateMethods = 0;
|
||||
_delegateSupportsImages = NO;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:acceptDrop:atRow:column:dropOperation:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:canDragRowsWithIndexes:inColumn:withEvent:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_canDragRowsWithIndexes_inColumn_withEvent_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:isLeafItem:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_isLeafItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:shouldSelectRowIndexes:inColumn:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:writeRowsWithIndexes:inColumn:toPasteboard:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:validateDrop:proposedRow:column:dropOperation:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:imageValueForItem:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_imageValueForItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:imageValueForItem:)])
|
||||
{
|
||||
_delegateSupportsImages = YES;
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_imageValueForItem_;
|
||||
}
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:selectionIndexesForProposedSelection:inColumn:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:numberOfChildrenOfItem:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_numberOfChildrenOfItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:draggingViewForRowsWithIndexes:inColumn:withEvent:offset:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:child:ofItem:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_child_ofItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:objectValueForItem:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_objectValueForItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(rootItemForBrowser:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_rootItemForBrowser_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:didChangeLastColumn:toColumn:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_didChangeLastColumn_toColumn_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:didChangeLastColumn:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browser_didResizeColumn_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browserSelectionIsChanging:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browserSelectionIsChanging_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)])
|
||||
_implementedDelegateMethods |= CPBrowserDelegate_browserSelectionDidChange_;
|
||||
|
||||
[self loadColumnZero];
|
||||
}
|
||||
@@ -162,16 +273,13 @@
|
||||
|
||||
- (void)loadColumnZero
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(rootItemForBrowser:)])
|
||||
_rootItem = [_delegate rootItemForBrowser:self];
|
||||
else
|
||||
_rootItem = nil;
|
||||
_rootItem = [self _sendDelegateRootItemForBrowser];
|
||||
|
||||
[self setLastColumn:-1];
|
||||
[self addColumn];
|
||||
}
|
||||
|
||||
- (void)setLastColumn:(int)columnIndex
|
||||
- (void)setLastColumn:(CPInteger)columnIndex
|
||||
{
|
||||
if (columnIndex >= _tableViews.length)
|
||||
return;
|
||||
@@ -181,7 +289,7 @@
|
||||
|
||||
if (columnIndex > 0)
|
||||
[_tableViews[columnIndex - 1] setNeedsDisplay:YES];
|
||||
|
||||
|
||||
[_tableViews[columnIndex] setNeedsDisplay:YES];
|
||||
|
||||
[[_tableViews.slice(indexPlusOne) valueForKey:"enclosingScrollView"]
|
||||
@@ -190,8 +298,7 @@
|
||||
_tableViews = _tableViews.slice(0, indexPlusOne);
|
||||
_tableDelegates = _tableDelegates.slice(0, indexPlusOne);
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:didChangeLastColumn:toColumn:)])
|
||||
[_delegate browser:self didChangeLastColumn:oldValue toColumn:columnIndex];
|
||||
[self _sendDelegateBrowserDidChangeLastColumn:oldValue toColumn:columnIndex];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
@@ -291,7 +398,7 @@
|
||||
[aTableView addTableColumn:column];
|
||||
}
|
||||
|
||||
- (void)reloadColumn:(int)column
|
||||
- (void)reloadColumn:(CPInteger)column
|
||||
{
|
||||
[[self tableViewInColumn:column] reloadData];
|
||||
}
|
||||
@@ -359,17 +466,17 @@
|
||||
|
||||
// ITEMS
|
||||
|
||||
- (id)itemAtRow:(int)row inColumn:(int)column
|
||||
- (id)itemAtRow:(CPInteger)row inColumn:(CPInteger)column
|
||||
{
|
||||
return [_tableDelegates[column] childAtIndex:row];
|
||||
}
|
||||
|
||||
- (BOOL)isLeafItem:(id)item
|
||||
{
|
||||
return [_delegate respondsToSelector:@selector(browser:isLeafItem:)] && [_delegate browser:self isLeafItem:item];
|
||||
return (_implementedDelegateMethods & CPBrowserDelegate_browser_isLeafItem_) && [_delegate browser:self isLeafItem:item];
|
||||
}
|
||||
|
||||
- (id)parentForItemsInColumn:(int)column
|
||||
- (id)parentForItemsInColumn:(CPInteger)column
|
||||
{
|
||||
return [_tableDelegates[column] _item];
|
||||
}
|
||||
@@ -493,9 +600,7 @@
|
||||
{
|
||||
_columnWidths[column] = aWidth;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:didResizeColumn:)])
|
||||
[_delegate browser:self didResizeColumn:column];
|
||||
|
||||
[self _sendDelegateBrowserDidResizeColumn:column];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
@@ -610,15 +715,12 @@
|
||||
if (column < 0 || column > [self lastColumn] + 1)
|
||||
return;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:selectionIndexesForProposedSelection:inColumn:)])
|
||||
indexSet = [_delegate browser:self selectionIndexesForProposedSelection:indexSet inColumn:column];
|
||||
indexSet = [self _sendDelegateBrowserSelectionIndexesForProposedSelection:indexSet inColumn:column];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browser:shouldSelectRowIndexes:inColumn:)] &&
|
||||
![_delegate browser:self shouldSelectRowIndexes:indexSet inColumn:column])
|
||||
if (![self _sendDelegateBrowserShouldSelectRowIndexes:indexSet inColumn:column])
|
||||
return;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browserSelectionIsChanging:)])
|
||||
[_delegate browserSelectionIsChanging:self];
|
||||
[self _sendDelegateBrowserSelectionIsChanging];
|
||||
|
||||
if (column > [self lastColumn])
|
||||
[self addColumn];
|
||||
@@ -629,8 +731,7 @@
|
||||
|
||||
[self scrollColumnToVisible:column];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(browserSelectionDidChange:)])
|
||||
[_delegate browserSelectionDidChange:self];
|
||||
[self _sendDelegateBrowserSelectionDidChange];
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(CPColor)aColor
|
||||
@@ -652,30 +753,6 @@
|
||||
[_tableViews makeObjectsPerformSelector:@selector(registerForDraggedTypes:) withObject:types];
|
||||
}
|
||||
|
||||
- (BOOL)canDragRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(int)columnIndex withEvent:(CPEvent)dragEvent
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(browser:canDragRowsWithIndexes:inColumn:withEvent:)])
|
||||
return [_delegate browser:self canDragRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPImage)draggingImageForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(int)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:)])
|
||||
return [_delegate browser:self draggingImageForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CPView)draggingViewForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(int)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(browser:draggingViewForRowsWithIndexes:inColumn:withEvent:offset:)])
|
||||
return [_delegate browser:self draggingViewForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPBrowser (CPCoding)
|
||||
@@ -771,7 +848,7 @@
|
||||
CPBrowser _browser @accessors;
|
||||
}
|
||||
|
||||
- (void)initWithFrame:(CGRect)aFrame
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
{
|
||||
@@ -860,8 +937,6 @@
|
||||
|
||||
@end
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@implementation _CPBrowserTableDelegate : CPObject
|
||||
{
|
||||
CPBrowser _browser @accessors;
|
||||
@@ -902,22 +977,22 @@
|
||||
[_browser selectRowIndexes:selectedIndexes inColumn:_index];
|
||||
}
|
||||
|
||||
- (id)childAtIndex:(unsigned)index
|
||||
- (id)childAtIndex:(CPUInteger)index
|
||||
{
|
||||
return [_delegate browser:_browser child:index ofItem:_item];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id)info row:(int)row dropOperation:(CPTableViewDropOperation)operation
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id)info row:(CPInteger)row dropOperation:(CPTableViewDropOperation)operation
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(browser:acceptDrop:atRow:column:dropOperation:)])
|
||||
if (_browser._implementedDelegateMethods & CPBrowserDelegate_browser_acceptDrop_atRow_column_dropOperation_)
|
||||
return [_delegate browser:_browser acceptDrop:info atRow:row column:_index dropOperation:operation];
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id)info proposedRow:(int)row proposedDropOperation:(CPTableViewDropOperation)operation
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id)info proposedRow:(CPInteger)row proposedDropOperation:(CPTableViewDropOperation)operation
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(browser:validateDrop:proposedRow:column:dropOperation:)])
|
||||
if (_browser._implementedDelegateMethods & CPBrowserDelegate_browser_validateDrop_proposedRow_column_dropOperation_)
|
||||
return [_delegate browser:_browser validateDrop:info proposedRow:row column:_index dropOperation:operation];
|
||||
else
|
||||
return CPDragOperationNone;
|
||||
@@ -925,7 +1000,7 @@
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView writeRowsWithIndexes:(CPIndexSet)rowIndexes toPasteboard:(CPPasteboard)pboard
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(browser:writeRowsWithIndexes:inColumn:toPasteboard:)])
|
||||
if (_browser._implementedDelegateMethods & CPBrowserDelegate_browser_writeRowsWithIndexes_inColumn_toPasteboard_)
|
||||
return [_delegate browser:_browser writeRowsWithIndexes:rowIndexes inColumn:_index toPasteboard:pboard];
|
||||
else
|
||||
return NO;
|
||||
@@ -980,7 +1055,7 @@
|
||||
var imageView = [self layoutEphemeralSubviewNamed:@"image-view"
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:nil],
|
||||
isHighlighted = [self themeState] & CPThemeStateSelectedDataView;
|
||||
isHighlighted = [self hasThemeState:CPThemeStateSelectedDataView];
|
||||
|
||||
[imageView setImage: _isLeaf ? (isHighlighted ? _highlightedBranchImage : _branchImage) : nil];
|
||||
[imageView setImageScaling:CPImageScaleNone];
|
||||
@@ -995,7 +1070,7 @@
|
||||
[aCoder encodeObject:_highlightedBranchImage forKey:"_CPBrowserLeafViewHighlightedBranchImageKey"];
|
||||
}
|
||||
|
||||
- (void)initWithCoder:(CPCoder)aCoder
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{
|
||||
@@ -1008,3 +1083,115 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPBrowser (CPBrowserDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate rootItemForBrowser:
|
||||
*/
|
||||
- (id)_sendDelegateRootItemForBrowser
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_rootItemForBrowser_))
|
||||
return nil;
|
||||
|
||||
return [_delegate rootItemForBrowser:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate browser:didChangeLastColumn:toColumn:
|
||||
*/
|
||||
- (void)_sendDelegateBrowserDidChangeLastColumn:(CPInteger)lastColumn toColumn:(CPInteger)newColumn
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_didChangeLastColumn_toColumn_))
|
||||
return;
|
||||
|
||||
[_delegate browser:self didChangeLastColumn:lastColumn toColumn:newColumn];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate browser:didResizeColumn:
|
||||
*/
|
||||
- (void)_sendDelegateBrowserDidResizeColumn:(CPInteger)column
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_didResizeColumn_))
|
||||
return;
|
||||
|
||||
[_delegate browser:self didResizeColumn:column];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate browserSelectionIsChanging:
|
||||
*/
|
||||
- (void)_sendDelegateBrowserSelectionIsChanging
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_browserSelectionIsChanging_))
|
||||
return;
|
||||
|
||||
[_delegate browserSelectionIsChanging:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate browser:shouldSelectRowIndexes:inColumn:
|
||||
*/
|
||||
- (BOOL)_sendDelegateBrowserShouldSelectRowIndexes:(CPIndexSet)anIndexSet inColumn:(CPInteger)aColumn
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_shouldSelectRowIndexes_inColumn_))
|
||||
return YES;
|
||||
|
||||
return [_delegate browser:self shouldSelectRowIndexes:anIndexSet inColumn:aColumn];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate browser:selectionIndexesForProposedSelection:inColumn:
|
||||
*/
|
||||
- (CPIndexSet)_sendDelegateBrowserSelectionIndexesForProposedSelection:(CPIndexSet)anIndexSet inColumn:(CPInteger)aColumn
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_browser_selectionIndexesForProposedSelection_inColumn_))
|
||||
return anIndexSet;
|
||||
|
||||
return [_delegate browser:self selectionIndexesForProposedSelection:anIndexSet inColumn:aColumn];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate browserSelectionDidChange
|
||||
*/
|
||||
- (void)_sendDelegateBrowserSelectionDidChange
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPBrowserDelegate_browserSelectionDidChange_))
|
||||
return;
|
||||
|
||||
[_delegate browserSelectionDidChange:self];
|
||||
}
|
||||
|
||||
- (BOOL)canDragRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)columnIndex withEvent:(CPEvent)dragEvent
|
||||
{
|
||||
if (_implementedDelegateMethods & CPBrowserDelegate_browser_canDragRowsWithIndexes_inColumn_withEvent_)
|
||||
return [_delegate browser:self canDragRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPImage)draggingImageForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
|
||||
{
|
||||
if (_implementedDelegateMethods & CPBrowserDelegate_browser_draggingImageForRowsWithIndexes_inColumn_withEvent_offset_)
|
||||
return [_delegate browser:self draggingImageForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CPView)draggingViewForRowsWithIndexes:(CPIndexSet)rowIndexes inColumn:(CPInteger)columnIndex withEvent:(CPEvent)dragEvent offset:(CGPoint)dragImageOffset
|
||||
{
|
||||
if (_implementedDelegateMethods & CPBrowserDelegate_browser_draggingViewForRowsWithIndexes_inColumn_withEvent_offset_)
|
||||
return [_delegate browser:self draggingViewForRowsWithIndexes:rowIndexes inColumn:columnIndex withEvent:dragEvent offset:dragImageOffset];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+40
-30
@@ -72,13 +72,14 @@ CPPushInCellMask = CPPushInButtonMask;
|
||||
CPChangeGrayCellMask = CPGrayButtonMask;
|
||||
CPChangeBackgroundCellMask = CPBackgroundButtonMask;
|
||||
|
||||
CPButtonStateMixed = CPThemeState("mixed");
|
||||
CPButtonStateBezelStyleRounded = CPThemeState("rounded");
|
||||
CPButtonStateMixed = CPThemeState("mixed");
|
||||
CPButtonStateBezelStyleRounded = CPThemeState("rounded");
|
||||
CPButtonStateBezelStyleRoundRect = CPThemeState("roundRect");
|
||||
|
||||
// add all future correspondance between bezel styles and theme state here.
|
||||
var CPButtonBezelStyleStateMap = @{
|
||||
CPRoundedBezelStyle: CPButtonStateBezelStyleRounded,
|
||||
CPRoundRectBezelStyle: [CPNull null],
|
||||
CPRoundRectBezelStyle: CPButtonStateBezelStyleRoundRect,
|
||||
};
|
||||
|
||||
/// @cond IGNORE
|
||||
@@ -149,7 +150,7 @@ CPButtonImageOffset = 3.0;
|
||||
return @"button";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"image": [CPNull null],
|
||||
@@ -268,7 +269,7 @@ CPButtonImageOffset = 3.0;
|
||||
break;
|
||||
|
||||
case CPOffState:
|
||||
[self unsetThemeState:CPThemeStateSelected | CPButtonStateMixed | CPThemeStateHighlighted];
|
||||
[self unsetThemeState:[CPThemeStateSelected, CPButtonStateMixed, CPThemeStateHighlighted]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +293,7 @@ CPButtonImageOffset = 3.0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the button's next state to \c aState.
|
||||
Sets the button's state to the next available state.
|
||||
@param aState Possible states are any of the CPButton globals:
|
||||
\c CPOffState, \c CPOnState, \c CPMixedState
|
||||
*/
|
||||
@@ -448,38 +449,47 @@ CPButtonImageOffset = 3.0;
|
||||
{
|
||||
switch (aButtonType)
|
||||
{
|
||||
case CPMomentaryLightButton: [self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPNoCellMask];
|
||||
break;
|
||||
case CPMomentaryLightButton:
|
||||
[self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPNoCellMask];
|
||||
break;
|
||||
|
||||
case CPMomentaryPushInButton: [self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPNoCellMask];
|
||||
break;
|
||||
case CPMomentaryPushInButton:
|
||||
[self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPNoCellMask];
|
||||
break;
|
||||
|
||||
case CPMomentaryChangeButton: [self setHighlightsBy:CPContentsCellMask];
|
||||
[self setShowsStateBy:CPNoCellMask];
|
||||
break;
|
||||
case CPMomentaryChangeButton:
|
||||
[self setHighlightsBy:CPContentsCellMask];
|
||||
[self setShowsStateBy:CPNoCellMask];
|
||||
break;
|
||||
|
||||
case CPPushOnPushOffButton: [self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPChangeBackgroundCellMask | CPChangeGrayCellMask];
|
||||
break;
|
||||
case CPPushOnPushOffButton:
|
||||
[self setHighlightsBy:CPPushInCellMask | CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPChangeBackgroundCellMask | CPChangeGrayCellMask];
|
||||
break;
|
||||
|
||||
case CPOnOffButton: [self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
break;
|
||||
case CPOnOffButton:
|
||||
[self setHighlightsBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
[self setShowsStateBy:CPChangeGrayCellMask | CPChangeBackgroundCellMask];
|
||||
break;
|
||||
|
||||
case CPToggleButton: [self setHighlightsBy:CPPushInCellMask | CPContentsCellMask];
|
||||
[self setShowsStateBy:CPContentsCellMask];
|
||||
break;
|
||||
case CPToggleButton:
|
||||
[self setHighlightsBy:CPPushInCellMask | CPContentsCellMask];
|
||||
[self setShowsStateBy:CPContentsCellMask];
|
||||
break;
|
||||
|
||||
case CPSwitchButton: [CPException raise:CPInvalidArgumentException
|
||||
reason:"The CPSwitchButton type is not supported in Cappuccino, use the CPCheckBox class instead."];
|
||||
case CPSwitchButton:
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:"The CPSwitchButton type is not supported in Cappuccino, use the CPCheckBox class instead."];
|
||||
|
||||
case CPRadioButton: [CPException raise:CPInvalidArgumentException
|
||||
reason:"The CPRadioButton type is not supported in Cappuccino, use the CPRadio class instead."];
|
||||
case CPRadioButton:
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:"The CPRadioButton type is not supported in Cappuccino, use the CPRadio class instead."];
|
||||
|
||||
default: [CPException raise:CPInvalidArgumentException
|
||||
reason:"Unknown button type."];
|
||||
default:
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:"Unknown button type."];
|
||||
}
|
||||
|
||||
[self setImageDimsWhenDisabled:YES];
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
return @"button-bar";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"resize-control-inset": CGInsetMake(0.0, 0.0, 0.0, 0.0),
|
||||
@@ -250,15 +250,15 @@
|
||||
currentButtonOffset += width - 1;
|
||||
}
|
||||
|
||||
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal | CPThemeStateBordered];
|
||||
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted | CPThemeStateBordered];
|
||||
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled | CPThemeStateBordered];
|
||||
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:[CPThemeStateNormal, CPThemeStateBordered]];
|
||||
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:[CPThemeStateHighlighted, CPThemeStateBordered, ]];
|
||||
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:[CPThemeStateDisabled, CPThemeStateBordered]];
|
||||
[button setValue:textColor forThemeAttribute:@"text-color" inState:CPThemeStateBordered];
|
||||
|
||||
// FIXME shouldn't need this
|
||||
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:CPThemeStateNormal | CPThemeStateBordered | CPPopUpButtonStatePullsDown];
|
||||
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted | CPThemeStateBordered | CPPopUpButtonStatePullsDown];
|
||||
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:CPThemeStateDisabled | CPThemeStateBordered | CPPopUpButtonStatePullsDown];
|
||||
[button setValue:normalColor forThemeAttribute:@"bezel-color" inState:[CPThemeStateNormal, CPThemeStateBordered, CPPopUpButtonStatePullsDown]];
|
||||
[button setValue:highlightedColor forThemeAttribute:@"bezel-color" inState:[CPThemeStateHighlighted, CPThemeStateBordered, CPPopUpButtonStatePullsDown]];
|
||||
[button setValue:disabledColor forThemeAttribute:@"bezel-color" inState:[CPThemeStateDisabled, CPThemeStateBordered, CPPopUpButtonStatePullsDown]];
|
||||
|
||||
[self addSubview:button];
|
||||
}
|
||||
|
||||
+284
-76
@@ -32,6 +32,35 @@
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_ = 1 << 0,
|
||||
CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_ = 1 << 1,
|
||||
CPCollectionViewDelegate_collectionView_writeItemsAtIndexes_toPasteboard_ = 1 << 2,
|
||||
CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_ = 1 << 3,
|
||||
CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_ = 1 << 4,
|
||||
CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_ = 1 << 5,
|
||||
CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_ = 1 << 6,
|
||||
CPCollectionViewDelegate_collectionViewDidChangeSelection_ = 1 << 7,
|
||||
CPCollectionViewDelegate_collectionView_menuForItemAtIndex_ = 1 << 8,
|
||||
CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset = 1 << 9;
|
||||
|
||||
|
||||
@protocol CPCollectionViewDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)collectionView:(CPCollectionView)collectionView acceptDrop:(id)draggingInfo index:(CPInteger)index dropOperation:(CPCollectionViewDropOperation)dropOperation;
|
||||
- (BOOL)collectionView:(CPCollectionView)collectionView canDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event;
|
||||
- (BOOL)collectionView:(CPCollectionView)collectionView writeItemsAtIndexes:(CPIndexSet)indexes toPasteboard:(CPPasteboard)pasteboard;
|
||||
- (CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indexes;
|
||||
- (CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType;
|
||||
- (CPDragOperation)collectionView:(CPCollectionView)collectionView validateDrop:(id)draggingInfo proposedIndex:(CPInteger)proposedDropIndex dropOperation:(CPCollectionViewDropOperation)proposedDropOperation;
|
||||
- (CPMenu)collectionView:(CPCollectionView)collectionView menuForItemAtIndex:(CPInteger)anIndex;
|
||||
- (CPView)collectionView:(CPCollectionView)collectionView dragginViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset;
|
||||
- (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
|
||||
- (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPCollectionView
|
||||
@@ -69,51 +98,52 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
@implementation CPCollectionView : CPView
|
||||
{
|
||||
CPArray _content;
|
||||
CPArray _items;
|
||||
CPArray _content;
|
||||
CPArray _items;
|
||||
|
||||
CPData _itemData;
|
||||
CPCollectionViewItem _itemPrototype;
|
||||
CPCollectionViewItem _itemForDragging;
|
||||
CPMutableArray _cachedItems;
|
||||
CPData _itemData;
|
||||
CPCollectionViewItem _itemPrototype;
|
||||
CPCollectionViewItem _itemForDragging;
|
||||
CPMutableArray _cachedItems;
|
||||
|
||||
unsigned _maxNumberOfRows;
|
||||
unsigned _maxNumberOfColumns;
|
||||
unsigned _maxNumberOfRows;
|
||||
unsigned _maxNumberOfColumns;
|
||||
|
||||
CGSize _minItemSize;
|
||||
CGSize _maxItemSize;
|
||||
CGSize _minItemSize;
|
||||
CGSize _maxItemSize;
|
||||
|
||||
CPArray _backgroundColors;
|
||||
CPArray _backgroundColors;
|
||||
|
||||
float _tileWidth;
|
||||
float _tileWidth;
|
||||
|
||||
BOOL _isSelectable;
|
||||
BOOL _allowsMultipleSelection;
|
||||
BOOL _allowsEmptySelection;
|
||||
CPIndexSet _selectionIndexes;
|
||||
BOOL _isSelectable;
|
||||
BOOL _allowsMultipleSelection;
|
||||
BOOL _allowsEmptySelection;
|
||||
CPIndexSet _selectionIndexes;
|
||||
|
||||
CGSize _itemSize;
|
||||
CGSize _itemSize;
|
||||
|
||||
float _horizontalMargin;
|
||||
float _verticalMargin;
|
||||
float _horizontalMargin;
|
||||
float _verticalMargin;
|
||||
|
||||
unsigned _numberOfRows;
|
||||
unsigned _numberOfColumns;
|
||||
unsigned _numberOfRows;
|
||||
unsigned _numberOfColumns;
|
||||
|
||||
id _delegate;
|
||||
id <CPCollectionViewDelegate> _delegate;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
CPEvent _mouseDownEvent;
|
||||
CPEvent _mouseDownEvent;
|
||||
|
||||
BOOL _needsMinMaxItemSizeUpdate;
|
||||
CGSize _storedFrameSize;
|
||||
BOOL _needsMinMaxItemSizeUpdate;
|
||||
CGSize _storedFrameSize;
|
||||
|
||||
BOOL _uniformSubviewsResizing @accessors(property=uniformSubviewsResizing);
|
||||
BOOL _lockResizing;
|
||||
BOOL _uniformSubviewsResizing @accessors(property=uniformSubviewsResizing);
|
||||
BOOL _lockResizing;
|
||||
|
||||
CPInteger _currentDropIndex;
|
||||
CPDragOperation _currentDragOperation;
|
||||
CPInteger _currentDropIndex;
|
||||
CPDragOperation _currentDragOperation;
|
||||
|
||||
_CPCollectionViewDropIndicator _dropView;
|
||||
_CPCollectionViewDropIndicator _dropView;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -168,6 +198,54 @@ var HORIZONTAL_MARGIN = 2;
|
||||
[self setAutoresizingMask:0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate
|
||||
|
||||
/*!
|
||||
Set the delegate of the receiver
|
||||
@param aDelegate the delegate object for the collectionView.
|
||||
*/
|
||||
- (void)setDelegate:(id <CPCollectionViewDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:acceptDrop:index:dropOperation:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:writeItemsAtIndexes:toPasteboard:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_writeItemsAtIndexes_toPasteboard_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:dragTypesForItemsAtIndexes:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:dataForItemsAtIndexes:forType:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:didDoubleClickOnItemAtIndex:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionViewDidChangeSelection:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionViewDidChangeSelection_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:menuForItemAtIndex:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_menuForItemAtIndex_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:draggingViewForItemsAtIndexes:withEvent:offset:)])
|
||||
_implementedDelegateMethods |= CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the item prototype to \c anItem
|
||||
@param anItem the new item prototype.
|
||||
@@ -455,12 +533,12 @@ var HORIZONTAL_MARGIN = 2;
|
||||
[self tileIfNeeded:NO];
|
||||
}
|
||||
|
||||
- (void)resizeSubviewsWithOldSize:(CPSize)oldBoundsSize
|
||||
- (void)resizeSubviewsWithOldSize:(CGSize)oldBoundsSize
|
||||
{
|
||||
// Desactivate subviews autoresizing
|
||||
}
|
||||
|
||||
- (void)resizeWithOldSuperviewSize:(CPSize)oldBoundsSize
|
||||
- (void)resizeWithOldSuperviewSize:(CGSize)oldBoundsSize
|
||||
{
|
||||
if (_lockResizing)
|
||||
return;
|
||||
@@ -755,8 +833,8 @@ var HORIZONTAL_MARGIN = 2;
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
if ([_selectionIndexes count] && [anEvent clickCount] == 2 && [_delegate respondsToSelector:@selector(collectionView:didDoubleClickOnItemAtIndex:)])
|
||||
[_delegate collectionView:self didDoubleClickOnItemAtIndex:[_selectionIndexes firstIndex]];
|
||||
if ([_selectionIndexes count] && [anEvent clickCount] == 2)
|
||||
[self _sendDelegateDidDoubleClickOnItemAtIndex:[_selectionIndexes firstIndex]];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
@@ -784,6 +862,10 @@ var HORIZONTAL_MARGIN = 2;
|
||||
var firstSelectedIndex = [[self selectionIndexes] firstIndex],
|
||||
newSelectedRange = nil;
|
||||
|
||||
// This catches the case where the shift key is held down for the first selection.
|
||||
if (firstSelectedIndex === CPNotFound)
|
||||
firstSelectedIndex = index;
|
||||
|
||||
if (index < firstSelectedIndex)
|
||||
newSelectedRange = CPMakeRange(index, (firstSelectedIndex - index) + 1);
|
||||
else
|
||||
@@ -826,7 +908,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setUniformSubviewsResizing:(float)flag
|
||||
- (void)setUniformSubviewsResizing:(BOOL)flag
|
||||
{
|
||||
_uniformSubviewsResizing = flag;
|
||||
[self tileIfNeeded:NO];
|
||||
@@ -842,15 +924,6 @@ var HORIZONTAL_MARGIN = 2;
|
||||
return _verticalMargin;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the collection view's delegate
|
||||
@param aDelegate the new delegate
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
_delegate = aDelegate;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the collection view's delegate
|
||||
*/
|
||||
@@ -864,13 +937,13 @@ var HORIZONTAL_MARGIN = 2;
|
||||
*/
|
||||
- (CPMenu)menuForEvent:(CPEvent)theEvent
|
||||
{
|
||||
if (![[self delegate] respondsToSelector:@selector(collectionView:menuForItemAtIndex:)])
|
||||
if (![self _delegateRespondsToCollectionViewMenuForItemAtIndex])
|
||||
return [super menuForEvent:theEvent];
|
||||
|
||||
var location = [self convertPoint:[theEvent locationInWindow] fromView:nil],
|
||||
index = [self _indexAtPoint:location];
|
||||
|
||||
return [_delegate collectionView:self menuForItemAtIndex:index];
|
||||
return [self _sendDelegateMenuForItemAtIndex:index];
|
||||
}
|
||||
|
||||
- (int)_indexAtPoint:(CGPoint)thePoint
|
||||
@@ -888,12 +961,12 @@ var HORIZONTAL_MARGIN = 2;
|
||||
return CPNotFound;
|
||||
}
|
||||
|
||||
- (CPCollectionViewItem)itemAtIndex:(unsigned)anIndex
|
||||
- (CPCollectionViewItem)itemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
return [_items objectAtIndex:anIndex];
|
||||
}
|
||||
|
||||
- (CGRect)frameForItemAtIndex:(unsigned)anIndex
|
||||
- (CGRect)frameForItemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
return [[[self itemAtIndex:anIndex] view] frame];
|
||||
}
|
||||
@@ -928,7 +1001,7 @@ var HORIZONTAL_MARGIN = 2;
|
||||
*/
|
||||
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
|
||||
{
|
||||
[aPasteboard setData:[_delegate collectionView:self dataForItemsAtIndexes:_selectionIndexes forType:aType] forType:aType];
|
||||
[aPasteboard setData:[self _sendDelegateDataForItemsAtIndexes:_selectionIndexes forType:aType] forType:aType];
|
||||
}
|
||||
|
||||
- (void)_createDropIndicatorIfNeeded
|
||||
@@ -958,24 +1031,23 @@ var HORIZONTAL_MARGIN = 2;
|
||||
(ABS(locationInWindow.y - mouseDownLocationInWindow.y) < 3))
|
||||
return;
|
||||
|
||||
if (![_delegate respondsToSelector:@selector(collectionView:dragTypesForItemsAtIndexes:)])
|
||||
if (![self _delegateRespondsToCollectionViewDragTypesForItemsAtIndexes])
|
||||
return;
|
||||
|
||||
// If we don't have any selected items, we've clicked away, and thus the drag is meaningless.
|
||||
if (![_selectionIndexes count])
|
||||
return;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)] &&
|
||||
![_delegate collectionView:self canDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
|
||||
if (![self _sendDelegateCanDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
|
||||
return;
|
||||
|
||||
// Set up the pasteboard
|
||||
var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes];
|
||||
var dragTypes = [self _sendDelegateDragTypesForItemsAtIndexes:_selectionIndexes];
|
||||
|
||||
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:dragTypes owner:self];
|
||||
|
||||
var dragImageOffset = CGSizeMakeZero(),
|
||||
view = [self _draggingViewForItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent offset:dragImageOffset];
|
||||
view = [self _sendDelegateDraggingViewForItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent offset:dragImageOffset];
|
||||
|
||||
[view setFrameSize:_itemSize];
|
||||
[view setAlphaValue:0.7];
|
||||
@@ -992,14 +1064,6 @@ var HORIZONTAL_MARGIN = 2;
|
||||
slideBack:YES];
|
||||
}
|
||||
|
||||
- (CPView)_draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent offset:(CGPoint)offset
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:draggingViewForItemsAtIndexes:withEvent:offset:)])
|
||||
return [_delegate collectionView:self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:offset];
|
||||
|
||||
return [self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:offset];
|
||||
}
|
||||
|
||||
- (CPView)draggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)event offset:(CGPoint)dragImageOffset
|
||||
{
|
||||
var idx = _content[[indexes firstIndex]];
|
||||
@@ -1012,14 +1076,6 @@ var HORIZONTAL_MARGIN = 2;
|
||||
return [_itemForDragging view];
|
||||
}
|
||||
|
||||
- (BOOL)_canDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent
|
||||
{
|
||||
if ([self respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)])
|
||||
return [_delegate collectionView:self canDragItemsAtIndexes:indexes withEvent:anEvent];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPDragOperation)draggingEntered:(id)draggingInfo
|
||||
{
|
||||
var dropIndex = -1,
|
||||
@@ -1057,16 +1113,14 @@ var HORIZONTAL_MARGIN = 2;
|
||||
var result = CPDragOperationMove,
|
||||
dropIndex = [self _dropIndexForDraggingInfo:draggingInfo proposedDropOperation:dropOperation];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(collectionView:validateDrop:proposedIndex:dropOperation:)])
|
||||
if ([self _delegateRespondsToCollectionViewValidateDropProposedIndexDropOperation])
|
||||
{
|
||||
var dropIndexRef2 = @ref(dropIndex);
|
||||
|
||||
result = [_delegate collectionView:self validateDrop:draggingInfo proposedIndex:dropIndexRef2 dropOperation:dropOperation];
|
||||
result = [self _sendDelegateValidateDrop:draggingInfo proposedIndex:dropIndexRef2 dropOperation:dropOperation];
|
||||
|
||||
if (result !== CPDragOperationNone)
|
||||
{
|
||||
dropIndex = dropIndexRef2();
|
||||
}
|
||||
}
|
||||
|
||||
dropIndexRef(dropIndex);
|
||||
@@ -1100,7 +1154,7 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
var result = NO;
|
||||
|
||||
if (_currentDragOperation && _currentDropIndex !== -1)
|
||||
result = [_delegate collectionView:self acceptDrop:draggingInfo index:_currentDropIndex dropOperation:1];
|
||||
result = [self _sendDelegateAcceptDrop:draggingInfo index:_currentDropIndex dropOperation:1];
|
||||
|
||||
[self draggingEnded:draggingInfo]; // Is this correct ?
|
||||
|
||||
@@ -1318,13 +1372,14 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
[self interpretKeyEvents:[anEvent]];
|
||||
}
|
||||
|
||||
- (void)setAutoresizingMask:(int)aMask
|
||||
- (void)setAutoresizingMask:(unsigned)aMask
|
||||
{
|
||||
[super setAutoresizingMask:0];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPCollectionView (Deprecated)
|
||||
|
||||
- (CGRect)rectForItemAtIndex:(int)anIndex
|
||||
@@ -1345,6 +1400,159 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype:
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPCollectionView (CPCollectionViewDelegate)
|
||||
|
||||
/*
|
||||
@ignore
|
||||
Return YES if the delegate implements collectionView:validateDrop:proposedIndex:dropOperation:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToCollectionViewValidateDropProposedIndexDropOperation
|
||||
{
|
||||
return _implementedDelegateMethods & CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_;
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
Return YES if the delegate implements collectionView:menuForItemAtIndex:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToCollectionViewMenuForItemAtIndex
|
||||
{
|
||||
return _implementedDelegateMethods & CPCollectionViewDelegate_collectionView_menuForItemAtIndex_;
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
Return YES if the delegate implements collectionView:dragTypesForItemsAtIndexes:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToCollectionViewDragTypesForItemsAtIndexes
|
||||
{
|
||||
return _implementedDelegateMethods & CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:acceptDrop:index:dropOperation:
|
||||
*/
|
||||
- (BOOL)_sendDelegateAcceptDrop:(id)draggingInfo index:(CPInteger)index dropOperation:(CPCollectionViewDropOperation)dropOperation
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_))
|
||||
return NO;
|
||||
|
||||
return [_delegate collectionView:self acceptDrop:draggingInfo index:index dropOperation:dropOperation];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:canDragItemsAtIndexes:withEvent:
|
||||
*/
|
||||
- (BOOL)_sendDelegateCanDragItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_))
|
||||
return YES;
|
||||
|
||||
return [_delegate collectionView:self canDragItemsAtIndexes:indexes withEvent:anEvent];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:writeItemsAtIndexes:toPasteboard:
|
||||
*/
|
||||
- (BOOL)_sendDelegateWriteItemsAtIndexes:(CPIndexSet)indexes toPasteboard:(CPPasteboard)pasteboard
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_writeItemsAtIndexes_toPasteboard_))
|
||||
return NO;
|
||||
|
||||
return [_delegate collectionView:self writeItemsAtIndexes:indexes toPasteboard:pasteboard];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:dragTypesForItemsAtIndexes:
|
||||
*/
|
||||
- (CPArray)_sendDelegateDragTypesForItemsAtIndexes:(CPIndexSet)indexes
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_dragTypesForItemsAtIndexes_))
|
||||
return [];
|
||||
|
||||
return [_delegate collectionView:self dragTypesForItemsAtIndexes:indexes];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:dataForItemsAtIndexes:forType:
|
||||
*/
|
||||
- (CPData)_sendDelegateDataForItemsAtIndexes:(CPIndexSet)indexes forType:(CPString)aType
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_dataForItemsAtIndexes_forType_))
|
||||
return nil;
|
||||
|
||||
return [_delegate collectionView:self dataForItemsAtIndexes:indexes forType:aType];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:validateDrop:proposedIndex:dropOperation:
|
||||
*/
|
||||
- (CPDragOperation)_sendDelegateValidateDrop:(id)draggingInfo proposedIndex:(CPInteger)proposedDropIndex dropOperation:(CPCollectionViewDropOperation)proposedDropOperation
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_validateDrop_proposedIndex_dropOperation_))
|
||||
return CPDragOperationNone;
|
||||
|
||||
return [_delegate collectionView:self validateDrop:draggingInfo proposedIndex:proposedDropIndex dropOperation:proposedDropOperation];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:didDoubleClickOnItemAtIndex:
|
||||
*/
|
||||
- (void)_sendDelegateDidDoubleClickOnItemAtIndex:(int)index
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_didDoubleClickOnItemAtIndex_))
|
||||
return;
|
||||
|
||||
return [_delegate collectionView:self didDoubleClickOnItemAtIndex:index];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionViewDidChangeSelection
|
||||
*/
|
||||
- (void)_sendDelegateCollectionViewDidChangeSelection:(CPCollectionView)collectionView
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionViewDidChangeSelection_))
|
||||
return;
|
||||
|
||||
return [_delegate collectionViewDidChangeSelection:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate collectionView:menuForItemAtIndex:
|
||||
*/
|
||||
- (void)_sendDelegateMenuForItemAtIndex:(CPInteger)anIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_menuForItemAtIndex_))
|
||||
return nil;
|
||||
|
||||
return [_delegate collectionView:self menuForItemAtIndex:anIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate draggingViewForItemsAtIndexes:withEvent:offset:
|
||||
*/
|
||||
- (CPView)_sendDelegateDraggingViewForItemsAtIndexes:(CPIndexSet)indexes withEvent:(CPEvent)anEvent offset:(CGPoint)dragImageOffset
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPCollectionViewDelegate_collectionView_draggingViewForItemsAtIndexes_withEvent_offset))
|
||||
return [self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:dragImageOffset];
|
||||
|
||||
return [_delegate collectionView:self draggingViewForItemsAtIndexes:indexes withEvent:anEvent offset:dragImageOffset];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
||||
CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey",
|
||||
CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey",
|
||||
|
||||
+93
-20
@@ -156,11 +156,15 @@ var cachedBlackColor,
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a new color in HSB space.
|
||||
Creates a new color based on the given HSB components.
|
||||
|
||||
@param hue the hue value
|
||||
@param saturation the saturation value
|
||||
@param brightness the brightness value
|
||||
Note: earlier versions of this method took a hue component as degrees between 0-360,
|
||||
and saturation and brightness components as percent between 0-100. This method has
|
||||
now been corrected to take all components in the 0-1 range as in Cocoa.
|
||||
|
||||
@param hue the hue component (0.0-1.0)
|
||||
@param saturation the saturation component (0.0-1.0)
|
||||
@param brightness the brightness component (0.0-1.0)
|
||||
|
||||
@return the initialized color
|
||||
*/
|
||||
@@ -169,25 +173,61 @@ var cachedBlackColor,
|
||||
return [self colorWithHue:hue saturation:saturation brightness:brightness alpha:1.0];
|
||||
}
|
||||
|
||||
/*!
|
||||
Calibrated colors are not supported in Cappuccino.
|
||||
|
||||
This method has the same result as [CPColor colorWithHue:saturation:brightness:alpha:].
|
||||
*/
|
||||
+ (CPColor)colorWithCalibratedHue:(float)hue saturation:(float)saturation brightness:(float)brightness alpha:(float)alpha
|
||||
{
|
||||
return [self colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha];
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a new color based on the given HSB components.
|
||||
|
||||
Note: earlier versions of this method took a hue component as degrees between 0-360,
|
||||
and saturation and brightness components as percent between 0-100. This method has
|
||||
now been corrected to take all components in the 0-1 range as in Cocoa.
|
||||
|
||||
@param hue the hue component (0.0-1.0)
|
||||
@param saturation the saturation component (0.0-1.0)
|
||||
@param brightness the brightness component (0.0-1.0)
|
||||
@param alpha the opacity component (0.0-1.0)
|
||||
|
||||
@return the initialized color
|
||||
*/
|
||||
+ (CPColor)colorWithHue:(float)hue saturation:(float)saturation brightness:(float)brightness alpha:(float)alpha
|
||||
{
|
||||
// Clamp values.
|
||||
hue = MAX(MIN(hue, 1.0), 0.0);
|
||||
saturation = MAX(MIN(saturation, 1.0), 0.0);
|
||||
brightness = MAX(MIN(brightness, 1.0), 0.0);
|
||||
|
||||
if (saturation === 0.0)
|
||||
return [CPColor colorWithCalibratedWhite:brightness / 100.0 alpha:alpha];
|
||||
return [CPColor colorWithCalibratedWhite:brightness alpha:alpha];
|
||||
|
||||
var f = hue % 60,
|
||||
p = (brightness * (100 - saturation)) / 10000,
|
||||
q = (brightness * (6000 - saturation * f)) / 600000,
|
||||
t = (brightness * (6000 - saturation * (60 -f))) / 600000,
|
||||
b = brightness / 100.0;
|
||||
var f = (hue * 360) % 60,
|
||||
p = (brightness * (1 - saturation)),
|
||||
q = (brightness * (60 - saturation * f)) / 60,
|
||||
t = (brightness * (60 - saturation * (60 - f))) / 60,
|
||||
b = brightness;
|
||||
|
||||
switch (FLOOR(hue / 60))
|
||||
switch (FLOOR(hue * 6))
|
||||
{
|
||||
case 0: return [CPColor colorWithCalibratedRed:b green:t blue:p alpha:alpha];
|
||||
case 1: return [CPColor colorWithCalibratedRed:q green:b blue:p alpha:alpha];
|
||||
case 2: return [CPColor colorWithCalibratedRed:p green:b blue:t alpha:alpha];
|
||||
case 3: return [CPColor colorWithCalibratedRed:p green:q blue:b alpha:alpha];
|
||||
case 4: return [CPColor colorWithCalibratedRed:t green:p blue:b alpha:alpha];
|
||||
case 5: return [CPColor colorWithCalibratedRed:b green:p blue:q alpha:alpha];
|
||||
case 0:
|
||||
case 6:
|
||||
return [CPColor colorWithCalibratedRed:b green:t blue:p alpha:alpha];
|
||||
case 1:
|
||||
return [CPColor colorWithCalibratedRed:q green:b blue:p alpha:alpha];
|
||||
case 2:
|
||||
return [CPColor colorWithCalibratedRed:p green:b blue:t alpha:alpha];
|
||||
case 3:
|
||||
return [CPColor colorWithCalibratedRed:p green:q blue:b alpha:alpha];
|
||||
case 4:
|
||||
return [CPColor colorWithCalibratedRed:t green:p blue:b alpha:alpha];
|
||||
case 5:
|
||||
return [CPColor colorWithCalibratedRed:b green:p blue:q alpha:alpha];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,6 +615,9 @@ var cachedBlackColor,
|
||||
|
||||
/*!
|
||||
Returns an array with the HSB values for this color.
|
||||
|
||||
The values are expressed as fractions between 0.0-1.0.
|
||||
|
||||
The index values are ordered as:
|
||||
<pre>
|
||||
<b>Index</b> <b>Component</b>
|
||||
@@ -621,12 +664,36 @@ var cachedBlackColor,
|
||||
}
|
||||
|
||||
return [
|
||||
ROUND(hue * 360.0),
|
||||
ROUND(saturation * 100.0),
|
||||
ROUND(brightness * 100.0)
|
||||
hue,
|
||||
saturation,
|
||||
brightness
|
||||
];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the hue component, the H in HSB, of the receiver.
|
||||
*/
|
||||
- (float)hueComponent
|
||||
{
|
||||
return [self hsbComponents][0];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the saturation component, the S in HSB, of the receiver.
|
||||
*/
|
||||
- (float)saturationComponent
|
||||
{
|
||||
return [self hsbComponents][1];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the brightness component, the B in HSB, of the receiver.
|
||||
*/
|
||||
- (float)brightnessComponent
|
||||
{
|
||||
return [self hsbComponents][2];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the CSS representation of this color. The color will
|
||||
be in one of the following forms:
|
||||
@@ -746,6 +813,12 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
return [CPColor colorWithRed:RAND() green:RAND() blue:RAND() alpha:1.0];
|
||||
}
|
||||
|
||||
+ (CPColor)checkerBoardColor
|
||||
{
|
||||
// Thanks to cocco http://stackoverflow.com/a/18368212/76900.
|
||||
return [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEX////MzMw46qqDAAAAEElEQVQImWNg+M+AFeEQBgB+vw/xfUUZkgAAAABJRU5ErkJggg=="]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/// @cond IGNORE
|
||||
|
||||
@@ -576,7 +576,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
[aPasteboard setData:[CPKeyedArchiver archivedDataWithRootObject:_dragColor] forType:aType];
|
||||
}
|
||||
|
||||
- (void)performDragOperation:(id <CPDraggingInfo>)aSender
|
||||
- (void)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
|
||||
{
|
||||
var location = [self convertPoint:[aSender draggingLocation] fromView:nil],
|
||||
pasteboard = [aSender draggingPasteboard],
|
||||
@@ -615,7 +615,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
|
||||
return _colorPanel;
|
||||
}
|
||||
|
||||
- (void)performDragOperation:(id <CPDraggingInfo>)aSender
|
||||
- (void)performDragOperation:(id /*<CPDraggingInfo>*/)aSender
|
||||
{
|
||||
var pasteboard = [aSender draggingPasteboard];
|
||||
|
||||
|
||||
@@ -158,12 +158,12 @@
|
||||
brightness = [_brightnessSlider floatValue];
|
||||
|
||||
[_hueSaturationView setWheelBrightness:brightness / 100.0];
|
||||
[_brightnessSlider setBackgroundColor:[CPColor colorWithHue:hue saturation:saturation brightness:100]];
|
||||
[_brightnessSlider setBackgroundColor:[CPColor colorWithHue:hue / 360.0 saturation:saturation / 100.0 brightness:1]];
|
||||
|
||||
var colorPanel = [self colorPanel],
|
||||
opacity = [colorPanel opacity];
|
||||
|
||||
_cachedColor = [CPColor colorWithHue:hue saturation:saturation brightness:brightness alpha:opacity];
|
||||
_cachedColor = [CPColor colorWithHue:hue / 360.0 saturation:saturation / 100.0 brightness:brightness / 100.0 alpha:opacity];
|
||||
|
||||
[[self colorPanel] setColor:_cachedColor];
|
||||
}
|
||||
@@ -194,10 +194,10 @@
|
||||
var hsb = [newColor hsbComponents];
|
||||
|
||||
[_hueSaturationView setPositionToColor:newColor];
|
||||
[_brightnessSlider setFloatValue:hsb[2]];
|
||||
[_hueSaturationView setWheelBrightness:hsb[2] / 100.0];
|
||||
[_brightnessSlider setFloatValue:hsb[2] * 100.0];
|
||||
[_hueSaturationView setWheelBrightness:hsb[2]];
|
||||
|
||||
[_brightnessSlider setBackgroundColor:[CPColor colorWithHue:hsb[0] saturation:hsb[1] brightness:100]];
|
||||
[_brightnessSlider setBackgroundColor:[CPColor colorWithHue:hsb[0] saturation:hsb[1] brightness:1]];
|
||||
}
|
||||
|
||||
- (CPImage)provideNewButtonImage
|
||||
@@ -366,8 +366,8 @@
|
||||
{
|
||||
var hsb = [aColor hsbComponents],
|
||||
bounds = [self bounds],
|
||||
angle = [self degreesToRadians:hsb[0]],
|
||||
distance = (hsb[1] / 100.0) * _radius;
|
||||
angle = [self degreesToRadians:hsb[0] * 360.0],
|
||||
distance = hsb[1] * _radius;
|
||||
|
||||
[self setAngle:angle distance:distance];
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
return @"colorwell";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-inset": CGInsetMakeZero(),
|
||||
|
||||
+17
-5
@@ -25,6 +25,18 @@
|
||||
@import "_CPPopUpList.j"
|
||||
|
||||
|
||||
// TODO : should conform to protocol CPTextFieldDelegate
|
||||
@protocol CPComboBoxDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (void)comboBoxSelectionIsChanging:(CPNotification)aNotification;
|
||||
- (void)comboBoxSelectionDidChange:(CPNotification)aNotification;
|
||||
- (void)comboBoxWillPopUp:(CPNotification)aNotification;
|
||||
- (void)comboBoxWillDismiss:(CPNotification)aNotification;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
CPComboBoxSelectionDidChangeNotification = @"CPComboBoxSelectionDidChangeNotification";
|
||||
CPComboBoxSelectionIsChangingNotification = @"CPComboBoxSelectionIsChangingNotification";
|
||||
CPComboBoxWillDismissNotification = @"CPComboBoxWillDismissNotification";
|
||||
@@ -58,7 +70,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
return "combobox";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"popup-button-size": CGSizeMake(21.0, 29.0),
|
||||
@@ -171,7 +183,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
|
||||
#pragma mark Setting a Delegate
|
||||
|
||||
- (id < CPComboBoxDelegate >)delegate
|
||||
- (id /*< CPComboBoxDelegate >*/)delegate
|
||||
{
|
||||
return [super delegate];
|
||||
}
|
||||
@@ -182,7 +194,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
protocol, in actual fact it doesn't. Also note that the same
|
||||
delegate may conform to the NSTextFieldDelegate protocol.
|
||||
*/
|
||||
- (void)setDelegate:(id < CPComboBoxDelegate >)aDelegate
|
||||
- (void)setDelegate:(id <CPComboBoxDelegate>)aDelegate
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
|
||||
@@ -231,7 +243,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
|
||||
#pragma mark Setting a Data Source
|
||||
|
||||
- (id < CPComboBoxDataSource >)dataSource
|
||||
- (id /*< CPComboBoxDataSource >*/)dataSource
|
||||
{
|
||||
if (!_usesDataSource)
|
||||
[self _dataSourceWarningForMethod:_cmd condition:NO];
|
||||
@@ -239,7 +251,7 @@ var CPComboBoxTextSubview = @"text",
|
||||
return _dataSource;
|
||||
}
|
||||
|
||||
- (void)setDataSource:(id < CPComboBoxDataSource >)aSource
|
||||
- (void)setDataSource:(id /*< CPComboBoxDataSource >*/)aSource
|
||||
{
|
||||
if (!_usesDataSource)
|
||||
[self _dataSourceWarningForMethod:_cmd condition:NO];
|
||||
|
||||
@@ -46,7 +46,9 @@ CPHTMLDragAndDropFeature = 8;
|
||||
|
||||
CPJavaScriptInnerTextFeature = 9;
|
||||
CPJavaScriptTextContentFeature = 10;
|
||||
// In onpaste, oncopy and oncut events, the event has an event.clipboardData from which the current pasteboard contents can be read with event.clipboardData.getData.
|
||||
CPJavaScriptClipboardEventsFeature = 11;
|
||||
// window.clipboardData exists and can be read and written to at any time using window.clipboardData.getData/setData.
|
||||
CPJavaScriptClipboardAccessFeature = 12;
|
||||
CPJavaScriptCanvasDrawFeature = 13;
|
||||
CPJavaScriptCanvasTransformFeature = 14;
|
||||
@@ -76,11 +78,19 @@ CPInputOnInputEventFeature = 30;
|
||||
|
||||
CPFileAPIFeature = 31;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
When an absolutely positioned div (CPView) with an absolutely positioned canvas in it (CPView with drawRect:) moves things on top of the canvas (subviews) don't redraw correctly. E.g. if you have a bunch of text fields in a CPBox in a sheet which animates in, some of the text fields might not be visible because the CPBox has a canvas at the bottom and the box moved form offscreen to onscreen. This bug is probably very related: https://bugs.webkit.org/show_bug.cgi?id=67203
|
||||
*/
|
||||
CPCanvasParentDrawErrorsOnMovementBug = 1 << 0;
|
||||
|
||||
// The paste event is only sent if an input or textarea has focus.
|
||||
CPJavaScriptPasteRequiresEditableTarget = 1 << 1;
|
||||
// Redirecting the focus of the browser on keydown to an input for Cmd-V or Ctrl-V makes the paste fail.
|
||||
CPJavaScriptPasteCantRefocus = 1 << 2;
|
||||
|
||||
|
||||
var USER_AGENT = "",
|
||||
PLATFORM_ENGINE = CPUnknownBrowserEngine,
|
||||
PLATFORM_FEATURES = [],
|
||||
@@ -118,6 +128,9 @@ else if (typeof window !== "undefined" && window.attachEvent) // Must follow Ope
|
||||
|
||||
// Tested in Internet Explore 8 and 9.
|
||||
PLATFORM_FEATURES[CPInputSetFontOutsideOfDOM] = NO;
|
||||
|
||||
// IE allows free clipboard access.
|
||||
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = YES;
|
||||
}
|
||||
|
||||
// WebKit
|
||||
@@ -129,11 +142,8 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
|
||||
PLATFORM_FEATURES[CPCSSRGBAFeature] = YES;
|
||||
PLATFORM_FEATURES[CPHTMLContentEditableFeature] = YES;
|
||||
|
||||
if (USER_AGENT.indexOf("Chrome") === -1)
|
||||
PLATFORM_FEATURES[CPHTMLDragAndDropFeature] = YES;
|
||||
|
||||
PLATFORM_FEATURES[CPJavaScriptClipboardEventsFeature] = YES;
|
||||
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = YES;
|
||||
PLATFORM_FEATURES[CPJavaScriptClipboardAccessFeature] = NO;
|
||||
PLATFORM_FEATURES[CPJavaScriptShadowFeature] = YES;
|
||||
|
||||
var versionStart = USER_AGENT.indexOf("AppleWebKit/") + "AppleWebKit/".length,
|
||||
@@ -159,7 +169,14 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
|
||||
PLATFORM_FEATURES[CPInput1PxLeftPadding] = YES;
|
||||
|
||||
if (USER_AGENT.indexOf("Chrome") === CPNotFound)
|
||||
{
|
||||
PLATFORM_FEATURES[CPSOPDisabledFromFileURLs] = YES;
|
||||
PLATFORM_FEATURES[CPHTMLDragAndDropFeature] = YES;
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=75891
|
||||
PLATFORM_BUGS |= CPJavaScriptPasteRequiresEditableTarget;
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=39689
|
||||
PLATFORM_BUGS |= CPJavaScriptPasteCantRefocus;
|
||||
}
|
||||
|
||||
// Assume this bug was introduced around Safari 5.1/Chrome 16. This could probably be tighter.
|
||||
if (majorVersion > 533)
|
||||
@@ -190,6 +207,17 @@ 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;
|
||||
|
||||
// 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.
|
||||
/*if (version >= 22.0)
|
||||
{
|
||||
PLATFORM_FEATURES[CPJavaScriptClipboardEventsFeature] = YES;
|
||||
// TODO File a bug at https://bugzilla.mozilla.org/. In other browsers, one can return "false" from the
|
||||
// beforepaste event to indicate a paste should be enabled even that the DOMEvent.target is not editable.
|
||||
PLATFORM_BUGS |= CPJavaScriptPasteRequiresEditableTarget;
|
||||
}*/
|
||||
}
|
||||
|
||||
// Feature-specific checks
|
||||
@@ -323,6 +351,20 @@ function CPBrowserStyleProperty(aProperty)
|
||||
|
||||
r = candidates[PLATFORM_STYLE_JS_PROPERTIES['transition']] || nil;
|
||||
break;
|
||||
|
||||
case 'transformorigin':
|
||||
|
||||
var candidates = {
|
||||
'WebkitTransform' : 'WebkitTransformOrigin',
|
||||
'MozTransform' : 'MozTransformOrigin',
|
||||
'OTransform' : 'OTransformOrigin',
|
||||
'msTransform' : 'MSTransformOrigin',
|
||||
'transform' : 'transformOrigin'
|
||||
};
|
||||
|
||||
r = candidates[PLATFORM_STYLE_JS_PROPERTIES['transform']] || nil;
|
||||
break;
|
||||
|
||||
default:
|
||||
var prefixes = ["Webkit", "Moz", "O", "ms"],
|
||||
strippedProperty = aProperty.split('-').join(' '),
|
||||
|
||||
+61
-7
@@ -30,6 +30,18 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
@protocol CPControlTextEditingDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (void)controlTextDidBeginEditing:(CPNotification)aNotification;
|
||||
- (void)controlTextDidChange:(CPNotification)aNotification;
|
||||
- (void)controlTextDidEndEditing:(CPNotification)aNotification;
|
||||
- (void)controlTextDidFocus:(CPNotification)aNotification;
|
||||
- (void)controlTextDidBlur:(CPNotification)aNotification;
|
||||
- (BOOL)control:(CPControl)control didFailToFormatString:(CPString)string errorDescription:(CPString)error;
|
||||
|
||||
@end
|
||||
|
||||
CPLeftTextAlignment = 0;
|
||||
CPRightTextAlignment = 1;
|
||||
CPCenterTextAlignment = 2;
|
||||
@@ -322,11 +334,11 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
_previousTrackingLocation = currentLocation;
|
||||
}
|
||||
|
||||
- (void)setState:(int)state
|
||||
- (void)setState:(CPInteger)state
|
||||
{
|
||||
}
|
||||
|
||||
- (int)nextState
|
||||
- (CPInteger)nextState
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -530,7 +542,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
return formattedValue;
|
||||
}
|
||||
|
||||
return (_value === undefined || _value === nil) ? "" : String(_value);
|
||||
return (_value === undefined || _value === nil) ? @"" : String(_value);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -607,7 +619,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
if ([note object] != self)
|
||||
return;
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidBeginEditingNotification object:self userInfo:@{ "CPFieldEditor": [note object] }];
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidBeginEditingNotification object:self userInfo:@{"CPFieldEditor": [note object]}];
|
||||
}
|
||||
|
||||
- (void)textDidChange:(CPNotification)note
|
||||
@@ -616,7 +628,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
if ([note object] != self)
|
||||
return;
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidChangeNotification object:self userInfo:@{ "CPFieldEditor": [note object] }];
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidChangeNotification object:self userInfo:@{"CPFieldEditor": [note object]}];
|
||||
}
|
||||
|
||||
- (void)textDidEndEditing:(CPNotification)note
|
||||
@@ -627,7 +639,49 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
|
||||
[self _reverseSetBinding];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidEndEditingNotification object:self userInfo:@{ "CPFieldEditor": [note object] }];
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidEndEditingNotification object:self userInfo:[note userInfo]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Return the currentTextMovement needed by the delegate textDidEndEditing
|
||||
This is going to check the currentEvent of the CPApp
|
||||
*/
|
||||
- (unsigned)_currentTextMovement
|
||||
{
|
||||
var currentEvent = [CPApp currentEvent],
|
||||
keyCode = [currentEvent keyCode],
|
||||
modifierFlags = [currentEvent modifierFlags];
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case CPEscapeKeyCode:
|
||||
return CPCancelTextMovement;
|
||||
|
||||
case CPLeftArrowKeyCode:
|
||||
return CPLeftTextMovement;
|
||||
|
||||
case CPRightArrowKeyCode:
|
||||
return CPRightTextMovement;
|
||||
|
||||
case CPUpArrowKeyCode:
|
||||
return CPUpTextMovement;
|
||||
|
||||
case CPDownArrowKeyCode:
|
||||
return CPDownTextMovement;
|
||||
|
||||
case CPReturnKeyCode:
|
||||
return CPReturnTextMovement;
|
||||
|
||||
case CPTabKeyCode:
|
||||
if (modifierFlags & CPShiftKeyMask)
|
||||
return CPBacktabTextMovement;
|
||||
|
||||
return CPTabTextMovement;
|
||||
|
||||
default:
|
||||
return CPOtherTextMovement;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -813,7 +867,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
/*!
|
||||
Returns the image scaling of the control.
|
||||
*/
|
||||
- (CPImageScaling)imageScaling
|
||||
- (CPUInteger)imageScaling
|
||||
{
|
||||
return [self valueForThemeAttribute:@"image-scaling"];
|
||||
}
|
||||
|
||||
+2
-1
@@ -116,7 +116,8 @@ var currentCursor = nil,
|
||||
|
||||
- (void)push
|
||||
{
|
||||
currentCursor = cursorStack.push(self);
|
||||
cursorStack.push(self);
|
||||
currentCursor = self;
|
||||
}
|
||||
|
||||
- (void)set
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
@import <Foundation/CPDate.j>
|
||||
@import <Foundation/CPDateFormatter.j>
|
||||
@import <Foundation/CPLocale.j>
|
||||
@import <Foundation/CPTimeZone.j>
|
||||
|
||||
@class CPStepper
|
||||
@class CPApp
|
||||
@@ -68,10 +69,9 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
CPFont _textFont @accessors(property=textFont);
|
||||
CPLocale _locale @accessors(property=locale);
|
||||
//CPCalendar _calendar @accessors(property=calendar);
|
||||
//CPTimeZone _timeZone @accessors(property=timeZone);
|
||||
CPDateFormatter _formatter @accessors(property=formatter);
|
||||
CPTimeZone _timeZone @accessors(property=timeZone);
|
||||
id _delegate @accessors(property=delegate);
|
||||
unsigned _datePickerElements @accessors(property=datePickerElements);
|
||||
CPInteger _datePickerElements @accessors(property=datePickerElements);
|
||||
CPInteger _datePickerMode @accessors(property=datePickerMode);
|
||||
CPInteger _datePickerStyle @accessors(property=datePickerStyle);
|
||||
CPInteger _timeInterval @accessors(property=timeInterval);
|
||||
@@ -90,7 +90,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
return @"datePicker";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-color": [CPColor clearColor],
|
||||
@@ -135,10 +135,10 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
@"clock-text-shadow-color": [CPColor clearColor],
|
||||
@"clock-text-shadow-offset": CGSizeMakeZero(),
|
||||
@"clock-font": [CPNull null],
|
||||
@"second-hand-color": [CPColor clearColor],
|
||||
@"hour-hand-color": [CPColor clearColor],
|
||||
@"middle-hand-color": [CPColor clearColor],
|
||||
@"minute-hand-color": [CPColor clearColor],
|
||||
@"second-hand-image": [CPNull null],
|
||||
@"hour-hand-image": [CPNull null],
|
||||
@"middle-hand-image": [CPNull null],
|
||||
@"minute-hand-image": [CPNull null],
|
||||
@"size-clock": CGSizeMakeZero(),
|
||||
@"second-hand-size": CGSizeMakeZero(),
|
||||
@"hour-hand-size": CGSizeMakeZero(),
|
||||
@@ -159,7 +159,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
return [super _binderClassForBinding:theBinding];
|
||||
}
|
||||
|
||||
- (id)_replacementKeyPathForBinding:(CPString)aBinding
|
||||
- (CPString)_replacementKeyPathForBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding == CPValueBinding)
|
||||
return @"dateValue";
|
||||
@@ -187,7 +187,6 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
_datePickerElements = CPYearMonthDayDatePickerElementFlag | CPHourMinuteSecondDatePickerElementFlag;
|
||||
_timeInterval = 0;
|
||||
_implementedCDatePickerDelegateMethods = 0;
|
||||
_formatter = [[CPDateFormatter alloc] init];
|
||||
|
||||
[self setObjectValue:[CPDate date]];
|
||||
_minDate = [CPDate distantPast];
|
||||
@@ -265,18 +264,12 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
#pragma mark -
|
||||
#pragma mark Setter
|
||||
|
||||
/*! Return the objectValue of the datePicker. The objectValue is made with the current formatter of the datePicker
|
||||
/*! Return the objectValue of the datePicker. The objectValue should take the timeZoneEffect
|
||||
*/
|
||||
- (void)objectValue
|
||||
- (id)objectValue
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// return [_formatter stringFromDate:_dateValue];
|
||||
// }
|
||||
// catch(e)
|
||||
// {
|
||||
return _dateValue
|
||||
// }
|
||||
// TODO : add timeZone effect. How to do it because js ???
|
||||
return _dateValue
|
||||
}
|
||||
|
||||
/*! Set the objectValue ofhe datePier. It has to be a CPDate
|
||||
@@ -313,7 +306,14 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
aTimeInterval = MAX(MIN(aTimeInterval, [_maxDate timeIntervalSinceDate:aDateValue]), [_minDate timeIntervalSinceDate:aDateValue]);
|
||||
|
||||
if ([aDateValue isEqualToDate:_dateValue] && aTimeInterval == _timeInterval)
|
||||
{
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
else
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_implementedCDatePickerDelegateMethods & CPDatePicker_validateProposedDateValue_timeInterval)
|
||||
{
|
||||
@@ -328,8 +328,8 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
[self willChangeValueForKey:@"dateValue"];
|
||||
_dateValue = aDateValue;
|
||||
[super setObjectValue:_dateValue];
|
||||
[self didChangeValueForKey:@"dateValue"];
|
||||
[self didChangeValueForKey:@"objectValue"];
|
||||
[self didChangeValueForKey:@"dateValue"];
|
||||
|
||||
[self willChangeValueForKey:@"timeInterval"];
|
||||
_timeInterval = (_datePickerMode == CPSingleDateMode)? 0 : aTimeInterval;
|
||||
@@ -370,7 +370,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
/*! Set the syle of the datePicker
|
||||
@param aDatePickerStyle the datePicker style
|
||||
*/
|
||||
- (void)setDatePickerStyle:(CPDate)aDatePickerStyle
|
||||
- (void)setDatePickerStyle:(CPInteger)aDatePickerStyle
|
||||
{
|
||||
_datePickerStyle = aDatePickerStyle;
|
||||
|
||||
@@ -381,7 +381,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
/*! Set the elements of the datePicker
|
||||
@param aDatePickerElements the datePicker elements
|
||||
*/
|
||||
- (void)setDatePickerElements:(CPDate)aDatePickerElements
|
||||
- (void)setDatePickerElements:(CPInteger)aDatePickerElements
|
||||
{
|
||||
_datePickerElements = aDatePickerElements;
|
||||
|
||||
@@ -392,7 +392,7 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
/*! Set the mode of the datePicker
|
||||
@param aDatePickerMode the datePicker mode
|
||||
*/
|
||||
- (void)setDatePickerMode:(CPDate)aDatePickerMode
|
||||
- (void)setDatePickerMode:(CPInteger)aDatePickerMode
|
||||
{
|
||||
_datePickerMode = aDatePickerMode;
|
||||
|
||||
@@ -503,6 +503,23 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
/*! Set the timeZone
|
||||
@param aTimeZone
|
||||
*/
|
||||
- (void)setTimeZone:(CPTimeZone)aTimeZone
|
||||
{
|
||||
[self willChangeValueForKey:@"timeZone"];
|
||||
_timeZone = aTimeZone;
|
||||
[self didChangeValueForKey:@"timeZone"];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
[_datePickerTextfield setDateValue:_dateValue];
|
||||
else
|
||||
[_datePickerCalendar setDateValue:_dateValue];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark First responder methods
|
||||
@@ -603,7 +620,6 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
CPDatePickerElementsKey = @"CPDatePickerElementsKey",
|
||||
CPDatePickerStyleKey = @"CPDatePickerStyleKey",
|
||||
CPLocaleKey = @"CPLocaleKey",
|
||||
CPFormatterKey = @"CPFormatterKey",
|
||||
CPBorderedKey = @"CPBorderedKey",
|
||||
CPDateValueKey = @"CPDateValueKey";
|
||||
|
||||
@@ -623,7 +639,6 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
_datePickerElements = [aCoder decodeIntForKey:CPDatePickerElementsKey];
|
||||
_datePickerStyle = [aCoder decodeIntForKey:CPDatePickerStyleKey];
|
||||
_locale = [aCoder decodeObjectForKey:CPLocaleKey];
|
||||
_formatter = [aCoder decodeObjectForKey:CPFormatterKey];
|
||||
_dateValue = [aCoder decodeObjectForKey:CPDateValueKey];
|
||||
_backgroundColor = [aCoder decodeObjectForKey:CPBackgroundColorKey];
|
||||
_drawsBackground = [aCoder decodeBoolForKey:CPDrawsBackgroundKey];
|
||||
@@ -646,7 +661,6 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
[aCoder encodeObject:_dateValue forKey:CPDateValueKey];;
|
||||
[aCoder encodeObject:_textFont forKey:CPTextFontKey];
|
||||
[aCoder encodeObject:_locale forKey:CPLocaleKey];
|
||||
[aCoder encodeObject:_formatter forKey:CPFormatterKey];
|
||||
[aCoder encodeObject:_backgroundColor forKey:CPBackgroundColorKey];
|
||||
[aCoder encodeObject:_drawsBackground forKey:CPDrawsBackgroundKey];
|
||||
[aCoder encodeObject:_isBordered forKey:CPBorderedKey];
|
||||
@@ -683,4 +697,4 @@ var CPDatePickerModeKey = @"CPDatePickerModeKey",
|
||||
self.setMilliseconds(99);
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
@class CPDatePicker
|
||||
|
||||
@global CPApp
|
||||
@global CPSingleDateMode
|
||||
@global CPRangeDateMode
|
||||
|
||||
@@ -43,6 +44,10 @@
|
||||
@global CPYearMonthDayDatePickerElementFlag
|
||||
@global CPEraDatePickerElementFlag
|
||||
|
||||
@global CPAlternateKeyMask
|
||||
@global CPCommandKeyMask
|
||||
@global CPControlKeyMask
|
||||
|
||||
var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"],
|
||||
CPShortWeekDayNameArrayUS = [@"Su", @"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa"],
|
||||
CPShortWeekDayNameArrayFr = [@"L", @"M", @"M", @"J", @"V", @"S", @"D"],
|
||||
@@ -132,7 +137,10 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
*/
|
||||
- (void)setDateValue:(CPDate)aDateValue
|
||||
{
|
||||
[_monthView setMonthForDate:aDateValue];
|
||||
var dateValue = [aDateValue copy];
|
||||
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
|
||||
|
||||
[_monthView setMonthForDate:dateValue];
|
||||
[_headerView setMonthForDate:[_monthView monthDate]];
|
||||
|
||||
[self setNeedsLayout];
|
||||
@@ -220,16 +228,62 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
|
||||
/*! Move to the nextMonth without changing the dateValue of the datePicker
|
||||
*/
|
||||
- (void)_nextMonth:(id)sender
|
||||
- (void)_clickArrowNext:(id)sender
|
||||
{
|
||||
[self setDateValue:[_monthView nextMonth]];
|
||||
var currentEvent = [CPApp currentEvent],
|
||||
modifierFlags = [currentEvent modifierFlags];
|
||||
|
||||
if (modifierFlags & (CPCommandKeyMask | CPControlKeyMask | CPAlternateKeyMask))
|
||||
{
|
||||
var date = [[_monthView monthDate] copy];
|
||||
date.setDate(1);
|
||||
|
||||
if (modifierFlags & CPAlternateKeyMask)
|
||||
date.setUTCFullYear(date.getUTCFullYear() + 10);
|
||||
else
|
||||
date.setUTCFullYear(date.getUTCFullYear() + 1);
|
||||
|
||||
[self setDateValue:date];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _displayNextMonth];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_displayNextMonth
|
||||
{
|
||||
[self setDateValue:[_monthView nextMonth]];
|
||||
}
|
||||
|
||||
- (void)_displayPreviousMonth
|
||||
{
|
||||
[self setDateValue:[_monthView previousMonth]];
|
||||
}
|
||||
|
||||
/*! Move to the previous month without changing the dateValue of the datePicker
|
||||
*/
|
||||
- (void)_previousMonth:(id)sender
|
||||
- (void)_clickArrowPrevious:(id)sender
|
||||
{
|
||||
[self setDateValue:[_monthView previousMonth]];
|
||||
var currentEvent = [CPApp currentEvent],
|
||||
modifierFlags = [currentEvent modifierFlags];
|
||||
|
||||
if (modifierFlags & (CPCommandKeyMask | CPControlKeyMask | CPAlternateKeyMask))
|
||||
{
|
||||
var date = [[_monthView monthDate] copy];
|
||||
date.setDate(1);
|
||||
|
||||
if (modifierFlags & CPAlternateKeyMask)
|
||||
date.setUTCFullYear(date.getUTCFullYear() - 10);
|
||||
else
|
||||
date.setUTCFullYear(date.getUTCFullYear() - 1);
|
||||
|
||||
[self setDateValue:date];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _displayPreviousMonth];
|
||||
}
|
||||
}
|
||||
|
||||
/*! Move to the current selected day
|
||||
@@ -331,10 +385,10 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
[self addSubview:_currentButton];
|
||||
|
||||
[_previousButton setTarget:aDelegate];
|
||||
[_previousButton setAction:@selector(_previousMonth:)];
|
||||
[_previousButton setAction:@selector(_clickArrowPrevious:)];
|
||||
|
||||
[_nextButton setTarget:aDelegate];
|
||||
[_nextButton setAction:@selector(_nextMonth:)];
|
||||
[_nextButton setAction:@selector(_clickArrowNext:)];
|
||||
|
||||
[_currentButton setTarget:aDelegate];
|
||||
[_currentButton setAction:@selector(_currentMonth:)];
|
||||
@@ -442,6 +496,9 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
return;
|
||||
|
||||
var bounds = [self bounds],
|
||||
dayNames = [self _dayNames],
|
||||
width = CGRectGetWidth(bounds),
|
||||
@@ -750,6 +807,9 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
return;
|
||||
|
||||
[super layoutSubviews];
|
||||
|
||||
[self tile];
|
||||
@@ -852,9 +912,9 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
{
|
||||
// Check the year and the month. The year is usefull when changing from Jan to Dec.
|
||||
if (_date.getMonth() - [dayTile date].getMonth() == 1 || _date.getFullYear() - [dayTile date].getFullYear() == 1)
|
||||
[_delegate _previousMonth:self];
|
||||
[_delegate _displayPreviousMonth];
|
||||
else
|
||||
[_delegate _nextMonth:self];
|
||||
[_delegate _displayNextMonth];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,9 +950,9 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
|
||||
// Check the year and the month. The year is usefull when changing from Jan to Dec.
|
||||
if (_date.getMonth() - [dayTile date].getMonth() == 1 || _date.getFullYear() - [dayTile date].getFullYear() == 1)
|
||||
[_delegate _previousMonth:self];
|
||||
[_delegate _displayPreviousMonth];
|
||||
else
|
||||
[_delegate _nextMonth:self];
|
||||
[_delegate _displayNextMonth];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -935,7 +995,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
if (_isMonthJustChanged)
|
||||
{
|
||||
_dragDate.setMonth(_date.getMonth() + 1);
|
||||
[_delegate _nextMonth:self];
|
||||
[_delegate _displayNextMonth];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,7 +1004,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
if (_isMonthJustChanged)
|
||||
{
|
||||
_dragDate.setMonth(_date.getMonth() - 1);
|
||||
[_delegate _previousMonth:self];
|
||||
[_delegate _displayPreviousMonth];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1011,30 +1071,30 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateDisabled] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled];
|
||||
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateDisabled | CPThemeStateSelected] forThemeAttribute:@"font" inState:CPThemeStateDisabled | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateDisabled | CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateDisabled | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateDisabled | CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateDisabled | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateDisabled | CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateDisabled | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:[CPThemeStateDisabled, CPThemeStateSelected]] forThemeAttribute:@"font" inState:[CPThemeStateDisabled, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:[CPThemeStateDisabled, CPThemeStateSelected]]forThemeAttribute:@"text-color" inState:[CPThemeStateDisabled, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:[CPThemeStateDisabled, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-color" inState:[CPThemeStateDisabled, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:[CPThemeStateDisabled, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-offset" inState:[CPThemeStateDisabled, CPThemeStateSelected]];
|
||||
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateHighlighted] forThemeAttribute:@"font" inState:CPThemeStateHighlighted];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateHighlighted] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateHighlighted] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateHighlighted];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateHighlighted] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateHighlighted];
|
||||
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"font" inState:CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState:CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState:CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"font" inState:[CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-color" inState:[CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-color" inState:[CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:[CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-offset" inState:[CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"font" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"text-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"text-shadow-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected] forThemeAttribute:@"text-shadow-offset" inState: CPThemeStateDisabled | CPThemeStateHighlighted | CPThemeStateSelected];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"font" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]] forThemeAttribute:@"text-shadow-offset" inState:[CPThemeStateDisabled, CPThemeStateHighlighted, CPThemeStateSelected]];
|
||||
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState: CPThemeStateDisabled | CPThemeStateHighlighted ] forThemeAttribute:@"font" inState: CPThemeStateDisabled | CPThemeStateHighlighted ];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted ] forThemeAttribute:@"text-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted ];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted ] forThemeAttribute:@"text-shadow-color" inState: CPThemeStateDisabled | CPThemeStateHighlighted ];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState: CPThemeStateDisabled | CPThemeStateHighlighted ] forThemeAttribute:@"text-shadow-offset" inState: CPThemeStateDisabled | CPThemeStateHighlighted];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-font" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"font" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"text-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"text-shadow-color" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]];
|
||||
[_textField setValue:[_datePicker valueForThemeAttribute:@"tile-text-shadow-offset" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]] forThemeAttribute:@"text-shadow-offset" inState:[CPThemeStateDisabled, CPThemeStateHighlighted]];
|
||||
|
||||
[self addSubview:_textField];
|
||||
|
||||
@@ -1050,7 +1110,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
|
||||
/*! Set a theme
|
||||
*/
|
||||
- (void)setThemeState:(CPThemeState)aState
|
||||
- (BOOL)setThemeState:(ThemeState)aState
|
||||
{
|
||||
[_textField setThemeState:aState];
|
||||
[super setThemeState:aState];
|
||||
@@ -1058,7 +1118,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
|
||||
/*! Unset a theme
|
||||
*/
|
||||
- (void)unsetThemeState:(CPThemeState)aState
|
||||
- (BOOL)unsetThemeState:(ThemeState)aState
|
||||
{
|
||||
[_textField unsetThemeState:aState];
|
||||
[super unsetThemeState:aState];
|
||||
@@ -1130,6 +1190,9 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
return;
|
||||
|
||||
var bounds = [self bounds];
|
||||
[_textField sizeToFit];
|
||||
[_textField setFrameOrigin:CGPointMake(bounds.size.width / 2 - [_textField frameSize].width / 2 + [_datePicker valueForThemeAttribute:@"border-width"], bounds.size.height / 2 - [_textField frameSize].height / 2)];
|
||||
@@ -1144,7 +1207,7 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
var themeState = [self themeState],
|
||||
context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
if (themeState & CPThemeStateSelected)
|
||||
if (themeState.hasThemeState(CPThemeStateSelected))
|
||||
{
|
||||
[self setBackgroundColor:[_datePicker valueForThemeAttribute:@"bezel-color-calendar" inState:themeState]];
|
||||
CGContextSetLineWidth(context, [_datePicker valueForThemeAttribute:@"border-width"]);
|
||||
@@ -1202,6 +1265,9 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
return;
|
||||
|
||||
if ([_datePicker drawsBackground])
|
||||
[self setBackgroundColor:[_datePicker backgroundColor]];
|
||||
else
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* _CPDatePickerClock.j
|
||||
/*
|
||||
* _CPDatePickerClock.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexandre Wilhelm
|
||||
@@ -24,9 +25,16 @@
|
||||
@import "CPImageView.j"
|
||||
@import "CALayer.j"
|
||||
|
||||
|
||||
@class _CPCibCustomResource
|
||||
@class CPDatePicker
|
||||
|
||||
@global CPHourMinuteSecondDatePickerElementFlag
|
||||
@global CPTextFieldAndStepperDatePickerStyle
|
||||
@global CPTextFieldDatePickerStyle
|
||||
|
||||
var RADIANS = Math.PI / 180;
|
||||
|
||||
|
||||
@implementation _CPDatePickerClock : CPView
|
||||
{
|
||||
@@ -44,11 +52,6 @@
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
/*! Init a new _CPDatePickerClock
|
||||
@param aFrame
|
||||
@param aDatePicker
|
||||
@return a new instance of _CPDatePickerClock
|
||||
*/
|
||||
- (id)initWithFrame:(CGRect)aFrame datePicker:(CPDatePicker)aDatePicker
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
@@ -110,8 +113,8 @@
|
||||
[_rootLayer addSublayer:_middleHandLayer];
|
||||
|
||||
[_rootLayer setNeedsDisplay];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -119,23 +122,27 @@
|
||||
#pragma mark -
|
||||
#pragma mark Layout methods
|
||||
|
||||
/*! Layout the subviews
|
||||
*/
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPTextFieldAndStepperDatePickerStyle || [_datePicker datePickerStyle] == CPTextFieldDatePickerStyle)
|
||||
return;
|
||||
|
||||
[super layoutSubviews];
|
||||
|
||||
var bounds = [self bounds];
|
||||
var bounds = [self bounds],
|
||||
dateValue = [[_datePicker dateValue] copy];
|
||||
|
||||
[self setBackgroundColor:[_datePicker valueForThemeAttribute:@"bezel-color-clock" inState:[_datePicker themeState]]];
|
||||
[_middleHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"middle-hand-color" inState:[_datePicker themeState]]];
|
||||
[_hourHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"hour-hand-color" inState:[_datePicker themeState]]];
|
||||
[_minuteHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"minute-hand-color" inState:[_datePicker themeState]]];
|
||||
[_secondHandLayer setBackgroundHandColor:[_datePicker valueForThemeAttribute:@"second-hand-color" inState:[_datePicker themeState]]];
|
||||
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
|
||||
|
||||
[self setBackgroundColor:[_datePicker currentValueForThemeAttribute:@"bezel-color-clock"]];
|
||||
[_middleHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"middle-hand-image"]];
|
||||
[_hourHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"hour-hand-image"]];
|
||||
[_minuteHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"minute-hand-image"]];
|
||||
[_secondHandLayer setImage:[_datePicker currentValueForThemeAttribute:@"second-hand-image"]];
|
||||
|
||||
if ([_datePicker _isEnglishFormat])
|
||||
{
|
||||
if ([_datePicker dateValue].getHours() > 11)
|
||||
if (dateValue.getHours() > 11)
|
||||
[_PMAMTextField setStringValue:@"PM"]
|
||||
else
|
||||
[_PMAMTextField setStringValue:@"AM"];
|
||||
@@ -149,9 +156,15 @@
|
||||
[_PMAMTextField setHidden:YES];
|
||||
}
|
||||
|
||||
[_hourHandLayer setRotationRadians:[self _hourPositionRadianForDate:[_datePicker dateValue]]];
|
||||
[_minuteHandLayer setRotationRadians:[self _minutePositionRadianForDate:[_datePicker dateValue]]];
|
||||
[_secondHandLayer setRotationRadians:[self _secondPositionRadianForDate:[_datePicker dateValue]]];
|
||||
[_hourHandLayer setRotationRadians:[self _hourPositionRadianForDate:dateValue]];
|
||||
[_minuteHandLayer setRotationRadians:[self _minutePositionRadianForDate:dateValue]];
|
||||
[_secondHandLayer setRotationRadians:[self _secondPositionRadianForDate:dateValue]];
|
||||
|
||||
[_PMAMTextField setEnabled:_isEnabled];
|
||||
[_hourHandLayer setEnabled:_isEnabled];
|
||||
[_middleHandLayer setEnabled:_isEnabled];
|
||||
[_secondHandLayer setEnabled:_isEnabled];
|
||||
[_minuteHandLayer setEnabled:_isEnabled];
|
||||
|
||||
// Check if we have to display the hand second
|
||||
if (([_datePicker datePickerElements] & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
@@ -164,46 +177,41 @@
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Getter Setter methods
|
||||
#pragma mark Accessors
|
||||
|
||||
/*! Return the radian position of the hour
|
||||
*/
|
||||
- (float)_hourPositionRadianForDate:(CPDate)aDate
|
||||
{
|
||||
var hours = aDate.getHours() + aDate.getMinutes() / 60;
|
||||
|
||||
return (360 * hours / 12) * (Math.PI / 180)
|
||||
return (360 * hours / 12) * RADIANS;
|
||||
}
|
||||
|
||||
/*! Return the radian position of the second
|
||||
*/
|
||||
- (float)_secondPositionRadianForDate:(CPDate)aDate
|
||||
{
|
||||
return (360 * aDate.getSeconds() / 60) * (Math.PI / 180)
|
||||
return (360 * aDate.getSeconds() / 60) * RADIANS;
|
||||
}
|
||||
|
||||
/*! Return the radian position of the minute
|
||||
*/
|
||||
- (float)_minutePositionRadianForDate:(CPDate)aDate
|
||||
{
|
||||
var minutes = aDate.getMinutes() + aDate.getSeconds() / 60;
|
||||
|
||||
return (360 * minutes / 60) * (Math.PI / 180)
|
||||
return (360 * minutes / 60) * RADIANS;
|
||||
}
|
||||
|
||||
/*! Set enabled
|
||||
@param aBoolean
|
||||
*/
|
||||
- (void)setEnabled:(BOOL)aBoolean
|
||||
- (void)setEnabled:(BOOL)shouldEnable
|
||||
{
|
||||
_isEnabled = aBoolean;
|
||||
[_PMAMTextField setEnabled:aBoolean];
|
||||
[_hourHandLayer setEnabled:aBoolean];
|
||||
[_middleHandLayer setEnabled:aBoolean];
|
||||
[_secondHandLayer setEnabled:aBoolean];
|
||||
[_minuteHandLayer setEnabled:aBoolean];
|
||||
shouldEnable = !!shouldEnable;
|
||||
|
||||
if (shouldEnable === _isEnabled)
|
||||
return;
|
||||
|
||||
_isEnabled = shouldEnable;
|
||||
[self setNeedsLayout];
|
||||
|
||||
// FIXME: This is a workaround for an apparent bug in CALayer.
|
||||
// Without pumping the event loop, the sublayers of _rootLayer
|
||||
// (the hands) are not redrawn until an event occurs.
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -213,6 +221,7 @@
|
||||
{
|
||||
BOOL _isEnabled @accessors(setter=setEnabled:, getter=isEnabled);
|
||||
|
||||
CPImage _image;
|
||||
CALayer _imageLayer;
|
||||
float _rotationRadians;
|
||||
}
|
||||
@@ -221,10 +230,6 @@
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
/*! Init a new hand layer with an image. The image will be draw in a ImageLayer
|
||||
@param anImage
|
||||
@return a new instance of handLayer
|
||||
*/
|
||||
- (id)initWithSize:(CGSize)aSize
|
||||
{
|
||||
if (self = [super init])
|
||||
@@ -238,6 +243,7 @@
|
||||
|
||||
[self addSublayer:_imageLayer];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -245,8 +251,8 @@
|
||||
#pragma mark -
|
||||
#pragma mark Setter Getter methods
|
||||
|
||||
/*! Set the bounds of the layer. The imageLayer will be at the center of this bounds
|
||||
@param aRect
|
||||
/*!
|
||||
Set the bounds of the layer. The imageLayer will be at the center of this bounds.
|
||||
*/
|
||||
- (void)setBounds:(CGRect)aRect
|
||||
{
|
||||
@@ -255,12 +261,22 @@
|
||||
[_imageLayer setPosition:CGPointMake(CGRectGetMidX(aRect), CGRectGetMidY(aRect))];
|
||||
}
|
||||
|
||||
/*! Set the rotation of the imageLayer
|
||||
@param radians
|
||||
*/
|
||||
- (void)setImage:(CPImage)anImage
|
||||
{
|
||||
if (_image === anImage)
|
||||
return;
|
||||
|
||||
if ([anImage isKindOfClass:[_CPCibCustomResource class]])
|
||||
_image = [anImage imageFromCoder:nil];
|
||||
else
|
||||
_image = anImage;
|
||||
|
||||
[_imageLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)setRotationRadians:(float)radians
|
||||
{
|
||||
if (_rotationRadians == radians)
|
||||
if (_rotationRadians === radians)
|
||||
return;
|
||||
|
||||
_rotationRadians = radians;
|
||||
@@ -270,15 +286,29 @@
|
||||
1.0, 1.0)];
|
||||
}
|
||||
|
||||
- (void)setBackgroundHandColor:(CPColor)aColor
|
||||
- (void)setEnabled:(BOOL)shouldEnable
|
||||
{
|
||||
[_imageLayer setBackgroundColor:aColor];
|
||||
shouldEnable = !!shouldEnable;
|
||||
|
||||
if (_isEnabled === shouldEnable)
|
||||
return;
|
||||
|
||||
_isEnabled = shouldEnable;
|
||||
[self setNeedsDisplay];
|
||||
[_imageLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)aBoolean
|
||||
- (void)imageDidLoad:(CPImage)anImage
|
||||
{
|
||||
_isEnabled = aBoolean;
|
||||
[self setNeedsDisplay];
|
||||
[_imageLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)drawLayer:(CALayer)aLayer inContext:(CGContext)aContext
|
||||
{
|
||||
if ([_image loadStatus] != CPImageLoadStatusCompleted)
|
||||
[_image setDelegate:self];
|
||||
else
|
||||
CGContextDrawImage(aContext, [aLayer bounds], _image);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
@import "CPControl.j"
|
||||
@import "CPFont.j"
|
||||
@import "CPTextField.j"
|
||||
@import "CPStepper.j"
|
||||
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
@@ -30,7 +31,6 @@
|
||||
@import <Foundation/CPLocale.j>
|
||||
|
||||
@class CPDatePicker
|
||||
@class CPStepper
|
||||
|
||||
@global CPSingleDateMode
|
||||
@global CPRangeDateMode
|
||||
@@ -66,7 +66,6 @@ var CPZeroKeyCode = 48,
|
||||
_CPDatePickerElementView _datePickerElementView;
|
||||
CPDatePicker _datePicker;
|
||||
CPStepper _stepper;
|
||||
CPTimer _timerEdition;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +100,7 @@ var CPZeroKeyCode = 48,
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Responder methods
|
||||
#pragma mark Override responder methods
|
||||
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
@@ -116,7 +115,7 @@ var CPZeroKeyCode = 48,
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
// End the timer of editing
|
||||
[self _endTimer];
|
||||
[_currentTextField _endEditing];
|
||||
|
||||
// Don't forget to unbind, otherwise several steppers will increase or decrease
|
||||
[_currentTextField unbind:@"objectValue"];
|
||||
@@ -129,6 +128,10 @@ var CPZeroKeyCode = 48,
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyView
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Setter Getter methods
|
||||
@@ -139,7 +142,9 @@ var CPZeroKeyCode = 48,
|
||||
*/
|
||||
- (void)setDateValue:(CPDate)aDateValue
|
||||
{
|
||||
[_datePickerElementView setDateValue:aDateValue];
|
||||
var dateValue = [aDateValue copy];
|
||||
[dateValue _dateWithTimeZone:[_datePicker timeZone]];
|
||||
[_datePickerElementView setDateValue:dateValue];
|
||||
}
|
||||
|
||||
/*! Set the widget enabled or not
|
||||
@@ -177,6 +182,8 @@ var CPZeroKeyCode = 48,
|
||||
|
||||
- (void)_selecteTextFieldWithFlags:(unsigned)flags
|
||||
{
|
||||
[_datePickerElementView _updateResponderTextField];
|
||||
|
||||
// We select the firstTextField when the datePicker becomes firstResponder if _currentTextField is null. It can be null just when using tab
|
||||
if (!_currentTextField)
|
||||
{
|
||||
@@ -197,7 +204,7 @@ var CPZeroKeyCode = 48,
|
||||
return;
|
||||
|
||||
// End the timer of editing
|
||||
[self _endTimer];
|
||||
[_currentTextField _endEditing];
|
||||
|
||||
// Don't forget to unbind, otherwise several steppers will increase or decrease
|
||||
[_currentTextField unbind:@"objectValue"];
|
||||
@@ -210,7 +217,7 @@ var CPZeroKeyCode = 48,
|
||||
if ([_currentTextField dateType] != CPAMPMDateType)
|
||||
{
|
||||
// We update the value of the stepper dependind on the textField
|
||||
[_stepper setObjectValue:parseInt([_currentTextField objectValue])];
|
||||
[_stepper setObjectValue:parseInt([_currentTextField stringValue])];
|
||||
[_stepper setMaxValue:[_currentTextField maxNumber]];
|
||||
[_stepper setMinValue:[_currentTextField minNumber]];
|
||||
|
||||
@@ -276,7 +283,7 @@ var CPZeroKeyCode = 48,
|
||||
|
||||
if (key == CPUpArrowFunctionKey)
|
||||
{
|
||||
[self _endTimer];
|
||||
[_currentTextField _invalidTimer];
|
||||
[_stepper setDoubleValue:parseInt([_currentTextField objectValue])];
|
||||
[_stepper performClickUp:self];
|
||||
return YES;
|
||||
@@ -284,7 +291,7 @@ var CPZeroKeyCode = 48,
|
||||
|
||||
if (key == CPDownArrowFunctionKey)
|
||||
{
|
||||
[self _endTimer];
|
||||
[_currentTextField _invalidTimer];
|
||||
[_stepper setDoubleValue:parseInt([_currentTextField objectValue])];
|
||||
[_stepper performClickDown:self];
|
||||
return YES;
|
||||
@@ -294,34 +301,37 @@ var CPZeroKeyCode = 48,
|
||||
{
|
||||
if (_currentTextField == _firstTextField && [anEvent keyCode] == CPTabKeyCode)
|
||||
{
|
||||
if ([_datePicker previousKeyView])
|
||||
[[self window] makeFirstResponder:[_datePicker previousKeyView]];
|
||||
var previousValidKeyView = [_datePicker previousValidKeyView];
|
||||
|
||||
if (previousValidKeyView)
|
||||
[[self window] makeFirstResponder:previousValidKeyView];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
[self _selectTextField:[_currentTextField previousKeyView]];
|
||||
[self _selectTextField:[_currentTextField previousTextField]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (key == CPRightArrowFunctionKey || [anEvent keyCode] == CPTabKeyCode)
|
||||
{
|
||||
|
||||
if (_currentTextField == _lastTextField && [anEvent keyCode] == CPTabKeyCode)
|
||||
{
|
||||
if ([_datePicker nextKeyView])
|
||||
[[self window] makeFirstResponder:[_datePicker nextKeyView]];
|
||||
var nextValidKeyView = [_datePicker nextValidKeyView];
|
||||
|
||||
if (nextValidKeyView)
|
||||
[[self window] makeFirstResponder:nextValidKeyView];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
[self _selectTextField:[_currentTextField nextKeyView]];
|
||||
[self _selectTextField:[_currentTextField nextTextField]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([anEvent keyCode] == CPReturnKeyCode && _timerEdition)
|
||||
if ([anEvent keyCode] == CPReturnKeyCode)
|
||||
{
|
||||
[_timerEdition fire];
|
||||
[_currentTextField _endEditing];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -348,84 +358,7 @@ var CPZeroKeyCode = 48,
|
||||
return;
|
||||
}
|
||||
|
||||
if ([anEvent keyCode] != CPDeleteKeyCode && [anEvent keyCode] != CPDeleteForwardKeyCode && [anEvent keyCode] < CPZeroKeyCode || [anEvent keyCode] > CPNineKeyCode)
|
||||
return;
|
||||
|
||||
// Here, at the first editing we launch a timer to auto-finish the editing. There is another behavior when the user has already edited something
|
||||
if (!_timerEdition)
|
||||
{
|
||||
_timerEdition = [CPTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(_timerKeyEvent:) userInfo:nil repeats:NO];
|
||||
|
||||
// Take care about the delete key
|
||||
if ([anEvent keyCode] == CPDeleteKeyCode || [anEvent keyCode] == CPDeleteForwardKeyCode)
|
||||
[_currentTextField setStringKeyValue:@""];
|
||||
else
|
||||
[_currentTextField setStringKeyValue:[anEvent characters]];
|
||||
}
|
||||
else
|
||||
{
|
||||
var newFireDate = [CPDate date],
|
||||
key;
|
||||
|
||||
newFireDate.setSeconds(newFireDate.getSeconds() + 2);
|
||||
|
||||
[_timerEdition setFireDate:newFireDate];
|
||||
|
||||
// Take care about the delete key
|
||||
if ([anEvent keyCode] == CPDeleteKeyCode || [anEvent keyCode] == CPDeleteForwardKeyCode)
|
||||
key = [[_currentTextField stringValue] substringToIndex:[[_currentTextField stringValue] length] - 1];
|
||||
else
|
||||
key = [CPString stringWithFormat:@"%i%i",parseInt([_currentTextField stringValue]), parseInt([anEvent characters])];
|
||||
|
||||
[_currentTextField setStringKeyValue:key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Timer event
|
||||
|
||||
/*! End of the timer
|
||||
*/
|
||||
- (void)_timerKeyEvent:(id)sender
|
||||
{
|
||||
_timerEdition = nil;
|
||||
|
||||
if (![[_currentTextField stringValue] isEqualToString:@" "] && ![[_currentTextField stringValue] isEqualToString:@" "])
|
||||
{
|
||||
var value = [_currentTextField stringValue];
|
||||
|
||||
if ([_datePicker _isEnglishFormat] && [_currentTextField dateType] == CPHourDateType)
|
||||
{
|
||||
if (![_datePickerElementView _isAMHour] && value != 12)
|
||||
value = parseInt(value) + 12;
|
||||
|
||||
if (value == 12 && ![_datePickerElementView _isAMHour])
|
||||
value = 12;
|
||||
else if (value == 12)
|
||||
value = 0;
|
||||
}
|
||||
|
||||
[_currentTextField setObjectValue:value];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_currentTextField setObjectValue:@"0"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*! We force to end the timer
|
||||
*/
|
||||
- (void)_endTimer
|
||||
{
|
||||
if (_timerEdition)
|
||||
{
|
||||
[_timerEdition invalidate];
|
||||
[self _timerKeyEvent:_timerEdition];
|
||||
_timerEdition = nil;
|
||||
}
|
||||
[_currentTextField setValueForKeyEvent:anEvent];
|
||||
}
|
||||
|
||||
|
||||
@@ -516,6 +449,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldDay setDateType:CPDayDateType];
|
||||
[_textFieldDay setDatePicker:_datePicker];
|
||||
[_textFieldDay setAlignment:CPRightTextAlignment];
|
||||
[_textFieldDay setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldDay];
|
||||
|
||||
_textFieldMonth = [_CPDatePickerElementTextField new];
|
||||
@@ -524,6 +458,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldMonth setDateType:CPMonthDateType];
|
||||
[_textFieldMonth setDatePicker:_datePicker];
|
||||
[_textFieldMonth setAlignment:CPRightTextAlignment];
|
||||
[_textFieldMonth setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldMonth];
|
||||
|
||||
_textFieldYear = [_CPDatePickerElementTextField new];
|
||||
@@ -532,6 +467,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldYear setDateType:CPYearDateType];
|
||||
[_textFieldYear setDatePicker:_datePicker];
|
||||
[_textFieldYear setAlignment:CPRightTextAlignment];
|
||||
[_textFieldYear setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldYear];
|
||||
|
||||
_textFieldHour = [_CPDatePickerElementTextField new];
|
||||
@@ -540,6 +476,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldHour setDateType:CPHourDateType];
|
||||
[_textFieldHour setDatePicker:_datePicker];
|
||||
[_textFieldHour setAlignment:CPRightTextAlignment];
|
||||
[_textFieldHour setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldHour];
|
||||
|
||||
_textFieldMinute = [_CPDatePickerElementTextField new];
|
||||
@@ -548,6 +485,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldMinute setDateType:CPMinuteDateType];
|
||||
[_textFieldMinute setDatePicker:_datePicker];
|
||||
[_textFieldMinute setAlignment:CPRightTextAlignment];
|
||||
[_textFieldMinute setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldMinute];
|
||||
|
||||
_textFieldSecond = [_CPDatePickerElementTextField new];
|
||||
@@ -556,6 +494,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldSecond setDateType:CPSecondDateType];
|
||||
[_textFieldSecond setDatePicker:_datePicker];
|
||||
[_textFieldSecond setAlignment:CPRightTextAlignment];
|
||||
[_textFieldSecond setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldSecond];
|
||||
|
||||
_textFieldPMAM = [_CPDatePickerElementTextField new];
|
||||
@@ -564,6 +503,7 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldPMAM setDateType:CPAMPMDateType];
|
||||
[_textFieldPMAM setDatePicker:_datePicker];
|
||||
[_textFieldPMAM setAlignment:CPRightTextAlignment];
|
||||
[_textFieldPMAM setDatePickerElementView:self];
|
||||
[self addSubview:_textFieldPMAM];
|
||||
|
||||
_textFieldSeparatorOne = [CPTextField labelWithTitle:@"/"];
|
||||
@@ -585,7 +525,7 @@ var CPZeroKeyCode = 48,
|
||||
#pragma mark -
|
||||
#pragma mark Responder methods
|
||||
|
||||
- (BOOL)acceptFirstResponder
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@@ -612,6 +552,13 @@ var CPZeroKeyCode = 48,
|
||||
[_textFieldPMAM setStringValue:@"AM"];
|
||||
}
|
||||
|
||||
/*! Set the day date value to the appropriate textField
|
||||
@param aDayDateValue the day
|
||||
*/
|
||||
- (void)setDayDateValue:(CPString)aDayDateValue
|
||||
{
|
||||
[_textFieldDay setStringValue:aDayDateValue];
|
||||
}
|
||||
|
||||
/*! Set the widget enabled or not
|
||||
@param aBoolean
|
||||
@@ -639,6 +586,65 @@ var CPZeroKeyCode = 48,
|
||||
return [[_textFieldPMAM stringValue] isEqualToString:@"AM"];
|
||||
}
|
||||
|
||||
- (CPDate)dateValue
|
||||
{
|
||||
var date = [[_datePicker dateValue] copy];
|
||||
|
||||
[date _dateWithTimeZone:[_datePicker timeZone]];
|
||||
|
||||
if (![_textFieldDay isHidden])
|
||||
date.setDate([_textFieldDay stringValue]);
|
||||
|
||||
if (![_textFieldMonth isHidden])
|
||||
date.setMonth(parseInt([_textFieldMonth stringValue]) - 1);
|
||||
|
||||
if (![_textFieldYear isHidden])
|
||||
date.setFullYear([_textFieldYear stringValue]);
|
||||
|
||||
if (![_textFieldSecond isHidden])
|
||||
date.setSeconds([_textFieldSecond stringValue]);
|
||||
|
||||
if (![_textFieldMinute isHidden])
|
||||
date.setMinutes([_textFieldMinute stringValue]);
|
||||
|
||||
if (![_textFieldHour isHidden])
|
||||
{
|
||||
var hour = parseInt([_textFieldHour stringValue]),
|
||||
currentHour = parseInt(date.getHours());
|
||||
|
||||
if (hour != currentHour)
|
||||
{
|
||||
if (([_datePicker _isEnglishFormat] || [_datePicker _isAmericanFormat]))
|
||||
{
|
||||
if (![self _isAMHour])
|
||||
{
|
||||
if (!(currentHour == 12 && hour == 11) && hour < 13)
|
||||
hour = hour + 12;
|
||||
}
|
||||
else if (hour == 12 && currentHour != 11)
|
||||
{
|
||||
hour = 0;
|
||||
}
|
||||
else if (currentHour == 0 && hour == 11)
|
||||
{
|
||||
hour = 23;
|
||||
}
|
||||
else if (hour == 13)
|
||||
{
|
||||
hour = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hour == 24)
|
||||
hour = 0;
|
||||
|
||||
date.setHours(hour);
|
||||
}
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Notification methods
|
||||
@@ -649,16 +655,19 @@ var CPZeroKeyCode = 48,
|
||||
- (void)_datePickerElementTextFieldAMPMChangedNotification:(CPNotification)aNotification
|
||||
{
|
||||
var value = [[aNotification object] stringValue],
|
||||
dateValue = [[_datePicker dateValue] copy];
|
||||
dateValue = [[_datePicker dateValue] copy],
|
||||
d = [dateValue copy];
|
||||
|
||||
[d _dateWithTimeZone:[_datePicker timeZone]];
|
||||
|
||||
if ([value isEqualToString:@"PM"])
|
||||
{
|
||||
if (dateValue.getHours() <= 11)
|
||||
if (d.getHours() <= 11)
|
||||
dateValue.setHours(dateValue.getHours() + 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dateValue.getHours() > 11)
|
||||
if (d.getHours() > 11)
|
||||
dateValue.setHours(dateValue.getHours() - 12);
|
||||
}
|
||||
|
||||
@@ -671,6 +680,9 @@ var CPZeroKeyCode = 48,
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if ([_datePicker datePickerStyle] == CPClockAndCalendarDatePickerStyle)
|
||||
return;
|
||||
|
||||
[super layoutSubviews];
|
||||
|
||||
var themeState = [_datePicker themeState];
|
||||
@@ -1076,6 +1088,12 @@ var CPZeroKeyCode = 48,
|
||||
/*! Update the nextTextField params of all of the textField. This is used to move the current textField with the arrows
|
||||
*/
|
||||
- (void)_updateKeyView
|
||||
{
|
||||
[self _updateNextTextField];
|
||||
[self _updatePreviousTextField]
|
||||
}
|
||||
|
||||
- (void)_updateNextTextField
|
||||
{
|
||||
var datePickerElements = [_datePicker datePickerElements],
|
||||
firstTexField = _textFieldMonth,
|
||||
@@ -1089,45 +1107,94 @@ var CPZeroKeyCode = 48,
|
||||
}
|
||||
|
||||
if ((datePickerElements & CPYearMonthDayDatePickerElementFlag) == CPYearMonthDayDatePickerElementFlag)
|
||||
[firstTexField setNextKeyView:secondTextField];
|
||||
[firstTexField setNextTextField:secondTextField];
|
||||
else
|
||||
[firstTexField setNextKeyView:_textFieldYear];
|
||||
[firstTexField setNextTextField:_textFieldYear];
|
||||
|
||||
[secondTextField setNextKeyView:_textFieldYear];
|
||||
[secondTextField setNextTextField:_textFieldYear];
|
||||
|
||||
if (datePickerElements & CPHourMinuteSecondDatePickerElementFlag || datePickerElements & CPHourMinuteDatePickerElementFlag)
|
||||
[_textFieldYear setNextKeyView:_textFieldHour];
|
||||
[_textFieldYear setNextTextField:_textFieldHour];
|
||||
else if (isEnglishFormat || (datePickerElements & CPYearMonthDayDatePickerElementFlag) == CPYearMonthDayDatePickerElementFlag)
|
||||
[_textFieldYear setNextKeyView:firstTexField];
|
||||
[_textFieldYear setNextTextField:firstTexField];
|
||||
else
|
||||
[_textFieldYear setNextKeyView:secondTextField];
|
||||
[_textFieldYear setNextTextField:secondTextField];
|
||||
|
||||
[_textFieldHour setNextKeyView:_textFieldMinute];
|
||||
[_textFieldHour setNextTextField:_textFieldMinute];
|
||||
|
||||
if ((datePickerElements & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
[_textFieldMinute setNextKeyView:_textFieldSecond];
|
||||
[_textFieldMinute setNextTextField:_textFieldSecond];
|
||||
else if (isEnglishFormat)
|
||||
[_textFieldMinute setNextKeyView:_textFieldPMAM];
|
||||
[_textFieldMinute setNextTextField:_textFieldPMAM];
|
||||
else if ((datePickerElements & CPYearMonthDayDatePickerElementFlag) == CPYearMonthDayDatePickerElementFlag)
|
||||
[_textFieldMinute setNextKeyView:firstTexField];
|
||||
[_textFieldMinute setNextTextField:firstTexField];
|
||||
else if (datePickerElements & CPYearMonthDatePickerElementFlag)
|
||||
[_textFieldMinute setNextKeyView:secondTextField];
|
||||
[_textFieldMinute setNextTextField:secondTextField];
|
||||
else
|
||||
[_textFieldMinute setNextKeyView:_textFieldHour];
|
||||
[_textFieldMinute setNextTextField:_textFieldHour];
|
||||
|
||||
if (isEnglishFormat)
|
||||
[_textFieldSecond setNextKeyView:_textFieldPMAM];
|
||||
[_textFieldSecond setNextTextField:_textFieldPMAM];
|
||||
else if ((datePickerElements & CPYearMonthDayDatePickerElementFlag) == CPYearMonthDayDatePickerElementFlag)
|
||||
[_textFieldSecond setNextKeyView:firstTexField];
|
||||
[_textFieldSecond setNextTextField:firstTexField];
|
||||
else if (datePickerElements & CPYearMonthDatePickerElementFlag)
|
||||
[_textFieldSecond setNextKeyView:secondTextField];
|
||||
[_textFieldSecond setNextTextField:secondTextField];
|
||||
else
|
||||
[_textFieldSecond setNextKeyView:_textFieldHour];
|
||||
[_textFieldSecond setNextTextField:_textFieldHour];
|
||||
|
||||
if (datePickerElements & CPYearMonthDayDatePickerElementFlag)
|
||||
[_textFieldPMAM setNextKeyView:_textFieldMonth];
|
||||
[_textFieldPMAM setNextTextField:_textFieldMonth];
|
||||
else
|
||||
[_textFieldPMAM setNextKeyView:_textFieldHour];
|
||||
[_textFieldPMAM setNextTextField:_textFieldHour];
|
||||
}
|
||||
|
||||
- (void)_updatePreviousTextField
|
||||
{
|
||||
var datePickerElements = [_datePicker datePickerElements],
|
||||
firstTexField = _textFieldMonth,
|
||||
secondTextField = _textFieldDay,
|
||||
isEnglishFormat = [_datePicker _isEnglishFormat];
|
||||
|
||||
if (!isEnglishFormat)
|
||||
{
|
||||
firstTexField = _textFieldDay;
|
||||
secondTextField = _textFieldMonth;
|
||||
}
|
||||
|
||||
if ((datePickerElements & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
[_textFieldPMAM setPreviousTextField:_textFieldSecond];
|
||||
else if (datePickerElements & CPHourMinuteDatePickerElementFlag)
|
||||
[_textFieldPMAM setPreviousTextField:_textFieldMinute];
|
||||
|
||||
[_textFieldSecond setPreviousTextField:_textFieldMinute];
|
||||
[_textFieldMinute setPreviousTextField:_textFieldHour];
|
||||
|
||||
if (datePickerElements & CPYearMonthDatePickerElementFlag)
|
||||
[_textFieldHour setPreviousTextField:_textFieldYear];
|
||||
else if (isEnglishFormat)
|
||||
[_textFieldHour setPreviousTextField:_textFieldPMAM];
|
||||
else if ((datePickerElements & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
[_textFieldHour setPreviousTextField:_textFieldSecond];
|
||||
else
|
||||
[_textFieldHour setPreviousTextField:_textFieldMinute];
|
||||
|
||||
if (!isEnglishFormat)
|
||||
[_textFieldYear setPreviousTextField:_textFieldMonth];
|
||||
else if ((datePickerElements & CPYearMonthDayDatePickerElementFlag) == CPYearMonthDayDatePickerElementFlag)
|
||||
[_textFieldYear setPreviousTextField:_textFieldDay];
|
||||
else
|
||||
[_textFieldYear setPreviousTextField:_textFieldMonth];
|
||||
|
||||
[secondTextField setPreviousTextField:firstTexField];
|
||||
|
||||
if (isEnglishFormat && datePickerElements & CPHourMinuteDatePickerElementFlag)
|
||||
[firstTexField setPreviousTextField:_textFieldPMAM];
|
||||
else if ((datePickerElements & CPHourMinuteSecondDatePickerElementFlag) == CPHourMinuteSecondDatePickerElementFlag)
|
||||
[firstTexField setPreviousTextField:_textFieldSecond];
|
||||
else if (datePickerElements & CPHourMinuteDatePickerElementFlag)
|
||||
[firstTexField setPreviousTextField:_textFieldMinute];
|
||||
else
|
||||
[firstTexField setPreviousTextField:_textFieldYear];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1145,11 +1212,18 @@ var CPMonthDateType = 0,
|
||||
*/
|
||||
@implementation _CPDatePickerElementTextField : CPTextField
|
||||
{
|
||||
_CPDatePickerElementTextField _nextTextField @accessors(property=nextTextField);
|
||||
_CPDatePickerElementTextField _previousTextField @accessors(property=previousTextField);
|
||||
_CPDatePickerElementView _datePickerElementView @accessors(property=datePickerElementView);
|
||||
|
||||
CPDatePicker _datePicker @accessors(setter=setDatePicker:);
|
||||
|
||||
int _dateType @accessors(getter=dateType);
|
||||
int _maxNumber @accessors(getter=maxNumber);
|
||||
int _minNumber @accessors(getter=minNumber);
|
||||
|
||||
BOOL _firstEvent;
|
||||
CPTimer _timerEdition;
|
||||
}
|
||||
|
||||
|
||||
@@ -1158,6 +1232,7 @@ var CPMonthDateType = 0,
|
||||
|
||||
- (BOOL)acceptFirstResponder
|
||||
{
|
||||
_firstEvent = YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -1259,38 +1334,128 @@ var CPMonthDateType = 0,
|
||||
It's called when the user is editing with the keyboard
|
||||
@param aStringValue a CPString
|
||||
*/
|
||||
- (void)setStringKeyValue:(id)anObjectValue
|
||||
- (void)setValueForKeyEvent:(CPEvent)anEvent
|
||||
{
|
||||
if (_dateType == CPYearDateType)
|
||||
{
|
||||
if ([anObjectValue length] > 4)
|
||||
return
|
||||
var keyCode = [anEvent keyCode];
|
||||
|
||||
while ([anObjectValue length] < 4)
|
||||
anObjectValue = " " + anObjectValue;
|
||||
if (keyCode != CPDeleteKeyCode && keyCode != CPDeleteForwardKeyCode && keyCode < CPZeroKeyCode || keyCode > CPNineKeyCode)
|
||||
return;
|
||||
|
||||
var newValue = [self stringValue].replace(/\s/g, ''),
|
||||
length = [newValue length],
|
||||
eventKeyValue = parseInt([anEvent characters]).toString();
|
||||
|
||||
if (keyCode == CPDeleteKeyCode || keyCode == CPDeleteForwardKeyCode)
|
||||
{
|
||||
[_timerEdition invalidate];
|
||||
_timerEdition = nil;
|
||||
newValue = [newValue substringToIndex:(length - 1)];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([anObjectValue length] > 2)
|
||||
return
|
||||
if (!_timerEdition)
|
||||
{
|
||||
_timerEdition = [CPTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(_timerKeyEvent:) userInfo:nil repeats:NO];
|
||||
|
||||
while ([anObjectValue length] < 2)
|
||||
anObjectValue = " " + anObjectValue;
|
||||
if (_firstEvent || !length)
|
||||
newValue = eventKeyValue;
|
||||
else
|
||||
newValue = parseInt(newValue).toString() + eventKeyValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newFireDate = [CPDate date];
|
||||
|
||||
newFireDate.setSeconds(newFireDate.getSeconds() + 2);
|
||||
[_timerEdition setFireDate:newFireDate];
|
||||
|
||||
newValue = parseInt(newValue).toString() + eventKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (parseInt(anObjectValue) > [self _maxNumberWithMaxDate])
|
||||
if (parseInt(newValue) > [self _maxNumberWithMaxDate] || ([_datePicker _isEnglishFormat] && _dateType == CPHourDateType && parseInt(newValue) > 12))
|
||||
return;
|
||||
|
||||
if ([_datePicker _isEnglishFormat] && _dateType == CPHourDateType && parseInt(anObjectValue) > 12)
|
||||
return;
|
||||
_firstEvent = NO;
|
||||
|
||||
[super setObjectValue:anObjectValue];
|
||||
[super setObjectValue:newValue];
|
||||
}
|
||||
|
||||
/*!
|
||||
End of the timer
|
||||
*/
|
||||
- (void)_timerKeyEvent:(id)sender
|
||||
{
|
||||
var stringValue = [self stringValue];
|
||||
|
||||
_timerEdition = nil;
|
||||
|
||||
if ([stringValue length])
|
||||
{
|
||||
if ([_datePicker _isEnglishFormat] && [self dateType] == CPHourDateType)
|
||||
{
|
||||
var isAMHour = [[self superview] _isAMHour];
|
||||
|
||||
if (!isAMHour && stringValue != 12)
|
||||
stringValue = parseInt(stringValue) + 12;
|
||||
|
||||
if (stringValue == 12 && !isAMHour)
|
||||
stringValue = 12;
|
||||
else if (stringValue == 12)
|
||||
stringValue = 0;
|
||||
}
|
||||
|
||||
[self setObjectValue:stringValue];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
We force to end the timer
|
||||
*/
|
||||
- (void)_invalidTimer
|
||||
{
|
||||
if (_timerEdition)
|
||||
{
|
||||
[_timerEdition invalidate];
|
||||
_timerEdition = nil;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
We force to end the timer and to update the objectValue of the datePicker
|
||||
*/
|
||||
- (void)_endEditing
|
||||
{
|
||||
if (_timerEdition)
|
||||
[_timerEdition invalidate];
|
||||
|
||||
_timerEdition = nil;
|
||||
|
||||
var objectValue = [self stringValue];
|
||||
|
||||
if (![objectValue length])
|
||||
objectValue = [self objectValue];
|
||||
|
||||
if ([_datePicker _isEnglishFormat] && [self dateType] == CPHourDateType)
|
||||
{
|
||||
var isAMHour = [[self superview] _isAMHour];
|
||||
|
||||
if (!isAMHour && objectValue != 12)
|
||||
objectValue = parseInt(objectValue) + 12;
|
||||
|
||||
if (objectValue == 12 && !isAMHour)
|
||||
objectValue = 12;
|
||||
else if (objectValue == 12)
|
||||
objectValue = 0;
|
||||
}
|
||||
|
||||
[self setObjectValue:objectValue];
|
||||
}
|
||||
|
||||
/*! Set the stringValue of the TextField. Add some zeros of there isn't 2/4 letters in the value. It's called at the end of the editing process
|
||||
@param aStringValue a CPString
|
||||
*/
|
||||
- (void)setStringValue:(id)aStringValue
|
||||
- (void)setStringValue:(CPString)aStringValue
|
||||
{
|
||||
if (_dateType == CPYearDateType)
|
||||
{
|
||||
@@ -1312,7 +1477,13 @@ var CPMonthDateType = 0,
|
||||
}
|
||||
|
||||
while ([aStringValue length] < 2)
|
||||
aStringValue = "0" + aStringValue;
|
||||
{
|
||||
if (_dateType == CPSecondDateType || _dateType == CPMinuteDateType)
|
||||
aStringValue = @"0" + aStringValue;
|
||||
else
|
||||
aStringValue = @" " + aStringValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[super setObjectValue:aStringValue];
|
||||
@@ -1325,12 +1496,20 @@ var CPMonthDateType = 0,
|
||||
*/
|
||||
- (void)setObjectValue:(id)anObjectValue
|
||||
{
|
||||
var dateValue = [[_datePicker dateValue] copy];
|
||||
var dateValue = [[_datePicker dateValue] copy],
|
||||
lengthString = [[self stringValue] length],
|
||||
objectValue = parseInt(anObjectValue);
|
||||
|
||||
switch (_dateType)
|
||||
{
|
||||
case CPMonthDateType:
|
||||
|
||||
if (objectValue == 0 || !lengthString)
|
||||
{
|
||||
[self setStringValue:(dateValue.getMonth() + 1).toString()];
|
||||
return;
|
||||
}
|
||||
|
||||
var dateNextMonth = [dateValue copy];
|
||||
|
||||
dateNextMonth.setDate(1);
|
||||
@@ -1339,76 +1518,81 @@ var CPMonthDateType = 0,
|
||||
var numberDayNextMonth = [dateNextMonth _daysInMonth];
|
||||
|
||||
if (numberDayNextMonth < [dateValue _daysInMonth] && dateValue.getDate() > numberDayNextMonth)
|
||||
dateValue.setDate(numberDayNextMonth);
|
||||
[_datePickerElementView setDayDateValue:numberDayNextMonth.toString()];
|
||||
|
||||
dateValue.setMonth(parseInt(anObjectValue) - 1);
|
||||
[super setObjectValue:objectValue];
|
||||
break;
|
||||
|
||||
case CPDayDateType:
|
||||
dateValue.setDate(parseInt(anObjectValue));
|
||||
|
||||
if (objectValue == 0 || !lengthString)
|
||||
{
|
||||
[self setStringValue:dateValue.getDate().toString()];
|
||||
return;
|
||||
}
|
||||
|
||||
[super setObjectValue:objectValue];
|
||||
break;
|
||||
|
||||
case CPYearDateType:
|
||||
dateValue.setFullYear(parseInt(anObjectValue));
|
||||
|
||||
if (objectValue == 0 || !lengthString)
|
||||
{
|
||||
[self setStringValue:dateValue.getFullYear().toString()];
|
||||
return;
|
||||
}
|
||||
|
||||
[super setObjectValue:objectValue];
|
||||
break;
|
||||
|
||||
case CPHourDateType:
|
||||
dateValue.setHours(parseInt(anObjectValue));
|
||||
|
||||
if (!lengthString)
|
||||
{
|
||||
[self setStringValue:dateValue.getHours().toString()];
|
||||
return;
|
||||
}
|
||||
|
||||
[super setObjectValue:objectValue];
|
||||
break;
|
||||
|
||||
case CPSecondDateType:
|
||||
dateValue.setSeconds(parseInt(anObjectValue));
|
||||
|
||||
if (!lengthString)
|
||||
{
|
||||
[self setStringValue:dateValue.getSeconds().toString()];
|
||||
return;
|
||||
}
|
||||
[super setObjectValue:objectValue];
|
||||
break;
|
||||
|
||||
case CPMinuteDateType:
|
||||
dateValue.setMinutes(parseInt(anObjectValue));
|
||||
|
||||
if (!lengthString)
|
||||
{
|
||||
[self setStringValue:dateValue.getMinutes().toString()];
|
||||
return;
|
||||
}
|
||||
|
||||
[super setObjectValue:objectValue];
|
||||
break;
|
||||
}
|
||||
|
||||
[_datePicker setDateValue:dateValue];
|
||||
}
|
||||
var newDateValue = [_datePickerElementView dateValue],
|
||||
timeZone = [_datePicker timeZone];
|
||||
|
||||
/*! Return the objectValue of the textField. Needed for the binding.
|
||||
This returns the objectValue relative to the dateValue
|
||||
*/
|
||||
- (void)objectValue
|
||||
{
|
||||
var dateValue = [[_datePicker dateValue] copy];
|
||||
|
||||
switch (_dateType)
|
||||
if (timeZone)
|
||||
{
|
||||
case CPMonthDateType:
|
||||
return dateValue.getMonth() + 1;
|
||||
break;
|
||||
var secondsFromGMT = [timeZone secondsFromGMTForDate:newDateValue],
|
||||
secondsFromGMTTimeZone = [timeZone secondsFromGMT];
|
||||
|
||||
case CPDayDateType:
|
||||
return dateValue.getDate();
|
||||
break;
|
||||
|
||||
case CPYearDateType:
|
||||
return dateValue.getFullYear();
|
||||
break;
|
||||
|
||||
case CPHourDateType:
|
||||
return dateValue.getHours();
|
||||
break;
|
||||
|
||||
case CPSecondDateType:
|
||||
return dateValue.getSeconds();
|
||||
break;
|
||||
|
||||
case CPMinuteDateType:
|
||||
return dateValue.getMinutes();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [super objectValue];
|
||||
break;
|
||||
newDateValue.setSeconds(newDateValue.getSeconds() + secondsFromGMT - secondsFromGMTTimeZone);
|
||||
}
|
||||
|
||||
return [super objectValue];
|
||||
[_datePicker setDateValue:newDateValue];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Mouse event
|
||||
|
||||
@@ -1438,7 +1622,69 @@ var CPMonthDateType = 0,
|
||||
*/
|
||||
- (void)makeDeselectable
|
||||
{
|
||||
_firstEvent = YES;
|
||||
[self unsetThemeState:CPThemeStateSelected];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Override
|
||||
|
||||
/*!
|
||||
We override this method to get all the time the good width
|
||||
*/
|
||||
- (CGSize)_minimumFrameSize
|
||||
{
|
||||
var frameSize = [self frameSize],
|
||||
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
minSize = [self currentValueForThemeAttribute:@"min-size"],
|
||||
maxSize = [self currentValueForThemeAttribute:@"max-size"],
|
||||
lineBreakMode = [self lineBreakMode],
|
||||
text = (_dateType == CPYearDateType) ? @"0000" : @"00",
|
||||
textSize = CGSizeMakeCopy(frameSize),
|
||||
font = [self currentValueForThemeAttribute:@"font"];
|
||||
|
||||
textSize.width -= contentInset.left + contentInset.right;
|
||||
textSize.height -= contentInset.top + contentInset.bottom;
|
||||
|
||||
if (_dateType == CPAMPMDateType)
|
||||
text = [self stringValue];
|
||||
|
||||
if (frameSize.width !== 0 &&
|
||||
![self isBezeled] &&
|
||||
(lineBreakMode === CPLineBreakByWordWrapping || lineBreakMode === CPLineBreakByCharWrapping))
|
||||
{
|
||||
textSize = [text sizeWithFont:font inWidth:textSize.width];
|
||||
}
|
||||
else
|
||||
{
|
||||
textSize = [text sizeWithFont:font];
|
||||
|
||||
// Account for possible fractional pixels at right edge
|
||||
textSize.width += 1;
|
||||
}
|
||||
|
||||
// Account for possible fractional pixels at bottom edge
|
||||
textSize.height += 1;
|
||||
|
||||
frameSize.height = textSize.height + contentInset.top + contentInset.bottom;
|
||||
|
||||
if ([self isBezeled])
|
||||
{
|
||||
frameSize.height = MAX(frameSize.height, minSize.height);
|
||||
|
||||
if (maxSize.width > 0.0)
|
||||
frameSize.width = MIN(frameSize.width, maxSize.width);
|
||||
|
||||
if (maxSize.height > 0.0)
|
||||
frameSize.height = MIN(frameSize.height, maxSize.height);
|
||||
}
|
||||
else
|
||||
frameSize.width = textSize.width + contentInset.left + contentInset.right;
|
||||
|
||||
frameSize.width = MAX(frameSize.width, minSize.width);
|
||||
|
||||
return frameSize;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+11
-25
@@ -244,11 +244,6 @@ var CPDocumentUntitledCount = 0;
|
||||
{
|
||||
}
|
||||
|
||||
- (CPWindowController)firstEligibleExistingWindowController
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Creating and managing window controllers
|
||||
/*!
|
||||
Creates the window controller for this document.
|
||||
@@ -261,6 +256,7 @@ var CPDocumentUntitledCount = 0;
|
||||
- (void)makeViewAndWindowControllers
|
||||
{
|
||||
var viewCibName = [self viewCibName],
|
||||
windowCibName = [self windowCibName],
|
||||
viewController = nil,
|
||||
windowController = nil;
|
||||
|
||||
@@ -268,31 +264,21 @@ var CPDocumentUntitledCount = 0;
|
||||
if ([viewCibName length])
|
||||
viewController = [[CPViewController alloc] initWithCibName:viewCibName bundle:nil owner:self];
|
||||
|
||||
// If we have a view controller, check if we have a free window for it.
|
||||
if (viewController)
|
||||
windowController = [self firstEligibleExistingWindowController];
|
||||
// From a cib if we have one.
|
||||
if ([windowCibName length])
|
||||
windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self];
|
||||
|
||||
// If not, create one.
|
||||
if (!windowController)
|
||||
// If not you get a standard window capable of displaying multiple documents and view
|
||||
else if (viewController)
|
||||
{
|
||||
var windowCibName = [self windowCibName];
|
||||
var view = [viewController view],
|
||||
viewFrame = [view frame];
|
||||
|
||||
// From a cib if we have one.
|
||||
if ([windowCibName length])
|
||||
windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self];
|
||||
viewFrame.origin = CGPointMake(50, 50);
|
||||
|
||||
// If not you get a standard window capable of displaying multiple documents and view
|
||||
else if (viewController)
|
||||
{
|
||||
var view = [viewController view],
|
||||
viewFrame = [view frame];
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
|
||||
|
||||
viewFrame.origin = CGPointMake(50, 50);
|
||||
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
|
||||
|
||||
windowController = [[CPWindowController alloc] initWithWindow:theWindow];
|
||||
}
|
||||
windowController = [[CPWindowController alloc] initWithWindow:theWindow];
|
||||
}
|
||||
|
||||
if (windowController && viewController)
|
||||
|
||||
@@ -253,6 +253,14 @@ var CPSharedDocumentController = nil;
|
||||
return _documents;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the CPDocument object associated with the main window.
|
||||
*/
|
||||
- (CPDocument)currentDocument
|
||||
{
|
||||
return [[[CPApp mainWindow] windowController] document];
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds \c aDocument under the control of the receiver.
|
||||
@param aDocument the document to add
|
||||
@@ -271,6 +279,33 @@ var CPSharedDocumentController = nil;
|
||||
[_documents removeObjectIdenticalTo:aDocument];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the document object whose window controller
|
||||
owns a specified window.
|
||||
*/
|
||||
- (CPDocument)documentForWindow:(CPWindow)aWindow
|
||||
{
|
||||
return [[aWindow windowController] document];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a Boolean value that indicates whether the receiver
|
||||
has any documents with unsaved changes.
|
||||
*/
|
||||
- (BOOL)hasEditedDocuments
|
||||
{
|
||||
var iter = [_documents objectEnumerator],
|
||||
obj;
|
||||
|
||||
while ((obj = [iter nextObject]) !== nil)
|
||||
{
|
||||
if ([obj isDocumentEdited])
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPString)defaultType
|
||||
{
|
||||
return [_documentTypes[0] objectForKey:@"CPBundleTypeName"];
|
||||
|
||||
@@ -68,6 +68,11 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
float _deltaX;
|
||||
float _deltaY;
|
||||
float _deltaZ;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
BOOL _suppressCappuccinoCut;
|
||||
BOOL _suppressCappuccinoPaste;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -473,6 +478,24 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
return !firstResponderIsText;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return YES if this event is a part of processing a browser controlled cut or paste event
|
||||
where the browser will go ahead and do the work of cutting or pasting within the input
|
||||
element after processing of this event. The implication is that it should not be done by
|
||||
the CPTextField (or whatever else is controlling the input) since this would result in
|
||||
nothing being cut (because the field already cut the text out), or a double paste
|
||||
(because the field pasted as well as the browser).
|
||||
*/
|
||||
- (BOOL)_platformIsEffectingCutOrPaste
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
return _suppressCappuccinoCut || _suppressCappuccinoPaste;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Generates periodic events every \c aPeriod seconds.
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
|
||||
return @"CPFV_" + [self UID];
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(id)sommit
|
||||
- (void)mouseMoved:(CPEvent)sommit
|
||||
{
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ following:
|
||||
var systemSize = String(_CPFontSystemFontSize),
|
||||
currentSize = String(CPFontCurrentSystemSize);
|
||||
|
||||
for (key in _CPSystemFontCache)
|
||||
for (var key in _CPSystemFontCache)
|
||||
{
|
||||
if (_CPSystemFontCache.hasOwnProperty(key) &&
|
||||
(key.indexOf(systemSize) === 0 || key.indexOf(currentSize) === 0))
|
||||
|
||||
+45
-12
@@ -30,6 +30,20 @@
|
||||
@import "CGGeometry.j"
|
||||
@import "CPCompatibility.j"
|
||||
|
||||
|
||||
@protocol CPImageDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (void)imageDidLoad:(CPImage)anImage;
|
||||
- (void)imageDidError:(CPImage)anImage;
|
||||
- (void)imageDidAbort:(CPImage)anImage;
|
||||
|
||||
@end
|
||||
|
||||
var CPImageDelegate_imageDidLoad_ = 1 << 1,
|
||||
CPImageDelegate_imageDidError_ = 1 << 2,
|
||||
CPImageDelegate_imageDidAbort_ = 1 << 3;
|
||||
|
||||
CPImageLoadStatusInitialized = 0;
|
||||
CPImageLoadStatusLoading = 1;
|
||||
CPImageLoadStatusCompleted = 2;
|
||||
@@ -119,14 +133,15 @@ function CPAppKitImage(aFilename, aSize)
|
||||
*/
|
||||
@implementation CPImage : CPObject
|
||||
{
|
||||
CGSize _size;
|
||||
CPString _filename;
|
||||
CPString _name;
|
||||
CGSize _size;
|
||||
CPString _filename;
|
||||
CPString _name;
|
||||
|
||||
id _delegate;
|
||||
unsigned _loadStatus;
|
||||
id <CPImageDelegate> _delegate;
|
||||
unsigned _loadStatus;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
Image _image;
|
||||
Image _image;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@@ -136,14 +151,19 @@ function CPAppKitImage(aFilename, aSize)
|
||||
|
||||
/*!
|
||||
Initializes the image, by associating it with a filename. The image
|
||||
denoted in \c aFilename is not actually loaded. It will
|
||||
be loaded once needed.
|
||||
denoted in \c aFilename is not actually loaded. It will be loaded
|
||||
once needed.
|
||||
|
||||
@param aFilename the file containing the image
|
||||
@param aSize the image's size
|
||||
@return the initialized image
|
||||
*/
|
||||
- (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize
|
||||
{
|
||||
// Quietly return nil like in Cocoa, rather than crashing later.
|
||||
if (aFilename === undefined || aFilename === nil)
|
||||
return nil;
|
||||
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
@@ -314,9 +334,22 @@ function CPAppKitImage(aFilename, aSize)
|
||||
Sets the receiver's delegate.
|
||||
@param the delegate
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPImageDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidLoad:)])
|
||||
_implementedDelegateMethods |= CPImageDelegate_imageDidLoad_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidError:)])
|
||||
_implementedDelegateMethods |= CPImageDelegate_imageDidError_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidAbort:)])
|
||||
_implementedDelegateMethods |= CPImageDelegate_imageDidAbort_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -452,7 +485,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
postNotificationName:CPImageDidLoadNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidLoad:)])
|
||||
if (_implementedDelegateMethods & CPImageDelegate_imageDidLoad_)
|
||||
[_delegate imageDidLoad:self];
|
||||
}
|
||||
|
||||
@@ -461,7 +494,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
{
|
||||
_loadStatus = CPImageLoadStatusReadError;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidError:)])
|
||||
if (_implementedDelegateMethods & CPImageDelegate_imageDidError_)
|
||||
[_delegate imageDidError:self];
|
||||
}
|
||||
|
||||
@@ -470,7 +503,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
{
|
||||
_loadStatus = CPImageLoadStatusCancelled;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(imageDidAbort:)])
|
||||
if (_implementedDelegateMethods & CPImageDelegate_imageDidAbort_)
|
||||
[_delegate imageDidAbort:self];
|
||||
}
|
||||
|
||||
|
||||
+33
-40
@@ -87,26 +87,37 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
if (self)
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_DOMImageElement = document.createElement("img");
|
||||
_DOMImageElement.style.position = "absolute";
|
||||
_DOMImageElement.style.left = "0px";
|
||||
_DOMImageElement.style.top = "0px";
|
||||
|
||||
if ([CPPlatform supportsDragAndDrop])
|
||||
{
|
||||
_DOMImageElement.setAttribute("draggable", "true");
|
||||
_DOMImageElement.style["-khtml-user-drag"] = "element";
|
||||
}
|
||||
|
||||
CPDOMDisplayServerAppendChild(_DOMElement, _DOMImageElement);
|
||||
|
||||
_DOMImageElement.style.visibility = "hidden";
|
||||
[self _createDOMImageElement];
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_createDOMImageElement
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (_DOMImageElement)
|
||||
return;
|
||||
|
||||
_DOMImageElement = document.createElement("img");
|
||||
_DOMImageElement.style.position = "absolute";
|
||||
_DOMImageElement.style.left = "0px";
|
||||
_DOMImageElement.style.top = "0px";
|
||||
|
||||
if ([CPPlatform supportsDragAndDrop])
|
||||
{
|
||||
_DOMImageElement.setAttribute("draggable", "true");
|
||||
_DOMImageElement.style["-khtml-user-drag"] = "element";
|
||||
}
|
||||
|
||||
_DOMImageElement.style.visibility = "hidden";
|
||||
AppKitTagDOMElement(self, _DOMImageElement);
|
||||
|
||||
CPDOMDisplayServerAppendChild(_DOMElement, _DOMImageElement);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the view's image.
|
||||
*/
|
||||
@@ -138,6 +149,9 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
var newImage = [self objectValue];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
if (!_DOMImageElement)
|
||||
[self _createDOMImageElement];
|
||||
|
||||
_DOMImageElement.src = newImage ? [newImage filename] : [CPImageViewEmptyPlaceholderImage filename];
|
||||
#endif
|
||||
|
||||
@@ -253,7 +267,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (unsigned)imageScaling
|
||||
- (CPUInteger)imageScaling
|
||||
{
|
||||
return [self currentValueForThemeAttribute:@"image-scaling"];
|
||||
}
|
||||
@@ -488,7 +502,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
[_source setImage:image];
|
||||
}
|
||||
|
||||
- (void)valueForBinding:(CPString)aBinding
|
||||
- (id)valueForBinding:(CPString)aBinding
|
||||
{
|
||||
var image = [_source image];
|
||||
|
||||
@@ -517,28 +531,12 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
|
||||
*/
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_DOMImageElement = document.createElement("img");
|
||||
_DOMImageElement.style.position = "absolute";
|
||||
_DOMImageElement.style.left = "0px";
|
||||
_DOMImageElement.style.top = "0px";
|
||||
_DOMImageElement.style.visibility = "hidden";
|
||||
if ([CPPlatform supportsDragAndDrop])
|
||||
{
|
||||
_DOMImageElement.setAttribute("draggable", "true");
|
||||
_DOMImageElement.style["-khtml-user-drag"] = "element";
|
||||
}
|
||||
|
||||
if (typeof(appkit_tag_dom_elements) !== "undefined" && !!appkit_tag_dom_elements)
|
||||
_DOMImageElement.setAttribute("data-cappuccino-view", [self className]);
|
||||
#endif
|
||||
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.appendChild(_DOMImageElement);
|
||||
[self _createDOMImageElement];
|
||||
#endif
|
||||
|
||||
[self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]];
|
||||
@@ -564,17 +562,12 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
|
||||
// We do this in order to avoid encoding the _shadowView, which
|
||||
// should just automatically be created programmatically as needed.
|
||||
if (_shadowView)
|
||||
{
|
||||
var actualSubviews = _subviews;
|
||||
|
||||
_subviews = [_subviews copy];
|
||||
[_subviews removeObjectIdenticalTo:_shadowView];
|
||||
}
|
||||
[_shadowView removeFromSuperview];
|
||||
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
if (_shadowView)
|
||||
_subviews = actualSubviews;
|
||||
[self addSubview:_shadowView];
|
||||
|
||||
[aCoder encodeBool:_hasShadow forKey:CPImageViewHasShadowKey];
|
||||
[aCoder encodeInt:_imageAlignment forKey:CPImageViewImageAlignmentKey];
|
||||
|
||||
@@ -62,7 +62,7 @@ CPRatingLevelIndicatorStyle = 3;
|
||||
return "level-indicator";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-color": [CPNull null],
|
||||
|
||||
+102
-37
@@ -30,6 +30,17 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
@protocol CPMenuDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (void)menuWillOpen:(CPMenu)aMenu;
|
||||
- (void)menuDidClose:(CPMenu)aMenu;
|
||||
|
||||
@end
|
||||
|
||||
var CPMenuDelegate_menuWillOpen_ = 1 << 1,
|
||||
CPMenuDelegate_menuDidClose_ = 1 << 2;
|
||||
|
||||
CPMenuDidAddItemNotification = @"CPMenuDidAddItemNotification";
|
||||
CPMenuDidChangeItemNotification = @"CPMenuDidChangeItemNotification";
|
||||
CPMenuDidRemoveItemNotification = @"CPMenuDidRemoveItemNotification";
|
||||
@@ -50,26 +61,27 @@ var _CPMenuBarVisible = NO,
|
||||
*/
|
||||
@implementation CPMenu : CPObject
|
||||
{
|
||||
CPMenu _supermenu;
|
||||
CPMenu _supermenu;
|
||||
|
||||
CPString _title;
|
||||
CPString _name;
|
||||
CPString _title;
|
||||
CPString _name;
|
||||
|
||||
CPFont _font;
|
||||
CPFont _font;
|
||||
|
||||
float _minimumWidth;
|
||||
float _minimumWidth;
|
||||
|
||||
CPMutableArray _items;
|
||||
CPMutableArray _items;
|
||||
|
||||
BOOL _autoenablesItems;
|
||||
BOOL _showsStateColumn;
|
||||
BOOL _autoenablesItems;
|
||||
BOOL _showsStateColumn;
|
||||
|
||||
id _delegate;
|
||||
id <CPMenuDelegate> _delegate;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
int _highlightedIndex;
|
||||
_CPMenuWindow _menuWindow;
|
||||
int _highlightedIndex;
|
||||
_CPMenuWindow _menuWindow;
|
||||
|
||||
CPEvent _lastCloseEvent;
|
||||
CPEvent _lastCloseEvent;
|
||||
}
|
||||
|
||||
// Managing the Menu Bar
|
||||
@@ -278,7 +290,7 @@ var _CPMenuBarVisible = NO,
|
||||
@param aMenuItem the item to insert
|
||||
@param anIndex the index in the menu to insert the item.
|
||||
*/
|
||||
- (void)insertItem:(CPMenuItem)aMenuItem atIndex:(unsigned)anIndex
|
||||
- (void)insertItem:(CPMenuItem)aMenuItem atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
[self insertObject:aMenuItem inItemsAtIndex:anIndex];
|
||||
}
|
||||
@@ -291,7 +303,7 @@ var _CPMenuBarVisible = NO,
|
||||
@param anIndex the index location in the menu for the new item
|
||||
@return the new menu item
|
||||
*/
|
||||
- (CPMenuItem)insertItemWithTitle:(CPString)aTitle action:(SEL)anAction keyEquivalent:(CPString)aKeyEquivalent atIndex:(unsigned)anIndex
|
||||
- (CPMenuItem)insertItemWithTitle:(CPString)aTitle action:(SEL)anAction keyEquivalent:(CPString)aKeyEquivalent atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
var item = [[CPMenuItem alloc] initWithTitle:aTitle action:anAction keyEquivalent:aKeyEquivalent];
|
||||
|
||||
@@ -335,7 +347,7 @@ var _CPMenuBarVisible = NO,
|
||||
Removes the item at the specified index from the menu
|
||||
@param anIndex the index of the item to remove
|
||||
*/
|
||||
- (void)removeItemAtIndex:(unsigned)anIndex
|
||||
- (void)removeItemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
[self removeObjectFromItemsAtIndex:anIndex];
|
||||
}
|
||||
@@ -355,7 +367,7 @@ var _CPMenuBarVisible = NO,
|
||||
while (count--)
|
||||
[_items[count] setMenu:nil];
|
||||
|
||||
_highlightedIndex = CPNotFound;
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
// Because we are changing _items directly, be sure to notify KVO
|
||||
[self willChangeValueForKey:@"items"];
|
||||
@@ -621,7 +633,7 @@ var _CPMenuBarVisible = NO,
|
||||
*/
|
||||
- (void)update
|
||||
{
|
||||
if (![self autoenablesItems])
|
||||
if (!_autoenablesItems)
|
||||
return;
|
||||
|
||||
var items = [self itemArray];
|
||||
@@ -633,14 +645,24 @@ var _CPMenuBarVisible = NO,
|
||||
if ([item hasSubmenu])
|
||||
continue;
|
||||
|
||||
var validator = [CPApp targetForAction:[item action] to:[item target] from:item];
|
||||
// If there are enabled bindings for the item, they override anything else
|
||||
var binder = [CPBinder getBinding:CPEnabledBinding forObject:item];
|
||||
|
||||
if (binder)
|
||||
{
|
||||
[binder setValueFor:CPEnabledBinding];
|
||||
return;
|
||||
}
|
||||
|
||||
var validator = [CPApp targetForAction:[item action] to:[item target] from:item],
|
||||
shouldBeEnabled = YES;
|
||||
|
||||
if (!validator)
|
||||
{
|
||||
// If targetForAction: returns nil, it could be that there is no action.
|
||||
// If there is an action and nil is returned, no valid target could be found.
|
||||
if ([item action] || [item target])
|
||||
[item setEnabled:NO];
|
||||
shouldBeEnabled = NO;
|
||||
else
|
||||
{
|
||||
// Check to see if there is a target binding with an invalid selector
|
||||
@@ -655,16 +677,18 @@ var _CPMenuBarVisible = NO,
|
||||
selector = [options valueForKey:CPSelectorNameBindingOption];
|
||||
|
||||
if (target && selector && ![target respondsToSelector:CPSelectorFromString(selector)])
|
||||
[item setEnabled:NO];
|
||||
shouldBeEnabled = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (![validator respondsToSelector:[item action]])
|
||||
[item setEnabled:NO];
|
||||
shouldBeEnabled = NO;
|
||||
else if ([validator respondsToSelector:@selector(validateMenuItem:)])
|
||||
[item setEnabled:[validator validateMenuItem:item]];
|
||||
shouldBeEnabled = [validator validateMenuItem:item];
|
||||
else if ([validator respondsToSelector:@selector(validateUserInterfaceItem:)])
|
||||
[item setEnabled:[validator validateUserInterfaceItem:item]];
|
||||
shouldBeEnabled = [validator validateUserInterfaceItem:item];
|
||||
|
||||
[item setEnabled:shouldBeEnabled];
|
||||
}
|
||||
|
||||
[[_menuWindow _menuView] tile];
|
||||
@@ -843,6 +867,9 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
+ (void)popUpContextMenu:(CPMenu)aMenu withEvent:(CPEvent)anEvent forView:(CPView)aView withFont:(CPFont)aFont
|
||||
{
|
||||
// This is needed when we are making several rights click
|
||||
[[_CPMenuManager sharedMenuManager] cancelActiveMenu];
|
||||
|
||||
[aMenu _menuWillOpen];
|
||||
|
||||
if (!aFont)
|
||||
@@ -851,8 +878,6 @@ var _CPMenuBarVisible = NO,
|
||||
var theWindow = [aView window],
|
||||
menuWindow = [_CPMenuWindow menuWindowWithMenu:aMenu font:aFont];
|
||||
|
||||
[_CPMenuWindow poolMenuWindow:menuWindow];
|
||||
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
|
||||
|
||||
var constraintRect = [CPMenu _constraintRectForView:aView],
|
||||
@@ -928,9 +953,19 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
// Managing the Delegate
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPMenuDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(menuWillOpen:)])
|
||||
_implementedDelegateMethods |= CPMenuDelegate_menuWillOpen_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(menuDidClose:)])
|
||||
_implementedDelegateMethods |= CPMenuDelegate_menuDidClose_;
|
||||
}
|
||||
|
||||
- (id)delegate
|
||||
@@ -940,10 +975,7 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
- (void)_menuWillOpen
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(menuWillOpen:)])
|
||||
[delegate menuWillOpen:self];
|
||||
[self _sendDelegateMenuWillOpen];
|
||||
}
|
||||
|
||||
- (void)_menuDidClose
|
||||
@@ -952,10 +984,7 @@ var _CPMenuBarVisible = NO,
|
||||
// when a click on the button itself caused the menu to close.
|
||||
_lastCloseEvent = [CPApp currentEvent];
|
||||
|
||||
var delegate = [self delegate];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(menuDidClose:)])
|
||||
[delegate menuDidClose:self];
|
||||
[self _sendDelegateMenuDidClose];
|
||||
}
|
||||
|
||||
// Handling Tracking
|
||||
@@ -1048,7 +1077,7 @@ var _CPMenuBarVisible = NO,
|
||||
Sends the action of the menu item at the specified index.
|
||||
@param anIndex the index of the item
|
||||
*/
|
||||
- (void)performActionForItemAtIndex:(unsigned)anIndex
|
||||
- (void)performActionForItemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
var item = _items[anIndex];
|
||||
|
||||
@@ -1119,6 +1148,36 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPMenu (CPMenuDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate menuWillOpen
|
||||
*/
|
||||
- (void)_sendDelegateMenuWillOpen
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPMenuDelegate_menuWillOpen_))
|
||||
return;
|
||||
|
||||
[_delegate menuWillOpen:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate menuDidClose
|
||||
*/
|
||||
- (void)_sendDelegateMenuDidClose
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPMenuDelegate_menuDidClose_))
|
||||
return;
|
||||
|
||||
[_delegate menuDidClose:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPMenu (CPKeyValueCoding)
|
||||
|
||||
- (CPUInteger)countOfItems
|
||||
@@ -1151,6 +1210,7 @@ var _CPMenuBarVisible = NO,
|
||||
return;
|
||||
|
||||
[aMenuItem setMenu:self];
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
[_items insertObject:aMenuItem atIndex:anIndex];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
@@ -1165,6 +1225,7 @@ var _CPMenuBarVisible = NO,
|
||||
return;
|
||||
|
||||
[[_items objectAtIndex:anIndex] setMenu:nil];
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
[_items removeObjectAtIndex:anIndex];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
@@ -1178,7 +1239,8 @@ var _CPMenuBarVisible = NO,
|
||||
var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
CPMenuNameKey = @"CPMenuNameKey",
|
||||
CPMenuItemsKey = @"CPMenuItemsKey",
|
||||
CPMenuShowsStateColumnKey = @"CPMenuShowsStateColumnKey";
|
||||
CPMenuShowsStateColumnKey = @"CPMenuShowsStateColumnKey",
|
||||
CPMenuAutoEnablesItemsKey = @"CPMenuAutoEnablesItemsKey";
|
||||
|
||||
@implementation CPMenu (CPCoding)
|
||||
|
||||
@@ -1200,7 +1262,7 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
|
||||
_showsStateColumn = ![aCoder containsValueForKey:CPMenuShowsStateColumnKey] || [aCoder decodeBoolForKey:CPMenuShowsStateColumnKey];
|
||||
|
||||
_autoenablesItems = YES;
|
||||
_autoenablesItems = ![aCoder containsValueForKey:CPMenuAutoEnablesItemsKey] || [aCoder decodeBoolForKey:CPMenuAutoEnablesItemsKey];
|
||||
|
||||
[self setMinimumWidth:0];
|
||||
}
|
||||
@@ -1223,6 +1285,9 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
|
||||
if (!_showsStateColumn)
|
||||
[aCoder encodeBool:_showsStateColumn forKey:CPMenuShowsStateColumnKey];
|
||||
|
||||
if (!_autoenablesItems)
|
||||
[aCoder encodeBool:_autoenablesItems forKey:CPMenuAutoEnablesItemsKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -407,6 +407,15 @@ var STICKY_TIME_INTERVAL = 0.4,
|
||||
[menu cancelTracking];
|
||||
}
|
||||
|
||||
- (void)cancelActiveMenu
|
||||
{
|
||||
if (CPApp._activeMenu)
|
||||
{
|
||||
[self completeTracking];
|
||||
_menuContainerStack = [];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)completeTracking
|
||||
{
|
||||
var trackingMenu = [self trackingMenu];
|
||||
|
||||
@@ -72,7 +72,8 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
|
||||
+ (void)poolMenuWindow:(_CPMenuWindow)aMenuWindow
|
||||
{
|
||||
if (!aMenuWindow || _CPMenuWindowPool.length >= _CPMenuWindowPoolCapacity)
|
||||
// FIXME :the poolMenuWindow is called too many times somewhere....
|
||||
if (!aMenuWindow || _CPMenuWindowPool.length >= _CPMenuWindowPoolCapacity || [_CPMenuWindowPool containsObject:aMenuWindow])
|
||||
return;
|
||||
|
||||
_CPMenuWindowPool.push(aMenuWindow);
|
||||
@@ -434,7 +435,7 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2;
|
||||
return "menu-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"menu-window-more-above-image": [CPNull null],
|
||||
|
||||
@@ -166,6 +166,9 @@ var CPMenuItemStringRepresentationDictionary = @{
|
||||
if (_isEnabled === isEnabled)
|
||||
return;
|
||||
|
||||
if (!isEnabled && [self isHighlighted])
|
||||
[_menu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
_isEnabled = !!isEnabled;
|
||||
|
||||
[_menuItemView setDirty];
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
return "menu-item-bar-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"horizontal-margin": 9.0,
|
||||
@@ -84,25 +84,25 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPColor)setTextColor:(CPColor)aColor
|
||||
- (void)setTextColor:(CPColor)aColor
|
||||
{
|
||||
_textColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)setTextShadowColor:(CPColor)aColor
|
||||
- (void)setTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
_textShadowColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)setHighlightTextColor:(CPColor)aColor
|
||||
- (void)setHighlightTextColor:(CPColor)aColor
|
||||
{
|
||||
_highlightTextColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)setHighlightTextShadowColor:(CPColor)aColor
|
||||
- (void)setHighlightTextShadowColor:(CPColor)aColor
|
||||
{
|
||||
_highlightTextShadowColor = aColor;
|
||||
[self setNeedsLayout];
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
return "menu-item-standard-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"submenu-indicator-color": [CPNull null],
|
||||
@@ -336,6 +336,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isHighlighted
|
||||
{
|
||||
return _highlighted;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPMenuItemSubmenuIndicatorView : CPView
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
@implementation _CPMenuItemView : CPView
|
||||
{
|
||||
CPMenuItem _menuItem;
|
||||
CPView _view;
|
||||
CPView _view @accessors(property=view, readonly);
|
||||
|
||||
CPFont _font;
|
||||
CPColor _textColor;
|
||||
@@ -53,7 +53,7 @@
|
||||
return "menu-item-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{};
|
||||
}
|
||||
@@ -112,7 +112,6 @@
|
||||
_view = menuItemView;
|
||||
}
|
||||
}
|
||||
|
||||
else if ([_menuItem menu] == [CPApp mainMenu])
|
||||
{
|
||||
if (![_view isKindOfClass:[_CPMenuItemMenuBarView class]])
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
CPCountedSet _observedKeys;
|
||||
}
|
||||
|
||||
+ (id)initialize
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== [CPObjectController class])
|
||||
return;
|
||||
@@ -572,7 +572,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
}
|
||||
}
|
||||
|
||||
- (void)insertObject:(id)anObject atIndex:(unsigned)anIndex
|
||||
- (void)insertObject:(id)anObject atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
for (var i = 0, count = [_observationProxies count]; i < count; i++)
|
||||
{
|
||||
@@ -592,7 +592,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
[super insertObject:anObject atIndex:anIndex];
|
||||
}
|
||||
|
||||
- (void)removeObjectAtIndex:(unsigned)anIndex
|
||||
- (void)removeObjectAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
var currentObject = [self objectAtIndex:anIndex];
|
||||
|
||||
@@ -614,7 +614,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
[super removeObjectAtIndex:anIndex];
|
||||
}
|
||||
|
||||
- (_CPObservableArray)objectsAtIndexes:(CPIndexSet)theIndexes
|
||||
- (CPArray)objectsAtIndexes:(CPIndexSet)theIndexes
|
||||
{
|
||||
return [_CPObservableArray arrayWithArray:[super objectsAtIndexes:theIndexes]];
|
||||
}
|
||||
@@ -629,7 +629,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
[self removeObjectAtIndex:[self count]];
|
||||
}
|
||||
|
||||
- (void)replaceObjectAtIndex:(unsigned)anIndex withObject:(id)anObject
|
||||
- (void)replaceObjectAtIndex:(CPUInteger)anIndex withObject:(id)anObject
|
||||
{
|
||||
var currentObject = [self objectAtIndex:anIndex];
|
||||
|
||||
|
||||
+180
-42
@@ -52,7 +52,6 @@ var CPOutlineViewDataSource_outlineView_objectValue_forTableColumn_byItem_
|
||||
CPOutlineViewDataSource_outlineView_sortDescriptorsDidChange_ = 1 << 11;
|
||||
|
||||
var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_ = 1 << 1,
|
||||
CPOutlineViewDelegate_outlineView_viewForTableColumn_item_ = 1 << 26,
|
||||
CPOutlineViewDelegate_outlineView_didClickTableColumn_ = 1 << 2,
|
||||
CPOutlineViewDelegate_outlineView_didDragTableColumn_ = 1 << 3,
|
||||
CPOutlineViewDelegate_outlineView_heightOfRowByItem_ = 1 << 4,
|
||||
@@ -75,8 +74,10 @@ var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_
|
||||
CPOutlineViewDelegate_outlineView_typeSelectStringForTableColumn_item_ = 1 << 21,
|
||||
CPOutlineViewDelegate_outlineView_willDisplayOutlineView_forTableColumn_item_ = 1 << 22,
|
||||
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 23,
|
||||
CPOutlineViewDelegate_selectionShouldChangeInOutlineView_ = 1 << 24,
|
||||
CPOutlineViewDelegate_outlineView_menuForTableColumn_item_ = 1 << 25;
|
||||
CPOutlineViewDelegate_outlineView_willRemoveView_forTableColumn_item_ = 1 << 24,
|
||||
CPOutlineViewDelegate_selectionShouldChangeInOutlineView_ = 1 << 25,
|
||||
CPOutlineViewDelegate_outlineView_menuForTableColumn_item_ = 1 << 26,
|
||||
CPOutlineViewDelegate_outlineView_viewForTableColumn_item_ = 1 << 27;
|
||||
|
||||
CPOutlineViewDropOnItemIndex = -1;
|
||||
|
||||
@@ -88,6 +89,58 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
#define SHOULD_SELECT_ITEM(anOutlineView, anItem) (!((anOutlineView)._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_) || [(anOutlineView)._outlineViewDelegate outlineView:(anOutlineView) shouldSelectItem:(anItem)])
|
||||
|
||||
|
||||
@protocol CPOutlineViewDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView isGroupItem:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldCollapseItem:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldEditTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldExpandItem:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldReorderColumn:(CPInteger)columnIndex toColumn:(CPInteger)newColumnIndex;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldSelectItem:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldSelectTableColumn:(CPTableColumn)aTableColumn;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldShowOutlineDisclosureControlForItem:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldShowViewExpansionForTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldTrackView:(CPView)aView forTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldTypeSelectForEvent:(CPEvent)anEvent withCurrentSearchString:(CPString)searchString;
|
||||
- (BOOL)selectionShouldChangeInOutlineView:(CPOutlineView)anOutlineView;
|
||||
- (CPIndexSet)outlineView:(CPOutlineView)anOutlineView selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes;
|
||||
- (CPMenu)outlineView:(CPOutlineView)anOutlineView menuForTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (CPString)outlineView:(CPOutlineView)anOutlineView toolTipForView:(CPView)aView rect:(CGRect)aRect tableColumn:(CPTableColumn)aTableColumn item:(id)anItem mouseLocation:(CGPoint)mouseLocation;
|
||||
- (CPString)outlineView:(CPOutlineView)anOutlineView typeSelectStringForTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (CPView)outlineView:(CPOutlineView)anOutlineView dataViewForTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (CPView)outlineView:(CPOutlineView)anOutlineView viewForTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (float)outlineView:(CPOutlineView)anOutlineView heightOfRowByItem:(id)anItem;
|
||||
- (float)outlineView:(CPOutlineView)anOutlineView sizeToFitWidthOfColumn:(CPTableColumn)aTableColumn;
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView nextTypeSelectMatchFromItem:(id)startItem toItem:(id)endItem forString:(CPString)searchString;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView didClickTableColumn:(CPTableColumn)aTableColumn;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView didDragTableColumn:(CPTableColumn)aTableColumn;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView mouseDownInHeaderOfTableColumn:(CPTableColumn)aTableColumn;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView willDisplayOutlineView:(CPView)aView forTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView willDisplayView:(CPView)aView forTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView willRemoveView:(CPView)aView forTableColumn:(CPTableColumn)aTableColumn item:(id)anItem;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@protocol CPOutlineViewDataSource <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView acceptDrop:(id /*<CPDraggingInfo>*/)info item:(id)anItem childIndex:(CPInteger)anIndex;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView shouldDeferDisplayingChildrenOfItem:(id)anItem;
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView writeItems:(CPArray)items toPasteboard:(CPPasteboard)pboard;
|
||||
- (CPArray)outlineView:(CPOutlineView)anOutlineView namesOfPromisedFilesDroppedAtDestination:(CPURL)dropDestination forDraggedItems:(CPArray)items;
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id /*<CPDraggingInfo>*/)info proposedItem:(id)anItem proposedChildIndex:(CPInteger)anIndex;
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id /*<CPDraggingInfo>*/)info proposedRow:(int)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation;
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView itemForPersistentObject:(id)anObject;
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView objectValueforTableColumn:(CPTableColumn)aTableColumn byItem:(id)anItem;
|
||||
- (id)outlineView:(CPOutlineView)anOutlineView persistentObjectForItem:(id)anItem;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView setObjectValue:(id)anObject forTableColumn:(CPTableColumn)aTableColumn byItem:(id)anItem;
|
||||
- (void)outlineView:(CPOutlineView)anOutlineView sortDescriptorsDidChange:(CPArray)oldDescriptors;
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPOutlineView
|
||||
@@ -105,34 +158,34 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
*/
|
||||
@implementation CPOutlineView : CPTableView
|
||||
{
|
||||
id _outlineViewDataSource;
|
||||
id _outlineViewDelegate;
|
||||
CPTableColumn _outlineTableColumn;
|
||||
id <CPOutlineViewDataSource> _outlineViewDataSource;
|
||||
id <CPOutlineViewDelegate> _outlineViewDelegate;
|
||||
CPTableColumn _outlineTableColumn;
|
||||
|
||||
float _indentationPerLevel;
|
||||
BOOL _indentationMarkerFollowsDataView;
|
||||
float _indentationPerLevel;
|
||||
BOOL _indentationMarkerFollowsDataView;
|
||||
|
||||
CPInteger _implementedOutlineViewDataSourceMethods;
|
||||
CPInteger _implementedOutlineViewDelegateMethods;
|
||||
CPInteger _implementedOutlineViewDataSourceMethods;
|
||||
CPInteger _implementedOutlineViewDelegateMethods;
|
||||
|
||||
Object _rootItemInfo;
|
||||
CPMutableArray _itemsForRows;
|
||||
Object _itemInfosForItems;
|
||||
Object _rootItemInfo;
|
||||
CPMutableArray _itemsForRows;
|
||||
Object _itemInfosForItems;
|
||||
|
||||
CPControl _disclosureControlPrototype;
|
||||
CPArray _disclosureControlsForRows;
|
||||
CPData _disclosureControlData;
|
||||
CPArray _disclosureControlQueue;
|
||||
CPControl _disclosureControlPrototype;
|
||||
CPArray _disclosureControlsForRows;
|
||||
CPData _disclosureControlData;
|
||||
CPArray _disclosureControlQueue;
|
||||
|
||||
BOOL _shouldRetargetItem;
|
||||
id _retargetedItem;
|
||||
BOOL _shouldRetargetItem;
|
||||
id _retargetedItem;
|
||||
|
||||
BOOL _shouldRetargetChildIndex;
|
||||
CPInteger _retargedChildIndex;
|
||||
CPTimer _dragHoverTimer;
|
||||
id _dropItem;
|
||||
BOOL _shouldRetargetChildIndex;
|
||||
CPInteger _retargedChildIndex;
|
||||
CPTimer _dragHoverTimer;
|
||||
id _dropItem;
|
||||
|
||||
BOOL _coalesceSelectionNotificationState;
|
||||
BOOL _coalesceSelectionNotificationState;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -234,7 +287,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
If you want the drag to begin you should return YES and place the drag data on the pboard.
|
||||
@code - (BOOL)outlineView:(CPOutlineView)outlineView writeItems:(CPArray)items toPasteboard:(CPPasteboard)pboard; @endcode
|
||||
*/
|
||||
- (void)setDataSource:(id)aDataSource
|
||||
- (void)setDataSource:(id <CPOutlineViewDataSource>)aDataSource
|
||||
{
|
||||
if (_outlineViewDataSource === aDataSource)
|
||||
return;
|
||||
@@ -368,6 +421,10 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
*/
|
||||
- (void)expandItem:(id)anItem expandChildren:(BOOL)shouldExpandChildren
|
||||
{
|
||||
if ([self _delegateRespondsToShouldExpandItem])
|
||||
if ([_outlineViewDelegate outlineView:self shouldExpandItem:anItem] == NO)
|
||||
return;
|
||||
|
||||
var itemInfo = null;
|
||||
|
||||
if (!anItem)
|
||||
@@ -443,6 +500,10 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
if (!anItem)
|
||||
return;
|
||||
|
||||
if ([self _delegateRespondsToShouldCollapseItem])
|
||||
if ([_outlineViewDelegate outlineView:self shouldCollapseItem:anItem] == NO)
|
||||
return;
|
||||
|
||||
var itemInfo = _itemInfosForItems[[anItem UID]];
|
||||
|
||||
if (!itemInfo)
|
||||
@@ -735,6 +796,29 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return frame;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Select or deselect rows, this is overridden because we need to change the color of the outline control.
|
||||
*/
|
||||
- (void)_setSelectedRowIndexes:(CPIndexSet)rows
|
||||
{
|
||||
if (_disclosureControlsForRows.length)
|
||||
{
|
||||
var indexes = [_selectedRowIndexes copy];
|
||||
[indexes removeIndexesInRange:CPMakeRange(_disclosureControlsForRows.length, _itemsForRows.length - _disclosureControlsForRows.length)];
|
||||
[[_disclosureControlsForRows objectsAtIndexes:indexes] makeObjectsPerformSelector:@selector(unsetThemeState:) withObject:CPThemeStateSelected];
|
||||
}
|
||||
|
||||
[super _setSelectedRowIndexes:rows];
|
||||
|
||||
if (_disclosureControlsForRows.length)
|
||||
{
|
||||
var indexes = [_selectedRowIndexes copy];
|
||||
[indexes removeIndexesInRange:CPMakeRange(_disclosureControlsForRows.length, _itemsForRows.length - _disclosureControlsForRows.length)];
|
||||
[[_disclosureControlsForRows objectsAtIndexes:indexes] makeObjectsPerformSelector:@selector(setThemeState:) withObject:CPThemeStateSelected];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Sets the delegate for the outlineview.
|
||||
@@ -811,7 +895,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
@code - (int)outlineView:(CPOutlineView)outlineView heightOfRowByItem:(id)anItem; @endcode
|
||||
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPOutlineViewDelegate>)aDelegate
|
||||
{
|
||||
if (_outlineViewDelegate === aDelegate)
|
||||
return;
|
||||
@@ -897,6 +981,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
CPOutlineViewDelegate_outlineView_typeSelectStringForTableColumn_item_ , @selector(outlineView:typeSelectStringForTableColumn:item:),
|
||||
CPOutlineViewDelegate_outlineView_willDisplayOutlineView_forTableColumn_item_ , @selector(outlineView:willDisplayOutlineView:forTableColumn:item:),
|
||||
CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ , @selector(outlineView:willDisplayView:forTableColumn:item:),
|
||||
CPOutlineViewDelegate_outlineView_willRemoveView_forTableColumn_item_ , @selector(outlineView:willRemoveView:forTableColumn:item:),
|
||||
CPOutlineViewDelegate_selectionShouldChangeInOutlineView_ , @selector(selectionShouldChangeInOutlineView:),
|
||||
CPOutlineViewDelegate_outlineView_menuForTableColumn_item_ , @selector(outlineView:menuForTableColumn:item:)
|
||||
],
|
||||
@@ -1154,7 +1239,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (id)_parentItemForUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex atMouseOffset:(CGPoint)theOffset
|
||||
- (id)_parentItemForUpperRow:(CPInteger)theUpperRowIndex andLowerRow:(CPInteger)theLowerRowIndex atMouseOffset:(CGPoint)theOffset
|
||||
{
|
||||
if (_shouldRetargetItem)
|
||||
return _retargetedItem;
|
||||
@@ -1184,7 +1269,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (CGRect)_rectForDropHighlightViewBetweenUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex offset:(CGPoint)theOffset
|
||||
- (CGRect)_rectForDropHighlightViewBetweenUpperRow:(CPInteger)theUpperRowIndex andLowerRow:(CPInteger)theLowerRowIndex offset:(CGPoint)theOffset
|
||||
{
|
||||
// Call super and the update x to reflect the current indentation level
|
||||
var rect = [super _rectForDropHighlightViewBetweenUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex offset:theOffset],
|
||||
@@ -1479,12 +1564,12 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
[super keyDown:anEvent];
|
||||
}
|
||||
|
||||
- (CPView)_viewForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
- (CPView)_sendDelegateViewForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
return [_outlineViewDelegate outlineView:self viewForTableColumn:aTableColumn item:[self itemAtRow:aRow]];
|
||||
}
|
||||
|
||||
- (CPView)_dataViewForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
- (CPView)_sendDelegateDataViewForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
return [_outlineViewDelegate outlineView:self dataViewForTableColumn:aTableColumn item:[self itemAtRow:aRow]];
|
||||
}
|
||||
@@ -1512,6 +1597,34 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return [super _hitTest:aView];
|
||||
}
|
||||
|
||||
- (BOOL)_delegateRespondsToShouldExpandItem
|
||||
{
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldExpandItem_;
|
||||
}
|
||||
|
||||
- (BOOL)_delegateRespondsToShouldCollapseItem
|
||||
{
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldCollapseItem_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Return YES if the delegate implements outlineView:selectionIndexesForProposedSelection
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToSelectionIndexesForProposedSelection
|
||||
{
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_selectionIndexesForProposedSelection_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Return YES if the delegate implements outlineView:shouldSelectItem:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToShouldSelectRow
|
||||
{
|
||||
return _implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
|
||||
@@ -1709,7 +1822,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView writeItems:items toPasteboard:thePasteboard];
|
||||
}
|
||||
|
||||
- (int)_childIndexForDropOperation:(CPTableViewDropOperation)theDropOperation row:(int)theRow offset:(CGPoint)theOffset
|
||||
- (int)_childIndexForDropOperation:(CPTableViewDropOperation)theDropOperation row:(CPInteger)theRow offset:(CGPoint)theOffset
|
||||
{
|
||||
if (_outlineView._shouldRetargetChildIndex)
|
||||
return _outlineView._retargedChildIndex;
|
||||
@@ -1733,7 +1846,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return childIndex;
|
||||
}
|
||||
|
||||
- (void)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation row:(int)theRow offset:(CGPoint)theOffset
|
||||
- (void)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation row:(CPInteger)theRow offset:(CGPoint)theOffset
|
||||
{
|
||||
if (theDropOperation === CPTableViewDropAbove)
|
||||
return [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset]
|
||||
@@ -1741,8 +1854,8 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [_outlineView itemAtRow:theRow];
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id < CPDraggingInfo >)theInfo
|
||||
proposedRow:(int)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id /*< CPDraggingInfo >*/)theInfo
|
||||
proposedRow:(CPInteger)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_))
|
||||
return CPDragOperationNone;
|
||||
@@ -1761,7 +1874,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView validateDrop:theInfo proposedItem:parentItem proposedChildIndex:childIndex];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id <CPDraggingInfo>)theInfo row:(int)theRow dropOperation:(CPTableViewDropOperation)theOperation
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id /*<CPDraggingInfo>*/)theInfo row:(CPInteger)theRow dropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_))
|
||||
return NO;
|
||||
@@ -1805,7 +1918,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)theTableView shouldSelectRow:(int)theRow
|
||||
- (BOOL)tableView:(CPTableView)theTableView shouldSelectRow:(CPInteger)theRow
|
||||
{
|
||||
return SHOULD_SELECT_ITEM(_outlineView, [_outlineView itemAtRow:theRow]);
|
||||
}
|
||||
@@ -1815,7 +1928,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return SELECTION_SHOULD_CHANGE(_outlineView);
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)aColumn row:(int)aRow
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)aColumn row:(CPInteger)aRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldEditTableColumn_item_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldEditTableColumn:aColumn item:[_outlineView itemAtRow:aRow]];
|
||||
@@ -1823,7 +1936,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (float)tableView:(CPTableView)theTableView heightOfRow:(int)theRow
|
||||
- (float)tableView:(CPTableView)theTableView heightOfRow:(CPInteger)theRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_heightOfRowByItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView heightOfRowByItem:[_outlineView itemAtRow:theRow]];
|
||||
@@ -1831,7 +1944,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [theTableView rowHeight];
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView willDisplayView:(id)aView forTableColumn:(CPTableColumn)aTableColumn row:(int)aRowIndex
|
||||
- (void)tableView:(CPTableView)aTableView willDisplayView:(id)aView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRowIndex
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_))
|
||||
{
|
||||
@@ -1840,7 +1953,16 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(int)aRow
|
||||
- (void)tableView:(CPTableView)aTableView willRemoveView:(id)aView forTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRowIndex
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_willRemoveView_forTableColumn_item_))
|
||||
{
|
||||
var item = [_outlineView itemAtRow:aRowIndex];
|
||||
[_outlineView._outlineViewDelegate outlineView:_outlineView willRemoveView:aView forTableColumn:aTableColumn item:item];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(CPInteger)aRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_isGroupItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView isGroupItem:[_outlineView itemAtRow:aRow]];
|
||||
@@ -1848,7 +1970,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPMenu)tableView:(CPTableView)aTableView menuForTableColumn:(CPTableColumn)aTableColumn row:(int)aRow
|
||||
- (CPMenu)tableView:(CPTableView)aTableView menuForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_menuForTableColumn_item_))
|
||||
{
|
||||
@@ -1861,6 +1983,22 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [_outlineView menu] || [[_outlineView class] defaultMenu];
|
||||
}
|
||||
|
||||
- (CPIndexSet)tableView:(CPTableView)aTableView selectionIndexesForProposedSelection:(CPIndexSet)anIndexSet
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_selectionIndexesForProposedSelection_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView selectionIndexesForProposedSelection:anIndexSet];
|
||||
|
||||
return anIndexSet;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldSelectTableColumn:(CPTableColumn)aTableColumn
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldSelectTableColumn:aTableColumn];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPDisclosureButton : CPButton
|
||||
@@ -1878,7 +2016,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setState:(CPState)aState
|
||||
- (void)setState:(CPInteger)aState
|
||||
{
|
||||
[super setState:aState];
|
||||
|
||||
|
||||
+11
-4
@@ -191,10 +191,12 @@ var CPPasteboards = nil,
|
||||
_owners = @{};
|
||||
_provided = @{};
|
||||
|
||||
var count = _types.length;
|
||||
|
||||
while (count--)
|
||||
[_owners setObject:anOwner forKey:_types[count]];
|
||||
if (anOwner)
|
||||
{
|
||||
var count = _types.length;
|
||||
while (count--)
|
||||
[_owners setObject:anOwner forKey:_types[count]];
|
||||
}
|
||||
|
||||
if (_nativePasteboard && shouldUpdate)
|
||||
{
|
||||
@@ -205,6 +207,7 @@ var CPPasteboards = nil,
|
||||
_nativePasteboard.declareTypes_(nativeTypes);
|
||||
_changeCount = _nativePasteboard.changeCount();
|
||||
}
|
||||
|
||||
return ++_changeCount;
|
||||
}
|
||||
|
||||
@@ -243,6 +246,10 @@ var CPPasteboards = nil,
|
||||
*/
|
||||
- (void)setString:(CPString)aString forType:(CPString)aType
|
||||
{
|
||||
// Putting a non-string on the string pasteboard can lead to strange crashes.
|
||||
if (aString && aString.isa && ![aString isKindOfClass:CPString])
|
||||
[CPException raise:CPInvalidArgumentException reason:"CPPasteboard setString:forType: must be called with a string."];
|
||||
|
||||
[self setPropertyList:aString forType:aType];
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
Selects the item at the specified index
|
||||
@param anIndex the index of the item to select
|
||||
*/
|
||||
- (void)setObjectValue:(int)anIndex
|
||||
- (void)setObjectValue:(id)anIndex
|
||||
{
|
||||
var indexOfSelectedItem = [self objectValue];
|
||||
|
||||
@@ -344,7 +344,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
Returns the item at the specified index or \c nil if the item does not exist.
|
||||
@param anIndex the index of the item to obtain
|
||||
*/
|
||||
- (CPMenuItem)itemAtIndex:(unsigned)anIndex
|
||||
- (CPMenuItem)itemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
return [[self menu] itemAtIndex:anIndex];
|
||||
}
|
||||
@@ -353,7 +353,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
Returns the title of the item at the specified index or \c nil if no item exists.
|
||||
@param anIndex the index of the item
|
||||
*/
|
||||
- (CPString)itemTitleAtIndex:(unsigned)anIndex
|
||||
- (CPString)itemTitleAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
return [[[self menu] itemAtIndex:anIndex] title];
|
||||
}
|
||||
@@ -838,7 +838,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
[self _setContentValuesIfNeeded:contentArray];
|
||||
}
|
||||
|
||||
- (void)valueForBinding:(CPString)aBinding
|
||||
- (id)valueForBinding:(CPString)aBinding
|
||||
{
|
||||
return [self _content];
|
||||
}
|
||||
@@ -910,7 +910,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
|
||||
- (void)setValue:(CPArray)aValue forBinding:(CPString)aBinding
|
||||
{
|
||||
[super _setContent:aValue];
|
||||
}
|
||||
|
||||
+19
-8
@@ -30,6 +30,16 @@
|
||||
@import "CPView.j"
|
||||
@import "_CPPopoverWindow.j"
|
||||
|
||||
@protocol CPPopoverDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)popoverShouldClose:(CPPopover)aPopover;
|
||||
- (void)popoverWillClose:(CPPopover)aPopover;
|
||||
- (void)popoverDidClose:(CPPopover)aPopover;
|
||||
- (void)popoverWillShow:(CPPopover)aPopover;
|
||||
- (void)popoverDidShow:(CPPopover)aPopover;
|
||||
|
||||
@end
|
||||
|
||||
CPPopoverBehaviorApplicationDefined = 0;
|
||||
CPPopoverBehaviorTransient = 1;
|
||||
@@ -60,15 +70,15 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
*/
|
||||
@implementation CPPopover : CPResponder
|
||||
{
|
||||
@outlet CPViewController _contentViewController @accessors(property=contentViewController);
|
||||
@outlet id _delegate @accessors(getter=delegate);
|
||||
@outlet CPViewController _contentViewController @accessors(property=contentViewController);
|
||||
@outlet id <CPPopoverDelegate> _delegate @accessors(getter=delegate);
|
||||
|
||||
BOOL _animates @accessors(getter=animates);
|
||||
int _appearance @accessors(property=appearance);
|
||||
int _behavior @accessors(getter=behavior);
|
||||
BOOL _animates @accessors(getter=animates);
|
||||
int _appearance @accessors(property=appearance);
|
||||
int _behavior @accessors(getter=behavior);
|
||||
|
||||
_CPPopoverWindow _popoverWindow;
|
||||
int _implementedDelegateMethods;
|
||||
_CPPopoverWindow _popoverWindow;
|
||||
int _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +194,7 @@ Set the behavior of the CPPopover. It can be:
|
||||
[_popoverWindow setStyleMask:[self styleMaskForBehavior]];
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPPopoverDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
@@ -238,6 +248,7 @@ Set the behavior of the CPPopover. It can be:
|
||||
_popoverWindow = [[_CPPopoverWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:[self styleMaskForBehavior]];
|
||||
}
|
||||
|
||||
[_popoverWindow setPlatformWindow:[[positioningView window] platformWindow]];
|
||||
[_popoverWindow setAppearance:_appearance];
|
||||
[_popoverWindow setAnimates:_animates];
|
||||
[_popoverWindow setDelegate:self];
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ CPRadioImageOffset = 4.0;
|
||||
[_radioGroup _setSelectedRadio:self];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)anObject
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
|
||||
{
|
||||
[super sendAction:anAction to:anObject];
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ CPDeleteForwardKeyCode = 46;
|
||||
var CPResponderNextResponderKey = @"CPResponderNextResponderKey",
|
||||
CPResponderMenuKey = @"CPResponderMenuKey";
|
||||
|
||||
@implementation CPResponder (CPCoding)
|
||||
@implementation CPResponder (CPCoding) <CPCoding>
|
||||
|
||||
/*!
|
||||
Initializes the responder with data from a coder.
|
||||
|
||||
@@ -484,7 +484,7 @@
|
||||
|
||||
#pragma mark RuleEditor delegate methods
|
||||
|
||||
- (int)_queryNumberOfChildrenOfItem:(id)rowItem withRowType:(int)type
|
||||
- (int)_queryNumberOfChildrenOfItem:(id)rowItem withRowType:(CPRuleEditorRowType)type
|
||||
{
|
||||
if (rowItem == nil)
|
||||
{
|
||||
@@ -494,7 +494,7 @@
|
||||
return [[rowItem children] count];
|
||||
}
|
||||
|
||||
- (id)_queryChild:(int)childIndex ofItem:(id)rowItem withRowType:(int)type
|
||||
- (id)_queryChild:(int)childIndex ofItem:(id)rowItem withRowType:(CPRuleEditorRowType)type
|
||||
{
|
||||
if (rowItem == nil)
|
||||
{
|
||||
@@ -505,7 +505,7 @@
|
||||
return [[rowItem children] objectAtIndex:childIndex];
|
||||
}
|
||||
|
||||
- (id)_queryValueForItem:(id)rowItem inRow:(int)rowIndex
|
||||
- (id)_queryValueForItem:(id)rowItem inRow:(CPInteger)rowIndex
|
||||
{
|
||||
return [rowItem displayValue];
|
||||
}
|
||||
@@ -516,7 +516,7 @@ var CPPredicateTemplatesKey = @"CPPredicateTemplates";
|
||||
|
||||
@implementation CPPredicateEditor (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(id)aCoder
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
@@ -531,7 +531,7 @@ var CPPredicateTemplatesKey = @"CPPredicateTemplates";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(id)aCoder
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeObject:_allTemplates forKey:CPPredicateTemplatesKey];
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
@import "CPMenuItem.j"
|
||||
@import "CPTextField.j"
|
||||
|
||||
// NOTE: CPDatePicker is not implemented yet
|
||||
@class CPDatePicker
|
||||
@import "CPDatePicker.j"
|
||||
|
||||
|
||||
CPUndefinedAttributeType = 0;
|
||||
@@ -488,7 +487,36 @@ CPTransformableAttributeType = 1800;
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
return [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:self]];
|
||||
var views = [CPArray array];
|
||||
|
||||
var copy = [[[self class] alloc] init];
|
||||
[copy _setTemplateType:_templateType];
|
||||
[copy _setOptions:_predicateOptions];
|
||||
[copy _setModifier:_predicateModifier];
|
||||
[copy _setLeftAttributeType:_leftAttributeType];
|
||||
[copy _setRightAttributeType:_rightAttributeType];
|
||||
[copy setLeftIsWildcard:_leftIsWildcard];
|
||||
[copy setRightIsWildcard:_rightIsWildcard];
|
||||
|
||||
[_views enumerateObjectsUsingBlock:function(aView, idx, stop)
|
||||
{
|
||||
var vcopy;
|
||||
|
||||
if ([aView implementsSelector:@selector(copy)])
|
||||
{
|
||||
vcopy = [aView copy];
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:aView]];
|
||||
}
|
||||
|
||||
[views addObject:vcopy];
|
||||
}];
|
||||
|
||||
[copy setTemplateViews:views];
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
+ (id)_operatorsForAttributeType:(CPAttributeType)attributeType
|
||||
@@ -680,7 +708,7 @@ CPTransformableAttributeType = 1800;
|
||||
view = [[CPCheckBox alloc] initWithFrame:CGRectMake(0, 0, 50, 26)];
|
||||
}
|
||||
else if (attributeType == CPDateAttributeType)
|
||||
view = [[CPDatePicker alloc] initWithFrame:CGRectMake(0, 0, 150, 26)];
|
||||
view = [[CPDatePicker alloc] initWithFrame:CGRectMake(0, 0, 180, 26)];
|
||||
else
|
||||
return nil;
|
||||
|
||||
@@ -702,12 +730,12 @@ CPTransformableAttributeType = 1800;
|
||||
return textField;
|
||||
}
|
||||
|
||||
- (void)_setOptions:(unsigned int)options
|
||||
- (void)_setOptions:(unsigned)options
|
||||
{
|
||||
_predicateOptions = options;
|
||||
}
|
||||
|
||||
- (void)_setModifier:(unsigned int)modifier
|
||||
- (void)_setModifier:(unsigned)modifier
|
||||
{
|
||||
_predicateModifier = modifier;
|
||||
}
|
||||
@@ -797,5 +825,31 @@ var CPPredicateTemplateTypeKey = @"CPPredicateTemplateType",
|
||||
[coder encodeObject:_views forKey:CPPredicateTemplateViewsKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Copy support for built-in types
|
||||
@implementation CPDatePicker (CPCopying)
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
var ret = [[[self class] alloc] initWithFrame:[self frame]];
|
||||
|
||||
[ret setTextFont:[self textFont]];
|
||||
[ret setMinDate:[self minDate]];
|
||||
[ret setMaxDate:[self maxDate]];
|
||||
[ret setTimeInterval:[self timeInterval]];
|
||||
[ret setDatePickerMode:[self datePickerMode]];
|
||||
[ret setDatePickerElements:[self datePickerElements]];
|
||||
[ret setDatePickerStyle:[self datePickerStyle]];
|
||||
[ret setLocale:[self locale]];
|
||||
[ret setDateValue:[self dateValue]];
|
||||
[ret setBackgroundColor:[self backgroundColor]];
|
||||
[ret setDrawsBackground:[self drawsBackground]];
|
||||
[ret setBordered:[self isBordered]];
|
||||
[ret _init];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@end
|
||||
/*! @endcond */
|
||||
|
||||
@@ -41,6 +41,21 @@
|
||||
@global CPCaseInsensitivePredicateOption
|
||||
@global CPOrPredicateType
|
||||
|
||||
@protocol CPRuleEditorDelegate <CPObject>
|
||||
|
||||
@required
|
||||
- (id)ruleEditor:(CPRuleEditor)editor child:(CPInteger)index forCriterion:(id)criterion withRowType:(CPRuleEditorRowType)rowType;
|
||||
- (id)ruleEditor:(CPRuleEditor)editor displayValueForCriterion:(id)criterion inRow:(CPInteger)row;
|
||||
- (CPInteger)ruleEditor:(CPRuleEditor)editor numberOfChildrenForCriterion:(id)criterion withRowType:(CPRuleEditorRowType)rowType;
|
||||
|
||||
@optional
|
||||
- (CPDictionary)ruleEditor:(CPRuleEditor)editor predicatePartsForCriterion:(id)criterion withDisplayValue:(id)value inRow:(CPInteger)row;
|
||||
- (void)ruleEditorRowsDidChange:(CPNotification)notification;
|
||||
|
||||
@end
|
||||
|
||||
var CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_ = 1 << 1;
|
||||
|
||||
var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
itemsContext = "items",
|
||||
valuesContext = "values",
|
||||
@@ -69,50 +84,51 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
|
||||
@implementation CPRuleEditor : CPControl
|
||||
{
|
||||
BOOL _suppressKeyDownHandling;
|
||||
BOOL _allowsEmptyCompoundRows;
|
||||
BOOL _disallowEmpty;
|
||||
BOOL _delegateWantsValidation;
|
||||
BOOL _editable;
|
||||
BOOL _sendAction;
|
||||
BOOL _suppressKeyDownHandling;
|
||||
BOOL _allowsEmptyCompoundRows;
|
||||
BOOL _disallowEmpty;
|
||||
BOOL _delegateWantsValidation;
|
||||
BOOL _editable;
|
||||
BOOL _sendAction;
|
||||
|
||||
Class _rowClass;
|
||||
Class _rowClass;
|
||||
|
||||
CPIndexSet _draggingRows;
|
||||
CPInteger _subviewIndexOfDropLine;
|
||||
CPView _dropLineView;
|
||||
CPIndexSet _draggingRows;
|
||||
CPInteger _subviewIndexOfDropLine;
|
||||
CPView _dropLineView;
|
||||
|
||||
CPMutableArray _rowCache;
|
||||
CPMutableArray _slices;
|
||||
CPMutableArray _rowCache;
|
||||
CPMutableArray _slices;
|
||||
|
||||
CPPredicate _predicate;
|
||||
CPPredicate _predicate;
|
||||
|
||||
CPString _itemsKeyPath;
|
||||
CPString _subrowsArrayKeyPath;
|
||||
CPString _typeKeyPath;
|
||||
CPString _valuesKeyPath;
|
||||
CPString _boundArrayKeyPath @accessors(property=boundArrayKeyPath);
|
||||
CPString _itemsKeyPath;
|
||||
CPString _subrowsArrayKeyPath;
|
||||
CPString _typeKeyPath;
|
||||
CPString _valuesKeyPath;
|
||||
CPString _boundArrayKeyPath @accessors(property=boundArrayKeyPath);
|
||||
|
||||
CPView _slicesHolder;
|
||||
CPViewAnimation _currentAnimation;
|
||||
CPView _slicesHolder;
|
||||
CPViewAnimation _currentAnimation;
|
||||
|
||||
CPInteger _lastRow;
|
||||
CPInteger _nestingMode;
|
||||
CPInteger _lastRow;
|
||||
CPInteger _nestingMode;
|
||||
|
||||
float _alignmentGridWidth;
|
||||
float _sliceHeight;
|
||||
float _alignmentGridWidth;
|
||||
float _sliceHeight;
|
||||
|
||||
id _ruleDataSource;
|
||||
id _ruleDelegate;
|
||||
id _boundArrayOwner;
|
||||
id _ruleDataSource;
|
||||
id <CPRuleEditorDelegate> _ruleDelegate;
|
||||
id _boundArrayOwner;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
CPString _stringsFilename;
|
||||
CPString _stringsFilename;
|
||||
|
||||
BOOL _isKeyDown;
|
||||
BOOL _nestingModeDidChange;
|
||||
BOOL _isKeyDown;
|
||||
BOOL _nestingModeDidChange;
|
||||
|
||||
_CPRuleEditorLocalizer _standardLocalizer @accessors(property=standardLocalizer);
|
||||
CPDictionary _itemsAndValuesToAddForRowType;
|
||||
_CPRuleEditorLocalizer _standardLocalizer @accessors(property=standardLocalizer);
|
||||
CPDictionary _itemsAndValuesToAddForRowType;
|
||||
}
|
||||
|
||||
/*! @cond */
|
||||
@@ -122,7 +138,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
return @"rule-editor";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"alternating-row-colors": [CPNull null],
|
||||
@@ -213,19 +229,24 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
@discussion CPRuleEditor requires a delegate that implements the required delegate methods to function.
|
||||
@see delegate
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPRuleEditorDelegate>)aDelegate
|
||||
{
|
||||
if (_ruleDelegate === aDelegate)
|
||||
return;
|
||||
|
||||
var nc = [CPNotificationCenter defaultCenter];
|
||||
|
||||
if (_ruleDelegate)
|
||||
[nc removeObserver:_ruleDelegate name:nil object:self];
|
||||
|
||||
_ruleDelegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_ruleDelegate respondsToSelector:@selector(ruleEditorRowsDidChange:)])
|
||||
[nc addObserver:_ruleDelegate selector:@selector(ruleEditorRowsDidChange:) name:CPRuleEditorRowsDidChangeNotification object:nil];
|
||||
|
||||
if ([_ruleDelegate respondsToSelector:@selector(ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:)])
|
||||
_implementedDelegateMethods |= CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_;
|
||||
}
|
||||
/*!
|
||||
@brief Returns a Boolean value that indicates whether the receiver is editable.
|
||||
@@ -461,7 +482,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
@param row The index of a row in the receiver.
|
||||
@return The currently chosen items for row @a row.
|
||||
*/
|
||||
- (id)criteriaForRow:(int)row
|
||||
- (id)criteriaForRow:(CPInteger)row
|
||||
{
|
||||
var rowcache = [self _rowCacheForIndex:row];
|
||||
if (rowcache)
|
||||
@@ -480,7 +501,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
@return The chosen values (strings, views, or menu items) for row row.
|
||||
@discussion The values returned are the same as those returned from the delegate method -#ruleEditor:displayValueForCriterion:inRow:
|
||||
*/
|
||||
- (CPMutableArray)displayValuesForRow:(int)row
|
||||
- (CPMutableArray)displayValuesForRow:(CPInteger)row
|
||||
{
|
||||
var rowcache = [self _rowCacheForIndex:row];
|
||||
if (rowcache)
|
||||
@@ -503,7 +524,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
|
||||
@param rowIndex The index of a row in the receiver.
|
||||
@return The index of the parent of the row at @a rowIndex. If the row at @a rowIndex is a root row, returns @c -1.
|
||||
*/
|
||||
- (int)parentRowForRow:(int)rowIndex
|
||||
- (int)parentRowForRow:(CPInteger)rowIndex
|
||||
{
|
||||
if (rowIndex < 0 || rowIndex >= [self numberOfRows])
|
||||
[CPException raise:CPRangeException reason:_cmd + @" row " + rowIndex + " is out of range"];
|
||||
@@ -544,7 +565,7 @@ TODO: implement
|
||||
@return The type of the row at @a rowIndex.
|
||||
@warning Raises a @c CPRangeException if rowIndex is less than @c 0 or greater than or equal to the number of rows.
|
||||
*/
|
||||
- (CPRuleEditorRowType)rowTypeForRow:(int)rowIndex
|
||||
- (CPRuleEditorRowType)rowTypeForRow:(CPInteger)rowIndex
|
||||
{
|
||||
if (rowIndex < 0 || rowIndex > [self numberOfRows])
|
||||
[CPException raise:CPRangeException reason:_cmd + @"row " + rowIndex + " is out of range"];
|
||||
@@ -565,7 +586,7 @@ TODO: implement
|
||||
@return The immediate subrows of the row at @a rowIndex.
|
||||
@discussion Rows are numbered starting at @c 0.
|
||||
*/
|
||||
- (CPIndexSet)subrowIndexesForRow:(int)rowIndex
|
||||
- (CPIndexSet)subrowIndexesForRow:(CPInteger)rowIndex
|
||||
{
|
||||
var object;
|
||||
|
||||
@@ -691,7 +712,7 @@ TODO: implement
|
||||
@note Currently, @a shouldAnimate has no effect, rows are always animated when calling this method.
|
||||
@see addRow:
|
||||
*/
|
||||
- (void)insertRowAtIndex:(int)rowIndex withType:(unsigned int)rowType asSubrowOfRow:(int)parentRow animate:(BOOL)shouldAnimate
|
||||
- (void)insertRowAtIndex:(int)rowIndex withType:(unsigned int)rowType asSubrowOfRow:(CPInteger)parentRow animate:(BOOL)shouldAnimate
|
||||
{
|
||||
/*
|
||||
TODO: raise exceptions if parentRow is greater than or equal to rowIndex, or if rowIndex would fall amongst the children of some other parent, or if the nesting mode forbids this configuration.
|
||||
@@ -810,7 +831,7 @@ TODO: implement
|
||||
var item = [items objectAtIndex:i],
|
||||
//var displayValue = [self _queryValueForItem:item inRow:aRow]; Ask the delegate or get cached value ?.
|
||||
displayValue = [[self displayValuesForRow:aRow] objectAtIndex:i],
|
||||
predpart = [_ruleDelegate ruleEditor:self predicatePartsForCriterion:item withDisplayValue:displayValue inRow:aRow];
|
||||
predpart = [self _sendDelegateRuleEditorPredicatePartsForCriterion:item withDisplayValue:displayValue inRow:aRow];
|
||||
|
||||
if (predpart)
|
||||
[predicateParts addEntriesFromDictionary:predpart];
|
||||
@@ -1313,7 +1334,7 @@ TODO: implement
|
||||
return [_boundArrayOwner mutableArrayValueForKey:_boundArrayKeyPath];
|
||||
}
|
||||
|
||||
- (BOOL)_nextUnusedItems:(CPArray)items andValues:(CPArray)values forRow:(int)rowIndex forRowType:(unsigned int)type
|
||||
- (BOOL)_nextUnusedItems:(CPArray)items andValues:(CPArray)values forRow:(CPInteger)rowIndex forRowType:(unsigned int)type
|
||||
{
|
||||
var parentItem = [items lastObject], // if empty items array, this is NULL aka the root item;
|
||||
childrenCount = [self _queryNumberOfChildrenOfItem:parentItem withRowType:type],
|
||||
@@ -1375,7 +1396,7 @@ TODO: implement
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPMutableArray)_getItemsAndValuesToAddForRow:(int)rowIndex ofType:(CPRuleEditorRowType)type
|
||||
- (CPMutableArray)_getItemsAndValuesToAddForRow:(CPInteger)rowIndex ofType:(CPRuleEditorRowType)type
|
||||
{
|
||||
//var cachedItemsAndValues = _itemsAndValuesToAddForRowType[type];
|
||||
//if (cachedItemsAndValues)
|
||||
@@ -1418,7 +1439,7 @@ TODO: implement
|
||||
[self insertRowAtIndex:insertIndex withType:type asSubrowOfRow:parentRowIndex animate:YES];
|
||||
}
|
||||
|
||||
- (id)_insertNewRowAtIndex:(int)insertIndex ofType:(CPRuleEditorRowType)rowtype withParentRow:(int)parentRowIndex
|
||||
- (id)_insertNewRowAtIndex:(int)insertIndex ofType:(CPRuleEditorRowType)rowtype withParentRow:(CPInteger)parentRowIndex
|
||||
{
|
||||
var row = [[[self rowClass] alloc] init],
|
||||
itemsandvalues = [self _getItemsAndValuesToAddForRow:insertIndex ofType:rowtype],
|
||||
@@ -1520,7 +1541,7 @@ TODO: implement
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_changedItem:(id)fromItem toItem:(id)toItem inRow:(int)aRow atCriteriaIndex:(int)fromItemIndex
|
||||
- (void)_changedItem:(id)fromItem toItem:(id)toItem inRow:(CPInteger)aRow atCriteriaIndex:(int)fromItemIndex
|
||||
{
|
||||
var criteria = [self criteriaForRow:aRow],
|
||||
displayValues = [self displayValuesForRow:aRow],
|
||||
@@ -1684,7 +1705,7 @@ TODO: implement
|
||||
[super bind:aBinding toObject:observableController withKeyPath:aKeyPath options:options];
|
||||
}
|
||||
|
||||
- (void)unbind:(id)object
|
||||
- (void)unbind:(CPString)object
|
||||
{
|
||||
_rowClass = [_CPRuleEditorRowObject class];
|
||||
[super unbind:object];
|
||||
@@ -1716,8 +1737,7 @@ TODO: implement
|
||||
{
|
||||
if (_delegateWantsValidation)
|
||||
{
|
||||
var selector = @selector(ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:);
|
||||
if (![_ruleDelegate respondsToSelector:selector])
|
||||
if (![self _delegateRespondsToRuleEditorPredicatePartsForCriterionWithDisplayValueInRow])
|
||||
return;
|
||||
|
||||
_delegateWantsValidation = NO;
|
||||
@@ -2005,7 +2025,7 @@ TODO: implement
|
||||
return [_ruleDelegate ruleEditor:self child:childIndex forCriterion:item withRowType:type];
|
||||
}
|
||||
|
||||
- (id)_queryValueForItem:(id)item inRow:(int)row
|
||||
- (id)_queryValueForItem:(id)item inRow:(CPInteger)row
|
||||
{
|
||||
return [_ruleDelegate ruleEditor:self displayValueForCriterion:item inRow:row];
|
||||
}
|
||||
@@ -2026,12 +2046,12 @@ TODO: implement
|
||||
_alignmentGridWidth = width;
|
||||
}
|
||||
|
||||
- (BOOL)_validateItem:(id)item value:(id)value inRow:(int)row
|
||||
- (BOOL)_validateItem:(id)item value:(id)value inRow:(CPInteger)row
|
||||
{
|
||||
return [self _queryCanSelectItem:item displayValue:value inRow:row];
|
||||
}
|
||||
|
||||
- (BOOL)_queryCanSelectItem:(id)item displayValue:(id)value inRow:(int)row
|
||||
- (BOOL)_queryCanSelectItem:(id)item displayValue:(id)value inRow:(CPInteger)row
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@@ -2128,7 +2148,7 @@ TODO: implement
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPDragOperation)draggingEntered:(id < CPDraggingInfo >)sender
|
||||
- (CPDragOperation)draggingEntered:(id /*< CPDraggingInfo >*/)sender
|
||||
{
|
||||
if ([sender draggingSource] === self)
|
||||
{
|
||||
@@ -2158,7 +2178,7 @@ TODO: implement
|
||||
_subviewIndexOfDropLine = CPNotFound;
|
||||
}
|
||||
|
||||
- (CPDragOperation)draggingUpdated:(id <CPDraggingInfo>)sender
|
||||
- (CPDragOperation)draggingUpdated:(id /*<CPDraggingInfo>*/)sender
|
||||
{
|
||||
var point = [self convertPoint:[sender draggingLocation] fromView:nil],
|
||||
y = point.y + _sliceHeight / 2,
|
||||
@@ -2195,12 +2215,12 @@ TODO: implement
|
||||
return CPDragOperationMove;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id < CPDraggingInfo >)sender
|
||||
- (BOOL)prepareForDragOperation:(id /*< CPDraggingInfo >*/)sender
|
||||
{
|
||||
return (_subviewIndexOfDropLine !== CPNotFound);
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id < CPDraggingInfo >)info
|
||||
- (BOOL)performDragOperation:(id /*< CPDraggingInfo >*/)info
|
||||
{
|
||||
var aboveInsertIndexCount = 0,
|
||||
object,
|
||||
@@ -2262,7 +2282,7 @@ TODO: implement
|
||||
{
|
||||
}
|
||||
|
||||
- (void)_setWindow:(id)window
|
||||
- (void)_setWindow:(CPWindow)window
|
||||
{
|
||||
[super _setWindow:window];
|
||||
}
|
||||
@@ -2279,7 +2299,7 @@ TODO: implement
|
||||
|
||||
- (void)_postRowCountChangedNotificationOfType:(CPString)notificationName indexes:indexes
|
||||
{
|
||||
var userInfo = @{ "indexes": indexes };
|
||||
var userInfo = indexes === nil ? @{} : @{ "indexes": indexes };
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:notificationName object:self userInfo:userInfo];
|
||||
}
|
||||
|
||||
@@ -2325,7 +2345,7 @@ TODO: implement
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_getAllAvailableItems:(id)items values:(id)values asChildrenOfItem:(id)parentItem inRow:(int)aRow
|
||||
- (void)_getAllAvailableItems:(id)items values:(id)values asChildrenOfItem:(id)parentItem inRow:(CPInteger)aRow
|
||||
{
|
||||
var type,
|
||||
indexofCriterion,
|
||||
@@ -2377,6 +2397,33 @@ TODO: implement
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPRuleEditor (CPRuleEditorDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Check if the delegate responds to ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToRuleEditorPredicatePartsForCriterionWithDisplayValueInRow
|
||||
{
|
||||
return _implementedDelegateMethods & CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:
|
||||
*/
|
||||
- (CPDictionary)_sendDelegateRuleEditorPredicatePartsForCriterion:(id)criterion withDisplayValue:(id)value inRow:(CPInteger)row
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPRuleEditorDelegate_ruleEditor_predicatePartsForCriterion_withDisplayValue_inRow_))
|
||||
return @{};
|
||||
|
||||
return [_ruleDelegate ruleEditor:self predicatePartsForCriterion:criterion withDisplayValue:value inRow:row];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth",
|
||||
CPRuleEditorSliceHeightKey = @"CPRuleEditorSliceHeight",
|
||||
CPRuleEditorStringsFilenameKey = @"CPRuleEditorStringsFilename",
|
||||
@@ -2426,7 +2473,7 @@ var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth",
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(id)coder
|
||||
- (void)encodeWithCoder:(CPCoder)coder
|
||||
{
|
||||
[super encodeWithCoder:coder];
|
||||
|
||||
@@ -2481,7 +2528,7 @@ var CriteriaKey = @"criteria",
|
||||
return "<" + [self className] + ">\nsubrows = " + [subrows description] + "\ncriteria = " + [criteria description] + "\ndisplayValues = " + [displayValues description];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(id)coder
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
self = [super init];
|
||||
if (self !== nil)
|
||||
@@ -2495,7 +2542,7 @@ var CriteriaKey = @"criteria",
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(id)coder
|
||||
- (void)encodeWithCoder:(CPCoder)coder
|
||||
{
|
||||
[coder encodeObject:subrows forKey:SubrowsKey];
|
||||
[coder encodeObject:criteria forKey:CriteriaKey];
|
||||
@@ -2534,7 +2581,7 @@ var CPBoundArrayKey = @"CPBoundArray";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(id)coder
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
if (self = [super init])
|
||||
boundArray = [coder decodeObjectForKey:CPBoundArrayKey];
|
||||
@@ -2542,7 +2589,7 @@ var CPBoundArrayKey = @"CPBoundArray";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(id)coder
|
||||
- (void)encodeWithCoder:(CPCoder)coder
|
||||
{
|
||||
[coder encodeObject:boundArray forKey:CPBoundArrayKey];
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)hitTest:(CGPoint)point
|
||||
- (CPView)hitTest:(CGPoint)point
|
||||
{
|
||||
if (!CGRectContainsPoint([self frame], point) || ![self sliceIsEditable])
|
||||
return nil;
|
||||
@@ -100,12 +100,12 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return ![superview isKindOfClass:[_CPRuleEditorViewSlice]] || [superview isEditable];
|
||||
}
|
||||
|
||||
- (BOOL)trackMouse:(CPEvent)theEvent
|
||||
- (void)trackMouse:(CPEvent)theEvent
|
||||
{
|
||||
if (![self sliceIsEditable])
|
||||
return NO;
|
||||
return;
|
||||
|
||||
return [super trackMouse:theEvent];
|
||||
[super trackMouse:theEvent];
|
||||
}
|
||||
|
||||
- (CGRect)contentRectForBounds:(CGRect)bounds
|
||||
|
||||
@@ -522,7 +522,7 @@ var CONTROL_HEIGHT = 16.,
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)hitTest:(CGPoint)point
|
||||
- (CPView)hitTest:(CGPoint)point
|
||||
{
|
||||
if (!CGRectContainsPoint([self frame], point))
|
||||
return nil;
|
||||
|
||||
+27
-17
@@ -34,34 +34,44 @@
|
||||
|
||||
|
||||
/*! @ignore */
|
||||
var _isSystemUsingOverlayScrollers = function()
|
||||
var _isBrowserUsingOverlayScrollers = function()
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var inner = document.createElement('p'),
|
||||
outer = document.createElement('div');
|
||||
/*
|
||||
Even if the system supports overlay (Lion) scrollers,
|
||||
the browser (e.g. FireFox *cough*) may not.
|
||||
|
||||
inner.style.width = "100%";
|
||||
inner.style.height = "200px";
|
||||
To determine if the browser is using overlay scrollbars,
|
||||
we put a <p> element inside a shorter <div> and set its
|
||||
overflow to scroll. If the browser is using visible scrollers,
|
||||
the outer div's clientWidth will less than the offsetWidth, because
|
||||
clientWidth does not include scrollbars, whereas offsetWidth does.
|
||||
So if clientWidth === offsetWidth, the scrollers must be overlay.
|
||||
Even IE gets this right.
|
||||
*/
|
||||
var outer = document.createElement('div'),
|
||||
inner = document.createElement('p');
|
||||
|
||||
// position it absolute so it doesn't affect existing DOM elements
|
||||
outer.style.position = "absolute";
|
||||
outer.style.top = "0px";
|
||||
outer.style.left = "0px";
|
||||
outer.style.visibility = "hidden";
|
||||
outer.style.width = "200px";
|
||||
outer.style.height = "150px";
|
||||
outer.style.overflow = "hidden";
|
||||
outer.appendChild (inner);
|
||||
outer.style.overflow = "scroll";
|
||||
|
||||
document.body.appendChild (outer);
|
||||
var w1 = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
var w2 = inner.offsetWidth;
|
||||
if (w1 == w2)
|
||||
w2 = outer.clientWidth;
|
||||
inner.style.width = "100%";
|
||||
inner.style.height = "200px";
|
||||
outer.appendChild(inner);
|
||||
|
||||
document.body.removeChild (outer);
|
||||
document.body.appendChild(outer);
|
||||
|
||||
return (w1 - w2 == 0);
|
||||
var usingOverlayScrollers = outer.clientWidth === outer.offsetWidth;
|
||||
|
||||
document.body.removeChild(outer);
|
||||
|
||||
return usingOverlayScrollers;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
@@ -130,8 +140,8 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
|
||||
var globalValue = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPScrollersGlobalStyle"];
|
||||
|
||||
if (globalValue == nil || globalValue == -1)
|
||||
CPScrollerStyleGlobal = _isSystemUsingOverlayScrollers() ? CPScrollerStyleOverlay : CPScrollerStyleLegacy
|
||||
if (globalValue === nil || globalValue === -1)
|
||||
CPScrollerStyleGlobal = _isBrowserUsingOverlayScrollers() ? CPScrollerStyleOverlay : CPScrollerStyleLegacy
|
||||
else
|
||||
CPScrollerStyleGlobal = globalValue;
|
||||
}
|
||||
|
||||
+3
-2
@@ -108,7 +108,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
return "scroller";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"scroller-width": 7.0,
|
||||
@@ -182,6 +182,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
_allowFadingOut = YES;
|
||||
_isMouseOver = NO;
|
||||
_style = CPScrollerStyleOverlay;
|
||||
|
||||
var paramAnimFadeOut = @{
|
||||
CPViewAnimationTargetKey: self,
|
||||
CPViewAnimationEffectKey: CPViewAnimationFadeOutEffect,
|
||||
@@ -732,7 +733,7 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
var themeState = _themeState;
|
||||
|
||||
if (NAMES_FOR_PARTS[_hitPart] + "-color" !== anAttributeName)
|
||||
themeState &= ~CPThemeStateHighlighted;
|
||||
themeState = themeState.without(CPThemeStateHighlighted);
|
||||
|
||||
return [self valueForThemeAttribute:anAttributeName inState:themeState];
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ var RECENT_SEARCH_PREFIX = @" ";
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)anObject
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
|
||||
{
|
||||
[super sendAction:anAction to:anObject];
|
||||
|
||||
|
||||
+22
-18
@@ -56,7 +56,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
return "segmented-control";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"alignment": CPCenterTextAlignment,
|
||||
@@ -285,7 +285,6 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
- (void)setWidth:(float)aWidth forSegment:(unsigned)aSegment
|
||||
{
|
||||
[_segments[aSegment] setWidth:aWidth];
|
||||
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
}
|
||||
|
||||
@@ -432,9 +431,9 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
[_segments[aSegment] setEnabled:shouldBeEnabled];
|
||||
|
||||
if (shouldBeEnabled)
|
||||
_themeStates[aSegment] &= ~CPThemeStateDisabled;
|
||||
_themeStates[aSegment] = _themeStates[aSegment].without(CPThemeStateDisabled);
|
||||
else
|
||||
_themeStates[aSegment] |= CPThemeStateDisabled;
|
||||
_themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateDisabled);
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -477,10 +476,13 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)drawSegmentBezel:(int)aSegment highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
if (shouldHighlight)
|
||||
_themeStates[aSegment] |= CPThemeStateHighlighted;
|
||||
else
|
||||
_themeStates[aSegment] &= ~CPThemeStateHighlighted;
|
||||
if(aSegment < _themeStates.length)
|
||||
{
|
||||
if (shouldHighlight)
|
||||
_themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateHighlighted);
|
||||
else
|
||||
_themeStates[aSegment] = _themeStates[aSegment].without(CPThemeStateHighlighted);
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -574,9 +576,10 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_segments.length <= 0)
|
||||
return;
|
||||
|
||||
var themeState = _themeStates[0];
|
||||
var themeState = _themeStates[0],
|
||||
isDisabled = [self hasThemeState:CPThemeStateDisabled];
|
||||
|
||||
themeState |= _themeState & CPThemeStateDisabled;
|
||||
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
|
||||
|
||||
var leftCapColor = [self valueForThemeAttribute:@"left-segment-bezel-color"
|
||||
inState:themeState],
|
||||
@@ -589,7 +592,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
var themeState = _themeStates[_themeStates.length - 1];
|
||||
|
||||
themeState |= _themeState & CPThemeStateDisabled;
|
||||
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
|
||||
|
||||
var rightCapColor = [self valueForThemeAttribute:@"right-segment-bezel-color"
|
||||
inState:themeState],
|
||||
@@ -604,7 +607,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
{
|
||||
var themeState = _themeStates[i];
|
||||
|
||||
themeState |= _themeState & CPThemeStateDisabled;
|
||||
themeState = isDisabled ? themeState.and(CPThemeStateDisabled) : themeState;
|
||||
|
||||
var bezelColor = [self valueForThemeAttribute:@"center-segment-bezel-color"
|
||||
inState:themeState],
|
||||
@@ -642,11 +645,11 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (i == count - 1)
|
||||
continue;
|
||||
|
||||
var borderState = _themeStates[i] | _themeStates[i + 1];
|
||||
var borderState = _themeStates[i].and(_themeStates[i + 1]);
|
||||
|
||||
borderState = (borderState & CPThemeStateSelected & ~CPThemeStateHighlighted) ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
borderState = (borderState.hasThemeState(CPThemeStateSelected) && !borderState.hasThemeState(CPThemeStateHighlighted)) ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
|
||||
borderState |= _themeState & CPThemeStateDisabled;
|
||||
borderState = isDisabled ? borderState.and(CPThemeStateDisabled) : borderState;
|
||||
|
||||
var borderColor = [self valueForThemeAttribute:@"divider-bezel-color"
|
||||
inState:borderState],
|
||||
@@ -676,7 +679,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
var segment = _segments[aSegment],
|
||||
segmentWidth = [segment width],
|
||||
themeState = _themeStates[aSegment] | (_themeState & CPThemeStateDisabled),
|
||||
themeState = _themeState.hasThemeState(CPThemeStateDisabled) ? _themeStates[aSegment].and(CPThemeStateDisabled) : _themeStates[aSegment];
|
||||
contentInset = [self valueForThemeAttribute:@"content-inset" inState:themeState],
|
||||
font = [self font];
|
||||
|
||||
@@ -915,10 +918,11 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
// HACK
|
||||
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
{
|
||||
_themeStates[i] = [_segments[i] selected] ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
|
||||
// We do this in a second loop because it relies on all the themeStates being set first
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
[self tileWithChangedSegment:i];
|
||||
}
|
||||
|
||||
var difference = MAX(originalWidth - [self frame].size.width, 0.0),
|
||||
remainingWidth = FLOOR(difference / _segments.length);
|
||||
|
||||
@@ -47,7 +47,7 @@ CPThemeStateShadowViewHeavy = CPThemeState("shadowview-style-heavy");
|
||||
return "shadow-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-color": [CPNull null],
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ CPCircularSlider = 1;
|
||||
return "slider";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"knob-color": [CPNull null],
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
CPTextField _hexLabel;
|
||||
CPTextField _hexValue;
|
||||
|
||||
CPTextField _hexValue;
|
||||
CPTextField _redValue;
|
||||
CPTextField _greenValue;
|
||||
CPTextField _blueValue;
|
||||
@@ -146,7 +145,7 @@
|
||||
[_hueLabel setTextColor:[CPColor blackColor]];
|
||||
|
||||
_hueSlider = [[CPSlider alloc] initWithFrame:CGRectMake(15, 143, aFrame.size.width - 70, 20)];
|
||||
[_hueSlider setMaxValue:359.0];
|
||||
[_hueSlider setMaxValue:0.999];
|
||||
[_hueSlider setMinValue:0.0];
|
||||
[_hueSlider setTarget:self];
|
||||
[_hueSlider setAction:@selector(sliderChanged:)];
|
||||
@@ -165,7 +164,7 @@
|
||||
[_saturationLabel setTextColor:[CPColor blackColor]];
|
||||
|
||||
_saturationSlider = [[CPSlider alloc] initWithFrame:CGRectMake(15, 168, aFrame.size.width - 70, 20)];
|
||||
[_saturationSlider setMaxValue:100.0];
|
||||
[_saturationSlider setMaxValue:1.0];
|
||||
[_saturationSlider setMinValue:0.0];
|
||||
[_saturationSlider setTarget:self];
|
||||
[_saturationSlider setAction:@selector(sliderChanged:)];
|
||||
@@ -184,7 +183,7 @@
|
||||
[_brightnessLabel setTextColor:[CPColor blackColor]];
|
||||
|
||||
_brightnessSlider = [[CPSlider alloc] initWithFrame:CGRectMake(15, 194, aFrame.size.width - 70, 20)];
|
||||
[_brightnessSlider setMaxValue:100.0];
|
||||
[_brightnessSlider setMaxValue:1.0];
|
||||
[_brightnessSlider setMinValue:0.0];
|
||||
[_brightnessSlider setTarget:self];
|
||||
[_brightnessSlider setAction:@selector(sliderChanged:)];
|
||||
@@ -282,6 +281,9 @@
|
||||
|
||||
- (void)setColor:(CPColor)aColor
|
||||
{
|
||||
if (!aColor)
|
||||
[CPException raise:CPInvalidArgumentException reason:"aColor can't be nil"];
|
||||
|
||||
[self updateRGBSliders:aColor];
|
||||
[self updateHSBSliders:aColor];
|
||||
[self updateHex:aColor];
|
||||
@@ -313,9 +315,9 @@
|
||||
|
||||
- (void)updateLabels
|
||||
{
|
||||
[_hueValue setStringValue:ROUND([_hueSlider floatValue])];
|
||||
[_saturationValue setStringValue:ROUND([_saturationSlider floatValue])];
|
||||
[_brightnessValue setStringValue:ROUND([_brightnessSlider floatValue])];
|
||||
[_hueValue setStringValue:ROUND([_hueSlider floatValue] * 360.0)];
|
||||
[_saturationValue setStringValue:ROUND([_saturationSlider floatValue] * 100.0)];
|
||||
[_brightnessValue setStringValue:ROUND([_brightnessSlider floatValue] * 100.0)];
|
||||
|
||||
[_redValue setStringValue:ROUND([_redSlider floatValue] * 255)];
|
||||
[_greenValue setStringValue:ROUND([_greenSlider floatValue] * 255)];
|
||||
@@ -363,15 +365,15 @@
|
||||
[self sliderChanged:_blueSlider];
|
||||
break;
|
||||
|
||||
case _hueValue: [_hueSlider setFloatValue:MAX(MIN(ROUND(value), 360), 0)];
|
||||
case _hueValue: [_hueSlider setFloatValue:MAX(MIN(ROUND(value), 360) / 360.0, 0)];
|
||||
[self sliderChanged:_hueSlider];
|
||||
break;
|
||||
|
||||
case _saturationValue: [_saturationSlider setFloatValue:MAX(MIN(ROUND(value), 100), 0)];
|
||||
case _saturationValue: [_saturationSlider setFloatValue:MAX(MIN(ROUND(value), 100) / 100.0, 0)];
|
||||
[self sliderChanged:_saturationSlider];
|
||||
break;
|
||||
|
||||
case _brightnessValue: [_brightnessSlider setFloatValue:MAX(MIN(ROUND(value), 100), 0)];
|
||||
case _brightnessValue: [_brightnessSlider setFloatValue:MAX(MIN(ROUND(value), 100) / 100.0, 0)];
|
||||
[self sliderChanged:_brightnessSlider];
|
||||
break;
|
||||
}
|
||||
|
||||
+49
-2
@@ -23,6 +23,17 @@
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPRunLoop.j>
|
||||
|
||||
|
||||
@protocol CPSoundDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (void)sound:(CPSound)aSound didFinishPlaying:(BOOL)finishedLoading;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPSoundDelegate_sound_didFinishPlaying_ = 1 << 1;
|
||||
|
||||
CPSoundLoadStateEmpty = 0;
|
||||
CPSoundLoadStateLoading = 1;
|
||||
CPSoundLoadStateCanBePlayed = 2;
|
||||
@@ -50,6 +61,7 @@ CPSoundPlayBackStatePause = 2;
|
||||
HTMLAudioElement _audioTag;
|
||||
int _loadStatus;
|
||||
int _playBackStatus;
|
||||
unsigned _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@@ -133,6 +145,25 @@ CPSoundPlayBackStatePause = 2;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate methods
|
||||
|
||||
/*!
|
||||
Sets the sound's delegate.
|
||||
@param aDelegate the new delegate
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(sound:didFinishPlaying:)])
|
||||
_implementedDelegateMethods |= CPSoundDelegate_sound_didFinishPlaying_;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Events listener
|
||||
|
||||
@@ -207,8 +238,7 @@ CPSoundPlayBackStatePause = 2;
|
||||
_audioTag.currentTime = 0.0;
|
||||
_playBackStatus = CPSoundPlayBackStateStop;
|
||||
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(sound:didFinishPlaying:)])
|
||||
[_delegate sound:self didFinishPlaying:YES];
|
||||
[self _sendDelegateSoundDidFinishPlaying:YES];
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -316,3 +346,20 @@ CPSoundPlayBackStatePause = 2;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPSound (CPSoundDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate sound:didFinishPlaying:
|
||||
*/
|
||||
- (void)_sendDelegateSoundDidFinishPlaying:(BOOL)finishedPlaying
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSoundDelegate_sound_didFinishPlaying_))
|
||||
return;
|
||||
|
||||
[_delegate sound:self didFinishPlaying:finishedPlaying];
|
||||
}
|
||||
|
||||
@end
|
||||
+255
-75
@@ -30,6 +30,33 @@
|
||||
@class CPUserDefaults
|
||||
@global CPApp
|
||||
|
||||
@protocol CPSplitViewDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)splitView:(CPSplitView)splitView canCollapseSubview:(CPView)subview;
|
||||
- (BOOL)splitView:(CPSplitView)splitView shouldAdjustSizeOfSubview:(CPView)subview;
|
||||
- (BOOL)splitView:(CPSplitView)splitView shouldCollapseSubview:(CPView)subview forDoubleClickOnDividerAtIndex:(CPInteger)dividerIndex;
|
||||
- (CGRect)splitView:(CPSplitView)splitView additionalEffectiveRectOfDividerAtIndex:(CPInteger)dividerIndex;
|
||||
- (CGRect)splitView:(CPSplitView)splitView effectiveRect:(CGRect)proposedEffectiveRect forDrawnRect:(CGRect)drawnRect ofDividerAtIndex:(CPInteger)dividerIndex;
|
||||
- (float)splitView:(CPSplitView)splitView constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(CPInteger)dividerIndex;
|
||||
- (float)splitView:(CPSplitView)splitView constrainMinCoordinate:(float)proposedMin ofSubviewAt:(CPInteger)dividerIndex;
|
||||
- (float)splitView:(CPSplitView)splitView constrainSplitPosition:(float)proposedPosition ofSubviewAt:(CPInteger)dividerIndex;
|
||||
- (void)splitView:(CPSplitView)splitView resizeSubviewsWithOldSize:(CGSize)oldSize;
|
||||
- (void)splitViewDidResizeSubviews:(CPNotification)aNotification;
|
||||
- (void)splitViewWillResizeSubviews:(CPNotification)aNotification;
|
||||
|
||||
@end
|
||||
|
||||
var CPSplitViewDelegate_splitView_canCollapseSubview_ = 1 << 0,
|
||||
CPSplitViewDelegate_splitView_shouldAdjustSizeOfSubview_ = 1 << 1,
|
||||
CPSplitViewDelegate_splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex_ = 1 << 2,
|
||||
CPSplitViewDelegate_splitView_additionalEffectiveRectOfDividerAtIndex_ = 1 << 3,
|
||||
CPSplitViewDelegate_splitView_effectiveRect_forDrawnRect_ofDividerAtIndex_ = 1 << 4,
|
||||
CPSplitViewDelegate_splitView_constrainMaxCoordinate_ofSubviewAt_ = 1 << 5,
|
||||
CPSplitViewDelegate_splitView_constrainMinCoordinate_ofSubviewAt_ = 1 << 6,
|
||||
CPSplitViewDelegate_splitView_constrainSplitPosition_ofSubviewAt_ = 1 << 7,
|
||||
CPSplitViewDelegate_splitView_resizeSubviewsWithOldSize_ = 1 << 8;
|
||||
|
||||
#define SPLIT_VIEW_MAYBE_POST_WILL_RESIZE() \
|
||||
if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0) \
|
||||
{ \
|
||||
@@ -73,29 +100,31 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
|
||||
@implementation CPSplitView : CPView
|
||||
{
|
||||
id _delegate;
|
||||
BOOL _isVertical;
|
||||
BOOL _isPaneSplitter;
|
||||
id <CPSplitViewDelegate> _delegate;
|
||||
BOOL _isVertical;
|
||||
BOOL _isPaneSplitter;
|
||||
|
||||
int _currentDivider;
|
||||
float _initialOffset;
|
||||
CPDictionary _preCollapsePositions;
|
||||
int _currentDivider;
|
||||
float _initialOffset;
|
||||
CPDictionary _preCollapsePositions;
|
||||
|
||||
CPString _originComponent;
|
||||
CPString _sizeComponent;
|
||||
CPString _originComponent;
|
||||
CPString _sizeComponent;
|
||||
|
||||
CPArray _DOMDividerElements;
|
||||
CPString _dividerImagePath;
|
||||
int _drawingDivider;
|
||||
CPArray _DOMDividerElements;
|
||||
CPString _dividerImagePath;
|
||||
int _drawingDivider;
|
||||
|
||||
CPString _autosaveName;
|
||||
BOOL _shouldAutosave;
|
||||
CGSize _shouldRestoreFromAutosaveUnlessFrameSize;
|
||||
CPString _autosaveName;
|
||||
BOOL _shouldAutosave;
|
||||
CGSize _shouldRestoreFromAutosaveUnlessFrameSize;
|
||||
|
||||
BOOL _needsResizeSubviews;
|
||||
int _suppressResizeNotificationsMask;
|
||||
BOOL _needsResizeSubviews;
|
||||
int _suppressResizeNotificationsMask;
|
||||
|
||||
CPArray _buttonBars;
|
||||
CPArray _buttonBars;
|
||||
|
||||
unsigned _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -103,7 +132,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
return @"splitview";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"divider-thickness": 1.0,
|
||||
@@ -406,11 +435,8 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
buttonBarRect.origin = [self convertPoint:buttonBarRect.origin fromView:buttonBar];
|
||||
}
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:)])
|
||||
effectiveRect = [_delegate splitView:self effectiveRect:effectiveRect forDrawnRect:effectiveRect ofDividerAtIndex:anIndex];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:additionalEffectiveRectOfDividerAtIndex:)])
|
||||
additionalRect = [_delegate splitView:self additionalEffectiveRectOfDividerAtIndex:anIndex];
|
||||
effectiveRect = [self _sendDelegateSplitViewEffectiveRect:effectiveRect forDrawnRect:effectiveRect ofDividerAtIndex:anIndex];
|
||||
additionalRect = [self _sendDelegateSplitViewAdditionalEffectiveRectOfDividerAtIndex:anIndex];
|
||||
|
||||
return CGRectContainsPoint(effectiveRect, aPoint) ||
|
||||
(additionalRect && CGRectContainsPoint(additionalRect, aPoint)) ||
|
||||
@@ -472,21 +498,21 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
if ([self cursorAtPoint:point hitDividerAtIndex:i])
|
||||
{
|
||||
if ([anEvent clickCount] == 2 &&
|
||||
[_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] &&
|
||||
[_delegate respondsToSelector:@selector(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:)])
|
||||
[self _delegateRespondsToSplitViewCanCollapseSubview] &&
|
||||
[self _delegateRespondsToSplitViewshouldCollapseSubviewForDoubleClickOnDividerAtIndex])
|
||||
{
|
||||
var minPosition = [self minPossiblePositionOfDividerAtIndex:i],
|
||||
maxPosition = [self maxPossiblePositionOfDividerAtIndex:i],
|
||||
preCollapsePosition = [_preCollapsePositions objectForKey:"" + i] || 0;
|
||||
|
||||
if ([_delegate splitView:self canCollapseSubview:_subviews[i]] && [_delegate splitView:self shouldCollapseSubview:_subviews[i] forDoubleClickOnDividerAtIndex:i])
|
||||
if ([self _sendDelegateSplitViewCanCollapseSubview:_subviews[i]] && [self _sendDelegateSplitViewShouldCollapseSubview:_subviews[i] forDoubleClickOnDividerAtIndex:i])
|
||||
{
|
||||
if ([self isSubviewCollapsed:_subviews[i]])
|
||||
[self setPosition:preCollapsePosition ? preCollapsePosition : (minPosition + (maxPosition - minPosition) / 2) ofDividerAtIndex:i];
|
||||
else
|
||||
[self setPosition:minPosition ofDividerAtIndex:i];
|
||||
}
|
||||
else if ([_delegate splitView:self canCollapseSubview:_subviews[i + 1]] && [_delegate splitView:self shouldCollapseSubview:_subviews[i + 1] forDoubleClickOnDividerAtIndex:i])
|
||||
else if ([self _sendDelegateSplitViewCanCollapseSubview:_subviews[i + 1]] && [self _sendDelegateSplitViewShouldCollapseSubview:_subviews[i + 1] forDoubleClickOnDividerAtIndex:i])
|
||||
{
|
||||
if ([self isSubviewCollapsed:_subviews[i + 1]])
|
||||
[self setPosition:preCollapsePosition ? preCollapsePosition : (minPosition + (maxPosition - minPosition) / 2) ofDividerAtIndex:i];
|
||||
@@ -580,12 +606,8 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
|
||||
if (sizeA === 0)
|
||||
canGrow = YES; // Subview is collapsed.
|
||||
else if (!canShrink &&
|
||||
[_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] &&
|
||||
[_delegate splitView:self canCollapseSubview:_subviews[i]])
|
||||
{
|
||||
else if (!canShrink && [self _sendDelegateSplitViewCanCollapseSubview:_subviews[i]])
|
||||
canShrink = YES; // Subview is collapsible.
|
||||
}
|
||||
|
||||
if (sizeB === 0)
|
||||
{
|
||||
@@ -594,9 +616,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
// It's safe to assume it can always be uncollapsed.
|
||||
canShrink = YES;
|
||||
}
|
||||
else if (!canGrow &&
|
||||
[_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] &&
|
||||
[_delegate splitView:self canCollapseSubview:_subviews[i + 1]])
|
||||
else if (!canGrow && [self _sendDelegateSplitViewCanCollapseSubview:_subviews[i + 1]])
|
||||
{
|
||||
canGrow = YES; // Right/lower subview is collapsible.
|
||||
}
|
||||
@@ -657,53 +677,38 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
- (int)_realPositionForPosition:(float)position ofDividerAtIndex:(int)dividerIndex
|
||||
{
|
||||
// not sure where this should override other positions?
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainSplitPosition:ofSubviewAt:)])
|
||||
{
|
||||
var proposedPosition = [_delegate splitView:self constrainSplitPosition:position ofSubviewAt:dividerIndex];
|
||||
var proposedPosition = [self _sendDelegateSplitViewConstrainSplitPosition:position ofSubviewAt:dividerIndex];
|
||||
|
||||
// Silently ignore bad positions which could result from odd delegate responses. We don't want these
|
||||
// bad results to go into the system and cause havoc with frame sizes as the split view tries to resize
|
||||
// its subviews.
|
||||
if (_IS_NUMERIC(proposedPosition))
|
||||
position = proposedPosition;
|
||||
}
|
||||
// Silently ignore bad positions which could result from odd delegate responses. We don't want these
|
||||
// bad results to go into the system and cause havoc with frame sizes as the split view tries to resize
|
||||
// its subviews.
|
||||
if (_IS_NUMERIC(proposedPosition))
|
||||
position = proposedPosition;
|
||||
|
||||
var proposedMax = [self maxPossiblePositionOfDividerAtIndex:dividerIndex],
|
||||
proposedMin = [self minPossiblePositionOfDividerAtIndex:dividerIndex],
|
||||
actualMax = proposedMax,
|
||||
actualMin = proposedMin;
|
||||
actualMin = proposedMin,
|
||||
proposedActualMin = [self _sendDelegateSplitViewConstrainMinCoordinate:proposedMin ofSubviewAt:dividerIndex],
|
||||
proposedActualMax = [self _sendDelegateSplitViewConstrainMaxCoordinate:proposedMax ofSubviewAt:dividerIndex];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)])
|
||||
{
|
||||
var proposedActualMin = [_delegate splitView:self constrainMinCoordinate:proposedMin ofSubviewAt:dividerIndex];
|
||||
if (_IS_NUMERIC(proposedActualMin))
|
||||
actualMin = proposedActualMin;
|
||||
|
||||
if (_IS_NUMERIC(proposedActualMin))
|
||||
actualMin = proposedActualMin;
|
||||
}
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)])
|
||||
{
|
||||
var proposedActualMax = [_delegate splitView:self constrainMaxCoordinate:proposedMax ofSubviewAt:dividerIndex];
|
||||
|
||||
if (_IS_NUMERIC(proposedActualMax))
|
||||
actualMax = proposedActualMax;
|
||||
}
|
||||
if (_IS_NUMERIC(proposedActualMax))
|
||||
actualMax = proposedActualMax;
|
||||
|
||||
var viewA = _subviews[dividerIndex],
|
||||
viewB = _subviews[dividerIndex + 1],
|
||||
realPosition = MAX(MIN(position, actualMax), actualMin);
|
||||
|
||||
// Is this position past the halfway point to collapse?
|
||||
if (position < proposedMin + (actualMin - proposedMin) / 2)
|
||||
if ([_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)])
|
||||
if ([_delegate splitView:self canCollapseSubview:viewA])
|
||||
realPosition = proposedMin;
|
||||
if ((position < proposedMin + (actualMin - proposedMin) / 2) && [self _sendDelegateSplitViewCanCollapseSubview:viewA])
|
||||
realPosition = proposedMin;
|
||||
|
||||
// We can also collapse to the right.
|
||||
if (position > proposedMax - (proposedMax - actualMax) / 2)
|
||||
if ([_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)])
|
||||
if ([_delegate splitView:self canCollapseSubview:viewB])
|
||||
realPosition = proposedMax;
|
||||
if ((position > proposedMax - (proposedMax - actualMax) / 2) && [self _sendDelegateSplitViewCanCollapseSubview:viewB])
|
||||
realPosition = proposedMax;
|
||||
|
||||
return realPosition;
|
||||
}
|
||||
@@ -787,9 +792,9 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
|
||||
- (void)resizeSubviewsWithOldSize:(CGSize)oldSize
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
|
||||
if ([self _delegateRespondsToSplitViewResizeSubviewsWithOldSize])
|
||||
{
|
||||
[_delegate splitView:self resizeSubviewsWithOldSize:oldSize];
|
||||
[self _sendDelegateSplitViewResizeSubviewsWithOldSize:oldSize];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -815,8 +820,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
oldFlexibleSpace = 0,
|
||||
totalSizablePanes = 0,
|
||||
isSizableMap = {},
|
||||
viewSizes = [],
|
||||
delegateRespondsToShouldAdjust = [_delegate respondsToSelector:@selector(splitView:shouldAdjustSizeOfSubview:)];
|
||||
viewSizes = [];
|
||||
|
||||
// What we want to do is to preserve non resizable sizes first, and then to preserve the ratio of size to available
|
||||
// non fixed space for every other subview. E.g. assume fixed space was 20 pixels initially, view 1 was 20 and
|
||||
@@ -832,7 +836,7 @@ var ShouldSuppressResizeNotifications = 1,
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var view = _subviews[index],
|
||||
isSizable = !delegateRespondsToShouldAdjust || [_delegate splitView:self shouldAdjustSizeOfSubview:view],
|
||||
isSizable = [self _sendDelegateSplitViewShouldAdjustSizeOfSubview:view],
|
||||
size = [view frame].size[_sizeComponent];
|
||||
|
||||
isSizableMap[index] = isSizable;
|
||||
@@ -958,25 +962,59 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
|
||||
@param delegate - The delegate of the splitview.
|
||||
*/
|
||||
- (void)setDelegate:(id)delegate
|
||||
- (void)setDelegate:(id <CPSplitViewDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitViewDidResizeSubviews:)])
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:_delegate name:CPSplitViewDidResizeSubviewsNotification object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitViewWillResizeSubviews:)])
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:_delegate name:CPSplitViewWillResizeSubviewsNotification object:self];
|
||||
|
||||
_delegate = delegate;
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitViewDidResizeSubviews:)])
|
||||
[[CPNotificationCenter defaultCenter] addObserver:_delegate
|
||||
selector:@selector(splitViewDidResizeSubviews:)
|
||||
name:CPSplitViewDidResizeSubviewsNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitViewWillResizeSubviews:)])
|
||||
[[CPNotificationCenter defaultCenter] addObserver:_delegate
|
||||
selector:@selector(splitViewWillResizeSubviews:)
|
||||
name:CPSplitViewWillResizeSubviewsNotification
|
||||
object:self];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_canCollapseSubview_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:shouldAdjustSizeOfSubview:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_shouldAdjustSizeOfSubview_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:additionalEffectiveRectOfDividerAtIndex:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_additionalEffectiveRectOfDividerAtIndex_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_effectiveRect_forDrawnRect_ofDividerAtIndex_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_constrainMaxCoordinate_ofSubviewAt_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_constrainMinCoordinate_ofSubviewAt_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainSplitPosition:ofSubviewAt:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_constrainSplitPosition_ofSubviewAt_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
|
||||
_implementedDelegateMethods |= CPSplitViewDelegate_splitView_resizeSubviewsWithOldSize_;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -995,7 +1033,7 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
@param unsigned int - The divider index the button bar will be assigned to.
|
||||
*/
|
||||
// FIXME Should be renamed to setButtonBar:ofDividerAtIndex:.
|
||||
- (void)setButtonBar:(CPButtonBar)aButtonBar forDividerAtIndex:(unsigned)dividerIndex
|
||||
- (void)setButtonBar:(CPButtonBar)aButtonBar forDividerAtIndex:(CPUInteger)dividerIndex
|
||||
{
|
||||
if (!aButtonBar)
|
||||
{
|
||||
@@ -1192,6 +1230,148 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPSplitView (CPSplitViewDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Return YES if the delegate implements splitView:resizeSubviewsWithOldSize:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToSplitViewResizeSubviewsWithOldSize
|
||||
{
|
||||
return _implementedDelegateMethods & CPSplitViewDelegate_splitView_resizeSubviewsWithOldSize_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Return YES if the delegate implements splitView:canCollapseSubview:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToSplitViewCanCollapseSubview
|
||||
{
|
||||
return _implementedDelegateMethods & CPSplitViewDelegate_splitView_canCollapseSubview_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Return YES if the delegate implements splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToSplitViewshouldCollapseSubviewForDoubleClickOnDividerAtIndex
|
||||
{
|
||||
return _implementedDelegateMethods & CPSplitViewDelegate_splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex_;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:canCollapseSubview:
|
||||
*/
|
||||
- (BOOL)_sendDelegateSplitViewCanCollapseSubview:(CPView)aView
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_canCollapseSubview_))
|
||||
return NO;
|
||||
|
||||
return [_delegate splitView:self canCollapseSubview:aView];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:shouldAdjustSizeOfSubview:
|
||||
*/
|
||||
- (BOOL)_sendDelegateSplitViewShouldAdjustSizeOfSubview:(CPView)aView
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_shouldAdjustSizeOfSubview_))
|
||||
return YES;
|
||||
|
||||
return [_delegate splitView:self shouldAdjustSizeOfSubview:aView];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:
|
||||
*/
|
||||
- (BOOL)_sendDelegateSplitViewShouldCollapseSubview:(CPView)aView forDoubleClickOnDividerAtIndex:(int)anIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex_))
|
||||
return NO;
|
||||
|
||||
return [_delegate splitView:self shouldCollapseSubview:aView forDoubleClickOnDividerAtIndex:anIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:additionalEffectiveRectOfDividerAtIndex:
|
||||
*/
|
||||
- (CGRect)_sendDelegateSplitViewAdditionalEffectiveRectOfDividerAtIndex:(int)anIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_additionalEffectiveRectOfDividerAtIndex_))
|
||||
return nil;
|
||||
|
||||
return [_delegate splitView:self additionalEffectiveRectOfDividerAtIndex:anIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:
|
||||
*/
|
||||
- (CGRect)_sendDelegateSplitViewEffectiveRect:(CGRect)proposedEffectiveRect forDrawnRect:(CGRect)drawnRect ofDividerAtIndex:(CPInteger)dividerIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_effectiveRect_forDrawnRect_ofDividerAtIndex_))
|
||||
return proposedEffectiveRect;
|
||||
|
||||
return [_delegate splitView:self effectiveRect:proposedEffectiveRect forDrawnRect:drawnRect ofDividerAtIndex:dividerIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:constrainMaxCoordinate:ofSubviewAt:
|
||||
*/
|
||||
- (float)_sendDelegateSplitViewConstrainMaxCoordinate:(float)proposedMax ofSubviewAt:(CPInteger)dividerIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_constrainMaxCoordinate_ofSubviewAt_))
|
||||
return nil;
|
||||
|
||||
return [_delegate splitView:self constrainMaxCoordinate:proposedMax ofSubviewAt:dividerIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:constrainMinCoordinate:ofSubviewAt:
|
||||
*/
|
||||
- (float)_sendDelegateSplitViewConstrainMinCoordinate:(float)proposedMin ofSubviewAt:(CPInteger)dividerIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_constrainMinCoordinate_ofSubviewAt_))
|
||||
return nil;
|
||||
|
||||
return [_delegate splitView:self constrainMinCoordinate:proposedMin ofSubviewAt:dividerIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:constrainSplitPosition:ofSubviewAt:
|
||||
*/
|
||||
- (float)_sendDelegateSplitViewConstrainSplitPosition:(float)proposedMax ofSubviewAt:(CPInteger)dividerIndex
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_constrainSplitPosition_ofSubviewAt_))
|
||||
return nil;
|
||||
|
||||
return [_delegate splitView:self constrainSplitPosition:proposedMax ofSubviewAt:dividerIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate splitView:resizeSubviewsWithOldSize:
|
||||
*/
|
||||
- (void)_sendDelegateSplitViewResizeSubviewsWithOldSize:(CGSize)oldSize
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPSplitViewDelegate_splitView_resizeSubviewsWithOldSize_))
|
||||
return;
|
||||
|
||||
[_delegate splitView:self resizeSubviewsWithOldSize:oldSize];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPSplitViewDelegateKey = "CPSplitViewDelegateKey",
|
||||
CPSplitViewIsVerticalKey = "CPSplitViewIsVerticalKey",
|
||||
CPSplitViewIsPaneSplitterKey = "CPSplitViewIsPaneSplitterKey",
|
||||
|
||||
+6
-6
@@ -182,11 +182,11 @@
|
||||
[_buttonDown setFrame:downFrame];
|
||||
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered | CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateDisabled];
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
|
||||
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:[CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateDisabled];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[CPThemeStateBordered, CPThemeStateDisabled]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateDisabled]];
|
||||
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:[CPThemeStateBordered, CPThemeStateHighlighted]] forThemeAttribute:@"bezel-color" inState:[CPThemeStateBordered, CPThemeStateHighlighted]];
|
||||
}
|
||||
|
||||
- (void)_sizeToFit
|
||||
@@ -213,7 +213,7 @@
|
||||
Set the current value of the stepper.
|
||||
@param aValue a float containing the value
|
||||
*/
|
||||
- (void)setDoubleValue:(float)aValue
|
||||
- (void)setDoubleValue:(double)aValue
|
||||
{
|
||||
if (aValue > _maxValue)
|
||||
[super setDoubleValue:_valueWraps ? _minValue : _maxValue];
|
||||
@@ -267,7 +267,7 @@
|
||||
return @"stepper";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-color-up-button": [CPNull null],
|
||||
|
||||
+28
-16
@@ -33,10 +33,22 @@ CPNoTabsBezelBorder = 4; //Displays no tabs and has a bezeled border.
|
||||
CPNoTabsLineBorder = 5; //Has no tabs and displays a line border.
|
||||
CPNoTabsNoBorder = 6; //Displays no tabs and no border.
|
||||
|
||||
var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
CPTabViewShouldSelectTabViewItemSelector = 2,
|
||||
CPTabViewWillSelectTabViewItemSelector = 4,
|
||||
CPTabViewDidChangeNumberOfTabViewItemsSelector = 8;
|
||||
var CPTabViewDidSelectTabViewItemSelector = 1 << 1,
|
||||
CPTabViewShouldSelectTabViewItemSelector = 1 << 2,
|
||||
CPTabViewWillSelectTabViewItemSelector = 1 << 3,
|
||||
CPTabViewDidChangeNumberOfTabViewItemsSelector = 1 << 4;
|
||||
|
||||
|
||||
@protocol CPTabViewDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)tabView:(CPTabView)tabView shouldSelectTabViewItem:(CPTabViewItem)tabViewItem;
|
||||
- (void)tabView:(CPTabView)tabView didSelectTabViewItem:(CPTabViewItem)tabViewItem;
|
||||
- (void)tabView:(CPTabView)tabView willSelectTabViewItem:(CPTabViewItem)tabViewItem;
|
||||
- (void)tabViewDidChangeNumberOfTabViewItems:(CPTabView)tabView;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -48,18 +60,18 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
*/
|
||||
@implementation CPTabView : CPView
|
||||
{
|
||||
CPArray _items;
|
||||
CPArray _items;
|
||||
|
||||
CPSegmentedControl _tabs;
|
||||
CPBox _box;
|
||||
CPSegmentedControl _tabs;
|
||||
CPBox _box;
|
||||
|
||||
CPNumber _selectedIndex;
|
||||
CPNumber _selectedIndex;
|
||||
|
||||
CPTabViewType _type;
|
||||
CPFont _font;
|
||||
CPTabViewType _type;
|
||||
CPFont _font;
|
||||
|
||||
id _delegate;
|
||||
unsigned _delegateSelectors;
|
||||
id <CPTabViewDelegate> _delegate;
|
||||
unsigned _delegateSelectors;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -107,7 +119,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
@param aTabViewItem the item to insert
|
||||
@param anIndex the index for the item
|
||||
*/
|
||||
- (void)insertTabViewItem:(CPTabViewItem)aTabViewItem atIndex:(unsigned)anIndex
|
||||
- (void)insertTabViewItem:(CPTabViewItem)aTabViewItem atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
[_items insertObject:aTabViewItem atIndex:anIndex];
|
||||
|
||||
@@ -183,7 +195,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
Returns the CPTabViewItem at the specified index.
|
||||
@return a tab view item, or nil
|
||||
*/
|
||||
- (CPTabViewItem)tabViewItemAtIndex:(unsigned)anIndex
|
||||
- (CPTabViewItem)tabViewItemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
return [_items objectAtIndex:anIndex];
|
||||
}
|
||||
@@ -270,7 +282,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
Selects the item at the specified index.
|
||||
@param anIndex the index of the item to display.
|
||||
*/
|
||||
- (BOOL)selectTabViewItemAtIndex:(unsigned)anIndex
|
||||
- (BOOL)selectTabViewItemAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
if (anIndex === _selectedIndex)
|
||||
return;
|
||||
@@ -405,7 +417,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
Sets the delegate for this tab view.
|
||||
@param aDelegate the tab view's delegate
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPTabViewDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate == aDelegate)
|
||||
return;
|
||||
|
||||
@@ -416,7 +416,7 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
to be invoked with row equal to -1 in cases where no actual row is involved but the table
|
||||
view needs to get some generic cell info.
|
||||
*/
|
||||
- (id)dataViewForRow:(int)aRowIndex
|
||||
- (id)dataViewForRow:(CPInteger)aRowIndex
|
||||
{
|
||||
return [self dataView];
|
||||
}
|
||||
@@ -595,7 +595,7 @@ CPTableColumnUserResizingMask = 1 << 1;
|
||||
|
||||
@implementation CPTableColumn (Bindings)
|
||||
|
||||
+ (id)_binderClassForBinding:(CPString)aBinding
|
||||
+ (Class)_binderClassForBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding == CPValueBinding)
|
||||
return [CPTableColumnValueBinder class];
|
||||
@@ -828,7 +828,7 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (id)dataCellForRow:(int)row
|
||||
- (id)dataCellForRow:(CPInteger)row
|
||||
{
|
||||
[CPException raise:CPUnsupportedMethodException
|
||||
reason:@"dataCellForRow: is not supported. Use -dataViewForRow:row instead."];
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
return @"columnHeader";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"background-color": [CPNull null],
|
||||
@@ -48,11 +48,11 @@
|
||||
@"text-color": [CPNull null],
|
||||
@"font": [CPNull null],
|
||||
@"text-shadow-color": [CPNull null],
|
||||
@"text-shadow-offset": CGSizeMakeZero(),
|
||||
@"text-shadow-offset": CGSizeMakeZero()
|
||||
};
|
||||
}
|
||||
|
||||
- (void)initWithFrame:(CGRect)frame
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
|
||||
@@ -272,11 +272,12 @@ var CPTableHeaderViewResizeZone = 3.0,
|
||||
return @"tableHeaderRow";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"background-color": [CPNull null],
|
||||
@"divider-color": [CPColor grayColor],
|
||||
@"divider-thickness": 1.0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -392,7 +393,7 @@ var CPTableHeaderViewResizeZone = 3.0,
|
||||
_activeColumn = columnIndex;
|
||||
_canDragColumn = YES;
|
||||
|
||||
[_tableView _sendDelegateDidMouseDownInHeader:columnIndex];
|
||||
[_tableView _sendDelegateMouseDownInHeaderOfTableColumn:columnIndex];
|
||||
|
||||
if ([self _shouldResizeTableColumn:columnIndex at:currentLocation])
|
||||
[self _startResizingTableColumn:columnIndex at:currentLocation];
|
||||
@@ -822,4 +823,4 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
|
||||
[aCoder encodeObject:_tableView forKey:CPTableHeaderViewTableViewKey];
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
+989
-400
File diff suppressed because it is too large
Load Diff
@@ -28,3 +28,14 @@ CPFormFeedCharacter = "\u000c";
|
||||
CPCarriageReturnCharacter = "\u000d";
|
||||
CPBackTabCharacter = "\u0019";
|
||||
CPDeleteCharacter = "\u007f";
|
||||
|
||||
CPIllegalTextMovement = 0;
|
||||
CPOtherTextMovement = 0;
|
||||
CPReturnTextMovement = 16;
|
||||
CPTabTextMovement = 17;
|
||||
CPBacktabTextMovement = 18;
|
||||
CPLeftTextMovement = 19;
|
||||
CPRightTextMovement = 20;
|
||||
CPUpTextMovement = 21;
|
||||
CPDownTextMovement = 22;
|
||||
CPCancelTextMovement = 23;
|
||||
+348
-129
@@ -32,6 +32,14 @@
|
||||
@global CPApp
|
||||
@global CPStringPboardType
|
||||
|
||||
|
||||
@protocol CPTextFieldDelegate <CPControlTextEditingDelegate>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPTextFieldDelegate_control_didFailToFormatString_errorDescription_ = 1 << 1;
|
||||
|
||||
CPTextFieldSquareBezel = 0; /*! A textfield bezel with squared corners. */
|
||||
CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */
|
||||
|
||||
@@ -112,26 +120,27 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
*/
|
||||
@implementation CPTextField : CPControl
|
||||
{
|
||||
BOOL _isEditing;
|
||||
BOOL _isEditing;
|
||||
|
||||
BOOL _isEditable;
|
||||
BOOL _isSelectable;
|
||||
BOOL _isSecure;
|
||||
BOOL _willBecomeFirstResponderByClick;
|
||||
BOOL _isEditable;
|
||||
BOOL _isSelectable;
|
||||
BOOL _isSecure;
|
||||
BOOL _willBecomeFirstResponderByClick;
|
||||
|
||||
BOOL _drawsBackground;
|
||||
BOOL _drawsBackground;
|
||||
|
||||
CPColor _textFieldBackgroundColor;
|
||||
CPColor _textFieldBackgroundColor;
|
||||
|
||||
CPString _placeholderString;
|
||||
CPString _stringValue;
|
||||
CPString _placeholderString;
|
||||
CPString _stringValue;
|
||||
|
||||
id _delegate;
|
||||
id <CPTextFieldDelegate> _delegate;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
// NS-style Display Properties
|
||||
CPTextFieldBezelStyle _bezelStyle;
|
||||
BOOL _isBordered;
|
||||
CPControlSize _controlSize;
|
||||
CPTextFieldBezelStyle _bezelStyle;
|
||||
BOOL _isBordered;
|
||||
CPControlSize _controlSize;
|
||||
}
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)aBinding
|
||||
@@ -209,7 +218,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return "textfield";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"bezel-inset": CGInsetMakeZero(),
|
||||
@@ -218,7 +227,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
};
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
#if PLATFORM(DOM)
|
||||
- (DOMElement)_inputElement
|
||||
{
|
||||
@@ -352,8 +360,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateEditable];
|
||||
|
||||
// We only allow first responder status if the field is editable and enabled.
|
||||
if (!shouldBeEditable && [[self window] firstResponder] === self)
|
||||
// We only allow first responder status if the field is enable, and editable or selectable.
|
||||
if (!(shouldBeEditable && ![self isSelectable]) && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
|
||||
if (shouldBeEditable)
|
||||
@@ -378,7 +386,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
{
|
||||
[super setEnabled:shouldBeEnabled];
|
||||
|
||||
// We only allow first responder status if the field is editable and enabled.
|
||||
// We only allow first responder status if the field is enabled.
|
||||
if (!shouldBeEnabled && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
}
|
||||
@@ -529,30 +537,36 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return _textFieldBackgroundColor;
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
/*! @ignore */
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return [self isEditable] && [self isEnabled] && [self _isWithinUsablePlatformRect];
|
||||
return [self isEnabled] && ([self isEditable] || [self isSelectable]) && [self _isWithinUsablePlatformRect];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
/*! @ignore */
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
if (![self isEnabled])
|
||||
return NO;
|
||||
|
||||
// As long as we are the first responder we need to monitor the key status of our window.
|
||||
[self _setObserveWindowKeyNotifications:YES];
|
||||
|
||||
_isEditing = NO;
|
||||
|
||||
if ([[self window] isKeyWindow])
|
||||
if ([[self window] isKeyWindow] && [self isEditable])
|
||||
return [self _becomeFirstKeyResponder];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
/*
|
||||
A text field can be the first responder without necessarily being the focus of keyboard input. For example, it might be the first responder of window A but window B is the main and key window. It's important we don't put a focused input field into a text field in a non-key window, even if that field is the first responder, because the key window might also have a first responder text field which the user will expect to receive keyboard input.
|
||||
|
||||
Since a first responder but non-key window text field can't receive input it should not even look like an active text field (Cocoa has a "slightly active" text field look it uses when another window is the key window, but Cappuccino doesn't today.)
|
||||
|
||||
It's also possible for a text field to be non-editable but selectable in which case it can also become the first responder -
|
||||
this is what allows text to be copied from it.
|
||||
*/
|
||||
- (BOOL)_becomeFirstKeyResponder
|
||||
{
|
||||
@@ -561,6 +575,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (![self _isWithinUsablePlatformRect])
|
||||
return NO;
|
||||
|
||||
// A selectable but non-editable text field may be the first responder, but never the
|
||||
// first key responder (first key responder indicating editability.)
|
||||
if (![self isEditable])
|
||||
return NO;
|
||||
|
||||
[self setThemeState:CPThemeStateEditing];
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
@@ -576,7 +595,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
lineHeight = [font defaultLineHeightForFont];
|
||||
|
||||
element.value = _stringValue;
|
||||
element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString];
|
||||
element.style.color = [[self valueForThemeAttribute:@"text-color" inState:CPThemeStateEditing] cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM))
|
||||
element.style.font = [font cssString];
|
||||
@@ -677,28 +696,30 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return YES;
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
/*! @ignore */
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var element = [self _inputElement],
|
||||
newValue = element.value,
|
||||
error = @"";
|
||||
|
||||
if (newValue !== _stringValue)
|
||||
// We might have been the first responder without actually editing.
|
||||
if (_isEditing && CPTextFieldInputOwner === self)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
}
|
||||
var element = [self _inputElement],
|
||||
newValue = element.value,
|
||||
error = @"";
|
||||
|
||||
// If there is a formatter, always give it a chance to reject the resignation,
|
||||
// even if the value has not changed.
|
||||
if ([self _valueIsValid:newValue] === NO)
|
||||
{
|
||||
element.focus();
|
||||
return NO;
|
||||
}
|
||||
if (newValue !== _stringValue)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
}
|
||||
|
||||
// If there is a formatter, always give it a chance to reject the resignation,
|
||||
// even if the value has not changed.
|
||||
if ([self _valueIsValid:newValue] === NO)
|
||||
{
|
||||
element.focus();
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// When we are no longer the first responder we don't worry about the key status of our window anymore.
|
||||
@@ -707,10 +728,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self _resignFirstKeyResponder];
|
||||
|
||||
_isEditing = NO;
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
if ([self isEditable])
|
||||
{
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:@{"CPTextMovement": [self _currentTextMovement]}]];
|
||||
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
[self textDidBlur:[CPNotification notificationWithName:CPTextFieldDidBlurNotification object:self userInfo:nil]];
|
||||
|
||||
@@ -783,9 +807,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)_windowDidBecomeKey:(CPNotification)aNotification
|
||||
{
|
||||
if ([[self window] isKeyWindow] && [[self window] firstResponder] === self)
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var wind = [self window];
|
||||
|
||||
if ([wind isKeyWindow] && [wind firstResponder] === self)
|
||||
if (![self _becomeFirstKeyResponder])
|
||||
[[self window] makeFirstResponder:nil];
|
||||
[wind makeFirstResponder:nil];
|
||||
}
|
||||
|
||||
- (BOOL)_valueIsValid:(CPString)aValue
|
||||
@@ -798,7 +827,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
{
|
||||
var acceptInvalidValue = NO;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(control:didFailToFormatString:errorDescription:)])
|
||||
if (_implementedDelegateMethods & CPTextFieldDelegate_control_didFailToFormatString_errorDescription_)
|
||||
acceptInvalidValue = [_delegate control:self didFailToFormatString:aValue errorDescription:error];
|
||||
|
||||
if (acceptInvalidValue === NO)
|
||||
@@ -820,13 +849,24 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
|
||||
/*!
|
||||
Only text fields that can become first responder accepts first mouse.
|
||||
Only text fields that can become first responder accept first mouse.
|
||||
*/
|
||||
- (BOOL)acceptsFirstMouse:(CPEvent)anEvent
|
||||
{
|
||||
return [self acceptsFirstResponder];
|
||||
}
|
||||
|
||||
- (void)_didEdit
|
||||
{
|
||||
if (!_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
// Don't track! (ever?)
|
||||
@@ -853,7 +893,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isSelectable] && (![self isEditable] || ![self isEnabled]))
|
||||
if (![self isEnabled] || !([self isSelectable] || [self isEditable]))
|
||||
[[self nextResponder] mouseUp:anEvent];
|
||||
else if ([self isSelectable])
|
||||
{
|
||||
@@ -865,13 +905,22 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldCachedSelectStartFunction = nil
|
||||
CPTextFieldCachedDragFunction = nil;
|
||||
}
|
||||
|
||||
// TODO clickCount === 2 should select the clicked word.
|
||||
|
||||
if ([[CPApp currentEvent] clickCount] === 3)
|
||||
{
|
||||
[self selectText:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isSelectable] && (![self isEditable] || ![self isEnabled]))
|
||||
if (![self isEnabled] || !([self isSelectable] || [self isEditable]))
|
||||
[[self nextResponder] mouseDragged:anEvent];
|
||||
else if ([self isSelectable])
|
||||
return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
@@ -879,26 +928,21 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)keyUp:(CPEvent)anEvent
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var newValue = [self _inputElement].value;
|
||||
|
||||
if (newValue !== _stringValue)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
|
||||
if (!_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
@@ -931,11 +975,15 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)insertNewline:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var newValue = [self _inputElement].value;
|
||||
|
||||
if (newValue !== _stringValue)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
if ([self _valueIsValid:_stringValue])
|
||||
@@ -948,7 +996,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (_isEditing)
|
||||
{
|
||||
_isEditing = NO;
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:@{"CPTextMovement": [self _currentTextMovement]}]];
|
||||
}
|
||||
|
||||
// If there is no target action, or the sendAction call returns
|
||||
@@ -974,6 +1022,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)_insertCharacterIgnoringFieldEditor:(CPString)aCharacter
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var oldValue = _stringValue,
|
||||
@@ -986,13 +1037,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// NOTE: _stringValue is now the current input element value
|
||||
if (oldValue !== _stringValue)
|
||||
{
|
||||
if (!_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1035,7 +1080,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
Sets the internal string value without updating the value in the input element.
|
||||
This should only be invoked when the underlying text element's value has changed.
|
||||
*/
|
||||
@@ -1044,8 +1088,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return [self _setStringValue:aValue isNewValue:YES errorDescription:nil];
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
/*!
|
||||
Sets the internal string value without updating the value in the input element.
|
||||
If there is a formatter and formatting fails, returns NO. Otherwise returns YES.
|
||||
*/
|
||||
@@ -1104,14 +1147,17 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
value = undefined;
|
||||
|
||||
[super setObjectValue:value];
|
||||
_stringValue = (value === nil || value === undefined) ? @"" : String(value);
|
||||
}
|
||||
else
|
||||
_stringValue = formattedString;
|
||||
}
|
||||
|
||||
_stringValue = [self stringValue];
|
||||
else
|
||||
_stringValue = [self stringValue];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
if (CPTextFieldInputOwner === self || [[self window] firstResponder] === self)
|
||||
if ((CPTextFieldInputOwner === self || [[self window] firstResponder] === self) && [[self window] isKeyWindow])
|
||||
[self _inputElement].value = _stringValue;
|
||||
|
||||
#endif
|
||||
@@ -1121,7 +1167,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)_updatePlaceholderState
|
||||
{
|
||||
if ((!_stringValue || _stringValue.length === 0) && ![self hasThemeState:CPThemeStateEditing])
|
||||
if (!_stringValue || _stringValue.length === 0)
|
||||
[self setThemeState:CPTextFieldStatePlaceholder];
|
||||
else
|
||||
[self unsetThemeState:CPTextFieldStatePlaceholder];
|
||||
@@ -1241,22 +1287,29 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)_selectText:(id)sender immediately:(BOOL)immediately
|
||||
{
|
||||
// Selecting the text in a field makes it the first responder
|
||||
if (([self isEditable] || [self isSelectable]))
|
||||
if ([self isEditable] || [self isSelectable])
|
||||
{
|
||||
var wind = [self window];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var element = [self _inputElement];
|
||||
|
||||
if ([wind firstResponder] === self)
|
||||
if ([self isEditable])
|
||||
{
|
||||
if (immediately)
|
||||
element.select();
|
||||
else
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
var element = [self _inputElement];
|
||||
|
||||
if ([wind firstResponder] === self)
|
||||
{
|
||||
if (immediately)
|
||||
element.select();
|
||||
else
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
}
|
||||
else if (wind !== nil && [wind makeFirstResponder:self])
|
||||
[self _selectText:sender immediately:immediately];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setSelectedRange:CPMakeRange(0, _stringValue.length)];
|
||||
}
|
||||
else if (wind !== nil && [wind makeFirstResponder:self])
|
||||
[self _selectText:sender immediately:immediately];
|
||||
#else
|
||||
// Even if we can't actually select the text we need to preserve the first
|
||||
// responder side effect.
|
||||
@@ -1269,36 +1322,70 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)copy:(id)sender
|
||||
{
|
||||
if (![CPPlatform isBrowser])
|
||||
// First write to the Cappuccino clipboard.
|
||||
var stringToCopy = nil;
|
||||
|
||||
if ([self isEditable])
|
||||
{
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 1)
|
||||
return;
|
||||
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
stringForPasting = [_stringValue substringWithRange:selectedRange];
|
||||
stringToCopy = [_stringValue substringWithRange:selectedRange];
|
||||
}
|
||||
else
|
||||
{
|
||||
// selectedRange won't work if we're displaying our text using a <div>. Instead we have to ask the browser
|
||||
// what's selected and hope it's right in a Cappuccino context as well.
|
||||
#if PLATFORM(DOM)
|
||||
stringToCopy = [[[self window] platformWindow] _selectedText];
|
||||
#endif
|
||||
}
|
||||
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
|
||||
[pasteboard setString:stringForPasting forType:CPStringPboardType];
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
|
||||
[pasteboard setString:stringToCopy forType:CPStringPboardType];
|
||||
|
||||
if ([CPPlatform isBrowser])
|
||||
{
|
||||
// Then also allow the browser to capture the copied text into the system clipboard.
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cut:(id)sender
|
||||
{
|
||||
if (![CPPlatform isBrowser])
|
||||
if (![self isEnabled])
|
||||
return;
|
||||
|
||||
[self copy:sender];
|
||||
|
||||
if (![self isEditable])
|
||||
return;
|
||||
|
||||
if (![[CPApp currentEvent] _platformIsEffectingCutOrPaste])
|
||||
{
|
||||
[self copy:sender];
|
||||
[self deleteBackward:sender];
|
||||
}
|
||||
// If we don't have an oninput listener, we won't detect the change made by the cut and need to fake a key up "soon".
|
||||
else if (!CPFeatureIsCompatible(CPInputOnInputEventFeature))
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(keyUp:) userInfo:nil repeats:NO];
|
||||
else
|
||||
{
|
||||
// Allow the browser's standard cut handling. This should also result in the deleteBackward: happening.
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
|
||||
// If we don't have an oninput listener, we won't detect the change made by the cut and need to fake a key up "soon".
|
||||
if (!CPFeatureIsCompatible(CPInputOnInputEventFeature))
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(keyUp:) userInfo:nil repeats:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
if (![CPPlatform isBrowser])
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
if (![[CPApp currentEvent] _platformIsEffectingCutOrPaste])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
@@ -1312,15 +1399,24 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:pasteString];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self _didEdit];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location + pasteString.length, 0)];
|
||||
}
|
||||
// If we don't have an oninput listener, we won't detect the change made by the cut and need to fake a key up "soon".
|
||||
else if (!CPFeatureIsCompatible(CPInputOnInputEventFeature))
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(keyUp:) userInfo:nil repeats:NO];
|
||||
else
|
||||
{
|
||||
// Allow the browser's standard paste handling.
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
|
||||
if (!CPFeatureIsCompatible(CPInputOnInputEventFeature))
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(keyUp:) userInfo:nil repeats:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (CPRange)selectedRange
|
||||
{
|
||||
// TODO Need a way to figure out the selected range if we're not using an input. Need
|
||||
// to get whole document selection and somehow see which part is inside of this text field.
|
||||
if ([[self window] firstResponder] !== self)
|
||||
return CPMakeRange(0, 0);
|
||||
|
||||
@@ -1364,35 +1460,48 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var inputElement = [self _inputElement];
|
||||
|
||||
try
|
||||
if (![self isEditable])
|
||||
{
|
||||
if ([inputElement.selectionStart isKindOfClass:CPNumber])
|
||||
{
|
||||
inputElement.selectionStart = aRange.location;
|
||||
inputElement.selectionEnd = CPMaxRange(aRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
// browsers which don't support selectionStart/selectionEnd (aka IE).
|
||||
var theDocument = inputElement.ownerDocument || inputElement.document,
|
||||
existingRange = theDocument.selection.createRange(),
|
||||
range = inputElement.createTextRange();
|
||||
// No input element - selectable text field only.
|
||||
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:@"bezel-view"];
|
||||
|
||||
if (range.inRange(existingRange))
|
||||
if (contentView)
|
||||
[contentView setSelectedRange:aRange];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input element
|
||||
var inputElement = [self _inputElement];
|
||||
|
||||
try
|
||||
{
|
||||
if ([inputElement.selectionStart isKindOfClass:CPNumber])
|
||||
{
|
||||
range.collapse(true);
|
||||
range.move('character', aRange.location);
|
||||
range.moveEnd('character', aRange.length);
|
||||
range.select();
|
||||
inputElement.selectionStart = aRange.location;
|
||||
inputElement.selectionEnd = CPMaxRange(aRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
// browsers which don't support selectionStart/selectionEnd (aka IE).
|
||||
var theDocument = inputElement.ownerDocument || inputElement.document,
|
||||
existingRange = theDocument.selection.createRange(),
|
||||
range = inputElement.createTextRange();
|
||||
|
||||
if (range.inRange(existingRange))
|
||||
{
|
||||
range.collapse(true);
|
||||
range.move('character', aRange.location);
|
||||
range.moveEnd('character', aRange.length);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1403,23 +1512,89 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)deleteBackward:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 2)
|
||||
return;
|
||||
if (selectedRange.length < 1)
|
||||
{
|
||||
if (selectedRange.location < 1)
|
||||
return;
|
||||
|
||||
selectedRange.location += 1;
|
||||
selectedRange.length -= 1;
|
||||
// Delete a single element backward from the insertion point if there's no selection.
|
||||
selectedRange.location -= 1;
|
||||
selectedRange.length += 1;
|
||||
}
|
||||
|
||||
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
|
||||
[self _didEdit];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// Since we just performed the deletion manually, we don't need the browser to do anything else.
|
||||
// (Previously we would allow the event to propagate for the browser to delete 1 character only,
|
||||
// and we'd delete the rest manually. But this meant that if deleteBackward: was called without
|
||||
// it being a browser backspace event, 1 character would be left behind.)
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
// delete: only works when there's a selection (as opposed to deleteForward: and deleteBackward:).
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 1)
|
||||
return;
|
||||
|
||||
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
|
||||
[self _didEdit];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// Since we just performed the deletion manually, we don't need the browser to do anything else.
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)deleteForward:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 1)
|
||||
{
|
||||
if (selectedRange.location + 1 >= _stringValue.length)
|
||||
return;
|
||||
|
||||
selectedRange.length += 1;
|
||||
}
|
||||
|
||||
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
|
||||
[self _didEdit];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// Since we just performed the deletion manually, we don't need the browser to do anything else.
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark Setting the Delegate
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPTextFieldDelegate>)aDelegate
|
||||
{
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
@@ -1434,6 +1609,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(control:didFailToFormatString:errorDescription:)])
|
||||
_implementedDelegateMethods |= CPTextFieldDelegate_control_didFailToFormatString_errorDescription_
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(controlTextDidBeginEditing:)])
|
||||
[defaultCenter
|
||||
@@ -1539,7 +1718,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
if (contentView)
|
||||
{
|
||||
[contentView setHidden:[self hasThemeState:CPThemeStateEditing]];
|
||||
[contentView setHidden:(_stringValue && _stringValue.length > 0) && [self hasThemeState:CPThemeStateEditing]];
|
||||
|
||||
var string = "";
|
||||
|
||||
@@ -1581,6 +1760,41 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Overrides
|
||||
|
||||
- (void)viewDidHide
|
||||
{
|
||||
[super viewDidHide];
|
||||
|
||||
if ([[self window] firstResponder] === self)
|
||||
[self _resignFirstKeyResponder];
|
||||
}
|
||||
|
||||
- (void)viewDidUnhide
|
||||
{
|
||||
[super viewDidUnhide];
|
||||
|
||||
if ([self isEditable] && [[self window] firstResponder] === self)
|
||||
[self _becomeFirstKeyResponder];
|
||||
}
|
||||
|
||||
- (BOOL)validateUserInterfaceItem:(id /*<CPValidatedUserInterfaceItem>*/)anItem
|
||||
{
|
||||
var theAction = [anItem action];
|
||||
|
||||
if (![self isEditable] && (theAction == @selector(cut:) || theAction == @selector(paste:) || theAction == @selector(delete:)))
|
||||
return NO;
|
||||
|
||||
// FIXME - [self selectedRange] is always empty if we're not an editable field, so we must assume yes here.
|
||||
if (![self isEditable])
|
||||
return YES;
|
||||
|
||||
if (theAction == @selector(copy:) || theAction == @selector(cut:) || theAction == @selector(delete:))
|
||||
return [self selectedRange].length;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
|
||||
- (BOOL)_isWithinUsablePlatformRect
|
||||
@@ -1588,8 +1802,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// Make sure the text field is completely within the platform window
|
||||
// so the browser will not scroll it into view.
|
||||
|
||||
var wind = [self window],
|
||||
frame = [self convertRectToBase:[self bounds]],
|
||||
var wind = [self window];
|
||||
|
||||
// If the field is not yet within a window, it can't be first responder
|
||||
if (!wind)
|
||||
return NO;
|
||||
|
||||
var frame = [self convertRectToBase:[self bounds]],
|
||||
usableRect = [[wind platformWindow] usableContentFrame];
|
||||
|
||||
frame.origin = [wind convertBaseToGlobal:frame.origin];
|
||||
@@ -1677,7 +1896,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
|
||||
@implementation _CPTextFieldValueBinder : CPBinder
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options forBinding:(CPBinder)aBinding
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options forBinding:(CPString)aBinding
|
||||
{
|
||||
[super _updatePlaceholdersWithOptions:options];
|
||||
|
||||
|
||||
+183
-133
@@ -240,7 +240,7 @@ var CPThemesByName = { },
|
||||
@param aClass The themed class in which to look for the attribute
|
||||
@return A value or nil
|
||||
*/
|
||||
- (id)valueForAttributeWithName:(CPString)aName inState:(CPThemeState)aState forClass:(id)aClass
|
||||
- (id)valueForAttributeWithName:(CPString)aName inState:(ThemeState)aState forClass:(id)aClass
|
||||
{
|
||||
var attribute = [self attributeWithName:aName forClass:aClass];
|
||||
|
||||
@@ -314,6 +314,164 @@ var CPThemeNameKey = @"CPThemeNameKey",
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
* ThemeStates are immutable objects representing a particular ThemeState. Applications should never be creating
|
||||
* ThemeStates directly but should instead use the CPThemeState function.
|
||||
*/
|
||||
function ThemeState(stateNames)
|
||||
{
|
||||
var stateNameKeys = [];
|
||||
this._stateNames = {};
|
||||
|
||||
for (key in stateNames)
|
||||
{
|
||||
if (!stateNames.hasOwnProperty(key))
|
||||
continue;
|
||||
if (key !== 'normal')
|
||||
{
|
||||
this._stateNames[key] = true;
|
||||
stateNameKeys.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
if (stateNameKeys.length === 0)
|
||||
{
|
||||
stateNameKeys.push('normal');
|
||||
this._stateNames['normal'] = true;
|
||||
}
|
||||
|
||||
stateNameKeys.sort();
|
||||
this._stateNameString = stateNameKeys[0];
|
||||
|
||||
var stateNameLength = stateNameKeys.length;
|
||||
for (var stateIndex = 1; stateIndex < stateNameLength; stateIndex++)
|
||||
this._stateNameString = this._stateNameString + "+" + stateNameKeys[stateIndex];
|
||||
this._stateNameCount = stateNameLength;
|
||||
}
|
||||
|
||||
ThemeState.prototype.toString = function()
|
||||
{
|
||||
return this._stateNameString;
|
||||
}
|
||||
|
||||
ThemeState.prototype.hasThemeState = function(aState)
|
||||
{
|
||||
if (!aState || !aState._stateNames)
|
||||
return false;
|
||||
|
||||
// We can do this in O(n) because both states have their stateNames already sorted.
|
||||
for (var stateName in aState._stateNames)
|
||||
{
|
||||
if (!aState._stateNames.hasOwnProperty(stateName))
|
||||
continue;
|
||||
|
||||
if (!this._stateNames[stateName])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ThemeState.prototype.isSubsetOf = function(aState)
|
||||
{
|
||||
if (aState._stateNameCount < this._stateNameCount)
|
||||
return false;
|
||||
|
||||
for (var key in this._stateNames)
|
||||
{
|
||||
if (!this._stateNames.hasOwnProperty(key))
|
||||
continue;
|
||||
|
||||
if (!aState._stateNames[key])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ThemeState.prototype.without = function(aState)
|
||||
{
|
||||
if (!aState || aState === [CPNull null])
|
||||
return this;
|
||||
|
||||
var newStates = {};
|
||||
for (var stateName in this._stateNames)
|
||||
{
|
||||
if (!this._stateNames.hasOwnProperty(stateName))
|
||||
continue;
|
||||
|
||||
if (!aState._stateNames[stateName])
|
||||
newStates[stateName] = true;
|
||||
}
|
||||
|
||||
return ThemeState._cacheThemeState(new ThemeState(newStates));
|
||||
}
|
||||
|
||||
ThemeState.prototype.and = function(aState)
|
||||
{
|
||||
return CPThemeState(this, aState);
|
||||
}
|
||||
|
||||
var CPThemeStates = {};
|
||||
|
||||
ThemeState._cacheThemeState = function(aState)
|
||||
{
|
||||
// We do this caching so themeState equality works. Basically, doing CPThemeState('foo+bar') === CPThemeState('bar', 'foo') will return true.
|
||||
var themeState = CPThemeStates[String(aState)];
|
||||
if (themeState === undefined)
|
||||
{
|
||||
themeState = aState;
|
||||
CPThemeStates[String(themeState)] = themeState;
|
||||
}
|
||||
return themeState;
|
||||
}
|
||||
|
||||
/*!
|
||||
* This method can be called in multiple ways:
|
||||
* CPThemeState('state1') - creates a new CPThemeState that corresponds to the string 'state1'
|
||||
* CPThemeState('state1', 'state2') - creates a new composite CPThemeState made up of both 'state1' or 'state2'
|
||||
* CPThemeState('state1+state2') - The same as CPThemeState('state1', 'state2')
|
||||
* CPThemeState(state1, state2) - creates a new composite CPThemeState made up of state1 and state2
|
||||
* where state1 and state2 are not strings but are themselves CPThemeStates.
|
||||
*/
|
||||
function CPThemeState()
|
||||
{
|
||||
if (arguments.length < 1)
|
||||
throw "CPThemeState() must be called with at least one string argument";
|
||||
|
||||
var themeState;
|
||||
if (arguments.length === 1 && typeof arguments[0] === 'string')
|
||||
{
|
||||
themeState = CPThemeStates[arguments[0]];
|
||||
if (themeState !== undefined)
|
||||
return themeState;
|
||||
}
|
||||
|
||||
var stateNames = {};
|
||||
for (var argIndex = 0; argIndex < arguments.length; argIndex++)
|
||||
{
|
||||
if (arguments[argIndex] === [CPNull null] || !arguments[argIndex])
|
||||
continue;
|
||||
|
||||
if (typeof arguments[argIndex] === 'object')
|
||||
{
|
||||
for (var stateName in arguments[argIndex]._stateNames)
|
||||
{
|
||||
if (!arguments[argIndex]._stateNames.hasOwnProperty(stateName))
|
||||
continue;
|
||||
stateNames[stateName] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var allNames = arguments[argIndex].split('+');
|
||||
for (var nameIndex = 0; nameIndex < allNames.length; nameIndex++)
|
||||
stateNames[allNames[nameIndex]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
themeState = ThemeState._cacheThemeState(new ThemeState(stateNames));
|
||||
return themeState;
|
||||
}
|
||||
|
||||
@implementation _CPThemeKeyedUnarchiver : CPKeyedUnarchiver
|
||||
{
|
||||
CPBundle _bundle;
|
||||
@@ -341,71 +499,7 @@ var CPThemeNameKey = @"CPThemeNameKey",
|
||||
|
||||
@end
|
||||
|
||||
var CPThemeStates = {},
|
||||
CPThemeStateNames = {},
|
||||
CPThemeStateCount = 0;
|
||||
|
||||
function CPThemeState(aStateName)
|
||||
{
|
||||
var state = CPThemeStates[aStateName];
|
||||
|
||||
if (state === undefined)
|
||||
{
|
||||
if (aStateName.indexOf('+') === -1)
|
||||
state = 1 << CPThemeStateCount++;
|
||||
else
|
||||
{
|
||||
var state = 0,
|
||||
states = aStateName.split('+'),
|
||||
count = states.length;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var stateName = states[count],
|
||||
individualState = CPThemeStates[stateName];
|
||||
|
||||
if (individualState === undefined)
|
||||
{
|
||||
individualState = 1 << CPThemeStateCount++;
|
||||
CPThemeStates[stateName] = individualState;
|
||||
CPThemeStateNames[individualState] = stateName;
|
||||
}
|
||||
|
||||
state |= individualState;
|
||||
}
|
||||
}
|
||||
|
||||
CPThemeStates[aStateName] = state;
|
||||
CPThemeStateNames[state] = aStateName;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function CPThemeStateName(aState)
|
||||
{
|
||||
var name = CPThemeStateNames[aState];
|
||||
|
||||
if (name !== undefined)
|
||||
return name;
|
||||
|
||||
if (!(aState & (aState - 1)))
|
||||
return "";
|
||||
|
||||
var state = 1,
|
||||
name = "";
|
||||
|
||||
for (; state < aState; state <<= 1)
|
||||
if (aState & state)
|
||||
name += (name.length === 0 ? '' : '+') + CPThemeStateNames[state];
|
||||
|
||||
CPThemeStateNames[aState] = name;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
CPThemeStateNames[0] = "normal";
|
||||
CPThemeStateNormal = CPThemeStates["normal"] = 0;
|
||||
CPThemeStateNormal = CPThemeState("normal");
|
||||
CPThemeStateDisabled = CPThemeState("disabled");
|
||||
CPThemeStateHovered = CPThemeState("hovered");
|
||||
CPThemeStateHighlighted = CPThemeState("highlighted");
|
||||
@@ -464,11 +558,6 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
return [_values count] > 0;
|
||||
}
|
||||
|
||||
- (BOOL)isTrivial
|
||||
{
|
||||
return ([_values count] === 1) && (Number([_values allKeys][0]) === CPThemeStateNormal);
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue
|
||||
{
|
||||
_cache = {};
|
||||
@@ -479,7 +568,7 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
_values = @{ String(CPThemeStateNormal): aValue };
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forState:(CPThemeState)aState
|
||||
- (void)setValue:(id)aValue forState:(ThemeState)aState
|
||||
{
|
||||
_cache = { };
|
||||
|
||||
@@ -494,44 +583,34 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
return [self valueForState:CPThemeStateNormal];
|
||||
}
|
||||
|
||||
- (id)valueForState:(CPThemeState)aState
|
||||
- (id)valueForState:(ThemeState)aState
|
||||
{
|
||||
var value = _cache[aState];
|
||||
var stateName = String(aState),
|
||||
value = _cache[stateName];
|
||||
|
||||
// This can be nil.
|
||||
if (value !== undefined)
|
||||
return value;
|
||||
|
||||
value = [_values objectForKey:String(aState)];
|
||||
value = [_values objectForKey:stateName];
|
||||
|
||||
// If we don't have a value, and we have a non-normal state...
|
||||
if ((value === undefined || value === nil) && aState !== CPThemeStateNormal)
|
||||
if (value === undefined || value === nil)
|
||||
{
|
||||
// If this is a composite state (not a power of 2), find the closest partial subset match.
|
||||
if (aState & (aState - 1))
|
||||
// If this is a composite state, find the closest partial subset match.
|
||||
if (aState._stateNameCount > 1)
|
||||
{
|
||||
var highestOneCount = 0,
|
||||
states = [_values allKeys],
|
||||
count = states.length;
|
||||
var states = [_values allKeys],
|
||||
count = states.length,
|
||||
largestThemeState = 0;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
// states[count] is a string!
|
||||
var state = Number(states[count]);
|
||||
var stateObject = CPThemeState(states[count]);
|
||||
|
||||
// A & B = A iff A < B
|
||||
if ((state & aState) === state)
|
||||
if (stateObject.isSubsetOf(aState) && stateObject._stateNameCount > largestThemeState)
|
||||
{
|
||||
var oneCount = cachedNumberOfOnes[state];
|
||||
|
||||
if (oneCount === undefined)
|
||||
oneCount = numberOfOnes(state);
|
||||
|
||||
if (oneCount > highestOneCount)
|
||||
{
|
||||
highestOneCount = oneCount;
|
||||
value = [_values objectForKey:String(state)];
|
||||
}
|
||||
value = [_values objectForKey:states[count]];
|
||||
largestThemeState = stateObject._stateNameCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,7 +633,7 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
value = nil;
|
||||
}
|
||||
|
||||
_cache[aState] = value;
|
||||
_cache[stateName] = value;
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -596,10 +675,10 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
|
||||
if ([aCoder containsValueForKey:@"value"])
|
||||
{
|
||||
var state = CPThemeStateNormal;
|
||||
var state = String(CPThemeStateNormal);
|
||||
|
||||
if ([aCoder containsValueForKey:@"state"])
|
||||
state = CPThemeState([aCoder decodeObjectForKey:@"state"]);
|
||||
state = [aCoder decodeObjectForKey:@"state"];
|
||||
|
||||
[_values setObject:[aCoder decodeObjectForKey:"value"] forKey:state];
|
||||
}
|
||||
@@ -613,7 +692,7 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
{
|
||||
var key = keys[count];
|
||||
|
||||
[_values setObject:[encodedValues objectForKey:key] forKey:CPThemeState(key)];
|
||||
[_values setObject:[encodedValues objectForKey:key] forKey:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -633,8 +712,8 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
{
|
||||
var onlyKey = keys[0];
|
||||
|
||||
if (Number(onlyKey) !== CPThemeStateNormal)
|
||||
[aCoder encodeObject:CPThemeStateName(Number(onlyKey)) forKey:@"state"];
|
||||
if (onlyKey !== String(CPThemeStateNormal))
|
||||
[aCoder encodeObject:onlyKey forKey:@"state"];
|
||||
|
||||
[aCoder encodeObject:[_values objectForKey:onlyKey] forKey:@"value"];
|
||||
}
|
||||
@@ -646,7 +725,7 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
{
|
||||
var key = keys[count];
|
||||
|
||||
[encodedValues setObject:[_values objectForKey:key] forKey:CPThemeStateName(Number(key))];
|
||||
[encodedValues setObject:[_values objectForKey:key] forKey:key];
|
||||
}
|
||||
|
||||
[aCoder encodeObject:encodedValues forKey:@"values"];
|
||||
@@ -655,35 +734,6 @@ CPThemeStateKeyWindow = CPThemeState("keyWindow");
|
||||
|
||||
@end
|
||||
|
||||
var cachedNumberOfOnes = [ 0 /*000000*/, 1 /*000001*/, 1 /*000010*/, 2 /*000011*/, 1 /*000100*/, 2 /*000101*/, 2 /*000110*/,
|
||||
3 /*000111*/, 1 /*001000*/, 2 /*001001*/, 2 /*001010*/, 3 /*001011*/, 2 /*001100*/, 3 /*001101*/,
|
||||
3 /*001110*/, 4 /*001111*/, 1 /*010000*/, 2 /*010001*/, 2 /*010010*/, 3 /*010011*/, 2 /*010100*/,
|
||||
3 /*010101*/, 3 /*010110*/, 4 /*010111*/, 2 /*011000*/, 3 /*011001*/, 3 /*011010*/, 4 /*011011*/,
|
||||
3 /*011100*/, 4 /*011101*/, 4 /*011110*/, 5 /*011111*/, 1 /*100000*/, 2 /*100001*/, 2 /*100010*/,
|
||||
3 /*100011*/, 2 /*100100*/, 3 /*100101*/, 3 /*100110*/, 4 /*100111*/, 2 /*101000*/, 3 /*101001*/,
|
||||
3 /*101010*/, 4 /*101011*/, 3 /*101100*/, 4 /*101101*/, 4 /*101110*/, 5 /*101111*/, 2 /*110000*/,
|
||||
3 /*110001*/, 3 /*110010*/, 4 /*110011*/, 3 /*110100*/, 4 /*110101*/, 4 /*110110*/, 5 /*110111*/,
|
||||
3 /*111000*/, 4 /*111001*/, 4 /*111010*/, 5 /*111011*/, 4 /*111100*/, 5 /*111101*/, 5 /*111110*/,
|
||||
6 /*111111*/ ];
|
||||
|
||||
var numberOfOnes = function(aNumber)
|
||||
{
|
||||
var count = 0,
|
||||
slot = aNumber;
|
||||
|
||||
while (aNumber)
|
||||
{
|
||||
++count;
|
||||
aNumber &= (aNumber - 1);
|
||||
}
|
||||
|
||||
cachedNumberOfOnes[slot] = count;
|
||||
|
||||
return count;
|
||||
};
|
||||
|
||||
numberOfOnes.displayName = "numberOfOnes";
|
||||
|
||||
function CPThemeAttributeEncode(aCoder, aThemeAttribute)
|
||||
{
|
||||
var values = aThemeAttribute._values,
|
||||
@@ -694,7 +744,7 @@ function CPThemeAttributeEncode(aCoder, aThemeAttribute)
|
||||
{
|
||||
var state = [values allKeys][0];
|
||||
|
||||
if (Number(state) === 0)
|
||||
if (state === String(CPThemeStateNormal))
|
||||
{
|
||||
[aCoder encodeObject:[values objectForKey:state] forKey:key];
|
||||
|
||||
|
||||
Executable → Regular
+113
-44
@@ -34,6 +34,30 @@
|
||||
@import "CPWindow_Constants.j"
|
||||
|
||||
@global CPApp
|
||||
@global CPTextFieldDidFocusNotification
|
||||
@global CPTextFieldDidBlurNotification
|
||||
|
||||
|
||||
// TODO: should be conform to protocol CPTextFieldDelegate
|
||||
@protocol CPTokenFieldDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)tokenField:(CPTokenField)tokenField hasMenuForRepresentedObject:(id)representedObject;
|
||||
- (CPArray)tokenField:(CPTokenField)tokenField completionsForSubstring:(CPString)substring indexOfToken:(CPInteger)tokenIndex indexOfSelectedItem:(CPInteger)selectedIndex;
|
||||
- (CPArray)tokenField:(CPTokenField)tokenField shouldAddObjects:(CPArray)tokens atIndex:(CPUInteger)index;
|
||||
- (CPMenu)tokenField:(CPTokenField)tokenField menuForRepresentedObject:(id)representedObject;
|
||||
- (CPString )tokenField:(CPTokenField)tokenField displayStringForRepresentedObject:(id)representedObject;
|
||||
- (id)tokenField:(CPTokenField)tokenField representedObjectForEditingString:(CPString)editingString;
|
||||
|
||||
@end
|
||||
|
||||
var CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_ = 1 << 1,
|
||||
CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_ = 1 << 2,
|
||||
CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_ = 1 << 3,
|
||||
CPTokenFieldDelegate_tokenField_menuForRepresentedObject_ = 1 << 4,
|
||||
CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_ = 1 << 5,
|
||||
CPTokenFieldDelegate_tokenField_representedObjectForEditingString_ = 1 << 6;
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
@@ -62,23 +86,26 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
|
||||
@implementation CPTokenField : CPTextField
|
||||
{
|
||||
CPScrollView _tokenScrollView;
|
||||
int _shouldScrollTo;
|
||||
CPScrollView _tokenScrollView;
|
||||
int _shouldScrollTo;
|
||||
|
||||
CPRange _selectedRange;
|
||||
CPRange _selectedRange;
|
||||
|
||||
_CPAutocompleteMenu _autocompleteMenu;
|
||||
CGRect _inputFrame;
|
||||
_CPAutocompleteMenu _autocompleteMenu;
|
||||
CGRect _inputFrame;
|
||||
|
||||
CPTimeInterval _completionDelay;
|
||||
CPTimeInterval _completionDelay;
|
||||
|
||||
CPCharacterSet _tokenizingCharacterSet @accessors(property=tokenizingCharacterSet);
|
||||
CPCharacterSet _tokenizingCharacterSet @accessors(property=tokenizingCharacterSet);
|
||||
|
||||
CPEvent _mouseDownEvent;
|
||||
CPEvent _mouseDownEvent;
|
||||
|
||||
BOOL _shouldNotifyTarget;
|
||||
BOOL _shouldNotifyTarget;
|
||||
|
||||
int _buttonType @accessors(property=buttonType);
|
||||
int _buttonType @accessors(property=buttonType);
|
||||
|
||||
id <CPTokenFieldDelegate> _tokenFieldDelegate;
|
||||
unsigned _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
+ (CPCharacterSet)defaultTokenizingCharacterSet
|
||||
@@ -96,7 +123,7 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
return "tokenfield";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{ @"editor-inset": CGInsetMakeZero() };
|
||||
}
|
||||
@@ -138,6 +165,41 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
[self addSubview:_tokenScrollView];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate methods
|
||||
|
||||
/*!
|
||||
Set the delegate of the receiver
|
||||
*/
|
||||
- (void)setDelegate:(id <CPTokenFieldDelegate>)aDelegate
|
||||
{
|
||||
if (_tokenFieldDelegate === aDelegate)
|
||||
return;
|
||||
|
||||
_tokenFieldDelegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:hasMenuForRepresentedObject:)])
|
||||
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_;
|
||||
|
||||
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:)])
|
||||
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_;
|
||||
|
||||
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:shouldAddObjects:atIndex:)])
|
||||
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_;
|
||||
|
||||
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:menuForRepresentedObject:)])
|
||||
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_menuForRepresentedObject_;
|
||||
|
||||
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:displayStringForRepresentedObject:)])
|
||||
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_;
|
||||
|
||||
if ([_tokenFieldDelegate respondsToSelector:@selector(tokenField:representedObjectForEditingString:)])
|
||||
_implementedDelegateMethods |= CPTokenFieldDelegate_tokenField_representedObjectForEditingString_;
|
||||
|
||||
[super setDelegate:_tokenFieldDelegate];
|
||||
}
|
||||
|
||||
- (_CPAutocompleteMenu)_autocompleteMenu
|
||||
{
|
||||
if (!_autocompleteMenu)
|
||||
@@ -392,6 +454,8 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
element.focus();
|
||||
CPTokenFieldInputOwner = self;
|
||||
}, 0.0);
|
||||
|
||||
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
|
||||
}, 0.0);
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
@@ -424,12 +488,14 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
if (_shouldNotifyTarget)
|
||||
{
|
||||
_shouldNotifyTarget = NO;
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:@{"CPTextMovement": [self _currentTextMovement]}]];
|
||||
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
[self textDidBlur:[CPNotification notificationWithName:CPTextFieldDidBlurNotification object:self userInfo:nil]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -639,7 +705,7 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
[[self _tokens] makeObjectsPerformSelector:@selector(setEditable:) withObject:shouldBeEditable];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)anObject
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)anObject
|
||||
{
|
||||
_shouldNotifyTarget = NO;
|
||||
[super sendAction:anAction to:anObject];
|
||||
@@ -647,7 +713,7 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
|
||||
// Incredible hack to disable supers implementation
|
||||
// so it cannot change our object value and break the tokenfield
|
||||
- (void)_setStringValue:(id)aValue
|
||||
- (BOOL)_setStringValue:(CPString)aValue
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1179,12 +1245,10 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
*/
|
||||
- (CPArray)_completionsForSubstring:(CPString)substring indexOfToken:(int)tokenIndex indexOfSelectedItem:(int)selectedIndex
|
||||
{
|
||||
if ([[self delegate] respondsToSelector:@selector(tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem:)])
|
||||
{
|
||||
return [[self delegate] tokenField:self completionsForSubstring:substring indexOfToken:tokenIndex indexOfSelectedItem:selectedIndex];
|
||||
}
|
||||
if (!(_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_completionsForSubstring_indexOfToken_indexOfSelectedItem_))
|
||||
return [];
|
||||
|
||||
return [];
|
||||
return [_tokenFieldDelegate tokenField:self completionsForSubstring:substring indexOfToken:tokenIndex indexOfSelectedItem:selectedIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1193,6 +1257,7 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
- (CGPoint)_completionOrigin:(_CPAutocompleteMenu)anAutocompleteMenu
|
||||
{
|
||||
var relativeFrame = _inputFrame ? [[_tokenScrollView documentView] convertRect:_inputFrame toView:self ] : [self bounds];
|
||||
|
||||
return CGPointMake(CGRectGetMinX(relativeFrame), CGRectGetMaxY(relativeFrame));
|
||||
}
|
||||
|
||||
@@ -1206,13 +1271,12 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
*/
|
||||
- (CPString)_displayStringForRepresentedObject:(id)representedObject
|
||||
{
|
||||
if ([[self delegate] respondsToSelector:@selector(tokenField:displayStringForRepresentedObject:)])
|
||||
if (_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_displayStringForRepresentedObject_)
|
||||
{
|
||||
var stringForRepresentedObject = [[self delegate] tokenField:self displayStringForRepresentedObject:representedObject];
|
||||
var stringForRepresentedObject = [_tokenFieldDelegate tokenField:self displayStringForRepresentedObject:representedObject];
|
||||
|
||||
if (stringForRepresentedObject !== nil)
|
||||
{
|
||||
return stringForRepresentedObject;
|
||||
}
|
||||
}
|
||||
|
||||
return representedObject;
|
||||
@@ -1229,10 +1293,10 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
*/
|
||||
- (CPArray)_shouldAddObjects:(CPArray)tokens atIndex:(int)index
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tokenField:shouldAddObjects:atIndex:)])
|
||||
if (_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_shouldAddObjects_atIndex_)
|
||||
{
|
||||
var approvedObjects = [delegate tokenField:self shouldAddObjects:tokens atIndex:index];
|
||||
var approvedObjects = [_tokenFieldDelegate tokenField:self shouldAddObjects:tokens atIndex:index];
|
||||
|
||||
if (approvedObjects !== nil)
|
||||
return approvedObjects;
|
||||
}
|
||||
@@ -1251,10 +1315,10 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
*/
|
||||
- (id)_representedObjectForEditingString:(CPString)aString
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tokenField:representedObjectForEditingString:)])
|
||||
if (_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_representedObjectForEditingString_)
|
||||
{
|
||||
var token = [delegate tokenField:self representedObjectForEditingString:aString];
|
||||
var token = [_tokenFieldDelegate tokenField:self representedObjectForEditingString:aString];
|
||||
|
||||
if (token !== nil && token !== undefined)
|
||||
return token;
|
||||
// If nil was returned, assume the string is the represented object. The alternative would have been
|
||||
@@ -1266,23 +1330,22 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
|
||||
- (BOOL)_hasMenuForRepresentedObject:(id)aRepresentedObject
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tokenField:hasMenuForRepresentedObject:)] &&
|
||||
[delegate respondsToSelector:@selector(tokenField:menuForRepresentedObject:)])
|
||||
return [delegate tokenField:self hasMenuForRepresentedObject:aRepresentedObject];
|
||||
if ((_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_) &&
|
||||
(_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_menuForRepresentedObject_))
|
||||
return [_tokenFieldDelegate tokenField:self hasMenuForRepresentedObject:aRepresentedObject];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CPMenu)_menuForRepresentedObject:(id)aRepresentedObject
|
||||
{
|
||||
var delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tokenField:hasMenuForRepresentedObject:)] &&
|
||||
[delegate respondsToSelector:@selector(tokenField:menuForRepresentedObject:)])
|
||||
if ((_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_hasMenuForRepresentedObject_) &&
|
||||
(_implementedDelegateMethods & CPTokenFieldDelegate_tokenField_menuForRepresentedObject_))
|
||||
{
|
||||
var hasMenu = [delegate tokenField:self hasMenuForRepresentedObject:aRepresentedObject];
|
||||
var hasMenu = [_tokenFieldDelegate tokenField:self hasMenuForRepresentedObject:aRepresentedObject];
|
||||
|
||||
if (hasMenu)
|
||||
return [delegate tokenField:self menuForRepresentedObject:aRepresentedObject] || nil;
|
||||
return [_tokenFieldDelegate tokenField:self menuForRepresentedObject:aRepresentedObject] || nil;
|
||||
}
|
||||
|
||||
return nil;
|
||||
@@ -1383,12 +1446,15 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (BOOL)setThemeState:(CPThemeState)aState
|
||||
- (BOOL)setThemeState:(ThemeState)aState
|
||||
{
|
||||
if (aState.isa && [aState isKindOfClass:CPArray])
|
||||
aState = CPThemeState.apply(null, aState);
|
||||
|
||||
var r = [super setThemeState:aState];
|
||||
|
||||
// Share hover state with the disclosure and delete buttons.
|
||||
if (aState & CPThemeStateHovered)
|
||||
if (aState.hasThemeState(CPThemeStateHovered))
|
||||
{
|
||||
[_disclosureButton setThemeState:CPThemeStateHovered];
|
||||
[_deleteButton setThemeState:CPThemeStateHovered];
|
||||
@@ -1397,12 +1463,15 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
- (BOOL)unsetThemeState:(CPThemeState)aState
|
||||
- (BOOL)unsetThemeState:(ThemeState)aState
|
||||
{
|
||||
if (aState.isa && [aState isKindOfClass:CPArray])
|
||||
aState = CPThemeState.apply(null, aState);
|
||||
|
||||
var r = [super unsetThemeState:aState];
|
||||
|
||||
// Share hover state with the disclosure and delete button.
|
||||
if (aState & CPThemeStateHovered)
|
||||
if (aState.hasThemeState(CPThemeStateHovered))
|
||||
{
|
||||
[_disclosureButton unsetThemeState:CPThemeStateHovered];
|
||||
[_deleteButton unsetThemeState:CPThemeStateHovered];
|
||||
@@ -1535,7 +1604,7 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
{
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
var attributes = [CPButton themeAttributes];
|
||||
|
||||
@@ -1565,7 +1634,7 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
{
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
var attributes = [CPButton themeAttributes];
|
||||
|
||||
|
||||
+140
-20
@@ -30,6 +30,13 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
var CPToolbarDelegate_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_ = 1 << 0,
|
||||
CPToolbarDelegate_toolbarAllowedItemIdentifiers_ = 1 << 1,
|
||||
CPToolbarDelegate_toolbarDefaultItemIdentifiers_ = 1 << 2,
|
||||
CPToolbarDelegate_toolbarDidRemoveItem_ = 1 << 3,
|
||||
CPToolbarDelegate_toolbarSelectableItemIdentifiers_ = 1 << 4,
|
||||
CPToolbarDelegate_toolbarWillAddItem_ = 1 << 5;
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPToolbarDisplayMode
|
||||
@@ -59,6 +66,20 @@ CPToolbarSizeModeSmall = 2;
|
||||
var CPToolbarsByIdentifier = nil,
|
||||
CPToolbarConfigurationsByIdentifier = nil;
|
||||
|
||||
|
||||
@protocol CPToolbarDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag;
|
||||
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)toolbar;
|
||||
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar;
|
||||
- (void)toolbarDidRemoveItem:(CPNotification)notification;
|
||||
- (CPArray)toolbarSelectableItemIdentifiers:(CPToolbar)toolbar;
|
||||
- (void)toolbarWillAddItem:(CPNotification)notification;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPToolbar
|
||||
@@ -89,14 +110,15 @@ var CPToolbarsByIdentifier = nil,
|
||||
@implementation CPToolbar : CPObject
|
||||
{
|
||||
CPString _identifier;
|
||||
CPToolbarDisplayMode _displayMode @accessors(property=displayMode);
|
||||
CPToolbarDisplayMode _displayMode @accessors(property=displayMode);
|
||||
BOOL _showsBaselineSeparator;
|
||||
BOOL _allowsUserCustomization;
|
||||
BOOL _isVisible;
|
||||
int _sizeMode @accessors(property=sizeMode);
|
||||
CPToolbarSizeMode _sizeMode @accessors(property=sizeMode);
|
||||
int _desiredHeight;
|
||||
|
||||
id _delegate;
|
||||
id <CPToolbarDelegate> _delegate;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
CPArray _itemIdentifiers;
|
||||
|
||||
@@ -165,15 +187,6 @@ var CPToolbarsByIdentifier = nil,
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Sets the toolbar's display mode. NOT YET IMPLEMENTED.
|
||||
*/
|
||||
- (void)setDisplayMode:(CPToolbarDisplayMode)aDisplayMode
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the toolbar's identifier
|
||||
*/
|
||||
@@ -248,6 +261,25 @@ var CPToolbarsByIdentifier = nil,
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:)])
|
||||
_implementedDelegateMethods |= CPToolbarDelegate_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbarAllowedItemIdentifiers:)])
|
||||
_implementedDelegateMethods |= CPToolbarDelegate_toolbarAllowedItemIdentifiers_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
|
||||
_implementedDelegateMethods |= CPToolbarDelegate_toolbarDefaultItemIdentifiers_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbarDidRemoveItem:)])
|
||||
_implementedDelegateMethods |= CPToolbarDelegate_toolbarDidRemoveItem_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbarSelectableItemIdentifiers:)])
|
||||
_implementedDelegateMethods |= CPToolbarDelegate_toolbarSelectableItemIdentifiers_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbarWillAddItem:)])
|
||||
_implementedDelegateMethods |= CPToolbarDelegate_toolbarWillAddItem_;
|
||||
|
||||
[self _reloadToolbarItems];
|
||||
}
|
||||
@@ -298,9 +330,9 @@ var CPToolbarsByIdentifier = nil,
|
||||
// _defaultItems may have been loaded from Cib
|
||||
_itemIdentifiers = [_defaultItems valueForKey:@"itemIdentifier"] || [];
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
|
||||
if ([self _delegateRespondsToToolbarDefaultItemIdentifiers])
|
||||
{
|
||||
var itemIdentifiersFromDelegate = [_delegate toolbarDefaultItemIdentifiers:self];
|
||||
var itemIdentifiersFromDelegate = [self _sendDelegateToolbarDefaultItemIdentifiers];
|
||||
|
||||
// If we get items both from the Cib and from the delegate method, put the delegate items before the
|
||||
// Cib ones.
|
||||
@@ -325,7 +357,7 @@ var CPToolbarsByIdentifier = nil,
|
||||
item = [_identifiedItems objectForKey:identifier];
|
||||
|
||||
if (!item && _delegate)
|
||||
item = [_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES];
|
||||
item = [self _sendDelegateItemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES];
|
||||
|
||||
item = [item copy];
|
||||
|
||||
@@ -403,12 +435,14 @@ var CPToolbarsByIdentifier = nil,
|
||||
- (id)_itemForItemIdentifier:(CPString)identifier willBeInsertedIntoToolbar:(BOOL)toolbar
|
||||
{
|
||||
var item = [_identifiedItems objectForKey:identifier];
|
||||
|
||||
if (!item)
|
||||
{
|
||||
item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
|
||||
|
||||
if (_delegate && !item)
|
||||
{
|
||||
item = [[_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:toolbar] copy];
|
||||
item = [[self _sendDelegateItemForItemIdentifier:identifier willBeInsertedIntoToolbar:toolbar] copy];
|
||||
if (!item)
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:@"Toolbar delegate " + _delegate + " returned nil toolbar item for identifier " + identifier];
|
||||
@@ -433,11 +467,11 @@ var CPToolbarsByIdentifier = nil,
|
||||
/* @ignore */
|
||||
- (id)_defaultToolbarItems
|
||||
{
|
||||
if (!_defaultItems && [_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
|
||||
if (!_defaultItems && [self _delegateRespondsToToolbarDefaultItemIdentifiers])
|
||||
{
|
||||
_defaultItems = [];
|
||||
|
||||
var identifiers = [_delegate toolbarDefaultItemIdentifiers:self],
|
||||
var identifiers = [self _sendDelegateToolbarDefaultItemIdentifiers],
|
||||
index = 0,
|
||||
count = [identifiers count];
|
||||
|
||||
@@ -603,7 +637,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
return @"toolbar-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"item-margin": 10.0,
|
||||
@@ -1225,7 +1259,7 @@ var LABEL_MARGIN = 2.0;
|
||||
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)aSender
|
||||
- (BOOL)sendAction:(SEL)anAction to:(id)aSender
|
||||
{
|
||||
[CPApp sendAction:anAction to:aSender from:_toolbarItem];
|
||||
}
|
||||
@@ -1249,3 +1283,89 @@ var LABEL_MARGIN = 2.0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPToolbar (CPToolbarDelegate)
|
||||
|
||||
/*
|
||||
@ignore
|
||||
Return YES if the delegate implements toolbarDefaultItemIdentifiers:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToToolbarDefaultItemIdentifiers
|
||||
{
|
||||
return _implementedDelegateMethods & CPToolbarDelegate_toolbarDefaultItemIdentifiers_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:
|
||||
*/
|
||||
- (CPToolbarItem)_sendDelegateItemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPToolbarDelegate_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_))
|
||||
return nil;
|
||||
|
||||
return [_delegate toolbar:self itemForItemIdentifier:itemIdentifier willBeInsertedIntoToolbar:flag];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate toolbarAllowedItemIdentifiers:
|
||||
*/
|
||||
- (CPArray)_sendDelegateToolbarAllowedItemIdentifiers
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPToolbarDelegate_toolbarAllowedItemIdentifiers_))
|
||||
return [];
|
||||
|
||||
return [_delegate toolbarAllowedItemIdentifiers:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate toolbarDefaultItemIdentifiers:
|
||||
*/
|
||||
- (CPArray)_sendDelegateToolbarDefaultItemIdentifiers
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPToolbarDelegate_toolbarDefaultItemIdentifiers_))
|
||||
return [];
|
||||
|
||||
return [_delegate toolbarDefaultItemIdentifiers:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate toolbarDidRemoveItem:
|
||||
*/
|
||||
- (void)_sendDelegateToolbarDidRemoveItem:(CPNotification)notification
|
||||
{
|
||||
if (!(_delegate & CPToolbarDelegate_toolbarDidRemoveItem_))
|
||||
return;
|
||||
|
||||
[_delegate toolbarDidRemoveItem:notification];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate toolbarSelectableItemIdentifiers:
|
||||
*/
|
||||
- (CPArray)_sendDelegateToolbarSelectableItemIdentifiers
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPToolbarDelegate_toolbarSelectableItemIdentifiers_))
|
||||
return [];
|
||||
|
||||
return [_delegate toolbarSelectableItemIdentifiers:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call the delegate toolbarWillAddItem:
|
||||
*/
|
||||
- (void)_sendDelegateToolbarWillAddItem:(CPNotification)notification
|
||||
{
|
||||
if (!(_delegate & CPToolbarDelegate_toolbarWillAddItem_))
|
||||
return;
|
||||
|
||||
[_delegate toolbarWillAddItem:notification];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+341
-68
@@ -43,6 +43,26 @@
|
||||
|
||||
@global appkit_tag_dom_elements
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
if (typeof(appkit_tag_dom_elements) !== "undefined" && appkit_tag_dom_elements)
|
||||
{
|
||||
AppKitTagDOMElement = function(owner, element)
|
||||
{
|
||||
element.setAttribute("data-cappuccino-view", [owner className]);
|
||||
element.setAttribute("data-cappuccino-uid", [owner UID]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AppKitTagDOMElement = function(owner, element)
|
||||
{
|
||||
// By default, do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@global
|
||||
@group CPViewAutoresizingMasks
|
||||
@@ -179,6 +199,11 @@ var CPViewFlags = { },
|
||||
|
||||
_CPViewFullScreenModeState _fullScreenModeState;
|
||||
|
||||
// Zoom Support
|
||||
BOOL _isScaled;
|
||||
CGSize _hierarchyScaleSize;
|
||||
CGSize _scaleSize;
|
||||
|
||||
// Layout Support
|
||||
BOOL _needsLayout;
|
||||
JSObject _ephemeralSubviews;
|
||||
@@ -314,15 +339,17 @@ var CPViewFlags = { },
|
||||
_isHidden = NO;
|
||||
_hitTests = YES;
|
||||
|
||||
_hierarchyScaleSize = CGSizeMake(1.0 , 1.0);
|
||||
_scaleSize = CGSizeMake(1.0, 1.0);
|
||||
_isScaled = NO;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement = DOMElementPrototype.cloneNode(false);
|
||||
AppKitTagDOMElement(self, _DOMElement);
|
||||
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, CGRectGetMinX(aFrame), CGRectGetMinY(aFrame));
|
||||
CPDOMDisplayServerSetStyleSize(_DOMElement, width, height);
|
||||
|
||||
if (typeof(appkit_tag_dom_elements) !== "undefined" && !!appkit_tag_dom_elements)
|
||||
_DOMElement.setAttribute("data-cappuccino-view", [self className]);
|
||||
|
||||
_DOMImageParts = [];
|
||||
_DOMImageSizes = [];
|
||||
#endif
|
||||
@@ -373,9 +400,9 @@ var CPViewFlags = { },
|
||||
#if PLATFORM(DOM)
|
||||
if (_DOMElement.addEventListener)
|
||||
{
|
||||
_DOMElement.addEventListener("mouseover", _toolTipFunctionIn, NO);
|
||||
_DOMElement.addEventListener("keypress", _toolTipFunctionOut, NO);
|
||||
_DOMElement.addEventListener("mouseout", _toolTipFunctionOut, NO);
|
||||
_DOMElement.addEventListener("mouseover", _toolTipFunctionIn, YES);
|
||||
_DOMElement.addEventListener("keypress", _toolTipFunctionOut, YES);
|
||||
_DOMElement.addEventListener("mouseout", _toolTipFunctionOut, YES);
|
||||
}
|
||||
else if (_DOMElement.attachEvent)
|
||||
{
|
||||
@@ -400,9 +427,9 @@ var CPViewFlags = { },
|
||||
#if PLATFORM(DOM)
|
||||
if (_DOMElement.removeEventListener)
|
||||
{
|
||||
_DOMElement.removeEventListener("mouseover", _toolTipFunctionIn, NO);
|
||||
_DOMElement.removeEventListener("keypress", _toolTipFunctionOut, NO);
|
||||
_DOMElement.removeEventListener("mouseout", _toolTipFunctionOut, NO);
|
||||
_DOMElement.removeEventListener("mouseover", _toolTipFunctionIn, YES);
|
||||
_DOMElement.removeEventListener("keypress", _toolTipFunctionOut, YES);
|
||||
_DOMElement.removeEventListener("mouseout", _toolTipFunctionOut, YES);
|
||||
}
|
||||
else if (_DOMElement.detachEvent)
|
||||
{
|
||||
@@ -543,6 +570,13 @@ var CPViewFlags = { },
|
||||
}
|
||||
|
||||
[aSubview setNextResponder:self];
|
||||
[aSubview _scaleSizeUnitSquareToSize:[self _hierarchyScaleSize]];
|
||||
|
||||
// If the subview is not hidden and one of its ancestors is hidden,
|
||||
// notify the subview that it is now hidden.
|
||||
if (![aSubview isHidden] && [self isHiddenOrHasHiddenAncestor])
|
||||
[aSubview _notifyViewDidHide];
|
||||
|
||||
[aSubview viewDidMoveToSuperview];
|
||||
|
||||
[self didAddSubview:aSubview];
|
||||
@@ -575,6 +609,12 @@ var CPViewFlags = { },
|
||||
#if PLATFORM(DOM)
|
||||
CPDOMDisplayServerRemoveChild(_superview._DOMElement, _DOMElement);
|
||||
#endif
|
||||
|
||||
// If the view is not hidden and one of its ancestors is hidden,
|
||||
// notify the view that it is now unhidden.
|
||||
if (!_isHidden && [_superview isHiddenOrHasHiddenAncestor])
|
||||
[self _notifyViewDidUnhide];
|
||||
|
||||
_superview = nil;
|
||||
|
||||
[self _setWindow:nil];
|
||||
@@ -930,8 +970,8 @@ var CPViewFlags = { },
|
||||
|
||||
if (YES)
|
||||
{
|
||||
_bounds.size.width = aSize.width;
|
||||
_bounds.size.height = aSize.height;
|
||||
_bounds.size.width = aSize.width * 1 / _scaleSize.width;
|
||||
_bounds.size.height = aSize.height * 1 / _scaleSize.height;
|
||||
}
|
||||
|
||||
if (_layer)
|
||||
@@ -944,7 +984,7 @@ var CPViewFlags = { },
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
CPDOMDisplayServerSetStyleSize(_DOMElement, size.width, size.height);
|
||||
[self _setDisplayServerSetStyleSize:size];
|
||||
|
||||
if (_DOMContentsElement)
|
||||
{
|
||||
@@ -1053,6 +1093,19 @@ var CPViewFlags = { },
|
||||
[CachedNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
This method is used to set the width and height of the _DOMElement. It cares about the scale of the view.
|
||||
When scaling, for instance with a size (0.5, 0.5), the bounds of the view will be multiply by 2. It's why we multiply by the inverse of the scaling.
|
||||
The view will finally keep the same proportion for the user on the screen.
|
||||
*/
|
||||
- (void)_setDisplayServerSetStyleSize:(CGSize)aSize
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var scale = [self scaleSize];
|
||||
CPDOMDisplayServerSetStyleSize(_DOMElement, aSize.width * 1 / scale.width, aSize.height * 1 / scale.height);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the receiver's bounds. The bounds define the size and location of the receiver inside it's frame. Posts a
|
||||
CPViewBoundsDidChangeNotification to the default notification center if the receiver is configured to do so.
|
||||
@@ -1353,6 +1406,7 @@ var CPViewFlags = { },
|
||||
// FIXME: Should we return to visibility? This breaks in FireFox, Opera, and IE.
|
||||
// _DOMElement.style.visibility = (_isHidden = aFlag) ? "hidden" : "visible";
|
||||
_isHidden = aFlag;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement.style.display = _isHidden ? "none" : "block";
|
||||
#endif
|
||||
@@ -1388,6 +1442,7 @@ var CPViewFlags = { },
|
||||
[self viewDidHide];
|
||||
|
||||
var count = [_subviews count];
|
||||
|
||||
while (count--)
|
||||
[_subviews[count] _notifyViewDidHide];
|
||||
}
|
||||
@@ -1397,6 +1452,7 @@ var CPViewFlags = { },
|
||||
[self viewDidUnhide];
|
||||
|
||||
var count = [_subviews count];
|
||||
|
||||
while (count--)
|
||||
[_subviews[count] _notifyViewDidUnhide];
|
||||
}
|
||||
@@ -1547,15 +1603,42 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CPView)hitTest:(CGPoint)aPoint
|
||||
{
|
||||
if (_isHidden || !_hitTests || !CGRectContainsPoint(_frame, aPoint))
|
||||
if (_isHidden || !_hitTests)
|
||||
return nil;
|
||||
|
||||
var frame = _frame,
|
||||
sizeScale = [self _hierarchyScaleSize];
|
||||
|
||||
if (_isScaled)
|
||||
frame = CGRectApplyAffineTransform(_frame, CGAffineTransformMakeScale([_superview _hierarchyScaleSize].width, [_superview _hierarchyScaleSize].height));
|
||||
else
|
||||
frame = CGRectApplyAffineTransform(_frame, CGAffineTransformMakeScale(sizeScale.width, sizeScale.height));
|
||||
|
||||
if (!CGRectContainsPoint(frame, aPoint))
|
||||
return nil;
|
||||
|
||||
var view = nil,
|
||||
i = _subviews.length,
|
||||
adjustedPoint = CGPointMake(aPoint.x - CGRectGetMinX(_frame), aPoint.y - CGRectGetMinY(_frame));
|
||||
adjustedPoint = CGPointMake(aPoint.x - CGRectGetMinX(frame), aPoint.y - CGRectGetMinY(frame));
|
||||
|
||||
if (_inverseBoundsTransform)
|
||||
adjustedPoint = CGPointApplyAffineTransform(adjustedPoint, _inverseBoundsTransform);
|
||||
{
|
||||
var affineTransform = CGAffineTransformMakeCopy(_inverseBoundsTransform);
|
||||
|
||||
if (_isScaled)
|
||||
{
|
||||
affineTransform.tx *= [_superview _hierarchyScaleSize].width;
|
||||
affineTransform.ty *= [_superview _hierarchyScaleSize].height;
|
||||
}
|
||||
else
|
||||
{
|
||||
affineTransform.tx *= sizeScale.width;
|
||||
affineTransform.ty *= sizeScale.height;
|
||||
}
|
||||
|
||||
adjustedPoint = CGPointApplyAffineTransform(adjustedPoint, affineTransform);
|
||||
}
|
||||
|
||||
|
||||
while (i--)
|
||||
if (view = [_subviews[i] hitTest:adjustedPoint])
|
||||
@@ -1876,6 +1959,9 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGPoint)convertPoint:(CGPoint)aPoint fromView:(CPView)aView
|
||||
{
|
||||
if (aView === self)
|
||||
return aPoint;
|
||||
|
||||
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(aView, self));
|
||||
}
|
||||
|
||||
@@ -1886,7 +1972,7 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGPoint)convertPointFromBase:(CGPoint)aPoint
|
||||
{
|
||||
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(nil, self));
|
||||
return [self convertPoint:aPoint fromView:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1897,9 +1983,13 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGPoint)convertPoint:(CGPoint)aPoint toView:(CPView)aView
|
||||
{
|
||||
if (aView === self)
|
||||
return aPoint;
|
||||
|
||||
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(self, aView));
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Converts the point from the receiver’s coordinate system to the base coordinate system.
|
||||
@param aPoint A point specifying a location in the coordinate system of the receiver
|
||||
@@ -1907,7 +1997,7 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGPoint)convertPointToBase:(CGPoint)aPoint
|
||||
{
|
||||
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(self, nil));
|
||||
return [self convertPoint:aPoint toView:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1918,6 +2008,9 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGSize)convertSize:(CGSize)aSize fromView:(CPView)aView
|
||||
{
|
||||
if (aView === self)
|
||||
return aSize;
|
||||
|
||||
return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(aView, self));
|
||||
}
|
||||
|
||||
@@ -1929,6 +2022,9 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGSize)convertSize:(CGSize)aSize toView:(CPView)aView
|
||||
{
|
||||
if (aView === self)
|
||||
return aSize;
|
||||
|
||||
return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(self, aView));
|
||||
}
|
||||
|
||||
@@ -1940,6 +2036,9 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGRect)convertRect:(CGRect)aRect fromView:(CPView)aView
|
||||
{
|
||||
if (self === aView)
|
||||
return aRect;
|
||||
|
||||
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(aView, self));
|
||||
}
|
||||
|
||||
@@ -1950,7 +2049,7 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGRect)convertRectFromBase:(CGRect)aRect
|
||||
{
|
||||
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(nil, self));
|
||||
return [self convertRect:aRect fromView:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1961,6 +2060,9 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGRect)convertRect:(CGRect)aRect toView:(CPView)aView
|
||||
{
|
||||
if (self === aView)
|
||||
return aRect;
|
||||
|
||||
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(self, aView));
|
||||
}
|
||||
|
||||
@@ -1971,7 +2073,7 @@ var CPViewFlags = { },
|
||||
*/
|
||||
- (CGRect)convertRectToBase:(CGRect)aRect
|
||||
{
|
||||
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(self, nil));
|
||||
return [self convertRect:aRect toView:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -2116,6 +2218,88 @@ setBoundsOrigin:
|
||||
|
||||
}
|
||||
|
||||
// Scaling
|
||||
|
||||
/*!
|
||||
Scales the receiver’s coordinate system so that the unit square scales to the specified dimensions.
|
||||
The bounds of the receiver will change, for instance if the given size is (0.5, 0.5) the width and height of the bounds will be multiply by 2.
|
||||
You must call setNeedsDisplay: to redraw the view.
|
||||
@param aSize, the size corresponding the new unit scales
|
||||
*/
|
||||
- (void)scaleUnitSquareToSize:(CGSize)aSize
|
||||
{
|
||||
if (!aSize)
|
||||
return;
|
||||
|
||||
// Reset the bounds
|
||||
var bounds = CGRectMakeCopy([self bounds]);
|
||||
bounds.size.width *= _scaleSize.width;
|
||||
bounds.size.height *= _scaleSize.height;
|
||||
|
||||
[self willChangeValueForKey:@"scaleSize"];
|
||||
_scaleSize = CGSizeMakeCopy([self scaleSize]);
|
||||
_scaleSize.height *= aSize.height;
|
||||
_scaleSize.width *= aSize.width;
|
||||
[self didChangeValueForKey:@"scaleSize"];
|
||||
_isScaled = YES;
|
||||
|
||||
_hierarchyScaleSize = CGSizeMakeCopy([self _hierarchyScaleSize]);
|
||||
_hierarchyScaleSize.height *= aSize.height;
|
||||
_hierarchyScaleSize.width *= aSize.width;
|
||||
|
||||
var scaleAffine = CGAffineTransformMakeScale(1.0 / _scaleSize.width, 1.0 / _scaleSize.height),
|
||||
newBounds = CGRectApplyAffineTransform(CGRectMakeCopy(bounds), scaleAffine);
|
||||
|
||||
[self setBounds:newBounds];
|
||||
|
||||
[_subviews makeObjectsPerformSelector:@selector(_scaleSizeUnitSquareToSize:) withObject:aSize];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Set the _hierarchyScaleSize and call all of the subviews to set their _hierarchyScaleSize
|
||||
*/
|
||||
- (void)_scaleSizeUnitSquareToSize:(CGSize)aSize
|
||||
{
|
||||
_hierarchyScaleSize = CGSizeMakeCopy([_superview _hierarchyScaleSize]);
|
||||
|
||||
if (_isScaled)
|
||||
{
|
||||
_hierarchyScaleSize.width *= _scaleSize.width;
|
||||
_hierarchyScaleSize.height *= _scaleSize.height;
|
||||
}
|
||||
|
||||
[_subviews makeObjectsPerformSelector:@selector(_scaleSizeUnitSquareToSize:) withObject:aSize];
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the _hierarchyScaleSize, this is a CGSize with the real zoom of the view (depending with his parents)
|
||||
*/
|
||||
- (CGSize)_hierarchyScaleSize
|
||||
{
|
||||
return _hierarchyScaleSize || CGSizeMake(1.0, 1.0);
|
||||
}
|
||||
|
||||
/*!
|
||||
Make a zoom in css
|
||||
*/
|
||||
- (void)_applyCSSScalingTranformations
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (_isScaled)
|
||||
{
|
||||
var scale = [self scaleSize],
|
||||
browserPropertyTransform = CPBrowserStyleProperty(@"transform"),
|
||||
browserPropertyTransformOrigin = CPBrowserStyleProperty(@"transformOrigin");
|
||||
|
||||
self._DOMElement.style[browserPropertyTransform] = 'scale(' + scale.width + ', ' + scale.height + ')';
|
||||
self._DOMElement.style[browserPropertyTransformOrigin] = '0 0';
|
||||
|
||||
[self _setDisplayServerSetStyleSize:[self frameSize]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Displaying
|
||||
|
||||
/*!
|
||||
@@ -2124,7 +2308,10 @@ setBoundsOrigin:
|
||||
- (void)setNeedsDisplay:(BOOL)aFlag
|
||||
{
|
||||
if (aFlag)
|
||||
{
|
||||
[self _applyCSSScalingTranformations];
|
||||
[self setNeedsDisplayInRect:[self bounds]];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -2217,6 +2404,9 @@ setBoundsOrigin:
|
||||
var graphicsPort = CGBitmapGraphicsContextCreate();
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var width = CGRectGetWidth(_frame),
|
||||
height = CGRectGetHeight(_frame);
|
||||
|
||||
_DOMContentsElement = graphicsPort.DOMElement;
|
||||
|
||||
_DOMContentsElement.style.zIndex = -100;
|
||||
@@ -2225,13 +2415,10 @@ setBoundsOrigin:
|
||||
_DOMContentsElement.style.position = "absolute";
|
||||
_DOMContentsElement.style.visibility = "visible";
|
||||
|
||||
_DOMContentsElement.width = ROUND(CGRectGetWidth(_frame));
|
||||
_DOMContentsElement.height = ROUND(CGRectGetHeight(_frame));
|
||||
CPDOMDisplayServerSetSize(_DOMContentsElement, width, height);
|
||||
|
||||
_DOMContentsElement.style.top = "0px";
|
||||
_DOMContentsElement.style.left = "0px";
|
||||
_DOMContentsElement.style.width = ROUND(CGRectGetWidth(_frame)) + "px";
|
||||
_DOMContentsElement.style.height = ROUND(CGRectGetHeight(_frame)) + "px";
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMContentsElement, NULL, 0.0, 0.0);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMContentsElement, width, height);
|
||||
|
||||
// The performance implications of this aren't clear, but without this subviews might not be redrawn when this
|
||||
// view moves.
|
||||
@@ -2521,14 +2708,18 @@ setBoundsOrigin:
|
||||
- (CPView)nextValidKeyView
|
||||
{
|
||||
var result = [self nextKeyView],
|
||||
firstResult = result;
|
||||
resultUID = [result UID],
|
||||
unsuitableResults = {};
|
||||
|
||||
while (result && ![result canBecomeKeyView])
|
||||
{
|
||||
unsuitableResults[resultUID] = 1;
|
||||
result = [result nextKeyView];
|
||||
|
||||
// Cycled.
|
||||
if (result === firstResult)
|
||||
resultUID = [result UID];
|
||||
|
||||
// Did we get back to a key view we already ruled out due to ![result canBecomeKeyView]?
|
||||
if (unsuitableResults[resultUID])
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -2654,6 +2845,40 @@ setBoundsOrigin:
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPView (Scaling)
|
||||
|
||||
/*!
|
||||
Set the zoom of the view. This will call scaleUnitSquareToSize: and setNeedsDisplay:
|
||||
This method doesn't care about the last zoom you set in the view
|
||||
@param aSize, the size corresponding the new unit scales
|
||||
*/
|
||||
- (void)setScaleSize:(CGSize)aSize
|
||||
{
|
||||
if (CGSizeEqualToSize(_scaleSize, aSize))
|
||||
return;
|
||||
|
||||
var size = CGSizeMakeZero(),
|
||||
scale = CGSizeMakeCopy([self scaleSize]);
|
||||
|
||||
size.height = aSize.height / scale.height;
|
||||
size.width = aSize.width / scale.width;
|
||||
|
||||
[self scaleUnitSquareToSize:size];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Return the scaleSize of the view, this scaleSize is used to scale in css
|
||||
*/
|
||||
- (CGSize)scaleSize
|
||||
{
|
||||
return _scaleSize || CGSizeMake(1.0, 1.0);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPView (Theming)
|
||||
#pragma mark Theme States
|
||||
|
||||
@@ -2662,23 +2887,23 @@ setBoundsOrigin:
|
||||
return _themeState;
|
||||
}
|
||||
|
||||
- (BOOL)hasThemeState:(CPThemeState)aState
|
||||
- (BOOL)hasThemeState:(ThemeState)aState
|
||||
{
|
||||
// Because CPThemeStateNormal is defined as 0 we need to check for it explicitly here
|
||||
if (aState === CPThemeStateNormal && _themeState === CPThemeStateNormal)
|
||||
return YES;
|
||||
if (aState.isa && [aState isKindOfClass:CPArray])
|
||||
return _themeState.hasThemeState.apply(_themeState, aState);
|
||||
|
||||
return !!(_themeState & ((typeof aState === "string") ? CPThemeState(aState) : aState));
|
||||
return _themeState.hasThemeState(aState);
|
||||
}
|
||||
|
||||
- (BOOL)setThemeState:(CPThemeState)aState
|
||||
- (BOOL)setThemeState:(ThemeState)aState
|
||||
{
|
||||
var newState = (typeof aState === "string") ? CPThemeState(aState) : aState;
|
||||
if (aState && aState.isa && [aState isKindOfClass:CPArray])
|
||||
aState = CPThemeState.apply(null, aState);
|
||||
|
||||
if (_themeState & newState)
|
||||
if (_themeState.hasThemeState(aState))
|
||||
return NO;
|
||||
|
||||
_themeState |= newState;
|
||||
_themeState = CPThemeState(_themeState, aState);
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -2686,15 +2911,17 @@ setBoundsOrigin:
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)unsetThemeState:(CPThemeState)aState
|
||||
- (BOOL)unsetThemeState:(ThemeState)aState
|
||||
{
|
||||
var newState = ((typeof aState === "string") ? CPThemeState(aState) : aState);
|
||||
if (aState && aState.isa && [aState isKindOfClass:CPArray])
|
||||
aState = CPThemeState.apply(null, aState);
|
||||
|
||||
if (!(_themeState & newState))
|
||||
var oldThemeState = _themeState
|
||||
_themeState = _themeState.without(aState);
|
||||
|
||||
if (oldThemeState === _themeState)
|
||||
return NO;
|
||||
|
||||
_themeState &= ~newState;
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
@@ -2852,8 +3079,11 @@ setBoundsOrigin:
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(CPThemeState)aState
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(ThemeState)aState
|
||||
{
|
||||
if (aState.isa && [aState isKindOfClass:CPArray])
|
||||
aState = CPThemeState.apply(null, aState);
|
||||
|
||||
if (!_themeAttributes || !_themeAttributes[aName])
|
||||
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
|
||||
|
||||
@@ -2884,8 +3114,11 @@ setBoundsOrigin:
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (id)valueForThemeAttribute:(CPString)aName inState:(CPThemeState)aState
|
||||
- (id)valueForThemeAttribute:(CPString)aName inState:(ThemeState)aState
|
||||
{
|
||||
if (aState.isa && [aState isKindOfClass:CPArray])
|
||||
aState = CPThemeState.apply(null, aState);
|
||||
|
||||
if (!_themeAttributes || !_themeAttributes[aName])
|
||||
[CPException raise:CPInvalidArgumentException reason:[self className] + " does not contain theme attribute '" + aName + "'"];
|
||||
|
||||
@@ -3032,7 +3265,10 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
CPViewWindowKey = @"CPViewWindowKey",
|
||||
CPViewNextKeyViewKey = @"CPViewNextKeyViewKey",
|
||||
CPViewPreviousKeyViewKey = @"CPViewPreviousKeyViewKey",
|
||||
CPReuseIdentifierKey = @"CPReuseIdentifierKey";
|
||||
CPReuseIdentifierKey = @"CPReuseIdentifierKey",
|
||||
CPViewScaleKey = @"CPViewScaleKey",
|
||||
CPViewSizeScaleKey = @"CPViewSizeScaleKey",
|
||||
CPViewIsScaledKey = @"CPViewIsScaledKey";
|
||||
|
||||
@implementation CPView (CPCoding)
|
||||
|
||||
@@ -3049,6 +3285,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
// a more "elegant" way to do this...?
|
||||
#if PLATFORM(DOM)
|
||||
_DOMElement = DOMElementPrototype.cloneNode(false);
|
||||
AppKitTagDOMElement(self, _DOMElement);
|
||||
#endif
|
||||
|
||||
// Also decode these "early".
|
||||
@@ -3098,13 +3335,17 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
if (_toolTip)
|
||||
[self _installToolTipEventHandlers];
|
||||
|
||||
_scaleSize = [aCoder containsValueForKey:CPViewScaleKey] ? [aCoder decodeSizeForKey:CPViewScaleKey] : CGSizeMake(1.0, 1.0);
|
||||
_hierarchyScaleSize = [aCoder containsValueForKey:CPViewSizeScaleKey] ? [aCoder decodeSizeForKey:CPViewSizeScaleKey] : CGSizeMake(1.0, 1.0);
|
||||
_isScaled = [aCoder containsValueForKey:CPViewIsScaledKey] ? [aCoder decodeBoolForKey:CPViewIsScaledKey] : NO;
|
||||
|
||||
// DOM SETUP
|
||||
#if PLATFORM(DOM)
|
||||
_DOMImageParts = [];
|
||||
_DOMImageSizes = [];
|
||||
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, CGRectGetMinX(_frame), CGRectGetMinY(_frame));
|
||||
CPDOMDisplayServerSetStyleSize(_DOMElement, CGRectGetWidth(_frame), CGRectGetHeight(_frame));
|
||||
[self _setDisplayServerSetStyleSize:_frame.size];
|
||||
|
||||
var index = 0,
|
||||
count = _subviews.length;
|
||||
@@ -3128,7 +3369,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
|
||||
_theme = [CPTheme defaultTheme];
|
||||
_themeClass = [aCoder decodeObjectForKey:CPViewThemeClassKey];
|
||||
_themeState = CPThemeState([aCoder decodeIntForKey:CPViewThemeStateKey]);
|
||||
_themeState = CPThemeState([aCoder decodeObjectForKey:CPViewThemeStateKey]);
|
||||
_themeAttributes = {};
|
||||
|
||||
var theClass = [self class],
|
||||
@@ -3219,7 +3460,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
[aCoder encodeConditionalObject:previousKeyView forKey:CPViewPreviousKeyViewKey];
|
||||
|
||||
[aCoder encodeObject:[self themeClass] forKey:CPViewThemeClassKey];
|
||||
[aCoder encodeInt:CPThemeStateName(_themeState) forKey:CPViewThemeStateKey];
|
||||
[aCoder encodeObject:String(_themeState) forKey:CPViewThemeStateKey];
|
||||
|
||||
for (var attributeName in _themeAttributes)
|
||||
if (_themeAttributes.hasOwnProperty(attributeName))
|
||||
@@ -3227,6 +3468,10 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
|
||||
if (_identifier)
|
||||
[aCoder encodeObject:_identifier forKey:CPReuseIdentifierKey];
|
||||
|
||||
[aCoder encodeSize:[self scaleSize] forKey:CPViewScaleKey];
|
||||
[aCoder encodeSize:[self _hierarchyScaleSize] forKey:CPViewSizeScaleKey];
|
||||
[aCoder encodeBool:_isScaled forKey:CPViewIsScaledKey];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -3256,12 +3501,26 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
{
|
||||
var frame = view._frame;
|
||||
|
||||
if (view._isScaled)
|
||||
{
|
||||
var affineZoom = CGAffineTransformMakeScale(view._scaleSize.width, view._scaleSize.height);
|
||||
CGAffineTransformConcatTo(transform, affineZoom, transform);
|
||||
}
|
||||
|
||||
transform.tx += CGRectGetMinX(frame);
|
||||
transform.ty += CGRectGetMinY(frame);
|
||||
|
||||
if (view._boundsTransform)
|
||||
{
|
||||
CGAffineTransformConcatTo(transform, view._boundsTransform, transform);
|
||||
var inverseBoundsTransform = CGAffineTransformMakeCopy(view._boundsTransform);
|
||||
|
||||
if (view._isScaled)
|
||||
{
|
||||
var affineZoom = CGAffineTransformMakeScale(view._scaleSize.width, view._scaleSize.height);
|
||||
CGAffineTransformConcatTo(inverseBoundsTransform, affineZoom, inverseBoundsTransform);
|
||||
}
|
||||
|
||||
CGAffineTransformConcatTo(transform, inverseBoundsTransform, transform);
|
||||
}
|
||||
|
||||
view = view._superview;
|
||||
@@ -3269,50 +3528,64 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
|
||||
// If we hit toView, then we're done.
|
||||
if (view === toView)
|
||||
{
|
||||
return transform;
|
||||
|
||||
}
|
||||
else if (fromView && toView)
|
||||
{
|
||||
fromWindow = [fromView window];
|
||||
toWindow = [toView window];
|
||||
|
||||
if (fromWindow && toWindow && fromWindow !== toWindow)
|
||||
{
|
||||
sameWindow = NO;
|
||||
|
||||
var frame = [fromWindow frame];
|
||||
|
||||
transform.tx += CGRectGetMinX(frame);
|
||||
transform.ty += CGRectGetMinY(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: For now we can do things this way, but eventually we need to do them the "hard" way.
|
||||
var view = toView;
|
||||
var view = toView,
|
||||
transform2 = CGAffineTransformMakeIdentity();
|
||||
|
||||
while (view)
|
||||
while (view && view != fromView)
|
||||
{
|
||||
var frame = view._frame;
|
||||
var frame = CGRectMakeCopy(view._frame);
|
||||
|
||||
transform.tx -= CGRectGetMinX(frame);
|
||||
transform.ty -= CGRectGetMinY(frame);
|
||||
// FIXME : For now we don't care about rotate transform and so on
|
||||
if (view._isScaled)
|
||||
{
|
||||
transform2.a *= 1 / view._scaleSize.width;
|
||||
transform2.d *= 1 / view._scaleSize.height;
|
||||
}
|
||||
|
||||
transform2.tx += CGRectGetMinX(frame) * transform2.a;
|
||||
transform2.ty += CGRectGetMinY(frame) * transform2.d;
|
||||
|
||||
if (view._boundsTransform)
|
||||
{
|
||||
CGAffineTransformConcatTo(transform, view._inverseBoundsTransform, transform);
|
||||
var inverseBoundsTransform = CGAffineTransformMakeIdentity();
|
||||
inverseBoundsTransform.tx -= view._inverseBoundsTransform.tx * transform2.a;
|
||||
inverseBoundsTransform.ty -= view._inverseBoundsTransform.ty * transform2.d;
|
||||
|
||||
CGAffineTransformConcatTo(transform2, inverseBoundsTransform, transform2);
|
||||
}
|
||||
|
||||
view = view._superview;
|
||||
}
|
||||
|
||||
if (!sameWindow)
|
||||
{
|
||||
var frame = [toWindow frame];
|
||||
transform2.tx = -transform2.tx;
|
||||
transform2.ty = -transform2.ty;
|
||||
|
||||
transform.tx -= CGRectGetMinX(frame);
|
||||
transform.ty -= CGRectGetMinY(frame);
|
||||
if (view === fromView)
|
||||
{
|
||||
// toView is inside of fromView
|
||||
return transform2;
|
||||
}
|
||||
|
||||
CGAffineTransformConcatTo(transform, transform2, transform);
|
||||
|
||||
return transform;
|
||||
|
||||
|
||||
|
||||
/* var views = [],
|
||||
view = toView;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ CPViewAnimationFadeOutEffect = @"CPViewAnimationFadeOutEffect";
|
||||
[super startAnimation];
|
||||
}
|
||||
|
||||
- (void)setCurrentProgress:(CPAnimationProgress)progress
|
||||
- (void)setCurrentProgress:(float)progress
|
||||
{
|
||||
[super setCurrentProgress:progress];
|
||||
|
||||
|
||||
+164
-27
@@ -53,6 +53,28 @@
|
||||
|
||||
@global CPApp
|
||||
|
||||
|
||||
@protocol CPWindowDelegate <CPObject>
|
||||
|
||||
@optional
|
||||
- (BOOL)windowShouldClose:(CPWindow)aWindow;
|
||||
- (CPUndoManager)windowWillReturnUndoManager:(CPWindow)window;
|
||||
- (void)windowDidBecomeKey:(CPNotification)aNotification;
|
||||
- (void)windowDidBecomeMain:(CPNotification)aNotification;
|
||||
- (void)windowDidEndSheet:(CPNotification)aNotification;
|
||||
- (void)windowDidMove:(CPNotification)aNotification;
|
||||
- (void)windowDidResignKey:(CPNotification)aNotification;
|
||||
- (void)windowDidResignMain:(CPNotification)aNotification;
|
||||
- (void)windowDidResize:(CPNotification)aNotification;
|
||||
- (void)windowWillBeginSheet:(CPNotification)aNotification;
|
||||
- (void)windowWillClose:(CPWindow)aWindow;
|
||||
|
||||
@end
|
||||
|
||||
var CPWindowDelegate_windowShouldClose_ = 1 << 1
|
||||
CPWindowDelegate_windowWillReturnUndoManager_ = 1 << 2,
|
||||
CPWindowDelegate_windowWillClose_ = 1 << 3;
|
||||
|
||||
var CPWindowSaveImage = nil,
|
||||
|
||||
CPWindowResizeTime = 0.2,
|
||||
@@ -171,7 +193,8 @@ var CPWindowActionMessageKeys = [
|
||||
CPResponder _firstResponder;
|
||||
CPResponder _initialFirstResponder;
|
||||
BOOL _hasBecomeKeyWindow;
|
||||
id _delegate;
|
||||
id <CPWindowDelegate> _delegate;
|
||||
unsigned _implementedDelegateMethods;
|
||||
|
||||
CPString _title;
|
||||
|
||||
@@ -205,8 +228,6 @@ var CPWindowActionMessageKeys = [
|
||||
|
||||
unsigned _autoresizingMask;
|
||||
|
||||
BOOL _delegateRespondsToWindowWillReturnUndoManagerSelector;
|
||||
|
||||
BOOL _isFullPlatformWindow;
|
||||
_CPWindowFullPlatformWindowSession _fullPlatformWindowSession;
|
||||
|
||||
@@ -248,7 +269,7 @@ CPTexturedBackgroundWindowMask
|
||||
@param aStyleMask a style mask
|
||||
@return the initialized window
|
||||
*/
|
||||
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask
|
||||
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
@@ -735,6 +756,10 @@ CPTexturedBackgroundWindowMask
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Constrain a frame so that the window remains at least partially visible on screen,
|
||||
moving or resizing the frame as necessary.
|
||||
*/
|
||||
- (CGRect)_constrainFrame:(CGRect)aFrame toUsableScreenWidth:(BOOL)constrainWidth andHeight:(BOOL)constrainHeight
|
||||
{
|
||||
var frame = CGRectMakeCopy(aFrame);
|
||||
@@ -759,7 +784,7 @@ CPTexturedBackgroundWindowMask
|
||||
if (CGRectGetWidth(frame) > usableWidth)
|
||||
{
|
||||
frame.origin.x = CGRectGetMinX(usableRect);
|
||||
frame.size.width = usableWidth;
|
||||
frame.size.width = MAX(usableWidth, _minSize.width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,13 +803,20 @@ CPTexturedBackgroundWindowMask
|
||||
if (CGRectGetHeight(frame) > usableHeight)
|
||||
{
|
||||
frame.origin.y = CGRectGetMinY(usableRect);
|
||||
frame.size.height = usableHeight;
|
||||
frame.size.height = MAX(usableHeight, _minSize.height);
|
||||
}
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
/*
|
||||
Constrain the origin of a frame such that:
|
||||
|
||||
- The window view's minimum resize width is kept onscreen at the left/right of the window.
|
||||
- The top of the window is kept below the top of the usable content.
|
||||
- The top of the contentView + CPWindowMinVisibleVerticalMargin is kept above the bottom of the usable content.
|
||||
*/
|
||||
- (CGRect)_constrainOriginOfFrame:(CGRect)aFrame
|
||||
{
|
||||
var frame = CGRectMakeCopy(aFrame);
|
||||
@@ -792,19 +824,20 @@ CPTexturedBackgroundWindowMask
|
||||
if (!_constrainsToUsableScreen || !_isVisible)
|
||||
return frame;
|
||||
|
||||
/*
|
||||
- CPWindowMinVisibleHorizontalMargin is kept onscreen at the left/right of the window.
|
||||
- The top of the window is kept below the top of the usable content.
|
||||
- The top of the contentView + CPWindowMinVisibleVerticalMargin is kept above the bottom of the usable content.
|
||||
*/
|
||||
var usableRect = [_platformWindow usableContentFrame],
|
||||
maxUsableY = CGRectGetMaxY(usableRect) - CGRectGetMinY([_contentView frame]) - CPWindowMinVisibleVerticalMargin;
|
||||
minimumSize = [_windowView _minimumResizeSize];
|
||||
|
||||
frame.origin.x = MAX(frame.origin.x, CGRectGetMinX(usableRect) + CPWindowMinVisibleHorizontalMargin - CGRectGetWidth(frame));
|
||||
frame.origin.x = MIN(frame.origin.x, CGRectGetMaxX(usableRect) - CPWindowMinVisibleHorizontalMargin);
|
||||
// First constrain x so that at least CPWindowMinVisibleHorizontalMargin is visible on the right
|
||||
frame.origin.x = MAX(frame.origin.x, CGRectGetMinX(usableRect) + minimumSize.width - CGRectGetWidth(frame));
|
||||
|
||||
// Now constrain x so that at least CPWindowMinVisibleHorizontalMargin is visible on the left
|
||||
frame.origin.x = MIN(frame.origin.x, CGRectGetMaxX(usableRect) - minimumSize.width);
|
||||
|
||||
// Now constrain y so that it is below the top of the usable content
|
||||
frame.origin.y = MAX(frame.origin.y, CGRectGetMinY(usableRect));
|
||||
frame.origin.y = MIN(frame.origin.y, maxUsableY);
|
||||
|
||||
// Finally constrain y so that at least CPWindowMinVisibleHorizontalMargin is visible at the bottom
|
||||
frame.origin.y = MIN(frame.origin.y, CGRectGetMaxY(usableRect) - CGRectGetMinY([_contentView frame]) - CPWindowMinVisibleVerticalMargin);
|
||||
|
||||
return frame;
|
||||
}
|
||||
@@ -985,6 +1018,7 @@ CPTexturedBackgroundWindowMask
|
||||
[_platformWindow moveWindow:self fromLevel:_level toLevel:aLevel];
|
||||
|
||||
_level = aLevel;
|
||||
[_childWindows makeObjectsPerformSelector:@selector(setLevel:) withObject:_level];
|
||||
|
||||
if ([self _sharesChromeWithPlatformWindow])
|
||||
[_platformWindow setLevel:aLevel];
|
||||
@@ -1020,6 +1054,23 @@ CPTexturedBackgroundWindowMask
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowResizeStyleGlobalChangeNotification object:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
If set to NO, platform window (virtual screen) resizes will not attempt to move/resize user windows.
|
||||
to the usable area.
|
||||
*/
|
||||
+ (void)setConstrainWindowsToUsableScreen:(BOOL)shouldConstrain
|
||||
{
|
||||
CPWindowConstrainToScreen = shouldConstrain;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return whether platform window (virtual screen) resizes constrain user windows to the usable area.
|
||||
*/
|
||||
+ (BOOL)constrainWindowsToUsableScreen
|
||||
{
|
||||
return CPWindowConstrainToScreen;
|
||||
}
|
||||
|
||||
- (void)_didReceiveResizeStyleChange:(CPNotification)aNotification
|
||||
{
|
||||
[_windowView setShowsResizeIndicator:_styleMask & CPResizableWindowMask];
|
||||
@@ -1313,8 +1364,11 @@ CPTexturedBackgroundWindowMask
|
||||
Sets the delegate for the window. Passing \c nil will just remove the window's current delegate.
|
||||
@param aDelegate an object to respond to the various delegate methods of CPWindow
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
- (void)setDelegate:(id <CPWindowDelegate>)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidResignKeyNotification object:self];
|
||||
@@ -1327,7 +1381,16 @@ CPTexturedBackgroundWindowMask
|
||||
[defaultCenter removeObserver:_delegate name:CPWindowDidEndSheetNotification object:self];
|
||||
|
||||
_delegate = aDelegate;
|
||||
_delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)];
|
||||
_implementedDelegateMethods = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowShouldClose:)])
|
||||
_implementedDelegateMethods |= CPWindowDelegate_windowShouldClose_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)])
|
||||
_implementedDelegateMethods |= CPWindowDelegate_windowWillReturnUndoManager_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowWillClose:)])
|
||||
_implementedDelegateMethods |= CPWindowDelegate_windowWillClose_;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(windowDidResignKey:)])
|
||||
[defaultCenter
|
||||
@@ -1669,11 +1732,17 @@ CPTexturedBackgroundWindowMask
|
||||
switch (type)
|
||||
{
|
||||
case CPLeftMouseDown:
|
||||
|
||||
// This is needed when a doubleClick occurs when the sheet is closing or opening
|
||||
if (!_parentWindow)
|
||||
return;
|
||||
|
||||
[_windowView mouseDown:anEvent];
|
||||
|
||||
// -dw- if the window is clicked, the sheet should come to front, and become key,
|
||||
// and the window should be immediately behind
|
||||
[sheet makeKeyAndOrderFront:self];
|
||||
|
||||
return;
|
||||
|
||||
case CPMouseMoved:
|
||||
@@ -2207,9 +2276,9 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
// The Cocoa docs say that if both the delegate and the window implement
|
||||
// windowShouldClose:, only the delegate receives the message.
|
||||
if ([_delegate respondsToSelector:@selector(windowShouldClose:)])
|
||||
if ([self _delegateRespondsToWindowShouldClose])
|
||||
{
|
||||
if (![_delegate windowShouldClose:self])
|
||||
if (![self _sendDelegateWindowShouldClose])
|
||||
return;
|
||||
}
|
||||
else if ([self respondsToSelector:@selector(windowShouldClose:)])
|
||||
@@ -2265,8 +2334,7 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)close
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(windowWillClose:)])
|
||||
[_delegate windowWillClose:self];
|
||||
[self _sendDelegateWindowWillClose];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillCloseNotification object:self];
|
||||
|
||||
@@ -2465,7 +2533,7 @@ CPTexturedBackgroundWindowMask
|
||||
// If this has an owner, dump it!
|
||||
[[aToolbar _window] setToolbar:nil];
|
||||
|
||||
// This is no longer out toolbar.
|
||||
// This is no longer our toolbar.
|
||||
[_toolbar _setWindow:nil];
|
||||
|
||||
_toolbar = aToolbar;
|
||||
@@ -2530,6 +2598,7 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
[childWindow setParentWindow:self];
|
||||
[childWindow _setChildOrdering:orderingMode];
|
||||
[childWindow setLevel:[self level]];
|
||||
|
||||
if ([self isVisible] && ![childWindow isVisible])
|
||||
[childWindow orderWindow:orderingMode relativeTo:_windowNumber];
|
||||
@@ -2755,14 +2824,21 @@ CPTexturedBackgroundWindowMask
|
||||
}
|
||||
|
||||
// The sheet starts hidden just above the top of a clip rect
|
||||
// TODO : Make properly for the -1 in endY
|
||||
var sheetFrame = [sheet frame],
|
||||
sheetShadowFrame = sheet._hasShadow ? [sheet._shadowView frame] : sheetFrame,
|
||||
frame = [self frame],
|
||||
originX = frame.origin.x + FLOOR((frame.size.width - sheetFrame.size.width) / 2),
|
||||
startFrame = CGRectMake(originX, -sheetShadowFrame.size.height, sheetFrame.size.width, sheetFrame.size.height),
|
||||
endY = [_windowView bodyOffset] - [[self contentView] frame].origin.y,
|
||||
endY = -1 + [_windowView bodyOffset] - [[self contentView] frame].origin.y,
|
||||
endFrame = CGRectMake(originX, endY, sheetFrame.size.width, sheetFrame.size.height);
|
||||
|
||||
if (_toolbar && [_windowView showsToolbar] && [self isFullPlatformWindow])
|
||||
{
|
||||
endY += [[_toolbar _toolbarView] frameSize].height;
|
||||
endFrame = CGRectMake(originX, endY, sheetFrame.size.width, sheetFrame.size.height);
|
||||
}
|
||||
|
||||
// Move the sheet offscreen before ordering front so it doesn't appear briefly
|
||||
[sheet setFrameOrigin:CGPointMake(0, -13000)];
|
||||
|
||||
@@ -3250,6 +3326,66 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
return CPOrderedDescending;
|
||||
};
|
||||
|
||||
|
||||
@implementation CPWindow (CPWindowDelegate)
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Check if the delegate implements windowWillReturnUndoManager:
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToWindowWillUndoManager
|
||||
{
|
||||
return _implementedDelegateMethods & CPWindowDelegate_windowWillReturnUndoManager_;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Check if the delegate implements windowShouldClose
|
||||
*/
|
||||
- (BOOL)_delegateRespondsToWindowShouldClose
|
||||
{
|
||||
return _implementedDelegateMethods & CPWindowDelegate_windowShouldClose_
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate windowShouldClose:
|
||||
*/
|
||||
- (BOOL)_sendDelegateWindowShouldClose
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPWindowDelegate_windowShouldClose_))
|
||||
return YES;
|
||||
|
||||
return [_delegate windowShouldClose:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate windowWillReturnUndoManager:
|
||||
*/
|
||||
- (BOOL)_sendDelegateWindowWillReturnUndoManager
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPWindowDelegate_windowWillReturnUndoManager_))
|
||||
return nil;
|
||||
|
||||
return [_delegate windowWillReturnUndoManager:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Call delegate windowWillClose:
|
||||
*/
|
||||
- (void)_sendDelegateWindowWillClose
|
||||
{
|
||||
if (!(_implementedDelegateMethods & CPWindowDelegate_windowWillClose_))
|
||||
return;
|
||||
|
||||
[_delegate windowWillClose:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPWindow (BridgeSupport)
|
||||
|
||||
/*
|
||||
@@ -3260,7 +3396,8 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
if ([self isFullPlatformWindow])
|
||||
return [self setFrame:[_platformWindow visibleFrame]];
|
||||
|
||||
if (_autoresizingMask === CPWindowNotSizable)
|
||||
// If this window is constrainable and we are globally ignoring constraining, ignore the platform resize
|
||||
if ((_constrainsToUsableScreen && !CPWindowConstrainToScreen) || _autoresizingMask === CPWindowNotSizable)
|
||||
return;
|
||||
|
||||
var frame = [_platformWindow contentBounds],
|
||||
@@ -3282,7 +3419,7 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
if (_autoresizingMask & CPWindowHeightSizable)
|
||||
newFrame.size.height += dY;
|
||||
|
||||
[self setFrame:newFrame];
|
||||
[self _setFrame:newFrame display:YES animate:NO constrainWidth:YES constrainHeight:YES];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3386,8 +3523,8 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
return documentUndoManager;
|
||||
|
||||
// If not, check to see if the delegate has one.
|
||||
if (_delegateRespondsToWindowWillReturnUndoManagerSelector)
|
||||
return [_delegate windowWillReturnUndoManager:self];
|
||||
if ([self _delegateRespondsToWindowWillUndoManager])
|
||||
return [self _sendDelegateWindowWillReturnUndoManager];
|
||||
|
||||
// If not, create one.
|
||||
if (!_undoManager)
|
||||
|
||||
@@ -194,3 +194,5 @@ CPStandardWindowShadowStyle = 0;
|
||||
CPMenuWindowShadowStyle = 1;
|
||||
CPPanelWindowShadowStyle = 2;
|
||||
CPCustomWindowShadowStyle = 3;
|
||||
|
||||
CPWindowConstrainToScreen = YES;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
return @"bordeless-bridge-window-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"toolbar-background-color": [CPColor grayColor],
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
return @"doc-modal-window-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"body-color": [CPColor whiteColor],
|
||||
|
||||
@@ -28,11 +28,7 @@
|
||||
|
||||
@global CPPopoverAppearanceMinimal
|
||||
|
||||
var _CPPopoverWindowViewDefaultCursorSize = CGSizeMake(16, 10),
|
||||
_CPPopoverWindowViewRadius = 5.0,
|
||||
_CPPopoverWindowViewStrokeWidth = 1.0,
|
||||
_CPPopoverWindowViewShadowSize = CGSizeMake(0, 6),
|
||||
_CPPopoverWindowViewShadowBlur = 15.0;
|
||||
var _CPPopoverWindowViewDefaultCursorSize = CGSizeMake(16, 10);
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
@@ -54,13 +50,17 @@ var _CPPopoverWindowViewDefaultCursorSize = CGSizeMake(16, 10),
|
||||
return @"popover-window-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"background-gradient": [CPNull null],
|
||||
@"background-gradient-hud": [CPNull null],
|
||||
@"stroke-color": [CPNull null],
|
||||
@"stroke-color-hud": [CPNull null],
|
||||
@"border-radius": 5.0,
|
||||
@"stroke-width": 1.0,
|
||||
@"shadow-size": CGSizeMake(0, 6),
|
||||
@"shadow-blur": 15.0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -156,15 +156,15 @@ var _CPPopoverWindowViewDefaultCursorSize = CGSizeMake(16, 10),
|
||||
[super drawRect:aRect];
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
radius = _CPPopoverWindowViewRadius,
|
||||
radius = [self valueForThemeAttribute:@"border-radius"],
|
||||
arrowWidth = _cursorSize.width,
|
||||
arrowHeight = _cursorSize.height,
|
||||
strokeWidth = _CPPopoverWindowViewStrokeWidth,
|
||||
strokeWidth = [self valueForThemeAttribute:@"stroke-width"],
|
||||
halfStrokeWidth = strokeWidth / 2.0,
|
||||
strokeColor,
|
||||
shadowColor = [[CPColor blackColor] colorWithAlphaComponent:.2],
|
||||
shadowSize = _CPPopoverWindowViewShadowSize,
|
||||
shadowBlur = _CPPopoverWindowViewShadowBlur,
|
||||
shadowSize = [self valueForThemeAttribute:@"shadow-size"],
|
||||
shadowBlur = [self valueForThemeAttribute:@"shadow-blur"],
|
||||
gradient,
|
||||
frame = [self bounds];
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
return @"shadow-window-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
|
||||
@implementation _CPTexturedWindowHeadView : CPView
|
||||
{
|
||||
BOOL _isSheet @accessors(setter=setSheet:);
|
||||
|
||||
_CPWindowView _parentView;
|
||||
CPView _gradientView;
|
||||
CPView _solidView;
|
||||
@@ -39,7 +41,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
return @"textured-window-head-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{};
|
||||
}
|
||||
@@ -66,10 +68,11 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
[super layoutSubviews];
|
||||
|
||||
var gradientHeight = [[CPTheme defaultTheme] valueForAttributeWithName:@"gradient-height" forClass:_CPStandardWindowView],
|
||||
bounds = [self bounds];
|
||||
bounds = [self bounds],
|
||||
bezelHeadColor = [[CPTheme defaultTheme] valueForAttributeWithName:_isSheet ? @"bezel-head-sheet-color" : @"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView];
|
||||
|
||||
[_gradientView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), gradientHeight)];
|
||||
[_gradientView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]];
|
||||
[_gradientView setBackgroundColor:bezelHeadColor];
|
||||
|
||||
[_solidView setFrame:CGRectMake(0.0, gradientHeight, CGRectGetWidth(bounds), CGRectGetHeight(bounds) - gradientHeight)];
|
||||
[_solidView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"solid-color" forClass:_CPStandardWindowView]];
|
||||
@@ -97,6 +100,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
CPButton _minimizeButton;
|
||||
|
||||
BOOL _isDocumentEdited;
|
||||
BOOL _isSheet;
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -104,12 +108,13 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
return @"standard-window-view";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"gradient-height": [CPNull null],
|
||||
@"solid-color": [CPNull null],
|
||||
@"bezel-head-color": [CPNull null],
|
||||
@"bezel-head-sheet-color": [CPNull null],
|
||||
@"divider-color": [CPColor blackColor],
|
||||
@"body-color": [CPColor whiteColor],
|
||||
@"title-bar-height": 32,
|
||||
@@ -224,7 +229,14 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
width = CGRectGetWidth(bounds),
|
||||
headHeight = [self toolbarMaxY];
|
||||
|
||||
if (_isSheet && _toolbarView && [self showsToolbar])
|
||||
{
|
||||
headHeight = [_toolbarView frameSize].height;
|
||||
[_toolbarView setFrameOrigin:CGPointMake(0.0, 0.0)];
|
||||
}
|
||||
|
||||
[_headView setFrameSize:CGSizeMake(width, headHeight)];
|
||||
|
||||
[_dividerView setFrame:CGRectMake(0.0, headHeight, width, _CPStandardWindowViewDividerViewHeight)];
|
||||
|
||||
var dividerMinY = 0,
|
||||
@@ -312,12 +324,26 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
{
|
||||
[super _enableSheet:enable inWindow:parentWindow];
|
||||
|
||||
[_headView setHidden:enable];
|
||||
[_dividerView setHidden:enable];
|
||||
_isSheet = enable;
|
||||
[_headView setSheet:enable];
|
||||
|
||||
if (_toolbarView && [self showsToolbar])
|
||||
{
|
||||
[_headView setHidden:NO];
|
||||
[_dividerView setHidden:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_headView setHidden:enable];
|
||||
[_dividerView setHidden:enable];
|
||||
}
|
||||
|
||||
[_closeButton setHidden:enable];
|
||||
[_minimizeButton setHidden:enable];
|
||||
[_titleField setHidden:enable];
|
||||
|
||||
[[self window] setMovable:!enable];
|
||||
|
||||
if (enable)
|
||||
{
|
||||
[_bodyView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"body-color" forClass:_CPDocModalWindowView]];
|
||||
@@ -333,12 +359,13 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
|
||||
var theWindow = [self window],
|
||||
frame = [theWindow frame],
|
||||
dividerHeight = [_dividerView frame].size.height,
|
||||
dy;
|
||||
dy = [self toolbarMaxY] + dividerHeight;
|
||||
|
||||
if (_toolbarView && [self showsToolbar])
|
||||
dy = [[CPTheme defaultTheme] valueForAttributeWithName:@"gradient-height" forClass:_CPStandardWindowView];
|
||||
|
||||
if (enable)
|
||||
dy = -[_headView frame].size.height;
|
||||
else
|
||||
dy = [self toolbarMaxY] + dividerHeight;
|
||||
dy = -dy;
|
||||
|
||||
var newHeight = CGRectGetHeight(frame) + dy,
|
||||
newWidth = CGRectGetWidth(frame);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
return @"tooltip";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"stroke-color": [CPColor colorWithHexString:@"E3E3E3"],
|
||||
|
||||
@@ -81,7 +81,7 @@ _CPWindowViewResizeSlop = 3;
|
||||
return "window";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"title-bar-height": 25,
|
||||
@@ -631,7 +631,38 @@ _CPWindowViewResizeSlop = 3;
|
||||
newHeight = startHeight;
|
||||
}
|
||||
|
||||
[theWindow _setFrame:CGRectMake(newX, newY, newWidth, newHeight) display:YES animate:NO constrainWidth:NO constrainHeight:NO];
|
||||
// When resizing, we always constrain to the usable screen.
|
||||
frame = CGRectMake(newX, newY, newWidth, newHeight);
|
||||
|
||||
var constrainedFrame = [theWindow _constrainOriginOfFrame:frame],
|
||||
dx = constrainedFrame.origin.x - frame.origin.x,
|
||||
dy = constrainedFrame.origin.y - frame.origin.y;
|
||||
|
||||
// When resizing from the left or top, we adjust the origin and size.
|
||||
switch (_resizeRegion)
|
||||
{
|
||||
case _CPWindowViewResizeRegionBottomLeft:
|
||||
case _CPWindowViewResizeRegionLeft:
|
||||
case _CPWindowViewResizeRegionTopLeft:
|
||||
case _CPWindowViewResizeRegionTop:
|
||||
case _CPWindowViewResizeRegionTopRight:
|
||||
frame.origin = constrainedFrame.origin;
|
||||
frame.size.width -= dx;
|
||||
frame.size.height -= dy;
|
||||
}
|
||||
|
||||
// When resizing from the right or bottom, we only adjust the size.
|
||||
switch (_resizeRegion)
|
||||
{
|
||||
case _CPWindowViewResizeRegionTopRight:
|
||||
case _CPWindowViewResizeRegionRight:
|
||||
case _CPWindowViewResizeRegionBottomRight:
|
||||
case _CPWindowViewResizeRegionBottom:
|
||||
frame.size.width += dx;
|
||||
frame.size.height += dy;
|
||||
}
|
||||
|
||||
[theWindow _setFrame:frame display:YES animate:NO constrainWidth:NO constrainHeight:NO];
|
||||
[self setCursorForLocation:location resizing:YES];
|
||||
}
|
||||
|
||||
@@ -683,7 +714,7 @@ _CPWindowViewResizeSlop = 3;
|
||||
[theWindow _setAttachedSheetFrameOrigin];
|
||||
[sheet._windowView _adjustShadowViewSize];
|
||||
}
|
||||
else if (theWindow._isSheet)
|
||||
else if (theWindow && theWindow._isSheet)
|
||||
[self _adjustShadowViewSize];
|
||||
}
|
||||
|
||||
@@ -742,7 +773,9 @@ _CPWindowViewResizeSlop = 3;
|
||||
|
||||
- (BOOL)showsToolbar
|
||||
{
|
||||
return YES;
|
||||
var styleMaskWindow = [[self window] styleMask];
|
||||
|
||||
return styleMaskWindow & CPBorderlessWindowMask || styleMaskWindow & CPTitledWindowMask || styleMaskWindow & CPHUDBackgroundWindowMask || styleMaskWindow & CPBorderlessBridgeWindowMask;
|
||||
}
|
||||
|
||||
- (CGSize)toolbarOffset
|
||||
@@ -926,7 +959,8 @@ _CPWindowViewResizeSlop = 3;
|
||||
|
||||
- (CGSize)_minimumResizeSize
|
||||
{
|
||||
return CGSizeMake(0, _CPWindowViewMinContentHeight);
|
||||
// Leave at least 4px so there is something visible.
|
||||
return CGSizeMake(4, _CPWindowViewMinContentHeight);
|
||||
}
|
||||
|
||||
- (int)bodyOffset
|
||||
|
||||
@@ -63,8 +63,8 @@ var CPCibOwner = @"CPCibOwner";
|
||||
+ (CPCib)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable loadDelegate:aDelegate
|
||||
{
|
||||
return ([[CPCib alloc]
|
||||
initWithContentsOfURL:anAbsolutePath
|
||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||
initWithContentsOfURL:anAbsolutePath
|
||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||
initWithLoadDelegate:aDelegate
|
||||
externalNameTable:aNameTable]]);
|
||||
}
|
||||
@@ -84,9 +84,9 @@ var CPCibOwner = @"CPCibOwner";
|
||||
- (CPCib)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable loadDelegate:(id)aDelegate
|
||||
{
|
||||
return ([[CPCib alloc]
|
||||
initWithCibNamed:aFileName
|
||||
bundle:self
|
||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||
initWithCibNamed:aFileName
|
||||
bundle:self
|
||||
loadDelegate:[[_CPCibLoadDelegate alloc]
|
||||
initWithLoadDelegate:aDelegate
|
||||
externalNameTable:aNameTable]]);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
|
||||
var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
_CPCibCustomResourceResourceNameKey = @"_CPCibCustomResourceResourceNameKey",
|
||||
_CPCibCustomResourcePropertiesKey = @"_CPCibCustomResourcePropertiesKey";
|
||||
_CPCibCustomResourcePropertiesKey = @"_CPCibCustomResourcePropertiesKey",
|
||||
|
||||
_CPCibCustomResourceTemplateImageMap = nil;
|
||||
|
||||
|
||||
@implementation _CPCibCustomResource : CPObject
|
||||
{
|
||||
@@ -45,6 +48,16 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
CPBundle _bundle;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== [_CPCibCustomResource class])
|
||||
return;
|
||||
|
||||
_CPCibCustomResourceTemplateImageMap = @{
|
||||
"CPAddTemplate": "button-image-plus",
|
||||
"CPRemoveTemplate": "button-image-minus"
|
||||
};
|
||||
}
|
||||
+ (id)imageResourceWithName:(CPString)aResourceName size:(CGSize)aSize
|
||||
{
|
||||
return [[self alloc] initWithClassName:@"CPImage" resourceName:aResourceName properties:@{ @"size": aSize }];
|
||||
@@ -98,12 +111,12 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
(![aCoder respondsToSelector:@selector(awakenCustomResources)] || [aCoder awakenCustomResources]))
|
||||
if (_className === @"CPImage")
|
||||
{
|
||||
if (_resourceName == "CPAddTemplate")
|
||||
return [[CPTheme defaultTheme] valueForAttributeWithName:@"button-image-plus" forClass:[CPButtonBar class]];
|
||||
else if (_resourceName == "CPRemoveTemplate")
|
||||
return [[CPTheme defaultTheme] valueForAttributeWithName:@"button-image-minus" forClass:[CPButtonBar class]];
|
||||
var templateImage = [_CPCibCustomResourceTemplateImageMap objectForKey:_resourceName];
|
||||
|
||||
return [self imageFromCoder:aCoder];
|
||||
if (templateImage)
|
||||
return [[CPTheme defaultTheme] valueForAttributeWithName:templateImage forClass:[CPButtonBar class]];
|
||||
else
|
||||
return [self imageFromCoder:aCoder];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -176,6 +189,11 @@ var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
|
||||
return [_properties objectForKey:@"size"];
|
||||
}
|
||||
|
||||
- (BOOL)isSingleImage
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isThreePartImage
|
||||
{
|
||||
return NO;
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
@end
|
||||
|
||||
var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
|
||||
@implementation _CPCibCustomView (CPCoding)
|
||||
|
||||
|
||||
@@ -87,12 +87,17 @@
|
||||
|
||||
- (id)_cibInstantiate
|
||||
{
|
||||
var windowClass = CPClassFromString([self windowClass]),
|
||||
theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
|
||||
var windowClass = CPClassFromString([self windowClass]);
|
||||
|
||||
/* if (!windowClass)
|
||||
[NSException raise:NSInvalidArgumentException format:@"Unable to locate NSWindow class %@, using NSWindow",_windowClass];
|
||||
class=[NSWindow class];*/
|
||||
if (!windowClass)
|
||||
{
|
||||
#if DEBUG
|
||||
CPLog.warn("Unknown class \"%@\" in cib file, using CPWindow instead.", [self windowClass]);
|
||||
#endif
|
||||
windowClass = [CPWindow class];
|
||||
}
|
||||
|
||||
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
|
||||
|
||||
if (_minSize)
|
||||
[theWindow setMinSize:_minSize];
|
||||
@@ -103,12 +108,11 @@
|
||||
//[result setHidesOnDeactivate:(_wtFlags&0x80000000)?YES:NO];
|
||||
[theWindow setTitle:_windowTitle];
|
||||
|
||||
// FIXME: we can't autoresize yet...
|
||||
var contentViewAutoresizesSubviews = [_windowView autoresizesSubviews];
|
||||
|
||||
[_windowView setAutoresizesSubviews:NO];
|
||||
|
||||
[theWindow setContentView:_windowView];
|
||||
|
||||
[_windowView setAutoresizesSubviews:YES];
|
||||
[_windowView setAutoresizesSubviews:contentViewAutoresizesSubviews];
|
||||
|
||||
if ([_viewClass isKindOfClass:[CPToolbar class]])
|
||||
[theWindow setToolbar:_viewClass];
|
||||
|
||||
@@ -687,7 +687,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
|
||||
@param aLayer the layer to insert
|
||||
@param anIndex the index to insert the layer at
|
||||
*/
|
||||
- (void)insertSublayer:(CALayer)aLayer atIndex:(unsigned)anIndex
|
||||
- (void)insertSublayer:(CALayer)aLayer atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
if (!aLayer)
|
||||
return;
|
||||
|
||||
@@ -75,7 +75,7 @@ var CAMediaNamedTimingFunctions = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)getControlPointAtIndex:(unsigned)anIndex values:(float/*[2]*/)reference
|
||||
- (void)getControlPointAtIndex:(CPUInteger)anIndex values:(float/*[2]*/)reference
|
||||
{
|
||||
if (anIndex == 0)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ var CANVAS_LINECAP_TABLE = [ "butt", "round", "square" ],
|
||||
#define _CGContextFillRectCanvas(aContext, aRect) aContext.fillRect(CGRectGetMinX(aRect), CGRectGetMinY(aRect), CGRectGetWidth(aRect), CGRectGetHeight(aRect))
|
||||
#define _CGContextClipCanvas(aContext) aContext.clip()
|
||||
|
||||
// In Cocoa, all primitives excepts rects cannot be added to the context's path
|
||||
// In Cocoa, all primitives excepts rects and arcs cannot be added to the context's path
|
||||
// until a move to point has been done, because an empty path has no current point.
|
||||
var hasPath = function(aContext, methodName)
|
||||
{
|
||||
@@ -113,12 +113,12 @@ function CGContextSetBlendMode(aContext, aBlendMode)
|
||||
|
||||
function CGContextAddArc(aContext, x, y, radius, startAngle, endAngle, clockwise)
|
||||
{
|
||||
if (!hasPath(aContext, "CGContextAddArc"))
|
||||
return;
|
||||
|
||||
// Despite the documentation saying otherwise, the last parameter is anti-clockwise not clockwise.
|
||||
// http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes#Arcs
|
||||
_CGContextAddArcCanvas(aContext, x, y, radius, startAngle, endAngle, !clockwise);
|
||||
|
||||
// AddArc implicitly starts a path
|
||||
aContext.hasPath = YES;
|
||||
}
|
||||
|
||||
function CGContextAddArcToPoint(aContext, x1, y1, x2, y2, radius)
|
||||
@@ -470,7 +470,7 @@ var scale_rotate = function(a, b, c, d)
|
||||
|
||||
var rotate_scale = function(a, b, c, d)
|
||||
{
|
||||
var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0;
|
||||
var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0,
|
||||
a1 = (ATAN2(sign * b, sign * a) + ATAN2(-c, d)) / 2.0,
|
||||
cos = COS(a1),
|
||||
sin = SIN(a1);
|
||||
@@ -596,7 +596,6 @@ function CGContextDrawLinearGradient(aContext, aGradient, aStartPoint, anEndPoin
|
||||
{
|
||||
var colors = aGradient.colors,
|
||||
count = colors.length,
|
||||
|
||||
linearGradient = aContext.createLinearGradient(aStartPoint.x, aStartPoint.y, anEndPoint.x, anEndPoint.y);
|
||||
|
||||
while (count--)
|
||||
@@ -607,6 +606,20 @@ function CGContextDrawLinearGradient(aContext, aGradient, aStartPoint, anEndPoin
|
||||
aContext.hasPath = NO;
|
||||
}
|
||||
|
||||
function CGContextDrawRadialGradient(aContext, aGradient, aStartCenter, aStartRadius, anEndCenter, anEndRadius, options)
|
||||
{
|
||||
var colors = aGradient.colors,
|
||||
count = colors.length,
|
||||
linearGradient = aContext.createRadialGradient(aStartCenter.x, aStartCenter.y, aStartRadius, anEndCenter.x, anEndCenter.y, anEndRadius);
|
||||
|
||||
while (count--)
|
||||
linearGradient.addColorStop(aGradient.locations[count], to_string(colors[count]));
|
||||
|
||||
aContext.fillStyle = linearGradient;
|
||||
aContext.fill();
|
||||
aContext.hasPath = NO;
|
||||
}
|
||||
|
||||
function CGBitmapGraphicsContextCreate()
|
||||
{
|
||||
var DOMElement = document.createElement("canvas"),
|
||||
|
||||
@@ -120,12 +120,14 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle,
|
||||
The ending point of the arc becomes the new current point of the path.
|
||||
*/
|
||||
var arcEndX = x + aRadius * COS(anEndAngle),
|
||||
arcEndY = y + aRadius * SIN(anEndAngle);
|
||||
arcEndY = y + aRadius * SIN(anEndAngle),
|
||||
arcStartX = x + aRadius * COS(aStartAngle),
|
||||
arcStartY = y + aRadius * SIN(aStartAngle);
|
||||
|
||||
if (aPath.count)
|
||||
{
|
||||
if (aPath.current.x !== arcEndX || aPath.current.y !== arcEndY)
|
||||
CGPathAddLineToPoint(aPath, aTransform, arcEndX, arcEndY);
|
||||
if (aPath.current.x !== x || aPath.current.y !== y)
|
||||
CGPathAddLineToPoint(aPath, aTransform, arcStartX, arcStartY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -136,7 +138,7 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle,
|
||||
}
|
||||
|
||||
aPath.current = CGPointMake(arcEndX, arcEndY);
|
||||
aPath.elements[aPath.count++] = { type:kCGPathElementAddArc, x:x, y:y, radius:aRadius, startAngle:aStartAngle, endAngle:anEndAngle, clockwise:isClockwise };
|
||||
aPath.elements[aPath.count++] = { type:kCGPathElementAddArc, x:x, y:y, radius:aRadius, startAngle:aStartAngle, endAngle:anEndAngle, isClockwise:isClockwise };
|
||||
}
|
||||
|
||||
function CGPathAddArcToPoint(aPath, aTransform, x1, y1, x2, y2, aRadius)
|
||||
@@ -233,7 +235,7 @@ function CGPathAddPath(aPath, aTransform, anotherPath)
|
||||
case kCGPathElementAddArc:
|
||||
CGPathAddArc(aPath, aTransform, element.x, element.y,
|
||||
element.radius, element.startAngle,
|
||||
element.endAngle, element.clockwise);
|
||||
element.endAngle, element.isClockwise);
|
||||
break;
|
||||
|
||||
case kCGPathElementAddArcToPoint:
|
||||
@@ -438,7 +440,7 @@ function CGPathEqualToPath(aPath, anotherPath)
|
||||
element.radius !== anotherElement.radius ||
|
||||
element.startAngle !== anotherElement.startAngle ||
|
||||
element.endAngle !== anotherElement.endAngle ||
|
||||
element.clockwise !== anotherElement.clockwise)
|
||||
element.isClockwise !== anotherElement.isClockwise)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@@ -608,7 +610,23 @@ function CGPathGetBoundingBox(aPath)
|
||||
return CGRectMake(ox, oy, rx - ox, ry - oy);
|
||||
}
|
||||
|
||||
function CGPathContainsPoint(aPath, aTransform, point, eoFill)
|
||||
{
|
||||
if (!aPath.count)
|
||||
return NO;
|
||||
|
||||
if (aTransform)
|
||||
point = CGPointApplyAffineTransform(point, aTransform);
|
||||
|
||||
var context = CGBitmapGraphicsContextCreate();
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextAddPath(context, aPath);
|
||||
CGContextClosePath(context);
|
||||
|
||||
return context.isPointInPath(point.x, point.y);
|
||||
}
|
||||
|
||||
/*!
|
||||
@}
|
||||
*/
|
||||
|
||||
*/
|
||||
@@ -26,6 +26,7 @@
|
||||
@import "CPPlatform.j"
|
||||
|
||||
@class CPMenu
|
||||
@class CPPlatformPasteboard
|
||||
|
||||
@global CPApp
|
||||
|
||||
@@ -33,46 +34,42 @@ var PrimaryPlatformWindow = NULL;
|
||||
|
||||
@implementation CPPlatformWindow : CPObject
|
||||
{
|
||||
CGRect _contentRect;
|
||||
CGRect _contentRect;
|
||||
|
||||
CPInteger _level;
|
||||
BOOL _hasShadow;
|
||||
unsigned _shadowStyle;
|
||||
CPString _title;
|
||||
CPInteger _level;
|
||||
BOOL _hasShadow;
|
||||
unsigned _shadowStyle;
|
||||
CPString _title;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMWindow _DOMWindow;
|
||||
DOMWindow _DOMWindow;
|
||||
|
||||
DOMElement _DOMBodyElement;
|
||||
DOMElement _DOMFocusElement;
|
||||
DOMElement _DOMEventGuard;
|
||||
DOMElement _DOMScrollingElement;
|
||||
id _hideDOMScrollingElementTimeout;
|
||||
DOMElement _DOMBodyElement;
|
||||
DOMElement _DOMFocusElement;
|
||||
DOMElement _DOMEventGuard;
|
||||
DOMElement _DOMScrollingElement;
|
||||
id _hideDOMScrollingElementTimeout;
|
||||
|
||||
CPArray _windowLevels;
|
||||
CPDictionary _windowLayers;
|
||||
CPArray _windowLevels;
|
||||
CPDictionary _windowLayers;
|
||||
|
||||
BOOL _mouseIsDown;
|
||||
BOOL _mouseDownIsRightClick;
|
||||
CGPoint _lastMouseEventLocation;
|
||||
CPWindow _mouseDownWindow;
|
||||
CPTimeInterval _lastMouseUp;
|
||||
CPTimeInterval _lastMouseDown;
|
||||
BOOL _mouseIsDown;
|
||||
BOOL _mouseDownIsRightClick;
|
||||
CGPoint _lastMouseEventLocation;
|
||||
CPWindow _mouseDownWindow;
|
||||
CPTimeInterval _lastMouseUp;
|
||||
CPTimeInterval _lastMouseDown;
|
||||
|
||||
Object _charCodes;
|
||||
unsigned _keyCode;
|
||||
unsigned _lastKey;
|
||||
BOOL _capsLockActive;
|
||||
BOOL _ignoreNativeCopyOrCutEvent;
|
||||
BOOL _ignoreNativePastePreparation;
|
||||
Object _charCodes;
|
||||
unsigned _keyCode;
|
||||
unsigned _lastKey;
|
||||
BOOL _capsLockActive;
|
||||
|
||||
BOOL _DOMEventMode;
|
||||
BOOL _DOMEventMode;
|
||||
|
||||
// Native Pasteboard Support
|
||||
DOMElement _DOMPasteboardElement;
|
||||
CPEvent _pasteboardKeyDownEvent;
|
||||
CPPlatformPasteboard _platformPasteboard;
|
||||
|
||||
CPString _overriddenEventType;
|
||||
CPString _overriddenEventType;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@import "CGGeometry.j"
|
||||
|
||||
@implementation CPDOMWindowLayer : CPObject
|
||||
{
|
||||
@@ -78,7 +79,7 @@
|
||||
aWindow._isVisible = NO;
|
||||
}
|
||||
|
||||
- (void)insertWindow:(CPWindow)aWindow atIndex:(unsigned)anIndex
|
||||
- (void)insertWindow:(CPWindow)aWindow atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
// We will have to adjust the z-index of all windows starting at this index.
|
||||
var count = [_windows count],
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
/*
|
||||
* CPPlatformPasteboard.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2013, SlevenBits Ltd.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPRunLoop.j>
|
||||
|
||||
@import "CPCompatibility.j"
|
||||
@import "CPEvent.j"
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPPlatform.j"
|
||||
@import "CPPlatformWindow+DOMKeys.j"
|
||||
|
||||
@global CPApp
|
||||
@global CPPlatformWindow
|
||||
|
||||
// From CPPlatformWindow+DOM.j
|
||||
@global _CPDOMEventStop
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
#define SUPPRESS_CAPPUCCINO_CUT_FOR_EVENT(anEvent) anEvent._suppressCappuccinoCut = YES
|
||||
#define SUPPRESS_CAPPUCCINO_PASTE_FOR_EVENT(anEvent) anEvent._suppressCappuccinoPaste = YES
|
||||
|
||||
var hasEditableTarget = function(aDOMEvent)
|
||||
{
|
||||
var target = aDOMEvent.target || aDOMEvent.srcElement;
|
||||
|
||||
if (!target)
|
||||
return NO;
|
||||
|
||||
if (target.contentEditable == "true")
|
||||
return YES;
|
||||
|
||||
var nodeName = target.nodeName.toUpperCase();
|
||||
|
||||
return nodeName === "INPUT" || nodeName == "TEXTAREA";
|
||||
}
|
||||
|
||||
/*
|
||||
* This class encapsulates copy and paste related functionality for the
|
||||
* DOM environment. While originally all of this code was apread out in a
|
||||
* dozen places in CPPlatformWindow+DOM.j, this class serves to collect
|
||||
* and isolate that code for easier testing and maintenance.
|
||||
*/
|
||||
@implementation CPPlatformPasteboard : CPObject
|
||||
{
|
||||
DOMWindow _DOMWindow;
|
||||
|
||||
DOMElement _DOMPasteboardElement;
|
||||
|
||||
BOOL supportsNativeCopyAndPaste;
|
||||
BOOL hasBugWhichPreventsNonEditablePaste;
|
||||
BOOL hasBugWhichPreventsNonEditablePasteRedirect;
|
||||
|
||||
CPEvent _lastKeyDownEvent;
|
||||
BOOL currentEventIsNativePasteEvent;
|
||||
BOOL currentEventIsNativeCopyOrCutEvent;
|
||||
BOOL currentEventShouldBeSuppressed;
|
||||
BOOL currentEventShouldDefinitelyBubble;
|
||||
BOOL currentEventShouldDefinitelyNotBubble;
|
||||
|
||||
BOOL _ignoreNativeCopyOrCutEvent;
|
||||
BOOL _ignoreNativePastePreparation;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
supportsNativeCopyAndPaste = CPFeatureIsCompatible(CPJavaScriptClipboardEventsFeature);
|
||||
hasBugWhichPreventsNonEditablePaste = CPPlatformHasBug(CPJavaScriptPasteRequiresEditableTarget);
|
||||
hasBugWhichPreventsNonEditablePasteRedirect = CPPlatformHasBug(CPJavaScriptPasteCantRefocus);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setDOMWindow:(DOMWindow)aDOMWindow
|
||||
{
|
||||
if (_DOMWindow === aDOMWindow)
|
||||
return;
|
||||
|
||||
if (_DOMWindow)
|
||||
[self destroyDOMElements];
|
||||
|
||||
_DOMWindow = aDOMWindow;
|
||||
|
||||
if (_DOMWindow)
|
||||
[self createDOMElements];
|
||||
}
|
||||
|
||||
- (void)createDOMElements
|
||||
{
|
||||
var theDocument = _DOMWindow.document,
|
||||
_DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
|
||||
|
||||
// Create Native Pasteboard handler.
|
||||
_DOMPasteboardElement = theDocument.createElement("textarea");
|
||||
|
||||
_DOMPasteboardElement.style.position = "absolute";
|
||||
_DOMPasteboardElement.style.top = "-10000px";
|
||||
_DOMPasteboardElement.style.zIndex = "999";
|
||||
_DOMPasteboardElement.className = "cpdontremove";
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMPasteboardElement);
|
||||
|
||||
_DOMPasteboardElement.blur();
|
||||
|
||||
var copyEventCallback = function (anEvent) { return [self beforeCopyEvent:anEvent]; },
|
||||
nativeBeforeClipboardEventCallback = function (anEvent) { return [self nativeBeforeClipboardEvent:anEvent]; },
|
||||
nativeCopyOrCutEventCallback = function (anEvent) { return [self nativeCopyOrCutEvent:anEvent]; },
|
||||
pasteEventCallback = function (anEvent) { return [self beforePasteEvent:anEvent]; },
|
||||
nativePasteEventCallback = function (anEvent) { return [self nativePasteEvent:anEvent]; };
|
||||
|
||||
if (theDocument.addEventListener)
|
||||
{
|
||||
if (supportsNativeCopyAndPaste)
|
||||
{
|
||||
_DOMWindow.addEventListener("beforecopy", nativeBeforeClipboardEventCallback, NO);
|
||||
_DOMWindow.addEventListener("beforecut", nativeBeforeClipboardEventCallback, NO);
|
||||
_DOMWindow.addEventListener("beforepaste", nativeBeforeClipboardEventCallback, NO);
|
||||
_DOMWindow.addEventListener("copy", nativeCopyOrCutEventCallback, NO);
|
||||
_DOMWindow.addEventListener("cut", nativeCopyOrCutEventCallback, NO);
|
||||
_DOMWindow.addEventListener("paste", nativePasteEventCallback, NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
theDocument.addEventListener("beforepaste", pasteEventCallback, NO);
|
||||
theDocument.addEventListener("beforecopy", copyEventCallback, NO);
|
||||
theDocument.addEventListener("beforecut", copyEventCallback, NO);
|
||||
}
|
||||
|
||||
_DOMWindow.addEventListener("unload", function()
|
||||
{
|
||||
if (supportsNativeCopyAndPaste)
|
||||
{
|
||||
_DOMWindow.removeEventListener("beforecopy", nativeBeforeClipboardEventCallback, NO);
|
||||
_DOMWindow.removeEventListener("beforecut", nativeBeforeClipboardEventCallback, NO);
|
||||
_DOMWindow.removeEventListener("beforepaste", nativeBeforeClipboardEventCallback, NO);
|
||||
_DOMWindow.removeEventListener("copy", nativeCopyOrCutEventCallback, NO);
|
||||
_DOMWindow.removeEventListener("cut", nativeCopyOrCutEventCallback, NO);
|
||||
_DOMWindow.removeEventListener("paste", nativePasteEventCallback, NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
theDocument.removeEventListener("beforepaste", pasteEventCallback, NO);
|
||||
theDocument.removeEventListener("beforecopy", copyEventCallback, NO);
|
||||
theDocument.removeEventListener("beforecut", copyEventCallback, NO);
|
||||
}
|
||||
}, NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO If we wanted IE 8 and lower copy and paste it'd go here.
|
||||
}
|
||||
}
|
||||
|
||||
- (void)destroyDOMElements
|
||||
{
|
||||
var theDocument = _DOMWindow.document,
|
||||
_DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
|
||||
|
||||
_DOMBodyElement.removeChild(_DOMPasteboardElement);
|
||||
_DOMPasteboardElement = nil;
|
||||
}
|
||||
|
||||
- (void)windowMaySendKeyEvent:(CPEvent)anEvent
|
||||
{
|
||||
// Reset our opinions.
|
||||
currentEventIsNativePasteEvent = NO;
|
||||
currentEventIsNativeCopyOrCutEvent = NO;
|
||||
currentEventShouldBeSuppressed = NO;
|
||||
currentEventShouldDefinitelyNotBubble = NO;
|
||||
currentEventShouldDefinitelyBubble = NO;
|
||||
|
||||
if (!anEvent)
|
||||
return;
|
||||
|
||||
if ([anEvent type] !== CPKeyDown)
|
||||
{
|
||||
// Reset these flags on key up.
|
||||
_ignoreNativePastePreparation = NO;
|
||||
_ignoreNativeCopyOrCutEvent = NO;
|
||||
return;
|
||||
}
|
||||
|
||||
var modifierFlags = [anEvent modifierFlags];
|
||||
|
||||
if (!(modifierFlags & (CPControlKeyMask | CPCommandKeyMask)))
|
||||
return;
|
||||
|
||||
_lastKeyDownEvent = anEvent;
|
||||
|
||||
var aDOMEvent = anEvent._DOMEvent,
|
||||
characters = [anEvent characters],
|
||||
mayRequireDOMPasteboardElement = [self _mayRequireDOMPasteboardElementHack:aDOMEvent flags:modifierFlags];
|
||||
|
||||
if (characters === "v" && mayRequireDOMPasteboardElement)
|
||||
{
|
||||
if (supportsNativeCopyAndPaste && hasBugWhichPreventsNonEditablePaste && hasBugWhichPreventsNonEditablePasteRedirect && !hasEditableTarget(aDOMEvent))
|
||||
{
|
||||
// You can't paste from the system clipboard into a non-editable area in Safari, neither using native
|
||||
// copy and paste nor our _DOMPasteboardElement hack. We will paste from the Cappuccino pasteboard only
|
||||
// and allow Safari to "beep" to indicate something went wrong.
|
||||
|
||||
// The key down will not result in a paste event being sent by Safari, so it's not a paste event.
|
||||
currentEventIsNativePasteEvent = NO;
|
||||
// Yes to get the beep.
|
||||
currentEventShouldDefinitelyBubble = YES;
|
||||
}
|
||||
else if (!(supportsNativeCopyAndPaste || hasBugWhichPreventsNonEditablePaste) && !_ignoreNativePastePreparation)
|
||||
{
|
||||
// We don't support native copy and paste so we must focus the _DOMPasteboardElement to receive the
|
||||
// paste content. This needs to be done at keyDown time (or in the case of modern Safari, before the keyDown,
|
||||
// which unfortunately isn't possible. See above.)
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
_DOMWindow.setNativeTimeout(function () { [self _checkDOMPasteboardElement]; }, 0);
|
||||
|
||||
currentEventIsNativePasteEvent = YES;
|
||||
}
|
||||
else if (supportsNativeCopyAndPaste)
|
||||
currentEventIsNativePasteEvent = YES;
|
||||
|
||||
if (currentEventIsNativePasteEvent)
|
||||
{
|
||||
// We need the event to propagate or nothing will be pasted.
|
||||
currentEventShouldDefinitelyBubble = YES;
|
||||
|
||||
// And we don't send the keydown because either our native paste envent handler will send it,
|
||||
// or the _checkDOMPasteboardElement check will.
|
||||
currentEventShouldBeSuppressed = YES;
|
||||
}
|
||||
}
|
||||
else if ((characters == "c" || characters == "x") && mayRequireDOMPasteboardElement)
|
||||
{
|
||||
currentEventIsNativeCopyOrCutEvent = YES;
|
||||
|
||||
// If _ignoreNativeCopyOrCutEvent, we already handled the copy/cut in beforeCopyEvent:.
|
||||
// If supportsNativeCopyAndPaste, we will be handling it in the nativebeforeCopyEvent: handler.
|
||||
// In both of those cases we don't want to send the event on keydown too, or we'll get 2X copy/cut operations.
|
||||
if (supportsNativeCopyAndPaste || _ignoreNativeCopyOrCutEvent)
|
||||
currentEventShouldBeSuppressed = YES;
|
||||
}
|
||||
|
||||
if (!currentEventShouldBeSuppressed)
|
||||
{
|
||||
if (characters === "v")
|
||||
SUPPRESS_CAPPUCCINO_PASTE_FOR_EVENT(anEvent);
|
||||
else if (characters === "x")
|
||||
SUPPRESS_CAPPUCCINO_CUT_FOR_EVENT(anEvent);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldSuppressKeyEvent
|
||||
{
|
||||
return currentEventShouldBeSuppressed;
|
||||
}
|
||||
|
||||
- (void)windowDidSendKeyEvent:(CPEvent)anEvent
|
||||
{
|
||||
// Now that the copy event has been sent through the Cappuccino event stack, we can load any Cappuccino
|
||||
// pasteboard string into our DOMPasteboardElement hack, if necessary.
|
||||
if (!supportsNativeCopyAndPaste && currentEventIsNativeCopyOrCutEvent)
|
||||
[self _primeDOMPasteboardElement];
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldStopPropagation
|
||||
{
|
||||
return currentEventShouldDefinitelyNotBubble;
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldNotStopPropagation
|
||||
{
|
||||
return currentEventShouldDefinitelyBubble;
|
||||
}
|
||||
|
||||
- (CPEvent)_fakeClipboardEvent:(DOMEvent)aDOMEvent type:(CPString)aType
|
||||
{
|
||||
var keyCode = aType === "x" ? CPKeyCodes.X : (aType === "c" ? CPKeyCodes.C : CPKeyCodes.V),
|
||||
characters = aType,
|
||||
timestamp = [CPEvent currentTimestamp], // fake event, might as well use current timestamp
|
||||
windowNumber = [[CPApp keyWindow] windowNumber],
|
||||
modifierFlags = CPPlatformActionKeyMask,
|
||||
location = [_lastKeyDownEvent locationInWindow],
|
||||
anEvent = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
|
||||
timestamp:timestamp windowNumber:windowNumber context:nil
|
||||
characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode];
|
||||
|
||||
anEvent._data1 = @{ "simulated": YES };
|
||||
anEvent._DOMEvent = aDOMEvent;
|
||||
|
||||
return anEvent;
|
||||
}
|
||||
|
||||
- (void)beforeCopyEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if ([self _mayRequireDOMPasteboardElementHack:aDOMEvent flags:CPPlatformActionKeyMask] && !_ignoreNativeCopyOrCutEvent)
|
||||
{
|
||||
// we have to send out a fake copy or cut event so that we can force the copy/cut mechanisms to take place
|
||||
var anEvent = [self _fakeClipboardEvent:aDOMEvent type:(aDOMEvent.type === "beforecut" ? "x" : "c")];
|
||||
|
||||
[CPApp sendEvent:anEvent];
|
||||
|
||||
// Once we've sent it, we can load the copy information into the pasteboard hack.
|
||||
[self _primeDOMPasteboardElement];
|
||||
|
||||
//then we have to IGNORE the real keyboard event to prevent a double copy
|
||||
//safari also sends the beforecopy event twice, so we additionally check here and prevent two events
|
||||
_ignoreNativeCopyOrCutEvent = YES;
|
||||
}
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (boolean)beforePasteEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
// Set up to capture the paste in a temporary input field. We'll send the event after capture.
|
||||
if ([self _mayRequireDOMPasteboardElementHack:aDOMEvent flags:CPPlatformActionKeyMask])
|
||||
{
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
|
||||
_ignoreNativePastePreparation = YES;
|
||||
}
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
/*
|
||||
Return true if the event may be a copy and paste event, but the target is not an input or text area.
|
||||
*/
|
||||
- (void)_mayRequireDOMPasteboardElementHack:(DOMEvent)aDOMEvent flags:(unsigned)modifierFlags
|
||||
{
|
||||
return !hasEditableTarget(aDOMEvent) && (modifierFlags & CPPlatformActionKeyMask);
|
||||
}
|
||||
|
||||
- (void)_primeDOMPasteboardElement
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
types = [pasteboard types];
|
||||
|
||||
if (types.length)
|
||||
{
|
||||
if ([types indexOfObjectIdenticalTo:CPStringPboardType] !== CPNotFound)
|
||||
_DOMPasteboardElement.value = [pasteboard stringForType:CPStringPboardType];
|
||||
else
|
||||
_DOMPasteboardElement.value = [pasteboard _generateStateUID];
|
||||
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
|
||||
window.setNativeTimeout(function() { [self _clearDOMPasteboardElement]; }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_checkDOMPasteboardElement
|
||||
{
|
||||
if (supportsNativeCopyAndPaste)
|
||||
{
|
||||
[self _clearDOMPasteboardElement];
|
||||
return;
|
||||
}
|
||||
|
||||
var value = _DOMPasteboardElement.value;
|
||||
|
||||
if ([value length])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if ([pasteboard _stateUID] != value)
|
||||
{
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:self];
|
||||
[pasteboard setString:value forType:CPStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
[self _clearDOMPasteboardElement];
|
||||
|
||||
[CPApp sendEvent:[self _fakeClipboardEvent:nil type:@"v"]];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)_clearDOMPasteboardElement
|
||||
{
|
||||
_DOMPasteboardElement.value = "";
|
||||
_DOMPasteboardElement.blur();
|
||||
}
|
||||
|
||||
- (boolean)nativeBeforeClipboardEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
// Our job here is to return "false" if the given clipboard operation should be enabled even in a situation where
|
||||
// the browser might normally grey the option out.
|
||||
|
||||
// Allow these fields to do their own thing.
|
||||
if (hasEditableTarget(aDOMEvent))
|
||||
return true;
|
||||
|
||||
var returnValue = YES;
|
||||
|
||||
switch (aDOMEvent.type)
|
||||
{
|
||||
case "beforecopy":
|
||||
returnValue = !([CPApp targetForAction:@selector(copy:)]);
|
||||
break;
|
||||
case "beforecut":
|
||||
returnValue = !([CPApp targetForAction:@selector(cut:)]);
|
||||
break;
|
||||
case "beforepaste":
|
||||
returnValue = !([CPApp targetForAction:@selector(paste:)]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!returnValue)
|
||||
_CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
- (boolean)nativePasteEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
// This shouldn't happen.
|
||||
if (!supportsNativeCopyAndPaste)
|
||||
return;
|
||||
|
||||
var value;
|
||||
if (aDOMEvent.clipboardData && aDOMEvent.clipboardData.setData)
|
||||
value = aDOMEvent.clipboardData.getData('text/plain');
|
||||
else
|
||||
value = _DOMWindow.clipboardData.getData("Text");
|
||||
|
||||
if ([value length])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if ([pasteboard _stateUID] != value)
|
||||
{
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:self];
|
||||
[pasteboard setString:value forType:CPStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
var anEvent = [self _fakeClipboardEvent:aDOMEvent type:"v"],
|
||||
platformWindow = [[anEvent window] platformWindow];
|
||||
|
||||
SUPPRESS_CAPPUCCINO_PASTE_FOR_EVENT(anEvent);
|
||||
|
||||
// By default we'll stop the native handling of the event since we're handling it ourselves. However, we need to
|
||||
// stop it before we send the event so that the event can overrule our choice. CPTextField for instance wants the
|
||||
// default handling when focused (which is to insert into the field).
|
||||
[platformWindow _propagateCurrentDOMEvent:NO]
|
||||
|
||||
[CPApp sendEvent:anEvent];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
if (![platformWindow _willPropagateCurrentDOMEvent])
|
||||
_CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
- (boolean)nativeCopyOrCutEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
// This shouldn't happen.
|
||||
if (!supportsNativeCopyAndPaste)
|
||||
return;
|
||||
|
||||
var anEvent = [self _fakeClipboardEvent:aDOMEvent type:(aDOMEvent.type.indexOf("cut") != CPNotFound ? "x" : "c")],
|
||||
platformWindow = [[anEvent window] platformWindow];
|
||||
|
||||
SUPPRESS_CAPPUCCINO_CUT_FOR_EVENT(anEvent);
|
||||
|
||||
[platformWindow _propagateCurrentDOMEvent:NO]
|
||||
|
||||
// Let the app react through copy: and cut: actions.
|
||||
[CPApp sendEvent:anEvent];
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
// If StopDOMEventPropagation was set to NO, we don't try to write to the system clipboard. The control that did this
|
||||
// wants to use the default copy/cut functionality.
|
||||
if (![platformWindow _willPropagateCurrentDOMEvent])
|
||||
{
|
||||
// Now the app should have written whatever it wants to have copied to the Cappuccino clipboard. So now we need
|
||||
// to write it to the system board.
|
||||
_CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if ([[pasteboard types] containsObject:CPStringPboardType])
|
||||
{
|
||||
var stringValue = [pasteboard stringForType:CPStringPboardType];
|
||||
|
||||
if (aDOMEvent.clipboardData && aDOMEvent.clipboardData.setData)
|
||||
aDOMEvent.clipboardData.setData('text/plain', stringValue);
|
||||
else
|
||||
_DOMWindow.clipboardData.setData('Text', stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
return ![platformWindow _willPropagateCurrentDOMEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -53,7 +53,7 @@ var DOMFixedWidthSpanElement = nil,
|
||||
style = DOMFlexibleWidthSpanElement.style;
|
||||
style.position = "absolute";
|
||||
style.left = "-100000px";
|
||||
style.zIndex = -100000;
|
||||
style.zIndex = -10000;
|
||||
style.visibility = "visible";
|
||||
style.padding = "0px";
|
||||
style.margin = "0px";
|
||||
@@ -99,7 +99,7 @@ var DOMFixedWidthSpanElement = nil,
|
||||
DOMMetricsDivElement.className = "cpdontremove";
|
||||
style = DOMMetricsDivElement.style;
|
||||
style.position = "absolute";
|
||||
style.left = "-10000px";
|
||||
style.left = "-100000px";
|
||||
style.zIndex = -10000;
|
||||
style.width = "100000px";
|
||||
style.whiteSpace = "nowrap";
|
||||
|
||||
@@ -107,27 +107,29 @@
|
||||
* P: undefined 80 undefined
|
||||
*/
|
||||
|
||||
@import <Foundation/CPNotificationCenter.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
@import <Foundation/CPRunLoop.j>
|
||||
@import <Foundation/CPSet.j>
|
||||
@import <Foundation/CPTimer.j>
|
||||
|
||||
@import "CPCursor.j"
|
||||
@import "CPApplication_Constants.j"
|
||||
@import "CPCompatibility.j"
|
||||
@import "CPCursor.j"
|
||||
@import "CPDOMWindowLayer.j"
|
||||
@import "CPDragServer_Constants.j"
|
||||
@import "CPEvent.j"
|
||||
@import "CPPasteboard.j"
|
||||
@import "CPPlatform.j"
|
||||
@import "CPPlatformWindow.j"
|
||||
@import "CPPlatformPasteboard.j"
|
||||
@import "CPPlatformWindow+DOMKeys.j"
|
||||
@import "CPPlatformWindow.j"
|
||||
@import "CPText.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
|
||||
@class CPDragServer
|
||||
@class _CPToolTip
|
||||
|
||||
@global CPApp
|
||||
@global _CPRunModalLoop
|
||||
|
||||
// List of all open native windows
|
||||
@@ -135,7 +137,6 @@ var PlatformWindows = [CPSet set];
|
||||
|
||||
// Define up here so compressor knows about them.
|
||||
var CPDOMEventGetClickCount,
|
||||
CPDOMEventStop,
|
||||
StopDOMEventPropagation,
|
||||
StopContextMenuDOMEventPropagation;
|
||||
|
||||
@@ -196,11 +197,14 @@ var ModifierKeyCodes = [
|
||||
CPKeyCodes.ALT,
|
||||
CPKeyCodes.SHIFT
|
||||
],
|
||||
|
||||
supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
var resizeTimer = nil;
|
||||
var PreventScroll = true;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
@implementation CPPlatformWindow (DOM)
|
||||
|
||||
- (id)_init
|
||||
@@ -215,6 +219,8 @@ var resizeTimer = nil;
|
||||
_windowLevels = [];
|
||||
_windowLayers = @{};
|
||||
|
||||
_platformPasteboard = [CPPlatformPasteboard new];
|
||||
|
||||
[self registerDOMWindow];
|
||||
[self updateFromNativeContentRect];
|
||||
|
||||
@@ -301,19 +307,6 @@ var resizeTimer = nil;
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMFocusElement);
|
||||
|
||||
// Create Native Pasteboard handler.
|
||||
_DOMPasteboardElement = theDocument.createElement("textarea");
|
||||
|
||||
_DOMPasteboardElement.style.position = "absolute";
|
||||
_DOMPasteboardElement.style.top = "-10000px";
|
||||
_DOMPasteboardElement.style.zIndex = "999";
|
||||
_DOMPasteboardElement.className = "cpdontremove";
|
||||
|
||||
_DOMBodyElement.appendChild(_DOMPasteboardElement);
|
||||
|
||||
// Make sure the pastboard element is blurred.
|
||||
_DOMPasteboardElement.blur();
|
||||
|
||||
// Create a full screen div to protect against iframes and other elements
|
||||
// from consuming events during tracking
|
||||
// FIXME: multiple windows
|
||||
@@ -333,8 +326,8 @@ var resizeTimer = nil;
|
||||
_DOMScrollingElement.style.position = "absolute";
|
||||
_DOMScrollingElement.style.visibility = "hidden";
|
||||
_DOMScrollingElement.style.zIndex = @"999";
|
||||
_DOMScrollingElement.style.height = "60px";
|
||||
_DOMScrollingElement.style.width = "60px";
|
||||
_DOMScrollingElement.style.height = "500px";
|
||||
_DOMScrollingElement.style.width = "500px";
|
||||
_DOMScrollingElement.style.overflow = "scroll";
|
||||
//_DOMScrollingElement.style.backgroundColor = "rgba(0,0,0,1.0)"; // debug help.
|
||||
_DOMScrollingElement.style.opacity = "0";
|
||||
@@ -343,8 +336,8 @@ var resizeTimer = nil;
|
||||
_DOMBodyElement.appendChild(_DOMScrollingElement);
|
||||
|
||||
var _DOMInnerScrollingElement = theDocument.createElement("div");
|
||||
_DOMInnerScrollingElement.style.width = "400px";
|
||||
_DOMInnerScrollingElement.style.height = "400px";
|
||||
_DOMInnerScrollingElement.style.width = "5000px";
|
||||
_DOMInnerScrollingElement.style.height = "5000px";
|
||||
_DOMScrollingElement.appendChild(_DOMInnerScrollingElement);
|
||||
|
||||
// Set an initial scroll offset
|
||||
@@ -367,6 +360,8 @@ var resizeTimer = nil;
|
||||
[self createDOMElements];
|
||||
[self _addLayers];
|
||||
|
||||
[_platformPasteboard setDOMWindow:_DOMWindow];
|
||||
|
||||
var theClass = [self class],
|
||||
|
||||
dragEventImplementation = class_getMethodImplementation(theClass, @selector(dragEvent:)),
|
||||
@@ -376,17 +371,9 @@ var resizeTimer = nil;
|
||||
resizeEventImplementation = class_getMethodImplementation(theClass, resizeEventSelector),
|
||||
resizeEventCallback = function (anEvent) { resizeEventImplementation(self, nil, anEvent); },
|
||||
|
||||
copyEventSelector = @selector(copyEvent:),
|
||||
copyEventImplementation = class_getMethodImplementation(theClass, copyEventSelector),
|
||||
copyEventCallback = function (anEvent) {copyEventImplementation(self, nil, anEvent); },
|
||||
|
||||
pasteEventSelector = @selector(pasteEvent:),
|
||||
pasteEventImplementation = class_getMethodImplementation(theClass, pasteEventSelector),
|
||||
pasteEventCallback = function (anEvent) {pasteEventImplementation(self, nil, anEvent); },
|
||||
|
||||
keyEventSelector = @selector(keyEvent:),
|
||||
keyEventImplementation = class_getMethodImplementation(theClass, keyEventSelector),
|
||||
keyEventCallback = function (anEvent) { keyEventImplementation(self, nil, anEvent); },
|
||||
keyEventCallback = function (anEvent) { return keyEventImplementation(self, nil, anEvent); },
|
||||
|
||||
mouseEventSelector = @selector(mouseEvent:),
|
||||
mouseEventImplementation = class_getMethodImplementation(theClass, mouseEventSelector),
|
||||
@@ -421,10 +408,6 @@ var resizeTimer = nil;
|
||||
theDocument.addEventListener("mousemove", mouseEventCallback, NO);
|
||||
theDocument.addEventListener("contextmenu", contextMenuEventCallback, NO);
|
||||
|
||||
theDocument.addEventListener("beforecopy", copyEventCallback, NO);
|
||||
theDocument.addEventListener("beforecut", copyEventCallback, NO);
|
||||
theDocument.addEventListener("beforepaste", pasteEventCallback, NO);
|
||||
|
||||
theDocument.addEventListener("keyup", keyEventCallback, NO);
|
||||
theDocument.addEventListener("keydown", keyEventCallback, NO);
|
||||
theDocument.addEventListener("keypress", keyEventCallback, NO);
|
||||
@@ -454,10 +437,6 @@ var resizeTimer = nil;
|
||||
theDocument.removeEventListener("keydown", keyEventCallback, NO);
|
||||
theDocument.removeEventListener("keypress", keyEventCallback, NO);
|
||||
|
||||
theDocument.removeEventListener("beforecopy", copyEventCallback, NO);
|
||||
theDocument.removeEventListener("beforecut", copyEventCallback, NO);
|
||||
theDocument.removeEventListener("beforepaste", pasteEventCallback, NO);
|
||||
|
||||
theDocument.removeEventListener("touchstart", touchEventCallback, NO);
|
||||
theDocument.removeEventListener("touchend", touchEventCallback, NO);
|
||||
theDocument.removeEventListener("touchmove", touchEventCallback, NO);
|
||||
@@ -473,6 +452,8 @@ var resizeTimer = nil;
|
||||
|
||||
[PlatformWindows removeObject:self];
|
||||
|
||||
[_platformPasteboard setDOMWindow:nil];
|
||||
|
||||
self._DOMWindow = nil;
|
||||
}, NO);
|
||||
}
|
||||
@@ -494,7 +475,7 @@ var resizeTimer = nil;
|
||||
theDocument.onmousewheel = scrollEventCallback;
|
||||
|
||||
_DOMBodyElement.ondrag = function () { return NO; };
|
||||
_DOMBodyElement.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; };
|
||||
_DOMBodyElement.onselectstart = function () { return _DOMWindow.event.srcElement === _platformPasteboard._DOMPasteboardElement; };
|
||||
|
||||
_DOMWindow.attachEvent("onunload", function()
|
||||
{
|
||||
@@ -523,6 +504,8 @@ var resizeTimer = nil;
|
||||
|
||||
[PlatformWindows removeObject:self];
|
||||
|
||||
[_platformPasteboard setDOMWindow:nil];
|
||||
|
||||
self._DOMWindow = nil;
|
||||
}, NO);
|
||||
}
|
||||
@@ -709,9 +692,7 @@ var resizeTimer = nil;
|
||||
StopDOMEventPropagation = NO;
|
||||
}
|
||||
|
||||
var isNativePasteEvent = NO,
|
||||
isNativeCopyOrCutEvent = NO,
|
||||
overrideCharacters = nil,
|
||||
var overrideCharacters = nil,
|
||||
charactersIgnoringModifiers = @"";
|
||||
|
||||
switch (aDOMEvent.type)
|
||||
@@ -753,31 +734,6 @@ var resizeTimer = nil;
|
||||
//we are simply going to skip all keypress events that use cmd/ctrl key
|
||||
//this lets us be consistent in all browsers and send on the keydown
|
||||
//which means we can cancel the event early enough, but only if sendEvent needs to
|
||||
|
||||
var eligibleForCopyPaste = [self _validateCopyCutOrPasteEvent:aDOMEvent flags:modifierFlags];
|
||||
|
||||
// If this could be a native PASTE event, then we need to further examine it before
|
||||
// sending a CPEvent. Select our element to see if anything gets pasted in it.
|
||||
if (characters === "v" && eligibleForCopyPaste)
|
||||
{
|
||||
if (!_ignoreNativePastePreparation)
|
||||
{
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
}
|
||||
|
||||
isNativePasteEvent = YES;
|
||||
}
|
||||
|
||||
// However, of this could be a native COPY event, we need to let the normal event-process take place so it
|
||||
// can capture our internal Cappuccino pasteboard.
|
||||
else if ((characters == "c" || characters == "x") && eligibleForCopyPaste)
|
||||
{
|
||||
isNativeCopyOrCutEvent = YES;
|
||||
|
||||
if (_ignoreNativeCopyOrCutEvent)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (CPKeyCodes.firesKeyPressEvent(_keyCode, _lastKey, aDOMEvent.shiftKey, aDOMEvent.ctrlKey, aDOMEvent.altKey))
|
||||
{
|
||||
@@ -823,12 +779,6 @@ var resizeTimer = nil;
|
||||
timestamp:timestamp windowNumber:windowNumber context:nil
|
||||
characters:characters charactersIgnoringModifiers:charactersIgnoringModifiers isARepeat:isARepeat keyCode:charCode];
|
||||
|
||||
if (isNativePasteEvent)
|
||||
{
|
||||
_pasteboardKeyDownEvent = event;
|
||||
window.setNativeTimeout(function () { [self _checkPasteboardElement] }, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "keyup":
|
||||
@@ -838,8 +788,6 @@ var resizeTimer = nil;
|
||||
_keyCode = -1;
|
||||
_lastKey = -1;
|
||||
_charCodes[keyCode] = nil;
|
||||
_ignoreNativeCopyOrCutEvent = NO;
|
||||
_ignoreNativePastePreparation = NO;
|
||||
|
||||
// check for caps lock state
|
||||
if (keyCode === CPKeyCodes.CAPS_LOCK)
|
||||
@@ -864,131 +812,43 @@ var resizeTimer = nil;
|
||||
event = [CPEvent keyEventWithType:CPKeyUp location:location modifierFlags:modifierFlags
|
||||
timestamp: timestamp windowNumber:windowNumber context:nil
|
||||
characters:characters charactersIgnoringModifiers:charactersIgnoringModifiers isARepeat:NO keyCode:keyCode];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (event && !isNativePasteEvent)
|
||||
{
|
||||
if (event)
|
||||
event._DOMEvent = aDOMEvent;
|
||||
|
||||
[_platformPasteboard windowMaySendKeyEvent:event];
|
||||
|
||||
if (event && ![_platformPasteboard windowShouldSuppressKeyEvent])
|
||||
{
|
||||
[CPApp sendEvent:event];
|
||||
|
||||
if (isNativeCopyOrCutEvent)
|
||||
{
|
||||
// If this is a native copy event, then check if the pasteboard has anything in it.
|
||||
[self _primePasteboardElement];
|
||||
}
|
||||
[_platformPasteboard windowDidSendKeyEvent:event];
|
||||
}
|
||||
|
||||
if (StopDOMEventPropagation)
|
||||
CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)copyEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if ([self _validateCopyCutOrPasteEvent:aDOMEvent flags:CPPlatformActionKeyMask] && !_ignoreNativeCopyOrCutEvent)
|
||||
var didStop = NO;
|
||||
// Platform pasteboard can overrule the decision to stop propagation either way, or it might have no opinion.
|
||||
if ([_platformPasteboard windowShouldStopPropagation] || (StopDOMEventPropagation && ![_platformPasteboard windowShouldNotStopPropagation]))
|
||||
{
|
||||
// we have to send out a fake copy or cut event so that we can force the copy/cut mechanisms to take place
|
||||
var cut = aDOMEvent.type === "beforecut",
|
||||
keyCode = cut ? CPKeyCodes.X : CPKeyCodes.C,
|
||||
characters = cut ? "x" : "c",
|
||||
timestamp = [CPEvent currentTimestamp], // fake event, might as well use current timestamp
|
||||
windowNumber = [[CPApp keyWindow] windowNumber],
|
||||
modifierFlags = CPPlatformActionKeyMask,
|
||||
location = _lastMouseEventLocation || CGPointMakeZero(),
|
||||
event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
|
||||
timestamp:timestamp windowNumber:windowNumber context:nil
|
||||
characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode];
|
||||
|
||||
event._DOMEvent = aDOMEvent;
|
||||
[CPApp sendEvent:event];
|
||||
|
||||
[self _primePasteboardElement];
|
||||
|
||||
//then we have to IGNORE the real keyboard event to prevent a double copy
|
||||
//safari also sends the beforecopy event twice, so we additionally check here and prevent two events
|
||||
_ignoreNativeCopyOrCutEvent = YES;
|
||||
didStop = YES;
|
||||
_CPDOMEventStop(aDOMEvent, self);
|
||||
}
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)pasteEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if ([self _validateCopyCutOrPasteEvent:aDOMEvent flags:CPPlatformActionKeyMask])
|
||||
{
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
_DOMPasteboardElement.value = "";
|
||||
_ignoreNativePastePreparation = YES;
|
||||
}
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)_validateCopyCutOrPasteEvent:(DOMEvent)aDOMEvent flags:(unsigned)modifierFlags
|
||||
{
|
||||
return (
|
||||
((aDOMEvent.target || aDOMEvent.srcElement).nodeName.toUpperCase() !== "INPUT" &&
|
||||
(aDOMEvent.target || aDOMEvent.srcElement).nodeName.toUpperCase() !== "TEXTAREA"
|
||||
) || aDOMEvent.target === _DOMPasteboardElement
|
||||
) &&
|
||||
(modifierFlags & CPPlatformActionKeyMask);
|
||||
}
|
||||
|
||||
- (void)_primePasteboardElement
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
types = [pasteboard types];
|
||||
|
||||
if (types.length)
|
||||
{
|
||||
if ([types indexOfObjectIdenticalTo:CPStringPboardType] != CPNotFound)
|
||||
_DOMPasteboardElement.value = [pasteboard stringForType:CPStringPboardType];
|
||||
else
|
||||
_DOMPasteboardElement.value = [pasteboard _generateStateUID];
|
||||
|
||||
_DOMPasteboardElement.focus();
|
||||
_DOMPasteboardElement.select();
|
||||
|
||||
window.setNativeTimeout(function() { [self _clearPasteboardElement]; }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_checkPasteboardElement
|
||||
{
|
||||
var value = _DOMPasteboardElement.value;
|
||||
|
||||
if ([value length])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
if ([pasteboard _stateUID] != value)
|
||||
{
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:self];
|
||||
[pasteboard setString:value forType:CPStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
[self _clearPasteboardElement];
|
||||
|
||||
[CPApp sendEvent:_pasteboardKeyDownEvent];
|
||||
|
||||
_pasteboardKeyDownEvent = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
- (void)_clearPasteboardElement
|
||||
{
|
||||
_DOMPasteboardElement.value = "";
|
||||
_DOMPasteboardElement.blur();
|
||||
return !didStop;
|
||||
}
|
||||
|
||||
- (void)scrollEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if (PreventScroll)
|
||||
{
|
||||
PreventScroll = false;
|
||||
aDOMEvent.preventDefault();
|
||||
}
|
||||
|
||||
if (_hideDOMScrollingElementTimeout)
|
||||
{
|
||||
clearTimeout(_hideDOMScrollingElementTimeout);
|
||||
@@ -999,7 +859,6 @@ var resizeTimer = nil;
|
||||
aDOMEvent = window.event;
|
||||
|
||||
var location = nil;
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15))
|
||||
{
|
||||
var x = aDOMEvent._offsetX || 0.0,
|
||||
@@ -1060,7 +919,7 @@ var resizeTimer = nil;
|
||||
{
|
||||
// Find the scroll delta
|
||||
var deltaX = _DOMScrollingElement.scrollLeft - 150,
|
||||
deltaY = (_DOMScrollingElement.scrollTop - 150) || (aDOMEvent.deltaY===undefined?0: aDOMEvent.deltaY);
|
||||
deltaY = (_DOMScrollingElement.scrollTop - 150) || (aDOMEvent.deltaY === undefined ? 0 : aDOMEvent.deltaY);
|
||||
|
||||
// If we scroll super with momentum,
|
||||
// there are so many events going off that
|
||||
@@ -1081,7 +940,7 @@ var resizeTimer = nil;
|
||||
|
||||
// We set StopDOMEventPropagation = NO on line 1008
|
||||
//if (StopDOMEventPropagation)
|
||||
// CPDOMEventStop(aDOMEvent, self);
|
||||
// _CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
// Reset the DOM elements scroll offset
|
||||
_DOMScrollingElement.scrollLeft = 150;
|
||||
@@ -1097,6 +956,7 @@ var resizeTimer = nil;
|
||||
// can receive events.
|
||||
_hideDOMScrollingElementTimeout = setTimeout(function()
|
||||
{
|
||||
PreventScroll = true;
|
||||
_DOMScrollingElement.style.visibility = "hidden";
|
||||
}, 300);
|
||||
}
|
||||
@@ -1142,6 +1002,10 @@ var resizeTimer = nil;
|
||||
[windows[windowCount] resizeWithOldPlatformWindowSize:oldSize];
|
||||
}
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidChangeScreenParametersNotification
|
||||
object:CPApp
|
||||
userInfo:nil];
|
||||
|
||||
//window.liveResize = NO;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
@@ -1322,8 +1186,12 @@ var resizeTimer = nil;
|
||||
[CPApp sendEvent:event];
|
||||
}
|
||||
|
||||
var didStop = NO;
|
||||
if (StopDOMEventPropagation && (!supportsNativeDragAndDrop || type !== "mousedown" && !isDragging))
|
||||
CPDOMEventStop(aDOMEvent, self);
|
||||
{
|
||||
didStop = YES;
|
||||
_CPDOMEventStop(aDOMEvent, self);
|
||||
}
|
||||
|
||||
// If there are any tracking event listeners (listening for CPLeftMouseDraggedMask)
|
||||
// then show the event guard so we don't lose events to iframes
|
||||
@@ -1345,12 +1213,13 @@ var resizeTimer = nil;
|
||||
_DOMEventGuard.style.display = hasTrackingEventListener ? "" : "none";
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
return !didStop;
|
||||
}
|
||||
|
||||
- (void)contextMenuEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if (StopContextMenuDOMEventPropagation)
|
||||
CPDOMEventStop(aDOMEvent, self);
|
||||
_CPDOMEventStop(aDOMEvent, self);
|
||||
|
||||
return !StopContextMenuDOMEventPropagation;
|
||||
}
|
||||
@@ -1490,7 +1359,8 @@ var resizeTimer = nil;
|
||||
// relative to it or the furthest parent.
|
||||
var children = [aWindow childWindows],
|
||||
count = [children count],
|
||||
parent = aWindow;
|
||||
parent = aWindow,
|
||||
parentLevel = [parent level];
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
@@ -1501,6 +1371,10 @@ var resizeTimer = nil;
|
||||
if (!childWasVisible && ![child _hasBeenOrderedIn])
|
||||
continue;
|
||||
|
||||
// If a user moved level of the child window, we should respect that
|
||||
if ([child level] !== parentLevel)
|
||||
continue;
|
||||
|
||||
var ordering = [child _childOrdering];
|
||||
|
||||
if ((ordering === CPWindowAbove && furthestParent._index > parent._index) ||
|
||||
@@ -1641,6 +1515,44 @@ var resizeTimer = nil;
|
||||
return theWindow;
|
||||
}
|
||||
|
||||
/*! @ignore Return the selected text in the DOM window if known. */
|
||||
- (CPString)_selectedText
|
||||
{
|
||||
if (_DOMWindow.getSelection)
|
||||
return "" + _DOMWindow.getSelection();
|
||||
else if (_DOMWindow.document.getSelection)
|
||||
return "" + _DOMWindow.document.getSelection();
|
||||
else if (_DOMWindow.selection)
|
||||
return "" + _DOMWindow.selection.createRange().text;
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the text selection range to the given range within the given element, which must be a child of
|
||||
this DOM window.
|
||||
*/
|
||||
- (void)setSelectedRange:(CPRange)aRange inElement:(DOMElement)anElement
|
||||
{
|
||||
if (_DOMWindow.getSelection())
|
||||
{
|
||||
var domRange = _DOMWindow.document.createRange();
|
||||
domRange.setStart(anElement.childNodes[0], aRange.location);
|
||||
domRange.setEnd(anElement.childNodes[0], CPMaxRange(aRange));
|
||||
_DOMWindow.getSelection().removeAllRanges();
|
||||
_DOMWindow.getSelection().addRange(domRange);
|
||||
}
|
||||
else if (_DOMWindow.document.selection)
|
||||
{
|
||||
var domRange = _DOMWindow.document.body.createTextRange();
|
||||
domRange.moveToElementText(anElement);
|
||||
domRange.collapse(true);
|
||||
domRange.moveStart('character', aRange.location);
|
||||
domRange.moveEnd('character', aRange.length);
|
||||
domRange.select();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
When using command (mac) or control (windows), keys are propagated to the browser by default.
|
||||
To prevent a character key from propagating (to prevent its default action, and instead use it
|
||||
@@ -1746,24 +1658,18 @@ var CPDOMEventGetClickCount = function(aComparisonEvent, aTimestamp, aLocation)
|
||||
ABS(comparisonLocation.y - aLocation.y) < CLICK_SPACE_DELTA) ? [aComparisonEvent clickCount] + 1 : 1;
|
||||
};
|
||||
|
||||
var CPDOMEventStop = function(aDOMEvent, aPlatformWindow)
|
||||
// Global.
|
||||
_CPDOMEventStop = function(aDOMEvent, aPlatformWindow)
|
||||
{
|
||||
// IE Model
|
||||
aDOMEvent.cancelBubble = true;
|
||||
aDOMEvent.returnValue = false;
|
||||
|
||||
// W3C Model
|
||||
if (aDOMEvent.preventDefault)
|
||||
if (aDOMEvent.preventDefault) // W3C Model
|
||||
aDOMEvent.preventDefault();
|
||||
else // IE Model
|
||||
aDOMEvent.returnValue = false;
|
||||
|
||||
if (aDOMEvent.stopPropagation)
|
||||
if (aDOMEvent.stopPropagation) // W3C Model
|
||||
aDOMEvent.stopPropagation();
|
||||
|
||||
if (aDOMEvent.type === CPDOMEventMouseDown)
|
||||
{
|
||||
aPlatformWindow._DOMFocusElement.focus();
|
||||
aPlatformWindow._DOMFocusElement.blur();
|
||||
}
|
||||
else // IE Model
|
||||
aDOMEvent.cancelBubble = true;
|
||||
};
|
||||
|
||||
function CPWindowObjectList()
|
||||
|
||||
@@ -375,7 +375,7 @@ var themedButtonValues = nil,
|
||||
"themedMenuItemStandardView",
|
||||
"themedMenuItemMenuBarView",
|
||||
"themedToolbarView",
|
||||
"themedBordelessBridgeWindowView",
|
||||
"themedBorderlessBridgeWindowView",
|
||||
"themedWindowView",
|
||||
"themedBrowser",
|
||||
"themedRuleEditor",
|
||||
@@ -502,29 +502,29 @@ var themedButtonValues = nil,
|
||||
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], CPThemeStateBordered],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateBordered],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"text-shadow-offset", CGSizeMake(0.0, 1.0), CPThemeStateBordered],
|
||||
[@"line-break-mode", CPLineBreakByTruncatingTail],
|
||||
[@"bezel-color", bezelColor, CPThemeStateBordered],
|
||||
[@"bezel-color", highlightedBezelColor, CPThemeStateBordered | CPThemeStateHighlighted],
|
||||
[@"bezel-color", disabledBezelColor, CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color", defaultBezelColor, CPThemeStateBordered | CPThemeStateDefault],
|
||||
[@"bezel-color", defaultHighlightedBezelColor, CPThemeStateBordered | CPThemeStateHighlighted | CPThemeStateDefault],
|
||||
[@"bezel-color", defaultDisabledBezelColor, CPThemeStateBordered | CPThemeStateDefault | CPThemeStateDisabled],
|
||||
[@"bezel-color", highlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
[@"bezel-color", disabledBezelColor, [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"bezel-color", defaultBezelColor, [CPThemeStateBordered, CPThemeStateDefault]],
|
||||
[@"bezel-color", defaultHighlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted, CPThemeStateDefault]],
|
||||
[@"bezel-color", defaultDisabledBezelColor, [CPThemeStateBordered, CPThemeStateDefault, CPThemeStateDisabled]],
|
||||
[@"content-inset", CGInsetMake(0.0, 7.0, 0.0, 7.0), CPThemeStateBordered],
|
||||
|
||||
[@"bezel-color", roundedBezelColor, CPThemeStateBordered | CPButtonStateBezelStyleRounded],
|
||||
[@"bezel-color", roundedHighlightedBezelColor, CPThemeStateBordered | CPThemeStateHighlighted | CPButtonStateBezelStyleRounded],
|
||||
[@"bezel-color", roundedDisabledBezelColor, CPThemeStateBordered | CPThemeStateDisabled | CPButtonStateBezelStyleRounded],
|
||||
[@"bezel-color", defaultRoundedBezelColor, CPThemeStateBordered | CPThemeStateDefault | CPButtonStateBezelStyleRounded],
|
||||
[@"bezel-color", defaultRoundedHighlightedBezelColor, CPThemeStateBordered | CPThemeStateHighlighted | CPThemeStateDefault | CPButtonStateBezelStyleRounded],
|
||||
[@"bezel-color", defaultRoundedDisabledBezelColor, CPThemeStateBordered | CPThemeStateDefault | CPThemeStateDisabled | CPButtonStateBezelStyleRounded],
|
||||
[@"content-inset", CGInsetMake(0.0, 10.0, 0.0, 10.0), CPThemeStateBordered | CPButtonStateBezelStyleRounded],
|
||||
[@"bezel-color", roundedBezelColor, [CPThemeStateBordered, CPButtonStateBezelStyleRounded]],
|
||||
[@"bezel-color", roundedHighlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted, CPButtonStateBezelStyleRounded]],
|
||||
[@"bezel-color", roundedDisabledBezelColor, [CPThemeStateBordered, CPThemeStateDisabled, CPButtonStateBezelStyleRounded]],
|
||||
[@"bezel-color", defaultRoundedBezelColor, [CPThemeStateBordered, CPThemeStateDefault, CPButtonStateBezelStyleRounded]],
|
||||
[@"bezel-color", defaultRoundedHighlightedBezelColor, [CPThemeStateBordered, CPThemeStateHighlighted, CPThemeStateDefault, CPButtonStateBezelStyleRounded]],
|
||||
[@"bezel-color", defaultRoundedDisabledBezelColor, [CPThemeStateBordered, CPThemeStateDefault, CPThemeStateDisabled, CPButtonStateBezelStyleRounded]],
|
||||
[@"content-inset", CGInsetMake(0.0, 10.0, 0.0, 10.0), [CPThemeStateBordered, CPButtonStateBezelStyleRounded]],
|
||||
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], CPThemeStateDisabled],
|
||||
|
||||
[@"text-color", defaultTextColor, CPThemeStateDefault],
|
||||
[@"text-color", defaultDisabledTextColor, CPThemeStateDefault | CPThemeStateDisabled],
|
||||
[@"text-color", defaultDisabledTextColor, [CPThemeStateDefault, CPThemeStateDisabled]],
|
||||
|
||||
[@"min-size", CGSizeMake(0.0, 24.0)],
|
||||
[@"max-size", CGSizeMake(-1.0, 24.0)],
|
||||
@@ -588,15 +588,15 @@ var themedButtonValues = nil,
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", color, CPThemeStateBordered],
|
||||
[@"bezel-color", disabledColor, CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color", disabledColor, [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
|
||||
[@"content-inset", CGInsetMake(0, 21.0 + 5.0, 0, 5.0), CPThemeStateBordered],
|
||||
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
|
||||
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:0.6], CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:0.6], [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
|
||||
[@"min-size", CGSizeMake(32.0, 24.0)],
|
||||
[@"max-size", CGSizeMake(-1.0, 24.0)]
|
||||
@@ -631,16 +631,16 @@ var themedButtonValues = nil,
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", color, CPPopUpButtonStatePullsDown | CPThemeStateBordered],
|
||||
[@"bezel-color", disabledColor, CPPopUpButtonStatePullsDown | CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color", color, [CPPopUpButtonStatePullsDown, CPThemeStateBordered]],
|
||||
[@"bezel-color", disabledColor, [CPPopUpButtonStatePullsDown, CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
|
||||
[@"content-inset", CGInsetMake(0, 27.0 + 5.0, 0, 5.0), CPThemeStateBordered],
|
||||
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
|
||||
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:0.6], CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:0.6], [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
|
||||
[@"min-size", CGSizeMake(32.0, 24.0)],
|
||||
[@"max-size", CGSizeMake(-1.0, 24.0)]
|
||||
@@ -761,35 +761,35 @@ var themedButtonValues = nil,
|
||||
[@"track-inset", CGInsetMake(2.0, 0.0, 2.0, 0.0), CPThemeStateVertical],
|
||||
[@"track-border-overlay", 12.0, CPThemeStateVertical],
|
||||
[@"knob-slot-color", [CPNull null], CPThemeStateVertical],
|
||||
[@"knob-slot-color", trackColor, CPThemeStateVertical | CPThemeStateSelected],
|
||||
[@"knob-slot-color", trackColorLight, CPThemeStateVertical | CPThemeStateSelected | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-slot-color", trackColorDark, CPThemeStateVertical | CPThemeStateSelected | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-slot-color", trackColor, [CPThemeStateVertical, CPThemeStateSelected]],
|
||||
[@"knob-slot-color", trackColorLight, [CPThemeStateVertical, CPThemeStateSelected, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-slot-color", trackColorDark, [CPThemeStateVertical, CPThemeStateSelected, CPThemeStateScrollerKnobDark]],
|
||||
[@"knob-color", knobColor, CPThemeStateVertical],
|
||||
[@"knob-color", knobColorLight, CPThemeStateVertical | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-color", knobColorDark, CPThemeStateVertical | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-color", knobColorLight, [CPThemeStateVertical, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-color", knobColorDark, [CPThemeStateVertical, CPThemeStateScrollerKnobDark]],
|
||||
[@"increment-line-color", [CPNull null], CPThemeStateVertical],
|
||||
[@"decrement-line-color", [CPNull null], CPThemeStateVertical],
|
||||
[@"decrement-line-size", CGSizeMakeZero(), CPThemeStateVertical],
|
||||
[@"increment-line-size", CGSizeMakeZero(), CPThemeStateVertical],
|
||||
|
||||
// Legacy
|
||||
[@"scroller-width", 14.0, CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"track-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"track-border-overlay", 0.0, CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateSelected],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateSelected | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateSelected | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-color", knobColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"knob-color", knobColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-color", knobColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobDark],
|
||||
[@"increment-line-color", incrementColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"decrement-line-color", decrementColorLegacy, CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"decrement-line-size", CGSizeMake(14.0, 11.0), CPThemeStateVertical | CPThemeStateScrollViewLegacy],
|
||||
[@"increment-line-size", CGSizeMake(14.0, 11.0), CPThemeStateVertical | CPThemeStateScrollViewLegacy]
|
||||
[@"scroller-width", 14.0, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"track-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"track-border-overlay", 0.0, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateSelected]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateSelected, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateSelected, CPThemeStateScrollerKnobDark]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-color", knobColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"knob-color", knobColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-color", knobColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
|
||||
[@"increment-line-color", incrementColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"decrement-line-color", decrementColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"decrement-line-size", CGSizeMake(14.0, 11.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
|
||||
[@"increment-line-size", CGSizeMake(14.0, 11.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedVerticalScrollerValues forView:scroller];
|
||||
@@ -884,8 +884,8 @@ var themedButtonValues = nil,
|
||||
[@"track-border-overlay", 12.0],
|
||||
[@"knob-slot-color", [CPNull null]],
|
||||
[@"knob-slot-color", trackColor, CPThemeStateSelected],
|
||||
[@"knob-slot-color", trackColorLight, CPThemeStateSelected | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-slot-color", trackColorDark, CPThemeStateSelected | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-slot-color", trackColorLight, [CPThemeStateSelected, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-slot-color", trackColorDark, [CPThemeStateSelected, CPThemeStateScrollerKnobDark]],
|
||||
[@"knob-color", knobColor],
|
||||
[@"knob-color", knobColorLight, CPThemeStateScrollerKnobLight],
|
||||
[@"knob-color", knobColorDark, CPThemeStateScrollerKnobDark],
|
||||
@@ -898,12 +898,12 @@ var themedButtonValues = nil,
|
||||
[@"track-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateScrollViewLegacy],
|
||||
[@"track-border-overlay", 0.0, CPThemeStateScrollViewLegacy],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateScrollViewLegacy],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateScrollViewLegacy | CPThemeStateSelected],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-slot-color", trackColorLegacy, CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateSelected]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-slot-color", trackColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
|
||||
[@"knob-color", knobColorLegacy, CPThemeStateScrollViewLegacy],
|
||||
[@"knob-color", knobColorLegacy, CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobLight],
|
||||
[@"knob-color", knobColorLegacy, CPThemeStateScrollViewLegacy | CPThemeStateScrollerKnobDark],
|
||||
[@"knob-color", knobColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
|
||||
[@"knob-color", knobColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
|
||||
[@"increment-line-color", incrementColorLegacy, CPThemeStateScrollViewLegacy],
|
||||
[@"decrement-line-color", decrementColorLegacy, CPThemeStateScrollViewLegacy],
|
||||
[@"decrement-line-size", CGSizeMake(11.0, 14.0), CPThemeStateScrollViewLegacy],
|
||||
@@ -965,8 +965,8 @@ var themedButtonValues = nil,
|
||||
[
|
||||
[@"vertical-alignment", CPTopVerticalTextAlignment, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelColor, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelFocusedColor, CPThemeStateBezeled | CPThemeStateEditing],
|
||||
[@"bezel-color", bezelDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelFocusedColor, [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateBezeled],
|
||||
|
||||
@@ -978,30 +978,30 @@ var themedButtonValues = nil,
|
||||
[@"bezel-inset", CGInsetMakeZero(), CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(8.0, 7.0, 7.0, 8.0), CPThemeStateBezeled],
|
||||
|
||||
[@"text-color", textDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
[@"text-color", textDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
[@"text-color", placeholderColor, CPTextFieldStatePlaceholder],
|
||||
[@"text-color", placeholderColor, CPTextFieldStatePlaceholder | CPThemeStateDisabled],
|
||||
[@"text-color", placeholderColor, [CPTextFieldStatePlaceholder, CPThemeStateDisabled]],
|
||||
|
||||
[@"line-break-mode", CPLineBreakByTruncatingTail, CPThemeStateTableDataView],
|
||||
[@"vertical-alignment", CPCenterVerticalTextAlignment, CPThemeStateTableDataView],
|
||||
[@"content-inset", CGInsetMake(3.0, 3.0, 3.0, 5.0), CPThemeStateTableDataView],
|
||||
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:51.0 / 255.0 alpha:1.0], CPThemeStateTableDataView],
|
||||
[@"text-color", [CPColor whiteColor], CPThemeStateTableDataView | CPThemeStateSelectedDataView],
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateTableDataView | CPThemeStateSelectedDataView],
|
||||
[@"text-color", [CPColor blackColor], CPThemeStateTableDataView | CPThemeStateEditable],
|
||||
[@"text-color", [CPColor blackColor], CPThemeStateTableDataView | CPThemeStateSelectedDataView | CPThemeStateEditing],
|
||||
[@"text-color", [CPColor blackColor], CPThemeStateTableDataView | CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(8.0, 8.0, 7.0, 5.0), CPThemeStateTableDataView | CPThemeStateEditing],
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateTableDataView | CPThemeStateEditing],
|
||||
[@"bezel-inset", CGInsetMake(-1.0, -1.0, -1.0, -1.0), CPThemeStateTableDataView | CPThemeStateEditing],
|
||||
[@"text-color", [CPColor whiteColor], [CPThemeStateTableDataView, CPThemeStateSelectedDataView]],
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], [CPThemeStateTableDataView, CPThemeStateSelectedDataView]],
|
||||
[@"text-color", [CPColor blackColor], [CPThemeStateTableDataView, CPThemeStateEditable]],
|
||||
[@"text-color", [CPColor blackColor], [CPThemeStateTableDataView, CPThemeStateSelectedDataView, CPThemeStateEditing]],
|
||||
[@"text-color", [CPColor blackColor], [CPThemeStateTableDataView, CPThemeStateBezeled]],
|
||||
[@"content-inset", CGInsetMake(8.0, 8.0, 7.0, 5.0), [CPThemeStateTableDataView, CPThemeStateEditing]],
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], [CPThemeStateTableDataView, CPThemeStateEditing]],
|
||||
[@"bezel-inset", CGInsetMake(-1.0, -1.0, -1.0, -1.0), [CPThemeStateTableDataView, CPThemeStateEditing]],
|
||||
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:125.0 / 255.0 alpha:1.0], CPThemeStateTableDataView | CPThemeStateGroupRow],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:1.0 alpha:1.0], CPThemeStateTableDataView | CPThemeStateGroupRow | CPThemeStateSelectedDataView],
|
||||
[@"text-shadow-color", [CPColor whiteColor], CPThemeStateTableDataView | CPThemeStateGroupRow],
|
||||
[@"text-shadow-offset", CGSizeMake(0,1), CPThemeStateTableDataView | CPThemeStateGroupRow],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:0.0 alpha:0.6], CPThemeStateTableDataView | CPThemeStateGroupRow | CPThemeStateSelectedDataView],
|
||||
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], CPThemeStateTableDataView | CPThemeStateGroupRow]
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:125.0 / 255.0 alpha:1.0], [CPThemeStateTableDataView, CPThemeStateGroupRow]],
|
||||
[@"text-color", [CPColor colorWithCalibratedWhite:1.0 alpha:1.0], [CPThemeStateTableDataView, CPThemeStateGroupRow, CPThemeStateSelectedDataView]],
|
||||
[@"text-shadow-color", [CPColor whiteColor], [CPThemeStateTableDataView, CPThemeStateGroupRow]],
|
||||
[@"text-shadow-offset", CGSizeMake(0,1), [CPThemeStateTableDataView, CPThemeStateGroupRow]],
|
||||
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:0.0 alpha:0.6], [CPThemeStateTableDataView, CPThemeStateGroupRow, CPThemeStateSelectedDataView]],
|
||||
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], [CPThemeStateTableDataView, CPThemeStateGroupRow]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedTextFieldValues forView:textfield];
|
||||
@@ -1045,21 +1045,21 @@ var themedButtonValues = nil,
|
||||
// Global for reuse by subclasses
|
||||
themedRoundedTextFieldValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPTextFieldStateRounded | CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelFocusedColor, CPTextFieldStateRounded | CPThemeStateBezeled | CPThemeStateEditing],
|
||||
[@"bezel-color", bezelDisabledColor, CPTextFieldStateRounded | CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelColor, [CPTextFieldStateRounded, CPThemeStateBezeled]],
|
||||
[@"bezel-color", bezelFocusedColor, [CPTextFieldStateRounded, CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
[@"bezel-color", bezelDisabledColor, [CPTextFieldStateRounded, CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize]],
|
||||
|
||||
// The new bezel is one pixel shorter, so we add one extra empty pixel at the bottom
|
||||
// for size compatibility with an earlier version.
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0.0, 1.0, 0.0), CPTextFieldStateRounded | CPThemeStateBezeled],
|
||||
[@"content-inset", CGInsetMake(8.0, 13.0, 7.0, 14.0), CPTextFieldStateRounded | CPThemeStateBezeled],
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0.0, 1.0, 0.0), [CPTextFieldStateRounded, CPThemeStateBezeled]],
|
||||
[@"content-inset", CGInsetMake(8.0, 13.0, 7.0, 14.0), [CPTextFieldStateRounded, CPThemeStateBezeled]],
|
||||
|
||||
[@"text-color", textDisabledColor, CPTextFieldStateRounded | CPThemeStateDisabled],
|
||||
[@"text-color", placeholderColor, CPTextFieldStateRounded | CPTextFieldStatePlaceholder],
|
||||
[@"text-color", textDisabledColor, [CPTextFieldStateRounded, CPThemeStateDisabled]],
|
||||
[@"text-color", placeholderColor, [CPTextFieldStateRounded, CPTextFieldStatePlaceholder]],
|
||||
|
||||
[@"min-size", CGSizeMake(0.0, 30.0), CPTextFieldStateRounded | CPThemeStateBezeled],
|
||||
[@"max-size", CGSizeMake(-1.0, 30.0), CPTextFieldStateRounded | CPThemeStateBezeled]
|
||||
[@"min-size", CGSizeMake(0.0, 30.0), [CPTextFieldStateRounded, CPThemeStateBezeled]],
|
||||
[@"max-size", CGSizeMake(-1.0, 30.0), [CPTextFieldStateRounded, CPThemeStateBezeled]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedRoundedTextFieldValues forView:textfield];
|
||||
@@ -1097,7 +1097,7 @@ var themedButtonValues = nil,
|
||||
|
||||
+ (CPDatePicker)themedDatePicker
|
||||
{
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40,140,300,29)],
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40.0, 40.0, 170.0, 29.0)],
|
||||
|
||||
bezelColor = PatternColor(
|
||||
[
|
||||
@@ -1135,7 +1135,7 @@ var themedButtonValues = nil,
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
|
||||
[@"font", [CPFont boldSystemFontOfSize:13.0]],
|
||||
[@"text-color", [CPColor colorWithWhite:0.2 alpha:0.8]],
|
||||
@@ -1147,8 +1147,8 @@ var themedButtonValues = nil,
|
||||
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected],
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], CPThemeStateNormal | CPThemeStateDisabled],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"datepicker-textfield-bezel-color", [CPColor clearColor], [CPThemeStateNormal, CPThemeStateDisabled]],
|
||||
[@"datepicker-textfield-bezel-color", bezelColorDatePickerTextField, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
|
||||
[@"min-size-datepicker-textfield", CGSizeMake(6.0, 18.0)],
|
||||
|
||||
@@ -1166,6 +1166,7 @@ var themedButtonValues = nil,
|
||||
[@"max-size", CGSizeMake(-1.0, 29.0)]
|
||||
];
|
||||
|
||||
[datePicker setDatePickerStyle:CPTextFieldDatePickerStyle];
|
||||
[self registerThemeValues:themeValues forView:datePicker];
|
||||
|
||||
return datePicker;
|
||||
@@ -1173,7 +1174,7 @@ var themedButtonValues = nil,
|
||||
|
||||
+ (CPDatePicker)themedDatePickerCalendar
|
||||
{
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40,140,300,29)],
|
||||
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(40.0, 140.0, 276.0, 148.0)],
|
||||
|
||||
arrowImageLeft = PatternImage("datepicker-calendar-arrow-left.png", 7.0, 10.0),
|
||||
arrowImageRight = PatternImage("datepicker-calendar-arrow-right.png", 7.0, 10.0),
|
||||
@@ -1183,28 +1184,37 @@ var themedButtonValues = nil,
|
||||
arrowImageRightHighlighted = PatternImage("datepicker-calendar-arrow-right-highlighted.png", 7.0, 10.0),
|
||||
circleImageHighlighted = PatternImage("datepicker-circle-image-highlighted.png", 9.0, 10.0),
|
||||
|
||||
secondHandColor = PatternColor("datepicker-clock-second-hand.png", 89.0, 89.0),
|
||||
minuteHandColor = PatternColor("datepicker-clock-minute-hand.png", 85.0, 85.0),
|
||||
hourHandColor = PatternColor("datepicker-clock-hour-hand.png", 47.0, 47.0),
|
||||
middleHandColor = PatternColor("datepicker-clock-middle-hand.png", 13.0, 13.0),
|
||||
clockImageColor = PatternColor("datepicker-clock.png", 122.0, 123.0),
|
||||
secondHandSize = CGSizeMake(89.0, 89.0),
|
||||
secondHandImage = PatternImage("datepicker-clock-second-hand.png", secondHandSize.width, secondHandSize.height),
|
||||
|
||||
secondHandColorDisabled = PatternColor("datepicker-clock-second-hand-disabled.png", 89.0, 89.0),
|
||||
minuteHandColorDisabled = PatternColor("datepicker-clock-minute-hand-disabled.png", 85.0, 85.0),
|
||||
hourHandColorDisabled = PatternColor("datepicker-clock-hour-hand-disabled.png", 47.0, 47.0),
|
||||
middleHandColorDisabled = PatternColor("datepicker-clock-middle-hand-disabled.png", 13.0, 13.0),
|
||||
clockImageColorDisabled = PatternColor("datepicker-clock-disabled.png", 122.0, 123.0),
|
||||
minuteHandSize = CGSizeMake(85.0, 85.0),
|
||||
minuteHandImage = PatternImage("datepicker-clock-minute-hand.png", minuteHandSize.width, minuteHandSize.height),
|
||||
|
||||
hourHandSize = CGSizeMake(47.0, 47.0),
|
||||
hourHandImage = PatternImage("datepicker-clock-hour-hand.png", hourHandSize.width, hourHandSize.height),
|
||||
|
||||
middleHandSize = CGSizeMake(13.0, 13.0),
|
||||
middleHandImage = PatternImage("datepicker-clock-middle-hand.png", middleHandSize.width, middleHandSize.height),
|
||||
|
||||
clockSize = CGSizeMake(122.0, 123.0),
|
||||
clockImageColor = PatternColor("datepicker-clock.png", clockSize.width, clockSize.height),
|
||||
|
||||
secondHandImageDisabled = PatternImage("datepicker-clock-second-hand-disabled.png", secondHandSize.width, secondHandSize.height),
|
||||
minuteHandImageDisabled = PatternImage("datepicker-clock-minute-hand-disabled.png", minuteHandSize.width, minuteHandSize.height),
|
||||
hourHandImageDisabled = PatternImage("datepicker-clock-hour-hand-disabled.png", hourHandSize.width, hourHandSize.height),
|
||||
middleHandImageDisabled = PatternImage("datepicker-clock-middle-hand-disabled.png", middleHandSize.width, middleHandSize.height),
|
||||
clockImageColorDisabled = PatternColor("datepicker-clock-disabled.png", clockSize.width, clockSize.height),
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:1.0], CPThemeStateNormal],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:0.5], CPThemeStateNormal | CPThemeStateDisabled],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:0.5], CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:217.0 / 255.0 green:217.0 / 255.0 blue:211.0 / 255.0 alpha:0.5], [CPThemeStateNormal, CPThemeStateDisabled]],
|
||||
[@"border-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:0.5], [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
|
||||
[@"bezel-color-calendar", [CPColor whiteColor]],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:159.0 / 255.0 green:201.0 / 255.0 blue:225.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:159.0 / 255.0 green:201.0 / 255.0 blue:225.0 / 255.0 alpha:0.5], CPThemeStateSelected |CPThemeStateDisabled],
|
||||
[@"bezel-color-calendar", [CPColor colorWithCalibratedRed:159.0 / 255.0 green:201.0 / 255.0 blue:225.0 / 255.0 alpha:0.5], [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"bezel-color-clock", clockImageColor],
|
||||
[@"bezel-color-clock", clockImageColorDisabled, CPThemeStateDisabled],
|
||||
|
||||
@@ -1248,35 +1258,35 @@ var themedButtonValues = nil,
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:0.5], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted | CPThemeStateDisabled],
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:100.0 / 255.0 green:154.0 / 255.0 blue:184.0 / 255.0 alpha:0.5], [CPThemeStateHighlighted, CPThemeStateDisabled]],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], [CPThemeStateHighlighted, CPThemeStateDisabled]],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), [CPThemeStateHighlighted, CPThemeStateDisabled]],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], [CPThemeStateHighlighted, CPThemeStateDisabled]],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateSelected],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:1.0], [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:179.0 / 255.0 green:179.0 / 255.0 blue:179.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled | CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], [CPThemeStateDisabled, CPThemeStateSelected, CPThemeStateHighlighted]],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], [CPThemeStateDisabled, CPThemeStateSelected, CPThemeStateHighlighted]],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), [CPThemeStateDisabled, CPThemeStateSelected, CPThemeStateHighlighted]],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], [CPThemeStateDisabled, CPThemeStateSelected, CPThemeStateHighlighted]],
|
||||
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], CPThemeStateDisabled | CPThemeStateSelected],
|
||||
[@"tile-text-color", [CPColor colorWithCalibratedRed:13.0 / 255.0 green:51.0 / 255.0 blue:70.0 / 255.0 alpha:0.5], [CPThemeStateDisabled, CPThemeStateSelected]],
|
||||
[@"tile-text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], [CPThemeStateDisabled, CPThemeStateSelected]],
|
||||
[@"tile-text-shadow-offset", CGSizeMake(0,1), [CPThemeStateDisabled, CPThemeStateSelected]],
|
||||
[@"tile-font", [CPFont systemFontOfSize:10.0], [CPThemeStateDisabled, CPThemeStateSelected]],
|
||||
|
||||
[@"arrow-image-left", arrowImageLeft],
|
||||
[@"arrow-image-right", arrowImageRight],
|
||||
@@ -1286,25 +1296,25 @@ var themedButtonValues = nil,
|
||||
[@"circle-image-highlighted", circleImageHighlighted],
|
||||
[@"arrow-inset", CGInsetMake(9.0, 4.0, 0.0, 0.0)],
|
||||
|
||||
[@"second-hand-color", secondHandColor],
|
||||
[@"hour-hand-color", hourHandColor],
|
||||
[@"middle-hand-color", middleHandColor],
|
||||
[@"minute-hand-color", minuteHandColor],
|
||||
[@"second-hand-image", secondHandImage],
|
||||
[@"hour-hand-image", hourHandImage],
|
||||
[@"middle-hand-image", middleHandImage],
|
||||
[@"minute-hand-image", minuteHandImage],
|
||||
|
||||
[@"second-hand-color", secondHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"hour-hand-color", hourHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"middle-hand-color", middleHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"minute-hand-color", minuteHandColorDisabled, CPThemeStateDisabled],
|
||||
[@"second-hand-image", secondHandImageDisabled, CPThemeStateDisabled],
|
||||
[@"hour-hand-image", hourHandImageDisabled, CPThemeStateDisabled],
|
||||
[@"middle-hand-image", middleHandImageDisabled, CPThemeStateDisabled],
|
||||
[@"minute-hand-image", minuteHandImageDisabled, CPThemeStateDisabled],
|
||||
|
||||
[@"second-hand-size", CGSizeMake(89.0, 89.0)],
|
||||
[@"hour-hand-size", CGSizeMake(47.0, 47.0)],
|
||||
[@"middle-hand-size", CGSizeMake(13.0, 13.0)],
|
||||
[@"minute-hand-size", CGSizeMake(85.0, 85.0)],
|
||||
[@"second-hand-size", secondHandSize],
|
||||
[@"hour-hand-size", hourHandSize],
|
||||
[@"middle-hand-size", middleHandSize],
|
||||
[@"minute-hand-size", minuteHandSize],
|
||||
|
||||
[@"border-width", 1.0],
|
||||
[@"size-header", CGSizeMake(141.0, 39.0)],
|
||||
[@"size-tile", CGSizeMake(20.0, 18.0)],
|
||||
[@"size-clock", CGSizeMake(122.0, 123.0)],
|
||||
[@"size-clock", clockSize],
|
||||
[@"size-calendar", CGSizeMake(141.0, 109.0)],
|
||||
[@"min-size-calendar", CGSizeMake(141.0, 148.0)],
|
||||
[@"max-size-calendar", CGSizeMake(141.0, 148.0)]
|
||||
@@ -1312,6 +1322,7 @@ var themedButtonValues = nil,
|
||||
];
|
||||
|
||||
[datePicker setDatePickerStyle:CPClockAndCalendarDatePickerStyle];
|
||||
[datePicker setBackgroundColor:[CPColor whiteColor]];
|
||||
[self registerThemeValues:themeValues forView:datePicker];
|
||||
|
||||
return datePicker;
|
||||
@@ -1336,7 +1347,7 @@ var themedButtonValues = nil,
|
||||
[@"content-inset", CGInsetMake(5.0, 5.0, 4.0, 5.0), CPThemeStateBezeled],
|
||||
|
||||
// Bezeled token field with no tokens
|
||||
[@"content-inset", CGInsetMake(8.0, 8.0, 7.0, 8.0), CPThemeStateBezeled | CPTextFieldStatePlaceholder]
|
||||
[@"content-inset", CGInsetMake(8.0, 8.0, 7.0, 8.0), [CPThemeStateBezeled, CPTextFieldStatePlaceholder]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:overrides forView:tokenfield inherit:themedTextFieldValues];
|
||||
@@ -1378,8 +1389,8 @@ var themedButtonValues = nil,
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelHighlightedColor, CPThemeStateBezeled | CPThemeStateHighlighted],
|
||||
[@"bezel-color", bezelColorDisabled, CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelHighlightedColor, [CPThemeStateBezeled, CPThemeStateHighlighted]],
|
||||
[@"bezel-color", bezelColorDisabled, [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
|
||||
[@"text-color", textColor],
|
||||
[@"text-color", textHighlightedColor, CPThemeStateHighlighted],
|
||||
@@ -1411,8 +1422,8 @@ var themedButtonValues = nil,
|
||||
[@"content-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
|
||||
|
||||
[@"bezel-color", nil, CPThemeStateBordered],
|
||||
[@"bezel-color", arrowImage, CPThemeStateBordered | CPThemeStateHovered],
|
||||
[@"bezel-color", arrowImageHiglighted, CPThemeStateBordered | CPThemeStateHovered | CPThemeStateHighlighted],
|
||||
[@"bezel-color", arrowImage, [CPThemeStateBordered, CPThemeStateHovered]],
|
||||
[@"bezel-color", arrowImageHiglighted, [CPThemeStateBordered, CPThemeStateHovered, CPThemeStateHighlighted]],
|
||||
|
||||
[@"min-size", CGSizeMake(7.0, 6.0)],
|
||||
[@"max-size", CGSizeMake(7.0, 6.0)],
|
||||
@@ -1434,15 +1445,15 @@ var themedButtonValues = nil,
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPThemeStateBordered | CPThemeStateHovered],
|
||||
[@"bezel-color", [bezelColor colorWithAlphaComponent:0], CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelHighlightedColor, CPThemeStateBordered | CPThemeStateHighlighted],
|
||||
[@"bezel-color", bezelColor, [CPThemeStateBordered, CPThemeStateHovered]],
|
||||
[@"bezel-color", [bezelColor colorWithAlphaComponent:0], [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"bezel-color", bezelHighlightedColor, [CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
|
||||
[@"min-size", CGSizeMake(8.0, 8.0)],
|
||||
[@"max-size", CGSizeMake(8.0, 8.0)],
|
||||
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateBordered],
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateBordered | CPThemeStateHighlighted],
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), [CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
|
||||
[@"offset", CGPointMake(17, 6), CPThemeStateBordered]
|
||||
];
|
||||
@@ -1498,9 +1509,9 @@ var themedButtonValues = nil,
|
||||
[@"content-border-inset", CGInsetMake(5.0, 5.0, 4.0, 5.0), CPThemeStateBordered],
|
||||
[@"content-border-color", contentBorderColor, CPThemeStateBordered],
|
||||
|
||||
[@"bezel-color", bezelHighlightedColor, CPThemeStateBordered | CPThemeStateHighlighted],
|
||||
[@"bezel-color", bezelHighlightedColor, [CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
|
||||
[@"bezel-color", bezelDisabledColor, CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelDisabledColor, [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedColorWellValues forView:colorWell];
|
||||
@@ -1562,24 +1573,24 @@ var themedButtonValues = nil,
|
||||
|
||||
overrides =
|
||||
[
|
||||
[@"bezel-color", bezelColor, CPThemeStateBezeled | CPComboBoxStateButtonBordered],
|
||||
[@"bezel-color", bezelFocusedColor, CPThemeStateBezeled | CPComboBoxStateButtonBordered | CPThemeStateEditing],
|
||||
[@"bezel-color", bezelDisabledColor, CPThemeStateBezeled | CPComboBoxStateButtonBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
|
||||
[@"bezel-color", bezelFocusedColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateEditing]],
|
||||
[@"bezel-color", bezelDisabledColor, [CPThemeStateBezeled, CPComboBoxStateButtonBordered, CPThemeStateDisabled]],
|
||||
|
||||
[@"bezel-color", bezelNoBorderColor, CPThemeStateBezeled],
|
||||
[@"bezel-color", bezelNoBorderFocusedColor, CPThemeStateBezeled | CPThemeStateEditing],
|
||||
[@"bezel-color", bezelNoBorderDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
|
||||
[@"bezel-color", bezelNoBorderFocusedColor, [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
[@"bezel-color", bezelNoBorderDisabledColor, [CPThemeStateBezeled, CPThemeStateDisabled]],
|
||||
|
||||
[@"border-inset", CGInsetMake(3.0, 3.0, 3.0, 3.0), CPThemeStateBezeled],
|
||||
|
||||
[@"bezel-inset", CGInsetMake(0.0, 1.0, 1.0, 1.0), CPThemeStateBezeled | CPThemeStateEditing],
|
||||
[@"bezel-inset", CGInsetMake(0.0, 1.0, 1.0, 1.0), [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
// The right border inset has to make room for the focus ring and popup button
|
||||
[@"content-inset", CGInsetMake(8.0, 27.0, 7.0, 8.0), CPThemeStateBezeled | CPComboBoxStateButtonBordered],
|
||||
[@"content-inset", CGInsetMake(8.0, 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, 24.0, 7.0, 8.0), [CPThemeStateBezeled, CPThemeStateEditing]],
|
||||
|
||||
[@"popup-button-size", CGSizeMake(21.0, 23.0), CPThemeStateBezeled | CPComboBoxStateButtonBordered],
|
||||
[@"popup-button-size", CGSizeMake(21.0, 23.0), [CPThemeStateBezeled, CPComboBoxStateButtonBordered]],
|
||||
[@"popup-button-size", CGSizeMake(17.0, 23.0), CPThemeStateBezeled],
|
||||
|
||||
// Because combo box uses a three-part bezel, the height is fixed
|
||||
@@ -1610,10 +1621,10 @@ var themedButtonValues = nil,
|
||||
|
||||
[@"image", imageNormal, CPThemeStateNormal],
|
||||
[@"image", imageSelected, CPThemeStateSelected],
|
||||
[@"image", imageSelectedHighlighted, CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"image", imageSelectedHighlighted, [CPThemeStateSelected, CPThemeStateHighlighted]],
|
||||
[@"image", imageHighlighted, CPThemeStateHighlighted],
|
||||
[@"image", imageDisabled, CPThemeStateDisabled],
|
||||
[@"image", imageSelectedDisabled, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"image", imageSelectedDisabled, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"image-offset", CPRadioImageOffset],
|
||||
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
|
||||
@@ -1646,10 +1657,10 @@ var themedButtonValues = nil,
|
||||
|
||||
[@"image", imageNormal, CPThemeStateNormal],
|
||||
[@"image", imageSelected, CPThemeStateSelected],
|
||||
[@"image", imageSelectedHighlighted, CPThemeStateSelected | CPThemeStateHighlighted],
|
||||
[@"image", imageSelectedHighlighted, [CPThemeStateSelected, CPThemeStateHighlighted]],
|
||||
[@"image", imageHighlighted, CPThemeStateHighlighted],
|
||||
[@"image", imageDisabled, CPThemeStateDisabled],
|
||||
[@"image", imageSelectedDisabled, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"image", imageSelectedDisabled, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"image-offset", CPCheckBoxImageOffset],
|
||||
|
||||
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
|
||||
@@ -1680,8 +1691,8 @@ var themedButtonValues = nil,
|
||||
themeValues =
|
||||
[
|
||||
[@"image", mixedImage, CPButtonStateMixed],
|
||||
[@"image", mixedHighlightedImage, CPButtonStateMixed | CPThemeStateHighlighted],
|
||||
[@"image", mixedDisabledImage, CPButtonStateMixed | CPThemeStateDisabled],
|
||||
[@"image", mixedHighlightedImage, [CPButtonStateMixed, CPThemeStateHighlighted]],
|
||||
[@"image", mixedDisabledImage, [CPButtonStateMixed, CPThemeStateDisabled]],
|
||||
[@"image-offset", CPCheckBoxImageOffset, CPButtonStateMixed],
|
||||
[@"max-size", CGSizeMake(-1.0, -1.0)]
|
||||
];
|
||||
@@ -1744,29 +1755,29 @@ var themedButtonValues = nil,
|
||||
[
|
||||
[@"center-segment-bezel-color", centerBezelColor, CPThemeStateNormal],
|
||||
[@"center-segment-bezel-color", inactiveCenterBezelColor, CPThemeStateDisabled],
|
||||
[@"center-segment-bezel-color", inactiveHighlightedCenterBezelColor, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"center-segment-bezel-color", inactiveHighlightedCenterBezelColor, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"center-segment-bezel-color", centerHighlightedBezelColor, CPThemeStateSelected],
|
||||
[@"center-segment-bezel-color", pushedCenterBezelColor, CPThemeStateHighlighted],
|
||||
[@"center-segment-bezel-color", pushedHighlightedCenterBezelColor, CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"center-segment-bezel-color", pushedHighlightedCenterBezelColor, [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
|
||||
[@"divider-bezel-color", dividerBezelColor, CPThemeStateNormal],
|
||||
[@"divider-bezel-color", inactiveDividerBezelColor, CPThemeStateDisabled],
|
||||
[@"divider-bezel-color", inactiveHighlightedDividerBezelColor, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"divider-bezel-color", inactiveHighlightedDividerBezelColor, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"divider-bezel-color", dividerHighlightedBezelColor, CPThemeStateSelected],
|
||||
|
||||
[@"left-segment-bezel-color", leftBezelColor, CPThemeStateNormal],
|
||||
[@"left-segment-bezel-color", inactiveLeftBezelColor, CPThemeStateDisabled],
|
||||
[@"left-segment-bezel-color", inactiveHighlightedLeftBezelColor, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"left-segment-bezel-color", inactiveHighlightedLeftBezelColor, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"left-segment-bezel-color", leftHighlightedBezelColor, CPThemeStateSelected],
|
||||
[@"left-segment-bezel-color", pushedLeftBezelColor, CPThemeStateHighlighted],
|
||||
[@"left-segment-bezel-color", pushedHighlightedLeftBezelColor, CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"left-segment-bezel-color", pushedHighlightedLeftBezelColor, [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
|
||||
[@"right-segment-bezel-color", rightBezelColor, CPThemeStateNormal],
|
||||
[@"right-segment-bezel-color", inactiveRightBezelColor, CPThemeStateDisabled],
|
||||
[@"right-segment-bezel-color", inactiveHighlightedRightBezelColor, CPThemeStateSelected | CPThemeStateDisabled],
|
||||
[@"right-segment-bezel-color", inactiveHighlightedRightBezelColor, [CPThemeStateSelected, CPThemeStateDisabled]],
|
||||
[@"right-segment-bezel-color", rightHighlightedBezelColor, CPThemeStateSelected],
|
||||
[@"right-segment-bezel-color", pushedRightBezelColor, CPThemeStateHighlighted],
|
||||
[@"right-segment-bezel-color", pushedHighlightedRightBezelColor, CPThemeStateHighlighted | CPThemeStateSelected],
|
||||
[@"right-segment-bezel-color", pushedHighlightedRightBezelColor, [CPThemeStateHighlighted, CPThemeStateSelected]],
|
||||
|
||||
[@"content-inset", CGInsetMake(0.0, 4.0, 0.0, 4.0), CPThemeStateNormal],
|
||||
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
|
||||
@@ -1867,7 +1878,7 @@ var themedButtonValues = nil,
|
||||
[
|
||||
[@"track-width", 5.0],
|
||||
[@"track-color", trackColor, CPThemeStateVertical],
|
||||
[@"track-color", trackDisabledColor, CPThemeStateVertical | CPThemeStateDisabled],
|
||||
[@"track-color", trackDisabledColor, [CPThemeStateVertical, CPThemeStateDisabled]],
|
||||
|
||||
[@"knob-size", CGSizeMake(23.0, 24.0)],
|
||||
[@"knob-color", knobColor],
|
||||
@@ -1902,12 +1913,12 @@ var themedButtonValues = nil,
|
||||
themedCircularSliderValues =
|
||||
[
|
||||
[@"track-color", trackColor, CPThemeStateCircular],
|
||||
[@"track-color", trackDisabledColor, CPThemeStateCircular | CPThemeStateDisabled],
|
||||
[@"track-color", trackDisabledColor, [CPThemeStateCircular, CPThemeStateDisabled]],
|
||||
|
||||
[@"knob-size", CGSizeMake(5.0, 5.0), CPThemeStateCircular],
|
||||
[@"knob-color", knobColor, CPThemeStateCircular],
|
||||
[@"knob-color", knobHighlightedColor, CPThemeStateCircular | CPThemeStateHighlighted],
|
||||
[@"knob-color", knobDisabledColor, CPThemeStateCircular | CPThemeStateDisabled]
|
||||
[@"knob-color", knobHighlightedColor, [CPThemeStateCircular, CPThemeStateHighlighted]],
|
||||
[@"knob-color", knobDisabledColor, [CPThemeStateCircular, CPThemeStateDisabled]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedCircularSliderValues forView:slider];
|
||||
@@ -2018,7 +2029,7 @@ var themedButtonValues = nil,
|
||||
|
||||
[@"background-color", pressed, CPThemeStateHighlighted],
|
||||
[@"background-color", highlighted, CPThemeStateSelected],
|
||||
[@"background-color", highlightedPressed, CPThemeStateHighlighted | CPThemeStateSelected]
|
||||
[@"background-color", highlightedPressed, [CPThemeStateHighlighted, CPThemeStateSelected]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedColumnHeaderValues forView:header];
|
||||
@@ -2071,15 +2082,32 @@ var themedButtonValues = nil,
|
||||
|
||||
themedTableViewValues =
|
||||
[
|
||||
[@"alternating-row-colors", alternatingRowColors],
|
||||
[@"grid-color", gridColor],
|
||||
[@"highlighted-grid-color", [CPColor whiteColor]],
|
||||
[@"selection-color", selectionColor],
|
||||
[@"sourcelist-selection-color", sourceListSelectionColor],
|
||||
[@"sort-image", sortImage],
|
||||
[@"sort-image-reversed", sortImageReversed],
|
||||
[@"image-generic-file", imageGenericFile],
|
||||
[@"default-row-height", 23.0],
|
||||
[@"alternating-row-colors", alternatingRowColors],
|
||||
[@"grid-color", gridColor],
|
||||
[@"highlighted-grid-color", [CPColor whiteColor]],
|
||||
[@"selection-color", selectionColor],
|
||||
[@"sourcelist-selection-color", sourceListSelectionColor],
|
||||
[@"sort-image", sortImage],
|
||||
[@"sort-image-reversed", sortImageReversed],
|
||||
[@"image-generic-file", imageGenericFile],
|
||||
[@"default-row-height", 23.0],
|
||||
|
||||
[@"dropview-on-background-color", [CPColor colorWithRed:72 / 255 green:134 / 255 blue:202 / 255 alpha:0.25]],
|
||||
[@"dropview-on-border-color", [CPColor colorWithHexString:@"4886ca"]],
|
||||
[@"dropview-on-border-width", 3.0],
|
||||
[@"dropview-on-border-radius", 8.0],
|
||||
|
||||
[@"dropview-on-selected-background-color", [CPColor clearColor]],
|
||||
[@"dropview-on-selected-border-color", [CPColor whiteColor]],
|
||||
[@"dropview-on-selected-border-width", 2.0],
|
||||
[@"dropview-on-selected-border-radius", 8.0],
|
||||
|
||||
[@"dropview-above-border-color", [CPColor colorWithHexString:@"4886ca"]],
|
||||
[@"dropview-above-border-width", 3.0],
|
||||
|
||||
[@"dropview-above-selected-border-color", [CPColor colorWithHexString:@"8BB6F0"]],
|
||||
[@"dropview-above-selected-border-width", 2.0],
|
||||
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedTableViewValues forView:tableview];
|
||||
@@ -2232,10 +2260,10 @@ var themedButtonValues = nil,
|
||||
[
|
||||
[@"bezel-color-up-button", bezelUp, CPThemeStateBordered],
|
||||
[@"bezel-color-down-button", bezelDown, CPThemeStateBordered],
|
||||
[@"bezel-color-up-button", bezelUpDisabled, CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color-down-button", bezelDownDisabled, CPThemeStateBordered | CPThemeStateDisabled],
|
||||
[@"bezel-color-up-button", bezelUpHighlighted, CPThemeStateBordered | CPThemeStateHighlighted],
|
||||
[@"bezel-color-down-button", bezelDownHighlighted, CPThemeStateBordered | CPThemeStateHighlighted],
|
||||
[@"bezel-color-up-button", bezelUpDisabled, [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"bezel-color-down-button", bezelDownDisabled, [CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
[@"bezel-color-up-button", bezelUpHighlighted, [CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
[@"bezel-color-down-button", bezelDownHighlighted, [CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
[@"min-size", CGSizeMake(25.0, 25.0)],
|
||||
[@"up-button-size", CGSizeMake(19.0, 13.0)],
|
||||
[@"down-button-size", CGSizeMake(19.0, 12.0)]
|
||||
@@ -2401,6 +2429,7 @@ var themedButtonValues = nil,
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
+ (CPLevelIndicator)themedLevelIndicator
|
||||
{
|
||||
var levelIndicator = [[CPLevelIndicator alloc] initWithFrame:CGRectMake(0,0,100,100)],
|
||||
@@ -2687,6 +2716,7 @@ var themedButtonValues = nil,
|
||||
[
|
||||
[@"gradient-height", 31.0],
|
||||
[@"bezel-head-color", bezelHeadColor],
|
||||
[@"bezel-head-sheet-color", solidColor],
|
||||
[@"solid-color", solidColor],
|
||||
|
||||
[@"title-font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
|
||||
@@ -2750,7 +2780,7 @@ var themedButtonValues = nil,
|
||||
return docModalWindowView;
|
||||
}
|
||||
|
||||
+ (_CPBorderlessBridgeWindowView)themedBordelessBridgeWindowView
|
||||
+ (_CPBorderlessBridgeWindowView)themedBorderlessBridgeWindowView
|
||||
{
|
||||
var bordelessBridgeWindowView = [[_CPBorderlessBridgeWindowView alloc] initWithFrame:CGRectMake(0,0,0,0)],
|
||||
|
||||
@@ -2774,7 +2804,6 @@ var themedButtonValues = nil,
|
||||
+ (_CPToolbarView)themedToolbarView
|
||||
{
|
||||
var toolbarView = [[_CPToolbarView alloc] initWithFrame:CGRectMakeZero()],
|
||||
|
||||
toolbarExtraItemsImage = PatternImage(@"toolbar-view-extra-items-image.png", 10.0, 15.0),
|
||||
toolbarExtraItemsAlternateImage = PatternImage(@"toolbar-view-extra-items-alternate-image.png", 10.0, 15.0),
|
||||
toolbarSeparatorColor = PatternColor([
|
||||
@@ -2854,8 +2883,6 @@ var themedButtonValues = nil,
|
||||
+ (_CPMenuView)themedMenuView
|
||||
{
|
||||
var menuView = [[_CPMenuView alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 100.0)],
|
||||
|
||||
|
||||
menuWindowMoreAboveImage = PatternImage(@"menu-window-more-above.png", 38.0, 18.0),
|
||||
menuWindowMoreBelowImage = PatternImage(@"menu-window-more-below.png", 38.0, 18.0),
|
||||
generalIconNew = PatternImage(@"menu-general-icon-new.png", 16.0, 16.0),
|
||||
@@ -2968,6 +2995,10 @@ var themedButtonValues = nil,
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"border-radius", 5.0],
|
||||
[@"stroke-width", 1.0],
|
||||
[@"shadow-size", CGSizeMake(0, 6)],
|
||||
[@"shadow-blur", 15.0],
|
||||
[@"background-gradient", gradient],
|
||||
[@"background-gradient-hud", gradientHUD],
|
||||
[@"stroke-color", strokeColor],
|
||||
@@ -2981,7 +3012,6 @@ var themedButtonValues = nil,
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation AristoHUDThemeDescriptor : BKThemeDescriptor
|
||||
{
|
||||
}
|
||||
@@ -3061,7 +3091,7 @@ var themedButtonValues = nil,
|
||||
// var scroller = [AristoThemeDescriptor makeVerticalScroller],
|
||||
// overrides =
|
||||
// [
|
||||
// [@"knob-color", nil, CPThemeStateVertical | CPThemeStateDisabled]
|
||||
// [@"knob-color", nil, [CPThemeStateVertical, CPThemeStateDisabled]]
|
||||
// ];
|
||||
//
|
||||
// [self registerThemeValues:[self defaultThemeOverridesAddedTo:overrides] forView:scroller inherit:themedVerticalScrollerValues];
|
||||
@@ -3145,5 +3175,4 @@ var themedButtonValues = nil,
|
||||
|
||||
return progressBar;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 238 B |
Binary file not shown.
|
Before Width: | Height: | Size: 250 B |
Binary file not shown.
|
Before Width: | Height: | Size: 475 B |
Binary file not shown.
|
Before Width: | Height: | Size: 344 B |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user