mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-24 23:45:52 +00:00
Merge branch '0.7b-integration' into 0.7b
This commit is contained in:
commit
738d9186a6
51 files changed
+1154
-816
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
[submodule "External/narwhal"]
|
||||
path = External/narwhal
|
||||
url = git://github.com/tlrobinson/narwhal.git
|
||||
[submodule "External/browser.js"]
|
||||
path = External/browser.js
|
||||
url = git://github.com/tlrobinson/browser.js.git
|
||||
[submodule "External/ojunit"]
|
||||
path = External/ojunit
|
||||
url = git://github.com/280north/ojunit.git
|
||||
[submodule "External/jack"]
|
||||
path = External/jack
|
||||
url = git://github.com/tlrobinson/jack.git
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* CPBezierPath.j
|
||||
*
|
||||
* Created by Ross Boucher.
|
||||
* Copyright 2009, 280 North, Inc.
|
||||
*
|
||||
* Adapted from Kevin Wojniak, portions Copyright 2009 Kevin Wojniak.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Copyright 2009 280 North, Inc.
|
||||
|
||||
*/
|
||||
|
||||
@import <AppKit/CPGraphicsContext.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
|
||||
// Class defaults
|
||||
|
||||
var DefaultLineWidth = 1.0;
|
||||
|
||||
|
||||
|
||||
@implementation CPBezierPath : CPObject
|
||||
{
|
||||
CGPath _path;
|
||||
float _lineWidth;
|
||||
}
|
||||
|
||||
+ (CPBezierPath)bezierPath
|
||||
{
|
||||
return [[[self class] alloc] init];
|
||||
}
|
||||
|
||||
+ (CPBezierPath)bezierPathWithOvalInRect:(CGRect)rect
|
||||
{
|
||||
var path = [[self class] bezierPath];
|
||||
|
||||
[path appendBezierPathWithOvalInRect:rect];
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
+ (CPBezierPath)bezierPathWithRect:(CGRect)rect
|
||||
{
|
||||
var path = [[self class] bezierPath];
|
||||
|
||||
[path appendBezierPathWithRect:rect];
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
+ (float)defaultLineWidth
|
||||
{
|
||||
return DefaultLineWidth;
|
||||
}
|
||||
|
||||
+ (void)setDefaultLineWidth:(float)width
|
||||
{
|
||||
DefaultLineWidth = width;
|
||||
}
|
||||
|
||||
+ (void)fillRect:(CGRect)rect
|
||||
{
|
||||
[[[self class] bezierPathWithRect:rect] fill];
|
||||
}
|
||||
|
||||
+ (void)strokeRect:(CGRect)rect
|
||||
{
|
||||
[[[self class] bezierPathWithRect:rect] stroke];
|
||||
}
|
||||
|
||||
+ (void)strokeLineFromPoint:(CGPoint)point1 toPoint:(CGPoint)point2
|
||||
{
|
||||
var path = [[self class] bezierPath];
|
||||
|
||||
[path moveToPoint:point1];
|
||||
[path lineToPoint:point2];
|
||||
|
||||
[path stroke];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_path = CGPathCreateMutable();
|
||||
_lineWidth = [[self class] defaultLineWidth];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)moveToPoint:(CGPoint)point
|
||||
{
|
||||
CGPathMoveToPoint(_path, nil, point.x, point.y);
|
||||
}
|
||||
|
||||
- (void)lineToPoint:(CGPoint)point
|
||||
{
|
||||
CGPathAddLineToPoint(_path, nil, point.x, point.y);
|
||||
}
|
||||
|
||||
- (void)curveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
|
||||
{
|
||||
CGPathAddCurveToPoint(_path, nil, controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, endPoint.x, endPoint.y);
|
||||
}
|
||||
|
||||
- (void)closePath
|
||||
{
|
||||
CGPathCloseSubpath(_path);
|
||||
}
|
||||
|
||||
- (void)stroke
|
||||
{
|
||||
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGContextBeginPath(ctx);
|
||||
CGContextAddPath(ctx, _path);
|
||||
CGContextSetLineWidth(ctx, [self lineWidth]);
|
||||
CGContextStrokePath(ctx);
|
||||
CGContextClosePath(ctx);
|
||||
}
|
||||
|
||||
- (void)fill
|
||||
{
|
||||
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
CGContextBeginPath(ctx);
|
||||
CGContextAddPath(ctx, _path);
|
||||
CGContextSetLineWidth(ctx, [self lineWidth]);
|
||||
CGContextFillPath(ctx);
|
||||
CGContextClosePath(ctx);
|
||||
}
|
||||
|
||||
- (float)lineWidth
|
||||
{
|
||||
return _lineWidth;
|
||||
}
|
||||
|
||||
- (void)setLineWidth:(float)lineWidth
|
||||
{
|
||||
_lineWidth = lineWidth;
|
||||
}
|
||||
|
||||
- (unsigned)elementCount
|
||||
{
|
||||
return _path.count;
|
||||
}
|
||||
|
||||
- (BOOL)isEmpty
|
||||
{
|
||||
return CGPathIsEmpty(_path);
|
||||
}
|
||||
|
||||
- (CGPoint)currentPoint
|
||||
{
|
||||
return CGPathGetCurrentPoint(_path);
|
||||
}
|
||||
|
||||
- (void)appendBezierPathWithPoints:(CPArray)points count:(unsigned)count
|
||||
{
|
||||
CGPathAddLines(_path, nil, points, count);
|
||||
}
|
||||
|
||||
- (void)appendBezierPathWithRect:(CGRect)rect
|
||||
{
|
||||
CGPathAddRect(_path, nil, rect);
|
||||
}
|
||||
|
||||
- (void)appendBezierPathWithOvalInRect:(CGRect)rect
|
||||
{
|
||||
CGPathAddPath(_path, nil, CGPathWithEllipseInRect(rect));
|
||||
}
|
||||
|
||||
- (void)appendBezierPathWithRoundedRect:(CGRect)rect xRadius:(float)xRadius yRadius:(float)yRadius
|
||||
{
|
||||
CGPathAddPath(_path, nil, CGPathWithRoundedRectangleInRect(rect, xRadius, yRadius, YES, YES, YES, YES));
|
||||
}
|
||||
|
||||
- (void)appendBezierPath:(NSBezierPath *)other
|
||||
{
|
||||
CGPathAddPath(_path, nil, other._path);
|
||||
}
|
||||
|
||||
- (void)removeAllPoints
|
||||
{
|
||||
_path = CGPathCreateMutable();
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -127,6 +127,7 @@
|
||||
{
|
||||
_itemData = [CPKeyedArchiver archivedDataWithRootObject:anItem];
|
||||
_itemForDragging = anItem//[CPKeyedUnarchiver unarchiveObjectWithData:_itemData];
|
||||
_itemPrototype = anItem;
|
||||
|
||||
[self reloadContent];
|
||||
}
|
||||
|
||||
@@ -590,6 +590,37 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPColor (CoreGraphicsExtensions)
|
||||
|
||||
/*!
|
||||
Set's the receiver to be the fill and stroke color in the current graphics context
|
||||
*/
|
||||
- (void)set
|
||||
{
|
||||
[self setFill];
|
||||
[self setStroke];
|
||||
}
|
||||
|
||||
/*!
|
||||
Set's the receiver to be the fill color in the current graphics context
|
||||
*/
|
||||
- (void)setFill
|
||||
{
|
||||
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
CGContextSetFillColor(ctx, self);
|
||||
}
|
||||
|
||||
/*!
|
||||
Set's the receiver to be the stroke color in the current graphics context
|
||||
*/
|
||||
- (void)setStroke
|
||||
{
|
||||
var ctx = [[CPGraphicsContext currentContext] graphicsPort];
|
||||
CGContextSetStrokeColor(ctx, self);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPColorComponentsKey = @"CPColorComponentsKey",
|
||||
CPColorPatternImageKey = @"CPColorPatternImageKey";
|
||||
|
||||
|
||||
+158
-184
@@ -66,8 +66,8 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil, nil, nil, nil, 1.0, 24.0]
|
||||
forKeys:[@"bezel-inset", @"content-inset", @"left-segment-bezel-color", @"right-segment-bezel-color", @"center-segment-bezel-color", @"divider-bezel-color", @"divider-thickness", @"default-height"]];
|
||||
return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), nil, nil, nil, nil, 1.0, 24.0]
|
||||
forKeys:[@"alignment", @"vertical-alignment", @"image-position", @"image-scaling", @"bezel-inset", @"content-inset", @"left-segment-bezel-color", @"right-segment-bezel-color", @"center-segment-bezel-color", @"divider-bezel-color", @"divider-thickness", @"default-height"]];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aRect
|
||||
@@ -108,28 +108,17 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
var height = CGRectGetHeight([self bounds]);
|
||||
|
||||
if (_segments.length < aCount)
|
||||
{
|
||||
var index = _segments.length;
|
||||
|
||||
for (; index < aCount; ++index)
|
||||
{
|
||||
for (var index = _segments.length; index < aCount; ++index)
|
||||
{
|
||||
_segments[index] = [[_CPSegmentItem alloc] init];
|
||||
_segments[index].frame.size.height = height;
|
||||
|
||||
_themeStates[index] = CPThemeStateNormal;
|
||||
}
|
||||
}
|
||||
else if (aCount < _segments.length)
|
||||
{
|
||||
var index = aCount;
|
||||
|
||||
for (; index < _segments.length; ++index)
|
||||
{
|
||||
[_segments[index].imageView removeFromSuperview];
|
||||
[_segments[index].labelView removeFromSuperview];
|
||||
|
||||
for (var index = aCount; index < _segments.length; ++index)
|
||||
_segments[index] = nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (_selectedSegment < _segments.length)
|
||||
@@ -263,32 +252,9 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
{
|
||||
var segment = _segments[aSegment];
|
||||
|
||||
if (!anImage)
|
||||
{
|
||||
[segment.imageView removeFromSuperview];
|
||||
|
||||
segment.imageView = nil;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!segment.imageView)
|
||||
{
|
||||
segment.imageView = [[CPImageView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[self addSubview:segment.imageView];
|
||||
}
|
||||
|
||||
[segment.imageView setImage:anImage];
|
||||
[segment.imageView setFrameSize:CGSizeMakeCopy([anImage size])];
|
||||
}
|
||||
|
||||
segment.image = anImage;
|
||||
|
||||
if (segment.width)
|
||||
[self drawSegment:aSegment highlight:NO];
|
||||
else
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -310,35 +276,10 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
- (void)setLabel:(CPString)aLabel forSegment:(unsigned)aSegment
|
||||
{
|
||||
var segment = _segments[aSegment];
|
||||
|
||||
if (!aLabel || !aLabel.length)
|
||||
{
|
||||
[segment.labelView removeFromSuperview];
|
||||
|
||||
segment.labelView = nil;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!segment.labelView)
|
||||
{
|
||||
segment.labelView = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[segment.labelView setFont:[self font]];
|
||||
|
||||
[self addSubview:segment.labelView];
|
||||
}
|
||||
|
||||
[segment.labelView setStringValue:aLabel];
|
||||
[segment.labelView sizeToFit];
|
||||
}
|
||||
|
||||
_segments[aSegment].label = aLabel;
|
||||
|
||||
if (segment.width)
|
||||
[self drawSegment:aSegment highlight:NO];
|
||||
else
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
[self tileWithChangedSegment:aSegment];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -411,6 +352,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
[self drawSegmentBezel:aSegment highlight:NO];
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -432,6 +374,9 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
- (void)setEnabled:(BOOL)isEnabled forSegment:(unsigned)aSegment
|
||||
{
|
||||
_segments[aSegment].enabled = isEnabled;
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -477,6 +422,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
_themeStates[aSegment] &= ~CPThemeStateHighlighted;
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (float)_leftOffsetForSegment:(unsigned)segment
|
||||
@@ -504,22 +450,23 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
}
|
||||
else if (aName === "right-segment-bezel")
|
||||
{
|
||||
return CGRectMake(CGRectGetMaxX(bounds) - contentInset.right, bezelInset.top, contentInset.right, height);
|
||||
return CGRectMake(CGRectGetMaxX(bounds) - contentInset.right - bezelInset.right, bezelInset.top, contentInset.right, height);
|
||||
}
|
||||
else if (aName.substring(0, "segment-bezel".length) == "segment-bezel")
|
||||
{
|
||||
var segment = parseInt(aName.substring("segment-bezel-".length), 10),
|
||||
width = [self widthForSegment:segment],
|
||||
left = [self _leftOffsetForSegment:segment];
|
||||
frame = CGRectCreateCopy(_segments[segment].frame);
|
||||
|
||||
if (_segments.length == 1)
|
||||
return CGRectMake(left + contentInset.left, bezelInset.top, width - contentInset.left - contentInset.right, height);
|
||||
else if (segment == 0)
|
||||
return CGRectMake(left + contentInset.left, bezelInset.top, width - contentInset.left, height);
|
||||
else if (segment == _segments.length - 1)
|
||||
return CGRectMake(left, bezelInset.top, width - contentInset.right, height);
|
||||
else
|
||||
return CGRectMake(left, bezelInset.top, width, height);
|
||||
if (segment == 0)
|
||||
{
|
||||
frame.origin.x += contentInset.left;
|
||||
frame.size.width -= contentInset.left;
|
||||
}
|
||||
|
||||
if (segment == _segments.length - 1)
|
||||
frame.size.width -= contentInset.right;
|
||||
|
||||
return frame;
|
||||
}
|
||||
else if (aName.substring(0, "divider-bezel".length) == "divider-bezel")
|
||||
{
|
||||
@@ -530,12 +477,21 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
return CGRectMake(left + width, bezelInset.top, thickness, height);
|
||||
}
|
||||
else if (aName.substring(0, "segment-content".length) == "segment-content")
|
||||
{
|
||||
var segment = parseInt(aName.substring("segment-content-".length), 10);
|
||||
|
||||
return [self contentFrameForSegment:segment];
|
||||
}
|
||||
|
||||
return [super rectForEphemeralSubviewNamed:aName];
|
||||
}
|
||||
|
||||
- (CPView)createEphemeralSubviewNamed:(CPString)aName
|
||||
{
|
||||
if (aName.substring(0, "segment-content".length) == "segment-content")
|
||||
return [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
|
||||
|
||||
return [[CPView alloc] initWithFrame:_CGRectMakeZero()];
|
||||
}
|
||||
|
||||
@@ -561,8 +517,12 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
for (var i=0, count = _themeStates.length; i<count; i++)
|
||||
{
|
||||
var themeState = _themeStates[i];
|
||||
|
||||
themeState |= _themeState & CPThemeStateDisabled;
|
||||
|
||||
var bezelColor = [self valueForThemeAttribute:@"center-segment-bezel-color"
|
||||
inState:_themeStates[i]];
|
||||
inState:themeState];
|
||||
|
||||
var bezelView = [self layoutEphemeralSubviewNamed:"segment-bezel-"+i
|
||||
positioned:CPWindowBelow
|
||||
@@ -570,13 +530,41 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
[bezelView setBackgroundColor:bezelColor];
|
||||
|
||||
|
||||
//layout image/title views
|
||||
var segment = _segments[i];
|
||||
|
||||
|
||||
var contentView = [self layoutEphemeralSubviewNamed:@"segment-content-"+i
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:@"segment-bezel-"+i];
|
||||
|
||||
[contentView setText:segment.label];
|
||||
[contentView setImage:segment.image];
|
||||
|
||||
[contentView setFont:[self valueForThemeAttribute:@"font" inState:themeState]];
|
||||
[contentView setTextColor:[self valueForThemeAttribute:@"text-color" inState:themeState]];
|
||||
[contentView setAlignment:[self valueForThemeAttribute:@"alignment" inState:themeState]];
|
||||
[contentView setVerticalAlignment:[self valueForThemeAttribute:@"vertical-alignment" inState:themeState]];
|
||||
[contentView setLineBreakMode:[self valueForThemeAttribute:@"line-break-mode" inState:themeState]];
|
||||
[contentView setTextShadowColor:[self valueForThemeAttribute:@"text-shadow-color" inState:themeState]];
|
||||
[contentView setTextShadowOffset:[self valueForThemeAttribute:@"text-shadow-offset" inState:themeState]];
|
||||
[contentView setImageScaling:[self valueForThemeAttribute:@"image-scaling" inState:themeState]];
|
||||
|
||||
if (segment.image && segment.label)
|
||||
[contentView setImagePosition:[self valueForThemeAttribute:@"image-position" inState:themeState]];
|
||||
else if (segment.image)
|
||||
[contentView setImagePosition:CPImageOnly];
|
||||
|
||||
if (i == count - 1)
|
||||
continue;
|
||||
|
||||
var borderState = _themeStates[i] | _themeStates[i+1];
|
||||
|
||||
borderState = (borderState & CPThemeStateSelected & ~CPThemeStateHighlighted) ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
|
||||
|
||||
borderState |= _themeState & CPThemeStateDisabled;
|
||||
|
||||
var borderColor = [self valueForThemeAttribute:@"divider-bezel-color"
|
||||
inState:borderState];
|
||||
|
||||
@@ -596,63 +584,29 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (void)drawSegment:(int)aSegment highlight:(BOOL)shouldHighlight
|
||||
{
|
||||
var segment = _segments[aSegment],
|
||||
|
||||
imageView = segment.imageView,
|
||||
labelView = segment.labelView,
|
||||
|
||||
frame = segment.frame,
|
||||
|
||||
segmentX = CGRectGetMinX(frame),
|
||||
segmentWidth = CGRectGetWidth(frame),
|
||||
segmentHeight = CGRectGetHeight(frame) - 1.0;
|
||||
|
||||
if (imageView && labelView)
|
||||
{
|
||||
var imageViewSize = [imageView frame].size,
|
||||
labelViewSize = [labelView frame].size,
|
||||
totalHeight = imageViewSize.height + labelViewSize.height,
|
||||
labelWidth = MIN(labelViewSize.width, width),
|
||||
y = (segmentHeight - totalHeight) / 2.0;
|
||||
|
||||
[imageView setFrameOrigin:CGPointMake(segmentX + (segmentWidth - imageViewSize.width) / 2.0, y)];
|
||||
|
||||
if (labelWidth < labelViewSize.width)
|
||||
[labelView setFrameSize:CGSizeMake(labelWidth, labelViewSize.height)];
|
||||
|
||||
[labelView setFrameOrigin:CGPointMake(segmentX + (segmentWidth - labelWidth) / 2.0, y + imageViewSize.height)];
|
||||
}
|
||||
else if (imageView)
|
||||
{
|
||||
var imageViewSize = [imageView frame].size;
|
||||
|
||||
[imageView setFrameOrigin:CGPointMake(segmentX + (segmentWidth - imageViewSize.width) / 2.0, (segmentHeight - imageViewSize.height) / 2.0)];
|
||||
}
|
||||
else if (labelView)
|
||||
{
|
||||
var labelViewSize = [labelView frame].size,
|
||||
labelWidth = MIN(labelViewSize.width, segmentWidth);
|
||||
|
||||
if (labelWidth < labelViewSize.width)
|
||||
[labelView setFrameSize:CGSizeMake(labelWidth, labelViewSize.height)];
|
||||
|
||||
[labelView setFrameOrigin:CGPointMake(segmentX + (segmentWidth - labelWidth) / 2.0, (segmentHeight - labelViewSize.height) / 2.0)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tileWithChangedSegment:(unsigned)aSegment
|
||||
{
|
||||
if (aSegment >= _segments.length)
|
||||
return;
|
||||
|
||||
var segment = _segments[aSegment],
|
||||
segmentWidth = segment.width;
|
||||
segmentWidth = segment.width,
|
||||
themeState = _themeStates[aSegment] | (_themeState & CPThemeStateDisabled),
|
||||
contentInset = [self valueForThemeAttribute:@"content-inset" inState:themeState],
|
||||
font = [self valueForThemeAttribute:@"font" inState:themeState];
|
||||
|
||||
if (!segmentWidth)
|
||||
{
|
||||
if (segment.labelView && segment.imageView)
|
||||
segmentWidth = MAX(CGRectGetWidth([segment.labelView frame]) , CGRectGetWidth([segment.imageView frame]));
|
||||
else if (segment.labelView)
|
||||
segmentWidth = CGRectGetWidth([segment.labelView frame]);
|
||||
else if (segment.imageView)
|
||||
segmentWidth = CGRectGetWidth([segment.imageView frame]);
|
||||
if (segment.image && segment.label)
|
||||
segmentWidth = [segment.label sizeWithFont:font].width + [segment.image size].width + contentInset.left + contentInset.right;
|
||||
else if (segment.image)
|
||||
segmentWidth = [segment.image size].width + contentInset.left + contentInset.right;
|
||||
else if (segment.label)
|
||||
segmentWidth = [segment.label sizeWithFont:font].width + contentInset.left + contentInset.right;
|
||||
else
|
||||
segmentWidth = 0.0;
|
||||
}
|
||||
|
||||
var delta = segmentWidth - CGRectGetWidth(segment.frame);
|
||||
@@ -666,7 +620,8 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
[self setFrameSize:CGSizeMake(CGRectGetWidth(frame) + delta, CGRectGetHeight(frame))];
|
||||
|
||||
// Update Segment Width
|
||||
segment.frame.size.width = segmentWidth;
|
||||
segment.width = segmentWidth;
|
||||
segment.frame = [self frameForSegment:aSegment];;
|
||||
|
||||
// Update Following Segments Widths
|
||||
var index = aSegment + 1;
|
||||
@@ -681,6 +636,9 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
[self drawSegmentBezel:aSegment highlight:NO];
|
||||
[self drawSegment:aSegment highlight:NO];
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -689,7 +647,27 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
*/
|
||||
- (CGRect)frameForSegment:(unsigned)aSegment
|
||||
{
|
||||
return _segments[aSegment].frame;
|
||||
return [self bezelFrameForSegment:aSegment];
|
||||
}
|
||||
|
||||
- (CGRect)bezelFrameForSegment:(unsigned)aSegment
|
||||
{
|
||||
var height = [self currentValueForThemeAttribute:@"default-height"],
|
||||
bezelInset = [self currentValueForThemeAttribute:@"bezel-inset"],
|
||||
width = [self widthForSegment:aSegment],
|
||||
left = [self _leftOffsetForSegment:aSegment];
|
||||
|
||||
return CGRectMake(left, bezelInset.top, width, height);
|
||||
}
|
||||
|
||||
- (CGRect)contentFrameForSegment:(unsigned)aSegment
|
||||
{
|
||||
var height = [self currentValueForThemeAttribute:@"default-height"],
|
||||
contentInset = [self currentValueForThemeAttribute:@"content-inset"],
|
||||
width = [self widthForSegment:aSegment],
|
||||
left = [self _leftOffsetForSegment:aSegment];
|
||||
|
||||
return CGRectMake(left + contentInset.left, contentInset.top, width - contentInset.left - contentInset.right, height - contentInset.top - contentInset.bottom);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -733,6 +711,9 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
|
||||
if (type == CPLeftMouseUp)
|
||||
{
|
||||
if (_trackingSegment == -1)
|
||||
return;
|
||||
|
||||
if (CGRectContainsPoint(_segments[_trackingSegment].frame, location))
|
||||
{
|
||||
if (_trackingMode == CPSegmentSwitchTrackingSelectAny)
|
||||
@@ -766,13 +747,15 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
{
|
||||
_trackingHighlighted = YES;
|
||||
_trackingSegment = [self testSegment:location];
|
||||
|
||||
|
||||
[self drawSegmentBezel:_trackingSegment highlight:YES];
|
||||
}
|
||||
|
||||
else if (type == CPLeftMouseDragged)
|
||||
{
|
||||
if (_trackingSegment == -1)
|
||||
return;
|
||||
|
||||
var highlighted = CGRectContainsPoint(_segments[_trackingSegment].frame, location);
|
||||
|
||||
if (highlighted != _trackingHighlighted)
|
||||
@@ -790,14 +773,6 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
{
|
||||
[super setFont:aFont];
|
||||
|
||||
var count = _segments.length;
|
||||
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
while (count--)
|
||||
[_segments[count].labelView setFont:aFont];
|
||||
|
||||
[self tileWithChangedSegment:0];
|
||||
}
|
||||
|
||||
@@ -816,12 +791,16 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
|
||||
if (self)
|
||||
{
|
||||
_segments = [aCoder decodeObjectForKey:CPSegmentedControlSegmentsKey];
|
||||
_segmentStyle = [aCoder decodeIntForKey:CPSegmentedControlSegmentStyleKey];
|
||||
var frame = [self frame],
|
||||
originalWidth = frame.size.width;
|
||||
|
||||
_themeStates = [];
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
_themeStates[i] = 0;
|
||||
frame.size.width = 0;
|
||||
|
||||
[self setFrame:frame];
|
||||
|
||||
_segments = [aCoder decodeObjectForKey:CPSegmentedControlSegmentsKey];
|
||||
_segmentStyle = [aCoder decodeIntForKey:CPSegmentedControlSegmentStyleKey];
|
||||
_themeStates = [];
|
||||
|
||||
if ([aCoder containsValueForKey:CPSegmentedControlSelectedKey])
|
||||
_selectedSegment = [aCoder decodeIntForKey:CPSegmentedControlSelectedKey];
|
||||
@@ -829,18 +808,25 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
_selectedSegment = -1;
|
||||
|
||||
if ([aCoder containsValueForKey:CPSegmentedControlTrackingModeKey])
|
||||
_trackingMode = [aCoder decodeIntForKey:CPSegmentedControlTrackingModeKey];
|
||||
_trackingMode = [aCoder decodeIntForKey:CPSegmentedControlTrackingModeKey];
|
||||
else
|
||||
_trackingMode = CPSegmentSwitchTrackingSelectOne;
|
||||
|
||||
// HACK
|
||||
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
{
|
||||
if (_segments[i].image != undefined)
|
||||
[self setImage:_segments[i].image forSegment:i];
|
||||
if (_segments[i].label != undefined)
|
||||
[self setLabel:_segments[i].label forSegment:i];
|
||||
_themeStates[i] = _segments[i].selected ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
[self tileWithChangedSegment:i];
|
||||
}
|
||||
|
||||
var difference = MAX(originalWidth - [self frame].size.width, 0.0),
|
||||
remainingWidth = FLOOR(difference / _segments.length);
|
||||
|
||||
for (var i=0; i < _segments.length; i++)
|
||||
[self setWidth:_segments[i].width + remainingWidth forSegment:i];
|
||||
|
||||
[self tileWithChangedSegment:0];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -848,13 +834,7 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
var actualSubviews = _subviews;
|
||||
|
||||
_subviews = [];
|
||||
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
_subviews = actualSubviews;
|
||||
|
||||
[aCoder encodeObject:_segments forKey:CPSegmentedControlSegmentsKey];
|
||||
[aCoder encodeInt:_selectedSegment forKey:CPSegmentedControlSelectedKey];
|
||||
@@ -873,29 +853,24 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
|
||||
BOOL selected;
|
||||
BOOL enabled;
|
||||
int tag;
|
||||
|
||||
int width;
|
||||
CPView labelView;
|
||||
CPView imageView;
|
||||
CPRect frame;
|
||||
|
||||
CGRect frame;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
image = nil;
|
||||
label = @"";
|
||||
menu = nil;
|
||||
selected = NO;
|
||||
enabled = NO;
|
||||
tag = 0;
|
||||
|
||||
labelView = nil;
|
||||
imageView = nil;
|
||||
|
||||
width = 0;
|
||||
frame = CGRectMakeZero();
|
||||
image = nil;
|
||||
label = @"";
|
||||
menu = nil;
|
||||
selected = NO;
|
||||
enabled = NO;
|
||||
tag = 0;
|
||||
width = 0;
|
||||
|
||||
frame = CGRectMakeZero();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -907,7 +882,8 @@ var CPSegmentItemImageKey = "CPSegmentItemImageKey",
|
||||
CPSegmentItemMenuKey = "CPSegmentItemMenuKey",
|
||||
CPSegmentItemSelectedKey = "CPSegmentItemSelectedKey",
|
||||
CPSegmentItemEnabledKey = "CPSegmentItemEnabledKey",
|
||||
CPSegmentItemTagKey = "CPSegmentItemTagKey";
|
||||
CPSegmentItemTagKey = "CPSegmentItemTagKey",
|
||||
CPSegmentItemWidthKey = "CPSegmentItemWidthKey";
|
||||
|
||||
@implementation _CPSegmentItem (CPCoding)
|
||||
|
||||
@@ -917,18 +893,15 @@ var CPSegmentItemImageKey = "CPSegmentItemImageKey",
|
||||
|
||||
if (self)
|
||||
{
|
||||
image = [aCoder decodeObjectForKey:CPSegmentItemImageKey];
|
||||
label = [aCoder decodeObjectForKey:CPSegmentItemLabelKey];
|
||||
menu = [aCoder decodeObjectForKey:CPSegmentItemMenuKey];
|
||||
selected = [aCoder decodeBoolForKey:CPSegmentItemSelectedKey];
|
||||
enabled = [aCoder decodeBoolForKey:CPSegmentItemEnabledKey];
|
||||
tag = [aCoder decodeIntForKey:CPSegmentItemTagKey];
|
||||
|
||||
labelView = nil;
|
||||
imageView = nil;
|
||||
|
||||
width = 0;
|
||||
frame = CGRectMakeZero();
|
||||
image = [aCoder decodeObjectForKey:CPSegmentItemImageKey];
|
||||
label = [aCoder decodeObjectForKey:CPSegmentItemLabelKey];
|
||||
menu = [aCoder decodeObjectForKey:CPSegmentItemMenuKey];
|
||||
selected = [aCoder decodeBoolForKey:CPSegmentItemSelectedKey];
|
||||
enabled = [aCoder decodeBoolForKey:CPSegmentItemEnabledKey];
|
||||
tag = [aCoder decodeIntForKey:CPSegmentItemTagKey];
|
||||
width = [aCoder decodeFloatForKey:CPSegmentItemWidthKey];
|
||||
|
||||
frame = CGRectMakeZero();
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -942,6 +915,7 @@ var CPSegmentItemImageKey = "CPSegmentItemImageKey",
|
||||
[aCoder encodeBool:selected forKey:CPSegmentItemSelectedKey];
|
||||
[aCoder encodeBool:enabled forKey:CPSegmentItemEnabledKey];
|
||||
[aCoder encodeInt:tag forKey:CPSegmentItemTagKey];
|
||||
[aCoder encodeFloat:width forKey:CPSegmentItemWidthKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -98,7 +98,7 @@ var CPStringReferenceElement = nil,
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
|
||||
@@ -107,9 +107,14 @@ var CPStringReferenceElement = nil,
|
||||
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
|
||||
CPStringReferenceElement.textContent = self;
|
||||
|
||||
return CGSizeMake(CPStringReferenceElement.clientWidth, CPStringReferenceElement.clientHeight);
|
||||
return _CGSizeMake(CPStringReferenceElement.clientWidth, CPStringReferenceElement.clientHeight);
|
||||
#endif
|
||||
return _CGSizeMakeZero();
|
||||
}
|
||||
|
||||
+ (void)_resetSize
|
||||
{
|
||||
CPStringReferenceElement = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -78,6 +78,9 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
|
||||
|
||||
- (id)initWithCibNamed:(CPString)aName bundle:(CPBundle)aBundle loadDelegate:(id)aLoadDelegate
|
||||
{
|
||||
if (![aName hasSuffix:@".cib"])
|
||||
aName = [aName stringByAppendingString:@".cib"];
|
||||
|
||||
// If aBundle is nil, use mainBundle, but ONLY for searching for the nib, not for resources later.
|
||||
self = [self initWithContentsOfURL:[aBundle || [CPBundle mainBundle] pathForResource:aName] loadDelegate:aLoadDelegate];
|
||||
|
||||
|
||||
+199
-220
@@ -41,145 +41,37 @@ kCGPathStroke = 2;
|
||||
kCGPathFillStroke = 3;
|
||||
kCGPathEOFillStroke = 4;
|
||||
|
||||
/*
|
||||
@global
|
||||
/*!
|
||||
@group CGBlendMode
|
||||
*/
|
||||
|
||||
kCGBlendModeNormal = 0;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeMultiply = 1;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeScreen = 2;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeOverlay = 3;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeDarken = 4;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeLighten = 5;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeColorDodge = 6;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeColorBurn = 7;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeSoftLight = 8;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeHardLight = 9;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeDifference = 10;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeExclusion = 11;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeHue = 12;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeSaturation = 13;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeColor = 14;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeLuminosity = 15;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeClear = 16;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeCopy = 17;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeSourceIn = 18;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeSourceOut = 19;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeSourceAtop = 20;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeDestinationOver = 21;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeDestinationIn = 22;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeDestinationOut = 23;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeDestinationAtop = 24;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModeXOR = 25;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModePlusDarker = 26;
|
||||
/*
|
||||
@global
|
||||
@group CGBlendMode
|
||||
*/
|
||||
kCGBlendModePlusLighter = 27;
|
||||
|
||||
/*!
|
||||
@@ -206,6 +98,10 @@ function CGContextRetain(aContext)
|
||||
if (!CPFeatureIsCompatible(CPHTMLCanvasFeature))
|
||||
{
|
||||
|
||||
/*!
|
||||
Creates a new graphics state, which describes all the current values for drawing.
|
||||
@return a graphics state
|
||||
*/
|
||||
function CGGStateCreate()
|
||||
{
|
||||
return { alpha:1.0, strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0,
|
||||
@@ -213,6 +109,11 @@ function CGGStateCreate()
|
||||
shadowOffset:_CGSizeMakeZero(), shadowBlur:0.0, shadowColor:NULL, CTM:_CGAffineTransformMakeIdentity() };
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a copy of the given graphics state.
|
||||
@param aGState the graphics state to copy
|
||||
@return a copy of the given graphics state
|
||||
*/
|
||||
function CGGStateCreateCopy(aGState)
|
||||
{
|
||||
return { alpha:aGState.alpha, strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth,
|
||||
@@ -221,16 +122,30 @@ function CGGStateCreateCopy(aGState)
|
||||
shadowOffset:aGState.shadowOffset, shadowBlur:aGState.shadowBlur, shadowColor:aGState.shadowColor, CTM:_CGAffineTransformMakeCopy(aGState.CTM) };
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a new graphics context.
|
||||
@return CGContext a new graphics context which can be drawn into
|
||||
*/
|
||||
function CGBitmapGraphicsContextCreate()
|
||||
{
|
||||
return { DOMElement:document.createElement("div"), path:NULL, gState:CGGStateCreate(), gStateStack:[] };
|
||||
}
|
||||
|
||||
/*!
|
||||
Pushes the current graphics state of aContext onto the top of a stack.
|
||||
@param aContext the CGContext to edit
|
||||
@return void
|
||||
*/
|
||||
function CGContextSaveGState(aContext)
|
||||
{
|
||||
aContext.gStateStack.push(CGGStateCreateCopy(aContext.gState));
|
||||
}
|
||||
|
||||
/*!
|
||||
Pops the most recent graphics state of the top of the graphics stack and restores it.
|
||||
@param aContext the CGContext to edit
|
||||
@return void
|
||||
*/
|
||||
function CGContextRestoreGState(aContext)
|
||||
{
|
||||
aContext.gState = aContext.gStateStack.pop();
|
||||
@@ -266,26 +181,67 @@ function CGContextAddArc(aContext, x, y, radius, startAngle, endAngle, clockwise
|
||||
CGPathAddArc(aContext.path, aContext.gState.CTM, x, y, radius, startAngle, endAngle, clockwise);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds an arc to the current context that ends in the specified point.
|
||||
@param aContext the CGContext to edit
|
||||
@param x1 the x coordinate of the beginning of the arc
|
||||
@param y1 the y coordinate of the beginning of the arc
|
||||
@param x2 the x coordinate of the end of the arc
|
||||
@param y2 the y coordinate of the end of the arc
|
||||
@param radius the radius of the arc to be drawn
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddArcToPoint(aContext, x1, y1, x2, y2, radius)
|
||||
{
|
||||
CGPathAddArcToPoint(aContext.path, aContext.gState.CTM, x1, y1, x2, y2, radius);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a cubic curve to the current context
|
||||
@param aContext the CGContext to edit
|
||||
@param cp1x the x coordinate of the first control point
|
||||
@param cp1y the y coordinate of the first control point
|
||||
@param cp2x the x coordinate of the second control point
|
||||
@param cp2y the y coordinate of the second control point
|
||||
@param x the x coordinate of the end of the curve
|
||||
@param y the y coordinate of the end of the curve
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddCurveToPoint(aContext, cp1x, cp1y, cp2x, cp2y, x, y)
|
||||
{
|
||||
CGPathAddCurveToPoint(aContext.path, aContext.gState.CTM, cp1x, cp1y, cp2x, cp2y, x, y);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a line to each element in the points array
|
||||
@param aContext the CGContext to move
|
||||
@param points an array of points that are to be consecutively executed as if they were individual addToPoint calls
|
||||
@param count an upper bound on the number of points to use
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddLines(aContext, points, count)
|
||||
{
|
||||
CGPathAddLines(aContext.path, aContext.gState.CTM, points, count);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a line from the current point to the x/y
|
||||
@param aContext the CGContext to move
|
||||
@param x the x coordinate of the end point of the line
|
||||
@param y the y coordinate of the end point of the line
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddLineToPoint(aContext, x, y)
|
||||
{
|
||||
CGPathAddLineToPoint(aContext.path, aContext.gState.CTM, x, y);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds aPath to the current path in aContext
|
||||
@param aContext the CGContext to add to
|
||||
@param aPath the path to be added
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddPath(aContext, aPath)
|
||||
{
|
||||
if (!aContext || CGPathIsEmpty(aPath))
|
||||
@@ -297,32 +253,71 @@ function CGContextAddPath(aContext, aPath)
|
||||
CGPathAddPath(aContext.path, aContext.gState.CTM, aPath);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a quadratic curve from the current point to the point specified by x/y, using the control point specified by cpx/cpy
|
||||
@param aContext the CGContext to add the curve to
|
||||
@param cpx the x coordinate for the curve's control point
|
||||
@param cpy the y coordinate for the curve's control point
|
||||
@param x the x coordinate for the end point of the curve
|
||||
@param y the y coordinate for the end point of the curve
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddQuadCurveToPoint(aContext, cpx, cpy, x, y)
|
||||
{
|
||||
CGPathAddQuadCurveToPoint(aContext.path, aContext.gState.CTM, cpx, cpy, x, y);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds aRect to the current path in the given context
|
||||
@param aContext the CGContext to add to
|
||||
@param aRect the dimensions of the rectangle to add
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddRect(aContext, aRect)
|
||||
{
|
||||
CGPathAddRect(aContext.path, aContext.gState.CTM, aRect);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds up to count elements from rects to the current path in aContext
|
||||
@param aContext the CGContext to add to
|
||||
@param rects an array of CGRects to be added to the context's path
|
||||
@param the upper bound of elements to be added
|
||||
@return void
|
||||
*/
|
||||
function CGContextAddRects(aContext, rects, count)
|
||||
{
|
||||
CGPathAddRects(aContext.path, aContext.gState.CTM, rects, count);
|
||||
}
|
||||
|
||||
/*!
|
||||
Begins a new subpath in the given context
|
||||
@param aContext the CGContext to create a new path in
|
||||
@return void
|
||||
*/
|
||||
function CGContextBeginPath(aContext)
|
||||
{
|
||||
// This clears any previous path.
|
||||
aContext.path = CGPathCreateMutable();
|
||||
}
|
||||
|
||||
/*!
|
||||
Closes the currently open subpath, if any, in aContext
|
||||
@param aContext the CGContext to close a path in
|
||||
@return void
|
||||
*/
|
||||
function CGContextClosePath(aContext)
|
||||
{
|
||||
CGPathCloseSubpath(aContext.path);
|
||||
}
|
||||
|
||||
/*!
|
||||
Moves the current location of aContext to the given x and y coordinates
|
||||
@param aContext the CGContext to move
|
||||
@param x the x location to move the context to
|
||||
@param y the y location to move the context to
|
||||
@return void
|
||||
*/
|
||||
function CGContextMoveToPoint(aContext, x, y)
|
||||
{
|
||||
if (!aContext.path)
|
||||
@@ -331,11 +326,24 @@ function CGContextMoveToPoint(aContext, x, y)
|
||||
CGPathMoveToPoint(aContext.path, aContext.gState.CTM, x, y);
|
||||
}
|
||||
|
||||
/*!
|
||||
Fills a rectangle in the given context with aRect dimensions, using the context's current fill color
|
||||
@param aContext the CGContext to draw into
|
||||
@param aRect the dimensions of the rectangle to fill
|
||||
@return void
|
||||
*/
|
||||
function CGContextFillRect(aContext, aRect)
|
||||
{
|
||||
CGContextFillRects(aContext, [aRect], 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
Fills a rectangle in the given context for each CGRect in the given array, up to a total of count rects
|
||||
@param aContext the CGContext to draw into
|
||||
@param rects an array of rects to fill
|
||||
@param count the maximum number of rects from the given array to fill
|
||||
@return void
|
||||
*/
|
||||
function CGContextFillRects(aContext, rects, count)
|
||||
{
|
||||
if (arguments[2] === undefined)
|
||||
@@ -348,6 +356,12 @@ function CGContextFillRects(aContext, rects, count)
|
||||
CGContextDrawPath(aContext, kCGPathFill);
|
||||
}
|
||||
|
||||
/*!
|
||||
Strokes a rectangle with the given location into the given context, using the context's current width and color
|
||||
@param aContext the CGContext to draw into
|
||||
@param aRect a CGRect indicating the dimensions of the rectangle to be drawn
|
||||
@return void
|
||||
*/
|
||||
function CGContextStrokeRect(aContext, aRect)
|
||||
{
|
||||
CGContextBeginPath(aContext);
|
||||
@@ -357,6 +371,13 @@ function CGContextStrokeRect(aContext, aRect)
|
||||
CGContextDrawPath(aContext, kCGPathStroke);
|
||||
}
|
||||
|
||||
/*!
|
||||
Strokes a rectangle with the given dimensions and the given stroke width
|
||||
@param aContext the CGContext to draw into
|
||||
@param aRect the CGRect indicating the bounds of the rect to be drawn
|
||||
@param aWidth the width with which to stroke the rect
|
||||
@return void
|
||||
*/
|
||||
function CGContextStrokeRectWithWidth(aContext, aRect, aWidth)
|
||||
{
|
||||
CGContextSaveGState(aContext);
|
||||
@@ -367,6 +388,12 @@ function CGContextStrokeRectWithWidth(aContext, aRect, aWidth)
|
||||
CGContextRestoreGState(aContext);
|
||||
}
|
||||
|
||||
/*!
|
||||
Concatenates the given transformation matrix onto the current transformation matrix in aContext
|
||||
@param aContext the CGContext to transform
|
||||
@param aTransform the CGAffineTransform to apply to the given context
|
||||
@return void
|
||||
*/
|
||||
function CGContextConcatCTM(aContext, aTransform)
|
||||
{
|
||||
var CTM = aContext.gState.CTM;
|
||||
@@ -374,11 +401,23 @@ function CGContextConcatCTM(aContext, aTransform)
|
||||
_CGAffineTransformConcatTo(CTM, aTransform, CTM);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current transformation matrix for the given context
|
||||
@param aContext the CGContext for which we are asking for the transform
|
||||
@return CGAffineTransform the current transformation matrix of the given context
|
||||
*/
|
||||
function CGContextGetCTM(aContext)
|
||||
{
|
||||
return aContext.gState.CTM;
|
||||
}
|
||||
|
||||
/*!
|
||||
Rotates the current context by anAngle radians
|
||||
@param aContext the CGContext to rotate
|
||||
@param anAngle the amount to rotate, in radians
|
||||
@return void
|
||||
*/
|
||||
|
||||
function CGContextRotateCTM(aContext, anAngle)
|
||||
{
|
||||
var gState = aContext.gState;
|
||||
@@ -386,6 +425,13 @@ function CGContextRotateCTM(aContext, anAngle)
|
||||
gState.CTM = CGAffineTransformRotate(gState.CTM, anAngle);
|
||||
}
|
||||
|
||||
/*!
|
||||
Scales the current context by sx/sy
|
||||
@param aContext the CGContext to scale
|
||||
@param sx the amount to scale in the x direction
|
||||
@param sy the amount to scale in the y direction
|
||||
@return void
|
||||
*/
|
||||
function CGContextScaleCTM(aContext, sx, sy)
|
||||
{
|
||||
var gState = aContext.gState;
|
||||
@@ -393,6 +439,13 @@ function CGContextScaleCTM(aContext, sx, sy)
|
||||
gState.CTM = _CGAffineTransformScale(gState.CTM, sx, sy);
|
||||
}
|
||||
|
||||
/*!
|
||||
Translates the given context by tx in the x direction and ty in the y direction
|
||||
@param aContext the CGContext to translate
|
||||
@param tx the amount to move in the x direction
|
||||
@param ty the amount to move in the y direction
|
||||
@return void
|
||||
*/
|
||||
function CGContextTranslateCTM(aContext, tx, ty)
|
||||
{
|
||||
var gState = aContext.gState;
|
||||
@@ -400,6 +453,14 @@ function CGContextTranslateCTM(aContext, tx, ty)
|
||||
gState.CTM = _CGAffineTransformTranslate(gState.CTM, tx, ty);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the current offset, and blur for shadows in core graphics drawing operations
|
||||
@param aContext the CGContext of the shadow
|
||||
@param aSize a CGSize indicating the offset of the shaodw
|
||||
@param aBlur a float indicating the blur radius
|
||||
@return void
|
||||
*/
|
||||
|
||||
function CGContextSetShadow(aContext, aSize, aBlur)
|
||||
{
|
||||
var gState = aContext.gState;
|
||||
@@ -409,6 +470,14 @@ function CGContextSetShadow(aContext, aSize, aBlur)
|
||||
gState.shadowColor = [CPColor shadowColor];
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the current offset, blur, and color for shadows in core graphics drawing operations
|
||||
@param aContext the CGContext of the shadow
|
||||
@param aSize a CGSize indicating the offset of the shaodw
|
||||
@param aBlur a float indicating the blur radius
|
||||
@param aColor a CPColor object indicating the color of the shadow
|
||||
@return void
|
||||
*/
|
||||
function CGContextSetShadowWithColor(aContext, aSize, aBlur, aColor)
|
||||
{
|
||||
var gState = aContext.gState;
|
||||
@@ -418,6 +487,12 @@ function CGContextSetShadowWithColor(aContext, aSize, aBlur, aColor)
|
||||
gState.shadowColor = aColor;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the current alpha value for core graphics drawing operations in the given context .
|
||||
@param aContext the CGContext who's alpha value should be updated
|
||||
@param anAlpha the new alpha value. 1.0 is completely opaque, 0.0 is completely transparent.
|
||||
@return void
|
||||
*/
|
||||
function CGContextSetAlpha(aContext, anAlpha)
|
||||
{
|
||||
aContext.gState.alpha = MAX(MIN(anAlpha, 1.0), 0.0);
|
||||
@@ -430,7 +505,6 @@ function CGContextSetAlpha(aContext, anAlpha)
|
||||
Fills in the area of the current path, using the even-odd fill rule.
|
||||
@param aContext the CGContext of the path
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextEOFillPath(aContext)
|
||||
{
|
||||
@@ -441,7 +515,6 @@ function CGContextEOFillPath(aContext)
|
||||
Fills in the area of the current path, using the non-zero winding number rule.
|
||||
@param aContext the CGContext of the path
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextFillPath(aContext)
|
||||
{
|
||||
@@ -455,28 +528,10 @@ var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
|
||||
@param aContext CGContext to draw on
|
||||
@param aRect the rectangle bounding the ellipse
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextAddEllipseInRect(aContext, aRect)
|
||||
{
|
||||
CGContextBeginPath(aContext);
|
||||
|
||||
if (_CGRectGetWidth(aRect) == _CGRectGetHeight(aRect))
|
||||
CGContextAddArc(aContext, _CGRectGetMidX(aRect), _CGRectGetMidY(aRect), _CGRectGetWidth(aRect) / 2.0, 0.0, 2 * PI, YES);
|
||||
else
|
||||
{
|
||||
var axis = _CGSizeMake(_CGRectGetWidth(aRect) / 2.0, _CGRectGetHeight(aRect) / 2.0),
|
||||
center = _CGPointMake(_CGRectGetMinX(aRect) + axis.width, _CGRectGetMinY(aRect) + axis.height);
|
||||
|
||||
CGContextMoveToPoint(aContext, center.x, center.y - axis.height);
|
||||
|
||||
CGContextAddCurveToPoint(aContext, center.x + (KAPPA * axis.width), center.y - axis.height, center.x + axis.width, center.y - (KAPPA * axis.height), center.x + axis.width, center.y);
|
||||
CGContextAddCurveToPoint(aContext, center.x + axis.width, center.y + (KAPPA * axis.height), center.x + (KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height);
|
||||
CGContextAddCurveToPoint(aContext, center.x - (KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (KAPPA * axis.height), center.x - axis.width, center.y);
|
||||
CGContextAddCurveToPoint(aContext, center.x - axis.width, center.y - (KAPPA * axis.height), center.x - (KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height);
|
||||
}
|
||||
|
||||
CGContextClosePath(aContext);
|
||||
CGContextAddPath(aContext, CGPathWithEllipseInRect(aRect));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -484,7 +539,6 @@ function CGContextAddEllipseInRect(aContext, aRect)
|
||||
@param aContext CGContext to draw on
|
||||
@param aRect the rectangle bounding the ellipse
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextFillEllipseInRect(aContext, aRect)
|
||||
{
|
||||
@@ -497,7 +551,6 @@ function CGContextFillEllipseInRect(aContext, aRect)
|
||||
@param aContext CGContext to draw on
|
||||
@param aRect the rectangle bounding the ellipse
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextStrokeEllipseInRect(aContext, aRect)
|
||||
{
|
||||
@@ -509,7 +562,6 @@ function CGContextStrokeEllipseInRect(aContext, aRect)
|
||||
Paints a line in the current path of the current context.
|
||||
@param aContext CGContext to draw on
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextStrokePath(aContext)
|
||||
{
|
||||
@@ -525,7 +577,6 @@ function CGContextStrokePath(aContext)
|
||||
the beginning of second line segment, etc.
|
||||
@param count the number of points in the array
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextStrokeLineSegments(aContext, points, count)
|
||||
{
|
||||
@@ -553,7 +604,6 @@ function CGContextStrokeLineSegments(aContext, points, count)
|
||||
@param aContext the CGContext
|
||||
@param aColor the new color for the fill
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
|
||||
function CGContextSetFillColor(aContext, aColor)
|
||||
@@ -567,7 +617,6 @@ function CGContextSetFillColor(aContext, aColor)
|
||||
@param aContext the CGContext
|
||||
@param aColor the new color for the stroke
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextSetStrokeColor(aContext, aColor)
|
||||
{
|
||||
@@ -585,97 +634,27 @@ function CGContextSetStrokeColor(aContext, aColor)
|
||||
@param sw set it to <code>YES</code> for a rounded southwest corner
|
||||
@param nw set it to <code>YES</code> for a rounded northwest corner
|
||||
@return void
|
||||
@group CGContext
|
||||
*/
|
||||
function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
|
||||
{
|
||||
var xMin = _CGRectGetMinX(aRect),
|
||||
xMax = _CGRectGetMaxX(aRect),
|
||||
yMin = _CGRectGetMinY(aRect),
|
||||
yMax = _CGRectGetMaxY(aRect);
|
||||
|
||||
CGContextBeginPath(aContext);
|
||||
CGContextMoveToPoint(aContext, xMin + aRadius, yMin);
|
||||
|
||||
if (ne)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMax - aRadius, yMin);
|
||||
CGContextAddCurveToPoint(aContext, xMax - aRadius, yMin, xMax, yMin, xMax, yMin + aRadius);
|
||||
}
|
||||
else
|
||||
CGContextAddLineToPoint(aContext, xMax, yMin);
|
||||
|
||||
if (se)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMax, yMax - aRadius);
|
||||
CGContextAddCurveToPoint(aContext, xMax, yMax - aRadius, xMax, yMax, xMax - aRadius, yMax);
|
||||
}
|
||||
else
|
||||
CGContextAddLineToPoint(aContext, xMax, yMax);
|
||||
|
||||
if (sw)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMin + aRadius, yMax);
|
||||
CGContextAddCurveToPoint(aContext, xMin + aRadius, yMax, xMin, yMax, xMin, yMax - aRadius);
|
||||
}
|
||||
else
|
||||
CGContextAddLineToPoint(aContext, xMin, yMax);
|
||||
|
||||
if (nw)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMin, yMin + aRadius);
|
||||
CGContextAddCurveToPoint(aContext, xMin, yMin + aRadius, xMin, yMin, xMin + aRadius, yMin);
|
||||
} else
|
||||
CGContextAddLineToPoint(aContext, xMin, yMin);
|
||||
|
||||
CGContextClosePath(aContext);
|
||||
|
||||
CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));
|
||||
CGContextFillPath(aContext);
|
||||
}
|
||||
|
||||
/*!
|
||||
Strokes a rounded rectangle.
|
||||
@param aContext the CGContext to draw into
|
||||
@param aRect the base rectangle
|
||||
@param aRadius the distance from the rectange corner to the rounded corner
|
||||
@param ne set it to <code>YES</code> for a rounded northeast corner
|
||||
@param se set it to <code>YES</code> for a rounded southeast corner
|
||||
@param sw set it to <code>YES</code> for a rounded southwest corner
|
||||
@param nw set it to <code>YES</code> for a rounded northwest corner
|
||||
@return void
|
||||
*/
|
||||
function CGContextStrokeRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
|
||||
{
|
||||
var xMin = _CGRectGetMinX(aRect),
|
||||
xMax = _CGRectGetMaxX(aRect),
|
||||
yMin = _CGRectGetMinY(aRect),
|
||||
yMax = _CGRectGetMaxY(aRect);
|
||||
|
||||
CGContextBeginPath(aContext);
|
||||
CGContextMoveToPoint(aContext, xMin + aRadius, yMin);
|
||||
|
||||
if (ne)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMax - aRadius, yMin);
|
||||
CGContextAddCurveToPoint(aContext, xMax - aRadius, yMin, xMax, yMin, xMax, yMin + aRadius);
|
||||
}
|
||||
else
|
||||
CGContextAddLineToPoint(aContext, xMax, yMin);
|
||||
|
||||
if (se)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMax, yMax - aRadius);
|
||||
CGContextAddCurveToPoint(aContext, xMax, yMax - aRadius, xMax, yMax, xMax - aRadius, yMax);
|
||||
}
|
||||
else
|
||||
CGContextAddLineToPoint(aContext, xMax, yMax);
|
||||
|
||||
if (sw)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMin + aRadius, yMax);
|
||||
CGContextAddCurveToPoint(aContext, xMin + aRadius, yMax, xMin, yMax, xMin, yMax - aRadius);
|
||||
}
|
||||
else
|
||||
CGContextAddLineToPoint(aContext, xMin, yMax);
|
||||
|
||||
if (nw)
|
||||
{
|
||||
CGContextAddLineToPoint(aContext, xMin, yMin + aRadius);
|
||||
CGContextAddCurveToPoint(aContext, xMin, yMin + aRadius, xMin, yMin, xMin + aRadius, yMin);
|
||||
} else
|
||||
CGContextAddLineToPoint(aContext, xMin, yMin);
|
||||
|
||||
CGContextClosePath(aContext);
|
||||
|
||||
CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));
|
||||
CGContextStrokePath(aContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,10 @@ function CGContextDrawPath(aContext, aMode)
|
||||
|
||||
vml.push("\">");
|
||||
|
||||
if (fill)
|
||||
if (gState.gradient)
|
||||
vml.push(gState.gradient)
|
||||
|
||||
else if (fill)
|
||||
vml.push("<cg_vml_:fill color=\"", gState.fillStyle, "\" opacity=\"", opacity, "\" />");
|
||||
|
||||
if (stroke)
|
||||
@@ -260,3 +263,59 @@ function CGContextDrawPath(aContext, aMode)
|
||||
aContext.DOMElement.insertAdjacentHTML("BeforeEnd", vml.join(""));
|
||||
}
|
||||
|
||||
function to_string(aColor)
|
||||
{
|
||||
return "rgb(" + ROUND(aColor.components[0] * 255) + ", " + ROUND(aColor.components[1] * 255) + ", " + ROUND(255 * aColor.components[2]) + ")";
|
||||
}
|
||||
|
||||
function CGContextDrawLinearGradient(aContext, aGradient, aStartPoint, anEndPoint, options)
|
||||
{
|
||||
if (!aContext || !aGradient)
|
||||
return;
|
||||
|
||||
var vml = nil;
|
||||
|
||||
if (aGradient.vml_gradient)
|
||||
{
|
||||
var stops = [[aGradient.vml_gradient stops] sortedArrayUsingSelector:@selector(comparePosition:)],
|
||||
count = [stops count];
|
||||
|
||||
vml = ["<cg_vml_:fill type=\"gradient\" method=\"linear sigma\" "];
|
||||
vml.push("angle=\"" + ([aGradient.vml_gradient angle] + 90) +"\" ");
|
||||
|
||||
vml.push("colors=\"");
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
vml.push(([stops[i] position]*100).toFixed(0)+"% ");
|
||||
vml.push([[[stops[i] color] colorForSlideBase:nil] cssString]);
|
||||
|
||||
if (i < count-1)
|
||||
vml.push(",");
|
||||
}
|
||||
|
||||
vml.push("\" />");
|
||||
}
|
||||
else
|
||||
{
|
||||
var colors = aGradient.colors,
|
||||
count = colors.length;
|
||||
|
||||
vml = ["<cg_vml_:fill type=\"gradient\" "];
|
||||
|
||||
vml.push("colors=\"");
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
vml.push((aGradient.locations[i]*100).toFixed(0)+"% "+to_string(colors[i])+(i<count-1 ? "," : ""));
|
||||
|
||||
vml.push("\" />");
|
||||
}
|
||||
|
||||
aContext.gState.gradient = vml.join("");
|
||||
console.log(vml.join(""));
|
||||
|
||||
// if (aContext.buffer != nil)
|
||||
// aContext.buffer += vml.join("");
|
||||
// else
|
||||
// aContext.DOMElement.innerHTML = vml.join("");
|
||||
}
|
||||
@@ -36,11 +36,18 @@ kCGPathElementCloseSubpath = 4;
|
||||
kCGPathElementAddArc = 5;
|
||||
kCGPathElementAddArcToPoint = 6;
|
||||
|
||||
/*!
|
||||
Returns a new CGPath object.
|
||||
*/
|
||||
function CGPathCreateMutable()
|
||||
{
|
||||
return { count:0, start:NULL, current:NULL, elements:[] };
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a copy of the given path object.
|
||||
*/
|
||||
|
||||
function CGPathCreateMutableCopy(aPath)
|
||||
{
|
||||
var path = CGPathCreateMutable();
|
||||
@@ -50,6 +57,10 @@ function CGPathCreateMutableCopy(aPath)
|
||||
return path;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a copy of the given path object.
|
||||
*/
|
||||
|
||||
function CGPathCreateCopy(aPath)
|
||||
{
|
||||
return CGPathCreateMutableCopy(aPath);
|
||||
@@ -158,12 +169,15 @@ function CGPathAddPath(aPath, aTransform, anotherPath)
|
||||
|
||||
for (; i < count; ++i)
|
||||
{
|
||||
var element = anotherPath[i];
|
||||
var element = anotherPath.elements[i];
|
||||
|
||||
aPath.elements[aPath.count++] = { type:element.type, points:element.point.slice() };
|
||||
aPath.elements[aPath.count] = { type:element.type, x:element.x, y:element.y,
|
||||
cpx:element.cpx, cpy:element.cpy,
|
||||
radius:element.radius, startAngle:element.startAngle, endAngle:element.endAngle,
|
||||
cp1x:element.cp1x, cp1y:element.cp1y, cp2x:element.cp2x, cp2y:element.cp2y,
|
||||
points: element.points ? element.points.slice() : nil};
|
||||
|
||||
if (element.type == kCGPathElementAddArc || element.type == kCGPathElementAddArcToPoint)
|
||||
aPath.elements[aPath.count - 1].radius = element.radius;
|
||||
aPath.count++
|
||||
}
|
||||
|
||||
aPath.current = anotherPath.current;
|
||||
@@ -231,6 +245,76 @@ function CGPathMoveToPoint(aPath, aTransform, x, y)
|
||||
aPath.elements[aPath.count++] = { type:kCGPathElementMoveToPoint, x:point.x, y:point.y };
|
||||
}
|
||||
|
||||
function CGPathWithEllipseInRect(aRect)
|
||||
{
|
||||
var path = CGPathCreateMutable();
|
||||
|
||||
if (_CGRectGetWidth(aRect) == _CGRectGetHeight(aRect))
|
||||
CGPathAddArc(path, nil, _CGRectGetMidX(aRect), _CGRectGetMidY(aRect), _CGRectGetWidth(aRect) / 2.0, 0.0, 2 * PI, YES);
|
||||
else
|
||||
{
|
||||
var axis = _CGSizeMake(_CGRectGetWidth(aRect) / 2.0, _CGRectGetHeight(aRect) / 2.0),
|
||||
center = _CGPointMake(_CGRectGetMinX(aRect) + axis.width, _CGRectGetMinY(aRect) + axis.height);
|
||||
|
||||
CGPathMoveToPoint(path, nil, center.x, center.y - axis.height);
|
||||
|
||||
CGPathAddCurveToPoint(path, nil, center.x + (KAPPA * axis.width), center.y - axis.height, center.x + axis.width, center.y - (KAPPA * axis.height), center.x + axis.width, center.y);
|
||||
CGPathAddCurveToPoint(path, nil, center.x + axis.width, center.y + (KAPPA * axis.height), center.x + (KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height);
|
||||
CGPathAddCurveToPoint(path, nil, center.x - (KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (KAPPA * axis.height), center.x - axis.width, center.y);
|
||||
CGPathAddCurveToPoint(path, nil, center.x - axis.width, center.y - (KAPPA * axis.height), center.x - (KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height);
|
||||
}
|
||||
|
||||
CGPathCloseSubpath(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
function CGPathWithRoundedRectangleInRect(aRect, xRadius, yRadius/*not currently supported*/, ne, se, sw, nw)
|
||||
{
|
||||
var path = CGPathCreateMutable(),
|
||||
xMin = _CGRectGetMinX(aRect),
|
||||
xMax = _CGRectGetMaxX(aRect),
|
||||
yMin = _CGRectGetMinY(aRect),
|
||||
yMax = _CGRectGetMaxY(aRect);
|
||||
|
||||
CGPathMoveToPoint(path, nil, xMin + xRadius, yMin);
|
||||
|
||||
if (ne)
|
||||
{
|
||||
CGPathAddLineToPoint(path, nil, xMax - xRadius, yMin);
|
||||
CGPathAddCurveToPoint(path, nil, xMax - xRadius, yMin, xMax, yMin, xMax, yMin + xRadius);
|
||||
}
|
||||
else
|
||||
CGPathAddLineToPoint(path, nil, xMax, yMin);
|
||||
|
||||
if (se)
|
||||
{
|
||||
CGPathAddLineToPoint(path, nil, xMax, yMax - xRadius);
|
||||
CGPathAddCurveToPoint(path, nil, xMax, yMax - xRadius, xMax, yMax, xMax - xRadius, yMax);
|
||||
}
|
||||
else
|
||||
CGPathAddLineToPoint(path, nil, xMax, yMax);
|
||||
|
||||
if (sw)
|
||||
{
|
||||
CGPathAddLineToPoint(path, nil, xMin + xRadius, yMax);
|
||||
CGPathAddCurveToPoint(path, nil, xMin + xRadius, yMax, xMin, yMax, xMin, yMax - xRadius);
|
||||
}
|
||||
else
|
||||
CGPathAddLineToPoint(path, nil, xMin, yMax);
|
||||
|
||||
if (nw)
|
||||
{
|
||||
CGPathAddLineToPoint(path, nil, xMin, yMin + xRadius);
|
||||
CGPathAddCurveToPoint(path, nil, xMin, yMin + xRadius, xMin, yMin, xMin + xRadius, yMin);
|
||||
} else
|
||||
CGPathAddLineToPoint(path, nil, xMin, yMin);
|
||||
|
||||
CGPathCloseSubpath(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
function CGPathCloseSubpath(aPath)
|
||||
{
|
||||
var count = aPath.count;
|
||||
|
||||
@@ -105,6 +105,8 @@ var CPDOMWindowGetFrame,
|
||||
_DOMBodyElement.style.overflow = "hidden";
|
||||
_DOMBodyElement.style.webkitTouchCallout = "none";
|
||||
|
||||
[CPString _resetSize];
|
||||
|
||||
if (document.documentElement)
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
|
||||
- (void)removeWindow:(CPWindow)aWindow
|
||||
{
|
||||
if (!aWindow._isVisible)
|
||||
return;
|
||||
|
||||
var index = aWindow._index,
|
||||
count = _windows.length - 1;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 146 B |
Binary file not shown.
|
After Width: | Height: | Size: 590 B |
Binary file not shown.
|
After Width: | Height: | Size: 796 B |
Binary file not shown.
|
After Width: | Height: | Size: 569 B |
Binary file not shown.
|
After Width: | Height: | Size: 795 B |
@@ -68,16 +68,16 @@
|
||||
var scroller = [[CPScroller alloc] initWithFrame:CGRectMake(0.0, 0.0, 170.0, 17.0)],
|
||||
trackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-horizontal-track.png" size:CGSizeMake(1.0, 17.0)]),
|
||||
disabledTrackColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-vertical-track-disabled.png" size:CGSizeMake(17.0, 1.0)]);
|
||||
[scroller setBackgroundColor:[CPColor blueColor]];
|
||||
|
||||
[scroller setValue:CGSizeMake(19.0, 15.0) forThemeAttribute:@"minimum-knob-size"];
|
||||
|
||||
[scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 9.0) forThemeAttribute:@"track-overlap-inset" ];
|
||||
[scroller setValue:CGInsetMake(9.0, 9.0, 9.0, 12.0) forThemeAttribute:@"track-overlap-inset" ];
|
||||
[scroller setValue:trackColor forThemeAttribute:@"knob-slot-color"];
|
||||
[scroller setValue:disabledTrackColor forThemeAttribute:@"knob-slot-color" inState:CPThemeStateDisabled];
|
||||
|
||||
var arrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow.png" size:CGSizeMake(32.0, 17.0)]),
|
||||
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
|
||||
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
|
||||
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow-highlighted.png" size:CGSizeMake(32.0, 17.0)]),
|
||||
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-left-arrow-disabled.png" size:CGSizeMake(32.0, 17.0)]);
|
||||
|
||||
[scroller setValue:CGSizeMake(32.0, 17.0) forThemeAttribute:@"decrement-line-size"];
|
||||
[scroller setValue:arrowColor forThemeAttribute:@"decrement-line-color"];
|
||||
@@ -85,8 +85,8 @@
|
||||
[scroller setValue:disabledArrowColor forThemeAttribute:@"decrement-line-color" inState:CPThemeStateDisabled];
|
||||
|
||||
var arrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow.png" size:CGSizeMake(31.0, 17.0)]),
|
||||
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow-highlighted.png" size:CGSizeMake(17.0, 30.0)]),
|
||||
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow-disabled.png" size:CGSizeMake(17.0, 30.0)]);
|
||||
highlightedArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow-highlighted.png" size:CGSizeMake(31.0, 17.0)]),
|
||||
disabledArrowColor = PatternColor([_CPCibCustomResource imageResourceWithName:"scroller-right-arrow-disabled.png" size:CGSizeMake(31.0, 17.0)]);
|
||||
|
||||
[scroller setValue:CGSizeMake(31.0, 17.0) forThemeAttribute:@"increment-line-size"];
|
||||
[scroller setValue:arrowColor forThemeAttribute:@"increment-line-color"];
|
||||
|
||||
Regular → Executable
+11
-12
@@ -5,7 +5,6 @@
|
||||
@import <AppKit/CPTheme.j>
|
||||
@import <BlendKit/BlendKit.j>
|
||||
|
||||
importClass(java.io.File);
|
||||
importClass(java.io.FileOutputStream);
|
||||
importClass(java.io.BufferedWriter);
|
||||
importClass(java.io.OutputStreamWriter);
|
||||
@@ -14,7 +13,7 @@ importClass(java.io.OutputStreamWriter);
|
||||
function main()
|
||||
{
|
||||
var index = 0,
|
||||
count = arguments.length,
|
||||
count = system.args.length,
|
||||
|
||||
outputFilePath = "",
|
||||
descriptorFiles = [],
|
||||
@@ -23,22 +22,22 @@ function main()
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = arguments[index];
|
||||
var argument = system.args[index];
|
||||
|
||||
switch (argument)
|
||||
{
|
||||
case "-c":
|
||||
case "--cib": cibFiles.push(arguments[++index]);
|
||||
case "--cib": cibFiles.push(system.args[++index]);
|
||||
break;
|
||||
|
||||
case "-d":
|
||||
case "-descriptor": descriptorFiles.push(arguments[++index]);
|
||||
case "-descriptor": descriptorFiles.push(system.args[++index]);
|
||||
break;
|
||||
|
||||
case "-o": outputFilePath = arguments[++index];
|
||||
case "-o": outputFilePath = system.args[++index];
|
||||
break;
|
||||
|
||||
case "-R": resourcesPath = arguments[++index];
|
||||
case "-R": resourcesPath = system.args[++index];
|
||||
break;
|
||||
|
||||
default: jExtensionIndex = argument.indexOf(".j");
|
||||
@@ -67,7 +66,7 @@ function main()
|
||||
|
||||
var objectTemplates = BKThemeObjectTemplatesForClass(theClass),
|
||||
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
|
||||
temporaryCibFile = File.createTempFile("temp", ".cib"),
|
||||
temporaryCibFile = Packages.java.io.File.createTempFile("temp", ".cib"),
|
||||
temporaryCibFilePath = temporaryCibFile.getAbsolutePath(),
|
||||
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temporaryCibFilePath), "UTF-8"));
|
||||
|
||||
@@ -116,7 +115,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
|
||||
var resourcesFile = nil;
|
||||
|
||||
if (resourcesPath)
|
||||
resourcesFile = new File(resourcesPath);
|
||||
resourcesFile = new Packages.java.io.File(resourcesPath);
|
||||
|
||||
var count = cibFiles.length,
|
||||
replacedFiles = [],
|
||||
@@ -124,7 +123,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var theme = themeFromCibFile(new File(cibFiles[count])),
|
||||
var theme = themeFromCibFile(new Packages.java.io.File(cibFiles[count])),
|
||||
|
||||
// Archive our theme.
|
||||
filePath = [theme name] + ".keyedtheme",
|
||||
@@ -145,7 +144,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
|
||||
[infoDictionary setObject:replacedFiles forKey:@"CPBundleReplacedFiles"];
|
||||
[infoDictionary setObject:staticContentName forKey:@"CPBundleExecutable"];
|
||||
|
||||
var outputFile = new File(outputFilePath).getCanonicalFile();
|
||||
var outputFile = new Packages.java.io.File(outputFilePath).getCanonicalFile();
|
||||
|
||||
outputFile.mkdirs();
|
||||
|
||||
@@ -162,7 +161,7 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
|
||||
writer.close();
|
||||
|
||||
if (resourcesPath)
|
||||
rsync(new File(resourcesPath), new File(outputFilePath));
|
||||
rsync(new Packages.java.io.File(resourcesPath), new Packages.java.io.File(outputFilePath));
|
||||
}
|
||||
|
||||
function themeFromCibFile(aFile)
|
||||
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require '../common'
|
||||
require 'objective-j'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
$ENVIRONMENT_NARWHAL_PRODUCT = File.join($ENVIRONMENT_DIR, 'narwhal')
|
||||
$ENVIRONMENT_BROWSERJS_PRODUCT = File.join($ENVIRONMENT_NARWHAL_PRODUCT, 'packages', 'browser')
|
||||
$ENVIRONMENT_JACK_PRODUCT = File.join($ENVIRONMENT_NARWHAL_PRODUCT, 'packages', 'jack')
|
||||
|
||||
$ENVIRONMENT_NARWHAL_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'narwhal')
|
||||
|
||||
file_d $ENVIRONMENT_NARWHAL_PRODUCT do
|
||||
cp_r('narwhal', $ENVIRONMENT_NARWHAL_PRODUCT)
|
||||
end
|
||||
|
||||
file_d $ENVIRONMENT_NARWHAL_EXECUTABLE => [$ENVIRONMENT_NARWHAL_PRODUCT] do
|
||||
FileUtils.ln_sf('../narwhal/bin/narwhal', $ENVIRONMENT_NARWHAL_EXECUTABLE)
|
||||
end
|
||||
|
||||
file_d $ENVIRONMENT_BROWSERJS_PRODUCT => [$ENVIRONMENT_NARWHAL_PRODUCT] do
|
||||
cp_r('browser.js', $ENVIRONMENT_BROWSERJS_PRODUCT)
|
||||
end
|
||||
|
||||
file_d $ENVIRONMENT_JACK_PRODUCT => [$ENVIRONMENT_NARWHAL_PRODUCT] do
|
||||
cp_r('jack', $ENVIRONMENT_JACK_PRODUCT)
|
||||
end
|
||||
|
||||
task :build => [$ENVIRONMENT_NARWHAL_PRODUCT, $ENVIRONMENT_BROWSERJS_PRODUCT, $ENVIRONMENT_JACK_PRODUCT, $ENVIRONMENT_NARWHAL_EXECUTABLE]
|
||||
|
||||
CLOBBER.include($ENVIRONMENT_NARWHAL_PRODUCT, $ENVIRONMENT_BROWSERJS_PRODUCT, $ENVIRONMENT_JACK_PRODUCT, $ENVIRONMENT_NARWHAL_EXECUTABLE)
|
||||
+1
Submodule External/browser.js added at 5edca7a4f7.
+1
Submodule External/jack added at f9308de686.
+1
Submodule External/narwhal added at 9fa32b4be4.
+1
Submodule External/ojunit added at ca10912c3f.
@@ -155,7 +155,7 @@ var CPStringHashes = new objj_dictionary();
|
||||
*/
|
||||
- (CPString)description
|
||||
{
|
||||
return "<" + self.isa.name + " 0x" + [CPString stringWithHash:[self hash]] + " \"" + self + "\">";
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -251,15 +251,13 @@ var CPURLConnectionDelegate = nil;
|
||||
|
||||
if (!_isCanceled)
|
||||
{
|
||||
if (statusCode == 200 || (statusCode === 0 && _isLocalFileConnection))
|
||||
if (statusCode == 401 && [CPURLConnectionDelegate respondsToSelector:@selector(connectionDidReceiveAuthenticationChallenge:)])
|
||||
[CPURLConnectionDelegate connectionDidReceiveAuthenticationChallenge:self];
|
||||
else
|
||||
{
|
||||
[_delegate connection:self didReceiveData:_XMLHTTPRequest.responseText];
|
||||
[_delegate connectionDidFinishLoading:self];
|
||||
}
|
||||
else if (statusCode == 401 && [CPURLConnectionDelegate respondsToSelector:@selector(connectionDidReceiveAuthenticationChallenge:)])
|
||||
[CPURLConnectionDelegate connectionDidReceiveAuthenticationChallenge:self];
|
||||
else
|
||||
[_delegate connection:self didFailWithError:_XMLHTTPRequest.status]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,40 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rake'
|
||||
require '../../common'
|
||||
require 'objective-j'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
$ENVIRONMENT_NARWHAL_PRODUCT = File.join($ENVIRONMENT_DIR, 'narwhal')
|
||||
$ENVIRONMENT_OBJJ_PRODUCT = File.join($ENVIRONMENT_NARWHAL_PRODUCT, 'packages', 'objj')
|
||||
|
||||
subprojects = %w{cplutil objj objjc}
|
||||
$OBJJC_JS_COMPILER = File.join($ENVIRONMENT_LIB_DIR, 'shrinksafe.jar')
|
||||
$OBJJC_JS_COMPILER_RHINO = File.join($ENVIRONMENT_LIB_DIR, 'js.jar')
|
||||
|
||||
%w(build clean clobber).each do |task_name|
|
||||
task task_name do
|
||||
subrake(subprojects, task_name)
|
||||
$EXECUTABLES = ['objj', 'objjc', 'plutil']
|
||||
$EXECUTABLES_PRODUCTS = $EXECUTABLES.map {|e| File.join($ENVIRONMENT_BIN_DIR, e) }
|
||||
|
||||
file_d $ENVIRONMENT_OBJJ_PRODUCT do
|
||||
cp_r('objj', $ENVIRONMENT_OBJJ_PRODUCT)
|
||||
end
|
||||
|
||||
$EXECUTABLES.each do |executable|
|
||||
source = File.join('objj', 'bin', executable)
|
||||
dest = File.join($ENVIRONMENT_BIN_DIR, executable)
|
||||
file_d dest => source do
|
||||
#cp(source, dest)
|
||||
FileUtils.ln_sf("../narwhal/packages/objj/bin/#{executable}", dest)
|
||||
end
|
||||
end
|
||||
|
||||
file_d $OBJJC_JS_COMPILER => 'shrinksafe.jar' do
|
||||
cp('shrinksafe.jar', $OBJJC_JS_COMPILER)
|
||||
end
|
||||
|
||||
file_d $OBJJC_JS_COMPILER_RHINO => 'js.jar' do
|
||||
cp('js.jar', $OBJJC_JS_COMPILER_RHINO)
|
||||
end
|
||||
|
||||
task :build => [$ENVIRONMENT_OBJJ_PRODUCT, $OBJJC_JS_COMPILER, $OBJJC_JS_COMPILER_RHINO].concat($EXECUTABLES_PRODUCTS)
|
||||
|
||||
CLOBBER.include($ENVIRONMENT_OBJJ_PRODUCT, $EXECUTABLES_PRODUCTS, $OBJJC_JS_COMPILER, $OBJJC_JS_COMPILER_RHINO)
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require '../../../common'
|
||||
require 'objective-j'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
|
||||
$CPLUTIL_SCRIPT = File.join($BUILD_DIR, 'cplutil.build', $CONFIGURATION, 'main-concat.js')
|
||||
$CPLUTIL_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'cplutil', 'main.class')
|
||||
$CPLUTIL_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'cplutil')
|
||||
$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable'))
|
||||
|
||||
Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck!
|
||||
File.join($HOME_DIR, 'Tools', 'Utilities', 'regex-bridge.js'), #double-yuck!
|
||||
File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'),
|
||||
'main.js'];
|
||||
|
||||
file_d $CPLUTIL_EXECUTABLE => [$STANDARD_EXECUTABLE] do
|
||||
cp($STANDARD_EXECUTABLE, $CPLUTIL_EXECUTABLE)
|
||||
File.chmod 0755, $CPLUTIL_EXECUTABLE
|
||||
end
|
||||
|
||||
file_d $CPLUTIL_SCRIPT => Files do |t|
|
||||
cat(Files, $CPLUTIL_SCRIPT)
|
||||
end
|
||||
|
||||
file_d $CPLUTIL_CLASS => $CPLUTIL_SCRIPT do |t|
|
||||
js2java($CPLUTIL_SCRIPT, 'main.class', false)
|
||||
cp(File.join(File.dirname($CPLUTIL_SCRIPT), 'main.class'), $CPLUTIL_CLASS)
|
||||
end
|
||||
|
||||
task :build => [$CPLUTIL_CLASS, $CPLUTIL_EXECUTABLE]
|
||||
|
||||
CLEAN.include(File.join($BUILD_DIR, 'cplutil.build', $CONFIGURATION))
|
||||
CLOBBER.include(File.join($ENVIRONMENT_LIB_DIR, 'cplutil'), $CPLUTIL_EXECUTABLE)
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get path of the executable
|
||||
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
|
||||
|
||||
# resolve symlinks
|
||||
if [ -h $SELF_PATH ]; then
|
||||
SELF_PATH=`readlink $SELF_PATH`
|
||||
fi
|
||||
|
||||
SELF_DIR=`dirname $SELF_PATH`
|
||||
OBJJ_HOME=`dirname $SELF_DIR`
|
||||
OBJJ_LIB="$OBJJ_HOME/lib"
|
||||
|
||||
CLASSPATH_TMP="$OBJJ_LIB:$OBJJ_LIB/js.jar:$OBJJ_HOME/lib/$(basename $SELF_PATH)"
|
||||
|
||||
#OBJJ="$OBJJ_LIB/objj.js"
|
||||
RLWRAP=`which rlwrap`
|
||||
|
||||
# if there's a "lib" directory, add all the jars from it
|
||||
if [ -d "lib" ]; then
|
||||
JARS=`find ./lib -name '*.jar' 2> /dev/null | tr "\n" ":"`
|
||||
CLASSPATH="$JARS:$CLASSPATH"
|
||||
fi
|
||||
|
||||
# convert paths for Cygwin
|
||||
if [[ `uname` == CYGWIN* ]]; then
|
||||
OBJJ_HOME=`cygpath -wp "$OBJJ_HOME"`
|
||||
#OBJJ=`cygpath -wp "$OBJJ"`
|
||||
CLASSPATH_TMP=`cygpath -wp "$CLASSPATH_TMP"`
|
||||
CLASSPATH="$CLASSPATH_TMP;$CLASSPATH"
|
||||
else
|
||||
CLASSPATH="$CLASSPATH_TMP:$CLASSPATH"
|
||||
fi
|
||||
|
||||
export OBJJ_HOME
|
||||
|
||||
$RLWRAP java -cp $CLASSPATH main $@
|
||||
#$RLWRAP java -cp $CLASSPATH org.mozilla.javascript.tools.shell.Main $OBJJ $@
|
||||
Binary file not shown.
@@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require '../../../common'
|
||||
require 'objective-j'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
|
||||
$OBJJ_SCRIPT = File.join($BUILD_DIR, 'objj.build', $CONFIGURATION, 'main-concat.js')
|
||||
$OBJJ_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'objj', 'main.class')
|
||||
$OBJJ_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'objj')
|
||||
$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable'))
|
||||
|
||||
Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck!
|
||||
File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'),
|
||||
'main.js'];
|
||||
|
||||
file_d $OBJJ_EXECUTABLE => [$STANDARD_EXECUTABLE] do
|
||||
cp($STANDARD_EXECUTABLE, $OBJJ_EXECUTABLE)
|
||||
File.chmod 0755, $OBJJ_EXECUTABLE
|
||||
end
|
||||
|
||||
file_d $OBJJ_SCRIPT => Files do |t|
|
||||
cat(Files, $OBJJ_SCRIPT)
|
||||
end
|
||||
|
||||
file_d $OBJJ_CLASS => $OBJJ_SCRIPT do |t|
|
||||
js2java($OBJJ_SCRIPT, 'main.class', false)
|
||||
cp(File.join(File.dirname($OBJJ_SCRIPT), 'main.class'), $OBJJ_CLASS)
|
||||
end
|
||||
|
||||
task :build => [$OBJJ_CLASS, $OBJJ_EXECUTABLE]
|
||||
|
||||
CLEAN.include(File.join($BUILD_DIR, 'objj.build', $CONFIGURATION))
|
||||
CLOBBER.include(File.join($ENVIRONMENT_LIB_DIR, 'objj'), $OBJJ_EXECUTABLE)
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("objj/objj");
|
||||
Regular → Executable
+13
-8
@@ -1,14 +1,17 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
var objjc = require("objj/objjc");
|
||||
with (objjc)
|
||||
{
|
||||
|
||||
importPackage(java.lang);
|
||||
|
||||
importClass(java.io.File);
|
||||
importClass(java.io.BufferedReader);
|
||||
importClass(java.io.FileReader);
|
||||
importClass(java.io.BufferedWriter);
|
||||
importClass(java.io.FileWriter);
|
||||
|
||||
|
||||
|
||||
OBJJ_PREPROCESSOR_PREPROCESS = 1 << 10;
|
||||
OBJJ_PREPROCESSOR_COMPRESS = 1 << 11;
|
||||
OBJJ_PREPROCESSOR_SYNTAX = 1 << 12;
|
||||
@@ -55,7 +58,7 @@ function compress(/*String*/ aCode, /*Object*/ flags, /*File*/ tmpFile)
|
||||
|
||||
writer.close();
|
||||
|
||||
return exec(["java", "-jar", OBJJ_HOME + "/lib/objjc/shrinksafe.jar", "-c", tmpFile.getCanonicalPath()]);
|
||||
return exec(["java", "-classpath", OBJJ_HOME + "/lib/js.jar" + ":" + OBJJ_HOME + "/lib/shrinksafe.jar", "org.dojotoolkit.shrinksafe.Main", tmpFile.getCanonicalPath(), "-escape-unicode"]);
|
||||
}
|
||||
|
||||
//#define SET_CONTEXT(aFragment, aContext) aFragment.context = aContext
|
||||
@@ -119,7 +122,7 @@ function preprocess(aFilePath, outFilePath, gccArgs, flags)
|
||||
reader.close();
|
||||
|
||||
// Preprocess contents into fragments.
|
||||
var filePath = new String(new File(aFilePath).getName()),
|
||||
var filePath = new String(new java.io.File(aFilePath).getName()),
|
||||
fragments = objj_preprocess(fileContents, { path:"/x" }, {path:filePath}, flags),
|
||||
index = 0,
|
||||
count = fragments.length,
|
||||
@@ -179,7 +182,7 @@ function main()
|
||||
outFilePaths = [],
|
||||
|
||||
index = 0,
|
||||
count = arguments.length,
|
||||
count = system.args.length,
|
||||
|
||||
gccArgs = [],
|
||||
|
||||
@@ -188,12 +191,12 @@ function main()
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = String(arguments[index]);
|
||||
var argument = system.args[index];
|
||||
|
||||
if (argument === "-o")
|
||||
{
|
||||
if (++index < count)
|
||||
outFilePaths.push(String(arguments[index]));
|
||||
outFilePaths.push(system.args[index]);
|
||||
}
|
||||
|
||||
else if (argument.indexOf("-D") === 0)
|
||||
@@ -222,4 +225,6 @@ function main()
|
||||
preprocess(filePaths[index], outFilePaths[index], gccArgs, flags);
|
||||
}
|
||||
|
||||
main.apply(main, arguments);
|
||||
main();
|
||||
|
||||
}
|
||||
Regular → Executable
+11
-13
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
importPackage(java.lang);
|
||||
|
||||
importClass(java.io.File);
|
||||
importClass(java.io.BufferedReader);
|
||||
importClass(java.io.FileReader);
|
||||
importClass(java.io.BufferedWriter);
|
||||
@@ -15,7 +13,7 @@ function printUsage()
|
||||
|
||||
function main()
|
||||
{
|
||||
if (arguments.length < 1)
|
||||
if (system.args.length < 1)
|
||||
return printUsage();
|
||||
|
||||
var allFiles = NO,
|
||||
@@ -25,11 +23,11 @@ function main()
|
||||
outExtension = nil;
|
||||
|
||||
index = 0,
|
||||
count = arguments.length;
|
||||
count = system.args.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = arguments[index];
|
||||
var argument = system.args[index];
|
||||
|
||||
if (argument.charAt(0) === '-' && !allFiles)
|
||||
{
|
||||
@@ -37,13 +35,13 @@ function main()
|
||||
return printUsage();
|
||||
|
||||
else if (argument === "-convert")
|
||||
format = arguments[++index];
|
||||
format = system.args[++index];
|
||||
|
||||
else if (argument === "-o")
|
||||
outPath = arguments[++index];
|
||||
outPath = system.args[++index];
|
||||
|
||||
else if (argument === "-e")
|
||||
outExtension = arguments[++index];
|
||||
outExtension = system.args[++index];
|
||||
|
||||
else if (argument === "--")
|
||||
allFiles = YES;
|
||||
@@ -52,7 +50,7 @@ function main()
|
||||
return printUsage();
|
||||
}
|
||||
else
|
||||
filePaths.push(arguments[index]);
|
||||
filePaths.push(system.args[index]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
@@ -61,7 +59,7 @@ function main()
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
// Read the plist file
|
||||
var file = new File(filePaths[index]),
|
||||
var file = new java.io.File(filePaths[index]),
|
||||
reader = new BufferedReader(new FileReader(file)),
|
||||
fileContents = "";
|
||||
|
||||
@@ -86,7 +84,7 @@ function main()
|
||||
var outFile = file;
|
||||
|
||||
if (outPath)
|
||||
outFile = new File(outPath);
|
||||
outFile = new java.io.File(outPath);
|
||||
|
||||
// else if (outExtension)
|
||||
|
||||
@@ -100,4 +98,4 @@ function main()
|
||||
}
|
||||
}
|
||||
|
||||
main.apply(main, args);
|
||||
main();
|
||||
@@ -0,0 +1,75 @@
|
||||
var File = require("file");
|
||||
var window = require("browser/window");
|
||||
|
||||
var OBJJ_HOME = system.prefix + "/..";
|
||||
|
||||
window.OBJJ_INCLUDE_PATHS = [OBJJ_HOME+"/lib/Frameworks/"];
|
||||
if (system.env["OBJJ_INCLUDE_PATHS"])
|
||||
window.OBJJ_INCLUDE_PATHS = system.env["OBJJ_INCLUDE_PATHS"].split(":").concat(window.OBJJ_INCLUDE_PATHS);
|
||||
|
||||
//if (system.args.length > 0)
|
||||
// window.OBJJ_MAIN_FILE = String((new Packages.java.io.File(args.shift())).getAbsolutePath());
|
||||
|
||||
window.args = system.args;
|
||||
|
||||
with (window)
|
||||
{
|
||||
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js").toString());
|
||||
|
||||
if (system.args.length > 0)
|
||||
{
|
||||
while (system.args.length && system.args[0].indexOf('-I') === 0)
|
||||
OBJJ_INCLUDE_PATHS = system.args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS);
|
||||
|
||||
var mainFilePath = String((new Packages.java.io.File(args.shift())).getAbsolutePath());
|
||||
|
||||
objj_import(mainFilePath, YES, function() {
|
||||
if (typeof main === "function")
|
||||
main.apply(main, args);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var br = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(Packages.java.lang.System["in"], "UTF-8"));
|
||||
|
||||
while (true)
|
||||
{
|
||||
try {
|
||||
Packages.java.lang.System.out.print("objj> ");
|
||||
|
||||
var input = String(br.readLine()),
|
||||
fragments = objj_preprocess(input, new objj_bundle(), new objj_file(), OBJJ_PREPROCESSOR_DEBUG_SYMBOLS),
|
||||
count = fragments.length,
|
||||
ctx = (new objj_context);
|
||||
|
||||
if (count == 1 && (fragments[0].type & FRAGMENT_CODE))
|
||||
{
|
||||
var fragment = fragments[0];
|
||||
var result = eval(fragment.info);
|
||||
if (result != undefined)
|
||||
print(result);
|
||||
}
|
||||
else if (count > 0)
|
||||
{
|
||||
while (count--)
|
||||
{
|
||||
var fragment = fragments[count];
|
||||
|
||||
if (fragment.type & FRAGMENT_FILE)
|
||||
objj_request_file(fragment.info, (fragment.type & FRAGMENT_LOCAL), NULL);
|
||||
|
||||
ctx.pushFragment(fragment);
|
||||
}
|
||||
|
||||
ctx.schedule();
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
var File = require("file");
|
||||
var window = require("browser/window");
|
||||
|
||||
var exported = ["OBJJ_HOME", "objj_preprocess",
|
||||
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
|
||||
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
|
||||
"OBJJ_PREPROCESSOR_DEBUG_SYMBOLS"];
|
||||
|
||||
var OBJJ_HOME = system.prefix + "/..";
|
||||
|
||||
with (window)
|
||||
{
|
||||
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js").toString());
|
||||
|
||||
for (var i = 0; i < exported.length; i++)
|
||||
exports[exported[i]] = eval(exported[i]);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
debug = false;
|
||||
args = arguments;
|
||||
|
||||
// FIXME: remove these Rhino/Java dependencies
|
||||
|
||||
var OBJJ_HOME = Packages.java.lang.System.getenv("OBJJ_HOME"); // chicken/egg problem, getenv is defined in bridge.js
|
||||
|
||||
/*
|
||||
if (!this.window)
|
||||
{
|
||||
print("Loading Objective-J bridge.");
|
||||
load(OBJJ_HOME+'/lib/bridge.js');
|
||||
}
|
||||
|
||||
if (!this.objj_import)
|
||||
{
|
||||
print("Loading Objective-J.");
|
||||
load(OBJJ_HOME+'/lib/Frameworks-Rhino/Objective-J/Objective-J.js');
|
||||
}
|
||||
*/
|
||||
|
||||
OBJJ_INCLUDE_PATHS = [OBJJ_HOME+"/lib/Frameworks"];
|
||||
|
||||
var OBJJ_INCLUDE_PATHS_STRING = getenv("OBJJ_INCLUDE_PATHS");
|
||||
|
||||
if (OBJJ_INCLUDE_PATHS_STRING)
|
||||
OBJJ_INCLUDE_PATHS = OBJJ_INCLUDE_PATHS_STRING.split(":").concat(OBJJ_INCLUDE_PATHS);
|
||||
|
||||
try
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
// Convert all arguments to JavaScript-style Strings.
|
||||
var count = args.length;
|
||||
|
||||
while (count--)
|
||||
args[count] = String(args[count]);
|
||||
|
||||
while (args.length && args[0].indexOf('-I') === 0)
|
||||
OBJJ_INCLUDE_PATHS = args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS);
|
||||
}
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
// Grab the location of the objj file to run.
|
||||
var mainFilePath = args.shift();
|
||||
|
||||
// convert from relative to absolute path
|
||||
if (this.Packages)
|
||||
mainFilePath = String((new Packages.java.io.File(mainFilePath)).getAbsolutePath());
|
||||
|
||||
if (debug)
|
||||
print("Loading: " + mainFilePath);
|
||||
|
||||
objj_import(mainFilePath, YES, function() { if (typeof main === "function") main.apply(main, args); } );
|
||||
|
||||
serviceTimeouts();
|
||||
|
||||
if (debug)
|
||||
print("Done!");
|
||||
}
|
||||
else if (typeof objj_console != "undefined")
|
||||
{
|
||||
if (debug)
|
||||
print("Starting Objective-J console.");
|
||||
|
||||
objj_console();
|
||||
}
|
||||
else
|
||||
{
|
||||
print("Error: No file provided or console available.")
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
print("OBJJ EXCEPTION: " + e);
|
||||
print(" Name: " + e.name);
|
||||
print(" Message: " + e.message);
|
||||
print(" File: " + e.fileName);
|
||||
print(" Line: " + e.lineNumber);
|
||||
if (e.javaException)
|
||||
{
|
||||
print(" Java Exception: " + e.javaException);
|
||||
e.javaException.printStackTrace();
|
||||
}
|
||||
if (e.rhinoException)
|
||||
{
|
||||
print(" Rhino Exception: " + e.rhinoException);
|
||||
|
||||
print(" *** Message: " + e.rhinoException.getMessage());
|
||||
print(" *** Source name: " + e.rhinoException.sourceName());
|
||||
print(" *** Line number: " + e.rhinoException.lineNumber());
|
||||
print(" *** Column number: " + e.rhinoException.columnNumber());
|
||||
print(" *** Line Source: " + e.rhinoException.lineSource());
|
||||
|
||||
// print the JavaScript stack trace with line numbers:
|
||||
print(" *** Filtered stack trace:");
|
||||
var bos = new Packages.java.io.ByteArrayOutputStream();
|
||||
e.rhinoException.printStackTrace(new Packages.java.io.PrintStream(bos));
|
||||
var stack = String(bos.toString()).split("\n").slice(1);
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
var match;
|
||||
if (match = stack[i].match(/_c[0-9]+\((.+)\)/))
|
||||
print(match[1]);
|
||||
}
|
||||
|
||||
print(" *** Script stack trace:\n" + e.rhinoException.getScriptStackTrace());
|
||||
|
||||
print(" *** Raw stack trace:");
|
||||
e.rhinoException.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"author": "Tom Robinson",
|
||||
"dependencies": [],
|
||||
"js": "lib",
|
||||
"jars": "jars/"
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require '../../../common'
|
||||
require 'objective-j'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
|
||||
$OBJJC_SCRIPT = File.join($BUILD_DIR, 'objjc.build', $CONFIGURATION, 'main-concat.js')
|
||||
$OBJJC_CLASS = File.join($ENVIRONMENT_LIB_DIR, 'objjc', 'main.class')
|
||||
$OBJJC_JS_COMPILER = File.join($ENVIRONMENT_LIB_DIR, 'objjc', 'shrinksafe.jar')
|
||||
$OBJJC_EXECUTABLE = File.join($ENVIRONMENT_BIN_DIR, 'objjc')
|
||||
$STANDARD_EXECUTABLE = File.expand_path(File.join('..', 'executable'))
|
||||
|
||||
Files = [ File.join($HOME_DIR, 'Tools', 'Utilities', 'bridge.js'), #yuck!
|
||||
File.join($HOME_DIR, 'Tools', 'Utilities', 'regex-bridge.js'), #double-yuck!
|
||||
File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J', 'rhino.platform', 'Objective-J.js'),
|
||||
'main.js'];
|
||||
|
||||
file_d $OBJJC_EXECUTABLE => [$STANDARD_EXECUTABLE] do
|
||||
cp($STANDARD_EXECUTABLE, $OBJJC_EXECUTABLE)
|
||||
File.chmod 0755, $OBJJC_EXECUTABLE
|
||||
end
|
||||
|
||||
file_d $OBJJC_SCRIPT => Files do
|
||||
cat(Files, $OBJJC_SCRIPT)
|
||||
end
|
||||
|
||||
file_d $OBJJC_CLASS => $OBJJC_SCRIPT do
|
||||
js2java($OBJJC_SCRIPT, 'main.class', false)
|
||||
cp(File.join(File.dirname($OBJJC_SCRIPT), 'main.class'), $OBJJC_CLASS)
|
||||
end
|
||||
|
||||
file_d $OBJJC_JS_COMPILER => 'shrinksafe.jar' do
|
||||
cp('shrinksafe.jar', $OBJJC_JS_COMPILER)
|
||||
end
|
||||
|
||||
task :build => [$OBJJC_CLASS, $OBJJC_EXECUTABLE, $OBJJC_JS_COMPILER]
|
||||
|
||||
CLEAN.include(File.join($BUILD_DIR, 'objjc.build', $CONFIGURATION))
|
||||
CLOBBER.include(File.join($ENVIRONMENT_LIB_DIR, 'objjc'), $OBJJC_EXECUTABLE)
|
||||
Binary file not shown.
Binary file not shown.
@@ -158,8 +158,8 @@ function fragment_evaluate_code(aFragment)
|
||||
try
|
||||
{
|
||||
#if RHINO
|
||||
//compiled = eval("function(){"+GET_CODE(aFragment)+"}");
|
||||
compiled = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, "function(){"+GET_CODE(aFragment)+"}", GET_FILE(aFragment).path, 0, null);
|
||||
compiled = eval("function(){"+GET_CODE(aFragment)+"}");
|
||||
//compiled = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, "function(){"+GET_CODE(aFragment)+"}", GET_FILE(aFragment).path, 0, null);
|
||||
#else
|
||||
compiled = new Function(GET_CODE(aFragment));
|
||||
compiled.displayName = GET_FILE(aFragment).path;
|
||||
|
||||
@@ -279,10 +279,6 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
|
||||
|
||||
if (XMLNode.string)
|
||||
{
|
||||
#if RHINO
|
||||
XMLNode = DOCUMENT_ELEMENT(_documentBuilder.parse(
|
||||
new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(XMLNode.string))));
|
||||
#else
|
||||
if (window.ActiveXObject)
|
||||
{
|
||||
XMLNode = new ActiveXObject("Microsoft.XMLDOM");
|
||||
@@ -290,7 +286,6 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
|
||||
}
|
||||
else
|
||||
XMLNode = DOCUMENT_ELEMENT(new DOMParser().parseFromString(XMLNodeOrData.string, "text/xml"));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Skip over DOCTYPE and so forth.
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
|
||||
subprojects = %w{Objective-J Foundation AppKit Tools}
|
||||
subprojects = %w{External Objective-J Foundation AppKit Tools External/ojunit}
|
||||
|
||||
%w(build clean clobber).each do |task_name|
|
||||
task task_name do
|
||||
@@ -36,6 +36,7 @@ $STARTER_DOWNLOAD_README = File.join($STARTER_DOWNLOAD, 'README')
|
||||
task :downloads => [:starter_download, :tools_download]
|
||||
|
||||
file_d $TOOLS_DOWNLOAD_ENV => [:debug, :release] do
|
||||
rm_rf($TOOLS_DOWNLOAD_ENV)
|
||||
cp_r(File.join($RELEASE_ENV, '.'), $TOOLS_DOWNLOAD_ENV)
|
||||
cp_r(File.join($DEBUG_ENV, 'lib', 'Frameworks', '.'), File.join($TOOLS_DOWNLOAD_ENV, 'lib', 'Frameworks', 'Debug'))
|
||||
end
|
||||
@@ -71,7 +72,12 @@ file_d $STARTER_DOWNLOAD_README => [$STARTER_README] do
|
||||
end
|
||||
|
||||
task :install => [:downloads] do
|
||||
system %{cd #{$TOOLS_DOWNLOAD} && sudo sh ./install-tools }
|
||||
if ENV['prefix']
|
||||
prefix = "--prefix #{ENV['prefix']}"
|
||||
else
|
||||
prefix = ''
|
||||
end
|
||||
system %{cd #{$TOOLS_DOWNLOAD} && sudo sh ./install-tools #{prefix} }
|
||||
end
|
||||
|
||||
task :test => [:build] do
|
||||
@@ -82,6 +88,8 @@ task :test => [:build] do
|
||||
puts "tests failed, aborting the build"
|
||||
puts build_result
|
||||
rake abort
|
||||
else
|
||||
puts build_result
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+1
-2
@@ -3,8 +3,7 @@
|
||||
require 'rake'
|
||||
require '../common'
|
||||
|
||||
|
||||
subprojects = %w{bake capp nib2cib press ojunit}
|
||||
subprojects = %w{capp bake nib2cib press}
|
||||
|
||||
%w(build clean clobber).each do |task_name|
|
||||
task task_name do
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
[label sizeToFit];
|
||||
|
||||
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
|
||||
[label setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([label frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([label frame])) / 2.0)];
|
||||
[label setCenter:[contentView center]];
|
||||
|
||||
[contentView addSubview:label];
|
||||
|
||||
|
||||
+110
-29
@@ -1,6 +1,3 @@
|
||||
|
||||
importClass(java.lang.System);
|
||||
importClass(java.io.File);
|
||||
importClass(java.io.FileWriter);
|
||||
importClass(java.io.FileOutputStream);
|
||||
importClass(java.io.BufferedWriter);
|
||||
@@ -10,11 +7,11 @@ importClass(java.io.OutputStreamWriter);
|
||||
|
||||
function main()
|
||||
{
|
||||
if (arguments.length < 1)
|
||||
if (system.args.length < 1)
|
||||
return printUsage();
|
||||
|
||||
var index = 0,
|
||||
count = arguments.length,
|
||||
count = system.args.length,
|
||||
|
||||
shouldSymbolicallyLink = false,
|
||||
justFrameworks = false,
|
||||
@@ -24,9 +21,9 @@ function main()
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = arguments[index];
|
||||
var argument = system.args[index];
|
||||
|
||||
switch (arguments[index])
|
||||
switch (system.args[index])
|
||||
{
|
||||
case "-l": shouldSymbolicallyLink = true;
|
||||
break;
|
||||
@@ -36,7 +33,7 @@ function main()
|
||||
return;
|
||||
|
||||
case "-t":
|
||||
case "--template": template = arguments[++index];
|
||||
case "--template": template = system.args[++index];
|
||||
break;
|
||||
|
||||
case "-f":
|
||||
@@ -47,8 +44,8 @@ function main()
|
||||
}
|
||||
}
|
||||
|
||||
var sourceTemplate = new File(OBJJ_HOME + "/lib/capp/Resources/Templates/" + template),
|
||||
destinationProject = new File(destination);
|
||||
var sourceTemplate = new java.io.File(OBJJ_HOME + "/lib/capp/Resources/Templates/" + template),
|
||||
destinationProject = new java.io.File(destination);
|
||||
|
||||
if (!destinationProject.exists())
|
||||
{
|
||||
@@ -79,49 +76,52 @@ function main()
|
||||
|
||||
function createFrameworksInFile(/*File*/ aFile, /*Boolean*/ shouldSymbolicallyLink)
|
||||
{
|
||||
var destinationFrameworks = new File(aFile.getCanonicalPath()+ "/Frameworks"),
|
||||
destinationDebugFrameworks = new File(aFile.getCanonicalPath() + "/Frameworks/Debug");
|
||||
var destinationFrameworks = new java.io.File(aFile.getCanonicalPath()+ "/Frameworks"),
|
||||
destinationDebugFrameworks = new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug");
|
||||
|
||||
if (!shouldSymbolicallyLink)
|
||||
{
|
||||
var sourceFrameworks = new File(OBJJ_HOME + "/lib/Frameworks");
|
||||
var sourceFrameworks = new java.io.File(OBJJ_HOME + "/lib/Frameworks");
|
||||
|
||||
exec(["cp", "-vR", sourceFrameworks.getCanonicalPath(), destinationFrameworks.getCanonicalPath()], true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var STEAM_BUILD = System.getenv("STEAM_BUILD");
|
||||
var BUILD = system.env["CAPP_BUILD"] || system.env["STEAM_BUILD"];
|
||||
|
||||
if (!BUILD)
|
||||
throw "CAPP_BUILD or STEAM_BUILD must be defined";
|
||||
|
||||
// Release Frameworks
|
||||
new File(destinationFrameworks).mkdir();
|
||||
new java.io.File(destinationFrameworks).mkdir();
|
||||
|
||||
exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Objective-J").getCanonicalPath(),
|
||||
new File(aFile.getCanonicalPath() + "/Frameworks/Objective-J").getCanonicalPath()], true);
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Release/Objective-J").getCanonicalPath(),
|
||||
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Objective-J").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new File(STEAM_BUILD + "/Release/Foundation").getCanonicalPath(),
|
||||
new File(aFile.getCanonicalPath() + "/Frameworks/Foundation").getCanonicalPath()], true);
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Release/Foundation").getCanonicalPath(),
|
||||
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Foundation").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new File(STEAM_BUILD + "/Release/AppKit").getCanonicalPath(),
|
||||
new File(aFile.getCanonicalPath() + "/Frameworks/AppKit").getCanonicalPath()], true);
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Release/AppKit").getCanonicalPath(),
|
||||
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/AppKit").getCanonicalPath()], true);
|
||||
|
||||
// Debug Frameworks
|
||||
new File(destinationDebugFrameworks).mkdir();
|
||||
new java.io.File(destinationDebugFrameworks).mkdir();
|
||||
|
||||
exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Objective-J").getCanonicalPath(),
|
||||
new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true);
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Debug/Objective-J").getCanonicalPath(),
|
||||
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/Foundation").getCanonicalPath(),
|
||||
new File(aFile.getCanonicalPath() + "/Frameworks/Debug/Foundation").getCanonicalPath()], true);
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Debug/Foundation").getCanonicalPath(),
|
||||
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug/Foundation").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new File(STEAM_BUILD + "/Debug/AppKit").getCanonicalPath(),
|
||||
new File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true);
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Debug/AppKit").getCanonicalPath(),
|
||||
new java.io.File(aFile.getCanonicalPath() + "/Frameworks/Debug/AppKit").getCanonicalPath()], true);
|
||||
}
|
||||
|
||||
function printUsage()
|
||||
{
|
||||
print("capp /path/to/your/app [options]");
|
||||
print(" -l Symlink the Frameworks folder to your $STEAM_BUILD directory");
|
||||
print(" -l Symlink the Frameworks folder to your $CAPP_BUILD or $STEAM_BUILD directory");
|
||||
print(" -t, --template Specify the template name to use (listed in capp/Resources/Templates)");
|
||||
print(" -f, --frameworks Create only frameworks, not a full application");
|
||||
print(" -h, --help Print usage");
|
||||
@@ -136,3 +136,84 @@ function writeContentsToFile(/*String*/ aString, /*File*/ aFile)
|
||||
|
||||
writer.close();
|
||||
}
|
||||
|
||||
function exec(/*Array*/ command, /*Boolean*/ showOutput)
|
||||
{
|
||||
var line = "",
|
||||
output = "",
|
||||
|
||||
process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command));
|
||||
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream()));
|
||||
|
||||
while (line = reader.readLine())
|
||||
{
|
||||
if (showOutput)
|
||||
Packages.java.lang.System.out.println(line);
|
||||
|
||||
output += line + '\n';
|
||||
}
|
||||
|
||||
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream()));
|
||||
|
||||
while (line = reader.readLine())
|
||||
Packages.java.lang.System.out.println(line);
|
||||
|
||||
try
|
||||
{
|
||||
if (process.waitFor() != 0)
|
||||
Packages.java.lang.System.err.println("exit value = " + process.exitValue());
|
||||
}
|
||||
catch (anException)
|
||||
{
|
||||
Packages.java.lang.System.err.println(anException);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function getFiles(/*File*/ sourceDirectory, /*nil|String|Array<String>*/ extensions, /*Array*/ exclusions)
|
||||
{
|
||||
var matches = [],
|
||||
files = sourceDirectory.listFiles(),
|
||||
hasMultipleExtensions = typeof extensions !== "string";
|
||||
|
||||
if (files)
|
||||
{
|
||||
var index = 0,
|
||||
count = files.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var file = files[index].getCanonicalFile(),
|
||||
name = String(file.getName()),
|
||||
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 (isValidExtension)
|
||||
matches.push(file);
|
||||
|
||||
if (file.isDirectory())
|
||||
matches = matches.concat(getFiles(file, extensions, exclusions));
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
@@ -22,23 +22,45 @@
|
||||
|
||||
@import <AppKit/CPSegmentedControl.j>
|
||||
|
||||
@import "NSSegmentedControl.j"
|
||||
|
||||
|
||||
@implementation CPSegmentedControl (CPCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
_segments = [];
|
||||
_themeStates = [];
|
||||
|
||||
if (self = [super NS_initWithCoder:aCoder])
|
||||
{
|
||||
var frame = [self frame],
|
||||
originalWidth = frame.size.width;
|
||||
|
||||
frame.size.width = 0;
|
||||
frame.origin.x = MAX(frame.origin.x - 4.0, 0.0);
|
||||
|
||||
[self setFrame:frame];
|
||||
|
||||
var cell = [aCoder decodeObjectForKey:"NSCell"];
|
||||
|
||||
|
||||
_segments = [cell segments];
|
||||
_selectedSegment = [cell selectedSegment];
|
||||
_segmentStyle = [cell segmentStyle];
|
||||
_trackingMode = [cell trackingMode];
|
||||
|
||||
[self setValue:CPCenterTextAlignment forThemeAttribute:@"alignment"];
|
||||
|
||||
// HACK
|
||||
|
||||
for (var i = 0; i < _segments.length; i++)
|
||||
{
|
||||
_themeStates[i] = _segments[i].selected ? CPThemeStateSelected : CPThemeStateNormal;
|
||||
|
||||
[self tileWithChangedSegment:i];
|
||||
}
|
||||
|
||||
frame.size.width = originalWidth;
|
||||
[self setFrame:frame];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -76,8 +98,6 @@
|
||||
_selectedSegment = [aCoder decodeIntForKey:"NSSelectedSegment"];
|
||||
_segmentStyle = [aCoder decodeIntForKey:"NSSegmentStyle"];
|
||||
_trackingMode = [aCoder decodeIntForKey:"NSTrackingMode"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -98,7 +118,10 @@
|
||||
selected = [aCoder decodeBoolForKey:"NSSegmentItemSelected"];
|
||||
enabled = ![aCoder decodeBoolForKey:"NSSegmentItemDisabled"];
|
||||
tag = [aCoder decodeIntForKey:"NSSegmentItemTag"];
|
||||
|
||||
width = [aCoder decodeIntForKey:"NSSegmentItemWidth"];
|
||||
|
||||
frame = CGRectMakeZero();
|
||||
|
||||
// NSSegmentItemImageScaling
|
||||
// NSSegmentItemTooltip
|
||||
}
|
||||
|
||||
@@ -30,13 +30,12 @@
|
||||
@import "Nib2CibKeyedUnarchiver.j"
|
||||
|
||||
importPackage(java.io);
|
||||
importClass(java.io.File);
|
||||
|
||||
CPLogRegister(CPLogPrint);
|
||||
|
||||
function exec(command)
|
||||
{
|
||||
var p = Packages.java.lang.Runtime.getRuntime().exec(jsArrayToJavaArray(command));
|
||||
var p = Packages.java.lang.Runtime.getRuntime().exec(command);
|
||||
var result = p.waitFor();
|
||||
|
||||
var reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(p.getInputStream()));
|
||||
@@ -52,7 +51,7 @@ function exec(command)
|
||||
|
||||
function printUsage()
|
||||
{
|
||||
java.lang.System.out.println("usage: steam INPUT_FILE [OUTPUT_FILE]");
|
||||
java.lang.System.out.println("usage: nib2cib INPUT_FILE [OUTPUT_FILE] [-F /path/to/required/framework]");
|
||||
java.lang.System.exit(1);
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
|
||||
|
||||
if (resourcesPath)
|
||||
{
|
||||
resourcesFile = new File(resourcesPath).getCanonicalFile();
|
||||
resourcesFile = new java.io.File(resourcesPath).getCanonicalFile();
|
||||
|
||||
if (!resourcesFile.canRead())
|
||||
{
|
||||
@@ -101,7 +100,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
|
||||
}
|
||||
|
||||
// Compile xib or nib to make sure we have a non-new format nib.
|
||||
var temporaryNibFile = Packages.java.io.File.createTempFile("temp", ".nib"),
|
||||
var temporaryNibFile = java.io.File.createTempFile("temp", ".nib"),
|
||||
temporaryNibFilePath = temporaryNibFile.getAbsolutePath();
|
||||
|
||||
temporaryNibFile.deleteOnExit();
|
||||
@@ -113,7 +112,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
|
||||
}
|
||||
|
||||
// Convert from binary plist to XML plist
|
||||
var temporaryPlistFile = Packages.java.io.File.createTempFile("temp", ".plist"),
|
||||
var temporaryPlistFile = java.io.File.createTempFile("temp", ".plist"),
|
||||
temporaryPlistFilePath = temporaryPlistFile.getAbsolutePath();
|
||||
|
||||
temporaryPlistFile.deleteOnExit();
|
||||
@@ -171,7 +170,7 @@ function loadFrameworks(frameworkPaths, aCallback)
|
||||
|
||||
var frameworkPath = frameworkPaths.shift(),
|
||||
|
||||
infoPlist = new File(frameworkPath + "/Info.plist");
|
||||
infoPlist = new java.io.File(frameworkPath + "/Info.plist");
|
||||
|
||||
if (!infoPlist.exists())
|
||||
{
|
||||
@@ -179,7 +178,7 @@ function loadFrameworks(frameworkPaths, aCallback)
|
||||
java.lang.System.exit(1);
|
||||
}
|
||||
|
||||
var infoDictionary = readPlist(new File(frameworkPath + "/Info.plist"));
|
||||
var infoDictionary = readPlist(new java.io.File(frameworkPath + "/Info.plist"));
|
||||
|
||||
if ([infoDictionary objectForKey:@"CPBundlePackageType"] !== "FMWK")
|
||||
{
|
||||
|
||||
+6
-6
@@ -26,20 +26,20 @@ function main()
|
||||
verbose = false;
|
||||
|
||||
var usageError = false;
|
||||
while (args.length && !usageError)
|
||||
while (system.args.length && !usageError)
|
||||
{
|
||||
var arg = args.shift();
|
||||
var arg = system.args.shift();
|
||||
switch(arg)
|
||||
{
|
||||
case "--main":
|
||||
if (args.length)
|
||||
mainFilename = args.shift();
|
||||
if (system.args.length)
|
||||
mainFilename = system.args.shift();
|
||||
else
|
||||
usageError = true;
|
||||
break;
|
||||
case "--frameworks":
|
||||
if (args.length)
|
||||
frameworksDirectory = args.shift().replace(/\/$/, "");
|
||||
if (system.args.length)
|
||||
frameworksDirectory = system.args.shift().replace(/\/$/, "");
|
||||
else
|
||||
usageError = true;
|
||||
break;
|
||||
|
||||
@@ -77,40 +77,14 @@ end
|
||||
def subrake(directories, task_name)
|
||||
directories.each do |directory|
|
||||
if (File.directory?(directory) && File.file?(File.join(directory, "Rakefile")))
|
||||
system %{cd #{directory} && #{$serialized_env} #{$0} #{task_name}}
|
||||
ok = system(%{cd #{directory} && #{$serialized_env} #{$0} #{task_name}})
|
||||
rake abort unless ok
|
||||
else
|
||||
puts "warning: subrake missing: " + directory +" (this is not necessarily an error, "+directory+" may be optional)"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Shared Resrouces in env
|
||||
$JSJAR_PATH = File.expand_path(File.join($HOME_DIR, 'Tools/Utilities/js.jar'))
|
||||
$ENVIRONMENT_JS = File.join($ENVIRONMENT_LIB_DIR, 'js.jar')
|
||||
|
||||
file_d $ENVIRONMENT_JS do
|
||||
cp($JSJAR_PATH, $ENVIRONMENT_JS)
|
||||
end
|
||||
|
||||
def js2java(inputfile, className, debug)
|
||||
|
||||
debugString = '-nosource -debug' if debug
|
||||
|
||||
IO.popen("java -classpath #{$JSJAR_PATH}:. #{debugString} org.mozilla.javascript.tools.jsc.Main -o #{className} #{inputfile}") do |shrinksafe|
|
||||
puts shrinksafe.read
|
||||
end
|
||||
end
|
||||
|
||||
def cat(files, outfile)
|
||||
|
||||
File.open(outfile, "w") do |concated|
|
||||
|
||||
files.each do |file|
|
||||
concated.write IO.read(file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def executable_exists?(name)
|
||||
ENV["PATH"].split(":").any? {|p| File.executable? File.join(p, name) }
|
||||
end
|
||||
@@ -122,7 +96,7 @@ def make_objj_executable(path)
|
||||
File.chmod 0755, path
|
||||
end
|
||||
|
||||
task :build => [$ENVIRONMENT_JS]
|
||||
task :build
|
||||
task :default => [:build]
|
||||
|
||||
task :release do
|
||||
|
||||
Reference in new issue
Block a user