Merge branch 'jake' into menus

This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-11-19 14:02:34 -08:00
commit ed228b6183
40 files changed
+930 -589

No files matched your search

+4 -1
View File
@@ -149,7 +149,7 @@ var CPAlertWarningImage,
[button setFrameSize:CGSizeMake([button frame].size.width, (styleMask == CPHUDBackgroundWindowMask) ? 20.0 : 24.0)];
[button setBezelStyle:(styleMask & CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundedBezelStyle];
[[_alertPanel contentView] addSubview:button];
}
@@ -161,6 +161,7 @@ var CPAlertWarningImage,
[_messageLabel setFont:[CPFont boldSystemFontOfSize:13.0]];
[_messageLabel setLineBreakMode:CPLineBreakByWordWrapping];
[_messageLabel setAlignment:CPJustifiedTextAlignment];
[_messageLabel setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
_alertImageView = [[CPImageView alloc] initWithFrame:CGRectMake(15.0, 12.0, 32.0, 32.0)];
}
@@ -263,6 +264,8 @@ var CPAlertWarningImage,
[button setAction:@selector(_notifyDelegate:)];
[button setBezelStyle:(_windowStyle == CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundRectBezelStyle];
[button setAutoresizingMask:CPViewMinXMargin|CPViewMinYMargin];
[[_alertPanel contentView] addSubview:button];
if (_buttonCount == 0)
+27 -11
View File
@@ -275,15 +275,15 @@ CPRunContinuesResponse = -1002;
postNotificationName:CPApplicationWillFinishLaunchingNotification
object:self];
var filename = window.cpOpeningFilename && window.cpOpeningFilename(),
needsUntitled = !!_documentController;
var needsUntitled = !!_documentController,
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(),
index = 0,
count = [URLStrings count];
if ([filename length])
{
needsUntitled = ![self _openFile:filename];
}
for (; index < count; ++index)
needsUntitled = ![self _openURL:[CPURL URLWithString:URLStrings[index]]] || needsUntitled;
if (needsUntitled && [_delegate respondsToSelector: @selector(applicationShouldOpenUntitledFile:)])
if (needsUntitled && [_delegate respondsToSelector:@selector(applicationShouldOpenUntitledFile:)])
needsUntitled = [_delegate applicationShouldOpenUntitledFile:self];
if (needsUntitled)
@@ -333,6 +333,11 @@ CPRunContinuesResponse = -1002;
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
}
- (void)hideOtherApplications:(id)aSender
{
[CPPlatform hideOtherApplications:self];
}
/*!
Calls \c -finishLaunching method which results in starting
the main event loop.
@@ -515,6 +520,11 @@ CPRunContinuesResponse = -1002;
return _windows;
}
- (void)hide:(id)aSender
{
[CPPlatform hide:self];
}
// Accessing the Main Menu
/*!
Returns the application's main menu
@@ -834,12 +844,18 @@ CPRunContinuesResponse = -1002;
return _namedArgs;
}
- (BOOL)_openFile:(CPString)aFilename
- (BOOL)_openURL:(CPURL)aURL
{
if (_delegate && [_delegate respondsToSelector:@selector(application:openFile:)])
return [_delegate application:self openFile:aFilename];
else
return [_documentController openDocumentWithContentsOfURL:aFilename display:YES error:NULL];
{
CPLog.warn("application:openFile: is deprecated, use application:openURL: instead.");
return [_delegate application:self openFile:[aURL absoluteString]];
}
if (_delegate && [_delegate respondsToSelector:@selector(application:openURL:)])
return [_delegate application:self openURL:aURL];
return !![_documentController openDocumentWithContentsOfURL:aURL display:YES error:NULL];
}
- (void)_didResignActive
+2 -2
View File
@@ -192,8 +192,8 @@ CPButtonStateMixed = CPThemeState("mixed");
_allowsMixedState = aFlag;
if (!_allowsMixedState)
[self unsetThemeState:CPButtonStateMixed];
if (!_allowsMixedState && [self state] === CPMixedState)
[self setState:CPOnState];
}
- (void)setObjectValue:(id)anObjectValue
+10
View File
@@ -21,6 +21,7 @@
*/
@import "CPEvent.j"
@import "CPPlatform.j"
// Browser Engines
CPUnknownBrowserEngine = 0;
@@ -56,6 +57,7 @@ CPOpacityRequiresFilterFeature = 1 << 24;
//Internet explorer does not allow dynamically changing the type of an input element
CPInputTypeCanBeChangedFeature = 1 << 25;
CPHTML5DragAndDropSourceYOffBy1 = 1 << 26;
@@ -116,6 +118,14 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound)
PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
// FIXME this is a terrible hack to get around this bug:
// https://bugs.webkit.org/show_bug.cgi?id=21548
if (![CPPlatform isBrowser])
PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
if (majorVersion < 532 || (majorVersion === 532 && minorVersion < 6))
PLATFORM_FEATURES |= CPHTML5DragAndDropSourceYOffBy1;
}
// KHTML
+12 -5
View File
@@ -146,6 +146,8 @@ var CPSharedDocumentController = nil;
result = [self makeDocumentWithContentsOfURL:anAbsoluteURL ofType:type delegate:self didReadSelector:@selector(document:didRead:contextInfo:) contextInfo:[CPDictionary dictionaryWithObject:shouldDisplay forKey:@"shouldDisplay"]];
[self addDocument:result];
if (result)
[self noteNewRecentDocument:result];
}
@@ -207,7 +209,6 @@ var CPSharedDocumentController = nil;
if (!didRead)
return;
[self addDocument:aDocument];
[aDocument makeWindowControllers];
if ([aContextInfo objectForKey:@"shouldDisplay"])
@@ -276,7 +277,8 @@ var CPSharedDocumentController = nil;
var index = 0,
count = _documentTypes.length,
extension = [[anAbsoluteURL pathExtension] lowercaseString];
extension = [[anAbsoluteURL pathExtension] lowercaseString],
starType = nil;
for (; index < count; ++index)
{
@@ -286,12 +288,17 @@ var CPSharedDocumentController = nil;
extensionCount = extensions.length;
for (; extensionIndex < extensionCount; ++extensionIndex)
if ([extensions[extensionIndex] lowercaseString] === extension)
{
var thisExtension = [extensions[extensionIndex] lowercaseString];
if (thisExtension === extension)
return [documentType objectForKey:@"CPBundleTypeName"];
if (thisExtension === "****")
starType = [documentType objectForKey:@"CPBundleTypeName"];
}
}
// FIXME?
return [self defaultType];//nil;
return starType || [self defaultType];
}
// Managing Document Types
-84
View File
@@ -25,110 +25,26 @@
#include "CoreGraphics/CGGeometry.h"
/*
@global
@group CPEventType
*/
CPLeftMouseDown = 1;
/*
@global
@group CPEventType
*/
CPLeftMouseUp = 2;
/*
@global
@group CPEventType
*/
CPRightMouseDown = 3;
/*
@global
@group CPEventType
*/
CPRightMouseUp = 4;
/*
@global
@group CPEventType
*/
CPMouseMoved = 5;
/*
@global
@group CPEventType
*/
CPLeftMouseDragged = 6;
/*
@global
@group CPEventType
*/
CPRightMouseDragged = 7;
/*
@global
@group CPEventType
*/
CPMouseEntered = 8;
/*
@global
@group CPEventType
*/
CPMouseExited = 9;
/*
@global
@group CPEventType
*/
CPKeyDown = 10;
/*
@global
@group CPEventType
*/
CPKeyUp = 11;
/*
@global
@group CPEventType
*/
CPFlagsChanged = 12;
/*
@global
@group CPEventType
*/
CPAppKitDefined = 13;
/*
@global
@group CPEventType
*/
CPSystemDefined = 14;
/*
@global
@group CPEventType
*/
CPApplicationDefined = 15;
/*
@global
@group CPEventType
*/
CPPeriodic = 16;
/*
@global
@group CPEventType
*/
CPCursorUpdate = 17;
/*
@global
@group CPEventType
*/
CPScrollWheel = 22;
/*
@global
@group CPEventType
*/
CPOtherMouseDown = 25;
/*
@global
@group CPEventType
*/
CPOtherMouseUp = 26;
/*
@global
@group CPEventType
*/
CPOtherMouseDragged = 27;
// iPhone Event Types
+1 -1
View File
@@ -781,7 +781,7 @@ var _CPMenuBarVisible = NO,
for(; index < count; ++index)
{
var item = _items[index],
modifierMask = [item keyEquivalentModifierMask];
modifierMask = [item keyEquivalentModifierMask] | ([item keyEquivalent] === [[item keyEquivalent] uppercaseString] ? CPShiftKeyMask : 0);
if ((modifierFlags & (CPShiftKeyMask | CPAlternateKeyMask | CPCommandKeyMask | CPControlKeyMask)) == modifierMask &&
[characters caseInsensitiveCompare:[item keyEquivalent]] == CPOrderedSame)
+7 -2
View File
@@ -98,7 +98,7 @@
if (self)
{
[self setRadioGroup:aRadioGroup || [CPRadioGroup new]];
[self setRadioGroup:aRadioGroup];
[self setHighlightsBy:CPContentsCellMask];
[self setShowsStateBy:CPContentsCellMask];
@@ -115,7 +115,7 @@
- (id)initWithFrame:(CGRect)aFrame
{
return [self initWithFrame:aFrame radioGroup:nil];
return [self initWithFrame:aFrame radioGroup:[CPRadioGroup new]];
}
- (CPInteger)nextState
@@ -175,6 +175,9 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
{
CPSet _radios;
CPRadio _selectedRadio;
id _target @accessors(property=target);
SEL _action @accessors(property=action);
}
- (id)init
@@ -213,6 +216,8 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
[_selectedRadio setState:CPOffState];
_selectedRadio = aRadio;
[CPApp sendAction:_action to:_target from:self];
}
- (CPRadio)selectedRadio
+1 -1
View File
@@ -241,7 +241,7 @@ CPDownArrowKeyCode = 40;
*/
- (void)insertNewline:(id)aSender
{
[self insertNewline:aSender];
[[self nextResponder] insertNewline:aSender];
}
- (void)cancel:(id)sender
+24 -1
View File
@@ -5,6 +5,13 @@
@implementation CPSavePanel : CPPanel
{
CPURL _URL;
BOOL _isExtensionHidden @accessors(getter=isExtensionHidden, setter=setExtensionHidden:);
BOOL _canSelectHiddenExtension @accessors(property=canSelectHiddenExtension);
BOOL _allowsOtherFileTypes @accessors(property=allowsOtherFileTypes);
BOOL _canCreateDirectories @accessors(property=canCreateDirectories);
CPArray _allowedFileTypes @accessors(property=allowedFileTypes);
}
+ (id)savePanel
@@ -12,6 +19,16 @@
return [[CPSavePanel alloc] init];
}
- (id)init
{
if (self = [super init])
{
_canCreateDirectories = YES;
}
return self;
}
- (CPInteger)runModal
{
// FIXME: Is this correct???
@@ -19,7 +36,13 @@
if (typeof window["cpSavePanel"] === "function")
{
var resultObject = window.cpSavePanel(),
var resultObject = window.cpSavePanel({
isExtensionHidden: _isExtensionHidden,
canSelectHiddenExtension: _canSelectHiddenExtension,
allowsOtherFileTypes: _allowsOtherFileTypes,
canCreateDirectories: _canCreateDirectories,
allowedFileTypes: _allowedFileTypes
}),
result = resultObject.button;
_URL = result ? [CPURL URLWithString:resultObject.URL] : nil;
+3 -13
View File
@@ -313,16 +313,11 @@
return;
_hasHorizontalScroller = shouldHaveHorizontalScroller;
if (_hasHorizontalScroller && !_horizontalScroller)
[self setHorizontalScroller:[[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, _CGRectGetWidth([self bounds]), [CPScroller scrollerWidth])]];
else if (!_hasHorizontalScroller && _horizontalScroller)
{
[_horizontalScroller setHidden:YES];
[self reflectScrolledClipView:_contentView];
}
[self reflectScrolledClipView:_contentView];
}
/*!
@@ -380,12 +375,7 @@
if (_hasVerticalScroller && !_verticalScroller)
[self setVerticalScroller:[[CPScroller alloc] initWithFrame:_CGRectMake(0.0, 0.0, [CPScroller scrollerWidth], _CGRectGetHeight([self bounds]))]];
else if (!_hasVerticalScroller && _verticalScroller)
{
[_verticalScroller setHidden:YES];
[self reflectScrolledClipView:_contentView];
}
[self reflectScrolledClipView:_contentView];
}
/*!
+3
View File
@@ -151,6 +151,9 @@ var CPSplitViewHorizontalImage = nil,
_DOMDividerElements = [];
#endif
// The divider changes size when pane splitter mode is toggled, so the
// subviews need to change size too.
_needsResizeSubviews = YES;
[self setNeedsDisplay:YES];
}
+1 -1
View File
@@ -236,7 +236,7 @@ CPTableViewSolidHorizontalGridLineMask = 1 << 1;
if ([_dataSource respondsToSelector:@selector(tableView:setObjectValue:forTableColumn:row:)])
_implementedDataSourceMethods |= CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_;
if ([_dataSource respondsToSelector:@selector(tableView:setObjectValue:forTableColumn:row:)])
if ([_dataSource respondsToSelector:@selector(tableView:acceptDrop:row:dropOperation:)])
_implementedDataSourceMethods |= CPTableViewDataSource_tableView_acceptDrop_row_dropOperation_;
if ([_dataSource respondsToSelector:@selector(tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:)])
+71 -93
View File
@@ -209,97 +209,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
return true;
}
CPTextFieldKeyDownFunction = function(aDOMEvent)
{
CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue];
aDOMEvent = aDOMEvent || window.event;
if (aDOMEvent.keyCode == CPReturnKeyCode || aDOMEvent.keyCode == CPTabKeyCode)
CPTextFieldKeyPressFunction(aDOMEvent);
return true;
}
CPTextFieldKeyPressFunction = function(aDOMEvent)
{
aDOMEvent = aDOMEvent || window.event;
CPTextFieldKeyUpFunction();
if (aDOMEvent.keyCode == CPReturnKeyCode || aDOMEvent.keyCode == CPTabKeyCode)
{
if (aDOMEvent.preventDefault)
aDOMEvent.preventDefault();
if (aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
aDOMEvent.cancelBubble = true;
var owner = CPTextFieldInputOwner;
if (aDOMEvent && aDOMEvent.keyCode == CPReturnKeyCode)
{
if (owner._isEditing)
{
owner._isEditing = NO;
[owner textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:owner userInfo:nil]];
}
[owner sendAction:[owner action] to:[owner target]];
[owner selectText:nil];
}
else if (aDOMEvent && aDOMEvent.keyCode == CPTabKeyCode)
{
if (!aDOMEvent.shiftKey)
[[owner window] selectNextKeyView:owner];
else
[[owner window] selectPreviousKeyView:owner];
}
}
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
CPTextFieldKeyUpFunction = function()
{
[CPTextFieldInputOwner _setStringValue:CPTextFieldDOMInputElement.value];
if ([CPTextFieldInputOwner stringValue] !== CPTextFieldTextDidChangeValue)
{
if (!CPTextFieldInputOwner._isEditing)
{
CPTextFieldInputOwner._isEditing = YES;
[CPTextFieldInputOwner textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:CPTextFieldInputOwner userInfo:nil]];
}
[CPTextFieldInputOwner textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:CPTextFieldInputOwner userInfo:nil]];
CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue];
}
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
CPTextFieldHandleBlur = function(anEvent)
{
var owner = CPTextFieldInputOwner;
CPTextFieldInputOwner = nil;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
if (document.attachEvent)
{
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyUp, CPTextFieldKeyUpFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyDown, CPTextFieldKeyDownFunction);
CPTextFieldDOMInputElement.attachEvent("on" + CPDOMEventKeyPress, CPTextFieldKeyPressFunction);
}
else
{
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyUp, CPTextFieldKeyUpFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyDown, CPTextFieldKeyDownFunction, NO);
CPTextFieldDOMInputElement.addEventListener(CPDOMEventKeyPress, CPTextFieldKeyPressFunction, NO);
}
//FIXME make this not onblur
CPTextFieldDOMInputElement.onblur = CPTextFieldBlurFunction;
@@ -661,6 +577,77 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
return YES;
}
- (void)mouseDown:(CPEvent)anEvent
{
// Don't track! (ever?)
if ([self isEditable] && [self isEnabled])
return [[self window] makeFirstResponder:self];
else
return [[self nextResponder] mouseDown:anEvent];
}
- (void)mouseUp:(CPEvent)anEvent
{
if (![self isEditable] || ![self isEnabled])
[[self nextResponder] mouseUp:anEvent];
}
- (void)mouseDragged:(CPEvent)anEvent
{
if (![self isEditable] || ![self isEnabled])
[[self nextResponder] mouseDragged:anEvent];
}
- (void)keyUp:(CPEvent)anEvent
{
var oldValue = [self stringValue];
[self _setStringValue:[self _inputElement].value];
if (oldValue !== [self stringValue])
{
if (!_isEditing)
{
_isEditing = YES;
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
}
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
}
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
- (void)keyDown:(CPEvent)anEvent
{
if ([anEvent keyCode] === CPReturnKeyCode)
{
if (_isEditing)
{
_isEditing = NO;
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
}
[self sendAction:[self action] to:[self target]];
[self selectText:nil];
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
}
else if ([anEvent keyCode] === CPTabKeyCode)
{
if ([anEvent modifierFlags] & CPShiftKeyMask)
[[self window] selectPreviousKeyView:self];
else
[[self window] selectNextKeyView:self];
[[[self window] platformWindow] _propagateCurrentDOMEvent:NO];
}
else
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
- (void)textDidBlur:(CPNotification)note
{
//this looks to prevent false propagation of notifications for other objects
@@ -679,15 +666,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[[CPNotificationCenter defaultCenter] postNotification:note];
}
- (void)mouseDown:(CPEvent)anEvent
{
// Don't track! (ever?)
if ([self isEditable] && [self isEnabled])
return [[self window] makeFirstResponder:self];
else
return [[self nextResponder] mouseDown:anEvent];
}
/*!
Returns the string the text field.
*/
+388 -197
View File
@@ -28,6 +28,8 @@
@import "CPPopUpButton.j"
@import "CPToolbarItem.j"
#include "CoreGraphics/CGGeometry.h"
/*
@global
@@ -316,6 +318,15 @@ var CPToolbarConfigurationsByIdentifier = nil;
return _itemsSortedByVisibilityPriority;
}
- (void)validateVisibleToolbarItems
{
var toolbarItems = [self visibleItems],
count = [toolbarItems count];
while (count--)
[toolbarItems[count] validate];
}
/* @ignore */
- (id)_itemForItemIdentifier:(CPString)identifier willBeInsertedIntoToolbar:(BOOL)toolbar
{
@@ -448,15 +459,18 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
CPIndexSet _visibleFlexibleWidthIndexes;
CPDictionary _itemInfos;
CPArray _visibleItems;
JSObject _viewsForToolbarItems;
CPArray _visibleItems @accessors(readonly, property=visibleItems);
CPArray _invisibleItems;
CPPopUpButton _additionalItemsButton;
CPColor _labelColor;
CPColor _labelShadowColor;
float _minWidth;
BOOL _FIXME_isHUD;
}
+ (void)initialize
@@ -504,108 +518,110 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
return _toolbar;
}
- (void)setLabelColor:(CPColor)aColor
- (void)FIXME_setIsHUD:(BOOL)shouldBeHUD
{
if (_labelColor === aColor)
if (_FIXME_isHUD === shouldBeHUD)
return;
_labelColor = aColor;
var items = [_toolbar items],
count = [items count];
while (count--)
[[self labelForItem:items[count]] setTextColor:_labelColor];
}
- (void)setLabelShadowColor:(CPColor)aColor
{
if (_labelShadowColor === aColor)
return;
_labelShadowColor = aColor;
_FIXME_isHUD = shouldBeHUD;
var items = [_toolbar items],
count = [items count];
while (count--)
[[self labelForItem:items[count]] setTextShadowColor:_labelShadowColor];
[[self viewForItem:items[count]] FIXME_setIsHUD:shouldBeHUD];
}
// This *should* be roughly O(3N) = O(N)
- (void)resizeSubviewsWithOldSize:(CGSize)aSize
{
[self layoutSubviews];
[self tile];
}
- (void)layoutSubviews
- (_CPToolbarItemView)viewForItem:(CPToolbarItem)anItem
{
return _viewsForToolbarItems[[anItem UID]] || nil;
}
- (void)tile
{
// We begin by recalculating the visible items.
var items = [_toolbar items],
width = CGRectGetWidth([self bounds]),
itemsWidth = CGRectGetWidth([self bounds]),
minWidth = _minWidth,
flexibleItemIndexes = [CPIndexSet indexSet],
// FIXME: This should be a CPSet.
invisibleItemsSortedByPriority = [];
_visibleItems = items;
// We only have hidden items if our actual width is smaller than our
// minimum width for hiding items.
if (width < minWidth)
if (itemsWidth < minWidth)
{
width -= TOOLBAR_EXTRA_ITEMS_WIDTH;
itemsWidth -= TOOLBAR_EXTRA_ITEMS_WIDTH;
_visibleItems = [_visibleItems copy];
var itemsSortedByVisibilityPriority = [_toolbar itemsSortedByVisibilityPriority],
count = itemsSortedByVisibilityPriority.length;
// While our items take up too much space...
while (minWidth > width)
// Remove items until we fit:
// The assumption here is that there are more visible items than there are
// invisible items, if not it would be faster to add items until we *no
// longer fit*.
while (minWidth > itemsWidth && count)
{
var item = itemsSortedByVisibilityPriority[count--];
minWidth -= [self minWidthForItem:item] + TOOLBAR_ITEM_MARGIN;
var item = itemsSortedByVisibilityPriority[--count],
view = [self viewForItem:item];
minWidth -= [view minSize].width + TOOLBAR_ITEM_MARGIN;
[_visibleItems removeObjectIdenticalTo:item];
[invisibleItemsSortedByPriority addObject:item];
[[self viewForItem:item] setHidden:YES];
[[self labelForItem:item] setHidden:YES];
[view setHidden:YES];
[view FIXME_setIsHUD:_FIXME_isHUD];
}
}
// FIXME: minHeight?
var count = [items count],
height = 0.0;
while (count--)
{
var view = [self viewForItem:items[count]],
minSize = [view minSize];
if (height < minSize.height)
height = minSize.height;
}
// Determine all the items that have flexible width.
// Also determine the height of the toolbar.
// NOTE: height is height without top margin, and bottom margin/label.
var index = _visibleItems.length,
height = 0.0;
var count = _visibleItems.length
flexibleItemIndexes = [CPIndexSet indexSet];
while (index--)
while (count--)
{
var item = _visibleItems[index],
minSize = [item minSize],
view = [self viewForItem:item];
if (minSize.width != [item maxSize].width)
[flexibleItemIndexes addIndex:index];
// If the item doesn't have flexible width, then make sure it's set to the static width (min==max)
// This handles the case where the user did setView: with a view of a different size than minSize/maxSize
else
[view setFrameSize:CGSizeMake([item minSize].width, CGRectGetHeight([view frame]))];
var item = _visibleItems[count],
view = [self viewForItem:item],
minSize = [view minSize];
// FIXME: minHeight?
if (minSize.width !== [view maxSize].width)
[flexibleItemIndexes addIndex:count];
// FIXME: Is this still necessary? (probably not since we iterate them all below).
// If the item doesn't have flexible width, then make sure it's set to the
// static width (min==max). This handles the case where the user did setView:
// with a view of a different size than minSize/maxSize
else
[view setFrameSize:CGSizeMake(minSize.width, height)];
[view setHidden:NO];
[[self labelForItem:item] setHidden:NO];
if (height < minSize.height)
height = minSize.height;
}
var remainingSpace = width - minWidth,
var remainingSpace = itemsWidth - minWidth,
proportionate = 0.0;
// Continue to distribute space proportionately while we have it,
@@ -618,70 +634,44 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
// Reset the remaining space to 0
remainingSpace = 0.0;
var index = CPNotFound;
while ((index = [flexibleItemIndexes indexGreaterThanIndex:index]) != CPNotFound)
while ((index = [flexibleItemIndexes indexGreaterThanIndex:index]) !== CPNotFound)
{
var item = _visibleItems[index];
var item = _visibleItems[index],
view = [self viewForItem:item],
viewFrame = [view frame],
// FIXME: Should this be minWidthForItem: ?
proposedWidth = [item minSize].width + proportionate,
constrainedWidth = MIN(proposedWidth, [item maxSize].width);
proposedWidth = [view minSize].width + proportionate,
constrainedWidth = MIN(proposedWidth, [view maxSize].width);
if (constrainedWidth < proposedWidth)
{
[flexibleItemIndexes removeIndex:index];
remainingSpace += proposedWidth - constrainedWidth;
}
[view setFrameSize:CGSizeMake(constrainedWidth, CGRectGetHeight(viewFrame))];
[view setFrameSize:CGSizeMake(constrainedWidth, height)];
}
}
// Now that all the visible items are the correct width, position them accordingly.
var count = _visibleItems.length,
x = TOOLBAR_ITEM_MARGIN,
fullHeightItems = [];
// Now that all the visible items are the correct width, give them their final frames.
var index = 0,
count = _visibleItems.length,
x = TOOLBAR_ITEM_MARGIN;
for (index = 0; index < count; ++index)
for (; index < count; ++index)
{
var item = _visibleItems[index],
view = [self viewForItem:item],
viewFrame = [view frame],
viewWidth = CGRectGetWidth(viewFrame),
label = [self labelForItem:item],
labelFrame = [label frame],
labelWidth = CGRectGetWidth(labelFrame),
itemWidth = MAX([self minWidthForItem:item], viewWidth),
viewHeight = CGRectGetHeight(viewFrame);
var view = [self viewForItem:_visibleItems[index]],
viewWidth = CGRectGetWidth([view frame]);
// itemWidth != viewWidth. itemWidth is MAX(size of view, size of label). If the label is larger,
// *center* the view, don't resize it.
[view setFrame:CGRectMake(x + (itemWidth - viewWidth) / 2.0, TOOLBAR_TOP_MARGIN + (height - viewHeight) / 2.0, viewWidth, viewHeight)];
[label setFrameOrigin:CGPointMake(x + (itemWidth - labelWidth) / 2.0, TOOLBAR_TOP_MARGIN + height + 2.0)];
[view setFrame:CGRectMake(x, 0.0, viewWidth, height)];
x += itemWidth + TOOLBAR_ITEM_MARGIN;
if ([item itemIdentifier] == CPToolbarSeparatorItemIdentifier)
fullHeightItems.push(item);
}
for (index = 0, count = fullHeightItems.length; index < count; ++index)
{
var view = [self viewForItem:fullHeightItems[index]],
viewHeight = 53.0;
// FIXME: Variable Height
[view setFrame:CGRectMake(CGRectGetMinX([view frame]), (59.0 - viewHeight) / 2.0, CGRectGetWidth([view frame]), viewHeight)];
x += viewWidth + TOOLBAR_ITEM_MARGIN;
}
var needsAdditionalItemsButton = NO;
if ([invisibleItemsSortedByPriority count])
{
var index = 0,
@@ -692,27 +682,55 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
for (; index < count; ++index)
{
var item = items[index];
if ([invisibleItemsSortedByPriority indexOfObjectIdenticalTo:item] != CPNotFound)
if ([invisibleItemsSortedByPriority indexOfObjectIdenticalTo:item] !== CPNotFound)
{
[_invisibleItems addObject:item];
var identifier = [item itemIdentifier];
if (identifier !== CPToolbarSpaceItemIdentifier &&
identifier !== CPToolbarFlexibleSpaceItemIdentifier &&
identifier !== CPToolbarSeparatorItemIdentifier)
needsAdditionalItemsButton = YES;
}
}
[_additionalItemsButton setFrameOrigin:CGPointMake(width + 5.0, (CGRectGetHeight([self bounds]) - CGRectGetHeight([_additionalItemsButton frame])) / 2.0)];
}
if (needsAdditionalItemsButton)
{
[_additionalItemsButton setFrameOrigin:CGPointMake(itemsWidth + 5.0, (CGRectGetHeight([self bounds]) - CGRectGetHeight([_additionalItemsButton frame])) / 2.0)];
[self addSubview:_additionalItemsButton];
[_additionalItemsButton removeAllItems];
var index = 0,
count = [_invisibleItems count];
[_additionalItemsButton addItemWithTitle:@"Additional Items"];
[[_additionalItemsButton itemArray][0] setImage:_CPToolbarViewExtraItemsImage];
var index = 0,
count = [_invisibleItems count],
hasNonSeparatorItem = NO;
for (; index < count; ++index)
{
var item = _invisibleItems[index];
var item = _invisibleItems[index],
identifier = [item itemIdentifier];
if (identifier === CPToolbarSpaceItemIdentifier ||
identifier === CPToolbarFlexibleSpaceItemIdentifier)
continue;
if (identifier === CPToolbarSeparatorItemIdentifier)
{
if (hasNonSeparatorItem)
[_additionalItemsButton addItem:[CPMenuItem separatorItem]];
continue;
}
hasNonSeparatorItem = YES;
[_additionalItemsButton addItemWithTitle:[item label]];
var menuItem = [_additionalItemsButton itemArray][index + 1];
@@ -728,36 +746,6 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
}
- (CPView)viewForItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem UID]];
if (!info)
return nil;
return info.view;
}
- (CPTextField)labelForItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem UID]];
if (!info)
return nil;
return info.label;
}
- (float)minWidthForItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem UID]];
if (!info)
return 0;
return info.minWidth;
}
- (void)reloadToolbarItems
{
// Get rid of all our current subviews.
@@ -772,63 +760,22 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
index = 0;
count = items.length;
_itemInfos = [CPDictionary dictionary];
_minWidth = TOOLBAR_ITEM_MARGIN;
_viewsForToolbarItems = { };
for (; index < count; ++index)
{
var item = items[index],
view = [item view];
// If this item doesn't have a custom view, create a standard one.
if (!view)
{
view = [[CPButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 32.0, 32.0)];
[view setBordered:NO];
[view setImage:[item image]];
[view setAlternateImage:[item alternateImage]];
[view setTarget:[item target]];
[view setAction:[item action]];
[view setTag:[item tag]];
[view setImagePosition:CPImageOnly];
}
view = [[_CPToolbarItemView alloc] initWithToolbarItem:item toolbar:self];
_viewsForToolbarItems[[item UID]] = view;
[self addSubview:view];
// Create a lable for this item.
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[label setStringValue:[item label]];
[label setFont:[CPFont systemFontOfSize:11.0]];
[label setTextColor:_labelColor];
[label setTextShadowColor:_labelShadowColor];
[label setTextShadowOffset:CGSizeMake(0, 1)];
[label sizeToFit];
[label setTarget:[item target]];
[label setAction:[item action]];
[self addSubview:label];
var minSize = [item minSize],
minWidth = MAX(minSize.width, CGRectGetWidth([label frame]));
[_itemInfos setObject:_CPToolbarItemInfoMake(index, view, label, minWidth) forKey:[item UID]];
_minWidth += minWidth + TOOLBAR_ITEM_MARGIN;
// If the minSize is different than the maxSize, then this item has flexible width.
//if (minSize.width != [item maxSize].width)
// [_flexibleWidthIndexes addIndex:index];
_minWidth += [view minSize].width + TOOLBAR_ITEM_MARGIN;
}
[self layoutSubviews];
[self tile];
}
@end
@@ -847,3 +794,247 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return CPOrderedDescending;
}
var TOP_MARGIN = 5.0,
LABEL_MARGIN = 2.0;
@implementation _CPToolbarItemView : CPControl
{
CGSize _minSize @accessors(readonly, property=minSize);
CGSize _maxSize @accessors(readonly, property=maxSize);
CGSize _labelSize;
CPToolbarItem _toolbarItem;
CPToolbar _toolbar;
CPImageView _imageView;
CPView _view;
CPTextField _labelField;
BOOL _FIXME_isHUD;
}
- (id)initWithToolbarItem:(CPToolbarItem)aToolbarItem toolbar:(CPToolbar)aToolbar
{
self = [super init];
if (self)
{
_toolbarItem = aToolbarItem;
_labelField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_labelField setFont:[CPFont systemFontOfSize:11.0]];
[_labelField setTextColor:[self FIXME_labelColor]];
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
[_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
[_labelField setAutoresizingMask:CPViewWidthSizable | CPViewMinXMargin];
[self addSubview:_labelField];
[self updateFromItem];
_toolbar = aToolbar;
[_toolbarItem addObserver:self forKeyPath:"enabled" options:0 context:NULL];
}
return self;
}
- (void)FIXME_setIsHUD:(BOOL)shouldBeHUD
{
_FIXME_isHUD = shouldBeHUD;
[_labelField setTextColor:[self FIXME_labelColor]];
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
}
- (void)updateFromItem
{
var identifier = [_toolbarItem itemIdentifier];
if (identifier === CPToolbarSpaceItemIdentifier ||
identifier === CPToolbarFlexibleSpaceItemIdentifier ||
identifier === CPToolbarSeparatorItemIdentifier)
{
[_view removeFromSuperview];
[_imageView removeFromSuperview];
_minSize = [_toolbarItem minSize];
_maxSize = [_toolbarItem maxSize];
if (identifier === CPToolbarSeparatorItemIdentifier)
{
_view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 2.0, 32.0)];
// FIXME: Get rid of this old API!!!
sizes = {};
sizes[@"CPToolbarItemSeparator"] = [CGSizeMake(2.0, 26.0), CGSizeMake(2.0, 1.0), CGSizeMake(2.0, 26.0)];
[_view setBackgroundColor:_CPControlThreePartImagePattern(YES, sizes, @"CPToolbarItem", @"Separator")];
[self addSubview:_view];
}
return;
}
[self setTarget:[_toolbarItem target]];
[self setAction:[_toolbarItem action]];
var view = [_toolbarItem view] || nil;
if (view !== _view)
{
if (!view)
[_view removeFromSuperview];
else
{
[self addSubview:view];
[_imageView removeFromSuperview];
}
_view = view;
}
if (!_view)
{
if (!_imageView)
{
_imageView = [[CPImageView alloc] initWithFrame:[self bounds]];
[_imageView setImageScaling:CPScaleNone];
[self addSubview:_imageView];
}
[_imageView setImage:[_toolbarItem image]];
}
var minSize = [_toolbarItem minSize],
maxSize = [_toolbarItem maxSize];
[_labelField setStringValue:[_toolbarItem label]];
[_labelField sizeToFit]; // FIXME
_labelSize = [_labelField frame].size;
_minSize = CGSizeMake(MAX(_labelSize.width, minSize.width), _labelSize.height + minSize.height + LABEL_MARGIN + TOP_MARGIN);
_maxSize = CGSizeMake(MAX(_labelSize.width, minSize.width), 100000000.0);
[_toolbar tile];
}
- (void)layoutSubviews
{
var identifier = [_toolbarItem itemIdentifier];
if (identifier === CPToolbarSpaceItemIdentifier ||
identifier === CPToolbarFlexibleSpaceItemIdentifier)
return;
var bounds = [self bounds],
width = _CGRectGetWidth(bounds);
if (identifier === CPToolbarSeparatorItemIdentifier)
return [_view setFrame:CGRectMake(ROUND((width - 2.0) / 2.0), 0.0, 2.0, _CGRectGetHeight(bounds))];
var view = _view || _imageView,
itemMaxSize = [_toolbarItem maxSize],
height = _CGRectGetHeight(bounds) - _labelSize.height - LABEL_MARGIN - TOP_MARGIN,
viewWidth = MIN(itemMaxSize.width, width),
viewHeight = MIN(itemMaxSize.height, height);
[view setFrame:CGRectMake( ROUND((width - viewWidth) / 2.0),
TOP_MARGIN + ROUND((height - viewHeight) / 2.0),
viewWidth,
viewHeight)];
[_labelField setFrameOrigin:CGPointMake(ROUND((width - _labelSize.width) / 2.0), TOP_MARGIN + height + LABEL_MARGIN)];
}
- (void)mouseDown:(CPEvent)anEvent
{
if ([_toolbarItem view])
return [[self nextResponder] mouseDown:anEvent];
var identifier = [_toolbarItem itemIdentifier];
if (identifier === CPToolbarSpaceItemIdentifier ||
identifier === CPToolbarFlexibleSpaceItemIdentifier ||
identifier === CPToolbarSeparatorItemIdentifier)
return [[self nextResponder] mouseDown:anEvent];
[super mouseDown:anEvent];
}
- (void)setEnabled:(BOOL)shouldBeEnabled
{
[super setEnabled:shouldBeEnabled];
if (shouldBeEnabled)
{
[_imageView setAlphaValue:1.0];
[_labelField setAlphaValue:1.0];
}
else
{
[_imageView setAlphaValue:0.5];
[_labelField setAlphaValue:0.5];
}
}
- (CPColor)FIXME_labelColor
{
if (_FIXME_isHUD)
return [CPColor whiteColor];
return [CPColor blackColor];
}
- (CPColor)FIXME_labelShadowColor
{
if (_FIXME_isHUD)
return [self isHighlighted] ? [CPColor colorWithWhite:1.0 alpha:0.5] : [CPColor clearColor];
return [self isHighlighted] ? [CPColor colorWithWhite:0.0 alpha:0.3] : [CPColor colorWithWhite:1.0 alpha:0.75];
}
- (void)setHighlighted:(BOOL)shouldBeHighlighted
{
[super setHighlighted:shouldBeHighlighted];
if (shouldBeHighlighted)
{
var alternateImage = [_toolbarItem alternateImage];
if (alternateImage)
[_imageView setImage:alternateImage];
[_labelField setTextShadowOffset:CGSizeMakeZero()];
}
else
{
var image = [_toolbarItem image];
if (image)
[_imageView setImage:image];
[_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
}
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
}
- (void)observeValueForKeyPath:(CPString)aKeyPath
ofObject:(id)anObject
change:(CPDictionary)aChange
context:(id)aContext
{
// FIXME: Not clear if -synchronizeWindowTitleWithDocumentName is the best way to go.
if (aKeyPath === "enabled")
[self setEnabled:[anObject isEnabled]];
}
@end
+52 -39
View File
@@ -65,9 +65,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
@implementation CPToolbarItem : CPObject
{
CPString _itemIdentifier;
CPToolbar _toolbar;
CPString _label;
CPString _paletteLabel;
CPString _toolTip;
@@ -77,13 +77,15 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
BOOL _isEnabled;
CPImage _image;
CPImage _alternateImage;
CPView _view;
CGSize _minSize;
CGSize _maxSize;
int _visibilityPriority;
BOOL _autovalidates;
}
- (id)init
@@ -449,6 +451,48 @@ CPToolbarItemVisibilityPriorityUser
_visibilityPriority = aVisibilityPriority;
}
- (void)validate
{
// View items do not do any target-action analysis.
if (_view)
{
if ([target respondsToSelector:@selector(validateToolbarItem:)])
[self setEnabled:[target validateToolbarItem:self]];
return;
}
var action = [self action];
if (!action)
return [self setEnabled:NO];
var target = [self target];
if (target && ![target respondsToSelector:action])
return [self setEnabled:NO];
target = [CPApp targetForAction:action to:target from:self];
if (!target)
return [self setEnabled:NO];
if ([target respondsToSelector:@selector(validateToolbarItem:)])
[self setEnabled:[target validateToolbarItem:self]];
else
[self setEnabled:YES];
}
- (BOOL)autovalidates
{
return _autovalidates;
}
- (void)setAutovalidates:(BOOL)shouldAutovalidate
{
_autovalidates = !!shouldAutovalidate;
}
@end
@implementation CPToolbarItem (CPCopying)
@@ -485,33 +529,8 @@ CPToolbarItemVisibilityPriorityUser
// Standard toolbar identifiers
var _CPToolbarSeparatorItemView = nil,
_CPToolbarSpaceItemView = nil;
@implementation CPToolbarItem (Standard)
+ (CPView)_separatorItemView
{
if (!_CPToolbarSeparatorItemView)
{
_CPToolbarSeparatorItemView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 2.0, 32.0)];
sizes = {};
sizes[@"CPToolbarItemSeparator"] = [CGSizeMake(2.0, 26.0), CGSizeMake(2.0, 1.0), CGSizeMake(2.0, 26.0)];
[_CPToolbarSeparatorItemView setBackgroundColor:_CPControlThreePartImagePattern(YES, sizes, @"CPToolbarItem", @"Separator")];
}
return _CPToolbarSeparatorItemView;
}
+ (CPView)_spaceItemView
{
if (!_CPToolbarSpaceItemView)
_CPToolbarSpaceItemView = [[CPView alloc] initWithFrame:CGRectMakeZero()];
return _CPToolbarSpaceItemView;
}
/* @ignore */
+ (CPToolbarItem)_standardItemWithItemIdentifier:(CPString)anItemIdentifier
{
@@ -519,23 +538,17 @@ var _CPToolbarSeparatorItemView = nil,
switch (anItemIdentifier)
{
case CPToolbarSeparatorItemIdentifier: [item setView:[self _separatorItemView]];
[item setMinSize:CGSizeMake(2.0, 0.0)];
case CPToolbarSeparatorItemIdentifier: [item setMinSize:CGSizeMake(2.0, 0.0)];
[item setMaxSize:CGSizeMake(2.0, 100000.0)];
return item;
case CPToolbarSpaceItemIdentifier: [item setView:[self _spaceItemView]];
[item setMinSize:CGSizeMake(32.0, 32.0)];
case CPToolbarSpaceItemIdentifier: [item setMinSize:CGSizeMake(32.0, 32.0)];
[item setMaxSize:CGSizeMake(32.0, 32.0)];
return item;
case CPToolbarFlexibleSpaceItemIdentifier: [item setView:[self _spaceItemView]];
[item setMinSize:CGSizeMake(32.0, 32.0)];
case CPToolbarFlexibleSpaceItemIdentifier: [item setMinSize:CGSizeMake(32.0, 32.0)];
[item setMaxSize:CGSizeMake(10000.0, 32.0)];
return item;
+1 -1
View File
@@ -47,7 +47,7 @@
- (void)removeObjectFromChildNodesAtIndex:(CPInteger)anIndex
{
anObject._parentNode = nil;
[_childNodes objectAtIndex:anIndex]._parentNode = nil;
[_childNodes removeObjectAtIndex:anIndex];
}
+40 -6
View File
@@ -257,6 +257,7 @@ var CPWindowSaveImage = nil,
BOOL _hasShadow;
BOOL _isMovableByWindowBackground;
unsigned _shadowStyle;
BOOL _showsResizeIndicator;
BOOL _isDocumentEdited;
BOOL _isDocumentSaving;
@@ -421,6 +422,8 @@ CPTexturedBackgroundWindowMask
_defaultButtonEnabled = YES;
_keyViewLoopIsDirty = YES;
[self setShowsResizeIndicator:_styleMask & CPResizableWindowMask];
}
return self;
@@ -501,6 +504,7 @@ CPTexturedBackgroundWindowMask
[_windowView addSubview:_contentView];
[_windowView setTitle:_title];
[_windowView noteToolbarChanged];
[_windowView setShowsResizeIndicator:[self showsResizeIndicator]];
[self setFrame:[self frameRectForContentRect:contentRect]];
}
@@ -606,6 +610,30 @@ CPTexturedBackgroundWindowMask
*/
- (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate
{
var value = aFrame.origin.x,
delta = value - FLOOR(value);
if (delta)
aFrame.origin.x = value > 0.879 ? CEIL(value) : FLOOR(value);
value = aFrame.origin.y;
delta = value - FLOOR(value);
if (delta)
aFrame.origin.y = value > 0.879 ? CEIL(value) : FLOOR(value);
value = aFrame.size.width;
delta = value - FLOOR(value);
if (delta)
aFrame.size.width = value > 0.15 ? CEIL(value) : FLOOR(value);
value = aFrame.size.height;
delta = value - FLOOR(value);
if (delta)
aFrame.size.height = value > 0.15 ? CEIL(value) : FLOOR(value);
if (shouldAnimate)
{
var animation = [[_CPWindowFrameAnimation alloc] initWithWindow:self targetFrame:aFrame];
@@ -711,6 +739,9 @@ CPTexturedBackgroundWindowMask
*/
- (void)orderOut:(id)aSender
{
if ([self _sharesChromeWithPlatformWindow])
[_platformWindow orderOut:self];
if ([_delegate respondsToSelector:@selector(windowWillClose:)])
[_delegate windowWillClose:self];
@@ -722,9 +753,6 @@ CPTexturedBackgroundWindowMask
CPApp._keyWindow = nil;
}
if ([self _sharesChromeWithPlatformWindow])
[_platformWindow orderOut:self];
}
/*!
@@ -770,7 +798,7 @@ CPTexturedBackgroundWindowMask
*/
- (BOOL)showsResizeIndicator
{
return [_windowView showsResizeIndicator];
return _showsResizeIndicator;
}
/*!
@@ -778,8 +806,14 @@ CPTexturedBackgroundWindowMask
@param shouldShowResizeIndicator \c YES sets the window to show its resize indicator.
*/
- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
{
[_windowView setShowsResizeIndicator:shouldShowResizeIndicator];
{
shouldShowResizeIndicator = !!shouldShowResizeIndicator;
if (_showsResizeIndicator === shouldShowResizeIndicator)
return;
_showsResizeIndicator = shouldShowResizeIndicator;
[_windowView setShowsResizeIndicator:[self showsResizeIndicator]];
}
/*!
@@ -38,6 +38,11 @@ var _CPToolbarViewBackgroundColor = nil;
return _CPToolbarViewBackgroundColor;
}
- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
{
// We don't ever want to show the resize indicator.
}
- (void)tile
{
[super tile];
+4 -9
View File
@@ -81,8 +81,6 @@ var _CPWindowViewResizeIndicatorImage = nil;
_styleMask = aStyleMask;
_resizeIndicatorOffset = CGSizeMake(0.0, 0.0);
_toolbarOffset = CGSizeMake(0.0, 0.0);
[self setShowsResizeIndicator:!(_styleMask & CPBorderlessBridgeWindowMask) && (_styleMask & CPResizableWindowMask)];
}
return self;
@@ -213,13 +211,13 @@ var _CPWindowViewResizeIndicatorImage = nil;
[_resizeIndicator setImage:_CPWindowViewResizeIndicatorImage];
[_resizeIndicator setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[self addSubview:_resizeIndicator];
}
else
{
[_resizeIndicator removeFromSuperview];
_resizeIndicator = nil;
}
}
@@ -322,11 +320,8 @@ var _CPWindowViewResizeIndicatorImage = nil;
if (toolbarView)
{
[toolbarView removeFromSuperview];
[toolbarView setLabelColor:[self toolbarLabelColor]];
if ([self respondsToSelector:@selector(toolbarLabelShadowColor)])
[toolbarView setLabelShadowColor:[self toolbarLabelShadowColor]];
[toolbarView FIXME_setIsHUD:_styleMask & CPHUDBackgroundWindowMask];
[self addSubview:toolbarView];
}
+9 -1
View File
@@ -144,7 +144,7 @@
{
var theWindow = [self window];
if ([theWindow respondsToSelector:@selector(becomesKeyOnlyIfNeeded)] && [theWindow becomesKeyOnlyIfNeeded])
if ([theWindow respondsToSelector:@selector(becomesKeyOnlyIfNeeded)] && [theWindow becomesKeyOnlyIfNeeded])
[theWindow orderFront:aSender];
else
[theWindow makeKeyAndOrderFront:aSender];
@@ -173,6 +173,14 @@
if (_window === nil && [_cibOwner isKindOfClass:[CPDocument class]])
[self setWindow:[_cibOwner valueForKey:@"window"]];
if (!_window)
{
var reason = [CPString stringWithFormat:@"Window for %@ could not be loaded from Cib or no window specified. \
Override loadWindow to load the window manually.", self];
[CPException raise:CPInternalInconsistencyException reason:reason];
}
[self windowDidLoad];
[_document windowControllerDidLoadCib:self];
-1
View File
@@ -312,7 +312,6 @@ function CGContextDrawLinearGradient(aContext, aGradient, aStartPoint, anEndPoin
}
aContext.gState.gradient = vml.join("");
console.log(vml.join(""));
// if (aContext.buffer != nil)
// aContext.buffer += vml.join("");
+16
View File
@@ -53,4 +53,20 @@
#endif
}
+ (void)hideOtherApplications:(id)aSender
{
#if PLATFORM(DOM)
if (typeof window["cpHideOtherApplications"] === "function")
window.cpHideOtherApplications();
#endif
}
+ (void)hide:(id)aSender
{
#if PLATFORM(DOM)
if (typeof window["cpHide"] === "function")
window.cpHide();
#endif
}
@end
+107 -22
View File
@@ -19,6 +19,93 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* THIS DOCUMENTATION STOLEN DIRECTLY FROM GOOGLE CLOSURE (licensed under Apache 2)
*
* Different web browsers have very different keyboard event handling. Most
* importantly is that only certain browsers repeat keydown events:
* IE, Opera, FF/Win32, and Safari 3 repeat keydown events.
* FF/Mac and Safari 2 do not.
*
* For the purposes of this code, "Safari 3" means WebKit 525+, when WebKit
* decided that they should try to match IE's key handling behavior.
* Safari 3.0.4, which shipped with Leopard (WebKit 523), has the
* Safari 2 behavior.
*
* Firefox, Safari, Opera prevent on keypress
*
* IE prevents on keydown
*
* Firefox does not fire keypress for shift, ctrl, alt
* Firefox does fire keydown for shift, ctrl, alt, meta
* Firefox does not repeat keydown for shift, ctrl, alt, meta
*
* Firefox does not fire keypress for up and down in an input
*
* Opera fires keypress for shift, ctrl, alt, meta
* Opera does not repeat keypress for shift, ctrl, alt, meta
*
* Safari 2 and 3 do not fire keypress for shift, ctrl, alt
* Safari 2 does not fire keydown for shift, ctrl, alt
* Safari 3 *does* fire keydown for shift, ctrl, alt
*
* IE provides the keycode for keyup/down events and the charcode (in the
* keycode field) for keypress.
*
* Mozilla provides the keycode for keyup/down and the charcode for keypress
* unless it's a non text modifying key in which case the keycode is provided.
*
* Safari 3 provides the keycode and charcode for all events.
*
* Opera provides the keycode for keyup/down event and either the charcode or
* the keycode (in the keycode field) for keypress events.
*
* Firefox x11 doesn't fire keydown events if a another key is already held down
* until the first key is released. This can cause a key event to be fired with
* a keyCode for the first key and a charCode for the second key.
*
* Safari in keypress
*
* charCode keyCode which
* ENTER: 13 13 13
* F1: 63236 63236 63236
* F8: 63243 63243 63243
* ...
* p: 112 112 112
* P: 80 80 80
*
* Firefox, keypress:
*
* charCode keyCode which
* ENTER: 0 13 13
* F1: 0 112 0
* F8: 0 119 0
* ...
* p: 112 0 112
* P: 80 0 80
*
* Opera, Mac+Win32, keypress:
*
* charCode keyCode which
* ENTER: undefined 13 13
* F1: undefined 112 0
* F8: undefined 119 0
* ...
* p: undefined 112 112
* P: undefined 80 80
*
* IE7, keydown
*
* charCode keyCode which
* ENTER: undefined 13 undefined
* F1: undefined 112 undefined
* F8: undefined 119 undefined
* ...
* p: undefined 80 undefined
* P: undefined 80 undefined
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPRunLoop.j>
@@ -51,13 +138,6 @@ var DoubleClick = "dblclick",
TouchEnd = "touchend",
TouchCancel = "touchcancel";
var ExcludedDOMElements = [];
ExcludedDOMElements["INPUT"] = YES;
ExcludedDOMElements["SELECT"] = YES;
ExcludedDOMElements["TEXTAREA"] = YES;
ExcludedDOMElements["OPTION"] = YES;
// Define up here so compressor knows about em.
var CPDOMEventGetClickCount,
CPDOMEventStop,
@@ -68,7 +148,7 @@ var CPDOMEventGetClickCount,
//might be mac only, we should investigate futher later.
var KeyCodesToPrevent = {},
CharacterKeysToPrevent = {},
KeyCodesWithoutKeyPressEvents = { '8':1, '9':1, '16':1, '37':1, '38':1, '39':1, '40':1, '46':1, '33':1, '34':1 };
KeyCodesWithoutKeyPressEvents = { '8':1, '9':1, '16':1, '33':1, '34':1, '35':1, '36':1, '37':1, '38':1, '39':1, '40':1, '46':1, '33':1, '34':1 };
var CTRL_KEY_CODE = 17;
@@ -301,16 +381,16 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
[self updateFromNativeContentRect];
[self _removeLayers];
theDocument.removeEvent("onmouseup", mouseEventCallback);
theDocument.removeEvent("onmousedown", mouseEventCallback);
theDocument.removeEvent("onmousemove", mouseEventCallback);
theDocument.removeEvent("ondblclick", mouseEventCallback);
theDocument.detachEvent("onmouseup", mouseEventCallback);
theDocument.detachEvent("onmousedown", mouseEventCallback);
theDocument.detachEvent("onmousemove", mouseEventCallback);
theDocument.detachEvent("ondblclick", mouseEventCallback);
theDocument.removeEvent("onkeyup", keyEventCallback);
theDocument.removeEvent("onkeydown", keyEventCallback);
theDocument.removeEvent("onkeypress", keyEventCallback);
theDocument.detachEvent("onkeyup", keyEventCallback);
theDocument.detachEvent("onkeydown", keyEventCallback);
theDocument.detachEvent("onkeypress", keyEventCallback);
_DOMWindow.removeEvent("onresize", resizeEventCallback);
_DOMWindow.detachEvent("onresize", resizeEventCallback);
_DOMWindow.onmousewheel = NULL;
theDocument.onmousewheel = NULL;
@@ -388,7 +468,14 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
}
else if (type === "drag")
[dragServer draggingSourceUpdatedWithGlobalLocation:[CPPlatform isBrowser] ? location : _CGPointMake(aDOMEvent.screenX, aDOMEvent.screenY)];
{
var y = aDOMEvent.screenY;
if (CPFeatureIsCompatible(CPHTML5DragAndDropSourceYOffBy1))
y -= 1;
[dragServer draggingSourceUpdatedWithGlobalLocation:[CPPlatform isBrowser] ? location : _CGPointMake(aDOMEvent.screenX, y)];
}
else if (type === "dragover" || type === "dragleave")
{
@@ -452,8 +539,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
(aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
(aDOMEvent.metaKey ? CPCommandKeyMask : 0);
if (ExcludedDOMElements[sourceElement.tagName] && sourceElement != _DOMFocusElement && sourceElement != _DOMPasteboardElement)
return;
//We want to stop propagation if this is a command key AND this character or keycode has been added to our blacklist
StopDOMEventPropagation = !(modifierFlags & (CPControlKeyMask | CPCommandKeyMask)) ||
@@ -463,7 +548,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
var isNativePasteEvent = NO,
isNativeCopyOrCutEvent = NO,
overrideCharacters = nil;
switch (aDOMEvent.type)
{
case "keydown": // Grab and store the keycode now since it is correct and consistent at this point.
@@ -554,7 +639,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
event._DOMEvent = aDOMEvent;
[CPApp sendEvent:event];
if (isNativeCopyOrCutEvent)
{
var pasteboard = [CPPasteboard generalPasteboard],
@@ -809,7 +894,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
else if (type === "mousedown")
{
if (ExcludedDOMElements[sourceElement.tagName] && sourceElement != _DOMFocusElement)
if (sourceElement.tagName === "INPUT" && sourceElement != _DOMFocusElement)
{
if ([CPPlatform supportsDragAndDrop])
{
+1 -1
View File
@@ -48,7 +48,7 @@ task ("install", ["CommonJS"], function()
{
// FIXME: require("narwhal/tusk/install").install({}, $COMMONJS);
// Doesn't work due to some weird this.print business.
OS.system("tusk install --force " + $BUILD_CJS_OBJECTIVE_J + " " + $BUILD_CJS_CAPPUCCINO);
OS.system("sudo tusk install --force " + $BUILD_CJS_OBJECTIVE_J + " " + $BUILD_CJS_CAPPUCCINO);
});
// Documentation
+3 -5
View File
@@ -1,5 +1,4 @@
var FILE = require("file"),
readline = require("readline").readline;
var FILE = require("file");
var window = require("browser/window");
@@ -144,9 +143,8 @@ exports.run = function(args)
try {
system.stdout.write("objj> ").flush();
var input = readline(),
result = objj_eval(input);
var result = objj_eval(require("readline").readline());
if (result !== undefined)
print(result);
@@ -43,6 +43,7 @@ function compress(/*String*/ aCode, /*String*/ FIXME)
chunk = "";
compressor.stdin.write(tmpFile + "\n");
compressor.stdin.flush();
while ((chunk = compressor.stdout.readLine()) !== "/*----*/\n")
output += chunk;
@@ -55,15 +56,21 @@ function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags)
{
var shouldObjjPreprocess = objjcFlags & OBJJ_PREPROCESSOR_PREPROCESS,
shouldCheckSyntax = objjcFlags & OBJJ_PREPROCESSOR_SYNTAX,
shouldCompress = objjcFlags & OBJJ_PREPROCESSOR_COMPRESS;
shouldCompress = objjcFlags & OBJJ_PREPROCESSOR_COMPRESS,
fileContents = "";
// GCC preprocess the file.
var gcc = OS.popen("gcc -E -x c -P " + (gccFlags ? gccFlags.join(" ") : "") + " " + aFilePath),
fileContents = "",
chunk = "";
if (OS.popen("which gcc").stdout.read().length === 0)
fileContents = FILE.read(aFilePath, { charset:"UTF-8" });
while (chunk = gcc.stdout.read())
fileContents += chunk;
else
{
// GCC preprocess the file.
var gcc = OS.popen("gcc -E -x c -P " + (gccFlags ? gccFlags.join(" ") : "") + " " + OS.enquote(aFilePath)),
chunk = "";
while (chunk = gcc.stdout.read())
fileContents += chunk;
}
if (!shouldObjjPreprocess)
return fileContents;
@@ -56,13 +56,18 @@ ApplicationTask.prototype.defineFrameworksTask = function()
this.enhance([frameworks]);
}
ApplicationTask.prototype.buildIndexFilePath = function()
{
return FILE.join(this.buildProductPath(), FILE.basename(this.indexFilePath()));
}
ApplicationTask.prototype.defineIndexFileTask = function()
{
if (!this._indexFilePath)
return;
var indexFilePath = this.indexFilePath(),
buildIndexFilePath = FILE.join(this.buildProductPath(), FILE.basename(this.indexFilePath()));
buildIndexFilePath = this.buildIndexFilePath();
Jake.filedir (buildIndexFilePath, [indexFilePath], function()
{
@@ -383,6 +383,21 @@ BundleTask.prototype.defineInfoPlistTask = function()
require("objective-j/plist").writePlist(infoPlistProductPath, bundleTask.infoPlist());
});
var infoPlistPath = this.infoPlistPath();
if (infoPlistPath && FILE.exists(infoPlistPath))
filedir (infoPlistProductPath, [infoPlistPath]);
// FIXME: ? We do this because adding a .j file should cause Info.plist to be updated.
// Any better way to handle this? Perhaps this should happen unconditionally.
this.flattenedEnvironments().forEach(function(/*Environment*/ anEnvironment)
{
if (!anEnvironment.spritesImages())
return;
filedir (infoPlistProductPath, this.buildProductStaticPathForEnvironment(anEnvironment));
}, this);
this.enhance([infoPlistProductPath]);
}
@@ -494,7 +509,11 @@ function directoryInCommon(filenames)
{
var directory = FILE.dirname(aFilename);
if (!aCommonDirectory)
if (directory === ".")
directory = "";
// Empty string is an acceptable common directory.
if (aCommonDirectory === null)
aCommonDirectory = directory;
else
@@ -622,10 +641,10 @@ BundleTask.prototype.defineStaticTask = function()
}
}, this);
fileStream.write("e;", { charset:"UTF-8" });
fileStream.write("e;");
if (MHTMLContents.length > 0)
fileStream.write(MHTMLContents + "*/", { charset:"UTF-8" });
fileStream.write(MHTMLContents + "*/");
fileStream.close();
});
@@ -650,7 +669,8 @@ BundleTask.prototype.defineSourceTasks = function()
else if (compilerFlags.join)
compilerFlags = compilerFlags.join(" ");
var environments = this.flattenedEnvironments();
var environments = this.flattenedEnvironments(),
flattensSources = this.flattensSources();
environments.forEach(function(/*Environment*/ anEnvironment)
{
@@ -668,7 +688,9 @@ BundleTask.prototype.defineSourceTasks = function()
}
var replacedFiles = [],
environmentCompilerFlags = anEnvironment.compilerFlags().join(" ") + " " + compilerFlags;
environmentCompilerFlags = anEnvironment.compilerFlags().join(" ") + " " + compilerFlags,
flattensSources = this.flattensSources(),
basePathLength = directoryInCommon(environmentSources).length;
environmentSources.forEach(function(/*String*/ aFilename)
{
@@ -676,7 +698,8 @@ BundleTask.prototype.defineSourceTasks = function()
if (!FILE.exists(aFilename) || FILE.extension(aFilename) !== '.j')
return;
var compiledEnvironmentSource = FILE.join(sourcesPath, FILE.basename(aFilename));
var relativePath = aFilename.substring(basePathLength),
compiledEnvironmentSource = FILE.join(sourcesPath, relativePath);
filedir (compiledEnvironmentSource, [aFilename], function()
{
@@ -686,9 +709,7 @@ BundleTask.prototype.defineSourceTasks = function()
filedir (staticPath, [compiledEnvironmentSource]);
// FIXME: how do we non flatten?
// dir in common
replacedFiles.push(flattensSources ? FILE.basename(aFilename) : FILE.relative(sourcesPath, aFilename));
replacedFiles.push(flattensSources ? FILE.basename(aFilename) : relativePath);
}, this);
this._replacedFiles[anEnvironment] = replacedFiles;
+13 -11
View File
@@ -1,15 +1,17 @@
var file = require("file"),
objj = require("objective-j"),
CPPropertyListCreateData = objj.CPPropertyListCreateData,
kCFPropertyListXMLFormat_v1_0 = objj.kCFPropertyListXMLFormat_v1_0;
var FILE = require("file"),
OBJJ = require("objective-j"),
CPPropertyListCreateData = OBJJ.CPPropertyListCreateData,
kCFPropertyListXMLFormat_v1_0 = OBJJ.kCFPropertyListXMLFormat_v1_0;
exports.readPlist = function(path) {
var plistData = new objj.objj_data();
plistData.string = file.read(path);
return objj.CPPropertyListCreateFromData(plistData);
exports.readPlist = function(aPath)
{
var plistData = new OBJJ.objj_data();
plistData.string = FILE.read(aPath, { charset:"UTF-8" });
return OBJJ.CPPropertyListCreateFromData(plistData);
}
exports.writePlist = function(path, plist, format) {
format = format || objj.kCFPropertyListXMLFormat_v1_0;
file.write(path, objj.CPPropertyListCreateData(plist, format).string);
exports.writePlist = function(aPath, plist, format)
{
format = format || OBJJ.kCFPropertyListXMLFormat_v1_0;
FILE.write(aPath, OBJJ.CPPropertyListCreateData(plist, format).string, { charset:"UTF-8" });
}
+10 -22
View File
@@ -1,27 +1,15 @@
#!/bin/bash
#!/usr/bin/env narwhal
# get the absolute path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
var FILE = require("file");
# resolve symlinks
while [ -h "$SELF_PATH" ]; do
DIR=$(dirname -- "$SELF_PATH")
SYM=$(readlink -- "$SELF_PATH")
SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
done
var cappuccinoPackage = FILE.path(module.path).dirname().dirname();
var mainPath = cappuccinoPackage.join("lib", FILE.basename(module.path), "main.j");
var frameworksPath = cappuccinoPackage.join("Frameworks");
SELF_DIR=`dirname $SELF_PATH`
export SELF_HOME=`dirname $SELF_DIR`
SELF_LIB="$SELF_HOME/lib"
// TODO: is specifying the Frameworks necessary?
system.args.splice(1, 0, "-I"+frameworksPath, String(mainPath));
FRAMEWORKS="$SELF_HOME/Frameworks"
MAIN="$SELF_LIB/$(basename $SELF_PATH)/main.j"
// HACK: remove use of SELF_HOME from capp gen
system.env["SELF_HOME"] = cappuccinoPackage;
# convert paths for Cygwin
if [[ `uname` == CYGWIN* ]]; then
FRAMEWORKS=`cygpath -w "$FRAMEWORKS"`
MAIN=`cygpath -w "$MAIN"`
fi
objj -I$FRAMEWORKS $MAIN "$@"
require("objective-j").run(system.args);
+1 -1
View File
@@ -34,7 +34,7 @@ var userAgent = window.navigator.userAgent;
if (userAgent.indexOf("MSIE 7") !== -1)
OBJJ_ENVIRONMENTS.unshift("IE7");
if (userAgent.indexOf("MSIE 8") !== -1)
else if (userAgent.indexOf("MSIE 8") !== -1)
OBJJ_ENVIRONMENTS.unshift("IE8");
else
OBJJ_ENVIRONMENTS.unshift("W3C");
+3 -3
View File
@@ -161,12 +161,12 @@ function class_copyIvarList(/*Class*/ aClass)
#define METHOD_DISPLAY_NAME(aClass, aMethod) (ISMETA(aClass) ? '+' : '-') + " [" + class_getName(aClass) + ' ' + method_getName(aMethod) + ']'
function class_addMethod(/*Class*/ aClass, /*SEL*/ aName, /*IMP*/ anImplementation, /*String*/aType)
function class_addMethod(/*Class*/ aClass, /*SEL*/ aName, /*IMP*/ anImplementation, /*Array<String>*/ types)
{
if (aClass.method_hash[aName])
return NO;
var method = new objj_method(aName, anImplementation, aType);
var method = new objj_method(aName, anImplementation, types);
aClass.method_list.push(method);
aClass.method_dtable[aName] = method;
@@ -177,7 +177,7 @@ function class_addMethod(/*Class*/ aClass, /*SEL*/ aName, /*IMP*/ anImplementati
// FIXME: Should this be done here?
// If this is a root class...
if (!ISMETA(aClass) && GETMETA(aClass).isa === GETMETA(aClass))
class_addMethod(GETMETA(aClass), method);
class_addMethod(GETMETA(aClass), aName, anImplementation, types);
return YES;
}
+20 -10
View File
@@ -1,7 +1,7 @@
@import "Configuration.j"
var OS = require("OS"),
var OS = require("os"),
SYSTEM = require("system"),
FILE = require("file"),
OBJJ = require("objective-j");
@@ -73,7 +73,7 @@ function gen(/*va_args*/)
else if (!FILE.exists(destinationProject))
{
// FIXME???
OS.system("cp -vR " + sourceTemplate + " " + destinationProject);
FILE.copyTree(sourceTemplate, destinationProject);
var files = FILE.glob(FILE.join(destinationProject, "**", "*")),
index = 0,
@@ -92,18 +92,28 @@ function gen(/*va_args*/)
if (FILE.isDirectory(path))
continue;
// Don't do this for images.
if ([".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"].indexOf(FILE.extension(path)) !== -1)
if (FILE.basename(path) === ".DS_Store")
continue;
var contents = FILE.read(path, { charset : "UTF-8" }),
key = nil,
keyEnumerator = [configuration keyEnumerator];
// Don't do this for images.
if ([".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"].indexOf(FILE.extension(path).toLowerCase()) !== -1)
continue;
while (key = [keyEnumerator nextObject])
contents = contents.replace(new RegExp("__" + RegExp.escape(key) + "__", 'g'), [configuration valueForKey:key]);
try
{
var contents = FILE.read(path, { charset : "UTF-8" }),
key = nil,
keyEnumerator = [configuration keyEnumerator];
FILE.write(path, contents, { charset: "UTF-8"});
while (key = [keyEnumerator nextObject])
contents = contents.replace(new RegExp("__" + RegExp.escape(key) + "__", 'g'), [configuration valueForKey:key]);
FILE.write(path, contents, { charset: "UTF-8"});
}
catch (anException)
{
print("Copying and modifying " + path + " failed.");
}
}
var frameworkDestination = destinationProject;
@@ -20,7 +20,6 @@ blend ("__project.nameasidentifier__.blend", function(__project.nameasidentifier
__project.nameasidentifier__Task.setBuildPath(FILE.join("Build", configuration));
__project.nameasidentifier__Task.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
__project.nameasidentifier__Task.setPlatforms([BundleTask.Platform.Browser, BundleTask.Platform.CommonJS]);
__project.nameasidentifier__Task.setIdentifier("com.280n.__project.identifier__");
__project.nameasidentifier__Task.setResources(new FileList("Resources/*"));
});
+1 -1
View File
@@ -38,7 +38,7 @@
//FIXME push this check to CPPopUpButton?
_selectedIndex = [cell selectedIndex] || 0;
_pullsDown = [cell pullsDown];
[self setPullsDown:[cell pullsDown]];
_preferredEdge = [cell preferredEdge];
}
+3 -6
View File
@@ -35,12 +35,9 @@
_horizontalScroller = [aCoder decodeObjectForKey:"NSHScroller"];
_contentView = [aCoder decodeObjectForKey:"NSContentView"];
_hasVerticalScroller = !Boolean(flags & (1 << 4));
_hasHorizontalScroller = !Boolean(flags & (1 << 5));
_autohidesScrollers = Boolean(flags & (1 << 9));
[self setHasHorizontalScroller:!_hasHorizontalScroller];
[self setHasVerticalScroller:!_hasVerticalScroller];
_hasVerticalScroller = !!(flags & (1 << 4));
_hasHorizontalScroller = !!(flags & (1 << 5));
_autohidesScrollers = !!(flags & (1 << 9));
//[aCoder decodeBytesForKey:"NSScrollAmts"];
_verticalLineScroll = 10.0;
+26 -19
View File
@@ -15,6 +15,10 @@ function prompt () {
done
}
function which () {
echo "$PATH" | tr ":" "\n" | while read line; do [ -f "$line/$1" ] && return 0; done
}
function path_instructions () {
echo "Add \"$INSTALL_DIRECTORY/bin\" to your PATH environment variable in your shell configuration file (e.x. .profile, .bashrc, .bash_profile)."
echo "For example:"
@@ -26,20 +30,20 @@ INSTALL_DIRECTORY="/usr/local/narwhal"
ORIGINAL_PATH="$PATH"
if ! which -s "narwhal"; then
if ! which "narwhal"; then
echo "================================================================================"
echo "Narwhal JavaScript platform is required. Install it into \"$INSTALL_DIRECTORY\"?"
if prompt; then
echo "Downloading Narwhal..."
curl -L -o "$TEMPZIP" "http://github.com/tlrobinson/narwhal/zipball/master"
curl -L -o "$TEMPZIP" "http://github.com/280north/narwhal/zipball/master"
echo "Installing Narwhal..."
unzip "$TEMPZIP" -d "$INSTALL_DIRECTORY"
rm "$TEMPZIP"
mv $INSTALL_DIRECTORY/tlrobinson-narwhal-*/* $INSTALL_DIRECTORY/.
rm -rf $INSTALL_DIRECTORY/tlrobinson-narwhal-*
mv $INSTALL_DIRECTORY/280north-narwhal-*/* $INSTALL_DIRECTORY/.
rm -rf $INSTALL_DIRECTORY/280north-narwhal-*
if ! which -s "narwhal"; then
if ! which "narwhal"; then
export PATH="$INSTALL_DIRECTORY/bin:$PATH"
fi
else
@@ -48,7 +52,7 @@ if ! which -s "narwhal"; then
fi
fi
if ! which -s "narwhal"; then
if ! which "narwhal"; then
echo "Error: problem installing Narwhal"
exit 1
fi
@@ -66,28 +70,29 @@ if [ `uname` = "Darwin" ]; then
make webkit
popd
echo "================================================================================"
echo "Rhino is the default Narwhal engine, should we change the default to JavaScriptCore for you?"
echo "This can by overridden by setting the NARWHAL_ENGINE environment variable to \"jsc\" or \"rhino\"."
echo "(Note: you must use Rhino for certain tools such as \"tusk\")"
if prompt; then
tusk engine jsc
fi
# echo "================================================================================"
# echo "Rhino is the default Narwhal engine, should we change the default to JavaScriptCore for you?"
# echo "This can by overridden by setting the NARWHAL_ENGINE environment variable to \"jsc\" or \"rhino\"."
# echo "(Note: you must use Rhino for certain tools such as \"tusk\")"
# if prompt; then
# tusk engine jsc
# fi
fi
fi
export PATH="$ORIGINAL_PATH"
if ! which -s "narwhal"; then
if ! which "narwhal"; then
SHELL_CONFIG=""
if [ -f "$HOME/.profile" ]; then
SHELL_CONFIG="$HOME/.profile"
elif [ -f "$HOME/.bashrc" ]; then
SHELL_CONFIG="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
# use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
if [ -f "$HOME/.bash_profile" ]; then
SHELL_CONFIG="$HOME/.bash_profile"
elif [ -f "$HOME/.bash_login" ]; then
SHELL_CONFIG="$HOME/.bash_login"
elif [ -f "$HOME/.profile" ]; then
SHELL_CONFIG="$HOME/.profile"
elif [ -f "$HOME/.bashrc" ]; then
SHELL_CONFIG="$HOME/.bashrc"
fi
EXPORT_PATH_STRING="export PATH=\"$INSTALL_DIRECTORY/bin:\$PATH\""
@@ -108,3 +113,5 @@ if ! which -s "narwhal"; then
path_instructions
fi
fi
echo "Bootstrapping of Narwhal and other required tools is complete. You can now build Cappuccino."
+8 -1
View File
@@ -1,7 +1,14 @@
function ensurePackageUpToDate(packageName, requiredVersion)
{
var version = require("packages").catalog[packageName].version;
var packageInfo = require("packages").catalog[packageName];
if (!packageInfo)
{
print("You are missing package \"" + packageName + "\", version " + requiredVersion + " or later. Please install using \"tusk install "+packageName+"\" and re-run jake");
require("os").exit(1);
}
var version = packageInfo.version;
if (version && require("util").compare(version.split("."), requiredVersion.split(".")) !== -1)
return;
+3
View File
@@ -0,0 +1,3 @@
if [ -z "$NARWHAL_ENGINE" ] && [ -d "$NARWHAL_HOME/packages/narwhal-jsc" ]; then
export NARWHAL_ENGINE=jsc
fi