Merge branch 'master' into atrstring

This commit is contained in:
Ross Boucher committed 2008-11-11 13:40:01 -08:00
commit 75bedef465
9 files changed
+231 -83

No files matched your search

+6
View File
@@ -14,6 +14,9 @@
<string>CPOutlineView.j</string>
<string>CPTableColumn.j</string>
<string>CPTableView.j</string>
<!-- These get compiled into CGContext -->
<string>CoreGraphics/CGContextCanvas.j</string>
<string>CoreGraphics/CGContextVML.j</string>
</array>
<key>Flags</key>
<string>-DPLATFORM_DOM</string>
@@ -26,6 +29,9 @@
<string>CPOutlineView.j</string>
<string>CPTableColumn.j</string>
<string>CPTableView.j</string>
<!-- These get compiled into CGContext -->
<string>CoreGraphics/CGContextCanvas.j</string>
<string>CoreGraphics/CGContextVML.j</string>
</array>
</dict>
</array>
+3 -1
View File
@@ -238,4 +238,6 @@ var CPAlertWarningImage,
[CPApp abortModal];
[_alertPanel close];
}
}
@end
+134 -73
View File
@@ -2,6 +2,9 @@
* CPToolbar.j
* AppKit
*
* Portions based on NSToolbar.m (11/10/2008) in Cocotron (http://www.cocotron.org/)
* Copyright (c) 2006-2007 Christopher J. W. Lloyd
*
* Created by Francisco Tolmasky.
* Copyright 2008, 280 North, Inc.
*
@@ -83,18 +86,18 @@ var CPToolbarConfigurationsByIdentifier = nil;
BOOL _showsBaselineSeparator;
BOOL _allowsUserCustomization;
BOOL _isVisible;
BOOL _needsReloadOfItems;
id _delegate;
CPView _toolbarView;
CPArray _itemIdentifiers;
CPArray _allowedItemIdentifiers;
CPDictionary _identifiedItems;
CPArray _defaultItems;
CPArray _allowedItems;
CPArray _selectableItems;
CPArray _items;
CPArray _labels;
CPArray _itemsSortedByVisibilityPriority;
CPMutableDictionary _itemIndexes;
CPView _toolbarView;
}
/* @ignore */
@@ -107,6 +110,20 @@ var CPToolbarConfigurationsByIdentifier = nil;
CPToolbarConfigurationsByIdentifier = [CPDictionary dictionary];
}
/* @ignore */
+ (void)_addToolbar:(CPToolbar)toolbar forIdentifier:(CPString)identifier
{
var toolbarsSharingIdentifier = [CPToolbarsByIdentifier objectForKey:identifier];
if (!toolbarsSharingIdentifier)
{
toolbarsSharingIdentifier = []
[CPToolbarsByIdentifier setObject:toolbarsSharingIdentifier forKey:identifier];
}
[toolbarsSharingIdentifier addObject:toolbar];
}
/*!
Initializes the toolbar with the specified identifier.
@param anIdentifier the identifier for the toolbar
@@ -119,25 +136,17 @@ var CPToolbarConfigurationsByIdentifier = nil;
if (self)
{
_items = [];
_labels = [];
_identifier = anIdentifier;
_isVisible = YES;
var toolbarsSharingIdentifier = [CPToolbarsByIdentifier objectForKey:_identifier];
if (!toolbarsSharingIdentifier)
{
toolbarsSharingIdentifier = []
[CPToolbarsByIdentifier setObject:toolbarsSharingIdentifier forKey:_identifier];
}
[toolbarsSharingIdentifier addObject:self];
[CPToolbar _addToolbar:self forIdentifier:_identifier];
}
return self;
}
/*!
Sets the toolbar's display mode. NOT YET IMPLEMENTED.
*/
@@ -196,10 +205,6 @@ var CPToolbarConfigurationsByIdentifier = nil;
_delegate = aDelegate;
// When _delegate is nil, this will be cleared out.
_itemIdentifiers = nil;
_allowedItemIdentifiers = [_delegate toolbarAllowedItemIdentifiers:self];
[self _reloadToolbarItems];
}
@@ -229,36 +234,9 @@ var CPToolbarConfigurationsByIdentifier = nil;
if (![_toolbarView superview] || !_delegate)
return;
var count = [_itemIdentifiers count];
if (!count)
{
_itemIdentifiers = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy];
count = [_itemIdentifiers count];
}
[[_toolbarView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
_items = [];
_labels = [];
var index = 0;
for (; index < count; ++index)
{
var identifier = _itemIdentifiers[index],
item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
if (!item)
item = [[_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES] copy];
if (item == nil)
[CPException raise:CPInvalidArgumentException
reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)];
[_items addObject:item];
}
_items = [[self _defaultToolbarItems] mutableCopy];
// Store items sorted by priority. We want items to be removed first at the end of the array,
// items to be removed last at the front.
@@ -284,20 +262,6 @@ var CPToolbarConfigurationsByIdentifier = nil;
return [_toolbarView visibleItems];
}
/*!
Returns the index of the specified toolbar item
@param anItem the item to obtain the index for
*/
- (int)indexOfItem:(CPToolbarItem)anItem
{
var info = [_itemIndexes objectForKey:[anItem hash]];
if (!info)
return CPNotFound;
return info.index;
}
/*!
Returns the toolbar items sorted by their <code>visibilityPriority</code>(ies).
*/
@@ -306,6 +270,113 @@ var CPToolbarConfigurationsByIdentifier = nil;
return _itemsSortedByVisibilityPriority;
}
/* @ignore */
- (id)_itemForItemIdentifier:(CPString)identifier willBeInsertedIntoToolbar:(BOOL)toolbar
{
var item = [_identifiedItems objectForKey:identifier];
if (!item)
{
item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
if (_delegate && !item)
{
item = [_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:toolbar];
if (!item)
[CPException raise:CPInvalidArgumentException
reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)];
}
[_identifiedItems setObject:item forKey:identifier];
}
return item;
}
/* @ignore */
- (id)_itemsWithIdentifiers:(CPArray)identifiers
{
var items = [];
for (var i = 0; i < identifiers.length; i++)
[items addObject:[self _itemForItemIdentifier:identifiers[i] willBeInsertedIntoToolbar:NO]];
return items;
}
/* @ignore */
-(id)_defaultToolbarItems
{
if (!_defaultItems)
if ([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
_defaultItems = [self _itemsWithIdentifiers:[_delegate toolbarDefaultItemIdentifiers:self]];
return _defaultItems;
}
@end
var CPToolbarIdentifierKey = "CPToolbarIdentifierKey",
CPToolbarDisplayModeKey = "CPToolbarDisplayModeKey",
CPToolbarShowsBaselineSeparatorKey = "CPToolbarShowsBaselineSeparatorKey",
CPToolbarAllowsUserCustomizationKey = "CPToolbarAllowsUserCustomizationKey",
CPToolbarIsVisibleKey = "CPToolbarIsVisibleKey",
CPToolbarDelegateKey = "CPToolbarDelegateKey",
CPToolbarIdentifiedItemsKey = "CPToolbarIdentifiedItemsKey",
CPToolbarDefaultItemsKey = "CPToolbarDefaultItemsKey",
CPToolbarAllowedItemsKey = "CPToolbarAllowedItemsKey",
CPToolbarSelectableItemsKey = "CPToolbarSelectableItemsKey";
@implementation CPToolbar (CPCoding)
/*
Initializes the toolbar by unarchiving data from <code>aCoder</code>.
@param aCoder the coder containing the archived <objj>CPToolbar</objj>.
*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey];
_displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey];
_showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
_allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
_isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
_identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
_defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
_allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey];
_selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey];
_items = [];
[CPToolbar _addToolbar:self forIdentifier:_identifier];
[self setDelegate:[aCoder decodeObjectForKey:CPToolbarDelegateKey]];
}
return self;
}
/*
Archives this toolbar into the provided coder.
@param aCoder the coder to which the toolbar's instance data will be written.
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey];
[aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey];
[aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
[aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey];
[aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
[aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
[aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
[aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey];
[aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey];
[aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey];
}
@end
@@ -330,7 +401,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
CPIndexSet _flexibleWidthIndexes;
CPIndexSet _visibleFlexibleWidthIndexes;
CPMutableDictionary _itemInfos;
CPDictionary _itemInfos;
CPArray _visibleItems;
CPArray _invisibleItems;
@@ -580,16 +651,6 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
}
- (int)indexOfItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem hash]];
if (!info)
return CPNotFound;
return info.index;
}
- (CPView)viewForItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem hash]];
+10 -4
View File
@@ -5,7 +5,8 @@
var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
_CPCibWindowTemplateMaxSizeKey = @"_CPCibWindowTemplateMaxSizeKey",
_CPCibWindowTemplateViewClassKey = @"_CPCibWindowTemplateWindowClassKey",
_CPCibWindowTemplateViewClassKey = @"_CPCibWindowTemplateViewClassKey",
_CPCibWindowTemplateWindowClassKey = @"_CPCibWindowTemplateWindowClassKey",
_CPCibWindowTemplateWindowRectKey = @"_CPCibWindowTemplateWindowRectKey",
_CPCibWindowTemplateWindowStyleMaskKey = @"_CPCibWindowTempatStyleMaskKey",
@@ -18,7 +19,7 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
CGSize _maxSize;
//CGSize _screenRect;
CPString _viewClass;
id _viewClass;
//unsigned _wtFlags;
CPString _windowClass;
CGRect _windowRect;
@@ -39,7 +40,7 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
_viewClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateViewClassKey];
_windowClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateViewClassKey];
_windowClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateWindowClassKey];
_windowRect = [aCoder decodeRectForKey:_CPCibWindowTemplateWindowRectKey];
_windowStyleMask = [aCoder decodeIntForKey:_CPCibWindowTemplateWindowStyleMaskKey];
@@ -57,7 +58,7 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
[aCoder encodeObject:_viewClass forKey:_CPCibWindowTemplateViewClassKey];
[aCoder encodeObject:_windowClass forKey:_CPCibWindowTemplateViewClassKey];
[aCoder encodeObject:_windowClass forKey:_CPCibWindowTemplateWindowClassKey];
[aCoder encodeRect:_windowRect forKey:_CPCibWindowTemplateWindowRectKey];
[aCoder encodeInt:_windowStyleMask forKey:_CPCibWindowTemplateWindowStyleMaskKey];
@@ -91,6 +92,11 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
[_windowView setAutoresizesSubviews:YES];
if ([_viewClass isKindOfClass:[CPToolbar class]])
{
[theWindow setToolbar:_viewClass];
}
return theWindow;
}
+7 -2
View File
@@ -208,14 +208,14 @@ if (!CPFeatureIsCompatible(CPHTMLCanvasFeature))
function CGGStateCreate()
{
return { strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0,
return { alpha:1.0, strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0,
blendMode:kCGBlendModeNormal,
shadowOffset:_CGSizeMakeZero(), shadowBlur:0.0, shadowColor:NULL, CTM:_CGAffineTransformMakeIdentity() };
}
function CGGStateCreateCopy(aGState)
{
return { strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth,
return { alpha:aGState.alpha, strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth,
lineJoin:aGState.lineJoin, lineCap:aGState.lineCap, miterLimit:aGState.miterLimit, globalAlpha:aGState.globalAlpha,
blendMode:aGState.blendMode,
shadowOffset:aGState.shadowOffset, shadowBlur:aGState.shadowBlur, shadowColor:aGState.shadowColor, CTM:_CGAffineTransformMakeCopy(aGState.CTM) };
@@ -418,6 +418,11 @@ function CGContextSetShadowWithColor(aContext, aSize, aBlur, aColor)
gState.shadowColor = aColor;
}
function CGContextSetAlpha(aContext, anAlpha)
{
aContext.gState.alpha = MAX(MIN(anAlpha, 1.0), 0.0);
}
} // END CANVAS IF
// GOOD.
+2 -1
View File
@@ -111,7 +111,7 @@ function CGContextDrawPath(aContext, aMode)
{
if (!aContext || CGPathIsEmpty(aContext.path))
return;
var opacity = 1.0;
var elements = aContext.path.elements,
i = 0,
@@ -120,6 +120,7 @@ var opacity = 1.0;
gState = aContext.gState,
fill = (aMode == kCGPathFill || aMode == kCGPathFillStroke) ? 1 : 0,
stroke = (aMode == kCGPathStroke || aMode == kCGPathFillStroke) ? 1 : 0,
opacity = gState.alpha,
vml = [ "<cg_vml_:shape",
" fillcolor=\"", gState.fillStyle,
"\" filled=\"", VML_TRUTH_TABLE[fill],
+3 -2
View File
@@ -222,14 +222,15 @@ var CPURLConnectionDelegate = nil;
{
if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete)
{
var statusCode = _XMLHTTPRequest.status;
var statusCode = _XMLHTTPRequest.status,
url = [_request URL];
if ([_delegate respondsToSelector:@selector(connection:didReceiveResponse:)])
[_delegate connection:self didReceiveResponse:[[CPHTTPURLResponse alloc] _initWithStatusCode:statusCode]];
if (!_isCanceled)
{
if (statusCode == 200)
if (statusCode == 200 || (url.indexOf("file:") === 0 && statusCode === 0) || ((url.indexOf("http:") !== 0 || url.indexOf("https:") !== 0) && window.location && window.location.protocol === "file:" && statusCode === 0))
{
[_delegate connection:self didReceiveData:_XMLHTTPRequest.responseText];
[_delegate connectionDidFinishLoading:self];
+1
View File
@@ -34,6 +34,7 @@
@import "NSSlider.j"
@import "NSSplitView.j"
@import "NSTextField.j"
@import "NSToolbar.j"
@import "NSView.j"
@import "NSWindowTemplate.j"
@import "WebView.j"
+65
View File
@@ -0,0 +1,65 @@
/*
* NSToolbar.j
* nib2cib
*
* Created by Thomas Robinson.
* Copyright 2008, 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 <AppKit/CPToolbar.j>
@implementation CPToolbar (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
{
if (self)
{
_identifier = [aCoder decodeObjectForKey:"NSToolbarIdentifier"];
_displayMode = [aCoder decodeIntForKey:"NSToolbarDisplayMode"];
_showsBaselineSeparator = [aCoder decodeBoolForKey:"NSToolbarShowsBaselineSeparator"];
_allowsUserCustomization = [aCoder decodeBoolForKey:"NSToolbarAllowsUserCustomization"];
_isVisible = [aCoder decodeBoolForKey:"NSToolbarPrefersToBeShown"];
_identifiedItems = [aCoder decodeObjectForKey:"NSToolbarIBIdentifiedItems"];
_defaultItems = [aCoder decodeObjectForKey:"NSToolbarIBDefaultItems"];
_allowedItems = [aCoder decodeObjectForKey:"NSToolbarIBAllowedItems"];
_selectableItems = [aCoder decodeObjectForKey:"NSToolbarIBSelectableItems"];
_delegate = [aCoder decodeObjectForKey:"NSToolbarDelegate"];
}
return self;
}
@end
@implementation NSToolbar : CPToolbar
{
}
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
}
- (Class)classForKeyedArchiver
{
return [CPToolbar class];
}
@end