Merge remote-tracking branch 'upstream/master' into CPImageView-bindings

This commit is contained in:
cacaodev committed 2012-04-12 23:12:09 +02:00
commit 487d38fd21
70 files changed
+4910 -904

No files matched your search

+1
View File
@@ -38,6 +38,7 @@
@import "CPCibControlConnector.j"
@import "CPCibLoading.j"
@import "CPCibOutletConnector.j"
@import "CPCibRuntimeAttributesConnector.j"
@import "CPClipView.j"
@import "CPCollectionView.j"
@import "CPCollectionViewItem.j"
+1
View File
@@ -122,6 +122,7 @@ ACTUAL_FRAME_RATE = 0;
*/
- (void)setAnimationCurve:(CPAnimationCurve)anAnimationCurve
{
var timingFunctionName;
switch (anAnimationCurve)
{
case CPAnimationEaseInOut: timingFunctionName = kCAMediaTimingFunctionEaseInEaseOut;
+2 -2
View File
@@ -258,7 +258,7 @@
var column = [[CPTableColumn alloc] initWithIdentifier:@"Image"],
view = [[CPImageView alloc] initWithFrame:CGRectMakeZero()];
[view setImageScaling:CPScaleProportionally];
[view setImageScaling:CPImageScaleProportionallyDown];
[column setDataView:view];
[column setResizingMask:CPTableColumnNoResizing];
@@ -988,7 +988,7 @@ var _CPBrowserResizeControlBackgroundImage = nil;
isHighlighted = [self themeState] & CPThemeStateSelectedDataView;
[imageView setImage: _isLeaf ? (isHighlighted ? _highlightedBranchImage : _branchImage) : nil];
[imageView setImageScaling:CPScaleNone];
[imageView setImageScaling:CPImageScaleNone];
}
- (void)encodeWithCoder:(CPCoder)aCoder
+18 -18
View File
@@ -141,9 +141,9 @@ CPButtonImageOffset = 3.0;
}
/*!
Initializes and returns a newly allocated CPButton object with a specified frame rectangle.
@param aFrame The frame rectangle for the created button object.
@return An initialized CPView object or nil if the object couldn't be created.
Initializes and returns a newly allocated CPButton object with a specified frame rectangle.
@param aFrame The frame rectangle for the created button object.
@return An initialized CPView object or nil if the object couldn't be created.
*/
- (id)initWithFrame:(CGRect)aFrame
{
@@ -155,7 +155,7 @@ CPButtonImageOffset = 3.0;
[self setValue:CPCenterTextAlignment forThemeAttribute:@"alignment"];
[self setValue:CPCenterVerticalTextAlignment forThemeAttribute:@"vertical-alignment"];
[self setValue:CPImageLeft forThemeAttribute:@"image-position"];
[self setValue:CPScaleNone forThemeAttribute:@"image-scaling"];
[self setValue:CPImageScaleNone forThemeAttribute:@"image-scaling"];
[self setBezelStyle:CPRoundRectBezelStyle];
[self setBordered:YES];
@@ -180,7 +180,7 @@ CPButtonImageOffset = 3.0;
// Setting the state
/*!
Returns a Boolean value indicating whether the button allows a mixed state.
Returns a Boolean value indicating whether the button allows a mixed state.
@return \c YES if the button has a 'mixed' state in addition to on and off.
*/
- (BOOL)allowsMixedState
@@ -206,8 +206,8 @@ CPButtonImageOffset = 3.0;
}
/*!
Sets the value of the button using an Objective-J object.
@param anObjectValue The value of the button interpreted as an Objective-J object.
Sets the value of the button using an Objective-J object.
@param anObjectValue The value of the button interpreted as an Objective-J object.
*/
- (void)setObjectValue:(id)anObjectValue
{
@@ -244,11 +244,11 @@ CPButtonImageOffset = 3.0;
}
/*!
Returns the button's next state.
@return The button's state. A button can have two or three states.
If it has two, this value is either \c CPOffState (the normal or unpressed state)
or \c CPOnState (the alternate or pressed state).
If it has three, this value can be \c CPOnState (the feature is in effect everywhere), \c CPOffState (the feature is in effect nowhere), or \c CPMixedState (the feature is in effect somewhere).
Returns the button's next state.
@return The button's state. A button can have two or three states.
If it has two, this value is either \c CPOffState (the normal or unpressed state)
or \c CPOnState (the alternate or pressed state).
If it has three, this value can be \c CPOnState (the feature is in effect everywhere), \c CPOffState (the feature is in effect nowhere), or \c CPMixedState (the feature is in effect somewhere).
*/
- (CPInteger)nextState
{
@@ -294,9 +294,9 @@ CPButtonImageOffset = 3.0;
}
/*!
Sets the title displayed by the button when in its normal state.
@param aTitle The string to set as the button's title. This title is always shown on buttons
that don’t use their alternate contents when highlighting or displaying their alternate state.
Sets the title displayed by the button when in its normal state.
@param aTitle The string to set as the button's title. This title is always shown on buttons
that don’t use their alternate contents when highlighting or displaying their alternate state.
*/
- (void)setTitle:(CPString)aTitle
{
@@ -310,9 +310,9 @@ CPButtonImageOffset = 3.0;
}
/*!
Returns the title displayed on the button when it’s in its normal state.
@return The title displayed on the receiver when it’s in its normal state
or the empty string if the button doesn’t display a title.
Returns the title displayed on the button when it’s in its normal state.
@return The title displayed on the receiver when it’s in its normal state
or the empty string if the button doesn’t display a title.
*/
- (CPString)title
{
+40 -33
View File
@@ -28,42 +28,48 @@
@import "CPView.j"
@import "CPKeyValueBinding.j"
CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
CPJustifiedTextAlignment = 3;
CPNaturalTextAlignment = 4;
CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
CPJustifiedTextAlignment = 3;
CPNaturalTextAlignment = 4;
CPRegularControlSize = 0;
CPSmallControlSize = 1;
CPMiniControlSize = 2;
CPRegularControlSize = 0;
CPSmallControlSize = 1;
CPMiniControlSize = 2;
CPLineBreakByWordWrapping = 0;
CPLineBreakByCharWrapping = 1;
CPLineBreakByClipping = 2;
CPLineBreakByTruncatingHead = 3;
CPLineBreakByTruncatingTail = 4;
CPLineBreakByTruncatingMiddle = 5;
CPLineBreakByWordWrapping = 0;
CPLineBreakByCharWrapping = 1;
CPLineBreakByClipping = 2;
CPLineBreakByTruncatingHead = 3;
CPLineBreakByTruncatingTail = 4;
CPLineBreakByTruncatingMiddle = 5;
CPTopVerticalTextAlignment = 1;
CPCenterVerticalTextAlignment = 2;
CPBottomVerticalTextAlignment = 3;
CPTopVerticalTextAlignment = 1;
CPCenterVerticalTextAlignment = 2;
CPBottomVerticalTextAlignment = 3;
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
// Deprecated for use with images, use the CPImageScale constants
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
CPNoImage = 0;
CPImageOnly = 1;
CPImageLeft = 2;
CPImageRight = 3;
CPImageBelow = 4;
CPImageAbove = 5;
CPImageOverlaps = 6;
CPImageScaleProportionallyDown = 0;
CPImageScaleAxesIndependently = 1;
CPImageScaleNone = 2;
CPImageScaleProportionallyUpOrDown = 3;
CPOnState = 1;
CPOffState = 0;
CPMixedState = -1;
CPNoImage = 0;
CPImageOnly = 1;
CPImageLeft = 2;
CPImageRight = 3;
CPImageBelow = 4;
CPImageAbove = 5;
CPImageOverlaps = 6;
CPOnState = 1;
CPOffState = 0;
CPMixedState = -1;
CPControlNormalBackgroundColor = "CPControlNormalBackgroundColor";
CPControlSelectedBackgroundColor = "CPControlSelectedBackgroundColor";
@@ -784,9 +790,10 @@ var CPControlBlackColor = [CPColor blackColor];
Sets the image scaling of the control.
<pre>
CPScaleProportionally
CPScaleToFit
CPScaleNone
CPImageScaleProportionallyDown
CPImageScaleAxesIndependently
CPImageScaleNone
CPImageScaleProportionallyUpOrDown
</pre>
*/
- (void)setImageScaling:(CPImageScaling)scaling
+31 -38
View File
@@ -26,11 +26,6 @@
@import "CPImage.j"
@import "CPShadowView.j"
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
CPImageAlignCenter = 0;
CPImageAlignTop = 1;
CPImageAlignTopLeft = 2;
@@ -240,7 +235,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
[super setImageScaling:anImageScaling];
#if PLATFORM(DOM)
if ([self currentValueForThemeAttribute:@"image-scaling"] === CPScaleToFit)
if ([self currentValueForThemeAttribute:@"image-scaling"] === CPImageScaleAxesIndependently)
{
CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, 0.0, 0.0);
}
@@ -304,12 +299,12 @@ var CPImageViewEmptyPlaceholderImage = nil;
width = boundsWidth - insetWidth,
height = boundsHeight - insetHeight;
if (imageScaling === CPScaleToFit)
if (imageScaling === CPImageScaleAxesIndependently)
{
#if PLATFORM(DOM)
_DOMImageElement.width = ROUND(width);
_DOMImageElement.height = ROUND(height);
#endif
#if PLATFORM(DOM)
_DOMImageElement.width = ROUND(width);
_DOMImageElement.height = ROUND(height);
#endif
}
else
{
@@ -318,17 +313,19 @@ var CPImageViewEmptyPlaceholderImage = nil;
if (size.width == -1 && size.height == -1)
return;
if (imageScaling === CPScaleProportionally)
switch (imageScaling)
{
// The max size it can be is size.width x size.height, so only
// only proportion otherwise.
if (width >= size.width && height >= size.height)
{
width = size.width;
height = size.height;
}
else
{
case CPImageScaleProportionallyDown:
if (width >= size.width && height >= size.height)
{
width = size.width;
height = size.height;
break;
}
// intentionally fall through to the next case
case CPImageScaleProportionallyUpOrDown:
var imageRatio = size.width / size.height,
viewRatio = width / height;
@@ -336,26 +333,19 @@ var CPImageViewEmptyPlaceholderImage = nil;
width = height * imageRatio;
else
height = width / imageRatio;
}
break;
#if PLATFORM(DOM)
case CPImageScaleAxesIndependently:
case CPImageScaleNone:
width = size.width;
height = size.height;
break;
}
#if PLATFORM(DOM)
_DOMImageElement.width = ROUND(width);
_DOMImageElement.height = ROUND(height);
#endif
}
else
{
width = size.width;
height = size.height;
}
if (imageScaling == CPScaleNone)
{
#if PLATFORM(DOM)
_DOMImageElement.width = ROUND(size.width);
_DOMImageElement.height = ROUND(size.height);
#endif
}
#endif
var x,
y;
@@ -510,6 +500,9 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
_DOMImageElement.setAttribute("draggable", "true");
_DOMImageElement.style["-khtml-user-drag"] = "element";
}
if (typeof(appkit_tag_dom_elements) !== "undefined" && !!appkit_tag_dom_elements)
_DOMImageElement.setAttribute("data-cappuccino-view", [self className]);
#endif
self = [super initWithCoder:aCoder];
+5 -2
View File
@@ -193,7 +193,10 @@ var CPBindingOperationAnd = 0,
newValue = [_source valueForKeyPath:aBinding];
newValue = [self reverseTransformValue:newValue withOptions:options];
[self suppressSpecificNotificationFromObject:destination keyPath:keyPath];
[destination setValue:newValue forKeyPath:keyPath];
[self unsuppressSpecificNotificationFromObject:destination keyPath:keyPath];
}
- (void)observeValueForKeyPath:(CPString)aKeyPath ofObject:(id)anObject change:(CPDictionary)changes context:(id)context
@@ -468,7 +471,7 @@ var CPBindingOperationAnd = 0,
@end
var resolveMultipleValues = function resolveMultipleValues(/*CPString*/key, /*CPDictionary*/bindings, /*GSBindingOperationKind*/operation)
var resolveMultipleValues = function(/*CPString*/key, /*CPDictionary*/bindings, /*GSBindingOperationKind*/operation)
{
var bindingName = key,
theBinding,
@@ -492,7 +495,7 @@ var resolveMultipleValues = function resolveMultipleValues(/*CPString*/key, /*CP
return !operation;
};
var invokeAction = function invokeAction(/*CPString*/targetKey, /*CPString*/argumentKey, /*CPDictionary*/bindings)
var invokeAction = function(/*CPString*/targetKey, /*CPString*/argumentKey, /*CPDictionary*/bindings)
{
var theBinding = [bindings objectForKey:targetKey],
infoDictionary = theBinding._info,
+1 -3
View File
@@ -148,10 +148,8 @@ var SelectionColor = nil,
[_submenuIndicatorView setFrame:submenuViewFrame];
}
_minSize = CGSizeMake(x + HORIZONTAL_MARGIN, height);
[self setAutoresizesSubviews:NO];
[self setFrameSize:_minSize];
[self setFrameSize:CGSizeMake(x + HORIZONTAL_MARGIN, height)];
[self setAutoresizesSubviews:YES];
}
+14 -14
View File
@@ -6,14 +6,14 @@ var LEFT_MARGIN = 3.0,
STATE_COLUMN_WIDTH = 14.0,
INDENTATION_WIDTH = 17.0,
VERTICAL_MARGIN = 4.0,
RIGHT_COLUMNS_MARGIN = 30.0,
KEY_EQUIVALENT_MARGIN = 10.0;
var SUBMENU_INDICATOR_COLOR = nil,
_CPMenuItemSelectionColor = nil,
_CPMenuItemTextShadowColor = nil,
_CPMenuItemDefaultStateImages = [],
_CPMenuItemDefaultStateHighlightedImages = [];
@@ -43,9 +43,9 @@ var SUBMENU_INDICATOR_COLOR = nil,
_CPMenuItemSelectionColor = [CPColor colorWithCalibratedRed:95.0 / 255.0 green:131.0 / 255.0 blue:185.0 / 255.0 alpha:1.0];
_CPMenuItemTextShadowColor = [CPColor colorWithCalibratedRed:26.0 / 255.0 green: 73.0 / 255.0 blue:109.0 / 255.0 alpha:1.0];
var bundle = [CPBundle bundleForClass:self];
_CPMenuItemDefaultStateImages[CPOffState] = nil;
_CPMenuItemDefaultStateHighlightedImages[CPOffState] = nil;
@@ -74,7 +74,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
{
_stateView = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)];
[_stateView setImageScaling:CPScaleNone];
[_stateView setImageScaling:CPImageScaleNone];
[self addSubview:_stateView];
@@ -175,7 +175,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
[_keyEquivalentView setTextShadowOffset:CGSizeMake(0, 1)];
[_keyEquivalentView setFrameOrigin:CGPointMake(x, VERTICAL_MARGIN)];
[_keyEquivalentView sizeToFit];
var keyEquivalentViewFrame = [_keyEquivalentView frame];
keyEquivalentViewFrame.origin.x = x;
@@ -215,7 +215,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
keyEquivalentViewFrame.origin.y = FLOOR((height - CGRectGetHeight(keyEquivalentViewFrame)) / 2.0);
[_keyEquivalentView setFrame:keyEquivalentViewFrame];
}
if (hasSubmenu)
{
submenuViewFrame.origin.y = FLOOR((height - CGRectGetHeight(submenuViewFrame)) / 2.0);
@@ -223,7 +223,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
}
_minSize = CGSizeMake(x + RIGHT_MARGIN, height);
[self setAutoresizesSubviews:NO];
[self setFrameSize:_minSize];
[self setAutoresizesSubviews:YES];
@@ -233,7 +233,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
{
// FIXME: This should probably be even throw.
if (![_menuItem isEnabled])
return;
return;
if (shouldHighlight)
{
@@ -259,7 +259,7 @@ var SUBMENU_INDICATOR_COLOR = nil,
[_imageAndTextView setTextShadowColor:[self textShadowColor]];
[_keyEquivalentView setTextShadowColor:[self textShadowColor]];
}
if ([[_menuItem menu] showsStateColumn])
{
if (shouldHighlight)
@@ -290,15 +290,15 @@ var SUBMENU_INDICATOR_COLOR = nil,
{
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds];
CGContextBeginPath(context);
CGContextMoveToPoint(context, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
CGContextAddLineToPoint(context, CGRectGetMaxX(bounds), CGRectGetMidY(bounds));
CGContextAddLineToPoint(context, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
CGContextClosePath(context);
CGContextSetFillColor(context, _color);
CGContextFillPath(context);
}
+1 -2
View File
@@ -151,7 +151,6 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
_retargedChildIndex = nil;
_shouldRetargetChildIndex = NO;
_startHoverTime = nil;
[self setIndentationPerLevel:16.0];
[self setIndentationMarkerFollowsDataView:YES];
@@ -1365,7 +1364,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
[self collapseItem:item];
else
[self expandItem:item];
[self expandItem:item expandChildren:([[CPApp currentEvent] modifierFlags] & CPAlternateKeyMask)];
}
/*!
+2 -1
View File
@@ -345,7 +345,8 @@
{
var rootRowsArray = [super _rootRowsArray],
subpredicates = [CPMutableArray array],
count = count2 = [rootRowsArray count],
count,
count2 = count = [rootRowsArray count],
predicate;
while (count--)
+2 -2
View File
@@ -173,7 +173,7 @@ var RECENT_SEARCH_PREFIX = @" ";
searchButtonImage = (_searchMenuTemplate === nil) ? CPSearchFieldSearchImage : CPSearchFieldFindImage;
[button setBordered:NO];
[button setImageScaling:CPScaleToFit];
[button setImageScaling:CPImageScaleAxesIndependently];
[button setImage:searchButtonImage];
[button setAutoresizingMask:CPViewMaxXMargin];
}
@@ -215,7 +215,7 @@ var RECENT_SEARCH_PREFIX = @" ";
{
var button = [self cancelButton];
[button setBordered:NO];
[button setImageScaling:CPScaleToFit];
[button setImageScaling:CPImageScaleAxesIndependently];
[button setImage:CPSearchFieldCancelImage];
[button setAlternateImage:CPSearchFieldCancelPressedImage];
[button setAutoresizingMask:CPViewMinXMargin];
+1 -1
View File
@@ -55,7 +55,7 @@ CPSegmentSwitchTrackingMomentary = 2;
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), [CPNull null], [CPNull null], [CPNull null], [CPNull null], 1.0, 24.0]
return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPImageScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), [CPNull null], [CPNull null], [CPNull null], [CPNull null], 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"]];
}
+4 -8
View File
@@ -321,7 +321,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/
- (void)_init
{
_tableViewFlags = 0;
_lastSelectedRow = -1;
_selectedColumnIndexes = [CPIndexSet indexSet];
@@ -335,15 +334,12 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (!_alternatingRowBackgroundColors)
_alternatingRowBackgroundColors = [[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]];
_selectionHighlightColor = [CPColor colorWithHexString:@"5f83b9"];
_tableColumnRanges = [];
_dirtyTableColumnRangeIndex = 0;
_numberOfHiddenColumns = 0;
_objectValues = { };
_dataViewsForTableColumns = { };
_dataViews = [];
_numberOfRows = 0;
_exposedRows = [CPIndexSet indexSet];
_exposedColumns = [CPIndexSet indexSet];
@@ -3696,7 +3692,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
[_selectedColumnIndexes getIndexes:indexes maxCount:-1 inIndexRange:exposedRange];
}
var count = count2 = [indexes count];
var count,
count2 = count = [indexes count];
if (!count)
return;
@@ -4852,9 +4849,8 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
while (index != CPNotFound)
{
var indexSet = (switchFlag) ? otherSet : self;
otherIndex = [indexSet indexGreaterThanOrEqualToIndex:index];
var indexSet = (switchFlag) ? otherSet : self,
otherIndex = [indexSet indexGreaterThanOrEqualToIndex:index];
if (otherIndex == index)
{
+1 -1
View File
@@ -1024,7 +1024,7 @@ var TOP_MARGIN = 5.0,
{
_imageView = [[CPImageView alloc] initWithFrame:[self bounds]];
[_imageView setImageScaling:CPScaleProportionally];
[_imageView setImageScaling:CPImageScaleProportionallyDown];
[self addSubview:_imageView];
}
+1 -1
View File
@@ -105,7 +105,7 @@ var HUD_TITLEBAR_HEIGHT = 26.0;
if ([[[self window] toolbar] isVisible])
{
toolbarHeight = CGRectGetHeight([[self toolbarView] frame]);
var toolbarHeight = CGRectGetHeight([[self toolbarView] frame]);
frameRect.origin.y -= toolbarHeight;
frameRect.size.height += toolbarHeight;
+1 -1
View File
@@ -197,7 +197,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
if ([theToolbar isVisible])
{
toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]);
frameRect.origin.y -= toolbarHeight;
frameRect.size.height += toolbarHeight;
@@ -0,0 +1,64 @@
/*
* CPCibRuntimeAttributesConnector.j
* AppKit
*
* Created by Aparajita Fishman.
* Copyright 2012, The Cappuccino Project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPCibConnector.j"
var CPCibRuntimeAttributesConnectorObjectKey = @"CPCibRuntimeAttributesConnectorObjectKey",
CPCibRuntimeAttributesConnectorKeyPathsKey = @"CPCibRuntimeAttributesConnectorKeyPathsKey",
CPCibRuntimeAttributesConnectorValuesKey = @"CPCibRuntimeAttributesConnectorValuesKey";
@implementation CPCibRuntimeAttributesConnector : CPCibConnector
{
id _keyPaths;
id _values;
}
- (id)initWithCoder:(CPCoder)aCoder
{
if (self = [super initWithCoder:aCoder])
{
_source = [aCoder decodeObjectForKey:CPCibRuntimeAttributesConnectorObjectKey];
_keyPaths = [aCoder decodeObjectForKey:CPCibRuntimeAttributesConnectorKeyPathsKey];
_values = [aCoder decodeObjectForKey:CPCibRuntimeAttributesConnectorValuesKey];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
[aCoder encodeObject:_source forKey:CPCibRuntimeAttributesConnectorObjectKey];
[aCoder encodeObject:_keyPaths forKey:CPCibRuntimeAttributesConnectorKeyPathsKey];
[aCoder encodeObject:_values forKey:CPCibRuntimeAttributesConnectorValuesKey];
}
- (void)establishConnection
{
var count = [_keyPaths count];
while (count--)
[_source setValue:_values[count] forKeyPath:_keyPaths[count]];
}
@end
+2 -2
View File
@@ -61,14 +61,14 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
if (!object)
{
CPLog.error("Unable to find class " + theClassName + " in cib file.");
CPLog.error("Unable to find class " + theClassName + " referenced in cib file.");
object = [self allocObjectWithCoder:aCoder className:[aCoder decodeObjectForKey:_CPCibClassSwapperOriginalClassNameKey]];
}
}
if (!object)
[CPException raise:CPInvalidArgumentException reason:@"Unable to find class " + theClassName + " in cib file."];
[CPException raise:CPInvalidArgumentException reason:@"Unable to find class " + theClassName + " referenced in cib file."];
return object;
}
+24 -5
View File
@@ -29,6 +29,7 @@
@import "CPCibControlConnector.j"
@import "CPCibOutletConnector.j"
@import "CPCibBindingConnector.j"
@import "CPCibRuntimeAttributesConnector.j"
@implementation _CPCibObjectData : CPObject
@@ -232,15 +233,15 @@ var _CPCibObjectDataNamesKeysKey = @"_CPCibObjectDataNamesKeysKey
{
_replacementObjects[[object UID]] = instantiatedObject;
if ([instantiatedObject isKindOfClass:[CPView class]])
if ([instantiatedObject isKindOfClass:CPView])
{
var clipView = [instantiatedObject superview];
if ([clipView isKindOfClass:[CPClipView class]])
if ([clipView isKindOfClass:CPClipView])
{
var scrollView = [clipView superview];
if ([scrollView isKindOfClass:[CPScrollView class]])
if ([scrollView isKindOfClass:CPScrollView])
[scrollView setDocumentView:instantiatedObject];
}
}
@@ -257,11 +258,29 @@ var _CPCibObjectDataNamesKeysKey = @"_CPCibObjectDataNamesKeysKey
_replacementObjects[[_fileOwner UID]] = anOwner;
var index = 0,
count = _connections.length;
count = _connections.length,
runtimeAttributeConnectors = [],
connection = nil;
for (; index < count; ++index)
{
var connection = _connections[index];
connection = _connections[index];
if ([connection isKindOfClass:CPCibRuntimeAttributesConnector])
// Defer runtime attribute connections until after all other connections are made
runtimeAttributeConnectors.push(connection);
else
{
[connection replaceObjects:_replacementObjects];
[connection establishConnection];
}
}
count = runtimeAttributeConnectors.length;
for (index = 0; index < count; ++index)
{
connection = runtimeAttributeConnectors[index];
[connection replaceObjects:_replacementObjects];
[connection establishConnection];
+3 -3
View File
@@ -100,7 +100,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
[self setAlignment:CPCenterTextAlignment];
[self setFont:[CPFont systemFontOfSize:12.0]];
[self setImagePosition:CPNoImage];
[self setImageScaling:CPScaleNone];
[self setImageScaling:CPImageScaleNone];
}
_textSize = nil;
@@ -607,12 +607,12 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
imageWidth = imageSize.width,
imageHeight = imageSize.height;
if (_imageScaling === CPScaleToFit)
if (_imageScaling === CPImageScaleAxesIndependently)
{
imageWidth = size.width;
imageHeight = size.height;
}
else if (_imageScaling === CPScaleProportionally)
else if (_imageScaling === CPImageScaleProportionallyDown)
{
var scale = MIN(MIN(size.width, imageWidth) / imageWidth, MIN(size.height, imageHeight) / imageHeight);
+1 -1
View File
@@ -522,7 +522,7 @@ var concat = Array.prototype.concat,
if ([objects count])
{
argumentsArray = [[nil, aSelector] arrayByAddingObjectsFromArray:objects];
var argumentsArray = [[nil, aSelector] arrayByAddingObjectsFromArray:objects];
for (; index < count; ++index)
{
+1 -1
View File
@@ -163,7 +163,7 @@ var concat = Array.prototype.concat,
if ([objects count])
{
argumentsArray = [[nil, aSelector] arrayByAddingObjectsFromArray:objects];
var argumentsArray = [[nil, aSelector] arrayByAddingObjectsFromArray:objects];
for (; index < count; ++index)
{
+9 -2
View File
@@ -122,8 +122,8 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
- (CPArray)pathComponents
{
var path = self.pathComponents();
return [path copy];
var components = self.pathComponents();
return [components copy];
}
// if absolute, returns the same as path
@@ -202,6 +202,13 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
return self.pathExtension();
}
- (CPURL)URLByDeletingLastPathComponent
{
var result = self.createCopyDeletingLastPathComponent();
result.isa = [self class];
return result;
}
- (CPURL)standardizedURL
{
return self.standardizedURL();
+22 -4
View File
@@ -122,10 +122,9 @@ function CFURLGetParts(/*CFURL*/ aURL)
{
var split = parts.path.split("/"),
pathComponents = parts.pathComponents,
index = 0,
count = split.length;
for (; index < count; ++index)
for (index = 0; index < count; ++index)
{
var component = split[index];
@@ -160,7 +159,7 @@ GLOBAL(CFURL) = function(/*CFURL|String*/ aURL, /*CFURL*/ aBaseURL)
if (aURL instanceof CFURL)
{
if (!aBaseURL)
return aURL;
return new CFURL(aURL.absoluteString());
var existingBaseURL = aURL.baseURL();
@@ -360,7 +359,7 @@ function standardizePathComponents(/*Array*/ pathComponents, /*BOOL*/ inPlace)
var component = pathComponents[index];
if (component === "")
continue;
continue;
if (component === ".")
{
@@ -564,6 +563,25 @@ CFURL.prototype.path = function()
DISPLAY_NAME(CFURL.prototype.path);
CFURL.prototype.createCopyDeletingLastPathComponent = function()
{
var parts = PARTS(this),
components = standardizePathComponents(parts.pathComponents, NO);
if (components.length > 0)
if (components.length > 1 || components[0] !== "/")
components.pop();
// pathFromPathComponents() returns an empty path for ["/"]
var isRoot = components.length === 1 && components[0] === "/";
parts.pathComponents = components;
parts.path = isRoot ? "/" : pathFromPathComponents(components, NO);
return new CFURL(URLStringFromParts(parts));
};
DISPLAY_NAME(CFURL.prototype.createCopyDeletingLastPathComponent);
CFURL.prototype.pathComponents = function()
{
return PARTS(this).pathComponents;
+31 -1
View File
@@ -297,6 +297,36 @@
[self assert:@"octarine" equals:[control stringValue] message:@"binding update no longer suppressed"];
}
- (void)testReverseSetValueForDoesNotSetObjectValueOnSource
{
var control = [[TextField alloc] init];
[control setStringValue:@"brown"];
var oc = [[CPObjectController alloc] initWithContent:[CPDictionary dictionaryWithObject:@"toto" forKey:@"foo"]];
[oc setAutomaticallyPreparesContent:YES];
[control bind:CPValueBinding toObject:oc withKeyPath:@"selection.foo" options:nil];
[control setObjectValueSetterCount:0];
// This will force a binding update -reverseSetValueFor:
[control sendAction:nil to:nil];
[self assert:0 equals:[control objectValueSetterCount] message:@"-setObjectValue should not be called"];
}
@end
@implementation TextField : CPTextField
{
CPInteger objectValueSetterCount @accessors;
}
- (void)setObjectValue:(id)aValue
{
objectValueSetterCount++;
[super setObjectValue:aValue];
}
@end
@implementation BindingTester : CPObject
@@ -371,4 +401,4 @@
return valueB;
}
@end
@end
+18
View File
@@ -103,6 +103,24 @@ var exampleProtocol = "http",
[self assert:[url lastPathComponent] equals:examplePathRelative];
}
- (void)testDeleteComponent
{
var url = [CPURL URLWithString:exampleFullPath];
url = [url URLByDeletingLastPathComponent];
[self assert:[url absoluteString] equals:examplePathBase.substring(0, examplePathBase.length - 1)];
url = [url URLByDeletingLastPathComponent];
[self assert:[url absoluteString] equals:@"/"];
url = [url URLByDeletingLastPathComponent];
[self assert:[url absoluteString] equals:@"/"];
url = [CPURL URLWithString:@"foo"];
url = [url URLByDeletingLastPathComponent];
[self assert:[url absoluteString] equals:@""];
}
- (void)testURLToString
{
[self assert:String([CPURL URLWithString:exampleURL]) equals:exampleURL];
@@ -0,0 +1,65 @@
/*
* AppController.j
* CPBinder-echo-bug
*
* Created by You on March 29, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var message = [[CPTextField alloc] initWithFrame:CGRectMake(10,10,1000,32)];
[message setFont:[CPFont boldSystemFontOfSize:16.0]];
[message setStringValue:@"Type some text in the text field and press enter. You should NOT see any new call to -setObjectValue: in the console"];
[contentView addSubview:message];
var label = [[TextField alloc] initWithFrame:CGRectMake(0,0,400,22)];
[label setPlaceholderString:@"Type some text and hit enter"];
[label setBezeled:YES];
[label setBezelStyle:CPTextFieldSquareBezel];
[label setBordered:YES];
[label setEditable:YES];
var oc = [[CPObjectController alloc] initWithContent:[CPDictionary dictionaryWithObject:@"" forKey:@"foo"]];
[oc setAutomaticallyPreparesContent:YES];
[label bind:CPValueBinding toObject:oc withKeyPath:@"selection.foo" options:nil];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
[label setBackgroundColor:[CPColor greenColor]];
[label sizeToFit];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:[contentView center]];
[contentView addSubview:label];
[theWindow orderFront:self];
// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
}
@end
@implementation TextField : CPTextField
{
}
- (void)setObjectValue:(id)aValue
{
CPLogConsole(_cmd + [super objectValue] + " > " + aValue);
[self setBackgroundColor:[CPColor redColor]];
[super setObjectValue:aValue];
}
@end
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>CPBinder-echo-bug</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
+93
View File
@@ -0,0 +1,93 @@
/*
* Jakefile
* CPBinder-echo-bug
*
* Created by You on March 29, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("CPBinderEchoBug", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "CPBinderEchoBug.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPBinder-echo-bug");
task.setIdentifier("com.yourcompany.CPBinderEchoBug");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPBinder-echo-bug");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["CPBinderEchoBug"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "CPBinderEchoBug", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "CPBinderEchoBug", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "CPBinderEchoBug"));
OS.system(["press", "-f", FILE.join("Build", "Release", "CPBinderEchoBug"), FILE.join("Build", "Deployment", "CPBinderEchoBug")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "CPBinderEchoBug"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPBinderEchoBug"), FILE.join("Build", "Desktop", "CPBinderEchoBug", "CPBinderEchoBug.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "CPBinderEchoBug", "CPBinderEchoBug.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPBinderEchoBug"));
print("----------------------------");
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,107 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
CPBinder-echo-bug
Created by You on March 29, 2012.
Copyright 2012, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPBinder-echo-bug</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPBinder-echo-bug...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
+77
View File
@@ -0,0 +1,77 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
CPBinder-echo-bug
Created by You on March 29, 2012.
Copyright 2012, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPBinder-echo-bug</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPBinder-echo-bug...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPBinder-echo-bug
*
* Created by You on March 29, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
@@ -0,0 +1,39 @@
/*
* AppController.j
* CPImageViewScaling
*
* Created by aparajita on April 12, 2012.
* Copyright 2012, Victory-Heart Productions All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
}
- (void)awakeFromCib
{
}
@end
@implementation MyImageView : CPImageView
- (void)drawRect:(CGRect)aRect
{
var path = [CPBezierPath bezierPathWithRect:[self bounds]];
[[CPColor greenColor] set];
[path setLineWidth:1];
[path stroke];
}
@end
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>CPImageViewScaling</string>
</dict>
</plist>
@@ -0,0 +1,94 @@
/*
* Jakefile
* CPImageViewScaling
*
* Created by aparajita on April 12, 2012.
* Copyright 2012, Victory-Heart Productions All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("CPImageViewScaling", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "CPImageViewScaling.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPImageViewScaling");
task.setIdentifier("com.aparajita.CPImageViewScaling");
task.setVersion("1.0");
task.setAuthor("Victory-Heart Productions");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPImageViewScaling");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["CPImageViewScaling"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "CPImageViewScaling", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "CPImageViewScaling", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "CPImageViewScaling"));
OS.system(["press", "-f", FILE.join("Build", "Release", "CPImageViewScaling"), FILE.join("Build", "Deployment", "CPImageViewScaling")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "CPImageViewScaling"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPImageViewScaling"), FILE.join("Build", "Desktop", "CPImageViewScaling", "CPImageViewScaling.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "CPImageViewScaling", "CPImageViewScaling.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPImageViewScaling"));
print("----------------------------");
}
@@ -0,0 +1 @@
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;D;K;6;CP$UIDd;2;16E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;17E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;28E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;32E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;35E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;36E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;37E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;39E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;40E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;41E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;42E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;43E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;44E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;45E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;46E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;47E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;48E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;49E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;50E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;51E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;52E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;28E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;32E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;35E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;36E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;37E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;38E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;39E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;40E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;41E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;42E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;43E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;44E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;45E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;46E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;47E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;48E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;49E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;50E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;51E;D;K;6;CP$UIDd;2;11E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;53E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;12E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;54E;E;D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;11E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;52E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;55E;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;52E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;19E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;56E;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;53E;E;D;K;10;$classnameS;20;_CPCibWindowTemplateK;8;$classesA;S;20;_CPCibWindowTemplateS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;18E;K;30;_CPCibWindowTemplateMaxSizeKeyD;K;6;CP$UIDd;2;57E;K;32;_CPCibWindowTemplateViewClassKeyD;K;6;CP$UIDd;1;0E;K;34;_CPCibWindowTemplateWindowClassKeyD;K;6;CP$UIDd;2;58E;K;33;_CPCibWindowTemplateWindowRectKeyD;K;6;CP$UIDd;2;59E;K;30;_CPCibWindowTempatStyleMaskKeyD;K;6;CP$UIDd;Line truncated
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,107 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
CPImageViewScaling
Created by aparajita on April 12, 2012.
Copyright 2012, Victory-Heart Productions All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPImageViewScaling</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPImageViewScaling...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
@@ -0,0 +1,77 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
CPImageViewScaling
Created by aparajita on April 12, 2012.
Copyright 2012, Victory-Heart Productions All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPImageViewScaling</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPImageViewScaling...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPImageViewScaling
*
* Created by aparajita on April 12, 2012.
* Copyright 2012, Victory-Heart Productions All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
+2 -2
View File
@@ -32,8 +32,8 @@
image = CPImageInBundle("280px-1730_Homann_Map_of_Scandinavia,_Norway,_Sweden,_Denmark,_Finland_and_the_Baltics_-_Geographicus_-_Scandinavia-homann-1730.jpg", CGSizeMake(280, 240)),
imageViewShadow = [[CPImageView alloc] initWithFrame:CGRectMake(320.0, 50.0, 290.0, 250.0)];
[imageView setImageScaling:CPScaleNone];
[imageViewShadow setImageScaling:CPScaleNone];
[imageView setImageScaling:CPImageScaleNone];
[imageViewShadow setImageScaling:CPImageScaleNone];
[imageView setImage:image];
[imageViewShadow setImage:image];
@@ -29,7 +29,7 @@
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
[iconView setImageScaling:CPImageScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
@@ -69,7 +69,7 @@
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone];
[iconView setImageScaling:CPImageScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
@@ -46,7 +46,7 @@ tableTestDragType = @"CPTableViewTestDragType";
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16, 16, 0, 0)];
[iconView setImageScaling:CPScaleNone];
[iconView setImageScaling:CPImageScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
@@ -0,0 +1,36 @@
/*
* AppController.j
* UserlandNSTest
*
* Created by aparajita on April 11, 2012.
* Copyright 2012, The Cappuccino Foundation. All rights reserved.
*/
@import <Foundation/CPObject.j>
@import "BorderView.j"
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
@outlet CPTextField field1 @accessors(readonly);
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
}
- (void)awakeFromCib
{
}
- (void)setInitialResponderByTag:(CPInteger)tag
{
CPLog("setInitialFirstResponder:%d", tag);
[theWindow setInitialFirstResponder:[[theWindow contentView] viewWithTag:tag]];
}
- (void)setValue:(id)value forUndefinedKey:(CPString)key
{
CPLog("setValue:" + value + " forKey:" + key);
}
@end
+97
View File
@@ -0,0 +1,97 @@
/*
* BorderView.j
* UserlandNSTest
*
* Created by aparajita on April 11, 2012.
* Copyright 2012, The Cappuccino Foundation. All rights reserved.
*/
@import <AppKit/CPColor.j>
@import <AppKit/CPView.j>
BorderViewDefaultBorderWidth = 1.0;
BorderViewDefaultBorderColor = nil;
@implementation BorderView : CPView
{
int borderWidth @accessors;
CPColor borderColor @accessors;
}
+ (void)initialize
{
BorderViewDefaultBorderColor = [CPColor colorWithHexString:@"0000ff"];
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self)
{
borderWidth = BorderViewDefaultBorderWidth;
borderColor = BorderViewDefaultBorderColor;
}
return self;
}
- (void)setBorderWidth:(int)width
{
if (width === borderWidth)
return;
borderWidth = width;
[self setNeedsDisplay:YES];
}
- (void)setBorderColorWithHexString:(CPString)aColor
{
CPLog("setBorderColorWithHexString:%s", aColor);
var hexString = [borderColor hexString] || @"";
if (aColor.toLowerCase() === hexString.toLowerCase())
return;
borderColor = [CPColor colorWithHexString:aColor];
[self setNeedsDisplay:YES];
}
- (void)drawRect:(CGRect)dirtyRect
{
var path = [CPBezierPath bezierPathWithRect:CGRectInset([self bounds], borderWidth / 2.0, borderWidth / 2.0)];
[path setLineWidth:borderWidth];
[borderColor set];
[path stroke];
}
@end
var BorderViewBorderWidthKey = @"BorderViewBorderWidthKey",
BorderViewBorderColorKey = @"BorderViewBorderColorKey";
@implementation BorderView (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
borderWidth = [aCoder decodeIntForKey:BorderViewBorderWidthKey];
borderColor = [aCoder decodeObjectForKey:BorderViewBorderColorKey];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeInt:borderWidth forKey:BorderViewBorderWidthKey];
[aCoder encodeObject:borderColor forKey:BorderViewBorderColorKey];
}
@end
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>UserlandNSTest</string>
<key>IBClasses</key>
<array>
<string>BorderView</string>
</array>
</dict>
</plist>
+94
View File
@@ -0,0 +1,94 @@
/*
* Jakefile
* UserlandNSTest
*
* Created by aparajita on April 11, 2012.
* Copyright 2012, Victory-Heart Productions All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("UserlandNSTest", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "UserlandNSTest.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("UserlandNSTest");
task.setIdentifier("com.aparajita.UserlandNSTest");
task.setVersion("1.0");
task.setAuthor("Victory-Heart Productions");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("UserlandNSTest");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["UserlandNSTest"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "UserlandNSTest", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "UserlandNSTest", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "UserlandNSTest"));
OS.system(["press", "-f", FILE.join("Build", "Release", "UserlandNSTest"), FILE.join("Build", "Deployment", "UserlandNSTest")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "UserlandNSTest"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "UserlandNSTest"), FILE.join("Build", "Desktop", "UserlandNSTest", "UserlandNSTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "UserlandNSTest", "UserlandNSTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "UserlandNSTest"));
print("----------------------------");
}
@@ -0,0 +1,40 @@
/*
* BorderView.j
* UserlandNSTest
*
* Created by aparajita on April 11, 2012.
* Copyright 2012, The Cappuccino Foundation. All rights reserved.
*/
@import "BorderView.j"
@implementation BorderView (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
borderWidth = BorderViewDefaultBorderWidth;
borderColor = BorderViewDefaultBorderColor;
}
return self;
}
@end
@implementation NS_BorderView : BorderView
+ (Class)classForKeyedArchiver
{
return [BorderView class];
}
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
}
@end
@@ -0,0 +1,5 @@
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;18E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;20E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;32E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;35E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;36E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;32E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;33E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;34E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;35E;D;K;6;CP$UIDd;2;11E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;37E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;12E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;38E;E;D;K;10;$classnameS;31;CPCibRuntimeAttributesConnectorK;8;$classesA;S;31;CPCibRuntimeAttributesConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;36E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;1;0E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;1;0E;K;40;CPCibRuntimeAttributesConnectorObjectKeyD;K;6;CP$UIDd;2;36E;K;42;CPCibRuntimeAttributesConnectorKeyPathsKeyD;K;6;CP$UIDd;2;39E;K;40;CPCibRuntimeAttributesConnectorValuesKeyD;K;6;CP$UIDd;2;40E;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;30E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;1;0E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;1;0E;K;40;CPCibRuntimeAttributesConnectorObjectKeyD;K;6;CP$UIDd;2;30E;K;42;CPCibRuntimeAttributesConnectorKeyPathsKeyD;K;6;CP$UIDd;2;41E;K;40;CPCibRuntimeAttributesConnectorValuesKeyD;K;6;CP$UIDd;2;42E;E;D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;11E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;36E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;43E;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;36E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;32E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;44E;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;36E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;23E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;45E;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;37E;E;D;K;10;$classnameS;20;_CPCibWindowTemplateK;8;$classesA;S;20;_CPCibWindowTemplateS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;22E;K;30;_CPCibWindowTemplateMaxSizeKeyD;K;6;CP$UIDd;2;46E;K;32;_CPCibWindowTemplateViewClassKeyD;K;6;CP$UIDd;1;0E;K;34;_CPCibWindowTemplateWindowClassKeyD;K;6;CP$UIDd;2;47E;K;33;_CPCibWindowTemplateWindowRectKeyD;K;6;CP$UIDd;2;48E;K;30;_CPCibWindowTempatStyleMaskKeyD;K;6;CP$UIDd;2;49E;K;34;_CPCibWindowTemplateWindowTitleKeyD;K;6;CP$UIDd;2;50E;K;33;_CPCibWindowTemplateWindowViewKeyD;K;6;CP$UIDd;2;25E;E;D;K;10;$classnameS;6;CPViewK;8;$classesA;S;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;24E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;51E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;52E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;52E;K;17;CPViewSubviewsKeyD;K;6;CP$UIDd;2;53E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;1;0E;K;19;CPViewThemeStateKeyD;K;6;CPLine truncated
borderWidth: 1
borderColor: #0000ffd;4;3072F;S;23;{{220, 156}, {163, 96}}S;22;{{32, 164}, {183, 88}}S;43;Custom:
borderWidth: 6
borderColor: #006600d;1;1S;23;{{276, 297}, {104, 29}}S;19;{{0, 0}, {104, 29}}S;19;bezeled+placeholderd;1;2S;0;D;K;10;$classnameS;7;CPColorK;8;$classesA;S;7;CPColorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;78E;K;20;CPColorComponentsKeyD;K;6;CP$UIDd;2;99E;E;S;23;{{276, 338}, {104, 29}}S;22;{{32, 301}, {220, 17}}S;19;{{0, 0}, {220, 17}}S;32;Ordinarily this would have focusS;22;{{32, 342}, {234, 17}}S;19;{{0, 0}, {234, 17}}S;37;This gets focus via runtime attributeS;13;AppControllerS;21;initialResponderByTagS;16;undefinedKeyPathS;18;field1.stringValueS;4;oopsS;8;runtime!S;11;borderWidthS;24;borderColorWithHexStringd;1;6S;6;006600S;17;Arial, sans-serifd;2;12D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;72E;D;K;6;CP$UIDd;2;72E;D;K;6;CP$UIDd;2;72E;D;K;6;CP$UIDd;2;72E;E;E;E;K;9;$archiverS;15;CPKeyedArchiverK;8;$versionS;6;100000E;
@@ -0,0 +1,593 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">11D50</string>
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">2182</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSCustomView</string>
<string>NSTextField</string>
<string>NSWindowTemplate</string>
<string>NSView</string>
<string>NSTextFieldCell</string>
<string>NSCustomObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1021">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomObject" id="1014">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1050">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="972006081">
<int key="NSWindowStyleMask">7</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{145, 701}, {428, 398}}</string>
<int key="NSWTFlags">1946157056</int>
<string key="NSWindowTitle">Runtime Attributes &amp; Userland NS Classes</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="439893737">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomView" id="227023416">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{220, 268}, {163, 96}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1024293047"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSClassName">BorderView</string>
</object>
<object class="NSTextField" id="876233018">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{32, 268}, {183, 88}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="227023416"/>
<string key="NSReuseIdentifierKey">_NS:1505</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="779391536">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">272629760</int>
<string type="base64-UTF8" key="NSContents">RGVmYXVsdDoKYm9yZGVyV2lkdGg6IDEKYm9yZGVyQ29sb3I6ICMwMDAwZmY</string>
<object class="NSFont" key="NSSupport" id="669420959">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:1505</string>
<reference key="NSControlView" ref="876233018"/>
<object class="NSColor" key="NSBackgroundColor" id="920385912">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="380872025">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<object class="NSColor" key="NSColor" id="145079232">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
</object>
<object class="NSCustomView" id="440595587">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{220, 146}, {163, 96}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="497625231"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSClassName">BorderView</string>
</object>
<object class="NSTextField" id="1024293047">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{32, 146}, {183, 88}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="440595587"/>
<string key="NSReuseIdentifierKey">_NS:1505</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="493023028">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">272629760</int>
<string type="base64-UTF8" key="NSContents">Q3VzdG9tOgpib3JkZXJXaWR0aDogNgpib3JkZXJDb2xvcjogIzAwNjYwMA</string>
<reference key="NSSupport" ref="669420959"/>
<string key="NSCellIdentifier">_NS:1505</string>
<reference key="NSControlView" ref="1024293047"/>
<reference key="NSBackgroundColor" ref="920385912"/>
<reference key="NSTextColor" ref="380872025"/>
</object>
</object>
<object class="NSTextField" id="962979951">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{282, 75}, {96, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="451437546"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="524591192">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="669420959"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="962979951"/>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSColor" key="NSBackgroundColor" id="777858718">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="321260064">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textColor</string>
<reference key="NSColor" ref="145079232"/>
</object>
</object>
</object>
<object class="NSTextField" id="518018247">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{282, 34}, {96, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<int key="NSTag">2</int>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="689202424">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="669420959"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="518018247"/>
<bool key="NSDrawsBackground">YES</bool>
<reference key="NSBackgroundColor" ref="777858718"/>
<reference key="NSTextColor" ref="321260064"/>
</object>
</object>
<object class="NSTextField" id="497625231">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{32, 80}, {220, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="962979951"/>
<string key="NSReuseIdentifierKey">_NS:1505</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="414228525">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">Ordinarily this would have focus</string>
<reference key="NSSupport" ref="669420959"/>
<string key="NSCellIdentifier">_NS:1505</string>
<reference key="NSControlView" ref="497625231"/>
<reference key="NSBackgroundColor" ref="920385912"/>
<reference key="NSTextColor" ref="380872025"/>
</object>
</object>
<object class="NSTextField" id="451437546">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{32, 39}, {234, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="518018247"/>
<string key="NSReuseIdentifierKey">_NS:1505</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="951303157">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">This gets focus via runtime attribute</string>
<reference key="NSSupport" ref="669420959"/>
<string key="NSCellIdentifier">_NS:1505</string>
<reference key="NSControlView" ref="451437546"/>
<reference key="NSBackgroundColor" ref="920385912"/>
<reference key="NSTextColor" ref="380872025"/>
</object>
</object>
</object>
<string key="NSFrameSize">{428, 398}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="876233018"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
<object class="NSCustomObject" id="635946545">
<string key="NSClassName">AppController</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="635946545"/>
</object>
<int key="connectionID">451</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">theWindow</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="972006081"/>
</object>
<int key="connectionID">459</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">field1</string>
<reference key="source" ref="635946545"/>
<reference key="destination" ref="962979951"/>
</object>
<int key="connectionID">474</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1048"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1021"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1014"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1050"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">371</int>
<reference key="object" ref="972006081"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="439893737"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">372</int>
<reference key="object" ref="439893737"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="227023416"/>
<reference ref="876233018"/>
<reference ref="440595587"/>
<reference ref="1024293047"/>
<reference ref="962979951"/>
<reference ref="518018247"/>
<reference ref="497625231"/>
<reference ref="451437546"/>
</object>
<reference key="parent" ref="972006081"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">450</int>
<reference key="object" ref="635946545"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">460</int>
<reference key="object" ref="227023416"/>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">461</int>
<reference key="object" ref="876233018"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="779391536"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">462</int>
<reference key="object" ref="779391536"/>
<reference key="parent" ref="876233018"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">463</int>
<reference key="object" ref="440595587"/>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">464</int>
<reference key="object" ref="1024293047"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="493023028"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">465</int>
<reference key="object" ref="493023028"/>
<reference key="parent" ref="1024293047"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">466</int>
<reference key="object" ref="962979951"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="524591192"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">467</int>
<reference key="object" ref="524591192"/>
<reference key="parent" ref="962979951"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">468</int>
<reference key="object" ref="518018247"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="689202424"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">469</int>
<reference key="object" ref="689202424"/>
<reference key="parent" ref="518018247"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">470</int>
<reference key="object" ref="497625231"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="414228525"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">471</int>
<reference key="object" ref="414228525"/>
<reference key="parent" ref="497625231"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">472</int>
<reference key="object" ref="451437546"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="951303157"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">473</int>
<reference key="object" ref="951303157"/>
<reference key="parent" ref="451437546"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>371.IBAttributePlaceholdersKey</string>
<string>371.IBPluginDependency</string>
<string>371.IBWindowTemplateEditedContentRect</string>
<string>371.NSWindowTemplate.visibleAtLaunch</string>
<string>372.IBPluginDependency</string>
<string>450.IBAttributePlaceholdersKey</string>
<string>450.IBPluginDependency</string>
<string>460.IBPluginDependency</string>
<string>461.IBPluginDependency</string>
<string>462.IBPluginDependency</string>
<string>463.IBAttributePlaceholdersKey</string>
<string>463.IBPluginDependency</string>
<string>464.IBPluginDependency</string>
<string>465.IBPluginDependency</string>
<string>466.IBPluginDependency</string>
<string>467.IBPluginDependency</string>
<string>468.IBPluginDependency</string>
<string>469.IBPluginDependency</string>
<string>470.IBPluginDependency</string>
<string>471.IBPluginDependency</string>
<string>472.IBPluginDependency</string>
<string>473.IBPluginDependency</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{303, 221}, {480, 360}}</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">IBUserDefinedRuntimeAttributesPlaceholderName</string>
<object class="IBUserDefinedRuntimeAttributesPlaceholder" key="NS.object.0">
<string key="name">IBUserDefinedRuntimeAttributesPlaceholderName</string>
<reference key="object" ref="635946545"/>
<object class="NSArray" key="userDefinedRuntimeAttributes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUserDefinedRuntimeAttribute">
<string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.number</string>
<string key="keyPath">initialResponderByTag</string>
<real value="2" key="value"/>
</object>
<object class="IBUserDefinedRuntimeAttribute">
<string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.string</string>
<string key="keyPath">undefinedKeyPath</string>
<string key="value">oops</string>
</object>
<object class="IBUserDefinedRuntimeAttribute">
<string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.string</string>
<string key="keyPath">field1.stringValue</string>
<string key="value">runtime!</string>
</object>
</object>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">IBUserDefinedRuntimeAttributesPlaceholderName</string>
<object class="IBUserDefinedRuntimeAttributesPlaceholder" key="NS.object.0">
<string key="name">IBUserDefinedRuntimeAttributesPlaceholderName</string>
<reference key="object" ref="440595587"/>
<object class="NSArray" key="userDefinedRuntimeAttributes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUserDefinedRuntimeAttribute">
<string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.number</string>
<string key="keyPath">borderWidth</string>
<real value="6" key="value"/>
</object>
<object class="IBUserDefinedRuntimeAttribute">
<string key="typeIdentifier">com.apple.InterfaceBuilder.userDefinedRuntimeAttributeType.string</string>
<string key="keyPath">borderColorWithHexString</string>
<string key="value">006600</string>
</object>
</object>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">474</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">AppController</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">field1</string>
<string key="NS.object.0">NSTextField</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">field1</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">field1</string>
<string key="candidateClassName">NSTextField</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/AppController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">BorderView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/BorderView.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,107 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
UserlandNSTest
Created by aparajita on April 11, 2012.
Copyright 2012, Victory-Heart Productions All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>UserlandNSTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading UserlandNSTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
+77
View File
@@ -0,0 +1,77 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
UserlandNSTest
Created by aparajita on April 11, 2012.
Copyright 2012, Victory-Heart Productions All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>UserlandNSTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading UserlandNSTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* UserlandNSTest
*
* Created by aparajita on April 11, 2012.
* Copyright 2012, Victory-Heart Productions All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
+1
View File
@@ -0,0 +1 @@
-v -v
+7 -8
View File
@@ -40,18 +40,16 @@ ConverterConversionException = @"ConverterConversionException";
@implementation Converter : CPObject
{
CPString inputPath @accessors(readonly);
CPString outputPath @accessors;
CPString resourcesPath @accessors;
NibFormat format @accessors(readonly);
CPArray themes @accessors(readonly);
CPString inputPath @accessors(readonly);
CPString outputPath @accessors;
CPString resourcesPath @accessors;
NibFormat format @accessors(readonly);
CPArray themes @accessors(readonly);
CPArray userNSClasses @accessors;
}
+ (Converter)sharedConverter
{
if (!SharedConverter)
SharedConverter = [[Converter alloc] init];
return SharedConverter;
}
@@ -61,6 +59,7 @@ ConverterConversionException = @"ConverterConversionException";
if (self)
{
SharedConverter = self;
inputPath = aPath;
format = nibFormat;
themes = themeList;
+67 -4
View File
@@ -1,3 +1,26 @@
/*
* NSClassSwapper.j
* nib2cib
*
* Created by Francisco Tolmasky
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "Converter.j"
var NSClassSwapperClassNames = {},
NSClassSwapperOriginalClassNames = {};
@@ -16,15 +39,38 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
if (!swapperClass)
{
var originalClass = objj_lookUpClass(anOriginalClassName);
// If this is a userland NS class, call its KVC methods directly
var nsClass = nil;
if ([[[Converter sharedConverter] userNSClasses] containsObject:aClassName])
nsClass = objj_lookUpClass("NS_" + aClassName);
var originalClass = nsClass || objj_lookUpClass(anOriginalClassName);
swapperClass = objj_allocateClassPair(originalClass, swapperClassName);
objj_registerClassPair(swapperClass);
/*
When calling userland KVC methods, they should think that the class is
the NS class (not the swapper class) so that they are in their userland space,
not in AppKit space. For example, this ensures that bundleForClass:[self class] will work correctly.
We can accomplish this safely by changing the class of self temporarily and sending directly
to self instead of to super. This swizzle is safe because NSClassSwapper and _CPCibClassSwapper
do not add any ivars.
*/
class_addMethod(swapperClass, @selector(initWithCoder:), function(self, _cmd, aCoder)
{
self = objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
if (nsClass)
{
// Switch to userland temporarily
self.isa = nsClass;
self = objj_msgSend(self, _cmd, aCoder);
self.isa = swapperClass;
}
else
self = objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
if (self)
{
@@ -44,9 +90,26 @@ var _CPCibClassSwapperClassNameKey = @"_CPCibClassSwapperClassNameKey",
class_addMethod(swapperClass, @selector(encodeWithCoder:), function(self, _cmd, aCoder)
{
objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
if (nsClass)
{
// Switch to userland temporarily
self.isa = nsClass;
objj_msgSend(self, _cmd, aCoder);
self.isa = swapperClass;
}
else
objj_msgSendSuper({super_class:originalClass, receiver:self}, _cmd, aCoder);
// If this is a custom NS class, lookup its archiver class so that
// the correct class is swapped during unarchiving.
if (nsClass)
{
var classForArchiver = objj_msgSend(nsClass, "classForKeyedArchiver");
if (classForArchiver)
aClassName = [classForArchiver className];
}
// FIXME: map class name as well?
[aCoder encodeObject:aClassName forKey:_CPCibClassSwapperClassNameKey];
[aCoder encodeObject:CP_NSMapClassName(anOriginalClassName) forKey:_CPCibClassSwapperOriginalClassNameKey];
}, "");
+1
View File
@@ -26,6 +26,7 @@
@import "NSExpression.j"
@import "NSFormatter.j"
@import "NSMutableString.j"
@import "NSNull.j"
@import "NSNumberFormatter.j"
@import "NSSet.j"
+1 -8
View File
@@ -83,13 +83,6 @@ NSImageFrameGrayBezel = 2;
NSImageFrameGroove = 3;
NSImageFrameButton = 4;
var NSImageScalingToCPImageScaling = {};
NSImageScalingToCPImageScaling[NSImageScaleProportionallyDown] = CPScaleProportionally;
NSImageScalingToCPImageScaling[NSImageScaleAxesIndependently] = CPScaleToFit;
NSImageScalingToCPImageScaling[NSImageScaleNone] = CPScaleNone;
NSImageScalingToCPImageScaling[NSImageScaleProportionallyUpOrDown] = CPScaleProportionally;
@implementation NSImageCell : NSCell
{
BOOL _animates @accessors;
@@ -106,7 +99,7 @@ NSImageScalingToCPImageScaling[NSImageScaleProportionallyUpOrDown] = CPScalePro
{
_animates = [aCoder decodeBoolForKey:@"NSAnimates"];
_imageAlignment = [aCoder decodeIntForKey:@"NSAlign"];
_imageScaling = NSImageScalingToCPImageScaling[[aCoder decodeIntForKey:@"NSScale"]];
_imageScaling = [aCoder decodeIntForKey:@"NSScale"];
_frameStyle = [aCoder decodeIntForKey:@"NSStyle"];
}
+47 -1
View File
@@ -23,6 +23,7 @@
@import <AppKit/CPCibConnector.j>
@import <AppKit/CPCibControlConnector.j>
@import <AppKit/CPCibOutletConnector.j>
@import <AppKit/CPCibRuntimeAttributesConnector.j>
NIB_CONNECTION_EQUIVALENCY_TABLE = {};
@@ -53,7 +54,8 @@ NIB_CONNECTION_EQUIVALENCY_TABLE = {};
_destination = NIB_CONNECTION_EQUIVALENCY_TABLE[destinationUID];
}
CPLog.debug(@"NSNibConnector: connection: " + [_source description] + " " + [_destination description] + " " + _label);
if (_source && _destination)
CPLog.debug(@"NSNibConnector: connection: " + [_source description] + " " + [_destination description] + " " + _label);
}
return self;
@@ -167,3 +169,47 @@ var NSTransformers = [CPSet setWithObjects:
}
@end
@implementation CPCibRuntimeAttributesConnector (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
_source = [aCoder decodeObjectForKey:@"NSObject"];
_keyPaths = [aCoder decodeObjectForKey:@"NSKeyPaths"];
_values = [aCoder decodeObjectForKey:@"NSValues"];
var count = [_keyPaths count];
CPLog.debug(@"NSNibConnector: runtime attributes connector: " + [_source description]);
while (count--)
{
var value = _values[count],
type = typeof(value) === "boolean" ? "BOOL" : [value className];
CPLog.debug(@" %s (%s): %s", _keyPaths[count], type, value);
}
}
return self;
}
@end
@implementation NSIBUserDefinedRuntimeAttributesConnector : CPCibRuntimeAttributesConnector
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
}
- (Class)classForKeyedArchiver
{
return [CPCibRuntimeAttributesConnector class];
}
@end
+37
View File
@@ -0,0 +1,37 @@
/*
* NSNull.j
* nib2cib
*
* Created by Aparajita Fishman.
* Copyright 2012 The Cappuccino Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPNull.j>
@implementation NSNull : CPNull
- (id)initWithCoder:(CPCoder)aCoder
{
return [CPNull null];
}
- (Class)classForKeyedArchiver
{
return [CPNull class];
}
@end
+1
View File
@@ -68,6 +68,7 @@ var NSViewAutoresizingMask = 0x3F,
_isHidden = vFlags & NSViewHiddenMask;
_opacity = 1.0;//[aCoder decodeIntForKey:CPViewOpacityKey];
_themeClass = [self themeClass];
_themeAttributes = {};
_themeState = CPThemeStateNormal;
[self _loadThemeAttributes];
+952
View File
@@ -0,0 +1,952 @@
/*
* Nib2Cib.j
* nib2cib
*
* Created by Francisco Tolmasky and Aparajita Fishman.
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import <BlendKit/BlendKit.j>
@import "NSFoundation.j"
@import "NSAppKit.j"
@import "Nib2CibKeyedUnarchiver.j"
@import "Converter.j"
var FILE = require("file"),
OS = require("os"),
SYS = require("system"),
FileList = require("jake").FileList,
stream = require("narwhal/term").stream,
StaticResource = require("objective-j").StaticResource,
DefaultTheme = "Aristo",
BuildTypes = ["Debug", "Release"],
DefaultFile = "MainMenu",
AllowedStoredOptionsRe = new RegExp("^(defaultTheme|auxThemes|verbosity|quiet|frameworks|format)$");
ArgsRe = /"[^\"]+"|'[^\']+'|\S+/g;
@implementation Nib2Cib : CPObject
{
CPArray commandLineArgs;
JSObject parser;
JSObject nibInfo;
CPString appDirectory;
CPString resourcesDirectory;
CPDictionary infoPlist;
CPArray userNSClasses;
}
- (id)initWithArgs:(CPArray)theArgs
{
self = [super init];
if (self)
{
commandLineArgs = theArgs;
parser = new (require("narwhal/args").Parser)();
nibInfo = {};
appDirectory = @"";
resourcesDirectory = @"";
infoPlist = [CPDictionary dictionary];
userNSClasses = [];
}
return self;
}
- (void)run
{
try
{
var options = [self parseOptionsFromArgs:commandLineArgs];
[self setLogLevel:options.quiet ? -1 : options.verbosity];
if (options.watch)
[self watchWithOptions:options];
else
[self convertWithOptions:options inputFile:nil];
}
catch (anException)
{
CPLog.fatal([self exceptionReason:anException]);
OS.exit(1);
}
}
- (BOOL)convertWithOptions:(JSObject)options inputFile:(CPString)inputFile
{
try
{
inputFile = inputFile || [self getInputFile:options.args];
[self getAppAndResourceDirectoriesFromInputFile:inputFile options:options];
if (options.readStoredOptions)
{
options = [self mergeOptionsWithStoredOptions:options inputFile:inputFile];
[self setLogLevel:options.quiet ? -1 : options.verbosity];
}
if (!options.quiet && options.verbosity > 0)
[self printVersion];
var outputFile = [self getOutputFileFromInputFile:inputFile args:options.args],
configInfo = [self readConfigFile:options.configFile || @"" inputFile:inputFile];
infoPlist = configInfo.plist;
if (infoPlist)
{
var systemFontFace = [infoPlist valueForKey:@"CPSystemFontFace"];
if (systemFontFace)
[CPFont setSystemFontFace:systemFontFace];
var systemFontSize = [infoPlist valueForKey:@"CPSystemFontSize"];
if (systemFontSize)
[CPFont setSystemFontSize:parseFloat(systemFontSize, 10)];
}
var themeList = [self getThemeList:options],
themes = [self loadThemesFromList:themeList];
CPLog.info("\n-------------------------------------------------------------");
CPLog.info("Input : " + inputFile);
CPLog.info("Output : " + outputFile);
CPLog.info("Format : " + ["Auto", "Mac", "iPhone"][options.format]);
CPLog.info("Application : " + appDirectory);
CPLog.info("Resources : " + resourcesDirectory);
CPLog.info("Frameworks : " + (options.frameworks || ""));
CPLog.info("Default theme : " + themeList[0]);
CPLog.info("Aux themes : " + themeList.slice(1).join(", "));
CPLog.info("Config file : " + (configInfo.path || ""));
CPLog.info("System Font : " + [CPFont systemFontSize] + "px " + [CPFont systemFontFace]);
CPLog.info("-------------------------------------------------------------\n");
var converter = [[Converter alloc] initWithInputPath:inputFile
format:options.format
themes:themes];
[converter setOutputPath:outputFile];
[converter setResourcesPath:resourcesDirectory];
var loadFrameworksCallback = function()
{
[self loadNSClassesFromBundle:[CPBundle mainBundle]];
[converter setUserNSClasses:userNSClasses];
[converter convert];
};
[self loadFrameworks:options.frameworks verbosity:options.verbosity callback:loadFrameworksCallback];
return YES;
}
catch (anException)
{
CPLog.fatal([self exceptionReason:anException]);
return NO;
}
}
- (void)watchWithOptions:(JSObject)options
{
var verbosity = options.quiet ? -1 : options.verbosity,
watchDir = options.args[0];
if (!watchDir)
watchDir = FILE.canonical(FILE.isDirectory("Resources") ? "Resources" : ".");
else
{
watchDir = FILE.canonical(watchDir);
if (FILE.basename(watchDir) !== "Resources")
{
var path = FILE.join(watchDir, "Resources");
if (FILE.isDirectory(path))
watchDir = path;
}
}
if (!FILE.isDirectory(watchDir))
[self failWithMessage:@"Cannot find the directory: " + watchDir];
// Turn on info messages
[self setLogLevel:1];
var nibs = new FileList(FILE.join(watchDir, "*.[nx]ib")).items(),
count = nibs.length;
// First time through only IB files with no corresponding cib
// or a cib with an earlier or equal mtime are converted.
while (count--)
{
var nib = nibs[count],
cib = nib.substr(0, nib.length - 4) + ".cib";
if (FILE.exists(cib) && (FILE.mtime(nib) - FILE.mtime(cib)) <= 0)
nibInfo[nib] = FILE.mtime(nib);
}
CPLog.info("Watching: " + CPLogColorize(watchDir, "debug"));
CPLog.info("Press Control-C to stop...");
while (true)
{
var modifiedNibs = [self getModifiedNibsInDirectory:watchDir];
for (var i = 0; i < modifiedNibs.length; ++i)
{
var action = modifiedNibs[i][0],
nib = modifiedNibs[i][1],
label = action === "add" ? "Added" : "Modified",
level = action === "add" ? "info" : "debug";
CPLog.info(">> %s: %s", CPLogColorize(label, level), nib);
// Don't convert an add if there is an existing cib with a later mtime
if (action === "add")
{
var cib = nib.substr(0, nib.length - 4) + ".cib";
if (FILE.exists(cib) && (FILE.mtime(nib) - FILE.mtime(cib)) < 0)
continue;
}
// Let the converter log however the user configured it
[self setLogLevel:verbosity];
var success = [self convertWithOptions:options inputFile:nib];
[self setLogLevel:1];
if (success)
{
if (verbosity > 0)
stream.print();
else
CPLog.warn("Conversion successful");
}
}
OS.sleep(1);
}
}
- (JSObject)parseOptionsFromArgs:(CPArray)theArgs
{
parser.usage("[--watch DIRECTORY] [INPUT_FILE [OUTPUT_FILE]]");
parser.option("--watch", "watch")
.set(true)
.help("Ask nib2cib to watch a directory for changes");
parser.option("-R", "resourcesDir")
.set()
.displayName("directory")
.help("Set the Resources directory, usually unnecessary as it is inferred from the input path");
parser.option("--default-theme", "defaultTheme")
.set()
.displayName("name")
.help("Specify a custom default theme which is not set in your Info.plist");
parser.option("-t", "--theme", "auxThemes")
.push()
.displayName("name")
.help("An additional theme loaded dynamically by your application");
parser.option("--config", "configFile")
.set()
.displayName("path")
.help("A path to an Info.plist file from which the system font and/or size can be retrieved");
parser.option("-v", "--verbose", "verbosity")
.inc()
.help("Increase verbosity level");
parser.option("-q", "--quiet", "quiet")
.set(true)
.help("No output");
parser.option("-F", "--framework", "frameworks")
.push()
.help("Add a framework to load");
parser.option("--no-stored-options", "readStoredOptions")
.set(false)
.def(true)
.help("Do not read stored options");
parser.option("--mac", "format")
.set(NibFormatMac)
.def(NibFormatUndetermined)
.help("Set format to Mac");
parser.option("--version", "showVersion")
.action(function() { [self printVersionAndExit]; })
.help("Show the version of nib2cib and quit");
parser.helpful();
var options = parser.parse(theArgs, null, null, true);
if (options.args.length > 2)
{
parser.printUsage(options);
OS.exit(0);
}
return options;
}
- (JSObject)mergeOptionsWithStoredOptions:(JSObject)options inputFile:(CPString)inputFile
{
// We have to clone options
var userOptions = [self readStoredOptionsAtPath:FILE.join(SYS.env["HOME"], ".nib2cibconfig")],
appOptions = [self readStoredOptionsAtPath:FILE.join(appDirectory, "nib2cib.conf")],
filename = FILE.basename(inputFile, FILE.extension(inputFile)) + ".conf",
fileOptions = [self readStoredOptionsAtPath:FILE.join(FILE.dirname(inputFile), filename)];
// At this point we have an array of args without the initial command in args[0],
// add the command and parse the options.
userOptions = [self parseOptionsFromArgs:[options.command].concat(userOptions)];
appOptions = [self parseOptionsFromArgs:[options.command].concat(appOptions)];
fileOptions = [self parseOptionsFromArgs:[options.command].concat(fileOptions)];
// The increasing order of precedence is: user -> app -> file -> command line
var mergedOptions = userOptions;
[self mergeOptions:appOptions with:mergedOptions];
[self mergeOptions:fileOptions with:mergedOptions];
[self mergeOptions:options with:mergedOptions];
mergedOptions.args = options.args;
return mergedOptions;
}
- (CPArray)readStoredOptionsAtPath:(CPString)path
{
path = FILE.canonical(path);
if (!FILE.isReadable(path))
return [];
var file = FILE.open(path, "r"),
line = file.readLine(),
matches = line.match(ArgsRe) || [];
file.close();
CPLog.debug("Reading stored options: " + path);
if (matches)
{
for (var i = 0; i < matches.length; ++i)
{
var str = matches[i];
if ((str.charAt(0) === '"' && str.substr(-1) === '"') || (str.charAt(0) === "'" && str.substr(-1) === "'"))
matches[i] = str.substr(1, str.length - 2);
}
return matches;
}
else
return [];
}
- (void)printOptions:options
{
for (option in options)
{
var value = options[option];
if (value)
{
var show = value.length !== undefined ? value.length > 0 : !!value;
if (show)
print(option + ": " + value);
}
}
}
// Merges properties in sourceOptions into targetOptions, overriding properties in targetOptions
- (void)mergeOptions:(JSObject)sourceOptions with:(JSObject)targetOptions
{
for (option in sourceOptions)
{
// Make sure only a supported option is given
if (!AllowedStoredOptionsRe.test(option))
continue;
if (sourceOptions.hasOwnProperty(option))
{
var value = sourceOptions[option];
if (value)
{
var copy = value.length !== undefined ? value.length > 0 : !!value;
if (copy)
targetOptions[option] = value;
}
}
}
}
- (void)setLogLevel:(int)level
{
CPLogUnregister(CPLogPrint);
if (level === 0)
CPLogRegister(CPLogPrint, "warn", logFormatter);
else if (level === 1)
CPLogRegister(CPLogPrint, "info", logFormatter);
else if (level > 1)
CPLogRegister(CPLogPrint, null, logFormatter);
}
- (CPString)getInputFile:(CPArray)theArgs
{
var inputFile = theArgs[0] || DefaultFile,
path = "";
if (!/^.+\.[nx]ib$/.test(inputFile))
{
if (path = [self findInputFile:inputFile extension:@".xib"])
inputFile = path;
else if (path = [self findInputFile:inputFile extension:@".nib"])
inputFile = path;
else
[self failWithMessage:@"Cannot find the input file (.xib or .nib): " + FILE.canonical(inputFile)];
}
else if (path = [self findInputFile:inputFile extension:nil])
inputFile = path;
else
[self failWithMessage:@"Could not read the input file: " + FILE.canonical(inputFile)];
return FILE.canonical(inputFile);
}
- (void)findInputFile:(CPString)inputFile extension:(CPString)extension
{
var path = inputFile;
if (extension)
path += extension;
if (FILE.isReadable(path))
return path;
if (FILE.basename(FILE.dirname(inputFile)) !== "Resources" && FILE.isDirectory("Resources"))
{
path = FILE.resolve(path, FILE.join("Resources", FILE.basename(path)));
if (FILE.isReadable(path))
return path;
}
return null;
}
- (void)getAppAndResourceDirectoriesFromInputFile:(CPString)inputFile options:(JSObject)options
{
appDirectory = resourcesDirectory = "";
if (options.resourcesDir)
{
var path = FILE.canonical(options.resourcesDir);
if (!FILE.isDirectory(path))
[self failWithMessage:@"Cannot read resources at: " + path];
resourcesDirectory = path;
}
var parentDir = FILE.dirname(inputFile);
if (FILE.basename(parentDir) === "Resources")
{
appDirectory = FILE.dirname(parentDir);
resourcesDirectory = resourcesDirectory || parentDir;
}
else
{
appDirectory = parentDir;
if (!resourcesDirectory)
{
var path = FILE.join(appDirectory, "Resources");
if (FILE.isDirectory(path))
resourcesDirectory = path;
}
}
}
- (CPString)getOutputFileFromInputFile:(CPString)inputFile args:(CPArray)theArgs
{
var outputFile = null;
if (theArgs.length > 1)
{
outputFile = theArgs[1];
if (!/^.+\.cib$/.test(outputFile))
outputFile += ".cib";
}
else
outputFile = FILE.join(FILE.dirname(inputFile), FILE.basename(inputFile, FILE.extension(inputFile))) + ".cib";
outputFile = FILE.canonical(outputFile);
if (!FILE.isWritable(FILE.dirname(outputFile)))
[self failWithMessage:@"Cannot write the output file at: " + outputFile];
return outputFile;
}
- (void)loadFrameworks:(CPArray)frameworks verbosity:(int)verbosity callback:(JSObject)aCallback
{
if (!frameworks || frameworks.length === 0)
return aCallback();
var returnPath = function(path) { return path; };
frameworks.forEach(function(aFramework)
{
[self setLogLevel:verbosity];
var frameworkPath = nil;
// If it is just a name with no path components, try to locate it
if (aFramework.indexOf("/") === -1)
{
frameworkPath = [self findInCappBuild:aFramework isDirectory:YES callback:returnPath];
if (!frameworkPath)
frameworkPath = [self findInFrameworks:FILE.join(appDirectory, "Frameworks")
path:aFramework
isDirectory:YES
callback:returnPath];
if (!frameworkPath)
frameworkPath = [self findInInstalledFrameworks:aFramework isDirectory:YES callback:returnPath];
}
else
frameworkPath = FILE.canonical(aFramework);
if (!frameworkPath)
[self failWithMessage:@"Cannot find the framework \"" + aFramework + "\""];
CPLog.debug("Loading framework: " + frameworkPath);
try
{
// CPBundle is a bit loquacious with logging, we will defer
// logging its exceptions till later.
[self setLogLevel:-1];
var frameworkBundle = [[CPBundle alloc] initWithPath:frameworkPath];
[frameworkBundle loadWithDelegate:nil];
[self setLogLevel:verbosity];
[self loadNSClassesFromBundle:frameworkBundle];
}
finally
{
[self setLogLevel:verbosity];
}
require("browser/timeout").serviceTimeouts();
});
aCallback();
}
- (void)loadNSClassesFromBundle:(CPBundle)aBundle
{
// See if the framework defines NS classes
var nsClasses = [aBundle objectForInfoDictionaryKey:@"NSClasses"] || [],
bundlePath = [aBundle bundlePath];
for (var i = 0; i < nsClasses.length; ++i)
{
if (userNSClasses.indexOf(nsClasses[i]) >= 0)
continue;
var path = FILE.join(bundlePath, "NS_" + nsClasses[i] + ".j");
objj_importFile(path, YES);
CPLog.debug("Imported NS class: %s", path);
userNSClasses.push(nsClasses[i]);
}
}
- (CPArray)getThemeList:(JSObject)options
{
var defaultTheme = options.defaultTheme;
if (!defaultTheme)
defaultTheme = [infoPlist valueForKey:@"CPDefaultTheme"];
if (!defaultTheme)
defaultTheme = [self getAppKitDefaultThemeName];
var themes = [CPSet setWithObject:defaultTheme];
if (options.auxThemes)
[themes addObjectsFromArray:options.auxThemes];
var auxThemes = infoPlist.valueForKey("CPAuxiliaryThemes");
if (auxThemes)
[themes addObjectsFromArray:auxThemes];
// Now remove the default theme, get the list as an array, and insert the default at the beginning
[themes removeObject:defaultTheme];
var allThemes = [themes allObjects];
[allThemes insertObject:defaultTheme atIndex:0];
return allThemes;
}
// Returns undefined if $CAPP_BUILD is not defined, false if path cannot be found in $CAPP_BUILD
- (id)findInCappBuild:(CPString)path isDirectory:(BOOL)isDirectory callback:(JSObject)callback
{
var cappBuild = SYS.env["CAPP_BUILD"];
if (!cappBuild)
return undefined;
cappBuild = FILE.canonical(cappBuild);
if (FILE.isDirectory(cappBuild))
{
var result = null;
for (var i = 0; i < BuildTypes.length && !result; ++i)
{
var findPath = FILE.join(cappBuild, BuildTypes[i], path);
if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath)))
result = callback(findPath);
}
return result;
}
else
return false;
}
- (id)findInInstalledFrameworks:(CPString)path isDirectory:(BOOL)isDirectory callback:(JSObject)callback
{
// NOTE: It's safe to use '/' directly in the path, we're guaranteed to be on a Mac
return [self findInFrameworks:FILE.canonical(FILE.join(SYS.prefix, "packages/cappuccino/Frameworks"))
path:path
isDirectory:isDirectory
callback:callback];
}
- (id)findInFrameworks:(CPString)frameworksPath path:(CPString)path isDirectory:(BOOL)isDirectory callback:(JSObject)callback
{
var result = null,
findPath = FILE.join(frameworksPath, "Debug", path);
if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath)))
result = callback(findPath);
if (!result)
{
findPath = FILE.join(frameworksPath, path);
if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath)))
result = callback(findPath);
}
return result;
}
- (CPString)getAppKitDefaultThemeName
{
var callback = function(path) { return [self themeNameFromPropertyList:path]; },
themeName = [self findInCappBuild:@"AppKit/Info.plist" isDirectory:NO callback:callback];
if (!themeName)
themeName = [self findInInstalledFrameworks:@"AppKit/Info.plist" isDirectory:NO callback:callback];
return themeName || DefaultTheme;
}
- (CPString)themeNameFromPropertyList:(CPString)path
{
if (!FILE.isReadable(path))
return nil;
var themeName = nil,
plist = CFPropertyList.readPropertyListFromFile(path);
if (plist)
themeName = plist.valueForKey("CPDefaultTheme");
return themeName;
}
- (CPArray)loadThemesFromList:(CPArray)themeList
{
var themes = [];
for (var i = 0; i < themeList.length; ++i)
themes.push([self loadThemeNamed:themeList[i] directory:resourcesDirectory]);
return themes;
}
- (CPTheme)loadThemeNamed:(CPString)themeName directory:(CPString)themeDir
{
if (/^.+\.blend$/.test(themeName))
themeName = themeName.substr(0, themeName.length - ".blend".length);
var blendName = themeName + ".blend",
themePath = "";
if (themeDir)
{
themePath = FILE.join(FILE.canonical(themeDir), blendName);
if (!FILE.isDirectory(themePath))
themePath = themeDir = null;
}
if (!themeDir)
{
var returnPath = function(path) { return path; };
themePath = [self findInCappBuild:blendName isDirectory:YES callback:returnPath];
if (!themePath)
themePath = [self findInInstalledFrameworks:@"AppKit/Resources/" + blendName isDirectory:YES callback:returnPath];
// Last resort, try the cwd
if (!themePath)
{
var path = FILE.canonical(blendName);
if (FILE.isDirectory(path))
themePath = path;
}
}
if (!themePath)
[self failWithMessage:@"Cannot find the theme \"" + themeName + "\""];
return [self readThemeWithName:themeName atPath:themePath];
}
- (CPTheme)readThemeWithName:(CPString)name atPath:(CPString)path
{
var themeBundle = new CFBundle(path);
// By default when we try to load the bundle it will use the CommonJS environment,
// but we want the Browser environment. So we override mostEligibleEnvironment().
themeBundle.mostEligibleEnvironment = function() { return "Browser"; }
themeBundle.load();
var keyedThemes = themeBundle.valueForInfoDictionaryKey("CPKeyedThemes");
if (!keyedThemes)
[self failWithMessage:@"Could not find the keyed themes in the theme: " + path];
var index = keyedThemes.indexOf(name + ".keyedtheme");
if (index < 0)
[self failWithMessage:@"Could not find the main theme data (" + name + ".keyedtheme" + ") in the theme: " + path];
// Load the keyed theme data, making sure to resolve it
var resourcePath = themeBundle.pathForResource(keyedThemes[index]),
themeData = new CFMutableData();
themeData.setRawString(StaticResource.resourceAtURL(new CFURL(resourcePath), true).contents());
var theme = [CPKeyedUnarchiver unarchiveObjectWithData:themeData];
if (!theme)
[self failWithMessage:@"Could not unarchive the theme at: " + path];
CPLog.debug("Loaded theme: " + path);
return theme;
}
- (JSObject)readConfigFile:(CPString)configFile inputFile:(CPString)inputFile
{
var configPath = null,
path;
// First see if the user passed a config file path
if (configFile)
{
path = FILE.canonical(configFile);
if (!FILE.isReadable(path))
[self failWithMessage:@"Cannot find the config file: " + path];
configPath = path;
}
else
{
path = FILE.join(appDirectory, "Info.plist");
if (FILE.isReadable(path))
configPath = path;
}
var plist = null;
if (configPath)
{
var plist = FILE.read(configPath);
if (!plist)
[self failWithMessage:@"Could not read the Info.plist at: " + configPath];
plist = CFPropertyList.propertyListFromString(plist);
if (!plist)
[self failWithMessage:@"Could not parse the Info.plist at: " + configPath];
}
return {path: configPath, plist: plist};
}
- (CPArray)getModifiedNibsInDirectory:(CPString)path
{
var nibs = new FileList(FILE.join(path, "*.[nx]ib")).items(),
count = nibs.length,
newNibInfo = {},
modifiedNibs = [];
while (count--)
{
var nib = nibs[count];
newNibInfo[nib] = FILE.mtime(nib);
if (!nibInfo.hasOwnProperty(nib))
modifiedNibs.push(["add", nib]);
else
{
if (newNibInfo[nib] - nibInfo[nib] !== 0)
modifiedNibs.push(["mod", nib]);
// Remove matching nibs so that we leave
// deleted nibs in nibInfo.
delete nibInfo[nib];
}
}
for (var nib in nibInfo)
if (nibInfo.hasOwnProperty(nib))
CPLog.info(">> %s: %s", CPLogColorize("Deleted", "warn"), nib);
nibInfo = newNibInfo;
return modifiedNibs;
}
- (void)printVersionAndExit
{
[self printVersion];
OS.exit(0);
}
- (void)printVersion
{
/*
There are two usual possibilities for the location of the nib2cib binary.
If we are executing the installed narwhal binary, the location is:
<narwhal>/packages/cappuccino/bin/nib2cib
If we are executing the built binary, the location is:
<CAPP_BUILD>/Debug|Release/CommonJS/cappuccino/bin/nib2cib
Base on these paths we can locate nib2cib's Info.plist.
*/
var path = FILE.dirname(FILE.dirname(FILE.canonical(SYS.args[0]))),
version = null;
if (FILE.basename(path) === "narwhal")
path = FILE.join(path, "packages", "cappuccino");
path = FILE.join(path, "lib", "nib2cib", "Info.plist");
if (FILE.isReadable(path))
{
var plist = FILE.read(path);
if (!plist)
return;
plist = CFPropertyList.propertyListFromString(plist);
if (!plist)
return;
version = plist.valueForKey("CPBundleVersion");
if (version)
stream.print("nib2cib v" + version);
}
if (!version)
stream.print("<No version info available>");
}
- (CPString)exceptionReason:(JSObject)exception
{
if (typeof(exception) === "string")
return exception;
else if (exception.isa && [exception respondsToSelector:@selector(reason)])
return [exception reason];
else
return @"An unknown error occurred";
}
- (void)failWithMessage:(CPString)message
{
[CPException raise:ConverterConversionException reason:message];
}
@end
function logFormatter(aString, aLevel, aTitle)
{
if (aLevel === "info")
return aString;
else
return CPLogColorize(aString, aLevel);
}
+3 -723
View File
@@ -20,731 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import <BlendKit/BlendKit.j>
@import "NSFoundation.j"
@import "NSAppKit.j"
@import "Nib2CibKeyedUnarchiver.j"
@import "Converter.j"
var FILE = require("file"),
OS = require("os"),
SYS = require("system"),
FileList = require("jake").FileList,
stream = require("narwhal/term").stream,
StaticResource = require("objective-j").StaticResource,
DefaultTheme = "Aristo",
BuildTypes = ["Debug", "Release"],
DefaultFile = "MainMenu";
var parser = new (require("narwhal/args").Parser)(),
nibInfo = {},
appDirectory = "",
resourcesDirectory = "";
@import "Nib2Cib.j"
function main(args)
{
try
{
var options = parseOptions(args),
ret = 0;
var nib2cib = [[Nib2Cib alloc] initWithArgs:args];
if (options.watch)
watch(options);
else
if (!convert(options))
ret = 2;
}
catch (anException)
{
CPLog.fatal(exceptionReason(anException));
OS.exit(1);
}
OS.exit(ret);
}
function convert(options, inputFile)
{
try
{
inputFile = inputFile || getInputFile(options.args);
getAppAndResourceDirectoriesFromInputFile(inputFile, options);
var outputFile = getOutputFile(inputFile, options.args),
configInfo = readConfigFile(options.configFile || "", inputFile),
defaultTheme = null;
if (configInfo.plist)
{
var systemFontFace = configInfo.plist.valueForKey("CPSystemFontFace");
if (systemFontFace)
[CPFont setSystemFontFace:systemFontFace];
var systemFontSize = configInfo.plist.valueForKey("CPSystemFontSize");
if (systemFontSize)
[CPFont setSystemFontSize:parseFloat(systemFontSize, 10)];
if (!options.defaultTheme)
defaultTheme = configInfo.plist.valueForKey("CPDefaultTheme");
}
var themeList = getThemeList(defaultTheme || options.defaultTheme, options),
themes = loadThemes(themeList);
CPLog.info("\n-------------------------------------------------------------");
CPLog.info("Input : " + inputFile);
CPLog.info("Output : " + outputFile);
CPLog.info("Format : " + ["Auto", "Mac", "iPhone"][options.format]);
CPLog.info("Application : " + appDirectory);
CPLog.info("Resources : " + resourcesDirectory);
CPLog.info("Frameworks : " + (options.frameworks || ""));
CPLog.info("Default theme : " + themeList[0]);
CPLog.info("Extra themes : " + themeList.slice(1).join(", "));
CPLog.info("Config file : " + (configInfo.path || ""));
CPLog.info("System Font : " + [CPFont systemFontSize] + "px " + [CPFont systemFontFace]);
CPLog.info("-------------------------------------------------------------\n");
var converter = [[Converter alloc] initWithInputPath:inputFile
format:options.format
themes:themes];
[converter setOutputPath:outputFile];
[converter setResourcesPath:resourcesDirectory];
loadFrameworks(options.frameworks, options.verbosity, function()
{
[converter convert];
});
return true;
}
catch (anException)
{
CPLog.fatal(exceptionReason(anException));
return false;
}
}
function watch(options)
{
var verbosity = options.quiet ? -1 : options.verbosity,
watchDir = options.args[0];
if (!watchDir)
watchDir = FILE.canonical(FILE.isDirectory("Resources") ? "Resources" : ".");
else
{
watchDir = FILE.canonical(watchDir);
if (FILE.basename(watchDir) !== "Resources")
{
var path = FILE.join(watchDir, "Resources");
if (FILE.isDirectory(path))
watchDir = path;
}
}
if (!FILE.isDirectory(watchDir))
fail("Cannot find the directory: " + watchDir);
// Turn on info messages
setLogLevel(1);
var nibs = new FileList(FILE.join(watchDir, "*.[nx]ib")).items(),
count = nibs.length;
// First time through only IB files with no corresponding cib
// or a cib with an earlier or equal mtime are converted.
while (count--)
{
var nib = nibs[count],
cib = nib.substr(0, nib.length - 4) + ".cib";
if (FILE.exists(cib) && (FILE.mtime(nib) - FILE.mtime(cib)) <= 0)
nibInfo[nib] = FILE.mtime(nib);
}
CPLog.info("Watching: " + CPLogColorize(watchDir, "debug"));
CPLog.info("Press Control-C to stop...");
while (true)
{
var modifiedNibs = getModifiedNibs(watchDir);
for (var i = 0; i < modifiedNibs.length; ++i)
{
var action = modifiedNibs[i][0],
nib = modifiedNibs[i][1],
label = action === "add" ? "Added" : "Modified",
level = action === "add" ? "info" : "debug";
CPLog.info(">> %s: %s", CPLogColorize(label, level), nib);
// Don't convert an add if there is an existing cib with a later mtime
if (action === "add")
{
var cib = nib.substr(0, nib.length - 4) + ".cib";
if (FILE.exists(cib) && (FILE.mtime(nib) - FILE.mtime(cib)) < 0)
continue;
}
// Let the converter log however the user configured it
setLogLevel(verbosity);
var success = convert(options, nib);
setLogLevel(1);
if (success)
{
if (verbosity > 0)
stream.print();
else
CPLog.warn("Conversion successful");
}
}
OS.sleep(1);
}
}
function parseOptions(args)
{
parser.usage("[--watch DIRECTORY] [INPUT_FILE [OUTPUT_FILE]]");
parser.option("--watch", "watch")
.set(true)
.help("Ask nib2cib to watch a directory for changes");
parser.option("-R", "resourcesDir")
.set()
.displayName("directory")
.help("Set the Resources directory, usually unnecessary as it is inferred from the input path");
parser.option("--default-theme", "defaultTheme")
.set()
.displayName("name")
.help("Specify a custom default theme which is not set in your Info.plist");
parser.option("-t", "--theme", "extraThemes")
.push()
.displayName("name")
.help("An additional theme loaded dynamically by your application");
parser.option("--config", "configFile")
.set()
.displayName("path")
.help("A path to an Info.plist file from which the system font and/or size can be retrieved");
// parser.option("--iphone", "format")
// .set(NibFormatIPhone)
// .help("Set format to iPhone");
parser.option("-v", "--verbose", "verbosity")
.inc()
.help("Increase verbosity level");
parser.option("-q", "--quiet", "quiet")
.set(true)
.help("No output");
parser.option("-F", "framework", "frameworks")
.push()
.help("Add a framework to load");
parser.option("--mac", "format")
.set(NibFormatMac)
.def(NibFormatUndetermined)
.help("Set format to Mac");
parser.option("--version", "showVersion")
.action(printVersionAndExit)
.help("Show the version of nib2cib and quit");
parser.helpful();
var options = parser.parse(args, null, null, true);
if (options.args.length > 2)
{
parser.printUsage(options);
OS.exit(0);
}
setLogLevel(options.quiet ? -1 : options.verbosity);
if (!options.quiet && options.verbosity > 0)
printVersion();
return options;
}
function setLogLevel(level)
{
CPLogUnregister(CPLogPrint);
if (level === 0)
CPLogRegister(CPLogPrint, "warn", logFormatter);
else if (level === 1)
CPLogRegister(CPLogPrint, "info", logFormatter);
else if (level > 1)
CPLogRegister(CPLogPrint, null, logFormatter);
}
function getInputFile(args)
{
var inputFile = args[0] || DefaultFile,
path = "";
if (!/^.+\.[nx]ib$/.test(inputFile))
{
if (path = findInputFile(inputFile, ".xib"))
inputFile = path;
else if (path = findInputFile(inputFile, ".nib"))
inputFile = path;
else
fail("Cannot find the input file (.xib or .nib): " + FILE.canonical(inputFile));
}
else if (path = findInputFile(inputFile))
inputFile = path;
else
fail("Could not read the input file: " + FILE.canonical(inputFile));
return FILE.canonical(inputFile);
}
function findInputFile(inputFile, extension)
{
var path = inputFile;
if (extension)
path += extension;
if (FILE.isReadable(path))
return path;
if (FILE.basename(FILE.dirname(inputFile)) !== "Resources" && FILE.isDirectory("Resources"))
{
path = FILE.resolve(path, FILE.join("Resources", FILE.basename(path)));
if (FILE.isReadable(path))
return path;
}
return null;
}
function getAppAndResourceDirectoriesFromInputFile(inputFile, options)
{
appDirectory = resourcesDirectory = "";
if (options.resourcesDir)
{
var path = FILE.canonical(options.resourcesDir);
if (!FILE.isDirectory(path))
fail("Cannot read resources at: " + path);
resourcesDirectory = path;
}
var parentDir = FILE.dirname(inputFile);
if (FILE.basename(parentDir) === "Resources")
{
appDirectory = FILE.dirname(parentDir);
resourcesDirectory = resourcesDirectory || parentDir;
}
else
{
appDirectory = parentDir;
if (!resourcesDirectory)
{
var path = FILE.join(appDirectory, "Resources");
if (FILE.isDirectory(path))
resourcesDirectory = path;
}
}
}
function getOutputFile(inputFile, args)
{
var outputFile = null;
if (args.length > 1)
{
outputFile = args[1];
if (!/^.+\.cib$/.test(outputFile))
outputFile += ".cib";
}
else
outputFile = FILE.join(FILE.dirname(inputFile), FILE.basename(inputFile, FILE.extension(inputFile))) + ".cib";
outputFile = FILE.canonical(outputFile);
if (!FILE.isWritable(FILE.dirname(outputFile)))
fail("Cannot write the output file at: " + outputFile);
return outputFile;
}
function loadFrameworks(frameworkPaths, verbosity, aCallback)
{
if (!frameworkPaths || frameworkPaths.length === 0)
return aCallback();
frameworkPaths.forEach(function(aFrameworkPath)
{
setLogLevel(verbosity);
CPLog.info("Loading " + aFrameworkPath);
try
{
// CPBundle is a bit loquacious with logging, we will defer
// logging its exceptions till later.
setLogLevel(-1);
var frameworkBundle = [[CPBundle alloc] initWithPath:aFrameworkPath];
[frameworkBundle loadWithDelegate:nil];
}
finally
{
setLogLevel(verbosity);
}
require("browser/timeout").serviceTimeouts();
});
aCallback();
}
function logFormatter(aString, aLevel, aTitle)
{
if (aLevel === "info")
return aString;
else
return CPLogColorize(aString, aLevel);
}
function getThemeList(defaultTheme, options)
{
var themes = [defaultTheme || getAppKitDefaultThemeName()];
if (options.extraThemes)
for (var i = 0; i < options.extraThemes.length; ++i)
if (themes.indexOf(options.extraThemes[i]) < 0)
themes.push(options.extraThemes[i]);
return themes;
}
// Returns undefined if $CAPP_BUILD is not defined, false if path cannot be found in $CAPP_BUILD
function findInCappBuild(path, isDirectory, callback)
{
var cappBuild = SYS.env["CAPP_BUILD"];
if (!cappBuild)
return undefined;
cappBuild = FILE.canonical(cappBuild);
if (FILE.isDirectory(cappBuild))
{
var result = null;
for (var i = 0; i < BuildTypes.length && !result; ++i)
{
var findPath = FILE.join(cappBuild, BuildTypes[i], path);
if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath)))
result = callback(findPath);
}
return result;
}
else
return false;
}
function findInInstalledFrameworks(path, isDirectory, callback)
{
// NOTE: It's safe to use '/' directly in the path, we're guaranteed to be on a Mac
var frameworks = FILE.canonical(FILE.join(SYS.prefix, "packages/cappuccino/Frameworks")),
result = null,
findPath = FILE.join(frameworks, "Debug", path);
if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath)))
result = callback(findPath);
if (!result)
{
findPath = FILE.join(frameworks, path);
if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath)))
result = callback(findPath);
}
return result;
}
function getAppKitDefaultThemeName()
{
var callback = function(path) { return themeNameFromPropertyList(path); },
themeName = findInCappBuild("AppKit/Info.plist", false, callback);
if (!themeName)
themeName = findInInstalledFrameworks("AppKit/Info.plist", false, callback);
return themeName || DefaultTheme;
}
function themeNameFromPropertyList(path)
{
if (!FILE.isReadable(path))
return nil;
var themeName = nil,
plist = CFPropertyList.readPropertyListFromFile(path);
if (plist)
themeName = plist.valueForKey("CPDefaultTheme");
return themeName;
}
function loadThemes(themeList)
{
var themes = [];
for (var i = 0; i < themeList.length; ++i)
themes.push(loadTheme(themeList[i], resourcesDirectory));
return themes;
}
function loadTheme(themeName, themeDir)
{
if (/^.+\.blend$/.test(themeName))
themeName = themeName.substr(0, themeName.length - ".blend".length);
var blendName = themeName + ".blend",
themePath = "";
if (themeDir)
{
themePath = FILE.join(FILE.canonical(themeDir), blendName);
if (!FILE.isDirectory(themePath))
themePath = themeDir = null;
}
if (!themeDir)
{
var returnPath = function(path) { return path; };
themePath = findInCappBuild(blendName, true, returnPath);
if (!themePath)
themePath = findInInstalledFrameworks("AppKit/Resources/" + blendName, true, returnPath);
// Last resort, try the cwd
if (!themePath)
{
var path = FILE.canonical(blendName);
if (FILE.isDirectory(path))
themePath = path;
}
}
if (!themePath)
fail('Cannot find the theme "' + themeName + '"');
return readTheme(themeName, themePath);
}
function readTheme(name, path)
{
var themeBundle = new CFBundle(path);
// By default when we try to load the bundle it will use the CommonJS environment,
// but we want the Browser environment. So we override mostEligibleEnvironment().
themeBundle.mostEligibleEnvironment = function() { return "Browser"; };
themeBundle.load();
var keyedThemes = themeBundle.valueForInfoDictionaryKey("CPKeyedThemes");
if (!keyedThemes)
fail("Could not find the keyed themes in the theme: " + path);
var index = keyedThemes.indexOf(name + ".keyedtheme");
if (index < 0)
fail("Could not find the main theme data (" + name + ".keyedtheme" + ") in the theme: " + path);
// Load the keyed theme data, making sure to resolve it
var resourcePath = themeBundle.pathForResource(keyedThemes[index]),
themeData = new CFMutableData();
themeData.setRawString(StaticResource.resourceAtURL(new CFURL(resourcePath), true).contents());
var theme = [CPKeyedUnarchiver unarchiveObjectWithData:themeData];
if (!theme)
fail("Could not unarchive the theme at: " + path);
CPLog.debug("Loaded theme: " + path);
return theme;
}
function readConfigFile(configFile, inputFile)
{
var configPath = null,
path;
// First see if the user passed a config file path
if (configFile)
{
path = FILE.canonical(configFile);
if (!FILE.isReadable(path))
fail("Cannot find the config file: " + path);
configPath = path;
}
else
{
path = FILE.join(appDirectory, "Info.plist");
if (FILE.isReadable(path))
configPath = path;
}
var plist = null;
if (configPath)
{
var plist = FILE.read(configPath);
if (!plist)
fail("Could not read the Info.plist at: " + configPath);
plist = CFPropertyList.propertyListFromString(plist);
if (!plist)
fail("Could not parse the Info.plist at: " + configPath);
}
return {path: configPath, plist: plist};
}
function getModifiedNibs(path)
{
var nibs = new FileList(FILE.join(path, "*.[nx]ib")).items(),
count = nibs.length,
newNibInfo = {},
modifiedNibs = [];
while (count--)
{
var nib = nibs[count];
newNibInfo[nib] = FILE.mtime(nib);
if (!nibInfo.hasOwnProperty(nib))
modifiedNibs.push(["add", nib]);
else
{
if (newNibInfo[nib] - nibInfo[nib] !== 0)
modifiedNibs.push(["mod", nib]);
// Remove matching nibs so that we leave
// deleted nibs in nibInfo.
delete nibInfo[nib];
}
}
for (var nib in nibInfo)
if (nibInfo.hasOwnProperty(nib))
CPLog.info(">> %s: %s", CPLogColorize("Deleted", "warn"), nib);
nibInfo = newNibInfo;
return modifiedNibs;
}
function printVersionAndExit()
{
printVersion();
OS.exit(0);
}
function printVersion()
{
/*
There are two usual possibilities for the location of the nib2cib binary.
If we are executing the installed narwhal binary, the location is:
<narwhal>/packages/cappuccino/bin/nib2cib
If we are executing the built binary, the location is:
<CAPP_BUILD>/Debug|Release/CommonJS/cappuccino/bin/nib2cib
Base on these paths we can locate nib2cib's Info.plist.
*/
var path = FILE.dirname(FILE.dirname(FILE.canonical(SYS.args[0]))),
version = null;
if (FILE.basename(path) === "narwhal")
path = FILE.join(path, "packages", "cappuccino");
path = FILE.join(path, "lib", "nib2cib", "Info.plist");
if (FILE.isReadable(path))
{
var plist = FILE.read(path);
if (!plist)
return;
plist = CFPropertyList.propertyListFromString(plist);
if (!plist)
return;
version = plist.valueForKey("CPBundleVersion");
if (version)
stream.print("nib2cib v" + version);
}
if (!version)
stream.print("<No version info available>");
}
function exceptionReason(exception)
{
if (typeof(exception) === "string")
return exception;
else if (exception.isa && [exception respondsToSelector:@selector(reason)])
return [exception reason];
else
return "An unknown error occurred";
}
function fail(message)
{
[CPException raise:ConverterConversionException reason:message];
[nib2cib run];
}
+138 -4
View File
@@ -1,6 +1,7 @@
.Dd April 3, 2011
.Os "Cappuccino"
.Dt NIB2CIB 1 "PRM"
.nh
.\"-----------------------------------------------------------------------------------------
.Sh NAME
.\"-----------------------------------------------------------------------------------------
@@ -154,8 +155,82 @@ options, one for each theme that you load.
.Pp
Themes are searched for in the Resources, $CAPP_BUILD/Debug and
$CAPP_BUILD/Release directories.
.Pp
If you have a list of auxiliary themes in your Info.plist using the
.Ar CPAuxiliaryThemes
item,
.Nm
will load them automatically, you do not have to do anything special.
.\"-----------------------------------------------------------------------------------------
.Sh "COMMON OPTIONS"
.Ss "Userland NS Classes"
.\"-----------------------------------------------------------------------------------------
Let's say you are working on a subclass of CPTextField called FormField. Obviously you will
want to use FormFields in cibs. You would also like to have some reasonable defaults established
for the view in Xcode, and perhaps override or ignore some CPTextField settings that do not apply to FormField.
.Pp
.Nm
allows you to dynamically define NS classes and use them in Interface Builder. Here's how:
.Bl -enum
.It
Indicate which classes will be used in Interface Builder by setting an
.Ar NSClasses
item in Info.plist:
<key>NSClasses</key>
<array>
<string>BorderView</string>
</array>
.It
For each class listed in
.Ar NSClasses ,
a corresponding NS_<class>.j file must be
created. This file is structured exactly like a Cappuccino NS class, with one exception:
@implementation BorderView (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [super NS_initWithCoder:aCoder];
if (self)
{
// Do default initialization here
}
return self;
}
@end
@implementation NS_BorderView : BorderView
+ (Class)classForKeyedArchiver
{
return [BorderView class];
}
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
}
@end
The only difference between this file and a Cappuccino NS file is that
.Sy classForKeyedArchiver
is a class method instead of an instance method.
.It
If necessary, the main class'
.Sy encodeWithCoder
can be enhanced to do extra work to support
.Sy nib2cib.
.Pp
By making your classes key-value coding compliant, you can use User Defined
Runtime Attributes in Interface Builder to configure your custom views without
any code.
.El
.\"-----------------------------------------------------------------------------------------
.Sh "OPTIONS"
.\"-----------------------------------------------------------------------------------------
The following options are available in watch mode or single mode:
.Bl -tag -width 4n
@@ -192,7 +267,7 @@ use this option, as
uses the Info.plist in the application directory, which is inferred from
the input file.
.It Fl F
Specify the path of a framework to load before converting. This is only useful if:
Specify the name or path of a framework to load before converting. This is only useful if:
.Bl -dash -width 0n -hang
.It
Your IB files use classes from the framework.
@@ -202,13 +277,33 @@ Those classes need to serialize/deserialize more data than their superclasses.
Those classes implement encodeWithCoder: and initWithCoder:.
.El
.Pp
This option may be used multiple times to load multiple frameworks.
This option may be used multiple times to load multiple frameworks. If the argument
contains a "/" character, it is considered to be a relative or absolute path and
the framework is searched for at that location. Otherwise it is considered a framework
name and is searched for in the following directories:
.Bl -ohang -offset 4n
.It $CAPP_BUILD/Debug
.It $CAPP_BUILD/Release
.It <App>/Frameworks/Debug
.It <App>/Frameworks
.It <narwhal>/packages/cappuccino/Frameworks/Debug
.It <narwhal>/packages/cappuccino/Frameworks
.El
.It Fl \-quiet
Tells
.Nm
to output nothing. This is useful if you are using
.Nm
in a shell script and are only interested in the return value.
in a shell script and are only interested in the return value. Note that this
option overrides the
.Fl v
option.
.It Fl \-no-stored-options
Tells
.Nm
not to read stored options. See
.Sy Stored Options
below for more information.
.It Fl \-version
Prints the current version of
.Nm
@@ -221,6 +316,45 @@ Displays
usage and options.
.El
.\"-----------------------------------------------------------------------------------------
.Ss "Stored Options"
.\"-----------------------------------------------------------------------------------------
To make it easier to use nib2cib in an automated way, you can store command line options
that will apply to converted xibs/nibs. To store command line options, you enter the
options on a single line into a text file. For example, if you always want to set
"MyTheme" as the default theme, you would create a text file with this line:
.Pp
.D1 --default-theme MyTheme
.Pp
If an option takes a parameter and the parameter contains spaces, it must be enclosed in
single or double quotes. You may store options in the following three places, in increasing
order of precedence:
.Bl -ohang -offset 4n
.It Em ~/.nib2cibconfig
nib2cib options that apply to all nibs converted under your user account.
.It Em <app>/nib2cib.conf
nib2cib options that apply to all nibs in <app>/Resources.
.It Em <app>/Resources/<xib-or-nib-basename>.conf
nib2cib options that apply to a specific xib or nib. For example, if the xib
is called MainMenu.xib, the stored options file would be MainMenu.conf.
.El
.Pp
Each of these files is read in the order listed above, and if it exists, its options
are merged with the previous file's options. Options in later files (more specific)
override options in earlier files (more generic). After all of the stored options
are merged, the command line options are merged in. Thus command line options always
override stored options.
.Pp
Using stored options is especially useful if your xibs/nibs use custom themes or
frameworks. By using stored options, you can avoid remembering (or forgetting!) to
specify the theme or framework every time you invoke
.Nm .
.Pp
To prevent
.Nm
from reading stored options, and thus only use command line options, use the
.Fl \-no-stored-options
option on the command line.
.\"-----------------------------------------------------------------------------------------
.Sh "RETURN VALUES"
.\"-----------------------------------------------------------------------------------------
.Nm
+2 -5
View File
@@ -488,14 +488,11 @@ global.copyManPage = function(/*String*/ name, /*int*/ section)
{
if (!FILE.isDirectory(manDir))
{
if (!sudo(["mkdir", "-p", "-m", "0755", manDir]))
{
if (sudo(["mkdir", "-p", "-m", "0755", manDir]))
stream.print("\0red(Unable to create the man directory.\0)");
OS.exit(1);
}
}
if (!sudo(["cp", "-f", pageFile, manDir]))
if (sudo(["cp", "-f", pageFile, manDir]))
stream.print("\0red(Unable to copy the man file.\0)");
}
}