Merge branch 'master' of git://github.com/280north/cappuccino

Conflicts:
	AppKit/CPTableView.j
This commit is contained in:
Randall Luecke committed 2010-12-02 19:51:40 -05:00
commit 54e106bb14
93 files changed
+2275 -1501

No files matched your search

+90 -14
View File
@@ -312,7 +312,7 @@ ACTUAL_FRAME_RATE = 0;
[_timingFunction getControlPointAtIndex:1 values:c1];
[_timingFunction getControlPointAtIndex:2 values:c2];
return CubicBezierAtTime(t,c1[0],c1[1],c2[0],c2[1],_duration);
return CubicBezierAtTime(t, c1[0], c1[1], c2[0], c2[1], _duration);
}
@end
@@ -320,28 +320,104 @@ ACTUAL_FRAME_RATE = 0;
// currently used function to determine time
// 1:1 conversion to js from webkit source files
// UnitBezier.h, WebCore_animation_AnimationBase.cpp
var CubicBezierAtTime = function CubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration)
var CubicBezierAtTime = function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration)
{
var ax=0,bx=0,cx=0,ay=0,by=0,cy=0;
var ax = 0,
bx = 0,
cx = 0,
ay = 0,
by = 0,
cy = 0;
// `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
function sampleCurveX(t) {return ((ax*t+bx)*t+cx)*t;};
function sampleCurveY(t) {return ((ay*t+by)*t+cy)*t;};
function sampleCurveDerivativeX(t) {return (3.0*ax*t+2.0*bx)*t+cx;};
function sampleCurveX(t)
{
return ((ax * t + bx) * t + cx) * t;
}
function sampleCurveY(t)
{
return ((ay * t + by) * t + cy) * t;
}
function sampleCurveDerivativeX(t)
{
return (3.0 * ax * t + 2.0 * bx) * t + cx;
}
// The epsilon value to pass given that the animation is going to run over |duration| seconds. The longer the animation, the more precision is needed in the timing function result to avoid ugly discontinuities.
function solveEpsilon(duration) {return 1.0/(200.0*duration);};
function solve(x,epsilon) {return sampleCurveY(solveCurveX(x,epsilon));};
function solveEpsilon(duration)
{
return 1.0 / (200.0 * duration);
}
function solve(x, epsilon)
{
return sampleCurveY(solveCurveX(x, epsilon));
}
// Given an x value, find a parametric value it came from.
function solveCurveX(x,epsilon) {var t0,t1,t2,x2,d2,i;
function fabs(n) {if(n>=0) {return n;}else {return 0-n;}};
function solveCurveX(x, epsilon)
{
var t0,
t1,
t2 = x,
x2,
d2,
i = 0;
// First try a few iterations of Newton's method -- normally very fast.
for(t2=x, i=0; i<8; i++) {x2=sampleCurveX(t2)-x; if(fabs(x2)<epsilon) {return t2;} d2=sampleCurveDerivativeX(t2); if(fabs(d2)<1e-6) {break;} t2=t2-x2/d2;}
for (; i < 8; i++)
{
x2 = sampleCurveX(t2) - x;
if (ABS(x2) < epsilon)
return t2;
d2 = sampleCurveDerivativeX(t2);
if (ABS(d2) < 1e-6)
break;
t2 = t2 - x2 / d2;
}
// Fall back to the bisection method for reliability.
t0=0.0; t1=1.0; t2=x; if(t2<t0) {return t0;} if(t2>t1) {return t1;}
while(t0<t1) {x2=sampleCurveX(t2); if(fabs(x2-x)<epsilon) {return t2;} if(x>x2) {t0=t2;}else {t1=t2;} t2=(t1-t0)*.5+t0;}
t0 = 0.0;
t1 = 1.0;
t2 = x;
if (t2 < t0)
return t0;
if (t2 > t1)
return t1;
while (t0 < t1)
{
x2 = sampleCurveX(t2);
if (ABS(x2 - x) < epsilon)
return t2;
if (x > x2)
t0 = t2;
else
t1 = t2;
t2 = (t1 - t0) * 0.5 + t0;
}
return t2; // Failure.
};
// Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
cx=3.0*p1x; bx=3.0*(p2x-p1x)-cx; ax=1.0-cx-bx; cy=3.0*p1y; by=3.0*(p2y-p1y)-cy; ay=1.0-cy-by;
cx = 3.0 * p1x;
bx = 3.0 * (p2x - p1x) - cx;
ax = 1.0 - cx - bx;
cy = 3.0 * p1y;
by = 3.0 * (p2y - p1y) - cy;
ay = 1.0 - cy - by;
// Convert from input time to parametric value in curve, then from that to output time.
return solve(t, solveEpsilon(duration));
};
+1 -1
View File
@@ -534,7 +534,7 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
{
var point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
if(point.x > [self bounds].size.width - 1 || point.x < 1)
if (point.x > [self bounds].size.width - 1 || point.x < 1)
return NO;
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:[CPArray arrayWithObject:CPColorDragType] owner:self];
+3 -3
View File
@@ -220,14 +220,14 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
[_draggingUpdateTimer invalidate];
_draggingUpdateTimer = nil;
var dragOperation = CPDragOperationCopy;
var dragOperation = CPDragOperationCopy,
// We have to convert base to bridge since the drag event comes from the source window, not the drag window.
var draggingDestination = [aPlatformWindow _dragHitTest:aLocation pasteboard:[CPDragServerDraggingInfo draggingPasteboard]];
draggingDestination = [aPlatformWindow _dragHitTest:aLocation pasteboard:[CPDragServerDraggingInfo draggingPasteboard]];
if (draggingDestination)
_draggingLocation = [DRAGGING_WINDOW(draggingDestination) convertPlatformWindowToBase:aLocation];
if(draggingDestination !== _draggingDestination)
if (draggingDestination !== _draggingDestination)
{
if ([_draggingDestination respondsToSelector:@selector(draggingExited:)])
[_draggingDestination draggingExited:CPDragServerDraggingInfo];
+5 -3
View File
@@ -158,6 +158,7 @@ CPFindFunctionKey = "\uF745";
CPHelpFunctionKey = "\uF746";
CPModeSwitchFunctionKey = "\uF747";
CPEscapeFunctionKey = "\u001B";
CPSpaceFunctionKey = "\u0020";
CPDOMEventDoubleClick = "dblclick",
@@ -556,9 +557,9 @@ var _CPEventPeriodicEventPeriod = 0,
if (_modifierFlags & (CPCommandKeyMask | CPControlKeyMask))
return YES;
for(var i=0; i<characterCount; i++)
for (var i = 0; i < characterCount; i++)
{
switch(_characters.charAt(i))
switch (_characters.charAt(i))
{
case CPBackspaceCharacter:
case CPDeleteCharacter:
@@ -566,6 +567,7 @@ var _CPEventPeriodicEventPeriod = 0,
case CPTabCharacter:
case CPCarriageReturnCharacter:
case CPNewlineCharacter:
case CPSpaceFunctionKey:
case CPEscapeFunctionKey:
case CPPageUpFunctionKey:
case CPPageDownFunctionKey:
@@ -576,7 +578,7 @@ var _CPEventPeriodicEventPeriod = 0,
return YES;
}
}
// FIXME: More cases? Space?
// FIXME: More cases?
return NO;
}
+21 -21
View File
@@ -32,10 +32,10 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
@implementation CPFlashView : CPView
{
CPFlashMovie _flashMovie;
CPDictionary _params;
CPDictionary _paramElements;
#if PLATFORM(DOM)
#if PLATFORM(DOM)
DOMElement _DOMParamElement;
DOMElement _DOMObjectElement;
DOMElement _DOMInnerObjectElement;
@@ -45,7 +45,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
#if PLATFORM(DOM)
@@ -58,24 +58,24 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
_DOMObjectElement.style.left = @"0px";
_DOMObjectElement.type = @"application/x-shockwave-flash";
_DOMObjectElement.setAttribute(@"classid", IEFlashCLSID);
_DOMParamElement = document.createElement(@"param");
_DOMParamElement.name = @"movie";
_DOMInnerObjectElement = document.createElement(@"object");
_DOMInnerObjectElement.width = @"100%";
_DOMInnerObjectElement.height = @"100%";
_DOMObjectElement.appendChild(_DOMParamElement);
_DOMObjectElement.appendChild(_DOMInnerObjectElement);
_DOMElement.appendChild(_DOMObjectElement);
}
else
[self _rebuildIEObjects];
#endif
}
return self;
}
@@ -83,7 +83,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
{
if (_flashMovie == aFlashMovie)
return;
_flashMovie = aFlashMovie;
#if PLATFORM(DOM)
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
@@ -105,14 +105,14 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
{
var varString = @"",
enumerator = [aDictionary keyEnumerator];
var key;
while (key = [enumerator nextObject])
varString = [varString stringByAppendingFormat:@"&%@=%@", key, [aDictionary objectForKey:key]];
if (!_params)
_params = [CPDictionary dictionary];
[_params setObject:varString forKey:@"flashvars"];
[self setParameters:_params];
}
@@ -129,7 +129,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
{
var elements = [_paramElements allValues],
count = [elements count];
for (var i = 0; i < count; i++)
_DOMObjectElement.removeChild([elements objectAtIndex:i]);
}
@@ -139,18 +139,18 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
_paramElements = [CPDictionary dictionary];
var enumerator = [_params keyEnumerator],
key;
while (key = [enumerator nextObject] && _DOMObjectElement)
{
var param = document.createElement(@"param");
param.name = key;
param.value = [_params objectForKey:key];
_DOMObjectElement.appendChild(param);
[_paramElements setObject:param forKey:key];
}
}
@@ -170,17 +170,17 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
_DOMElement.innerHTML = @"";
if (![_flashMovie filename])
return;
var paramString = [CPString stringWithFormat:@"<param name='movie' value='%@' />", [_flashMovie filename]],
paramEnumerator = [_params keyEnumerator],
key;
while (key = [paramEnumerator nextObject])
paramString = [paramString stringByAppendingFormat:@"<param name='%@' value='%@' />", key, [_params objectForKey:key]];
_DOMObjectElement = document.createElement(@"object");
_DOMElement.appendChild(_DOMObjectElement);
_DOMObjectElement.outerHTML = [CPString stringWithFormat:@"<object classid=%@ width=%@ height=%@>%@</object>", IEFlashCLSID, CGRectGetWidth([self bounds]), CGRectGetHeight([self bounds]), paramString];
}
#endif
+38 -32
View File
@@ -45,7 +45,7 @@ var CPSharedFontManager = nil,
{
if (!CPSharedFontManager)
CPSharedFontManager = [[CPFontManagerFactory alloc] init];
return CPSharedFontManager;
}
@@ -65,7 +65,7 @@ var CPSharedFontManager = nil,
- (CPArray)availableFonts
{
if (!_availableFonts)
{
{
_CPFontDetectSpan = document.createElement("span");
_CPFontDetectSpan.fontSize = "24px";
_CPFontDetectSpan.appendChild(document.createTextNode("mmmmmmmmmml"));
@@ -74,13 +74,14 @@ var CPSharedFontManager = nil,
div.style.top = "-1000px";
div.appendChild(_CPFontDetectSpan);
document.getElementsByTagName("body")[0].appendChild(div);
_CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace", "serif", "sans-serif", "cursive"]);
_CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace", "serif", "sans-serif", "cursive"]);
_availableFonts = [];
for (var i = 0; i < _CPFontDetectAllFonts.length; i++) {
for (var i = 0; i < _CPFontDetectAllFonts.length; i++)
{
var available = _CPFontDetectFontAvailable(_CPFontDetectAllFonts[i]);
if (available)
if (available)
_availableFonts.push(_CPFontDetectAllFonts[i]);
}
}
@@ -101,8 +102,8 @@ var CPSharedFontManager = nil,
var _CPFontDetectSpan,
_CPFontDetectReferenceFonts,
_CPFontDetectAllFonts = [
/* "04b_21","A Charming Font","Abadi MT Condensed","Abadi MT Condensed Extra Bold","Abadi MT Condensed Light","Academy Engraved LET","Agency FB","Alba","Alba Matter","Alba Super","Algerian",*/
"American Typewriter",
/* "04b_21","A Charming Font","Abadi MT Condensed","Abadi MT Condensed Extra Bold","Abadi MT Condensed Light","Academy Engraved LET","Agency FB","Alba","Alba Matter","Alba Super","Algerian",*/
"American Typewriter",
/* "Andale Mono","Andale Mono IPA","Andy", */
"Apple Chancery","Arial","Arial Black","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS",
/* "Avant Garde","Avantgarde","Baby Kruffy","Base 02","Baskerville","Baskerville Old Face","Bauhaus 93","Beesknees ITC","Bell MT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","Bickley Script",*/
@@ -122,8 +123,8 @@ var _CPFontDetectSpan,
/* "GlooGun","Gloucester MT Extra Condensed","Goudy Old Style","Goudy Stout","Haettenschweiler","Harlow Solid Italic","Harrington",*/
"Helvetica","Helvetica Narrow","Helvetica Neue","Herculanum","High Tower Text","Highlight LET","Hoefler Text","Impact","Imprint MT Shadow",
/* "Informal Roman","Jenkins v2.0","John Handy LET","Jokerman","Jokerman LET","Jokewood","Juice ITC","Kabel Ult BT","Kartika","Kino MT","Kristen ITC","Kunstler Script","La Bamba LET", */
"Lucida","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","Lucida Grande","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode",
/* "Luxi Mono","Luxi Sans","Luxi Serif","MARKETPRO","MS Reference Sans Serif","MS Reference Serif","Magneto","Maiandra GD", */
"Lucida","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","Lucida Grande","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode",
/* "Luxi Mono","Luxi Sans","Luxi Serif","MARKETPRO","MS Reference Sans Serif","MS Reference Serif","Magneto","Maiandra GD", */
"Marker Felt",
/* "Matisse ITC","Matura MT Script Capitals","Mead Bold","Mekanik LET","Mercurius Script MT Bold", */
"Microsoft Sans Serif","Milano LET","Minion Web","MisterEarl BT","Mistral","Monaco","Monotype Corsiva","Monotype.com","New Century Schoolbook","New York","News Gothic MT",
@@ -136,39 +137,44 @@ var _CPFontDetectSpan,
"Zapfino"];
// Compare against the reference fonts. Return true if it produces a different size than at least one of them.
var _CPFontDetectFontAvailable = function(font) {
for (var i = 0; i < _CPFontDetectReferenceFonts.length; i++)
if (_CPFontDetectCompareFonts(_CPFontDetectReferenceFonts[i], font))
return true;
return false;
var _CPFontDetectFontAvailable = function(font)
{
for (var i = 0; i < _CPFontDetectReferenceFonts.length; i++)
if (_CPFontDetectCompareFonts(_CPFontDetectReferenceFonts[i], font))
return true;
return false;
}
var _CPFontDetectCache = {};
// Compares two given fonts. Returns true if they produce different sizes (i.e. fontA didn't fallback to fontB)
var _CPFontDetectCompareFonts = function(fontA, fontB) {
var _CPFontDetectCompareFonts = function(fontA, fontB)
{
var a;
if (_CPFontDetectCache[fontA]) {
if (_CPFontDetectCache[fontA])
a = _CPFontDetectCache[fontA];
} else {
_CPFontDetectSpan.style.fontFamily = '"' + fontA + '"';
else
{
_CPFontDetectSpan.style.fontFamily = '"' + fontA + '"';
_CPFontDetectCache[fontA] = a = { w: _CPFontDetectSpan.offsetWidth, h: _CPFontDetectSpan.offsetHeight };
}
_CPFontDetectSpan.style.fontFamily= '"' + fontB + '", "' + fontA + '"';
var bWidth = _CPFontDetectSpan.offsetWidth;
var bHeight = _CPFontDetectSpan.offsetHeight;
return (a.w != bWidth || a.h != bHeight);
_CPFontDetectSpan.style.fontFamily = '"' + fontB + '", "' + fontA + '"';
var bWidth = _CPFontDetectSpan.offsetWidth,
Height = _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) {
for (var i = 0; i < candidates.length; i++)
for (var j = 0; j < i; j++)
if (_CPFontDetectCompareFonts(candidates[i], candidates[j]))
return [candidates[i], candidates[j]];
return [candidates[0]];
var _CPFontDetectPickTwoDifferentFonts = function(candidates)
{
for (var i = 0; i < candidates.length; i++)
for (var j = 0; j < i; j++)
if (_CPFontDetectCompareFonts(candidates[i], candidates[j]))
return [candidates[i], candidates[j]];
return [candidates[0]];
}
[CPFontManager setFontManagerFactory:[CPFontManager class]];
+1 -1
View File
@@ -71,7 +71,7 @@ function CPPointMake(x, y)
function CPRectInset(aRect, dX, dY)
{
return CPRectMake( aRect.origin.x + dX, aRect.origin.y + dY,
aRect.size.width - 2 * dX, aRect.size.height - 2*dY);
aRect.size.width - 2 * dX, aRect.size.height - 2 * dY);
}
/*!
+2 -2
View File
@@ -71,10 +71,10 @@ var CPGraphicsContextCurrent = nil;
- (id)initWithGraphicsPort:(CPContext)aGraphicsPort
{
self = [super init];
if (self)
_graphicsPort = aGraphicsPort;
return self;
}
+2 -2
View File
@@ -65,7 +65,7 @@ function CPAppKitImage(aFilename, aSize)
return CPImageInBundle(aFilename, aSize, [CPBundle bundleForClass:[CPView class]]);
}
/*!
/*!
@ingroup appkit
@class CPImage
@@ -73,7 +73,7 @@ function CPAppKitImage(aFilename, aSize)
all image types supported by the browser.
@par Delegate Methods
@delegate -(void)imageDidLoad:(CPImage)image;
Called when the specified image has finished loading.
@param image the image that loaded
+45 -44
View File
@@ -43,7 +43,7 @@ CPImageAlignRight = 8;
var CPImageViewShadowBackgroundColor = nil,
CPImageViewEmptyPlaceholderImage = nil;
var LEFT_SHADOW_INSET = 3.0,
RIGHT_SHADOW_INSET = 3.0,
TOP_SHADOW_INSET = 3.0,
@@ -51,7 +51,7 @@ var LEFT_SHADOW_INSET = 3.0,
VERTICAL_SHADOW_INSET = TOP_SHADOW_INSET + BOTTOM_SHADOW_INSET,
HORIZONTAL_SHADOW_INSET = LEFT_SHADOW_INSET + RIGHT_SHADOW_INSET;
/*!
/*!
@ingroup appkit
@class CPImageView
@@ -60,7 +60,7 @@ var LEFT_SHADOW_INSET = 3.0,
@implementation CPImageView : CPControl
{
DOMElement _DOMImageElement;
BOOL _hasShadow;
CPView _shadowView;
@@ -73,14 +73,14 @@ var LEFT_SHADOW_INSET = 3.0,
+ (void)initialize
{
var bundle = [CPBundle bundleForClass:[CPView class]];
CPImageViewEmptyPlaceholderImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"empty.png"]];
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
#if PLATFORM(DOM)
@@ -96,11 +96,11 @@ var LEFT_SHADOW_INSET = 3.0,
}
CPDOMDisplayServerAppendChild(_DOMElement, _DOMImageElement);
_DOMImageElement.style.visibility = "hidden";
#endif
}
return self;
}
@@ -121,29 +121,29 @@ var LEFT_SHADOW_INSET = 3.0,
- (void)setObjectValue:(CPImage)anImage
{
var oldImage = [self objectValue];
if (oldImage === anImage)
return;
[super setObjectValue:anImage];
var defaultCenter = [CPNotificationCenter defaultCenter];
if (oldImage)
[defaultCenter removeObserver:self name:CPImageDidLoadNotification object:oldImage];
var newImage = [self objectValue];
#if PLATFORM(DOM)
_DOMImageElement.src = newImage ? [newImage filename] : [CPImageViewEmptyPlaceholderImage filename];
#endif
var size = [newImage size];
if (size && size.width === -1 && size.height === -1)
{
[defaultCenter addObserver:self selector:@selector(imageDidLoad:) name:CPImageDidLoadNotification object:newImage];
#if PLATFORM(DOM)
_DOMImageElement.width = 0;
_DOMImageElement.height = 0;
@@ -162,7 +162,7 @@ var LEFT_SHADOW_INSET = 3.0,
- (void)imageDidLoad:(CPNotification)aNotification
{
[self hideOrDisplayContents];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -184,25 +184,25 @@ var LEFT_SHADOW_INSET = 3.0,
{
if (_hasShadow == shouldHaveShadow)
return;
_hasShadow = shouldHaveShadow;
if (_hasShadow)
{
_shadowView = [[CPShadowView alloc] initWithFrame:[self bounds]];
[self addSubview:_shadowView];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
else
{
[_shadowView removeFromSuperview];
_shadowView = nil;
}
[self hideOrDisplayContents];
}
@@ -215,12 +215,12 @@ var LEFT_SHADOW_INSET = 3.0,
{
if (_imageAlignment == anImageAlignment)
return;
_imageAlignment = anImageAlignment;
if (![self image])
return;
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -238,14 +238,14 @@ var LEFT_SHADOW_INSET = 3.0,
- (void)setImageScaling:(CPImageScaling)anImageScaling
{
[super setImageScaling:anImageScaling];
#if PLATFORM(DOM)
if ([self currentValueForThemeAttribute:@"image-scaling"] === CPScaleToFit)
{
CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, 0.0, 0.0);
}
#endif
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -314,7 +314,7 @@ var LEFT_SHADOW_INSET = 3.0,
else
{
var size = [image size];
if (size.width == -1 && size.height == -1)
return;
@@ -331,7 +331,7 @@ var LEFT_SHADOW_INSET = 3.0,
{
var imageRatio = size.width / size.height,
viewRatio = width / height;
if (viewRatio > imageRatio)
width = height * imageRatio;
else
@@ -348,7 +348,7 @@ var LEFT_SHADOW_INSET = 3.0,
width = size.width;
height = size.height;
}
if (imageScaling == CPScaleNone)
{
#if PLATFORM(DOM)
@@ -357,8 +357,9 @@ var LEFT_SHADOW_INSET = 3.0,
#endif
}
var x, y;
var x,
y;
switch (_imageAlignment)
{
case CPImageAlignLeft:
@@ -366,7 +367,7 @@ var LEFT_SHADOW_INSET = 3.0,
case CPImageAlignBottomLeft:
x = 0.0;
break;
case CPImageAlignRight:
case CPImageAlignTopRight:
case CPImageAlignBottomRight:
@@ -377,7 +378,7 @@ var LEFT_SHADOW_INSET = 3.0,
x = (boundsWidth - width) / 2.0;
break;
}
switch (_imageAlignment)
{
case CPImageAlignTop:
@@ -385,7 +386,7 @@ var LEFT_SHADOW_INSET = 3.0,
case CPImageAlignTopRight:
y = 0.0;
break;
case CPImageAlignBottom:
case CPImageAlignBottomLeft:
case CPImageAlignBottomRight:
@@ -395,7 +396,7 @@ var LEFT_SHADOW_INSET = 3.0,
default:
y = (boundsHeight - height) / 2.0;
break;
}
}
#if PLATFORM(DOM)
CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, x, y);
@@ -403,7 +404,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)];
}
@@ -450,7 +451,7 @@ var LEFT_SHADOW_INSET = 3.0,
[self setImage:images[0]];
[self sendAction:[self action] to:[self target]];
}
return YES;
}
@@ -485,7 +486,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
#endif
self = [super initWithCoder:aCoder];
if (self)
{
#if PLATFORM(DOM)
@@ -494,14 +495,14 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
[self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]];
[self setImageAlignment:[aCoder decodeIntForKey:CPImageViewImageAlignmentKey]];
if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey] || NO)
[self setEditable:YES];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
return self;
}
@@ -512,21 +513,21 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
// We do this in order to avoid encoding the _shadowView, which
// We do this in order to avoid encoding the _shadowView, which
// should just automatically be created programmatically as needed.
if (_shadowView)
{
var actualSubviews = _subviews;
_subviews = [_subviews copy];
[_subviews removeObjectIdenticalTo:_shadowView];
}
[super encodeWithCoder:aCoder];
if (_shadowView)
_subviews = actualSubviews;
[aCoder encodeBool:_hasShadow forKey:CPImageViewHasShadowKey];
[aCoder encodeInt:_imageAlignment forKey:CPImageViewImageAlignmentKey];
+13 -9
View File
@@ -513,10 +513,10 @@ CPOutlineViewDropOnItemIndex = -1;
],
delegateCount = [delegateMethods count];
for (var i=0; i < delegateCount; i += 2)
for (var i = 0; i < delegateCount; i += 2)
{
var bitMask = delegateMethods[i],
selector = delegateMethods[i+1];
selector = delegateMethods[i + 1];
if ([_outlineViewDelegate respondsToSelector:selector])
_implementedOutlineViewDelegateMethods |= bitMask;
@@ -670,8 +670,8 @@ CPOutlineViewDropOnItemIndex = -1;
if (_shouldRetargetItem)
return _retargetedItem;
var lowerLevel = [self levelForRow:theLowerRowIndex]
upperItem = [self itemAtRow:theUpperRowIndex];
var lowerLevel = [self levelForRow:theLowerRowIndex],
upperItem = [self itemAtRow:theUpperRowIndex],
upperLevel = [self levelForItem:upperItem];
// If the row above us has a higher level the item can be added to multiple parent items
@@ -875,7 +875,7 @@ var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem)
if (!anItem)
return;
with(anOutlineView)
with (anOutlineView)
{
// Get the existing info if it exists.
var itemInfosForItems = _itemInfosForItems,
@@ -911,7 +911,7 @@ var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem)
// 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)
{
with(anOutlineView)
with (anOutlineView)
{
var itemInfosForItems = _itemInfosForItems,
dataSource = _outlineViewDataSource;
@@ -1261,12 +1261,16 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
CGContextBeginPath(context);
CGContextMoveToPoint(context, 0.0, 0.0);
if(_angle === 0.0) {
if (_angle === 0.0)
{
CGContextAddLineToPoint(context, 4.5, 8.0);
CGContextAddLineToPoint(context, 9.0, 0.0);
} else {
CGContextAddLineToPoint(context, 4.5, 8.0);
}
else
CGContextAddLineToPoint(context, 4.5, 8.0);
CGContextSetStrokeColor(context, [CPColor colorWithCalibratedWhite:1.0 alpha: 0.8]);
CGContextStrokePath(context);
}
+1 -1
View File
@@ -51,7 +51,7 @@ CPCancelButton = 0;
@global
@class CPWindow
*/
CPDocModalWindowMask = 1 << 6;
CPDocModalWindowMask = 1 << 6;
@implementation CPPanel : CPWindow
{
+24 -24
View File
@@ -50,18 +50,18 @@ CPImagePboardType = @"CPImagePboardType";
var CPPasteboards = nil,
supportsNativePasteboard = NO;
/*!
/*!
@ingroup appkit
@class CPPasteboard
CPPasteBoard is the object responsible for cut/copy/paste and drag&drop operations.
CPPasteBoard is the object responsible for cut/copy/paste and drag&drop operations.
*/
@implementation CPPasteboard : CPObject
{
CPArray _types;
CPDictionary _owners;
CPDictionary _provided;
unsigned _changeCount;
CPString _stateUID;
@@ -77,7 +77,7 @@ var CPPasteboards = nil,
return;
[self setVersion:1.0];
CPPasteboards = [CPDictionary dictionary];
if (typeof window.cpPasteboardWithName !== "undefined")
@@ -103,10 +103,10 @@ var CPPasteboards = nil,
if (pasteboard)
return pasteboard;
pasteboard = [[CPPasteboard alloc] _initWithName:aName];
[CPPasteboards setObject:pasteboard forKey:aName];
return pasteboard;
}
@@ -114,15 +114,15 @@ var CPPasteboards = nil,
- (id)_initWithName:(CPString)aName
{
self = [super init];
if (self)
{
_name = aName;
_types = [];
_owners = [CPDictionary dictionary];
_provided = [CPDictionary dictionary];
_changeCount = 0;
if (supportsNativePasteboard)
@@ -131,7 +131,7 @@ var CPPasteboards = nil,
[self _synchronizePasteboard];
}
}
return self;
}
@@ -145,17 +145,17 @@ var CPPasteboards = nil,
{
var i = 0,
count = types.length;
for (; i < count; ++i)
{
var type = types[i];
if(![_owners objectForKey:type])
if (![_owners objectForKey:type])
{
[_types addObject:type];
[_provided removeObjectForKey:type];
}
[_owners setObject:anOwner forKey:type];
}
@@ -191,7 +191,7 @@ var CPPasteboards = nil,
_provided = [CPDictionary dictionary];
var count = _types.length;
while (count--)
[_owners setObject:anOwner forKey:_types[count]];
@@ -283,18 +283,18 @@ var CPPasteboards = nil,
- (CPData)dataForType:(CPString)aType
{
var data = [_provided objectForKey:aType];
if (data)
return data;
var owner = [_owners objectForKey:aType];
if (owner)
{
[owner pasteboard:self provideDataForType:aType];
[owner pasteboard:self provideDataForType:aType];
return [_provided objectForKey:aType];
}
if (aType === CPStringPboardType)
return [self dataForType:UTF8PboardType];
@@ -339,10 +339,10 @@ var CPPasteboards = nil,
- (id)propertyListForType:(CPString)aType
{
var data = [self dataForType:aType];
if (data)
return [CPPropertyListSerialization propertyListFromData:data format:CPPropertyList280NorthFormat_v1_0];
return nil;
}
@@ -360,9 +360,9 @@ var CPPasteboards = nil,
- (CPString)_generateStateUID
{
var bits = 32;
_stateUID = @"";
while (bits--)
_stateUID += FLOOR(RAND() * 16.0).toString(16).toUpperCase();
+40 -41
View File
@@ -47,7 +47,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
CPProgressIndicatorStyleIdentifiers = nil,
CPProgressIndicatorStyleSizes = nil;
/*!
/*!
@ingroup appkit
@class CPProgressIndicator
@@ -59,19 +59,19 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
double _minValue;
double _maxValue;
double _doubleValue;
CPControlSize _controlSize;
BOOL _isIndeterminate;
CPProgressIndicatorStyle _style;
BOOL _isAnimating;
BOOL _isDisplayedWhenStoppedSet;
BOOL _isDisplayedWhenStopped;
CPView _barView;
}
@@ -82,11 +82,11 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (self != [CPProgressIndicator class])
return;
var bundle = [CPBundle bundleForClass:self];
CPProgressIndicatorSpinningStyleColors = [];
CPProgressIndicatorSpinningStyleColors[CPMiniControlSize] = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(64.0, 64.0)]];
CPProgressIndicatorSpinningStyleColors[CPSmallControlSize] = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:
@@ -95,10 +95,10 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(64.0, 64.0)]];
CPProgressIndicatorBezelBorderViewPool = [];
var start = CPProgressIndicatorBarStyle,
end = CPProgressIndicatorHUDBarStyle;
for (; start <= end; ++start)
{
CPProgressIndicatorBezelBorderViewPool[start] = [];
@@ -106,14 +106,14 @@ var CPProgressIndicatorSpinningStyleColors = nil,
CPProgressIndicatorBezelBorderViewPool[start][CPSmallControlSize] = [];
CPProgressIndicatorBezelBorderViewPool[start][CPRegularControlSize] = [];
}
CPProgressIndicatorClassName = [self className];
CPProgressIndicatorStyleIdentifiers = [];
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle] = @"Bar";
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorSpinningStyle] = @"Spinny";
CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle] = @"HUDBar";
var regularIdentifier = _CPControlIdentifierForControlSize(CPRegularControlSize),
smallIdentifier = _CPControlIdentifierForControlSize(CPSmallControlSize),
miniIdentifier = _CPControlIdentifierForControlSize(CPMiniControlSize);
@@ -128,7 +128,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
CPProgressIndicatorClassName + @"Bar" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorHUDBarStyle]
];
for (var i = 0, count = prefixes.length; i<count; i++)
for (var i = 0, count = prefixes.length; i < count; i++)
{
var prefix = prefixes[i];
CPProgressIndicatorStyleSizes[prefix + regularIdentifier] = [_CGSizeMake(3.0, 16.0), _CGSizeMake(1.0, 16.0), _CGSizeMake(3.0, 16.0)];
@@ -140,23 +140,23 @@ var CPProgressIndicatorSpinningStyleColors = nil,
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
_minValue = 0.0;
_maxValue = 100.0;
_doubleValue = 0.0;
_style = CPProgressIndicatorBarStyle;
_isDisplayedWhenStoppedSet = NO;
_controlSize = CPRegularControlSize;
[self updateBackgroundColor];
[self drawBar];
}
return self;
}
@@ -174,7 +174,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
- (void)startAnimation:(id)aSender
{
_isAnimating = YES;
[self _hideOrDisplay];
}
@@ -213,7 +213,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
- (void)setDoubleValue:(double)aValue
{
_doubleValue = MIN(MAX(aValue, _minValue), _maxValue);
[self drawBar];
}
@@ -268,7 +268,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (_controlSize == aControlSize)
return;
_controlSize = aControlSize;
[self updateBackgroundColor];
@@ -320,7 +320,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (_isIndeterminate == isIndeterminate)
return;
_isIndeterminate = isIndeterminate;
[self updateBackgroundColor];
@@ -342,9 +342,9 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (_style == aStyle)
return;
_style = aStyle;
[self updateBackgroundColor];
}
@@ -357,8 +357,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self setFrameSize:[[CPProgressIndicatorSpinningStyleColors[_controlSize] patternImage] size]];
else
[self setFrameSize:CGSizeMake(CGRectGetWidth([self frame]), CPProgressIndicatorStyleSizes[
CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle] +
_CPControlIdentifierForControlSize(_controlSize)][0].height)];
CPProgressIndicatorClassName + @"BezelBorder" + CPProgressIndicatorStyleIdentifiers[CPProgressIndicatorBarStyle] + _CPControlIdentifierForControlSize(_controlSize)][0].height)];
}
/*!
@@ -370,11 +369,11 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (_isDisplayedWhenStoppedSet && _isDisplayedWhenStopped == isDisplayedWhenStopped)
return;
_isDisplayedWhenStoppedSet = YES;
_isDisplayedWhenStopped = isDisplayedWhenStopped;
[self _hideOrDisplay];
}
@@ -385,10 +384,10 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (_isDisplayedWhenStoppedSet)
return _isDisplayedWhenStopped;
if (_style == CPProgressIndicatorBarStyle || _style == CPProgressIndicatorHUDBarStyle)
return YES;
return NO;
}
@@ -401,7 +400,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
- (void)setFrameSize:(CGSize)aSize
{
[super setFrameSize:aSize];
[self drawBar];
}
@@ -410,13 +409,13 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
if (_style == CPProgressIndicatorSpinningStyle)
return;
if (!_barView)
{
_barView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 16.0)];
_barView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 16.0)];
[self addSubview:_barView];
}
[_barView setBackgroundColor:_CPControlThreePartImagePattern(
NO,
CPProgressIndicatorStyleSizes,
@@ -442,9 +441,9 @@ var CPProgressIndicatorSpinningStyleColors = nil,
if (_style == CPProgressIndicatorSpinningStyle)
{
[_barView removeFromSuperview];
_barView = nil;
[self setBackgroundColor:CPProgressIndicatorSpinningStyleColors[_controlSize]];
}
else
@@ -456,7 +455,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
@"BezelBorder",
CPProgressIndicatorStyleIdentifiers[_style],
_CPControlIdentifierForControlSize(_controlSize))];
[self drawBar];
}
}
+111 -136
View File
@@ -23,12 +23,10 @@
@import "CPButton.j"
@import "CPTextField.j"
CPSearchFieldRecentsTitleMenuItemTag = 1000;
CPSearchFieldRecentsMenuItemTag = 1001;
CPSearchFieldClearRecentsMenuItemTag = 1002;
CPSearchFieldNoRecentsMenuItemTag = 1003;
CPSearchFieldSeparatorMenuItemTag = 1004;
var CPSearchFieldSearchImage = nil,
CPSearchFieldFindImage = nil,
@@ -39,15 +37,16 @@ var SEARCH_BUTTON_DEFAULT_WIDTH = 25.0,
CANCEL_BUTTON_DEFAULT_WIDTH = 22.0,
BUTTON_DEFAULT_HEIGHT = 22.0;
var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotification";
var RECENT_SEARCH_PREFIX = @" ";
/*!
/*!
@ingroup appkit
@class CPSearchField
The CPSearchField class defines the programmatic interface for text fields that are optimized for text-based searches. A CPSearchField object directly inherits from the CPTextField class. The search field implemented by these classes presents a standard user interface for searches, including a search button, a cancel button, and a pop-up icon menu for listing recent search strings and custom search categories.
When the user types and then pauses, the text field's action message is sent to its target. You can query the text field's string value for the current text to search for. Do not rely on the sender of the action to be an CPMenu object because the menu may change. If you need to change the menu, modify the search menu template and call the setSearchMenuTemplate: method to update.
When the user types and then pauses, the text field's action message is sent to its target. You can query the text field's string value for the current text to search for. Do not rely on the sender of the action to be an CPMenu object because the menu may change. If you need to change the menu, modify the search menu template and call the setSearchMenuTemplate: method to update.
*/
@implementation CPSearchField : CPTextField
{
@@ -58,7 +57,7 @@ var RECENT_SEARCH_PREFIX = @" ";
CPString _recentsAutosaveName;
CPArray _recentSearches;
int _maximumRecents;
BOOL _sendsWholeSearchString;
BOOL _sendsSearchStringImmediately;
@@ -96,9 +95,9 @@ var RECENT_SEARCH_PREFIX = @" ";
#if PLATFORM(DOM)
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
#endif
}
return self;
}
@@ -112,17 +111,17 @@ var RECENT_SEARCH_PREFIX = @" ";
[self setEditable:YES];
[self setDelegate:self];
[self setContinuous:YES];
var bounds = [self bounds],
cancelButton = [[CPButton alloc] initWithFrame:[self cancelButtonRectForBounds:bounds]],
searchButton = [[CPButton alloc] initWithFrame:[self searchButtonRectForBounds:bounds]];
[self setCancelButton:cancelButton];
[self resetCancelButton];
[self setSearchButton:searchButton];
[self resetSearchButton];
_canResignFirstResponder = YES;
}
@@ -132,12 +131,12 @@ var RECENT_SEARCH_PREFIX = @" ";
@param button The search button.
*/
- (void)setSearchButton:(CPButton)button
{
{
if (button != _searchButton)
{
[_searchButton removeFromSuperview];
_searchButton = button;
[_searchButton setFrame:[self searchButtonRectForBounds:[self bounds]]];
[_searchButton setAutoresizingMask:CPViewMaxXMargin];
[self addSubview:_searchButton];
@@ -161,7 +160,7 @@ var RECENT_SEARCH_PREFIX = @" ";
{
var button = [self searchButton],
searchButtonImage = (_searchMenuTemplate === nil) ? CPSearchFieldSearchImage : CPSearchFieldFindImage;
[button setBordered:NO];
[button setImageScaling:CPScaleToFit];
[button setImage:searchButtonImage];
@@ -178,11 +177,11 @@ var RECENT_SEARCH_PREFIX = @" ";
{
[_cancelButton removeFromSuperview];
_cancelButton = button;
[_cancelButton setFrame:[self cancelButtonRectForBounds:[self bounds]]];
[_cancelButton setAutoresizingMask:CPViewMinXMargin];
[_cancelButton setTarget:self];
[_cancelButton setAction:@selector(_searchFieldCancel:)];
[_cancelButton setAction:@selector(_searchFieldCancel:)];
[self _updateCancelButtonVisibility];
[self addSubview:_cancelButton];
}
@@ -222,22 +221,22 @@ var RECENT_SEARCH_PREFIX = @" ";
*/
- (CGRect)searchTextRectForBounds:(CGRect)rect
{
var leftOffset = 0,
var leftOffset = 0,
width = _CGRectGetWidth(rect),
bounds = [self bounds];
if (_searchButton)
{
var searchBounds = [self searchButtonRectForBounds:bounds];
leftOffset = _CGRectGetMaxX(searchBounds) + 2;
}
if (_cancelButton)
{
var cancelRect = [self cancelButtonRectForBounds:bounds];
width = _CGRectGetMinX(cancelRect) - leftOffset;
}
return _CGRectMake(leftOffset, _CGRectGetMinY(rect), width, _CGRectGetHeight(rect));
}
@@ -257,7 +256,7 @@ var RECENT_SEARCH_PREFIX = @" ";
Subclasses can override this method to return a new bounding rectangle for the cancel button. You might use this method to provide a custom layout for the search field control.
*/
- (CGRect)cancelButtonRectForBounds:(CGRect)rect
{
{
return _CGRectMake(_CGRectGetWidth(rect) - CANCEL_BUTTON_DEFAULT_WIDTH - 5, (_CGRectGetHeight(rect) - CANCEL_BUTTON_DEFAULT_WIDTH) / 2, BUTTON_DEFAULT_HEIGHT, BUTTON_DEFAULT_HEIGHT);
}
@@ -279,7 +278,7 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)setSearchMenuTemplate:(CPMenu)aMenu
{
_searchMenuTemplate = aMenu;
[self resetSearchButton];
[self _loadRecentSearchList];
[self _updateSearchMenu];
@@ -291,8 +290,8 @@ var RECENT_SEARCH_PREFIX = @" ";
@return \c YES if the action message is sent all at once when the user clicks the search button or presses return; otherwise, NO if the search string is sent after each keystroke. The default value is NO.
*/
- (BOOL)sendsWholeSearchString
{
return _sendsWholeSearchString;
{
return _sendsWholeSearchString;
}
/*!
@@ -309,8 +308,8 @@ var RECENT_SEARCH_PREFIX = @" ";
@return \c YES if the text field sends its action immediately upon notification of any changes to the search field; otherwise, NO.
*/
- (BOOL)sendsSearchStringImmediately
{
return _sendsSearchStringImmediately;
{
return _sendsSearchStringImmediately;
}
/*!
@@ -328,7 +327,7 @@ var RECENT_SEARCH_PREFIX = @" ";
@return The maximum number of search strings that can appear in the menu. This value is between 0 and 254.
*/
- (int)maximumRecents
{
{
return _maximumRecents;
}
@@ -342,13 +341,13 @@ var RECENT_SEARCH_PREFIX = @" ";
max = 254;
else if (max < 0)
max = 10;
_maximumRecents = max;
}
/*!
Returns the list of recent search strings for the control.
@return An array of \c CPString objects, each of which contains a search string either displayed in the search menu or from a recent autosave archive. If there have been no recent searches and no prior searches saved under an autosave name, this array may be empty.
@return An array of \c CPString objects, each of which contains a search string either displayed in the search menu or from a recent autosave archive. If there have been no recent searches and no prior searches saved under an autosave name, this array may be empty.
*/
- (CPArray)recentSearches
{
@@ -364,8 +363,8 @@ var RECENT_SEARCH_PREFIX = @" ";
{
var max = MIN([self maximumRecents], [searches count]),
searches = [searches subarrayWithRange:CPMakeRange(0, max)];
_recentSearches = searches;
_recentSearches = searches;
[self _autosaveRecentSearchList];
}
@@ -375,7 +374,7 @@ var RECENT_SEARCH_PREFIX = @" ";
*/
- (CPString)recentsAutosaveName
{
return _recentsAutosaveName;
return _recentsAutosaveName;
}
/*!
@@ -386,9 +385,9 @@ var RECENT_SEARCH_PREFIX = @" ";
{
if (_recentsAutosaveName != nil)
[self _deregisterForAutosaveNotification];
_recentsAutosaveName = name;
if (_recentsAutosaveName != nil)
[self _registerForAutosaveNotification];
}
@@ -397,13 +396,13 @@ var RECENT_SEARCH_PREFIX = @" ";
- (CGRect)contentRectForBounds:(CGRect)bounds
{
var superbounds = [super contentRectForBounds:bounds];
var superbounds = [super contentRectForBounds:bounds];
return [self searchTextRectForBounds:superbounds];
}
+ (double)_keyboardDelayForPartialSearchString:(CPString)string
{
return (6 - MIN([string length],4))/10;
return (6 - MIN([string length], 4)) / 10;
}
- (CPMenu)menu
@@ -431,15 +430,15 @@ var RECENT_SEARCH_PREFIX = @" ";
{
[_partialStringTimer invalidate];
var timeInterval = [CPSearchField _keyboardDelayForPartialSearchString:[self stringValue]];
_partialStringTimer = [CPTimer scheduledTimerWithTimeInterval:timeInterval
target:self
selector:@selector(_sendPartialString)
userInfo:nil
repeats:NO];
_partialStringTimer = [CPTimer scheduledTimerWithTimeInterval:timeInterval
target:self
selector:@selector(_sendPartialString)
userInfo:nil
repeats:NO];
}
}
[self _updateCancelButtonVisibility];
}
@@ -462,7 +461,7 @@ var RECENT_SEARCH_PREFIX = @" ";
{
if (string === nil || string === @"" || [_recentSearches containsObject:string])
return;
var searches = [CPMutableArray arrayWithArray:_recentSearches];
[searches addObject:string];
[self setRecentSearches:searches];
@@ -471,7 +470,7 @@ var RECENT_SEARCH_PREFIX = @" ";
- (CPView)hitTest:(CGPoint)aPoint
{
// Make sure a hit anywhere within the search field returns the search field itself
// Make sure a hit anywhere within the search field returns the search field itself
if (_CGRectContainsPoint([self frame], aPoint))
return self;
else
@@ -493,8 +492,8 @@ var RECENT_SEARCH_PREFIX = @" ";
if (_searchMenuTemplate == nil)
[self _sendAction:self];
else
[self _showMenu];
}
[self _showMenu];
}
else if (_CGRectContainsPoint([self cancelButtonRectForBounds:[self bounds]], point))
[_cancelButton mouseDown:anEvent];
else
@@ -504,69 +503,69 @@ var RECENT_SEARCH_PREFIX = @" ";
/*!
Provides the common case items for a recent searches menu. If there are not recent searches,
displays a single disabled item:
No Recent Searches
If there are 1 more recent searches, it displays:
Recent Searches
recent search 1
recent search 2
etc.
---------------------
Clear Recent Searches
If you wish to add items before or after the template, you can. If you put items
before, a separator will automatically be placed before the default template item.
If you add items after the default template, it is your responsibility to add a separator.
To add a custom item:
item = [[CPMenuItem alloc] initWithTitle:@"google"
action:@selector(google:)
item = [[CPMenuItem alloc] initWithTitle:@"google"
action:@selector(google:)
keyEquivalent:@""];
[item setTag:700];
[item setTarget:self];
[template addItem:item];
Be sure that your custom items do not use tags in the range 1000-1004 inclusive.
Be sure that your custom items do not use tags in the range 1000-1003 inclusive.
If you wish to maintain state in custom menu items that you add, you will need to maintain
the item state yourself, then in the action method of the custom items, modify the items
in the search menu template and send [searchField setSearchMenuTemplate:template] to update the menu.
*/
- (CPMenu)defaultSearchMenuTemplate
{
var template = [[CPMenu alloc] init],
var template = [[CPMenu alloc] init],
item;
item = [[CPMenuItem alloc] initWithTitle:@"Recent Searches"
action:nil
item = [[CPMenuItem alloc] initWithTitle:@"Recent Searches"
action:nil
keyEquivalent:@""];
[item setTag:CPSearchFieldRecentsTitleMenuItemTag];
[item setEnabled:NO];
[template addItem:item];
item = [[CPMenuItem alloc] initWithTitle:@"Recent search item"
action:@selector(_searchFieldSearch:)
item = [[CPMenuItem alloc] initWithTitle:@"Recent search item"
action:@selector(_searchFieldSearch:)
keyEquivalent:@""];
[item setTag:CPSearchFieldRecentsMenuItemTag];
[item setTarget:self];
[template addItem:item];
item = [[CPMenuItem alloc] initWithTitle:@"Clear Recent Searches"
action:@selector(_searchFieldClearRecents:)
item = [[CPMenuItem alloc] initWithTitle:@"Clear Recent Searches"
action:@selector(_searchFieldClearRecents:)
keyEquivalent:@""];
[item setTag:CPSearchFieldClearRecentsMenuItemTag];
[item setTarget:self];
[template addItem:item];
item = [[CPMenuItem alloc] initWithTitle:@"No Recent Searches"
action:nil
item = [[CPMenuItem alloc] initWithTitle:@"No Recent Searches"
action:nil
keyEquivalent:@""];
[item setTag:CPSearchFieldNoRecentsMenuItemTag];
[item setEnabled:NO];
[template addItem:item];
return template;
}
@@ -574,72 +573,66 @@ var RECENT_SEARCH_PREFIX = @" ";
{
if (_searchMenuTemplate === nil)
return;
var menu = [[CPMenu alloc] init],
countOfRecents = [_recentSearches count],
numberOfItems = [_searchMenuTemplate numberOfItems];
for (var i = 0; i < numberOfItems; i++)
{
var item = [[_searchMenuTemplate itemAtIndex:i] copy];
switch ([item tag])
{
case CPSearchFieldRecentsTitleMenuItemTag:
if (countOfRecents === 0)
continue;
if ([menu numberOfItems] > 0)
[self _addSeparatorToMenu:menu];
break;
case CPSearchFieldRecentsMenuItemTag:
{
var itemAction = @selector(_searchFieldSearch:);
for (var recentIndex = 0; recentIndex < countOfRecents; ++recentIndex)
{
// RECENT_SEARCH_PREFIX is a hack until CPMenuItem -setIndentationLevel works
var recentItem = [[CPMenuItem alloc] initWithTitle:RECENT_SEARCH_PREFIX + [_recentSearches objectAtIndex:recentIndex]
action:itemAction
var recentItem = [[CPMenuItem alloc] initWithTitle:RECENT_SEARCH_PREFIX + [_recentSearches objectAtIndex:recentIndex]
action:itemAction
keyEquivalent:[item keyEquivalent]];
[item setTarget:self];
[menu addItem:recentItem];
}
continue;
}
case CPSearchFieldClearRecentsMenuItemTag:
if (countOfRecents === 0)
continue;
if ([menu numberOfItems] > 0)
[self _addSeparatorToMenu:menu];
[item setAction:@selector(_searchFieldClearRecents:)];
[item setTarget:self];
break;
case CPSearchFieldNoRecentsMenuItemTag:
if (countOfRecents !== 0)
continue;
if ([menu numberOfItems] > 0)
[self _addSeparatorToMenu:menu];
break;
case CPSearchFieldSeparatorMenuItemTag:
item = [CPMenuItem separatorItem];
[item setEnabled:NO];
[menu addItem:item];
continue;
}
}
[item setEnabled:([item isEnabled] && [item action] != nil && [item target] != nil)];
[menu addItem:item];
}
[menu setDelegate:self];
_searchMenu = menu;
@@ -660,7 +653,7 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)menuDidClose:(CPMenu)menu
{
_canResignFirstResponder = YES;
[self becomeFirstResponder];
}
@@ -668,12 +661,12 @@ var RECENT_SEARCH_PREFIX = @" ";
{
if (_searchMenu === nil || [_searchMenu numberOfItems] === 0 || ![self isEnabled])
return;
var aFrame = [[self superview] convertRect:[self frame] toView:nil],
location = CPMakePoint(aFrame.origin.x + 10, aFrame.origin.y + aFrame.size.height - 4);
var anEvent = [CPEvent mouseEventWithType:CPRightMouseDown location:location modifierFlags:0 timestamp:[[CPApp currentEvent] timestamp] windowNumber:[[self window] windowNumber] context:nil eventNumber:1 clickCount:1 pressure:0];
[self selectAll:nil];
[CPMenu popUpContextMenu:_searchMenu withEvent:anEvent forView:self];
}
@@ -685,7 +678,7 @@ var RECENT_SEARCH_PREFIX = @" ";
}
- (void)_searchFieldCancel:(id)sender
{
{
[self setObjectValue:@""];
[self _sendPartialString];
[self _updateCancelButtonVisibility];
@@ -694,14 +687,14 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)_searchFieldSearch:(id)sender
{
var searchString = [[sender title] substringFromIndex:[RECENT_SEARCH_PREFIX length]];
if ([sender tag] != CPSearchFieldRecentsMenuItemTag)
[self _addStringToRecentSearches:searchString];
[self setObjectValue:searchString];
[self _sendPartialString];
[self selectAll:nil];
[self _updateCancelButtonVisibility];
}
@@ -715,54 +708,36 @@ var RECENT_SEARCH_PREFIX = @" ";
- (void)_registerForAutosaveNotification
{
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateAutosavedRecents:) name:@"CPAutosavedRecentsChangedNotification" object:nil];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateAutosavedRecents:) name:CPAutosavedRecentsChangedNotification object:_recentsAutosaveName];
}
- (void)_deregisterForAutosaveNotification
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:@"CPAutosavedRecentsChangedNotification" object:nil];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPAutosavedRecentsChangedNotification object:_recentsAutosaveName];
}
- (void)_autosaveRecentSearchList
{
if (_recentsAutosaveName != nil)
[[CPNotificationCenter defaultCenter] postNotificationName:@"CPAutosavedRecentsChangedNotification" object:_recentsAutosaveName];
{
if (_recentsAutosaveName != nil)
[[CPNotificationCenter defaultCenter] postNotificationName:CPAutosavedRecentsChangedNotification object:_recentsAutosaveName];
}
- (void)_updateAutosavedRecents:(id)notification
{
var list = [self recentSearches],
name = [notification object],
bundle_name = [[[CPBundle mainBundle] infoDictionary] objectForKey:"CPBundleName"],
cookie_name = [bundle_name lowercaseString] + "." + [notification object],
cookie = [[CPCookie alloc] initWithName:cookie_name],
cookie_value = [list componentsJoinedByString:@","];
[cookie setValue:cookie_value
expires:[[CPDate alloc] initWithTimeIntervalSinceNow:3600*24*365]
domain:(window.location.href.hostname)];
var name = [notification object];
[[CPUserDefaults standardUserDefaults] setObject:_recentSearches forKey:name];
}
- (void)_loadRecentSearchList
{
var list,
name = [self recentsAutosaveName];
var name = [self recentsAutosaveName];
if (name === nil)
return;
var bundle_name = [[[CPBundle mainBundle] infoDictionary] objectForKey:"CPBundleName"],
cookie_name = [bundle_name lowercaseString] + "." + name,
var list = [[CPUserDefaults standardUserDefaults] objectForKey:name];
cookie = [[CPCookie alloc] initWithName:cookie_name];
if (cookie != nil)
{
var cookie_value = [cookie value];
list = (cookie_value != @"") ? [cookie_value componentsSeparatedByString:@","] : [CPArray array];
if (list !== nil)
_recentSearches = list;
}
}
@end
@@ -780,7 +755,7 @@ var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
[_searchButton removeFromSuperview];
[_cancelButton removeFromSuperview];
[super encodeWithCoder:coder];
[super encodeWithCoder:coder];
if (_searchButton)
[self addSubview:_searchButton];
@@ -793,7 +768,7 @@ var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
if (_recentsAutosaveName)
[coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
if (_searchMenuTemplate)
[coder encodeObject:_searchMenuTemplate forKey:CPSearchMenuTemplateKey];
}
@@ -802,16 +777,16 @@ var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
{
if (self = [super initWithCoder:coder])
{
_recentsAutosaveName = [coder decodeObjectForKey:CPRecentsAutosaveNameKey];
[self setRecentsAutosaveName:[coder decodeObjectForKey:CPRecentsAutosaveNameKey]];
_sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
_sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
_maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
if (template)
[self setSearchMenuTemplate:template];
[self _init];
}
+6 -6
View File
@@ -23,8 +23,8 @@
@import <Foundation/CPObject.j>
/*!
@deprecated
/*!
@deprecated
@class CPShadow
Instances of this class contain the attributes of a drop shadow used in Cappuccino.
@@ -34,7 +34,7 @@
CPSize _offset;
float _blurRadius;
CPColor _color;
CPString _cssString;
}
@@ -54,16 +54,16 @@
- (id)_initWithOffset:(CPSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
{
self = [super init];
if (self)
{
_offset = anOffset;
_blurRadius = aBlurRadius;
_color = aColor;
_cssString = [_color cssString] + " " + Math.round(anOffset.width) + @"px " + Math.round(anOffset.height) + @"px " + Math.round(_blurRadius) + @"px";
}
return self;
}
+51 -44
View File
@@ -28,16 +28,16 @@
@ignore
*/
@implementation CPSliderColorPicker : CPColorPicker
{
{
CPView _contentView;
CPSlider _redSlider;
CPSlider _greenSlider;
CPSlider _blueSlider;
CPSlider _hueSlider;
CPSlider _saturationSlider;
CPSlider _brightnessSlider;
CPTextField _rgbLabel;
CPTextField _hsbLabel;
CPTextField _redLabel;
@@ -58,27 +58,27 @@
CPTextField _brightnessValue;
}
- (id)initWithPickerMask:(int)mask colorPanel:(CPColorPanel)owningColorPanel
- (id)initWithPickerMask:(int)mask colorPanel:(CPColorPanel)owningColorPanel
{
return [super initWithPickerMask:mask colorPanel: owningColorPanel];
}
-(id)initView
{
aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
aFrame = CGRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
_contentView = [[CPView alloc] initWithFrame:aFrame];
[_contentView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
_rgbLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 10, 100, 20)];
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
_rgbLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 10, 100, 20)];
[_rgbLabel setStringValue: "Red, Green, Blue"];
[_rgbLabel setTextColor:[CPColor blackColor]];
_redLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 35, 15, 20)];
_redLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 35, 15, 20)];
[_redLabel setStringValue: "R"];
[_redLabel setTextColor:[CPColor blackColor]];
_redSlider = [[CPSlider alloc] initWithFrame: CPRectMake(15, 35, aFrame.size.width - 70, 20)];
_redSlider = [[CPSlider alloc] initWithFrame: CGRectMake(15, 35, aFrame.size.width - 70, 20)];
[_redSlider setMaxValue: 1.0];
[_redSlider setMinValue: 0.0];
[_redSlider setTarget: self];
@@ -93,11 +93,11 @@
[_redValue setDelegate: self];
[_contentView addSubview: _redValue];
_greenLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 58, 15, 20)];
_greenLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 58, 15, 20)];
[_greenLabel setStringValue: "G"];
[_greenLabel setTextColor:[CPColor blackColor]];
_greenSlider = [[CPSlider alloc] initWithFrame: CPRectMake(15, 58, aFrame.size.width - 70, 20)];
_greenSlider = [[CPSlider alloc] initWithFrame: CGRectMake(15, 58, aFrame.size.width - 70, 20)];
[_greenSlider setMaxValue: 1.0];
[_greenSlider setMinValue: 0.0];
[_greenSlider setTarget: self];
@@ -112,11 +112,11 @@
[_greenValue setDelegate: self];
[_contentView addSubview: _greenValue];
_blueLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 81, 15, 20)];
_blueLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 81, 15, 20)];
[_blueLabel setStringValue: "B"];
[_blueLabel setTextColor:[CPColor blackColor]];
_blueSlider = [[CPSlider alloc] initWithFrame: CPRectMake(15, 81, aFrame.size.width - 70, 20)];
_blueSlider = [[CPSlider alloc] initWithFrame: CGRectMake(15, 81, aFrame.size.width - 70, 20)];
[_blueSlider setMaxValue: 1.0];
[_blueSlider setMinValue: 0.0];
[_blueSlider setTarget: self];
@@ -131,15 +131,15 @@
[_blueValue setDelegate: self];
[_contentView addSubview: _blueValue];
_hsbLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 120, 190, 20)];
_hsbLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 120, 190, 20)];
[_hsbLabel setStringValue: "Hue, Saturation, Brightness"];
[_hsbLabel setTextColor:[CPColor blackColor]];
_hueLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 145, 15, 20)];
_hueLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 145, 15, 20)];
[_hueLabel setStringValue: "H"];
[_hueLabel setTextColor:[CPColor blackColor]];
_hueSlider = [[CPSlider alloc] initWithFrame: CPRectMake(15, 145, aFrame.size.width - 70, 20)];
_hueSlider = [[CPSlider alloc] initWithFrame: CGRectMake(15, 145, aFrame.size.width - 70, 20)];
[_hueSlider setMaxValue: 359.0];
[_hueSlider setMinValue: 0.0];
[_hueSlider setTarget: self];
@@ -154,11 +154,11 @@
[_hueValue setDelegate: self];
[_contentView addSubview: _hueValue];
_saturationLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 168, 15, 20)];
_saturationLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 168, 15, 20)];
[_saturationLabel setStringValue: "S"];
[_saturationLabel setTextColor:[CPColor blackColor]];
_saturationSlider = [[CPSlider alloc] initWithFrame: CPRectMake(15, 168, aFrame.size.width - 70, 20)];
_saturationSlider = [[CPSlider alloc] initWithFrame: CGRectMake(15, 168, aFrame.size.width - 70, 20)];
[_saturationSlider setMaxValue: 100.0];
[_saturationSlider setMinValue: 0.0];
[_saturationSlider setTarget: self];
@@ -173,11 +173,11 @@
[_saturationValue setDelegate: self];
[_contentView addSubview: _saturationValue];
_brightnessLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 191, 15, 20)];
_brightnessLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 191, 15, 20)];
[_brightnessLabel setStringValue: "B"];
[_brightnessLabel setTextColor:[CPColor blackColor]];
_brightnessSlider = [[CPSlider alloc] initWithFrame: CPRectMake(15, 191, aFrame.size.width - 70, 20)];
_brightnessSlider = [[CPSlider alloc] initWithFrame: CGRectMake(15, 191, aFrame.size.width - 70, 20)];
[_brightnessSlider setMaxValue: 100.0];
[_brightnessSlider setMinValue: 0.0];
[_brightnessSlider setTarget: self];
@@ -192,7 +192,7 @@
[_brightnessValue setDelegate: self];
[_contentView addSubview: _brightnessValue];
_hexLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 230, 30, 20)];
_hexLabel = [[CPTextField alloc] initWithFrame: CGRectMake(0, 230, 30, 20)];
[_hexLabel setStringValue: "Hex"];
[_hexLabel setTextColor:[CPColor blackColor]];
@@ -210,7 +210,7 @@
[_contentView addSubview: _redSlider];
[_contentView addSubview: _greenSlider];
[_contentView addSubview: _blueSlider];
[_contentView addSubview: _hsbLabel];
[_contentView addSubview: _hueLabel];
[_contentView addSubview: _saturationLabel];
@@ -218,24 +218,24 @@
[_contentView addSubview: _hueSlider];
[_contentView addSubview: _saturationSlider];
[_contentView addSubview: _brightnessSlider];
[_contentView addSubview: _hexLabel];
}
- (CPView)provideNewView:(BOOL)initialRequest
- (CPView)provideNewView:(BOOL)initialRequest
{
if (initialRequest)
if (initialRequest)
[self initView];
return _contentView;
}
- (int)currentMode
- (int)currentMode
{
return CPSliderColorPickerMode;
}
- (BOOL)supportsMode:(int)mode
- (BOOL)supportsMode:(int)mode
{
return (mode == CPSliderColorPickerMode) ? YES : NO;
}
@@ -246,7 +246,7 @@
colorPanel = [self colorPanel],
alpha = [colorPanel opacity];
switch(sender)
switch (sender)
{
case _hueSlider:
case _saturationSlider:
@@ -254,21 +254,21 @@
saturation: [_saturationSlider floatValue]
brightness: [_brightnessSlider floatValue]
alpha: alpha];
[self updateRGBSliders: newColor];
break;
case _redSlider:
case _greenSlider:
case _blueSlider: newColor = [CPColor colorWithCalibratedRed: [_redSlider floatValue]
green: [_greenSlider floatValue]
blue: [_blueSlider floatValue]
alpha: alpha];
[self updateHSBSliders: newColor];
break;
}
[self updateLabels];
[self updateHex: newColor];
[colorPanel setColor: newColor];
@@ -285,7 +285,7 @@
-(void)updateHSBSliders:(CPColor)aColor
{
var hsb = [aColor hsbComponents];
[_hueSlider setFloatValue:hsb[0]];
[_saturationSlider setFloatValue:hsb[1]];
[_brightnessSlider setFloatValue:hsb[2]];
@@ -310,7 +310,7 @@
[_hueValue setStringValue: ROUND([_hueSlider floatValue])];
[_saturationValue setStringValue: ROUND([_saturationSlider floatValue])];
[_brightnessValue setStringValue: ROUND([_brightnessSlider floatValue])];
[_redValue setStringValue: ROUND([_redSlider floatValue] * 255)];
[_greenValue setStringValue: ROUND([_greenSlider floatValue] * 255)];
[_blueValue setStringValue: ROUND([_blueSlider floatValue] * 255)];
@@ -330,14 +330,21 @@
{
var field = [aNotification object],
value = [[field stringValue] stringByTrimmingWhitespace];
if (field === _hexValue) {
if (field === _hexValue)
{
var newColor = [CPColor colorWithHexString: value];
if (newColor) {
if (newColor)
{
[self setColor: newColor];
[[self colorPanel] setColor: newColor];
}
} else {
switch(field) {
}
else
{
switch (field)
{
case _redValue: [_redSlider setFloatValue:MAX(MIN(ROUND(value), 255) / 255.0, 0)];
[self sliderChanged: _redSlider];
break;
+18 -16
View File
@@ -37,7 +37,7 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
int _increment @accessors(property=increment);
int _maxValue @accessors(property=maxValue);
int _minValue @accessors(property=minValue);
_CPContinuousButton _buttonDown;
_CPContinuousButton _buttonUp;
}
@@ -57,11 +57,11 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
[stepper setDoubleValue:aValue];
[stepper setMinValue:aMinValue];
[stepper setMaxValue:aMaxValue];
return stepper;
}
/*! Initializes a CPStepper with default values:
/*! Initializes a CPStepper with default values:
- minValue = 0.0
- maxValue = 59.0
- value = 0.0
@@ -84,23 +84,23 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
_minValue = 0.0;
_increment = 1.0;
_valueWraps = YES;
[self setDoubleValue:0.0];
_buttonUp = [[_CPContinuousButton alloc] initWithFrame:CPRectMake(aFrame.size.width - CPStepperButtonsSize.width, 0, CPStepperButtonsSize.width, CPStepperButtonsSize.height)];
[_buttonUp setContinuous:YES];
[_buttonUp setTarget:self];
[_buttonUp setAction:@selector(_buttonDidClick:)];
[_buttonUp setAutoresizingMask:CPViewNotSizable];
[self addSubview:_buttonUp];
_buttonDown = [[_CPContinuousButton alloc] initWithFrame:CPRectMake(aFrame.size.width - CPStepperButtonsSize.width, CPStepperButtonsSize.height, CPStepperButtonsSize.width, CPStepperButtonsSize.height - 1)];
[_buttonDown setContinuous:YES];
[_buttonDown setTarget:self];
[_buttonDown setAction:@selector(_buttonDidClick:)];
[_buttonDown setAutoresizingMask:CPViewNotSizable];
[self addSubview:_buttonDown];
[self setNeedsLayout];
}
@@ -139,7 +139,7 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
[_buttonUp setValue:[self valueForThemeAttribute:@"bezel-color-up-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateDisabled] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateDisabled];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
[_buttonDown setValue:[self valueForThemeAttribute:@"bezel-color-down-button" inState:CPThemeStateBordered | CPThemeStateHighlighted] forThemeAttribute:@"bezel-color" inState:CPThemeStateBordered | CPThemeStateHighlighted];
}
/*! set if CPStepper should autorepeat
@@ -235,7 +235,7 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_maxValue forKey:@"_maxValue"];
[aCoder encodeObject:_minValue forKey:@"_minValue"];
[aCoder encodeObject:_increment forKey:@"_increment"];
@@ -264,7 +264,7 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
_periodicInterval = 0.05;
_periodicDelay = 0.5;
}
return self;
}
@@ -278,13 +278,15 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
{
if ([self isContinuous])
{
_continuousDelayTimer = [CPTimer scheduledTimerWithTimeInterval:_periodicDelay callback: function(){
_continuousDelayTimer = [CPTimer scheduledTimerWithTimeInterval:_periodicDelay callback: function()
{
if (!_continuousTimer)
_continuousTimer = [CPTimer scheduledTimerWithTimeInterval:_periodicInterval target:self selector:@selector(onContinousEvent:) userInfo:anEvent repeats:YES];
}
}
repeats:NO];
}
[super mouseDown:anEvent];
}
@@ -304,10 +306,10 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
{
if (_continuousTimer)
{
[_continuousTimer invalidate];
[_continuousTimer invalidate];
_continuousTimer = nil;
}
if (_continuousDelayTimer)
{
[_continuousDelayTimer invalidate];
@@ -334,7 +336,7 @@ var CPStepperButtonsSize = CPSizeMake(19, 13);
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[self invalidateTimers];
[aCoder encodeObject:_periodicDelay forKey:@"_periodicDelay"];
[aCoder encodeObject:_periodicInterval forKey:@"_periodicInterval"];
+9 -9
View File
@@ -44,7 +44,7 @@ CPBackgroundTab = 1;
*/
CPPressedTab = 2;
/*!
/*!
@ingroup appkit
@class CPTabViewItem
@@ -55,10 +55,10 @@ CPPressedTab = 2;
{
id _identifier;
CPString _label;
CPView _view;
CPView _auxiliaryView;
CPTabView _tabView;
}
@@ -74,10 +74,10 @@ CPPressedTab = 2;
- (id)initWithIdentifier:(id)anIdentifier
{
self = [super init];
if (self)
_identifier = anIdentifier;
return self;
}
@@ -191,16 +191,16 @@ var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_identifier = [aCoder decodeObjectForKey:CPTabViewItemIdentifierKey];
_label = [aCoder decodeObjectForKey:CPTabViewItemLabelKey];
_view = [aCoder decodeObjectForKey:CPTabViewItemViewKey];
_auxiliaryView = [aCoder decodeObjectForKey:CPTabViewItemAuxViewKey];
}
return self;
}
@@ -208,7 +208,7 @@ var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
{
[aCoder encodeObject:_identifier forKey:CPTabViewItemIdentifierKey];
[aCoder encodeObject:_label forKey:CPTabViewItemLabelKey];
[aCoder encodeObject:_view forKey:CPTabViewItemViewKey];
[aCoder encodeObject:_auxiliaryView forKey:CPTabViewItemAuxViewKey];
}
+11 -11
View File
@@ -56,7 +56,7 @@
{
_textField = [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
[_textField setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[_textField setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_textField setLineBreakMode:CPLineBreakByTruncatingTail];
[_textField setAlignment:CPLeftTextAlignment];
@@ -107,15 +107,15 @@
- (void)_setIndicatorImage:(CPImage)anImage
{
if (anImage)
{
[_textField setImage:anImage];
[_textField setImagePosition:CPImageRight];
}
else
{
[_textField setImagePosition:CPNoImage];
}
if (anImage)
{
[_textField setImage:anImage];
[_textField setImagePosition:CPImageRight];
}
else
{
[_textField setImagePosition:CPNoImage];
}
}
@end
@@ -634,7 +634,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
columnMaxX;
CGContextBeginPath(context);
for(; columnArrayIndex < columnArrayCount; columnArrayIndex++)
for (; columnArrayIndex < columnArrayCount; columnArrayIndex++)
{
// grab each column rect and add vertical lines
var columnIndex = columnsArray[columnArrayIndex],
+34 -35
View File
@@ -1318,7 +1318,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/
- (CGRect)rectOfRow:(CPInteger)aRowIndex
{
if(aRowIndex > [self numberOfRows] - 1 || aRowIndex < 0)
if (aRowIndex > [self numberOfRows] - 1 || aRowIndex < 0)
return _CGRectMakeZero();
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_heightOfRow_)
@@ -1331,7 +1331,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
var y = aRowIndex * (_rowHeight + _intercellSpacing.height),
height = _rowHeight + _intercellSpacing.height;
}
return _CGRectMake(0.0, y, _CGRectGetWidth([self bounds]), height);
}
@@ -1457,13 +1456,13 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
return idx = [_cachedRowHeights indexOfObject:aPoint sortedByFunction:function(aPoint, rowCache) {
var upperBound = rowCache.heightAboveRow;
if (aPoint.y < upperBound)
return CPOrderedAscending;
if (aPoint.y < upperBound)
return CPOrderedAscending;
if (aPoint.y > upperBound + rowCache.height)
return CPOrderedDescending;
if (aPoint.y > upperBound + rowCache.height)
return CPOrderedDescending;
return CPOrderedSame;
return CPOrderedSame;
}];
}
@@ -1723,7 +1722,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (!(_implementedDelegateMethods & CPTableViewDelegate_tableView_heightOfRow_))
return;
// this method will update the height of those rows, but since the cached array also contains
// this method will update the height of those rows, but since the cached array also contains
// the height above the row it needs to recalculate for the rows below it too
var i = [anIndexSet firstIndex],
count = _numberOfRows - i,
@@ -1766,7 +1765,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if ([self numberOfRows] !== _cachedRowHeights.length)
[self noteHeightOfRowsWithIndexesChanged:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self numberOfRows])]];
var heightObject = _cachedRowHeights[_cachedRowHeights.length -1],
var heightObject = _cachedRowHeights[_cachedRowHeights.length - 1],
height = heightObject.heightAboveRow + heightObject.height + _intercellSpacing.height;
}
@@ -2042,7 +2041,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/
- (BOOL)_sendDelegateDeleteKeyPressed
{
if([_delegate respondsToSelector: @selector(tableViewDeleteKeyPressed:)])
if ([_delegate respondsToSelector: @selector(tableViewDeleteKeyPressed:)])
{
[_delegate tableViewDeleteKeyPressed:self];
return YES;
@@ -2568,7 +2567,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_isGroupRow_)
{
if([_delegate tableView:self isGroupRow:row])
if ([_delegate tableView:self isGroupRow:row])
{
[_groupRows addIndex:row];
[dataView setThemeState:CPThemeStateGroupRow];
@@ -2738,8 +2737,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
groupRowRects = [],
row = exposedRows.location;
//loop through each color so we only draw once for each color
while(colorIndex < colorCount)
//loop through each color so we only draw once for each color
while (colorIndex < colorCount)
{
CGContextBeginPath(context);
for (var row = colorIndex; row < lastRow; row += colorCount)
@@ -3521,7 +3520,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/
- (void)draggedImage:(CPImage)anImage endedAt:(CGPoint)aLocation operation:(CPDragOperation)anOperation
{
if([_dataSource respondsToSelector:@selector(tableView:didEndDraggedImage:atPosition:operation:)])
if ([_dataSource respondsToSelector:@selector(tableView:didEndDraggedImage:atPosition:operation:)])
[_dataSource tableView:self didEndDraggedImage:anImage atPosition:aLocation operation:anOperation];
}
@@ -3538,7 +3537,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
- (void)_updateSelectionWithMouseAtRow:(CPInteger)aRow
{
//check to make sure the row exists
if(aRow < 0)
if (aRow < 0)
return;
var newSelection,
@@ -3683,43 +3682,43 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
![_delegate selectionShouldChangeInTableView:self])
return;
if([[self selectedRowIndexes] count] > 0)
if ([[self selectedRowIndexes] count] > 0)
{
var extend = NO;
if(([theEvent modifierFlags] & CPShiftKeyMask) && _allowsMultipleSelection)
if (([theEvent modifierFlags] & CPShiftKeyMask) && _allowsMultipleSelection)
extend = YES;
var i = [[self selectedRowIndexes] lastIndex];
if(i<[self numberOfRows] - 1)
if (i < [self numberOfRows] - 1)
i++; //set index to the next row after the last row selected
}
else
{
var extend = NO;
//no rows are currently selected
if([self numberOfRows] > 0)
if ([self numberOfRows] > 0)
var i = 0; //select the first row
}
if(_implementedDelegateMethods & CPTableViewDelegate_tableView_shouldSelectRow_)
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_shouldSelectRow_)
{
while((![_delegate tableView:self shouldSelectRow:i]) && i<[self numberOfRows])
while ((![_delegate tableView:self shouldSelectRow:i]) && i < [self numberOfRows])
{
//check to see if the row can be selected if it can't be then see if the next row can be selected
i++;
}
//if the index still can be selected after the loop then just return
if(![_delegate tableView:self shouldSelectRow:i])
if (![_delegate tableView:self shouldSelectRow:i])
return;
}
[self selectRowIndexes:[CPIndexSet indexSetWithIndex:i] byExtendingSelection:extend];
if(i >= 0)
if (i >= 0)
[self scrollRowToVisible:i];
}
@@ -3729,43 +3728,43 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
![_delegate selectionShouldChangeInTableView:self])
return;
if([[self selectedRowIndexes] count] > 0)
if ([[self selectedRowIndexes] count] > 0)
{
var extend = NO;
if(([theEvent modifierFlags] & CPShiftKeyMask) && _allowsMultipleSelection)
if (([theEvent modifierFlags] & CPShiftKeyMask) && _allowsMultipleSelection)
extend = YES;
var i = [[self selectedRowIndexes] firstIndex];
if(i > 0)
if (i > 0)
i--; //set index to the prev row before the first row selected
}
else
{
var extend = NO;
//no rows are currently selected
if([self numberOfRows] > 0)
if ([self numberOfRows] > 0)
var i = [self numberOfRows] - 1; //select the first row
}
if(_implementedDelegateMethods & CPTableViewDelegate_tableView_shouldSelectRow_)
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_shouldSelectRow_)
{
while((![_delegate tableView:self shouldSelectRow:i]) && i > 0)
while ((![_delegate tableView:self shouldSelectRow:i]) && i > 0)
{
//check to see if the row can be selected if it can't be then see if the prev row can be selected
i--;
}
//if the index still can be selected after the loop then just return
if(![_delegate tableView:self shouldSelectRow:i])
if (![_delegate tableView:self shouldSelectRow:i])
return;
}
[self selectRowIndexes:[CPIndexSet indexSetWithIndex:i] byExtendingSelection:extend];
if(i >= 0)
if (i >= 0)
[self scrollRowToVisible:i];
}
@@ -3919,7 +3918,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
var firstindex = [self firstIndex];
var index = MIN(firstindex, [otherSet firstIndex]);
var switchFlag = (index == firstindex);
while(index != CPNotFound)
while (index != CPNotFound)
{
var indexSet = (switchFlag) ? otherSet : self;
otherIndex = [indexSet indexGreaterThanOrEqualToIndex:index];
@@ -3945,7 +3944,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
- (void)drawRect:(CGRect)aRect
{
if(tableView._destinationDragStyle === CPTableViewDraggingDestinationFeedbackStyleNone || isBlinking)
if (tableView._destinationDragStyle === CPTableViewDraggingDestinationFeedbackStyleNone || isBlinking)
return;
var context = [[CPGraphicsContext currentContext] graphicsPort];
@@ -3964,7 +3963,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
var selectedRows = [tableView selectedRowIndexes],
newRect = _CGRectMake(aRect.origin.x + 2, aRect.origin.y + 2, aRect.size.width - 4, aRect.size.height - 5);
if([selectedRows containsIndex:currentRow])
if ([selectedRows containsIndex:currentRow])
{
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColor(context, [CPColor whiteColor]);
@@ -3984,7 +3983,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
var selectedRows = [tableView selectedRowIndexes];
if([selectedRows containsIndex:currentRow - 1] || [selectedRows containsIndex:currentRow])
if ([selectedRows containsIndex:currentRow - 1] || [selectedRows containsIndex:currentRow])
{
CGContextSetStrokeColor(context, [CPColor whiteColor]);
CGContextSetLineWidth(context, 4);
+1 -1
View File
@@ -667,7 +667,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
// Determine all the items that have flexible width.
// Also determine the height of the toolbar.
var count = _visibleItems.length
var count = _visibleItems.length,
flexibleItemIndexes = [CPIndexSet indexSet];
while (count--)
+36 -36
View File
@@ -40,7 +40,7 @@ CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItem";
CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItem";
CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
/*!
/*!
@ingroup appkit
@class CPToolbarItem
@@ -49,9 +49,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
@implementation CPToolbarItem : CPObject
{
CPString _itemIdentifier;
CPToolbar _toolbar;
CPString _label;
CPString _paletteLabel;
CPString _toolTip;
@@ -61,12 +61,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
BOOL _isEnabled;
CPImage _image;
CPImage _alternateImage;
CPView _view;
CGSize _minSize;
CGSize _maxSize;
CGSize _maxSize;
int _visibilityPriority;
BOOL _autovalidates;
@@ -86,21 +86,21 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
- (id)initWithItemIdentifier:(CPString)anItemIdentifier
{
self = [super init];
if (self)
{
_itemIdentifier = anItemIdentifier;
_tag = 0;
_isEnabled = YES;
_minSize = CGSizeMakeZero();
_maxSize = CGSizeMakeZero();
_visibilityPriority = CPToolbarItemVisibilityPriorityStandard;
_autovalidates = YES;
}
return self;
}
@@ -170,7 +170,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(toolTip)])
return [_view toolTip];
return _toolTip;
}
@@ -182,7 +182,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(setToolTip:)])
[_view setToolTip:aToolTip];
_toolTip = aToolTip;
}
@@ -193,7 +193,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(tag)])
return [_view tag];
return _tag;
}
@@ -205,7 +205,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(setTag:)])
[_view setTag:aTag];
_tag = aTag;
}
@@ -216,12 +216,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if (_view)
return [_view respondsToSelector:@selector(target)] ? [_view target] : nil;
return _target;
}
/*!
Sets the target of the action that is triggered when the user clicks this item. \c nil will cause
Sets the target of the action that is triggered when the user clicks this item. \c nil will cause
the action to be passed on to the first responder.
@param aTarget the new target
*/
@@ -229,7 +229,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if (!_view)
_target = aTarget;
else if ([_view respondsToSelector:@selector(setTarget:)])
[_view setTarget:aTarget];
}
@@ -241,7 +241,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if (_view)
return [_view respondsToSelector:@selector(action)] ? [_view action] : nil;
return _action;
}
@@ -265,7 +265,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(isEnabled)])
return [_view isEnabled];
return _isEnabled;
}
@@ -277,7 +277,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(setEnabled:)])
[_view setEnabled:shouldBeEnabled];
_isEnabled = shouldBeEnabled;
}
@@ -288,7 +288,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(image)])
return [_view image];
return _image;
}
@@ -302,11 +302,11 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
[_view setImage:anImage];
_image = anImage;
if (!_image)
return;
if (_minSize.width === 0 && _minSize.height === 0 &&
if (_minSize.width === 0 && _minSize.height === 0 &&
_maxSize.width === 0 && _maxSize.height === 0)
{
var imageSize = [_image size];
@@ -327,7 +327,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(setAlternateImage:)])
[_view setAlternateImage:anImage];
_alternateImage = anImage;
}
@@ -338,7 +338,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if ([_view respondsToSelector:@selector(alternateIamge)])
return [_view alternateImage];
return _alternateImage;
}
@@ -358,7 +358,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
{
if (_view == aView)
return;
_view = aView;
if (_view)
@@ -366,7 +366,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
// Tags get forwarded.
if (_tag !== 0 && [_view respondsToSelector:@selector(setTag:)])
[_view setTag:_tag];
_target = nil;
_action = nil;
}
@@ -386,11 +386,11 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
*/
- (void)setMinSize:(CGSize)aMinSize
{
if(!aMinSize.height || !aMinSize.width)
if (!aMinSize.height || !aMinSize.width)
return;
_minSize = CGSizeMakeCopy(aMinSize);
// Try to provide some sanity: Make maxSize >= minSize
_maxSize = CGSizeMake(MAX(_minSize.width, _maxSize.width), MAX(_minSize.height, _maxSize.height));
}
@@ -409,11 +409,11 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem";
*/
- (void)setMaxSize:(CGSize)aMaxSize
{
if(!aMaxSize.height || !aMaxSize.width)
if (!aMaxSize.height || !aMaxSize.width)
return;
_maxSize = CGSizeMakeCopy(aMaxSize);
// Try to provide some sanity: Make minSize <= maxSize
_minSize = CGSizeMake(MIN(_minSize.width, _maxSize.width), MIN(_minSize.height, _maxSize.height));
}
@@ -623,7 +623,7 @@ var CPToolbarItemItemIdentifierKey = @"CPToolbarItemItemIdentifierKey",
case CPToolbarCustomizeToolbarItemIdentifier: return nil;
case CPToolbarPrintItemIdentifier: return nil;
}
return nil;
}
+6 -6
View File
@@ -23,13 +23,13 @@
@import "CPAnimation.j"
CPViewAnimationTargetKey = @"CPViewAnimationTarget";
CPViewAnimationStartFrameKey = @"CPViewAnimationStartFrame";
CPViewAnimationEndFrameKey = @"CPViewAnimationEndFrame";
CPViewAnimationEffectKey = @"CPViewAnimationEffect";
CPViewAnimationTargetKey = @"CPViewAnimationTargetKey";
CPViewAnimationStartFrameKey = @"CPViewAnimationStartFrameKey";
CPViewAnimationEndFrameKey = @"CPViewAnimationEndFrameKey";
CPViewAnimationEffectKey = @"CPViewAnimationEffectKey";
CPViewAnimationFadeInEffect = @"CPViewAnimationFadeIn";
CPViewAnimationFadeOutEffect = @"CPViewAnimationFadeOut";
CPViewAnimationFadeInEffect = @"CPViewAnimationFadeInEffect";
CPViewAnimationFadeOutEffect = @"CPViewAnimationFadeOutEffect";
@implementation CPViewAnimation : CPAnimation
{
+24 -25
View File
@@ -107,7 +107,7 @@ CPWebViewScrollNative = 2;
_ignoreLoadEnd = YES;
_iframe = document.createElement("iframe");
_iframe.name = "iframe_" + Math.floor(Math.random()*10000);
_iframe.name = "iframe_" + FLOOR(RAND() * 10000);
_iframe.style.width = "100%";
_iframe.style.height = "100%";
_iframe.style.borderWidth = "0px";
@@ -116,47 +116,46 @@ CPWebViewScrollNative = 2;
[self setDrawsBackground:YES];
_loadCallback = function() {
// HACK: this block handles the case where we don't know about loads initiated by the user clicking a link
if (!_ignoreLoadStart)
{
// post the start load notification
[self _startedLoading];
// HACK: this block handles the case where we don't know about loads initiated by the user clicking a link
if (!_ignoreLoadStart)
{
// post the start load notification
[self _startedLoading];
if (_mainFrameURL)
[_backwardStack addObject:_mainFrameURL];
if (_mainFrameURL)
[_backwardStack addObject:_mainFrameURL];
// FIXME: this doesn't actually get the right URL for different domains. Not possible due to browser security restrictions.
// FIXME: this doesn't actually get the right URL for different domains. Not possible due to browser security restrictions.
_mainFrameURL = _iframe.src;
_mainFrameURL = _iframe.src;
// clear the forward
[_forwardStack removeAllObjects];
}
else
[_forwardStack removeAllObjects];
}
else
_ignoreLoadStart = NO;
if (!_ignoreLoadEnd)
{
if (!_ignoreLoadEnd)
{
[self _finishedLoading];
}
else
_ignoreLoadEnd = NO;
}
else
_ignoreLoadEnd = NO;
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
if (_iframe.addEventListener)
_iframe.addEventListener("load", _loadCallback, false);
else if (_iframe.attachEvent)
_iframe.attachEvent("onload", _loadCallback);
}
if (_iframe.addEventListener)
_iframe.addEventListener("load", _loadCallback, false);
else if (_iframe.attachEvent)
_iframe.attachEvent("onload", _loadCallback);
_frameView = [[CPView alloc] initWithFrame:[self bounds]];
[_frameView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[_frameView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
_scrollView = [[CPScrollView alloc] initWithFrame:[self bounds]];
[_scrollView setAutohidesScrollers:YES];
[_scrollView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
[_scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_scrollView setDocumentView:_frameView];
_frameView._DOMElement.appendChild(_iframe);
+5 -5
View File
@@ -28,7 +28,7 @@
@import "CPDocument.j"
/*!
/*!
@ingroup appkit
@class CPWindowController
@@ -171,8 +171,8 @@
if (_window === nil && [_cibOwner isKindOfClass:[CPDocument class]])
[self setWindow:[_cibOwner valueForKey:@"window"]];
if (!_window)
if (!_window)
{
var reason = [CPString stringWithFormat:@"Window for %@ could not be loaded from Cib or no window specified. \
Override loadWindow to load the window manually.", self];
@@ -232,7 +232,7 @@
{
if (![self supportsMultipleDocuments])
[self removeDocument:_document];
[defaultCenter removeObserver:self
name:CPDocumentWillSaveNotification
object:_document];
@@ -381,7 +381,7 @@
}
/*!
Sets whether the document has unsaved changes. The window can use this as a hint to
Sets whether the document has unsaved changes. The window can use this as a hint to
@param isEdited \c YES means the document has unsaved changes.
*/
- (void)setDocumentEdited:(BOOL)isEdited
+2 -2
View File
@@ -34,7 +34,7 @@ var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
if (self)
_className = [aCoder decodeObjectForKey:_CPCibCustomObjectClassName];
return self;
}
@@ -65,7 +65,7 @@ var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
if (theClass === [CPApplication class])
return [CPApplication sharedApplication];
return [[theClass alloc] init];
}
+2 -2
View File
@@ -152,14 +152,14 @@ function CPDecimalMakeWithString(string, locale)
{
if (i >= CPDecimalMaxDigits)
break; // truncate
[m addObject:parseInt(intpart[i])];
[m addObject:parseInt(intpart.charAt(i))];
}
var j = 0;
for (; j < (decpart?decpart.length:0); j++)
{
if ((i + j) >= CPDecimalMaxDigits)
break; // truncate
[m addObject:parseInt(decpart[j])];
[m addObject:parseInt(decpart.charAt(j))];
}
var dcm = {_exponent:exponent, _isNegative:isNegative, _isCompact:NO, _isNaN:NO, _mantissa:m};
+162 -157
View File
@@ -8,9 +8,9 @@ var sharedObject = [CPObject new];
- (CPAttributedString)stringForTesting
{
var string = [[CPAttributedString alloc] initWithString:"The quick brown fox jumped over the lazy dog."];
string._rangeEntries = [];
string._rangeEntries.push({
range:CPMakeRange(0, 9),
attributes:[CPDictionary dictionaryWithObjects:[1, "bar", sharedObject, 20] forKeys:["a", "b", "c", "d"]]
@@ -27,7 +27,7 @@ var sharedObject = [CPObject new];
range:CPMakeRange(32, 13),
attributes:[CPDictionary dictionaryWithObjects:[37, "baz", 1, 20, 55, 43] forKeys:["a", "b", "c", "d", "e", "f"]]
});
return string;
}
@@ -35,7 +35,7 @@ var sharedObject = [CPObject new];
{
var string = [[CPAttributedString alloc] initWithString:@"hi there"];
[self assertTrue:([string string] === @"hi there")
[self assertTrue:([string string] === @"hi there")
message:"testInitWithString: expected:" + @"hi there" + " actual:" + [string string]];
}
- (void)testInitWithAttributedString
@@ -43,13 +43,13 @@ var sharedObject = [CPObject new];
var string = [[CPAttributedString alloc] initWithString:@"hi there"],
attributedString = [[CPAttributedString alloc] initWithAttributedString:string];
[self assertTrue:([string isEqualToAttributedString:attributedString])
[self assertTrue:([string isEqualToAttributedString:attributedString])
message:"testInitWithAttributedString: expected:" + string + " actual:" + attributedString];
//TODO add a case where we init with a string that actually adds attributes
string = [[CPAttributedString alloc] initWithAttributedString:[self stringForTesting]];
[self assertTrue:([string isEqualToAttributedString:[self stringForTesting]])
[self assertTrue:([string isEqualToAttributedString:[self stringForTesting]])
message:"testInitWithAttributedString: expected:" + [self stringForTesting] + " actual:" + string];
}
@@ -57,15 +57,15 @@ var sharedObject = [CPObject new];
{
var string = [[CPAttributedString alloc] initWithString:@"hi there" attributes:[CPDictionary dictionary]];
[self assertTrue:([string string] === @"hi there")
[self assertTrue:([string string] === @"hi there")
message:"testIinitWithString_attributes: expected:" + @"hi there" + " actual:" + [string string]];
var string = [[CPAttributedString alloc] initWithString:@"hi there" attributes:[CPDictionary dictionaryWithObjects:[1, "bar"] forKeys:["number", "foo"]]];
[self assertTrue:([[string attributesAtIndex:0 effectiveRange:nil] objectForKey:@"number"] === 1)
[self assertTrue:([[string attributesAtIndex:0 effectiveRange:nil] objectForKey:@"number"] === 1)
message:"testIinitWithString_attributes: value for key 'number' expected:" + 1 + " actual:" + [[string attributesAtIndex:0 effectiveRange:nil] objectForKey:@"number"]];
[self assertTrue:([[string attributesAtIndex:0 effectiveRange:nil] objectForKey:@"foo"] === "bar")
[self assertTrue:([[string attributesAtIndex:0 effectiveRange:nil] objectForKey:@"foo"] === "bar")
message:"testIinitWithString_attributes: value for key 'foo' expected:" + "bar" + " actual:" + [[string attributesAtIndex:0 effectiveRange:nil] objectForKey:@"foo"]];
}
@@ -74,7 +74,7 @@ var sharedObject = [CPObject new];
{
var string = [[CPAttributedString alloc] initWithString:@"hi there"];
[self assertTrue:([string string] === string._string)
[self assertTrue:([string string] === string._string)
message:"testString: expected:" + @"hi there" + " actual:" + [string string]];
}
@@ -82,25 +82,25 @@ var sharedObject = [CPObject new];
{
var string = [[CPAttributedString alloc] initWithString:@"hi there"];
[self assertTrue:([string length] === 8)
[self assertTrue:([string length] === 8)
message:"testLength: expected:" + 8 + " actual:" + [string length]];
[self assertTrue:([[self stringForTesting] length] === 45)
[self assertTrue:([[self stringForTesting] length] === 45)
message:"testLength: expected:" + 45 + " actual:" + [[self stringForTesting] length]];
}
- (void)test_indexOfEntryWithIndex
{
var string = [self stringForTesting];
[self assertTrue:[string _indexOfEntryWithIndex:0]===0 message:@"expecting index 0, was:"+[string _indexOfEntryWithIndex:0]];
[self assertTrue:[string _indexOfEntryWithIndex:10]===1 message:@"expecting index 1, was:"+[string _indexOfEntryWithIndex:10]];
[self assertTrue:[string _indexOfEntryWithIndex:30]===2 message:@"expecting index 2, was:"+[string _indexOfEntryWithIndex:30]];
[self assertTrue:[string _indexOfEntryWithIndex:35]===3 message:@"expecting index 3, was:"+[string _indexOfEntryWithIndex:35]];
[self assertTrue:[string _indexOfEntryWithIndex:8]===0 message:@"expecting index 0, was:"+[string _indexOfEntryWithIndex:8]];
[self assertTrue:[string _indexOfEntryWithIndex:9]===1 message:@"expecting index 1, was:"+[string _indexOfEntryWithIndex:9]];
[self assertTrue:[string _indexOfEntryWithIndex:20]===2 message:@"expecting index 2, was:"+[string _indexOfEntryWithIndex:20]];
[self assertTrue:[string _indexOfEntryWithIndex:32]===3 message:@"expecting index 3, was:"+[string _indexOfEntryWithIndex:32]];
[self assertTrue:[string _indexOfEntryWithIndex:0] === 0 message:@"expecting index 0, was:" + [string _indexOfEntryWithIndex:0]];
[self assertTrue:[string _indexOfEntryWithIndex:10] === 1 message:@"expecting index 1, was:" + [string _indexOfEntryWithIndex:10]];
[self assertTrue:[string _indexOfEntryWithIndex:30] === 2 message:@"expecting index 2, was:" + [string _indexOfEntryWithIndex:30]];
[self assertTrue:[string _indexOfEntryWithIndex:35] === 3 message:@"expecting index 3, was:" + [string _indexOfEntryWithIndex:35]];
[self assertTrue:[string _indexOfEntryWithIndex:8] === 0 message:@"expecting index 0, was:" + [string _indexOfEntryWithIndex:8]];
[self assertTrue:[string _indexOfEntryWithIndex:9] === 1 message:@"expecting index 1, was:" + [string _indexOfEntryWithIndex:9]];
[self assertTrue:[string _indexOfEntryWithIndex:20] === 2 message:@"expecting index 2, was:" + [string _indexOfEntryWithIndex:20]];
[self assertTrue:[string _indexOfEntryWithIndex:32] === 3 message:@"expecting index 3, was:" + [string _indexOfEntryWithIndex:32]];
}
//Retrieving Attribute Information
@@ -108,7 +108,7 @@ var sharedObject = [CPObject new];
{
var string = [self stringForTesting],
expectedValues = {a:1, b:"bar", c:sharedObject, d:20};
testAttributesAtIndexWithValues(string, 1, expectedValues, self);
expectedValues = {a:37, b:"baz", f:43}
@@ -118,28 +118,28 @@ var sharedObject = [CPObject new];
//- (CPDictionary)attributesAtIndex:(unsigned)anIndex longestEffectiveRange:(CPRangePointer)aRange inRange:(CPRange)rangeLimit
- (void)testAttributesAtIndexLongestEffectiveRangeInRange
{
{
var string = [self stringForTesting];
string._rangeEntries[3].range.length = 10;
string._rangeEntries.push({range:CPMakeRange(42, 3), attributes:[string._rangeEntries[3].attributes copy]});
var range = CPMakeRange(0, 0),
attributes = [string attributesAtIndex:35 longestEffectiveRange:range inRange:CPMakeRange(0, 43)];
[self assertTrue:CPMaxRange(range)==43 message:@"expecting attributes to be valuable at range 43, was: "+CPMaxRange(range)];
[self assertTrue:range.location==32 message:@"expecting attributes to be valuable at range 32, was: "+range.location];
[self assertTrue:[attributes objectForKey:"a"]===37 message:@"expecting 'a' to be '1', was: "+[attributes objectForKey:"a"]];
[self assertTrue:[attributes objectForKey:"b"]==="baz" message:@"expecting 'b' to be 'baz', was: "+[attributes objectForKey:"b"]];
[self assertTrue:[attributes objectForKey:"f"]===43 message:@"expecting 'f' to be 43, was: "+[attributes objectForKey:"f"]];
[self assertTrue:CPMaxRange(range) == 43 message:@"expecting attributes to be valuable at range 43, was: " + CPMaxRange(range)];
[self assertTrue:range.location == 32 message:@"expecting attributes to be valuable at range 32, was: " + range.location];
[self assertTrue:[attributes objectForKey:"a"] === 37 message:@"expecting 'a' to be '1', was: " + [attributes objectForKey:"a"]];
[self assertTrue:[attributes objectForKey:"b"] === "baz" message:@"expecting 'b' to be 'baz', was: " + [attributes objectForKey:"b"]];
[self assertTrue:[attributes objectForKey:"f"] === 43 message:@"expecting 'f' to be 43, was: " + [attributes objectForKey:"f"]];
}
//- (id)attribute:(CPString)attribute atIndex:(unsigned)index effectiveRange:(CPRangePointer)aRange
- (void)testAttributeAtIndexEffectiveRange
{
var string = [self stringForTesting];
testAttributeAtIndexWithValue(string, 1, "a", 1, self);
testAttributeAtIndexWithValue(string, 20, "d", [CPNull null], self);
}
@@ -148,34 +148,34 @@ var sharedObject = [CPObject new];
- (void)testAttributeAtIndexLongestEffectiveRangeInRange
{
var string = [self stringForTesting];
var range = CPMakeRange(0, 0),
attribute = [string attribute:"b" atIndex:35 longestEffectiveRange:range inRange:CPMakeRange(0, 43)];
[self assertTrue:CPMaxRange(range)==43 message:@"expecting attributes to be valuable at range 43, was: "+CPMaxRange(range)];
[self assertTrue:range.location==9 message:@"expecting attributes to be valuable at range 9, was: "+range.location];
[self assertTrue:attribute==="baz" message:@"expecting 'b' to be 'baz', was: "+attribute];
[self assertTrue:CPMaxRange(range) == 43 message:@"expecting attributes to be valuable at range 43, was: " + CPMaxRange(range)];
[self assertTrue:range.location == 9 message:@"expecting attributes to be valuable at range 9, was: " + range.location];
[self assertTrue:attribute === "baz" message:@"expecting 'b' to be 'baz', was: " + attribute];
}
//Comparing Attributed Strings
- (void)testIsEqualToAttributedString
{
[self assertTrue:[[self stringForTesting] isEqualToAttributedString:[self stringForTesting]] message:"expected stringForTesting to equal itself, but it didn't"];
[self assertFalse:[[self stringForTesting] isEqualToAttributedString:[[CPAttributedString alloc] initWithString:@"HELLO!"]] message:"Expected stringForTesting to not equal 'HELLO!', but it did"];
}
- (void)testIsEqual
{
[self assertTrue:[[self stringForTesting] isEqual:[self stringForTesting]] message:"expected stringForTesting to equal itself, but it didn't"];
[self assertFalse:[[self stringForTesting] isEqual:[[CPAttributedString alloc] initWithString:@"HELLO!"]] message:"Expected stringForTesting to not equal 'HELLO!', but it did"];
var a = [self stringForTesting];
[self assertTrue:[a isEqual:a] message:"expected a to equal itself, but it didn't"];
[self assertFalse:[a isEqual:@"HELLO!"] message:"Expected a to not equal 'HELLO!', but it did"];
}
@@ -195,7 +195,7 @@ var sharedObject = [CPObject new];
var c = [[self stringForTesting] attributedSubstringFromRange:CPMakeRange(0, 45)];
[self assertTrue:[c isEqual:[self stringForTesting]] message:"expected c to equal itself, but it didn't"];
var d = [[self stringForTesting] attributedSubstringFromRange:CPMakeRange(9, 11)],
expectedValues = {a:2, b:"baz", c:sharedObject};
@@ -205,8 +205,8 @@ var sharedObject = [CPObject new];
expectedValues = {a:2, b:"baz", c:"astring", d:[CPNull null]};
testAttributesAtIndexWithValues(e, 13, expectedValues, self);
[self assertTrue:CPEqualRanges(e._rangeEntries[0].range, CPMakeRange(0, 1)) message:"expected range to be {0, 1}, was "+CPStringFromRange(e._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(e._rangeEntries[0].range, CPMakeRange(0, 1)) message:"expected range to be {0, 1}, was " + CPStringFromRange(e._rangeEntries[0].range)];
}
//Changing Characters
@@ -216,8 +216,8 @@ var sharedObject = [CPObject new];
var string = [self stringForTesting];
[string replaceCharactersInRange:CPMakeRange(10, 5) withString:"firetruck red"];
[self assertTrue:[string string]==="The quick firetruck red fox jumped over the lazy dog." message:"replacing 'brown' with 'firetruck red' produced: "+[string string].substr(10, 5)];
[self assertTrue:[string string] === "The quick firetruck red fox jumped over the lazy dog." message:"replacing 'brown' with 'firetruck red' produced: " + [string string].substr(10, 5)];
testAttributesAtIndexWithValues(string, 21, {a:2, b:"baz", c:sharedObject}, self);
testAttributesAtIndexWithValues(string, 40, {a:37, b:"baz", c:1, d:20, e:55, f:43}, self);
@@ -230,8 +230,8 @@ var sharedObject = [CPObject new];
var string = [self stringForTesting];
[string deleteCharactersInRange:CPMakeRange(10, 5)];
[self assertTrue:[string string]==="The quick fox jumped over the lazy dog." message:"replacing 'brown' with '' produced: "+[string string]];
[self assertTrue:[string string] === "The quick fox jumped over the lazy dog." message:"replacing 'brown' with '' produced: " + [string string]];
testAttributesAtIndexWithValues(string, 10, {a:2, b:"baz", c:sharedObject}, self);
testAttributesAtIndexWithValues(string, 27, {a:37, b:"baz", c:1, d:20, e:55, f:43}, self);
@@ -239,10 +239,10 @@ var sharedObject = [CPObject new];
[string deleteCharactersInRange:CPMakeRange(0, [string length])];
[self assertTrue:[string isEqual:[[CPAttributedString alloc] initWithString:""]] message:"emptry string was not equal: "+[string string]];
[self assertTrue:[string isEqual:[[CPAttributedString alloc] initWithString:""]] message:"emptry string was not equal: " + [string string]];
var string = [self stringForTesting];
//this deletes an exact rangeEntry
[string deleteCharactersInRange:CPMakeRange(9, 11)];
@@ -253,60 +253,59 @@ var sharedObject = [CPObject new];
//- (void)_indexOfRangeEntryForIndex:(unsigned)characterIndex splitOnMaxIndex:(BOOL)split
- (void)testIndexOfRangeEntryForIndexSplitOnMaxIndex
{
var string = [self stringForTesting];
var index = [string _indexOfRangeEntryForIndex:4 splitOnMaxIndex:YES];
var string = [self stringForTesting],
index = [string _indexOfRangeEntryForIndex:4 splitOnMaxIndex:YES];
[self assertTrue:index==1 message:"index of character 4 should have been 1, was: "+index];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 4)) message:"range 0 should be {0, 4}; was "+CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:index == 1 message:"index of character 4 should have been 1, was: " + index];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 4)) message:"range 0 should be {0, 4}; was " + CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(4, 5)) message:"range 1 should be {4, 5}; was " + CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(4, 5)) message:"range 1 should be {4, 5}; was "+CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:[string isEqual:[self stringForTesting]] message:"should be equal to template attributed string but wasn't"];
string = [self stringForTesting];
index = [string _indexOfRangeEntryForIndex:8 splitOnMaxIndex:YES];
[self assertTrue:index==1 message:"index of character 8 should have been 1, was: "+index];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 8)) message:"range 0 should be {0, 8}; was "+CPStringFromRange(string._rangeEntries[0].range)];
string = [self stringForTesting];
index = [string _indexOfRangeEntryForIndex:8 splitOnMaxIndex:YES];
[self assertTrue:index == 1 message:"index of character 8 should have been 1, was: " + index];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 8)) message:"range 0 should be {0, 8}; was " + CPStringFromRange(string._rangeEntries[0].range)];
index = [string _indexOfRangeEntryForIndex:9 splitOnMaxIndex:YES];
[self assertTrue:index==2 message:"index of character 9 should have been 2, was: "+index];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 8)) message:"range 0 should be {0, 8}; was "+CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:index == 2 message:"index of character 9 should have been 2, was: " + index];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(8, 1)) message:"range 1 should be {8, 1}; was "+CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 8)) message:"range 0 should be {0, 8}; was " + CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[2].range, CPMakeRange(9, 11)) message:"range 2 should be {9, 11}; was "+CPStringFromRange(string._rangeEntries[2].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(8, 1)) message:"range 1 should be {8, 1}; was " + CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[2].range, CPMakeRange(9, 11)) message:"range 2 should be {9, 11}; was " + CPStringFromRange(string._rangeEntries[2].range)];
string = [self stringForTesting];
index = [string _indexOfRangeEntryForIndex:44 splitOnMaxIndex:YES];
[self assertTrue:index==4 message:"index of character 44 should have been 4, was: "+index];
[self assertTrue:index == 4 message:"index of character 44 should have been 4, was: " + index];
[self assertTrue:CPEqualRanges(string._rangeEntries[index].range, CPMakeRange(44, 1)) message:"range 3 should be {44, 1}; was "+CPStringFromRange(string._rangeEntries[index].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[index].range, CPMakeRange(44, 1)) message:"range 3 should be {44, 1}; was " + CPStringFromRange(string._rangeEntries[index].range)];
index = [string _indexOfRangeEntryForIndex:43 splitOnMaxIndex:YES];
[self assertTrue:index==4 message:"index of character 43 should have been 4, was: "+index];
[self assertTrue:index == 4 message:"index of character 43 should have been 4, was: " + index];
[self assertTrue:CPEqualRanges(string._rangeEntries[index-1].range, CPMakeRange(32, 11)) message:"range 3 should be {32, 11}; was "+CPStringFromRange(string._rangeEntries[index-1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[index - 1].range, CPMakeRange(32, 11)) message:"range 3 should be {32, 11}; was " + CPStringFromRange(string._rangeEntries[index - 1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[index].range, CPMakeRange(43, 1)) message:"range 4 should be {43, 1}; was "+CPStringFromRange(string._rangeEntries[index].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[index].range, CPMakeRange(43, 1)) message:"range 4 should be {43, 1}; was " + CPStringFromRange(string._rangeEntries[index].range)];
}
//- (void)_coalesceRangeEntriesFromIndex:(unsigned)start toIndex:(unsigned)end
- (void)testCoalesceRangeEntriesFromIndexToIndex
{
var templateString = [[CPAttributedString alloc] initWithString:"The quick brown fox jumped over the lazy dog."];
templateString._rangeEntries = [];
templateString._rangeEntries.push({
range:CPMakeRange(0, 4),
attributes:[CPDictionary dictionaryWithObjects:[1, "bar", sharedObject, 20] forKeys:["a", "b", "c", "d"]]
@@ -339,30 +338,30 @@ var sharedObject = [CPObject new];
range:CPMakeRange(43, 2),
attributes:[CPDictionary dictionaryWithObjects:[37, "baz", 1, 20, 55, 43] forKeys:["a", "b", "c", "d", "e", "f"]]
});
var string = [[CPAttributedString alloc] initWithAttributedString:templateString];
[string _coalesceRangeEntriesFromIndex:0 toIndex:string._rangeEntries.length-1];
[self assertTrue:[string isEqual:templateString] message:"string should equal template string but does not."];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 9)) message:"range 0 should be {0, 9}; was "+CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(9, 11)) message:"range 1 should be {9, 11}; was "+CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[2].range, CPMakeRange(20, 12)) message:"range 2 should be {20, 12}; was "+CPStringFromRange(string._rangeEntries[2].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[3].range, CPMakeRange(32, 13)) message:"range 3 should be {32, 13}; was "+CPStringFromRange(string._rangeEntries[3].range)];
var string = [[CPAttributedString alloc] initWithAttributedString:templateString];
[string _coalesceRangeEntriesFromIndex:0 toIndex:string._rangeEntries.length - 1];
[self assertTrue:[string isEqual:templateString] message:"string should equal template string but does not."];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 9)) message:"range 0 should be {0, 9}; was " + CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(9, 11)) message:"range 1 should be {9, 11}; was " + CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[2].range, CPMakeRange(20, 12)) message:"range 2 should be {20, 12}; was " + CPStringFromRange(string._rangeEntries[2].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[3].range, CPMakeRange(32, 13)) message:"range 3 should be {32, 13}; was " + CPStringFromRange(string._rangeEntries[3].range)];
var string = [[CPAttributedString alloc] initWithAttributedString:templateString];
[string _coalesceRangeEntriesFromIndex:4 toIndex:7];
[self assertTrue:[string isEqual:templateString] message:"string should equal template string but does not."];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 4)) message:"range 0 should be {0, 4}; was "+CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(4, 5)) message:"range 1 should be {4, 5}; was "+CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[2].range, CPMakeRange(9, 10)) message:"range 2 should be {9, 10}; was "+CPStringFromRange(string._rangeEntries[2].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[3].range, CPMakeRange(19, 1)) message:"range 3 should be {19, 1}; was "+CPStringFromRange(string._rangeEntries[3].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[4].range, CPMakeRange(20, 12)) message:"range 4 should be {20, 12}; was "+CPStringFromRange(string._rangeEntries[4].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[5].range, CPMakeRange(32, 13)) message:"range 5 should be {32, 13}; was "+CPStringFromRange(string._rangeEntries[5].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[0].range, CPMakeRange(0, 4)) message:"range 0 should be {0, 4}; was " + CPStringFromRange(string._rangeEntries[0].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[1].range, CPMakeRange(4, 5)) message:"range 1 should be {4, 5}; was " + CPStringFromRange(string._rangeEntries[1].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[2].range, CPMakeRange(9, 10)) message:"range 2 should be {9, 10}; was " + CPStringFromRange(string._rangeEntries[2].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[3].range, CPMakeRange(19, 1)) message:"range 3 should be {19, 1}; was " + CPStringFromRange(string._rangeEntries[3].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[4].range, CPMakeRange(20, 12)) message:"range 4 should be {20, 12}; was " + CPStringFromRange(string._rangeEntries[4].range)];
[self assertTrue:CPEqualRanges(string._rangeEntries[5].range, CPMakeRange(32, 13)) message:"range 5 should be {32, 13}; was " + CPStringFromRange(string._rangeEntries[5].range)];
}
//Changing Attributes
@@ -382,30 +381,32 @@ var sharedObject = [CPObject new];
testAttributesAtIndexWithValues(string, 10, {a:1, b:2, c:3, d:4, e:5}, self);
var range = CPMakeRange(0, 0);
[string setAttributes:[CPDictionary dictionaryWithObject:"FOO" forKey:"BAR"] range:CPMakeRange(15, 20)];
var value = [string attribute:"BAR" atIndex:16 longestEffectiveRange:range inRange:CPMakeRange(0, 45)];
[self assertTrue:value==="FOO" message:"expected value to be 'FOO', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(15, 20)) message:"expected key to be valid across {15, 20}, was: "+CPStringFromRange(range)];
[self assertTrue:value === "FOO" message:"expected value to be 'FOO', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(15, 20)) message:"expected key to be valid across {15, 20}, was: " + CPStringFromRange(range)];
var index = range.location;
while(index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil]=="FOO" message:"incorrect value for key BAR"];
while (index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil] == "FOO" message:"incorrect value for key BAR"];
string = [self stringForTesting];
[string addAttributes:[CPDictionary dictionaryWithObject:"FOO" forKey:"BAR"] range:CPMakeRange(0, 45)];
var value = [string attribute:"BAR" atIndex:16 longestEffectiveRange:range inRange:CPMakeRange(0, 45)];
[self assertTrue:value==="FOO" message:"expected value to be 'FOO', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(0, 45)) message:"expected key to be valid across {0, 45}, was: "+CPStringFromRange(range)];
[self assertTrue:value === "FOO" message:"expected value to be 'FOO', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(0, 45)) message:"expected key to be valid across {0, 45}, was: " + CPStringFromRange(range)];
var index = range.location;
while(index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil]=="FOO" message:"incorrect value for key BAR"];
while (index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil] == "FOO" message:"incorrect value for key BAR"];
}
//- (void)addAttributes:(CPDictionary)aDictionary range:(CPRange)aRange
@@ -417,32 +418,34 @@ var sharedObject = [CPObject new];
[string addAttributes:[CPDictionary dictionaryWithObject:"FOO" forKey:"BAR"] range:CPMakeRange(15, 20)];
var value = [string attribute:"BAR" atIndex:16 longestEffectiveRange:range inRange:CPMakeRange(0, 45)];
[self assertTrue:value==="FOO" message:"expected value to be 'FOO', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(15, 20)) message:"expected key to be valid across {15, 20}, was: "+CPStringFromRange(range)];
[self assertTrue:value === "FOO" message:"expected value to be 'FOO', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(15, 20)) message:"expected key to be valid across {15, 20}, was: " + CPStringFromRange(range)];
var index = range.location;
while(index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil]=="FOO" message:"incorrect value for key BAR"];
while (index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil] == "FOO" message:"incorrect value for key BAR"];
string = [self stringForTesting];
[string addAttributes:[CPDictionary dictionaryWithObjects:[1, 2, 3, 4, 5] forKeys:["a", "b", "c", "d", "e"]] range:CPMakeRange(0, [string length])];
testAttributesAtIndexWithValues(string, 10, {a:1, b:2, c:3, d:4, e:5}, self);
string = [self stringForTesting];
[string addAttributes:[CPDictionary dictionaryWithObject:"FOO" forKey:"BAR"] range:CPMakeRange(0, 45)];
var value = [string attribute:"BAR" atIndex:16 longestEffectiveRange:range inRange:CPMakeRange(0, 45)];
[self assertTrue:value==="FOO" message:"expected value to be 'FOO', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(0, 45)) message:"expected key to be valid across {0, 45}, was: "+CPStringFromRange(range)];
[self assertTrue:value === "FOO" message:"expected value to be 'FOO', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(0, 45)) message:"expected key to be valid across {0, 45}, was: " + CPStringFromRange(range)];
var index = range.location;
while(index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil]=="FOO" message:"incorrect value for key BAR"];
while (index < CPMaxRange(range))
[self assertTrue:[string attribute:"BAR" atIndex:index++ effectiveRange:nil] == "FOO" message:"incorrect value for key BAR"];
}
//- (void)addAttribute:(CPString)anAttribute value:(id)aValue range:(CPRange)aRange
@@ -479,14 +482,14 @@ var sharedObject = [CPObject new];
[string appendAttributedString:addOn];
[string appendAttributedString:addOn];
[self assertTrue:[string string]==="The quick brown fox jumped over the lazy dog.dogdog" message:"wrong string after appending"];
[self assertTrue:[string string] === "The quick brown fox jumped over the lazy dog.dogdog" message:"wrong string after appending"];
var range = CPMakeRange(0, 0),
value = [string attribute:"c" atIndex:47 longestEffectiveRange:range inRange:CPMakeRange(0, [string length])];
[self assertTrue:value===1 message:"expected value to be '1', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(32, 13+3+3)) message:"expected key to be valid across {32, 19}, was: "+CPStringFromRange(range)];
[self assertTrue:value === 1 message:"expected value to be '1', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(32, 13 + 3 + 3)) message:"expected key to be valid across {32, 19}, was: " + CPStringFromRange(range)];
}
//- insertAttributedString:(CPAttributedString)aString atIndex:(CPString)anIndex
@@ -502,11 +505,11 @@ var sharedObject = [CPObject new];
string = [self stringForTesting];
addOn = [[self stringForTesting] attributedSubstringFromRange:CPMakeRange(41, 3)];
[string insertAttributedString:addOn atIndex:9];
testAttributesAtIndexWithValues(string, 9, {a:37, b:"baz", c:1, d:20, e:55, f:43}, self);
addOn = [[self stringForTesting] attributedSubstringFromRange:CPMakeRange(41, 3)];
[string insertAttributedString:addOn atIndex:8];
@@ -515,14 +518,14 @@ var sharedObject = [CPObject new];
var range = CPMakeRange(0, 0),
value = [string attribute:"a" atIndex:9 longestEffectiveRange:range inRange:CPMakeRange(0, 45)];
[self assertTrue:value===37 message:"expected value to be '37', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(8, 3)) message:"expected key to be valid across {8, 3}, was: "+CPStringFromRange(range)];
[self assertTrue:value === 37 message:"expected value to be '37', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(8, 3)) message:"expected key to be valid across {8, 3}, was: " + CPStringFromRange(range)];
value = [string attribute:"a" atIndex:11 longestEffectiveRange:range inRange:CPMakeRange(0, 45)];
[self assertTrue:value===1 message:"expected value to be '37', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(11, 1)) message:"expected key to be valid across {11, 1}, was: "+CPStringFromRange(range)];
[self assertTrue:value === 1 message:"expected value to be '37', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(11, 1)) message:"expected key to be valid across {11, 1}, was: " + CPStringFromRange(range)];
}
//- (void)replaceCharactersInRange:(CPRange)aRange withAttributedString:(CPAttributedString)aString
@@ -532,14 +535,14 @@ var sharedObject = [CPObject new];
addOn = [string attributedSubstringFromRange:CPMakeRange(41, 3)];
[string replaceCharactersInRange:CPMakeRange(41, 3) withAttributedString:addOn];
[self assertTrue:[string string]===[[self stringForTesting] string] message:"wrong string after replacing."];
[self assertTrue:[string string] === [[self stringForTesting] string] message:"wrong string after replacing."];
var range = CPMakeRange(0, 0),
value = [string attribute:"c" atIndex:42 longestEffectiveRange:range inRange:CPMakeRange(0, [string length])];
[self assertTrue:value===1 message:"expected value to be '1', was: "+value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(32, 13)) message:"expected key to be valid across {32, 13}, was: "+CPStringFromRange(range)];
[self assertTrue:value === 1 message:"expected value to be '1', was: " + value];
[self assertTrue:CPEqualRanges(range, CPMakeRange(32, 13)) message:"expected key to be valid across {32, 13}, was: " + CPStringFromRange(range)];
}
//- (void)setAttributedString:(CPAttributedString)aString
@@ -547,8 +550,8 @@ var sharedObject = [CPObject new];
{
var string = [[CPAttributedString alloc] initWithString:"HELLO THERE"];
[string setAttributedString:[self stringForTesting]];
[self assertTrue:[[self stringForTesting] isEqual:string] message:"setAttributedString should have made strings equal, but they were not"];
[self assertTrue:[[self stringForTesting] isEqual:string] message:"setAttributedString should have made strings equal, but they were not"];
}
@end
@@ -563,16 +566,17 @@ function testAttributesAtIndexWithValues(aString, anIndex, values, aSelf)
var range = CPMakeRange(0, 0),
attributes = [aString attributesAtIndex:anIndex effectiveRange:range];
for(key in values)
[aSelf assertTrue:isEqualAllowingUndefinedCast([attributes objectForKey:key], values[key]) message: "expecting '"+key+"' to be '"+values[key]+"', was '"+[attributes objectForKey:key]];
for (key in values)
[aSelf assertTrue:isEqualAllowingUndefinedCast([attributes objectForKey:key], values[key]) message: "expecting '" + key + "' to be '" + values[key] + "', was '" + [attributes objectForKey:key]];
var index = range.location;
while(index < CPMaxRange(range))
while (index < CPMaxRange(range))
{
attributes = [aString attributesAtIndex:index++ effectiveRange:nil];
for(key in values)
[aSelf assertTrue:isEqualAllowingUndefinedCast([attributes objectForKey:key], values[key]) message: "expecting '"+key+"' in loop to be '"+values[key]+"', was '"+[attributes objectForKey:key]];
for (key in values)
[aSelf assertTrue:isEqualAllowingUndefinedCast([attributes objectForKey:key], values[key]) message: "expecting '" + key + "' in loop to be '" + values[key] + "', was '" + [attributes objectForKey:key]];
}
}
@@ -581,18 +585,19 @@ function testAttributeAtIndexWithValue(aString, anIndex, aKey, aValue, aSelf)
var range = CPMakeRange(0, 0),
attribute = [aString attribute:aKey atIndex:anIndex effectiveRange:range];
[aSelf assertTrue: isEqualAllowingUndefinedCast(attribute, aValue) message: "expecting '"+aKey+"' to be '"+aValue+"', was '"+attribute];
[aSelf assertTrue: isEqualAllowingUndefinedCast(attribute, aValue) message: "expecting '" + aKey + "' to be '" + aValue + "', was '" + attribute];
var index = range.location;
while(index < CPMaxRange(range))
while (index < CPMaxRange(range))
{
attribute = [aString attribute:aKey atIndex:index++ effectiveRange:nil];
[aSelf assertTrue: isEqualAllowingUndefinedCast(attribute, aValue) message: "expecting '"+aKey+"' to be '"+aValue+"', was '"+attribute];
[aSelf assertTrue: isEqualAllowingUndefinedCast(attribute, aValue) message: "expecting '" + aKey + "' to be '" + aValue + "', was '" + attribute];
}
}
function printRangeEntry(entry)
{
print("range: "+CPStringFromRange(entry.range)+" "+[entry.attributes description]);
print("range: " + CPStringFromRange(entry.range) + " " + [entry.attributes description]);
}
+17 -17
View File
@@ -8,52 +8,52 @@
- (void)testCountForObject
{
var set = [CPCountedSet setWithArray:[1, 2, 3]];
[self assertTrue:[set countForObject:[CPNull null]] === 0 message:"Expected count of 0, got: "+[set countForObject:[CPNull null]]];
[self assertTrue:[set countForObject:3] === 1 message:"Expected count of 1, got: "+[set countForObject:0]];
[set addObject:1];
[self assertTrue:[set countForObject:1] === 2 message:"Expected count of 2, got: "+[set countForObject:1]];
[set addObject:2];
[set addObject:2];
[self assertTrue:[set countForObject:2] === 3 message:"Expected count of 3, got: "+[set countForObject:2]];
}
- (void)testAddObject
{
var set = [CPCountedSet new];
[self assertTrue:[set countForObject:"foo"] === 0 message:"Expected count of 0, got: "+[set countForObject:"foo"]];
[self assertTrue:[set countForObject:"foo"] === 0 message:"Expected count of 0, got: "+[set countForObject:"foo"]];
[set addObject:"foo"];
[self assertTrue:[set countForObject:"foo"] === 1 message:"Expected count of 1, got: "+[set countForObject:"foo"]];
[set addObject:"foo"];
[set addObject:"foo"];
[set addObject:"foo"];
[self assertTrue:[set countForObject:"foo"] === 4 message:"Expected count of 4, got: "+[set countForObject:"foo"]];
[self assertTrue:[set countForObject:"foo"] === 4 message:"Expected count of 4, got: "+[set countForObject:"foo"]];
}
- (void)testRemoveObject
{
var set = [CPCountedSet new];
[self assertTrue:[set countForObject:"foo"] === 0 message:"Expected count of 0, got: "+[set countForObject:"foo"]];
[self assertTrue:[set countForObject:"foo"] === 0 message:"Expected count of 0, got: "+[set countForObject:"foo"]];
[set addObject:"foo"];
[set addObject:"foo"];
[set addObject:"foo"];
[set addObject:"foo"];
[self assertTrue:[set countForObject:"foo"] === 4 message:"Expected count of 4, got: "+[set countForObject:"foo"]];
[set removeObject:"foo"];
[self assertTrue:[set countForObject:"foo"] === 3 message:"Expected count of 3, got: "+[set countForObject:"foo"]];
[set removeObject:"foo"];
+7 -8
View File
@@ -1,11 +1,11 @@
@import <Foundation/CPFunctionOperation.j>
@implementation SomeObject : CPObject
@implementation SomeObject : CPObject
{
CPString result @accessors;
}
- (CPString)setAString:(CPString)someString
- (CPString)setAString:(CPString)someString
{
result = someString;
return @"Done";
@@ -18,16 +18,15 @@
- (void)testRunInvocation
{
so = [[SomeObject alloc] init];
var someVar = nil;
funcOp = [CPFunctionOperation functionOperationWithFunction:function() {[so setAString:@"Hello World"]}];
[funcOp addExecutionFunction:function() {someVar = 'Soylent Green';}];
[funcOp start];
[self assert:@"Hello World" equals:[so result]];
[self assert:@"Soylent Green" equals:someVar];
[self assert:@"Soylent Green" equals:someVar];
}
@end
@end
+13 -15
View File
@@ -23,7 +23,7 @@ function descriptionWithoutEntity(aString)
// Test no indexes
[self assert:descriptionWithoutEntity(indexSet) equals:@"(no indexes)"];
// Test adding initial range
[indexSet addIndexesInRange:CPMakeRange(30,10)];
@@ -76,7 +76,7 @@ function descriptionWithoutEntity(aString)
// Test no indexes
[self assert:descriptionWithoutEntity(indexSet) equals:@"(no indexes)"];
// Test adding initial range
[indexSet addIndexesInRange:CPMakeRange(0, 70)];
@@ -121,12 +121,12 @@ function descriptionWithoutEntity(aString)
[indexSet removeIndexesInRange:CPMakeRange(20, 36)];
[self assert:@"[number of indexes: 31 (in 3 ranges), indexes: (0-19 56 60-69)]" equals:descriptionWithoutEntity(indexSet)];
// Remove single index that represents an entire range.
[indexSet removeIndex:56];
[self assert:@"[number of indexes: 30 (in 2 ranges), indexes: (0-19 60-69)]" equals:descriptionWithoutEntity(indexSet)];
// Remove index set that is subset of existing range, causing a split.
[indexSet removeIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(5, 10)]];
@@ -185,12 +185,10 @@ function descriptionWithoutEntity(aString)
- (void)testIndexSet:(CPIndexSet)set containsRange:(CPRange)range
{
[self assertFalse:[set containsIndex:range.location -1]];
for (var i=range.location, max=CPMaxRange(range); i<max; i++)
{
for (var i = range.location, max = CPMaxRange(range); i < max; i++)
[self assertTrue:[set containsIndex:i]];
}
[self assertFalse:[set containsIndex:i]];
}
@@ -296,14 +294,14 @@ function descriptionWithoutEntity(aString)
- (void)testAddSpeed
{
var startTime = [CPDate date];
for (var i = 0; i < 1000; i++)
{
[_set addIndex:ROUND(RAND()*100000)];
}
print([startTime timeIntervalSinceNow]);
//[self assertTrue: ABS([startTime timeIntervalSinceNow]) < 2];
//[self assertTrue: ABS([startTime timeIntervalSinceNow]) < 2];
}
*/
- (void)testIndexGreaterThanIndex
@@ -372,19 +370,19 @@ function descriptionWithoutEntity(aString)
var startRange = CPMakeRange(1, 5),
shiftRange = CPMakeRange(2, 5);
_set = [CPIndexSet indexSetWithIndexesInRange:startRange];
// positive delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:shiftRange]]];
// negative delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:-1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:startRange]]];
// test for fix to issue #746 (last item is mistakenly shifted)
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 1)];
[self assertTrue:[_set lastIndex] === 0];
[_set shiftIndexesStartingAtIndex:[_set lastIndex] + 1 by:1];
[self assertTrue:[_set lastIndex] === 0];
+6 -7
View File
@@ -1,11 +1,11 @@
@import <Foundation/CPInvocationOperation.j>
@implementation SomeObject : CPObject
@implementation SomeObject : CPObject
{
CPString result @accessors;
}
- (CPString)setAString:(CPString)someString
- (CPString)setAString:(CPString)someString
{
result = someString;
return @"Done";
@@ -19,12 +19,11 @@
{
var so = [[SomeObject alloc] init],
io = [[CPInvocationOperation alloc] initWithTarget:so selector:@selector(setAString:) object:@"Hello World"];
[io start];
[self assert:@"Hello World" equals:[so result]];
[self assert:@"Done" equals:[io result]];
[self assert:@"Done" equals:[io result]];
}
@end
@end
+69 -69
View File
@@ -7,7 +7,7 @@
BOOL _sawPriorObservation;
BOOL _sawObservation;
BOOL _sawDependentObservation;
id bob;
id obj;
id cs101;
@@ -24,11 +24,11 @@
- (void)testAddObserver
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:"testAddObserver"];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue: [bob valueForKey:@"name"] == @"set_bob" message: "valueForKey:'name' should be 'set_bob', was: "+[bob valueForKey:@"name"]];
[self assertTrue: bob.name == @"set_bob" message: "bob.name should be 'set_bob', was: "+bob.name];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
@@ -37,11 +37,11 @@
- (void)testUnobservedKey
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:"testUnobservedKey"];
[bob setValue:@"555" forKey:@"phoneNumber"];
[self assertTrue: [bob valueForKey:@"phoneNumber"] == @"555" message: "'phoneNumber' should be '555', was: "+[bob valueForKey:@"phoneNumber"]];
[self assertFalse: _sawObservation message:"Should not have recieved an observation"];
}
@@ -49,12 +49,12 @@
- (void)testAddTwoObservers
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:"testAddTwoObservers"];
[bob addObserver:[CPObject new] forKeyPath:@"name" options:nil context:"testAddTwoObservers"];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue: [bob valueForKey:@"name"] == @"set_bob" message: "valueForKey:'name' should be bob, was: "+[bob valueForKey:@"name"]];
[self assertTrue: bob.name == @"set_bob" message: "bob.name should be 'bob', was: "+bob.name];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
@@ -63,11 +63,11 @@
- (void)testDirectIVarObservation
{
var bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"phoneNumber" options:nil context:"testDirectIVarObservation"];
[bob setValue:@"555" forKey:@"phoneNumber"];
[self assertTrue: [bob valueForKey:@"phoneNumber"] == @"555" message: "valueForKey:'phoneNumber' should be '555', was: "+[bob valueForKey:@"phoneNumber"]];
[self assertTrue: bob.phoneNumber == @"555" message: "bob.phoneNumber should be '555', was: "+bob.phoneNumber];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
@@ -76,14 +76,14 @@
- (void)testRemoveObserver
{
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:nil context:"testRemoveObserver"];
[bob addObserver:[CPString new] forKeyPath:@"name" options:nil context:"testRemoveObserver"];
[bob removeObserver:self forKeyPath:@"name"];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue: [bob valueForKey:@"name"] == @"set_bob" message: "valueForKey:'name' should be bob, was: "+[bob valueForKey:@"name"]];
}
@@ -91,14 +91,14 @@
{
bob = [[PersonTester alloc] init];
obj = [CPString new];
[bob addObserver:self forKeyPath:@"name" options:nil context:"testRemoveOtherObserver"];
[bob addObserver:obj forKeyPath:@"name" options:nil context:"testRemoveOtherObserver"];
[bob removeObserver:obj forKeyPath:@"name"];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue: [bob valueForKey:@"name"] == @"set_bob" message: "valueForKey:'name' should be bob, was: "+[bob valueForKey:@"name"]];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
}
@@ -108,16 +108,16 @@
bob = [[PersonTester alloc] init];
obj = [CPArray new];
obj2 = [CPString new];
[bob addObserver:obj forKeyPath:@"name" options:nil context:"testRemoveAllObservers"];
[bob addObserver:obj2 forKeyPath:@"name" options:nil context:"testRemoveAllObservers"];
[bob removeObserver:obj forKeyPath:@"name"];
[bob removeObserver:obj2 forKeyPath:@"name"];
[bob removeObserver:nil forKeyPath:nil];
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue: [bob valueForKey:@"name"] == @"set_bob" message: "valueForKey:'name' should be bob, was: "+[bob valueForKey:@"name"]];
}
@@ -125,7 +125,7 @@
- (void)testDictionary
{
var dict = [[CPDictionary alloc] init];
[dict setObject:@"Bob Jones" forKey:@"dictionaryKey"];
[dict addObserver:self
@@ -141,9 +141,9 @@
- (void)testPriorObservationOption
{
_sawPriorObservation = NO;
bob = [[PersonTester alloc] init];
[bob addObserver:self forKeyPath:@"name" options:CPKeyValueObservingOptionPrior context:"testPriorObservationOption"];
[bob setValue:@"bob" forKey:@"name"];
@@ -170,10 +170,10 @@
- (void)testDependentKeyObservation
{
_sawDependentObservation = NO;
bob = [[PersonTester alloc] init];
bob.name = "paul";
bob.name = "paul";
[bob addObserver:self forKeyPath:@"bobName" options:0 context:"testDependentKeyObservation"];
[bob addObserver:self forKeyPath:@"twiceRemoved" options:0 context:"testDependentKeyObservation2"];
@@ -181,7 +181,7 @@
[bob setValue:@"bob" forKey:@"name"];
[self assertTrue:_sawDependentObservation message:"asked for bobName but did not recieve corresponding notification"];
[self assertTrue: [bob valueForKey:@"bobName"] === @"BOB! set_bob" message: "should have been BOB! set_bob, was "+[bob valueForKey:@"bobName"]];
[self assertTrue: [bob valueForKey:@"bobName"] === @"BOB! set_bob" message: "should have been BOB! set_bob, was "+[bob valueForKey:@"bobName"]];
}
- (void)testMultipartKey
@@ -190,11 +190,11 @@
bob = [PersonTester new];
[cs101 setTeacher:bob];
[cs101 addObserver:self forKeyPath:@"teacher.name" options:0 context:"testMultipartKey"];
[bob setName:@"bob"];
[self assertTrue:[cs101 valueForKeyPath:@"teacher.name"] == "set_bob" message:"teacher.name should be: set_bob, was: "+[cs101 valueForKeyPath:@"teacher.name"]];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
}
@@ -238,7 +238,7 @@
[focus setValue:"2000" forKey:"year"];
[cs101 addObserver:self forKeyPath:@"teacher.car.year" options:0 context:"testThreePartKeyPart2"];
[bob setValue:focus forKey:"car"];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
@@ -250,13 +250,13 @@
bob = [PersonTester new];
[cs101 setTeacher:bob];
[cs101 addObserver:self forKeyPath:@"teacher.name" options:0 context:"testRemoveMultipartKey"];
[cs101 removeObserver:self forKeyPath:@"teacher.name"];
[bob setName:@"bob"];
[self assertFalse: _sawObservation message:"Should not have recieved an observation"];
}
@@ -281,51 +281,51 @@
- (void)testCrazyKeyPathChanges
{
var a = [A new];
[a setValue:[B new] forKeyPath:"b"];
[a setValue:[C new] forKeyPath:"b.c"];
[a setValue:[D new] forKeyPath:"b.c.d"];
[a setValue:[E new] forKeyPath:"b.c.d.e"];
[a setValue:[F new] forKeyPath:"b.c.d.e.f"];
[a addObserver:self forKeyPath:"b.c.d.e.f" options:0 context:"testCrazyKeyPathChanges"];
[a setValue:[D new] forKeyPath:"b.c.d"];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
}
- (void)testCrazyKeyPathChanges2
{
var a = [A new];
[a setValue:[B new] forKeyPath:"b"];
[a setValue:[C new] forKeyPath:"b.c"];
[a setValue:[D new] forKeyPath:"b.c.d"];
[a setValue:[E new] forKeyPath:"b.c.d.e"];
[a setValue:[F new] forKeyPath:"b.c.d.e.f"];
[a addObserver:self forKeyPath:"b.c.d.e.f" options:0 context:"testCrazyKeyPathChanges2"];
[a setValue:nil forKeyPath:"b.c"];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
}
- (void)testCrazyKeyPathChanges3
{
var a = [A new];
[a setValue:[B new] forKeyPath:"b"];
[a setValue:[C new] forKeyPath:"b.c"];
[a setValue:[D new] forKeyPath:"b.c.d"];
[a setValue:[E new] forKeyPath:"b.c.d.e"];
[a setValue:[F new] forKeyPath:"b.c.d.e.f"];
[a addObserver:self forKeyPath:"b.c.d.e.f" options:0 context:"testCrazyKeyPathChanges3"];
[a setValue:7 forKeyPath:"b.c.d.e.f"];
[self assertTrue: _sawObservation message:"Never recieved an observation"];
}
@@ -386,9 +386,9 @@
{
var one = [1, 1, 1, 1, 1, 1, 1, 1],
two = [1, 2, 3, 4, 8, 0];
[self assert:[one valueForKey:"@count"] equals:8];
[self assert:[one valueForKeyPath:"@sum.intValue"] equals:8];
[self assert:[one valueForKeyPath:"@sum.intValue"] equals:8];
[self assert:[two valueForKeyPath:"@avg.intValue"] equals:3];
[self assert:[two valueForKeyPath:"@max.intValue"] equals:8];
[self assert:[two valueForKeyPath:"@min.intValue"] equals:0];
@@ -407,8 +407,8 @@
var startTime = new Date();
for(var i=0; i<1000; i++)
[bob setValue:i+"bob" forKey:"name"];
for (var i = 0; i < 1000; i++)
[bob setValue:i + "bob" forKey:"name"];
var total = new Date() - startTime;
@@ -416,8 +416,8 @@
startTime = new Date();
for(var i=0; i<1000; i++)
[bob setValue: i+"bob" forKey:"name"];
for (var i = 0; i < 1000; i++)
[bob setValue: i + "bob" forKey:"name"];
var secondTotal = new Date() - startTime;
@@ -449,19 +449,19 @@
{
case "testDependentKeysPaths": ++observationCount;
break;
case "testAddObserver":
case "testAddObserver":
[self assertTrue: newValue == "set_bob" message: "newValue should be: set_bob was: "+newValue];
[self assertTrue: oldValue == [CPNull null] message: "oldValue should be CPNull was: "+oldValue];
[self assertTrue: anObject == bob message: "anObject should be: "+[bob description]+", was: "+[anObject description]];
break;
case "testUnobservedKey":
case "testUnobservedKey":
[self assertFalse: YES message: "not observing this key, should never get here"];
break;
case "testAddTwoObservers":
case "testAddTwoObservers":
[self assertTrue: newValue == "set_bob" message: "newValue should be: set_bob was: "+newValue];
[self assertTrue: oldValue == [CPNull null] message: "oldValue should be CPNull was: "+oldValue];
break;
case "testDirectIVarObservation":
[self assertTrue: newValue == "555" message: "newValue should be: 555 was: "+newValue];
[self assertTrue: oldValue == [CPNull null] message: "oldValue should be CPNull was: "+oldValue];
@@ -479,10 +479,10 @@
case "testRemoveAllObservers":
[self assertTrue: NO message: "all observers were removed, but notification was still received"];
break;
case "testPriorObservationOption":
var prior = [changes objectForKey:CPKeyValueChangeNotificationIsPriorKey];
if (!_sawPriorObservation)
{
[self assertTrue:prior message:"Have not been sent the prior notification, but it should have been sent"];
@@ -496,7 +496,7 @@
[self assertTrue: newValue == "set_bob" message: "newValue should be: set_bob was: "+newValue];
}
break;
case "testInitialObservationOption":
if (!_sawInitialObservation)
{
@@ -508,13 +508,13 @@
[self assertFalse:YES message:"Should never have received this notification"];
break;
case "testMultipartKey":
[self assertTrue: aKeyPath == "teacher.name" message:"Keypath should be: teacher.name, was: "+aKeyPath];
[self assertTrue: newValue == "set_bob" message:"New value should be: set_bob, was: "+newValue];
[self assertTrue: anObject == cs101 message: "anObject should be: "+[cs101 description]+", was: "+[anObject description]];
break;
case "testRemoveMultipartKey":
[self assertFalse:YES message:"Should never have received this notification"];
break;
@@ -534,7 +534,7 @@
[self assertTrue: newValue.year == "2000" message:"New value should be a car with year: 2000, was: "+[newValue description]];
[self assertTrue: anObject == cs101 message: "anObject should be: "+[cs101 description]+", was: "+[anObject description]];
break;
case "testCrazyKeyPathChanges":
[self assertTrue: [anObject class] == A message:"Should be observing an A class, was: "+[anObject class]];
[self assertTrue: [newValue class] == D message:"Changed class was a D class, got: "+[newValue class]];
@@ -552,7 +552,7 @@
[self assertTrue: newValue == 7 message:"Expected 7, got: "+newValue];
[self assertTrue: aKeyPath == "b.c.d.e.f" message:"Expected keyPath b.c.d.e.f, got: "+aKeyPath];
break;
case "testDependentKeyObservation":
[self assertTrue:aKeyPath === "bobName"
+31 -33
View File
@@ -2,13 +2,13 @@
globalResults = [];
@implementation TestOperation : CPOperation
@implementation TestOperation : CPOperation
{
CPString name @accessors;
CPString value @accessors;
}
- (void)main
- (void)main
{
[self setName:@"test"];
globalResults.push([self value]);
@@ -16,17 +16,16 @@ globalResults = [];
@end
@implementation TestObserver : CPObject
@implementation TestObserver : CPObject
{
CPArray changedKeyPaths @accessors;
}
- (id)init
- (id)init
{
if (self = [super init])
{
if (self = [super init])
changedKeyPaths = [[CPArray alloc] init];
}
return self;
}
@@ -43,30 +42,30 @@ globalResults = [];
@implementation CPOperationQueueTest : OJTestCase
- (void)testAddOperation
- (void)testAddOperation
{
var oq = [[CPOperationQueue alloc] init],
to = [[TestOperation alloc] init];
[self assert:0 equals:[oq operationCount]];
[oq addOperation:to];
[self assert:1 equals:[oq operationCount]];
}
- (void)testAddOperationsWithWaitUntilFinished
- (void)testAddOperationsWithWaitUntilFinished
{
var oq = [[CPOperationQueue alloc] init],
to1 = [[TestOperation alloc] init],
to2 = [[TestOperation alloc] init],
to3 = [[TestOperation alloc] init];
[to3 addDependency:to1];
[to3 addDependency:to2];
[self assert:0 equals:[oq operationCount]];
[oq addOperations:[to1, to2, to3] waitUntilFinished:YES];
//make sure they all ran and are finished...
[self assertTrue:[to1 isFinished]];
[self assertTrue:[to2 isFinished]];
@@ -74,11 +73,11 @@ globalResults = [];
[self assert:@"test" equals:[to1 name]];
[self assert:@"test" equals:[to2 name]];
[self assert:@"test" equals:[to3 name]];
[self assert:3 equals:[oq operationCount]];
}
- (void)testRunOperationsInCorrectOrder
- (void)testRunOperationsInCorrectOrder
{
var oq = [[CPOperationQueue alloc] init],
to1 = [[TestOperation alloc] init];
@@ -97,12 +96,12 @@ globalResults = [];
[to5 setValue:@"high"];
var to6 = [[TestOperation alloc] init];
[to6 setValue:@"also normal"];
globalResults = [];
[oq addOperations:[to3, to4, to5, to6] waitUntilFinished:NO];
[oq waitUntilAllOperationsAreFinished];
[self assertTrue:[to3 isFinished]];
[self assertTrue:[to4 isFinished]];
[self assertTrue:[to5 isFinished]];
@@ -111,7 +110,7 @@ globalResults = [];
[self assert:@"normal" equals:globalResults[1]];
[self assert:@"also normal" equals:globalResults[2]];
[self assert:@"low" equals:globalResults[3]];
globalResults = [];
[oq addOperation:to1];
[oq addOperation:to2];
@@ -120,31 +119,31 @@ globalResults = [];
[self assert:@"very low" equals:globalResults[1]];
}
- (void)testAddOperationWithFunction
- (void)testAddOperationWithFunction
{
var oq = [[CPOperationQueue alloc] init];
globalResults = [];
[oq addOperationWithFunction:function() {globalResults.push("Soylent");}];
[oq waitUntilAllOperationsAreFinished];
[self assert:@"Soylent" equals:globalResults[0]];
}
- (void)testKVO
{
- (void)testKVO
{
var oq = [[CPOperationQueue alloc] init],
obs = [[TestObserver alloc] init];
[oq addObserver:obs
forKeyPath:@"operations"
options:(CPKeyValueObservingOptionNew)
context:NULL];
[oq addObserver:obs
forKeyPath:@"operationCount"
options:(CPKeyValueObservingOptionNew)
context:NULL];
context:NULL];
[oq addObserver:obs
forKeyPath:@"suspended"
options:(CPKeyValueObservingOptionNew)
@@ -153,18 +152,17 @@ globalResults = [];
[oq addObserver:obs
forKeyPath:@"name"
options:(CPKeyValueObservingOptionNew)
context:NULL];
context:NULL];
[oq addOperationWithFunction:function() {globalResults.push("Soylent");}];
[self assert:@"operations" equals:[[obs changedKeyPaths] objectAtIndex:0]];
[self assert:@"operationCount" equals:[[obs changedKeyPaths] objectAtIndex:1]];
[oq setSuspended:YES];
[self assert:@"suspended" equals:[[obs changedKeyPaths] objectAtIndex:2]];
[oq setSuspended:NO];
[self assert:@"suspended" equals:[[obs changedKeyPaths] objectAtIndex:3]];
[oq setName:@"Soylent"];
[self assert:@"name" equals:[[obs changedKeyPaths] objectAtIndex:4]];
}
+40 -42
View File
@@ -6,21 +6,21 @@
CPString value @accessors;
}
- (void)main
- (void)main
{
[self setName:@"test"];
}
@end
@implementation TestObserver : CPObject
@implementation TestObserver : CPObject
{
CPArray changedKeyPaths @accessors;
}
- (id)init
- (id)init
{
if (self = [super init])
if (self = [super init])
{
changedKeyPaths = [[CPArray alloc] init];
}
@@ -44,7 +44,7 @@
{
var co = [[CPOperation alloc] init],
co_dep = [[CPOperation alloc] init];
[co addDependency:co_dep];
[self assert:1 equals:[[co dependencies] count]];
}
@@ -54,26 +54,26 @@
var co = [[CPOperation alloc] init],
co_dep1 = [[CPOperation alloc] init],
co_dep2 = [[CPOperation alloc] init];
[co addDependency:co_dep1];
[co addDependency:co_dep2];
[self assert:2 equals:[[co dependencies] count]];
[co removeDependency:co_dep2];
[self assert:1 equals:[[co dependencies] count]];
[co removeDependency:co_dep2];
[self assert:1 equals:[[co dependencies] count]];
[co removeDependency:co_dep1];
[self assert:0 equals:[[co dependencies] count]];
}
- (void)testCorrectValuesOnInit
- (void)testCorrectValuesOnInit
{
var co = [[CPOperation alloc] init];
[self assertTrue:[co isReady]];
[self assertFalse:[co isCancelled]];
[self assertFalse:[co isConcurrent]];
@@ -82,57 +82,56 @@
[self assert:CPOperationQueuePriorityNormal equals:[co queuePriority]];
}
- (void)testIsReadyWithDependencies
- (void)testIsReadyWithDependencies
{
var co = [[CPOperation alloc] init],
co_dep1 = [[CPOperation alloc] init],
co_dep2 = [[CPOperation alloc] init];
[self assertTrue:[co isReady]];
[co addDependency:co_dep1];
[co addDependency:co_dep2];
[self assertFalse:[co isReady]];
[co_dep1 start];
[self assertFalse:[co isReady]];
[co_dep2 start];
[self assertTrue:[co isReady]];
}
- (void)testCompletionFunction
- (void)testCompletionFunction
{
var to = [[TestOperation alloc] init];
[to setCompletionFunction:function() {[to setValue:@"something"];}];
[to start];
[self assert:@"something" equals:[to value]];
}
// KVO Tests
- (void)testKVO
- (void)testKVO
{
var to = [[TestOperation alloc] init],
to2 = [[TestOperation alloc] init],
obs = [[TestObserver alloc] init];
[to addObserver:obs
forKeyPath:@"isCancelled"
options:(CPKeyValueObservingOptionNew)
context:NULL];
[to addObserver:obs
forKeyPath:@"isExecuting"
options:(CPKeyValueObservingOptionNew)
context:NULL];
context:NULL];
[to addObserver:obs
forKeyPath:@"isFinished"
options:(CPKeyValueObservingOptionNew)
@@ -141,12 +140,12 @@
[to addObserver:obs
forKeyPath:@"isReady"
options:(CPKeyValueObservingOptionNew)
context:NULL];
context:NULL];
[to addObserver:obs
forKeyPath:@"dependencies"
options:(CPKeyValueObservingOptionNew)
context:NULL];
context:NULL];
[to addObserver:obs
forKeyPath:@"queuePriority"
@@ -156,9 +155,8 @@
[to addObserver:obs
forKeyPath:@"completionFunction"
options:(CPKeyValueObservingOptionNew)
context:NULL];
context:NULL];
[to addDependency:to2];
[self assert:@"dependencies" equals:[[obs changedKeyPaths] objectAtIndex:0]];
[self assert:@"isReady" equals:[[obs changedKeyPaths] objectAtIndex:1]];
@@ -166,20 +164,20 @@
[self assert:@"isReady" equals:[[obs changedKeyPaths] objectAtIndex:2]];
[to removeDependency:to2];
[self assert:@"dependencies" equals:[[obs changedKeyPaths] objectAtIndex:3]];
[to setQueuePriority:CPOperationQueuePriorityHigh];
[to setQueuePriority:CPOperationQueuePriorityHigh];
[self assert:@"queuePriority" equals:[[obs changedKeyPaths] objectAtIndex:4]];
[to setCompletionFunction:function() {}];
[self assert:@"completionFunction" equals:[[obs changedKeyPaths] objectAtIndex:5]];
[to setCompletionFunction:function() {}];
[self assert:@"completionFunction" equals:[[obs changedKeyPaths] objectAtIndex:5]];
// this should set executing = yes, executing = no, finished = yes.
[to start];
[self assert:@"isExecuting" equals:[[obs changedKeyPaths] objectAtIndex:6]];
[self assert:@"isExecuting" equals:[[obs changedKeyPaths] objectAtIndex:7]];
[self assert:@"isExecuting" equals:[[obs changedKeyPaths] objectAtIndex:7]];
[self assert:@"isFinished" equals:[[obs changedKeyPaths] objectAtIndex:8]];
[to cancel];
[self assert:@"isCancelled" equals:[[obs changedKeyPaths] objectAtIndex:9]];
}
@end
@end
+43 -41
View File
@@ -6,19 +6,19 @@
- (void)testStringByReplacingOccurrencesOfStringWithString
{
var expectedString = @"hello world. A new world!";
var dummyString = @"hello woold. A new woold!";
var actualString = [dummyString stringByReplacingOccurrencesOfString:@"woold" withString:@"world"];
[self assertTrue:(expectedString === actualString)
var expectedString = @"hello world. A new world!",
dummyString = @"hello woold. A new woold!",
actualString = [dummyString stringByReplacingOccurrencesOfString:@"woold" withString:@"world"];
[self assertTrue:(expectedString === actualString)
message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString];
}
- (void)testStringByReplacingWithRegexCharacters
{
var stringToTest = "${foo} {foo}",
result = [stringToTest stringByReplacingOccurrencesOfString:"${foo}" withString:"BAR"];
[self assert:result equals:"BAR {foo}"];
}
@@ -28,8 +28,8 @@
expectedString = "2 X 3 = 6",
dummyString = @"",
actualString = [dummyString stringByAppendingFormat:format, 2, 3, 6];
[self assertTrue:(expectedString === actualString)
[self assertTrue:(expectedString === actualString)
message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString];
}
@@ -57,7 +57,7 @@
[self assert:"42" equals:str];
str = [[CPString alloc] initWithFormat:"%f", 42.2];
[self assert:"42.2" equals:str];
[self assert:"42.2" equals:str];
}
- (void)testStringWithFormat
@@ -70,7 +70,7 @@
[self assert:"42" equals:str];
str = [CPString stringWithFormat:"%f", 42.2];
[self assert:"42.2" equals:str];
[self assert:"42.2" equals:str];
}
- (void)testLength
@@ -97,16 +97,16 @@
- (void)testStringByPaddingToLength
{
[self assert:"onebcd"
equals:["one" stringByPaddingToLength:6
withString:"abcdefg"
startingAtIndex:1]];
[self assert:"onebcd"
equals:["one" stringByPaddingToLength:6
withString:"abcdefg"
startingAtIndex:1]];
}
- (void)testComponentsSeparatedByString
{
[self assert:["arash", "francisco", "ross", "tom"]
equals:["arash.francisco.ross.tom" componentsSeparatedByString:"."]];
equals:["arash.francisco.ross.tom" componentsSeparatedByString:"."]];
}
- (void)testSubstringFromIndex
@@ -146,9 +146,9 @@
[" -N00", NO],
[" 00", NO],
[" -00", NO],
[" -+001", NO],
[" -+001", NO],
];
for (var i = 0; i < testStrings.length; i++)
[self assert:[testStrings[i][0] boolValue] equals:testStrings[i][1]];
}
@@ -161,14 +161,14 @@
["Abcd", "Abcd", "Abcd"],
["A long string", "A longer string", "A long"]
];
var testStringsCaseless = [
["hElLo", "HeLiCoPtEr", "hEl"],
["tEsTeR", "TaSeR", "t"],
["aBcD", "AbCd", "aBcD"],
["a LoNg StRiNg", "A lOnGeR sTrInG", "a LoNg"]
];
for (var i = 0; i < testStringsCase.length; i++)
[self assert: [testStringsCase[i][0] commonPrefixWithString:testStringsCase[i][1]]
equals: testStringsCase[i][2]];
@@ -187,9 +187,9 @@
[" monkey-Cow", " Monkey-cow"],
["tHe QuicK bRowN-Fox JumPed_Over +the LaZy%dog", "The Quick Brown-fox Jumped_over +the Lazy%dog"]
];
for (var i = 0; i < testStrings.length; i++)
[self assert:[testStrings[i][0] capitalizedString] equals:testStrings[i][1]];
[self assert:[testStrings[i][0] capitalizedString] equals:testStrings[i][1]];
}
- (void)testUppercaseString
@@ -197,7 +197,7 @@
var str = "This is a test";
[self assert:[str uppercaseString] equals:"THIS IS A TEST"];
}
- (void)testLowercaseString
{
var str = "This Is A TEST";
@@ -239,10 +239,12 @@
var testStrings = [
["tmp/scratch", ["tmp", "scratch"]],
["/tmp/scratch", ["/", "tmp", "scratch"]]
]
for (var i = 0; i < testStrings.length; i++) {
];
for (var i = 0; i < testStrings.length; i++)
{
var result = [testStrings[i][0] pathComponents];
[self assertTrue:[result isEqualToArray:testStrings[i][1]] message:"Expected [" + testStrings[i][1] + "] was [" + result + "]"];
}
}
@@ -256,7 +258,7 @@
["scratch", "scratch"],
["/", "/"]
];
for (var i = 0; i < testStrings.length; i++)
[self assert:testStrings[i][1] equals:[testStrings[i][0] lastPathComponent]];
}
@@ -270,7 +272,7 @@
["/tmp", ""],
["scratch", ""],
];
for (var i = 0; i < testStrings.length; i++)
[self assert:testStrings[i][1] equals:[testStrings[i][0] pathExtension]];
}
@@ -316,40 +318,40 @@
- (void)testComponentsSeparatedByCharactersInSetEmptyString
{
[self assert:[""]
equals:["" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
[self assert:[""]
equals:["" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersInSetStringWithoutCharactersFromSet
{
[self assert:["Abradab"]
equals:["Abradab" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
[self assert:["Abradab"]
equals:["Abradab" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersInSet
{
[self assert:["Baku", "baku", "to", "jest", "", "skład."]
equals:["Baku baku to jest skład." componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
[self assert:["Baku", "baku", "to", "jest", "", "skład."]
equals:["Baku baku to jest skład." componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersInSetLeadingAndTrailingCharacterFromSet
{
[self assert:["", "Test", ""]
equals:[" Test " componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
[self assert:["", "Test", ""]
equals:[" Test " componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersExceptionRaiseOnNilSeparator
- (void)testComponentsSeparatedByCharactersExceptionRaiseOnNilSeparator
{
try
try
{
[[CPString string] componentsSeparatedByCharactersInSet:nil];
[self assert:false];
[self assert:false];
}
catch (anException)
{
[self assert:[anException name] equals:CPInvalidArgumentException];
{
[self assert:[anException name] equals:CPInvalidArgumentException];
[self assert:[anException reason] equals:@"componentsSeparatedByCharactersInSet: the separator can't be 'nil'"];
}
}
}
- (void)testIsEqual
+22 -18
View File
@@ -2,32 +2,32 @@
@implementation MyDict : CPDictionary
{
int a;
int a;
}
+ (id)alloc
{
return class_createInstance(self);
return class_createInstance(self);
}
- (id)init
{
self = [super init];
if(self)
{
_a = "Bob";
}
return self;
self = [super init];
if (self)
_a = "Bob";
return self;
}
- (CPString)secondaryName
{
return "Saget";
return "Saget";
}
- (CPString)name
{
return _a;
return _a;
}
@end
@@ -37,26 +37,30 @@
- (void)testThatMyDictContainsReplacedNameSelector
{
var target = [[MyDict alloc] init];
[OJAssert assert:@"Bob" equals:[target name]];
var target = [[MyDict alloc] init];
[OJAssert assert:@"Bob" equals:[target name]];
}
- (void)testThatMyDictDoesHaveNewSelector
{
var target = [[MyDict alloc] init];
[OJAssert assert:@"Saget" equals:[target secondaryName]];
var target = [[MyDict alloc] init];
[OJAssert assert:@"Saget" equals:[target secondaryName]];
}
- (void)testThatDictionaryDoesNotHaveReplacedName
{
var target = [[CPDictionary alloc] init];
[OJAssert assert:@"Bob" notEqual:[target name]];
var target = [[CPDictionary alloc] init];
[OJAssert assert:@"Bob" notEqual:[target name]];
}
- (void)testThatTollFreeDoesNotHaveNewSelector
{
var target = {};
[OJAssert assertThrows:function() { [target secondaryName]; }];
var target = {};
[OJAssert assertThrows:function() { [target secondaryName]; }];
}
@end
+8 -10
View File
@@ -15,7 +15,6 @@ var exampleProtocol = "http",
@implementation CPURLTest : OJTestCase
{
}
- (void)testAbsolute
@@ -23,17 +22,17 @@ var exampleProtocol = "http",
var pathString = exampleFullPath,
urlString = exampleURL,
url = [CPURL URLWithString:urlString];
[self assert:[url baseURL] equals:nil];
[self assert:[url relativeString] equals:urlString];
[self assert:[url absoluteString] equals:urlString];
[self assert:[url relativePath] equals:pathString];
[self assert:[url path] equals:pathString];
[self assert:[url absoluteURL] same:url];
[self assert:[url scheme] equals:exampleProtocol];
[self assert:[url user] equals:exampleUser];
[self assert:[url password] equals:examplePassword];
@@ -41,7 +40,7 @@ var exampleProtocol = "http",
[self assert:[url port] equals:examplePort];
[self assert:[url parameterString] equals:exampleQuery];
[self assert:[url fragment] equals:exampleAnchor];
[self assert:[url pathExtension] equals:"php"];
[self assert:[url lastPathComponent] equals:examplePathRelative];
}
@@ -55,13 +54,13 @@ var exampleProtocol = "http",
url = [CPURL URLWithString:urlString relativeToURL:baseURL];
[self assert:[url baseURL] equals:baseURL];
[self assert:[url relativeString] equals:urlString];
[self assert:[url absoluteString] equals:exampleURL];
[self assert:[url relativePath] equals:pathString];
[self assert:[url path] equals:exampleFullPath];
[self assert:[url absoluteURL] notSame:url];
[self assert:[url scheme] equals:exampleProtocol];
@@ -102,7 +101,6 @@ var exampleProtocol = "http",
[self assert:[url pathExtension] equals:"php"];
[self assert:[url lastPathComponent] equals:examplePathRelative];
}
- (void)testURLToString
+21 -21
View File
@@ -98,48 +98,48 @@ CPLogRegister(CPLogConsole);
- (void)createBindings
{
// bind array controller to self's itemsArray
// bind array controller to self's itemsArray
[arrayController bind:@"contentArray" toObject:self
withKeyPath:@"itemsArray" options:nil];
withKeyPath:@"itemsArray" options:nil];
// bind the total field -- no options on this one
// Currently broken, crashes the app as it tries to pull valueForKey @sum at some point.
//[totalCountField bind:CPValueBinding toObject:arrayController
// withKeyPath:@"arrangedObjects.@sum.price" options:nil];
//[totalCountField bind:CPValueBinding toObject:arrayController
// withKeyPath:@"arrangedObjects.@sum.price" options:nil];
var bindingOptions = [CPDictionary dictionary];
var bindingOptions = [CPDictionary dictionary];
// binding options for "name"
//[bindingOptions setObject:@"No Name" forKey:@"NSNullPlaceholder"];
// binding options for "name"
//[bindingOptions setObject:@"No Name" forKey:@"NSNullPlaceholder"];
// binding for selected "name" field
// binding for selected "name" field
//[selectedNameField bind: @"value" toObject: arrayController
// withKeyPath:@"selection.name" options:bindingOptions];
// withKeyPath:@"selection.name" options:bindingOptions];
// binding for "name" column
// binding for "name" column
var tableColumn = [tableView tableColumnWithIdentifier:@"name"];
[tableColumn bind:@"value" toObject: arrayController
withKeyPath:@"arrangedObjects.name" options:bindingOptions];
[tableColumn bind:@"value" toObject: arrayController
withKeyPath:@"arrangedObjects.name" options:bindingOptions];
// binding options for "price"
// no need for placeholder as overridden by formatters
//[bindingOptions removeObjectForKey:@"NSNullPlaceholder"];
// no need for placeholder as overridden by formatters
//[bindingOptions removeObjectForKey:@"NSNullPlaceholder"];
//[bindingOptions setObject:YES
// forKey:CPValidatesImmediatelyBindingOption];
//[bindingOptions setObject:YES
// forKey:CPValidatesImmediatelyBindingOption];
// binding for selected "price" field
//[selectedPriceField bind: @"value" toObject: arrayController
// withKeyPath:@"selection.price" options:bindingOptions];
// binding for selected "price" field
//[selectedPriceField bind: @"value" toObject: arrayController
// withKeyPath:@"selection.price" options:bindingOptions];
// binding for "price" column
// binding for "price" column
tableColumn = [tableView tableColumnWithIdentifier:@"price"];
[tableColumn bind:@"value" toObject: arrayController
withKeyPath:@"arrangedObjects.price" options:bindingOptions];
withKeyPath:@"arrangedObjects.price" options:bindingOptions];
tableColumn = [tableView tableColumnWithIdentifier:@"all right"];
+40 -44
View File
@@ -16,7 +16,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
@implementation Menu : CPObject
{
Menu _menu @accessors(property=menu);
CPString _title @accessors(property=title);
CPArray _children @accessors(property=children);
}
@@ -43,7 +43,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
_title = theTitle;
[self setChildren:theChildren];
}
return self;
}
@@ -55,35 +55,31 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
- (void)insertSubmenu:(Menu)theItem atIndex:(int)theIndex
{
// CPLog.debug(@"insert menu: %@ in menu: %@ at index: %i", theItem, self, theIndex);
if ([[self children] containsObject:theItem])
return;
if ([theItem menu])
[theItem removeFromMenu];
[theItem setMenu:self];
if (theIndex === -1)
{
[[self children] addObject:theItem];
}
else
{
[[self children] insertObject:theItem atIndex:theIndex];
}
[[self children] insertObject:theItem atIndex:theIndex];
// CPLog.debug(@"%@ children: %@", self, [self children]);
}
- (void)removeFromMenu
{
// CPLog.debug(@"remove menu: %@ from menu: %@", self, [self menu]);
[[[self menu] children] removeObject:self];
CPLog.debug([[self menu] children]);
[self setMenu:nil];
}
@@ -91,10 +87,10 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
if (theChildren === nil)
theChildren = [];
if (_children === theChildren)
return;
var childIndex = [theChildren count];
while (childIndex--)
{
@@ -113,7 +109,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
_title = [theCoder decodeObjectForKey:@"MenuTitleKey"];
[self setChildren:[theCoder decodeObjectForKey:@"MenuChildrenKey"]];
}
return self;
}
@@ -130,7 +126,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
Menu _menu @accessors(property=menu);
CPOutlineView _outlineView;
CPArray _draggedItems;
}
@@ -187,26 +183,25 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
// ]]
// ]]
]];
var scrollView = [[CPScrollView alloc] initWithFrame:[contentView bounds]];
_outlineView = [[CPOutlineView alloc] initWithFrame:[contentView bounds]];
var column = [[CPTableColumn alloc] initWithIdentifier:@"One"];
[_outlineView addTableColumn:column];
[_outlineView setOutlineTableColumn:column];
[_outlineView addTableColumn:[[CPTableColumn alloc] initWithIdentifier:@"Two"]];
[_outlineView registerForDraggedTypes:[CustomOutlineViewDragType]];
[_outlineView setDataSource:self];
[_outlineView setAllowsMultipleSelection:YES];
[_outlineView expandItem:nil expandChildren:YES];
// [_outlineView setRowHeight:50.0];
// [_outlineView setRowHeight:50.0];
// [_outlineView setIntercellSpacing:CPSizeMake(0.0, 10.0)]
[scrollView setDocumentView:_outlineView];
[theWindow setContentView:scrollView];
@@ -221,9 +216,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
if (theItem === nil)
theItem = [self menu];
// CPLog.debug(@"child: %i ofItem:%@ : %@", theIndex, theItem, [[theItem children] objectAtIndex:theIndex]);
return [[theItem children] objectAtIndex:theIndex];
}
@@ -231,9 +226,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
if (theItem === nil)
theItem = [self menu];
// CPLog.debug(@"isItemExpandable:%@ : %@", theItem, [[theItem children] count] > 0);
return [[theItem children] count] > 0;
}
@@ -241,9 +236,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
if (theItem === nil)
theItem = [self menu];
// CPLog.debug(@"numberOfChildrenOfItem:%@ : %i", theItem, [[theItem children] count]);
return [[theItem children] count];
}
@@ -251,31 +246,31 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
// if ([theColumn identifier] === @"Two")
// return @"Two";
if (theItem === nil)
theItem = [self menu];
// CPLog.debug(@"objectValueForTableColumn:%@ byItem:%@ : %@", theColumn, theItem, [theItem title]);
return [theItem title];
}
- (BOOL)outlineView:(CPOutlineView)anOutlineView writeItems:(CPArray)theItems toPasteboard:(CPPasteBoard)thePasteBoard
{
_draggedItems = theItems;
[thePasteBoard declareTypes:[CustomOutlineViewDragType] owner:self];
[thePasteBoard declareTypes:[CustomOutlineViewDragType] owner:self];
[thePasteBoard setData:[CPKeyedArchiver archivedDataWithRootObject:theItems] forType:CustomOutlineViewDragType];
return YES;
}
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id < CPDraggingInfo >)theInfo proposedItem:(id)theItem proposedChildIndex:(int)theIndex
{
CPLog.debug(@"validate item: %@ at index: %i", theItem, theIndex);
if (theItem === nil)
[anOutlineView setDropItem:nil dropChildIndex:theIndex];
[anOutlineView setDropItem:theItem dropChildIndex:theIndex];
return CPDragOperationEvery;
@@ -285,16 +280,17 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
{
if (theItem === nil)
theItem = [self menu];
// CPLog.debug(@"drop item: %@ at index: %i", theItem, theIndex);
var menuIndex = [_draggedItems count];
while (menuIndex--)
{
var menu = [_draggedItems objectAtIndex:menuIndex];
// CPLog.debug(@"move item: %@ to: %@ index: %@", menu, theItem, theIndex);
if (menu === theItem)
continue;
@@ -302,7 +298,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
[theItem insertSubmenu:menu atIndex:theIndex];
theIndex += 1;
}
return YES;
}
+14 -15
View File
@@ -20,45 +20,44 @@
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
[theWindow orderFront:self];
scrollViewXCount = 0;
scrollViewYCount = 0;
// Vanilla scrollview
var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(0,0,900,675)];
[imageView setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"photo.jpg"]]];
var scrollView = [self makeScrollview];
[scrollView setDocumentView:imageView];
[[theWindow contentView] addSubview:scrollView];
// Scrollview with a CPTextField in it
var textField = [CPTextField textFieldWithStringValue:@"Try to select this" placeholder:@"" width:120];
[textField setFrameOrigin:CGPointMake(20,20)];
[textField setSelectable:YES];
var scrollView = [self makeScrollview];
[[scrollView documentView] addSubview:textField];
[[theWindow contentView] addSubview:scrollView];
// In another window
var aWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(120,400,400,300) styleMask:CPTitledWindowMask];
[aWindow setTitle:@"Scrollview in a ScrollView in a Window."]
[aWindow orderFront:nil];
// Scrollview with another scrollview in it
var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(0,0,900,675)];
[imageView setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"photo.jpg"]]];
var innerScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(20, 20, 150, 150)];
[innerScrollView setDocumentView:imageView];
var scrollView = [self makeScrollview];
[scrollView setFrameOrigin:CGPointMake(20,20)]
[[scrollView documentView] addSubview:innerScrollView];
[[aWindow contentView] addSubview:scrollView];
}
@@ -67,15 +66,15 @@
{
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake((scrollViewXCount * 320) + 120, (scrollViewYCount * 220) + 100, 300, 200)];
[scrollView setDocumentView:[[CPView alloc] initWithFrame:CGRectMake(0,0,1000,1000)]];
scrollViewXCount += 1;
if (scrollViewXCount === 3)
{
scrollViewXCount = 0;
scrollViewYCount += 1;
}
return scrollView;
}
+49 -82
View File
@@ -1,65 +1,54 @@
/*
* AppController.j
* CPSearchField
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
* Created by cacaodev on November 27, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
var categories = ["firstName","lastName"],
MenuItemPrefix = @" ";
@implementation AppController : CPObject
{
CPSearchField searchField;
CPTableView table;
CPArray tableArray;
CPArray filteredArray;
CPMenu searchMenuTemplate;
CPArray searchCategoryIndexes;
CPInteger searchCategoryIndex;
CPWindow theWindow;
CPTextField predicateField;
CPSearchField searchField;
CPMenu searchMenuTemplate;
CPArray searchCategoryIndexes;
CPInteger searchCategoryIndex;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
searchCategoryIndex = 0;
searchCategoryIndexes = [CPArray arrayWithArray:[1, 2]];
var theWindow = [[CPWindow alloc] initWithContentRect:CPMakeRect(0,10,500,300) styleMask:CPTitledWindowMask|CPResizableWindowMask],
contentView = [theWindow contentView];
var searchFieldContainer = [[CPView alloc] initWithFrame:CPMakeRect(10,10,220,50)];
[searchFieldContainer setBackgroundColor:[CPColor redColor]];
[searchFieldContainer setAutoresizingMask:CPViewWidthSizable];
searchField = [[CPSearchField alloc] initWithFrame:CPMakeRect(10,10,200,30)];
searchCategoryIndex = 0;
searchCategoryIndexes = [CPArray arrayWithArray:[1, 2]];
searchField = [[CPSearchField alloc] initWithFrame:CPMakeRect(30,72,150,30)];
[searchField setRecentsAutosaveName:"autosave"];
[searchField setTarget:self];
[searchField setAction:@selector(updateFilter:)];
[searchField setAutoresizingMask:CPViewWidthSizable];
[searchField setAutoresizingMask:CPViewMaxXMargin|CPViewMaxYMargin];
searchMenuTemplate = [searchField defaultSearchMenuTemplate];
[searchMenuTemplate insertItemWithTitle:@"Search By"
action:nil
action:nil
keyEquivalent:@""
atIndex:0];
var item = [[CPMenuItem alloc] initWithTitle:MenuItemPrefix + @"First Name"
action:@selector(changeCategory:)
keyEquivalent:@""];
[item setTarget:self];
[item setTag:1];
[item setState:CPOnState];
[searchMenuTemplate insertItem:item atIndex:1];
item = [[CPMenuItem alloc] initWithTitle:MenuItemPrefix + @"Last Name"
action:@selector(changeCategory:)
keyEquivalent:@""];
@@ -69,7 +58,7 @@ var categories = ["firstName","lastName"],
[searchMenuTemplate insertItem:item atIndex:2];
[searchField setSearchMenuTemplate:searchMenuTemplate];
var button = [[CPButton alloc] initWithFrame:CGRectMakeZero()];
[button setBackgroundColor:[CPColor greenColor]];
[button setBordered:NO];
@@ -79,83 +68,61 @@ var categories = ["firstName","lastName"],
[button setBackgroundColor:[CPColor blueColor]];
[button setBordered:NO];
[searchField setCancelButton:button];
[searchFieldContainer addSubview:searchField];
[contentView addSubview:searchFieldContainer];
tableArray = [CPArray arrayWithObjects:
[CPDictionary dictionaryWithObjects:["Jimmy","McNulty",46] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Kima","Greggs",41] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Lester","Freamon",57] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Kevin ","Russel",37] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["William","Moreland",53] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Cedric","Daniels",47] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Roland","Pryzbylewski",27] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Omar","Little",29] forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Avon","Barkstale",49] forKeys:["firstName","lastName","age"]],
nil];
filteredArray = tableArray;
table = [[CPTableView alloc] initWithFrame:CPMakeRect(10,60,300,300)];
[table setUsesAlternatingRowBackgroundColors:YES];
var colone = [[CPTableColumn alloc] initWithIdentifier:@"firstName"];
[colone setWidth:150];
[table addTableColumn:colone];
var coltwo = [[CPTableColumn alloc] initWithIdentifier:@"lastName"];
[coltwo setWidth:150];
[table addTableColumn:coltwo];
[table setDataSource:self];
[contentView addSubview:table];
[[theWindow contentView] addSubview:searchField];
[self changeCategory:[[searchField menu] itemAtIndex:1]];
[self updateFilter:nil];
[self updateFilter:searchField];
[theWindow center];
[theWindow orderFront:self];
[theWindow orderFront:self];
}
- (int)numberOfRowsInTableView:(CPTableView)aTableView
- (void)awakeFromCib
{
return [filteredArray count];
[theWindow setBackgroundColor:[CPColor colorWithHexString:@"f3f4f5"]];
[theWindow setFullBridge:YES];
}
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aTableColumn row:(int)rowIndex
- (IBAction)sendsWholeSearchString:(id)sender
{
return [filteredArray[rowIndex] objectForKey:[aTableColumn identifier]];
[searchField setSendsWholeSearchString:[sender state]];
}
- (IBAction)searchesImmediately:(id)sender
{
[searchField setSendsSearchStringImmediately:[sender state]];
}
- (void)changeCategory:(CPMenuItem)menuItem
{
searchCategoryIndex = [menuItem tag] - 1;
[searchField setPlaceholderString:[[menuItem title] substringFromIndex:[MenuItemPrefix length]]];
[self _updateSearchMenuTemplate];
}
- (void)_updateSearchMenuTemplate
{
for (var i = 0; i < searchCategoryIndexes.length; ++i)
[[searchMenuTemplate itemAtIndex:i + 1] setState:CPOffState];
[[searchMenuTemplate itemAtIndex:searchCategoryIndex + 1] setState:CPOnState];
[[searchMenuTemplate itemAtIndex:i + 1] setState:CPOffState];
[[searchMenuTemplate itemAtIndex:searchCategoryIndex + 1] setState:CPOnState];
[searchField setSearchMenuTemplate:searchMenuTemplate];
}
- (void)updateFilter:(id)sender
{
var searchString = [searchField stringValue];
filteredArray = [self filteredArrayWithString:searchString];
[table reloadData];
var searchString = [sender stringValue];
[self filteredArrayWithString:searchString];
}
- (CPArray)filteredArrayWithString:(CPString)string
- (void)filteredArrayWithString:(CPString)value
{
var keyPath = categories[searchCategoryIndex];
CPLogConsole("Filter the table here. Predicate would be *" + keyPath + " CONTAINS '" + string + "'*");
return tableArray;
var keyPath = categories[searchCategoryIndex],
predicate = [CPPredicate predicateWithFormat:@"%K CONTAINS %@", keyPath, value];
[predicateField setStringValue:[predicate predicateFormat]];
}
@end
+3 -3
View File
@@ -2,10 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>Hello World</string>
<string>CPSearchField</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
+94
View File
@@ -0,0 +1,94 @@
/*
* Jakefile
* CPSearchField
*
* Created by You on November 27, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("CPSearchField", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "CPSearchField.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPSearchField");
task.setIdentifier("com.yourcompany.CPSearchField");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPSearchField");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["CPSearchField"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "CPSearchField", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "CPSearchField", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "CPSearchField"));
OS.system(["press", "-f", FILE.join("Build", "Release", "CPSearchField"), FILE.join("Build", "Deployment", "CPSearchField")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "CPSearchField"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPSearchField"), FILE.join("Build", "Desktop", "CPSearchField", "CPSearchField.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "CPSearchField", "CPSearchField.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPSearchField"));
print("----------------------------");
}
@@ -0,0 +1 @@
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;4E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;7E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;9E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;2;10E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;2;11E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;2;12E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;2;13E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;2;14E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;16E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;18E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;20E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;2;36E;D;K;6;CP$UIDd;2;38E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;39E;D;K;6;CP$UIDd;2;40E;D;K;6;CP$UIDd;2;41E;D;K;6;CP$UIDd;2;42E;D;K;6;CP$UIDd;2;43E;D;K;6;CP$UIDd;2;44E;D;K;6;CP$UIDd;2;45E;D;K;6;CP$UIDd;2;46E;D;K;6;CP$UIDd;2;47E;D;K;6;CP$UIDd;2;48E;D;K;6;CP$UIDd;2;49E;D;K;6;CP$UIDd;2;50E;D;K;6;CP$UIDd;2;51E;D;K;6;CP$UIDd;2;52E;D;K;6;CP$UIDd;2;53E;D;K;6;CP$UIDd;2;54E;D;K;6;CP$UIDd;2;55E;D;K;6;CP$UIDd;2;56E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;58E;D;K;6;CP$UIDd;2;59E;D;K;6;CP$UIDd;2;60E;D;K;6;CP$UIDd;2;61E;D;K;6;CP$UIDd;2;62E;D;K;6;CP$UIDd;2;64E;D;K;6;CP$UIDd;2;65E;D;K;6;CP$UIDd;2;66E;E;E;S;16;IBCocoaFrameworkD;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;20E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;2;36E;D;K;6;CP$UIDd;2;23E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;2;36E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;26E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;15E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;67E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;68E;E;D;K;10;$classnameS;10;CPMenuItemK;8;$classesA;S;10;CPMenuItemS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;19E;K;18;CPMenuItemTitleKeyD;K;6;CP$UIDd;2;69E;K;19;CPMenuItemTargetKeyD;K;6;CP$UIDd;1;0E;K;19;CPMenuItemActionKeyD;K;6;CP$UIDd;1;0E;K;16;CPMenuItemTagKeyD;K;6;CP$UIDd;2;70E;K;18;CPMenuItemStateKeyD;K;6;CP$UIDd;1;0E;K;17;CPMenuItemMenuKeyD;K;6;CP$UIDd;2;38E;E;D;K;6;$classD;K;6;CP$UIDd;2;15E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;71E;E;D;K;10;$classnameS;11;CPTextFieldK;8;$classesA;S;11;CPTextFieldS;9;CPControlS;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;22E;K;27;CPResponderNextResponderKeyD;K;6;CP$UIDd;2;26E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;72E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;73E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;74E;K;18;CPViewSuperviewKeyD;K;6;CP$UIDd;2;26E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;75E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;2;76E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;77E;K;6;$afontD;K;6;CP$UIDd;2;79E;K;17;$aline-break-modeD;K;6;CP$UIDd;2;72E;K;11;$aalignmentD;K;6;CP$UIDd;2;80E;K;17;CPControlValueKeyD;K;6;CP$UIDd;2;81E;K;24;CPControlSendActionOnKeyD;K;6;CP$UIDd;2;82E;K;24;CPTextFieldIsEditableKeyD;K;6;CP$UIDd;2;83E;K;26;CPTextFieldIsSelectableKeyD;K;6;CP$UIDd;2;83E;K;29;CPTextFieldDrawsBackgroundKeyD;K;6;CP$UIDd;2;83E;K;29;CPTextFieldBackgroundColorKeyD;K;6;CP$UIDd;1;0E;K;27;CPTextFieldLineBreakModeKeyD;K;6;CP$UIDd;2;72E;K;23;CPTextFieldAlignmentKeyD;K;6;CP$UIDd;2;80E;K;31;CPTextFieldPlaceholderStringKeyD;K;6;CP$UIDd;2;84E;E;D;K;6;$classD;K;6;CP$UIDd;2;19E;K;18;CPMenuItemTitlLine truncated
@@ -0,0 +1,557 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10H574</string>
<string key="IBDocument.InterfaceBuilderVersion">823</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">823</string>
</object>
<array class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<integer value="372"/>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<object class="NSCustomObject" id="1021">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomObject" id="1014">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1050">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="972006081">
<int key="NSWindowStyleMask">7</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{335, 468}, {598, 282}}</string>
<int key="NSWTFlags">1946157056</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="439893737">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSSearchField" id="206425598">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{286, 183}, {154, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSearchFieldCell" key="NSCell" id="835402208">
<int key="NSCellFlags">343014976</int>
<int key="NSCellFlags2">1024</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="532939748">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSPlaceholderString">From Nib</string>
<reference key="NSControlView" ref="206425598"/>
<bool key="NSDrawsBackground">YES</bool>
<int key="NSTextBezelStyle">1</int>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="631143110">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
<object class="NSButtonCell" key="NSSearchButtonCell">
<int key="NSCellFlags">130560</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">search</string>
<reference key="NSControlView" ref="206425598"/>
<string key="NSAction">_searchFieldSearch:</string>
<reference key="NSTarget" ref="835402208"/>
<int key="NSButtonFlags">138690815</int>
<int key="NSButtonFlags2">0</int>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
<object class="NSButtonCell" key="NSCancelButtonCell">
<int key="NSCellFlags">130560</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">clear</string>
<array class="NSMutableArray" key="NSAccessibilityOverriddenAttributes">
<dictionary class="NSMutableDictionary">
<string key="AXDescription">cancel</string>
<integer value="1" key="NSAccessibilityEncodedAttributesValueType"/>
</dictionary>
</array>
<reference key="NSControlView" ref="206425598"/>
<string key="NSAction">_searchFieldCancel:</string>
<reference key="NSTarget" ref="835402208"/>
<int key="NSButtonFlags">138690815</int>
<int key="NSButtonFlags2">0</int>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
<string key="NSRecentsAutosaveName">autosavenib</string>
<int key="NSMaximumRecents">5</int>
<bytes key="NSSearchFieldFlags">CAAAAA</bytes>
</object>
</object>
<object class="NSButton" id="731799349">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{30, 246}, {159, 18}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="144038324">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">Searches Immediately</string>
<reference key="NSSupport" ref="532939748"/>
<reference key="NSControlView" ref="731799349"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage" id="262257347">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage" id="65352156">
<string key="NSImageName">NSSwitch</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSButton" id="885120521">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{30, 219}, {194, 18}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="991102315">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">Sends Whole Search String</string>
<reference key="NSSupport" ref="532939748"/>
<reference key="NSControlView" ref="885120521"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="262257347"/>
<reference key="NSAlternateImage" ref="65352156"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSTextField" id="299743148">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">266</int>
<string key="NSFrame">{{29, 110}, {544, 34}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1048478045">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">138412032</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">18</double>
<int key="NSfFlags">16</int>
</object>
<string key="NSPlaceholderString">Predicate</string>
<reference key="NSControlView" ref="299743148"/>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<reference key="NSTextColor" ref="631143110"/>
</object>
</object>
</array>
<string key="NSFrameSize">{598, 282}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
</object>
<object class="NSCustomObject" id="635946545">
<string key="NSClassName">AppController</string>
</object>
<object class="NSMenu" id="8029352">
<string key="NSTitle"/>
<array class="NSMutableArray" key="NSMenuItems">
<object class="NSMenuItem" id="250718973">
<reference key="NSMenu" ref="8029352"/>
<string key="NSTitle">Recent Searches</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<object class="NSCustomResource" key="NSOnImage" id="759953428">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="294311636">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
<int key="NSTag">1000</int>
</object>
<object class="NSMenuItem" id="164911549">
<reference key="NSMenu" ref="8029352"/>
<string key="NSTitle">Recent Search Item</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="759953428"/>
<reference key="NSMixedImage" ref="294311636"/>
<int key="NSTag">1001</int>
</object>
<object class="NSMenuItem" id="295260886">
<reference key="NSMenu" ref="8029352"/>
<string key="NSTitle">Clear Recent</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="759953428"/>
<reference key="NSMixedImage" ref="294311636"/>
<int key="NSTag">1002</int>
</object>
<object class="NSMenuItem" id="235967825">
<reference key="NSMenu" ref="8029352"/>
<string key="NSTitle">No Recent</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="759953428"/>
<reference key="NSMixedImage" ref="294311636"/>
<int key="NSTag">1003</int>
</object>
</array>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="635946545"/>
</object>
<int key="connectionID">451</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">theWindow</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="972006081"/>
</object>
<int key="connectionID">459</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1050"/>
<reference key="destination" ref="635946545"/>
</object>
<int key="connectionID">467</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">sendsWholeSearchString:</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="885120521"/>
</object>
<int key="connectionID">477</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">searchesImmediately:</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="731799349"/>
</object>
<int key="connectionID">478</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">predicateField</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="299743148"/>
</object>
<int key="connectionID">481</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">updateFilter:</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="206425598"/>
</object>
<int key="connectionID">482</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">searchMenuTemplate</string>
<reference key="source" ref="206425598"/>
<reference key="destination" ref="8029352"/>
</object>
<int key="connectionID">489</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1048"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1021"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1014"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1050"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">450</int>
<reference key="object" ref="635946545"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">371</int>
<reference key="object" ref="972006081"/>
<array class="NSMutableArray" key="children">
<reference ref="439893737"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">372</int>
<reference key="object" ref="439893737"/>
<array class="NSMutableArray" key="children">
<reference ref="731799349"/>
<reference ref="206425598"/>
<reference ref="885120521"/>
<reference ref="299743148"/>
</array>
<reference key="parent" ref="972006081"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">473</int>
<reference key="object" ref="731799349"/>
<array class="NSMutableArray" key="children">
<reference ref="144038324"/>
</array>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">474</int>
<reference key="object" ref="144038324"/>
<reference key="parent" ref="731799349"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">460</int>
<reference key="object" ref="206425598"/>
<array class="NSMutableArray" key="children">
<reference ref="835402208"/>
</array>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">461</int>
<reference key="object" ref="835402208"/>
<reference key="parent" ref="206425598"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">475</int>
<reference key="object" ref="885120521"/>
<array class="NSMutableArray" key="children">
<reference ref="991102315"/>
</array>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">476</int>
<reference key="object" ref="991102315"/>
<reference key="parent" ref="885120521"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">479</int>
<reference key="object" ref="299743148"/>
<array class="NSMutableArray" key="children">
<reference ref="1048478045"/>
</array>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">480</int>
<reference key="object" ref="1048478045"/>
<reference key="parent" ref="299743148"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">483</int>
<reference key="object" ref="8029352"/>
<array class="NSMutableArray" key="children">
<reference ref="250718973"/>
<reference ref="235967825"/>
<reference ref="164911549"/>
<reference ref="295260886"/>
</array>
<reference key="parent" ref="0"/>
<string key="objectName">Search Menu Template</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">484</int>
<reference key="object" ref="250718973"/>
<reference key="parent" ref="8029352"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">485</int>
<reference key="object" ref="235967825"/>
<reference key="parent" ref="8029352"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">487</int>
<reference key="object" ref="295260886"/>
<reference key="parent" ref="8029352"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">488</int>
<reference key="object" ref="164911549"/>
<reference key="parent" ref="8029352"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="371.IBEditorWindowLastContentRect">{{399, 420}, {598, 282}}</string>
<string key="371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="371.IBWindowTemplateEditedContentRect">{{399, 420}, {598, 282}}</string>
<integer value="1" key="371.NSWindowTemplate.visibleAtLaunch"/>
<string key="371.editorWindowContentRectSynchronizationRect">{{33, 99}, {480, 360}}</string>
<string key="371.windowTemplate.maxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="372.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform" key="460.IBViewBoundsToFrameTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDjwAAw4kAAA</bytes>
</object>
<string key="461.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform" key="473.IBViewBoundsToFrameTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABCZAAAw5kAAA</bytes>
</object>
<string key="474.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="475.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform" key="475.IBViewBoundsToFrameTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABB+AAAw5yAAA</bytes>
</object>
<string key="476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="480.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="483.IBEditorWindowLastContentRect">{{54, 779}, {182, 83}}</string>
<string key="483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="484.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="485.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">489</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">AppController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="searchesImmediately:">id</string>
<string key="sendsWholeSearchString:">id</string>
<string key="updateFilter:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="searchesImmediately:">
<string key="name">searchesImmediately:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="sendsWholeSearchString:">
<string key="name">sendsWholeSearchString:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="updateFilter:">
<string key="name">updateFilter:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="predicateField">NSTextField</string>
<string key="theWindow">NSWindow</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="predicateField">
<string key="name">predicateField</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="theWindow">
<string key="name">theWindow</string>
<string key="candidateClassName">NSWindow</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../adsfsdf.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NSMenuCheckmark">{9, 8}</string>
<string key="NSMenuMixedState">{7, 2}</string>
<string key="NSSwitch">{15, 15}</string>
</dictionary>
</data>
</archive>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+66 -44
View File
@@ -1,41 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
Untitled
CPSearchField
Created by You on July 30, 2009.
Copyright 2009, Your Company All rights reserved.
Created by You on November 27, 2010.
Copyright 2010, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>Untitled</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type = "text/javascript">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPSearchField</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<script type = "text/javascript">
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to enable runtime type checking:
objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
objj_typecheck_prints_backtrace = true;
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type = "text/css">
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
@@ -53,29 +73,31 @@
</head>
<body style="">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading Untitled...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPSearchField...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</div>
</noscript>
</noscript>
</div>
</div>
</body>
+60 -18
View File
@@ -1,36 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
//
// index.html
//
// Created by __Me__ on __Date__.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
index.html
CPSearchField
Created by You on November 27, 2010.
Copyright 2010, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>CPSearchField Demo</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type = "text/javascript">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPSearchField</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body>
<div style="position: absolute; left: 50%; top: 50%;">
<center>
<img src = "Frameworks/AppKit/Resources/CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif" style="left: -32px; position: relative; top: -32px;" />
</center>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPSearchField...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
</html>
+4 -3
View File
@@ -1,8 +1,9 @@
/*
* main.j
* AppController.j
* CPSearchField
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
* Created by You on November 27, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
+16 -16
View File
@@ -4,7 +4,7 @@
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*/
CPLogRegister(CPLogConsole);
@import <Foundation/CPObject.j>
@@ -14,8 +14,8 @@ CPLogRegister(CPLogConsole);
{
CPSlider slider;
CPTextField textField;
Track track @accessors;
Track track @accessors;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
@@ -37,17 +37,17 @@ CPLogRegister(CPLogConsole);
[contentView addSubview:textField];
var textFrame = [textField frame];
slider = [[CPSlider alloc] initWithFrame:CGRectMake(CGRectGetMinX(textFrame), CGRectGetMaxY(textFrame)+10, CGRectGetWidth(textFrame), 12)];
[slider setContinuous:YES];
[contentView addSubview:slider];
var button = [[CPButton alloc] initWithFrame:CGRectMake(CGRectGetMinX(textFrame)+25, CGRectGetMaxY(textFrame)+40, 100, 18)];
[button setTitle:@"mute"];
[button setTarget:self];
[button setAction:@selector(muteTrack:)];
@@ -59,19 +59,19 @@ CPLogRegister(CPLogConsole);
//SET UP AN OBJECT CONTROLLER
var controller = [[CPObjectController alloc] init];
var controller = [[CPObjectController alloc] init];
[controller bind:@"contentObject" toObject:self withKeyPath:@"track" options:nil];
[textField bind:CPValueBinding toObject:controller withKeyPath:@"selection.volume" options:nil];
[slider bind:CPValueBinding toObject:controller withKeyPath:@"selection.volume" options:nil];
[textField bind:CPValueBinding toObject:controller withKeyPath:@"selection.volume" options:nil];
[slider bind:CPValueBinding toObject:controller withKeyPath:@"selection.volume" options:nil];
[theWindow orderFront:self];
}
- (IBAction)muteTrack:(id)sender
{
[track setVolume:0.0];
[track setVolume:0.0];
}
@@ -80,8 +80,8 @@ CPLogRegister(CPLogConsole);
@implementation Track : CPObject
{
float volume @accessors;
CPString title @accessors;
float volume @accessors;
CPString title @accessors;
}
@end
@@ -27,13 +27,13 @@ CPLogRegister(CPLogConsole);
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
[theWindow setBackgroundColor:[CPColor colorWithHexString:@"f3f4f5"]];
[theBorderTypePopup selectItemWithTag:[theScrollView borderType]];
}
@@ -53,7 +53,7 @@ CPLogRegister(CPLogConsole);
{
var type = [[sender selectedItem] tag];
console.log('type=%d', type);
[theScrollView setBorderType:type];
}
@@ -11,12 +11,11 @@
@implementation AppController : CPObject
{
CPTableView table;
CPTableColumn columnA;
CPTableColumn columnB;
CPTableColumn columnC;
CPTableColumn columnD;
CPTableView table;
CPTableColumn columnA;
CPTableColumn columnB;
CPTableColumn columnC;
CPTableColumn columnD;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
@@ -92,16 +91,16 @@ var randomColors = {};
- (void)drawRow:(CPInteger)aRow clipRect:(CGRect)clipRect
{
var viewRect = [self frameOfDataViewAtColumn:[self columnWithIdentifier:@"A"] row:aRow],
badgeWidth = CGRectGetWidth(viewRect)/5,
badgeWidth = CGRectGetWidth(viewRect) / 5,
badgePath = [CPBezierPath bezierPath];
var badgeFrame = CGRectMake(CGRectGetMaxX(viewRect) - badgeWidth - ROW_RIGHT_MARGIN,
CGRectGetMidY(viewRect) - BADGE_HEIGHT / 2.0,
badgeWidth,
BADGE_HEIGHT);
[badgePath appendBezierPathWithRoundedRect:badgeFrame xRadius:(BADGE_HEIGHT/2.0) yRadius:(BADGE_HEIGHT/2.0)];
[[TableViewDrawRow colorForRow:aRow] setFill];
var badgeFrame = CGRectMake(CGRectGetMaxX(viewRect) - badgeWidth - ROW_RIGHT_MARGIN,
CGRectGetMidY(viewRect) - BADGE_HEIGHT / 2.0,
badgeWidth,
BADGE_HEIGHT);
[badgePath appendBezierPathWithRoundedRect:badgeFrame xRadius:(BADGE_HEIGHT / 2.0) yRadius:(BADGE_HEIGHT / 2.0)];
[[TableViewDrawRow colorForRow:aRow] setFill];
[badgePath fill];
}
@@ -28,7 +28,6 @@
[tableView setDelegate:self];
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
@@ -48,15 +47,15 @@
[column setMaxWidth:500.0];
[column setWidth:200.0];
[tableView addTableColumn:column];
}
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) / 2)];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[contentView addSubview:scrollView];
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 400.0)];
@@ -69,7 +68,6 @@
[tableView setDelegate:self];
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
@@ -89,15 +87,15 @@
[column setMaxWidth:500.0];
[column setWidth:200.0];
[tableView addTableColumn:column];
}
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight([contentView bounds]) / 2, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) / 2)];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[contentView addSubview:scrollView];
[theWindow orderFront:self];
@@ -113,7 +111,7 @@
{
if ([aColumn identifier] === "icons")
return iconImage;
return aRow;
}
@@ -121,7 +119,7 @@
{
var groups = [];
for(var i = 0; i < 100; i+=5)
for (var i = 0; i < 100; i += 5)
groups.push(i);
return [groups containsObject:aRow];
+85 -87
View File
@@ -16,16 +16,15 @@ tableTestDragType = @"CPTableViewTestDragType";
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
dataSet1 = [],
dataSet2 = [],
dataSet3 = [];
for(var i = 1; i < 10; i++)
for (var i = 1; i < 10; i++)
{
dataSet1[i - 1] = [CPNumber numberWithInt:i];
dataSet2[i - 1] = [CPNumber numberWithInt:i+10];
dataSet3[i - 1] = [CPNumber numberWithInt:i+20];
dataSet2[i - 1] = [CPNumber numberWithInt:i + 10];
dataSet3[i - 1] = [CPNumber numberWithInt:i + 20];
}
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,700,500) styleMask:CPClosableWindowMask],
@@ -37,7 +36,7 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView setAllowsColumnSelection:YES];
[tableView setUsesAlternatingRowBackgroundColors:YES];
[tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
@@ -46,8 +45,7 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView setSelectionHighlightColor:[CPColor redColor]];
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16, 16, 0, 0)];
[iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
@@ -67,7 +65,7 @@ tableTestDragType = @"CPTableViewTestDragType";
[column setMinWidth:50.0];
[column setMaxWidth:500.0];
[column setWidth:75.0];
[column setEditable:YES];
[tableView addTableColumn:column];
@@ -78,10 +76,10 @@ tableTestDragType = @"CPTableViewTestDragType";
// we offset this scrollview to make sure all the coordinates are calculated correctly
// bad things can happen when the tableview doesn't sit at (0,0)
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(200, 50, CGRectGetWidth([contentView bounds]) - 200, CGRectGetHeight([contentView bounds]) -200)];
[scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[contentView addSubview:scrollView];
[theWindow orderFront:self];
@@ -124,9 +122,9 @@ tableTestDragType = @"CPTableViewTestDragType";
[button setAction:@selector(addColumn:)];
[contentView addSubview:button];
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2),
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0],
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(92.0/255.0) blue:(207.0/255.0) alpha:1.0];
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0 / 255.0, 153.0 / 255.0, 209.0 / 255.0, 1.0, 33.0 / 255.0, 94.0 / 255.0, 208.0 / 255.0, 1.0], [0, 1], 2),
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0 / 255.0) green:(123.0 / 255.0) blue:(218.0 / 255.0) alpha:1.0],
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0 / 255.0) green:(92.0 / 255.0) blue:(207.0 / 255.0) alpha:1.0];
[tableView setSelectionGradientColors:[CPDictionary dictionaryWithObjects:[sourceListActiveGradient, sourceListActiveTopLineColor, sourceListActiveBottomLineColor] forKeys:[CPSourceListGradient, CPSourceListTopLineColor, CPSourceListBottomLineColor]]];
}
@@ -176,7 +174,7 @@ tableTestDragType = @"CPTableViewTestDragType";
{
var window2 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
tableView2 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];
[tableView2 setAllowsMultipleSelection:YES];
@@ -202,11 +200,11 @@ tableTestDragType = @"CPTableViewTestDragType";
[column setSortDescriptorPrototype:desc];
[[column headerView] setStringValue:"Number "+i];
[column setWidth:i*75];
[column setWidth:i * 75];
[column setMinWidth:50.0];
[column setEditable:YES];
[tableView2 addTableColumn:column];
}
@@ -216,19 +214,18 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView2 setRowHeight:32.0];
[scrollView setDocumentView:tableView2];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[[window2 contentView] addSubview:scrollView];
//[scrollView setAutohidesScrollers:YES];
[window2 orderFront:self];
}
- (void)sourceList
{
var window3 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 250, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
tableView3 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 500.0)];
[tableView3 setAllowsMultipleSelection:NO];
@@ -247,7 +244,7 @@ tableTestDragType = @"CPTableViewTestDragType";
[column setMinWidth:50.0];
[column setEditable:YES];
[tableView3 addTableColumn:column];
var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist2"];
[[column headerView] setStringValue:"Source List 2"];
[tableView3 addTableColumn:column];
@@ -257,25 +254,25 @@ tableTestDragType = @"CPTableViewTestDragType";
[scrollView3 setDocumentView:tableView3];
[scrollView3 setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2),
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0],
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(92.0/255.0) blue:(207.0/255.0) alpha:1.0];
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0 / 255.0, 153.0 / 255.0, 209.0 / 255.0, 1.0, 33.0 / 255.0, 94.0 / 255.0, 208.0 / 255.0, 1.0], [0, 1], 2),
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0 / 255.0) green:(123.0 / 255.0) blue:(218.0 / 255.0) alpha:1.0],
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0 / 255.0) green:(92.0 / 255.0) blue:(207.0 / 255.0) alpha:1.0];
[tableView3 setSelectionGradientColors:[CPDictionary dictionaryWithObjects:[sourceListActiveGradient, sourceListActiveTopLineColor, sourceListActiveBottomLineColor] forKeys:[CPSourceListGradient, CPSourceListTopLineColor, CPSourceListBottomLineColor]]];
[[window3 contentView] addSubview:scrollView3];
[scrollView3 setAutohidesScrollers:YES];
[window3 orderFront:self];
[window3 orderFront:self];
}
- (int)numberOfRowsInTableView:(CPTableView)atableView
{
if(atableView === tableView)
if (atableView === tableView)
return dataSet1.length;
else if(atableView === tableView2)
else if (atableView === tableView2)
return dataSet2.length;
else if(atableView === tableView3)
else if (atableView === tableView3)
return dataSet3.length;
}
@@ -283,34 +280,34 @@ tableTestDragType = @"CPTableViewTestDragType";
{
if ([aColumn identifier] === "icons")
return iconImage;
if (aTableView === tableView)
return String(dataSet1[aRow]* ([[aTableView tableColumns] indexOfObject:aColumn] + 1));
return String(dataSet1[aRow] * ([[aTableView tableColumns] indexOfObject:aColumn] + 1));
else if (aTableView === tableView2)
return String(dataSet2[aRow]);
else if(aTableView === tableView3)
else if (aTableView === tableView3)
return String(dataSet3[aRow]);
}
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
{
//CPLogConsole(_cmd + [oldDescriptors description]);
var newDescriptors = [aTableView sortDescriptors];
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
[aTableView reloadData];
[aTableView reloadData];
}
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification
{
//CPLog.debug(@"changing! %@", [aNotification description]);
//CPLog.debug(@"changing! %@", [aNotification description]);
}
- (void)tableViewSelectionDidChange:(CPNotification)aNotification
{
//CPLog.debug(@"did change! %@", [aNotification description]);
//CPLog.debug(@"did change! %@", [aNotification description]);
}
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
@@ -321,8 +318,8 @@ tableTestDragType = @"CPTableViewTestDragType";
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
{
//CPLog.debug(@"selectionShouldChangeInTableView");
return YES;
//CPLog.debug(@"selectionShouldChangeInTableView");
return YES;
}
- (void)tableViewSelectionDidChange:(id)notification
@@ -341,7 +338,7 @@ tableTestDragType = @"CPTableViewTestDragType";
}
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if(aTableView === tableView3)
if (aTableView === tableView3)
return YES;
else
return NO;
@@ -349,23 +346,23 @@ tableTestDragType = @"CPTableViewTestDragType";
- (void)tableView:(CPTableView)aTableView willDisplayView:(CPView)aView forTableColumn:(CPTableColumn)tableColumn row:(int)row
{
//CPLogConsole(_cmd + " column: " + [tableColumn identifier] + " row:" + row)
//CPLogConsole(_cmd + " column: " + [tableColumn identifier] + " row:" + row)
}
- (void)tableView:(CPTableView)aTableView setObjectValue:(id)aValue forTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if(aTableView === tableView3)
if (aTableView === tableView3)
dataSet3[row] = aValue;
}
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
{
//CPLogConsole(_cmd + [oldDescriptors description]);
var newDescriptors = [aTableView sortDescriptors];
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
[aTableView reloadData];
[aTableView reloadData];
}
- (BOOL)tableView:(CPTableView)aTableView writeRowsWithIndexes:(CPIndexSet)rowIndexes toPasteboard:(CPPasteboard)pboard
@@ -374,57 +371,57 @@ tableTestDragType = @"CPTableViewTestDragType";
return NO;
var data = [rowIndexes, [aTableView UID]];
var encodedData = [CPKeyedArchiver archivedDataWithRootObject:data];
[pboard declareTypes:[CPArray arrayWithObject:tableTestDragType] owner:self];
[pboard setData:encodedData forType:tableTestDragType];
return YES;
}
- (CPDragOperation)tableView:(CPTableView)aTableView
validateDrop:(id)info
proposedRow:(CPInteger)row
- (CPDragOperation)tableView:(CPTableView)aTableView
validateDrop:(id)info
proposedRow:(CPInteger)row
proposedDropOperation:(CPTableViewDropOperation)operation
{
[[aTableView window] orderFront:nil];
if(aTableView === tableView)
if (aTableView === tableView)
[aTableView setDropRow:row dropOperation:CPTableViewDropOn];
else
else
[aTableView setDropRow:row dropOperation:CPTableViewDropAbove];
return CPDragOperationMove;
}
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id)info row:(int)row dropOperation:(CPTableViewDropOperation)operation
{
{
var pboard = [info draggingPasteboard],
rowData = [pboard dataForType:tableTestDragType],
tables = [tableView, tableView2],
dataSets = [dataSet1, dataSet2];
dataSets = [dataSet1, dataSet2];
rowData = [CPKeyedUnarchiver unarchiveObjectWithData:rowData];
var sourceIndexes = rowData[0],
sourceTableUID = rowData[1];
var index = (aTableView == tableView) ? 1 : 0;
var destinationTable = tables[1 - index],
sourceTable = tables[index],
destinationDataSet = dataSets[1 - index],
sourceDataSet = dataSets[index];
if(operation | CPDragOperationMove)
if (operation & CPDragOperationMove)
{
if (sourceTableUID == [aTableView UID])
{
[destinationDataSet moveIndexes:sourceIndexes toIndex:row];
[destinationTable reloadData];
var destIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(row, [sourceIndexes count])];
[destinationTable selectRowIndexes:destIndexes byExtendingSelection:NO];
[destinationTable selectRowIndexes:destIndexes byExtendingSelection:NO];
}
else
{
@@ -434,19 +431,19 @@ tableTestDragType = @"CPTableViewTestDragType";
[destinationDataSet insertObjects:sourceObjects atIndexes:destIndexes];
[destinationTable reloadData];
[destinationTable selectRowIndexes:destIndexes byExtendingSelection:NO];
[sourceDataSet removeObjectsAtIndexes:sourceIndexes];
[sourceTable reloadData];
[sourceTable selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
[sourceTable selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
}
}
return YES;
}
- (void)tableView:(CPTableView)aTableView didEndDraggedImage:(CPImage)anImage atPosition:(CGPoint)aPoint operation:(CPDragOperation)anOperation
{
//for convenience
//for convenience
}
- (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn
@@ -457,33 +454,34 @@ tableTestDragType = @"CPTableViewTestDragType";
@end
@implementation CPArray (MoveIndexes)
- (void)moveIndexes:(CPIndexSet)indexes toIndex:(int)insertIndex
{
var aboveCount = 0,
object,
removeIndex;
var index = [indexes lastIndex];
var index = [indexes lastIndex];
while (index != CPNotFound)
{
if (index >= insertIndex)
{
removeIndex = index + aboveCount;
aboveCount ++;
}
else
{
removeIndex = index;
insertIndex --;
}
object = [self objectAtIndex:removeIndex];
[self removeObjectAtIndex:removeIndex];
[self insertObject:object atIndex:insertIndex];
index = [indexes indexLessThanIndex:index];
}
{
if (index >= insertIndex)
{
removeIndex = index + aboveCount;
aboveCount ++;
}
else
{
removeIndex = index;
insertIndex --;
}
object = [self objectAtIndex:removeIndex];
[self removeObjectAtIndex:removeIndex];
[self insertObject:object atIndex:insertIndex];
index = [indexes indexLessThanIndex:index];
}
}
@end
@@ -39,7 +39,7 @@ var tableTestDragType = "tableTestDragType";
[table setDelegate:self];
[table setUsesAlternatingRowBackgroundColors:YES];
[table setGridStyleMask:CPTableViewSolidVerticalGridLineMask|CPTableViewSolidHorizontalGridLineMask];
[table setGridStyleMask:CPTableViewSolidVerticalGridLineMask | CPTableViewSolidHorizontalGridLineMask];
[table setAllowsMultipleSelection:YES];
[table registerForDraggedTypes:[tableTestDragType]];
@@ -113,21 +113,21 @@ var tableTestDragType = "tableTestDragType";
- (BOOL)tableView:(CPTableView)aTableView writeRowsWithIndexes:(CPIndexSet)rowIndexes toPasteboard:(CPPasteboard)pboard
{
var data = [rowIndexes, [aTableView UID]];
var encodedData = [CPKeyedArchiver archivedDataWithRootObject:data];
[pboard declareTypes:[CPArray arrayWithObject:tableTestDragType] owner:self];
[pboard setData:encodedData forType:tableTestDragType];
return YES;
}
- (CPDragOperation)tableView:(CPTableView)aTableView
validateDrop:(id)info
proposedRow:(CPInteger)row
- (CPDragOperation)tableView:(CPTableView)aTableView
validateDrop:(id)info
proposedRow:(CPInteger)row
proposedDropOperation:(CPTableViewDropOperation)operation
{
[aTableView setDropRow:(row) dropOperation:CPTableViewDropOn];
return CPDragOperationMove;
}
@@ -89,7 +89,7 @@
//this will be called whenver the user clicks on an autoenabled menu
- (BOOL)validateMenuItem:(id)anItem
{
switch([anItem tag])
switch ([anItem tag])
{
case @"Undo" :
[anItem setTitle:[undoManager undoMenuItemTitle]];
@@ -118,10 +118,10 @@
- (void)update
{
var cnt = [_items count];
for(var i=0; i<cnt; ++i)
for (var i = 0; i < cnt; ++i)
{
var item = [_items objectAtIndex:i];
if([[item target] respondsToSelector:@selector(validateMenuItem:)])
if ([[item target] respondsToSelector:@selector(validateMenuItem:)])
[item _setEnabledByMenu:[[item target] validateMenuItem:item]];
else
[item _setEnabledByMenu:[item isEnabled]]; /// BD Change from NO
@@ -216,7 +216,7 @@
if (!newMenu)
return;
if([newMenu autoenablesItems])
if ([newMenu autoenablesItems])
[newMenu update];
// Unhighlight any previously highlighted item.
[newMenu _highlightItemAtIndex:CPNotFound];
+5 -5
View File
@@ -30,7 +30,7 @@ var DefaultDictionary = nil,
[DefaultDictionary setObject:@"feedback @nospam@ yourcompany.com" forKey:@"organization.email"];
[DefaultDictionary setObject:@"http://yourcompany.com" forKey:@"organization.url"];
[DefaultDictionary setObject:@"com.yourcompany" forKey:@"organization.identifier"];
var date = new Date(),
months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
@@ -90,7 +90,7 @@ var DefaultDictionary = nil,
[set addObjectsFromArray:[temporaryDictionary allKeys]];
[set addObjectsFromArray:[DefaultDictionary allKeys]];
return [set objectEnumerator];
}
@@ -147,7 +147,7 @@ function config(/*va_args*/)
case "--get": shouldGet = YES;
break;
case "-l":
case "-l":
case "--list": shouldList = YES;
break;
@@ -164,14 +164,14 @@ function config(/*va_args*/)
{
var key = nil,
keyEnumerator = [configuration storedKeyEnumerator];
while (key = [keyEnumerator nextObject])
print(key + '=' + [configuration valueForKey:key]);
}
else if (shouldGet)
{
var value = [configuration valueForKey:key];
if (value)
print(value);
}
+58 -29
View File
@@ -71,27 +71,33 @@ function gen(/*va_args*/)
var args = ["capp gen"].concat(Array.prototype.slice.call(arguments));
var options = parser.parse(args, null, null, true);
if (options.args.length > 1) {
if (options.args.length > 1)
{
parser.printUsage(options);
OS.exit(1);
}
if (options.listTemplates) {
if (options.listTemplates)
{
listTemplates();
return;
}
if (options.listFrameworks) {
if (options.listFrameworks)
{
listFrameworks();
return;
}
var destination = options.args[0];
if (!destination) {
if (!destination)
{
if (options.justFrameworks)
destination = ".";
else {
else
{
parser.printUsage(options);
OS.exit(1);
}
@@ -114,9 +120,8 @@ function gen(/*va_args*/)
configuration = options.noconfig ? [Configuration defaultConfiguration] : [Configuration userConfiguration];
var frameworks = options.frameworks;
if (!options.noFrameworks) {
if (!options.noFrameworks)
frameworks.push("Objective-J", "Foundation", "AppKit");
}
if (options.justFrameworks)
createFrameworksInFile(frameworks, destinationProject, options.symlink, options.useCappBuild, options.force);
@@ -174,7 +179,9 @@ function gen(/*va_args*/)
createFrameworksInFile(frameworks, frameworkDestination, options.symlink, options.useCappBuild);
}
else {
else
{
stream.print("Directory already exists");
OS.exit(1);
}
@@ -195,7 +202,8 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
//destinationFrameworks.mkdirs(); // redundant
destinationDebugFrameworks.mkdirs();
if (build) {
if (build)
{
if (!(SYSTEM.env["CAPP_BUILD"] || SYSTEM.env["STEAM_BUILD"]))
throw "CAPP_BUILD or STEAM_BUILD must be defined";
@@ -204,16 +212,21 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
var sourceFrameworks = builtFrameworks.join("Release"),
sourceDebugFrameworks = builtFrameworks.join("Debug");
frameworks.forEach(function(framework) {
frameworks.forEach(function(framework)
{
installFramework(sourceFrameworks.join(framework), destinationFrameworks.join(framework), force, symlink);
installFramework(sourceDebugFrameworks.join(framework), destinationDebugFrameworks.join(framework), force, symlink);
});
}
else {
else
{
// Frameworks. Search frameworks paths
frameworks.forEach(function(framework) {
frameworks.forEach(function(framework)
{
// Need a special case for Objective-J
if (framework === "Objective-J") {
if (framework === "Objective-J")
{
// Objective-J. Take from OBJJ_HOME.
var objjHome = FILE.path(OBJJ.OBJJ_HOME);
var objjPath = objjHome.join("Frameworks", "Objective-J");
@@ -227,9 +240,11 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
var found;
for (var i = 0, found = false; !found && i < OBJJ.objj_frameworks.length; i++) {
for (var i = 0, found = false; !found && i < OBJJ.objj_frameworks.length; i++)
{
var sourceFramework = FILE.path(OBJJ.objj_frameworks[i]).join(framework);
if (FILE.isDirectory(sourceFramework)) {
if (FILE.isDirectory(sourceFramework))
{
installFramework(sourceFramework, destinationFrameworks.join(framework), force, symlink);
found = true;
}
@@ -237,9 +252,11 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
if (!found)
stream.print("\0yellow(Warning:\0) Couldn't find framework \0cyan(" + framework +"\0)");
for (var i = 0, found = false; !found && i < OBJJ.objj_debug_frameworks.length; i++) {
for (var i = 0, found = false; !found && i < OBJJ.objj_debug_frameworks.length; i++)
{
var sourceDebugFramework = FILE.path(OBJJ.objj_debug_frameworks[i]).join(framework);
if (FILE.isDirectory(sourceDebugFramework)) {
if (FILE.isDirectory(sourceDebugFramework))
{
installFramework(sourceDebugFramework, destinationDebugFrameworks.join(framework), force, symlink);
found = true;
}
@@ -250,16 +267,21 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
}
}
function installFramework(source, dest, force, symlink) {
if (dest.exists()) {
if (force) {
function installFramework(source, dest, force, symlink)
{
if (dest.exists())
{
if (force)
dest.rmtree();
} else {
else
{
stream.print("\0yellow(Warning:\0) " + dest + " already exists. Use --force to overwrite.");
return;
}
}
if (source.exists()) {
if (source.exists())
{
stream.print((symlink ? "Symlinking " : "Copying ") + source + " to " + dest);
if (symlink)
FILE.symlink(source, dest);
@@ -299,24 +321,31 @@ function toIdentifier(/*String*/ aString)
return identifier;
}
function listTemplates() {
FILE.list(templatesDirectory).forEach(function(templateName) {
function listTemplates()
{
FILE.list(templatesDirectory).forEach(function(templateName)
{
stream.print(templateName);
});
}
function listFrameworks() {
function listFrameworks()
{
stream.print("Frameworks:");
OBJJ.objj_frameworks.forEach(function(frameworksDirectory) {
OBJJ.objj_frameworks.forEach(function(frameworksDirectory)
{
stream.print(" " + frameworksDirectory);
FILE.list(frameworksDirectory).forEach(function(templateName) {
FILE.list(frameworksDirectory).forEach(function(templateName)
{
stream.print(" + " + templateName);
});
});
stream.print("Frameworks (Debug):");
OBJJ.objj_debug_frameworks.forEach(function(frameworksDirectory) {
OBJJ.objj_debug_frameworks.forEach(function(frameworksDirectory)
{
stream.print(" " + frameworksDirectory);
FILE.list(frameworksDirectory).forEach(function(frameworkName) {
FILE.list(frameworksDirectory).forEach(function(frameworkName)
{
stream.print(" + " + frameworkName);
});
});
+10 -10
View File
@@ -8,7 +8,7 @@
function main(args)
{
args.shift();
if (args.length < 1)
return printUsage();
@@ -18,7 +18,7 @@ function main(args)
for (; index < count; ++index)
{
var argument = args[index];
switch (argument)
{
case "version":
@@ -30,7 +30,7 @@ function main(args)
case "config": return config.apply(this, args.slice(index + 1));
case "gen": return gen.apply(this, args.slice(index + 1));
default: print("unknown command " + argument);
}
}
@@ -66,38 +66,38 @@ function getFiles(/*File*/ sourceDirectory, /*nil|String|Array<String>*/ extensi
{
var index = 0,
count = files.length;
for (; index < count; ++index)
{
var file = files[index],
name = FILE.basename(file),
isValidExtension = !extensions;
if (exclusions && fileArrayContainsFile(exclusions, file))
continue;
if (!isValidExtension)
if (hasMultipleExtensions)
{
var extensionCount = extensions.length;
while (extensionCount-- && !isValidExtension)
{
var extension = extensions[extensionCount];
if (name.substring(name.length - extension.length - 1) === ("." + extension))
isValidExtension = true;
}
}
else if (name.substring(name.length - extensions.length - 1) === ("." + extensions))
isValidExtension = true;
if (FILE.isDirectory(file))
matches = matches.concat(getFiles(file, extensions, exclusions));
else if (isValidExtension)
matches.push(file);
}
}
return matches;
}
+1 -1
View File
@@ -52,7 +52,7 @@ ConverterConversionException = @"ConverterConversionException";
}
- (void)convert
{
{
try
{
if ([resourcesPath length] && !FILE.isReadable(resourcesPath))
+1 -1
View File
@@ -19,7 +19,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
+1 -1
View File
@@ -45,7 +45,7 @@ var NSButtonIsBorderedMask = 0x00800000,
NSButtonImagePositionShift = 16,
NSButtonNoImagePositionMask = 0x04,
NSButtonImageAbovePositionMask = 0x0C,
NSButtonImageBelowPositionMask = 0x1C;
NSButtonImageBelowPositionMask = 0x1C,
NSButtonImageRightPositionMask = 0x2C,
NSButtonImageLeftPositionMask = 0x3C,
NSButtonImageOnlyPositionMask = 0x44,
+3 -3
View File
@@ -11,7 +11,7 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
+ (id)swapperClassForClassName:(CPString)aClassName originalClassName:(CPString)anOriginalClassName
{
var swapperClassName = "$NSClassSwapper_" + aClassName + "_" + anOriginalClassName;
var swapperClassName = "$NSClassSwapper_" + aClassName + "_" + anOriginalClassName,
swapperClass = objj_lookUpClass(swapperClassName);
if (!swapperClass)
@@ -41,11 +41,11 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
{
return [_CPCibClassSwapper class];
}, "");
class_addMethod(swapperClass, @selector(encodeWithCoder:), function(self, _cmd, aCoder)
{
objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
// FIXME: map class name as well?
[aCoder encodeObject:aClassName forKey:_CPCibClassSwapperClassNameKey];
[aCoder encodeObject:CP_NSMapClassName(anOriginalClassName) forKey:_CPCibClassSwapperOriginalClassNameKey];
+3 -3
View File
@@ -30,13 +30,13 @@
if (self = [super NS_initWithCoder:aCoder])
{
_documentView = [aCoder decodeObjectForKey:"NSDocView"];
if ([aCoder containsValueForKey:"NSBGColor"])
[self setBackgroundColor:[aCoder decodeObjectForKey:"NSBGColor"]];
//var flags = [aCoder decodeIntForKey:"NScvFlags"];
}
return self;
}
+6 -6
View File
@@ -28,30 +28,30 @@
{
_items = [];
_content = [];
_cachedItems = [];
_itemSize = CGSizeMakeZero();
_minItemSize = CGSizeMakeZero();
_maxItemSize = CGSizeMakeZero();
_verticalMargin = 5.0;
_tileWidth = -1.0;
_selectionIndexes = [CPIndexSet indexSet];
_allowsEmptySelection = YES;
if (self = [super NS_initWithCoder:aCoder])
{
_backgroundColors = [aCoder decodeObjectForKey:@"NSBackgroundColors"];
_maxNumberOfRows = [aCoder decodeIntForKey:@"NSMaxNumberOfGridRows"];
_maxNumberOfColumns = [aCoder decodeIntForKey:@"NSMaxNumberOfGridColumns"];
_isSelectable = [aCoder decodeBoolForKey:@"NSSelectable"];
_allowsMultipleSelection = [aCoder decodeBoolForKey:@"NSAllowsMultipleSelection"];
}
return self;
}
+7 -7
View File
@@ -47,7 +47,7 @@ var NSUnknownColorSpaceModel = -1,
{
case 1: // [NSColor colorWithCalibratedRed:values[0] green:values[1] blue:values[2] alpha:values[3]];
case 2: // [NSColor colorWithDeviceRed:values[0] green:values[1] blue:values[2] alpha:values[3]];
// NSComponents data
// NSCustomColorSpace NSColorSpace
var rgb = [aCoder decodeBytesForKey:@"NSRGB"],
@@ -60,15 +60,15 @@ var NSUnknownColorSpaceModel = -1,
result = [CPColor colorWithCalibratedRed:values[0] green:values[1] blue:values[2] alpha:values[3]];
break;
case 3: // [NSColor colorWithCalibratedWhite:values[0] alpha:values[1]];
case 4: // [NSColor colorWithDeviceWhite:values[0] alpha:values[1]];
var bytes = [aCoder decodeBytesForKey:@"NSWhite"],
string = CFData.bytesToString(bytes),
components = [string componentsSeparatedByString:@" "],
values = [0,1];
for (var i = 0; i < components.length && i < 2; i++)
values[i] = [components[i] floatValue];
@@ -80,7 +80,7 @@ var NSUnknownColorSpaceModel = -1,
string = CFData.bytesToString(rgb),
components = [string componentsSeparatedByString:@" "],
values = [0,0,0,0,1];
for (var i = 0; i < components.length && i < 5; i++)
values[i] = [components[i] floatValue];
@@ -91,9 +91,9 @@ var NSUnknownColorSpaceModel = -1,
var catalogName = [aCoder decodeObjectForKey:@"NSCatalogName"],
colorName = [aCoder decodeObjectForKey:@"NSColorName"],
color = [aCoder decodeObjectForKey:@"NSColor"];
// We don't having color mappings implemented, so just use the cached NSColor
if (catalogName === @"System")
{
var //display = [NSDisplay currentDisplay],
+2 -2
View File
@@ -31,13 +31,13 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
[self setBordered:[aCoder decodeBoolForKey:"NSIsBordered"]];
[self setColor:[aCoder decodeObjectForKey:"NSColor"]];
}
return self;
}
+6 -6
View File
@@ -31,18 +31,18 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
[self sendActionOn:CPLeftMouseUpMask];
var cell = [aCoder decodeObjectForKey:@"NSCell"];
[self setObjectValue:[cell objectValue]];
[self setFont:[cell font]];
[self setAlignment:[cell alignment]];
[self setEnabled:[aCoder decodeObjectForKey:@"NSEnabled"]];
[self setContinuous:[cell isContinuous]];
@@ -51,7 +51,7 @@
[self setLineBreakMode:[cell lineBreakMode]];
}
return self;
}
+3 -3
View File
@@ -28,10 +28,10 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self){
if (self)
_className = CP_NSMapClassName([aCoder decodeObjectForKey:@"NSClassName"]);
}
return self;
}
+3 -3
View File
@@ -35,17 +35,17 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
_className = [aCoder decodeObjectForKey:@"NSClassName"];
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:CP_NSMapClassName(_className) forKey:_CPCibCustomViewClassNameKey];
}
+6 -6
View File
@@ -30,14 +30,14 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [self init];
if (self)
{
/* id owner;
if((owner=[nameTable objectForKey:NSNibOwner])!=nil)
[nameTable setObject:owner forKey:@"File's Owner"];
[nameTable setObject:[NSFontManager sharedFontManager] forKey:@"Font Manager"];
*/
_namesKeys = [aCoder decodeObjectForKey:@"NSNamesKeys"];
@@ -51,7 +51,7 @@
_classesValues = [aCoder decodeObjectForKey:@"NSClassesValues"];
_connections = [aCoder decodeObjectForKey:@"NSConnections"];
//_fontManager = [aCoder decodeObjectForKey:@"NSFontManager"] retain];
_framework = [aCoder decodeObjectForKey:@"NSFramework"];
@@ -76,8 +76,8 @@
{
// FIXME: Remove from top level objects and connections?
// Most cell references should be naturally removed by the fact that we don't manually
// encode them anywhere, however, they remain in our object graph. For each cell found,
// Most cell references should be naturally removed by the fact that we don't manually
// encode them anywhere, however, they remain in our object graph. For each cell found,
// take its children and promote them to our parent object's children.
var count = _objectsKeys.length,
parentForCellUIDs = { },
+11 -11
View File
@@ -28,16 +28,16 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
var cell = [aCoder decodeObjectForKey:@"NSCell"];
[self setImageScaling:[cell imageScaling]];
[self setImageAlignment:[cell imageAlignment]];
_isEditable = [cell isEditable];
}
return self;
}
@@ -92,24 +92,24 @@ NSImageScalingToCPImageScaling[NSImageScaleProportionallyUpOrDown] = CPScalePro
@implementation NSImageCell : NSCell
{
BOOL _animates @accessors;
BOOL _animates @accessors;
NSImageAlignment _imageAlignment @accessors(readonly, getter=imageAlignment);
NSImageScaling _imageScaling @accessors(readonly, getter=imageScaling);
NSImageFrameStyle _frameStyle @accessors;
}
- (id)initWithCoder:(CPCoder)aCoder
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
self = [super initWithCoder:aCoder];
if (self)
{
_animates = [aCoder decodeBoolForKey:@"NSAnimates"];
_imageAlignment = [aCoder decodeIntForKey:@"NSAlign"];
_imageScaling = NSImageScalingToCPImageScaling[[aCoder decodeIntForKey:@"NSScale"]];
_animates = [aCoder decodeBoolForKey:@"NSAnimates"];
_imageAlignment = [aCoder decodeIntForKey:@"NSAlign"];
_imageScaling = NSImageScalingToCPImageScaling[[aCoder decodeIntForKey:@"NSScale"]];
_frameStyle = [aCoder decodeIntForKey:@"NSStyle"];
}
return self;
}
+2 -2
View File
@@ -41,7 +41,7 @@ NS_CPMenuNameMap =
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_title = [aCoder decodeObjectForKey:@"NSTitle"];
@@ -55,7 +55,7 @@ NS_CPMenuNameMap =
_showsStateColumn = ![aCoder containsValueForKey:@"NSMenuExcludeMarkColumn"] || ![aCoder decodeBoolForKey:@"NSMenuExcludeMarkColumn"];
}
return self;
}
+4 -4
View File
@@ -31,7 +31,7 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_isSeparator = [aCoder decodeObjectForKey:@"NSIsSeparator"] || NO;
@@ -62,15 +62,15 @@
_keyEquivalentModifierMask = CP_NSMapKeyMask([aCoder decodeObjectForKey:"NSKeyEquivModMask"]);
// _mnemonicLocation = [aCoder decodeObjectForKey:"NSMnemonicLoc"];
// _isAlternate = [aCoder decodeBoolForKey:"NSIsAlternate"];
_indentationLevel = [aCoder decodeIntForKey:"NSIndent"];
// _toolTip;
// _representedObject = [aCoder decodeObjectForKey:CPMenuItemRepresentedObjectKey];
}
return self;
}
+5 -5
View File
@@ -28,20 +28,20 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
if([aCoder containsValueForKey:"NSOutlineViewOutlineTableColumnKey"])
if ([aCoder containsValueForKey:"NSOutlineViewOutlineTableColumnKey"])
_outlineTableColumn = [aCoder decodeObjectForKey:@"NSOutlineViewOutlineTableColumnKey"];
else
_outlineTableColumn = [[self tableColumns] objectAtIndex:0];
_indentationPerLevel = [aCoder decodeFloatForKey:@"NSOutlineViewIndentationPerLevelKey"];
_outlineViewDataSource = [aCoder decodeObjectForKey:@"NSDataSource"];
_outlineViewDelegate = [aCoder decodeObjectForKey:@"NSDelegate"];
}
return self;
}
+6 -6
View File
@@ -32,17 +32,17 @@
if (self = [super NS_initWithCoder:aCoder])
{
var cell = [aCoder decodeObjectForKey:@"NSCell"];
_menu = [cell menu];
// make sure it's not null/undefined
//FIXME push this check to CPPopUpButton?
_selectedIndex = [cell selectedIndex] || 0;
[self setPullsDown:[cell pullsDown]];
_preferredEdge = [cell preferredEdge];
}
return self;
}
@@ -76,15 +76,15 @@
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
{
pullsDown = [aCoder decodeBoolForKey:@"NSPullDown"];
selectedIndex = [aCoder decodeIntForKey:@"NSSelectedIndex"];
preferredEdge = [aCoder decodeIntForKey:@"NSPreferredEdge"];
menu = [aCoder decodeObjectForKey:@"NSMenu"];
}
return self;
}
+2 -2
View File
@@ -28,10 +28,10 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
[self setNextResponder:[aCoder decodeObjectForKey:@"NSNextResponder"]];
return self;
}
+4 -4
View File
@@ -30,11 +30,11 @@
if (self = [super NS_initWithCoder:aCoder])
{
var flags = [aCoder decodeIntForKey:"NSsFlags"];
_verticalScroller = [aCoder decodeObjectForKey:"NSVScroller"];
_horizontalScroller = [aCoder decodeObjectForKey:"NSHScroller"];
_contentView = [aCoder decodeObjectForKey:"NSContentView"];
_headerClipView = [aCoder decodeObjectForKey:"NSHeaderClipView"];
_cornerView = [aCoder decodeObjectForKey:"NSCornerView"];
_bottomCornerView = [[CPView alloc] init];
@@ -44,7 +44,7 @@
_hasVerticalScroller = !!(flags & (1 << 4));
_hasHorizontalScroller = !!(flags & (1 << 5));
_autohidesScrollers = !!(flags & (1 << 9));
_borderType = flags & 0x03;
//[aCoder decodeBytesForKey:"NSScrollAmts"];
@@ -53,7 +53,7 @@
_horizontalLineScroll = 10.0;
_horizontalPageScroll = 10.0;
}
return self;
}
+2 -2
View File
@@ -31,7 +31,7 @@
{
//"NSsFlags"
//"NSArrowsLoc"
_controlSize = CPRegularControlSize;
//if ([aCoder containsValueForKey:CPScrollerControlSizeKey])
// _controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey];
@@ -39,7 +39,7 @@
_knobProportion = 1.0;
if ([aCoder containsValueForKey:"NSPercent"])
_knobProportion = [aCoder decodeFloatForKey:"NSPercent"];
_value = 0.0;
// Cocoa uses NSCurValue instead of NSControl's NSContents
if ([aCoder containsValueForKey:"NSCurValue"])
+4 -4
View File
@@ -47,7 +47,7 @@
_trackingMode = [cell trackingMode];
[self setValue:CPCenterTextAlignment forThemeAttribute:@"alignment"];
// HACK
for (var i = 0; i < _segments.length; i++)
@@ -98,11 +98,11 @@
_selectedSegment = [aCoder decodeIntForKey:"NSSelectedSegment"] || -1;
_segmentStyle = [aCoder decodeIntForKey:"NSSegmentStyle"];
_trackingMode = [aCoder decodeIntForKey:"NSTrackingMode"] || CPSegmentSwitchTrackingSelectOne;
if (_trackingMode == CPSegmentSwitchTrackingSelectOne && _selectedSegment == -1)
_selectedSegment = 0;
}
return self;
}
@@ -128,7 +128,7 @@
// NSSegmentItemImageScaling
// NSSegmentItemTooltip
}
return self;
}
+1 -1
View File
@@ -19,7 +19,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPSet.j>
+7 -6
View File
@@ -42,14 +42,15 @@
_altIncrementValue = [cell altIncrementValue];
[self setSliderType:[cell sliderType]];
if ([self sliderType] === CPCircularSlider)
{
var frame = [self frame];
[self setFrameSize:CGSizeMake(frame.size.width + 4.0, frame.size.height + 2.0)];
}
}
return self;
}
@@ -83,19 +84,19 @@
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
_objectValue = [aCoder decodeDoubleForKey:@"NSValue"];
_minValue = [aCoder decodeDoubleForKey:@"NSMinValue"];
_maxValue = [aCoder decodeDoubleForKey:@"NSMaxValue"];
_altIncrementValue = [aCoder decodeDoubleForKey:@"NSAltIncValue"];
_isVertical = [aCoder decodeBoolForKey:@"NSVertical"];
_sliderType = [aCoder decodeIntForKey:@"NSSliderType"] || 0;
}
return self;
}
+1 -1
View File
@@ -32,7 +32,7 @@
_isVertical = [aCoder decodeBoolForKey:@"NSIsVertical"];
_isPaneSplitter = [aCoder decodeIntForKey:@"NSDividerStyle"] == 2 ? YES : NO;
}
return self;
}
+2 -2
View File
@@ -36,10 +36,10 @@
_bounds.size.height = 23;
_frame.size.height = 23;
}
_drawsColumnLines = YES;
}
return self;
}
+17 -17
View File
@@ -28,52 +28,52 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
var flags = [aCoder decodeIntForKey:@"NSTvFlags"];
//_dataSource = [aCoder decodeObjectForKey:CPTableViewDataSourceKey];
//_delegate = [aCoder decodeObjectForKey:CPTableViewDelegateKey];
_rowHeight = [aCoder decodeFloatForKey:@"NSRowHeight"];
// Convert xib default to cib default
if (_rowHeight == 17)
_rowHeight = 23;
_headerView = [aCoder decodeObjectForKey:@"NSHeaderView"];
_headerView = [aCoder decodeObjectForKey:@"NSHeaderView"];
_cornerView = [aCoder decodeObjectForKey:@"NSCornerView"];
_autosaveName = [aCoder decodeObjectForKey:@"NSAutosaveName"];
_tableColumns = [aCoder decodeObjectForKey:@"NSTableColumns"];
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
_intercellSpacing = CGSizeMake([aCoder decodeFloatForKey:@"NSIntercellSpacingWidth"],
_intercellSpacing = CGSizeMake([aCoder decodeFloatForKey:@"NSIntercellSpacingWidth"],
[aCoder decodeFloatForKey:@"NSIntercellSpacingHeight"]);
var gridColor = [aCoder decodeObjectForKey:@"NSGridColor"];
if (![gridColor isEqual:[CPColor colorWithRed:127.0 / 255.0 green:127.0 / 255.0 blue:127.0 / 255.0 alpha:1.0]])
[self setValue:gridColor forThemeAttribute:@"grid-color"];
_gridStyleMask = [aCoder decodeIntForKey:@"NSGridStyleMask"];
_usesAlternatingRowBackgroundColors = (flags & 0x00800000) ? YES : NO;
_alternatingRowBackgroundColors =[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]];
_alternatingRowBackgroundColors = [[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]];
_selectionHighlightStyle = [aCoder decodeIntForKey:@"NSTableViewSelectionHighlightStyle"] || CPTableViewSelectionHighlightStyleRegular;
_columnAutoResizingStyle = [aCoder decodeIntForKey:@"NSColumnAutoresizingStyle"];
_allowsMultipleSelection = (flags & 0x08000000) ? YES : NO;
_allowsEmptySelection = (flags & 0x10000000) ? YES : NO;
_allowsColumnSelection = (flags & 0x04000000) ? YES : NO;
_allowsColumnResizing = (flags & 0x40000000) ? YES : NO;
_allowsColumnReordering = (flags & 0x80000000) ? YES : NO;
}
return self;
}
+3 -3
View File
@@ -34,15 +34,15 @@
_showsBaselineSeparator = [aCoder decodeBoolForKey:"NSToolbarShowsBaselineSeparator"];
_allowsUserCustomization = [aCoder decodeBoolForKey:"NSToolbarAllowsUserCustomization"];
_isVisible = [aCoder decodeBoolForKey:"NSToolbarPrefersToBeShown"];
_identifiedItems = [aCoder decodeObjectForKey:"NSToolbarIBIdentifiedItems"];
_defaultItems = [aCoder decodeObjectForKey:"NSToolbarIBDefaultItems"];
_allowedItems = [aCoder decodeObjectForKey:"NSToolbarIBAllowedItems"];
_selectableItems = [aCoder decodeObjectForKey:"NSToolbarIBSelectableItems"];
_delegate = [aCoder decodeObjectForKey:"NSToolbarDelegate"];
}
return self;
}
+6 -6
View File
@@ -46,24 +46,24 @@ var NSViewAutoresizingMask = 0x3F,
if (self)
{
_tag = 0;
if ([aCoder containsValueForKey:@"NSTag"])
_tag = [aCoder decodeIntForKey:@"NSTag"];
_bounds = CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame));
_window = [aCoder decodeObjectForKey:@"NSWindow"];
_superview = [aCoder decodeObjectForKey:@"NSSuperview"];
_subviews = [aCoder decodeObjectForKey:@"NSSubviews"];
if (!_subviews)
_subviews = [];
var vFlags = [aCoder decodeIntForKey:@"NSvFlags"];
_autoresizingMask = vFlags & NSViewAutoresizingMask;
_autoresizesSubviews = vFlags & NSViewAutoresizesSubviewsMask;
_hitTests = YES;
_isHidden = vFlags & NSViewHiddenMask;
_opacity = 1.0;//[aCoder decodeIntForKey:CPViewOpacityKey];
@@ -72,7 +72,7 @@ var NSViewAutoresizingMask = 0x3F,
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
}
return self;
}
+2 -1
View File
@@ -34,7 +34,8 @@
_title = [aCoder decodeObjectForKey:@"NSTitle"];
_cibName = [aCoder decodeObjectForKey:@"NSNibName"];
var bundlePath = [aCoder decodeObjectForKey:@"NSNibBundleIdentifier"]
var bundlePath = [aCoder decodeObjectForKey:@"NSNibBundleIdentifier"];
if (bundlePath)
_cibBundle = [CPBundle bundleWithPath:bundlePath];
}
+8 -7
View File
@@ -38,22 +38,23 @@ var NSBorderlessWindowMask = 0x00,
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
{
if ([aCoder containsValueForKey:@"NSMinSize"])
_minSize = [aCoder decodeSizeForKey:@"NSMinSize"];
if ([aCoder containsValueForKey:@"NSMaxSize"])
_maxSize = [aCoder decodeSizeForKey:@"NSMaxSize"];
_screenRect = [aCoder decodeRectForKey:@"NSScreenRect"]; // screen created on
_viewClass = [aCoder decodeObjectForKey:@"NSViewClass"]; // references the toolbar if present (anything else?)
_wtFlags = [aCoder decodeIntForKey:@"NSWTFlags"];
_windowBacking = [aCoder decodeIntForKey:@"NSWindowBacking"];
// Convert NSWindows to CPWindows.
_windowClass = CP_NSMapClassName([aCoder decodeObjectForKey:@"NSWindowClass"]);
_windowRect = [aCoder decodeRectForKey:@"NSWindowRect"];
_windowStyleMask = [aCoder decodeIntForKey:@"NSWindowStyleMask"];
_windowTitle = [aCoder decodeObjectForKey:@"NSWindowTitle"];
@@ -66,7 +67,7 @@ var NSBorderlessWindowMask = 0x00,
_windowStyleMask = CPBorderlessWindowMask;
else
_windowStyleMask = (_windowStyleMask & NSTitledWindowMask ? CPTitledWindowMask : 0) |
_windowStyleMask = (_windowStyleMask & NSTitledWindowMask ? CPTitledWindowMask : 0) |
(_windowStyleMask & NSClosableWindowMask ? CPClosableWindowMask : 0) |
(_windowStyleMask & NSMiniaturizableWindowMask ? CPMiniaturizableWindowMask : 0) |
(_windowStyleMask & NSResizableWindowMask ? CPResizableWindowMask : 0) |
@@ -75,7 +76,7 @@ var NSBorderlessWindowMask = 0x00,
(_windowStyleMask & NSHUDBackgroundWindowMask ? CPHUDBackgroundWindowMask : 0);
_windowIsFullBridge = [aCoder decodeObjectForKey:"NSFrameAutosaveName"] === "CPBorderlessBridgeWindowMask";
/*if (![_windowClass isEqualToString:@"NSPanel"])
_windowRect.origin.y -= [NSMainMenuView menuHeight]; // compensation for the additional menu bar
*/
+1 -5
View File
@@ -27,11 +27,7 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
if (self = [super NS_initWithCoder:aCoder])
{
}
return self;
return [super NS_initWithCoder:aCoder];
}
@end
+4 -3
View File
@@ -87,7 +87,8 @@ function main(args)
{
var options = parser.parse(args, null, null, true);
if (options.args.length < 1 || options.args.length > 2) {
if (options.args.length < 1 || options.args.length > 2)
{
parser.printUsage(options);
OS.exit(1);
}
@@ -101,9 +102,9 @@ function main(args)
CPLogRegister(CPLogPrint);
CPLog.debug("Input: " + options.args[0]);
CPLog.debug("Output: " + (options.args[1]||""));
CPLog.debug("Output: " + (options.args[1] || ""));
CPLog.debug("Format: " + ["Auto","Mac","iPhone"][options.format]);
CPLog.debug("Resources: " + (options.resources||""));
CPLog.debug("Resources: " + (options.resources || ""));
CPLog.debug("Frameworks: " + options.frameworks);
var converter = [[Converter alloc] init];