mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-10 12:47:13 +00:00
Compare commits
238
Commits
v0.9.5
...
v0.9.6-RC1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
099ee1e249 | ||
|
|
aba7fd5527 | ||
|
|
68c794bf9d | ||
|
|
ca9b3a7dbf | ||
|
|
4eba585286 | ||
|
|
4172ecfdf2 | ||
|
|
da80176935 | ||
|
|
f50802b85b | ||
|
|
5351bf7e12 | ||
|
|
96a038559e | ||
|
|
c321084990 | ||
|
|
e13d070439 | ||
|
|
1a8fc7f07f | ||
|
|
9ef95e1f68 | ||
|
|
28ed2f9bd0 | ||
|
|
93f51eaa42 | ||
|
|
7c807dd887 | ||
|
|
429b42d3e0 | ||
|
|
08f013171e | ||
|
|
d620032d0d | ||
|
|
3bc5605633 | ||
|
|
3a0068186a | ||
|
|
e19a782954 | ||
|
|
88783efa7b | ||
|
|
a249588f52 | ||
|
|
2951a83e73 | ||
|
|
b99ece088d | ||
|
|
ebd797d6d7 | ||
|
|
fa7a68f3f8 | ||
|
|
8167c46cfc | ||
|
|
9456810c7e | ||
|
|
79f2ec5d17 | ||
|
|
38a0a261c0 | ||
|
|
91eb23ba87 | ||
|
|
706129bcbd | ||
|
|
97b77e9b7b | ||
|
|
3b85a67faf | ||
|
|
f2571e6536 | ||
|
|
bec8a4b1c6 | ||
|
|
028fb03ef1 | ||
|
|
65aa08a9d9 | ||
|
|
22058a7a93 | ||
|
|
90514bd3cb | ||
|
|
bd7d258fcd | ||
|
|
c21e40e819 | ||
|
|
e0c8ae6335 | ||
|
|
e9d5d33cb2 | ||
|
|
0d9b49df85 | ||
|
|
db5e5d7da6 | ||
|
|
44236795b5 | ||
|
|
a26bca5dbe | ||
|
|
872b446695 | ||
|
|
2b0ed8234c | ||
|
|
39ec1cfd27 | ||
|
|
b7dcd24e11 | ||
|
|
5097030143 | ||
|
|
516fac037f | ||
|
|
1bf632a575 | ||
|
|
6137aa8637 | ||
|
|
4be4506ffc | ||
|
|
d3c368ba92 | ||
|
|
9b0d03b024 | ||
|
|
c21d2fd017 | ||
|
|
2940b5e787 | ||
|
|
cf18bcaaf9 | ||
|
|
c4eaf083b4 | ||
|
|
df6b592d11 | ||
|
|
109e8b1e33 | ||
|
|
85c88d7c93 | ||
|
|
d8e5fa3087 | ||
|
|
697a7b308a | ||
|
|
dcc031f23a | ||
|
|
061ea47953 | ||
|
|
f0e5161b7b | ||
|
|
eada36af26 | ||
|
|
a02c687df9 | ||
|
|
e636087f4a | ||
|
|
4876f77914 | ||
|
|
ed6bed9bf7 | ||
|
|
87cb2eb19d | ||
|
|
53334251b8 | ||
|
|
a069f2945b | ||
|
|
5a0e1d7bb3 | ||
|
|
ed1d77c86d | ||
|
|
74054442a2 | ||
|
|
59ef8329c0 | ||
|
|
20cffaa7fe | ||
|
|
ebeb1040e8 | ||
|
|
cdb919dea3 | ||
|
|
c509e6131a | ||
|
|
db6a4d7042 | ||
|
|
a32b5ea72b | ||
|
|
58a2fce110 | ||
|
|
3d9ae42dbf | ||
|
|
c4a16d10bc | ||
|
|
eeca40c6f0 | ||
|
|
2a031e82a4 | ||
|
|
0e6ce205ab | ||
|
|
9acbe0f2f8 | ||
|
|
3ee9c1a439 | ||
|
|
0eeff20af6 | ||
|
|
a1cf9f1cd4 | ||
|
|
3897f422fe | ||
|
|
9d785d1a3c | ||
|
|
66f818872c | ||
|
|
342bacb25c | ||
|
|
8e81be0319 | ||
|
|
3acfa142bc | ||
|
|
94a58c810e | ||
|
|
757a2bf400 | ||
|
|
b18fbd685b | ||
|
|
56b5a9ec22 | ||
|
|
70432f0198 | ||
|
|
0736f86f32 | ||
|
|
107d739489 | ||
|
|
32a86a911f | ||
|
|
9a32733f88 | ||
|
|
0f655e3264 | ||
|
|
55a4afa341 | ||
|
|
3b5aa1a2ab | ||
|
|
658e569251 | ||
|
|
4eacfd83d6 | ||
|
|
ad0fd0a34e | ||
|
|
1d8092e431 | ||
|
|
87cc62d1d8 | ||
|
|
a16388b57d | ||
|
|
98e54d2e09 | ||
|
|
bd02ec057c | ||
|
|
6ac804d37c | ||
|
|
4b764dc8b4 | ||
|
|
3a8ad56d4b | ||
|
|
f5bee48d98 | ||
|
|
24fbfbee60 | ||
|
|
a1bc5ad4d3 | ||
|
|
4aa3824a2a | ||
|
|
37d92c1182 | ||
|
|
a0eadc6c4a | ||
|
|
fdf672cf0a | ||
|
|
b8dacb1ffa | ||
|
|
81a99dd190 | ||
|
|
6a42d601c5 | ||
|
|
59ce74a3df | ||
|
|
eacee00fc8 | ||
|
|
fe70a5541e | ||
|
|
c9d4089b9a | ||
|
|
8fdb872605 | ||
|
|
8b28041cf0 | ||
|
|
4d3f8c3c8c | ||
|
|
f8cb4a15cb | ||
|
|
dd7d36da43 | ||
|
|
12201d38f3 | ||
|
|
3b4ad1d583 | ||
|
|
d44df8a9da | ||
|
|
ab88f72827 | ||
|
|
75a00e8c4a | ||
|
|
76c5500488 | ||
|
|
8cb7c05c88 | ||
|
|
e081dbf127 | ||
|
|
71e8f0201a | ||
|
|
c9ecb20b50 | ||
|
|
7dc213995c | ||
|
|
bea34a9b35 | ||
|
|
5ae405a89b | ||
|
|
66fcbe7871 | ||
|
|
b27a3cdbe5 | ||
|
|
9d7b822409 | ||
|
|
ab3f260757 | ||
|
|
b26b0a321b | ||
|
|
9536858599 | ||
|
|
c7d3ccb13a | ||
|
|
a081f98fd1 | ||
|
|
7096ea549e | ||
|
|
8e007985a1 | ||
|
|
e03e774113 | ||
|
|
7a41282912 | ||
|
|
c8f8c01d2f | ||
|
|
7f6db7bf98 | ||
|
|
e058efb622 | ||
|
|
c14643849f | ||
|
|
edd09ef06a | ||
|
|
d06fccf157 | ||
|
|
6bc3d49ba2 | ||
|
|
a8d8736899 | ||
|
|
b1e4a43cd3 | ||
|
|
eafbebcebb | ||
|
|
0c72c52ba2 | ||
|
|
e8194d9c2e | ||
|
|
f0e1b67197 | ||
|
|
7ba27cf617 | ||
|
|
c9f765645c | ||
|
|
5daa8cb289 | ||
|
|
789d832808 | ||
|
|
d7971322cb | ||
|
|
6ddeb167b3 | ||
|
|
c1be09c692 | ||
|
|
1c2a304ee5 | ||
|
|
1a51acf2fc | ||
|
|
47a5296f0b | ||
|
|
1189e8c849 | ||
|
|
ce2316a8ee | ||
|
|
ec9ddc0819 | ||
|
|
a5bd55dcac | ||
|
|
b0b1bd88a6 | ||
|
|
75d5619abd | ||
|
|
522a641690 | ||
|
|
b39f509263 | ||
|
|
1ea95bf6e0 | ||
|
|
08d690b65d | ||
|
|
80f5ab09f3 | ||
|
|
5c8f201a92 | ||
|
|
cf777d7f41 | ||
|
|
bb7876759a | ||
|
|
800d6498d6 | ||
|
|
0648b4279f | ||
|
|
1a73abe7c3 | ||
|
|
cce4f7883c | ||
|
|
3dff67e0b1 | ||
|
|
24326883ca | ||
|
|
a5854f129d | ||
|
|
052c07f3e3 | ||
|
|
9367566e61 | ||
|
|
107103bcbb | ||
|
|
20ae47971c | ||
|
|
d4ecb03d15 | ||
|
|
f4eb47519d | ||
|
|
e37bfeeb09 | ||
|
|
bb0972ba49 | ||
|
|
ddc5994869 | ||
|
|
2169ba35ad | ||
|
|
50b447b05d | ||
|
|
bc14ad6b9d | ||
|
|
ffa33788c4 | ||
|
|
23c9c6bf44 | ||
|
|
476c02976b | ||
|
|
6ac28e1a77 | ||
|
|
6fe49fbf8d | ||
|
|
4a7c2a96db | ||
|
|
0b09ada144 |
@@ -42,6 +42,7 @@
|
||||
@import "CPCollectionViewItem.j"
|
||||
@import "CPColor.j"
|
||||
@import "CPColorPanel.j"
|
||||
@import "CPColorSpace.j"
|
||||
@import "CPColorWell.j"
|
||||
@import "CPCompatibility.j"
|
||||
@import "CPControl.j"
|
||||
@@ -55,6 +56,7 @@
|
||||
@import "CPFont.j"
|
||||
@import "CPFontManager.j"
|
||||
@import "CPGeometry.j"
|
||||
@import "CPGradient.j"
|
||||
@import "CPGraphics.j"
|
||||
@import "CPImage.j"
|
||||
@import "CPImageView.j"
|
||||
@@ -99,5 +101,6 @@
|
||||
@import "CPViewAnimation.j"
|
||||
@import "CPViewController.j"
|
||||
@import "CPWebView.j"
|
||||
@import "CPWorkspace.j"
|
||||
@import "CPWindow.j"
|
||||
@import "CPWindowController.j"
|
||||
|
||||
@@ -1166,12 +1166,12 @@ CPRunContinuesResponse = -1002;
|
||||
var _CPModalSessionMake = function(aWindow, aStopCode)
|
||||
{
|
||||
return { _window:aWindow, _state:CPRunContinuesResponse , _previous:nil };
|
||||
}
|
||||
};
|
||||
|
||||
var _CPEventListenerMake = function(anEventMask, aCallback)
|
||||
{
|
||||
return { _mask:anEventMask, _callback:aCallback };
|
||||
}
|
||||
};
|
||||
|
||||
// Make this a global for use in CPPlatformWindow+DOM.j.
|
||||
_CPRunModalLoop = function(anEvent)
|
||||
@@ -1183,7 +1183,7 @@ _CPRunModalLoop = function(anEvent)
|
||||
|
||||
if (theWindow == modalSession._window || [theWindow worksWhenModal])
|
||||
[theWindow sendEvent:anEvent];
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
Starts the GUI and Cappuccino frameworks. This function should be
|
||||
|
||||
@@ -564,7 +564,7 @@
|
||||
- (BOOL)setSelectionIndexes:(CPIndexSet)indexes
|
||||
{
|
||||
[self _selectionWillChange]
|
||||
var r = [self __setSelectionIndexes:indexes];
|
||||
var r = [self __setSelectionIndexes:indexes avoidEmpty:NO];
|
||||
[self _selectionDidChange];
|
||||
return r;
|
||||
}
|
||||
@@ -583,6 +583,11 @@
|
||||
@ignore
|
||||
*/
|
||||
- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes
|
||||
{
|
||||
[self __setSelectionIndexes:indexes avoidEmpty:_avoidsEmptySelection];
|
||||
}
|
||||
|
||||
- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes avoidEmpty:(BOOL)avoidEmpty
|
||||
{
|
||||
var newIndexes = indexes;
|
||||
|
||||
@@ -591,7 +596,7 @@
|
||||
|
||||
if (![newIndexes count])
|
||||
{
|
||||
if (_avoidsEmptySelection && [[self arrangedObjects] count])
|
||||
if (avoidEmpty && [[self arrangedObjects] count])
|
||||
newIndexes = [CPIndexSet indexSetWithIndex:0];
|
||||
}
|
||||
else
|
||||
@@ -606,7 +611,7 @@
|
||||
// Remove out of bounds indexes.
|
||||
[newIndexes removeIndexesInRange:CPMakeRange(objectsCount, [newIndexes lastIndex] + 1)];
|
||||
// When avoiding empty selection and the deleted selection was at the bottom, select the last item.
|
||||
if (![newIndexes count] && _avoidsEmptySelection && objectsCount)
|
||||
if (![newIndexes count] && avoidEmpty && objectsCount)
|
||||
newIndexes = [CPIndexSet indexSetWithIndex:objectsCount - 1];
|
||||
}
|
||||
|
||||
@@ -647,7 +652,7 @@
|
||||
[self willChangeValueForKey:@"selectionIndexes"];
|
||||
[self _selectionWillChange];
|
||||
|
||||
var r = [self __setSelectedObjects:objects];
|
||||
var r = [self __setSelectedObjects:objects avoidEmpty:NO];
|
||||
|
||||
[self didChangeValueForKey:@"selectionIndexes"];
|
||||
[self _selectionDidChange];
|
||||
@@ -659,6 +664,11 @@
|
||||
@ignore
|
||||
*/
|
||||
- (BOOL)__setSelectedObjects:(CPArray)objects
|
||||
{
|
||||
[self __setSelectedObjects:objects avoidEmpty:_avoidsEmptySelection];
|
||||
}
|
||||
|
||||
- (BOOL)__setSelectedObjects:(CPArray)objects avoidEmpty:(BOOL)avoidEmpty
|
||||
{
|
||||
var set = [CPIndexSet indexSet],
|
||||
count = [objects count],
|
||||
@@ -672,7 +682,7 @@
|
||||
[set addIndex:index];
|
||||
}
|
||||
|
||||
[self __setSelectionIndexes:set];
|
||||
[self __setSelectionIndexes:set avoidEmpty:avoidEmpty];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -1066,22 +1076,45 @@
|
||||
var destination = [_info objectForKey:CPObservedObjectKey],
|
||||
keyPath = [_info objectForKey:CPObservedKeyPathKey],
|
||||
options = [_info objectForKey:CPOptionsKey],
|
||||
isCompound = [self handlesContentAsCompoundValue];
|
||||
isCompound = [self handlesContentAsCompoundValue],
|
||||
dotIndex = keyPath.lastIndexOf("."),
|
||||
firstPart = dotIndex !== CPNotFound ? keyPath.substring(0, dotIndex) : nil,
|
||||
isSelectionProxy = firstPart && [[destination valueForKeyPath:firstPart] isKindOfClass:CPControllerSelectionProxy];
|
||||
|
||||
if (!isCompound)
|
||||
if (!isCompound && !isSelectionProxy)
|
||||
{
|
||||
newValue = [destination mutableArrayValueForKeyPath:keyPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
// handlesContentAsCompoundValue == YES so we cannot just set up a proxy.
|
||||
// 1. If handlesContentAsCompoundValue we cannot just set up a proxy.
|
||||
// Every read and every write must go through transformValue and
|
||||
// reverseTransformValue, and the resulting object cannot be described by
|
||||
// a key path.
|
||||
|
||||
// 2. If isSelectionProxy, we don't want to proxy a proxy - that's bad
|
||||
// for performance and won't work with markers.
|
||||
|
||||
newValue = [destination valueForKeyPath:keyPath];
|
||||
}
|
||||
|
||||
newValue = [self transformValue:newValue withOptions:options];
|
||||
var isPlaceholder = CPIsControllerMarker(newValue);
|
||||
if (isPlaceholder)
|
||||
{
|
||||
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
|
||||
{
|
||||
[CPException raise:CPGenericException
|
||||
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
|
||||
}
|
||||
|
||||
newValue = [self _placeholderForMarker:newValue];
|
||||
|
||||
// This seems to be what Cocoa does.
|
||||
if (!newValue)
|
||||
newValue = [CPMutableArray array];
|
||||
}
|
||||
else
|
||||
newValue = [self transformValue:newValue withOptions:options];
|
||||
|
||||
if (isCompound)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Copyright 2009 280 North, Inc.
|
||||
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@@ -276,7 +275,7 @@ var DefaultLineWidth = 1.0;
|
||||
/*!
|
||||
Append the contents of a CPBezierPath object.
|
||||
*/
|
||||
- (void)appendBezierPath:(NSBezierPath *)other
|
||||
- (void)appendBezierPath:(CPBezierPath)other
|
||||
{
|
||||
CGPathAddPath(_path, nil, other._path);
|
||||
}
|
||||
|
||||
+129
-7
@@ -35,6 +35,16 @@ CPLineBorder = 1;
|
||||
CPBezelBorder = 2;
|
||||
CPGrooveBorder = 3;
|
||||
|
||||
// CPTitlePosition
|
||||
CPNoTitle = 0;
|
||||
CPAboveTop = 1;
|
||||
CPAtTop = 2;
|
||||
CPBelowTop = 3;
|
||||
CPAboveBottom = 4;
|
||||
CPAtBottom = 5;
|
||||
CPBelowBottom = 6;
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPBox
|
||||
@@ -54,6 +64,10 @@ CPGrooveBorder = 3;
|
||||
|
||||
CPSize _contentMargin;
|
||||
CPView _contentView;
|
||||
|
||||
CPString _title @accessors(getter=title);
|
||||
int _titlePosition @accessors(getter=titlePosition);
|
||||
CPTextField _titleView;
|
||||
}
|
||||
|
||||
+ (id)boxEnclosingView:(CPView)aView
|
||||
@@ -61,7 +75,7 @@ CPGrooveBorder = 3;
|
||||
var box = [[self alloc] initWithFrame:CGRectMakeZero()],
|
||||
enclosingView = [aView superview];
|
||||
|
||||
[box setAutoresizingMask:[aView autoresizingMask]];
|
||||
[box setAutoresizingMask:[aView autoresizingMask]];
|
||||
[box setFrameFromContentFrame:[aView frame]];
|
||||
|
||||
[enclosingView replaceSubview:aView with:box];
|
||||
@@ -84,6 +98,9 @@ CPGrooveBorder = 3;
|
||||
_borderWidth = 1.0;
|
||||
_contentMargin = CGSizeMake(0.0, 0.0);
|
||||
|
||||
_titlePosition = CPNoTitle;
|
||||
_titleView = [CPTextField labelWithTitle:@""];
|
||||
|
||||
_contentView = [[CPView alloc] initWithFrame:[self bounds]];
|
||||
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
@@ -278,18 +295,100 @@ CPGrooveBorder = 3;
|
||||
|
||||
- (void)setFrameFromContentFrame:(CPRect)aRect
|
||||
{
|
||||
[self setFrame:CGRectInset(aRect, -(_contentMargin.width + _borderWidth), -(_contentMargin.height + _borderWidth))];
|
||||
var offset = [self _titleHeightOffset];
|
||||
|
||||
[self setFrame:CGRectInset(aRect, -(_contentMargin.width + _borderWidth), -(_contentMargin.height + offset[0] + _borderWidth))];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)setTitle:(CPString)aTitle
|
||||
{
|
||||
if (aTitle == _title)
|
||||
return;
|
||||
|
||||
_title = aTitle;
|
||||
|
||||
[self _manageTitlePositioning];
|
||||
}
|
||||
|
||||
- (void)setTitlePosition:(int)aTitlePotisition
|
||||
{
|
||||
if (aTitlePotisition == _titlePosition)
|
||||
return;
|
||||
|
||||
_titlePosition = aTitlePotisition;
|
||||
|
||||
[self _manageTitlePositioning];
|
||||
}
|
||||
|
||||
- (void)_manageTitlePositioning
|
||||
{
|
||||
if (_titlePosition == CPNoTitle)
|
||||
{
|
||||
[_titleView removeFromSuperview];
|
||||
[self setNeedsDisplay:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
[_titleView setStringValue:_title];
|
||||
[_titleView sizeToFit];
|
||||
[self addSubview:_titleView];
|
||||
|
||||
switch (_titlePosition)
|
||||
{
|
||||
case CPAtTop:
|
||||
case CPAboveTop:
|
||||
case CPBelowTop:
|
||||
[_titleView setFrameOrigin:CPPointMake(5.0, 0.0)];
|
||||
[_titleView setAutoresizingMask:CPViewNotSizable];
|
||||
break;
|
||||
|
||||
case CPAboveBottom:
|
||||
case CPAtBottom:
|
||||
case CPBelowBottom:
|
||||
var h = [_titleView frameSize].height;
|
||||
[_titleView setFrameOrigin:CPPointMake(5.0, [self frameSize].height - h)];
|
||||
[_titleView setAutoresizingMask:CPViewMinYMargin];
|
||||
break;
|
||||
}
|
||||
|
||||
[self sizeToFit];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)sizeToFit
|
||||
{
|
||||
var contentFrame = [_contentView frame];
|
||||
var contentFrame = [_contentView frame],
|
||||
offset = [self _titleHeightOffset];
|
||||
|
||||
if (!contentFrame)
|
||||
return;
|
||||
|
||||
[_contentView setAutoresizingMask:CPViewNotSizable];
|
||||
[self setFrameSize:CGSizeMake(contentFrame.size.width + _contentMargin.width * 2,
|
||||
contentFrame.size.height + _contentMargin.height * 2)];
|
||||
contentFrame.size.height + _contentMargin.height * 2 + offset[0])];
|
||||
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
[_contentView setFrameOrigin:CGPointMake(_contentMargin.width, _contentMargin.height)];
|
||||
[_contentView setFrameOrigin:CGPointMake(_contentMargin.width, _contentMargin.height + offset[1])];
|
||||
}
|
||||
|
||||
- (float)_titleHeightOffset
|
||||
{
|
||||
if (_titlePosition == CPNoTitle)
|
||||
return [0.0, 0.0];
|
||||
|
||||
switch (_titlePosition)
|
||||
{
|
||||
case CPAtTop:
|
||||
return [[_titleView frameSize].height, [_titleView frameSize].height];
|
||||
|
||||
case CPAtBottom:
|
||||
return [[_titleView frameSize].height, 0.0];
|
||||
|
||||
default:
|
||||
return [0.0, 0.0];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawRect:(CPRect)rect
|
||||
@@ -297,7 +396,7 @@ CPGrooveBorder = 3;
|
||||
if (_borderType === CPNoBorder)
|
||||
return;
|
||||
|
||||
var bounds = [self bounds];
|
||||
var bounds = CGRectMakeCopy([self bounds]);
|
||||
|
||||
switch (_boxType)
|
||||
{
|
||||
@@ -312,6 +411,16 @@ CPGrooveBorder = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_titlePosition == CPAtTop)
|
||||
{
|
||||
bounds.origin.y += [_titleView frameSize].height;
|
||||
bounds.size.height -= [_titleView frameSize].height;
|
||||
}
|
||||
if (_titlePosition == CPAtBottom)
|
||||
{
|
||||
bounds.size.height -= [_titleView frameSize].height;
|
||||
}
|
||||
|
||||
switch (_borderType)
|
||||
{
|
||||
case CPBezelBorder:
|
||||
@@ -386,7 +495,10 @@ var CPBoxTypeKey = @"CPBoxTypeKey",
|
||||
CPBoxFillColorKey = @"CPBoxFillColorKey",
|
||||
CPBoxCornerRadiusKey = @"CPBoxCornerRadiusKey",
|
||||
CPBoxBorderWidthKey = @"CPBoxBorderWidthKey",
|
||||
CPBoxContentMarginKey = @"CPBoxContentMarginKey";
|
||||
CPBoxContentMarginKey = @"CPBoxContentMarginKey",
|
||||
CPBoxTitle = @"CPBoxTitle",
|
||||
CPBoxTitlePosition = @"CPBoxTitlePosition",
|
||||
CPBoxTitleView = @"CPBoxTitleView";
|
||||
|
||||
@implementation CPBox (CPCoding)
|
||||
|
||||
@@ -407,10 +519,16 @@ var CPBoxTypeKey = @"CPBoxTypeKey",
|
||||
|
||||
_contentMargin = [aCoder decodeSizeForKey:CPBoxContentMarginKey];
|
||||
|
||||
_title = [aCoder decodeObjectForKey:CPBoxTitle];
|
||||
_titlePosition = [aCoder decodeIntForKey:CPBoxTitlePosition];
|
||||
_titleView = [aCoder decodeObjectForKey:CPBoxTitleView] || [CPTextField labelWithTitle:_title];
|
||||
|
||||
_contentView = [self subviews][0];
|
||||
|
||||
[self setAutoresizesSubviews:YES];
|
||||
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
[self _manageTitlePositioning];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -429,6 +547,10 @@ var CPBoxTypeKey = @"CPBoxTypeKey",
|
||||
[aCoder encodeFloat:_cornerRadius forKey:CPBoxCornerRadiusKey];
|
||||
[aCoder encodeFloat:_borderWidth forKey:CPBoxBorderWidthKey];
|
||||
|
||||
[aCoder encodeObject:_title forKey:CPBoxTitle];
|
||||
[aCoder encodeInt:_titlePosition forKey:CPBoxTitlePosition];
|
||||
[aCoder encodeObject:_titleView forKey:CPBoxTitleView];
|
||||
|
||||
[aCoder encodeSize:_contentMargin forKey:CPBoxContentMarginKey];
|
||||
}
|
||||
|
||||
|
||||
@@ -901,6 +901,12 @@ var _CPBrowserResizeControlBackgroundImage = nil;
|
||||
[_browser _column:_index clickedRow:[selectedIndexes count] === 1 ? [selectedIndexes firstIndex] : -1];
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(CPNotification)aNotification
|
||||
{
|
||||
var selectedIndexes = [[aNotification object] selectedRowIndexes];
|
||||
[_browser selectRowIndexes:selectedIndexes inColumn:_index];
|
||||
}
|
||||
|
||||
- (id)childAtIndex:(unsigned)index
|
||||
{
|
||||
return [_delegate browser:_browser child:index ofItem:_item];
|
||||
|
||||
+15
-15
@@ -100,6 +100,16 @@ CPCheckBoxImageOffset = 4.0;
|
||||
{
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
|
||||
{
|
||||
[super _updatePlaceholdersWithOptions:options];
|
||||
|
||||
[self _setPlaceholder:CPMixedState forMarker:CPMultipleValuesMarker isDefault:YES];
|
||||
[self _setPlaceholder:CPOffState forMarker:CPNoSelectionMarker isDefault:YES];
|
||||
[self _setPlaceholder:CPOffState forMarker:CPNotApplicableMarker isDefault:YES];
|
||||
[self _setPlaceholder:CPOffState forMarker:CPNullMarker isDefault:YES];
|
||||
}
|
||||
|
||||
- (void)setValueFor:(CPString)theBinding
|
||||
{
|
||||
var destination = [_info objectForKey:CPObservedObjectKey],
|
||||
@@ -110,24 +120,14 @@ CPCheckBoxImageOffset = 4.0;
|
||||
|
||||
if (isPlaceholder)
|
||||
{
|
||||
switch (newValue)
|
||||
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
|
||||
{
|
||||
case CPMultipleValuesMarker:
|
||||
newValue = CPMixedState;
|
||||
break;
|
||||
|
||||
case CPNoSelectionMarker:
|
||||
newValue = CPOffState;
|
||||
break;
|
||||
|
||||
case CPNotApplicableMarker:
|
||||
if ([options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
|
||||
[CPException raise:CPGenericException reason:@"can't transform non applicable key on: "+_source+" value: "+newValue];
|
||||
|
||||
newValue = CPOffState;
|
||||
break;
|
||||
[CPException raise:CPGenericException
|
||||
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
|
||||
}
|
||||
|
||||
newValue = [self _placeholderForMarker:newValue];
|
||||
|
||||
if (newValue === CPMixedState)
|
||||
{
|
||||
[_source setAllowsMixedState:YES];
|
||||
|
||||
+16
-11
@@ -40,23 +40,23 @@
|
||||
|
||||
@par Delegate Methods
|
||||
|
||||
@delegate -(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
||||
@delegate - (void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
|
||||
Called when the selection in the collection view has changed.
|
||||
@param collectionView the collection view who's selection changed
|
||||
|
||||
@delegate -(void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
|
||||
@delegate - (void)collectionView:(CPCollectionView)collectionView didDoubleClickOnItemAtIndex:(int)index;
|
||||
Called when the user double-clicks on an item in the collection view.
|
||||
@param collectionView the collection view that received the double-click
|
||||
@param index the index of the item that received the double-click
|
||||
|
||||
@delegate -(CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType;
|
||||
@delegate - (CPData)collectionView:(CPCollectionView)collectionView dataForItemsAtIndexes:(CPIndexSet)indices forType:(CPString)aType;
|
||||
Invoked to obtain data for a set of indices.
|
||||
@param collectionView the collection view to obtain data for
|
||||
@param indices the indices to return data for
|
||||
@param aType the data type
|
||||
@return a data object containing the index items
|
||||
|
||||
@delegate -(CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indices;
|
||||
@delegate - (CPArray)collectionView:(CPCollectionView)collectionView dragTypesForItemsAtIndexes:(CPIndexSet)indices;
|
||||
Invoked to obtain the data types supported by the specified indices for placement on the pasteboard.
|
||||
@param collectionView the collection view the items reside in
|
||||
@param indices the indices to obtain drag types
|
||||
@@ -340,19 +340,21 @@
|
||||
*/
|
||||
- (void)setSelectionIndexes:(CPIndexSet)anIndexSet
|
||||
{
|
||||
if ([_selectionIndexes isEqual:anIndexSet] || !_isSelectable)
|
||||
if (!anIndexSet)
|
||||
anIndexSet = [CPIndexSet indexSet];
|
||||
if (!_isSelectable || [_selectionIndexes isEqual:anIndexSet])
|
||||
return;
|
||||
|
||||
var index = CPNotFound;
|
||||
|
||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) !== CPNotFound)
|
||||
[_items[index] setSelected:NO];
|
||||
|
||||
_selectionIndexes = anIndexSet;
|
||||
|
||||
var index = CPNotFound;
|
||||
|
||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) != CPNotFound)
|
||||
while ((index = [_selectionIndexes indexGreaterThanIndex:index]) !== CPNotFound)
|
||||
[_items[index] setSelected:YES];
|
||||
|
||||
var binderClass = [[self class] _binderClassForBinding:@"selectionIndexes"];
|
||||
@@ -473,7 +475,7 @@
|
||||
}
|
||||
|
||||
var superview = [self superview],
|
||||
proposedHeight = y + itemSize.height + _verticalMargin;
|
||||
proposedHeight = y + itemSize.height + _verticalMargin;
|
||||
|
||||
if ([superview isKindOfClass:[CPClipView class]])
|
||||
{
|
||||
@@ -559,6 +561,8 @@
|
||||
*/
|
||||
- (void)setMinItemSize:(CGSize)aSize
|
||||
{
|
||||
if (aSize === nil || aSize === undefined)
|
||||
[CPException raise:CPInvalidArgumentException reason:"Invalid value provided for minimum size"];
|
||||
if (CGSizeEqualToSize(_minItemSize, aSize))
|
||||
return;
|
||||
|
||||
@@ -965,14 +969,15 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK
|
||||
{
|
||||
[super awakeFromCib];
|
||||
|
||||
if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()) || CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
|
||||
var prototypeView = [_itemPrototype view];
|
||||
if (prototypeView && (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()) || CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero())))
|
||||
{
|
||||
var item = _itemPrototype;
|
||||
|
||||
if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
|
||||
_minItemSize = [[item view] frameSize];
|
||||
_minItemSize = [prototypeView frameSize];
|
||||
else if (CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
|
||||
_maxItemSize = [[item view] frameSize];
|
||||
_maxItemSize = [prototypeView frameSize];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+35
-17
@@ -133,7 +133,7 @@ function CPColorWithImages()
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a color in the RGB color space, with an alpha value.
|
||||
Creates a color in the RGB colorspace, with an alpha value.
|
||||
Each component should be between the range of 0.0 to 1.0. For
|
||||
the alpha component, a value of 1.0 is opaque, and 0.0 means
|
||||
completely transparent.
|
||||
@@ -147,13 +147,13 @@ function CPColorWithImages()
|
||||
*/
|
||||
+ (CPColor)colorWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha
|
||||
{
|
||||
return [[CPColor alloc] _initWithRGBA:[red, green, blue, alpha]];
|
||||
return [[CPColor alloc] _initWithRGBA:[MAX(0.0, MIN(1.0, red)), MAX(0.0, MIN(1.0, green)), MAX(0.0, MIN(1.0, blue)), MAX(0.0, MIN(1.0, alpha))]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@deprecated in favor of colorWithRed:green:blue:alpha:
|
||||
|
||||
Creates a color in the RGB color space, with an alpha value.
|
||||
Creates a color in the RGB colorspace, with an alpha value.
|
||||
Each component should be between the range of 0.0 to 1.0. For
|
||||
the alpha component, a value of 1.0 is opaque, and 0.0 means
|
||||
completely transparent.
|
||||
@@ -228,12 +228,12 @@ function CPColorWithImages()
|
||||
|
||||
switch (FLOOR(hue / 60))
|
||||
{
|
||||
case 0: return [CPColor colorWithCalibratedRed: b green: t blue: p alpha: alpha];
|
||||
case 1: return [CPColor colorWithCalibratedRed: q green: b blue: p alpha: alpha];
|
||||
case 2: return [CPColor colorWithCalibratedRed: p green: b blue: t alpha: alpha];
|
||||
case 3: return [CPColor colorWithCalibratedRed: p green: q blue: b alpha: alpha];
|
||||
case 4: return [CPColor colorWithCalibratedRed: t green: p blue: b alpha: alpha];
|
||||
case 5: return [CPColor colorWithCalibratedRed: b green: p blue: q alpha: alpha];
|
||||
case 0: return [CPColor colorWithCalibratedRed:b green:t blue:p alpha:alpha];
|
||||
case 1: return [CPColor colorWithCalibratedRed:q green:b blue:p alpha:alpha];
|
||||
case 2: return [CPColor colorWithCalibratedRed:p green:b blue:t alpha:alpha];
|
||||
case 3: return [CPColor colorWithCalibratedRed:p green:q blue:b alpha:alpha];
|
||||
case 4: return [CPColor colorWithCalibratedRed:t green:p blue:b alpha:alpha];
|
||||
case 5: return [CPColor colorWithCalibratedRed:b green:p blue:q alpha:alpha];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,17 @@ function CPColorWithImages()
|
||||
return rgba ? [[CPColor alloc] _initWithRGBA: rgba] : null;
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a color in the sRGB colorspace with the given components and alpha values.
|
||||
Values below 0.0 are treated as 0.0 and values above 1.0 are treated as 1.0.
|
||||
*/
|
||||
+ (CPColor)colorWithSRGBRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha
|
||||
{
|
||||
// TODO If Cappuccino is ported to a colorspace aware platform, this color should be in
|
||||
// sRGBColorSpace.
|
||||
return [self colorWithRed:red green:green blue:blue alpha:alpha];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a black color object. (RGBA=[0.0, 0.0, 0.0, 1.0])
|
||||
*/
|
||||
@@ -480,7 +491,9 @@ function CPColorWithImages()
|
||||
parts[3] ? parseFloat(parts[3], 10) : 1.0
|
||||
];
|
||||
|
||||
_cssString = aString;
|
||||
// We can't reuse aString as _cssString because the browser might not support the `rgba` syntax, and aString might
|
||||
// use it (issue #1413.)
|
||||
[self _initCSSStringFromComponents];
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -494,18 +507,23 @@ function CPColorWithImages()
|
||||
{
|
||||
_components = components;
|
||||
|
||||
var hasAlpha = CPFeatureIsCompatible(CPCSSRGBAFeature) && _components[3] != 1.0;
|
||||
|
||||
_cssString = (hasAlpha ? "rgba(" : "rgb(") +
|
||||
parseInt(_components[0] * 255.0) + ", " +
|
||||
parseInt(_components[1] * 255.0) + ", " +
|
||||
parseInt(_components[2] * 255.0) +
|
||||
(hasAlpha ? (", " + _components[3]) : "") + ")";
|
||||
[self _initCSSStringFromComponents];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_initCSSStringFromComponents
|
||||
{
|
||||
var hasAlpha = CPFeatureIsCompatible(CPCSSRGBAFeature) && _components[3] != 1.0;
|
||||
|
||||
_cssString = (hasAlpha ? "rgba(" : "rgb(") +
|
||||
parseInt(_components[0] * 255.0) + ", " +
|
||||
parseInt(_components[1] * 255.0) + ", " +
|
||||
parseInt(_components[2] * 255.0) +
|
||||
(hasAlpha ? (", " + _components[3]) : "") + ")";
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (id)_initWithPatternImage:(CPImage)anImage
|
||||
{
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* CPColorSpace.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2012, SlevenBits Ltd.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
var sRGBColorSpace = nil;
|
||||
|
||||
/*!
|
||||
Represent color spaces.
|
||||
*/
|
||||
@implementation CPColorSpace : CPObject
|
||||
{
|
||||
CGColorSpace _cgColorSpace;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return an object representing the standard sRGB color space.
|
||||
*/
|
||||
+ (CPColorSpace)sRGBColorSpace
|
||||
{
|
||||
if (!sRGBColorSpace)
|
||||
sRGBColorSpace = [[self alloc] initWithCGColorSpace:CGColorSpaceCreateDeviceRGB()];
|
||||
return sRGBColorSpace;
|
||||
}
|
||||
|
||||
- (id)initWithCGColorSpace:(CGColorSpace)cgColorSpace
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_cgColorSpace = cgColorSpace;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return a Core Graphics color space representing the receiver.
|
||||
*/
|
||||
- (CGColorSpace)CGColorSpace
|
||||
{
|
||||
return _cgColorSpace;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -46,6 +46,22 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
CPView _wellView;
|
||||
}
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)theBinding
|
||||
{
|
||||
if (theBinding == CPValueBinding)
|
||||
return [CPColorWellValueBinder class];
|
||||
|
||||
return [super _binderClassForBinding:theBinding];
|
||||
}
|
||||
|
||||
- (void)_reverseSetBinding
|
||||
{
|
||||
var binderClass = [[self class] _binderClassForBinding:CPValueBinding],
|
||||
theBinding = [binderClass getBinding:CPValueBinding forObject:self];
|
||||
|
||||
[theBinding reverseSetValueFor:@"color"];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
@@ -262,6 +278,48 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPColorWellValueBinder : CPBinder
|
||||
{
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
|
||||
{
|
||||
var placeholderColor = [CPColor blueColor];
|
||||
|
||||
[self _setPlaceholder:placeholderColor forMarker:CPMultipleValuesMarker isDefault:YES];
|
||||
[self _setPlaceholder:placeholderColor forMarker:CPNoSelectionMarker isDefault:YES];
|
||||
[self _setPlaceholder:placeholderColor forMarker:CPNotApplicableMarker isDefault:YES];
|
||||
[self _setPlaceholder:placeholderColor forMarker:CPNullMarker isDefault:YES];
|
||||
}
|
||||
|
||||
- (void)setValueFor:(CPString)theBinding
|
||||
{
|
||||
var destination = [_info objectForKey:CPObservedObjectKey],
|
||||
keyPath = [_info objectForKey:CPObservedKeyPathKey],
|
||||
options = [_info objectForKey:CPOptionsKey],
|
||||
newValue = [destination valueForKeyPath:keyPath],
|
||||
isPlaceholder = CPIsControllerMarker(newValue);
|
||||
|
||||
if (isPlaceholder)
|
||||
{
|
||||
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
|
||||
{
|
||||
[CPException raise:CPGenericException
|
||||
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
|
||||
}
|
||||
|
||||
newValue = [self _placeholderForMarker:newValue];
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue = [self transformValue:newValue withOptions:options];
|
||||
}
|
||||
|
||||
[_source setColor:newValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPColorWellColorKey = "CPColorWellColorKey",
|
||||
CPColorWellBorderedKey = "CPColorWellBorderedKey";
|
||||
|
||||
|
||||
+2
-2
@@ -922,9 +922,9 @@ var CPDocumentUntitledCount = 0;
|
||||
var _CPReadSessionMake = function(aType, aDelegate, aDidReadSelector, aContextInfo)
|
||||
{
|
||||
return { fileType:aType, delegate:aDelegate, didReadSelector:aDidReadSelector, contextInfo:aContextInfo };
|
||||
}
|
||||
};
|
||||
|
||||
var _CPSaveSessionMake = function(anAbsoluteURL, aSaveOperation, aChangeCount, aDelegate, aDidSaveSelector, aContextInfo, aConnection)
|
||||
{
|
||||
return { absoluteURL:anAbsoluteURL, saveOperation:aSaveOperation, changeCount:aChangeCount, delegate:aDelegate, didSaveSelector:aDidSaveSelector, contextInfo:aContextInfo, connection:aConnection };
|
||||
}
|
||||
};
|
||||
|
||||
+8
-8
@@ -142,7 +142,7 @@ var _CPFonts = {},
|
||||
*/
|
||||
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO italic:NO];
|
||||
return [CPFont fontWithName:aName size:aSize bold:NO italic:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -154,7 +154,7 @@ var _CPFonts = {},
|
||||
*/
|
||||
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO italic:italic];
|
||||
return [CPFont fontWithName:aName size:aSize bold:NO italic:italic];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -165,7 +165,7 @@ var _CPFonts = {},
|
||||
*/
|
||||
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, YES, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES italic:NO];
|
||||
return [CPFont fontWithName:aName size:aSize bold:YES italic:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -177,7 +177,7 @@ var _CPFonts = {},
|
||||
*/
|
||||
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
|
||||
{
|
||||
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES italic:italic];
|
||||
return [CPFont fontWithName:aName size:aSize bold:YES italic:italic];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -187,7 +187,7 @@ var _CPFonts = {},
|
||||
*/
|
||||
+ (CPFont)systemFontOfSize:(CPSize)aSize
|
||||
{
|
||||
return _CPCachedFont(_CPFontSystemFontFace, aSize, NO, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:NO italic:NO];
|
||||
return [CPFont fontWithName:_CPFontSystemFontFace size:aSize bold:NO italic:NO];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -197,15 +197,15 @@ var _CPFonts = {},
|
||||
*/
|
||||
+ (CPFont)boldSystemFontOfSize:(CPSize)aSize
|
||||
{
|
||||
return _CPCachedFont(_CPFontSystemFontFace, aSize, YES, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:YES italic:NO];
|
||||
return [CPFont fontWithName:_CPFontSystemFontFace size:aSize bold:YES italic:NO];
|
||||
}
|
||||
|
||||
/* FIXME Font Descriptor
|
||||
@ignore
|
||||
*/
|
||||
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold
|
||||
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize bold:(BOOL)bold italic:(BOOL)italic
|
||||
{
|
||||
return [self _initWithName:aName size:aSize bold:isBold italic:NO];
|
||||
return _CPCachedFont(aName, aSize, bold, italic) || [[CPFont alloc] _initWithName:aName size:aSize bold:bold italic:italic];
|
||||
}
|
||||
|
||||
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold italic:(BOOL)isItalic
|
||||
|
||||
@@ -143,7 +143,7 @@ var _CPFontDetectFontAvailable = function(font)
|
||||
if (_CPFontDetectCompareFonts(_CPFontDetectReferenceFonts[i], font))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var _CPFontDetectCache = {};
|
||||
|
||||
@@ -165,7 +165,7 @@ var _CPFontDetectCompareFonts = function(fontA, fontB)
|
||||
bHeight = _CPFontDetectSpan.offsetHeight;
|
||||
|
||||
return (a.w != bWidth || a.h != bHeight);
|
||||
}
|
||||
};
|
||||
|
||||
// Test the candidate fonts pairwise until we find two that are different. Otherwise return the first.
|
||||
var _CPFontDetectPickTwoDifferentFonts = function(candidates)
|
||||
@@ -175,6 +175,6 @@ var _CPFontDetectPickTwoDifferentFonts = function(candidates)
|
||||
if (_CPFontDetectCompareFonts(candidates[i], candidates[j]))
|
||||
return [candidates[i], candidates[j]];
|
||||
return [candidates[0]];
|
||||
}
|
||||
};
|
||||
|
||||
[CPFontManager setFontManagerFactory:[CPFontManager class]];
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* CPGradient.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2012, SlevenBits Ltd.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
CPGradientDrawsBeforeStartingLocation = kCGGradientDrawsBeforeStartLocation;
|
||||
CPGradientDrawsAfterEndingLocation = kCGGradientDrawsAfterEndLocation;
|
||||
|
||||
/*!
|
||||
A class for drawing linear and radial gradients with a convenient API.
|
||||
*/
|
||||
@implementation CPGradient : CPObject
|
||||
{
|
||||
CGGradient _gradient;
|
||||
}
|
||||
|
||||
- (id)initWithColors:(CPArray)someColors
|
||||
{
|
||||
var count = [someColors count];
|
||||
|
||||
if (count < 2)
|
||||
[CPException raise:CPInvalidArgumentException reason:@"at least 2 colors required"];
|
||||
|
||||
var distance = 1.0 / (count - 1),
|
||||
locations = [CPMutableArray array],
|
||||
location = 0.0;
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
[locations addObject:location];
|
||||
location += distance;
|
||||
}
|
||||
|
||||
return [self initWithColors:someColors atLocations:locations colorSpace:nil];
|
||||
}
|
||||
|
||||
- (id)initWithColors:(CPArray)someColors atLocations:(CPArray)someLocations colorSpace:(CPColorSpace)aColorSpace
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
var cgColors = [],
|
||||
count = [someColors count],
|
||||
colorSpace = [aColorSpace CGColorSpace] || CGColorSpaceCreateDeviceRGB;
|
||||
for (var i = 0; i < count; i++)
|
||||
cgColors.push(CGColorCreate(colorSpace, [someColors[i] components]));
|
||||
_gradient = CGGradientCreateWithColors(colorSpace, cgColors, someLocations);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawInRect:(CGRect)rect angle:(float)angle
|
||||
{
|
||||
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGContextSaveGState(ctx);
|
||||
CGContextClipToRect(ctx, rect);
|
||||
CGContextAddRect(ctx, rect);
|
||||
|
||||
var startPoint,
|
||||
endPoint;
|
||||
|
||||
// Modulo of negative values doesn't work as expected in JS.
|
||||
angle = ((angle % 360.0) + 360.0) % 360.0;
|
||||
|
||||
if (angle < 90.0)
|
||||
startPoint = _CGPointMake(_CGRectGetMinX(rect), _CGRectGetMinY(rect));
|
||||
else if (angle < 180.0)
|
||||
startPoint = _CGPointMake(_CGRectGetMaxX(rect), _CGRectGetMinY(rect));
|
||||
else if (angle < 270.0)
|
||||
startPoint = _CGPointMake(_CGRectGetMaxX(rect), _CGRectGetMaxY(rect));
|
||||
else
|
||||
startPoint = _CGPointMake(_CGRectGetMinX(rect), _CGRectGetMaxY(rect));
|
||||
|
||||
// A line segment comes out of the starting point at the given angle, with the first colour
|
||||
// at the starting point and the last at the end. To do what drawInRect: is supposed to do
|
||||
// we want the opposite corner of the starting corner to just reach the final colour stop.
|
||||
// So when the angle isn't a right angle, the segment has to extend beyond the edge of the
|
||||
// rectangle just far enough. This is hard to describe without a picture but if we place
|
||||
// another line through the opposite corner at -90 degrees, it'll help form some triangles
|
||||
// from which we can derive this formula:
|
||||
//
|
||||
// length = cos(angle) * (rectWidth + rectHeight * tan(angle))
|
||||
//
|
||||
// This simplifies down to (in the first quadrant) rectWidth * cos(a) + rectHeight * sin(a).
|
||||
|
||||
var radians = PI * angle / 180.0,
|
||||
length = ABS(_CGRectGetWidth(rect) * COS(radians)) + ABS(_CGRectGetHeight(rect) * SIN(radians));
|
||||
|
||||
endPoint = _CGPointMake(startPoint.x + length * COS(radians),
|
||||
startPoint.y + length * SIN(radians));
|
||||
|
||||
[self drawFromPoint:startPoint toPoint:endPoint options:CPGradientDrawsBeforeStartingLocation | CPGradientDrawsAfterEndingLocation];
|
||||
CGContextRestoreGState(ctx);
|
||||
}
|
||||
|
||||
- (void)drawFromPoint:(NSPoint)startingPoint toPoint:(NSPoint)endingPoint options:(NSGradientDrawingOptions)options
|
||||
{
|
||||
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
// TODO kCGGradientDrawsBeforeStartLocation and kCGGradientDrawsAfterEndLocation are not actually supported
|
||||
// by CGContextDrawLinearGradient yet.
|
||||
CGContextDrawLinearGradient(ctx, _gradient, startingPoint, endingPoint, options);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -86,4 +86,17 @@ var CPGraphicsContextCurrent = nil;
|
||||
return _graphicsPort;
|
||||
}
|
||||
|
||||
/*!
|
||||
(Not implemented. Always returns Cappuccino's default, `YES`.)
|
||||
|
||||
Return `isFlipped` of the receiver's focused view, unless no view is focused in which case the receiver's
|
||||
`flipped` flag, as set by `graphicsContextWithGraphicsPort:flipped:`, is returned.
|
||||
|
||||
Note: Cappuccino is flipped by default.
|
||||
*/
|
||||
- (BOOL)isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+3
-3
@@ -281,7 +281,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
[self _derefFromImage];
|
||||
}
|
||||
};
|
||||
|
||||
_image.onerror = function ()
|
||||
{
|
||||
@@ -293,7 +293,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
[self _derefFromImage];
|
||||
}
|
||||
};
|
||||
|
||||
_image.onabort = function ()
|
||||
{
|
||||
@@ -305,7 +305,7 @@ function CPAppKitImage(aFilename, aSize)
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
[self _derefFromImage];
|
||||
}
|
||||
};
|
||||
|
||||
_image.src = _filename;
|
||||
|
||||
|
||||
+4
-12
@@ -41,15 +41,7 @@ CPImageAlignBottomLeft = 6;
|
||||
CPImageAlignBottomRight = 7;
|
||||
CPImageAlignRight = 8;
|
||||
|
||||
var CPImageViewShadowBackgroundColor = nil,
|
||||
CPImageViewEmptyPlaceholderImage = nil;
|
||||
|
||||
var LEFT_SHADOW_INSET = 3.0,
|
||||
RIGHT_SHADOW_INSET = 3.0,
|
||||
TOP_SHADOW_INSET = 3.0,
|
||||
BOTTOM_SHADOW_INSET = 5.0,
|
||||
VERTICAL_SHADOW_INSET = TOP_SHADOW_INSET + BOTTOM_SHADOW_INSET,
|
||||
HORIZONTAL_SHADOW_INSET = LEFT_SHADOW_INSET + RIGHT_SHADOW_INSET;
|
||||
var CPImageViewEmptyPlaceholderImage = nil;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -297,8 +289,8 @@ var LEFT_SHADOW_INSET = 3.0,
|
||||
imageScaling = [self currentValueForThemeAttribute:@"image-scaling"],
|
||||
x = 0.0,
|
||||
y = 0.0,
|
||||
insetWidth = (_hasShadow ? HORIZONTAL_SHADOW_INSET : 0.0),
|
||||
insetHeight = (_hasShadow ? VERTICAL_SHADOW_INSET : 0.0),
|
||||
insetWidth = (_hasShadow ? [_shadowView horizontalInset] : 0.0),
|
||||
insetHeight = (_hasShadow ? [_shadowView verticalInset] : 0.0),
|
||||
boundsWidth = _CGRectGetWidth(bounds),
|
||||
boundsHeight = _CGRectGetHeight(bounds),
|
||||
width = boundsWidth - insetWidth,
|
||||
@@ -406,7 +398,7 @@ var LEFT_SHADOW_INSET = 3.0,
|
||||
_imageRect = _CGRectMake(x, y, width, height);
|
||||
|
||||
if (_hasShadow)
|
||||
[_shadowView setFrame:_CGRectMake(x - LEFT_SHADOW_INSET, y - TOP_SHADOW_INSET, width + insetWidth, height + insetHeight)];
|
||||
[_shadowView setFrame:_CGRectMake(x - [_shadowView leftInset], y - [_shadowView topInset], width + insetWidth, height + insetHeight)];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
|
||||
@@ -41,6 +41,7 @@ var CPBindingOperationAnd = 0,
|
||||
id _source;
|
||||
|
||||
JSObject _suppressedNotifications;
|
||||
JSObject _placeholderForMarker;
|
||||
}
|
||||
|
||||
+ (void)exposeBinding:(CPString)aBinding forClass:(Class)aClass
|
||||
@@ -125,10 +126,13 @@ var CPBindingOperationAnd = 0,
|
||||
_source = aSource;
|
||||
_info = [CPDictionary dictionaryWithObjects:[aDestination, aKeyPath] forKeys:[CPObservedObjectKey, CPObservedKeyPathKey]];
|
||||
_suppressedNotifications = {};
|
||||
_placeholderForMarker = {};
|
||||
|
||||
if (options)
|
||||
[_info setObject:options forKey:CPOptionsKey];
|
||||
|
||||
[self _updatePlaceholdersWithOptions:options];
|
||||
|
||||
[aDestination addObserver:self forKeyPath:aKeyPath options:CPKeyValueObservingOptionNew context:aBinding];
|
||||
|
||||
var bindings = [bindingsMap objectForKey:[_source UID]];
|
||||
@@ -204,14 +208,13 @@ var CPBindingOperationAnd = 0,
|
||||
if (valueTransformer)
|
||||
aValue = [valueTransformer transformedValue:aValue];
|
||||
|
||||
|
||||
if (aValue === undefined || aValue === nil || aValue === [CPNull null])
|
||||
aValue = [options objectForKey:CPNullPlaceholderBindingOption] || nil;
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
- (id)reverseTransformValue:(id)aValue withOptions: (CPDictionary)options
|
||||
- (id)reverseTransformValue:(id)aValue withOptions:(CPDictionary)options
|
||||
{
|
||||
var valueTransformerName = [options objectForKey:CPValueTransformerNameBindingOption],
|
||||
valueTransformer;
|
||||
@@ -271,6 +274,42 @@ var CPBindingOperationAnd = 0,
|
||||
delete objectSuppressions[aKeyPath];
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
|
||||
{
|
||||
var count = [CPBinderPlaceholderMarkers count];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var marker = CPBinderPlaceholderMarkers[count],
|
||||
optionName = CPBinderPlaceholderOptions[count],
|
||||
isExplicit = [options containsKey:optionName],
|
||||
placeholder = isExplicit ? [options objectForKey:optionName] : nil;
|
||||
[self _setPlaceholder:placeholder forMarker:marker isDefault:!isExplicit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_placeholderForMarker:aMarker
|
||||
{
|
||||
var placeholder = _placeholderForMarker[aMarker];
|
||||
if (placeholder)
|
||||
return placeholder['value'];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)_setPlaceholder:(id)aPlaceholder forMarker:(id)aMarker isDefault:(BOOL)isDefault
|
||||
{
|
||||
if (isDefault)
|
||||
{
|
||||
var existingPlaceholder = _placeholderForMarker[aMarker];
|
||||
|
||||
// Don't overwrite an explicitly set placeholder with a default.
|
||||
if (existingPlaceholder && !existingPlaceholder['isDefault'])
|
||||
return;
|
||||
}
|
||||
|
||||
_placeholderForMarker[aMarker] = { 'isDefault': isDefault, 'value': aPlaceholder };
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPObject (KeyValueBindingCreation)
|
||||
@@ -426,7 +465,7 @@ var resolveMultipleValues = function resolveMultipleValues(/*CPString*/key, /*CP
|
||||
}
|
||||
|
||||
return !operation;
|
||||
}
|
||||
};
|
||||
|
||||
var invokeAction = function invokeAction(/*CPString*/targetKey, /*CPString*/argumentKey, /*CPDictionary*/bindings)
|
||||
{
|
||||
@@ -463,7 +502,7 @@ var invokeAction = function invokeAction(/*CPString*/targetKey, /*CPString*/argu
|
||||
}
|
||||
|
||||
[invocation invoke];
|
||||
}
|
||||
};
|
||||
|
||||
// Keys in options dictionary
|
||||
|
||||
@@ -518,4 +557,8 @@ CPValueTransformerBindingOption = @"CPValueTransformer";
|
||||
CPIsControllerMarker = function(/*id*/anObject)
|
||||
{
|
||||
return anObject === CPMultipleValuesMarker || anObject === CPNoSelectionMarker || anObject === CPNotApplicableMarker || anObject === CPNullMarker;
|
||||
}
|
||||
};
|
||||
|
||||
var CPBinderPlaceholderMarkers = [CPMultipleValuesMarker, CPNoSelectionMarker, CPNotApplicableMarker, CPNullMarker],
|
||||
CPBinderPlaceholderOptions = [CPMultipleValuesPlaceholderBindingOption, CPNoSelectionPlaceholderBindingOption, CPNotApplicablePlaceholderBindingOption, CPNullPlaceholderBindingOption];
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
items = [_menu itemArray],
|
||||
count = items.length;
|
||||
|
||||
for (index = 0; index < count; ++index)
|
||||
for (var index = 0; index < count; ++index)
|
||||
{
|
||||
var item = items[index],
|
||||
menuItemView = [item _menuItemView];
|
||||
|
||||
@@ -663,7 +663,8 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
- (id)_controllerMarkerForValues:(CPArray)theValues
|
||||
{
|
||||
var count = [theValues count];
|
||||
var count = [theValues count],
|
||||
value;
|
||||
|
||||
if (!count)
|
||||
value = CPNoSelectionMarker;
|
||||
@@ -677,7 +678,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
{
|
||||
value = [theValues objectAtIndex:0];
|
||||
|
||||
for (var i = 0, count= [theValues count]; i < count && value != CPMultipleValuesMarker; i++)
|
||||
for (var i = 0, count = [theValues count]; i < count && value != CPMultipleValuesMarker; i++)
|
||||
{
|
||||
if (![value isEqual:[theValues objectAtIndex:i]])
|
||||
value = CPMultipleValuesMarker;
|
||||
@@ -693,8 +694,8 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
- (id)valueForKeyPath:(CPString)theKeyPath
|
||||
{
|
||||
var values = [[_controller selectedObjects] valueForKeyPath:theKeyPath];
|
||||
value = [self _controllerMarkerForValues:values];
|
||||
var values = [[_controller selectedObjects] valueForKeyPath:theKeyPath],
|
||||
value = [self _controllerMarkerForValues:values];
|
||||
|
||||
[_cachedValues setObject:value forKey:theKeyPath];
|
||||
|
||||
|
||||
+84
-43
@@ -62,7 +62,7 @@ var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_
|
||||
CPOutlineViewDelegate_outlineView_shouldReorderColumn_toColumn_ = 1 << 12,
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 13,
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_ = 1 << 14,
|
||||
CPOutlineViewDelegate_outlineView_shouldShowOutlineViewForItem_ = 1 << 15,
|
||||
CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_ = 1 << 15,
|
||||
CPOutlineViewDelegate_outlineView_shouldShowViewExpansionForTableColumn_item_ = 1 << 16,
|
||||
CPOutlineViewDelegate_outlineView_shouldTrackView_forTableColumn_item_ = 1 << 17,
|
||||
CPOutlineViewDelegate_outlineView_shouldTypeSelectForEvent_withCurrentSearchString_ = 1 << 18,
|
||||
@@ -80,6 +80,10 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
CPOutlineViewCoalesceSelectionNotificationStateOn = 1,
|
||||
CPOutlineViewCoalesceSelectionNotificationStateDid = 2;
|
||||
|
||||
#define SELECTION_SHOULD_CHANGE(anOutlineView) (!((anOutlineView)._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_selectionShouldChangeInOutlineView_) || [(anOutlineView)._outlineViewDelegate selectionShouldChangeInOutlineView:(anOutlineView)])
|
||||
|
||||
#define SHOULD_SELECT_ITEM(anOutlineView, anItem) (!((anOutlineView)._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_) || [(anOutlineView)._outlineViewDelegate outlineView:(anOutlineView) shouldSelectItem:(anItem)])
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPOutlineView
|
||||
@@ -136,7 +140,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
_selectionHighlightStyle = CPTableViewSelectionHighlightStyleSourceList;
|
||||
|
||||
// The root item has weight "0", thus represents the weight solely of its descendants.
|
||||
_rootItemInfo = { isExpanded:YES, isExpandable:NO, level:-1, row:-1, children:[], weight:0 };
|
||||
_rootItemInfo = { isExpanded:YES, isExpandable:NO, shouldShowOutlineDisclosureControl:NO, level:-1, row:-1, children:[], weight:0 };
|
||||
|
||||
_itemsForRows = [];
|
||||
_itemInfosForItems = { };
|
||||
@@ -294,6 +298,19 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
return itemInfo.isExpandable;
|
||||
}
|
||||
|
||||
- (BOOL)_shouldShowOutlineDisclosureControlForItem:(id)anItem
|
||||
{
|
||||
if (!anItem)
|
||||
return YES;
|
||||
|
||||
var itemInfo = _itemInfosForItems[[anItem UID]];
|
||||
|
||||
if (!itemInfo)
|
||||
return YES;
|
||||
|
||||
return itemInfo.shouldShowOutlineDisclosureControl;
|
||||
}
|
||||
|
||||
/*!
|
||||
Used to find if an item is already expanded.
|
||||
|
||||
@@ -690,7 +707,8 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
*/
|
||||
- (CGRect)frameOfOutlineDisclosureControlAtRow:(CPInteger)aRow
|
||||
{
|
||||
if (![self isExpandable:[self itemAtRow:aRow]])
|
||||
var theItem = [self itemAtRow:aRow];
|
||||
if (![self isExpandable:theItem] || ![self _shouldShowOutlineDisclosureControlForItem:theItem])
|
||||
return _CGRectMakeZero();
|
||||
|
||||
var dataViewFrame = [self _frameOfOutlineDataViewAtRow:aRow],
|
||||
@@ -822,29 +840,24 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
name:CPOutlineViewSelectionIsChangingNotification
|
||||
object:self];
|
||||
|
||||
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewItemWillExpand:)])
|
||||
[defaultCenter
|
||||
removeObserver:_outlineViewDelegate
|
||||
name:CPOutlineViewItemWillExpandNotification
|
||||
object:self];
|
||||
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewItemDidExpand:)])
|
||||
[defaultCenter
|
||||
removeObserver:_outlineViewDelegate
|
||||
name:CPOutlineViewItemDidExpandNotification
|
||||
object:self];
|
||||
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewItemWillCollapse:)])
|
||||
[defaultCenter
|
||||
removeObserver:_outlineViewDelegate
|
||||
name:CPOutlineViewItemWillCollapseNotification
|
||||
object:self];
|
||||
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewItemDidCollapse:)])
|
||||
[defaultCenter
|
||||
removeObserver:_outlineViewDelegate
|
||||
@@ -870,7 +883,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
CPOutlineViewDelegate_outlineView_shouldReorderColumn_toColumn_ , @selector(outlineView:shouldReorderColumn:toColumn:),
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectItem_ , @selector(outlineView:shouldSelectItem:),
|
||||
CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_ , @selector(outlineView:shouldSelectTableColumn:),
|
||||
CPOutlineViewDelegate_outlineView_shouldShowOutlineViewForItem_ , @selector(outlineView:shouldShowOutlineViewForItem:),
|
||||
CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_ , @selector(outlineView:shouldShowOutlineDisclosureControlForItem:),
|
||||
CPOutlineViewDelegate_outlineView_shouldShowViewExpansionForTableColumn_item_ , @selector(outlineView:shouldShowViewExpansionForTableColumn:item:),
|
||||
CPOutlineViewDelegate_outlineView_shouldTrackView_forTableColumn_item_ , @selector(outlineView:shouldTrackView:forTableColumn:item:),
|
||||
CPOutlineViewDelegate_outlineView_shouldTypeSelectForEvent_withCurrentSearchString_ , @selector(outlineView:shouldTypeSelectForEvent:withCurrentSearchString:),
|
||||
@@ -921,7 +934,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
name:CPOutlineViewSelectionIsChangingNotification
|
||||
object:self];
|
||||
|
||||
|
||||
if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewItemWillExpand:)])
|
||||
[defaultCenter
|
||||
addObserver:_outlineViewDelegate
|
||||
@@ -984,7 +996,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
_disclosureControlData = nil;
|
||||
_disclosureControlQueue = [];
|
||||
|
||||
// fIXME: really?
|
||||
// FIXME: really?
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
@@ -1120,13 +1132,14 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
if (_dragHoverTimer)
|
||||
[_dragHoverTimer invalidate];
|
||||
|
||||
var autoExpandCallBack = function(){
|
||||
var autoExpandCallBack = function()
|
||||
{
|
||||
if (_dropItem)
|
||||
{
|
||||
[_dropOperationFeedbackView blink];
|
||||
[CPTimer scheduledTimerWithTimeInterval:.3 callback:objj_msgSend(self, "expandItem:", _dropItem) repeats:NO];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_dragHoverTimer = [CPTimer scheduledTimerWithTimeInterval:.8 callback:autoExpandCallBack repeats:NO];
|
||||
}
|
||||
@@ -1284,7 +1297,12 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
item = _itemsForRows[row],
|
||||
isExpandable = [self isExpandable:item];
|
||||
|
||||
if (!isExpandable)
|
||||
if (!isExpandable)
|
||||
continue;
|
||||
|
||||
var disclosureControlFrame = [self frameOfOutlineDisclosureControlAtRow:row];
|
||||
|
||||
if (_CGRectIsEmpty(disclosureControlFrame))
|
||||
continue;
|
||||
|
||||
var control = [self _dequeueDisclosureControl];
|
||||
@@ -1294,7 +1312,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
[control setState:[self isItemExpanded:item] ? CPOnState : CPOffState];
|
||||
var selector = [self isRowSelected:row] ? @"setThemeState:" : @"unsetThemeState:";
|
||||
[control performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected];
|
||||
[control setFrame:[self frameOfOutlineDisclosureControlAtRow:row]];
|
||||
[control setFrame:disclosureControlFrame];
|
||||
|
||||
[self addSubview:control];
|
||||
}
|
||||
@@ -1458,7 +1476,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
userInfo:[CPDictionary dictionaryWithObject:item forKey:"CPObject"]];
|
||||
}
|
||||
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
{
|
||||
var character = [anEvent charactersIgnoringModifiers],
|
||||
@@ -1467,7 +1484,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
// Check for the key events manually, as opposed to waiting for CPWindow to sent the actual action message
|
||||
// in _processKeyboardUIKey:, because we might not want to handle the arrow events.
|
||||
|
||||
if (character !== CPRightArrowFunctionKey && character !== CPLeftArrowFunctionKey)
|
||||
if (character !== CPRightArrowFunctionKey && character !== CPLeftArrowFunctionKey)
|
||||
return [super keyDown:anEvent];
|
||||
|
||||
var rows = [self selectedRowIndexes],
|
||||
@@ -1481,7 +1498,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
|
||||
for (; i < c; i++)
|
||||
items.push([self itemAtRow:indexes[i]]);
|
||||
|
||||
|
||||
if (character === CPRightArrowFunctionKey)
|
||||
{
|
||||
@@ -1490,12 +1506,32 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
|
||||
}
|
||||
else if (character === CPLeftArrowFunctionKey)
|
||||
{
|
||||
// When a single, collapsed item is selected and the left arrow key is pressed, the parent
|
||||
// should be selected if possible.
|
||||
if (c == 1)
|
||||
{
|
||||
var theItem = items[0];
|
||||
if (![self isItemExpanded:theItem])
|
||||
{
|
||||
var parent = [self parentForItem:theItem],
|
||||
shouldSelect = parent && SELECTION_SHOULD_CHANGE(self) && SHOULD_SELECT_ITEM(self, parent);
|
||||
if (shouldSelect)
|
||||
{
|
||||
var rowIndex = [self rowForItem:parent];
|
||||
[self selectRowIndexes:[CPIndexSet indexSetWithIndex:rowIndex] byExtendingSelection:NO];
|
||||
[self scrollRowToVisible:rowIndex];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < c; i++)
|
||||
[self collapseItem:items[i]];
|
||||
[self collapseItem:items[i]];
|
||||
}
|
||||
|
||||
[super keyDown:anEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
|
||||
@@ -1534,8 +1570,9 @@ var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem)
|
||||
|
||||
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem];
|
||||
itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded;
|
||||
itemInfo.shouldShowOutlineDisclosureControl = !(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_) || [_outlineViewDelegate outlineView:self shouldShowOutlineDisclosureControlForItem:newItem];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever...
|
||||
var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate)
|
||||
@@ -1559,6 +1596,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [];
|
||||
|
||||
itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem];
|
||||
itemInfo.shouldShowOutlineDisclosureControl = !(_implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldShowOutlineDisclosureControlForItem_) || [_outlineViewDelegate outlineView:self shouldShowOutlineDisclosureControlForItem:anItem];
|
||||
|
||||
// If we were previously expanded, but now no longer expandable, "de-expand".
|
||||
// NOTE: we are *not* collapsing, thus no notification is posted.
|
||||
@@ -1589,7 +1627,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
|
||||
if (!childItemInfo)
|
||||
{
|
||||
childItemInfo = { isExpanded:NO, isExpandable:NO, children:[], weight:1 };
|
||||
childItemInfo = { isExpanded:NO, isExpandable:NO, shouldShowOutlineDisclosureControl:YES, children:[], weight:1 };
|
||||
itemInfosForItems[[childItem UID]] = childItemInfo;
|
||||
}
|
||||
|
||||
@@ -1640,7 +1678,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
}
|
||||
}//end of with
|
||||
return descendants;
|
||||
}
|
||||
};
|
||||
|
||||
@implementation _CPOutlineViewTableViewDataSource : CPObject
|
||||
{
|
||||
@@ -1792,9 +1830,9 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
var dataView = nil;
|
||||
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_))
|
||||
dataView = [_outlineView._outlineViewDelegate outlineView:_outlineView
|
||||
dataViewForTableColumn:theTableColumn
|
||||
item:[_outlineView itemAtRow:theRow]];
|
||||
dataView = [_outlineView._outlineViewDelegate outlineView:_outlineView
|
||||
dataViewForTableColumn:theTableColumn
|
||||
item:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
if (!dataView)
|
||||
dataView = [theTableColumn dataViewForRow:theRow];
|
||||
@@ -1804,10 +1842,12 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
|
||||
- (BOOL)tableView:(CPTableView)theTableView shouldSelectRow:(int)theRow
|
||||
{
|
||||
if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_))
|
||||
return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldSelectItem:[_outlineView itemAtRow:theRow]];
|
||||
return SHOULD_SELECT_ITEM(_outlineView, [_outlineView itemAtRow:theRow]);
|
||||
}
|
||||
|
||||
return YES;
|
||||
- (BOOL)selectionShouldChangeInTableView:(CPTableView)theTableView
|
||||
{
|
||||
return SELECTION_SHOULD_CHANGE(_outlineView);
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)aColumn row:(int)aRow
|
||||
@@ -1885,16 +1925,22 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var bounds = [self bounds],
|
||||
context = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
width = _CGRectGetWidth(bounds),
|
||||
height = _CGRectGetHeight(bounds);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
|
||||
CGContextTranslateCTM(context, _CGRectGetWidth(bounds) / 2.0, _CGRectGetHeight(bounds) / 2.0);
|
||||
CGContextRotateCTM(context, _angle);
|
||||
CGContextTranslateCTM(context, -_CGRectGetWidth(bounds) / 2.0, -_CGRectGetHeight(bounds) / 2.0);
|
||||
if (_angle)
|
||||
{
|
||||
var centre = _CGPointMake(FLOOR(width / 2.0), FLOOR(height / 2.0));
|
||||
CGContextTranslateCTM(context, centre.x, centre.y);
|
||||
CGContextRotateCTM(context, _angle);
|
||||
CGContextTranslateCTM(context, -centre.x, -centre.y);
|
||||
}
|
||||
|
||||
// Center, but crisp.
|
||||
CGContextTranslateCTM(context, FLOOR((_CGRectGetWidth(bounds) - 9.0) / 2.0), FLOOR((_CGRectGetHeight(bounds) - 8.0) / 2.0));
|
||||
CGContextTranslateCTM(context, FLOOR((width - 9.0) / 2.0), FLOOR((height - 8.0) / 2.0));
|
||||
|
||||
CGContextMoveToPoint(context, 0.0, 0.0);
|
||||
CGContextAddLineToPoint(context, 9.0, 0.0);
|
||||
@@ -1907,20 +1953,14 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
[self hasThemeState:CPThemeStateHighlighted]));
|
||||
CGContextFillPath(context);
|
||||
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0.0, 0.0);
|
||||
|
||||
CGContextAddLineToPoint(context, 4.5, 8.0);
|
||||
if (_angle === 0.0)
|
||||
{
|
||||
CGContextAddLineToPoint(context, 4.5, 8.0);
|
||||
CGContextAddLineToPoint(context, 9.0, 0.0);
|
||||
}
|
||||
|
||||
else
|
||||
CGContextAddLineToPoint(context, 4.5, 8.0);
|
||||
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithCalibratedWhite:1.0 alpha: 0.8]);
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithCalibratedWhite:1.0 alpha: 0.7]);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
|
||||
@@ -1984,7 +2024,8 @@ var CPOutlineViewIndentationPerLevelKey = @"CPOutlineViewIndentationPerLevelKey"
|
||||
@end
|
||||
|
||||
|
||||
var colorForDisclosureTriangle = function(isSelected, isHighlighted) {
|
||||
var colorForDisclosureTriangle = function(isSelected, isHighlighted)
|
||||
{
|
||||
return isSelected
|
||||
? (isHighlighted
|
||||
? [CPColor colorWithCalibratedWhite:0.9 alpha: 1.0]
|
||||
@@ -1992,4 +2033,4 @@ var colorForDisclosureTriangle = function(isSelected, isHighlighted) {
|
||||
: (isHighlighted
|
||||
? [CPColor colorWithCalibratedWhite:0.4 alpha: 1.0]
|
||||
: [CPColor colorWithCalibratedWhite:0.5 alpha: 1.0]);
|
||||
}
|
||||
};
|
||||
|
||||
+11
-1
@@ -249,7 +249,7 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (int)selectedTag
|
||||
- (int)_selectedTag
|
||||
{
|
||||
return [[self selectedItem] tag];
|
||||
}
|
||||
@@ -776,6 +776,16 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
[[self selectedItem] setState:CPOffState];
|
||||
}
|
||||
|
||||
- (void)_reverseSetBinding
|
||||
{
|
||||
var binderClass = [[self class] _binderClassForBinding:CPSelectedIndexBinding],
|
||||
theBinding = [binderClass getBinding:CPSelectedIndexBinding forObject:self];
|
||||
|
||||
[theBinding reverseSetValueFor:@"objectValue"];
|
||||
|
||||
[super _reverseSetBinding];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var DEPRECATED_CPPopUpButtonMenuKey = @"CPPopUpButtonMenuKey",
|
||||
|
||||
+52
-45
@@ -35,7 +35,6 @@ CPPopoverBehaviorApplicationDefined = 0;
|
||||
CPPopoverBehaviorTransient = 1;
|
||||
CPPopoverBehaviorSemitransient = 2;
|
||||
|
||||
|
||||
var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
CPPopoverDelegate_popover_didShow_ = 1 << 1,
|
||||
CPPopoverDelegate_popover_shouldClose_ = 1 << 2,
|
||||
@@ -50,11 +49,14 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
view relative to another one.
|
||||
|
||||
Delegate can implement:
|
||||
– popoverShouldClose:(CPPopover)aPopOver
|
||||
– popoverWillShow:(CPPopover)aPopOver
|
||||
– popoverDidShow:(CPPopover)aPopOver
|
||||
– popoverWillClose:(CPPopover)aPopOver
|
||||
– popoverDidClose:(CPPopover)aPopOver
|
||||
|
||||
@code
|
||||
– popoverShouldClose:(CPPopover)aPopOver
|
||||
– popoverWillShow:(CPPopover)aPopOver
|
||||
– popoverDidShow:(CPPopover)aPopOver
|
||||
– popoverWillClose:(CPPopover)aPopOver
|
||||
– popoverDidClose:(CPPopover)aPopOver
|
||||
@endcode
|
||||
*/
|
||||
@implementation CPPopover : CPResponder
|
||||
{
|
||||
@@ -62,12 +64,11 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
@outlet id _delegate @accessors(getter=delegate);
|
||||
|
||||
BOOL _animates @accessors(property=animates);
|
||||
BOOL _shown @accessors(getter=shown);
|
||||
int _appearance @accessors(property=appearance);
|
||||
int _behavior @accessors(getter=behavior);
|
||||
|
||||
BOOL _needsCompute;
|
||||
_CPAttachedWindow _attachedWindow;
|
||||
BOOL _needsNewAttachedWindow;
|
||||
int _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
@@ -84,11 +85,10 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_animates = YES;
|
||||
_appearance = CPPopoverAppearanceMinimal;
|
||||
_behavior = CPPopoverBehaviorApplicationDefined;
|
||||
_needsCompute = YES;
|
||||
_shown = NO;
|
||||
_animates = YES;
|
||||
_appearance = CPPopoverAppearanceMinimal;
|
||||
_behavior = CPPopoverBehaviorApplicationDefined;
|
||||
_needsNewAttachedWindow = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -101,11 +101,11 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
/*!
|
||||
Returns the current rect of the popover
|
||||
|
||||
@return CPRect represeting the frame of the popover
|
||||
@return CGRect representing the frame of the popover
|
||||
*/
|
||||
- (CPRect)positioningRect
|
||||
- (CGRect)positioningRect
|
||||
{
|
||||
if (!_attachedWindow || ![_attachedWindow isVisible])
|
||||
if (![_attachedWindow isVisible])
|
||||
return nil;
|
||||
return [_attachedWindow frame];
|
||||
}
|
||||
@@ -113,9 +113,9 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
/*! Sets the frame of the popover
|
||||
@param aRect the desired frame
|
||||
*/
|
||||
- (void)setPositioningRect:(CPRect)aRect
|
||||
- (void)setPositioningRect:(CGRect)aRect
|
||||
{
|
||||
if (!_attachedWindow || ![_attachedWindow isVisible])
|
||||
if (![_attachedWindow isVisible])
|
||||
return;
|
||||
[_attachedWindow setFrame:aRect];
|
||||
}
|
||||
@@ -123,11 +123,11 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
/*!
|
||||
Returns the size of the popover's view
|
||||
|
||||
@return CPSize represeting the size of the popover's view
|
||||
@return CGSize representing the size of the popover's view
|
||||
*/
|
||||
- (CPRect)contentSize
|
||||
- (CGSize)contentSize
|
||||
{
|
||||
if (!_attachedWindow || ![_attachedWindow isVisible])
|
||||
if (![_attachedWindow isVisible])
|
||||
return nil;
|
||||
return [[_contentViewController view] frameSize];
|
||||
}
|
||||
@@ -145,21 +145,20 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
/*!
|
||||
Indicates if CPPopover is visible
|
||||
|
||||
@returns YES if visible
|
||||
@returns \c YES if visible
|
||||
*/
|
||||
- (BOOL)shown
|
||||
{
|
||||
if (!_attachedWindow)
|
||||
return NO;
|
||||
return [_attachedWindow isVisible];
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the behaviour of the CPPopover. It can be
|
||||
- CPPopoverBehaviorTransient: the popover will be close if another control outside the popover become the responder
|
||||
- CPPopoverBehaviorApplicationDefined: (DEFAULT) the application is responsible for closing the popover
|
||||
Set the behaviour of the CPPopover. It can be:
|
||||
|
||||
@param aBehaviour the desired behaviour
|
||||
- \c CPPopoverBehaviorTransient: the popover will close if another control outside the popover becomes the responder
|
||||
- \c CPPopoverBehaviorApplicationDefined: (DEFAULT) the application is responsible for closing the popover
|
||||
|
||||
@param aBehaviour the desired behaviour
|
||||
*/
|
||||
- (void)setBehaviour:(int)aBehaviour
|
||||
{
|
||||
@@ -167,10 +166,9 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
return;
|
||||
|
||||
_behavior = aBehaviour;
|
||||
_needsCompute = YES;
|
||||
_needsNewAttachedWindow = YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
if (_delegate === aDelegate)
|
||||
@@ -203,20 +201,21 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
|
||||
@param positioningRect if set, the popover will be positionned to a random rect relative to the window
|
||||
@param positioningView if set, the popover will be positioned relative to this view
|
||||
@param preferredEdge: CPRectEdge representing the preferred positioning.
|
||||
@param preferredEdge: \c CPRectEdge representing the preferred positioning.
|
||||
*/
|
||||
- (void)showRelativeToRect:(CPRect)positioningRect ofView:(CPView)positioningView preferredEdge:(CPRectEdge)preferredEdge
|
||||
- (void)showRelativeToRect:(CGRect)positioningRect ofView:(CPView)positioningView preferredEdge:(CPRectEdge)preferredEdge
|
||||
{
|
||||
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
|
||||
[_delegate popoverWillShow:self];
|
||||
|
||||
if (!_contentViewController)
|
||||
[CPException raise:CPInternalInconsistencyException reason:@"contentViewController must not be nil"];
|
||||
|
||||
if (_needsCompute || !_attachedWindow)
|
||||
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
|
||||
[_delegate popoverWillShow:self];
|
||||
|
||||
if (!_attachedWindow || _needsNewAttachedWindow || [_attachedWindow isVisible])
|
||||
{
|
||||
var styleMask = (_behavior == CPPopoverBehaviorTransient) ? CPClosableOnBlurWindowMask : nil;
|
||||
_attachedWindow = [[_CPAttachedWindow alloc] initWithContentRect:CPRectMakeZero() styleMask:styleMask];
|
||||
_attachedWindow = [[_CPAttachedWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:styleMask];
|
||||
_needsNewAttachedWindow = NO;
|
||||
}
|
||||
|
||||
[_attachedWindow setAppearance:_appearance];
|
||||
@@ -251,8 +250,8 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
|
||||
[_attachedWindow close];
|
||||
|
||||
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didClose_)
|
||||
[_delegate popoverDidClose:self];
|
||||
// popoverDidClose will be sent from attachedWindowDidClose, since
|
||||
// the attached window will close asynchronously when animating.
|
||||
}
|
||||
|
||||
|
||||
@@ -278,14 +277,22 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
{
|
||||
[self close];
|
||||
|
||||
// we return NO, because we want the CPPopover to compute
|
||||
// if the attached can be close in order to send delegate messages
|
||||
// We return NO, because we want the CPPopover to determine
|
||||
// if the attached window can be closed and to give us a chance
|
||||
// to send delegate messages.
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (void)attachedWindowDidClose:(_CPAttachedWindow)anAttachedWindow
|
||||
{
|
||||
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didClose_)
|
||||
[_delegate popoverDidClose:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",
|
||||
var CPPopoverNeedsNewAttachedWindowKey = @"CPPopoverNeedsNewAttachedWindowKey",
|
||||
CPPopoverAppearanceKey = @"CPPopoverAppearanceKey",
|
||||
CPPopoverAnimatesKey = @"CPPopoverAnimatesKey",
|
||||
CPPopoverContentViewControllerKey = @"CPPopoverContentViewControllerKey",
|
||||
@@ -300,7 +307,7 @@ var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",
|
||||
|
||||
if (self)
|
||||
{
|
||||
_needsCompute = [aCoder decodeIntForKey:CPPopoverNeedsComputeKey];
|
||||
_needsNewAttachedWindow = [aCoder decodeBoolForKey:CPPopoverNeedsNewAttachedWindowKey];
|
||||
_appearance = [aCoder decodeIntForKey:CPPopoverAppearanceKey];
|
||||
_animates = [aCoder decodeBoolForKey:CPPopoverAnimatesKey];
|
||||
_contentViewController = [aCoder decodeObjectForKey:CPPopoverContentViewControllerKey];
|
||||
@@ -314,9 +321,9 @@ var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeBool:_needsCompute forKey:CPPopoverNeedsComputeKey];
|
||||
[aCoder encodeBool:_needsNewAttachedWindow forKey:CPPopoverNeedsNewAttachedWindowKey];
|
||||
[aCoder encodeInt:_appearance forKey:CPPopoverAppearanceKey];
|
||||
[aCoder encodeObject:_animates forKey:CPPopoverAnimatesKey];
|
||||
[aCoder encodeBool:_animates forKey:CPPopoverAnimatesKey];
|
||||
[aCoder encodeObject:_contentViewController forKey:CPPopoverContentViewControllerKey];
|
||||
[aCoder encodeObject:_delegate forKey:CPPopoverDelegateKey];
|
||||
[aCoder encodeInt:_behavior forKey:CPPopoverBehaviorKey];
|
||||
|
||||
@@ -477,7 +477,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
|
||||
_doubleValue = [aCoder decodeObjectForKey:@"_doubleValue"];
|
||||
_controlSize = [aCoder decodeObjectForKey:@"_controlSize"];
|
||||
_isIndeterminate = [aCoder decodeObjectForKey:@"_isIndeterminate"];
|
||||
_style = [aCoder decodeObjectForKey:@"_style"];
|
||||
_style = [aCoder decodeIntForKey:@"_style"];
|
||||
_isAnimating = [aCoder decodeObjectForKey:@"_isAnimating"];
|
||||
_isDisplayedWhenStoppedSet = [aCoder decodeObjectForKey:@"_isDisplayedWhenStoppedSet"];
|
||||
_isDisplayedWhenStopped = [aCoder decodeObjectForKey:@"_isDisplayedWhenStopped"];
|
||||
@@ -495,7 +495,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
|
||||
[aCoder encodeObject:_doubleValue forKey:@"_doubleValue"];
|
||||
[aCoder encodeObject:_controlSize forKey:@"_controlSize"];
|
||||
[aCoder encodeObject:_isIndeterminate forKey:@"_isIndeterminate"];
|
||||
[aCoder encodeObject:_style forKey:@"_style"];
|
||||
[aCoder encodeInt:_style forKey:@"_style"];
|
||||
[aCoder encodeObject:_isAnimating forKey:@"_isAnimating"];
|
||||
[aCoder encodeObject:_isDisplayedWhenStoppedSet forKey:@"_isDisplayedWhenStoppedSet"];
|
||||
[aCoder encodeObject:_isDisplayedWhenStopped forKey:@"_isDisplayedWhenStopped"];
|
||||
|
||||
+97
-71
@@ -30,40 +30,42 @@
|
||||
@import "CPScroller.j"
|
||||
@import "CPView.j"
|
||||
|
||||
#define SHOULD_SHOW_CORNER_VIEW() (_scrollerStyle === CPScrollerStyleLegacy && _verticalScroller && ![_verticalScroller isHidden])
|
||||
|
||||
|
||||
/*! @ignore */
|
||||
var _isSystemUsingOverlayScrollers = function()
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var inner = document.createElement('p'),
|
||||
outer = document.createElement('div');
|
||||
var inner = document.createElement('p'),
|
||||
outer = document.createElement('div');
|
||||
|
||||
inner.style.width = "100%";
|
||||
inner.style.height = "200px";
|
||||
inner.style.width = "100%";
|
||||
inner.style.height = "200px";
|
||||
|
||||
outer.style.position = "absolute";
|
||||
outer.style.top = "0px";
|
||||
outer.style.left = "0px";
|
||||
outer.style.visibility = "hidden";
|
||||
outer.style.width = "200px";
|
||||
outer.style.height = "150px";
|
||||
outer.style.overflow = "hidden";
|
||||
outer.appendChild (inner);
|
||||
outer.style.position = "absolute";
|
||||
outer.style.top = "0px";
|
||||
outer.style.left = "0px";
|
||||
outer.style.visibility = "hidden";
|
||||
outer.style.width = "200px";
|
||||
outer.style.height = "150px";
|
||||
outer.style.overflow = "hidden";
|
||||
outer.appendChild (inner);
|
||||
|
||||
document.body.appendChild (outer);
|
||||
var w1 = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
var w2 = inner.offsetWidth;
|
||||
if (w1 == w2)
|
||||
w2 = outer.clientWidth;
|
||||
document.body.appendChild (outer);
|
||||
var w1 = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
var w2 = inner.offsetWidth;
|
||||
if (w1 == w2)
|
||||
w2 = outer.clientWidth;
|
||||
|
||||
document.body.removeChild (outer);
|
||||
document.body.removeChild (outer);
|
||||
|
||||
return (w1 - w2 == 0);
|
||||
return (w1 - w2 == 0);
|
||||
#else
|
||||
return NO;
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -272,7 +274,19 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the delegate of the scroll view
|
||||
Sets the delegate of the scroll view.
|
||||
Possible delegate methods to implement are listed below.
|
||||
|
||||
Notifies the delegate when the scroll view is about to scroll.
|
||||
@code
|
||||
- (void)scrollViewWillScroll:(CPScrollView)aScrollView
|
||||
@endcode
|
||||
|
||||
Notifies the delegate when the scroll view has finished scrolling.
|
||||
@code
|
||||
- (void)scrollViewDidScroll:(CPScrollView)aScrollView
|
||||
@endcode
|
||||
|
||||
*/
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
@@ -813,10 +827,15 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
_cornerView = documentCornerView;
|
||||
|
||||
if (_cornerView)
|
||||
{
|
||||
[_cornerView setHidden:!SHOULD_SHOW_CORNER_VIEW()];
|
||||
[self addSubview:_cornerView];
|
||||
}
|
||||
}
|
||||
|
||||
[self reflectScrolledClipView:_contentView];
|
||||
[documentHeaderView setNeedsLayout];
|
||||
[documentHeaderView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -851,7 +870,8 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
var frame = [self _insetBounds];
|
||||
|
||||
frame.size.height = _CGRectGetHeight([headerView frame]);
|
||||
frame.size.width -= _CGRectGetWidth([self _cornerViewFrame]);
|
||||
if (SHOULD_SHOW_CORNER_VIEW())
|
||||
frame.size.width -= _CGRectGetWidth([self _cornerViewFrame]);
|
||||
|
||||
return frame;
|
||||
}
|
||||
@@ -1138,8 +1158,9 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
if (_scrollerStyle === CPScrollerStyleOverlay && hasHorizontalScroll)
|
||||
verticalScrollerHeight -= horizontalScrollerHeight;
|
||||
|
||||
var documentHeight = _CGRectGetHeight(documentFrame);
|
||||
[_verticalScroller setFloatValue:(difference.height <= 0.0) ? 0.0 : scrollPoint.y / difference.height];
|
||||
[_verticalScroller setKnobProportion:_CGRectGetHeight(contentFrame) / _CGRectGetHeight(documentFrame)];
|
||||
[_verticalScroller setKnobProportion:documentHeight > 0 ? _CGRectGetHeight(contentFrame) / documentHeight : 1.0];
|
||||
[_verticalScroller setFrame:_CGRectMake(_CGRectGetMaxX(contentFrame) - overlay, verticalScrollerY, verticalScrollerWidth, verticalScrollerHeight)];
|
||||
}
|
||||
else if (wasShowingVerticalScroller)
|
||||
@@ -1155,8 +1176,10 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
if (_scrollerStyle === CPScrollerStyleOverlay && hasVerticalScroll)
|
||||
horizontalScrollerWidth -= verticalScrollerWidth;
|
||||
|
||||
var documentWidth = _CGRectGetWidth(documentFrame);
|
||||
|
||||
[_horizontalScroller setFloatValue:(difference.width <= 0.0) ? 0.0 : scrollPoint.x / difference.width];
|
||||
[_horizontalScroller setKnobProportion:_CGRectGetWidth(contentFrame) / _CGRectGetWidth(documentFrame)];
|
||||
[_horizontalScroller setKnobProportion:documentWidth > 0 ? _CGRectGetWidth(contentFrame) / documentWidth : 1.0];
|
||||
[_horizontalScroller setFrame:_CGRectMake(_CGRectGetMinX(contentFrame), _CGRectGetMaxY(contentFrame) - overlay, horizontalScrollerWidth, horizontalScrollerHeight)];
|
||||
}
|
||||
else if (wasShowingHorizontalScroller)
|
||||
@@ -1166,9 +1189,15 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
}
|
||||
|
||||
[_contentView setFrame:contentFrame];
|
||||
[_headerClipView setFrame:headerClipViewFrame];
|
||||
[_headerClipView setFrame:[self _headerClipViewFrame]];
|
||||
[[_headerClipView documentView] setNeedsDisplay:YES];
|
||||
[_cornerView setFrame:[self _cornerViewFrame]];
|
||||
if (SHOULD_SHOW_CORNER_VIEW())
|
||||
{
|
||||
[_cornerView setFrame:[self _cornerViewFrame]];
|
||||
[_cornerView setHidden:NO];
|
||||
}
|
||||
else
|
||||
[_cornerView setHidden:YES];
|
||||
|
||||
if (_scrollerStyle === CPScrollerStyleLegacy)
|
||||
{
|
||||
@@ -1248,70 +1277,67 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
|
||||
- (void)_drawGrayBezelInContext:(CGContext)context bounds:(CGRect)aRect
|
||||
{
|
||||
CGContextBeginPath(context);
|
||||
var minX = _CGRectGetMinX(aRect),
|
||||
maxX = _CGRectGetMaxX(aRect),
|
||||
minY = _CGRectGetMinY(aRect),
|
||||
maxY = _CGRectGetMaxY(aRect),
|
||||
y = minY + 0.5;
|
||||
|
||||
// Slightly darker line on top.
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithWhite:142.0 / 255.0 alpha:1.0]);
|
||||
|
||||
var y = _CGRectGetMinY(aRect) + 0.5;
|
||||
|
||||
CGContextMoveToPoint(context, _CGRectGetMinX(aRect), y);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMinX(aRect) + 1.0, y);
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, minX, y);
|
||||
CGContextAddLineToPoint(context, maxX, y);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
// The rest of the border.
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithWhite:192.0 / 255.0 alpha:1.0]);
|
||||
CGContextMoveToPoint(context, _CGRectGetMinX(aRect) + 1.0, y);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMaxX(aRect) - 1.0, y);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
var x = maxX - 0.5;
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithWhite:142.0 / 255.0 alpha:1.0]);
|
||||
CGContextMoveToPoint(context, _CGRectGetMaxX(aRect) - 1.0, y);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMaxX(aRect), y);
|
||||
CGContextStrokePath(context);
|
||||
CGContextMoveToPoint(context, x, minY + 1.0);
|
||||
CGContextAddLineToPoint(context, x, maxY);
|
||||
CGContextMoveToPoint(context, x - 0.5, maxY - 0.5);
|
||||
CGContextAddLineToPoint(context, minX, maxY - 0.5);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithWhite:190.0 / 255.0 alpha:1.0]);
|
||||
x = minX + 0.5;
|
||||
|
||||
var x = _CGRectGetMaxX(aRect) - 0.5;
|
||||
|
||||
CGContextMoveToPoint(context, x, _CGRectGetMinY(aRect) + 1.0);
|
||||
CGContextAddLineToPoint(context, x, _CGRectGetMaxY(aRect));
|
||||
|
||||
CGContextMoveToPoint(context, x - 0.5, _CGRectGetMaxY(aRect) - 0.5);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMinX(aRect), _CGRectGetMaxY(aRect) - 0.5);
|
||||
|
||||
x = _CGRectGetMinX(aRect) + 0.5;
|
||||
|
||||
CGContextMoveToPoint(context, x, _CGRectGetMaxY(aRect));
|
||||
CGContextAddLineToPoint(context, x, _CGRectGetMinY(aRect) + 1.0);
|
||||
CGContextMoveToPoint(context, x, maxY);
|
||||
CGContextAddLineToPoint(context, x, minY + 1.0);
|
||||
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
|
||||
- (void)_drawGrooveInContext:(CGContext)context bounds:(CGRect)aRect
|
||||
{
|
||||
var minX = _CGRectGetMinX(aRect),
|
||||
maxX = _CGRectGetMaxX(aRect),
|
||||
minY = _CGRectGetMinY(aRect),
|
||||
maxY = _CGRectGetMaxY(aRect);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithWhite:159.0 / 255.0 alpha:1.0]);
|
||||
|
||||
var y = _CGRectGetMinY(aRect) + 0.5;
|
||||
var y = minY + 0.5;
|
||||
|
||||
CGContextMoveToPoint(context, _CGRectGetMinX(aRect), y);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMaxX(aRect), y);
|
||||
CGContextMoveToPoint(context, minX, y);
|
||||
CGContextAddLineToPoint(context, maxX, y);
|
||||
|
||||
var x = _CGRectGetMaxX(aRect) - 1.5;
|
||||
var x = maxX - 1.5;
|
||||
|
||||
CGContextMoveToPoint(context, x, _CGRectGetMinY(aRect) + 2.0);
|
||||
CGContextAddLineToPoint(context, x, _CGRectGetMaxY(aRect) - 1.0);
|
||||
CGContextMoveToPoint(context, x, minY + 2.0);
|
||||
CGContextAddLineToPoint(context, x, maxY - 1.0);
|
||||
|
||||
y = _CGRectGetMaxY(aRect) - 1.5;
|
||||
y = maxY - 1.5;
|
||||
|
||||
CGContextMoveToPoint(context, _CGRectGetMaxX(aRect) - 1.0, y);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMinX(aRect) + 2.0, y);
|
||||
CGContextMoveToPoint(context, maxX - 1.0, y);
|
||||
CGContextAddLineToPoint(context, minX + 2.0, y);
|
||||
|
||||
x = _CGRectGetMinX(aRect) + 0.5;
|
||||
x = minX + 0.5;
|
||||
|
||||
CGContextMoveToPoint(context, x, _CGRectGetMaxY(aRect));
|
||||
CGContextAddLineToPoint(context, x, _CGRectGetMinY(aRect));
|
||||
CGContextMoveToPoint(context, x, maxY);
|
||||
CGContextAddLineToPoint(context, x, minY);
|
||||
|
||||
CGContextStrokePath(context);
|
||||
|
||||
@@ -1327,10 +1353,10 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
|
||||
CGContextBeginPath(context);
|
||||
CGContextSetStrokeColor(context, [CPColor colorWithWhite:192.0 / 255.0 alpha:1.0]);
|
||||
|
||||
y = _CGRectGetMinY(aRect) + 2.5;
|
||||
y = minY + 2.5;
|
||||
|
||||
CGContextMoveToPoint(context, _CGRectGetMinX(aRect) + 2.0, y);
|
||||
CGContextAddLineToPoint(context, _CGRectGetMaxX(aRect) - 2.0, y);
|
||||
CGContextMoveToPoint(context, minX + 2.0, y);
|
||||
CGContextAddLineToPoint(context, maxX - 2.0, y);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -23,6 +23,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "../Foundation/Foundation.h"
|
||||
|
||||
@import "CPControl.j"
|
||||
|
||||
// CPScroller Constants
|
||||
@@ -260,6 +262,9 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
*/
|
||||
- (void)setKnobProportion:(float)aProportion
|
||||
{
|
||||
if (!_IS_NUMERIC(aProportion))
|
||||
[CPException raise:CPInvalidArgumentException reason:"aProportion must be numeric"];
|
||||
|
||||
_knobProportion = MIN(1.0, MAX(0.0001, aProportion));
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
@@ -521,7 +526,8 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
|
||||
[self checkSpaceForParts];
|
||||
|
||||
var index = 0,
|
||||
count = PARTS_ARRANGEMENT.length;
|
||||
count = PARTS_ARRANGEMENT.length,
|
||||
view;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
|
||||
+38
-37
@@ -47,7 +47,6 @@ var LIGHT_LEFT_INSET = 3.0,
|
||||
/*!
|
||||
@ingroup appkit
|
||||
*/
|
||||
|
||||
@implementation CPShadowView : CPView
|
||||
{
|
||||
CPShadowWeight _weight;
|
||||
@@ -60,35 +59,33 @@ var LIGHT_LEFT_INSET = 3.0,
|
||||
|
||||
var bundle = [CPBundle bundleForClass:[self class]];
|
||||
|
||||
CPShadowViewLightBackgroundColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
|
||||
[
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightTopLeft.png"] size:CGSizeMake(9.0, 9.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightTop.png"] size:CGSizeMake(1.0, 9.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightTopRight.png"] size:CGSizeMake(9.0, 9.0)],
|
||||
CPShadowViewLightBackgroundColor = CPColorWithImages([
|
||||
[@"CPShadowView/CPShadowViewLightTopLeft.png", 9.0, 9.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewLightTop.png", 1.0, 9.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewLightTopRight.png", 9.0, 9.0, bundle],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightLeft.png"] size:CGSizeMake(9.0, 1.0)],
|
||||
nil,
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightRight.png"] size:CGSizeMake(9.0, 1.0)],
|
||||
[@"CPShadowView/CPShadowViewLightLeft.png", 9.0, 1.0, bundle],
|
||||
nil,
|
||||
[@"CPShadowView/CPShadowViewLightRight.png", 9.0, 1.0, bundle],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightBottomLeft.png"] size:CGSizeMake(9.0, 9.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightBottom.png"] size:CGSizeMake(1.0, 9.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewLightBottomRight.png"] size:CGSizeMake(9.0, 9.0)]
|
||||
]]];
|
||||
[@"CPShadowView/CPShadowViewLightBottomLeft.png", 9.0, 9.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewLightBottom.png", 1.0, 9.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewLightBottomRight.png", 9.0, 9.0, bundle]
|
||||
]);
|
||||
|
||||
CPShadowViewHeavyBackgroundColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
|
||||
[
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyTopLeft.png"] size:CGSizeMake(17.0, 17.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyTop.png"] size:CGSizeMake(1.0, 17.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyTopRight.png"] size:CGSizeMake(17.0, 17.0)],
|
||||
CPShadowViewHeavyBackgroundColor = CPColorWithImages([
|
||||
[@"CPShadowView/CPShadowViewHeavyTopLeft.png", 17.0, 17.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewHeavyTop.png", 1.0, 17.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewHeavyTopRight.png", 17.0, 17.0, bundle],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyLeft.png"] size:CGSizeMake(17.0, 1.0)],
|
||||
nil,
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyRight.png"] size:CGSizeMake(17.0, 1.0)],
|
||||
[@"CPShadowView/CPShadowViewHeavyLeft.png", 17.0, 1.0, bundle],
|
||||
nil,
|
||||
[@"CPShadowView/CPShadowViewHeavyRight.png", 17.0, 1.0, bundle],
|
||||
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyBottomLeft.png"] size:CGSizeMake(17.0, 17.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyBottom.png"] size:CGSizeMake(1.0, 17.0)],
|
||||
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPShadowView/CPShadowViewHeavyBottomRight.png"] size:CGSizeMake(17.0, 17.0)]
|
||||
]]];
|
||||
[@"CPShadowView/CPShadowViewHeavyBottomLeft.png", 17.0, 17.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewHeavyBottom.png", 1.0, 17.0, bundle],
|
||||
[@"CPShadowView/CPShadowViewHeavyBottomRight.png", 17.0, 17.0, bundle]
|
||||
]);
|
||||
}
|
||||
|
||||
+ (id)shadowViewEnclosingView:(CPView)aView
|
||||
@@ -98,20 +95,24 @@ var LIGHT_LEFT_INSET = 3.0,
|
||||
|
||||
+ (id)shadowViewEnclosingView:(CPView)aView withWeight:(CPShadowWeight)aWeight
|
||||
{
|
||||
var shadowView = [[CPShadowView alloc] initWithFrame:[aView frame]];
|
||||
[shadowView setWeight:aWeight];
|
||||
var shadowView = [[self alloc] initWithFrame:[aView frame]];
|
||||
|
||||
var size = [shadowView frame].size,
|
||||
width = size.width - [shadowView leftInset] - [shadowView rightInset],
|
||||
height = size.height - [shadowView topInset] - [shadowView bottomInset],
|
||||
enclosingView = [aView superview];
|
||||
if (shadowView)
|
||||
{
|
||||
[shadowView setWeight:aWeight];
|
||||
|
||||
[shadowView setHitTests:[aView hitTests]];
|
||||
[shadowView setAutoresizingMask:[aView autoresizingMask]];
|
||||
[aView removeFromSuperview];
|
||||
[shadowView addSubview:aView];
|
||||
[aView setFrame:CGRectMake([shadowView leftInset], [shadowView topInset], width, height)]
|
||||
[enclosingView addSubview:shadowView];
|
||||
var size = [shadowView frame].size,
|
||||
width = size.width - [shadowView leftInset] - [shadowView rightInset],
|
||||
height = size.height - [shadowView topInset] - [shadowView bottomInset],
|
||||
enclosingView = [aView superview];
|
||||
|
||||
[shadowView setHitTests:[aView hitTests]];
|
||||
[shadowView setAutoresizingMask:[aView autoresizingMask]];
|
||||
[aView removeFromSuperview];
|
||||
[shadowView addSubview:aView];
|
||||
[aView setFrame:CGRectMake([shadowView leftInset], [shadowView topInset], width, height)]
|
||||
[enclosingView addSubview:shadowView];
|
||||
}
|
||||
|
||||
return shadowView;
|
||||
}
|
||||
|
||||
+67
-27
@@ -773,66 +773,97 @@ var CPSplitViewHorizontalImage = nil,
|
||||
return;
|
||||
}
|
||||
|
||||
var count = [_subviews count];
|
||||
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
SPLIT_VIEW_MAYBE_POST_WILL_RESIZE();
|
||||
[self _postNotificationWillResize];
|
||||
|
||||
var index = 0,
|
||||
count = [_subviews count],
|
||||
bounds = [self bounds],
|
||||
boundsSize = bounds.size[_sizeComponent],
|
||||
dividerThickness = [self dividerThickness],
|
||||
totalDividers = count - 1,
|
||||
totalSizableSpace = 0,
|
||||
nonSizableSpace = 0,
|
||||
lastSizableIndex = -1,
|
||||
oldFlexibleSpace = 0,
|
||||
totalSizablePanes = 0,
|
||||
isVertical = [self isVertical];
|
||||
isSizableMap = {},
|
||||
viewSizes = [],
|
||||
delegateRespondsToShouldAdjust = [_delegate respondsToSelector:@selector(splitView:shouldAdjustSizeOfSubview:)];
|
||||
|
||||
// What we want to do is to preserve non resizable sizes first, and then to preserve the ratio of size to available
|
||||
// non fixed space for every other subview. E.g. assume fixed space was 20 pixels initially, view 1 was 20 and
|
||||
// view 2 was 30 pixels, for a total of 70 pixels. Then the new total size becomes 140 pixels. Now we want the fixed
|
||||
// space to still be 20 pixels, view 1 to be 48 pixels and view 2 to be 72 pixels. This way the relative size of
|
||||
// view 1 to view 2 remains the same - view 1 was 66% of view 2 initially and after the resize view 1 is still
|
||||
// 66% of view 2's size.
|
||||
//
|
||||
// For this calculation, we can consider the dividers themselves to also be fixed size areas - they should remain
|
||||
// the same size before and after.
|
||||
|
||||
// How much flexible size do we have in pre-resize pixels?
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var view = _subviews[index],
|
||||
isSizable = isVertical ? [view autoresizingMask] & CPViewWidthSizable : [view autoresizingMask] & CPViewHeightSizable;
|
||||
isSizable = !delegateRespondsToShouldAdjust || [_delegate splitView:self shouldAdjustSizeOfSubview:view],
|
||||
size = [view frame].size[_sizeComponent];
|
||||
|
||||
isSizableMap[index] = isSizable;
|
||||
|
||||
viewSizes.push(size);
|
||||
if (isSizable)
|
||||
{
|
||||
totalSizableSpace += [view frame].size[_sizeComponent];
|
||||
lastSizableIndex = index;
|
||||
oldFlexibleSpace += size;
|
||||
totalSizablePanes++;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalSizablePanes === count)
|
||||
totalSizableSpace = 0;
|
||||
// nonSizableSpace is the number of fixed pixels in pre-resize terms and the desired number post-resize.
|
||||
var nonSizableSpace = oldSize[_sizeComponent] - oldFlexibleSpace,
|
||||
newFlexibleSpace = boundsSize - nonSizableSpace,
|
||||
remainingFixedPixelsToRemove = 0;
|
||||
|
||||
var nonSizableSpace = totalSizableSpace ? bounds.size[_sizeComponent] - totalSizableSpace : 0,
|
||||
remainingFlexibleSpace = bounds.size[_sizeComponent] - oldSize[_sizeComponent],
|
||||
oldDimension = (oldSize[_sizeComponent] - totalDividers * dividerThickness - nonSizableSpace),
|
||||
ratio = oldDimension <= 0 ? 0 : (bounds.size[_sizeComponent] - totalDividers * dividerThickness - nonSizableSpace) / oldDimension;
|
||||
if (newFlexibleSpace < 0)
|
||||
{
|
||||
remainingFixedPixelsToRemove = -newFlexibleSpace;
|
||||
newFlexibleSpace = 0;
|
||||
}
|
||||
|
||||
var remainingFixedPanes = count - totalSizablePanes;
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var view = _subviews[index],
|
||||
viewFrame = CGRectMakeCopy(bounds),
|
||||
isSizable = isVertical ? [view autoresizingMask] & CPViewWidthSizable : [view autoresizingMask] & CPViewHeightSizable;
|
||||
isSizable = isSizableMap[index],
|
||||
targetSize = 0;
|
||||
|
||||
// The last area must take up exactly the remaining space, fixed or not.
|
||||
if (index + 1 === count)
|
||||
viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] - viewFrame.origin[_originComponent];
|
||||
|
||||
else if (totalSizableSpace && isSizable && lastSizableIndex === index)
|
||||
viewFrame.size[_sizeComponent] = MAX(0, ROUND([view frame].size[_sizeComponent] + remainingFlexibleSpace))
|
||||
|
||||
else if (isSizable || !totalSizableSpace)
|
||||
targetSize = boundsSize - viewFrame.origin[_originComponent];
|
||||
// Try to keep fixed size areas the same size.
|
||||
else if (!isSizable)
|
||||
{
|
||||
viewFrame.size[_sizeComponent] = MAX(0, ROUND(ratio * [view frame].size[_sizeComponent]));
|
||||
remainingFlexibleSpace -= (viewFrame.size[_sizeComponent] - [view frame].size[_sizeComponent]);
|
||||
var removedFixedPixels = MIN(remainingFixedPixelsToRemove / remainingFixedPanes, viewSizes[index]);
|
||||
targetSize = viewSizes[index] - removedFixedPixels;
|
||||
remainingFixedPixelsToRemove -= removedFixedPixels;
|
||||
remainingFixedPanes--;
|
||||
}
|
||||
// (new size / flexible size available) == (old size / old flexible size available)
|
||||
else if (oldFlexibleSpace > 0)
|
||||
targetSize = newFlexibleSpace * viewSizes[index] / oldFlexibleSpace;
|
||||
// oldFlexibleSpace <= 0 so all flexible areas were crushed. When we get space, allocate it evenly.
|
||||
// totalSizablePanes cannot be 0 since isSizable.
|
||||
else
|
||||
targetSize = newFlexibleSpace / totalSizablePanes;
|
||||
|
||||
else if (totalSizableSpace && !isSizable)
|
||||
viewFrame.size[_sizeComponent] = [view frame].size[_sizeComponent];
|
||||
targetSize = MAX(0, ROUND(targetSize));
|
||||
|
||||
bounds.origin[_originComponent] += viewFrame.size[_sizeComponent] + dividerThickness;
|
||||
viewFrame.size[_sizeComponent] = targetSize;
|
||||
|
||||
[view setFrame:viewFrame];
|
||||
|
||||
bounds.origin[_originComponent] += targetSize + dividerThickness;
|
||||
}
|
||||
|
||||
SPLIT_VIEW_MAYBE_POST_DID_RESIZE();
|
||||
@@ -852,6 +883,11 @@ Notifies the delegate when the subviews will be resized.
|
||||
- (void)splitViewWillResizeSubviews:(CPNotification)aNotification;
|
||||
@endcode
|
||||
|
||||
Allows the delegate to specify which of the CPSplitView's subviews should adjust if the window is resized.
|
||||
@code
|
||||
- (BOOL)splitView:(CPSplitView)aSplitView shouldAdjustSizeOfSubview:(CPView)aSubView
|
||||
@endcode
|
||||
|
||||
Lets the delegate specify a different rect for which the user can drag the splitView divider.
|
||||
@code
|
||||
- (CGRect)splitView:(CPSplitView)aSplitView effectiveRect:(CGRect)aRect forDrawnRect:(CGRect)aDrawnRect ofDividerAtIndex:(int)aDividerIndex;
|
||||
@@ -1002,7 +1038,7 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (void)_autosave
|
||||
{
|
||||
if (!_shouldAutosave)
|
||||
if (!_shouldAutosave || !autosaveName)
|
||||
return;
|
||||
|
||||
var userDefaults = [CPUserDefaults standardUserDefaults],
|
||||
@@ -1068,6 +1104,8 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (CPString)_framesKeyForAutosaveName:(CPString)theAutosaveName
|
||||
{
|
||||
if (!theAutosaveName)
|
||||
return nil;
|
||||
return @"CPSplitView Subview Frames " + theAutosaveName;
|
||||
}
|
||||
|
||||
@@ -1076,6 +1114,8 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (CPString)_precollapseKeyForAutosaveName:(CPString)theAutosaveName
|
||||
{
|
||||
if (!theAutosaveName)
|
||||
return nil;
|
||||
return @"CPSplitView Subview Precollapse Positions " + theAutosaveName;
|
||||
}
|
||||
|
||||
|
||||
+57
-29
@@ -34,6 +34,7 @@
|
||||
@implementation CPStepper: CPControl
|
||||
{
|
||||
BOOL _valueWraps @accessors(property=valueWraps);
|
||||
BOOL _autorepeat @accessors(getter=autorepeat);
|
||||
int _increment @accessors(property=increment);
|
||||
int _maxValue @accessors(property=maxValue);
|
||||
int _minValue @accessors(property=minValue);
|
||||
@@ -88,29 +89,38 @@
|
||||
_minValue = 0.0;
|
||||
_increment = 1.0;
|
||||
_valueWraps = YES;
|
||||
_autorepeat = YES;
|
||||
|
||||
[self setDoubleValue:0.0];
|
||||
|
||||
_buttonUp = [[CPButton alloc] initWithFrame:_CGRectMakeZero()];
|
||||
[_buttonUp setContinuous:YES];
|
||||
[_buttonUp setTarget:self];
|
||||
[_buttonUp setAction:@selector(_buttonDidClick:)];
|
||||
[_buttonUp setAutoresizingMask:CPViewNotSizable];
|
||||
[self addSubview:_buttonUp];
|
||||
|
||||
_buttonDown = [[CPButton alloc] initWithFrame:_CGRectMakeZero()];
|
||||
[_buttonDown setContinuous:YES];
|
||||
[_buttonDown setTarget:self];
|
||||
[_buttonDown setAction:@selector(_buttonDidClick:)];
|
||||
[_buttonDown setAutoresizingMask:CPViewNotSizable];
|
||||
[self addSubview:_buttonDown];
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self _init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
_buttonUp = [[CPButton alloc] initWithFrame:_CGRectMakeZero()];
|
||||
[_buttonUp setContinuous:_autorepeat];
|
||||
[_buttonUp setTarget:self];
|
||||
[_buttonUp setAction:@selector(_buttonDidClick:)];
|
||||
[_buttonUp setAutoresizingMask:CPViewNotSizable];
|
||||
[self addSubview:_buttonUp];
|
||||
|
||||
_buttonDown = [[CPButton alloc] initWithFrame:_CGRectMakeZero()];
|
||||
[_buttonDown setContinuous:_autorepeat];
|
||||
[_buttonDown setTarget:self];
|
||||
[_buttonDown setAction:@selector(_buttonDidClick:)];
|
||||
[_buttonDown setAutoresizingMask:CPViewNotSizable];
|
||||
|
||||
[self setContinuous:_autorepeat];
|
||||
[self addSubview:_buttonDown];
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Superclass overrides
|
||||
|
||||
@@ -164,8 +174,13 @@
|
||||
*/
|
||||
- (void)setAutorepeat:(BOOL)shouldAutoRepeat
|
||||
{
|
||||
[_buttonUp setContinuous:shouldAutoRepeat];
|
||||
[_buttonDown setContinuous:shouldAutoRepeat];
|
||||
if (shouldAutoRepeat !== _autorepeat)
|
||||
{
|
||||
[_buttonUp setContinuous:shouldAutoRepeat];
|
||||
[_buttonDown setContinuous:shouldAutoRepeat];
|
||||
}
|
||||
|
||||
[self setContinuous:shouldAutoRepeat];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -235,19 +250,27 @@
|
||||
|
||||
@end
|
||||
|
||||
var CPStepperMinValue = @"CPStepperMinValue",
|
||||
CPStepperMaxValue = @"CPStepperMaxValue",
|
||||
CPStepperValueWraps = @"CPStepperValueWraps",
|
||||
CPStepperAutorepeat = @"CPStepperAutorepeat",
|
||||
CPStepperIncrement = @"CPStepperIncrement";
|
||||
|
||||
@implementation CPStepper (CPCodingCompliance)
|
||||
@implementation CPStepper (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self = [super initWithCoder:aCoder])
|
||||
{
|
||||
_maxValue = [aCoder decodeObjectForKey:@"_maxValue"];
|
||||
_minValue = [aCoder decodeObjectForKey:@"_minValue"];
|
||||
_increment = [aCoder decodeObjectForKey:@"_increment"];
|
||||
_buttonUp = [aCoder decodeObjectForKey:@"_buttonUp"];
|
||||
_buttonDown = [aCoder decodeObjectForKey:@"_buttonDown"];
|
||||
_increment = [aCoder decodeIntForKey:CPStepperIncrement];
|
||||
_minValue = [aCoder decodeIntForKey:CPStepperMinValue] || 0;
|
||||
_maxValue = [aCoder decodeIntForKey:CPStepperMaxValue] || 0;
|
||||
_valueWraps = [aCoder decodeBoolForKey:CPStepperValueWraps] || NO;
|
||||
_autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat] || NO;
|
||||
|
||||
[self _init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -255,11 +278,16 @@
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject:_maxValue forKey:@"_maxValue"];
|
||||
[aCoder encodeObject:_minValue forKey:@"_minValue"];
|
||||
[aCoder encodeObject:_increment forKey:@"_increment"];
|
||||
[aCoder encodeObject:_buttonUp forKey:@"_buttonUp"];
|
||||
[aCoder encodeObject:_buttonDown forKey:@"_buttonDown"];
|
||||
[aCoder encodeInt:_increment forKey:CPStepperIncrement];
|
||||
|
||||
if (_minValue)
|
||||
[aCoder encodeInt:_minValue forKey:CPStepperMinValue];
|
||||
if (_maxValue)
|
||||
[aCoder encodeInt:_maxValue forKey:CPStepperMaxValue];
|
||||
if (_valueWraps)
|
||||
[aCoder encodeBool:_valueWraps forKey:CPStepperValueWraps];
|
||||
if (_autorepeat)
|
||||
[aCoder encodeBool:_autorepeat forKey:CPStepperAutorepeat];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+40
-9
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* CPTabView.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Derek Hammer.
|
||||
* Copyright 2010, Derek Hammer.
|
||||
*
|
||||
* 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 "CPBox.j"
|
||||
@import "CPSegmentedControl.j"
|
||||
@import "CPTabViewItem.j"
|
||||
@@ -45,7 +67,6 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
{
|
||||
_items = [CPArray array];
|
||||
_selectedIndex = CPNotFound;
|
||||
|
||||
[self _init];
|
||||
[self setTabViewType:CPTopTabsBezelBorder];
|
||||
@@ -56,6 +77,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
_selectedIndex = CPNotFound;
|
||||
|
||||
_tabs = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
|
||||
[_tabs setHitTests:NO];
|
||||
|
||||
@@ -252,8 +275,6 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
*/
|
||||
- (void)selectTabViewItemAtIndex:(unsigned)anIndex
|
||||
{
|
||||
var aTabViewItem = [_items objectAtIndex:anIndex];
|
||||
|
||||
if (anIndex === _selectedIndex)
|
||||
return;
|
||||
|
||||
@@ -278,7 +299,10 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
*/
|
||||
- (CPTabViewItem)selectedTabViewItem
|
||||
{
|
||||
return [_items objectAtIndex:_selectedIndex];
|
||||
if (_selectedIndex != CPNotFound)
|
||||
return [_items objectAtIndex:_selectedIndex];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Modifying the font
|
||||
@@ -428,8 +452,12 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
|
||||
- (void)_setSelectedIndex:(CPNumber)index
|
||||
{
|
||||
_selectedIndex = index;
|
||||
[self _setContentViewForItem:[_items objectAtIndex:_selectedIndex]];
|
||||
}
|
||||
|
||||
[_box setContentView:[[_items objectAtIndex:_selectedIndex] view]];
|
||||
- (void)_setContentViewForItem:(CPTabViewItem)anItem
|
||||
{
|
||||
[_box setContentView:[anItem view]];
|
||||
}
|
||||
|
||||
- (void)_updateItems
|
||||
@@ -469,17 +497,17 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
[_tabs setFont:_font];
|
||||
|
||||
_items = [aCoder decodeObjectForKey:CPTabViewItemsKey];
|
||||
[_items makeObjectsPerformSelector:@selector(_setTabView:) withObject:self];
|
||||
|
||||
[self _updateItems];
|
||||
[self _repositionTabs];
|
||||
|
||||
var selected = [aCoder decodeObjectForKey:CPTabViewSelectedItemKey];
|
||||
[self setDelegate:[aCoder decodeObjectForKey:CPTabViewDelegateKey]];
|
||||
|
||||
var selected = [aCoder decodeObjectForKey:CPTabViewSelectedItemKey];
|
||||
if (selected)
|
||||
[self selectTabViewItem:selected];
|
||||
|
||||
[self setDelegate:[aCoder decodeObjectForKey:CPTabViewDelegateKey]];
|
||||
|
||||
[self setTabViewType:[aCoder decodeIntForKey:CPTabViewTypeKey]];
|
||||
}
|
||||
|
||||
@@ -491,7 +519,10 @@ var CPTabViewItemsKey = "CPTabViewItemsKey",
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject:_items forKey:CPTabViewItemsKey];
|
||||
[aCoder encodeObject:[self selectedTabViewItem] forKey:CPTabViewSelectedItemKey];
|
||||
|
||||
var selected = [self selectedTabViewItem];
|
||||
if (selected)
|
||||
[aCoder encodeObject:selected forKey:CPTabViewSelectedItemKey];
|
||||
|
||||
[aCoder encodeInt:_type forKey:CPTabViewTypeKey];
|
||||
[aCoder encodeObject:_font forKey:CPTabViewFontKey];
|
||||
|
||||
@@ -132,7 +132,13 @@ CPPressedTab = 2;
|
||||
*/
|
||||
- (void)setView:(CPView)aView
|
||||
{
|
||||
if (_view == aView)
|
||||
return;
|
||||
|
||||
_view = aView;
|
||||
|
||||
if ([_tabView selectedTabViewItem] == self)
|
||||
[_tabView _setContentViewForItem:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -734,7 +734,6 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
|
||||
[self setIdentifier:[aCoder decodeObjectForKey:CPTableColumnIdentifierKey]];
|
||||
[self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
|
||||
[self setDataView:[aCoder decodeObjectForKey:CPTableColumnDataViewKey]];
|
||||
[self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
|
||||
|
||||
_resizingMask = [aCoder decodeIntForKey:CPTableColumnResizingMaskKey];
|
||||
_isHidden = [aCoder decodeBoolForKey:CPTableColumnIsHiddenKey];
|
||||
|
||||
@@ -643,7 +643,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
|
||||
columnMaxX = _CGRectGetMaxX(columnToStroke);
|
||||
|
||||
CGContextMoveToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(_CGRectGetMinY(columnToStroke)));
|
||||
CGContextAddLineToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(_CGRectGetMaxY(columnToStroke)));
|
||||
CGContextAddLineToPoint(context, FLOOR(columnMaxX) - 0.5, ROUND(_CGRectGetMaxY(columnToStroke)) - 1.0);
|
||||
}
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
+41
-28
@@ -87,9 +87,9 @@ CPTableViewSelectionHighlightStyleNone = -1;
|
||||
CPTableViewSelectionHighlightStyleRegular = 0;
|
||||
CPTableViewSelectionHighlightStyleSourceList = 1;
|
||||
|
||||
CPTableViewGridNone = 0;
|
||||
CPTableViewSolidVerticalGridLineMask = 1 << 0;
|
||||
CPTableViewSolidHorizontalGridLineMask = 1 << 1;
|
||||
CPTableViewGridNone = 0;
|
||||
CPTableViewSolidVerticalGridLineMask = 1 << 0;
|
||||
CPTableViewSolidHorizontalGridLineMask = 1 << 1;
|
||||
|
||||
CPTableViewNoColumnAutoresizing = 0;
|
||||
CPTableViewUniformColumnAutoresizingStyle = 1; // FIX ME: This is FUBAR
|
||||
@@ -683,6 +683,7 @@ NOT YET IMPLEMENTED
|
||||
*/
|
||||
- (void)setRowHeight:(unsigned)aRowHeight
|
||||
{
|
||||
// Accept row heights such as "0".
|
||||
aRowHeight = +aRowHeight;
|
||||
|
||||
if (_rowHeight === aRowHeight)
|
||||
@@ -768,10 +769,6 @@ NOT YET IMPLEMENTED
|
||||
*/
|
||||
- (void)setSelectionHighlightStyle:(unsigned)aSelectionHighlightStyle
|
||||
{
|
||||
//early return for IE.
|
||||
if (aSelectionHighlightStyle == CPTableViewSelectionHighlightStyleSourceList && !CPFeatureIsCompatible(CPHTMLCanvasFeature))
|
||||
return;
|
||||
|
||||
_selectionHighlightStyle = aSelectionHighlightStyle;
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
@@ -958,6 +955,7 @@ NOT YET IMPLEMENTED
|
||||
*/
|
||||
- (void)_moveColumn:(unsigned)fromIndex toColumn:(unsigned)toIndex
|
||||
{
|
||||
// Convert parameters such as "0" to 0.
|
||||
fromIndex = +fromIndex;
|
||||
toIndex = +toIndex;
|
||||
|
||||
@@ -1515,6 +1513,8 @@ NOT YET IMPLEMENTED
|
||||
|
||||
if ([scrollView isKindOfClass:[CPScrollView class]] && [scrollView documentView] === self)
|
||||
[scrollView _updateCornerAndHeaderView];
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
// Complexity:
|
||||
@@ -1566,6 +1566,7 @@ NOT YET IMPLEMENTED
|
||||
*/
|
||||
- (CGRect)rectOfColumn:(CPInteger)aColumnIndex
|
||||
{
|
||||
// Convert e.g. "0" to 0.
|
||||
aColumnIndex = +aColumnIndex;
|
||||
|
||||
if (aColumnIndex < 0 || aColumnIndex >= NUMBER_OF_COLUMNS())
|
||||
@@ -1795,7 +1796,7 @@ NOT YET IMPLEMENTED
|
||||
{
|
||||
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_heightOfRow_)
|
||||
{
|
||||
return idx = [_cachedRowHeights indexOfObject:aPoint
|
||||
return [_cachedRowHeights indexOfObject:aPoint
|
||||
inSortedRange:nil
|
||||
options:0
|
||||
usingComparator:function(aPoint, rowCache)
|
||||
@@ -3049,7 +3050,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
return _sortDescriptors;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
@@ -3430,7 +3430,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
[aTableColumn setDataView:dataView];
|
||||
}
|
||||
|
||||
|
||||
return [aTableColumn _newDataViewForRow:aRow];
|
||||
}
|
||||
|
||||
@@ -3502,8 +3501,20 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
{
|
||||
[super setNeedsDisplay:aFlag];
|
||||
[_tableDrawView setNeedsDisplay:aFlag];
|
||||
|
||||
[[self headerView] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)setNeedsLayout
|
||||
{
|
||||
[super setNeedsLayout];
|
||||
[[self headerView] setNeedsLayout];
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
@@ -3690,7 +3701,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
var drawGradient = (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList && [_selectedRowIndexes count] >= 1),
|
||||
var drawGradient = (CPFeatureIsCompatible(CPHTMLCanvasFeature) && _selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList && [_selectedRowIndexes count] >= 1),
|
||||
deltaHeight = 0.5 * (_gridStyleMask & CPTableViewSolidHorizontalGridLineMask);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
@@ -3710,7 +3721,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
{
|
||||
var topGroupLineColor = [CPColor colorWithCalibratedWhite:212.0 / 255.0 alpha:1.0],
|
||||
bottomGroupLineColor = [CPColor colorWithCalibratedWhite:185.0 / 255.0 alpha:1.0],
|
||||
gradientGroupColor = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [212.0 / 255.0, 212.0 / 255.0, 212.0 / 255.0,1.0, 197.0 / 255.0, 197.0 / 255.0, 197.0 / 255.0,1.0], [0,1], 2);
|
||||
gradientGroupColor = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [212.0 / 255.0, 212.0 / 255.0, 212.0 / 255.0, 1.0, 197.0 / 255.0, 197.0 / 255.0, 197.0 / 255.0, 1.0], [0, 1], 2);
|
||||
}
|
||||
|
||||
while (count--)
|
||||
@@ -3817,7 +3828,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
*/
|
||||
- (void)_drawGroupRowsForRects:(CPArray)rects
|
||||
{
|
||||
if (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList || !rects.length)
|
||||
if ((CPFeatureIsCompatible(CPHTMLCanvasFeature) && _selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList) || !rects.length)
|
||||
return;
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
@@ -3828,8 +3839,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
var gradientCache = [self selectionGradientColors],
|
||||
topLineColor = [CPColor colorWithHexString:"d3d3d3"],
|
||||
bottomLineColor = [CPColor colorWithHexString:"bebebd"],
|
||||
gradientColor = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [220.0 / 255.0, 220.0 / 255.0, 220.0 / 255.0,1.0,
|
||||
199.0 / 255.0, 199.0 / 255.0, 199.0 / 255.0,1.0], [0,1], 2),
|
||||
gradientColor = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [220.0 / 255.0, 220.0 / 255.0, 220.0 / 255.0, 1.0,
|
||||
199.0 / 255.0, 199.0 / 255.0, 199.0 / 255.0, 1.0], [0, 1], 2),
|
||||
drawGradient = YES;
|
||||
|
||||
while (i--)
|
||||
@@ -3977,7 +3988,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
{
|
||||
var row = [self rowAtPoint:aPoint];
|
||||
|
||||
//if the user clicks outside a row then deselect everything
|
||||
// If the user clicks outside a row then deselect everything.
|
||||
if (row < 0 && _allowsEmptySelection)
|
||||
[self selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
|
||||
|
||||
@@ -4642,19 +4653,19 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
while (![_delegate tableView:self shouldSelectRow:i] && (i < [self numberOfRows] || i > 0))
|
||||
shouldGoUpward ? i-- : i++; //check to see if the row can be selected if it can't be then see if the next row can be selected
|
||||
|
||||
//if the index still can be selected after the loop then just return
|
||||
if (![_delegate tableView:self shouldSelectRow:i])
|
||||
return;
|
||||
// If the index still can be selected after the loop then just return.
|
||||
if (![_delegate tableView:self shouldSelectRow:i])
|
||||
return;
|
||||
}
|
||||
|
||||
// if we go upward and see that this row is already selected we should deselect the row below
|
||||
if ([selectedIndexes containsIndex:i] && extend)
|
||||
// If we go upward and see that this row is already selected we should deselect the row below.
|
||||
if (extend && [selectedIndexes containsIndex:i])
|
||||
{
|
||||
// the row we're on is the last to be selected
|
||||
// The row we're on is the last to be selected.
|
||||
var differedLastSelectedRow = i;
|
||||
|
||||
// no remove the one before/after it
|
||||
shouldGoUpward ? i++ : i--;
|
||||
shouldGoUpward ? i++ : i--;
|
||||
|
||||
[selectedIndexes removeIndex:i];
|
||||
|
||||
@@ -4666,7 +4677,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
if ([selectedIndexes containsIndex:i])
|
||||
{
|
||||
i = shouldGoUpward ? [selectedIndexes firstIndex] -1 : [selectedIndexes lastIndex] + 1;
|
||||
i = MIN(MAX(i,0), [self numberOfRows] - 1);
|
||||
i = MIN(MAX(i, 0), [self numberOfRows] - 1);
|
||||
}
|
||||
|
||||
[selectedIndexes addIndex:i];
|
||||
@@ -4943,15 +4954,17 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
|
||||
|
||||
isBlinking = YES;
|
||||
|
||||
var showCallback = function() {
|
||||
var showCallback = function()
|
||||
{
|
||||
objj_msgSend(self, "setHidden:", NO)
|
||||
isBlinking = NO;
|
||||
}
|
||||
};
|
||||
|
||||
var hideCallback = function() {
|
||||
var hideCallback = function()
|
||||
{
|
||||
objj_msgSend(self, "setHidden:", YES)
|
||||
isBlinking = YES;
|
||||
}
|
||||
};
|
||||
|
||||
objj_msgSend(self, "setHidden:", YES);
|
||||
[CPTimer scheduledTimerWithTimeInterval:0.1 callback:showCallback repeats:NO];
|
||||
|
||||
+18
-23
@@ -202,14 +202,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldInputDidBlur = YES;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
CPTextFieldHandleBlur = function(anEvent)
|
||||
{
|
||||
CPTextFieldInputOwner = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
};
|
||||
|
||||
//FIXME make this not onblur
|
||||
CPTextFieldDOMInputElement.onblur = CPTextFieldBlurFunction;
|
||||
@@ -1433,7 +1433,7 @@ var secureStringForString = function(aString)
|
||||
return "";
|
||||
|
||||
return Array(aString.length + 1).join(CPSecureTextFieldCharacter);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
@@ -1503,6 +1503,16 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
{
|
||||
}
|
||||
|
||||
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
|
||||
{
|
||||
[super _updatePlaceholdersWithOptions:options];
|
||||
|
||||
[self _setPlaceholder:@"Multiple Values" forMarker:CPMultipleValuesMarker isDefault:YES];
|
||||
[self _setPlaceholder:@"No Selection" forMarker:CPNoSelectionMarker isDefault:YES];
|
||||
[self _setPlaceholder:@"Not Applicable" forMarker:CPNotApplicableMarker isDefault:YES];
|
||||
[self _setPlaceholder:@"" forMarker:CPNullMarker isDefault:YES];
|
||||
}
|
||||
|
||||
- (void)setValueFor:(CPString)theBinding
|
||||
{
|
||||
var destination = [_info objectForKey:CPObservedObjectKey],
|
||||
@@ -1513,29 +1523,14 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
|
||||
|
||||
if (isPlaceholder)
|
||||
{
|
||||
switch (newValue)
|
||||
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
|
||||
{
|
||||
case CPMultipleValuesMarker:
|
||||
newValue = [options objectForKey:CPMultipleValuesPlaceholderBindingOption] || @"Multiple Values";
|
||||
break;
|
||||
|
||||
case CPNoSelectionMarker:
|
||||
newValue = [options objectForKey:CPNoSelectionPlaceholderBindingOption] || @"No Selection";
|
||||
break;
|
||||
|
||||
case CPNotApplicableMarker:
|
||||
if ([options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
|
||||
[CPException raise:CPGenericException
|
||||
reason:@"can't transform non applicable key on: "+_source+" value: "+newValue];
|
||||
|
||||
newValue = [options objectForKey:CPNotApplicablePlaceholderBindingOption] || @"Not Applicable";
|
||||
break;
|
||||
|
||||
case CPNullMarker:
|
||||
newValue = [options objectForKey:CPNullPlaceholderBindingOption] || @"";
|
||||
break;
|
||||
[CPException raise:CPGenericException
|
||||
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
|
||||
}
|
||||
|
||||
newValue = [self _placeholderForMarker:newValue];
|
||||
|
||||
[_source setPlaceholderString:newValue];
|
||||
[_source setObjectValue:nil];
|
||||
}
|
||||
|
||||
+3
-1
@@ -579,6 +579,7 @@ CPThemeStateCircular = CPThemeState("circular");
|
||||
_cache = {};
|
||||
|
||||
_name = [aCoder decodeObjectForKey:@"name"];
|
||||
_defaultValue = [aCoder decodeObjectForKey:@"defaultValue"];
|
||||
_values = [CPDictionary dictionary];
|
||||
|
||||
if ([aCoder containsValueForKey:@"value"])
|
||||
@@ -611,6 +612,7 @@ CPThemeStateCircular = CPThemeState("circular");
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_name forKey:@"name"];
|
||||
[aCoder encodeObject:_defaultValue forKey:@"defaultValue"];
|
||||
|
||||
var keys = [_values allKeys],
|
||||
count = keys.length;
|
||||
@@ -666,7 +668,7 @@ var numberOfOnes = function(aNumber)
|
||||
cachedNumberOfOnes[slot] = count;
|
||||
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
numberOfOnes.displayName = "numberOfOnes";
|
||||
|
||||
|
||||
@@ -660,7 +660,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
CPTokenFieldInputDidBlur = YES;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
CPTokenFieldKeyDownFunction = function(aDOMEvent)
|
||||
{
|
||||
@@ -814,7 +814,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
CPTokenFieldKeyPressFunction = function(aDOMEvent)
|
||||
{
|
||||
@@ -844,7 +844,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
// Force immediate layout in case word wrapping is now necessary.
|
||||
[owner setNeedsLayout];
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
};
|
||||
|
||||
CPTokenFieldKeyUpFunction = function()
|
||||
{
|
||||
@@ -857,14 +857,14 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
[self setNeedsLayout];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
};
|
||||
|
||||
CPTokenFieldHandleBlur = function(anEvent)
|
||||
{
|
||||
CPTokenFieldInputOwner = nil;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
};
|
||||
|
||||
if (document.attachEvent)
|
||||
{
|
||||
@@ -1026,7 +1026,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
offset.x += width + spaceBetweenTokens.width;
|
||||
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
var placeEditor = function(useRemainingWidth)
|
||||
{
|
||||
@@ -1053,7 +1053,7 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
|
||||
// When editing, always scroll to the cursor.
|
||||
if (_selectedRange.length == 0)
|
||||
[[_tokenScrollView documentView] scrollRectToVisible:inputFrame];
|
||||
}
|
||||
};
|
||||
|
||||
for (var i = 0, count = [tokens count]; i < count; i++)
|
||||
{
|
||||
|
||||
+33
-5
@@ -50,9 +50,17 @@ CPToolbarDisplayModeIconOnly = 2;
|
||||
*/
|
||||
CPToolbarDisplayModeLabelOnly = 3;
|
||||
|
||||
|
||||
CPToolbarSizeModeDefault = 0;
|
||||
CPToolbarSizeModeRegular = 1;
|
||||
CPToolbarSizeModeSmall = 2;
|
||||
|
||||
var CPToolbarsByIdentifier = nil,
|
||||
CPToolbarConfigurationsByIdentifier = nil;
|
||||
|
||||
var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
TOOLBAR_SMALL_HEIGHT = 46.0;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPToolbar
|
||||
@@ -87,6 +95,7 @@ var CPToolbarsByIdentifier = nil,
|
||||
BOOL _showsBaselineSeparator;
|
||||
BOOL _allowsUserCustomization;
|
||||
BOOL _isVisible;
|
||||
int _sizeMode @accessors(property=sizeMode);
|
||||
|
||||
id _delegate;
|
||||
|
||||
@@ -148,6 +157,7 @@ var CPToolbarsByIdentifier = nil,
|
||||
|
||||
_identifier = anIdentifier;
|
||||
_isVisible = YES;
|
||||
_sizeMode = CPToolbarSizeModeDefault;
|
||||
|
||||
[CPToolbar _addToolbar:self forIdentifier:_identifier];
|
||||
}
|
||||
@@ -202,6 +212,16 @@ var CPToolbarsByIdentifier = nil,
|
||||
[_window _noteToolbarChanged];
|
||||
}
|
||||
|
||||
- (void)setSizeMode:(CPToolbarSizeMode)aSize
|
||||
{
|
||||
if (aSize === _sizeMode)
|
||||
return;
|
||||
_sizeMode = aSize;
|
||||
|
||||
[[self _toolbarView] setFrame:[self _toolbarViewFrame]];
|
||||
[_window _noteToolbarChanged];
|
||||
}
|
||||
|
||||
- (CPWindow)_window
|
||||
{
|
||||
return _window;
|
||||
@@ -232,12 +252,17 @@ var CPToolbarsByIdentifier = nil,
|
||||
|
||||
}
|
||||
|
||||
- (CGRect)_toolbarViewFrame
|
||||
{
|
||||
return CPRectMake(0.0, 0.0, 1200.0, _sizeMode != CPToolbarSizeModeSmall ? TOOLBAR_REGULAR_HEIGHT : TOOLBAR_SMALL_HEIGHT);
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (CPView)_toolbarView
|
||||
{
|
||||
if (!_toolbarView)
|
||||
{
|
||||
_toolbarView = [[_CPToolbarView alloc] initWithFrame:CPRectMake(0.0, 0.0, 1200.0, 59.0)];
|
||||
_toolbarView = [[_CPToolbarView alloc] initWithFrame:[self _toolbarViewFrame]];
|
||||
|
||||
[_toolbarView setToolbar:self];
|
||||
[_toolbarView setAutoresizingMask:CPViewWidthSizable];
|
||||
@@ -427,7 +452,8 @@ var CPToolbarIdentifierKey = @"CPToolbarIdentifierKey",
|
||||
CPToolbarIdentifiedItemsKey = @"CPToolbarIdentifiedItemsKey",
|
||||
CPToolbarDefaultItemsKey = @"CPToolbarDefaultItemsKey",
|
||||
CPToolbarAllowedItemsKey = @"CPToolbarAllowedItemsKey",
|
||||
CPToolbarSelectableItemsKey = @"CPToolbarSelectableItemsKey";
|
||||
CPToolbarSelectableItemsKey = @"CPToolbarSelectableItemsKey",
|
||||
CPToolbarSizeModeKey = @"CPToolbarSizeModeKey";
|
||||
|
||||
@implementation CPToolbar (CPCoding)
|
||||
|
||||
@@ -446,6 +472,7 @@ var CPToolbarIdentifierKey = @"CPToolbarIdentifierKey",
|
||||
_showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
|
||||
_allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
|
||||
_isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
|
||||
_sizeMode = [aCoder decodeIntForKey:CPToolbarSizeModeKey];
|
||||
|
||||
_identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
|
||||
_defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
|
||||
@@ -492,6 +519,7 @@ var CPToolbarIdentifierKey = @"CPToolbarIdentifierKey",
|
||||
[aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
|
||||
[aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey];
|
||||
[aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
|
||||
[aCoder encodeInt:_sizeMode forKey:CPToolbarSizeModeKey]
|
||||
|
||||
[aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
|
||||
[aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
|
||||
@@ -515,7 +543,7 @@ var TOOLBAR_TOP_MARGIN = 5.0,
|
||||
var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
{
|
||||
return { index:anIndex, view:aView, label:aLabel, minWidth:aMinWidth };
|
||||
}
|
||||
};
|
||||
|
||||
/* @ignore */
|
||||
@implementation _CPToolbarView : CPView
|
||||
@@ -547,7 +575,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size: CPSizeMake(10.0, 15.0)];
|
||||
_CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size:CPSizeMake(10.0, 15.0)];
|
||||
|
||||
_CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:CGSizeMake(10.0, 15.0)];
|
||||
}
|
||||
@@ -876,7 +904,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
|
||||
return CPOrderedAscending;
|
||||
|
||||
return CPOrderedDescending;
|
||||
}
|
||||
};
|
||||
|
||||
var TOP_MARGIN = 5.0,
|
||||
LABEL_MARGIN = 2.0;
|
||||
|
||||
@@ -180,7 +180,7 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey";
|
||||
var keys = [_cachedValues allKeys],
|
||||
keysCount = [keys count];
|
||||
|
||||
while(keysCount--)
|
||||
while (keysCount--)
|
||||
{
|
||||
var key = keys[keysCount];
|
||||
[self willChangeValueForKey:key];
|
||||
@@ -194,7 +194,7 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey";
|
||||
var keys = [_cachedValues allKeys],
|
||||
keysCount = [keys count];
|
||||
|
||||
while(keysCount--)
|
||||
while (keysCount--)
|
||||
{
|
||||
var key = keys[keysCount];
|
||||
[[_controller defaults] setObject:[_cachedValues objectForKey:key] forKey:key];
|
||||
@@ -207,7 +207,7 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey";
|
||||
keys = [_cachedValues allKeys],
|
||||
keysCount = [keys count];
|
||||
|
||||
while(keysCount--)
|
||||
while (keysCount--)
|
||||
{
|
||||
var key = keys[keysCount];
|
||||
[self willChangeValueForKey:key];
|
||||
@@ -229,7 +229,7 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey";
|
||||
keys = [_cachedValues allKeys],
|
||||
keysCount = [keys count];
|
||||
|
||||
while(keysCount--)
|
||||
while (keysCount--)
|
||||
{
|
||||
var key = keys[keysCount],
|
||||
value = [_cachedValues objectForKey:key],
|
||||
@@ -250,7 +250,7 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey";
|
||||
keys = [_cachedValues allKeys],
|
||||
keysCount = [keys count];
|
||||
|
||||
while(keysCount--)
|
||||
while (keysCount--)
|
||||
{
|
||||
var key = keys[keysCount],
|
||||
value = [_cachedValues objectForKey:key],
|
||||
|
||||
+99
-2
@@ -141,6 +141,7 @@ var CPViewFlags = { },
|
||||
BOOL _postsFrameChangedNotifications;
|
||||
BOOL _postsBoundsChangedNotifications;
|
||||
BOOL _inhibitFrameAndBoundsChangedNotifications;
|
||||
BOOL _inLiveResize;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMElement _DOMElement;
|
||||
@@ -291,6 +292,9 @@ var CPViewFlags = { },
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(aFrame), _CGRectGetMinY(aFrame));
|
||||
CPDOMDisplayServerSetStyleSize(_DOMElement, width, height);
|
||||
|
||||
if (typeof(appkit_tag_dom_elements) !== "undefined" && !!appkit_tag_dom_elements)
|
||||
_DOMElement.setAttribute("data-cappuccino-view", [self className]);
|
||||
|
||||
_DOMImageParts = [];
|
||||
_DOMImageSizes = [];
|
||||
#endif
|
||||
@@ -848,11 +852,17 @@ var CPViewFlags = { },
|
||||
|
||||
if (_backgroundType === BackgroundVerticalThreePartImage)
|
||||
{
|
||||
// Make sure to repeat the top and bottom pieces horizontally if they're not the exact width needed.
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], size.width, _DOMImageSizes[0].height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], size.width, size.height - _DOMImageSizes[0].height - _DOMImageSizes[2].height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[2], size.width, _DOMImageSizes[2].height);
|
||||
}
|
||||
else if (_backgroundType === BackgroundHorizontalThreePartImage)
|
||||
{
|
||||
// Make sure to repeat the left and right pieces vertically if they're not the exact height needed.
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], _DOMImageSizes[0].width, size.height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], size.width - _DOMImageSizes[0].width - _DOMImageSizes[2].width, size.height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[2], _DOMImageSizes[2].width, size.height);
|
||||
}
|
||||
else if (_backgroundType === BackgroundNinePartImage)
|
||||
{
|
||||
@@ -1539,7 +1549,10 @@ var CPViewFlags = { },
|
||||
}
|
||||
else if (_backgroundType == BackgroundVerticalThreePartImage)
|
||||
{
|
||||
// Make sure to repeat the top and bottom pieces horizontally if they're not the exact width needed.
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], frameSize.width, _DOMImageSizes[0].height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], frameSize.width, frameSize.height - _DOMImageSizes[0].height - _DOMImageSizes[2].height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[2], frameSize.width, _DOMImageSizes[2].height);
|
||||
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[0], NULL, 0.0, 0.0);
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[1], NULL, 0.0, _DOMImageSizes[0].height);
|
||||
@@ -1547,7 +1560,10 @@ var CPViewFlags = { },
|
||||
}
|
||||
else if (_backgroundType == BackgroundHorizontalThreePartImage)
|
||||
{
|
||||
// Make sure to repeat the left and right pieces vertically if they're not the exact height needed.
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[0], _DOMImageSizes[0].width, frameSize.height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[1], frameSize.width - _DOMImageSizes[0].width - _DOMImageSizes[2].width, frameSize.height);
|
||||
CPDOMDisplayServerSetStyleSize(_DOMImageParts[2], _DOMImageSizes[2].width, frameSize.height);
|
||||
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[0], NULL, 0.0, 0.0);
|
||||
CPDOMDisplayServerSetStyleLeftTop(_DOMImageParts[1], NULL, _DOMImageSizes[0].width, 0.0);
|
||||
@@ -2128,6 +2144,43 @@ setBoundsOrigin:
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Return yes if the receiver is in a live-resize operation.
|
||||
*/
|
||||
- (BOOL)inLiveResize
|
||||
{
|
||||
return _inLiveResize;
|
||||
}
|
||||
|
||||
/*!
|
||||
Not implemented.
|
||||
|
||||
A view will be sent this message before a window begins a resize operation. The
|
||||
receiver might choose to simplify its drawing operations during a live resize
|
||||
for speed.
|
||||
|
||||
Subclasses should call super.
|
||||
*/
|
||||
- (void)viewWillStartLiveResize
|
||||
{
|
||||
_inLiveResize = YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
Not implemented.
|
||||
|
||||
A view will be sent this message after a window finishes a resize operation. The
|
||||
receiver which simplified its drawing operations in viewWillStartLiveResize might
|
||||
stop doing so now. Note the view might no longer be in a window, so use
|
||||
[self setNeedsDisplay:YES] if a final non-simplified redraw is required.
|
||||
|
||||
Subclasses should call super.
|
||||
*/
|
||||
- (void)viewDidEndLiveResize
|
||||
{
|
||||
_inLiveResize = NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPView (KeyView)
|
||||
@@ -2543,6 +2596,50 @@ setBoundsOrigin:
|
||||
return (_themeAttributes && _themeAttributes[aName] !== undefined);
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers theme values encoded in an array at runtime. The format of the data in the array
|
||||
is the same as that used by ThemeDescriptors.j, with the exception that you need to use
|
||||
CPColorWithImages() in place of PatternColor(). For more information see the comments
|
||||
at the top of ThemeDescriptors.j.
|
||||
|
||||
@param themeValues array of theme values
|
||||
*/
|
||||
- (void)registerThemeValues:(CPArray)themeValues
|
||||
{
|
||||
for (var i = 0; i < themeValues.length; ++i)
|
||||
{
|
||||
var attributeValueState = themeValues[i],
|
||||
attribute = attributeValueState[0],
|
||||
value = attributeValueState[1],
|
||||
state = attributeValueState[2];
|
||||
|
||||
if (state)
|
||||
[self setValue:value forThemeAttribute:attribute inState:state];
|
||||
else
|
||||
[self setValue:value forThemeAttribute:attribute];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers theme values encoded in an array at runtime. The format of the data in the array
|
||||
is the same as that used by ThemeDescriptors.j, with the exception that you need to use
|
||||
CPColorWithImages() in place of PatternColor(). The values in \c inheritedValues are
|
||||
registered first, then those in \c themeValues override/augment the inherited values.
|
||||
For more information see the comments at the top of ThemeDescriptors.j.
|
||||
|
||||
@param themeValues array of base theme values
|
||||
@param inheritedValues array of overridden/additional theme values
|
||||
*/
|
||||
- (void)registerThemeValues:(CPArray)themeValues inherit:(CPArray)inheritedValues
|
||||
{
|
||||
// Register inherited values first, then override those with the subtheme values.
|
||||
if (inheritedValues)
|
||||
[self registerThemeValues:inheritedValues];
|
||||
|
||||
if (themeValues)
|
||||
[self registerThemeValues:themeValues];
|
||||
}
|
||||
|
||||
- (CPView)createEphemeralSubviewNamed:(CPString)aViewName
|
||||
{
|
||||
return nil;
|
||||
@@ -2799,7 +2896,7 @@ var _CPViewFullScreenModeStateMake = function(aView)
|
||||
var superview = aView._superview;
|
||||
|
||||
return { autoresizingMask:aView._autoresizingMask, frame:CGRectMakeCopy(aView._frame), index:(superview ? [superview._subviews indexOfObjectIdenticalTo:aView] : 0), superview:superview };
|
||||
}
|
||||
};
|
||||
|
||||
var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
{
|
||||
@@ -2896,4 +2993,4 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
}*/
|
||||
|
||||
return transform;
|
||||
}
|
||||
};
|
||||
|
||||
+30
-23
@@ -66,6 +66,7 @@ var CPViewControllerCachedCibs;
|
||||
{
|
||||
CPView _view @accessors(property=view);
|
||||
BOOL _isLoading;
|
||||
BOOL _isLazy;
|
||||
|
||||
id _representedObject @accessors(property=representedObject);
|
||||
CPString _title @accessors(property=title);
|
||||
@@ -124,6 +125,7 @@ var CPViewControllerCachedCibs;
|
||||
_cibExternalNameTable = anExternalNameTable || [CPDictionary dictionaryWithObject:self forKey:CPCibOwner];
|
||||
|
||||
_isLoading = NO;
|
||||
_isLazy = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -136,12 +138,12 @@ var CPViewControllerCachedCibs;
|
||||
|
||||
If you create your views manually, you must override this method and use
|
||||
it to create your view and assign it to the view property. The default
|
||||
implementation for programmatic views is to create a plain view. You can
|
||||
invoke super to utilize this view.
|
||||
implementation for programmatic views is to create a plain, zero width & height
|
||||
view. You can invoke super to utilize this view.
|
||||
|
||||
If you use Interface Builder to create your views, you initialize the view
|
||||
using the initWithCibName:bundle: method then you must not override this
|
||||
method. The consequences risk shattering the space-time continuum.
|
||||
If you use Interface Builder to create your views, and you initialize the
|
||||
controller using the initWithCibName:bundle: methods, then you MUST NOT override
|
||||
this method. The consequences risk shattering the space-time continuum.
|
||||
|
||||
Note: The cib loading system is currently synchronous.
|
||||
*/
|
||||
@@ -150,17 +152,22 @@ var CPViewControllerCachedCibs;
|
||||
if (_view)
|
||||
return;
|
||||
|
||||
// check if a cib is already cached for the current _cibName
|
||||
var cib = [CPViewControllerCachedCibs objectForKey:_cibName];
|
||||
|
||||
if (!cib)
|
||||
if (_cibName)
|
||||
{
|
||||
// if the cib isn't cached yet : fetch it and cache it
|
||||
cib = [[CPCib alloc] initWithContentsOfURL:[_cibBundle pathForResource:_cibName + @".cib"]];
|
||||
[CPViewControllerCachedCibs setObject:cib forKey:_cibName];
|
||||
}
|
||||
// check if a cib is already cached for the current _cibName
|
||||
var cib = [CPViewControllerCachedCibs objectForKey:_cibName];
|
||||
|
||||
[cib instantiateCibWithExternalNameTable:_cibExternalNameTable];
|
||||
if (!cib)
|
||||
{
|
||||
// if the cib isn't cached yet : fetch it and cache it
|
||||
cib = [[CPCib alloc] initWithCibNamed:_cibName bundle:_cibBundle];
|
||||
[CPViewControllerCachedCibs setObject:cib forKey:_cibName];
|
||||
}
|
||||
|
||||
[cib instantiateCibWithExternalNameTable:_cibExternalNameTable];
|
||||
}
|
||||
else
|
||||
_view = [CPView new];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -199,6 +206,11 @@ var CPViewControllerCachedCibs;
|
||||
_isLoading = NO;
|
||||
[self viewDidLoad];
|
||||
}
|
||||
else if (_isLazy)
|
||||
{
|
||||
_isLazy = NO;
|
||||
[self viewDidLoad];
|
||||
}
|
||||
|
||||
return _view;
|
||||
}
|
||||
@@ -208,9 +220,9 @@ var CPViewControllerCachedCibs;
|
||||
This method is called after the view controller has loaded its associated views into memory.
|
||||
|
||||
This method is called regardless of whether the views were stored in a nib
|
||||
file or created programmatically in the loadView method. This method is
|
||||
most commonly used to perform additional initialization steps on views
|
||||
that are loaded from cib files.
|
||||
file or created programmatically in the loadView method, but NOT when setView
|
||||
is invoked. This method is most commonly used to perform additional initialization
|
||||
steps on views that are loaded from cib files.
|
||||
*/
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
@@ -228,13 +240,7 @@ var CPViewControllerCachedCibs;
|
||||
*/
|
||||
- (void)setView:(CPView)aView
|
||||
{
|
||||
var viewWasLoaded = !_view;
|
||||
|
||||
_view = aView;
|
||||
|
||||
// Make sure the viewDidLoad method is called if the view is set directly
|
||||
if (!_isLoading && viewWasLoaded)
|
||||
[self viewDidLoad];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -266,6 +272,7 @@ var CPViewControllerViewKey = @"CPViewControllerViewKey",
|
||||
_cibBundle = bundlePath ? [CPBundle bundleWithPath:bundlePath] : [CPBundle mainBundle];
|
||||
|
||||
_cibExternalNameTable = [CPDictionary dictionaryWithObject:self forKey:CPCibOwner];
|
||||
_isLazy = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
+2
-2
@@ -199,7 +199,7 @@ CPWebViewAppKitScrollMaxPollCount = 3;
|
||||
_ignoreLoadEnd = NO;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
};
|
||||
|
||||
if (_iframe.addEventListener)
|
||||
_iframe.addEventListener("load", _loadCallback, false);
|
||||
@@ -830,7 +830,7 @@ CPWebViewAppKitScrollMaxPollCount = 3;
|
||||
- (@action)reload:(id)sender
|
||||
{
|
||||
// If we're displaying pure HTML, redisplay it.
|
||||
if(!_url && (_html !== nil))
|
||||
if (!_url && (_html !== nil))
|
||||
[self loadHTMLString:_html];
|
||||
else
|
||||
[self _loadMainFrameURL];
|
||||
|
||||
@@ -455,6 +455,7 @@ CPTexturedBackgroundWindowMask
|
||||
if (aStyleMask & CPBorderlessBridgeWindowMask)
|
||||
[self setFullPlatformWindow:YES];
|
||||
|
||||
_autorecalculatesKeyViewLoop = NO;
|
||||
_defaultButtonEnabled = YES;
|
||||
_keyViewLoopIsDirty = YES;
|
||||
|
||||
@@ -515,6 +516,10 @@ CPTexturedBackgroundWindowMask
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
_keyViewLoopIsDirty = ![self _hasKeyViewLoop];
|
||||
// If no key view loop has been specified by hand, and we are not intending to auto recalculate,
|
||||
// set up a default key view loop.
|
||||
if (_keyViewLoopIsDirty && ![self autorecalculatesKeyViewLoop])
|
||||
[self recalculateKeyViewLoop];
|
||||
}
|
||||
|
||||
- (void)_setWindowView:(CPView)aWindowView
|
||||
@@ -2500,9 +2505,7 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
_autorecalculatesKeyViewLoop = shouldRecalculate;
|
||||
|
||||
if (_keyViewLoopIsDirty)
|
||||
[self recalculateKeyViewLoop];
|
||||
else if (_autorecalculatesKeyViewLoop)
|
||||
if (_autorecalculatesKeyViewLoop)
|
||||
[self _dirtyKeyViewLoop];
|
||||
}
|
||||
|
||||
@@ -2673,7 +2676,7 @@ var allViews = function(aWindow)
|
||||
views = views.concat([views[index] subviews]);
|
||||
|
||||
return views;
|
||||
}
|
||||
};
|
||||
|
||||
var keyViewComparator = function(lhs, rhs, context)
|
||||
{
|
||||
@@ -2704,7 +2707,7 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
return CPOrderedSame;
|
||||
|
||||
return CPOrderedDescending;
|
||||
}
|
||||
};
|
||||
|
||||
@implementation CPWindow (MenuBar)
|
||||
|
||||
@@ -2928,7 +2931,7 @@ var keyViewComparator = function(lhs, rhs, context)
|
||||
var interpolate = function(fromValue, toValue, progress)
|
||||
{
|
||||
return fromValue + (toValue - fromValue) * progress;
|
||||
}
|
||||
};
|
||||
|
||||
/* @ignore */
|
||||
@implementation _CPWindowFrameAnimation : CPAnimation
|
||||
|
||||
@@ -22,11 +22,15 @@
|
||||
|
||||
@import "_CPWindowView.j"
|
||||
|
||||
#define ALIGN_STROKE(point) (FLOOR(point) === (point) ? (point) + halfStrokeWidth : (point))
|
||||
#define ALIGN_COORD(point) (FLOOR(point))
|
||||
|
||||
var _CPAttachedWindowViewDefaultCursorSize = CGSizeMake(16, 10);
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
|
||||
A custom CPWindowView that manage border and cursor
|
||||
A custom CPWindowView that manages a border and cursor
|
||||
*/
|
||||
@implementation _CPAttachedWindowView : _CPWindowView
|
||||
{
|
||||
@@ -36,7 +40,7 @@
|
||||
int _appearance @accessors(property=appearance);
|
||||
unsigned _preferredEdge @accessors(property=preferredEdge);
|
||||
|
||||
CPSize _cursorSize;
|
||||
CGSize _cursorSize;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -81,18 +85,16 @@
|
||||
/*!
|
||||
Initialize the _CPWindowView
|
||||
*/
|
||||
- (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask
|
||||
- (id)initWithFrame:(CGRect)aFrame styleMask:(unsigned)aStyleMask
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame styleMask:aStyleMask])
|
||||
{
|
||||
var bundle = [CPBundle bundleForClass:[self class]];
|
||||
_arrowOffsetX = 0.0;
|
||||
_arrowOffsetY = 0.0;
|
||||
|
||||
// @TODO: make this themable
|
||||
_useGlowingEffect = YES;
|
||||
_appearance = CPPopoverAppearanceMinimal;
|
||||
_cursorSize = CPSizeMake(15, 10);
|
||||
_cursorSize = CGSizeMakeCopy(_CPAttachedWindowViewDefaultCursorSize);
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -103,7 +105,7 @@
|
||||
*/
|
||||
- (void)hideCursor
|
||||
{
|
||||
_cursorSize = CPSizeMakeZero();
|
||||
_cursorSize = CGSizeMakeZero();
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
@@ -112,7 +114,7 @@
|
||||
*/
|
||||
- (void)showCursor
|
||||
{
|
||||
_cursorSize = CPSizeMake(15, 10);
|
||||
_cursorSize = CGSizeMakeCopy(_CPAttachedWindowViewDefaultCursorSize);
|
||||
[self setNeedsDisplay:YES];
|
||||
_mouseDownPressed = NO;
|
||||
}
|
||||
@@ -129,11 +131,13 @@
|
||||
arrowWidth = _cursorSize.width,
|
||||
arrowHeight = _cursorSize.height,
|
||||
strokeWidth = 1,
|
||||
halfStrokeWidth = strokeWidth / 2.0,
|
||||
strokeColor,
|
||||
shadowColor = [[CPColor blackColor] colorWithAlphaComponent:.2],
|
||||
shadowSize = CGSizeMake(0, 7),
|
||||
shadowSize = CGSizeMake(0, 6),
|
||||
shadowBlur = 15,
|
||||
gradient;
|
||||
gradient,
|
||||
frame = [self bounds];
|
||||
|
||||
if (_appearance == CPPopoverAppearanceMinimal)
|
||||
{
|
||||
@@ -149,133 +153,217 @@
|
||||
}
|
||||
|
||||
// fix rect to take care of stroke and shadow
|
||||
aRect.origin.x += strokeWidth + shadowBlur;
|
||||
aRect.origin.y += strokeWidth + (shadowBlur + shadowSize.height / 2);
|
||||
aRect.size.width -= (strokeWidth * 2) + (shadowBlur * 2);
|
||||
aRect.size.height -= (strokeWidth * 2) + (shadowBlur * 2 + shadowSize.height);
|
||||
frame.origin.x += halfStrokeWidth + shadowBlur;
|
||||
frame.origin.y += halfStrokeWidth + (shadowBlur + shadowSize.height / 2);
|
||||
frame.size.width -= strokeWidth + (shadowBlur * 2);
|
||||
frame.size.height -= strokeWidth + (shadowBlur * 2 + shadowSize.height);
|
||||
|
||||
CGContextSetStrokeColor(context, strokeColor);
|
||||
CGContextSetLineWidth(context, strokeWidth);
|
||||
CGContextBeginPath(context);
|
||||
CGContextSetShadowWithColor(context, shadowSize, shadowBlur, shadowColor);
|
||||
CGContextDrawLinearGradient(context, gradient, CGPointMake(CPRectGetMidX(aRect), 0.0), CGPointMake(CPRectGetMidX(aRect), aRect.size.height), 0);
|
||||
CGContextDrawLinearGradient(context, gradient, CGPointMake(CGRectGetMidX(frame), 0.0), CGPointMake(CGRectGetMidX(frame), frame.size.height), 0);
|
||||
|
||||
|
||||
var xMin = _CGRectGetMinX(aRect),
|
||||
xMax = _CGRectGetMaxX(aRect),
|
||||
yMin = _CGRectGetMinY(aRect),
|
||||
yMax = _CGRectGetMaxY(aRect);
|
||||
var xMin = _CGRectGetMinX(frame),
|
||||
xMax = _CGRectGetMaxX(frame),
|
||||
yMin = _CGRectGetMinY(frame),
|
||||
yMax = _CGRectGetMaxY(frame),
|
||||
arrowMinX = ALIGN_COORD(xMin + radius + strokeWidth),
|
||||
arrowMaxX = ALIGN_COORD(xMax - radius - strokeWidth),
|
||||
arrowMinY = ALIGN_COORD(yMin + radius + strokeWidth),
|
||||
arrowMaxY = ALIGN_COORD(yMax - radius + strokeWidth),
|
||||
arrowAnchor = CGPointMakeZero(),
|
||||
arrowStart = CGPointMakeZero(),
|
||||
pt = CGPointMakeZero();
|
||||
|
||||
// draw!
|
||||
switch (_preferredEdge)
|
||||
{
|
||||
case CPMinXEdge:
|
||||
// origin ne
|
||||
CGContextMoveToPoint(context, xMin + radius, yMin);
|
||||
|
||||
// ne
|
||||
CGContextAddLineToPoint(context, xMax - radius, yMin);
|
||||
CGContextAddCurveToPoint(context, xMax - radius, yMin, xMax, yMin, xMax, yMin + radius);
|
||||
|
||||
// arrow CPMinXEdge
|
||||
CGContextAddLineToPoint(context, xMax, (aRect.size.height / 2) + aRect.origin.y + _arrowOffsetY - (arrowHeight - 2));
|
||||
CGContextAddLineToPoint(context, aRect.size.width + arrowHeight + aRect.origin.x + _arrowOffsetX, (aRect.size.height / 2) + aRect.origin.y + _arrowOffsetY);
|
||||
CGContextAddLineToPoint(context, aRect.size.width + aRect.origin.x + _arrowOffsetX, (aRect.size.height / 2 + (arrowWidth / 2)) + aRect.origin.y + _arrowOffsetY);
|
||||
|
||||
// se
|
||||
CGContextAddLineToPoint(context, xMax, yMax - radius);
|
||||
CGContextAddCurveToPoint(context, xMax, yMax - radius, xMax, yMax, xMax - radius, yMax);
|
||||
|
||||
// sw
|
||||
CGContextAddLineToPoint(context, xMin + radius, yMax);
|
||||
CGContextAddCurveToPoint(context, xMin + radius, yMax, xMin, yMax, xMin, yMax - radius);
|
||||
|
||||
// nw
|
||||
CGContextAddLineToPoint(context, xMin, yMin + radius);
|
||||
CGContextAddCurveToPoint(context, xMin, yMin + radius, xMin, yMin, xMin + radius, yMin);
|
||||
break;
|
||||
|
||||
case CPMaxXEdge:
|
||||
// origin ne
|
||||
CGContextMoveToPoint(context, xMin + radius, yMin);
|
||||
// origin nw
|
||||
pt.x = ALIGN_COORD(xMin + radius);
|
||||
pt.y = yMin;
|
||||
CGContextMoveToPoint(context, pt.x, pt.y);
|
||||
|
||||
// ne
|
||||
CGContextAddLineToPoint(context, xMax - radius, yMin);
|
||||
CGContextAddCurveToPoint(context, xMax - radius, yMin, xMax, yMin, xMax, yMin + radius);
|
||||
pt.x = ALIGN_COORD(xMax - radius);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, xMax, yMin, xMax, ALIGN_COORD(yMin + radius));
|
||||
|
||||
if (_preferredEdge === CPMinXEdge)
|
||||
{
|
||||
// arrow CPMinXEdge
|
||||
arrowAnchor.x = ALIGN_STROKE(xMax);
|
||||
arrowAnchor.y = ALIGN_COORD((frame.size.height / 2) + yMin + _arrowOffsetY);
|
||||
|
||||
// to top edge
|
||||
pt.y = ALIGN_COORD(arrowAnchor.y - (arrowWidth / 2));
|
||||
|
||||
// adjust starting point to not go beyond the corner
|
||||
if (pt.y <= arrowMinY)
|
||||
pt.y = arrowMinY;
|
||||
else if ((pt.y + arrowWidth) > arrowMaxY)
|
||||
pt.y = arrowMaxY - arrowWidth;
|
||||
|
||||
pt.x = arrowAnchor.x;
|
||||
arrowStart = CGPointMakeCopy(pt);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// top edge -> point
|
||||
pt.x = ALIGN_STROKE(arrowAnchor.x + arrowHeight);
|
||||
pt.y = arrowAnchor.y;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// point -> bottom edge
|
||||
pt.x = arrowAnchor.x;
|
||||
pt.y = ALIGN_COORD(arrowStart.y + arrowWidth);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
}
|
||||
|
||||
// se
|
||||
CGContextAddLineToPoint(context, xMax, yMax - radius);
|
||||
CGContextAddCurveToPoint(context, xMax, yMax - radius, xMax, yMax, xMax - radius, yMax);
|
||||
pt.x = xMax;
|
||||
pt.y = ALIGN_COORD(yMax - radius);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, pt.x, yMax, ALIGN_COORD(xMax - radius), yMax);
|
||||
|
||||
// sw
|
||||
CGContextAddLineToPoint(context, xMin + radius, yMax);
|
||||
CGContextAddCurveToPoint(context, xMin + radius, yMax, xMin, yMax, xMin, yMax - radius);
|
||||
pt.x = ALIGN_COORD(xMin + radius);
|
||||
pt.y = yMax;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, xMin, pt.y, xMin, ALIGN_COORD(yMax - radius));
|
||||
|
||||
// arrow CPMaxXEdge
|
||||
CGContextAddLineToPoint(context, xMin, (aRect.size.height / 2 + (arrowWidth / 2) + aRect.origin.y + _arrowOffsetY));
|
||||
CGContextAddLineToPoint(context, aRect.origin.x - arrowHeight + _arrowOffsetX, (aRect.size.height / 2) + aRect.origin.y + _arrowOffsetY);
|
||||
CGContextAddLineToPoint(context, aRect.origin.x + _arrowOffsetX, (aRect.size.height / 2 - (arrowWidth / 2) + aRect.origin.y + _arrowOffsetY));
|
||||
if (_preferredEdge === CPMaxXEdge)
|
||||
{
|
||||
// arrow CPMaxXEdge
|
||||
arrowAnchor.x = ALIGN_STROKE(xMin);
|
||||
arrowAnchor.y = ALIGN_COORD((frame.size.height / 2) + yMin + _arrowOffsetY);
|
||||
|
||||
// to bottom edge
|
||||
pt.y = ALIGN_COORD(arrowAnchor.y + (arrowWidth / 2));
|
||||
|
||||
// adjust starting point to not go beyond the corner
|
||||
if ((pt.y - arrowWidth) < arrowMinY)
|
||||
pt.y = arrowMinY + arrowWidth;
|
||||
else if (pt.y > arrowMaxY)
|
||||
pt.y = arrowMaxY;
|
||||
|
||||
pt.x = arrowAnchor.x;
|
||||
arrowStart = CGPointMakeCopy(pt);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// bottom edge -> point
|
||||
pt.x = ALIGN_STROKE(arrowAnchor.x - arrowHeight);
|
||||
pt.y = arrowAnchor.y;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// point -> top edge
|
||||
pt.x = arrowAnchor.x;
|
||||
pt.y = ALIGN_COORD(arrowStart.y - arrowWidth);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
}
|
||||
|
||||
// nw
|
||||
CGContextAddLineToPoint(context, xMin, yMin + radius);
|
||||
CGContextAddCurveToPoint(context, xMin, yMin + radius, xMin, yMin, xMin + radius, yMin);
|
||||
pt.x = xMin;
|
||||
pt.y = ALIGN_COORD(yMin + radius);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, pt.x, yMin, ALIGN_COORD(xMin + radius), yMin);
|
||||
break;
|
||||
|
||||
case CPMaxYEdge:
|
||||
// origin nw
|
||||
CGContextMoveToPoint(context, xMin, yMin + yMin);
|
||||
|
||||
// nw
|
||||
CGContextAddLineToPoint(context, xMin, yMin + radius);
|
||||
CGContextAddCurveToPoint(context, xMin, yMin + radius, xMin, yMin, xMin + radius, yMin);
|
||||
|
||||
// arrow CPMaxYEdge
|
||||
CGContextAddLineToPoint(context, (aRect.size.width / 2) + aRect.origin.x + _arrowOffsetX - (arrowWidth / 2), yMin);
|
||||
CGContextAddLineToPoint(context, (aRect.size.width / 2) + aRect.origin.x + _arrowOffsetX, aRect.origin.y - arrowHeight + _arrowOffsetY);
|
||||
CGContextAddLineToPoint(context, (aRect.size.width / 2) + (arrowWidth / 2) + aRect.origin.x + _arrowOffsetX, aRect.origin.y + _arrowOffsetY);
|
||||
|
||||
// ne
|
||||
CGContextAddLineToPoint(context, xMax - radius, yMin);
|
||||
CGContextAddCurveToPoint(context, xMax - radius, yMin, xMax, yMin, xMax, yMin + radius);
|
||||
|
||||
// se
|
||||
CGContextAddLineToPoint(context, xMax, yMax - radius);
|
||||
CGContextAddCurveToPoint(context, xMax, yMax - radius, xMax, yMax, xMax - radius, yMax);
|
||||
|
||||
// sw
|
||||
CGContextAddLineToPoint(context, xMin + radius, yMax);
|
||||
CGContextAddCurveToPoint(context, xMin + radius, yMax, xMin, yMax, xMin, yMax - radius);
|
||||
break;
|
||||
|
||||
case CPMinYEdge:
|
||||
// origin nw
|
||||
CGContextMoveToPoint(context, xMin, yMin + yMin);
|
||||
// origin sw
|
||||
pt.x = xMin;
|
||||
pt.y = ALIGN_COORD(yMax - radius);
|
||||
CGContextMoveToPoint(context, pt.x, pt.y);
|
||||
|
||||
// nw
|
||||
CGContextAddLineToPoint(context, xMin, yMin + radius);
|
||||
CGContextAddCurveToPoint(context, xMin, yMin + radius, xMin, yMin, xMin + radius, yMin);
|
||||
pt.y = ALIGN_COORD(yMin + radius);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, pt.x, yMin, ALIGN_COORD(xMin + radius), yMin);
|
||||
|
||||
if (_preferredEdge === CPMaxYEdge)
|
||||
{
|
||||
// arrow CPMaxYEdge
|
||||
arrowAnchor.x = ALIGN_COORD((frame.size.width / 2) + xMin + _arrowOffsetX);
|
||||
arrowAnchor.y = ALIGN_STROKE(yMin + _arrowOffsetY);
|
||||
|
||||
// to left edge
|
||||
pt.x = ALIGN_COORD(arrowAnchor.x - (arrowWidth / 2));
|
||||
|
||||
// adjust starting point to not go beyond the corner
|
||||
if (pt.x < arrowMinX)
|
||||
pt.x = arrowMinX;
|
||||
else if ((pt.x + arrowWidth) > arrowMaxX)
|
||||
pt.x = arrowMaxX - arrowWidth;
|
||||
|
||||
pt.y = arrowAnchor.y;
|
||||
arrowStart = CGPointMakeCopy(pt);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// left edge -> point
|
||||
pt.x = arrowAnchor.x;
|
||||
pt.y = ALIGN_STROKE(arrowAnchor.y - arrowHeight);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// point -> right edge
|
||||
pt.x = ALIGN_COORD(arrowStart.x + arrowWidth);
|
||||
pt.y = arrowAnchor.y;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
}
|
||||
|
||||
// ne
|
||||
CGContextAddLineToPoint(context, xMax - radius, yMin);
|
||||
CGContextAddCurveToPoint(context, xMax - radius, yMin, xMax, yMin, xMax, yMin + radius);
|
||||
pt.x = ALIGN_COORD(xMax - radius);
|
||||
pt.y = yMin;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, xMax, pt.y, xMax, ALIGN_COORD(yMin + radius));
|
||||
|
||||
// se
|
||||
CGContextAddLineToPoint(context, xMax, yMax - radius);
|
||||
CGContextAddCurveToPoint(context, xMax, yMax - radius, xMax, yMax, xMax - radius, yMax);
|
||||
pt.x = xMax;
|
||||
pt.y = ALIGN_COORD(yMax - radius);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, pt.x, yMax, ALIGN_COORD(xMax - radius), yMax);
|
||||
|
||||
// arrow CPMinYEdge
|
||||
CGContextAddLineToPoint(context, (aRect.size.width / 2) + (arrowWidth / 2) + aRect.origin.x + _arrowOffsetX , yMax);
|
||||
CGContextAddLineToPoint(context, (aRect.size.width / 2) + aRect.origin.x + _arrowOffsetX, aRect.size.height + aRect.origin.y + arrowHeight + _arrowOffsetY);
|
||||
CGContextAddLineToPoint(context, (aRect.size.width / 2) - (arrowWidth / 2) + aRect.origin.x + _arrowOffsetX, aRect.size.height + aRect.origin.y + _arrowOffsetY);
|
||||
if (_preferredEdge === CPMinYEdge)
|
||||
{
|
||||
// arrow CPMinYEdge
|
||||
arrowAnchor.x = ALIGN_COORD((frame.size.width / 2) + xMin + _arrowOffsetX);
|
||||
arrowAnchor.y = ALIGN_STROKE(yMax + _arrowOffsetY);
|
||||
|
||||
// to right edge
|
||||
pt.x = ALIGN_COORD(arrowAnchor.x + (arrowWidth / 2));
|
||||
|
||||
// adjust starting point to not go beyond the corner
|
||||
if ((pt.x - arrowWidth) < arrowMinX)
|
||||
pt.x = arrowMinX + arrowWidth;
|
||||
else if (pt.x > arrowMaxX)
|
||||
pt.x = arrowMaxX;
|
||||
|
||||
pt.y = arrowAnchor.y;
|
||||
arrowStart = CGPointMakeCopy(pt);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// right edge -> point
|
||||
pt.x = arrowAnchor.x;
|
||||
pt.y = ALIGN_STROKE(arrowAnchor.y + arrowHeight);
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
|
||||
// point -> left edge
|
||||
pt.x = ALIGN_COORD(arrowStart.x - arrowWidth);
|
||||
pt.y = arrowAnchor.y;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
}
|
||||
|
||||
// sw
|
||||
CGContextAddLineToPoint(context, xMin + radius, yMax);
|
||||
CGContextAddCurveToPoint(context, xMin + radius, yMax, xMin, yMax, xMin, yMax - radius);
|
||||
pt.x = ALIGN_COORD(xMin + radius);
|
||||
pt.y = yMax;
|
||||
CGContextAddLineToPoint(context, pt.x, pt.y);
|
||||
CGContextAddCurveToPoint(context, pt.x, pt.y, xMin, pt.y, xMin, ALIGN_COORD(yMax - radius));
|
||||
break;
|
||||
|
||||
default:
|
||||
// no computed edge means standard rounded rect
|
||||
CGContextAddPath(context, CGPathWithRoundedRectangleInRect(aRect, radius, radius, YES, YES, YES, YES));
|
||||
CGContextAddPath(context, CGPathWithRoundedRectangleInRect(frame, radius, radius, YES, YES, YES, YES));
|
||||
}
|
||||
|
||||
CGContextClosePath(context);
|
||||
|
||||
@@ -33,7 +33,14 @@ var _CPToolbarViewBackgroundColor = nil;
|
||||
+ (CPColor)toolbarBackgroundColor
|
||||
{
|
||||
if (!_CPToolbarViewBackgroundColor)
|
||||
_CPToolbarViewBackgroundColor = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[_CPBorderlessBridgeWindowView class]] pathForResource:@"_CPToolbarView/_CPToolbarViewBackground.png"] size:CGSizeMake(1.0, 59.0)]];
|
||||
{
|
||||
var bundle = [CPBundle bundleForClass:[_CPBorderlessBridgeWindowView class]];
|
||||
_CPToolbarViewBackgroundColor = CPColorWithImages([
|
||||
["_CPToolbarView/toolbar-background-top.png", 1, 1, bundle],
|
||||
["_CPToolbarView/toolbar-background-center.png", 1, 57.0, bundle],
|
||||
["_CPToolbarView/toolbar-background-bottom.png", 1, 1, bundle],
|
||||
], CPColorPatternIsVertical);
|
||||
}
|
||||
|
||||
return _CPToolbarViewBackgroundColor;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ var HUD_TITLEBAR_HEIGHT = 26.0;
|
||||
|
||||
if ([[[self window] toolbar] isVisible])
|
||||
{
|
||||
toolbarHeight = CGRectGetHeight([[self toolbarView] frame]);
|
||||
var toolbarHeight = CGRectGetHeight([[self toolbarView] frame]);
|
||||
|
||||
contentRect.origin.y += toolbarHeight;
|
||||
contentRect.size.height -= toolbarHeight;
|
||||
|
||||
@@ -181,7 +181,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
|
||||
|
||||
if ([theToolbar isVisible])
|
||||
{
|
||||
toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
|
||||
|
||||
contentRect.origin.y += toolbarHeight;
|
||||
contentRect.size.height -= toolbarHeight;
|
||||
|
||||
@@ -27,15 +27,31 @@
|
||||
{
|
||||
BOOL _mouseDownPressed @accessors(getter=isMouseDownPressed, setter=setMouseDownPressed:);
|
||||
unsigned _gravity @accessors(property=gravity);
|
||||
|
||||
CPColor _backgroundColor;
|
||||
CPColor _strokeColor;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Class methods
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"tooltip";
|
||||
}
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[[CPColor colorWithHexString:@"E3E3E3"],
|
||||
[CPColor colorWithHexString:@"FFFFCA"],
|
||||
2.0,
|
||||
1.0,
|
||||
[CPColor blackColor]]
|
||||
forKeys:[@"stroke-color",
|
||||
@"background-color",
|
||||
@"border-radius",
|
||||
@"stroke-width",
|
||||
@"color"]];
|
||||
}
|
||||
|
||||
/*! compute the contentView frame from a given window frame
|
||||
@param aFrameRect the window frame
|
||||
*/
|
||||
@@ -67,21 +83,6 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization
|
||||
|
||||
- (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame styleMask:aStyleMask])
|
||||
{
|
||||
_strokeColor = [CPColor colorWithHexString:@"E3E3E3"];
|
||||
_backgroundColor = [CPColor colorWithHexString:@"FFFFCA"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark drawing
|
||||
|
||||
@@ -90,11 +91,13 @@
|
||||
[super drawRect:aRect];
|
||||
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
radius = 2,
|
||||
strokeWidth = 1;
|
||||
radius = [self currentValueForThemeAttribute:@"border-radius"],
|
||||
strokeWidth = [self currentValueForThemeAttribute:@"stroke-width"],
|
||||
strokeColor = [self currentValueForThemeAttribute:@"stroke-color"],
|
||||
bgColor = [self currentValueForThemeAttribute:@"background-color"];
|
||||
|
||||
CGContextSetStrokeColor(context, _strokeColor);
|
||||
CGContextSetFillColor(context, _backgroundColor);
|
||||
CGContextSetStrokeColor(context, strokeColor);
|
||||
CGContextSetFillColor(context, bgColor);
|
||||
CGContextSetLineWidth(context, strokeWidth);
|
||||
CGContextBeginPath(context);
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* CPWorkspace.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2012, SlevenBits Ltd.
|
||||
*
|
||||
* 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/CPString.j>
|
||||
|
||||
var SharedWorkspace = nil;
|
||||
|
||||
|
||||
@implementation CPWorkspace : CPObject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+ (CPWorkspace)sharedWorkspace
|
||||
{
|
||||
if (!SharedWorkspace)
|
||||
SharedWorkspace = [CPWorkspace new];
|
||||
|
||||
return SharedWorkspace;
|
||||
}
|
||||
|
||||
- (BOOL)openFile:(CPString)fullPath
|
||||
{
|
||||
var url = [CPURL URLWithString:fullPath];
|
||||
return [self openURL:url];
|
||||
}
|
||||
|
||||
- (BOOL)openURL:(CPURL)url
|
||||
{
|
||||
if (!url || ![url absoluteURL])
|
||||
return NO;
|
||||
window.open([url absoluteURL]);
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -125,14 +125,13 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemp
|
||||
|
||||
- (id)_cibInstantiate
|
||||
{
|
||||
var windowClass = CPClassFromString([self windowClass]);
|
||||
var windowClass = CPClassFromString([self windowClass]),
|
||||
theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
|
||||
|
||||
/* if (!windowClass)
|
||||
[NSException raise:NSInvalidArgumentException format:@"Unable to locate NSWindow class %@, using NSWindow",_windowClass];
|
||||
class=[NSWindow class];*/
|
||||
|
||||
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
|
||||
|
||||
if (_minSize)
|
||||
[theWindow setMinSize:_minSize];
|
||||
if (_maxSize)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
function CABackingStoreGetContext(aBackingStore)
|
||||
{
|
||||
return aBackingStore.context;
|
||||
}
|
||||
};
|
||||
|
||||
if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
|
||||
{
|
||||
@@ -42,7 +42,7 @@ CABackingStoreCreate = function()
|
||||
|
||||
// FIXME: Consolidate drawImage to support this.
|
||||
return { context:DOMElement.getContext("2d"), buffer:DOMElement, _image:DOMElement };
|
||||
}
|
||||
};
|
||||
|
||||
CABackingStoreSetSize = function(aBackingStore, aSize)
|
||||
{
|
||||
@@ -52,7 +52,8 @@ CABackingStoreSetSize = function(aBackingStore, aSize)
|
||||
buffer.height = aSize.height;
|
||||
buffer.style.width = PIXEL(aSize.width);
|
||||
buffer.style.height = PIXEL(aSize.height);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -64,10 +65,10 @@ CABackingStoreCreate = function()
|
||||
context.buffer = "";
|
||||
|
||||
return { context:context };
|
||||
}
|
||||
};
|
||||
|
||||
CABackingStoreSetSize = function(aBackingStore, aSize)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ if (CPFeatureIsCompatible(CPJavaScriptCanvasTransformFeature))
|
||||
CGContextConcatCTM = function(aContext, anAffineTransform)
|
||||
{
|
||||
aContext.transform(anAffineTransform.a, anAffineTransform.b, anAffineTransform.c, anAffineTransform.d, anAffineTransform.tx, anAffineTransform.ty);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
else
|
||||
@@ -428,7 +428,7 @@ CGContextConcatCTM = function(aContext, anAffineTransform)
|
||||
CGContextScaleCTM(aContext, sx, sy);
|
||||
if (a2 != 0.0)
|
||||
CGContextRotateCTM(aContext, a2);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,16 +29,16 @@ kCGGradientDrawsAfterEndLocation = 1 << 1;
|
||||
|
||||
function CGGradientCreateWithColorComponents(aColorSpace, components, locations, count)
|
||||
{
|
||||
if ( locations === undefined || locations === NULL )
|
||||
if (locations === undefined || locations === NULL)
|
||||
{
|
||||
var num_of_colors = components.length / 4,
|
||||
locations = [];
|
||||
for ( var idx = 0; idx < num_of_colors; idx++ )
|
||||
for (var idx = 0; idx < num_of_colors; idx++)
|
||||
locations.push( idx / (num_of_colors - 1) );
|
||||
}
|
||||
|
||||
if ( count === undefined || count === NULL)
|
||||
var count = locations.length;
|
||||
if (count === undefined || count === NULL)
|
||||
count = locations.length;
|
||||
|
||||
var colors = [];
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ var screenNeedsInitialization = NO,
|
||||
window.onunload = function()
|
||||
{
|
||||
[CPApp terminate:nil];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+ (BOOL)isBrowser
|
||||
|
||||
@@ -1568,7 +1568,7 @@ var _CPEventFromNativeMouseEvent = function(aNativeEvent, anEventType, aPoint, m
|
||||
aNativeEvent._eventNumber = anEventNumber;
|
||||
aNativeEvent._clickCount = aClickCount;
|
||||
aNativeEvent._pressure = aPressure;
|
||||
if((anEventType == CPLeftMouseDragged) || (anEventType == CPRightMouseDragged) || (anEventType == CPMouseMoved))
|
||||
if ((anEventType == CPLeftMouseDragged) || (anEventType == CPRightMouseDragged) || (anEventType == CPMouseMoved))
|
||||
{
|
||||
aNativeEvent._deltaX = aPoint.x - aMouseDragStart.x;
|
||||
aNativeEvent._deltaY = aPoint.y - aMouseDragStart.y;
|
||||
@@ -1581,7 +1581,7 @@ var _CPEventFromNativeMouseEvent = function(aNativeEvent, anEventType, aPoint, m
|
||||
|
||||
|
||||
return aNativeEvent;
|
||||
}
|
||||
};
|
||||
|
||||
var CLICK_SPACE_DELTA = 5.0,
|
||||
CLICK_TIME_DELTA = (typeof document != "undefined" && document.addEventListener) ? 350.0 : 1000.0;
|
||||
@@ -1596,7 +1596,7 @@ var CPDOMEventGetClickCount = function(aComparisonEvent, aTimestamp, aLocation)
|
||||
return (aTimestamp - [aComparisonEvent timestamp] < CLICK_TIME_DELTA &&
|
||||
ABS(comparisonLocation.x - aLocation.x) < CLICK_SPACE_DELTA &&
|
||||
ABS(comparisonLocation.y - aLocation.y) < CLICK_SPACE_DELTA) ? [aComparisonEvent clickCount] + 1 : 1;
|
||||
}
|
||||
};
|
||||
|
||||
var CPDOMEventStop = function(aDOMEvent, aPlatformWindow)
|
||||
{
|
||||
@@ -1616,7 +1616,7 @@ var CPDOMEventStop = function(aDOMEvent, aPlatformWindow)
|
||||
aPlatformWindow._DOMFocusElement.focus();
|
||||
aPlatformWindow._DOMFocusElement.blur();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function CPWindowObjectList()
|
||||
{
|
||||
|
||||
@@ -229,4 +229,4 @@ CPKeyCodes.isCharacterKey = function(keyCode)
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 185 B |
Binary file not shown.
|
After Width: | Height: | Size: 108 B |
Binary file not shown.
|
After Width: | Height: | Size: 193 B |
Binary file not shown.
|
After Width: | Height: | Size: 109 B |
@@ -1766,6 +1766,24 @@ var themedButtonValues = nil,
|
||||
return ruleEditor;
|
||||
}
|
||||
|
||||
+ (_CPToolTipWindowView)themedTooltip
|
||||
{
|
||||
var toolTipView = [[_CPToolTipWindowView alloc] initWithFrame:CPRectMakeZero() styleMask:_CPToolTipWindowMask],
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"stroke-color", [CPColor colorWithHexString:@"E3E3E3"]],
|
||||
[@"stroke-width", 1.0],
|
||||
[@"border-radius", 2.0],
|
||||
[@"background-color", [CPColor colorWithHexString:@"FFFFCA"]],
|
||||
[@"color", [CPColor blackColor]]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themeValues forView:toolTipView];
|
||||
|
||||
return toolTipView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AristoHUDThemeDescriptor : BKThemeDescriptor
|
||||
|
||||
@@ -26,7 +26,7 @@ BlendTask.prototype.__proto__ = BundleTask.prototype;
|
||||
BlendTask.prototype.packageType = function()
|
||||
{
|
||||
return "BLND";
|
||||
}
|
||||
};
|
||||
|
||||
BlendTask.prototype.infoPlist = function()
|
||||
{
|
||||
@@ -35,28 +35,28 @@ BlendTask.prototype.infoPlist = function()
|
||||
infoPlist.setValueForKey("CPKeyedThemes", require("narwhal/util").unique(this._keyedThemes));
|
||||
|
||||
return infoPlist;
|
||||
}
|
||||
};
|
||||
|
||||
BlendTask.prototype.themeDescriptors = function()
|
||||
{
|
||||
return this._themeDescriptors;
|
||||
}
|
||||
};
|
||||
|
||||
BlendTask.prototype.setThemeDescriptors = function(/*Array | FileList*/ themeDescriptors)
|
||||
{
|
||||
this._themeDescriptors = themeDescriptors;
|
||||
}
|
||||
};
|
||||
|
||||
BlendTask.prototype.defineTasks = function()
|
||||
{
|
||||
this.defineThemeDescriptorTasks();
|
||||
|
||||
BundleTask.prototype.defineTasks.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
BlendTask.prototype.defineSourceTasks = function()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
BlendTask.prototype.defineThemeDescriptorTasks = function()
|
||||
{
|
||||
@@ -106,7 +106,7 @@ BlendTask.prototype.defineThemeDescriptorTasks = function()
|
||||
});
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
function cibDataFromTopLevelObjects(objects)
|
||||
{
|
||||
@@ -232,4 +232,4 @@ exports.blend = function(aName, aFunction)
|
||||
{
|
||||
// No .apply necessary because the parameters aren't variable.
|
||||
return BlendTask.defineTask(aName, aFunction);
|
||||
}
|
||||
};
|
||||
|
||||
+145
-100
@@ -38,7 +38,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
@ignore
|
||||
|
||||
This is a simple attached window like the one that pops up
|
||||
when you double click on a meeting in iCal
|
||||
when you double click on a meeting in iCal.
|
||||
*/
|
||||
@implementation _CPAttachedWindow : CPWindow
|
||||
{
|
||||
@@ -47,23 +47,23 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
int _appearance @accessors(getter=appearance);
|
||||
|
||||
BOOL _closeOnBlur;
|
||||
BOOL _isClosed;
|
||||
BOOL _isClosing;
|
||||
BOOL _browserAnimates;
|
||||
BOOL _shouldPerformAnimation;
|
||||
CPButton _closeButton;
|
||||
float _animationDuration;
|
||||
CPInteger _implementedDelegateMethods;
|
||||
}
|
||||
|
||||
/*!
|
||||
override default windowView class loader
|
||||
|
||||
@param aStyleMask the window mask
|
||||
@return the windowView class
|
||||
*/
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Class methods
|
||||
|
||||
/*!
|
||||
Overrides the default windowView class loader.
|
||||
|
||||
@param aStyleMask the window mask
|
||||
@return the windowView class
|
||||
*/
|
||||
+ (Class)_windowViewClassForStyleMask:(unsigned)aStyleMask
|
||||
{
|
||||
return _CPAttachedWindowView;
|
||||
@@ -74,7 +74,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
#pragma mark Initialization
|
||||
|
||||
/*!
|
||||
Create and init a _CPAttachedWindow with given size of and view
|
||||
Create and init a _CPAttachedWindow with the given size and view.
|
||||
|
||||
@param aSize the size of the attached window
|
||||
@param aView the target view
|
||||
@@ -86,16 +86,16 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
}
|
||||
|
||||
/*!
|
||||
Create and init a _CPAttachedWindow with given size of and view
|
||||
Create and init a _CPAttachedWindow with given the size, view and style mask.
|
||||
|
||||
@param aSize the size of the attached window
|
||||
@param aView the target view
|
||||
@return ready to use _CPAttachedWindow
|
||||
@param styleMask the window style mask (combine CPClosableWindowMask and CPClosableOnBlurWindowMask)
|
||||
@return ready to use _CPAttachedWindow
|
||||
*/
|
||||
+ (id)attachedWindowWithSize:(CGSize)aSize forView:(CPView)aView styleMask:(int)aMask
|
||||
{
|
||||
var attachedWindow = [[_CPAttachedWindow alloc] initWithContentRect:CPRectMake(0.0, 0.0, aSize.width, aSize.height) styleMask:aMask];
|
||||
var attachedWindow = [[_CPAttachedWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, aSize.width, aSize.height) styleMask:aMask];
|
||||
|
||||
[attachedWindow attachToView:aView];
|
||||
|
||||
@@ -103,7 +103,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
}
|
||||
|
||||
/*!
|
||||
Create and init a _CPAttachedWindow with given frame
|
||||
Create and init a _CPAttachedWindow with given the given frame.
|
||||
|
||||
@param aFrame the frame of the attached window
|
||||
@return ready to use _CPAttachedWindow
|
||||
@@ -115,7 +115,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
}
|
||||
|
||||
/*!
|
||||
Create and init a _CPAttachedWindow with given frame
|
||||
Create and init a _CPAttachedWindow with the given frame and style mask.
|
||||
|
||||
@param aFrame the frame of the attached window
|
||||
@param styleMask the window style mask (combine CPClosableWindowMask and CPClosableOnBlurWindowMask)
|
||||
@@ -126,19 +126,16 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
if (self = [super initWithContentRect:aFrame styleMask:aStyleMask])
|
||||
{
|
||||
_animates = YES;
|
||||
_animates = YES;
|
||||
_animationDuration = 150;
|
||||
_closeOnBlur = (aStyleMask & CPClosableOnBlurWindowMask);
|
||||
_isClosed = NO;
|
||||
_shouldPerformAnimation = _animates;
|
||||
_isClosing = NO;
|
||||
_browserAnimates = [self browserSupportsAnimation];
|
||||
_shouldPerformAnimation = YES;
|
||||
|
||||
[self setLevel:CPStatusWindowLevel];
|
||||
[self setMovableByWindowBackground:YES];
|
||||
[self setHasShadow:NO];
|
||||
|
||||
_DOMElement.style.WebkitBackfaceVisibility = "hidden";
|
||||
_DOMElement.style.WebkitTransitionProperty = "-webkit-transform, opacity";
|
||||
_DOMElement.style.WebkitTransitionDuration = _animationDuration + "ms";
|
||||
[self setCSS3Property:@"TransitionProperty" value:@"-webkit-transform, opacity"];
|
||||
|
||||
[_windowView setNeedsDisplay:YES];
|
||||
}
|
||||
@@ -151,7 +148,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
|
||||
- (void)setAppearance:(int)anAppearance
|
||||
{
|
||||
if (_appearance == anAppearance)
|
||||
if (_appearance === anAppearance)
|
||||
return;
|
||||
|
||||
[_windowView setAppearance:anAppearance];
|
||||
@@ -159,7 +156,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
|
||||
- (void)setDelegate:(id)aDelegate
|
||||
{
|
||||
if (_delegate == aDelegate)
|
||||
if (_delegate === aDelegate)
|
||||
return;
|
||||
|
||||
_delegate = aDelegate;
|
||||
@@ -176,14 +173,13 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
#pragma mark Observer
|
||||
|
||||
/*!
|
||||
Update the _CPAttachedWindow frame if a resize event is observed
|
||||
|
||||
Update the _CPAttachedWindow frame if a resize event is observed.
|
||||
*/
|
||||
- (void)observeValueForKeyPath:(CPString)aPath ofObject:(id)anObject change:(CPDictionary)theChange context:(void)aContext
|
||||
{
|
||||
if ([aPath isEqual:@"frame"])
|
||||
{
|
||||
// @TODO: not recompute everything, just compute the move offset
|
||||
// TODO: don't recompute everything, just compute the move offset
|
||||
var g = [_windowView preferredEdge];
|
||||
|
||||
[self positionRelativeToView:_targetView preferredEdge:g];
|
||||
@@ -201,7 +197,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
[_targetView removeObserver:self forKeyPath:@"frame"];
|
||||
[_windowView hideCursor];
|
||||
[self setLevel:CPNormalWindowLevel];
|
||||
[_closeButton setFrameOrigin:CPPointMake(1.0, 1.0)];
|
||||
[_closeButton setFrameOrigin:CGPointMake(1.0, 1.0)];
|
||||
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPWindowDidMoveNotification object:self];
|
||||
}
|
||||
}
|
||||
@@ -210,15 +206,14 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
#pragma mark -
|
||||
#pragma mark Utilities
|
||||
|
||||
- (CPPoint)computeOrigin:(CPView)aView preferredEdge:(int)anEdge
|
||||
- (CGPoint)computeOrigin:(CPView)aView preferredEdge:(int)anEdge
|
||||
{
|
||||
var frameView = [aView frame],
|
||||
currentView = aView,
|
||||
origin = [aView frameOrigin],
|
||||
lastView;
|
||||
|
||||
// if somebody succeed to use the conversion function of CPView
|
||||
// to get this working, please do.
|
||||
// FIXME: make this work with the conversion function of CPView
|
||||
while (currentView = [currentView superview])
|
||||
{
|
||||
origin.x += [currentView frameOrigin].x;
|
||||
@@ -237,32 +232,33 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
origin.y -= offsetPoint.y;
|
||||
}
|
||||
|
||||
return [self computeOriginFromRect:CPRectMake(origin.x, origin.y, CPRectGetWidth(frameView), CPRectGetHeight(frameView)) preferredEdge:anEdge];
|
||||
return [self computeOriginFromRect:CGRectMake(origin.x, origin.y, CGRectGetWidth(frameView), CGRectGetHeight(frameView)) preferredEdge:anEdge];
|
||||
}
|
||||
|
||||
- (CPPoint)computeOriginFromRect:(CPRect)aRect preferredEdge:(int)anEdge
|
||||
- (CGPoint)computeOriginFromRect:(CGRect)aRect preferredEdge:(int)anEdge
|
||||
{
|
||||
var nativeRect = [[[CPApp mainWindow] platformWindow] nativeContentRect],
|
||||
originLeft = CPPointCreateCopy(aRect.origin),
|
||||
originRight = CPPointCreateCopy(aRect.origin),
|
||||
originTop = CPPointCreateCopy(aRect.origin),
|
||||
originBottom = CPPointCreateCopy(aRect.origin);
|
||||
originLeft = CGPointCreateCopy(aRect.origin),
|
||||
originRight = CGPointCreateCopy(aRect.origin),
|
||||
originTop = CGPointCreateCopy(aRect.origin),
|
||||
originBottom = CGPointCreateCopy(aRect.origin),
|
||||
frameSize = [self frame].size;
|
||||
|
||||
// CPMaxXEdge
|
||||
originRight.x += aRect.size.width;
|
||||
originRight.y += (aRect.size.height / 2.0) - (CPRectGetHeight([self frame]) / 2.0);
|
||||
originRight.y += (aRect.size.height / 2.0) - (frameSize.height / 2.0);
|
||||
|
||||
// CPMinXEdge
|
||||
originLeft.x -= CPRectGetWidth([self frame]);
|
||||
originLeft.y += (aRect.size.height / 2.0) - (CPRectGetHeight([self frame]) / 2.0);
|
||||
originLeft.x -= frameSize.width;
|
||||
originLeft.y += (aRect.size.height / 2.0) - (frameSize.height / 2.0);
|
||||
|
||||
// CPMaxYEdge
|
||||
originBottom.x += aRect.size.width / 2.0 - CPRectGetWidth([self frame]) / 2.0;
|
||||
originBottom.x += aRect.size.width / 2.0 - frameSize.width / 2.0;
|
||||
originBottom.y += aRect.size.height;
|
||||
|
||||
// CPMinYEdge
|
||||
originTop.x += aRect.size.width / 2.0 - CPRectGetWidth([self frame]) / 2.0;
|
||||
originTop.y -= CPRectGetHeight([self frame]);
|
||||
originTop.x += aRect.size.width / 2.0 - frameSize.width / 2.0;
|
||||
originTop.y -= frameSize.height;
|
||||
|
||||
var requestedEdge = (anEdge !== nil) ? anEdge : CPMaxXEdge,
|
||||
requestedOrigin;
|
||||
@@ -300,20 +296,20 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
[_windowView setArrowOffsetX:o.x];
|
||||
o.x = 0;
|
||||
}
|
||||
if (o.x + CPRectGetWidth([self frame]) > nativeRect.size.width)
|
||||
if (o.x + frameSize.width > nativeRect.size.width)
|
||||
{
|
||||
[_windowView setArrowOffsetX:(o.x + CPRectGetWidth([self frame]) - nativeRect.size.width)];
|
||||
o.x = nativeRect.size.width - CPRectGetWidth([self frame]);
|
||||
[_windowView setArrowOffsetX:(o.x + frameSize.width - nativeRect.size.width)];
|
||||
o.x = nativeRect.size.width - frameSize.width;
|
||||
}
|
||||
if (o.y < 0)
|
||||
{
|
||||
[_windowView setArrowOffsetY:o.y];
|
||||
o.y = 0;
|
||||
}
|
||||
if (o.y + CPRectGetHeight([self frame]) > nativeRect.size.height)
|
||||
if (o.y + frameSize.height > nativeRect.size.height)
|
||||
{
|
||||
[_windowView setArrowOffsetY:(CPRectGetHeight([self frame]) + o.y - nativeRect.size.height)];
|
||||
o.y = nativeRect.size.height - CPRectGetHeight([self frame]);
|
||||
[_windowView setArrowOffsetY:(frameSize.height + o.y - nativeRect.size.height)];
|
||||
o.y = nativeRect.size.height - frameSize.height;
|
||||
}
|
||||
|
||||
switch (g)
|
||||
@@ -323,7 +319,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
return o;
|
||||
break;
|
||||
case CPMinXEdge:
|
||||
if ((o.x + _frame.size.width) <= aRect.origin.x)
|
||||
if ((o.x + frameSize.width) <= aRect.origin.x)
|
||||
return o;
|
||||
break;
|
||||
case CPMaxYEdge:
|
||||
@@ -331,7 +327,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
return o;
|
||||
break;
|
||||
case CPMinYEdge:
|
||||
if ((o.y + _frame.size.height) <= aRect.origin.y)
|
||||
if ((o.y + frameSize.height) <= aRect.origin.y)
|
||||
return o;
|
||||
break;
|
||||
}
|
||||
@@ -366,7 +362,7 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
[self setFrameOrigin:point];
|
||||
[_windowView showCursor];
|
||||
[self setLevel:CPStatusWindowLevel];
|
||||
[_closeButton setFrameOrigin:CPPointMake(1.0, 1.0)];
|
||||
[_closeButton setFrameOrigin:CGPointMake(1.0, 1.0)];
|
||||
[_windowView setNeedsDisplay:YES];
|
||||
[self makeKeyAndOrderFront:nil];
|
||||
|
||||
@@ -375,33 +371,55 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
}
|
||||
|
||||
/*!
|
||||
Position the _CPAttachedWindow to a random point
|
||||
Position the _CPAttachedWindow relative to a given rect,
|
||||
automatically calculating the edge.
|
||||
|
||||
@param aPoint the point where the _CPAttachedWindow will be attached
|
||||
*/
|
||||
- (void)positionRelativeToRect:(CPRect)aRect
|
||||
- (void)positionRelativeToRect:(CGRect)aRect
|
||||
{
|
||||
[self positionRelativeToRect:aRect preferredEdge:nil];
|
||||
}
|
||||
|
||||
/*!
|
||||
Position the _CPAttachedWindow to a random point
|
||||
Position the _CPAttachedWindow relative to a given rect's edge.
|
||||
|
||||
@param aPoint the point where the _CPAttachedWindow will be attached
|
||||
@param anEdge the prefered edge
|
||||
*/
|
||||
- (void)positionRelativeToRect:(CPRect)aRect preferredEdge:(int)anEdge
|
||||
- (void)positionRelativeToRect:(CGRect)aRect preferredEdge:(int)anEdge
|
||||
{
|
||||
var point = [self computeOriginFromRect:aRect preferredEdge:anEdge];
|
||||
|
||||
[self setFrameOrigin:point];
|
||||
[_windowView showCursor];
|
||||
[self setLevel:CPStatusWindowLevel];
|
||||
[_closeButton setFrameOrigin:CPPointMake(1.0, 1.0)];
|
||||
[_closeButton setFrameOrigin:CGPointMake(1.0, 1.0)];
|
||||
[_windowView setNeedsDisplay:YES];
|
||||
[self makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (void)setCSS3Property:(CPString)property value:(CPString)value
|
||||
{
|
||||
_DOMElement.style['webkit' + property] = value;
|
||||
|
||||
// Support other browsers here eventually
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (BOOL)browserSupportsAnimation
|
||||
{
|
||||
return typeof(_DOMElement.style.webkitTransition) !== "undefined";
|
||||
|
||||
/*
|
||||
No others browsers supported yet.
|
||||
|
||||
typeof(_DOMElement.style.MozTransition) !== "undefined" ||
|
||||
typeof(_DOMElement.style.MsTransition) !== "undefined" ||
|
||||
typeof(_DOMElement.style.OTransition) !== "undefined";
|
||||
*/
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Actions
|
||||
@@ -421,11 +439,12 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
#pragma mark Overrides
|
||||
|
||||
/*!
|
||||
Called when the window is loowing focus and close the window if CPClosableOnBlurWindowMask is setted
|
||||
Called when the window is losing focus.
|
||||
Close the window if CPClosableOnBlurWindowMask is set.
|
||||
*/
|
||||
- (void)resignMainWindow
|
||||
{
|
||||
if (_closeOnBlur && !_isClosed)
|
||||
if (_closeOnBlur && !_isClosing)
|
||||
{
|
||||
if (!_delegate || ((_implementedDelegateMethods & _CPAttachedWindow_attachedWindowShouldClose_)
|
||||
&& [_delegate attachedWindowShouldClose:self]))
|
||||
@@ -434,7 +453,8 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
}
|
||||
|
||||
/*!
|
||||
Order front the window as usual and add listener for CPWindowDidMoveNotification
|
||||
When the window appears, show animation if necessary.
|
||||
Also take this opportunity to keep track of window moves.
|
||||
|
||||
@param sender the sender of the action
|
||||
*/
|
||||
@@ -442,78 +462,103 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
{
|
||||
[super orderFront:aSender];
|
||||
|
||||
var tranformOrigin = "50% 100%";
|
||||
|
||||
switch ([_windowView preferredEdge])
|
||||
if (_animates && _browserAnimates && _shouldPerformAnimation)
|
||||
{
|
||||
case CPMaxYEdge:
|
||||
var posX = 50 + (([_windowView arrowOffsetX] * 100) / _frame.size.width);
|
||||
tranformOrigin = posX + "% 0%"; // 50 0
|
||||
break;
|
||||
case CPMinYEdge:
|
||||
var posX = 50 + (([_windowView arrowOffsetX] * 100) / _frame.size.width);
|
||||
tranformOrigin = posX + "% 100%"; // 50 100
|
||||
break;
|
||||
case CPMinXEdge:
|
||||
var posY = 50 + (([_windowView arrowOffsetY] * 100) / _frame.size.height);
|
||||
tranformOrigin = "100% " + posY + "%"; // 100 50
|
||||
break;
|
||||
case CPMaxXEdge:
|
||||
var posY = 50 + (([_windowView arrowOffsetY] * 100) / _frame.size.height);
|
||||
tranformOrigin = "0% "+ posY + "%"; // 0 50
|
||||
break;
|
||||
}
|
||||
var transformOrigin = "50% 100%",
|
||||
frame = [self frame],
|
||||
preferredEdge = [_windowView preferredEdge],
|
||||
posX;
|
||||
|
||||
switch (preferredEdge)
|
||||
{
|
||||
case CPMaxYEdge:
|
||||
case CPMinYEdge:
|
||||
posX = 50 + (([_windowView arrowOffsetX] * 100) / frame.size.width);
|
||||
transformOrigin = posX + "% " + (preferredEdge === CPMaxYEdge ? "0%" : "100%");
|
||||
break;
|
||||
|
||||
case CPMinXEdge:
|
||||
case CPMaxXEdge:
|
||||
posY = 50 + (([_windowView arrowOffsetY] * 100) / frame.size.height);
|
||||
transformOrigin = (preferredEdge === CPMaxXEdge ? "0% " : "100% ") + posY + "%";
|
||||
break;
|
||||
}
|
||||
|
||||
// This is the initial transform. We start scaled to zero and watch for opacity changes.
|
||||
[self setCSS3Property:@"Transform" value:@"scale(0)"];
|
||||
[self setCSS3Property:@"TransformOrigin" value:transformOrigin];
|
||||
[self setCSS3Property:@"Transition" value:"opacity 0 linear"];
|
||||
|
||||
// @TODO: implement for FF
|
||||
if (_animates && _shouldPerformAnimation && typeof(_DOMElement.style.WebkitTransform) != "undefined")
|
||||
{
|
||||
_DOMElement.style.opacity = 0;
|
||||
_DOMElement.style.WebkitTransform = "scale(0)";
|
||||
_DOMElement.style.WebkitTransformOrigin = tranformOrigin;
|
||||
window.setTimeout(function()
|
||||
{
|
||||
_DOMElement.style.height = _frame.size.height + @"px";
|
||||
_DOMElement.style.width = _frame.size.width + @"px";
|
||||
// We are watching opacity, so this triggers the next transition
|
||||
_DOMElement.style.opacity = 1;
|
||||
_DOMElement.style.WebkitTransform = "scale(1.1)";
|
||||
_DOMElement.style.height = frame.size.height + @"px";
|
||||
_DOMElement.style.width = frame.size.width + @"px";
|
||||
|
||||
// Set up the pop-out transition
|
||||
[self setCSS3Property:@"Transform" value:@"scale(1.1)"];
|
||||
[self setCSS3Property:@"Transition" value:@"-webkit-transform 200ms ease-in"];
|
||||
|
||||
var transitionEndFunction = function()
|
||||
{
|
||||
_DOMElement.style.WebkitTransform = "scale(1)";
|
||||
_DOMElement.removeEventListener("webkitTransitionEnd", transitionEndFunction, YES);
|
||||
|
||||
// Now set up the pop-in to normal size transition.
|
||||
// Because we are watching the -webkit-transform, it will occur now.
|
||||
[self setCSS3Property:@"Transform" value:@"scale(1)"];
|
||||
[self setCSS3Property:@"Transition" value:@"-webkit-transform 50ms linear"];
|
||||
};
|
||||
|
||||
_DOMElement.addEventListener("webkitTransitionEnd", transitionEndFunction, YES);
|
||||
},0);
|
||||
}, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setCSS3Property:@"Transition" value:@""];
|
||||
_DOMElement.style.opacity = 1;
|
||||
}
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_attachedWindowDidMove:) name:CPWindowDidMoveNotification object:self];
|
||||
|
||||
_shouldPerformAnimation = NO;
|
||||
_isClosed = NO;
|
||||
_isClosing = NO;
|
||||
}
|
||||
|
||||
/*!
|
||||
Close the windo with animation
|
||||
Animate window closing.
|
||||
*/
|
||||
- (void)close
|
||||
{
|
||||
// set a close flag to avoid infinite loop
|
||||
_isClosed = YES;
|
||||
// set a flag to avoid an infinite loop in resignMainWindow
|
||||
_isClosing = YES;
|
||||
|
||||
if (_animates && typeof(_DOMElement.style.WebkitTransform) != "undefined")
|
||||
if (_animates && _browserAnimates)
|
||||
{
|
||||
// Tell the element to fade out when the opacity changes
|
||||
[self setCSS3Property:@"Transition" value:@"opacity 250ms linear"];
|
||||
_DOMElement.style.opacity = 0;
|
||||
var transitionEndFunction = function(){
|
||||
[super close];
|
||||
|
||||
var transitionEndFunction = function()
|
||||
{
|
||||
_DOMElement.removeEventListener("webkitTransitionEnd", transitionEndFunction, YES);
|
||||
[self _close];
|
||||
};
|
||||
|
||||
_DOMElement.addEventListener("webkitTransitionEnd", transitionEndFunction, YES);
|
||||
}
|
||||
else
|
||||
[super close];
|
||||
{
|
||||
[self _close];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_close
|
||||
{
|
||||
[super close];
|
||||
[_targetView removeObserver:self forKeyPath:@"frame"];
|
||||
|
||||
_shouldPerformAnimation = _animates;
|
||||
_shouldPerformAnimation = YES;
|
||||
|
||||
if (_implementedDelegateMethods & _CPAttachedWindow_attachedWindowDidClose_)
|
||||
[_delegate attachedWindowDidClose:self];
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
CGContextSetStrokeColor(context, [self currentValueForThemeAttribute:@"divider-color"]);
|
||||
|
||||
CGContextMoveToPoint(context, _CGRectGetMinX(aRect) + 0.5, ROUND(_CGRectGetMinY(aRect)));
|
||||
CGContextAddLineToPoint(context, _CGRectGetMinX(aRect) + 0.5, ROUND(_CGRectGetMaxY(aRect)));
|
||||
CGContextAddLineToPoint(context, _CGRectGetMinX(aRect) + 0.5, ROUND(_CGRectGetMaxY(aRect)) - 1.0);
|
||||
|
||||
CGContextClosePath(context);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
@@ -390,7 +390,10 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
var textStyle = hasDOMTextElement ? _DOMTextElement.style : nil;
|
||||
|
||||
// Create or destroy the DOM Text Shadow element as necessary.
|
||||
var needsDOMTextShadowElement = hasDOMTextElement && !!_textShadowColor,
|
||||
// If _textShadowColor's alphaComponent is 0, don't bother drawing anything (issue #1412).
|
||||
// This improves performance as we get rid of an invisible element, and makes IE <9.0 capable
|
||||
// of correctly 'rendering' shadows with [CPColor clearColor].
|
||||
var needsDOMTextShadowElement = hasDOMTextElement && [_textShadowColor alphaComponent] > 0.0,
|
||||
hasDOMTextShadowElement = !!_DOMTextShadowElement;
|
||||
|
||||
if (needsDOMTextShadowElement !== hasDOMTextShadowElement)
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ var _CPToolTipHeight = 24.0,
|
||||
[_content setFrameOrigin:CPPointMake(0.0, 0.0)];
|
||||
[_content setFrameSize:textFrameSize];
|
||||
[_content setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_content setTextColor:[CPColor blackColor]];
|
||||
[_content setTextColor:[[[CPTheme defaultTheme] attributeWithName:@"color" forClass:_CPToolTipWindowView] value]];
|
||||
|
||||
[[self contentView] addSubview:_content];
|
||||
|
||||
|
||||
+1
-2
@@ -371,8 +371,7 @@ function pngcrushDirectory(directory) {
|
||||
var pngs = directoryPath.glob("**/*.png");
|
||||
|
||||
system.stderr.print("Running pngcrush on " + pngs.length + " pngs:");
|
||||
pngs.forEach(function(dst) {
|
||||
var dstPath = directoryPath.join(dst);
|
||||
pngs.forEach(function(dstPath) {
|
||||
var tmpPath = FILE.path(dstPath+".tmp");
|
||||
|
||||
var p = OS.popen(["pngcrush", "-rem", "alla", "-reduce", /*"-brute",*/ dstPath, tmpPath]);
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
function findCibClassDependencies(cibPath) {
|
||||
var cib = [[CPCib alloc] initWithContentsOfURL:cibPath];
|
||||
var cib = [[CPCib alloc] initWithContentsOfURL:cibPath],
|
||||
dependencies = {},
|
||||
CPClassFromStringOriginal = CPClassFromString;
|
||||
|
||||
var dependencies = {};
|
||||
|
||||
var CPClassFromStringOriginal = CPClassFromString;
|
||||
CPClassFromString = function(aClassName) {
|
||||
CPClassFromString = function(aClassName)
|
||||
{
|
||||
var result = CPClassFromStringOriginal(aClassName);
|
||||
|
||||
// print("CPClassFromString: " + Array.prototype.slice.call(arguments) + " => " + result);
|
||||
dependencies[aClassName] = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// make sure CPApp is init'd
|
||||
[CPApplication sharedApplication];
|
||||
@@ -29,6 +29,7 @@ function findCibClassDependencies(cibPath) {
|
||||
|
||||
return Object.keys(dependencies);
|
||||
}
|
||||
|
||||
// this is copied from CPCib's "instantiateCibWithExternalNameTable:"
|
||||
@implementation CPCib (Press)
|
||||
|
||||
|
||||
@@ -9,4 +9,4 @@ exports.fontinfo = function(name, size)
|
||||
return JSON.parse(p.stdout.read());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,15 +21,15 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
|
||||
_OBJJ.Executable.prototype.path = function() {
|
||||
var url = this.URL();
|
||||
return url ? url.absoluteURL().path() : null;
|
||||
}
|
||||
};
|
||||
_OBJJ.FileDependency.prototype.path = function() {
|
||||
var url = this.URL();
|
||||
return url ? url.path() : null;
|
||||
}
|
||||
};
|
||||
this.context.global.CFBundle.prototype.executablePath = function() {
|
||||
var url = this.executableURL();
|
||||
return url ? url.absoluteURL().path() : null;
|
||||
}
|
||||
};
|
||||
|
||||
this.require("cappuccino/objj-flatten-additions");
|
||||
|
||||
@@ -42,16 +42,16 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
|
||||
var path = new CFURL(aURL, this.rootURL).absoluteURL().path();
|
||||
requestedURLs[path] = true;
|
||||
return _lookupCachedRequest.apply(null, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.setIncludePaths = function(includePaths) {
|
||||
this.context.global.OBJJ_INCLUDE_PATHS = includePaths;
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.setEnvironments = function(environments) {
|
||||
this.context.global.CFBundle.environments = function() { return environments; };
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.makeAbsoluteURL = function(/*CFURL|String*/ aURL)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ ObjectiveJRuntimeAnalyzer.prototype.makeAbsoluteURL = function(/*CFURL|String*/
|
||||
return aURL;
|
||||
|
||||
return new this.context.global.CFURL(aURL, this.mainBundleURL);
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
|
||||
{
|
||||
@@ -103,7 +103,8 @@ ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
|
||||
|
||||
var _OBJJ = this.require("objective-j");
|
||||
var _fileExecuterForURL = _OBJJ.Executable.fileExecuterForURL;
|
||||
_OBJJ.Executable.fileExecuterForURL = function(/*CFURL*/ referenceURL) {
|
||||
_OBJJ.Executable.fileExecuterForURL = function(/*CFURL*/ referenceURL)
|
||||
{
|
||||
referenceURL = self.makeAbsoluteURL(referenceURL);
|
||||
var referencePath = referenceURL.absoluteURL().path()
|
||||
var fileExecutor = _fileExecuterForURL.apply(this, arguments);
|
||||
@@ -130,8 +131,8 @@ ObjectiveJRuntimeAnalyzer.prototype.initializeGlobalRecorder = function()
|
||||
|
||||
currentFile = evaluatingPaths.pop();
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.load = function(path)
|
||||
{
|
||||
@@ -142,13 +143,13 @@ ObjectiveJRuntimeAnalyzer.prototype.load = function(path)
|
||||
});
|
||||
})+")"
|
||||
)(path);
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.finishLoading = function(path)
|
||||
{
|
||||
// run the "event loop"
|
||||
this.require('browser/timeout').serviceTimeouts();
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.mapGlobalsToFiles = function()
|
||||
{
|
||||
@@ -164,7 +165,7 @@ ObjectiveJRuntimeAnalyzer.prototype.mapGlobalsToFiles = function()
|
||||
(globals[globalName] = globals[globalName] || []).push(fileName);
|
||||
}
|
||||
return globals;
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.mapFilesToGlobals = function()
|
||||
{
|
||||
@@ -177,7 +178,7 @@ ObjectiveJRuntimeAnalyzer.prototype.mapFilesToGlobals = function()
|
||||
files[fileName][globalName] = true;
|
||||
}
|
||||
return files;
|
||||
}
|
||||
};
|
||||
|
||||
// this method resolves library imports and merges their recorded globals with the canonical
|
||||
// file object for each file
|
||||
@@ -197,7 +198,7 @@ ObjectiveJRuntimeAnalyzer.prototype.mergeLibraryImports = function()
|
||||
delete this.files[relativePath];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// returns an executable for the import path, or null if none exists
|
||||
ObjectiveJRuntimeAnalyzer.prototype.executableForImport = function(path, isLocal)
|
||||
@@ -213,7 +214,7 @@ ObjectiveJRuntimeAnalyzer.prototype.executableForImport = function(path, isLocal
|
||||
});
|
||||
|
||||
return fileExecutable;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
param context includes
|
||||
@@ -313,7 +314,7 @@ ObjectiveJRuntimeAnalyzer.prototype.traverseDependencies = function(executable,
|
||||
context.referencedFiles[path] = referencedFiles;
|
||||
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.checkImported = function(context, path, importedFiles) {
|
||||
for (var importedFile in importedFiles)
|
||||
@@ -330,7 +331,7 @@ ObjectiveJRuntimeAnalyzer.prototype.checkImported = function(context, path, impo
|
||||
CPLog.error("Missing imported file: " + importedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.checkReferenced = function(context, path, referencedFiles) {
|
||||
for (var referencedFile in referencedFiles)
|
||||
@@ -347,16 +348,17 @@ ObjectiveJRuntimeAnalyzer.prototype.checkReferenced = function(context, path, re
|
||||
CPLog.error("Missing referenced file: " + referencedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ObjectiveJRuntimeAnalyzer.prototype.fileExecutables = function() {
|
||||
var _OBJJ = this.require("objective-j");
|
||||
return _OBJJ.FileExecutablesForPaths;
|
||||
}
|
||||
};
|
||||
|
||||
// returns a unique list of tokens for a piece of code.
|
||||
// ideally this should return identifiers only
|
||||
function uniqueTokens(code) {
|
||||
function uniqueTokens(code)
|
||||
{
|
||||
// FIXME: this breaks for indentifiers containing "$" since it's considered a distinct token by the lexer
|
||||
var lexer = new OBJJ.Lexer(code, null);
|
||||
|
||||
@@ -374,7 +376,8 @@ function uniqueTokens(code) {
|
||||
globalsToFiles (in): map from tokens to files which define those tokens
|
||||
referencedFiles (out): map of required files (to map of tokens defined in that file)
|
||||
*/
|
||||
function markFilesReferencedByTokens(tokens, globalsToFiles, referencedFiles) {
|
||||
function markFilesReferencedByTokens(tokens, globalsToFiles, referencedFiles)
|
||||
{
|
||||
tokens.forEach(function(token) {
|
||||
if (globalsToFiles.hasOwnProperty(token))
|
||||
{
|
||||
@@ -427,14 +430,14 @@ function addMockBrowserEnvironment(scope)
|
||||
if (!scope.Element)
|
||||
scope.Element = function() {
|
||||
this.style = {}
|
||||
}
|
||||
};
|
||||
|
||||
if (!scope.document)
|
||||
scope.document = {
|
||||
createElement : function() {
|
||||
return new scope.Element();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// does a shallow copy of an object. if onlyList is true, it sets each property to "true" instead of the actual value
|
||||
@@ -457,4 +460,4 @@ function diff(o)
|
||||
for (var i in o.before)
|
||||
if (o.deleted && !o.ignore[i] && typeof o.after[i] == "undefined")
|
||||
o.deleted[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,13 +536,46 @@ var concat = Array.prototype.concat,
|
||||
objj_msgSend([self objectAtIndex:index], aSelector);
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsUsingBlock:(Function)aFunction
|
||||
- (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];
|
||||
count = [self count],
|
||||
shouldStop = NO,
|
||||
shouldStopRef = AT_REF(shouldStop);
|
||||
|
||||
for (; index < count; ++index)
|
||||
aFunction([self objectAtIndex:index], 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
|
||||
|
||||
@@ -411,7 +411,7 @@
|
||||
var selectorCompare = function selectorCompare(object1, object2, selector)
|
||||
{
|
||||
return [object1 performSelector:selector withObject:object2];
|
||||
}
|
||||
};
|
||||
|
||||
// sort using sort descriptors
|
||||
var compareObjectsUsingDescriptors= function compareObjectsUsingDescriptors(lhs, rhs, descriptors)
|
||||
@@ -424,4 +424,4 @@ var compareObjectsUsingDescriptors= function compareObjectsUsingDescriptors(lhs,
|
||||
result = [descriptors[i++] compareObject:lhs withObject:rhs];
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
return CPOrderedDescending;
|
||||
else
|
||||
return CPOrderedAscending;
|
||||
}
|
||||
};
|
||||
|
||||
return [_rangeEntries indexOfObject:anIndex inSortedRange:nil options:0 usingComparator:sortFunction];
|
||||
}
|
||||
@@ -814,17 +814,17 @@ var isEqual = function isEqual(a, b)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
};
|
||||
|
||||
var makeRangeEntry = function makeRangeEntry(/*CPRange*/aRange, /*CPDictionary*/attributes)
|
||||
{
|
||||
return {range:aRange, attributes:[attributes copy]};
|
||||
}
|
||||
};
|
||||
|
||||
var copyRangeEntry = function copyRangeEntry(/*RangeEntry*/aRangeEntry)
|
||||
{
|
||||
return makeRangeEntry(CPCopyRange(aRangeEntry.range), [aRangeEntry.attributes copy]);
|
||||
}
|
||||
};
|
||||
|
||||
var splitRangeEntry = function splitRangeEntryAtIndex(/*RangeEntry*/aRangeEntry, /*unsigned*/anIndex)
|
||||
{
|
||||
@@ -837,4 +837,4 @@ var splitRangeEntry = function splitRangeEntryAtIndex(/*RangeEntry*/aRangeEntry,
|
||||
newRangeEntry.attributes = [newRangeEntry.attributes copy];
|
||||
|
||||
return [aRangeEntry, newRangeEntry];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -231,4 +231,42 @@ var CPDateTimeKey = @"CPDateTimeKey";
|
||||
|
||||
@end
|
||||
|
||||
// Based on 'Universal JavaScript Date.parse for ISO 8601' available at https://github.com/csnover/js-iso8601.
|
||||
var numericKeys = [1, 4, 5, 6, 7, 10, 11];
|
||||
|
||||
Date.parseISO8601 = function (date)
|
||||
{
|
||||
var timestamp, struct, minutesOffset = 0;
|
||||
|
||||
// First, check for native parsing.
|
||||
timestamp = Date.parse(date);
|
||||
|
||||
if (isNaN(timestamp) && (struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(date)))
|
||||
{
|
||||
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
|
||||
for (var i = 0, k; (k = numericKeys[i]); ++i)
|
||||
{
|
||||
struct[k] = +struct[k] || 0;
|
||||
}
|
||||
|
||||
// allow undefined days and months
|
||||
struct[2] = (+struct[2] || 1) - 1;
|
||||
struct[3] = +struct[3] || 1;
|
||||
|
||||
if (struct[8] !== 'Z' && struct[9] !== undefined)
|
||||
{
|
||||
minutesOffset = struct[10] * 60 + struct[11];
|
||||
|
||||
if (struct[9] === '+')
|
||||
{
|
||||
minutesOffset = 0 - minutesOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);
|
||||
}
|
||||
|
||||
return timestamp;
|
||||
};
|
||||
|
||||
Date.prototype.isa = CPDate;
|
||||
|
||||
+85
-16
@@ -483,6 +483,75 @@
|
||||
return description;
|
||||
}
|
||||
|
||||
- (void)enumerateIndexesUsingBlock:(Function /*(int idx, @ref BOOL stop) */)aFunction
|
||||
{
|
||||
[self enumerateIndexesWithOptions:CPEnumerationNormal usingBlock:aFunction];
|
||||
}
|
||||
|
||||
- (void)enumerateIndexesWithOptions:(CPEnumerationOptions)options usingBlock:(Function /*(int idx, @ref BOOL stop)*/)aFunction
|
||||
{
|
||||
if (!_count)
|
||||
return;
|
||||
[self enumerateIndexesInRange:CPMakeRange(0, _CPMaxRange(_ranges[_ranges.length - 1])) options:options usingBlock:aFunction];
|
||||
}
|
||||
|
||||
- (void)enumerateIndexesInRange:(CPRange)enumerationRange options:(CPEnumerationOptions)options usingBlock:(Function /*(int idx, @ref BOOL stop)*/)aFunction
|
||||
{
|
||||
if (!_count || CPEmptyRange(enumerationRange))
|
||||
return;
|
||||
|
||||
var shouldStop = NO,
|
||||
index,
|
||||
stop,
|
||||
increment;
|
||||
|
||||
if (options & CPEnumerationReverse)
|
||||
{
|
||||
index = _ranges.length - 1,
|
||||
stop = -1,
|
||||
increment = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = 0;
|
||||
stop = _ranges.length;
|
||||
increment = 1;
|
||||
}
|
||||
|
||||
for (; index !== stop; index += increment)
|
||||
{
|
||||
var range = _ranges[index];
|
||||
|
||||
var rangeIndex,
|
||||
rangeStop,
|
||||
rangeIncrement;
|
||||
|
||||
if (options & CPEnumerationReverse)
|
||||
{
|
||||
rangeIndex = _CPMaxRange(range) - 1;
|
||||
rangeStop = range.location - 1;
|
||||
rangeIncrement = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rangeIndex = range.location;
|
||||
rangeStop = _CPMaxRange(range);
|
||||
rangeIncrement = 1;
|
||||
}
|
||||
|
||||
for (; rangeIndex !== rangeStop; rangeIndex += rangeIncrement)
|
||||
{
|
||||
if (CPLocationInRange(rangeIndex, enumerationRange))
|
||||
{
|
||||
aFunction(rangeIndex, AT_REF(shouldStop));
|
||||
if (shouldStop)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPIndexSet(CPMutableIndexSet)
|
||||
@@ -537,7 +606,7 @@
|
||||
if (lhsRangeIndexCEIL === lhsRangeIndex && lhsRangeIndexCEIL < rangeCount)
|
||||
aRange = CPUnionRange(aRange, _ranges[lhsRangeIndexCEIL]);
|
||||
|
||||
var rhsRangeIndex = assumedPositionOfIndex(_ranges, CPMaxRange(aRange)),
|
||||
var rhsRangeIndex = assumedPositionOfIndex(_ranges, _CPMaxRange(aRange)),
|
||||
rhsRangeIndexFLOOR = FLOOR(rhsRangeIndex);
|
||||
|
||||
if (rhsRangeIndexFLOOR === rhsRangeIndex && rhsRangeIndexFLOOR >= 0)
|
||||
@@ -640,8 +709,8 @@
|
||||
// If these ranges don't start in the same place, we have to cull it.
|
||||
if (aRange.location !== existingRange.location)
|
||||
{
|
||||
var maxRange = CPMaxRange(aRange),
|
||||
existingMaxRange = CPMaxRange(existingRange);
|
||||
var maxRange = _CPMaxRange(aRange),
|
||||
existingMaxRange = _CPMaxRange(existingRange);
|
||||
|
||||
existingRange.length = aRange.location - existingRange.location;
|
||||
|
||||
@@ -661,14 +730,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
var rhsRangeIndex = assumedPositionOfIndex(_ranges, CPMaxRange(aRange) - 1),
|
||||
var rhsRangeIndex = assumedPositionOfIndex(_ranges, _CPMaxRange(aRange) - 1),
|
||||
rhsRangeIndexFLOOR = FLOOR(rhsRangeIndex);
|
||||
|
||||
if (rhsRangeIndex === rhsRangeIndexFLOOR && rhsRangeIndexFLOOR >= 0)
|
||||
{
|
||||
var maxRange = CPMaxRange(aRange),
|
||||
var maxRange = _CPMaxRange(aRange),
|
||||
existingRange = _ranges[rhsRangeIndexFLOOR],
|
||||
existingMaxRange = CPMaxRange(existingRange);
|
||||
existingMaxRange = _CPMaxRange(existingRange);
|
||||
|
||||
if (maxRange !== existingMaxRange)
|
||||
{
|
||||
@@ -714,7 +783,7 @@
|
||||
for (; i >= 0; --i)
|
||||
{
|
||||
var range = _ranges[i],
|
||||
maximum = CPMaxRange(range);
|
||||
maximum = _CPMaxRange(range);
|
||||
|
||||
if (anIndex >= maximum)
|
||||
break;
|
||||
@@ -734,7 +803,7 @@
|
||||
// If it's negative, it needs to be added properly later.
|
||||
else if (shifted.location < 0)
|
||||
{
|
||||
shifted.length = CPMaxRange(shifted);
|
||||
shifted.length = _CPMaxRange(shifted);
|
||||
shifted.location = 0;
|
||||
}
|
||||
|
||||
@@ -745,8 +814,8 @@
|
||||
// Shift the range, and normalize it if the result is negative.
|
||||
if ((range.location += aDelta) < 0)
|
||||
{
|
||||
_count -= range.length - CPMaxRange(range);
|
||||
range.length = CPMaxRange(range);
|
||||
_count -= range.length - _CPMaxRange(range);
|
||||
range.length = _CPMaxRange(range);
|
||||
range.location = 0;
|
||||
}
|
||||
}
|
||||
@@ -766,7 +835,7 @@
|
||||
|
||||
if ((j = i + 1) < count)
|
||||
{
|
||||
[_ranges removeObjectsInRange:CPMakeRange(j, count - j)];
|
||||
[_ranges removeObjectsInRange:_CPMakeRange(j, count - j)];
|
||||
|
||||
for (j = 0, count = shifts.length; j < count; ++j)
|
||||
[self addIndexesInRange:shifts[j]];
|
||||
@@ -882,7 +951,7 @@ var positionOfIndex = function(ranges, anIndex)
|
||||
if (anIndex < range.location)
|
||||
high = middle - 1;
|
||||
|
||||
else if (anIndex >= CPMaxRange(range))
|
||||
else if (anIndex >= _CPMaxRange(range))
|
||||
low = middle + 1;
|
||||
|
||||
else
|
||||
@@ -890,7 +959,7 @@ var positionOfIndex = function(ranges, anIndex)
|
||||
}
|
||||
|
||||
return CPNotFound;
|
||||
}
|
||||
};
|
||||
|
||||
var assumedPositionOfIndex = function(ranges, anIndex)
|
||||
{
|
||||
@@ -910,7 +979,7 @@ var assumedPositionOfIndex = function(ranges, anIndex)
|
||||
|
||||
if (position === positionFLOOR)
|
||||
{
|
||||
if (positionFLOOR - 1 >= 0 && anIndex < CPMaxRange(ranges[positionFLOOR - 1]))
|
||||
if (positionFLOOR - 1 >= 0 && anIndex < _CPMaxRange(ranges[positionFLOOR - 1]))
|
||||
high = middle - 1;
|
||||
|
||||
else if (positionFLOOR < count && anIndex >= ranges[positionFLOOR].location)
|
||||
@@ -926,7 +995,7 @@ var assumedPositionOfIndex = function(ranges, anIndex)
|
||||
if (anIndex < range.location)
|
||||
high = middle - 1;
|
||||
|
||||
else if (anIndex >= CPMaxRange(range))
|
||||
else if (anIndex >= _CPMaxRange(range))
|
||||
low = middle + 1;
|
||||
|
||||
else
|
||||
@@ -935,7 +1004,7 @@ var assumedPositionOfIndex = function(ranges, anIndex)
|
||||
}
|
||||
|
||||
return CPNotFound;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
new old method
|
||||
|
||||
@@ -90,7 +90,7 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
|
||||
{
|
||||
try
|
||||
{
|
||||
CPJSONPConnectionCallbacks["callback"+[self UID]] = function(data)
|
||||
CPJSONPConnectionCallbacks["callback" + [self UID]] = function(data)
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(connection:didReceiveData:)])
|
||||
[_delegate connection:self didReceiveData:data];
|
||||
@@ -109,11 +109,11 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
|
||||
if (_callbackParameter)
|
||||
{
|
||||
source += (source.indexOf('?') < 0) ? "?" : "&";
|
||||
source += _callbackParameter+"=CPJSONPConnectionCallbacks.callback"+[self UID];
|
||||
source += _callbackParameter + "=CPJSONPConnectionCallbacks.callback" + [self UID];
|
||||
}
|
||||
else if (source.indexOf(CPJSONPCallbackReplacementString) >= 0)
|
||||
{
|
||||
source = [source stringByReplacingOccurrencesOfString:CPJSONPCallbackReplacementString withString:"CPJSONPConnectionCallbacks.callback"+[self UID]];
|
||||
source = [source stringByReplacingOccurrencesOfString:CPJSONPCallbackReplacementString withString:"CPJSONPConnectionCallbacks.callback" + [self UID]];
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
@@ -214,7 +214,7 @@ var _changeKindForSetMutationKind = function(mutationKind)
|
||||
case CPKeyValueIntersectSetMutation: return CPKeyValueChangeRemoval;
|
||||
case CPKeyValueSetSetMutation: return CPKeyValueChangeReplacement;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
|
||||
DependentKeysKey = "$KVODEPENDENT",
|
||||
@@ -1139,7 +1139,7 @@ var _CPKVOInfoMake = function _CPKVOInfoMake(anObserver, theOptions, aContext, a
|
||||
context: aContext,
|
||||
forwarder: aForwarder
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@import "CPArray+KVO.j"
|
||||
@import "CPSet+KVO.j"
|
||||
|
||||
@@ -597,4 +597,4 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional)
|
||||
}
|
||||
|
||||
return [CPDictionary dictionaryWithObject:UID forKey:_CPKeyedArchiverUIDKey];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -367,7 +367,7 @@ var CPArrayClass = Ni
|
||||
|
||||
var objectClass = data.isa;
|
||||
if (objectClass === CPDataClass)
|
||||
return data.bytes;
|
||||
return data.bytes();
|
||||
|
||||
return nil;
|
||||
}
|
||||
@@ -541,4 +541,4 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
|
||||
object = [object JSObject];
|
||||
|
||||
return object;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,7 +85,6 @@ var CPNotificationDefaultCenter = nil;
|
||||
|
||||
if (aNotificationName == nil)
|
||||
registry = _unnamedRegistry;
|
||||
|
||||
else if (!(registry = [_namedRegistries objectForKey:aNotificationName]))
|
||||
{
|
||||
registry = [[_CPNotificationRegistry alloc] init];
|
||||
@@ -172,7 +171,7 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
{
|
||||
[self._unnamedRegistry postNotification:aNotification];
|
||||
[[self._namedRegistries objectForKey:[aNotification name]] postNotification:aNotification];
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Mapping of Notification Name to listening object/selector.
|
||||
@@ -181,7 +180,6 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
@implementation _CPNotificationRegistry : CPObject
|
||||
{
|
||||
CPDictionary _objectObservers;
|
||||
BOOL _observerRemovalCount;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@@ -190,7 +188,6 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
|
||||
if (self)
|
||||
{
|
||||
_observerRemovalCount = 0;
|
||||
_objectObservers = [CPDictionary dictionary];
|
||||
}
|
||||
|
||||
@@ -209,12 +206,12 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
|
||||
if (!observers)
|
||||
{
|
||||
observers = [];
|
||||
observers = [CPMutableSet set];
|
||||
[_objectObservers setObject:observers forKey:[anObject UID]];
|
||||
}
|
||||
|
||||
// Add this observer.
|
||||
observers.push(anObserver);
|
||||
[observers addObject:anObserver];
|
||||
}
|
||||
|
||||
- (void)removeObserver:(id)anObserver object:(id)anObject
|
||||
@@ -231,16 +228,14 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
while (key = [keys nextObject])
|
||||
{
|
||||
var observers = [_objectObservers objectForKey:key],
|
||||
count = observers ? observers.length : 0;
|
||||
observer = nil,
|
||||
observersEnumerator = [observers objectEnumerator];
|
||||
|
||||
while (count--)
|
||||
if ([observers[count] observer] == anObserver)
|
||||
{
|
||||
++_observerRemovalCount;
|
||||
observers.splice(count, 1);
|
||||
}
|
||||
while ((observer = [observersEnumerator nextObject]) !== nil)
|
||||
if ([observer observer] == anObserver)
|
||||
[observers removeObject:observer];
|
||||
|
||||
if (!observers || observers.length == 0)
|
||||
if (![observers count])
|
||||
removedKeys.push(key);
|
||||
}
|
||||
}
|
||||
@@ -248,16 +243,14 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
{
|
||||
var key = [anObject UID],
|
||||
observers = [_objectObservers objectForKey:key],
|
||||
count = observers ? observers.length : 0;
|
||||
observer = nil,
|
||||
observersEnumerator = [observers objectEnumerator];
|
||||
|
||||
while (count--)
|
||||
if ([observers[count] observer] == anObserver)
|
||||
{
|
||||
++_observerRemovalCount;
|
||||
observers.splice(count, 1)
|
||||
}
|
||||
while ((observer = [observersEnumerator nextObject]) !== nil)
|
||||
if ([observer observer] == anObserver)
|
||||
[observers removeObject:observer];
|
||||
|
||||
if (!observers || observers.length == 0)
|
||||
if (![observers count])
|
||||
removedKeys.push(key);
|
||||
}
|
||||
|
||||
@@ -273,47 +266,37 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */
|
||||
// during the posting of this notification, nor observers that get added. The
|
||||
// best way to do this is to make a copy of the current observers (this avoids
|
||||
// new observers from being notified) and double checking every observer against
|
||||
// the current array (this avoids removed observers from receiving notifications).
|
||||
// However, this is a very expensive operation (O(N) => O(N^2)), so to avoid it,
|
||||
// we keep track of whether observers are added or removed, and only do our
|
||||
// rigorous testing in those cases.
|
||||
var observerRemovalCount = _observerRemovalCount,
|
||||
object = [aNotification object],
|
||||
observers = nil;
|
||||
// the current set (this avoids removed observers from receiving notifications).
|
||||
var object = [aNotification object],
|
||||
currentObservers = nil;
|
||||
|
||||
if (object != nil && (observers = [[_objectObservers objectForKey:[object UID]] copy]))
|
||||
if (object != nil && (currentObservers = [_objectObservers objectForKey:[object UID]]))
|
||||
{
|
||||
var currentObservers = observers,
|
||||
count = observers.length;
|
||||
var observers = [currentObservers copy],
|
||||
observer = nil,
|
||||
observersEnumerator = [observers objectEnumerator];
|
||||
|
||||
while (count--)
|
||||
while ((observer = [observersEnumerator nextObject]) !== nil)
|
||||
{
|
||||
var observer = observers[count];
|
||||
|
||||
// if there wasn't removal of an observer during this posting, or there
|
||||
// was but we are still in the observer list...
|
||||
if ((observerRemovalCount === _observerRemovalCount) || [currentObservers indexOfObjectIdenticalTo:observer] !== CPNotFound)
|
||||
// CPSet containsObject is N(1) so this is a fast check.
|
||||
if ([currentObservers containsObject:observer])
|
||||
[observer postNotification:aNotification];
|
||||
}
|
||||
}
|
||||
|
||||
// Now do the same for the nil object observers...
|
||||
observers = [[_objectObservers objectForKey:[[CPNull null] UID]] copy];
|
||||
currentObservers = [_objectObservers objectForKey:[[CPNull null] UID]];
|
||||
|
||||
if (!observers)
|
||||
if (!currentObservers)
|
||||
return;
|
||||
|
||||
var observerRemovalCount = _observerRemovalCount,
|
||||
count = observers.length,
|
||||
currentObservers = observers;
|
||||
var observers = [currentObservers copy],
|
||||
observersEnumerator = [observers objectEnumerator];
|
||||
|
||||
while (count--)
|
||||
while ((observer = [observersEnumerator nextObject]) !== nil)
|
||||
{
|
||||
var observer = observers[count];
|
||||
|
||||
// if there wasn't removal of an observer during this posting, or there
|
||||
// was but we are still in the observer list...
|
||||
if ((observerRemovalCount === _observerRemovalCount) || [currentObservers indexOfObjectIdenticalTo:observer] !== CPNotFound)
|
||||
// CPSet containsObject is N(1) so this is a fast check.
|
||||
if ([currentObservers containsObject:observer])
|
||||
[observer postNotification:aNotification];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ CPNumberFormatterRoundHalfUp = CPRoundPlain;
|
||||
- (CPString)stringFromNumber:(CPNumber)number
|
||||
{
|
||||
// TODO Add locale support.
|
||||
switch(_numberStyle)
|
||||
switch (_numberStyle)
|
||||
{
|
||||
case CPNumberFormatterDecimalStyle:
|
||||
UPDATE_NUMBER_HANDLER_IF_NECESSARY();
|
||||
@@ -96,7 +96,7 @@ CPNumberFormatterRoundHalfUp = CPRoundPlain;
|
||||
// TODO This is just a temporary solution. Should be generalised.
|
||||
// Add in thousands separators.
|
||||
if (perMillSymbol)
|
||||
while(commaPosition < [preFraction length])
|
||||
while (commaPosition < [preFraction length])
|
||||
{
|
||||
preFraction = [preFraction stringByReplacingCharactersInRange:CPMakeRange(commaPosition, 0) withString:perMillSymbol];
|
||||
commaPosition += 4;
|
||||
|
||||
@@ -329,6 +329,18 @@ CPLog(@"Got some class: %@", inst);
|
||||
return objj_msgSend(self, aSelector, anObject, anotherObject);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sends the specified message to the reciever, with any number of arguments.
|
||||
@param aSelector the message to send
|
||||
@param anObject... comma seperated objects to pass to the selector
|
||||
@return the return value of the message
|
||||
*/
|
||||
- (id)performSelector:(SEL)aSelector withObjects:(id)anObject, ...
|
||||
{
|
||||
var params = [self, aSelector].concat(Array.prototype.slice.apply(arguments, [3]));
|
||||
return objj_msgSend.apply(this, params);
|
||||
}
|
||||
|
||||
- (id)forwardingTargetForSelector:(SEL)aSelector
|
||||
{
|
||||
return nil;
|
||||
|
||||
@@ -318,7 +318,6 @@ var CPComparisonPredicateModifier,
|
||||
return _right;
|
||||
}
|
||||
|
||||
|
||||
- (CPString)predicateFormat
|
||||
{
|
||||
var modifier;
|
||||
@@ -398,6 +397,17 @@ var CPComparisonPredicateModifier,
|
||||
return [CPComparisonPredicate predicateWithLeftExpression:left rightExpression:right customSelector:_customSelector];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
if (self === anObject)
|
||||
return YES;
|
||||
|
||||
if (anObject.isa !== self.isa || _modifier !== [anObject comparisonPredicateModifier] || _type !== [anObject predicateOperatorType] || _options !== [anObject options] || _customSelector !== [anObject customSelector] || ![_left isEqual:[anObject leftExpression]] || ![_right isEqual:[anObject rightExpression]])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_evaluateValue:lhs rightValue:rhs
|
||||
{
|
||||
var leftIsNil = (lhs == nil || [lhs isEqual:[CPNull null]]),
|
||||
@@ -577,4 +587,4 @@ String.prototype.escapeForRegExp = function()
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -154,7 +154,7 @@ var CPCompoundPredicateType;
|
||||
i = 0;
|
||||
|
||||
if (count == 0)
|
||||
return @"TRUPREDICATE";
|
||||
return @"TRUEPREDICATE";
|
||||
|
||||
for (; i < count; i++)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ var CPCompoundPredicateType;
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case CPNotPredicateType: result += "NOT %s" + [args objectAtIndex:0];
|
||||
case CPNotPredicateType: result += "NOT " + [args objectAtIndex:0];
|
||||
break;
|
||||
|
||||
case CPAndPredicateType: result += [args objectAtIndex:0];
|
||||
@@ -228,6 +228,17 @@ var CPCompoundPredicateType;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
if (self === anObject)
|
||||
return YES;
|
||||
|
||||
if (anObject.isa !== self.isa || _type !== [anObject compoundPredicateType] || ![_predicates isEqualToArray:[anObject subpredicates]])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPCompoundPredicate (CPCoding)
|
||||
|
||||
@@ -105,7 +105,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForConstantValue:(id)value
|
||||
{
|
||||
return [[CPExpression_constant alloc] initWithValue:value];
|
||||
return [[_CPConstantValueExpression alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -114,7 +114,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForEvaluatedObject
|
||||
{
|
||||
return [CPExpression_self evaluatedObject];
|
||||
return [_CPSelfExpression evaluatedObject];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -124,7 +124,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForVariable:(CPString)string
|
||||
{
|
||||
return [[CPExpression_variable alloc] initWithVariable:string];
|
||||
return [[_CPVariableExpression alloc] initWithVariable:string];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -134,7 +134,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForKeyPath:(CPString)keyPath
|
||||
{
|
||||
return [[CPExpression_keypath alloc] initWithKeyPath:keyPath];
|
||||
return [[_CPKeyPathExpression alloc] initWithKeyPath:keyPath];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -144,7 +144,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForAggregate:(CPArray)collection
|
||||
{
|
||||
return [[CPExpression_aggregate alloc] initWithAggregate:collection];
|
||||
return [[_CPAggregateExpression alloc] initWithAggregate:collection];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -155,7 +155,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForUnionSet:(CPExpression)left with:(CPExpression)right
|
||||
{
|
||||
return [[CPExpression_set alloc] initWithType:CPUnionSetExpressionType left:left right:right];
|
||||
return [[_CPSetExpression alloc] initWithType:CPUnionSetExpressionType left:left right:right];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -166,7 +166,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForIntersectSet:(CPExpression)left with:(CPExpression)right
|
||||
{
|
||||
return [[CPExpression_set alloc] initWithType:CPIntersectSetExpressionType left:left right:right];
|
||||
return [[_CPSetExpression alloc] initWithType:CPIntersectSetExpressionType left:left right:right];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -177,7 +177,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForMinusSet:(CPExpression)left with:(CPExpression)right
|
||||
{
|
||||
return [[CPExpression_set alloc] initWithType:CPMinusSetExpressionType left:left right:right];
|
||||
return [[_CPSetExpression alloc] initWithType:CPMinusSetExpressionType left:left right:right];
|
||||
}
|
||||
|
||||
// Creating an Expression for a Function
|
||||
@@ -230,7 +230,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForFunction:(CPString)function_name arguments:(CPArray)parameters
|
||||
{
|
||||
return [[CPExpression_function alloc] initWithSelector:CPSelectorFromString(function_name) arguments:parameters];
|
||||
return [[_CPFunctionExpression alloc] initWithSelector:CPSelectorFromString(function_name) arguments:parameters];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -244,7 +244,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForFunction:(CPExpression)target selectorName:(CPString)selectorName arguments:(CPArray)parameters
|
||||
{
|
||||
return [[CPExpression_function alloc] initWithTarget:target selector:CPSelectorFromString(selectorName) arguments:parameters];
|
||||
return [[_CPFunctionExpression alloc] initWithTarget:target selector:CPSelectorFromString(selectorName) arguments:parameters];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -256,7 +256,7 @@ CPMinusSetExpressionType = 9;
|
||||
*/
|
||||
+ (CPExpression)expressionForSubquery:(CPExpression)expression usingIteratorVariable:(CPString)variable predicate:(CPPredicate)predicate
|
||||
{
|
||||
return [[CPExpression_subquery alloc] initWithExpression:expression usingIteratorVariable:variable predicate:predicate];
|
||||
return [[_CPSubqueryExpression alloc] initWithExpression:expression usingIteratorVariable:variable predicate:predicate];
|
||||
}
|
||||
|
||||
// Getting Information About an Expression
|
||||
@@ -387,11 +387,11 @@ CPMinusSetExpressionType = 9;
|
||||
|
||||
@end
|
||||
|
||||
@import "CPExpression_constant.j"
|
||||
@import "CPExpression_self.j"
|
||||
@import "CPExpression_variable.j"
|
||||
@import "CPExpression_keypath.j"
|
||||
@import "CPExpression_function.j"
|
||||
@import "CPExpression_aggregate.j"
|
||||
@import "CPExpression_set.j"
|
||||
@import "CPExpression_subquery.j"
|
||||
@import "_CPConstantValueExpression.j"
|
||||
@import "_CPSelfExpression.j"
|
||||
@import "_CPVariableExpression.j"
|
||||
@import "_CPKeyPathExpression.j"
|
||||
@import "_CPFunctionExpression.j"
|
||||
@import "_CPAggregateExpression.j"
|
||||
@import "_CPSetExpression.j"
|
||||
@import "_CPSubqueryExpression.j"
|
||||
|
||||
@@ -176,6 +176,17 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
if (self === anObject)
|
||||
return YES;
|
||||
|
||||
if (self.isa !== anObject.isa || _value !== [anObject evaluateObject:nil])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)evaluateObject:(id)object
|
||||
{
|
||||
return _value;
|
||||
@@ -199,7 +210,7 @@
|
||||
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var object = self[i];
|
||||
var object = [self objectAtIndex:i];
|
||||
if ([predicate evaluateWithObject:object])
|
||||
result.push(object);
|
||||
}
|
||||
@@ -213,7 +224,7 @@
|
||||
|
||||
while (count--)
|
||||
{
|
||||
if (![predicate evaluateWithObject:self[count]])
|
||||
if (![predicate evaluateWithObject:[self objectAtIndex:count]])
|
||||
splice(count, 1);
|
||||
}
|
||||
}
|
||||
@@ -737,7 +748,7 @@ function(newValue)\
|
||||
if (![self scanString:@")" intoString:NULL])
|
||||
CPRaiseParseError(self, @"expression");
|
||||
|
||||
return [[CPExpression_subquery alloc] initWithExpression:collection usingIteratorExpression:variableExpression predicate:subpredicate];
|
||||
return [[_CPSubqueryExpression alloc] initWithExpression:collection usingIteratorExpression:variableExpression predicate:subpredicate];
|
||||
}
|
||||
|
||||
if ([self scanString:@"FUNCTION" intoString:NULL])
|
||||
@@ -777,7 +788,7 @@ function(newValue)\
|
||||
expressionType = [right expressionType];
|
||||
|
||||
if (expressionType == CPKeyPathExpressionType)
|
||||
left = [[CPExpression_keypath alloc] initWithOperand:left andKeyPath:[right keyPath]];
|
||||
left = [[_CPKeyPathExpression alloc] initWithOperand:left andKeyPath:[right keyPath]];
|
||||
else if (expressionType == CPVariableExpressionType)
|
||||
left = [CPExpression expressionForFunction:left selectorName:@"valueForKey:" arguments:[right]];
|
||||
else
|
||||
@@ -957,7 +968,7 @@ function(newValue)\
|
||||
var CPRaiseParseError = function CPRaiseParseError(aScanner, target)
|
||||
{
|
||||
[CPException raise:CPInvalidArgumentException reason:@"unable to parse " + target + " at index " + [aScanner scanLocation]];
|
||||
}
|
||||
};
|
||||
|
||||
@import "CPCompoundPredicate.j"
|
||||
@import "CPComparisonPredicate.j"
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_aggregate.j
|
||||
* _CPAggregateExpression.j
|
||||
*
|
||||
* Created by cacaodev.
|
||||
* Copyright 2010.
|
||||
@@ -23,7 +23,7 @@
|
||||
@import "CPExpression.j"
|
||||
@import "CPString.j"
|
||||
|
||||
@implementation CPExpression_aggregate : CPExpression
|
||||
@implementation _CPAggregateExpression : CPExpression
|
||||
{
|
||||
CPArray _aggregate;
|
||||
}
|
||||
@@ -39,10 +39,10 @@
|
||||
|
||||
- (BOOL)isEqual:(id)object
|
||||
{
|
||||
if (self == object)
|
||||
if (self === object)
|
||||
return YES;
|
||||
|
||||
if (object.isa != self.isa || [object expressionType] != [self expressionType] || ![[object collection] isEqual:[self collection]])
|
||||
if (object.isa !== self.isa || ![[object collection] isEqual:_aggregate])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
var CPCollectionKey = @"CPCollection";
|
||||
|
||||
@implementation CPExpression_aggregate (CPCoding)
|
||||
@implementation _CPAggregateExpression (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_constant.j
|
||||
* _CPConstantValueExpression.j
|
||||
*
|
||||
* Portions based on NSExpression_constant.m in Cocotron (http://www.cocotron.org/)
|
||||
* Copyright (c) 2006-2007 Christopher J. W. Lloyd
|
||||
@@ -25,7 +25,7 @@
|
||||
@import "CPDictionary.j"
|
||||
@import "CPExpression.j"
|
||||
|
||||
@implementation CPExpression_constant : CPExpression
|
||||
@implementation _CPConstantValueExpression : CPExpression
|
||||
{
|
||||
id _value;
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
if (self === object)
|
||||
return YES;
|
||||
|
||||
if (object.isa != self.isa || [object expressionType] != [self expressionType] || ![[object constantValue] isEqual:[self constantValue]])
|
||||
if (object.isa !== self.isa || ![[object constantValue] isEqual:_value])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
var CPConstantValueKey = @"CPConstantValue";
|
||||
|
||||
@implementation CPExpression_constant (CPCoding)
|
||||
@implementation _CPConstantValueExpression (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_function.j
|
||||
* _CPFunctionExpression.j
|
||||
*
|
||||
* Created by cacaodev.
|
||||
* Copyright 2010.
|
||||
@@ -26,7 +26,7 @@
|
||||
@import "CPExpression.j"
|
||||
@import "CPString.j"
|
||||
|
||||
@implementation CPExpression_function : CPExpression
|
||||
@implementation _CPFunctionExpression : CPExpression
|
||||
{
|
||||
CPExpression _operand;
|
||||
SEL _selector;
|
||||
@@ -69,10 +69,10 @@
|
||||
|
||||
- (BOOL)isEqual:(id)object
|
||||
{
|
||||
if (self == object)
|
||||
if (self === object)
|
||||
return YES;
|
||||
|
||||
if (object.isa != self.isa || [object expressionType] != [self expressionType] || ![[object _function] isEqualToString:[self _function]] || ![[object operand] isEqual:[self operand]] || ![[object arguments] isEqualToArray:[self arguments]])
|
||||
if (object.isa !== self.isa || ![[object _function] isEqual:_selector] || ![[object operand] isEqual:_operand] || ![[object arguments] isEqualToArray:_arguments])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
@@ -159,7 +159,7 @@ var CPSelectorNameKey = @"CPSelectorName",
|
||||
CPOperandKey = @"CPOperand",
|
||||
CPExpressionTypeKey = @"CPExpressionType";
|
||||
|
||||
@implementation CPExpression_function (CPCoding)
|
||||
@implementation _CPFunctionExpression (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
+8
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_keypath.j
|
||||
* _CPKeyPathExpression.j
|
||||
*
|
||||
* Portions based on NSExpression_keypath.m in Cocotron (http://www.cocotron.org/)
|
||||
* Copyright (c) 2006-2007 Christopher J. W. Lloyd
|
||||
@@ -23,11 +23,11 @@
|
||||
*/
|
||||
|
||||
@import "CPExpression.j"
|
||||
@import "CPExpression_function.j"
|
||||
@import "_CPFunctionExpression.j"
|
||||
@import "CPKeyValueCoding.j"
|
||||
@import "CPString.j"
|
||||
|
||||
@implementation CPExpression_keypath : CPExpression_function
|
||||
@implementation _CPKeyPathExpression : _CPFunctionExpression
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,7 +50,10 @@
|
||||
if (object === self)
|
||||
return YES;
|
||||
|
||||
return ([object keyPath] == [self keyPath]); // If it appears that parsing generates nested keypaths with different targets and same keyPath, comparing -keyPath won't work.
|
||||
if (object.isa !== self.isa || ![[object keyPath] isEqualToString:[self keyPath]])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPExpression)pathExpression
|
||||
@@ -75,7 +78,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPExpression_constant (KeyPath)
|
||||
@implementation _CPConstantValueExpression (KeyPath)
|
||||
|
||||
- (CPString)keyPath
|
||||
{
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_self.j
|
||||
* _CPSelfExpression.j
|
||||
*
|
||||
* Created by cacaodev.
|
||||
* Copyright 2010.
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
var evaluatedObject = nil;
|
||||
|
||||
@implementation CPExpression_self : CPExpression
|
||||
@implementation _CPSelfExpression : CPExpression
|
||||
{
|
||||
}
|
||||
|
||||
+ (id)evaluatedObject
|
||||
{
|
||||
if (evaluatedObject == nil)
|
||||
evaluatedObject = [CPExpression_self new];
|
||||
evaluatedObject = [_CPSelfExpression new];
|
||||
|
||||
return evaluatedObject;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ var evaluatedObject = nil;
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
return [CPExpression_self evaluatedObject];
|
||||
return [_CPSelfExpression evaluatedObject];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)coder
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_set.j
|
||||
* _CPSetExpression.j
|
||||
*
|
||||
* Created by cacaodev.
|
||||
* Copyright 2010.
|
||||
@@ -23,7 +23,7 @@
|
||||
@import "CPExpression.j"
|
||||
@import "CPSet.j"
|
||||
|
||||
@implementation CPExpression_set : CPExpression
|
||||
@implementation _CPSetExpression : CPExpression
|
||||
{
|
||||
CPExpression _left;
|
||||
CPExpression _right;
|
||||
@@ -44,10 +44,10 @@
|
||||
|
||||
- (BOOL)isEqual:(id)object
|
||||
{
|
||||
if (self == object)
|
||||
if (self === object)
|
||||
return YES;
|
||||
|
||||
if (object.isa != self.isa || [object expressionType] != [self expressionType] || ![[object leftExpression] isEqual:[self leftExpression]] || ![[object rightExpression] isEqual:[self rightExpression]])
|
||||
if (object.isa !== self.isa || ![[object leftExpression] isEqual:_left] || ![[object rightExpression] isEqual:_right])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
@@ -121,7 +121,7 @@ var CPLeftExpressionKey = @"CPLeftExpression",
|
||||
CPRightExpressionKey = @"CPRightExpression",
|
||||
CPExpressionType = @"CPExpressionType";
|
||||
|
||||
@implementation CPExpression_set (CPCoding)
|
||||
@implementation _CPSetExpression (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_subquery.j
|
||||
* _CPSubqueryExpression.j
|
||||
*
|
||||
* Created by cacaodev.
|
||||
* Copyright 2010.
|
||||
@@ -24,7 +24,7 @@
|
||||
@import "CPExpression.j"
|
||||
@import "CPPredicate.j"
|
||||
|
||||
@implementation CPExpression_subquery : CPExpression
|
||||
@implementation _CPSubqueryExpression : CPExpression
|
||||
{
|
||||
CPExpression _collection;
|
||||
CPExpression _variableExpression;
|
||||
@@ -73,7 +73,7 @@
|
||||
if (self === object)
|
||||
return YES;
|
||||
|
||||
if (![_collection isEqual:[object collection]] || ![_subpredicate isEqual:[object predicate]])
|
||||
if (object.isa !== self.isa || ![_collection isEqual:[object collection]] || ![_variableExpression isEqual:[object variableExpression]] || ![_subpredicate isEqual:[object predicate]])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
return [[CPExpression_subquery alloc] initWithExpression:[_collection copy] usingIteratorExpression:[_variableExpression copy] predicate:[_subpredicate copy]];
|
||||
return [[_CPSubqueryExpression alloc] initWithExpression:[_collection copy] usingIteratorExpression:[_variableExpression copy] predicate:[_subpredicate copy]];
|
||||
}
|
||||
|
||||
- (CPPredicate)predicate
|
||||
@@ -113,13 +113,14 @@
|
||||
{
|
||||
return _variableExpression;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPExpressionKey = @"CPExpression",
|
||||
CPSubpredicateKey = @"CPSubpredicate",
|
||||
CPVariableKey = @"CPVariable";
|
||||
|
||||
@implementation CPExpression_subquery (CPCoding)
|
||||
@implementation _CPSubqueryExpression (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CPExpression_variable.j
|
||||
* _CPVariableExpression.j
|
||||
*
|
||||
* Portions based on NSExpression_variable.m in Cocotron (http://www.cocotron.org/)
|
||||
* Copyright (c) 2006-2007 Christopher J. W. Lloyd
|
||||
@@ -27,7 +27,7 @@
|
||||
@import "CPExpression.j"
|
||||
@import "CPString.j"
|
||||
|
||||
@implementation CPExpression_variable : CPExpression
|
||||
@implementation _CPVariableExpression : CPExpression
|
||||
{
|
||||
CPString _variable;
|
||||
}
|
||||
@@ -45,10 +45,10 @@
|
||||
|
||||
- (BOOL)isEqual:(id)object
|
||||
{
|
||||
if (self == object)
|
||||
if (self === object)
|
||||
return YES;
|
||||
|
||||
if (object.isa != self.isa || [object expressionType] != [self expressionType] || ![[object variable] isEqualToString:[self variable]])
|
||||
if (object.isa !== self.isa || ![[object variable] isEqual:_variable])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
@@ -87,7 +87,7 @@
|
||||
|
||||
var CPVariableKey = @"CPVariable";
|
||||
|
||||
@implementation CPExpression_variable (CPCoding)
|
||||
@implementation _CPVariableExpression (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
@@ -101,4 +101,3 @@ var CPVariableKey = @"CPVariable";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
|
||||
@import "CPSet.j"
|
||||
|
||||
|
||||
@implementation CPMutableSet : CPSet
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns an initialized set with a given initial capacity.
|
||||
@param aCapacity, only present for compatability
|
||||
*/
|
||||
@@ -21,7 +20,7 @@
|
||||
return [self init];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns a set with a given initial capacity.
|
||||
@param aCapacity, only present for compatability
|
||||
*/
|
||||
@@ -30,7 +29,10 @@
|
||||
return [[self alloc] initWithCapacity:aCapacity];
|
||||
}
|
||||
|
||||
- (void)filterUsingPredicate:(CPPredicate)aPredicate
|
||||
/*!
|
||||
Returns a set filtered using a given predicate.
|
||||
@prarm aPredicate a CPPredicate object used to filter the objects in the set.
|
||||
*/- (void)filterUsingPredicate:(CPPredicate)aPredicate
|
||||
{
|
||||
var object,
|
||||
objectEnumerator = [self objectEnumerator];
|
||||
@@ -40,11 +42,19 @@
|
||||
[self removeObject:object];
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes an object from the set.
|
||||
@param anObject the object to remove from the set. If the object is not in the set, the method will not modify the set.
|
||||
*/
|
||||
- (void)removeObject:(id)anObject
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes an array of objects from the set.
|
||||
@param anArray an array of object to remove from the set.
|
||||
*/
|
||||
- (void)removeObjectsInArray:(CPArray)anArray
|
||||
{
|
||||
var index = 0,
|
||||
@@ -54,6 +64,9 @@
|
||||
[self removeObject:[anArray objectAtIndex:index]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes all the objects from the set.
|
||||
*/
|
||||
- (void)removeAllObjects
|
||||
{
|
||||
var object,
|
||||
@@ -63,7 +76,7 @@
|
||||
[self removeObject:object];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Adds to the receiver each object contained in a given array that is not already a member.
|
||||
@param array An array of objects to add to the receiver.
|
||||
*/
|
||||
@@ -75,7 +88,7 @@
|
||||
[self addObject:objects[count]];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Adds to the receiver each object contained in another given set
|
||||
@param set The set of objects to add to the receiver.
|
||||
*/
|
||||
@@ -88,7 +101,7 @@
|
||||
[self addObject:object];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Removes from the receiver each object contained in another given set that is present in the receiver.
|
||||
@param set The set of objects to remove from the receiver.
|
||||
*/
|
||||
@@ -101,7 +114,7 @@
|
||||
[self removeObject:object];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Removes from the receiver each object that isn't a member of another given set.
|
||||
@param set The set with which to perform the intersection.
|
||||
*/
|
||||
@@ -121,7 +134,7 @@
|
||||
[self removeObject:objectsToRemove[count]];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Empties the receiver, then adds to the receiver each object contained in another given set.
|
||||
@param set The set whose members replace the receiver's content.
|
||||
*/
|
||||
|
||||
+76
-24
@@ -29,6 +29,13 @@
|
||||
@import "CPNumber.j"
|
||||
@import "CPObject.j"
|
||||
|
||||
/*!
|
||||
@class CPMutableSet
|
||||
@ingroup Foundation
|
||||
|
||||
CPSet is a data structure for storing an an unordered collection of unique objects.
|
||||
Sets have O(1) insertion/lookup/deletion time complexity.
|
||||
*/
|
||||
|
||||
@implementation CPSet : CPObject
|
||||
{
|
||||
@@ -42,7 +49,7 @@
|
||||
return [super alloc];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns an empty set.
|
||||
*/
|
||||
+ (id)set
|
||||
@@ -50,7 +57,7 @@
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns a set containing a uniqued collection of those objects contained in a given array.
|
||||
@param anArray array containing the objects to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
||||
*/
|
||||
@@ -59,7 +66,7 @@
|
||||
return [[self alloc] initWithArray:anArray];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns a set that contains a single given object.
|
||||
@param anObject The object to add to the new set.
|
||||
*/
|
||||
@@ -68,7 +75,7 @@
|
||||
return [[self alloc] initWithObjects:anObject];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns a set containing a specified number of objects from a given array of objects.
|
||||
@param objects A array of objects to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
||||
@param count The number of objects from objects to add to the new set.
|
||||
@@ -78,7 +85,7 @@
|
||||
return [[self alloc] initWithObjects:objects count:count];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns a set containing the objects in a given argument list.
|
||||
@param anObject The first object to add to the new set.
|
||||
@param ... A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once objects, it is added only once to the returned set.
|
||||
@@ -93,7 +100,7 @@
|
||||
return objj_msgSend.apply(this, argumentsArray);
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Creates and returns a set containing the objects from another set.
|
||||
@param aSet A set containing the objects to add to the new set.
|
||||
*/
|
||||
@@ -102,30 +109,42 @@
|
||||
return [[self alloc] initWithSet:set];
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a set by adding anObject.
|
||||
@param anObject to add to the new set.
|
||||
*/
|
||||
- (id)setByAddingObject:(id)anObject
|
||||
{
|
||||
return [[self class] setWithArray:[[self allObjects] arrayByAddingObject:anObject]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a set by adding the objects from another set.
|
||||
@param aSet to add objects to add to the new set.
|
||||
*/
|
||||
- (id)setByAddingObjectsFromSet:(CPSet)aSet
|
||||
{
|
||||
return [self setByAddingObjectsFromArray:[aSet allObjects]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a set by adding the objects from an array.
|
||||
@param anArray with objects to add to a new set.
|
||||
*/
|
||||
- (id)setByAddingObjectsFromArray:(CPArray)anArray
|
||||
{
|
||||
return [[self class] setWithArray:[[self allObjects] arrayByAddingObjectsFromArray:anArray]];
|
||||
}
|
||||
|
||||
/*
|
||||
Basic initializer, returns an empty set
|
||||
/*!
|
||||
Basic initializer, returns an empty set.
|
||||
*/
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithObjects:nil count:0];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Initializes a newly allocated set with the objects that are contained in a given array.
|
||||
@param array An array of objects to add to the new set. If the same object appears more than once in array, it is represented only once in the returned set.
|
||||
*/
|
||||
@@ -134,7 +153,7 @@
|
||||
return [self initWithObjects:anArray count:[anArray count]];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Initializes a newly allocated set with members taken from the specified list of objects.
|
||||
@param anObject The first object to add to the new set.
|
||||
@param ... A comma-separated list of objects, ending with nil, to add to the new set. If the same object appears more than once in the list, it is represented only once in the returned set.
|
||||
@@ -151,6 +170,11 @@
|
||||
return [self initWithObjects:Array.prototype.slice.call(arguments, 2, index) count:index - 2];
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates and returns a set containing the objects from an array.
|
||||
@param anArray An array containing the objects to add to the new set.
|
||||
@param aCount the number of objects in anArray.
|
||||
*/
|
||||
- (id)initWithObjects:(CPArray)objects count:(CPUInteger)aCount
|
||||
{
|
||||
if (self === _CPSharedPlaceholderSet)
|
||||
@@ -159,16 +183,19 @@
|
||||
return [super init];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Initializes a newly allocated set and adds to it objects from another given set.
|
||||
@param aSet a set containing objects to add to the new set.
|
||||
*/
|
||||
- (id)initWithSet:(CPSet)aSet
|
||||
{
|
||||
return [self initWithArray:[aSet allObjects]];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Initializes a newly allocated set and adds to it members of another given set. Only included for compatability.
|
||||
@param aSet a set of objects to add to the new set.
|
||||
@param shouldCopyItems a boolean value. If YES the objects would be copied, if NO the objects will not be copied.
|
||||
*/
|
||||
- (id)initWithSet:(CPSet)aSet copyItems:(BOOL)shouldCopyItems
|
||||
{
|
||||
@@ -178,7 +205,7 @@
|
||||
return [self initWithSet:aSet];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns the number of members in the receiver.
|
||||
*/
|
||||
- (CPUInteger)count
|
||||
@@ -186,7 +213,7 @@
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns an array containing the receiver’s members, or an empty array if the receiver has no members.
|
||||
*/
|
||||
- (CPArray)allObjects
|
||||
@@ -201,7 +228,7 @@
|
||||
return objects;
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns one of the objects in the receiver, or nil if the receiver contains no objects.
|
||||
*/
|
||||
- (id)anyObject
|
||||
@@ -209,7 +236,7 @@
|
||||
return [[self objectEnumerator] nextObject];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns a Boolean value that indicates whether a given object is present in the receiver.
|
||||
@param anObject The object for which to test membership of the receiver.
|
||||
*/
|
||||
@@ -218,7 +245,11 @@
|
||||
return [self member:anObject] !== nil;
|
||||
}
|
||||
|
||||
- (void)filteredSetUsingPredicate:(CPPredicate)aPredicate
|
||||
/*!
|
||||
Returns a set filtered using a given predicate.
|
||||
@prarm aPredicate a CPPredicate object used to filter the objects in the set.
|
||||
*/
|
||||
- (CPSet)filteredSetUsingPredicate:(CPPredicate)aPredicate
|
||||
{
|
||||
var objects = [],
|
||||
object,
|
||||
@@ -231,7 +262,7 @@
|
||||
return [[[self class] alloc] initWithArray:objects];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Sends to each object in the receiver a message specified by a given selector.
|
||||
@param aSelector A selector that specifies the message to send to the members of the receiver. The method must not take any arguments. It should not have the side effect of modifying the receiver. This value must not be NULL.
|
||||
*/
|
||||
@@ -240,7 +271,7 @@
|
||||
[self makeObjectsPerformSelector:aSelector withObjects:nil];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Sends to each object in the receiver a message specified by a given selector.
|
||||
@param aSelector A selector that specifies the message to send to the receiver's members. The method must take a single argument of type id. The method should not, as a side effect, modify the receiver. The value must not be NULL.
|
||||
@param anObject The object to pass as an argument to the method specified by aSelector.
|
||||
@@ -250,7 +281,7 @@
|
||||
[self makeObjectsPerformSelector:aSelector withObjects:[anObject]];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Sends to each object in the receiver a message specified by a given selector.
|
||||
@param aSelector A selector that specifies the message to send to the receiver's members. The method must take a single argument of type id. The method should not, as a side effect, modify the receiver. The value must not be NULL.
|
||||
@param objects The objects to pass as an argument to the method specified by aSelector.
|
||||
@@ -268,7 +299,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Determines whether the receiver contains an object equal to a given object, and returns that object if it is present.
|
||||
@param anObject The object for which to test for membership of the receiver.
|
||||
*/
|
||||
@@ -277,11 +308,18 @@
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an object enumerator (CPEnumerator) for the receiver.
|
||||
*/
|
||||
- (CPEnumerator)objectEnumerator
|
||||
{
|
||||
_CPRaiseInvalidAbstractInvocation(self, _cmd);
|
||||
}
|
||||
|
||||
/*!
|
||||
Enumberates over the objects in a set using a given function.
|
||||
@param aFunction a callback for each itteration, should be of the format: function(anObject).
|
||||
*/
|
||||
- (void)enumerateObjectsUsingBlock:(Function)aFunction
|
||||
{
|
||||
var object,
|
||||
@@ -306,7 +344,7 @@
|
||||
return [[[self class] alloc] initWithArray:objects];
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns a Boolean value that indicates whether every object in the receiver is also present in another given set.
|
||||
@param set The set with which to compare the receiver.
|
||||
*/
|
||||
@@ -322,7 +360,7 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns a Boolean value that indicates whether at least one object in the receiver is also present in another given set.
|
||||
@param set The set with which to compare the receiver.
|
||||
*/
|
||||
@@ -342,7 +380,17 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
/*!
|
||||
Returns an array of the set's content sorted as specified by a given array of sort descriptors.
|
||||
|
||||
@param sortDescriptors an array of CPSortDescriptor objects.
|
||||
*/
|
||||
- (CPArray)sortedArrayUsingDescriptors:(CPArray)someSortDescriptors
|
||||
{
|
||||
return [[self allObjects] sortedArrayUsingDescriptors:someSortDescriptors];
|
||||
}
|
||||
|
||||
/*!
|
||||
Compares the receiver to another set.
|
||||
@param set The set with which to compare the receiver.
|
||||
*/
|
||||
@@ -351,6 +399,10 @@
|
||||
return [self isEqual:aSet];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns YES if BOTH sets are a subset of the other.
|
||||
@param aSet a set of objects
|
||||
*/
|
||||
- (BOOL)isEqual:(CPSet)aSet
|
||||
{
|
||||
// If both are subsets of each other, they are equal
|
||||
|
||||
@@ -849,6 +849,6 @@ String.prototype.stripDiacritics = function()
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
String.prototype.isa = CPString;
|
||||
|
||||
@@ -257,7 +257,7 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio
|
||||
CPTimersForTimeoutIDs[timeoutID] = [CPTimer scheduledTimerWithTimeInterval:aDelay / 1000 callback:theFunction repeats:shouldRepeat];
|
||||
|
||||
return timeoutID;
|
||||
}
|
||||
};
|
||||
|
||||
// Avoid "TypeError: Result of expression 'window' [undefined] is not an object" when running unit tests.
|
||||
// We can't use a regular PLATFORM(DOM) check because that platform constant is not defined in Foundation.
|
||||
@@ -266,7 +266,7 @@ if (typeof(window) !== 'undefined')
|
||||
window.setTimeout = function(codeOrFunction, aDelay)
|
||||
{
|
||||
return _CPTimerBridgeTimer(codeOrFunction, aDelay, NO, Array.prototype.slice.apply(arguments, [2]));
|
||||
}
|
||||
};
|
||||
|
||||
window.clearTimeout = function(aTimeoutID)
|
||||
{
|
||||
@@ -276,15 +276,15 @@ if (typeof(window) !== 'undefined')
|
||||
[timer invalidate];
|
||||
|
||||
CPTimersForTimeoutIDs[aTimeoutID] = nil;
|
||||
}
|
||||
};
|
||||
|
||||
window.setInterval = function(codeOrFunction, aDelay, functionArgs)
|
||||
{
|
||||
return _CPTimerBridgeTimer(codeOrFunction, aDelay, YES, Array.prototype.slice.apply(arguments, [2]));
|
||||
}
|
||||
};
|
||||
|
||||
window.clearInterval = function(aTimeoutID)
|
||||
{
|
||||
window.clearTimeout(aTimeoutID);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ var CPURLConnectionDelegate = nil;
|
||||
{
|
||||
_HTTPRequest.open([_request HTTPMethod], [[_request URL] absoluteString], YES);
|
||||
|
||||
_HTTPRequest.onreadystatechange = function() { [self _readyStateDidChange]; }
|
||||
_HTTPRequest.onreadystatechange = function() { [self _readyStateDidChange]; };
|
||||
|
||||
var fields = [_request allHTTPHeaderFields],
|
||||
key = nil,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user