Merge branch 'master' of github.com:cappuccino/cappuccino

This commit is contained in:
Alexander Ljungberg committed 2013-01-19 02:27:55 +00:00
commit 8eae427591
187 files changed
+11343 -7217

No files matched your search

+1 -1
View File
@@ -227,7 +227,7 @@ var secondItem = [[CPAccordionViewItem alloc] initWithIdentifier:@"secondSection
{
var indexSet = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, _items.length)];
[indexSet removeIndexes:_expandedIndexes];
[indexSet removeIndexes:_expandedItemIndexes];
return indexSet;
}
+3
View File
@@ -37,6 +37,9 @@
@import "CPPanel.j"
@import "CPTextField.j"
@class CPCheckBox
/*
@global
@group CPAlertStyle
+4 -1
View File
@@ -33,6 +33,9 @@
@import "CPCibLoading.j"
@import "CPPlatform.j"
@class CPCursor
@class CPColorPanel
var CPMainCibFile = @"CPMainCibFile",
CPMainCibFileHumanFriendly = @"Main cib file base name",
@@ -407,7 +410,7 @@ CPRunContinuesResponse = -1002;
}
- (void)_documentController:(NSDocumentController *)docController didCloseAll:(BOOL)didCloseAll context:(Object)info
- (void)_documentController:(CPDocumentController)docController didCloseAll:(BOOL)didCloseAll context:(Object)info
{
// callback method for terminate:
if (didCloseAll)
+3 -2
View File
@@ -964,7 +964,7 @@
// be the 'wrong' one - as in not the one the user selected - but the wrong
// one is still just another pointer to the same object, so the user will not
// be able to see any difference.
contentIndex = [_contentObject indexOfObjectIdenticalTo:object];
var contentIndex = [_contentObject indexOfObjectIdenticalTo:object];
[_contentObject removeObjectAtIndex:contentIndex];
}
[arrangedObjects removeObjectAtIndex:anIndex];
@@ -1093,7 +1093,8 @@
isCompound = [self handlesContentAsCompoundValue],
dotIndex = keyPath.lastIndexOf("."),
firstPart = dotIndex !== CPNotFound ? keyPath.substring(0, dotIndex) : nil,
isSelectionProxy = firstPart && [[destination valueForKeyPath:firstPart] isKindOfClass:CPControllerSelectionProxy];
isSelectionProxy = firstPart && [[destination valueForKeyPath:firstPart] isKindOfClass:CPControllerSelectionProxy],
newValue;
if (!isCompound && !isSelectionProxy)
{
+7 -6
View File
@@ -492,16 +492,17 @@ CPBelowBottom = 6;
- (void)_drawLineBorderInRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
sides = [CPMinYEdge, CPMaxXEdge, CPMaxYEdge, CPMinXEdge],
sideGray = 190.0 / 255.0,
grays = [142.0 / 255.0, sideGray, sideGray, sideGray],
cornerRadius = [self cornerRadius],
borderWidth = [self borderWidth];
while (borderWidth--)
aRect = CPDrawTiledRects(aRect, aRect, sides, grays);
aRect = CGRectInset(aRect, borderWidth / 2.0, borderWidth / 2.0);
CGContextSetFillColor(context, [self fillColor]);
CGContextFillRect(context, aRect);
CGContextSetStrokeColor(context, [self borderColor]);
CGContextSetLineWidth(context, borderWidth);
CGContextFillRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES);
CGContextStrokeRoundedRectangleInRect(context, aRect, cornerRadius, YES, YES, YES, YES);
}
- (void)_drawBezelBorderInRect:(CGRect)aRect
+4 -2
View File
@@ -26,6 +26,8 @@
@import "CPControl.j"
@import "CPStringDrawing.j"
@global CPWindowAbove
@global CPWindowBelow
/* @group CPBezelStyle */
@@ -989,5 +991,5 @@ var CPButtonImageKey = @"CPButtonImageKey",
@end
@import "CPCheckBox.j"
@import "CPRadio.j"
//@import "CPCheckBox.j"
//@import "CPRadio.j"
+4
View File
@@ -1,6 +1,10 @@
@import "CPView.j"
@class CPSplitView
@global CPPopUpButtonStatePullsDown
@implementation CPButtonBar : CPView
{
+1
View File
@@ -22,6 +22,7 @@
@import "CPView.j"
@class CPScrollView
/*!
@ingroup appkit
+1
View File
@@ -21,6 +21,7 @@
*/
@import <Foundation/CPObject.j>
@import "CPGraphicsContext.j"
@import "CGColor.j"
+2
View File
@@ -26,6 +26,8 @@
@import "CPPanel.j"
@import "CPView.j"
@class CPSlider
CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification";
+6
View File
@@ -24,6 +24,12 @@
@import "CPView.j"
@class CPSlider
@global CPColorPickerViewWidth
@global CPColorPickerViewHeight
@global CPWheelColorPickerMode
/*!
@ingroup appkit
+1 -1
View File
@@ -83,7 +83,7 @@ var CPComboBoxTextSubview = @"text",
- (void)_initComboBox
{
_items = [CPArray array];
_listClass = [_CPPopUpList class];
// _listClass = [_CPPopUpList class];
_usesDataSource = NO;
_completes = NO;
_canComplete = NO;
+4 -1
View File
@@ -22,12 +22,15 @@
#import "../Foundation/Ref.h"
@import "../Foundation/CPFormatter.j"
@import <Foundation/CPFormatter.j>
@import <Foundation/CPTimer.j>
@import "CPFont.j"
@import "CPShadow.j"
@import "CPView.j"
@import "CPKeyValueBinding.j"
@global CPApp
CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
+1 -1
View File
@@ -64,7 +64,7 @@ var CPControllerDeclaredKeysKey = @"CPControllerDeclaredKeysKey";
count = _editors.length;
for (; index < count; ++index)
if (![[_editors objectAtIndex:i] commitEditing])
if (![[_editors objectAtIndex:index] commitEditing])
return NO;
return YES;
+1 -1
View File
@@ -77,7 +77,7 @@ var currentCursor = nil,
*/
- (id)initWithImage:(CPImage)image foregroundColorHint:(CPColor)foregroundColor backgroundColorHint:(CPColor)backgroundColor hotSpot:(CGPoint)aHotSpot
{
return [self initWithImage:image hotSpot:hotSpot];
return [self initWithImage:image hotSpot:aHotSpot];
}
+ (void)hide
+8 -2
View File
@@ -29,6 +29,12 @@
@import "CPViewController.j"
@import "CPWindowController.j"
@class CPDocumentController
@class CPAlert
@global CPApp
@global CPWarningAlertStyle
/*
@global
@@ -142,7 +148,7 @@ var CPDocumentUntitledCount = 0;
@param anError not used
@return the initialized document
*/
- (id)initWithType:(CPString)aType error:({CPError})anError
- (id)initWithType:(CPString)aType error:(/*{*/CPError/*}*/)anError
{
self = [self init];
@@ -211,7 +217,7 @@ var CPDocumentUntitledCount = 0;
@throws CPUnsupportedMethodException if this method hasn't been overridden by the subclass
@return the document data
*/
- (CPData)dataOfType:(CPString)aType error:({CPError})anError
- (CPData)dataOfType:(CPString)aType error:(/*{*/CPError/*}*/)anError
{
[CPException raise:CPUnsupportedMethodException
reason:"dataOfType:error: must be overridden by the document subclass."];
+4 -1
View File
@@ -25,6 +25,9 @@
@import "CPDocument.j"
@import "CPOpenPanel.j"
@import "CPMenuItem.j"
@global CPApp
var CPSharedDocumentController = nil;
@@ -124,7 +127,7 @@ var CPSharedDocumentController = nil;
@param anError not used
@return the created document
*/
- (CPDocument)makeUntitledDocumentOfType:(CPString)aType error:({CPError})anError
- (CPDocument)makeUntitledDocumentOfType:(CPString)aType error:(/*{*/CPError/*}*/)anError
{
return [[[self documentClassForType:aType] alloc] initWithType:aType error:anError];
}
+2
View File
@@ -27,6 +27,8 @@
@import "CPView.j"
@import "CPWindow.j"
@class _CPDOMDataTransferPasteboard
CPDragOperationNone = 0;
CPDragOperationCopy = 1 << 1;
+7
View File
@@ -21,8 +21,14 @@
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPGeometry.j>
@import "CPText.j"
@class CPTextField
@global CPApp
@global CPBrowserIsOperatingSystem
@global CPMacOperatingSystem
CPLeftMouseDown = 1;
CPLeftMouseUp = 2;
@@ -206,6 +212,7 @@ var _CPEventPeriodicEventPeriod = 0,
DOMEvent _DOMEvent;
int _data1;
int _data2;
short _subtype;
float _deltaX;
float _deltaY;
+2 -7
View File
@@ -54,7 +54,7 @@ var CPSharedFontManager = nil,
id _delegate @accessors(property=delegate);
CPFont _selectedFont;
BOOL _multiple @accessors;
BOOL _multiple @accessors(getter=isMultiple, setter=setMultiple:);
CPDictionary _activeChange;
}
@@ -139,7 +139,7 @@ var CPSharedFontManager = nil,
- (void)setSelectedFont:(CPFont)aFont isMultiple:(BOOL)aFlag
{
_selectedFont = aFont;
_isMultiple = aFlag;
_multiple = aFlag;
// TODO Notify CPFontPanel when it exists.
}
@@ -149,11 +149,6 @@ var CPSharedFontManager = nil,
return _selectedFont;
}
- (BOOL)isMultiple
{
return _isMultiple;
}
- (int)weightOfFont:(CPFont)aFont
{
// TODO Weight 5 is a normal of book weight and 9 and above is bold, but it would be nice to be more
+1
View File
@@ -26,6 +26,7 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPRunLoop.j>
@import <Foundation/CPString.j>
@import <Foundation/CPData.j>
CPImageLoadStatusInitialized = 0;
+3
View File
@@ -26,6 +26,9 @@
@import "CPImage.j"
@import "CPShadowView.j"
@global CPImagesPboardType
@global appkit_tag_dom_elements
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
CPImageAlignTopLeft = 2;
+1
View File
@@ -27,6 +27,7 @@
@import <Foundation/CPArray.j>
@import <Foundation/CPDictionary.j>
@import <Foundation/CPValueTransformer.j>
@import <Foundation/CPKeyValueObserving.j>
var exposedBindingsMap = [CPDictionary new],
+2
View File
@@ -31,6 +31,8 @@
@import "CPMenuItem.j"
@import "CPPanel.j"
@global CPApp
CPMenuDidAddItemNotification = @"CPMenuDidAddItemNotification";
CPMenuDidChangeItemNotification = @"CPMenuDidChangeItemNotification";
+4
View File
@@ -1,6 +1,10 @@
@import "CPPanel.j"
@import "_CPMenuWindow.j"
@global CPMenuDidAddItemNotification
@global CPMenuDidChangeItemNotification
@global CPMenuDidRemoveItemNotification
@implementation _CPMenuBarWindow : CPPanel
{
CPMenu _menu;
+24 -13
View File
@@ -1,5 +1,14 @@
@import <Foundation/CPObject.j>
@import <Foundation/Foundation.j>
@import "CPWindow.j"
@import "CPEvent.j"
@class _CPMenuWindow
@global CPApp
@global CPMenuDidEndTrackingNotification
@global _CPMenuWindowMenuBarBackgroundStyle
@global _CPMenuWindowPopUpBackgroundStyle
_CPMenuManagerScrollingStateUp = -1;
_CPMenuManagerScrollingStateDown = 1;
@@ -26,6 +35,8 @@ var STICKY_TIME_INTERVAL = 0.5,
CPMenuItem _previousActiveItem;
int _showTimerID;
int _menuBarButtonItemIndex;
}
+ (_CPMenuManager)sharedMenuManager
@@ -85,7 +96,7 @@ var STICKY_TIME_INTERVAL = 0.5,
activeItem = activeItemIndex !== CPNotFound ? [menu itemAtIndex:activeItemIndex] : nil;
_menuBarButtonItemIndex = activeItemIndex;
_menuBarButtonMenuContainer = aMenuContainer;
// _menuBarButtonMenuContainer = aMenuContainer;
if ([activeItem _isMenuBarButton])
return [self trackMenuBarButtonEvent:anEvent];
@@ -125,15 +136,6 @@ var STICKY_TIME_INTERVAL = 0.5,
return;
}
if (_keyBuffer)
{
if (([anEvent timestamp] - _startTime) > (STICKY_TIME_INTERVAL + [activeMenu numberOfItems] / 2))
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu clearBuffer:YES];
if (type === CPPeriodic)
return;
}
// Periodic events don't have a valid location.
var globalLocation = type === CPPeriodic ? _lastGlobalLocation : [anEvent globalLocation];
@@ -149,6 +151,15 @@ var STICKY_TIME_INTERVAL = 0.5,
activeItemIndex = activeMenuContainer ? [activeMenuContainer itemIndexAtPoint:menuLocation] : CPNotFound,
activeItem = activeItemIndex !== CPNotFound ? [activeMenu itemAtIndex:activeItemIndex] : nil;
if (_keyBuffer)
{
if (([anEvent timestamp] - _startTime) > (STICKY_TIME_INTERVAL + [activeMenu numberOfItems] / 2))
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu clearBuffer:YES];
if (type === CPPeriodic)
return;
}
// unhighlight when mouse is moved off the menu
if (_lastGlobalLocation && CGRectContainsPoint([activeMenuContainer globalFrame], _lastGlobalLocation)
&& !CGRectContainsPoint([activeMenuContainer globalFrame], globalLocation))
@@ -556,7 +567,7 @@ var STICKY_TIME_INTERVAL = 0.5,
return;
}
next = current + (last - first);
var next = current + (last - first);
if (next < [menu numberOfItems])
[menu _highlightItemAtIndex:next];
@@ -584,7 +595,7 @@ var STICKY_TIME_INTERVAL = 0.5,
return;
}
next = current - (last - first);
var next = current - (last - first);
if (next < 0)
[menu _highlightItemAtIndex:0];
+2
View File
@@ -29,6 +29,8 @@
@import "CPView.j"
@import "_CPMenuItemView.j"
@global CPApp
var CPMenuItemStringRepresentationDictionary = [CPDictionary dictionary];
[CPMenuItemStringRepresentationDictionary setObject:"\u238B" forKey:CPEscapeFunctionKey];
@@ -1,5 +1,8 @@
@import "CPView.j"
@class _CPMenuBarWindow
@class _CPMenuView
@implementation _CPMenuItemMenuBarView : CPView
{
CPMenuItem _menuItem @accessors(property=menuItem);
+2 -1
View File
@@ -1,10 +1,11 @@
@import <AppKit/CPControl.j>
@import "CPControl.j"
@import "_CPMenuItemSeparatorView.j"
@import "_CPMenuItemStandardView.j"
@import "_CPMenuItemMenuBarView.j"
@global CPApp
// var LEFT_MARGIN = 3.0,
// RIGHT_MARGIN = 16.0,
+1 -1
View File
@@ -798,7 +798,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
[_observationProxies removeObjectAtIndex:index];
_observedObjects = nil;
_observedObjectsByKeyPath[aKeyPath] = nil;
}
@end
+1 -1
View File
@@ -117,7 +117,7 @@ var CPPasteboards = nil,
if (self)
{
_name = aName;
// _name = aName;
_types = [];
_owners = [CPDictionary dictionary];
+1
View File
@@ -22,6 +22,7 @@
@import <Foundation/CPObject.j>
@class CPKeyBinding
CPDeleteKeyCode = 8;
CPTabKeyCode = 9;
+1 -1
View File
@@ -220,7 +220,7 @@
var children = [CPArray array],
itemsCount = 0,
menuIndex = -1,
itemsArray,
itemArray,
templateView = [templateViews objectAtIndex:count],
isPopup = [templateView isKindOfClass:[CPPopUpButton class]];
@@ -20,6 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPPredicate.j>
@class CPDatePicker
CPUndefinedAttributeType = 0;
CPInteger16AttributeType = 100;
CPInteger32AttributeType = 200;
+13 -5
View File
@@ -20,17 +20,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <AppKit/CPTextField.j>
@import <AppKit/CPViewAnimation.j>
@import <AppKit/CPView.j>
@import <Foundation/CPPredicate.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPDictionary.j>
@import <Foundation/CPIndexSet.j>
@import "CPTextField.j"
@import "CPViewAnimation.j"
@import "CPView.j"
@import "_CPRuleEditorViewSliceRow.j"
@import "_CPRuleEditorLocalizer.j"
@class CPCompoundPredicate
@class CPComparisonPredicate
@global CPDirectPredicateModifier
@global CPCaseInsensitivePredicateOption
@global CPOrPredicateType
CPRuleEditorPredicateLeftExpression = "CPRuleEditorPredicateLeftExpression";
CPRuleEditorPredicateRightExpression = "CPRuleEditorPredicateRightExpression";
CPRuleEditorPredicateComparisonModifier = "CPRuleEditorPredicateComparisonModifier";
@@ -1703,8 +1711,8 @@ TODO: implement
- (void)_setBoundDataSource:(id)datasource withKeyPath:(CPString)keyPath options:(CPDictionary)options
{
if ([observableController respondsToSelector:@selector(objectClass)])
_rowClass = [observableController objectClass];
if ([datasource respondsToSelector:@selector(objectClass)])
_rowClass = [datasource objectClass];
_boundArrayKeyPath = keyPath;
_boundArrayOwner = datasource;
@@ -3,7 +3,7 @@
* Copyright (c) 2011 Pear, Inc. All rights reserved.
*/
@class _CPPredicateEditorTree;
//@class _CPPredicateEditorTree;
@implementation _CPPredicateEditorRowNode : CPObject
{
_CPPredicateEditorTree tree @accessors;
+3 -1
View File
@@ -13,7 +13,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
{
CPDictionary _dictionary @accessors(property=dictionary);
CPURLConnection connection;
CPURLRequest resquest;
CPURLRequest request;
}
- (void)loadContentOfURL:(CPURL)aURL
@@ -77,3 +77,5 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
return aString;
}
@end
@@ -46,9 +46,11 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
[self setBordered:NO];
#if PLATFORM(DOM)
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
@@ -100,11 +102,13 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
- (void)layoutSubviews
{
#if PLATFORM(DOM)
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
style.borderRadius = radiusCSS;
#endif
[super layoutSubviews];
}
@@ -141,9 +145,11 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
[self setBordered:NO];
#if PLATFORM(DOM)
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
#endif
}
- (id)initWithFrame:(CGRect)aFrame
@@ -164,6 +170,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
- (void)layoutSubviews
{
#if PLATFORM(DOM)
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
@@ -171,6 +178,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
style.borderRadius = radiusCSS;
style[GRADIENT_PROPERTY] = ([self isHighlighted]) ? GRADIENT_HIGHLIGHTED : GRADIENT_NORMAL;
#endif
[super layoutSubviews];
}
+5 -2
View File
@@ -3,6 +3,8 @@
* Copyright (c) 2011 Pear, Inc. All rights reserved.
*/
@import "CPView.j"
@implementation _CPRuleEditorViewSlice : CPView
{
CPRuleEditor _ruleEditor;
@@ -12,6 +14,7 @@
BOOL _selected @accessors(getter=_isSelected, setter=_setSelected:);
BOOL _lastSelected @accessors(getter=_isLastSelected, setter=_setLastSelected:);
CPColor _backgroundColor @accessors(property=backgroundColor);
BOOL _editable @accessors(getter=isEditable, setter=setEditable:);
}
- (void)removeFromSuperview
@@ -81,13 +84,13 @@
- (void)mouseDown:(CPEvent)theEvent
{
if (editable)
if (_editable)
[_ruleEditor _mouseDownOnSlice:self withEvent:theEvent];
}
- (void)mouseUp:(CPEvent)theEvent
{
if (editable)
if (_editable)
[_ruleEditor _mouseUpOnSlice:self withEvent:theEvent];
}
+11 -11
View File
@@ -7,6 +7,11 @@
@import "_CPRuleEditorPopUpButton.j"
@import "CPRuleEditor.j"
@global CPRuleEditorNestingModeCompound
@global CPRuleEditorRowTypeCompound
@global CPRuleEditorNestingModeSingle
var CONTROL_HEIGHT = 16.,
BUTTON_HEIGHT = 16.;
@@ -18,7 +23,7 @@ var CONTROL_HEIGHT = 16.,
CPMutableArray _ruleOptionInitialViewFrames;
CPButton _addButton;
CPButton _subtractButton;
BOOL editable;
CPRuleEditorRowType _rowType @accessors;
CPRuleEditorRowType _plusButtonRowType;
}
@@ -37,14 +42,14 @@ var CONTROL_HEIGHT = 16.,
_ruleOptionFrames = [[CPMutableArray alloc] init];
_ruleOptionInitialViewFrames = [[CPMutableArray alloc] init];
_ruleOptionViews = [[CPMutableArray alloc] init];
editable = [_ruleEditor isEditable];
_editable = [_ruleEditor isEditable];
_addButton = [self _createAddRowButton];
_subtractButton = [self _createDeleteRowButton];
[_addButton setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
[_subtractButton setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
[_addButton setHidden:!editable];
[_subtractButton setHidden:!editable];
[_addButton setHidden:!_editable];
[_subtractButton setHidden:!_editable];
[self addSubview:_addButton];
[self addSubview:_subtractButton];
@@ -300,7 +305,7 @@ var CONTROL_HEIGHT = 16.,
[_correspondingRuleItems setArray:ruleItems];
if (!editable)
if (!_editable)
[self _updateEnabledStateForSubviews];
[self _relayoutSubviewsWidthChanged:YES];
@@ -390,14 +395,9 @@ var CONTROL_HEIGHT = 16.,
[self _setRowTypeToAddFromPlusButton:type];
}
- (BOOL)isEditable
{
return editable;
}
- (void)setEditable:(BOOL)value
{
editable = value;
[super setEditable:value]
// [self _updateEnabledStateForSubviews];
[self _updateButtonVisibilities];
}
+2 -2
View File
@@ -1112,8 +1112,8 @@ Notifies the delegate when the scroll view has finished scrolling.
contentFrame.size.height -= headerClipViewHeight;
var difference = _CGSizeMake(_CGRectGetWidth(documentFrame) - _CGRectGetWidth(contentFrame), _CGRectGetHeight(documentFrame) - _CGRectGetHeight(contentFrame)),
verticalScrollerWidth = _CGRectGetWidth([_verticalScroller frame]),
horizontalScrollerHeight = _CGRectGetHeight([_horizontalScroller frame]),
verticalScrollerWidth = [CPScroller scrollerWidthInStyle:[_verticalScroller style]],
horizontalScrollerHeight = [CPScroller scrollerWidthInStyle:[_horizontalScroller style]],
hasVerticalScroll = difference.height > 0.0,
hasHorizontalScroll = difference.width > 0.0,
shouldShowVerticalScroller = _hasVerticalScroller && (!_autohidesScrollers || hasVerticalScroll),
+7
View File
@@ -27,6 +27,13 @@
@import "CPControl.j"
@class CPViewAnimation
@global CPViewAnimationFadeOutEffect
@global CPViewAnimationTargetKey
@global CPViewAnimationEffectKey
// CPScroller Constants
CPScrollerNoPart = 0;
CPScrollerDecrementPage = 1;
+3
View File
@@ -23,6 +23,9 @@
@import "CPButton.j"
@import "CPTextField.j"
@class CPUserDefaults
CPSearchFieldRecentsTitleMenuItemTag = 1000;
CPSearchFieldRecentsMenuItemTag = 1001;
CPSearchFieldClearRecentsMenuItemTag = 1002;
+2
View File
@@ -39,6 +39,8 @@ CPCircularSlider = 1;
double _altIncrementValue;
BOOL _isVertical;
CGSize _dragOffset;
}
+ (CPString)defaultThemeClass
+7 -1
View File
@@ -23,6 +23,12 @@
@import "CPView.j"
@import "CPColorPicker.j"
@class CPSlider
@global CPColorPickerViewWidth
@global CPColorPickerViewHeight
@global CPSliderColorPickerMode
/*
@ignore
@@ -65,7 +71,7 @@
- (id)initView
{
aFrame = CGRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
var aFrame = CGRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
_contentView = [[CPView alloc] initWithFrame:aFrame];
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
+1 -1
View File
@@ -59,7 +59,7 @@ CPSoundPlayBackStatePause = 2;
if (self = [super init])
{
_loadStatus = CPSoundLoadStateEmpty;
_loops = NO;
// _loops = NO;
_audioTag = document.createElement("audio");
_audioTag.preload = YES;
_playRequestBeforeLoad = NO;
+3
View File
@@ -26,6 +26,9 @@
@import "CPImage.j"
@import "CPView.j"
@class CPUserDefaults
#define SPLIT_VIEW_MAYBE_POST_WILL_RESIZE() \
if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0) \
{ \
+5 -4
View File
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <AppKit/CPControl.j>
@import <AppKit/CPButton.j>
@import <AppKit/CPTextField.j>
@import "CPControl.j"
@import "CPButton.j"
@import "CPTextField.j"
@@ -159,7 +159,7 @@
- (void)setFrame:(CGRect)aFrame
{
var upSize = [self valueForThemeAttribute:@"up-button-size"],
var upSize = [self valueForThemeAttribute:@"up-button-size"],
downSize = [self valueForThemeAttribute:@"down-button-size"],
minSize = _CGSizeMake(upSize.width, upSize.height + downSize.height),
frame = _CGRectMakeCopy(aFrame);
@@ -177,6 +177,7 @@
downSize = [self valueForThemeAttribute:@"down-button-size"],
upFrame = _CGRectMake(aFrame.size.width - upSize.width, 0, upSize.width, upSize.height),
downFrame = _CGRectMake(aFrame.size.width - downSize.width, upSize.height, downSize.width, downSize.height);
[_buttonUp setFrame:upFrame];
[_buttonDown setFrame:downFrame];
+1
View File
@@ -60,6 +60,7 @@ CPPressedTab = 2;
CPView _auxiliaryView;
CPTabView _tabView;
unsigned _tabState; // Looks like it is not yet implemented
}
- (id)init
+3
View File
@@ -27,6 +27,9 @@
@import <Foundation/CPString.j>
@import "CPTableHeaderView.j"
@import "CPKeyValueBinding.j"
@global CPTableViewColumnDidResizeNotification
CPTableColumnNoResizing = 0;
+4
View File
@@ -26,6 +26,10 @@
@import "CPTableView.j"
@import "CPView.j"
@class CPCursor
@global CPTableColumnUserResizingMask
@implementation _CPTableColumnHeaderView : CPView
{
+3
View File
@@ -31,6 +31,9 @@
@import "CPScroller.j"
@import "CPCompatibility.j"
@class CPScrollView
@class CPUserDefaults
CPTableViewColumnDidMoveNotification = @"CPTableViewColumnDidMoveNotification";
CPTableViewColumnDidResizeNotification = @"CPTableViewColumnDidResizeNotification";
+9 -4
View File
@@ -27,6 +27,15 @@
@import "CPCompatibility.j"
@import "_CPImageAndTextView.j"
@class CPPasteboard
@global CPApp
@global CPStringPboardType
@global CPWindowAbove
@global CPWindowBelow
@global CPWindowDidBecomeKeyNotification
@global CPWindowDidResignKeyNotification
@global CPWindowDidResignKeyNotification
CPTextFieldSquareBezel = 0; /*! A textfield bezel with squared corners. */
CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */
@@ -34,8 +43,6 @@ CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corne
CPTextFieldDidFocusNotification = @"CPTextFieldDidFocusNotification";
CPTextFieldDidBlurNotification = @"CPTextFieldDidBlurNotification";
#if PLATFORM(DOM)
var CPTextFieldDOMInputElement = nil,
CPTextFieldDOMPasswordInputElement = nil,
CPTextFieldDOMStandardInputElement = nil,
@@ -49,8 +56,6 @@ var CPTextFieldDOMInputElement = nil,
CPTextFieldBlurHandler = nil,
CPTextFieldInputFunction = nil;
#endif
var CPSecureTextFieldCharacter = "\u2022";
+3 -1
View File
@@ -21,9 +21,11 @@
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPMutableArray.j>
@import <Foundation/CPString.j>
@import <Foundation/CPKeyedUnarchiver.j>
@class CPView
var CPThemesByName = { },
CPThemeDefaultTheme = nil,
@@ -145,7 +147,7 @@ var CPThemesByName = { },
className = [aClass defaultThemeClass];
else if ([aClass respondsToSelector:@selector(themeClass)])
{
CPLog.warn(@"%@ themeClass is deprecated in favor of defaultThemeClass",CPStringFromClass([anObject class]));
CPLog.warn(@"%@ themeClass is deprecated in favor of defaultThemeClass",CPStringFromClass(aClass));
className = [aClass themeClass];
}
else
+5 -1
View File
@@ -911,7 +911,9 @@ var CPScrollDestinationNone = 0,
- (void)keyDown:(CPEvent)anEvent
{
#if PLATFORM(DOM)
CPTokenFieldTextDidChangeValue = [self stringValue];
#endif
// Leave the default _propagateCurrentDOMEvent setting in place. This might be YES or NO depending
// on if something that could be a browser shortcut was pressed or not, such as Cmd-R to reload.
@@ -921,14 +923,16 @@ var CPScrollDestinationNone = 0,
[self interpretKeyEvents:[anEvent]];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}}
}
- (void)keyUp:(CPEvent)anEvent
{
#if PLATFORM(DOM)
if ([self stringValue] !== CPTokenFieldTextDidChangeValue)
{
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
}
#endif
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
+1 -634
View File
@@ -20,641 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@import "CPImage.j"
@import "CPView.j"
CPToolbarItemVisibilityPriorityStandard = 0;
CPToolbarItemVisibilityPriorityLow = -1000;
CPToolbarItemVisibilityPriorityHigh = 1000;
CPToolbarItemVisibilityPriorityUser = 2000;
CPToolbarSeparatorItemIdentifier = @"CPToolbarSeparatorItem";
CPToolbarSpaceItemIdentifier = @"CPToolbarSpaceItem";
CPToolbarFlexibleSpaceItemIdentifier = @"CPToolbarFlexibleSpaceItem";
CPToolbarShowColorsItemIdentifier = @"CPToolbarShowColorsItem";
CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItem";
CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItem";
CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
/*!
@ingroup appkit
@class CPToolbarItem
A representation of an item in a CPToolbar.
*/
@implementation CPToolbarItem : CPObject
{
CPString _itemIdentifier;
CPToolbar _toolbar;
CPString _label;
CPString _paletteLabel;
CPString _toolTip;
int _tag;
id _target;
SEL _action;
BOOL _isEnabled;
CPImage _image;
CPImage _alternateImage;
CPView _view;
CGSize _minSize;
CGSize _maxSize;
int _visibilityPriority;
BOOL _autovalidates;
}
- (id)init
{
return [self initWithItemIdentifier:@""];
}
// Creating a Toolbar Item
/*!
Initializes the toolbar item with a specified identifier.
@param anItemIdentifier the item's identifier
@return the initialized toolbar item
*/
- (id)initWithItemIdentifier:(CPString)anItemIdentifier
{
self = [super init];
if (self)
{
_itemIdentifier = anItemIdentifier;
_tag = 0;
_isEnabled = YES;
_minSize = CGSizeMakeZero();
_maxSize = CGSizeMakeZero();
_visibilityPriority = CPToolbarItemVisibilityPriorityStandard;
_autovalidates = YES;
}
return self;
}
// Managing Attributes
/*!
Returns the item's identifier.
*/
- (CPString)itemIdentifier
{
return _itemIdentifier;
}
/*!
Returns the toolbar of which this item is a part.
*/
- (CPToolbar)toolbar
{
return _toolbar;
}
/* @ignore */
- (void)_setToolbar:(CPToolbar)aToolbar
{
_toolbar = aToolbar;
}
/*!
Returns the item's label
*/
- (CPString)label
{
return _label;
}
/*!
Sets the item's label.
@param aLabel the new label for the item
*/
- (void)setLabel:(CPString)aLabel
{
_label = aLabel;
}
/*!
Returns the palette label.
*/
- (CPString)paletteLabel
{
return _paletteLabel;
}
/*!
Sets the palette label
@param aPaletteLabel the new palette label
*/
- (void)setPaletteLabel:(CPString)aPaletteLabel
{
_paletteLabel = aPaletteLabel;
}
/*!
Returns the item's tooltip. A tooltip pops up
next to the cursor when the user hovers over
the item with the mouse.
*/
- (CPString)toolTip
{
if ([_view respondsToSelector:@selector(toolTip)])
return [_view toolTip];
return _toolTip;
}
/*!
Sets the item's tooltip. A tooltip pops up next to the cursor when the user hovers over the item with the mouse.
@param aToolTip the new item tool tip
*/
- (void)setToolTip:(CPString)aToolTip
{
if ([_view respondsToSelector:@selector(setToolTip:)])
[_view setToolTip:aToolTip];
_toolTip = aToolTip;
}
/*!
Returns the item's tag.
*/
- (int)tag
{
if ([_view respondsToSelector:@selector(tag)])
return [_view tag];
return _tag;
}
/*!
Sets the item's tag.
@param aTag the new tag for the item
*/
- (void)setTag:(int)aTag
{
if ([_view respondsToSelector:@selector(setTag:)])
[_view setTag:aTag];
_tag = aTag;
}
/*!
Returns the item's action target.
*/
- (id)target
{
if (_view)
return [_view respondsToSelector:@selector(target)] ? [_view target] : nil;
return _target;
}
/*!
Sets the target of the action that is triggered when the user clicks this item. \c nil will cause
the action to be passed on to the first responder.
@param aTarget the new target
*/
- (void)setTarget:(id)aTarget
{
if (!_view)
_target = aTarget;
else if ([_view respondsToSelector:@selector(setTarget:)])
[_view setTarget:aTarget];
}
/*!
Returns the action that is triggered when the user clicks this item.
*/
- (SEL)action
{
if (_view)
return [_view respondsToSelector:@selector(action)] ? [_view action] : nil;
return _action;
}
/*!
Sets the action that is triggered when the user clicks this item.
@param anAction the new action
*/
- (void)setAction:(SEL)anAction
{
if (!_view)
_action = anAction;
else if ([_view respondsToSelector:@selector(setAction:)])
[_view setAction:anAction];
}
/*!
Returns \c YES if the item is enabled.
*/
- (BOOL)isEnabled
{
if ([_view respondsToSelector:@selector(isEnabled)])
return [_view isEnabled];
return _isEnabled;
}
/*!
Sets whether the item is enabled.
@param aFlag \c YES enables the item
*/
- (void)setEnabled:(BOOL)shouldBeEnabled
{
if (_isEnabled === shouldBeEnabled)
return;
if ([_view respondsToSelector:@selector(setEnabled:)])
[_view setEnabled:shouldBeEnabled];
_isEnabled = shouldBeEnabled;
}
/*!
Returns the item's image
*/
- (CPImage)image
{
if ([_view respondsToSelector:@selector(image)])
return [_view image];
return _image;
}
/*!
Sets the item's image.
@param anImage the new item image
*/
- (void)setImage:(CPImage)anImage
{
if ([_view respondsToSelector:@selector(setImage:)])
[_view setImage:anImage];
_image = anImage;
if (!_image)
return;
if (_minSize.width === 0 && _minSize.height === 0 &&
_maxSize.width === 0 && _maxSize.height === 0)
{
var imageSize = [_image size];
if (imageSize.width > 0 || imageSize.height > 0)
{
[self setMinSize:imageSize];
[self setMaxSize:imageSize];
}
}
}
/*!
Sets the alternate image. This image is displayed on the item when the user is clicking it.
@param anImage the new alternate image
*/
- (void)setAlternateImage:(CPImage)anImage
{
if ([_view respondsToSelector:@selector(setAlternateImage:)])
[_view setAlternateImage:anImage];
_alternateImage = anImage;
}
/*!
Returns the alternate image. This image is displayed on the item when the user is clicking it.
*/
- (CPImage)alternateImage
{
if ([_view respondsToSelector:@selector(alternateIamge)])
return [_view alternateImage];
return _alternateImage;
}
/*!
Returns the item's view.
*/
- (CPView)view
{
return _view;
}
/*!
Sets the item's view
@param aView the item's new view
*/
- (void)setView:(CPView)aView
{
if (_view == aView)
return;
_view = aView;
if (_view)
{
// Tags get forwarded.
if (_tag !== 0 && [_view respondsToSelector:@selector(setTag:)])
[_view setTag:_tag];
_target = nil;
_action = nil;
}
}
/*!
Returns the item's minimum size.
*/
- (CGSize)minSize
{
return _minSize;
}
/*!
Sets the item's minimum size.
@param aMinSize the new minimum size
*/
- (void)setMinSize:(CGSize)aMinSize
{
if (!aMinSize.height || !aMinSize.width)
return;
_minSize = CGSizeMakeCopy(aMinSize);
// Try to provide some sanity: Make maxSize >= minSize
_maxSize = CGSizeMake(MAX(_minSize.width, _maxSize.width), MAX(_minSize.height, _maxSize.height));
}
/*!
Returns the item's maximum size.
*/
- (CGSize)maxSize
{
return _maxSize;
}
/*!
Sets the item's new maximum size.
@param aMaxSize the new maximum size
*/
- (void)setMaxSize:(CGSize)aMaxSize
{
if (!aMaxSize.height || !aMaxSize.width)
return;
_maxSize = CGSizeMakeCopy(aMaxSize);
// Try to provide some sanity: Make minSize <= maxSize
_minSize = CGSizeMake(MIN(_minSize.width, _maxSize.width), MIN(_minSize.height, _maxSize.height));
}
// Visibility Priority
/*!
Returns the item's visibility priority. The value will be one of:
<pre>
CPToolbarItemVisibilityPriorityStandard
CPToolbarItemVisibilityPriorityLow
CPToolbarItemVisibilityPriorityHigh
CPToolbarItemVisibilityPriorityUser
</pre>
*/
- (int)visibilityPriority
{
return _visibilityPriority;
}
/*!
Sets the item's visibility priority. The value must be one of:
<pre>
CPToolbarItemVisibilityPriorityStandard
CPToolbarItemVisibilityPriorityLow
CPToolbarItemVisibilityPriorityHigh
CPToolbarItemVisibilityPriorityUser
</pre>
@param aVisiblityPriority the priority
*/
- (void)setVisibilityPriority:(int)aVisibilityPriority
{
_visibilityPriority = aVisibilityPriority;
}
- (void)validate
{
var action = [self action],
target = [self target];
// View items do not do any target-action analysis.
if (_view)
{
if ([target respondsToSelector:@selector(validateToolbarItem:)])
{
var shouldBeEnabled = [target validateToolbarItem:self];
if (_isEnabled !== shouldBeEnabled)
[self setEnabled:shouldBeEnabled];
}
return;
}
if (!action)
{
if (_isEnabled)
return [self setEnabled:NO];
return;
}
if (target && ![target respondsToSelector:action])
{
if (_isEnabled)
return [self setEnabled:NO];
return;
}
target = [CPApp targetForAction:action to:target from:self];
if (!target)
{
if (_isEnabled)
return [self setEnabled:NO];
return;
}
if ([target respondsToSelector:@selector(validateToolbarItem:)])
{
var shouldBeEnabled = [target validateToolbarItem:self];
if (_isEnabled !== shouldBeEnabled)
[self setEnabled:shouldBeEnabled];
}
else
{
if (!_isEnabled)
[self setEnabled:YES];
}
}
- (BOOL)autovalidates
{
return _autovalidates;
}
- (void)setAutovalidates:(BOOL)shouldAutovalidate
{
_autovalidates = !!shouldAutovalidate;
}
@end
var CPToolbarItemItemIdentifierKey = @"CPToolbarItemItemIdentifierKey",
CPToolbarItemLabelKey = @"CPToolbarItemLabelKey",
CPToolbarItemPaletteLabelKey = @"CPToolbarItemPaletteLabelKey",
CPToolbarItemToolTipKey = @"CPToolbarItemToolTipKey",
CPToolbarItemTagKey = @"CPToolbarItemTagKey",
CPToolbarItemTargetKey = @"CPToolbarItemTargetKey",
CPToolbarItemActionKey = @"CPToolbarItemActionKey",
CPToolbarItemEnabledKey = @"CPToolbarItemEnabledKey",
CPToolbarItemImageKey = @"CPToolbarItemImageKey",
CPToolbarItemAlternateImageKey = @"CPToolbarItemAlternateImageKey",
CPToolbarItemViewKey = @"CPToolbarItemViewKey",
CPToolbarItemMinSizeKey = @"CPToolbarItemMinSizeKey",
CPToolbarItemMaxSizeKey = @"CPToolbarItemMaxSizeKey",
CPToolbarItemVisibilityPriorityKey = @"CPToolbarItemVisibilityPriorityKey",
CPToolbarItemAutovalidatesKey = @"CPToolbarItemAutovalidatesKey";
@implementation CPToolbarItem (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_itemIdentifier = [aCoder decodeObjectForKey:CPToolbarItemItemIdentifierKey];
_minSize = [aCoder decodeSizeForKey:CPToolbarItemMinSizeKey];
_maxSize = [aCoder decodeSizeForKey:CPToolbarItemMaxSizeKey];
[self setLabel:[aCoder decodeObjectForKey:CPToolbarItemLabelKey]];
[self setPaletteLabel:[aCoder decodeObjectForKey:CPToolbarItemPaletteLabelKey]];
[self setToolTip:[aCoder decodeObjectForKey:CPToolbarItemToolTipKey]];
[self setTag:[aCoder decodeObjectForKey:CPToolbarItemTagKey]];
[self setTarget:[aCoder decodeObjectForKey:CPToolbarItemTargetKey]];
[self setAction:CPSelectorFromString([aCoder decodeObjectForKey:CPToolbarItemActionKey])];
[self setEnabled:[aCoder decodeBoolForKey:CPToolbarItemEnabledKey]];
[self setImage:[aCoder decodeObjectForKey:CPToolbarItemImageKey]];
[self setAlternateImage:[aCoder decodeObjectForKey:CPToolbarItemAlternateImageKey]];
[self setView:[aCoder decodeObjectForKey:CPToolbarItemViewKey]];
[self setVisibilityPriority:[aCoder decodeIntForKey:CPToolbarItemVisibilityPriorityKey]];
[self setAutovalidates:[aCoder decodeBoolForKey:CPToolbarItemAutovalidatesKey]];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_itemIdentifier forKey:CPToolbarItemItemIdentifierKey];
[aCoder encodeObject:[self label] forKey:CPToolbarItemLabelKey];
[aCoder encodeObject:[self paletteLabel] forKey:CPToolbarItemPaletteLabelKey];
[aCoder encodeObject:[self toolTip] forKey:CPToolbarItemToolTipKey];
[aCoder encodeObject:[self tag] forKey:CPToolbarItemTagKey];
[aCoder encodeObject:[self target] forKey:CPToolbarItemTargetKey];
[aCoder encodeObject:[self action] forKey:CPToolbarItemActionKey];
[aCoder encodeObject:[self isEnabled] forKey:CPToolbarItemEnabledKey];
[aCoder encodeObject:[self image] forKey:CPToolbarItemImageKey];
[aCoder encodeObject:[self alternateImage] forKey:CPToolbarItemAlternateImageKey];
[aCoder encodeObject:[self view] forKey:CPToolbarItemViewKey];
[aCoder encodeSize:[self minSize] forKey:CPToolbarItemMinSizeKey];
[aCoder encodeSize:[self maxSize] forKey:CPToolbarItemMaxSizeKey];
[aCoder encodeObject:[self visibilityPriority] forKey:CPToolbarItemVisibilityPriorityKey];
[aCoder encodeBool:[self autovalidates] forKey:CPToolbarItemAutovalidatesKey];
}
@end
@implementation CPToolbarItem (CPCopying)
- (id)copy
{
var copy = [[[self class] alloc] initWithItemIdentifier:_itemIdentifier];
if (_view)
[copy setView:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:_view]]];
[copy _setToolbar:_toolbar];
[copy setLabel:_label];
[copy setPaletteLabel:_paletteLabel];
[copy setToolTip:[self toolTip]];
[copy setTag:[self tag]];
[copy setTarget:[self target]];
[copy setAction:[self action]];
[copy setEnabled:[self isEnabled]];
[copy setImage:[self image]];
[copy setAlternateImage:[self alternateImage]];
[copy setMinSize:_minSize];
[copy setMaxSize:_maxSize];
[copy setVisibilityPriority:[self visibilityPriority]];
[copy setAutovalidates:[self autovalidates]];
return copy;
}
@end
// Standard toolbar identifiers
@implementation CPToolbarItem (Standard)
/* @ignore */
+ (CPToolbarItem)_standardItemWithItemIdentifier:(CPString)anItemIdentifier
{
switch (anItemIdentifier)
{
case CPToolbarSeparatorItemIdentifier: return [_CPToolbarSeparatorItem new];
case CPToolbarSpaceItemIdentifier: return [_CPToolbarSpaceItem new];
case CPToolbarFlexibleSpaceItemIdentifier: return [_CPToolbarFlexibleSpaceItem new];
case CPToolbarShowColorsItemIdentifier: return [_CPToolbarShowColorsItem new];
case CPToolbarShowFontsItemIdentifier: return nil;
case CPToolbarCustomizeToolbarItemIdentifier: return nil;
case CPToolbarPrintItemIdentifier: return nil;
}
return nil;
}
@end
@import "_CPToolbarItem.j"
@import "_CPToolbarFlexibleSpaceItem.j"
@import "_CPToolbarShowColorsItem.j"
@import "_CPToolbarSeparatorItem.j"
+7 -1
View File
@@ -25,7 +25,12 @@
@import <Foundation/CPString.j>
@import <AppKit/CPController.j>
@import "CPController.j"
@class CPUserDefaults
@global CPUserDefaultsDidChangeNotification
var SharedUserDefaultsController = nil;
@@ -34,6 +39,7 @@ var SharedUserDefaultsController = nil;
CPUserDefaults _defaults @accessors(readonly, property=defaults);
CPDictionary _initialValues @accessors(property=initialValues);
BOOL _appliesImmediately @accessors(property=appliesImmediately);
id _valueProxy;
}
+ (id)sharedUserDefaultsController
+13 -1
View File
@@ -34,6 +34,18 @@
@import "CPTheme.j"
@import "_CPDisplayServer.j"
@class _CPToolTip
@class CPWindow
@class _CPMenuItemView
@class CPPlatformWindow
@class CPMenu
@class CPClipView
@class CPScrollView
@global appkit_tag_dom_elements
@global CPWindowAbove
@global CPBorderlessWindowMask
@global CPScreenSaverWindowLevel
/*
@global
@@ -2192,6 +2204,7 @@ setBoundsOrigin:
{
var graphicsPort = CGBitmapGraphicsContextCreate();
#if PLATFORM(DOM)
_DOMContentsElement = graphicsPort.DOMElement;
_DOMContentsElement.style.zIndex = -100;
@@ -2208,7 +2221,6 @@ setBoundsOrigin:
_DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_frame)) + "px";
_DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_frame)) + "px";
#if PLATFORM(DOM)
// The performance implications of this aren't clear, but without this subviews might not be redrawn when this
// view moves.
if (CPPlatformHasBug(CPCanvasParentDrawErrorsOnMovementBug))
+5 -1
View File
@@ -26,6 +26,10 @@
@import "CPCib.j"
@import "CPResponder.j"
@class CPDocument
@global CPApp
var CPViewControllerCachedCibs;
@@ -222,7 +226,7 @@ var CPViewControllerCachedCibs;
{
[self willChangeValueForKey:"isViewLoaded"];
[self viewDidLoad];
isViewLoaded = YES;
_isViewLoaded = YES;
[self didChangeValueForKey:"isViewLoaded"];
}
File diff suppressed because it is too large. Load diff
+3
View File
@@ -21,6 +21,9 @@
*/
@import "_CPWindowView.j"
@import "CGGradient.j"
@global CPPopoverAppearanceMinimal
#define ALIGN_STROKE(point) (FLOOR(point) === (point) ? (point) + halfStrokeWidth : (point))
#define ALIGN_COORD(point) (FLOOR(point))
+14 -2
View File
@@ -22,6 +22,9 @@
@import "CPTextField.j"
@import "_CPTitleableWindowView.j"
@import "CPButton.j"
@class _CPDocModalWindowView
@implementation _CPTexturedWindowHeadView : CPView
{
@@ -206,6 +209,7 @@
var dividerMaxY = 0,
dividerMinY = 0;
if (![_dividerView isHidden])
{
dividerMinY = _CGRectGetMinY([_dividerView frame]);
@@ -319,6 +323,7 @@
[self setFrameSize:_CGSizeMake(newWidth, newHeight)];
[self tile];
[theWindow setFrame:frame display:NO animate:NO];
}
- (void)layoutSubviews
@@ -331,9 +336,16 @@
[_minimizeButton setImage:[self valueForThemeAttribute:@"minimize-image-button"]];
[_minimizeButton setAlternateImage:[self valueForThemeAttribute:@"minimize-image-highlighted-button"]];
[_headView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), [self toolbarMaxY])];
if(![_headView isHidden])
[_headView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), [self toolbarMaxY])];
else
[_headView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), 0)];
if(![_dividerView isHidden])
[_dividerView setFrame:CGRectMake(0.0, CGRectGetMaxY([_headView frame]), CGRectGetWidth(bounds), 1.0)];
else
[_dividerView setFrame:CGRectMake(0.0, CGRectGetMaxY([_headView frame]), CGRectGetWidth(bounds), 0.0)];
[_dividerView setFrame:CGRectMake(0.0, CGRectGetMaxY([_headView frame]), CGRectGetWidth(bounds), 1.0)];
[_dividerView setBackgroundColor:[self valueForThemeAttribute:@"divider-color"]];
var y = CGRectGetMaxY([_dividerView frame]);
+3
View File
@@ -22,6 +22,9 @@
@import "_CPWindowView.j"
@class CPTextField
@implementation _CPTitleableWindowView : _CPWindowView
{
CPTextField _titleField;
File diff suppressed because it is too large. Load diff
+12
View File
@@ -23,6 +23,18 @@
@import "CPImageView.j"
@import "CPView.j"
@class CPCursor
@class CPMenu
@class CPPlatformWindow
@global CPApp
@global CPHUDBackgroundWindowMask
@global CPResizableWindowMask
@global CPWindowResizeSlop
@global CPWindowResizeStyle
@global CPWindowResizeStyleLegacy
@global CPWindowResizeStyleModern
var _CPWindowViewCornerResizeRectWidth = 10,
_CPWindowViewResizeRegionNone = -1,
+7
View File
@@ -27,6 +27,13 @@
@import "CPWindow.j"
@import "CPDocument.j"
@class CPDocument
@global CPApp
@global CPDocumentWillSaveNotification
@global CPDocumentDidSaveNotification
@global CPDocumentDidFailToSaveNotification
/*!
@ingroup appkit
+2
View File
@@ -1,6 +1,8 @@
@import <Foundation/CPObject.j>
@class CPApplication
var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
+2
View File
@@ -26,6 +26,8 @@
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@class CPButtonBar
var _CPCibCustomResourceClassNameKey = @"_CPCibCustomResourceClassNameKey",
_CPCibCustomResourceResourceNameKey = @"_CPCibCustomResourceResourceNameKey",
+3
View File
@@ -31,6 +31,9 @@
@import "CPCibBindingConnector.j"
@import "CPCibRuntimeAttributesConnector.j"
@import "CPCibHelpConnector.j"
@import "CPClipView.j"
@class CPScrollView
@implementation _CPCibObjectData : CPObject
+5
View File
@@ -4,6 +4,11 @@
@import "CGGeometry.j"
@import "CPWindow.j"
@class CPToolbar
@global CPPositionProportionalHorizontal
@global CPPositionProportionalVertical
CPWindowPositionFlexibleRight = 1 << 19;
CPWindowPositionFlexibleLeft = 1 << 20;
CPWindowPositionFlexibleBottom = 1 << 21;
+2 -1
View File
@@ -85,6 +85,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
float _opacity;
BOOL _isHidden;
BOOL _masksToBounds;
CPColor _backgroundColor;
// Managing Layer Hierarchy
@@ -856,7 +857,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
*/
- (void)setNeedsDisplayInRect:(CGRect)aRect
{
_dirtyRect = aRect;
// _dirtyRect = aRect;
[self display];
}
+1 -1
View File
@@ -75,7 +75,7 @@ var CAMediaNamedTimingFunctions = nil;
return self;
}
- (void)getControlPointAtIndex:(unsigned)anIndex values:(float[2])reference
- (void)getControlPointAtIndex:(unsigned)anIndex values:(float/*[2]*/)reference
{
if (anIndex == 0)
{
+8 -1
View File
@@ -21,7 +21,14 @@
*/
@import <Foundation/CPObject.j>
@import "CPKeyBinding.j"
//@import "CPMenu.j"
@import "CPPlatform.j"
//@import "CPEvent.j"
@class CPMenu
@global CPApp
var PrimaryPlatformWindow = NULL;
@@ -278,5 +285,5 @@ var PrimaryPlatformWindow = NULL;
@end
#if PLATFORM(BROWSER)
@import "CPPlatformWindow+DOM.j"
//@import "CPPlatformWindow+DOM.j"
#endif
+23 -2
View File
@@ -119,6 +119,25 @@
@import "CPPlatformWindow.j"
@import "CPPlatformWindow+DOMKeys.j"
@class CPCursor
@class CPDragServer
@class CPPasteboard
@class _CPDOMDataTransferPasteboard
@class _CPToolTip
@global CPDragOperationNone
@global CPDragOperationMove
@global CPDragOperationCopy
@global CPDragOperationLink
@global CPDragOperationPrivate
@global CPDragOperationGeneric
@global CPApp
@global CPStringPboardType
@global CPWindowOut
@global _CPRunModalLoop
@global CPDraggingWindowLevel
@global CPWindowAbove
// List of all open native windows
var PlatformWindows = [CPSet set];
@@ -192,6 +211,7 @@ var ModifierKeyCodes = [
var resizeTimer = nil;
#if PLATFORM(DOM)
@implementation CPPlatformWindow (DOM)
- (id)_init
@@ -795,7 +815,7 @@ var resizeTimer = nil;
if (!characters)
characters = String.fromCharCode(charCode);
charactersIgnoringModifiers = characters.toLowerCase(); // FIXME: This isn't correct. It SHOULD include Shift.
var charactersIgnoringModifiers = characters.toLowerCase(); // FIXME: This isn't correct. It SHOULD include Shift.
// Safari won't send proper capitalization during cmd-key events
if (!overrideCharacters && (modifierFlags & CPCommandKeyMask) && ((modifierFlags & CPShiftKeyMask) || _capsLockActive))
@@ -879,7 +899,7 @@ var resizeTimer = nil;
windowNumber = [[CPApp keyWindow] windowNumber],
modifierFlags = CPPlatformActionKeyMask;
event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
var event = [CPEvent keyEventWithType:CPKeyDown location:location modifierFlags:modifierFlags
timestamp:timestamp windowNumber:windowNumber context:nil
characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode];
@@ -1581,6 +1601,7 @@ var resizeTimer = nil;
}
@end
#endif
var CPEventClass = [CPEvent class];
+1 -1
View File
@@ -1758,7 +1758,7 @@ var themedButtonValues = nil,
[@"sort-image", sortImage],
[@"sort-image-reversed", sortImageReversed],
[@"image-generic-file", imageGenericFile],
[@"default-row-height", 25.0],
[@"default-row-height", 23.0],
];
[self registerThemeValues:themedTableViewValues forView:tableview];
+8 -8
View File
@@ -628,8 +628,8 @@ var themedButtonValues = nil,
[@"bezel-color", bezelDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
[@"font", [CPFont systemFontOfSize:12.0], CPThemeStateBezeled],
[@"content-inset", CGInsetMake(8.0, 7.0, 5.0, 8.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(8.0, 7.0, 5.0, 8.0), CPThemeStateBezeled | CPThemeStateEditing],
[@"content-inset", CGInsetMake(8.0, 7.0, 5.0, 10.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(8.0, 7.0, 5.0, 10.0), CPThemeStateBezeled | CPThemeStateEditing],
[@"bezel-inset", CGInsetMake(3.0, 4.0, 3.0, 4.0), CPThemeStateBezeled],
[@"bezel-inset", CGInsetMake(0.0, 1.0, 0.0, 1.0), CPThemeStateBezeled | CPThemeStateEditing],
@@ -643,7 +643,7 @@ var themedButtonValues = nil,
[@"text-color", [CPColor whiteColor], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView],
[@"font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView],
[@"text-color", [CPColor blackColor], CPThemeStateTableDataView | CPThemeStateEditing],
[@"content-inset", CGInsetMake(7.0, 7.0, 5.0, 8.0), CPThemeStateTableDataView | CPThemeStateEditing],
[@"content-inset", CGInsetMake(7.0, 7.0, 5.0, 10.0), CPThemeStateTableDataView | CPThemeStateEditing],
[@"font", [CPFont systemFontOfSize:12.0], CPThemeStateTableDataView | CPThemeStateEditing],
[@"bezel-inset", CGInsetMake(-2.0, -2.0, -2.0, -2.0), CPThemeStateTableDataView | CPThemeStateEditing],
@@ -767,10 +767,10 @@ var themedButtonValues = nil,
[@"content-inset", CGInsetMake(7.0, 8.0, 6.0, 8.0), CPTextFieldStatePlaceholder],
// Bezeled token field with tokens
[@"content-inset", CGInsetMake(5.0, 8.0, 4.0, 8.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(4.0, 8.0, 4.0, 8.0), CPThemeStateBezeled],
// Bezeled token field with no tokens
[@"content-inset", CGInsetMake(10.0, 8.0, 7.0, 8.0), CPThemeStateBezeled | CPTextFieldStatePlaceholder],
[@"content-inset", CGInsetMake(8.0, 8.0, 7.0, 8.0), CPThemeStateBezeled | CPTextFieldStatePlaceholder],
];
[self registerThemeValues:overrides forView:tokenfield inherit:themedTextFieldValues];
@@ -928,9 +928,9 @@ var themedButtonValues = nil,
[@"bezel-inset", CGInsetMake(0.0, 1.0, 1.0, 1.0), CPThemeStateBezeled | CPThemeStateEditing],
// The right border inset has to make room for the focus ring and popup button
[@"content-inset", CGInsetMake(10.0, 26.0, 7.0, 8.0), CPThemeStateBezeled | CPComboBoxStateButtonBordered],
[@"content-inset", CGInsetMake(10.0, 24.0, 7.0, 8.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(10.0, 24.0, 7.0, 8.0), CPThemeStateBezeled | CPThemeStateEditing],
[@"content-inset", CGInsetMake(10.0, 26.0, 7.0, 10.0), CPThemeStateBezeled | CPComboBoxStateButtonBordered],
[@"content-inset", CGInsetMake(10.0, 24.0, 7.0, 10.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(10.0, 24.0, 7.0, 10.0), CPThemeStateBezeled | CPThemeStateEditing],
[@"popup-button-size", CGSizeMake(21.0, 23.0), CPThemeStateBezeled | CPComboBoxStateButtonBordered],
[@"popup-button-size", CGSizeMake(17.0, 23.0), CPThemeStateBezeled],
@@ -20,8 +20,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/Foundation.j>
@import <AppKit/CPCollectionView.j>
@import <AppKit/CPColorPanel.j>
@import <AppKit/CPScrollView.j>
@import <AppKit/CPSplitView.j>
@import <AppKit/CPTheme.j>
@import <AppKit/CPToolbar.j>
@import <AppKit/CPView.j>
@import <AppKit/CPWindow.j>
@import "BKThemeDescriptor.j"
var LEFT_PANEL_WIDTH = 176.0;
@@ -21,6 +21,9 @@
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPWindow.j>
@import <AppKit/_CPStandardWindowView.j>
@import <AppKit/_CPToolTipWindowView.j>
var ItemSizes = { },
+21 -1
View File
@@ -354,8 +354,10 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
{
var browserProperty = CPBrowserStyleProperty(aProperty);
#if PLATFORM(DOM)
if (browserProperty)
_DOMElement.style[browserProperty] = value;
#endif
}
/*! @ignore */
@@ -430,7 +432,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
var transformOrigin = "50% 100%",
frame = [self frame],
preferredEdge = [_windowView preferredEdge],
posX;
posX, posY;
switch (preferredEdge)
{
@@ -455,9 +457,11 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
window.setTimeout(function()
{
// We are watching opacity, so this triggers the next transition
#if PLATFORM(DOM)
_DOMElement.style.opacity = 1;
_DOMElement.style.height = frame.size.height + @"px";
_DOMElement.style.width = frame.size.width + @"px";
#endif
// Set up the pop-out transition
[self setCSS3Property:@"Transform" value:@"scale(1.1)"];
@@ -465,7 +469,9 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
var transitionEndFunction = function()
{
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), transitionEndFunction, YES);
#endif
// Now set up the pop-in to normal size transition.
// Because we are watching the -webkit-transform, it will occur now.
@@ -474,21 +480,29 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
var transitionCompleteFunction = function()
{
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty('transitionend'), transitionCompleteFunction, YES);
#endif
if (_implementedDelegateMethods & _CPAttachedWindow_attachedWindowDidShow_)
[_delegate attachedWindowDidShow:self];
}
#if PLATFORM(DOM)
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), transitionCompleteFunction, YES);
#endif
};
#if PLATFORM(DOM)
_DOMElement.addEventListener(CPBrowserStyleProperty('transitionend'), transitionEndFunction, YES);
#endif
}, 0);
}
else
{
[self setCSS3Property:@"Transition" value:@""];
#if PLATFORM(DOM)
_DOMElement.style.opacity = 1;
#endif
}
}
@@ -511,15 +525,21 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
{
// Tell the element to fade out when the opacity changes
[self setCSS3Property:@"Transition" value:@"opacity 250ms linear"];
#if PLATFORM(DOM)
_DOMElement.style.opacity = 0;
#endif
var transitionEndFunction = function()
{
#if PLATFORM(DOM)
_DOMElement.removeEventListener(CPBrowserStyleProperty("transitionend"), transitionEndFunction, YES);
#endif
[self _close];
};
#if PLATFORM(DOM)
_DOMElement.addEventListener(CPBrowserStyleProperty("transitionend"), transitionEndFunction, YES);
#endif
}
else
{
+4
View File
@@ -23,8 +23,12 @@
@import <Foundation/CPObject.j>
@import "CPTextField.j"
@import "CPTableView.j"
@import "_CPMenuWindow.j"
@class CPScrollView
// TODO Make themable.
var _CPAutocompleteMenuMaximumHeight = 307;
+3
View File
@@ -27,6 +27,7 @@
@import "CPImage.j"
@import "CPView.j"
@import "CPControl.j"
@import "CPPlatform.j"
var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
@@ -294,6 +295,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
var textFrame = _CGRectMakeZero();
#if PLATFORM(DOM)
if (_DOMTextElement)
{
var textStyle = _DOMTextElement.style;
@@ -306,6 +308,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
textFrame.size.width += _textShadowOffset.width;
textFrame.size.height += _textShadowOffset.height;
}
#endif
return textFrame;
}
+6 -1
View File
@@ -21,8 +21,13 @@
*/
@import "CPTableView.j"
@import "CPPanel.j"
@import "_CPPopUpListDataSource.j"
@class CPScrollView
@global CPLineBorder
/*!
Notification sent when the list is about to pop up. \c object is the _CPPopUpList.
@@ -839,7 +844,7 @@ var _CPPopUpListDataSourceKey = @"_CPPopUpListDataSourceKey",
*/
- (CPTableColumn)listColumn
{
return _tableColumn;
return _tableColumns[0];
}
@end
+1 -1
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPToolbarItem.j"
@import "_CPToolbarItem.j"
@implementation _CPToolbarFlexibleSpaceItem : CPToolbarItem
+662
View File
@@ -0,0 +1,662 @@
/*
* CPToolbarItem.j
* AppKit
*
* Created by Francisco Tolmasky.
* 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 <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@import "CPImage.j"
@import "CPView.j"
CPToolbarItemVisibilityPriorityStandard = 0;
CPToolbarItemVisibilityPriorityLow = -1000;
CPToolbarItemVisibilityPriorityHigh = 1000;
CPToolbarItemVisibilityPriorityUser = 2000;
CPToolbarSeparatorItemIdentifier = @"CPToolbarSeparatorItem";
CPToolbarSpaceItemIdentifier = @"CPToolbarSpaceItem";
CPToolbarFlexibleSpaceItemIdentifier = @"CPToolbarFlexibleSpaceItem";
CPToolbarShowColorsItemIdentifier = @"CPToolbarShowColorsItem";
CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItem";
CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItem";
CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
/*!
@ingroup appkit
@class CPToolbarItem
A representation of an item in a CPToolbar.
*/
@implementation CPToolbarItem : CPObject
{
CPString _itemIdentifier;
CPToolbar _toolbar;
CPString _label;
CPString _paletteLabel;
CPString _toolTip;
int _tag;
id _target;
SEL _action;
BOOL _isEnabled;
CPImage _image;
CPImage _alternateImage;
CPView _view;
CGSize _minSize;
CGSize _maxSize;
int _visibilityPriority;
BOOL _autovalidates;
}
- (id)init
{
return [self initWithItemIdentifier:@""];
}
// Creating a Toolbar Item
/*!
Initializes the toolbar item with a specified identifier.
@param anItemIdentifier the item's identifier
@return the initialized toolbar item
*/
- (id)initWithItemIdentifier:(CPString)anItemIdentifier
{
self = [super init];
if (self)
{
_itemIdentifier = anItemIdentifier;
_tag = 0;
_isEnabled = YES;
_minSize = CGSizeMakeZero();
_maxSize = CGSizeMakeZero();
_visibilityPriority = CPToolbarItemVisibilityPriorityStandard;
_autovalidates = YES;
}
return self;
}
// Managing Attributes
/*!
Returns the item's identifier.
*/
- (CPString)itemIdentifier
{
return _itemIdentifier;
}
/*!
Returns the toolbar of which this item is a part.
*/
- (CPToolbar)toolbar
{
return _toolbar;
}
/* @ignore */
- (void)_setToolbar:(CPToolbar)aToolbar
{
_toolbar = aToolbar;
}
/*!
Returns the item's label
*/
- (CPString)label
{
return _label;
}
/*!
Sets the item's label.
@param aLabel the new label for the item
*/
- (void)setLabel:(CPString)aLabel
{
_label = aLabel;
}
/*!
Returns the palette label.
*/
- (CPString)paletteLabel
{
return _paletteLabel;
}
/*!
Sets the palette label
@param aPaletteLabel the new palette label
*/
- (void)setPaletteLabel:(CPString)aPaletteLabel
{
_paletteLabel = aPaletteLabel;
}
/*!
Returns the item's tooltip. A tooltip pops up
next to the cursor when the user hovers over
the item with the mouse.
*/
- (CPString)toolTip
{
if ([_view respondsToSelector:@selector(toolTip)])
return [_view toolTip];
return _toolTip;
}
/*!
Sets the item's tooltip. A tooltip pops up next to the cursor when the user hovers over the item with the mouse.
@param aToolTip the new item tool tip
*/
- (void)setToolTip:(CPString)aToolTip
{
if ([_view respondsToSelector:@selector(setToolTip:)])
[_view setToolTip:aToolTip];
_toolTip = aToolTip;
}
/*!
Returns the item's tag.
*/
- (int)tag
{
if ([_view respondsToSelector:@selector(tag)])
return [_view tag];
return _tag;
}
/*!
Sets the item's tag.
@param aTag the new tag for the item
*/
- (void)setTag:(int)aTag
{
if ([_view respondsToSelector:@selector(setTag:)])
[_view setTag:aTag];
_tag = aTag;
}
/*!
Returns the item's action target.
*/
- (id)target
{
if (_view)
return [_view respondsToSelector:@selector(target)] ? [_view target] : nil;
return _target;
}
/*!
Sets the target of the action that is triggered when the user clicks this item. \c nil will cause
the action to be passed on to the first responder.
@param aTarget the new target
*/
- (void)setTarget:(id)aTarget
{
if (!_view)
_target = aTarget;
else if ([_view respondsToSelector:@selector(setTarget:)])
[_view setTarget:aTarget];
}
/*!
Returns the action that is triggered when the user clicks this item.
*/
- (SEL)action
{
if (_view)
return [_view respondsToSelector:@selector(action)] ? [_view action] : nil;
return _action;
}
/*!
Sets the action that is triggered when the user clicks this item.
@param anAction the new action
*/
- (void)setAction:(SEL)anAction
{
if (!_view)
_action = anAction;
else if ([_view respondsToSelector:@selector(setAction:)])
[_view setAction:anAction];
}
/*!
Returns \c YES if the item is enabled.
*/
- (BOOL)isEnabled
{
if ([_view respondsToSelector:@selector(isEnabled)])
return [_view isEnabled];
return _isEnabled;
}
/*!
Sets whether the item is enabled.
@param aFlag \c YES enables the item
*/
- (void)setEnabled:(BOOL)shouldBeEnabled
{
if (_isEnabled === shouldBeEnabled)
return;
if ([_view respondsToSelector:@selector(setEnabled:)])
[_view setEnabled:shouldBeEnabled];
_isEnabled = shouldBeEnabled;
}
/*!
Returns the item's image
*/
- (CPImage)image
{
if ([_view respondsToSelector:@selector(image)])
return [_view image];
return _image;
}
/*!
Sets the item's image.
@param anImage the new item image
*/
- (void)setImage:(CPImage)anImage
{
if ([_view respondsToSelector:@selector(setImage:)])
[_view setImage:anImage];
_image = anImage;
if (!_image)
return;
if (_minSize.width === 0 && _minSize.height === 0 &&
_maxSize.width === 0 && _maxSize.height === 0)
{
var imageSize = [_image size];
if (imageSize.width > 0 || imageSize.height > 0)
{
[self setMinSize:imageSize];
[self setMaxSize:imageSize];
}
}
}
/*!
Sets the alternate image. This image is displayed on the item when the user is clicking it.
@param anImage the new alternate image
*/
- (void)setAlternateImage:(CPImage)anImage
{
if ([_view respondsToSelector:@selector(setAlternateImage:)])
[_view setAlternateImage:anImage];
_alternateImage = anImage;
}
/*!
Returns the alternate image. This image is displayed on the item when the user is clicking it.
*/
- (CPImage)alternateImage
{
if ([_view respondsToSelector:@selector(alternateIamge)])
return [_view alternateImage];
return _alternateImage;
}
/*!
Returns the item's view.
*/
- (CPView)view
{
return _view;
}
/*!
Sets the item's view
@param aView the item's new view
*/
- (void)setView:(CPView)aView
{
if (_view == aView)
return;
_view = aView;
if (_view)
{
// Tags get forwarded.
if (_tag !== 0 && [_view respondsToSelector:@selector(setTag:)])
[_view setTag:_tag];
_target = nil;
_action = nil;
}
}
/*!
Returns the item's minimum size.
*/
- (CGSize)minSize
{
return _minSize;
}
/*!
Sets the item's minimum size.
@param aMinSize the new minimum size
*/
- (void)setMinSize:(CGSize)aMinSize
{
if (!aMinSize.height || !aMinSize.width)
return;
_minSize = CGSizeMakeCopy(aMinSize);
// Try to provide some sanity: Make maxSize >= minSize
_maxSize = CGSizeMake(MAX(_minSize.width, _maxSize.width), MAX(_minSize.height, _maxSize.height));
}
/*!
Returns the item's maximum size.
*/
- (CGSize)maxSize
{
return _maxSize;
}
/*!
Sets the item's new maximum size.
@param aMaxSize the new maximum size
*/
- (void)setMaxSize:(CGSize)aMaxSize
{
if (!aMaxSize.height || !aMaxSize.width)
return;
_maxSize = CGSizeMakeCopy(aMaxSize);
// Try to provide some sanity: Make minSize <= maxSize
_minSize = CGSizeMake(MIN(_minSize.width, _maxSize.width), MIN(_minSize.height, _maxSize.height));
}
// Visibility Priority
/*!
Returns the item's visibility priority. The value will be one of:
<pre>
CPToolbarItemVisibilityPriorityStandard
CPToolbarItemVisibilityPriorityLow
CPToolbarItemVisibilityPriorityHigh
CPToolbarItemVisibilityPriorityUser
</pre>
*/
- (int)visibilityPriority
{
return _visibilityPriority;
}
/*!
Sets the item's visibility priority. The value must be one of:
<pre>
CPToolbarItemVisibilityPriorityStandard
CPToolbarItemVisibilityPriorityLow
CPToolbarItemVisibilityPriorityHigh
CPToolbarItemVisibilityPriorityUser
</pre>
@param aVisiblityPriority the priority
*/
- (void)setVisibilityPriority:(int)aVisibilityPriority
{
_visibilityPriority = aVisibilityPriority;
}
- (void)validate
{
var action = [self action],
target = [self target];
// View items do not do any target-action analysis.
if (_view)
{
if ([target respondsToSelector:@selector(validateToolbarItem:)])
{
var shouldBeEnabled = [target validateToolbarItem:self];
if (_isEnabled !== shouldBeEnabled)
[self setEnabled:shouldBeEnabled];
}
return;
}
if (!action)
{
if (_isEnabled)
return [self setEnabled:NO];
return;
}
if (target && ![target respondsToSelector:action])
{
if (_isEnabled)
return [self setEnabled:NO];
return;
}
target = [CPApp targetForAction:action to:target from:self];
if (!target)
{
if (_isEnabled)
return [self setEnabled:NO];
return;
}
if ([target respondsToSelector:@selector(validateToolbarItem:)])
{
var shouldBeEnabled = [target validateToolbarItem:self];
if (_isEnabled !== shouldBeEnabled)
[self setEnabled:shouldBeEnabled];
}
else
{
if (!_isEnabled)
[self setEnabled:YES];
}
}
- (BOOL)autovalidates
{
return _autovalidates;
}
- (void)setAutovalidates:(BOOL)shouldAutovalidate
{
_autovalidates = !!shouldAutovalidate;
}
@end
var CPToolbarItemItemIdentifierKey = @"CPToolbarItemItemIdentifierKey",
CPToolbarItemLabelKey = @"CPToolbarItemLabelKey",
CPToolbarItemPaletteLabelKey = @"CPToolbarItemPaletteLabelKey",
CPToolbarItemToolTipKey = @"CPToolbarItemToolTipKey",
CPToolbarItemTagKey = @"CPToolbarItemTagKey",
CPToolbarItemTargetKey = @"CPToolbarItemTargetKey",
CPToolbarItemActionKey = @"CPToolbarItemActionKey",
CPToolbarItemEnabledKey = @"CPToolbarItemEnabledKey",
CPToolbarItemImageKey = @"CPToolbarItemImageKey",
CPToolbarItemAlternateImageKey = @"CPToolbarItemAlternateImageKey",
CPToolbarItemViewKey = @"CPToolbarItemViewKey",
CPToolbarItemMinSizeKey = @"CPToolbarItemMinSizeKey",
CPToolbarItemMaxSizeKey = @"CPToolbarItemMaxSizeKey",
CPToolbarItemVisibilityPriorityKey = @"CPToolbarItemVisibilityPriorityKey",
CPToolbarItemAutovalidatesKey = @"CPToolbarItemAutovalidatesKey";
@implementation CPToolbarItem (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_itemIdentifier = [aCoder decodeObjectForKey:CPToolbarItemItemIdentifierKey];
_minSize = [aCoder decodeSizeForKey:CPToolbarItemMinSizeKey];
_maxSize = [aCoder decodeSizeForKey:CPToolbarItemMaxSizeKey];
[self setLabel:[aCoder decodeObjectForKey:CPToolbarItemLabelKey]];
[self setPaletteLabel:[aCoder decodeObjectForKey:CPToolbarItemPaletteLabelKey]];
[self setToolTip:[aCoder decodeObjectForKey:CPToolbarItemToolTipKey]];
[self setTag:[aCoder decodeObjectForKey:CPToolbarItemTagKey]];
[self setTarget:[aCoder decodeObjectForKey:CPToolbarItemTargetKey]];
[self setAction:CPSelectorFromString([aCoder decodeObjectForKey:CPToolbarItemActionKey])];
[self setEnabled:[aCoder decodeBoolForKey:CPToolbarItemEnabledKey]];
[self setImage:[aCoder decodeObjectForKey:CPToolbarItemImageKey]];
[self setAlternateImage:[aCoder decodeObjectForKey:CPToolbarItemAlternateImageKey]];
[self setView:[aCoder decodeObjectForKey:CPToolbarItemViewKey]];
[self setVisibilityPriority:[aCoder decodeIntForKey:CPToolbarItemVisibilityPriorityKey]];
[self setAutovalidates:[aCoder decodeBoolForKey:CPToolbarItemAutovalidatesKey]];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_itemIdentifier forKey:CPToolbarItemItemIdentifierKey];
[aCoder encodeObject:[self label] forKey:CPToolbarItemLabelKey];
[aCoder encodeObject:[self paletteLabel] forKey:CPToolbarItemPaletteLabelKey];
[aCoder encodeObject:[self toolTip] forKey:CPToolbarItemToolTipKey];
[aCoder encodeObject:[self tag] forKey:CPToolbarItemTagKey];
[aCoder encodeObject:[self target] forKey:CPToolbarItemTargetKey];
[aCoder encodeObject:[self action] forKey:CPToolbarItemActionKey];
[aCoder encodeObject:[self isEnabled] forKey:CPToolbarItemEnabledKey];
[aCoder encodeObject:[self image] forKey:CPToolbarItemImageKey];
[aCoder encodeObject:[self alternateImage] forKey:CPToolbarItemAlternateImageKey];
[aCoder encodeObject:[self view] forKey:CPToolbarItemViewKey];
[aCoder encodeSize:[self minSize] forKey:CPToolbarItemMinSizeKey];
[aCoder encodeSize:[self maxSize] forKey:CPToolbarItemMaxSizeKey];
[aCoder encodeObject:[self visibilityPriority] forKey:CPToolbarItemVisibilityPriorityKey];
[aCoder encodeBool:[self autovalidates] forKey:CPToolbarItemAutovalidatesKey];
}
@end
@implementation CPToolbarItem (CPCopying)
- (id)copy
{
var copy = [[[self class] alloc] initWithItemIdentifier:_itemIdentifier];
if (_view)
[copy setView:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:_view]]];
[copy _setToolbar:_toolbar];
[copy setLabel:_label];
[copy setPaletteLabel:_paletteLabel];
[copy setToolTip:[self toolTip]];
[copy setTag:[self tag]];
[copy setTarget:[self target]];
[copy setAction:[self action]];
[copy setEnabled:[self isEnabled]];
[copy setImage:[self image]];
[copy setAlternateImage:[self alternateImage]];
[copy setMinSize:_minSize];
[copy setMaxSize:_maxSize];
[copy setVisibilityPriority:[self visibilityPriority]];
[copy setAutovalidates:[self autovalidates]];
return copy;
}
@end
// Standard toolbar identifiers
@implementation CPToolbarItem (Standard)
/* @ignore */
+ (CPToolbarItem)_standardItemWithItemIdentifier:(CPString)anItemIdentifier
{
switch (anItemIdentifier)
{
case CPToolbarSeparatorItemIdentifier: return [_CPToolbarSeparatorItem new];
case CPToolbarSpaceItemIdentifier: return [_CPToolbarSpaceItem new];
case CPToolbarFlexibleSpaceItemIdentifier: return [_CPToolbarFlexibleSpaceItem new];
case CPToolbarShowColorsItemIdentifier: return [_CPToolbarShowColorsItem new];
case CPToolbarShowFontsItemIdentifier: return nil;
case CPToolbarCustomizeToolbarItemIdentifier: return nil;
case CPToolbarPrintItemIdentifier: return nil;
}
return nil;
}
@end
/*@import "_CPToolbarFlexibleSpaceItem.j"
@import "_CPToolbarShowColorsItem.j"
@import "_CPToolbarSeparatorItem.j"
@import "_CPToolbarSpaceItem.j"
*/
+1 -1
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPToolbarItem.j"
@import "_CPToolbarItem.j"
@implementation _CPToolbarSeparatorItem : CPToolbarItem
+1 -1
View File
@@ -21,7 +21,7 @@
*/
@import "CPApplication.j"
@import "CPToolbarItem.j"
@import "_CPToolbarItem.j"
@implementation _CPToolbarShowColorsItem : CPToolbarItem
+1 -1
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPToolbarItem.j"
@import "_CPToolbarItem.j"
@implementation _CPToolbarSpaceItem : CPToolbarItem
+3 -2
View File
@@ -24,6 +24,7 @@
@import "CPNull.j"
@import "_CPCollectionKVCOperators.j"
@class CPIndexSet
@implementation CPObject (CPArrayKVO)
@@ -347,7 +348,7 @@
while ((index = [self indexOfObject:theObject inRange:theRange]) !== CPNotFound)
{
[self removeObjectAtIndex:index];
theRange = CPIntersectionRange(CPMakeRange(index, length - index), theRange);
theRange = CPIntersectionRange(CPMakeRange(index, self.length - index), theRange);
}
}
}
@@ -427,7 +428,7 @@
[CPException raise:CPInvalidArgumentException reason:"called valueForKey: on an array with a complex key (" + aKey + "). use valueForKeyPath:"];
if (aKey === "@count")
return length;
return self.length;
return [self valueForUndefinedKey:aKey];
}
Executable → Regular
+1 -995
View File
@@ -20,999 +20,5 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPEnumerator.j"
@import "CPException.j"
@import "CPObject.j"
@import "CPRange.j"
@import "CPSortDescriptor.j"
CPEnumerationNormal = 0;
CPEnumerationConcurrent = 1 << 0;
CPEnumerationReverse = 1 << 1;
CPBinarySearchingFirstEqual = 1 << 8;
CPBinarySearchingLastEqual = 1 << 9;
CPBinarySearchingInsertionIndex = 1 << 10;
var concat = Array.prototype.concat,
join = Array.prototype.join,
push = Array.prototype.push;
#define FORWARD_TO_CONCRETE_CLASS()\
if (self === _CPSharedPlaceholderArray)\
{\
arguments[0] = [_CPJavaScriptArray alloc];\
return objj_msgSend.apply(this, arguments);\
}\
return [super init];
/*!
@class CPArray
@brief A mutable array backed by a JavaScript Array.
@ingroup foundation
A mutable array class backed by a JavaScript Array.
There is also a CPMutableArray class,
but it is just a child class of this class with an
empty implementation. All mutable functionality is
implemented directly in CPArray.
*/
@implementation CPArray : CPObject
/*!
Returns a new uninitialized CPArray.
*/
+ (id)alloc
{
if (self === CPArray || self === CPMutableArray)
return [_CPPlaceholderArray alloc];
return [super alloc];
}
/*!
Returns a new initialized CPArray.
*/
+ (id)array
{
return [[self alloc] init];
}
/*!
Creates a new array containing the objects in \c anArray.
@param anArray Objects in this array will be added to the new array
@return a new CPArray of the provided objects
*/
+ (id)arrayWithArray:(CPArray)anArray
{
return [[self alloc] initWithArray:anArray];
}
/*!
Creates a new array with \c anObject in it.
@param anObject the object to be added to the array
@return a new CPArray containing a single object
*/
+ (id)arrayWithObject:(id)anObject
{
return [[self alloc] initWithObjects:anObject];
}
/*!
Creates a new CPArray containing all the objects passed as arguments to the method.
@param anObject the objects that will be added to the new array
@return a new CPArray containing the argument objects
*/
+ (id)arrayWithObjects:(id)anObject, ...
{
arguments[0] = [self alloc];
arguments[1] = @selector(initWithObjects:);
return objj_msgSend.apply(this, arguments);
}
/*!
Creates a CPArray from a JavaScript array of objects.
@param objects the JavaScript Array
@param aCount the number of objects in the JS Array
@return a new CPArray containing the specified objects
*/
+ (id)arrayWithObjects:(id)objects count:(unsigned)aCount
{
return [[self alloc] initWithObjects:objects count:aCount];
}
/*!
Initializes the CPArray.
@return the initialized array
*/
- (id)init
{
FORWARD_TO_CONCRETE_CLASS();
}
// Creating an Array
/*!
Creates a new CPArray from \c anArray.
@param anArray objects in this array will be added to the new array
@return a new CPArray containing the objects of \c anArray
*/
- (id)initWithArray:(CPArray)anArray
{
FORWARD_TO_CONCRETE_CLASS();
}
/*!
Initializes a the array with the contents of \c anArray
and optionally performs a deep copy of the objects based on \c copyItems.
@param anArray the array to copy the data from
@param shouldCopyItems if \c YES, each object will be copied by having a \c -copy message
sent to it, and the returned object will be added to the receiver. Otherwise, no copying will be performed.
@return the initialized array of objects
*/
- (id)initWithArray:(CPArray)anArray copyItems:(BOOL)shouldCopyItems
{
FORWARD_TO_CONCRETE_CLASS();
}
/*!
initializes an array with the contents of anArray
*/
- (id)initWithObjects:(id)anObject, ...
{
FORWARD_TO_CONCRETE_CLASS();
}
/*!
Initializes the array with a JavaScript array of objects.
@param objects the array of objects to add to the receiver
@param aCount the number of objects in \c objects
@return the initialized CPArray
*/
- (id)initWithObjects:(id)objects count:(unsigned)aCount
{
FORWARD_TO_CONCRETE_CLASS();
}
// FIXME: This should be defined in CPMutableArray, not here.
- (id)initWithCapacity:(unsigned)aCapacity
{
FORWARD_TO_CONCRETE_CLASS();
}
// Querying an array
/*!
Returns \c YES if the array contains \c anObject. Otherwise, it returns \c NO.
@param anObject the method checks if this object is already in the array
*/
- (BOOL)containsObject:(id)anObject
{
return [self indexOfObject:anObject] !== CPNotFound;
}
- (BOOL)containsObjectIdenticalTo:(id)anObject
{
return [self indexOfObjectIdenticalTo:anObject] !== CPNotFound;
}
/*!
Returns the number of elements in the array
*/
- (int)count
{
_CPRaiseInvalidAbstractInvocation(self, _cmd);
}
/*!
Returns the first object in the array. If the array is empty, returns \c nil
*/
- (id)firstObject
{
var count = [self count];
if (count > 0)
return [self objectAtIndex:0];
return nil;
}
/*!
Returns the last object in the array. If the array is empty, returns \c nil
*/
- (id)lastObject
{
var count = [self count];
if (count <= 0)
return nil;
return [self objectAtIndex:count - 1];
}
/*!
Returns the object at index \c anIndex.
@throws CPRangeException if \c anIndex is out of bounds
*/
- (id)objectAtIndex:(int)anIndex
{
_CPRaiseInvalidAbstractInvocation(self, _cmd);
}
/*!
Returns the objects at \c indexes in a new CPArray.
@param indexes the set of indices
@throws CPRangeException if any of the indices is greater than or equal to the length of the array
*/
- (CPArray)objectsAtIndexes:(CPIndexSet)indexes
{
var index = CPNotFound,
objects = [];
while ((index = [indexes indexGreaterThanIndex:index]) !== CPNotFound)
objects.push([self objectAtIndex:index]);
return objects;
}
/*!
Returns an enumerator describing the array sequentially
from the first to the last element. You should not modify
the array during enumeration.
*/
- (CPEnumerator)objectEnumerator
{
return [[_CPArrayEnumerator alloc] initWithArray:self];
}
/*!
Returns an enumerator describing the array sequentially
from the last to the first element. You should not modify
the array during enumeration.
*/
- (CPEnumerator)reverseObjectEnumerator
{
return [[_CPReverseArrayEnumerator alloc] initWithArray:self];
}
/*!
Returns the index of \c anObject in this array.
If the object is not in the array,
returns \c CPNotFound. It first attempts to find
a match using \c -isEqual:, then \c ===.
@param anObject the object to search for
*/
- (CPUInteger)indexOfObject:(id)anObject
{
return [self indexOfObject:anObject inRange:nil];
}
/*!
Returns the index of \c anObject in the array
within \c aRange. It first attempts to find
a match using \c -isEqual:, then \c ===.
@param anObject the object to search for
@param aRange the range to search within
@return the index of the object, or \c CPNotFound if it was not found.
*/
- (CPUInteger)indexOfObject:(id)anObject inRange:(CPRange)aRange
{
// Only use isEqual: if our object is a CPObject.
if (anObject && anObject.isa)
{
var index = aRange ? aRange.location : 0,
count = aRange ? CPMaxRange(aRange) : [self count];
for (; index < count; ++index)
if ([[self objectAtIndex:index] isEqual:anObject])
return index;
return CPNotFound;
}
return [self indexOfObjectIdenticalTo:anObject inRange:aRange];
}
/*!
Returns the index of \c anObject in the array. The test for equality is done using only \c ===.
@param anObject the object to search for
@return the index of the object in the array. \c CPNotFound if the object is not in the array.
*/
- (CPUInteger)indexOfObjectIdenticalTo:(id)anObject
{
return [self indexOfObjectIdenticalTo:anObject inRange:nil];
}
/*!
Returns the index of \c anObject in the array
within \c aRange. The test for equality is
done using only \c ==.
@param anObject the object to search for
@param aRange the range to search within
@return the index of the object, or \c CPNotFound if it was not found.
*/
- (CPUInteger)indexOfObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
{
var index = aRange ? aRange.location : 0,
count = aRange ? CPMaxRange(aRange) : [self count];
for (; index < count; ++index)
if ([self objectAtIndex:index] === anObject)
return index;
return CPNotFound;
}
/*!
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return \c CPNotFound to the sender.
@return The index of the first matching object, or \c CPNotFound if there is no matching object.
*/
- (unsigned)indexOfObjectPassingTest:(Function /*(id anObject, int idx)*/)aPredicate
{
return [self indexOfObjectWithOptions:CPEnumerationNormal passingTest:aPredicate context:undefined];
}
/*!
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index, context) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return \c CPNotFound to the sender.
@param context An object that contains context information you want passed to the predicate function.
@return The index of the first matching object, or \c CPNotFound if there is no matching object.
*/
- (unsigned)indexOfObjectPassingTest:(Function /*(id anObject, int idx, id context)*/)aPredicate context:(id)aContext
{
return [self indexOfObjectWithOptions:CPEnumerationNormal passingTest:aPredicate context:aContext];
}
/*!
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
@param options Specifies the direction in which the array is searched. Pass CPEnumerationNormal to search forwards
or CPEnumerationReverse to search in reverse.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return CPNotFound to the sender.
@return The index of the first matching object, or \c CPNotFound if there is no matching object.
*/
- (unsigned)indexOfObjectWithOptions:(CPEnumerationOptions)options passingTest:(Function /*(id anObject, int idx)*/)aPredicate
{
return [self indexOfObjectWithOptions:options passingTest:aPredicate context:undefined];
}
/*!
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
@param options Specifies the direction in which the array is searched. Pass CPEnumerationNormal to search forwards
or CPEnumerationReverse to search in reverse.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index, context) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return CPNotFound to the sender.
@param context An object that contains context information you want passed to the predicate function.
@return The index of the first matching object, or \c CPNotFound if there is no matching object.
*/
- (unsigned)indexOfObjectWithOptions:(CPEnumerationOptions)options passingTest:(Function /*(id anObject, int idx, id context)*/)aPredicate context:(id)aContext
{
// We don't use an enumerator because they return nil to indicate end of enumeration,
// but nil may actually be the value we are looking for, so we have to loop over the array.
if (options & CPEnumerationReverse)
{
var index = [self count] - 1,
stop = -1,
increment = -1;
}
else
{
var index = 0,
stop = [self count],
increment = 1;
}
for (; index !== stop; index += increment)
if (aPredicate([self objectAtIndex:index], index, aContext))
return index;
return CPNotFound;
}
- (CPUInteger)indexOfObject:(id)anObject
inSortedRange:(CPRange)aRange
options:(CPBinarySearchingOptions)options
usingComparator:(Function)aComparator
{
// FIXME: comparator is not a function
if (!aComparator)
_CPRaiseInvalidArgumentException(self, _cmd, "comparator is nil");
if ((options & CPBinarySearchingFirstEqual) && (options & CPBinarySearchingLastEqual))
_CPRaiseInvalidArgumentException(self, _cmd,
"both CPBinarySearchingFirstEqual and CPBinarySearchingLastEqual options cannot be specified");
var count = [self count];
if (count <= 0)
return (options & CPBinarySearchingInsertionIndex) ? 0 : CPNotFound;
var first = aRange ? aRange.location : 0,
last = (aRange ? CPMaxRange(aRange) : [self count]) - 1;
if (first < 0)
_CPRaiseRangeException(self, _cmd, first, count);
if (last >= count)
_CPRaiseRangeException(self, _cmd, last, count);
while (first <= last)
{
var middle = FLOOR((first + last) / 2),
result = aComparator(anObject, [self objectAtIndex:middle]);
if (result > 0)
first = middle + 1;
else if (result < 0)
last = middle - 1;
else
{
if (options & CPBinarySearchingFirstEqual)
while (middle > first && aComparator(anObject, [self objectAtIndex:middle - 1]) === CPOrderedSame)
--middle;
else if (options & CPBinarySearchingLastEqual)
{
while (middle < last && aComparator(anObject, [self objectAtIndex:middle + 1]) === CPOrderedSame)
++middle;
if (options & CPBinarySearchingInsertionIndex)
++middle;
}
return middle;
}
}
if (options & CPBinarySearchingInsertionIndex)
return MAX(first, 0);
return CPNotFound;
}
/*!
Returns the indexes of the objects in the receiver that pass a test in a given Javascript function.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return \c CPNotFound to the sender.
@return A CPIndexSet of the matching object indexes.
*/
- (CPIndexSet)indexesOfObjectsPassingTest:(Function /*(id anObject, int idx)*/)aPredicate
{
return [self indexesOfObjectsWithOptions:CPEnumerationNormal passingTest:aPredicate context:undefined];
}
/*!
Returns the indexes of the objects in the receiver that pass a test in a given Javascript function.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index, context) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return \c CPNotFound to the sender.
@param context An object that contains context information you want passed to the predicate function.
@return A CPIndexSet of the matching object indexes.
*/
- (CPIndexSet)indexesOfObjectsPassingTest:(Function /*(id anObject, int idx, id context)*/)aPredicate context:(id)aContext
{
return [self indexesOfObjectsWithOptions:CPEnumerationNormal passingTest:aPredicate context:aContext];
}
/*!
Returns the indexes of the objects in the receiver that pass a test in a given Javascript function.
@param options Specifies the direction in which the array is searched. Pass CPEnumerationNormal to search forwards
or CPEnumerationReverse to search in reverse.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return CPNotFound to the sender.
@return A CPIndexSet of the matching object indexes.
*/
- (CPIndexSet)indexesOfObjectsWithOptions:(CPEnumerationOptions)options passingTest:(Function /*(id anObject, int idx)*/)aPredicate
{
return [self indexesOfObjectsWithOptions:options passingTest:aPredicate context:undefined];
}
/*!
Returns the indexes of the objects in the receiver that pass a test in a given Javascript function.
@param options Specifies the direction in which the array is searched. Pass CPEnumerationNormal to search forwards
or CPEnumerationReverse to search in reverse.
@param predicate The function to apply to objects of the array. The function should have the signature:
@code function(object, index, context) @endcode
The predicate function should either return a Boolean value that indicates whether the object passed the test,
or nil to stop the search, which will return CPNotFound to the sender.
@param context An object that contains context information you want passed to the predicate function.
@return A CPIndexSet of the matching object indexes.
*/
- (CPIndexSet)indexesOfObjectsWithOptions:(CPEnumerationOptions)options passingTest:(Function /*(id anObject, int idx, id context)*/)aPredicate context:(id)aContext
{
// We don't use an enumerator because they return nil to indicate end of enumeration,
// but nil may actually be the value we are looking for, so we have to loop over the array.
if (options & CPEnumerationReverse)
{
var index = [self count] - 1,
stop = -1,
increment = -1;
}
else
{
var index = 0,
stop = [self count],
increment = 1;
}
var indexes = [CPIndexSet indexSet];
for (; index !== stop; index += increment)
if (aPredicate([self objectAtIndex:index], index, aContext))
[indexes addIndex:index];
return indexes;
}
// Sending messages to elements
/*!
Sends each element in the array a message.
@param aSelector the selector of the message to send
@throws CPInvalidArgumentException if \c aSelector is \c nil
*/
- (void)makeObjectsPerformSelector:(SEL)aSelector
{
[self makeObjectsPerformSelector:aSelector withObjects:nil];
}
/*!
Sends each element in the array a message with an argument.
@param aSelector the selector of the message to send
@param anObject the first argument of the message
@throws CPInvalidArgumentException if \c aSelector is \c nil
*/
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject
{
return [self makeObjectsPerformSelector:aSelector withObjects:[anObject]];
}
- (void)makeObjectsPerformSelector:(SEL)aSelector withObjects:(CPArray)objects
{
if (!aSelector)
[CPException raise:CPInvalidArgumentException
reason:"makeObjectsPerformSelector:withObjects: 'aSelector' can't be nil"];
var index = 0,
count = [self count];
if ([objects count])
{
var argumentsArray = [[nil, aSelector] arrayByAddingObjectsFromArray:objects];
for (; index < count; ++index)
{
argumentsArray[0] = [self objectAtIndex:index];
objj_msgSend.apply(this, argumentsArray);
}
}
else
for (; index < count; ++index)
objj_msgSend([self objectAtIndex:index], aSelector);
}
- (void)enumerateObjectsUsingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
{
// This could have been [self enumerateObjectsWithOptions:CPEnumerationNormal usingBlock:aFunction]
// but this method should be as fast as possible.
var index = 0,
count = [self count],
shouldStop = NO,
shouldStopRef = AT_REF(shouldStop);
for (; index < count; ++index)
{
aFunction([self objectAtIndex:index], index, shouldStopRef);
if (shouldStop)
return;
}
}
- (void)enumerateObjectsWithOptions:(CPEnumerationOptions)options usingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
{
var shouldStop = NO;
if (options & CPEnumerationReverse)
{
var index = [self count] - 1,
stop = -1,
increment = -1;
}
else
{
var index = 0,
stop = [self count],
increment = 1;
}
for (; index !== stop; index += increment)
{
aFunction([self objectAtIndex:index], index, AT_REF(shouldStop));
if (shouldStop)
return;
}
}
// Comparing arrays
/*!
Returns the first object found in the receiver (starting at index 0) which is present in the
\c otherArray as determined by using the \c -containsObject: method.
@return the first object found, or \c nil if no common object was found.
*/
- (id)firstObjectCommonWithArray:(CPArray)anArray
{
var count = [self count];
if (![anArray count] || !count)
return nil;
var index = 0;
for (; index < count; ++index)
{
var object = [self objectAtIndex:index];
if ([anArray containsObject:object])
return object;
}
return nil;
}
/*!
Returns true if anArray contains exactly the same objects as the receiver.
*/
- (BOOL)isEqualToArray:(id)anArray
{
if (self === anArray)
return YES;
if (![anArray isKindOfClass:CPArray])
return NO;
var count = [self count],
otherCount = [anArray count];
if (anArray === nil || count !== otherCount)
return NO;
var index = 0;
for (; index < count; ++index)
{
var lhs = [self objectAtIndex:index],
rhs = [anArray objectAtIndex:index];
// If they're not equal, and either doesn't have an isa, or they're !isEqual (not isEqual)
if (lhs !== rhs && (lhs && !lhs.isa || rhs && !rhs.isa || ![lhs isEqual:rhs]))
return NO;
}
return YES;
}
- (BOOL)isEqual:(id)anObject
{
return (self === anObject) || [self isEqualToArray:anObject];
}
- (Array)_javaScriptArrayCopy
{
var index = 0,
count = [self count],
copy = [];
for (; index < count; ++index)
push.call(copy, [self objectAtIndex:index]);
return copy;
}
// Deriving new arrays
/*!
Returns a copy of this array plus \c anObject inside the copy.
@param anObject the object to be added to the array copy
@throws CPInvalidArgumentException if \c anObject is \c nil
@return a new array that should be n+1 in size compared to the receiver.
*/
- (CPArray)arrayByAddingObject:(id)anObject
{
var argumentArray = [self _javaScriptArrayCopy];
// We push instead of concat,because concat flattens arrays, so if the object
// passed in is an array, we end up with its contents added instead of itself.
push.call(argumentArray, anObject);
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
}
/*!
Returns a new array which is the concatenation of \c self and otherArray (in this precise order).
@param anArray the array that will be concatenated to the receiver's copy
*/
- (CPArray)arrayByAddingObjectsFromArray:(CPArray)anArray
{
if (!anArray)
return [self copy];
var anArray = anArray.isa === _CPJavaScriptArray ? anArray : [anArray _javaScriptArrayCopy],
argumentArray = concat.call([self _javaScriptArrayCopy], anArray);
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
}
/*
- (CPArray)filteredArrayUsingPredicate:(CPPredicate)aPredicate
{
var i= 0,
count = [self count],
array = [CPArray array];
for (; i<count; ++i)
if (aPredicate.evaluateWithObject(self[i]))
array.push(self[i]);
return array;
}
*/
/*!
Returns a subarray of the receiver containing the objects found in the specified range \c aRange.
@param aRange the range of objects to be copied into the subarray
@throws CPRangeException if the specified range exceeds the bounds of the array
*/
- (CPArray)subarrayWithRange:(CPRange)aRange
{
if (!aRange)
return [self copy];
if (aRange.location < 0 || CPMaxRange(aRange) > self.length)
[CPException raise:CPRangeException reason:"subarrayWithRange: aRange out of bounds"];
var index = aRange.location,
count = CPMaxRange(aRange),
argumentArray = [];
for (; index < count; ++index)
push.call(argumentArray, [self objectAtIndex:index]);
return objj_msgSend([self class], @selector(arrayWithArray:), argumentArray);
}
// Sorting arrays
/*
Not yet described.
*/
- (CPArray)sortedArrayUsingDescriptors:(CPArray)descriptors
{
var sorted = [self copy];
[sorted sortUsingDescriptors:descriptors];
return sorted;
}
/*!
Return a copy of the receiver sorted using the function passed into the first parameter.
*/
- (CPArray)sortedArrayUsingFunction:(Function)aFunction
{
return [self sortedArrayUsingFunction:aFunction context:nil];
}
/*!
Returns an array in which the objects are ordered according
to a sort with \c aFunction. This invokes
\c -sortUsingFunction:context.
@param aFunction a JavaScript 'Function' type that compares objects
@param aContext context information
@return a new sorted array
*/
- (CPArray)sortedArrayUsingFunction:(Function)aFunction context:(id)aContext
{
var sorted = [self copy];
[sorted sortUsingFunction:aFunction context:aContext];
return sorted;
}
/*!
Returns a new array in which the objects are ordered according to a sort with \c aSelector.
@param aSelector the selector that will perform object comparisons
*/
- (CPArray)sortedArrayUsingSelector:(SEL)aSelector
{
var sorted = [self copy];
[sorted sortUsingSelector:aSelector];
return sorted;
}
// Working with string elements
/*!
Returns a string formed by concatenating the objects in the
receiver, with the specified separator string inserted between each part.
If the element is a Objective-J object, then the \c -description
of that object will be used, otherwise the default JavaScript representation will be used.
@param aString the separator that will separate each object string
@return the string representation of the array
*/
- (CPString)componentsJoinedByString:(CPString)aString
{
return join.call([self _javaScriptArrayCopy], aString);
}
// Creating a description of the array
/*!
Returns a human readable description of this array and it's elements.
*/
- (CPString)description
{
var index = 0,
count = [self count],
description = "@[";
for (; index < count; ++index)
{
if (index === 0)
description += "\n\t";
var object = [self objectAtIndex:index];
description += CPDescriptionOfObject(object);
if (index !== count - 1)
description += ",\n\t";
else
description += "\n";
}
return description + "]";
}
// Collecting paths
/*!
Returns a new array subset formed by selecting the elements that have
filename extensions from \c filterTypes. Only elements
that are of type CPString are candidates for inclusion in the returned array.
@param filterTypes an array of CPString objects that contain file extensions (without the '.')
@return a new array with matching paths
*/
- (CPArray)pathsMatchingExtensions:(CPArray)filterTypes
{
var index = 0,
count = [self count],
array = [];
for (; index < count; ++index)
if (self[index].isa && [self[index] isKindOfClass:[CPString class]] && [filterTypes containsObject:[self[index] pathExtension]])
array.push(self[index]);
return array;
}
// Copying arrays
/*!
Makes a copy of the receiver.
@return a new CPArray copy
*/
- (id)copy
{
return [[self class] arrayWithArray:self];
}
@end
@implementation CPArray (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
return [aCoder decodeObjectForKey:@"CP.objects"];
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder _encodeArrayOfObjects:self forKey:@"CP.objects"];
}
@end
/* @ignore */
@implementation _CPArrayEnumerator : CPEnumerator
{
CPArray _array;
int _index;
}
- (id)initWithArray:(CPArray)anArray
{
self = [super init];
if (self)
{
_array = anArray;
_index = -1;
}
return self;
}
- (id)nextObject
{
if (++_index >= [_array count])
return nil;
return [_array objectAtIndex:_index];
}
@end
/* @ignore */
@implementation _CPReverseArrayEnumerator : CPEnumerator
{
CPArray _array;
int _index;
}
- (id)initWithArray:(CPArray)anArray
{
self = [super init];
if (self)
{
_array = anArray;
_index = [_array count];
}
return self;
}
- (id)nextObject
{
if (--_index < 0)
return nil;
return [_array objectAtIndex:_index];
}
@end
var _CPSharedPlaceholderArray = nil;
@implementation _CPPlaceholderArray : CPArray
{
}
+ (id)alloc
{
if (!_CPSharedPlaceholderArray)
_CPSharedPlaceholderArray = [super alloc];
return _CPSharedPlaceholderArray;
}
@end
@import "_CPArray.j"
@import "_CPJavaScriptArray.j"
+4 -3
View File
@@ -1,6 +1,7 @@
@import "CPArray.j"
@import "_CPArray.j"
@class CPIndexSet
/*!
@class CPMutableArray
@@ -217,7 +218,7 @@
*/
- (void)removeObject:(id)anObject
{
[self removeObject:anObject inRange:CPMakeRange(0, length)];
[self removeObject:anObject inRange:CPMakeRange(0, self.length)];
}
/*!
@@ -232,7 +233,7 @@
while ((index = [self indexOfObject:anObject inRange:aRange]) != CPNotFound)
{
[self removeObjectAtIndex:index];
aRange = CPIntersectionRange(CPMakeRange(index, length - index), aRange);
aRange = CPIntersectionRange(CPMakeRange(index, self.length - index), aRange);
}
}
+1020
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -826,7 +826,7 @@ var copyRangeEntry = function copyRangeEntry(/*RangeEntry*/aRangeEntry)
return makeRangeEntry(CPMakeRangeCopy(aRangeEntry.range), [aRangeEntry.attributes copy]);
};
var splitRangeEntry = function splitRangeEntryAtIndex(/*RangeEntry*/aRangeEntry, /*unsigned*/anIndex)
var splitRangeEntryAtIndex = function splitRangeEntryAtIndex(/*RangeEntry*/aRangeEntry, /*unsigned*/anIndex)
{
var newRangeEntry = copyRangeEntry(aRangeEntry),
cachedIndex = CPMaxRange(aRangeEntry.range);
+2 -2
View File
@@ -237,8 +237,8 @@ var CPCharacterSetInvertedKey = @"CPCharacterSetInvertedKey";
- (BOOL)characterIsMember:(CPString)aCharacter
{
c = aCharacter.charCodeAt(0);
var enu = [_ranges objectEnumerator],
var c = aCharacter.charCodeAt(0),
enu = [_ranges objectEnumerator],
range;
while ((range = [enu nextObject]) !== nil)
+2
View File
@@ -23,6 +23,8 @@
@import "CPException.j"
@import "CPObject.j"
@global _CPRaiseInvalidAbstractInvocation;
/*!
@class CPCoder
@ingroup foundation
+1 -1
View File
@@ -21,7 +21,7 @@
*/
@import "CPObject.j"
@import "CPSet.j"
@import "_CPConcreteMutableSet.j"
/*!
@class CPCountedSet
+5 -5
View File
@@ -22,9 +22,9 @@
#import "Ref.h"
@import <Foundation/CPDate.j>
@import <Foundation/CPString.j>
@import <Foundation/CPFormatter.j>
@import "CPDate.j"
@import "CPString.j"
@import "CPFormatter.j"
CPDateFormatterNoStyle = 0;
CPDateFormatterShortStyle = 1;
@@ -78,9 +78,9 @@ CPDateFormatterFullStyle = 4;
{
case CPDateFormatterShortStyle:
var format = "d/m/Y";
return Date.parseDate(string, format);
return Date.parseDate(aString, format);
default:
return Date.parseDate(string);
return Date.parseDate(aString);
}
}
+30 -23
View File
@@ -322,7 +322,7 @@
*/
- (int)count
{
return _count;
return self._count;
}
/*!
@@ -330,7 +330,7 @@
*/
- (CPArray)allKeys
{
return [_keys copy];
return [self._keys copy];
}
/*!
@@ -338,11 +338,12 @@
*/
- (CPArray)allValues
{
var index = _keys.length,
var keys = self._keys,
index = keys.length,
values = [];
while (index--)
values.push(self.valueForKey(_keys[index]));
values.push(self.valueForKey(keys[index]));
return values;
}
@@ -357,7 +358,8 @@
*/
- (CPArray)allKeysForObject:(id)anObject
{
var count = _keys.length,
var keys = self._keys,
count = keys.length,
index = 0,
matchingKeys = [],
key = nil,
@@ -365,8 +367,8 @@
for (; index < count; ++index)
{
key = _keys[index];
value = _buckets[key];
key = keys[index];
value = self._buckets[key];
if (value.isa && anObject && anObject.isa && [value respondsToSelector:@selector(isEqual:)] && [value isEqual:anObject])
matchingKeys.push(key);
@@ -384,16 +386,18 @@
- (CPArray)keysOfEntriesWithOptions:(CPEnumerationOptions)options passingTest:(Function /*(id key, id obj, @ref BOOL stop)*/)predicate
{
var keys = self._keys;
if (options & CPEnumerationReverse)
{
var index = [_keys count] - 1,
var index = [keys count] - 1,
stop = -1,
increment = -1;
}
else
{
var index = 0,
stop = [_keys count],
stop = [keys count],
increment = 1;
}
@@ -405,8 +409,8 @@
for (; index !== stop; index += increment)
{
key = _keys[index];
value = _buckets[key];
key = keys[index];
value = self._buckets[key];
if (predicate(key, value, stopRef))
matchingKeys.push(key);
@@ -447,7 +451,7 @@
*/
- (CPEnumerator)keyEnumerator
{
return [_keys objectEnumerator];
return [self._keys objectEnumerator];
}
/*!
@@ -471,12 +475,13 @@
if (count !== [aDictionary count])
return NO;
var index = count;
var index = count,
keys = self._keys;
while (index--)
{
var currentKey = _keys[index],
lhsObject = _buckets[currentKey],
var currentKey = keys[index],
lhsObject = self._buckets[currentKey],
rhsObject = aDictionary._buckets[currentKey];
if (lhsObject === rhsObject)
@@ -532,7 +537,7 @@
*/
- (id)objectForKey:(id)aKey
{
var object = _buckets[aKey];
var object = self._buckets[aKey];
return (object === undefined) ? nil : object;
}
@@ -634,14 +639,14 @@
- (CPString)description
{
var string = "@{\n",
keys = _keys,
keys = self._keys,
index = 0,
count = _count;
count = self._count;
for (; index < count; ++index)
{
var key = keys[index],
value = valueForKey(key);
value = self.valueForKey(key);
string += "\t" + key + ": " + CPDescriptionOfObject(value).split('\n').join("\n\t") + ",\n";
}
@@ -658,12 +663,14 @@
- (void)enumerateKeysAndObjectsUsingBlock:(Function /*(id aKey, id anObject, @ref BOOL stop)*/)aFunction
{
var shouldStop = NO,
shouldStopRef = AT_REF(shouldStop);
shouldStopRef = AT_REF(shouldStop),
keys = self._keys,
count = self._count;
for (var index = 0; index < _count; index++)
for (var index = 0; index < count; index++)
{
var key = _keys[index],
value = valueForKey(key);
var key = keys[index],
value = self.valueForKey(key);
aFunction(key, value, shouldStopRef);
+3
View File
@@ -28,6 +28,7 @@ CPInvalidArgumentException = @"CPInvalidArgumentException";
CPUnsupportedMethodException = @"CPUnsupportedMethodException";
CPRangeException = @"CPRangeException";
CPInternalInconsistencyException = @"CPInternalInconsistencyException";
CPGenericException = @"CPGenericException";
/*!
@class CPException
@@ -46,6 +47,8 @@ if (input == nil)
@implementation CPException : CPObject
{
id _userInfo;
CPString name;
CPString message;
}
/*
+5 -5
View File
@@ -33,8 +33,8 @@ var CPArchiverReplacementClassNames = nil;
var _CPKeyedArchiverDidEncodeObjectSelector = 1,
_CPKeyedArchiverWillEncodeObjectSelector = 2,
_CPKeyedArchiverWillReplaceObjectWithObjectSelector = 4,
_CPKeyedArchiverDidFinishSelector = 8,
_CPKeyedArchiverWillFinishSelector = 16;
_CPKeyedArchiverDidFinishEncodingSelector = 8,
_CPKeyedArchiverWillFinishEncodingSelector = 16;
var _CPKeyedArchiverNullString = "$null",
_CPKeyedArchiverNullReference = nil,
@@ -190,7 +190,7 @@ var _CPKeyedArchiverStringClass = Nil,
*/
- (void)finishEncoding
{
if (_delegate && _delegateSelectors & _CPKeyedArchiverWillFinishSelector)
if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishEncodingSelector)
[_delegate archiverWillFinish:self];
var i = 0,
@@ -220,7 +220,7 @@ var _CPKeyedArchiverStringClass = Nil,
[_data setPlistObject:_plistObject];
if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishSelector)
if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishEncodingSelector)
[_delegate archiverDidFinish:self];
}
@@ -460,7 +460,7 @@ var _CPKeyedArchiverStringClass = Nil,
if (!_replacementClassNames)
return aClass.name;
var className = [_replacementClassNames objectForKey:CPStringFromClass(aClassName)];
var className = [_replacementClassNames objectForKey:CPStringFromClass(aClass)];
return className ? className : aClass.name;
}
+1 -1
View File
@@ -417,7 +417,7 @@ var CPArrayClass = Ni
_delegateSelectors |= _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector;
if ([_delegate respondsToSelector:@selector(unarchiverWillFinish:)])
_delegateSelectors |= _CPKeyedUnarchiverWilFinishSelector;
_delegateSelectors |= _CPKeyedUnarchiverWillFinishSelector;
if ([_delegate respondsToSelector:@selector(unarchiverDidFinish:)])
_delegateSelectors |= _CPKeyedUnarchiverDidFinishSelector;
Loaded 100 of 187 files, more files were not shown because too many files have changed in this diff. Show more