Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1cb388827 | ||
|
|
2e1a0da0e4 | ||
|
|
47d0537ae4 | ||
|
|
81c2f219ee | ||
|
|
5e53a2326c | ||
|
|
0394731fdf | ||
|
|
a426aec2c9 | ||
|
|
dbad10f060 | ||
|
|
3985ef24e3 | ||
|
|
ff4a79d6cd | ||
|
|
9b017de39c |
@@ -1,8 +0,0 @@
|
||||
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,33 +75,32 @@ 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 : CPObject
|
||||
@implementation CPAlert : CPView
|
||||
{
|
||||
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;
|
||||
|
||||
_CPAlertThemeView _themeView @accessors(property=themeView, readonly);
|
||||
CPWindow _window @accessors(property=window,readonly);
|
||||
int _defaultWindowStyle;
|
||||
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
|
||||
@@ -165,7 +164,6 @@ CPCriticalAlertStyle = 2;
|
||||
_showHelp = NO;
|
||||
_needsLayout = YES;
|
||||
_defaultWindowStyle = CPTitledWindowMask;
|
||||
_themeView = [_CPAlertThemeView new];
|
||||
|
||||
_messageLabel = [CPTextField labelWithTitle:@"Alert"];
|
||||
_alertImageView = [[CPImageView alloc] init];
|
||||
@@ -182,11 +180,6 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
#pragma mark Accessors
|
||||
|
||||
- (CPTheme)theme
|
||||
{
|
||||
return [_themeView theme];
|
||||
}
|
||||
|
||||
/*!
|
||||
set the theme to use
|
||||
|
||||
@@ -204,20 +197,9 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
_window = nil; // will be regenerated at next layout
|
||||
_needsLayout = YES;
|
||||
[_themeView setTheme:aTheme];
|
||||
[super 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
|
||||
@@ -352,16 +334,16 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (void)_layoutMessageView
|
||||
{
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
sizeWithFontCorrection = 6.0,
|
||||
messageLabelWidth,
|
||||
messageLabelTextSize;
|
||||
|
||||
[_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 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 setLineBreakMode:CPLineBreakByWordWrapping];
|
||||
|
||||
messageLabelWidth = CGRectGetWidth([[_window contentView] frame]) - inset.left - inset.right;
|
||||
@@ -375,18 +357,18 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (void)_layoutInformativeView
|
||||
{
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
sizeWithFontCorrection = 6.0,
|
||||
informativeLabelWidth,
|
||||
informativeLabelOriginY,
|
||||
informativeLabelTextSize;
|
||||
|
||||
[_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 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 setLineBreakMode:CPLineBreakByWordWrapping];
|
||||
|
||||
informativeLabelWidth = CGRectGetWidth([[_window contentView] frame]) - inset.left - inset.right;
|
||||
@@ -404,8 +386,8 @@ CPCriticalAlertStyle = 2;
|
||||
if (!_accessoryView)
|
||||
return;
|
||||
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
accessoryViewWidth = CGRectGetWidth([[_window contentView] frame]) - inset.left - inset.right,
|
||||
accessoryViewOriginY = CGRectGetMaxY([_informativeLabel frame]) + defaultElementsMargin;
|
||||
|
||||
@@ -421,16 +403,16 @@ CPCriticalAlertStyle = 2;
|
||||
if (!_showSuppressionButton)
|
||||
return;
|
||||
|
||||
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"],
|
||||
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"],
|
||||
suppressionButtonViewOriginY = CGRectGetMaxY([(_accessoryView || _informativeLabel) frame]) + defaultElementsMargin + suppressionViewYOffset;
|
||||
|
||||
[_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 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 sizeToFit];
|
||||
|
||||
[_suppressionButton setFrameOrigin:CGPointMake(inset.left + suppressionViewXOffset, suppressionButtonViewOriginY)];
|
||||
@@ -442,12 +424,12 @@ CPCriticalAlertStyle = 2;
|
||||
*/
|
||||
- (CGSize)_layoutButtonsFromView:(CPView)lastView
|
||||
{
|
||||
var inset = [_themeView currentValueForThemeAttribute:@"content-inset"],
|
||||
minimumSize = [_themeView currentValueForThemeAttribute:@"size"],
|
||||
buttonOffset = [_themeView currentValueForThemeAttribute:@"button-offset"],
|
||||
helpLeftOffset = [_themeView currentValueForThemeAttribute:@"help-image-left-offset"],
|
||||
var inset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
minimumSize = [self currentValueForThemeAttribute:@"size"],
|
||||
buttonOffset = [self currentValueForThemeAttribute:@"button-offset"],
|
||||
helpLeftOffset = [self currentValueForThemeAttribute:@"help-image-left-offset"],
|
||||
aRepresentativeButton = [_buttons objectAtIndex:0],
|
||||
defaultElementsMargin = [_themeView currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
defaultElementsMargin = [self currentValueForThemeAttribute:@"default-elements-margin"],
|
||||
panelSize = [[_window contentView] frame].size,
|
||||
buttonsOriginY,
|
||||
offsetX;
|
||||
@@ -479,8 +461,8 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
if (_showHelp)
|
||||
{
|
||||
var helpImage = [_themeView currentValueForThemeAttribute:@"help-image"],
|
||||
helpImagePressed = [_themeView currentValueForThemeAttribute:@"help-image-pressed"],
|
||||
var helpImage = [self currentValueForThemeAttribute:@"help-image"],
|
||||
helpImagePressed = [self currentValueForThemeAttribute:@"help-image-pressed"],
|
||||
helpImageSize = helpImage ? [helpImage size] : CGSizeMakeZero(),
|
||||
helpFrame = CGRectMake(helpLeftOffset, buttonsOriginY, helpImageSize.width, helpImageSize.height);
|
||||
|
||||
@@ -505,7 +487,7 @@ CPCriticalAlertStyle = 2;
|
||||
if (!_window)
|
||||
[self _createWindowWithStyle:nil];
|
||||
|
||||
var iconOffset = [_themeView currentValueForThemeAttribute:@"image-offset"],
|
||||
var iconOffset = [self currentValueForThemeAttribute:@"image-offset"],
|
||||
theImage = _icon,
|
||||
finalSize;
|
||||
|
||||
@@ -513,13 +495,13 @@ CPCriticalAlertStyle = 2;
|
||||
switch (_alertStyle)
|
||||
{
|
||||
case CPWarningAlertStyle:
|
||||
theImage = [_themeView currentValueForThemeAttribute:@"warning-image"];
|
||||
theImage = [self currentValueForThemeAttribute:@"warning-image"];
|
||||
break;
|
||||
case CPInformationalAlertStyle:
|
||||
theImage = [_themeView currentValueForThemeAttribute:@"information-image"];
|
||||
theImage = [self currentValueForThemeAttribute:@"information-image"];
|
||||
break;
|
||||
case CPCriticalAlertStyle:
|
||||
theImage = [_themeView currentValueForThemeAttribute:@"error-image"];
|
||||
theImage = [self currentValueForThemeAttribute:@"error-image"];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -537,7 +519,7 @@ CPCriticalAlertStyle = 2;
|
||||
if (_showSuppressionButton)
|
||||
lastView = _suppressionButton;
|
||||
else if (_accessoryView)
|
||||
lastView = _accessoryView;
|
||||
lastView = _accessoryView
|
||||
|
||||
finalSize = [self _layoutButtonsFromView:lastView];
|
||||
if ([_window styleMask] & CPDocModalWindowMask)
|
||||
@@ -610,10 +592,9 @@ CPCriticalAlertStyle = 2;
|
||||
- (void)_createWindowWithStyle:(int)forceStyle
|
||||
{
|
||||
var frame = CGRectMakeZero();
|
||||
frame.size = [_themeView currentValueForThemeAttribute:@"size"];
|
||||
frame.size = [self currentValueForThemeAttribute:@"size"];
|
||||
|
||||
_window = [[CPWindow alloc] initWithContentRect:frame styleMask:forceStyle || _defaultWindowStyle];
|
||||
[_window setLevel:CPStatusWindowLevel];
|
||||
|
||||
if (_title)
|
||||
[_window setTitle:_title];
|
||||
@@ -651,8 +632,8 @@ CPCriticalAlertStyle = 2;
|
||||
{
|
||||
if ([_window isSheet])
|
||||
{
|
||||
[_window orderOut:nil];
|
||||
[CPApp endSheet:_window returnCode:[aSender tag]];
|
||||
[_window orderOut:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -668,19 +649,17 @@ 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];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPAlertThemeView : CPView
|
||||
#pragma mark Theme Attributes
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
@@ -689,63 +668,42 @@ CPCriticalAlertStyle = 2;
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[
|
||||
CGSizeMake(400.0, 110.0),
|
||||
CGInsetMake(15, 15, 15, 50), 6, 10,
|
||||
CPJustifiedTextAlignment,
|
||||
[CPColor blackColor],
|
||||
[CPFont boldSystemFontOfSize:13.0],
|
||||
[CPNull null], CGSizeMakeZero(),
|
||||
CPJustifiedTextAlignment,
|
||||
[CPColor blackColor],
|
||||
[CPFont systemFontOfSize:12.0],
|
||||
[CPNull null], CGSizeMakeZero(),
|
||||
CGPointMake(15, 12),
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
0.0,
|
||||
0.0,
|
||||
3.0,
|
||||
[CPColor blackColor],
|
||||
[CPFont systemFontOfSize:12.0],
|
||||
[CPNull null],
|
||||
0.0
|
||||
]
|
||||
forKeys:[
|
||||
@"size",
|
||||
@"content-inset",
|
||||
@"informative-offset",
|
||||
@"button-offset",
|
||||
@"message-text-alignment",
|
||||
@"message-text-color",
|
||||
@"message-text-font",
|
||||
@"message-text-shadow-color",
|
||||
@"message-text-shadow-offset",
|
||||
@"informative-text-alignment",
|
||||
@"informative-text-color",
|
||||
@"informative-text-font",
|
||||
@"informative-text-shadow-color",
|
||||
@"informative-text-shadow-offset",
|
||||
@"image-offset",
|
||||
@"information-image",
|
||||
@"warning-image",
|
||||
@"error-image",
|
||||
@"help-image",
|
||||
@"help-image-left-offset",
|
||||
@"help-image-pressed",
|
||||
@"suppression-button-y-offset",
|
||||
@"suppression-button-x-offset",
|
||||
@"default-elements-margin",
|
||||
@"suppression-button-text-color",
|
||||
@"suppression-button-text-font",
|
||||
@"suppression-button-text-shadow-color",
|
||||
@"suppression-button-text-shadow-offset"
|
||||
]
|
||||
];
|
||||
return [CPDictionary dictionaryWithObjects:[CGSizeMake(400.0, 110.0), CGInsetMake(15, 15, 15, 50), 6, 10,
|
||||
CPJustifiedTextAlignment, [CPColor blackColor], [CPFont boldSystemFontOfSize:13.0], [CPNull null], CGSizeMakeZero(),
|
||||
CPJustifiedTextAlignment, [CPColor blackColor], [CPFont systemFontOfSize:12.0], [CPNull null], CGSizeMakeZero(),
|
||||
CGPointMake(15, 12),
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
[CPNull null],
|
||||
0.0,
|
||||
0.0,
|
||||
3.0,
|
||||
[CPColor blackColor],
|
||||
[CPFont systemFontOfSize:12.0],
|
||||
[CPNull null],
|
||||
0.0
|
||||
]
|
||||
forKeys:[@"size", @"content-inset", @"informative-offset", @"button-offset",
|
||||
@"message-text-alignment", @"message-text-color", @"message-text-font", @"message-text-shadow-color", @"message-text-shadow-offset",
|
||||
@"informative-text-alignment", @"informative-text-color", @"informative-text-font", @"informative-text-shadow-color", @"informative-text-shadow-offset",
|
||||
@"image-offset",
|
||||
@"information-image",
|
||||
@"warning-image",
|
||||
@"error-image",
|
||||
@"help-image",
|
||||
@"help-image-left-offset",
|
||||
@"help-image-pressed",
|
||||
@"suppression-button-y-offset",
|
||||
@"suppression-button-x-offset",
|
||||
@"default-elements-margin",
|
||||
@"suppression-button-text-color",
|
||||
@"suppression-button-text-font",
|
||||
@"suppression-button-text-shadow-color",
|
||||
@"suppression-button-text-shadow-offset"
|
||||
]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#import "../Foundation/CPRange.h"
|
||||
|
||||
@import <Foundation/CPBundle.j>
|
||||
|
||||
@import "CPCompatibility.j"
|
||||
@@ -86,7 +84,6 @@ CPRunContinuesResponse = -1002;
|
||||
CPArray _eventListeners;
|
||||
|
||||
CPEvent _currentEvent;
|
||||
CPWindow _lastMouseMoveWindow;
|
||||
|
||||
CPArray _windows;
|
||||
CPWindow _keyWindow;
|
||||
@@ -142,7 +139,9 @@ CPRunContinuesResponse = -1002;
|
||||
{
|
||||
_eventListeners = [];
|
||||
|
||||
_windows = [[CPNull null]];
|
||||
_windows = [];
|
||||
|
||||
[_windows addObject:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -251,13 +250,8 @@ CPRunContinuesResponse = -1002;
|
||||
_documentController = [CPDocumentController sharedDocumentController];
|
||||
|
||||
var needsUntitled = !!_documentController,
|
||||
URLStrings = nil;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings();
|
||||
#endif
|
||||
|
||||
var index = 0,
|
||||
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(),
|
||||
index = 0,
|
||||
count = [URLStrings count];
|
||||
|
||||
for (; index < count; ++index)
|
||||
@@ -584,14 +578,12 @@ CPRunContinuesResponse = -1002;
|
||||
_currentEvent = anEvent;
|
||||
CPEventModifierFlags = [anEvent modifierFlags];
|
||||
|
||||
var theWindow = [anEvent window];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var willPropagate = [[theWindow platformWindow] _willPropagateCurrentDOMEvent];
|
||||
var willPropagate = [[[anEvent window] 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];
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:NO];
|
||||
#endif
|
||||
|
||||
// Check if this is a candidate for key equivalent...
|
||||
@@ -603,7 +595,7 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
// Unconditionally propagate on these keys to solve browser copy paste bugs
|
||||
if ((characters == "c" || characters == "x" || characters == "v") && (modifierFlags & CPPlatformActionKeyMask))
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -611,7 +603,7 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
// if we make it this far, then restore the original willPropagate value
|
||||
[[theWindow platformWindow] _propagateCurrentDOMEvent:willPropagate];
|
||||
[[[anEvent window] platformWindow] _propagateCurrentDOMEvent:willPropagate];
|
||||
#endif
|
||||
|
||||
if (_eventListeners.length)
|
||||
@@ -622,16 +614,7 @@ CPRunContinuesResponse = -1002;
|
||||
return;
|
||||
}
|
||||
|
||||
if ([anEvent type] == CPMouseMoved)
|
||||
{
|
||||
if (theWindow !== _lastMouseMoveWindow)
|
||||
[_lastMouseMoveWindow _mouseExitedResizeRect];
|
||||
|
||||
_lastMouseMoveWindow = theWindow;
|
||||
}
|
||||
|
||||
if (theWindow)
|
||||
[theWindow sendEvent:anEvent];
|
||||
[[anEvent window] sendEvent:anEvent];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -667,10 +650,6 @@ 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];
|
||||
}
|
||||
|
||||
@@ -679,8 +658,7 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
- (CPArray)windows
|
||||
{
|
||||
// Return all windows, but not the CPNull placeholder in _windows[0].
|
||||
return [_windows subarrayWithRange:_CPMakeRange(1, [_windows count] - 1)];
|
||||
return _windows;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -970,7 +948,6 @@ CPRunContinuesResponse = -1002;
|
||||
[aWindow orderFront:self];
|
||||
[aSheet setPlatformWindow:[aWindow platformWindow]];
|
||||
}
|
||||
|
||||
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
|
||||
}
|
||||
|
||||
@@ -1032,8 +1009,7 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
- (CPArray)arguments
|
||||
{
|
||||
// FIXME This should probably not access the window object #if !PLATFORM(DOM), but the unit tests rely on it.
|
||||
if (window && window.location && _fullArgsString !== window.location.hash)
|
||||
if (_fullArgsString !== window.location.hash)
|
||||
[self _reloadArguments];
|
||||
|
||||
return _args;
|
||||
@@ -1060,9 +1036,8 @@ CPRunContinuesResponse = -1002;
|
||||
if (!args || args.length == 0)
|
||||
{
|
||||
_args = [];
|
||||
// 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 = @"#";
|
||||
window.location.hash = @"#";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1077,15 +1052,12 @@ CPRunContinuesResponse = -1002;
|
||||
|
||||
var hash = [toEncode componentsJoinedByString:@"/"];
|
||||
|
||||
// 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;
|
||||
window.location.hash = @"#" + hash;
|
||||
}
|
||||
|
||||
- (void)_reloadArguments
|
||||
{
|
||||
// FIXME This should probably not access the window object #if !PLATFORM(DOM), but the unit tests rely on it.
|
||||
_fullArgsString = (window && window.location) ? window.location.hash : "";
|
||||
_fullArgsString = window.location.hash;
|
||||
|
||||
if (_fullArgsString.length)
|
||||
{
|
||||
@@ -1246,17 +1218,7 @@ function CPApplicationMain(args, namedArgs)
|
||||
#if PLATFORM(DOM)
|
||||
// hook to allow recorder, etc to manipulate things before starting AppKit
|
||||
if (window.parent !== window && typeof window.parent._childAppIsStarting === "function")
|
||||
{
|
||||
try
|
||||
{
|
||||
window.parent._childAppIsStarting(window);
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
// This could happen if we're in an iframe without access to the parent frame.
|
||||
CPLog.warn("Failed to call parent frame's _childAppIsStarting().");
|
||||
}
|
||||
}
|
||||
window.parent._childAppIsStarting(window);
|
||||
#endif
|
||||
|
||||
var mainBundle = [CPBundle mainBundle],
|
||||
|
||||
@@ -332,16 +332,6 @@ CPBelowBottom = 6;
|
||||
[_titleView setFont:aFont];
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the text field used to display the receiver's title.
|
||||
|
||||
This is the Cappuccino equivalent to the `titleCell` method.
|
||||
*/
|
||||
- (CPTextField)titleView
|
||||
{
|
||||
return _titleView;
|
||||
}
|
||||
|
||||
- (void)_manageTitlePositioning
|
||||
{
|
||||
if (_titlePosition == CPNoTitle)
|
||||
|
||||
@@ -83,8 +83,7 @@ CPCanvasParentDrawErrorsOnMovementBug = 1 << 0;
|
||||
var USER_AGENT = "",
|
||||
PLATFORM_ENGINE = CPUnknownBrowserEngine,
|
||||
PLATFORM_FEATURES = 0,
|
||||
PLATFORM_BUGS = 0,
|
||||
PLATFORM_STYLE_JS_PROPERTIES = {};
|
||||
PLATFORM_BUGS = 0;
|
||||
|
||||
// default these features to true
|
||||
|
||||
@@ -274,106 +273,3 @@ else
|
||||
CPUndoKeyEquivalentModifierMask = CPControlKeyMask;
|
||||
CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the properly prefixed JS property for the given name. E.g. in a webkit browser,
|
||||
CPBrowserStyleProperty('transition') -> WebkitTransition
|
||||
|
||||
While technically not a style property, style related event handler names are also supported.
|
||||
CPBrowserStyleProperty('transitionend') -> 'webkitTransitionEnd'
|
||||
|
||||
CSS is only available in platform(dom), so don't rely too heavily on it.
|
||||
*/
|
||||
function CPBrowserStyleProperty(aProperty)
|
||||
{
|
||||
var lowerProperty = aProperty.toLowerCase();
|
||||
|
||||
if (PLATFORM_STYLE_JS_PROPERTIES[lowerProperty] === undefined)
|
||||
{
|
||||
var r = nil;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var testElement = document.createElement('div');
|
||||
|
||||
switch (lowerProperty)
|
||||
{
|
||||
case 'transitionend':
|
||||
var candidates = {
|
||||
'WebkitTransition' : 'webkitTransitionEnd',
|
||||
'MozTransition' : 'transitionend',
|
||||
'OTransition' : 'oTransitionEnd',
|
||||
'msTransition' : 'MSTransitionEnd',
|
||||
'transition' : 'transitionend'
|
||||
};
|
||||
|
||||
r = candidates[PLATFORM_STYLE_JS_PROPERTIES['transition']] || nil;
|
||||
break;
|
||||
default:
|
||||
var prefixes = ["Webkit", "Moz", "O", "ms"],
|
||||
strippedProperty = aProperty.split('-').join(' '),
|
||||
capProperty = [strippedProperty capitalizedString].split(' ').join('');
|
||||
|
||||
for (var i = 0; i < prefixes.length; i++)
|
||||
{
|
||||
// First check if the property is already valid without being formatted, otherwise try the capitalized property
|
||||
if (prefixes[i] + aProperty in testElement.style)
|
||||
{
|
||||
r = prefixes[i] + aProperty;
|
||||
break;
|
||||
}
|
||||
else if (prefixes[i] + capProperty in testElement.style)
|
||||
{
|
||||
r = prefixes[i] + capProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!r && lowerProperty in testElement.style)
|
||||
r = lowerProperty;
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
PLATFORM_STYLE_JS_PROPERTIES[lowerProperty] = r;
|
||||
}
|
||||
|
||||
return PLATFORM_STYLE_JS_PROPERTIES[lowerProperty];
|
||||
}
|
||||
|
||||
function CPBrowserCSSProperty(aProperty)
|
||||
{
|
||||
var browserProperty = CPBrowserStyleProperty(aProperty);
|
||||
|
||||
if (!browserProperty)
|
||||
return nil;
|
||||
|
||||
var prefixes = {
|
||||
'Webkit': '-webkit-',
|
||||
'Moz': '-moz-',
|
||||
'O': '-o-',
|
||||
'ms': '-ms-'
|
||||
};
|
||||
|
||||
for (var prefix in prefixes)
|
||||
{
|
||||
if (browserProperty.substring(0, prefix.length) == prefix)
|
||||
{
|
||||
var browserPropertyWithoutPrefix = browserProperty.substring(prefix.length),
|
||||
parts = browserPropertyWithoutPrefix.match(/[A-Z][a-z]+/g);
|
||||
|
||||
// If there were any capitalized words in the browserProperty, insert a "-" between each one
|
||||
if (parts && parts.length > 0)
|
||||
browserPropertyWithoutPrefix = parts.join("-");
|
||||
|
||||
return prefixes[prefix] + browserPropertyWithoutPrefix.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
var parts = browserProperty.match(/[A-Z][a-z]+/g);
|
||||
|
||||
if (parts && parts.length > 0)
|
||||
browserProperty = parts.join("-");
|
||||
|
||||
return browserProperty.toLowerCase();
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
domain = "";
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
document.cookie = _cookieName + "=" + value + expires + "; path=/" + domain;
|
||||
document.cookie = _cookieName+"="+value+expires+"; path=/"+domain;
|
||||
#else
|
||||
_cookieValue = value;
|
||||
_expires = expires;
|
||||
|
||||
@@ -25,8 +25,7 @@ Cursor support by browser:
|
||||
|
||||
var currentCursor = nil,
|
||||
cursorStack = [],
|
||||
cursors = {},
|
||||
ieCursorMap = {};
|
||||
cursors = {};
|
||||
|
||||
@implementation CPCursor : CPObject
|
||||
{
|
||||
@@ -37,20 +36,6 @@ 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])
|
||||
@@ -59,30 +44,23 @@ var currentCursor = nil,
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
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 is supported in CSS3 (but not IE).
|
||||
- (id)initWithImage:(CPImage)image hotSpot:(CPPoint)hotSpot
|
||||
{
|
||||
_hotSpot = hotSpot;
|
||||
_image = image;
|
||||
return [self initWithCSSString:"url(" + [_image filename] + ")" + hotSpot.x + " " + hotSpot.y + ", auto"];
|
||||
}
|
||||
|
||||
/*!
|
||||
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
|
||||
// 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
|
||||
{
|
||||
return [self initWithImage:image hotSpot:hotSpot];
|
||||
}
|
||||
|
||||
+ (void)hide
|
||||
{
|
||||
[self _setCursorCSS:@"none"]; // Not supported in IE < 9
|
||||
[self _setCursorCSS:"none"]; // Not supported in IE
|
||||
}
|
||||
|
||||
+ (void)unhide
|
||||
@@ -143,7 +121,6 @@ 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
|
||||
@@ -153,34 +130,22 @@ 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 = [CPString stringWithFormat:@"url(%@/CPCursor/%@.cur), %@", [[CPBundle bundleForClass:self] resourcePath], cursorName, aString];
|
||||
cssString = @"url(" + [[CPBundle bundleForClass:self] resourcePath] + @"/CPCursor/" + cursorName + ".cur), " + aString;
|
||||
else
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
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
|
||||
@@ -198,36 +163,6 @@ 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];
|
||||
@@ -253,21 +188,11 @@ 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];
|
||||
|
||||
@@ -99,9 +99,6 @@ var CPSharedFontManager = nil,
|
||||
{
|
||||
if (!_availableFonts)
|
||||
{
|
||||
_availableFonts = [];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_CPFontDetectSpan = document.createElement("span");
|
||||
_CPFontDetectSpan.fontSize = "24px";
|
||||
_CPFontDetectSpan.appendChild(document.createTextNode("mmmmmmmmmml"));
|
||||
@@ -113,16 +110,13 @@ var CPSharedFontManager = nil,
|
||||
|
||||
_CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace", "serif", "sans-serif", "cursive"]);
|
||||
|
||||
_availableFonts = [];
|
||||
for (var i = 0; i < _CPFontDetectAllFonts.length; i++)
|
||||
{
|
||||
var available = _CPFontDetectFontAvailable(_CPFontDetectAllFonts[i]);
|
||||
if (available)
|
||||
_availableFonts.push(_CPFontDetectAllFonts[i]);
|
||||
}
|
||||
#else
|
||||
// If there's no font detection, just assume all fonts are available.
|
||||
_availableFonts = _CPFontDetectAllFonts;
|
||||
#endif
|
||||
}
|
||||
return _availableFonts;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ var CPBindingOperationAnd = 0,
|
||||
if (options)
|
||||
[_info setObject:options forKey:CPOptionsKey];
|
||||
|
||||
[self _updatePlaceholdersWithOptions:options forBinding:aName];
|
||||
[self _updatePlaceholdersWithOptions:options];
|
||||
|
||||
[aDestination addObserver:self forKeyPath:aKeyPath options:CPKeyValueObservingOptionNew context:aBinding];
|
||||
|
||||
@@ -321,11 +321,6 @@ var CPBindingOperationAnd = 0,
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options forBinding:(CPString)aBinding
|
||||
{
|
||||
[self _updatePlaceholdersWithOptions:options];
|
||||
}
|
||||
|
||||
- (void)_placeholderForMarker:aMarker
|
||||
{
|
||||
var placeholder = _placeholderForMarker[aMarker];
|
||||
@@ -569,8 +564,6 @@ CPFontNameBinding = @"fontName";
|
||||
CPFontBoldBinding = @"fontBold";
|
||||
CPHiddenBinding = @"hidden";
|
||||
CPFilterPredicateBinding = @"filterPredicate";
|
||||
CPMaxValueBinding = @"maxValue";
|
||||
CPMinValueBinding = @"minValue";
|
||||
CPPredicateBinding = @"predicate";
|
||||
CPSelectedIndexBinding = @"selectedIndex";
|
||||
CPSelectedLabelBinding = @"selectedLabel";
|
||||
|
||||
@@ -114,9 +114,4 @@ CPDocModalWindowMask = 1 << 6;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyWindow
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -234,7 +234,7 @@ Set the behavior of the CPPopover. It can be:
|
||||
[_attachedWindow setContentView:[_contentViewController view]];
|
||||
[_attachedWindow positionRelativeToRect:positioningRect ofView:positioningView preferredEdge:preferredEdge];
|
||||
|
||||
if (!_animates && _implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
|
||||
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
|
||||
[_delegate popoverDidShow:self];
|
||||
}
|
||||
|
||||
@@ -311,13 +311,6 @@ Set the behavior of the CPPopover. It can be:
|
||||
[_delegate popoverDidClose:self];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (void)attachedWindowDidShow:(_CPAttachedWindow)anAttachedWindow
|
||||
{
|
||||
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didShow_)
|
||||
[_delegate popoverDidShow:self];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Notifications
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Copyright (c) 2011 Pear, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
@import "CPPopUpButton.j"
|
||||
|
||||
var GRADIENT_START_COLOR = "#fcfcfc",
|
||||
GRADIENT_END_COLOR = "#dfdfdf",
|
||||
BORDER_COLOR = "#BDBDBD";
|
||||
|
||||
@@ -213,7 +213,7 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
|
||||
@param aStyle the scroller style to set all scroller views to use (CPScrollerStyleLegacy or CPScrollerStyleOverlay)
|
||||
*/
|
||||
+ (void)setGlobalScrollerStyle:(int)aStyle
|
||||
+ (int)setGlobalScrollerStyle:(int)aStyle
|
||||
{
|
||||
CPScrollerStyleGlobal = aStyle;
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPScrollerStyleGlobalChangeNotification object:nil];
|
||||
|
||||
@@ -115,15 +115,13 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_selectedSegment >= _segments.length)
|
||||
_selectedSegment = -1;
|
||||
|
||||
// Make space for/remove space used by dividers.
|
||||
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"],
|
||||
frame = [self frame],
|
||||
widthOfAllSegments = 0,
|
||||
dividerExtraSpace = ([_segments count] - 1) * thickness;
|
||||
delta = thickness * (dividersAfter - dividersBefore),
|
||||
frame = [self frame];
|
||||
|
||||
for (var i = 0; i < [_segments count]; i++)
|
||||
widthOfAllSegments += [_segments[i] width];
|
||||
|
||||
[self setFrameSize:CGSizeMake(widthOfAllSegments + dividerExtraSpace, frame.size.height)];
|
||||
if (delta)
|
||||
[self setFrameSize:CGSizeMake(frame.size.width + delta, frame.size.height)];
|
||||
|
||||
[self tileWithChangedSegment:0];
|
||||
}
|
||||
|
||||
@@ -76,22 +76,6 @@
|
||||
return [CPStepper stepperWithInitialValue:0.0 minValue:0.0 maxValue:59.0];
|
||||
}
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)theBinding
|
||||
{
|
||||
if (theBinding == CPValueBinding || theBinding == CPMinValueBinding || theBinding == CPMaxValueBinding)
|
||||
return [_CPStepperValueBinder class];
|
||||
|
||||
return [super _binderClassForBinding:theBinding];
|
||||
}
|
||||
|
||||
- (id)_replacementKeyPathForBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding == CPValueBinding)
|
||||
return @"doubleValue";
|
||||
|
||||
return [super _replacementKeyPathForBinding:aBinding];
|
||||
}
|
||||
|
||||
/*!
|
||||
Initializes a CPStepper.
|
||||
@param aFrame the frame of the control
|
||||
@@ -227,7 +211,8 @@
|
||||
else
|
||||
[self setDoubleValue:([self doubleValue] - _increment)];
|
||||
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
if (_target && _action && [_target respondsToSelector:_action])
|
||||
[self sendAction:_action to:_target];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -265,24 +250,6 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPStepperValueBinder : CPBinder
|
||||
{
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options forBinding:(CPString)aBinding
|
||||
{
|
||||
var placeholder = (aBinding == CPMaxValueBinding) ? [_source maxValue] : [_source minValue];
|
||||
|
||||
[super _updatePlaceholdersWithOptions:options];
|
||||
|
||||
[self _setPlaceholder:placeholder forMarker:CPMultipleValuesMarker isDefault:YES];
|
||||
[self _setPlaceholder:placeholder forMarker:CPNoSelectionMarker isDefault:YES];
|
||||
[self _setPlaceholder:placeholder forMarker:CPNotApplicableMarker isDefault:YES];
|
||||
[self _setPlaceholder:placeholder forMarker:CPNullMarker isDefault:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPStepperMinValue = @"CPStepperMinValue",
|
||||
CPStepperMaxValue = @"CPStepperMaxValue",
|
||||
CPStepperValueWraps = @"CPStepperValueWraps",
|
||||
|
||||
@@ -88,6 +88,9 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
_box = [[CPBox alloc] initWithFrame:[self bounds]];
|
||||
[self setBackgroundColor:[CPColor colorWithCalibratedWhite:0.95 alpha:1.0]];
|
||||
|
||||
[_box setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
[_tabs setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
|
||||
|
||||
[self addSubview:_box];
|
||||
[self addSubview:_tabs];
|
||||
}
|
||||
@@ -340,9 +343,21 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
_type = aTabViewType;
|
||||
|
||||
if (_type !== CPTopTabsBezelBorder && _type !== CPBottomTabsBezelBorder)
|
||||
{
|
||||
[_box setFrame:[self bounds]];
|
||||
[_tabs removeFromSuperview];
|
||||
}
|
||||
else
|
||||
{
|
||||
var aFrame = [self frame],
|
||||
segmentedHeight = _CGRectGetHeight([_tabs frame]),
|
||||
origin = _type === CPTopTabsBezelBorder ? segmentedHeight / 2 : 0;
|
||||
|
||||
[_box setFrame:_CGRectMake(0, origin, _CGRectGetWidth(aFrame),
|
||||
_CGRectGetHeight(aFrame) - segmentedHeight / 2)];
|
||||
|
||||
[self addSubview:_tabs];
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
@@ -358,29 +373,6 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
[_box setBorderType:CPNoBorder];
|
||||
break;
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
// Even if CPTabView's autoresizesSubviews is NO, _tabs and _box has to be laid out.
|
||||
// This means we can't rely on autoresize masks.
|
||||
if (_type !== CPTopTabsBezelBorder && _type !== CPBottomTabsBezelBorder)
|
||||
{
|
||||
[_box setFrame:[self bounds]];
|
||||
}
|
||||
else
|
||||
{
|
||||
var aFrame = [self frame],
|
||||
segmentedHeight = _CGRectGetHeight([_tabs frame]),
|
||||
origin = _type === CPTopTabsBezelBorder ? segmentedHeight / 2 : 0;
|
||||
|
||||
[_box setFrame:_CGRectMake(0, origin, _CGRectGetWidth(aFrame),
|
||||
_CGRectGetHeight(aFrame) - segmentedHeight / 2)];
|
||||
|
||||
[self _repositionTabs];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -505,6 +497,7 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
[_items makeObjectsPerformSelector:@selector(_setTabView:) withObject:self];
|
||||
|
||||
[self _updateItems];
|
||||
[self _repositionTabs];
|
||||
|
||||
[self setDelegate:[aCoder decodeObjectForKey:CPTabViewDelegateKey]];
|
||||
|
||||
@@ -513,8 +506,6 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
[self selectTabViewItem:selected];
|
||||
|
||||
[self setTabViewType:[aCoder decodeIntForKey:CPTabViewTypeKey]];
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -138,7 +138,7 @@ CPPressedTab = 2;
|
||||
_view = aView;
|
||||
|
||||
if ([_tabView selectedTabViewItem] == self)
|
||||
[_tabView _setContentViewFromItem:self];
|
||||
[_tabView _setContentViewForItem:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -46,44 +46,13 @@ var CPTextFieldDOMInputElement = nil,
|
||||
CPTextFieldInputIsActive = NO,
|
||||
CPTextFieldCachedSelectStartFunction = nil,
|
||||
CPTextFieldCachedDragFunction = nil,
|
||||
CPTextFieldBlurHandler = nil,
|
||||
CPTextFieldBlurFunction = nil,
|
||||
CPTextFieldInputFunction = nil;
|
||||
|
||||
#endif
|
||||
|
||||
var CPSecureTextFieldCharacter = "\u2022";
|
||||
|
||||
|
||||
function CPTextFieldBlurFunction(anEvent, owner, domElement, inputElement, resigning, didBlurRef)
|
||||
{
|
||||
if (owner && domElement != inputElement.parentNode)
|
||||
return;
|
||||
|
||||
if (!resigning && [[owner window] isKeyWindow])
|
||||
{
|
||||
/*
|
||||
Browsers blur text fields when a click occurs anywhere outside the text field. That is normal for browsers, but in Cocoa the key view retains focus unless the click target accepts first responder. So if we lost focus but were not told to resign and our window is still key, restore focus.
|
||||
*/
|
||||
window.setTimeout(function()
|
||||
{
|
||||
inputElement.focus();
|
||||
}, 0.0);
|
||||
}
|
||||
|
||||
CPTextFieldHandleBlur(anEvent, AT_REF(owner));
|
||||
AT_DEREF(didBlurRef, YES);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function CPTextFieldHandleBlur(anEvent, ownerRef)
|
||||
{
|
||||
AT_DEREF(ownerRef, nil);
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
|
||||
@implementation CPString (CPTextFieldAdditions)
|
||||
|
||||
/*!
|
||||
@@ -219,15 +188,28 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldDOMInputElement.style.background = "transparent";
|
||||
CPTextFieldDOMInputElement.style.outline = "none";
|
||||
|
||||
CPTextFieldBlurHandler = function(anEvent)
|
||||
CPTextFieldBlurFunction = function(anEvent)
|
||||
{
|
||||
return CPTextFieldBlurFunction(
|
||||
anEvent,
|
||||
CPTextFieldInputOwner,
|
||||
CPTextFieldInputOwner._DOMElement,
|
||||
CPTextFieldDOMInputElement,
|
||||
CPTextFieldInputResigning,
|
||||
AT_REF(CPTextFieldInputDidBlur));
|
||||
if (CPTextFieldInputOwner && CPTextFieldInputOwner._DOMElement != CPTextFieldDOMInputElement.parentNode)
|
||||
return;
|
||||
|
||||
if (!CPTextFieldInputResigning)
|
||||
{
|
||||
[[CPTextFieldInputOwner window] makeFirstResponder:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
CPTextFieldHandleBlur(anEvent, CPTextFieldDOMInputElement);
|
||||
CPTextFieldInputDidBlur = YES;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
CPTextFieldHandleBlur = function(anEvent)
|
||||
{
|
||||
CPTextFieldInputOwner = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
};
|
||||
|
||||
if (CPFeatureIsCompatible(CPInputOnInputEventFeature))
|
||||
@@ -237,16 +219,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (!CPTextFieldInputOwner)
|
||||
return;
|
||||
|
||||
var cappEvent = [CPEvent keyEventWithType:CPKeyUp
|
||||
location:_CGPointMakeZero()
|
||||
modifierFlags:0
|
||||
timestamp:[CPEvent currentTimestamp]
|
||||
windowNumber:[[CPApp keyWindow] windowNumber]
|
||||
context:nil
|
||||
characters:nil
|
||||
charactersIgnoringModifiers:nil
|
||||
isARepeat:NO
|
||||
keyCode:nil];
|
||||
var cappEvent = [CPEvent keyEventWithType:CPKeyUp location:_CGPointMakeZero() modifierFlags:0
|
||||
timestamp:[CPEvent currentTimestamp] windowNumber:[[CPApp keyWindow] windowNumber] context:nil
|
||||
characters:nil charactersIgnoringModifiers:nil isARepeat:NO keyCode:nil];
|
||||
|
||||
[CPTextFieldInputOwner keyUp:cappEvent];
|
||||
|
||||
@@ -256,8 +231,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldDOMInputElement.oninput = CPTextFieldInputFunction;
|
||||
}
|
||||
|
||||
// FIXME make this not onblur
|
||||
CPTextFieldDOMInputElement.onblur = CPTextFieldBlurHandler;
|
||||
//FIXME make this not onblur
|
||||
CPTextFieldDOMInputElement.onblur = CPTextFieldBlurFunction;
|
||||
|
||||
CPTextFieldDOMStandardInputElement = CPTextFieldDOMInputElement;
|
||||
}
|
||||
@@ -286,7 +261,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldDOMPasswordInputElement.style.outline = "none";
|
||||
CPTextFieldDOMPasswordInputElement.type = "password";
|
||||
|
||||
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurHandler;
|
||||
CPTextFieldDOMPasswordInputElement.onblur = CPTextFieldBlurFunction;
|
||||
}
|
||||
|
||||
CPTextFieldDOMInputElement = CPTextFieldDOMPasswordInputElement;
|
||||
@@ -333,11 +308,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (shouldBeEditable)
|
||||
_isSelectable = YES;
|
||||
|
||||
if (_isEditable)
|
||||
[self setThemeState:CPThemeStateEditable];
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateEditable];
|
||||
|
||||
// We only allow first responder status if the field is editable and enabled.
|
||||
if (!shouldBeEditable && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
@@ -519,8 +489,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
/* @ignore */
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (CPTextFieldInputOwner && [CPTextFieldInputOwner window] !== [self window])
|
||||
[[CPTextFieldInputOwner window] makeFirstResponder:nil];
|
||||
#endif
|
||||
|
||||
// As long as we are the first responder we need to monitor the key status of our window.
|
||||
[self _setObserveWindowKeyNotifications:YES];
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResignKey:) name:CPWindowDidResignKeyNotification object:[self window]];
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidBecomeKey:) name:CPWindowDidBecomeKeyNotification object:[self window]];
|
||||
|
||||
_isEditing = NO;
|
||||
|
||||
@@ -531,7 +507,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
}
|
||||
|
||||
/*!
|
||||
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.
|
||||
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.)
|
||||
*/
|
||||
@@ -553,10 +529,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
element.value = _stringValue;
|
||||
element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM))
|
||||
element.style.font = [font cssString];
|
||||
|
||||
element.style.zIndex = 1000;
|
||||
|
||||
switch ([self alignment])
|
||||
@@ -592,24 +566,35 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
element.style.top = topPoint;
|
||||
var left = _CGRectGetMinX(contentRect);
|
||||
|
||||
// If the browser has a built in left padding, compensate for it. We need the input text to be exactly on top of the original text.
|
||||
if (CPFeatureIsCompatible(CPInput1PxLeftPadding))
|
||||
left -= 1;
|
||||
|
||||
element.style.left = left + "px";
|
||||
element.style.width = _CGRectGetWidth(contentRect) + "px";
|
||||
element.style.height = ROUND(lineHeight) + "px";
|
||||
element.style.lineHeight = ROUND(lineHeight) + "px";
|
||||
element.style.verticalAlign = "top";
|
||||
element.style.cursor = "auto";
|
||||
element.style.verticalAlign = @"top";
|
||||
|
||||
_DOMElement.appendChild(element);
|
||||
|
||||
// The font change above doesn't work for some browsers if the element isn't already appendChild'ed.
|
||||
// The font change above doesn't work for some browsers if the element isn't already .appendChild'ed.
|
||||
if (!CPFeatureIsCompatible(CPInputSetFontOutsideOfDOM))
|
||||
element.style.font = [font cssString];
|
||||
|
||||
window.setTimeout(function()
|
||||
{
|
||||
element.focus();
|
||||
|
||||
// Select the text if the textfield became first responder through keyboard interaction
|
||||
if (!_willBecomeFirstResponderByClick)
|
||||
[self _selectText:self immediately:YES];
|
||||
|
||||
_willBecomeFirstResponderByClick = NO;
|
||||
|
||||
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
|
||||
CPTextFieldInputOwner = self;
|
||||
}, 0.0);
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
|
||||
CPTextFieldInputIsActive = YES;
|
||||
@@ -622,34 +607,16 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[[self window] platformWindow]._DOMBodyElement.ondrag = function () {};
|
||||
[[self window] platformWindow]._DOMBodyElement.onselectstart = function () {};
|
||||
}
|
||||
|
||||
CPTextFieldInputOwner = self;
|
||||
|
||||
window.setTimeout(function()
|
||||
{
|
||||
/*
|
||||
setTimeout handlers are not guaranteed to fire in the order they were initiated. This can cause a race condition when several windows with text fields are opened quickly, resulting in several instances of this timeout function being fired, perhaps out of order. So we have to check that by the time this function is fired, CPTextFieldInputOwner has not been changed to another text field in the meantime.
|
||||
*/
|
||||
if (CPTextFieldInputOwner !== self)
|
||||
return;
|
||||
|
||||
element.focus();
|
||||
|
||||
// Select the text if the textfield became first responder through keyboard interaction
|
||||
if (!_willBecomeFirstResponderByClick)
|
||||
[self _selectText:self immediately:YES];
|
||||
|
||||
_willBecomeFirstResponderByClick = NO;
|
||||
|
||||
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
|
||||
}, 0.0);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
// When we are no longer the first responder we don't worry about the key status of our window anymore.
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPWindowDidResignKeyNotification object:[self window]];
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPWindowDidBecomeKeyNotification object:[self window]];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var element = [self _inputElement],
|
||||
@@ -671,9 +638,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
#endif
|
||||
|
||||
// When we are no longer the first responder we don't worry about the key status of our window anymore.
|
||||
[self _setObserveWindowKeyNotifications:NO];
|
||||
|
||||
[self _resignFirstKeyResponder];
|
||||
|
||||
_isEditing = NO;
|
||||
@@ -697,6 +661,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
_willBecomeFirstResponderByClick = NO;
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
@@ -709,7 +674,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
element.blur();
|
||||
|
||||
if (!CPTextFieldInputDidBlur)
|
||||
CPTextFieldBlurHandler();
|
||||
CPTextFieldBlurFunction();
|
||||
|
||||
CPTextFieldInputDidBlur = NO;
|
||||
CPTextFieldInputResigning = NO;
|
||||
@@ -731,20 +696,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)_setObserveWindowKeyNotifications:(BOOL)shouldObserve
|
||||
{
|
||||
if (shouldObserve)
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResignKey:) name:CPWindowDidResignKeyNotification object:[self window]];
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidBecomeKey:) name:CPWindowDidBecomeKeyNotification object:[self window]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPWindowDidResignKeyNotification object:[self window]];
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPWindowDidBecomeKeyNotification object:[self window]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_windowDidResignKey:(CPNotification)aNotification
|
||||
{
|
||||
if (![[self window] isKeyWindow])
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
#import "../Foundation/CPRange.h"
|
||||
#import "../Foundation/Ref.h"
|
||||
|
||||
@import <Foundation/CPCharacterSet.j>
|
||||
@import <Foundation/CPIndexSet.j>
|
||||
@@ -48,7 +47,7 @@ var CPTokenFieldDOMInputElement = nil,
|
||||
CPTokenFieldCachedDragFunction = nil,
|
||||
CPTokenFieldFocusInput = NO,
|
||||
|
||||
CPTokenFieldBlurHandler = nil;
|
||||
CPTokenFieldBlurFunction = nil;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -72,6 +71,7 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
CPEvent _mouseDownEvent;
|
||||
|
||||
BOOL _preventResign;
|
||||
BOOL _shouldNotifyTarget;
|
||||
}
|
||||
|
||||
@@ -138,23 +138,18 @@ var CPScrollDestinationNone = 0,
|
||||
return _autocompleteMenu;
|
||||
}
|
||||
|
||||
- (void)_complete:(_CPAutocompleteMenu)anAutocompleteMenu
|
||||
{
|
||||
[self _autocompleteWithEvent:nil];
|
||||
}
|
||||
|
||||
- (void)_autocompleteWithEvent:(CPEvent)anEvent
|
||||
{
|
||||
if (![self _editorValue] && (![_autocompleteMenu contentArray] || ![self hasThemeState:CPThemeStateAutocompleting]))
|
||||
if (![self _inputElement].value && (![_autocompleteMenu contentArray] || ![self hasThemeState:CPThemeStateAutocompleting]))
|
||||
return;
|
||||
|
||||
[self _hideCompletions];
|
||||
|
||||
var token = [_autocompleteMenu selectedItem],
|
||||
shouldRemoveLastObject = token !== @"" && [self _editorValue] !== @"";
|
||||
shouldRemoveLastObject = token !== @"" && [self _inputElement].value !== @"";
|
||||
|
||||
if (!token)
|
||||
token = [self _editorValue];
|
||||
token = [self _inputElement].value;
|
||||
|
||||
// Make sure the user typed an actual token to prevent the previous token from being emptied
|
||||
// If the input area is empty, we want to fall back to the normal behavior, resigning first
|
||||
@@ -312,22 +307,9 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (CPTokenFieldInputOwner && [CPTokenFieldInputOwner window] !== [self window])
|
||||
[[CPTokenFieldInputOwner window] makeFirstResponder:nil];
|
||||
#endif
|
||||
|
||||
// As long as we are the first responder we need to monitor the key status of our window.
|
||||
[self _setObserveWindowKeyNotifications:YES];
|
||||
|
||||
if ([[self window] isKeyWindow])
|
||||
[self _becomeFirstKeyResponder];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_becomeFirstKeyResponder
|
||||
{
|
||||
[self setThemeState:CPThemeStateEditing];
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
@@ -386,35 +368,18 @@ var CPScrollDestinationNone = 0,
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
[self _autocomplete];
|
||||
|
||||
// From CPTextField superclass.
|
||||
[self _setObserveWindowKeyNotifications:NO];
|
||||
|
||||
[self _resignFirstKeyResponder];
|
||||
|
||||
if (_shouldNotifyTarget)
|
||||
{
|
||||
_shouldNotifyTarget = NO;
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_resignFirstKeyResponder
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
if (_preventResign)
|
||||
return NO;
|
||||
|
||||
[self unsetThemeState:CPThemeStateEditing];
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
[self setNeedsLayout];
|
||||
[self _autocomplete];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
@@ -424,7 +389,7 @@ var CPScrollDestinationNone = 0,
|
||||
element.blur();
|
||||
|
||||
if (!CPTokenFieldInputDidBlur)
|
||||
CPTokenFieldBlurHandler();
|
||||
CPTokenFieldBlurFunction();
|
||||
|
||||
CPTokenFieldInputDidBlur = NO;
|
||||
CPTokenFieldInputResigning = NO;
|
||||
@@ -444,10 +409,26 @@ var CPScrollDestinationNone = 0,
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
|
||||
[self setNeedsLayout];
|
||||
|
||||
if (_shouldNotifyTarget)
|
||||
{
|
||||
_shouldNotifyTarget = NO;
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
_preventResign = YES;
|
||||
_mouseDownEvent = anEvent;
|
||||
|
||||
[self _selectToken:nil byExtendingSelection:NO];
|
||||
@@ -457,11 +438,13 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
_preventResign = NO;
|
||||
_mouseDownEvent = nil;
|
||||
}
|
||||
|
||||
- (void)_mouseDownOnToken:(_CPTokenFieldToken)aToken withEvent:(CPEvent)anEvent
|
||||
{
|
||||
_preventResign = YES;
|
||||
_mouseDownEvent = anEvent;
|
||||
}
|
||||
|
||||
@@ -474,6 +457,8 @@ var CPScrollDestinationNone = 0,
|
||||
// Snap to the token if it's only half visible due to mouse wheel scrolling.
|
||||
_shouldScrollTo = aToken;
|
||||
}
|
||||
|
||||
_preventResign = NO;
|
||||
}
|
||||
|
||||
// ===========
|
||||
@@ -507,9 +492,9 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
if ([self _editorValue])
|
||||
if ([self _inputElement].value != @"")
|
||||
{
|
||||
var token = [self _representedObjectForEditingString:[self _editorValue]];
|
||||
var token = [self _representedObjectForEditingString:[self _inputElement].value];
|
||||
[objectValue insertObject:token atIndex:_selectedRange.location];
|
||||
}
|
||||
|
||||
@@ -562,7 +547,6 @@ var CPScrollDestinationNone = 0,
|
||||
[newToken setTokenField:self];
|
||||
[newToken setRepresentedObject:tokenObject];
|
||||
[newToken setStringValue:tokenValue];
|
||||
[newToken setEditable:[self isEditable]];
|
||||
[contentView addSubview:newToken];
|
||||
}
|
||||
|
||||
@@ -608,13 +592,6 @@ var CPScrollDestinationNone = 0,
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setEditable:(BOOL)shouldBeEditable
|
||||
{
|
||||
[super setEditable:shouldBeEditable];
|
||||
|
||||
[[self _tokens] makeObjectsPerformSelector:@selector(setEditable:) withObject:shouldBeEditable];
|
||||
}
|
||||
|
||||
- (void)sendAction:(SEL)anAction to:(id)anObject
|
||||
{
|
||||
_shouldNotifyTarget = NO;
|
||||
@@ -644,19 +621,35 @@ var CPScrollDestinationNone = 0,
|
||||
CPTokenFieldDOMInputElement.style.background = "transparent";
|
||||
CPTokenFieldDOMInputElement.style.outline = "none";
|
||||
|
||||
CPTokenFieldBlurHandler = function(anEvent)
|
||||
CPTokenFieldBlurFunction = function(anEvent)
|
||||
{
|
||||
return CPTextFieldBlurFunction(
|
||||
anEvent,
|
||||
CPTokenFieldInputOwner,
|
||||
[CPTokenFieldInputOwner._tokenScrollView documentView]._DOMElement,
|
||||
CPTokenFieldDOMInputElement,
|
||||
CPTokenFieldInputResigning,
|
||||
AT_REF(CPTokenFieldInputDidBlur));
|
||||
if (CPTokenFieldInputOwner && [CPTokenFieldInputOwner._tokenScrollView documentView]._DOMElement != CPTokenFieldDOMInputElement.parentNode)
|
||||
return;
|
||||
|
||||
if (CPTokenFieldInputOwner && CPTokenFieldInputOwner._preventResign)
|
||||
return false;
|
||||
|
||||
if (!CPTokenFieldInputResigning && !CPTokenFieldFocusInput)
|
||||
{
|
||||
[[CPTokenFieldInputOwner window] makeFirstResponder:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
CPTokenFieldHandleBlur(anEvent, CPTokenFieldDOMInputElement);
|
||||
CPTokenFieldInputDidBlur = YES;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// FIXME make this not onblur
|
||||
CPTokenFieldDOMInputElement.onblur = CPTokenFieldBlurHandler;
|
||||
CPTokenFieldHandleBlur = function(anEvent)
|
||||
{
|
||||
CPTokenFieldInputOwner = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
};
|
||||
|
||||
//FIXME make this not onblur
|
||||
CPTokenFieldDOMInputElement.onblur = CPTokenFieldBlurFunction;
|
||||
|
||||
CPTokenFieldDOMStandardInputElement = CPTokenFieldDOMInputElement;
|
||||
}
|
||||
@@ -675,13 +668,6 @@ var CPScrollDestinationNone = 0,
|
||||
}
|
||||
#endif
|
||||
|
||||
- (CPString)_editorValue
|
||||
{
|
||||
if (![self hasThemeState:CPThemeStateEditing])
|
||||
return @"";
|
||||
return [self _inputElement].value;
|
||||
}
|
||||
|
||||
- (void)moveUp:(id)sender
|
||||
{
|
||||
[[self _autocompleteMenu] selectPrevious];
|
||||
@@ -761,7 +747,7 @@ var CPScrollDestinationNone = 0,
|
||||
- (void)moveLeft:(id)sender
|
||||
{
|
||||
// Left arrow
|
||||
if ((_selectedRange.location > 0 || _selectedRange.length) && [self _editorValue] == "")
|
||||
if ((_selectedRange.location > 0 || _selectedRange.length) && CPTokenFieldDOMInputElement.value == "")
|
||||
{
|
||||
if (_selectedRange.length)
|
||||
// Simply collapse the range.
|
||||
@@ -780,7 +766,7 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (void)moveLeftAndModifySelection:(id)sender
|
||||
{
|
||||
if (_selectedRange.location > 0 && [self _editorValue] == "")
|
||||
if (_selectedRange.location > 0 && CPTokenFieldDOMInputElement.value == "")
|
||||
{
|
||||
_selectedRange.location--;
|
||||
// When shift is depressed, select the next token backwards.
|
||||
@@ -798,7 +784,7 @@ var CPScrollDestinationNone = 0,
|
||||
- (void)moveRight:(id)sender
|
||||
{
|
||||
// Right arrow
|
||||
if ((_selectedRange.location < [[self _tokens] count] || _selectedRange.length) && [self _editorValue] == "")
|
||||
if ((_selectedRange.location < [[self _tokens] count] || _selectedRange.length) && CPTokenFieldDOMInputElement.value == "")
|
||||
{
|
||||
if (_selectedRange.length)
|
||||
{
|
||||
@@ -824,7 +810,7 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (void)moveRightAndModifySelection:(id)sender
|
||||
{
|
||||
if (_CPMaxRange(_selectedRange) < [[self _tokens] count] && [self _editorValue] == "")
|
||||
if (_CPMaxRange(_selectedRange) < [[self _tokens] count] && CPTokenFieldDOMInputElement.value == "")
|
||||
{
|
||||
// Leave the selection location in place but include the next token to the right.
|
||||
_selectedRange.length++;
|
||||
@@ -842,7 +828,7 @@ var CPScrollDestinationNone = 0,
|
||||
{
|
||||
// TODO Even if the editor isn't empty you should be able to delete the previous token by placing the cursor
|
||||
// at the beginning of the editor.
|
||||
if ([self _editorValue] == @"")
|
||||
if (CPTokenFieldDOMInputElement.value == @"")
|
||||
{
|
||||
[self _hideCompletions];
|
||||
|
||||
@@ -868,7 +854,7 @@ var CPScrollDestinationNone = 0,
|
||||
{
|
||||
// TODO Even if the editor isn't empty you should be able to delete the next token by placing the cursor
|
||||
// at the end of the editor.
|
||||
if ([self _editorValue] == @"")
|
||||
if (CPTokenFieldDOMInputElement.value == @"")
|
||||
{
|
||||
// Delete forward if nothing is selected, else delete all selected.
|
||||
[self _hideCompletions];
|
||||
@@ -984,7 +970,8 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
var frame = [self frame],
|
||||
contentView = [_tokenScrollView documentView],
|
||||
tokens = [self _tokens];
|
||||
tokens = [self _tokens],
|
||||
shouldShowAutoComplete = [self hasThemeState:CPThemeStateAutocompleting];
|
||||
|
||||
// Hack to make sure we are handling an array
|
||||
if (![tokens isKindOfClass:[CPArray class]])
|
||||
@@ -1002,9 +989,6 @@ var CPScrollDestinationNone = 0,
|
||||
lineHeight = [font defaultLineHeightForFont],
|
||||
editorInset = [self currentValueForThemeAttribute:@"editor-inset"];
|
||||
|
||||
// Put half a spacing above the tokens.
|
||||
offset.y += CEIL(spaceBetweenTokens.height / 2.0);
|
||||
|
||||
// Get the height of a typical token, or a token token if you will.
|
||||
[tokenToken sizeToFit];
|
||||
|
||||
@@ -1092,19 +1076,12 @@ var CPScrollDestinationNone = 0,
|
||||
if (isEditing && _selectedRange.length)
|
||||
{
|
||||
_inputFrame = nil;
|
||||
var inputElement = [self _inputElement];
|
||||
inputElement.style.display = "none";
|
||||
}
|
||||
else if (isEditing)
|
||||
{
|
||||
var inputElement = [self _inputElement];
|
||||
inputElement.style.display = "block";
|
||||
if (document.activeElement !== inputElement)
|
||||
inputElement.focus();
|
||||
[self _inputElement].style.left = "-10000px";
|
||||
[self _inputElement].focus();
|
||||
}
|
||||
|
||||
// Trim off any excess height downwards (in case we shrank).
|
||||
var scrollHeight = offset.y + tokenHeight;
|
||||
var scrollHeight = offset.y + tokenHeight + CEIL(spaceBetweenTokens.height / 2.0);
|
||||
if (_CGRectGetHeight([contentView bounds]) > scrollHeight)
|
||||
[contentView setFrameSize:_CGSizeMake(_CGRectGetWidth([_tokenScrollView bounds]), scrollHeight)];
|
||||
|
||||
@@ -1272,11 +1249,6 @@ var CPScrollDestinationNone = 0,
|
||||
return "tokenfield-token";
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CPRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame])
|
||||
@@ -1312,34 +1284,6 @@ var CPScrollDestinationNone = 0,
|
||||
_representedObject = representedObject;
|
||||
}
|
||||
|
||||
- (void)setEditable:(BOOL)shouldBeEditable
|
||||
{
|
||||
[super setEditable:shouldBeEditable];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (BOOL)setThemeState:(CPThemeState)aState
|
||||
{
|
||||
var r = [super setThemeState:aState];
|
||||
|
||||
// Share hover state with the delete button.
|
||||
if (r && aState === CPThemeStateHovered)
|
||||
[_deleteButton setThemeState:aState];
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
- (BOOL)unsetThemeState:(CPThemeState)aState
|
||||
{
|
||||
var r = [super unsetThemeState:aState];
|
||||
|
||||
// Share hover state with the delete button.
|
||||
if (r && aState === CPThemeStateHovered)
|
||||
[_deleteButton unsetThemeState:aState];
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
- (CGSize)_minimumFrameSize
|
||||
{
|
||||
var size = _CGSizeMakeZero(),
|
||||
@@ -1365,7 +1309,6 @@ var CPScrollDestinationNone = 0,
|
||||
{
|
||||
[_deleteButton setTarget:self];
|
||||
[_deleteButton setAction:@selector(_delete:)];
|
||||
[_deleteButton setEnabled:[self isEditable]];
|
||||
|
||||
var frame = [bezelView frame],
|
||||
buttonOffset = [_deleteButton currentValueForThemeAttribute:@"offset"],
|
||||
@@ -1387,8 +1330,7 @@ var CPScrollDestinationNone = 0,
|
||||
|
||||
- (void)_delete:(id)sender
|
||||
{
|
||||
if ([self isEditable])
|
||||
[_tokenField _deleteToken:self];
|
||||
[_tokenField _deleteToken:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -247,7 +247,7 @@ var CPToolbarsByIdentifier = nil,
|
||||
_window = aWindow;
|
||||
|
||||
if (_window)
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_autoValidateVisibleItems) name:_CPWindowDidChangeFirstResponderNotification object:aWindow];
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_autovalidate) name:_CPWindowDidChangeFirstResponderNotification object:aWindow];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -400,15 +400,14 @@ var CPToolbarsByIdentifier = nil,
|
||||
*/
|
||||
- (void)validateVisibleItems
|
||||
{
|
||||
[self _validateVisibleItems:NO]
|
||||
var toolbarItems = [self visibleItems],
|
||||
count = [toolbarItems count];
|
||||
|
||||
while (count--)
|
||||
[toolbarItems[count] validate];
|
||||
}
|
||||
|
||||
- (void)_autoValidateVisibleItems
|
||||
{
|
||||
[self _validateVisibleItems:YES]
|
||||
}
|
||||
|
||||
- (void)_validateVisibleItems:(BOOL)isAutovalidation
|
||||
- (void)_autovalidate
|
||||
{
|
||||
var toolbarItems = [self visibleItems],
|
||||
count = [toolbarItems count];
|
||||
@@ -416,7 +415,7 @@ var CPToolbarsByIdentifier = nil,
|
||||
while (count--)
|
||||
{
|
||||
var item = [toolbarItems objectAtIndex:count];
|
||||
if (!isAutovalidation || [item autovalidates])
|
||||
if ([item autovalidates])
|
||||
[item validate];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
/*
|
||||
* CPTreeNode.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2009, 280 North, Inc.
|
||||
*
|
||||
* 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/CPIndexPath.j>
|
||||
|
||||
@@ -463,7 +463,7 @@ var CPViewFlags = { },
|
||||
// We will have to adjust the z-index of all views starting at this index.
|
||||
var count = _subviews.length;
|
||||
|
||||
// Dirty the key view loop, in case the window wants to auto recalculate it
|
||||
// dirty the key view loop, in case the window wants to auto recalculate it
|
||||
[[self window] _dirtyKeyViewLoop];
|
||||
|
||||
// If this is already one of our subviews, remove it.
|
||||
@@ -544,7 +544,7 @@ var CPViewFlags = { },
|
||||
if (!_superview)
|
||||
return;
|
||||
|
||||
// Dirty the key view loop, in case the window wants to auto recalculate it
|
||||
// dirty the key view loop, in case the window wants to auto recalculate it
|
||||
[[self window] _dirtyKeyViewLoop];
|
||||
|
||||
[_superview willRemoveSubview:self];
|
||||
|
||||
@@ -53,20 +53,15 @@ var _CPAttachedWindowViewDefaultCursorSize = CGSizeMake(16, 10),
|
||||
*/
|
||||
- (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
|
||||
{
|
||||
var contentRect = CGRectMakeCopy(aFrameRect),
|
||||
modifierX = 16,
|
||||
modifierY = 19;
|
||||
var contentRect = CGRectMakeCopy(aFrameRect);
|
||||
|
||||
// @todo change border art and remove this pixel perfect adaptation
|
||||
//
|
||||
// @comment: If we use this, each time we open the popover, the content
|
||||
// view is reduced a little over and over
|
||||
// return CGRectInset(contentRect, modifierX, modifierY);
|
||||
// return CGRectInset(contentRect, 20, 20);
|
||||
|
||||
contentRect.origin.x += modifierX;
|
||||
contentRect.origin.y += modifierY;
|
||||
contentRect.size.width -= modifierX * 2;
|
||||
contentRect.size.height -= modifierY * 2;
|
||||
contentRect.origin.x += 18;
|
||||
contentRect.origin.y += 17;
|
||||
contentRect.size.width -= 35;
|
||||
contentRect.size.height -= 37;
|
||||
|
||||
return contentRect;
|
||||
}
|
||||
@@ -78,21 +73,15 @@ var _CPAttachedWindowViewDefaultCursorSize = CGSizeMake(16, 10),
|
||||
*/
|
||||
+ (CGRect)frameRectForContentRect:(CGRect)aContentRect
|
||||
{
|
||||
var frameRect = CGRectMakeCopy(aContentRect),
|
||||
modifierX = 16,
|
||||
modifierY = 19;
|
||||
var frameRect = CGRectMakeCopy(aContentRect);
|
||||
|
||||
// @todo change border art and remove this pixel perfect adaptation
|
||||
// @comment: If we use this, each time we open the popover, the content
|
||||
//
|
||||
// view is reduced a little over and over
|
||||
// return CGRectOffset(frameRect, modifierX, modifierY);
|
||||
|
||||
frameRect.origin.x -= modifierX;
|
||||
frameRect.origin.y -= modifierY;
|
||||
frameRect.size.width += modifierX * 2;
|
||||
frameRect.size.height += modifierY * 2;
|
||||
//return CGRectOffset(frameRect, 20, 20);
|
||||
|
||||
frameRect.origin.x -= 18;
|
||||
frameRect.origin.y -= 17;
|
||||
frameRect.size.width += 35;
|
||||
frameRect.size.height += 37;
|
||||
return frameRect;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,38 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
|
||||
return _CPStandardWindowViewDividerBackgroundColor;
|
||||
}
|
||||
|
||||
- (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
|
||||
{
|
||||
var contentRect = [[self class] contentRectForFrameRect:aFrameRect],
|
||||
theToolbar = [[self window] toolbar];
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
contentRect.origin.y += toolbarHeight;
|
||||
contentRect.size.height -= toolbarHeight;
|
||||
}
|
||||
|
||||
return contentRect;
|
||||
}
|
||||
|
||||
- (CGRect)frameRectForContentRect:(CGRect)aContentRect
|
||||
{
|
||||
var frameRect = [[self class] frameRectForContentRect:aContentRect],
|
||||
theToolbar = [[self window] toolbar];
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
frameRect.origin.y -= toolbarHeight;
|
||||
frameRect.size.height += toolbarHeight;
|
||||
}
|
||||
|
||||
return frameRect;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask
|
||||
{
|
||||
self = [super initWithFrame:aFrame styleMask:aStyleMask];
|
||||
@@ -334,13 +366,13 @@ var STANDARD_GRADIENT_HEIGHT = 41.0;
|
||||
[self _updateCloseButton];
|
||||
}
|
||||
|
||||
- (BOOL)couldBeMoveEvent:(CPEvent)anEvent
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
if (![_headView isHidden])
|
||||
if (CGRectContainsPoint([_headView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||
return YES;
|
||||
return [self trackMoveWithEvent:anEvent];
|
||||
|
||||
return [super couldBeMoveEvent:anEvent];
|
||||
[super mouseDown:anEvent];
|
||||
}
|
||||
|
||||
- (void)_enableSheet:(BOOL)enable
|
||||
|
||||
@@ -24,18 +24,7 @@
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
var _CPWindowViewResizeIndicatorImage = nil,
|
||||
_CPWindowViewCornerResizeRectWidth = 10,
|
||||
|
||||
_CPWindowViewResizeRegionNone = -1,
|
||||
_CPWindowViewResizeRegionTopLeft = 0,
|
||||
_CPWindowViewResizeRegionTop = 1,
|
||||
_CPWindowViewResizeRegionTopRight = 2,
|
||||
_CPWindowViewResizeRegionRight = 3,
|
||||
_CPWindowViewResizeRegionBottomRight = 4,
|
||||
_CPWindowViewResizeRegionBottom = 5,
|
||||
_CPWindowViewResizeRegionBottomLeft = 6,
|
||||
_CPWindowViewResizeRegionLeft = 7;
|
||||
var _CPWindowViewResizeIndicatorImage = nil;
|
||||
|
||||
@implementation _CPWindowView : CPView
|
||||
{
|
||||
@@ -49,7 +38,6 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
// BOOL _isAnimatingToolbar;
|
||||
|
||||
CGRect _resizeFrame;
|
||||
int _resizeRegion;
|
||||
CGPoint _mouseDraggedPoint;
|
||||
|
||||
CGRect _cachedScreenFrame;
|
||||
@@ -62,17 +50,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
|
||||
@@ -88,34 +76,12 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
|
||||
- (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
|
||||
{
|
||||
var contentRect = [[self class] contentRectForFrameRect:aFrameRect],
|
||||
theToolbar = [[self window] toolbar];
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
var toolbarHeight = _CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
contentRect.origin.y += toolbarHeight;
|
||||
contentRect.size.height -= toolbarHeight;
|
||||
}
|
||||
|
||||
return contentRect;
|
||||
return [[self class] contentRectForFrameRect:aFrameRect];
|
||||
}
|
||||
|
||||
- (CGRect)frameRectForContentRect:(CGRect)aContentRect
|
||||
{
|
||||
var frameRect = [[self class] frameRectForContentRect:aContentRect],
|
||||
theToolbar = [[self window] toolbar];
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
var toolbarHeight = _CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
frameRect.origin.y -= toolbarHeight;
|
||||
frameRect.size.height += toolbarHeight;
|
||||
}
|
||||
|
||||
return frameRect;
|
||||
return [[self class] frameRectForContentRect:aContentRect];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask
|
||||
@@ -125,8 +91,8 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
if (self)
|
||||
{
|
||||
_styleMask = aStyleMask;
|
||||
_resizeIndicatorOffset = _CGSizeMakeZero();
|
||||
_toolbarOffset = _CGSizeMakeZero();
|
||||
_resizeIndicatorOffset = CGSizeMakeZero();
|
||||
_toolbarOffset = CGSizeMakeZero();
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -147,356 +113,48 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
var theWindow = [self window],
|
||||
couldResize = _styleMask & CPResizableWindowMask;
|
||||
var theWindow = [self window];
|
||||
|
||||
couldResize = couldResize && (
|
||||
(CPWindowResizeStyle === CPWindowResizeStyleModern) ||
|
||||
((CPWindowResizeStyle === CPWindowResizeStyleLegacy) && _resizeIndicator));
|
||||
|
||||
if (couldResize)
|
||||
if ((_styleMask & CPResizableWindowMask) && _resizeIndicator)
|
||||
{
|
||||
var theWindow = [self window],
|
||||
windowFrame = [theWindow frame],
|
||||
shouldResize = NO;
|
||||
// FIXME: This should be better
|
||||
var frame = [_resizeIndicator frame];
|
||||
|
||||
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)
|
||||
if (CGRectContainsPoint(frame, [self convertPoint:[anEvent locationInWindow] fromView:nil]))
|
||||
return [self trackResizeWithEvent:anEvent];
|
||||
}
|
||||
|
||||
if ([self couldBeMoveEvent:anEvent])
|
||||
if ([theWindow isMovable] && [theWindow isMovableByWindowBackground])
|
||||
[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
|
||||
{
|
||||
/*
|
||||
If the window is fixed width (minSize.width === maxSize.width), there
|
||||
are 2 possible resize rects: top and bottom.
|
||||
|
||||
If the window is fixed height (minSize.height === maxSize.height), there
|
||||
are 2 possible resize rects: left and right.
|
||||
|
||||
Otherwise 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 wind = [self window],
|
||||
frame = [wind frame],
|
||||
rect,
|
||||
minSize = [wind minSize],
|
||||
maxSize = [wind maxSize],
|
||||
isFixedWidth = minSize.width === maxSize.width,
|
||||
isFixedHeight = minSize.height === maxSize.height;
|
||||
|
||||
if (isFixedWidth)
|
||||
{
|
||||
rect = _CGRectMake(frame.origin.x - CPWindowResizeSlop,
|
||||
frame.origin.y - CPWindowResizeSlop,
|
||||
frame.size.width + (CPWindowResizeSlop * 2),
|
||||
CPWindowResizeSlop * 2);
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionTop;
|
||||
|
||||
rect.origin.y = _CGRectGetMaxY(frame) - CPWindowResizeSlop;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionBottom;
|
||||
}
|
||||
else if (isFixedHeight)
|
||||
{
|
||||
rect = _CGRectMake(frame.origin.x - CPWindowResizeSlop,
|
||||
frame.origin.y - CPWindowResizeSlop,
|
||||
CPWindowResizeSlop * 2,
|
||||
frame.size.height + (CPWindowResizeSlop * 2));
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionLeft;
|
||||
|
||||
rect.origin.x = _CGRectGetMaxX(frame) - CPWindowResizeSlop;
|
||||
|
||||
if (_CGRectContainsPoint(rect, aPoint))
|
||||
return _CPWindowViewResizeRegionRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
{
|
||||
var theWindow = [self window];
|
||||
|
||||
if ([theWindow isFullPlatformWindow] ||
|
||||
!(_styleMask & CPResizableWindowMask) ||
|
||||
(CPWindowResizeStyle !== CPWindowResizeStyleModern))
|
||||
return;
|
||||
|
||||
var globalPoint = [theWindow convertBaseToGlobal:aPoint],
|
||||
resizeRegion = isResizing ? _resizeRegion : [self resizeRegionForPoint:globalPoint],
|
||||
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 if ([CPMenu menuBarVisible] && (_CGRectGetMinY([theWindow frame]) <= [CPMenu menuBarHeight]))
|
||||
[[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 type = [anEvent type];
|
||||
var location = [anEvent locationInWindow],
|
||||
type = [anEvent type];
|
||||
|
||||
if (type === CPLeftMouseUp)
|
||||
return;
|
||||
|
||||
var location = [anEvent locationInWindow],
|
||||
theWindow = [self window],
|
||||
globalLocation = [theWindow convertBaseToGlobal:location],
|
||||
frame = [theWindow frame];
|
||||
var theWindow = [self window];
|
||||
|
||||
if (type === CPLeftMouseDown)
|
||||
{
|
||||
_mouseDraggedPoint = _CGPointMakeCopy(globalLocation);
|
||||
_resizeFrame = _CGRectMakeCopy(frame);
|
||||
var frame = [theWindow frame];
|
||||
|
||||
_resizeFrame = CGRectMake(location.x, location.y, CGRectGetWidth(frame), CGRectGetHeight(frame));
|
||||
}
|
||||
|
||||
else if (type === CPLeftMouseDragged)
|
||||
{
|
||||
var diffX = globalLocation.x - _mouseDraggedPoint.x,
|
||||
diffY = globalLocation.y - _mouseDraggedPoint.y,
|
||||
newX = _CGRectGetMinX(_resizeFrame),
|
||||
newY = _CGRectGetMinY(_resizeFrame),
|
||||
newWidth = _CGRectGetWidth(_resizeFrame),
|
||||
newHeight = _CGRectGetHeight(_resizeFrame),
|
||||
platformFrame = [[theWindow platformWindow] usableContentFrame],
|
||||
minSize = [theWindow minSize],
|
||||
maxSize = [theWindow maxSize];
|
||||
var newSize = CGSizeMake(CGRectGetWidth(_resizeFrame) + location.x - CGRectGetMinX(_resizeFrame), CGRectGetHeight(_resizeFrame) + location.y - CGRectGetMinY(_resizeFrame));
|
||||
|
||||
// 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))
|
||||
if (theWindow._isSheet && theWindow._parentView && (theWindow._frame.size.width !== newSize.width))
|
||||
[theWindow._parentView _setAttachedSheetFrameOrigin];
|
||||
|
||||
// Constrain resize to fit within the platform window.
|
||||
var newFrame = CGRectIntersection(_CGRectMake(newX, newY, newWidth, newHeight), platformFrame);
|
||||
|
||||
[theWindow setFrame:newFrame];
|
||||
[self setCursorForLocation:location resizing:YES];
|
||||
[theWindow setFrameSize:newSize];
|
||||
}
|
||||
|
||||
[CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
|
||||
@@ -518,10 +176,10 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
if ([CPMenu menuBarVisible])
|
||||
minPointY = [[CPApp mainMenu] menuBarHeight];
|
||||
|
||||
var restrictedPoint = _CGPointMake(0, 0);
|
||||
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;
|
||||
}
|
||||
@@ -548,8 +206,8 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
var theWindow = [self window],
|
||||
frame = [theWindow frame],
|
||||
location = [theWindow convertBaseToGlobal:[anEvent locationInWindow]],
|
||||
origin = [self _pointWithinScreenFrame:_CGPointMake(_CGRectGetMinX(frame) + (location.x - _mouseDraggedPoint.x),
|
||||
_CGRectGetMinY(frame) + (location.y - _mouseDraggedPoint.y))];
|
||||
origin = [self _pointWithinScreenFrame:CGPointMake(_CGRectGetMinX(frame) + (location.x - _mouseDraggedPoint.x),
|
||||
_CGRectGetMinY(frame) + (location.y - _mouseDraggedPoint.y))];
|
||||
[theWindow setFrameOrigin:origin];
|
||||
|
||||
_mouseDraggedPoint = [self _pointWithinScreenFrame:location];
|
||||
@@ -571,12 +229,12 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
|
||||
- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
|
||||
{
|
||||
if (shouldShowResizeIndicator && CPWindowResizeStyle === CPWindowResizeStyleLegacy)
|
||||
if (shouldShowResizeIndicator)
|
||||
{
|
||||
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];
|
||||
@@ -598,7 +256,7 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
|
||||
- (void)setResizeIndicatorOffset:(CGSize)anOffset
|
||||
{
|
||||
if (_CGSizeEqualToSize(_resizeIndicatorOffset, anOffset))
|
||||
if (CGSizeEqualToSize(_resizeIndicatorOffset, anOffset))
|
||||
return;
|
||||
|
||||
_resizeIndicatorOffset = anOffset;
|
||||
@@ -609,7 +267,7 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
var size = [_resizeIndicator frame].size,
|
||||
boundsSize = [self frame].size;
|
||||
|
||||
[_resizeIndicator setFrameOrigin:_CGPointMake(boundsSize.width - size.width - anOffset.width, boundsSize.height - size.height - anOffset.height)];
|
||||
[_resizeIndicator setFrameOrigin:CGPointMake(boundsSize.width - size.width - anOffset.width, boundsSize.height - size.height - anOffset.height)];
|
||||
}
|
||||
|
||||
- (CGSize)resizeIndicatorOffset
|
||||
@@ -645,7 +303,7 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
if (!_toolbarView || [_toolbarView isHidden])
|
||||
return [self toolbarOffset].height;
|
||||
|
||||
return _CGRectGetMaxY([_toolbarView frame]);
|
||||
return CGRectGetMaxY([_toolbarView frame]);
|
||||
}
|
||||
|
||||
- (_CPToolbarView)toolbarView
|
||||
@@ -657,14 +315,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])
|
||||
@@ -672,7 +330,7 @@ var _CPWindowViewResizeIndicatorImage = nil,
|
||||
var size = [_resizeIndicator frame].size,
|
||||
boundsSize = [self bounds].size;
|
||||
|
||||
[_resizeIndicator setFrameOrigin:_CGPointMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height)];
|
||||
[_resizeIndicator setFrameOrigin:CGPointMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
|
||||
// Change of document means toolbar items may no longer make sense.
|
||||
// FIXME: DOCUMENT ARCHITECTURE Should we setToolbar: as well?
|
||||
[[[self window] toolbar] _autoValidateVisibleItems];
|
||||
[[[self window] toolbar] validateVisibleItems];
|
||||
}
|
||||
|
||||
- (void)setSupportsMultipleDocuments:(BOOL)shouldSupportMultipleDocuments
|
||||
|
||||
@@ -76,7 +76,6 @@ CPWindowPositionFlexibleTop = 1 << 22;
|
||||
|
||||
if (_minSize)
|
||||
[theWindow setMinSize:_minSize];
|
||||
|
||||
if (_maxSize)
|
||||
[theWindow setMaxSize:_maxSize];
|
||||
|
||||
|
||||
@@ -1177,6 +1177,7 @@ var resizeTimer = nil;
|
||||
{
|
||||
var type = _overriddenEventType || aDOMEvent.type;
|
||||
|
||||
|
||||
// IE's event order is down, up, up, dblclick, so we have create these events artificially.
|
||||
if (type === @"dblclick")
|
||||
{
|
||||
@@ -1207,7 +1208,7 @@ var resizeTimer = nil;
|
||||
windowNumber = [_mouseDownWindow windowNumber];
|
||||
else
|
||||
{
|
||||
var theWindow = [self _mouseHitTest:location];
|
||||
var theWindow = [self hitTest:location];
|
||||
|
||||
if ((aDOMEvent.type === CPDOMEventMouseDown) && theWindow)
|
||||
_mouseDownWindow = theWindow;
|
||||
@@ -1307,7 +1308,6 @@ var resizeTimer = nil;
|
||||
// if there are any tracking event listeners then show the event guard so we don't lose events to iframes
|
||||
// TODO Actually check for tracking event listeners, not just any listener but _CPRunModalLoop.
|
||||
var hasTrackingEventListener = NO;
|
||||
|
||||
for (var i = 0; i < CPApp._eventListeners.length; i++)
|
||||
{
|
||||
if (CPApp._eventListeners[i]._callback !== _CPRunModalLoop)
|
||||
@@ -1316,7 +1316,6 @@ var resizeTimer = nil;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_lastMouseEventLocation = location;
|
||||
|
||||
_DOMEventGuard.style.display = hasTrackingEventListener ? "" : "none";
|
||||
@@ -1487,17 +1486,7 @@ 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;
|
||||
@@ -1516,7 +1505,7 @@ var resizeTimer = nil;
|
||||
{
|
||||
var candidateWindow = windows[windowCount];
|
||||
|
||||
if (!candidateWindow._ignoresMouseEvents && [candidateWindow performSelector:aTest withObject:location])
|
||||
if (!candidateWindow._ignoresMouseEvents && [candidateWindow containsPoint:location])
|
||||
theWindow = candidateWindow;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 274 B After Width: | Height: | Size: 409 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 81 B |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 114 B |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 256 B |
|
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 302 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 86 B |
|
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 228 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 234 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 88 B |
|
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 206 B |
|
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 84 B |
|
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 112 B |
|
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 208 B |
|
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 221 B |
|
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 223 B |
|
Before Width: | Height: | Size: 74 B After Width: | Height: | Size: 80 B |
|
Before Width: | Height: | Size: 72 B After Width: | Height: | Size: 74 B |
|
Before Width: | Height: | Size: 74 B After Width: | Height: | Size: 80 B |
|
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 93 B |
|
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 416 B |
|
Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 150 B |
|
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 428 B After Width: | Height: | Size: 524 B |
|
Before Width: | Height: | Size: 804 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 195 B |
|
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 71 B After Width: | Height: | Size: 72 B |
|
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
@@ -7,7 +7,7 @@
|
||||
<key>CPBundleName</key>
|
||||
<string>Aristo</string>
|
||||
<key>BKLearnMoreURL</key>
|
||||
<string>http://cappuccino-project.org/aristo</string>
|
||||
<string>http://cappuccino.org/aristo</string>
|
||||
<key>BKLearnMoreButtonTitle</key>
|
||||
<string>Aristo Home Page</string>
|
||||
<key>CPPrincipalClass</key>
|
||||
|
||||
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 79 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.2 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 73 B After Width: | Height: | Size: 77 B |
|
Before Width: | Height: | Size: 73 B After Width: | Height: | Size: 77 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 97 B |
|
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 91 B |
|
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 143 B |
|
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 147 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 170 B |
|
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 177 B |
|
Before Width: | Height: | Size: 263 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 88 B |
|
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 77 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 76 B |
|
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 107 B |