Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c69589355 | ||
|
|
261c0df2e7 | ||
|
|
2fd6e7432a | ||
|
|
dcdcd8e41a | ||
|
|
24443221f2 | ||
|
|
0d674c3496 | ||
|
|
c7e0341c2c | ||
|
|
a15b24b9be | ||
|
|
787dd10c69 | ||
|
|
d0988fa5b0 | ||
|
|
b7031f2f77 | ||
|
|
588da9addb | ||
|
|
8f8f1a0224 | ||
|
|
9705f1fe28 | ||
|
|
2a11bdb7ef | ||
|
|
3775c3fb2e | ||
|
|
cea120945c | ||
|
|
a202cfbbe9 | ||
|
|
848c893b9e | ||
|
|
252b8f5ca5 | ||
|
|
d82da5d571 | ||
|
|
1ebdd8ed8e | ||
|
|
7070fe9b2e | ||
|
|
7b2464a740 | ||
|
|
e2f19c30f1 | ||
|
|
5408df40f5 | ||
|
|
79894781b1 | ||
|
|
e798842dee | ||
|
|
98ff6c1279 | ||
|
|
59fb04321d | ||
|
|
81d537fa24 | ||
|
|
6488ab2375 | ||
|
|
a10f36e3a2 | ||
|
|
f5bb8abfe0 | ||
|
|
a24f33ad93 |
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
before_install:
|
||||
- jdk_switcher use openjdk6
|
||||
install: ./bootstrap.sh --quiet --noprompt --directory ./narwhal
|
||||
script: jake test
|
||||
env: PATH=/home/travis/builds/cappuccino/cappuccino/narwhal/bin:$PATH CAPP_BUILD=/home/travis/builds/cappuccino/cappuccino/Build NARWHAL_ENGINE=rhino
|
||||
@@ -75,32 +75,33 @@ CPCriticalAlertStyle = 2;
|
||||
representing the first button added to the alert which appears on the
|
||||
right, 1 representing the next button to the left and so on)
|
||||
*/
|
||||
@implementation CPAlert : CPView
|
||||
@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 _delegate @accessors(property=delegate);
|
||||
id _modalDelegate;
|
||||
SEL _didEndSelector;
|
||||
|
||||
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
|
||||
@@ -164,6 +165,7 @@ CPCriticalAlertStyle = 2;
|
||||
_showHelp = NO;
|
||||
_needsLayout = YES;
|
||||
_defaultWindowStyle = CPTitledWindowMask;
|
||||
_themeView = [_CPAlertThemeView new];
|
||||
|
||||
_messageLabel = [CPTextField labelWithTitle:@"Alert"];
|
||||
_alertImageView = [[CPImageView alloc] init];
|
||||
@@ -180,6 +182,11 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
#pragma mark Accessors
|
||||
|
||||
- (CPTheme)theme
|
||||
{
|
||||
return [_themeView theme];
|
||||
}
|
||||
|
||||
/*!
|
||||
set the theme to use
|
||||
|
||||
@@ -197,9 +204,20 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
_window = nil; // will be regenerated at next layout
|
||||
_needsLayout = YES;
|
||||
[super setTheme:aTheme];
|
||||
[_themeView setTheme:aTheme];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName
|
||||
{
|
||||
[_themeView setValue:aValue forThemeAttribute:aName];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(CPThemeState)aState
|
||||
{
|
||||
[_themeView setValue:aValue forThemeAttribute:aName inState:aState];
|
||||
}
|
||||
|
||||
|
||||
/*! @deprecated
|
||||
*/
|
||||
- (void)setWindowStyle:(int)aStyle
|
||||
@@ -334,16 +352,16 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (void)_layoutMessageView
|
||||
{
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
sizeWithFontCorrection = 6.0,
|
||||
messageLabelWidth,
|
||||
messageLabelTextSize;
|
||||
|
||||
[_messageLabel setTextColor:[self currentValueForThemeAttribute:@"message-text-color"]];
|
||||
[_messageLabel setFont:[self currentValueForThemeAttribute:@"message-text-font"]];
|
||||
[_messageLabel setTextShadowColor:[self currentValueForThemeAttribute:@"message-text-shadow-color"]];
|
||||
[_messageLabel setTextShadowOffset:[self currentValueForThemeAttribute:@"message-text-shadow-offset"]];
|
||||
[_messageLabel setAlignment:[self currentValueForThemeAttribute:@"message-text-alignment"]];
|
||||
[_messageLabel setTextColor:[_themeView currentValueForThemeAttribute:@"message-text-color"]];
|
||||
[_messageLabel setFont:[_themeView currentValueForThemeAttribute:@"message-text-font"]];
|
||||
[_messageLabel setTextShadowColor:[_themeView currentValueForThemeAttribute:@"message-text-shadow-color"]];
|
||||
[_messageLabel setTextShadowOffset:[_themeView currentValueForThemeAttribute:@"message-text-shadow-offset"]];
|
||||
[_messageLabel setAlignment:[_themeView currentValueForThemeAttribute:@"message-text-alignment"]];
|
||||
[_messageLabel setLineBreakMode:CPLineBreakByWordWrapping];
|
||||
|
||||
messageLabelWidth = CGRectGetWidth([[_window contentView] frame]) - inset.left - inset.right;
|
||||
@@ -357,18 +375,18 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (void)_layoutInformativeView
|
||||
{
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
sizeWithFontCorrection = 6.0,
|
||||
informativeLabelWidth,
|
||||
informativeLabelOriginY,
|
||||
informativeLabelTextSize;
|
||||
|
||||
[_informativeLabel setTextColor:[self currentValueForThemeAttribute:@"informative-text-color"]];
|
||||
[_informativeLabel setFont:[self currentValueForThemeAttribute:@"informative-text-font"]];
|
||||
[_informativeLabel setTextShadowColor:[self currentValueForThemeAttribute:@"informative-text-shadow-color"]];
|
||||
[_informativeLabel setTextShadowOffset:[self currentValueForThemeAttribute:@"informative-text-shadow-offset"]];
|
||||
[_informativeLabel setAlignment:[self currentValueForThemeAttribute:@"informative-text-alignment"]];
|
||||
[_informativeLabel setTextColor:[_themeView currentValueForThemeAttribute:@"informative-text-color"]];
|
||||
[_informativeLabel setFont:[_themeView currentValueForThemeAttribute:@"informative-text-font"]];
|
||||
[_informativeLabel setTextShadowColor:[_themeView currentValueForThemeAttribute:@"informative-text-shadow-color"]];
|
||||
[_informativeLabel setTextShadowOffset:[_themeView currentValueForThemeAttribute:@"informative-text-shadow-offset"]];
|
||||
[_informativeLabel setAlignment:[_themeView currentValueForThemeAttribute:@"informative-text-alignment"]];
|
||||
[_informativeLabel setLineBreakMode:CPLineBreakByWordWrapping];
|
||||
|
||||
informativeLabelWidth = CGRectGetWidth([[_window contentView] frame]) - inset.left - inset.right;
|
||||
@@ -386,8 +404,8 @@ CPCriticalAlertStyle = 2;
|
||||
if (!_accessoryView)
|
||||
return;
|
||||
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
accessoryViewWidth = CGRectGetWidth([[_window contentView] frame]) - inset.left - inset.right,
|
||||
accessoryViewOriginY = CGRectGetMaxY([_informativeLabel frame]) + defaultElementsMargin;
|
||||
|
||||
@@ -403,16 +421,16 @@ CPCriticalAlertStyle = 2;
|
||||
if (!_showSuppressionButton)
|
||||
return;
|
||||
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
suppressionViewXOffset = [self currentValueForThemeAttribute:@"suppression-button-x-offset"],
|
||||
suppressionViewYOffset = [self currentValueForThemeAttribute:@"suppression-button-y-offset"],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
suppressionViewXOffset = [_themeView currentValueForThemeAttribute:@"suppression-button-x-offset"],
|
||||
suppressionViewYOffset = [_themeView currentValueForThemeAttribute:@"suppression-button-y-offset"],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
suppressionButtonViewOriginY = CGRectGetMaxY([(_accessoryView || _informativeLabel) frame]) + defaultElementsMargin + suppressionViewYOffset;
|
||||
|
||||
[_suppressionButton setTextColor:[self currentValueForThemeAttribute:@"suppression-button-text-color"]];
|
||||
[_suppressionButton setFont:[self currentValueForThemeAttribute:@"suppression-button-text-font"]];
|
||||
[_suppressionButton setTextShadowColor:[self currentValueForThemeAttribute:@"suppression-button-text-shadow-color"]];
|
||||
[_suppressionButton setTextShadowOffset:[self currentValueForThemeAttribute:@"suppression-button-text-shadow-offset"]];
|
||||
[_suppressionButton setTextColor:[_themeView currentValueForThemeAttribute:@"suppression-button-text-color"]];
|
||||
[_suppressionButton setFont:[_themeView currentValueForThemeAttribute:@"suppression-button-text-font"]];
|
||||
[_suppressionButton setTextShadowColor:[_themeView currentValueForThemeAttribute:@"suppression-button-text-shadow-color"]];
|
||||
[_suppressionButton setTextShadowOffset:[_themeView currentValueForThemeAttribute:@"suppression-button-text-shadow-offset"]];
|
||||
[_suppressionButton sizeToFit];
|
||||
|
||||
[_suppressionButton setFrameOrigin:CGPointMake(inset.left + suppressionViewXOffset, suppressionButtonViewOriginY)];
|
||||
@@ -424,12 +442,12 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (CGSize)_layoutButtonsFromView:(CPView)lastView
|
||||
{
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
minimumSize = [self currentValueForThemeAttribute:@"size"],
|
||||
buttonOffset = [self currentValueForThemeAttribute:@"button-offset"],
|
||||
helpLeftOffset = [self currentValueForThemeAttribute:@"help-image-left-offset"],
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
minimumSize = [_themeView currentValueForThemeAttribute:@"size"],
|
||||
buttonOffset = [_themeView currentValueForThemeAttribute:@"button-offset"],
|
||||
helpLeftOffset = [_themeView currentValueForThemeAttribute:@"help-image-left-offset"],
|
||||
aRepresentativeButton = [_buttons objectAtIndex:0],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
panelSize = [[_window contentView] frame].size,
|
||||
buttonsOriginY,
|
||||
offsetX;
|
||||
@@ -461,8 +479,8 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
if (_showHelp)
|
||||
{
|
||||
var helpImage = [self currentValueForThemeAttribute:@"help-image"],
|
||||
helpImagePressed = [self currentValueForThemeAttribute:@"help-image-pressed"],
|
||||
var helpImage = [_themeView currentValueForThemeAttribute:@"help-image"],
|
||||
helpImagePressed = [_themeView currentValueForThemeAttribute:@"help-image-pressed"],
|
||||
helpImageSize = helpImage ? [helpImage size] : CGSizeMakeZero(),
|
||||
helpFrame = CGRectMake(helpLeftOffset, buttonsOriginY, helpImageSize.width, helpImageSize.height);
|
||||
|
||||
@@ -487,7 +505,7 @@ CPCriticalAlertStyle = 2;
|
||||
if (!_window)
|
||||
[self _createWindowWithStyle:nil];
|
||||
|
||||
var iconOffset = [self currentValueForThemeAttribute:@"image-offset"],
|
||||
var iconOffset = [_themeView currentValueForThemeAttribute:@"image-offset"],
|
||||
theImage = _icon,
|
||||
finalSize;
|
||||
|
||||
@@ -495,13 +513,13 @@ CPCriticalAlertStyle = 2;
|
||||
switch (_alertStyle)
|
||||
{
|
||||
case CPWarningAlertStyle:
|
||||
theImage = [self currentValueForThemeAttribute:@"warning-image"];
|
||||
theImage = [_themeView currentValueForThemeAttribute:@"warning-image"];
|
||||
break;
|
||||
case CPInformationalAlertStyle:
|
||||
theImage = [self currentValueForThemeAttribute:@"information-image"];
|
||||
theImage = [_themeView currentValueForThemeAttribute:@"information-image"];
|
||||
break;
|
||||
case CPCriticalAlertStyle:
|
||||
theImage = [self currentValueForThemeAttribute:@"error-image"];
|
||||
theImage = [_themeView currentValueForThemeAttribute:@"error-image"];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -592,7 +610,7 @@ CPCriticalAlertStyle = 2;
|
||||
- (void)_createWindowWithStyle:(int)forceStyle
|
||||
{
|
||||
var frame = CGRectMakeZero();
|
||||
frame.size = [self currentValueForThemeAttribute:@"size"];
|
||||
frame.size = [_themeView currentValueForThemeAttribute:@"size"];
|
||||
|
||||
_window = [[CPWindow alloc] initWithContentRect:frame styleMask:forceStyle || _defaultWindowStyle];
|
||||
[_window setLevel:CPStatusWindowLevel];
|
||||
@@ -633,8 +651,8 @@ CPCriticalAlertStyle = 2;
|
||||
{
|
||||
if ([_window isSheet])
|
||||
{
|
||||
[CPApp endSheet:_window returnCode:[aSender tag]];
|
||||
[_window orderOut:nil];
|
||||
[CPApp endSheet:_window returnCode:[aSender tag]];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -650,17 +668,19 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (void)_alertDidEnd:(CPWindow)aWindow returnCode:(int)returnCode contextInfo:(id)contextInfo
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
|
||||
[_delegate alertDidEnd:self returnCode:returnCode];
|
||||
|
||||
if (_didEndSelector)
|
||||
objj_msgSend(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
|
||||
|
||||
_modalDelegate = nil;
|
||||
_didEndSelector = nil;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
|
||||
[_delegate alertDidEnd:self returnCode:returnCode];
|
||||
}
|
||||
|
||||
#pragma mark Theme Attributes
|
||||
@end
|
||||
|
||||
@implementation _CPAlertThemeView : CPView
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#import "../Foundation/CPRange.h"
|
||||
|
||||
@import <Foundation/CPBundle.j>
|
||||
|
||||
@import "CPCompatibility.j"
|
||||
@@ -139,9 +141,7 @@ CPRunContinuesResponse = -1002;
|
||||
{
|
||||
_eventListeners = [];
|
||||
|
||||
_windows = [];
|
||||
|
||||
[_windows addObject:nil];
|
||||
_windows = [[CPNull null]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -583,12 +583,14 @@ CPRunContinuesResponse = -1002;
|
||||
_currentEvent = anEvent;
|
||||
CPEventModifierFlags = [anEvent modifierFlags];
|
||||
|
||||
var theWindow = [anEvent window];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var willPropagate = [[[anEvent window] platformWindow] _willPropagateCurrentDOMEvent];
|
||||
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
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
#endif
|
||||
|
||||
// Check if this is a candidate for key equivalent...
|
||||
@@ -600,7 +602,7 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
// Unconditionally propagate on these keys to solve browser copy paste bugs
|
||||
if ((characters == "c" || characters == "x" || characters == "v") && (modifierFlags & CPPlatformActionKeyMask))
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -608,7 +610,7 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// if we make it this far, then restore the original willPropagate value
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:willPropagate];
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:willPropagate];
|
||||
#endif
|
||||
|
||||
if (_eventListeners.length)
|
||||
@@ -619,7 +621,10 @@ CPRunContinuesResponse = -1002;
|
||||
return;
|
||||
}
|
||||
|
||||
[[anEvent window] sendEvent:anEvent];
|
||||
if (theWindow)
|
||||
[theWindow sendEvent:anEvent];
|
||||
else if ([anEvent type] == CPMouseMoved)
|
||||
[[CPCursor arrowCursor] set];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -655,6 +660,10 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
- (CPWindow)windowWithWindowNumber:(int)aWindowNumber
|
||||
{
|
||||
// Never allow _windows[0] to be returned - it's an internal CPNull placeholder.
|
||||
if (!aWindowNumber)
|
||||
return nil;
|
||||
|
||||
return _windows[aWindowNumber];
|
||||
}
|
||||
|
||||
@@ -663,7 +672,8 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
- (CPArray)windows
|
||||
{
|
||||
return _windows;
|
||||
// Return all windows, but not the CPNull placeholder in _windows[0].
|
||||
return [_windows subarrayWithRange:_CPMakeRange(1, [_windows count] - 1)];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1042,9 +1052,9 @@ CPRunContinuesResponse = -1002;
|
||||
if (!args || args.length == 0)
|
||||
{
|
||||
_args = [];
|
||||
#if PLATFORM(DOM)
|
||||
window.location.hash = @"#";
|
||||
#endif
|
||||
// Don't use if PLATFORM(DOM) here - the unit test fakes window.location so we should play along.
|
||||
if (window && window.location)
|
||||
window.location.hash = @"#";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1059,9 +1069,9 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
var hash = [toEncode componentsJoinedByString:@"/"];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
window.location.hash = @"#" + hash;
|
||||
#endif
|
||||
// Don't use if PLATFORM(DOM) here - the unit test fakes window.location so we should play along.
|
||||
if (window && window.location)
|
||||
window.location.hash = @"#" + hash;
|
||||
}
|
||||
|
||||
- (void)_reloadArguments
|
||||
|
||||
@@ -25,7 +25,8 @@ Cursor support by browser:
|
||||
|
||||
var currentCursor = nil,
|
||||
cursorStack = [],
|
||||
cursors = {};
|
||||
cursors = {},
|
||||
ieCursorMap = {};
|
||||
|
||||
@implementation CPCursor : CPObject
|
||||
{
|
||||
@@ -36,6 +37,20 @@ var currentCursor = nil,
|
||||
BOOL _isSetOnMouseExited @accessors(readwrite, getter=isSetOnMouseExited, setter=setOnMouseExited:);
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self !== CPCursor)
|
||||
return;
|
||||
|
||||
// IE < 9 does not support some CSS cursors, we map them to supported ones
|
||||
ieCursorMap = {
|
||||
"ew-resize": "e-resize",
|
||||
"ns-resize": "n-resize",
|
||||
"nesw-resize": "ne-resize",
|
||||
"nwse-resize": "nw-resize"
|
||||
};
|
||||
}
|
||||
|
||||
- (id)initWithCSSString:(CPString)aString
|
||||
{
|
||||
if (self = [super init])
|
||||
@@ -44,23 +59,30 @@ var currentCursor = nil,
|
||||
return self;
|
||||
}
|
||||
|
||||
// hotspot is supported in CSS3 (but not IE).
|
||||
- (id)initWithImage:(CPImage)image hotSpot:(CPPoint)hotSpot
|
||||
/*!
|
||||
Init a cursor with the given image and hotspot.
|
||||
hotspot is supported in CSS3 (but not IE).
|
||||
*/
|
||||
- (id)initWithImage:(CPImage)image hotSpot:(CGPoint)hotSpot
|
||||
{
|
||||
_hotSpot = hotSpot;
|
||||
_image = image;
|
||||
return [self initWithCSSString:"url(" + [_image filename] + ")" + hotSpot.x + " " + hotSpot.y + ", auto"];
|
||||
}
|
||||
|
||||
// foregroundColor and backgroundColor are ignored in Cocoa as well. See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSCursor_Class/Reference/Reference.html
|
||||
- (id)initWithImage:(CPImage)image foregroundColorHint:(CPColor)foregroundColor backgroundColorHint:(CPColor)backgroundColor hotSpot:(CPPoint)aHotSpot
|
||||
/*!
|
||||
Init a cursor with the given image and hotspot. This is provided
|
||||
for compliance with Cocoa. Note that foregroundColor and backgroundColor are ignored
|
||||
(as they are in Cocoa). See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSCursor_Class/Reference/Reference.html
|
||||
*/
|
||||
- (id)initWithImage:(CPImage)image foregroundColorHint:(CPColor)foregroundColor backgroundColorHint:(CPColor)backgroundColor hotSpot:(CGPoint)aHotSpot
|
||||
{
|
||||
return [self initWithImage:image hotSpot:hotSpot];
|
||||
}
|
||||
|
||||
+ (void)hide
|
||||
{
|
||||
[self _setCursorCSS:"none"]; // Not supported in IE
|
||||
[self _setCursorCSS:@"none"]; // Not supported in IE < 9
|
||||
}
|
||||
|
||||
+ (void)unhide
|
||||
@@ -121,6 +143,7 @@ var currentCursor = nil,
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
|
||||
|
||||
for (var i = 0, count = [platformWindows count]; i < count; i++)
|
||||
platformWindows[i]._DOMBodyElement.style.cursor = aString;
|
||||
#endif
|
||||
@@ -130,22 +153,34 @@ var currentCursor = nil,
|
||||
+ (CPCursor)_systemCursorWithName:(CPString)cursorName cssString:(CPString)aString hasImage:(BOOL)doesHaveImage
|
||||
{
|
||||
var cursor = cursors[cursorName];
|
||||
if (typeof cursor === 'undefined')
|
||||
|
||||
if (typeof cursor === "undefined")
|
||||
{
|
||||
var cssString;
|
||||
|
||||
if (doesHaveImage)
|
||||
cssString = @"url(" + [[CPBundle bundleForClass:self] resourcePath] + @"/CPCursor/" + cursorName + ".cur), " + aString;
|
||||
cssString = [CPString stringWithFormat:@"url(%@/CPCursor/%@.cur), %@", [[CPBundle bundleForClass:self] resourcePath], cursorName, aString];
|
||||
else
|
||||
cssString = aString
|
||||
{
|
||||
// IE <= 8 does not support some cursors, map them to supported cursors
|
||||
var ieLessThan9 = CPBrowserIsEngine(CPInternetExplorerBrowserEngine) && !CPFeatureIsCompatible(CPHTMLCanvasFeature);
|
||||
|
||||
if (ieLessThan9)
|
||||
cssString = ieCursorMap[aString] || aString;
|
||||
else
|
||||
cssString = aString;
|
||||
}
|
||||
|
||||
cursor = [[CPCursor alloc] initWithCSSString:cssString];
|
||||
cursors[cursorName] = cursor;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
+ (CPCursor)arrowCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:"default" hasImage:NO];
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"default" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)crosshairCursor
|
||||
@@ -163,6 +198,36 @@ var currentCursor = nil,
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"pointer" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeNorthwestCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nw-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeNorthwestSoutheastCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nwse-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeNortheastCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ne-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeNortheastSouthwestCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"nesw-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeSouthwestCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"sw-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeSoutheastCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"se-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeDownCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"s-resize" hasImage:NO];
|
||||
@@ -188,11 +253,21 @@ var currentCursor = nil,
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"col-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeEastWestCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ew-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpDownCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"row-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeNorthSouthCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"ns-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)operationNotAllowedCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"not-allowed" hasImage:NO];
|
||||
|
||||
@@ -114,4 +114,9 @@ CPDocModalWindowMask = 1 << 6;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyWindow
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -706,7 +706,11 @@ var CPScrollDestinationNone = 0,
|
||||
{
|
||||
if (![self hasThemeState:CPThemeStateEditing])
|
||||
return @"";
|
||||
#if PLATFORM(DOM)
|
||||
return [self _inputElement].value;
|
||||
#else
|
||||
return @"";
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
|
||||
@@ -651,6 +651,9 @@ var CPViewFlags = { },
|
||||
if (_window === aWindow)
|
||||
return;
|
||||
|
||||
// Unlike in Cocoa you can observe the window of a view.
|
||||
[self willChangeValueForKey:@"window"];
|
||||
|
||||
[[self window] _dirtyKeyViewLoop];
|
||||
|
||||
// Clear out first responder if we're the first responder and leaving.
|
||||
@@ -678,6 +681,8 @@ var CPViewFlags = { },
|
||||
[self viewDidMoveToWindow];
|
||||
|
||||
[[self window] _dirtyKeyViewLoop];
|
||||
|
||||
[self didChangeValueForKey:@"window"];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -186,6 +186,11 @@ CPWindowShadowStyleStandard = 0;
|
||||
CPWindowShadowStyleMenu = 1;
|
||||
CPWindowShadowStylePanel = 2;
|
||||
|
||||
CPWindowResizeStyleModern = 0;
|
||||
CPWindowResizeStyleLegacy = 1;
|
||||
CPWindowResizeStyle = CPWindowResizeStyleModern;
|
||||
CPWindowResizeSlop = 3;
|
||||
|
||||
var SHADOW_MARGIN_LEFT = 20.0,
|
||||
SHADOW_MARGIN_RIGHT = 19.0,
|
||||
SHADOW_MARGIN_TOP = 10.0,
|
||||
@@ -197,7 +202,8 @@ var SHADOW_MARGIN_LEFT = 20.0,
|
||||
var CPWindowSaveImage = nil,
|
||||
CPWindowSavingImage = nil,
|
||||
|
||||
CPWindowResizeTime = 0.2;
|
||||
CPWindowResizeTime = 0.2,
|
||||
CPWindowResizeStyleGlobalChangeNotification = @"CPWindowResizeStyleGlobalChangeNotification";
|
||||
|
||||
/*
|
||||
Keys for which action messages will be sent by default when unhandled, e.g. complete:.
|
||||
@@ -477,6 +483,11 @@ CPTexturedBackgroundWindowMask
|
||||
_keyViewLoopIsDirty = YES;
|
||||
|
||||
[self setShowsResizeIndicator:_styleMask & CPResizableWindowMask];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didReceiveResizeStyleChange:)
|
||||
name:CPWindowResizeStyleGlobalChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -901,6 +912,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
[_platformWindow orderFront:self];
|
||||
[_platformWindow order:CPWindowAbove window:self relativeTo:nil];
|
||||
#else
|
||||
_isVisible = YES;
|
||||
#endif
|
||||
|
||||
if (!CPApp._keyWindow)
|
||||
@@ -946,6 +959,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
[_platformWindow order:CPWindowOut window:self relativeTo:nil];
|
||||
#else
|
||||
_isVisible = NO;
|
||||
#endif
|
||||
|
||||
[self _updateMainAndKeyWindows];
|
||||
@@ -996,6 +1011,33 @@ CPTexturedBackgroundWindowMask
|
||||
return _isVisible;
|
||||
}
|
||||
|
||||
/*!
|
||||
Globally sets whether windows resize following the legacy style (using a resize thumb
|
||||
in the bottom right corner), or the modern style (no resize thumb, resizing
|
||||
can be done on all edges).
|
||||
*/
|
||||
+ (void)setGlobalResizeStyle:(int)aStyle
|
||||
{
|
||||
if (CPWindowResizeStyle === aStyle)
|
||||
return;
|
||||
|
||||
CPWindowResizeStyle = aStyle;
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowResizeStyleGlobalChangeNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)_didReceiveResizeStyleChange:(CPNotification)aNotification
|
||||
{
|
||||
[_windowView setShowsResizeIndicator:_styleMask & CPResizableWindowMask];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the global window resizing style.
|
||||
*/
|
||||
+ (int)globalResizeStyle
|
||||
{
|
||||
return CPWindowResizeStyle;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c YES if the window's resize indicator is showing. \c NO otherwise.
|
||||
*/
|
||||
@@ -1642,6 +1684,7 @@ CPTexturedBackgroundWindowMask
|
||||
// CPLeftMouseDown is needed for window moving and resizing to work.
|
||||
// CPMouseMoved is needed for rollover effects on title bar buttons.
|
||||
var sheet = [self attachedSheet];
|
||||
|
||||
if (sheet)
|
||||
{
|
||||
switch (type)
|
||||
@@ -1663,162 +1706,175 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CPFlagsChanged: return [[self firstResponder] flagsChanged:anEvent];
|
||||
case CPFlagsChanged:
|
||||
return [[self firstResponder] flagsChanged:anEvent];
|
||||
|
||||
case CPKeyUp: return [[self firstResponder] keyUp:anEvent];
|
||||
case CPKeyUp:
|
||||
return [[self firstResponder] keyUp:anEvent];
|
||||
|
||||
case CPKeyDown: if ([anEvent charactersIgnoringModifiers] === CPTabCharacter)
|
||||
{
|
||||
if ([anEvent modifierFlags] & CPShiftKeyMask)
|
||||
[self selectPreviousKeyView:self];
|
||||
else
|
||||
[self selectNextKeyView:self];
|
||||
case CPKeyDown:
|
||||
if ([anEvent charactersIgnoringModifiers] === CPTabCharacter)
|
||||
{
|
||||
if ([anEvent modifierFlags] & CPShiftKeyMask)
|
||||
[self selectPreviousKeyView:self];
|
||||
else
|
||||
[self selectNextKeyView:self];
|
||||
#if PLATFORM(DOM)
|
||||
// Make sure the browser doesn't try to do its own tab handling.
|
||||
// This is important or the browser might blur the shared text field or token field input field,
|
||||
// even that we just moved it to a new first responder.
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO]
|
||||
// Make sure the browser doesn't try to do its own tab handling.
|
||||
// This is important or the browser might blur the shared text field or token field input field,
|
||||
// even that we just moved it to a new first responder.
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO]
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else if ([anEvent charactersIgnoringModifiers] === CPBackTabCharacter)
|
||||
{
|
||||
var didTabBack = [self selectPreviousKeyView:self];
|
||||
if (didTabBack)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if ([anEvent charactersIgnoringModifiers] === CPBackTabCharacter)
|
||||
{
|
||||
var didTabBack = [self selectPreviousKeyView:self];
|
||||
|
||||
if (didTabBack)
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
// Make sure the browser doesn't try to do its own tab handling.
|
||||
// This is important or the browser might blur the shared text field or token field input field,
|
||||
// even that we just moved it to a new first responder.
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO]
|
||||
// Make sure the browser doesn't try to do its own tab handling.
|
||||
// This is important or the browser might blur the shared text field or token field input field,
|
||||
// even that we just moved it to a new first responder.
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO]
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return didTabBack;
|
||||
}
|
||||
return didTabBack;
|
||||
}
|
||||
|
||||
[[self firstResponder] keyDown:anEvent];
|
||||
[[self firstResponder] keyDown:anEvent];
|
||||
|
||||
// Trigger the default button if needed
|
||||
// FIXME: Is this only applicable in a sheet? See isse: #722.
|
||||
if (![self disableKeyEquivalentForDefaultButton])
|
||||
{
|
||||
var defaultButton = [self defaultButton],
|
||||
keyEquivalent = [defaultButton keyEquivalent],
|
||||
modifierMask = [defaultButton keyEquivalentModifierMask];
|
||||
// Trigger the default button if needed
|
||||
// FIXME: Is this only applicable in a sheet? See isse: #722.
|
||||
if (![self disableKeyEquivalentForDefaultButton])
|
||||
{
|
||||
var defaultButton = [self defaultButton],
|
||||
keyEquivalent = [defaultButton keyEquivalent],
|
||||
modifierMask = [defaultButton keyEquivalentModifierMask];
|
||||
|
||||
if ([anEvent _triggersKeyEquivalent:keyEquivalent withModifierMask:modifierMask])
|
||||
[[self defaultButton] performClick:self];
|
||||
}
|
||||
if ([anEvent _triggersKeyEquivalent:keyEquivalent withModifierMask:modifierMask])
|
||||
[[self defaultButton] performClick:self];
|
||||
}
|
||||
|
||||
return;
|
||||
return;
|
||||
|
||||
case CPScrollWheel: return [[_windowView hitTest:point] scrollWheel:anEvent];
|
||||
case CPScrollWheel:
|
||||
return [[_windowView hitTest:point] scrollWheel:anEvent];
|
||||
|
||||
case CPLeftMouseUp:
|
||||
case CPRightMouseUp: var hitTestedView = _leftMouseDownView,
|
||||
selector = type == CPRightMouseUp ? @selector(rightMouseUp:) : @selector(mouseUp:);
|
||||
case CPRightMouseUp:
|
||||
var hitTestedView = _leftMouseDownView,
|
||||
selector = type == CPRightMouseUp ? @selector(rightMouseUp:) : @selector(mouseUp:);
|
||||
|
||||
if (!hitTestedView)
|
||||
hitTestedView = [_windowView hitTest:point];
|
||||
if (!hitTestedView)
|
||||
hitTestedView = [_windowView hitTest:point];
|
||||
|
||||
[hitTestedView performSelector:selector withObject:anEvent];
|
||||
[hitTestedView performSelector:selector withObject:anEvent];
|
||||
|
||||
_leftMouseDownView = nil;
|
||||
_leftMouseDownView = nil;
|
||||
|
||||
return;
|
||||
|
||||
return;
|
||||
case CPLeftMouseDown:
|
||||
case CPRightMouseDown: _leftMouseDownView = [_windowView hitTest:point];
|
||||
case CPRightMouseDown:
|
||||
_leftMouseDownView = [_windowView hitTest:point] || _windowView;
|
||||
|
||||
if (_leftMouseDownView != _firstResponder && [_leftMouseDownView acceptsFirstResponder])
|
||||
[self makeFirstResponder:_leftMouseDownView];
|
||||
if (_leftMouseDownView != _firstResponder && [_leftMouseDownView acceptsFirstResponder])
|
||||
[self makeFirstResponder:_leftMouseDownView];
|
||||
|
||||
[CPApp activateIgnoringOtherApps:YES];
|
||||
[CPApp activateIgnoringOtherApps:YES];
|
||||
|
||||
var theWindow = [anEvent window],
|
||||
selector = type == CPRightMouseDown ? @selector(rightMouseDown:) : @selector(mouseDown:);
|
||||
var theWindow = [anEvent window],
|
||||
selector = type == CPRightMouseDown ? @selector(rightMouseDown:) : @selector(mouseDown:);
|
||||
|
||||
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded] && ![_leftMouseDownView needsPanelToBecomeKey])
|
||||
return [_leftMouseDownView performSelector:selector withObject:anEvent];
|
||||
else
|
||||
{
|
||||
// FIXME: delayed ordering?
|
||||
[self makeKeyAndOrderFront:self];
|
||||
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded] && ![_leftMouseDownView needsPanelToBecomeKey])
|
||||
return [_leftMouseDownView performSelector:selector withObject:anEvent];
|
||||
else
|
||||
{
|
||||
// FIXME: delayed ordering?
|
||||
[self makeKeyAndOrderFront:self];
|
||||
|
||||
if ([_leftMouseDownView acceptsFirstMouse:anEvent])
|
||||
return [_leftMouseDownView performSelector:selector withObject:anEvent];
|
||||
}
|
||||
break;
|
||||
if ([_leftMouseDownView acceptsFirstMouse:anEvent])
|
||||
return [_leftMouseDownView performSelector:selector withObject:anEvent];
|
||||
}
|
||||
break;
|
||||
|
||||
case CPLeftMouseDragged:
|
||||
case CPRightMouseDragged: if (!_leftMouseDownView)
|
||||
return [[_windowView hitTest:point] mouseDragged:anEvent];
|
||||
case CPRightMouseDragged:
|
||||
if (!_leftMouseDownView)
|
||||
return [[_windowView hitTest:point] mouseDragged:anEvent];
|
||||
|
||||
var selector;
|
||||
if (type == CPRightMouseDragged)
|
||||
{
|
||||
selector = @selector(rightMouseDragged:)
|
||||
if (![_leftMouseDownView respondsToSelector:selector])
|
||||
selector = nil;
|
||||
}
|
||||
var selector;
|
||||
|
||||
if (!selector)
|
||||
selector = @selector(mouseDragged:)
|
||||
if (type == CPRightMouseDragged)
|
||||
{
|
||||
selector = @selector(rightMouseDragged:)
|
||||
if (![_leftMouseDownView respondsToSelector:selector])
|
||||
selector = nil;
|
||||
}
|
||||
|
||||
return [_leftMouseDownView performSelector:selector withObject:anEvent];
|
||||
if (!selector)
|
||||
selector = @selector(mouseDragged:)
|
||||
|
||||
case CPMouseMoved: if (!_acceptsMouseMovedEvents)
|
||||
return;
|
||||
return [_leftMouseDownView performSelector:selector withObject:anEvent];
|
||||
|
||||
if (!_mouseEnteredStack)
|
||||
_mouseEnteredStack = [];
|
||||
case CPMouseMoved:
|
||||
[_windowView setCursorForLocation:point resizing:NO];
|
||||
|
||||
var hitTestView = [_windowView hitTest:point];
|
||||
if (!_acceptsMouseMovedEvents)
|
||||
return;
|
||||
|
||||
if ([_mouseEnteredStack count] && [_mouseEnteredStack lastObject] === hitTestView)
|
||||
return [hitTestView mouseMoved:anEvent];
|
||||
if (!_mouseEnteredStack)
|
||||
_mouseEnteredStack = [];
|
||||
|
||||
var view = hitTestView,
|
||||
mouseEnteredStack = [];
|
||||
var hitTestView = [_windowView hitTest:point];
|
||||
|
||||
while (view)
|
||||
{
|
||||
mouseEnteredStack.unshift(view);
|
||||
if ([_mouseEnteredStack count] && [_mouseEnteredStack lastObject] === hitTestView)
|
||||
return [hitTestView mouseMoved:anEvent];
|
||||
|
||||
view = [view superview];
|
||||
}
|
||||
var view = hitTestView,
|
||||
mouseEnteredStack = [];
|
||||
|
||||
var deviation = MIN(_mouseEnteredStack.length, mouseEnteredStack.length);
|
||||
while (view)
|
||||
{
|
||||
mouseEnteredStack.unshift(view);
|
||||
|
||||
while (deviation--)
|
||||
if (_mouseEnteredStack[deviation] === mouseEnteredStack[deviation])
|
||||
break;
|
||||
view = [view superview];
|
||||
}
|
||||
|
||||
var index = deviation + 1,
|
||||
count = _mouseEnteredStack.length;
|
||||
var deviation = MIN(_mouseEnteredStack.length, mouseEnteredStack.length);
|
||||
|
||||
if (index < count)
|
||||
{
|
||||
var event = [CPEvent mouseEventWithType:CPMouseExited location:point modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:_windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
|
||||
while (deviation--)
|
||||
if (_mouseEnteredStack[deviation] === mouseEnteredStack[deviation])
|
||||
break;
|
||||
|
||||
for (; index < count; ++index)
|
||||
[_mouseEnteredStack[index] mouseExited:event];
|
||||
}
|
||||
var index = deviation + 1,
|
||||
count = _mouseEnteredStack.length;
|
||||
|
||||
index = deviation + 1;
|
||||
count = mouseEnteredStack.length;
|
||||
if (index < count)
|
||||
{
|
||||
var event = [CPEvent mouseEventWithType:CPMouseExited location:point modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:_windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
|
||||
|
||||
if (index < count)
|
||||
{
|
||||
var event = [CPEvent mouseEventWithType:CPMouseEntered location:point modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:_windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
|
||||
for (; index < count; ++index)
|
||||
[_mouseEnteredStack[index] mouseExited:event];
|
||||
}
|
||||
|
||||
for (; index < count; ++index)
|
||||
[mouseEnteredStack[index] mouseEntered:event];
|
||||
}
|
||||
index = deviation + 1;
|
||||
count = mouseEnteredStack.length;
|
||||
|
||||
_mouseEnteredStack = mouseEnteredStack;
|
||||
if (index < count)
|
||||
{
|
||||
var event = [CPEvent mouseEventWithType:CPMouseEntered location:point modifierFlags:[anEvent modifierFlags] timestamp:[anEvent timestamp] windowNumber:_windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
|
||||
|
||||
[hitTestView mouseMoved:anEvent];
|
||||
for (; index < count; ++index)
|
||||
[mouseEnteredStack[index] mouseEntered:event];
|
||||
}
|
||||
|
||||
_mouseEnteredStack = mouseEnteredStack;
|
||||
|
||||
[hitTestView mouseMoved:anEvent];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2158,6 +2214,7 @@ CPTexturedBackgroundWindowMask
|
||||
return;
|
||||
|
||||
var documents = [_windowController documents];
|
||||
|
||||
if ([documents count])
|
||||
{
|
||||
var index = [documents indexOfObject:[_windowController document]];
|
||||
@@ -3229,6 +3286,15 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
return CGRectContainsPoint(_frame, aPoint);
|
||||
}
|
||||
|
||||
- (BOOL)_isValidMousePoint:(CGPoint)aPoint
|
||||
{
|
||||
// If we are using the new resizing mode, mouse events are valid
|
||||
// outside the window's frame.
|
||||
var mouseFrame = ((_styleMask & CPResizableWindowMask) && (CPWindowResizeStyle === CPWindowResizeStyleModern)) ? _CGRectInset(_frame, -CPWindowResizeSlop, -CPWindowResizeSlop) : _frame;
|
||||
|
||||
return CGRectContainsPoint(mouseFrame, aPoint);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPWindow (Deprecated)
|
||||
|
||||
@@ -334,13 +334,13 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
|
||||
[self _updateCloseButton];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
- (BOOL)couldBeMoveEvent:(CPEvent)anEvent
|
||||
{
|
||||
if (![_headView isHidden])
|
||||
if (CGRectContainsPoint([_headView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||
return [self trackMoveWithEvent:anEvent];
|
||||
return YES;
|
||||
|
||||
[super mouseDown:anEvent];
|
||||
return [super couldBeMoveEvent:anEvent];
|
||||
}
|
||||
|
||||
- (void)_enableSheet:(BOOL)enable
|
||||
|
||||
@@ -24,7 +24,18 @@
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
var _CPWindowViewResizeIndicatorImage = nil;
|
||||
var _CPWindowViewResizeIndicatorImage = nil,
|
||||
_CPWindowViewCornerResizeRectWidth = 10,
|
||||
|
||||
_CPWindowViewResizeRegionNone = -1,
|
||||
_CPWindowViewResizeRegionTopLeft = 0,
|
||||
_CPWindowViewResizeRegionTop = 1,
|
||||
_CPWindowViewResizeRegionTopRight = 2,
|
||||
_CPWindowViewResizeRegionRight = 3,
|
||||
_CPWindowViewResizeRegionBottomRight = 4,
|
||||
_CPWindowViewResizeRegionBottom = 5,
|
||||
_CPWindowViewResizeRegionBottomLeft = 6,
|
||||
_CPWindowViewResizeRegionLeft = 7;
|
||||
|
||||
@implementation _CPWindowView : CPView
|
||||
{
|
||||
@@ -38,6 +49,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
// BOOL _isAnimatingToolbar;
|
||||
|
||||
CGRect _resizeFrame;
|
||||
int _resizeRegion;
|
||||
CGPoint _mouseDraggedPoint;
|
||||
|
||||
CGRect _cachedScreenFrame;
|
||||
@@ -50,17 +62,17 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
if (self !== [_CPWindowView class])
|
||||
return;
|
||||
|
||||
_CPWindowViewResizeIndicatorImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPWindow class]] pathForResource:@"_CPWindowView/_CPWindowViewResizeIndicator.png"] size:CGSizeMake(12.0, 12.0)];
|
||||
_CPWindowViewResizeIndicatorImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPWindow class]] pathForResource:@"_CPWindowView/_CPWindowViewResizeIndicator.png"] size:_CGSizeMake(12.0, 12.0)];
|
||||
}
|
||||
|
||||
+ (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
|
||||
{
|
||||
return CGRectMakeCopy(aFrameRect);
|
||||
return _CGRectMakeCopy(aFrameRect);
|
||||
}
|
||||
|
||||
+ (CGRect)frameRectForContentRect:(CGRect)aContentRect
|
||||
{
|
||||
return CGRectMakeCopy(aContentRect);
|
||||
return _CGRectMakeCopy(aContentRect);
|
||||
}
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
@@ -81,7 +93,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
var toolbarHeight = _CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
contentRect.origin.y += toolbarHeight;
|
||||
contentRect.size.height -= toolbarHeight;
|
||||
@@ -97,7 +109,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
var toolbarHeight = _CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
frameRect.origin.y -= toolbarHeight;
|
||||
frameRect.size.height += toolbarHeight;
|
||||
@@ -113,8 +125,8 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
if (self)
|
||||
{
|
||||
_styleMask = aStyleMask;
|
||||
_resizeIndicatorOffset = CGSizeMakeZero();
|
||||
_toolbarOffset = CGSizeMakeZero();
|
||||
_resizeIndicatorOffset = _CGSizeMakeZero();
|
||||
_toolbarOffset = _CGSizeMakeZero();
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -135,48 +147,301 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
var theWindow = [self window];
|
||||
var theWindow = [self window],
|
||||
couldResize = _styleMask & CPResizableWindowMask;
|
||||
|
||||
if ((_styleMask & CPResizableWindowMask) && _resizeIndicator)
|
||||
couldResize = couldResize && (
|
||||
(CPWindowResizeStyle === CPWindowResizeStyleModern) ||
|
||||
((CPWindowResizeStyle === CPWindowResizeStyleLegacy) && _resizeIndicator));
|
||||
|
||||
if (couldResize)
|
||||
{
|
||||
// FIXME: This should be better
|
||||
var frame = [_resizeIndicator frame];
|
||||
var theWindow = [self window],
|
||||
windowFrame = [theWindow frame],
|
||||
shouldResize = NO;
|
||||
|
||||
if (CGRectContainsPoint(frame, [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||
if (CPWindowResizeStyle === CPWindowResizeStyleModern)
|
||||
{
|
||||
var globalPoint = [theWindow convertBaseToGlobal:[anEvent locationInWindow]];
|
||||
|
||||
_resizeRegion = [self resizeRegionForPoint:globalPoint];
|
||||
shouldResize = _resizeRegion !== _CPWindowViewResizeRegionNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Extend the resize frame to the edge of the window frame
|
||||
var resizeFrame = [_resizeIndicator frame];
|
||||
resizeFrame.size.width = _CGRectGetWidth(windowFrame) - _CGRectGetMinX(resizeFrame);
|
||||
resizeFrame.size.height = _CGRectGetHeight(windowFrame) - _CGRectGetMinY(resizeFrame);
|
||||
|
||||
var localPoint = [self convertPoint:[anEvent locationInWindow] fromView:nil];
|
||||
shouldResize = CGRectContainsPoint(resizeFrame, localPoint);
|
||||
|
||||
// When in legacy mode, the only possible resize region is lower right
|
||||
_resizeRegion = shouldResize ? _CPWindowViewResizeRegionBottomRight : _CPWindowViewResizeRegionNone;
|
||||
}
|
||||
|
||||
if (shouldResize)
|
||||
return [self trackResizeWithEvent:anEvent];
|
||||
}
|
||||
|
||||
if ([theWindow isMovable] && [theWindow isMovableByWindowBackground])
|
||||
if ([self couldBeMoveEvent:anEvent])
|
||||
[self trackMoveWithEvent:anEvent];
|
||||
else
|
||||
[super mouseDown:anEvent];
|
||||
}
|
||||
|
||||
- (BOOL)couldBeMoveEvent:(CPEvent)anEvent
|
||||
{
|
||||
var theWindow = [self window];
|
||||
|
||||
return [theWindow isMovable] && [theWindow isMovableByWindowBackground];
|
||||
}
|
||||
|
||||
/*
|
||||
aPoint should be in global coordinates
|
||||
*/
|
||||
- (int)resizeRegionForPoint:(CGPoint)aPoint
|
||||
{
|
||||
/*
|
||||
There are 8 possible resize rects, 1 for each side and 1 for each corner.
|
||||
The four corner rects are the same size, and the top/bottom and left/right
|
||||
rects are the same size. So to save calculations, we can just create
|
||||
3 rects and move them around to do hit testing. Start with the corners
|
||||
and then do left/right and top/bottom.
|
||||
*/
|
||||
var frame = [[self window] frame],
|
||||
rect = _CGRectMake(frame.origin.x - CPWindowResizeSlop,
|
||||
frame.origin.y - CPWindowResizeSlop,
|
||||
_CPWindowViewCornerResizeRectWidth + CPWindowResizeSlop,
|
||||
_CPWindowViewCornerResizeRectWidth + CPWindowResizeSlop);
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionTopLeft;
|
||||
|
||||
rect.origin.x = _CGRectGetMaxX(frame) - _CPWindowViewCornerResizeRectWidth;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionTopRight;
|
||||
|
||||
rect.origin.y = _CGRectGetMaxY(frame) - _CPWindowViewCornerResizeRectWidth;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionBottomRight;
|
||||
|
||||
rect.origin.x = frame.origin.x - CPWindowResizeSlop;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionBottomLeft;
|
||||
|
||||
rect = _CGRectMake(rect.origin.x,
|
||||
frame.origin.y + _CPWindowViewCornerResizeRectWidth,
|
||||
CPWindowResizeSlop * 2,
|
||||
_CGRectGetHeight(frame) - (_CPWindowViewCornerResizeRectWidth * 2));
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionLeft;
|
||||
|
||||
rect.origin.x = _CGRectGetMaxX(frame) - CPWindowResizeSlop;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionRight;
|
||||
|
||||
rect = _CGRectMake(frame.origin.x + _CPWindowViewCornerResizeRectWidth,
|
||||
frame.origin.y - CPWindowResizeSlop,
|
||||
_CGRectGetWidth(frame) - (_CPWindowViewCornerResizeRectWidth * 2),
|
||||
CPWindowResizeSlop * 2);
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionTop;
|
||||
|
||||
rect.origin.y = _CGRectGetMaxY(frame) - CPWindowResizeSlop;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionBottom;
|
||||
|
||||
return _CPWindowViewResizeRegionNone;
|
||||
}
|
||||
|
||||
/*
|
||||
aPoint is in window coordinates
|
||||
*/
|
||||
- (void)setCursorForLocation:(CGPoint)aPoint resizing:(BOOL)isResizing
|
||||
{
|
||||
if (!(_styleMask & CPResizableWindowMask) ||
|
||||
(CPWindowResizeStyle !== CPWindowResizeStyleModern))
|
||||
return;
|
||||
|
||||
var theWindow = [self window],
|
||||
resizeRegion = isResizing ? _resizeRegion : [self resizeRegionForPoint:[theWindow convertBaseToGlobal:aPoint]],
|
||||
minSize = nil,
|
||||
maxSize = nil,
|
||||
frameSize;
|
||||
|
||||
if (resizeRegion !== _CPWindowViewResizeRegionNone)
|
||||
{
|
||||
minSize = [theWindow minSize];
|
||||
maxSize = [theWindow maxSize];
|
||||
frameSize = [theWindow frame].size;
|
||||
}
|
||||
|
||||
switch (resizeRegion)
|
||||
{
|
||||
case _CPWindowViewResizeRegionTopLeft:
|
||||
if (minSize && _CGSizeEqualToSize(frameSize, minSize))
|
||||
[[CPCursor resizeNorthwestCursor] set];
|
||||
else if (maxSize && _CGSizeEqualToSize(frameSize, maxSize))
|
||||
[[CPCursor resizeSoutheastCursor] set];
|
||||
else
|
||||
[[CPCursor resizeNorthwestSoutheastCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionTop:
|
||||
if (minSize && (frameSize.height === minSize.height))
|
||||
[[CPCursor resizeUpCursor] set];
|
||||
else if (maxSize && (frameSize.height === maxSize.height))
|
||||
[[CPCursor resizeDownCursor] set];
|
||||
else
|
||||
[[CPCursor resizeNorthSouthCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionTopRight:
|
||||
if (minSize && _CGSizeEqualToSize(frameSize, minSize))
|
||||
[[CPCursor resizeNortheastCursor] set];
|
||||
else if (maxSize && _CGSizeEqualToSize(frameSize, maxSize))
|
||||
[[CPCursor resizeSouthwestCursor] set];
|
||||
else
|
||||
[[CPCursor resizeNortheastSouthwestCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionRight:
|
||||
if (minSize && (frameSize.width === minSize.width))
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else if (maxSize && (frameSize.width === maxSize.width))
|
||||
[[CPCursor resizeLeftCursor] set];
|
||||
else
|
||||
[[CPCursor resizeEastWestCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionBottomRight:
|
||||
if (minSize && _CGSizeEqualToSize(frameSize, minSize))
|
||||
[[CPCursor resizeSoutheastCursor] set];
|
||||
else if (maxSize && _CGSizeEqualToSize(frameSize, maxSize))
|
||||
[[CPCursor resizeNorthwestCursor] set];
|
||||
else
|
||||
[[CPCursor resizeNorthwestSoutheastCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionBottom:
|
||||
if (minSize && (frameSize.height === minSize.height))
|
||||
[[CPCursor resizeDownCursor] set];
|
||||
else if (maxSize && (frameSize.height === maxSize.height))
|
||||
[[CPCursor resizeUpCursor] set];
|
||||
else
|
||||
[[CPCursor resizeNorthSouthCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionBottomLeft:
|
||||
if (minSize && _CGSizeEqualToSize(frameSize, minSize))
|
||||
[[CPCursor resizeSouthwestCursor] set];
|
||||
else if (maxSize && _CGSizeEqualToSize(frameSize, maxSize))
|
||||
[[CPCursor resizeNortheastCursor] set];
|
||||
else
|
||||
[[CPCursor resizeNortheastSouthwestCursor] set];
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionLeft:
|
||||
if (minSize && (frameSize.width === minSize.width))
|
||||
[[CPCursor resizeLeftCursor] set];
|
||||
else if (maxSize && (frameSize.width === maxSize.width))
|
||||
[[CPCursor resizeRightCursor] set];
|
||||
else
|
||||
[[CPCursor resizeEastWestCursor] set];
|
||||
break;
|
||||
|
||||
default:
|
||||
[[CPCursor arrowCursor] set];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)trackResizeWithEvent:(CPEvent)anEvent
|
||||
{
|
||||
var location = [anEvent locationInWindow],
|
||||
type = [anEvent type];
|
||||
var type = [anEvent type];
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
return;
|
||||
|
||||
var theWindow = [self window];
|
||||
var location = [anEvent locationInWindow],
|
||||
theWindow = [self window],
|
||||
globalLocation = [theWindow convertBaseToGlobal:location],
|
||||
frame = [theWindow frame];
|
||||
|
||||
if (type === CPLeftMouseDown)
|
||||
{
|
||||
var frame = [theWindow frame];
|
||||
|
||||
_resizeFrame = CGRectMake(location.x, location.y, CGRectGetWidth(frame), CGRectGetHeight(frame));
|
||||
_mouseDraggedPoint = _CGPointMakeCopy(globalLocation);
|
||||
_resizeFrame = _CGRectMakeCopy(frame);
|
||||
}
|
||||
|
||||
else if (type === CPLeftMouseDragged)
|
||||
{
|
||||
var newSize = CGSizeMake(CGRectGetWidth(_resizeFrame) + location.x - CGRectGetMinX(_resizeFrame), CGRectGetHeight(_resizeFrame) + location.y - CGRectGetMinY(_resizeFrame));
|
||||
var diffX = globalLocation.x - _mouseDraggedPoint.x,
|
||||
diffY = globalLocation.y - _mouseDraggedPoint.y,
|
||||
newX = _CGRectGetMinX(_resizeFrame),
|
||||
newY = _CGRectGetMinY(_resizeFrame),
|
||||
newWidth = _CGRectGetWidth(_resizeFrame),
|
||||
newHeight = _CGRectGetHeight(_resizeFrame),
|
||||
minSize = [theWindow minSize],
|
||||
maxSize = [theWindow maxSize];
|
||||
|
||||
if (theWindow._isSheet && theWindow._parentView && (theWindow._frame.size.width !== newSize.width))
|
||||
// Calculate x and width first
|
||||
switch (_resizeRegion)
|
||||
{
|
||||
case _CPWindowViewResizeRegionTopLeft:
|
||||
case _CPWindowViewResizeRegionLeft:
|
||||
case _CPWindowViewResizeRegionBottomLeft:
|
||||
if (minSize && diffX > 0)
|
||||
diffX = MIN(newWidth - minSize.width, diffX);
|
||||
else if (maxSize && diffX < 0)
|
||||
diffX = MAX(newWidth - maxSize.width, diffX);
|
||||
|
||||
newX += diffX,
|
||||
newWidth -= diffX;
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionTopRight:
|
||||
case _CPWindowViewResizeRegionRight:
|
||||
case _CPWindowViewResizeRegionBottomRight:
|
||||
newWidth += diffX;
|
||||
break;
|
||||
}
|
||||
|
||||
// Now calculate y and height
|
||||
switch (_resizeRegion)
|
||||
{
|
||||
case _CPWindowViewResizeRegionTopLeft:
|
||||
case _CPWindowViewResizeRegionTop:
|
||||
case _CPWindowViewResizeRegionTopRight:
|
||||
if (minSize && diffY > 0)
|
||||
diffY = MIN(newHeight - minSize.height, diffY);
|
||||
else if (maxSize && diffY < 0)
|
||||
diffY = MAX(newHeight - maxSize.height, diffY);
|
||||
|
||||
newY += diffY,
|
||||
newHeight -= diffY;
|
||||
break;
|
||||
|
||||
case _CPWindowViewResizeRegionBottomLeft:
|
||||
case _CPWindowViewResizeRegionBottom:
|
||||
case _CPWindowViewResizeRegionBottomRight:
|
||||
newHeight += diffY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (theWindow._isSheet && theWindow._parentView && (frame.size.width !== newWidth))
|
||||
[theWindow._parentView _setAttachedSheetFrameOrigin];
|
||||
|
||||
[theWindow setFrameSize:newSize];
|
||||
[theWindow setFrame:_CGRectMake(newX, newY, newWidth, newHeight)];
|
||||
[self setCursorForLocation:location resizing:YES];
|
||||
}
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
|
||||
@@ -200,8 +465,8 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
var restrictedPoint = CGPointMake(0, 0);
|
||||
|
||||
restrictedPoint.x = MIN(MAX(aPoint.x, -_frame.size.width + 4.0), CGRectGetMaxX(visibleFrame) - 4.0);
|
||||
restrictedPoint.y = MIN(MAX(aPoint.y, minPointY), CGRectGetMaxY(visibleFrame) - 8.0);
|
||||
restrictedPoint.x = MIN(MAX(aPoint.x, -_frame.size.width + 4.0), _CGRectGetMaxX(visibleFrame) - 4.0);
|
||||
restrictedPoint.y = MIN(MAX(aPoint.y, minPointY), _CGRectGetMaxY(visibleFrame) - 8.0);
|
||||
|
||||
return restrictedPoint;
|
||||
}
|
||||
@@ -251,12 +516,12 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
|
||||
{
|
||||
if (shouldShowResizeIndicator)
|
||||
if (shouldShowResizeIndicator && CPWindowResizeStyle === CPWindowResizeStyleLegacy)
|
||||
{
|
||||
var size = [_CPWindowViewResizeIndicatorImage size],
|
||||
boundsSize = [self frame].size;
|
||||
|
||||
_resizeIndicator = [[CPImageView alloc] initWithFrame:CGRectMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height, size.width, size.height)];
|
||||
_resizeIndicator = [[CPImageView alloc] initWithFrame:_CGRectMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height, size.width, size.height)];
|
||||
|
||||
[_resizeIndicator setImage:_CPWindowViewResizeIndicatorImage];
|
||||
[_resizeIndicator setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
|
||||
@@ -325,7 +590,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
if (!_toolbarView || [_toolbarView isHidden])
|
||||
return [self toolbarOffset].height;
|
||||
|
||||
return CGRectGetMaxY([_toolbarView frame]);
|
||||
return _CGRectGetMaxY([_toolbarView frame]);
|
||||
}
|
||||
|
||||
- (_CPToolbarView)toolbarView
|
||||
@@ -337,14 +602,14 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
{
|
||||
var theWindow = [self window],
|
||||
bounds = [self bounds],
|
||||
width = CGRectGetWidth(bounds);
|
||||
width = _CGRectGetWidth(bounds);
|
||||
|
||||
if ([[theWindow toolbar] isVisible])
|
||||
{
|
||||
var toolbarView = [self toolbarView],
|
||||
toolbarOffset = [self toolbarOffset];
|
||||
|
||||
[toolbarView setFrame:CGRectMake(toolbarOffset.width, toolbarOffset.height, width, CGRectGetHeight([toolbarView frame]))];
|
||||
[toolbarView setFrame:_CGRectMake(toolbarOffset.width, toolbarOffset.height, width, _CGRectGetHeight([toolbarView frame]))];
|
||||
}
|
||||
|
||||
if ([self showsResizeIndicator])
|
||||
|
||||
@@ -1208,7 +1208,7 @@ var resizeTimer = nil;
|
||||
windowNumber = [_mouseDownWindow windowNumber];
|
||||
else
|
||||
{
|
||||
var theWindow = [self hitTest:location];
|
||||
var theWindow = [self _mouseHitTest:location];
|
||||
|
||||
if ((aDOMEvent.type === CPDOMEventMouseDown) && theWindow)
|
||||
_mouseDownWindow = theWindow;
|
||||
@@ -1486,7 +1486,17 @@ var resizeTimer = nil;
|
||||
return StopContextMenuDOMEventPropagation;
|
||||
}
|
||||
|
||||
- (CPWindow)_mouseHitTest:(CPPoint)location
|
||||
{
|
||||
return [self _hitTest:location withTest:@selector(_isValidMousePoint:)]
|
||||
}
|
||||
|
||||
- (CPWindow)hitTest:(CPPoint)location
|
||||
{
|
||||
return [self _hitTest:location withTest:@selector(containsPoint:)]
|
||||
}
|
||||
|
||||
- (CPWindow)_hitTest:(CPPoint)location withTest:(SEL)aTest
|
||||
{
|
||||
if (self._only)
|
||||
return self._only;
|
||||
@@ -1505,7 +1515,7 @@ var resizeTimer = nil;
|
||||
{
|
||||
var candidateWindow = windows[windowCount];
|
||||
|
||||
if (!candidateWindow._ignoresMouseEvents && [candidateWindow containsPoint:location])
|
||||
if (!candidateWindow._ignoresMouseEvents && [candidateWindow performSelector:aTest withObject:location])
|
||||
theWindow = candidateWindow;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 274 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 81 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 105 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 105 B |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 234 B |
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 224 B |
|
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 303 B |
|
Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 213 B |
|
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 190 B |
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 213 B |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 83 B |
|
Before Width: | Height: | Size: 112 B After Width: | Height: | Size: 106 B |
|
Before Width: | Height: | Size: 208 B After Width: | Height: | Size: 189 B |
|
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 196 B |
|
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 205 B |
|
Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 74 B After Width: | Height: | Size: 72 B |
|
Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 416 B After Width: | Height: | Size: 415 B |
|
Before Width: | Height: | Size: 150 B After Width: | Height: | Size: 138 B |
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 129 B |
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 134 B |
|
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 428 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 804 B |
|
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 160 B |
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 134 B |
|
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 173 B |
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 97 B |
|
Before Width: | Height: | Size: 72 B After Width: | Height: | Size: 71 B |
|
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 92 B |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 190 B |
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 191 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 77 B After Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 77 B After Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 87 B |
|
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 122 B |
|
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 122 B |
|
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 170 B After Width: | Height: | Size: 142 B |
|
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 256 B |
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 263 B |
|
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 76 B |
|
Before Width: | Height: | Size: 77 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 77 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 104 B |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 77 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 104 B |
|
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 98 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 76 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 78 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 96 B |
|
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 121 B |
|
Before Width: | Height: | Size: 78 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 97 B |
|
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 97 B |