Merge branch master
@@ -307,7 +307,7 @@ ACTUAL_FRAME_RATE = 0;
|
||||
|
||||
if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
|
||||
return [_delegate animation:self valueForProgress:t];
|
||||
|
||||
|
||||
if (_animationCurve == CPAnimationLinear)
|
||||
return t;
|
||||
|
||||
|
||||
@@ -219,28 +219,22 @@ CPRunContinuesResponse = -1002;
|
||||
// At this point we clear the window.status to eliminate Safari's "Cancelled" error message
|
||||
// The message shouldn't be displayed, because only an XHR is cancelled, but it is a usability issue.
|
||||
// We do it here so that applications can change it in willFinish or didFinishLaunching
|
||||
#if PLATFORM(DOM)
|
||||
window.status = " ";
|
||||
#endif
|
||||
|
||||
// We also want to set the default cursor on the body, so that buttons and things don't have an iBeam
|
||||
[[CPCursor arrowCursor] set];
|
||||
|
||||
var bundle = [CPBundle mainBundle],
|
||||
types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];
|
||||
|
||||
if ([types count] > 0)
|
||||
_documentController = [CPDocumentController sharedDocumentController];
|
||||
|
||||
var delegateClassName = [bundle objectForInfoDictionaryKey:@"CPApplicationDelegateClass"];
|
||||
delegateClassName = [bundle objectForInfoDictionaryKey:@"CPApplicationDelegateClass"];
|
||||
|
||||
if (delegateClassName)
|
||||
{
|
||||
var delegateClass = objj_getClass(delegateClassName);
|
||||
|
||||
if (delegateClass)
|
||||
if ([_documentController class] == delegateClass)
|
||||
[self setDelegate:_documentController];
|
||||
else
|
||||
[self setDelegate:[[delegateClass alloc] init]];
|
||||
[self setDelegate:[[delegateClass alloc] init]];
|
||||
}
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
@@ -249,6 +243,11 @@ CPRunContinuesResponse = -1002;
|
||||
postNotificationName:CPApplicationWillFinishLaunchingNotification
|
||||
object:self];
|
||||
|
||||
var types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];
|
||||
|
||||
if ([types count] > 0)
|
||||
_documentController = [CPDocumentController sharedDocumentController];
|
||||
|
||||
var needsUntitled = !!_documentController,
|
||||
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(),
|
||||
index = 0,
|
||||
|
||||
@@ -584,7 +584,7 @@
|
||||
*/
|
||||
- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes
|
||||
{
|
||||
[self __setSelectionIndexes:indexes avoidEmpty:_avoidsEmptySelection];
|
||||
return [self __setSelectionIndexes:indexes avoidEmpty:_avoidsEmptySelection];
|
||||
}
|
||||
|
||||
- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes avoidEmpty:(BOOL)avoidEmpty
|
||||
@@ -920,6 +920,15 @@
|
||||
[self removeObjectsAtArrangedObjectIndexes:_selectionIndexes];
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the object at the specified index in the controller's arranged objects from the content array.
|
||||
@param int index - index of the object to remove.
|
||||
*/
|
||||
- (void)removeObjectAtArrangedObjectIndex:(int)index
|
||||
{
|
||||
[self removeObjectsAtArrangedObjectIndexes:[CPIndexSet indexSetWithIndex:index]];
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the objects at the specified indexes in the controller's arranged objects from the content array.
|
||||
@param CPIndexSet indexes - indexes of the objects to remove.
|
||||
|
||||
@@ -180,6 +180,8 @@ CPButtonImageOffset = 3.0;
|
||||
// Continuous button defaults.
|
||||
_periodicInterval = 0.05;
|
||||
_periodicDelay = 0.5;
|
||||
|
||||
_imageDimsWhenDisabled = YES;
|
||||
}
|
||||
|
||||
// Setting the state
|
||||
|
||||
@@ -535,7 +535,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
// Cocoa raises an invalid parameter assertion and returns if you pass nil.
|
||||
if (aString === nil || aString === undefined)
|
||||
{
|
||||
CPLog.warn("nil sent to CPControl -setStringValue");
|
||||
CPLog.warn("nil or undefined sent to CPControl -setStringValue");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,8 +111,12 @@
|
||||
for (var i = 0; i < ca.length; i++)
|
||||
{
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||||
|
||||
while (c.charAt(0) == ' ')
|
||||
c = c.substring(1, c.length);
|
||||
|
||||
if (c.indexOf(nameEQ) == 0)
|
||||
return c.substring(nameEQ.length, c.length);
|
||||
}
|
||||
#endif
|
||||
return "";
|
||||
|
||||
@@ -634,7 +634,7 @@ var _CPEventPeriodicEventPeriod = 0,
|
||||
|
||||
function _CPEventFirePeriodEvent()
|
||||
{
|
||||
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
|
||||
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:[CPEvent currentTimestamp] windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
|
||||
}
|
||||
|
||||
var CPEventClass = [CPEvent class];
|
||||
|
||||
@@ -70,7 +70,10 @@ function CPDrawColorTiledRects(
|
||||
if (_CGRectIsEmpty(slice))
|
||||
continue;
|
||||
|
||||
var minX, maxX, minY, maxY;
|
||||
var minX,
|
||||
maxX,
|
||||
minY,
|
||||
maxY;
|
||||
|
||||
if (side == CPMinXEdge || side == CPMaxXEdge)
|
||||
{
|
||||
@@ -105,4 +108,4 @@ function CPDrawColorTiledRects(
|
||||
CGContextRestoreGState(context);
|
||||
|
||||
return resultRect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +158,20 @@ function CPAppKitImage(aFilename, aSize)
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
Initializes the receiver with the specified data. The method loads the data into memory.
|
||||
@param someData the CPData object representing the image
|
||||
@return the initialized image
|
||||
*/
|
||||
- (id)initWithData:(CPData)someData
|
||||
{
|
||||
var base64 = [someData base64],
|
||||
type = [base64 hasPrefix:@"/9j/4AAQSkZJRgABAQEASABIAAD/"] ? @"jpg" : @"png",
|
||||
dataURL = "data:image/" + type + ";base64," + base64;
|
||||
|
||||
return [self initWithContentsOfFile:dataURL];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the path of the file associated with this image.
|
||||
*/
|
||||
@@ -166,6 +180,37 @@ function CPAppKitImage(aFilename, aSize)
|
||||
return _filename;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the data associated with this image.
|
||||
@discussion Returns nil if the reciever was not initialized with -initWithData: and the browser does not support the canvas feature;
|
||||
*/
|
||||
- (CPData)data
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var dataURL;
|
||||
|
||||
if ([_filename hasPrefix:@"data:image"])
|
||||
dataURL = _filename;
|
||||
else if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
|
||||
{
|
||||
var canvas = document.createElement("canvas"),
|
||||
ctx = canvas.getContext("2d");
|
||||
|
||||
canvas.width = _image.width,
|
||||
canvas.height = _image.height;
|
||||
|
||||
ctx.drawImage(_image, 0, 0);
|
||||
|
||||
dataURL = canvas.toDataURL("image/png");
|
||||
}
|
||||
else
|
||||
return nil;
|
||||
|
||||
var base64 = dataURL.replace(/^data:image\/png;base64,/, "");
|
||||
return [CPData dataWithBase64:base64];
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the size of the image.
|
||||
@param the size of the image
|
||||
|
||||
@@ -66,7 +66,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
|
||||
+ (Class)_binderClassForBinding:(CPString)theBinding
|
||||
{
|
||||
if (theBinding === CPValueBinding || theBinding === CPValueURLBinding || theBinding === CPValuePathBinding)
|
||||
if (theBinding === CPValueBinding || theBinding === CPValueURLBinding || theBinding === CPValuePathBinding || theBinding === CPDataBinding)
|
||||
return [CPImageViewValueBinder class];
|
||||
|
||||
return [super _binderClassForBinding:theBinding];
|
||||
@@ -466,10 +466,16 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
|
||||
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
|
||||
{
|
||||
if (aBinding === CPValueURLBinding || aBinding === CPValuePathBinding)
|
||||
aValue = [[CPImage alloc] initWithContentsOfFile:aValue];
|
||||
var image;
|
||||
|
||||
[_source setImage:aValue];
|
||||
if (aBinding === CPDataBinding)
|
||||
image = [[CPImage alloc] initWithData:aValue];
|
||||
else if (aBinding === CPValueURLBinding || aBinding === CPValuePathBinding)
|
||||
image = [[CPImage alloc] initWithContentsOfFile:aValue];
|
||||
else if (aBinding === CPValueBinding)
|
||||
image = aValue;
|
||||
|
||||
[_source setImage:image];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
CPStandardKeyBindings = {
|
||||
@"@.": @"cancelOperation:",
|
||||
|
||||
@"@a": @"selectAll:",
|
||||
@"^a": @"moveToBeginningOfParagraph:",
|
||||
@"^$a": @"moveToBeginningOfParagraphAndModifySelection:",
|
||||
@"^b": @"moveBackward:",
|
||||
|
||||
@@ -253,7 +253,7 @@ var _CPLevelIndicatorBezelColor = nil,
|
||||
|
||||
var location = [self convertPoint:[anEvent locationInWindow] fromView:nil],
|
||||
bounds = [self bounds],
|
||||
oldValue = [self doubleValue];
|
||||
oldValue = [self doubleValue],
|
||||
newValue = oldValue;
|
||||
|
||||
// Moving the mouse outside of the widget to the left sets it
|
||||
|
||||
@@ -137,10 +137,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
// Periodic events don't have a valid location.
|
||||
var globalLocation = type === CPPeriodic ? _lastGlobalLocation : [anEvent globalLocation];
|
||||
|
||||
// Remember this for the next periodic event.
|
||||
_lastGlobalLocation = globalLocation;
|
||||
|
||||
if (!_lastGlobalLocation)
|
||||
if (!globalLocation)
|
||||
return;
|
||||
|
||||
// Find which menu window the mouse is currently on top of
|
||||
@@ -152,6 +149,14 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
activeItemIndex = activeMenuContainer ? [activeMenuContainer itemIndexAtPoint:menuLocation] : CPNotFound,
|
||||
activeItem = activeItemIndex !== CPNotFound ? [activeMenu itemAtIndex:activeItemIndex] : nil;
|
||||
|
||||
// unhighlight when mouse is moved off the menu
|
||||
if (_lastGlobalLocation && CGRectContainsPoint([activeMenuContainer globalFrame], _lastGlobalLocation)
|
||||
&& !CGRectContainsPoint([activeMenuContainer globalFrame], globalLocation))
|
||||
[activeMenu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
// Remember this for the next periodic event.
|
||||
_lastGlobalLocation = globalLocation;
|
||||
|
||||
// If the item isn't enabled its as if we clicked on nothing.
|
||||
if (![activeItem isEnabled] || [activeItem _isMenuBarButton])
|
||||
{
|
||||
@@ -161,7 +166,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
|
||||
var mouseOverMenuView = [activeItem view];
|
||||
|
||||
if (type === CPScrollWheel)
|
||||
if (type === CPScrollWheel && ![activeMenuContainer isMenuBar])
|
||||
[activeMenuContainer scrollByDelta:[anEvent deltaY]];
|
||||
|
||||
if (type === CPPeriodic)
|
||||
@@ -211,7 +216,8 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
_lastMouseOverMenuView = nil;
|
||||
}
|
||||
|
||||
[activeMenu _highlightItemAtIndex:activeItemIndex];
|
||||
if (activeItemIndex != CPNotFound)
|
||||
[activeMenu _highlightItemAtIndex:activeItemIndex];
|
||||
|
||||
if (type === CPMouseMoved || type === CPLeftMouseDragged || type === CPLeftMouseDown || type === CPPeriodic)
|
||||
{
|
||||
@@ -485,7 +491,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
{
|
||||
if (!_keyBuffer)
|
||||
{
|
||||
_startTime = [CPDate date];
|
||||
_startTime = [anEvent timestamp];
|
||||
_keyBuffer = character;
|
||||
|
||||
[CPEvent stopPeriodicEvents];
|
||||
@@ -522,7 +528,7 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
_keyBuffer = Nil;
|
||||
}
|
||||
else
|
||||
_startTime = [CPDate date];
|
||||
_startTime = [CPEvent currentTimestamp];
|
||||
}
|
||||
|
||||
- (void)scrollToBeginningOfDocument:(CPMenu)menu
|
||||
@@ -666,8 +672,11 @@ var STICKY_TIME_INTERVAL = 0.5,
|
||||
var index = menu._highlightedIndex - 1;
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
if (index != CPNotFound)
|
||||
[menu _highlightItemAtIndex:[menu numberOfItems] - 1];
|
||||
return;
|
||||
|
||||
}
|
||||
[menu _highlightItemAtIndex:index];
|
||||
|
||||
var item = [menu highlightedItem];
|
||||
|
||||
@@ -110,8 +110,6 @@ var STICKY_TIME_INTERVAL = 500,
|
||||
[_moreBelowView setFrameSize:[_CPMenuWindowMoreBelowImage size]];
|
||||
|
||||
[contentView addSubview:_moreBelowView];
|
||||
|
||||
[self setShadowStyle:CPWindowShadowStyleMenu];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -185,7 +185,8 @@ CPTransformableAttributeType = 1800;
|
||||
if (![[self operators] containsObject:[predicate predicateOperatorType]])
|
||||
return 0;
|
||||
|
||||
if (!_rightIsWildcard && ![[self rightExpressions] containsObject:[predicate rightExpression]]) return 0;
|
||||
if (!_rightIsWildcard && ![[self rightExpressions] containsObject:[predicate rightExpression]])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1065,7 +1065,7 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (void)_autosave
|
||||
{
|
||||
if (!_shouldAutosave || !autosaveName)
|
||||
if (!_shouldAutosave || !_autosaveName)
|
||||
return;
|
||||
|
||||
var userDefaults = [CPUserDefaults standardUserDefaults],
|
||||
|
||||
@@ -257,8 +257,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
*/
|
||||
+ (id)themeAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[[CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null]]
|
||||
forKeys:["alternating-row-colors", "grid-color", "highlighted-grid-color", "selection-color", "sourcelist-selection-color", "sort-image", "sort-image-reversed"]];
|
||||
return [CPDictionary dictionaryWithObjects:[[CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null]]
|
||||
forKeys:["alternating-row-colors", "grid-color", "highlighted-grid-color", "selection-color", "sourcelist-selection-color", "sort-image", "sort-image-reversed", "selection-radius"]];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -1257,7 +1257,7 @@ NOT YET IMPLEMENTED
|
||||
*/
|
||||
- (int)selectedColumn
|
||||
{
|
||||
[_selectedColumnIndexes lastIndex];
|
||||
return [_selectedColumnIndexes lastIndex];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -3773,7 +3773,25 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
else
|
||||
CGContextAddRect(context, rowRect);
|
||||
{
|
||||
var radius = [self currentValueForThemeAttribute:@"selection-radius"];
|
||||
|
||||
if (radius > 0)
|
||||
{
|
||||
var minX = CGRectGetMinX(rowRect),
|
||||
maxX = CGRectGetMaxX(rowRect),
|
||||
minY = CGRectGetMinY(rowRect),
|
||||
maxY = CGRectGetMaxY(rowRect);
|
||||
|
||||
CGContextMoveToPoint(context, minX + radius, minY);
|
||||
CGContextAddArcToPoint(context, maxX, minY, maxX, minY + radius, radius);
|
||||
CGContextAddArcToPoint(context, maxX, maxY, maxX - radius, maxY, radius);
|
||||
CGContextAddArcToPoint(context, minX, maxY, minX, maxY - radius, radius);
|
||||
CGContextAddArcToPoint(context, minX, minY, minX + radius, minY, radius);
|
||||
}
|
||||
else
|
||||
CGContextAddRect(context, rowRect);
|
||||
}
|
||||
}
|
||||
|
||||
CGContextClosePath(context);
|
||||
@@ -3991,6 +4009,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
*/
|
||||
- (BOOL)startTrackingAt:(CGPoint)aPoint
|
||||
{
|
||||
if (![[self window] makeFirstResponder:self])
|
||||
return NO;
|
||||
|
||||
var row = [self rowAtPoint:aPoint];
|
||||
|
||||
// If the user clicks outside a row then deselect everything.
|
||||
@@ -4018,7 +4039,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
if (row >= 0 && !(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_))
|
||||
[self _updateSelectionWithMouseAtRow:row];
|
||||
|
||||
[[self window] makeFirstResponder:self];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -4141,6 +4161,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
|
||||
*/
|
||||
- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
|
||||
{
|
||||
if ([[self window] firstResponder] !== self)
|
||||
return;
|
||||
|
||||
_isSelectingSession = NO;
|
||||
|
||||
var CLICK_TIME_DELTA = 1000,
|
||||
|
||||
@@ -418,6 +418,8 @@ CPThemeStateEditing = CPThemeState("editing");
|
||||
CPThemeStateVertical = CPThemeState("vertical");
|
||||
CPThemeStateDefault = CPThemeState("default");
|
||||
CPThemeStateCircular = CPThemeState("circular");
|
||||
CPThemeStateAutocompleting = CPThemeState("autocompleting");
|
||||
|
||||
|
||||
@implementation _CPThemeAttribute : CPObject
|
||||
{
|
||||
|
||||
@@ -58,9 +58,6 @@ CPToolbarSizeModeSmall = 2;
|
||||
var CPToolbarsByIdentifier = nil,
|
||||
CPToolbarConfigurationsByIdentifier = nil;
|
||||
|
||||
var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
TOOLBAR_SMALL_HEIGHT = 46.0;
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@class CPToolbar
|
||||
@@ -91,11 +88,12 @@ var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
@implementation CPToolbar : CPObject
|
||||
{
|
||||
CPString _identifier;
|
||||
CPToolbarDisplayMode _displayMode;
|
||||
CPToolbarDisplayMode _displayMode @accessors(property=displayMode);
|
||||
BOOL _showsBaselineSeparator;
|
||||
BOOL _allowsUserCustomization;
|
||||
BOOL _isVisible;
|
||||
int _sizeMode @accessors(property=sizeMode);
|
||||
int _desiredHeight;
|
||||
|
||||
id _delegate;
|
||||
|
||||
@@ -137,6 +135,19 @@ var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
[toolbarsSharingIdentifier addObject:toolbar];
|
||||
}
|
||||
|
||||
/*
|
||||
Temporary theme attributes until we've figured out which CPView these theme attributes should
|
||||
belong to.
|
||||
@ignore
|
||||
*/
|
||||
+ (id)_themeAttributes
|
||||
{
|
||||
// "regular-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeRegular.
|
||||
// "small-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeSmall.
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMake(4.0, 4.0, 4.0, TOOLBAR_ITEM_MARGIN), 59.0, 46.0]
|
||||
forKeys:[@"content-inset", @"regular-size-height", @"small-size-height"]];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithIdentifier:@""];
|
||||
@@ -158,6 +169,7 @@ var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
_identifier = anIdentifier;
|
||||
_isVisible = YES;
|
||||
_sizeMode = CPToolbarSizeModeDefault;
|
||||
_desiredHeight = 0;
|
||||
|
||||
[CPToolbar _addToolbar:self forIdentifier:_identifier];
|
||||
}
|
||||
@@ -246,6 +258,15 @@ var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
[self _reloadToolbarItems];
|
||||
}
|
||||
|
||||
- (void)setDisplayMode:(CPToolbarDisplayMode)aDisplayMode
|
||||
{
|
||||
if (_displayMode === aDisplayMode)
|
||||
return;
|
||||
_displayMode = aDisplayMode;
|
||||
|
||||
[self _reloadToolbarItems];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
- (void)_loadConfiguration
|
||||
{
|
||||
@@ -254,7 +275,18 @@ var TOOLBAR_REGULAR_HEIGHT = 59.0,
|
||||
|
||||
- (CGRect)_toolbarViewFrame
|
||||
{
|
||||
return CPRectMake(0.0, 0.0, 1200.0, _sizeMode != CPToolbarSizeModeSmall ? TOOLBAR_REGULAR_HEIGHT : TOOLBAR_SMALL_HEIGHT);
|
||||
var height = _desiredHeight || (_sizeMode != CPToolbarSizeModeSmall ? [self _valueForThemeAttribute:@"regular-size-height"] : [self _valueForThemeAttribute:@"small-size-height"]);
|
||||
return CPRectMake(0.0, 0.0, 1200.0, height);
|
||||
}
|
||||
|
||||
/*
|
||||
Temporary theme attributes until we've figured out which CPView these theme attributes should
|
||||
belong to.
|
||||
@ignore
|
||||
*/
|
||||
- (id)_valueForThemeAttribute:(CPString)attributeName
|
||||
{
|
||||
return [[[self class] _themeAttributes] valueForKey:attributeName];
|
||||
}
|
||||
|
||||
/* @ignore */
|
||||
@@ -536,8 +568,7 @@ var _CPToolbarViewBackgroundColor = nil,
|
||||
_CPToolbarViewExtraItemsImage = nil,
|
||||
_CPToolbarViewExtraItemsAlternateImage = nil;
|
||||
|
||||
var TOOLBAR_TOP_MARGIN = 5.0,
|
||||
TOOLBAR_ITEM_MARGIN = 10.0,
|
||||
var TOOLBAR_ITEM_MARGIN = 10.0,
|
||||
TOOLBAR_EXTRA_ITEMS_WIDTH = 20.0;
|
||||
|
||||
var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
@@ -575,9 +606,9 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
|
||||
_CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size:CPSizeMake(10.0, 15.0)];
|
||||
_CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size:CPSizeMake(10.0, 15.0)];
|
||||
|
||||
_CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile: [bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:CGSizeMake(10.0, 15.0)];
|
||||
_CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:_CGSizeMake(10.0, 15.0)];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -591,7 +622,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
_labelColor = [CPColor blackColor];
|
||||
_labelShadowColor = [CPColor colorWithWhite:1.0 alpha:0.75];
|
||||
|
||||
_additionalItemsButton = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 15.0) pullsDown:YES];
|
||||
_additionalItemsButton = [[CPPopUpButton alloc] initWithFrame:_CGRectMake(0.0, 0.0, 10.0, 15.0) pullsDown:YES];
|
||||
[_additionalItemsButton setBordered:NO];
|
||||
|
||||
[_additionalItemsButton setImagePosition:CPImageOnly];
|
||||
@@ -643,7 +674,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
{
|
||||
// We begin by recalculating the visible items.
|
||||
var items = [_toolbar items],
|
||||
itemsWidth = CGRectGetWidth([self bounds]),
|
||||
itemsWidth = _CGRectGetWidth([self bounds]),
|
||||
minWidth = _minWidth,
|
||||
// FIXME: This should be a CPSet.
|
||||
invisibleItemsSortedByPriority = [];
|
||||
@@ -693,6 +724,24 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
height = minSize.height;
|
||||
}
|
||||
|
||||
// We'll figure out the proper height for the toolbar depending on its items.
|
||||
// If nothing has a minimum size we'll use the standard toolbar size for the
|
||||
// sizeMode, indicated by a 0 _desiredHeight.
|
||||
var contentInset = [_toolbar _valueForThemeAttribute:@"content-inset"],
|
||||
newDesiredHeight = height ? height + contentInset.top + contentInset.bottom : 0;
|
||||
|
||||
if (newDesiredHeight != _toolbar._desiredHeight)
|
||||
{
|
||||
// FIXME Probably the toolbar view shouldn't be telling the toolbar which height it should be. Maybe refactor
|
||||
// to just have the toolbar scan the toolbar items whenever the items change.
|
||||
_toolbar._desiredHeight = newDesiredHeight;
|
||||
|
||||
[self setFrame:[_toolbar _toolbarViewFrame]];
|
||||
[_toolbar._window _noteToolbarChanged];
|
||||
// The above will cause tile to be called again.
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine all the items that have flexible width.
|
||||
// Also determine the height of the toolbar.
|
||||
var count = _visibleItems.length,
|
||||
@@ -712,7 +761,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
// static width (min==max). This handles the case where the user did setView:
|
||||
// with a view of a different size than minSize/maxSize
|
||||
else
|
||||
[view setFrameSize:CGSizeMake(minSize.width, height)];
|
||||
[view setFrameSize:_CGSizeMake(minSize.width, height)];
|
||||
|
||||
[view setHidden:NO];
|
||||
}
|
||||
@@ -747,21 +796,23 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
remainingSpace += proposedWidth - constrainedWidth;
|
||||
}
|
||||
|
||||
[view setFrameSize:CGSizeMake(constrainedWidth, height)];
|
||||
[view setFrameSize:_CGSizeMake(constrainedWidth, height)];
|
||||
}
|
||||
}
|
||||
|
||||
// Now that all the visible items are the correct width, give them their final frames.
|
||||
var index = 0,
|
||||
count = _visibleItems.length,
|
||||
x = TOOLBAR_ITEM_MARGIN;
|
||||
x = contentInset.left,
|
||||
contentInset = [_toolbar _valueForThemeAttribute:@"content-inset"],
|
||||
y = contentInset.top;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var view = [self viewForItem:_visibleItems[index]],
|
||||
viewWidth = CGRectGetWidth([view frame]);
|
||||
viewWidth = _CGRectGetWidth([view frame]);
|
||||
|
||||
[view setFrame:CGRectMake(x, 0.0, viewWidth, height)];
|
||||
[view setFrame:_CGRectMake(x, y, viewWidth, height)];
|
||||
|
||||
x += viewWidth + TOOLBAR_ITEM_MARGIN;
|
||||
}
|
||||
@@ -795,7 +846,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
|
||||
|
||||
if (needsAdditionalItemsButton)
|
||||
{
|
||||
[_additionalItemsButton setFrameOrigin:CGPointMake(itemsWidth + 5.0, (CGRectGetHeight([self bounds]) - CGRectGetHeight([_additionalItemsButton frame])) / 2.0)];
|
||||
[_additionalItemsButton setFrameOrigin:_CGPointMake(itemsWidth + 5.0, (_CGRectGetHeight([self bounds]) - _CGRectGetHeight([_additionalItemsButton frame])) / 2.0)];
|
||||
|
||||
[self addSubview:_additionalItemsButton];
|
||||
|
||||
@@ -906,8 +957,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
|
||||
return CPOrderedDescending;
|
||||
};
|
||||
|
||||
var TOP_MARGIN = 5.0,
|
||||
LABEL_MARGIN = 2.0;
|
||||
var LABEL_MARGIN = 2.0;
|
||||
|
||||
@implementation _CPToolbarItemView : CPControl
|
||||
{
|
||||
@@ -934,12 +984,12 @@ var TOP_MARGIN = 5.0,
|
||||
{
|
||||
_toolbarItem = aToolbarItem;
|
||||
|
||||
_labelField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
||||
_labelField = [[CPTextField alloc] initWithFrame:_CGRectMakeZero()];
|
||||
|
||||
[_labelField setFont:[CPFont systemFontOfSize:11.0]];
|
||||
[_labelField setTextColor:[self FIXME_labelColor]];
|
||||
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
|
||||
[_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_labelField setTextShadowOffset:_CGSizeMake(0.0, 1.0)];
|
||||
[_labelField setAutoresizingMask:CPViewWidthSizable | CPViewMinXMargin];
|
||||
|
||||
[self addSubview:_labelField];
|
||||
@@ -986,11 +1036,11 @@ var TOP_MARGIN = 5.0,
|
||||
|
||||
if (identifier === CPToolbarSeparatorItemIdentifier)
|
||||
{
|
||||
_view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 2.0, 32.0)];
|
||||
_view = [[CPView alloc] initWithFrame:_CGRectMake(0.0, 0.0, 2.0, 32.0)];
|
||||
|
||||
// FIXME: Get rid of this old API!!!
|
||||
sizes = {};
|
||||
sizes[@"CPToolbarItemSeparator"] = [CGSizeMake(2.0, 26.0), CGSizeMake(2.0, 1.0), CGSizeMake(2.0, 26.0)];
|
||||
sizes[@"CPToolbarItemSeparator"] = [_CGSizeMake(2.0, 26.0), _CGSizeMake(2.0, 1.0), _CGSizeMake(2.0, 26.0)];
|
||||
[_view setBackgroundColor:_CPControlThreePartImagePattern(YES, sizes, @"CPToolbarItem", @"Separator")];
|
||||
|
||||
[self addSubview:_view];
|
||||
@@ -1042,8 +1092,13 @@ var TOP_MARGIN = 5.0,
|
||||
|
||||
_labelSize = [_labelField frame].size;
|
||||
|
||||
_minSize = CGSizeMake(MAX(_labelSize.width, minSize.width), _labelSize.height + minSize.height + LABEL_MARGIN + TOP_MARGIN);
|
||||
_maxSize = CGSizeMake(MAX(_labelSize.width, maxSize.width), 100000000.0);
|
||||
var iconOnly = [[_toolbarItem toolbar] displayMode] === CPToolbarDisplayModeIconOnly,
|
||||
labelOnly = [[_toolbarItem toolbar] displayMode] === CPToolbarDisplayModeLabelOnly;
|
||||
[_labelField setHidden:iconOnly];
|
||||
[_view setHidden:labelOnly];
|
||||
|
||||
_minSize = _CGSizeMake(MAX(_labelSize.width, minSize.width), (labelOnly ? 0 : minSize.height) + (iconOnly ? 0 : _labelSize.height + LABEL_MARGIN));
|
||||
_maxSize = _CGSizeMake(MAX(_labelSize.width, maxSize.width), 100000000.0);
|
||||
|
||||
[_toolbar tile];
|
||||
}
|
||||
@@ -1060,20 +1115,23 @@ var TOP_MARGIN = 5.0,
|
||||
width = _CGRectGetWidth(bounds);
|
||||
|
||||
if (identifier === CPToolbarSeparatorItemIdentifier)
|
||||
return [_view setFrame:CGRectMake(ROUND((width - 2.0) / 2.0), 0.0, 2.0, _CGRectGetHeight(bounds))];
|
||||
return [_view setFrame:_CGRectMake(ROUND((width - 2.0) / 2.0), 0.0, 2.0, _CGRectGetHeight(bounds))];
|
||||
|
||||
// The view is centred in the available space above the label.
|
||||
var view = _view || _imageView,
|
||||
itemMaxSize = [_toolbarItem maxSize],
|
||||
height = _CGRectGetHeight(bounds) - _labelSize.height - LABEL_MARGIN - TOP_MARGIN,
|
||||
iconOnly = [[_toolbarItem toolbar] displayMode] === CPToolbarDisplayModeIconOnly,
|
||||
height = _CGRectGetHeight(bounds) - (iconOnly ? 0 : _labelSize.height),
|
||||
viewWidth = MIN(itemMaxSize.width, width),
|
||||
viewHeight = MIN(itemMaxSize.height, height);
|
||||
|
||||
[view setFrame:CGRectMake( ROUND((width - viewWidth) / 2.0),
|
||||
TOP_MARGIN + ROUND((height - viewHeight) / 2.0),
|
||||
viewWidth,
|
||||
viewHeight)];
|
||||
[view setFrame:_CGRectMake(ROUND((width - viewWidth) / 2.0),
|
||||
ROUND((height - viewHeight) / 2.0),
|
||||
viewWidth,
|
||||
viewHeight)];
|
||||
|
||||
[_labelField setFrameOrigin:CGPointMake(ROUND((width - _labelSize.width) / 2.0), TOP_MARGIN + height + LABEL_MARGIN)];
|
||||
// Label is always drawn at the bottom of the view. So if the view is really tall but the icon is tiny, the icon is centred above the label while the label remains on the bottom.
|
||||
[_labelField setFrameOrigin:_CGPointMake(ROUND((width - _labelSize.width) / 2.0), _CGRectGetHeight(bounds) - _labelSize.height)];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
@@ -1136,7 +1194,7 @@ var TOP_MARGIN = 5.0,
|
||||
if (alternateImage)
|
||||
[_imageView setImage:alternateImage];
|
||||
|
||||
[_labelField setTextShadowOffset:CGSizeMakeZero()];
|
||||
[_labelField setTextShadowOffset:_CGSizeMakeZero()];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1145,7 +1203,7 @@ var TOP_MARGIN = 5.0,
|
||||
if (image)
|
||||
[_imageView setImage:image];
|
||||
|
||||
[_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
|
||||
[_labelField setTextShadowOffset:_CGSizeMake(0.0, 1.0)];
|
||||
}
|
||||
|
||||
[_labelField setTextShadowColor:[self FIXME_labelShadowColor]];
|
||||
|
||||
@@ -24,7 +24,7 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
|
||||
if (self)
|
||||
{
|
||||
var theClass = [self class],
|
||||
bounds = [self bounds];
|
||||
bounds = [self bounds];
|
||||
|
||||
_bodyView = [[CPView alloc] initWithFrame:_CGRectMake(0.0, 0.0, _CGRectGetWidth(bounds), _CGRectGetHeight(bounds))];
|
||||
|
||||
@@ -54,4 +54,4 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
|
||||
return aContentRect;
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
@implementation CPCibHelpConnector : CPCibConnector
|
||||
{
|
||||
id _destination;
|
||||
id _file;
|
||||
id _marker;
|
||||
id _file;
|
||||
id _marker;
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
|
||||
@@ -193,7 +193,7 @@ function CGColorSpaceRetain(aColorSpace)
|
||||
}
|
||||
|
||||
// FIXME: We should refer to some default values.
|
||||
#define STANDARDIZE(components, index, minimum, maximum, multiplier) \
|
||||
#define STANDARDIZE(components, index, minimum, maximum, multiplier) \
|
||||
{ \
|
||||
if (index > components.length) \
|
||||
{ \
|
||||
|
||||
@@ -192,6 +192,8 @@ var ModifierKeyCodes = [
|
||||
],
|
||||
supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
|
||||
var resizeTimer = nil;
|
||||
|
||||
@implementation CPPlatformWindow (DOM)
|
||||
|
||||
- (id)_init
|
||||
@@ -1083,6 +1085,21 @@ var ModifierKeyCodes = [
|
||||
|
||||
- (void)resizeEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
// This is a hack for the browser resize bug in safari.
|
||||
// See bug ID: 1325
|
||||
// https://github.com/cappuccino/cappuccino/issues/1325
|
||||
// Addendum by Antoine Mercadal : I also noticed that reszing is causing
|
||||
// problem under latest Firefox 13.0. Let's just use this hack
|
||||
// for all browser now.
|
||||
|
||||
[resizeTimer invalidate];
|
||||
resizeTimer = [CPTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(_actualResizeEvent) userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
- (void)_actualResizeEvent
|
||||
{
|
||||
resizeTimer = nil;
|
||||
|
||||
// FIXME: This is not the right way to do this.
|
||||
// We should pay attention to mouse down and mouse up in conjunction with this.
|
||||
//window.liveResize = YES;
|
||||
|
||||
|
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 127 B |
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 122 B |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 145 B |
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 138 B |
|
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 141 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 136 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 142 B |
|
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 148 B |
@@ -31,9 +31,8 @@
|
||||
[_CPCibCustomResource imageResourceWithName:"horizontal-track-center.png" size:CPSizeMake(1.0, 4.0)],
|
||||
[_CPCibCustomResource imageResourceWithName:"horizontal-track-right.png" size:CPSizeMake(2.0, 4.0)]
|
||||
]
|
||||
isVertical:NO]];
|
||||
|
||||
var horizontalSlider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 24.0)];
|
||||
isVertical:NO]],
|
||||
horizontalSlider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 24.0)];
|
||||
|
||||
[horizontalSlider setTrackWidth:4.0];
|
||||
[horizontalSlider setHorizontalTrackColor:horizontalTrackColor];
|
||||
@@ -55,9 +54,8 @@
|
||||
[_CPCibCustomResource imageResourceWithName:"vertical-track-center.png" size:CPSizeMake(4.0, 1.0)],
|
||||
[_CPCibCustomResource imageResourceWithName:"vertical-track-bottom.png" size:CPSizeMake(4.0, 2.0)]
|
||||
]
|
||||
isVertical:YES]];
|
||||
|
||||
var verticalSlider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 24.0, 50.0)];
|
||||
isVertical:YES]],
|
||||
verticalSlider = [[CPSlider alloc] initWithFrame:CGRectMake(0.0, 0.0, 24.0, 50.0)];
|
||||
|
||||
[verticalSlider setTrackWidth:4];
|
||||
[verticalSlider setVerticalTrackColor:verticalTrackColor];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* _CPToolTipWindowView.j
|
||||
* _CPAttachedWindow.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Antoine Mercadal
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* _CPAutocompleteMenu.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by Alexander Ljungberg on May 10, 2012.
|
||||
* Copyright 2012, Alexander Ljungberg. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@import "CPTextField.j"
|
||||
@import "_CPMenuWindow.j"
|
||||
|
||||
// TODO Make themable.
|
||||
var _CPAutocompleteMenuMaximumHeight = 307;
|
||||
|
||||
/*!
|
||||
An "autocomplete" menu displayed by a text field.
|
||||
*/
|
||||
@implementation _CPAutocompleteMenu : CPObject
|
||||
{
|
||||
CPTextField textField @accessors;
|
||||
CPArray contentArray @accessors;
|
||||
float widestItemWidth;
|
||||
|
||||
CPWindow _menuWindow;
|
||||
CPScrollView scrollView;
|
||||
CPTableView tableView;
|
||||
|
||||
CPTimer _showCompletionsTimer;
|
||||
}
|
||||
|
||||
- (id)initWithTextField:(CPTextField)aTextField
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
textField = aTextField;
|
||||
|
||||
_menuWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 100, 100) styleMask:CPBorderlessWindowMask];
|
||||
|
||||
[_menuWindow setLevel:CPPopUpMenuWindowLevel];
|
||||
[_menuWindow setHasShadow:YES];
|
||||
[_menuWindow setShadowStyle:CPMenuWindowShadowStyle];
|
||||
[_menuWindow setAcceptsMouseMovedEvents:NO];
|
||||
[_menuWindow setBackgroundColor:[_CPMenuWindow backgroundColorForBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle]];
|
||||
|
||||
var contentView = [_menuWindow contentView];
|
||||
|
||||
scrollView = [[CPScrollView alloc] initWithFrame:CGRectMakeZero()];
|
||||
[scrollView setAutohidesScrollers:YES];
|
||||
[scrollView setHasHorizontalScroller:NO];
|
||||
[contentView addSubview:scrollView];
|
||||
|
||||
tableView = [[CPTableView alloc] initWithFrame:CPRectMakeZero()];
|
||||
|
||||
var tableColumn = [CPTableColumn new];
|
||||
[tableColumn setResizingMask:CPTableColumnAutoresizingMask];
|
||||
[tableView addTableColumn:tableColumn];
|
||||
|
||||
[tableView setDataSource:self];
|
||||
[tableView setDelegate:self];
|
||||
[tableView setAllowsMultipleSelection:NO];
|
||||
[tableView setHeaderView:nil];
|
||||
[tableView setCornerView:nil];
|
||||
[tableView setRowHeight:24.0];
|
||||
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask];
|
||||
[tableView setBackgroundColor:[CPColor clearColor]];
|
||||
[tableView setGridColor:[CPColor colorWithRed:242.0 / 255.0 green:243.0 / 255.0 blue:245.0 / 255.0 alpha:1.0]];
|
||||
|
||||
[scrollView setDocumentView:tableView];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set an array of strings to use as the available completions.
|
||||
*/
|
||||
- (void)setContentArray:(CPArray)anArray
|
||||
{
|
||||
if (contentArray === anArray || [contentArray isEqualToArray:anArray])
|
||||
return;
|
||||
|
||||
contentArray = [anArray copy];
|
||||
|
||||
// Go away automatically if there are no suggestions.
|
||||
if (![contentArray count])
|
||||
[self _hideCompletions];
|
||||
|
||||
widestItemWidth = CPNotFound;
|
||||
|
||||
[tableView reloadData];
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)setIndexOfSelectedItem:(int)anIndex
|
||||
{
|
||||
[tableView selectRowIndexes:[CPIndexSet indexSetWithIndex:anIndex] byExtendingSelection:NO];
|
||||
[tableView scrollRowToVisible:anIndex];
|
||||
}
|
||||
|
||||
- (int)indexOfSelectedItem
|
||||
{
|
||||
return [tableView selectedRow];
|
||||
}
|
||||
|
||||
- (CPString)selectedItem
|
||||
{
|
||||
return contentArray ? contentArray[[tableView selectedRow]] : nil;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
// TODO
|
||||
/*
|
||||
The autocompletion menu should be underneath the word/text being
|
||||
autocompleted. It should at least be wide enough to fit the widest option
|
||||
but no wider than the width of the text field. It might stick out on the
|
||||
right side, so that if the edited text is on the right of the text field
|
||||
the menu might extend a full text field width more into space on the right
|
||||
side. It should not stick out outside of the screen. The height should be
|
||||
the smallest possible to fit all options or at most ~307px (based on
|
||||
Cocoa). If the options don't fit horizontally they should be truncated
|
||||
with an ellipsis.
|
||||
*/
|
||||
|
||||
var frame = [textField frame],
|
||||
origin = frame.origin,
|
||||
tableColumn = [[tableView tableColumns] firstObject];
|
||||
|
||||
if ([textField respondsToSelector:@selector(_completionOrigin:)])
|
||||
origin = [textField _completionOrigin:self];
|
||||
|
||||
if (widestItemWidth === CPNotFound)
|
||||
{
|
||||
// This calculation could be slow for many items.
|
||||
|
||||
var dataView = [tableColumn dataView],
|
||||
fontNormal = [dataView valueForThemeAttribute:@"font" inState:CPThemeStateTableDataView],
|
||||
fontSelected = [dataView valueForThemeAttribute:@"font" inState:CPThemeStateTableDataView | CPThemeStateSelectedTableDataView],
|
||||
contentInsetNormal = [dataView valueForThemeAttribute:@"content-inset" inState:CPThemeStateTableDataView],
|
||||
contentInsetSelected = [dataView valueForThemeAttribute:@"content-inset" inState:CPThemeStateTableDataView | CPThemeStateSelectedTableDataView];
|
||||
|
||||
var mergedString = contentArray.join("\n");
|
||||
|
||||
widestItemWidth = MAX([mergedString sizeWithFont:fontNormal].width + contentInsetNormal.left + contentInsetNormal.right, [mergedString sizeWithFont:fontSelected].width + contentInsetSelected.left + contentInsetSelected.right) + [tableView intercellSpacing].width + 2.0 + 5.0; // 2.0 because we inset by 1.0 below, 5.0 mystery constant.
|
||||
// TODO Track down why mystery constant is needed to allocate enough width. Scroll view insets?
|
||||
}
|
||||
|
||||
var frameOrigin = [textField convertPoint:origin toView:nil],
|
||||
screenSize = [([CPPlatform isBrowser] ? [_menuWindow platformWindow] : [_menuWindow screen]) visibleFrame].size,
|
||||
availableWidth = screenSize.width - frameOrigin.x,
|
||||
availableHeight = screenSize.height - frameOrigin.y,
|
||||
width = MIN(widestItemWidth, availableWidth),
|
||||
spacingHeight = [tableView intercellSpacing].height,
|
||||
height = MIN(MIN(spacingHeight + [contentArray count] * ([tableView rowHeight] + spacingHeight), _CPAutocompleteMenuMaximumHeight), availableHeight),
|
||||
newFrame = CGRectMake(frameOrigin.x, frameOrigin.y, width, height);
|
||||
|
||||
newFrame = [_menuWindow frameRectForContentRect:newFrame];
|
||||
[_menuWindow setFrame:newFrame];
|
||||
|
||||
var scrollFrame = CGRectInset([[_menuWindow contentView] bounds], 1.0, 1.0);
|
||||
[scrollView setFrame:scrollFrame];
|
||||
|
||||
[tableColumn setWidth:[[scrollView contentView] frame].size.width];
|
||||
}
|
||||
|
||||
- (void)_showCompletions:(CPTimer)timer
|
||||
{
|
||||
var indexOfSelectedItem = [self indexOfSelectedItem];
|
||||
|
||||
[self setContentArray:[textField _completionsForSubstring:[textField _inputElement].value indexOfToken:0 indexOfSelectedItem:indexOfSelectedItem]];
|
||||
|
||||
if (![contentArray count])
|
||||
return;
|
||||
|
||||
// TODO Support indexOfSelectedItem. Always 0 right now.
|
||||
[self setIndexOfSelectedItem:indexOfSelectedItem];
|
||||
|
||||
[textField setThemeState:CPThemeStateAutocompleting];
|
||||
[_menuWindow orderFront:self];
|
||||
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)_delayedShowCompletions
|
||||
{
|
||||
var completionDelay = 0.5;
|
||||
|
||||
if ([textField respondsToSelector:@selector(completionDelay)])
|
||||
completionDelay = [textField completionDelay];
|
||||
|
||||
_showCompletionsTimer = [CPTimer scheduledTimerWithTimeInterval:completionDelay
|
||||
target:self
|
||||
selector:@selector(_showCompletions:)
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
}
|
||||
|
||||
- (void)_hideCompletions
|
||||
{
|
||||
[_showCompletionsTimer invalidate];
|
||||
_showCompletionsTimer = nil;
|
||||
|
||||
[textField unsetThemeState:CPThemeStateAutocompleting];
|
||||
[_menuWindow orderOut:self];
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)selectNext
|
||||
{
|
||||
var index = [self indexOfSelectedItem] + 1;
|
||||
|
||||
if (index >= [contentArray count])
|
||||
return;
|
||||
|
||||
[self setIndexOfSelectedItem:index];
|
||||
}
|
||||
|
||||
- (void)selectPrevious
|
||||
{
|
||||
var index = [self indexOfSelectedItem] - 1;
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
[self setIndexOfSelectedItem:index];
|
||||
}
|
||||
|
||||
- (int)numberOfRowsInTableView:(CPTableView)tableView
|
||||
{
|
||||
return [contentArray count];
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
{
|
||||
return [contentArray objectAtIndex:row];
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(CPNotification)notification
|
||||
{
|
||||
// FIXME
|
||||
// make sure a mouse click in the tableview doesn't steal first responder state
|
||||
window.setTimeout(function()
|
||||
{
|
||||
[[textField window] makeFirstResponder:textField];
|
||||
}, 2.0);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -334,7 +334,16 @@
|
||||
|
||||
- (void)sortUsingDescriptors:(CPArray)descriptors
|
||||
{
|
||||
[self sortUsingFunction:compareObjectsUsingDescriptors context:descriptors];
|
||||
var i = [descriptors count],
|
||||
jsDescriptors = [];
|
||||
|
||||
// Revert the order of the descriptors
|
||||
while (i--)
|
||||
{
|
||||
var d = [descriptors objectAtIndex:i];
|
||||
[jsDescriptors addObject:{ "k": [d key], "a": [d ascending], "s": [d selector]}];
|
||||
}
|
||||
sortArrayUsingJSDescriptors(self, jsDescriptors);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -344,46 +353,7 @@
|
||||
*/
|
||||
- (void)sortUsingFunction:(Function)aFunction context:(id)aContext
|
||||
{
|
||||
var h,
|
||||
i,
|
||||
j,
|
||||
k,
|
||||
l,
|
||||
m,
|
||||
n = [self count],
|
||||
o;
|
||||
|
||||
var A,
|
||||
B = [];
|
||||
|
||||
for (h = 1; h < n; h += h)
|
||||
{
|
||||
for (m = n - 1 - h; m >= 0; m -= h + h)
|
||||
{
|
||||
l = m - h + 1;
|
||||
if (l < 0)
|
||||
l = 0;
|
||||
|
||||
for (i = 0, j = l; j <= m; i++, j++)
|
||||
B[i] = self[j];
|
||||
|
||||
for (i = 0, k = l; k < j && j <= m + h; k++)
|
||||
{
|
||||
A = self[j];
|
||||
o = aFunction(A, B[i], aContext);
|
||||
if (o >= 0)
|
||||
self[k] = B[i++];
|
||||
else
|
||||
{
|
||||
self[k] = A;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
while (k < j)
|
||||
self[k++] = B[i++];
|
||||
}
|
||||
}
|
||||
sortArrayUsingFunction(self, aFunction, aContext);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -392,7 +362,7 @@
|
||||
*/
|
||||
- (void)sortUsingSelector:(SEL)aSelector
|
||||
{
|
||||
[self sortUsingFunction:selectorCompare context:aSelector];
|
||||
sortArrayUsingFunction(self, selectorCompare, aSelector);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -408,20 +378,163 @@
|
||||
|
||||
@end
|
||||
|
||||
var selectorCompare = function selectorCompare(object1, object2, selector)
|
||||
var selectorCompare = function(object1, object2, selector)
|
||||
{
|
||||
return [object1 performSelector:selector withObject:object2];
|
||||
};
|
||||
|
||||
// sort using sort descriptors
|
||||
var compareObjectsUsingDescriptors= function compareObjectsUsingDescriptors(lhs, rhs, descriptors)
|
||||
var sortArrayUsingFunction = function(array, aFunction, aContext)
|
||||
{
|
||||
var result = CPOrderedSame,
|
||||
i = 0,
|
||||
n = [descriptors count];
|
||||
var h,
|
||||
i,
|
||||
j,
|
||||
k,
|
||||
l,
|
||||
m,
|
||||
n = array.length,
|
||||
o;
|
||||
|
||||
while (i < n && result === CPOrderedSame)
|
||||
result = [descriptors[i++] compareObject:lhs withObject:rhs];
|
||||
var A,
|
||||
B = [];
|
||||
|
||||
return result;
|
||||
};
|
||||
for (h = 1; h < n; h += h)
|
||||
{
|
||||
for (m = n - 1 - h; m >= 0; m -= h + h)
|
||||
{
|
||||
l = m - h + 1;
|
||||
if (l < 0)
|
||||
l = 0;
|
||||
|
||||
for (i = 0, j = l; j <= m; i++, j++)
|
||||
B[i] = array[j];
|
||||
|
||||
for (i = 0, k = l; k < j && j <= m + h; k++)
|
||||
{
|
||||
A = array[j];
|
||||
o = aFunction(A, B[i], aContext);
|
||||
|
||||
if (o >= 0)
|
||||
array[k] = B[i++];
|
||||
else
|
||||
{
|
||||
array[k] = A;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
while (k < j)
|
||||
array[k++] = B[i++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Observe that the sort descriptors has the reversed order by the caller
|
||||
var sortArrayUsingJSDescriptors = function(a, d)
|
||||
{
|
||||
var h,
|
||||
i,
|
||||
j,
|
||||
k,
|
||||
l,
|
||||
m,
|
||||
n = a.length,
|
||||
dl = d.length - 1,
|
||||
o,
|
||||
c = {};
|
||||
|
||||
var A,
|
||||
B = [],
|
||||
C1,
|
||||
C2,
|
||||
cn,
|
||||
aUID,
|
||||
bUID,
|
||||
key,
|
||||
dd;
|
||||
|
||||
if (dl < 0)
|
||||
return;
|
||||
|
||||
for (h = 1; h < n; h += h)
|
||||
{
|
||||
for (m = n - 1 - h; m >= 0; m -= h + h)
|
||||
{
|
||||
l = m - h + 1;
|
||||
|
||||
if (l < 0)
|
||||
l = 0;
|
||||
|
||||
for (i = 0, j = l; j <= m; i++, j++)
|
||||
B[i] = a[j];
|
||||
|
||||
for (i = 0, k = l; k < j && j <= m + h; k++)
|
||||
{
|
||||
A = a[j];
|
||||
aUID = A._UID;
|
||||
|
||||
if (!aUID)
|
||||
aUID = [A UID];
|
||||
|
||||
C1 = c[aUID];
|
||||
|
||||
if (!C1)
|
||||
{
|
||||
C1 = {};
|
||||
cn = dl;
|
||||
|
||||
do
|
||||
{
|
||||
key = d[cn].k;
|
||||
C1[key] = [A valueForKey:key];
|
||||
} while (cn--)
|
||||
|
||||
c[aUID] = C1;
|
||||
}
|
||||
|
||||
bUID = B[i]._UID;
|
||||
|
||||
if (!bUID)
|
||||
bUID = [B[i] UID];
|
||||
|
||||
C2 = c[bUID];
|
||||
|
||||
if (!C2)
|
||||
{
|
||||
C2 = {};
|
||||
cn = dl;
|
||||
|
||||
do
|
||||
{
|
||||
key = d[cn].k;
|
||||
C2[key] = [B[i] valueForKey:key];
|
||||
} while (cn--)
|
||||
|
||||
c[bUID] = C2;
|
||||
}
|
||||
|
||||
cn = dl;
|
||||
|
||||
do
|
||||
{
|
||||
dd = d[cn];
|
||||
key = dd.k;
|
||||
o = objj_msgSend(C1[key], dd.s, C2[key]);
|
||||
|
||||
if (o && !dd.a)
|
||||
o = -o;
|
||||
} while (cn-- && o == CPOrderedSame)
|
||||
|
||||
if (o >= 0)
|
||||
a[k] = B[i++];
|
||||
else
|
||||
{
|
||||
a[k] = A;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
while (k < j)
|
||||
a[k++] = B[i++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,7 +823,7 @@ var makeRangeEntry = function makeRangeEntry(/*CPRange*/aRange, /*CPDictionary*/
|
||||
|
||||
var copyRangeEntry = function copyRangeEntry(/*RangeEntry*/aRangeEntry)
|
||||
{
|
||||
return makeRangeEntry(CPCopyRange(aRangeEntry.range), [aRangeEntry.attributes copy]);
|
||||
return makeRangeEntry(CPMakeRangeCopy(aRangeEntry.range), [aRangeEntry.attributes copy]);
|
||||
};
|
||||
|
||||
var splitRangeEntry = function splitRangeEntryAtIndex(/*RangeEntry*/aRangeEntry, /*unsigned*/anIndex)
|
||||
|
||||
@@ -24,14 +24,12 @@
|
||||
@import "CPString.j"
|
||||
@import "CPException.j"
|
||||
|
||||
var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0));
|
||||
var CPDateReferenceDate = new Date(Date.UTC(2001, 0, 1, 0, 0, 0, 0));
|
||||
|
||||
/*!
|
||||
@class CPDate
|
||||
@ingroup foundation
|
||||
@brief A representation of a single point in time.
|
||||
|
||||
|
||||
*/
|
||||
@implementation CPDate : CPObject
|
||||
{
|
||||
@@ -66,12 +64,12 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0));
|
||||
|
||||
+ (id)distantPast
|
||||
{
|
||||
return new Date(-10000, 1, 1, 0, 0, 0, 0);
|
||||
return [CPDate dateWithTimeIntervalSinceReferenceDate:-63113817600.0];
|
||||
}
|
||||
|
||||
+ (id)distantFuture
|
||||
{
|
||||
return new Date(10000, 1, 1, 0, 0, 0, 0);
|
||||
return [CPDate dateWithTimeIntervalSinceReferenceDate:63113990400.0];
|
||||
}
|
||||
|
||||
- (id)initWithTimeIntervalSinceNow:(CPTimeInterval)seconds
|
||||
@@ -169,7 +167,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0));
|
||||
|
||||
- (CPComparisonResult)compare:(CPDate)anotherDate
|
||||
{
|
||||
return (self > anotherDate) ? CPOrderedDescending : ((self < anotherDate) ? CPOrderedAscending : CPOrderedSame);
|
||||
return (self > anotherDate) ? CPOrderedDescending : ((self < anotherDate) ? CPOrderedAscending : CPOrderedSame);
|
||||
}
|
||||
|
||||
- (CPDate)earlierDate:(CPDate)anotherDate
|
||||
@@ -200,7 +198,7 @@ var CPDateReferenceDate = new Date(Date.UTC(2001, 1, 1, 0, 0, 0, 0));
|
||||
*/
|
||||
- (CPString)description
|
||||
{
|
||||
return [CPString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d %s", self.getFullYear(), self.getMonth()+1, self.getDate(), self.getHours(), self.getMinutes(), self.getSeconds(), [CPDate timezoneOffsetString:self.getTimezoneOffset()]];
|
||||
return [CPString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d %s", self.getFullYear(), self.getMonth() + 1, self.getDate(), self.getHours(), self.getMinutes(), self.getSeconds(), [CPDate timezoneOffsetString:self.getTimezoneOffset()]];
|
||||
}
|
||||
|
||||
- (id)copy
|
||||
@@ -245,7 +243,7 @@ Date.parseISO8601 = function (date)
|
||||
|
||||
if (isNaN(timestamp) && (struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(date)))
|
||||
{
|
||||
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
|
||||
// avoid NaN timestamps caused by "undefined" values being passed to Date.UTC
|
||||
for (var i = 0, k; (k = numericKeys[i]); ++i)
|
||||
struct[k] = +struct[k] || 0;
|
||||
|
||||
|
||||
@@ -99,12 +99,10 @@ CPDateFormatterFullStyle = 4;
|
||||
|
||||
- (BOOL)getObjectValue:(id)anObject forString:(CPString)aString errorDescription:(CPString)anError
|
||||
{
|
||||
console.log("getObjectValue: forString:" + aString);
|
||||
// TODO Error handling.
|
||||
var value = [self dateFromString:aString];
|
||||
AT_DEREF(anObject, value);
|
||||
|
||||
console.log("got " + value);
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ function CPDecimalMakeWithParts(mantissa, exponent)
|
||||
var m = [],
|
||||
isNegative = NO;
|
||||
|
||||
if (mantissa < 0 )
|
||||
if (mantissa < 0)
|
||||
{
|
||||
isNegative = YES;
|
||||
mantissa = ABS(mantissa);
|
||||
@@ -1400,10 +1400,9 @@ function CPDecimalRound(result, dcm, scale ,roundingMode)
|
||||
function CPDecimalCompact(dcm)
|
||||
{
|
||||
// if positive or zero exp leading zeros simply delete, trailing ones u need to increment exponent
|
||||
if (!dcm || dcm._mantissa.length == 0 || CPDecimalIsNotANumber(dcm) )
|
||||
if (!dcm || dcm._mantissa.length == 0 || CPDecimalIsNotANumber(dcm))
|
||||
return;
|
||||
|
||||
|
||||
if (CPDecimalIsZero(dcm))
|
||||
{
|
||||
// handle zero number compacting
|
||||
|
||||
@@ -20,14 +20,12 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "CPRange.h"
|
||||
|
||||
@import "CPArray.j"
|
||||
@import "CPObject.j"
|
||||
@import "CPRange.j"
|
||||
|
||||
#define _CPMaxRange(aRange) ((aRange).location + (aRange).length)
|
||||
#define _CPMakeRange(aLocation, aLength) { location:(aLocation), length:aLength }
|
||||
#define _CPMakeRangeCopy(aRange) { location:(aRange).location, length:(aRange).length }
|
||||
|
||||
/*!
|
||||
@class CPIndexSet
|
||||
@ingroup foundation
|
||||
|
||||
@@ -222,7 +222,8 @@ FIXME: Do we need this?
|
||||
|
||||
- (CPString)descriptionWithLocale:(CPDictionary)aDictionary
|
||||
{
|
||||
if (!aDictionary) return toString();
|
||||
if (!aDictionary)
|
||||
return toString();
|
||||
|
||||
throw new Error("descriptionWithLocale: NOT YET IMPLEMENTED");
|
||||
}
|
||||
@@ -234,37 +235,43 @@ FIXME: Do we need this?
|
||||
|
||||
- (double)doubleValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (float)floatValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int)intValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (long long)longLongValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (long)longValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (short)shortValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -280,7 +287,8 @@ FIXME: Do we need this?
|
||||
|
||||
- (unsigned int)unsignedIntValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
/*
|
||||
@@ -292,20 +300,24 @@ FIXME: Do we need this?
|
||||
*/
|
||||
- (unsigned long)unsignedLongValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (unsigned short)unsignedShortValue
|
||||
{
|
||||
if (typeof self == "boolean") return self ? 1 : 0;
|
||||
if (typeof self == "boolean")
|
||||
return self ? 1 : 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPComparisonResult)compare:(CPNumber)aNumber
|
||||
{
|
||||
if (self > aNumber) return CPOrderedDescending;
|
||||
else if (self < aNumber) return CPOrderedAscending;
|
||||
if (self > aNumber)
|
||||
return CPOrderedDescending;
|
||||
else if (self < aNumber)
|
||||
return CPOrderedAscending;
|
||||
|
||||
return CPOrderedSame;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* CPRange.h
|
||||
* Foundation
|
||||
*
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2012, SlevenBits Ltd.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define _CPMaxRange(aRange) ((aRange).location + (aRange).length)
|
||||
#define _CPMakeRange(aLocation, aLength) { location:(aLocation), length:aLength }
|
||||
#define _CPMakeRangeCopy(aRange) { location:(aRange).location, length:(aRange).length }
|
||||
@@ -20,6 +20,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define _function(inline) function inline { return _##inline; }
|
||||
|
||||
#include "CPRange.h"
|
||||
|
||||
/*!
|
||||
@addtogroup foundation
|
||||
@{
|
||||
@@ -32,10 +36,7 @@
|
||||
@group CPRange
|
||||
@return CPRange the new range object
|
||||
*/
|
||||
function CPMakeRange(location, length)
|
||||
{
|
||||
return { location: location, length: length };
|
||||
}
|
||||
_function(CPMakeRange(location, length))
|
||||
|
||||
/*!
|
||||
Makes a copy of a CPRange.
|
||||
@@ -43,21 +44,7 @@ function CPMakeRange(location, length)
|
||||
@group CPRange
|
||||
@return CPRange the copy of the range
|
||||
*/
|
||||
function CPCopyRange(aRange)
|
||||
{
|
||||
return { location: aRange.location, length: aRange.length };
|
||||
}
|
||||
|
||||
/*!
|
||||
Makes a copy of a CPRange.
|
||||
@param aRange the CPRange to copy
|
||||
@group CPRange
|
||||
@return CPRange the copy of the range
|
||||
*/
|
||||
function CPMakeRangeCopy(aRange)
|
||||
{
|
||||
return { location:aRange.location, length:aRange.length };
|
||||
}
|
||||
_function(CPMakeRangeCopy(aRange))
|
||||
|
||||
/*!
|
||||
Determines if a range is empty \c length is 0.
|
||||
@@ -76,10 +63,7 @@ function CPEmptyRange(aRange)
|
||||
@group CPRange
|
||||
@return int the range maximum
|
||||
*/
|
||||
function CPMaxRange(aRange)
|
||||
{
|
||||
return aRange.location + aRange.length;
|
||||
}
|
||||
_function(CPMaxRange(aRange))
|
||||
|
||||
/*!
|
||||
Determines if two CPRanges are equal.
|
||||
|
||||
@@ -292,7 +292,7 @@
|
||||
|
||||
loc += (""+f).length;
|
||||
var i = 0;
|
||||
while (!isNaN(parseFloat(str.substring(loc+i, str.length))))
|
||||
while (!isNaN(parseFloat(str.substring(loc + i, str.length))))
|
||||
{i++;}
|
||||
|
||||
[self setScanLocation:loc + i];
|
||||
|
||||
@@ -111,11 +111,27 @@
|
||||
{
|
||||
// Verify that the split view does not attempt to auto save without an auto save name.
|
||||
|
||||
// This storage class will cause a crash if a save is attempted.
|
||||
[[CPUserDefaults standardUserDefaults] setPersistentStoreClass:CPUserDefaultsFailingStore forDomain:CPApplicationDomain reloadData:NO];
|
||||
|
||||
[splitView setPosition:50 ofDividerAtIndex:0];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
// Now test that it does work normally.
|
||||
[[CPUserDefaults standardUserDefaults] setPersistentStoreClass:CPUserDefaultsTestStore forDomain:CPApplicationDomain reloadData:NO];
|
||||
[splitView setAutosaveName:@"Charles"];
|
||||
[splitView setPosition:25 ofDividerAtIndex:0];
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
// Recreate the split view.
|
||||
[self setUp];
|
||||
[splitView setAutosaveName:@"Charles"];
|
||||
// FIXME At the moment restore from autosave only happens if the split view is loaded from a
|
||||
// coder. It seems like it should happen when initialising in code too, but some research of
|
||||
// Cocoa's behaviour will need to be done first.
|
||||
splitView._needsRestoreFromAutosave = YES;
|
||||
// Trigger autosave restore.
|
||||
[splitView setFrameSize:CGSizeMake(110, 100)];
|
||||
[self assert:25 equals:[viewA frameSize].height message:@"divider position restored"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -131,6 +147,7 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
This store always fails.
|
||||
*/
|
||||
@@ -149,3 +166,24 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
This is a temporary store.
|
||||
*/
|
||||
@implementation CPUserDefaultsTestStore : CPUserDefaultsStore
|
||||
{
|
||||
CPData _data;
|
||||
}
|
||||
|
||||
- (CPData)data
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
- (void)setData:(CPData)aData
|
||||
{
|
||||
_data = aData;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1,72 +1,136 @@
|
||||
var FILE = require("file");
|
||||
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPString.j>
|
||||
@import <Foundation/CPNumber.j>
|
||||
@import <Foundation/CPSortDescriptor.j>
|
||||
|
||||
|
||||
var ELEMENTS = 100,
|
||||
REPEATS = 10;
|
||||
|
||||
@implementation CPArrayPerformanceTest : OJTestCase
|
||||
|
||||
- (void)testSortUsingDescriptorsSpeed
|
||||
{
|
||||
var array = [self makeUnsorted];
|
||||
|
||||
var descriptors = [
|
||||
[CPSortDescriptor sortDescriptorWithKey:"a" ascending:NO],
|
||||
[CPSortDescriptor sortDescriptorWithKey:"b" ascending:YES]
|
||||
];
|
||||
|
||||
var start = (new Date).getTime();
|
||||
|
||||
for (var i = 0; i < REPEATS; ++i)
|
||||
{
|
||||
var sorted = [array sortedArrayUsingDescriptors:descriptors];
|
||||
|
||||
[self checkSorted:sorted];
|
||||
}
|
||||
|
||||
var end = (new Date).getTime();
|
||||
|
||||
CPLog.warn(_cmd + ": " + (end - start) + "ms");
|
||||
CPArray descriptors;
|
||||
}
|
||||
|
||||
- (void)testSortUsingNativeSort
|
||||
- (void)setUp
|
||||
{
|
||||
var array = [self makeUnsorted];
|
||||
|
||||
var descriptors = [
|
||||
[CPSortDescriptor sortDescriptorWithKey:"a" ascending:NO],
|
||||
[CPSortDescriptor sortDescriptorWithKey:"b" ascending:YES]
|
||||
];
|
||||
[CPSortDescriptor sortDescriptorWithKey:"a" ascending:NO],
|
||||
[CPSortDescriptor sortDescriptorWithKey:"b" ascending:YES]
|
||||
];
|
||||
}
|
||||
|
||||
function sortFunction(lhs, rhs)
|
||||
{
|
||||
return ([lhs a] === [rhs a]) ? ([lhs b] - [rhs b]) : ([rhs a] - [lhs a]);
|
||||
}
|
||||
- (void)testAlmostSortedNumericUsingMergeSort
|
||||
{
|
||||
CPLog.warn("\nNUMERIC ALMOST SORTED");
|
||||
var a = [self makeUnsorted],
|
||||
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingDescriptors:) withObject:descriptors];
|
||||
[self checkAlmostSorted:sorted];
|
||||
}
|
||||
|
||||
var start = (new Date).getTime();
|
||||
- (void)testAlmostSortedNumericUsingNativeSort
|
||||
{
|
||||
var a = [self makeUnsorted],
|
||||
sorted = [self sort:a usingSortSelector:@selector(_native_sortedArrayUsingDescriptors:) withObject:descriptors];
|
||||
[self checkAlmostSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomNumericUsingMergeSort
|
||||
{
|
||||
CPLog.warn("\nNUMERIC RANDOM");
|
||||
var a = [self makeRandomNumeric],
|
||||
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingDescriptors:) withObject:descriptors];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomNumericUsingNativeSort
|
||||
{
|
||||
var a = [self makeRandomNumeric],
|
||||
sorted = [self sort:a usingSortSelector:@selector(_native_sortedArrayUsingDescriptors:) withObject:descriptors];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomTextUsingMergeSort
|
||||
{
|
||||
CPLog.warn("\nTEXT RANDOM");
|
||||
var a = [self makeRandomText],
|
||||
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingDescriptors:) withObject:descriptors];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomTextUsingNativeSort
|
||||
{
|
||||
var a = [self makeRandomText],
|
||||
sorted = [self sort:a usingSortSelector:@selector(_native_sortedArrayUsingDescriptors:) withObject:descriptors];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testAlmostSortedNumericUsingMergeSelectorSort
|
||||
{
|
||||
CPLog.warn("\nNUMERIC ALMOST SORTED (SELECTOR)");
|
||||
var a = [self makeUnsorted],
|
||||
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
|
||||
[self checkAlmostSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testAlmostSortedNumericUsingNativeSelectorSort
|
||||
{
|
||||
var a = [self makeUnsorted],
|
||||
sorted = [self sort:a usingSortSelector:@selector(_native_sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
|
||||
[self checkAlmostSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomNumericUsingMergeSelectorSort
|
||||
{
|
||||
CPLog.warn("\nNUMERIC RANDOM (SELECTOR)");
|
||||
var a = [self makeRandomNumeric],
|
||||
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomNumericUsingNativeSelectorSort
|
||||
{
|
||||
var a = [self makeRandomNumeric],
|
||||
sorted = [self sort:a usingSortSelector:@selector(_native_sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomTextUsingMergeSelectorSort
|
||||
{
|
||||
CPLog.warn("\nTEXT RANDOM (SELECTOR)");
|
||||
var a = [self makeRandomText],
|
||||
sorted = [self sort:a usingSortSelector:@selector(sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (void)testRandomTextUsingNativeSelectorSort
|
||||
{
|
||||
var a = [self makeRandomText],
|
||||
sorted = [self sort:a usingSortSelector:@selector(_native_sortedArrayUsingSelector:) withObject:@selector(compareAAscendingThenBDescending:)];
|
||||
[self checkRandomSorted:sorted];
|
||||
}
|
||||
|
||||
- (CPArray)sort:(CPArray)anArray usingSortSelector:(SEL)aSelector withObject:(id)anObject
|
||||
{
|
||||
var sorted,
|
||||
start = (new Date).getTime();
|
||||
|
||||
for (var i = 0; i < REPEATS; ++i)
|
||||
{
|
||||
var sorted = [array copy];
|
||||
|
||||
sorted.sort(sortFunction)
|
||||
|
||||
[self checkSorted:sorted];
|
||||
}
|
||||
sorted = [anArray performSelector:aSelector withObject:anObject];
|
||||
|
||||
var end = (new Date).getTime();
|
||||
|
||||
CPLog.warn(_cmd+": " + (end - start) + "ms");
|
||||
CPLog.warn(aSelector + ": " + (end - start) + "ms");
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
- (CPArray)makeUnsorted
|
||||
{
|
||||
var array = [];
|
||||
|
||||
for (var i=0; i < ELEMENTS; ++i)
|
||||
for (var i = 0; i < ELEMENTS; ++i)
|
||||
{
|
||||
var s = [Sortable new];
|
||||
|
||||
@@ -79,12 +143,49 @@ var ELEMENTS = 100,
|
||||
return array;
|
||||
}
|
||||
|
||||
- (void)checkSorted:(CPArray)sorted
|
||||
- (CPArray)makeRandomNumeric
|
||||
{
|
||||
var array = [];
|
||||
|
||||
for (var i = 0; i < ELEMENTS; i++)
|
||||
{
|
||||
var s = [Sortable new],
|
||||
n1 = ROUND(RAND() * ELEMENTS),
|
||||
n2 = ROUND(RAND() * ELEMENTS);
|
||||
|
||||
[s setA:n1];
|
||||
[s setB:n2];
|
||||
array.push(s);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
- (CPArray)makeRandomText
|
||||
{
|
||||
var the_big_sort = FILE.read(FILE.join(FILE.dirname(module.path), "the_big_sort.txt"), { charset:"UTF-8" }),
|
||||
words = the_big_sort.split(" ", ELEMENTS),
|
||||
wordcount = words.length,
|
||||
array = [];
|
||||
|
||||
for (var i = 0; i < wordcount - 1; i++)
|
||||
{
|
||||
var s = [Sortable new];
|
||||
|
||||
[s setA:words[i]];
|
||||
[s setB:words[i + 1]];
|
||||
array.push(s);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
- (void)checkAlmostSorted:(CPArray)sorted
|
||||
{
|
||||
// Verify it really got sorted.
|
||||
for (var j=0; j < ELEMENTS; ++j)
|
||||
for (var j = 0; j < sorted.length; ++j)
|
||||
{
|
||||
var expectedA = 4-FLOOR(j * 5 / ELEMENTS);
|
||||
var expectedA = 4 - FLOOR(j * 5 / ELEMENTS);
|
||||
|
||||
if (sorted[j].a != expectedA)
|
||||
[self fail:"a out of order: " + expectedA + " != " + sorted[j].a];
|
||||
@@ -96,6 +197,66 @@ var ELEMENTS = 100,
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkRandomSorted:(CPArray)sorted
|
||||
{
|
||||
// Verify that it really got sorted.
|
||||
for (var j = 0; j < sorted.length - 1; ++j)
|
||||
{
|
||||
if ([sorted[j].a compare:sorted[j + 1].a] == CPOrderedAscending)
|
||||
[self fail:"a out of order: " + sorted[j].a + " > " + sorted[j + 1].a];
|
||||
|
||||
if ([sorted[j].a compare:sorted[j + 1].a] == CPOrderedSame && [sorted[j].b compare: sorted[j + 1].b] == CPOrderedDescending)
|
||||
[self fail:"b out of order: " + sorted[j].b + " < " + sorted[j + 1].b];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPArray (NativeSort)
|
||||
|
||||
- (CPArray)_native_sortedArrayUsingDescriptors:(CPArray)descriptors
|
||||
{
|
||||
var sorted = [self copy];
|
||||
|
||||
[sorted _native_sortUsingDescriptors:descriptors];
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
- (CPArray)_native_sortUsingDescriptors:(CPArray)descriptors
|
||||
{
|
||||
var count = [descriptors count];
|
||||
|
||||
sort(function(lhs, rhs)
|
||||
{
|
||||
var i = 0,
|
||||
result = CPOrderedSame;
|
||||
|
||||
while (i < count)
|
||||
if ((result = [descriptors[i++] compareObject:lhs withObject:rhs]) !== CPOrderedSame)
|
||||
return result;
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
- (CPArray)_native_sortedArrayUsingSelector:(SEL)aSelector
|
||||
{
|
||||
var sorted = [self copy];
|
||||
|
||||
[sorted _native_sortUsingSelector:aSelector];
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
- (CPArray)_native_sortUsingSelector:(SEL)aSelector
|
||||
{
|
||||
sort(function(lhs, rhs)
|
||||
{
|
||||
return [lhs performSelector:aSelector withObject:rhs];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation Sortable : CPObject
|
||||
@@ -104,4 +265,11 @@ var ELEMENTS = 100,
|
||||
int b @accessors;
|
||||
}
|
||||
|
||||
- (int)compareAAscendingThenBDescending:(Sortable)other
|
||||
{
|
||||
var aResult = [a compare:other.a];
|
||||
|
||||
return aResult === CPOrderedSame ? [b compare:other.b] : -aResult;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -539,6 +539,20 @@
|
||||
[self assertTrue:d.indexOf("y: 6") !== -1 message:"Can't find 'y: 6' in description of array " + d];
|
||||
}
|
||||
|
||||
- (void)testSortUsingDescriptorsWithDifferentSelectors
|
||||
{
|
||||
var a = [CPDictionary dictionaryWithJSObject:{"a": "AB", "b": "ba"}],
|
||||
b = [CPDictionary dictionaryWithJSObject:{"a": "aa", "b": "BB"}],
|
||||
array = [a, b],
|
||||
d1 = [[CPSortDescriptor sortDescriptorWithKey:@"a" ascending:YES selector:@selector(compare:)]],
|
||||
d2 = [[CPSortDescriptor sortDescriptorWithKey:@"a" ascending:YES selector:@selector(caseInsensitiveCompare:)]],
|
||||
s1 = [array sortedArrayUsingDescriptors:d1],
|
||||
s2 = [array sortedArrayUsingDescriptors:d2];
|
||||
|
||||
[self assertTrue:s1[0] === a message:s1[0] + " is larger then " + a + " when sorting case sensitive"];
|
||||
[self assertTrue:s2[1] === a message:s2[1] + " is larger then " + a + " when sorting case insensitive"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation AlwaysEqual : CPObject
|
||||
|
||||
@@ -4,10 +4,20 @@
|
||||
|
||||
- (void)testSince1970
|
||||
{
|
||||
/* These two dates should be equal to Fri Feb 13 2009 15:31:30 GMT-0800 */
|
||||
unixDate = [CPDate dateWithTimeIntervalSince1970: 1234567890];
|
||||
cocoaDate = [CPDate dateWithTimeIntervalSinceReferenceDate: 253582290];
|
||||
[self assertTrue:[unixDate isEqualToDate: cocoaDate]];
|
||||
/* These two dates should be equal to Fri Jan 13 2009 23:31:30 +0000 */
|
||||
unixDate = [CPDate dateWithTimeIntervalSince1970:1231889490];
|
||||
cocoaDate = [CPDate dateWithTimeIntervalSinceReferenceDate:253582290];
|
||||
[self assertTrue:[unixDate isEqualToDate:cocoaDate] message:[unixDate description] + " isEqualToDate: " + [cocoaDate description]];
|
||||
}
|
||||
|
||||
- (void)testDistantPast
|
||||
{
|
||||
[self assert:[CPDate dateWithTimeIntervalSinceReferenceDate:-63113817600.0] equals:[CPDate distantPast]];
|
||||
}
|
||||
|
||||
- (void)testDistantFuture
|
||||
{
|
||||
[self assert:[CPDate dateWithTimeIntervalSinceReferenceDate:63113990400.0] equals:[CPDate distantFuture]];
|
||||
}
|
||||
|
||||
- (void)testDate
|
||||
@@ -19,7 +29,7 @@
|
||||
past = [CPDate distantPast];
|
||||
|
||||
[self assertTrue:(before <= middle) message:"before not less than middle"];
|
||||
[self assertTrue:(middle <= after) message:"middle not less than after ("+middle+","+after+")"];
|
||||
[self assertTrue:(middle <= after) message:"middle not less than after (" + middle + "," + after + ")"];
|
||||
|
||||
[self assert:middle equals:[middle earlierDate:future] message:"earlierDate incorrect"];
|
||||
[self assert:middle equals:[middle laterDate:past] message:"laterDate incorrect"];
|
||||
@@ -49,13 +59,14 @@
|
||||
- (void)testInitWithString
|
||||
{
|
||||
var tests = [
|
||||
["1970-01-01 00:00:00 +0000", 0],
|
||||
["1970-01-01 00:01:00 +0000", 60],
|
||||
["1970-01-01 01:00:00 +0000", 60*60],
|
||||
["1970-01-02 00:00:00 +0000", 24*60*60],
|
||||
["2009-11-17 17:52:04 +0000", 1258480324],
|
||||
["2009-11-17 18:52:04 +0200", 1258476724],
|
||||
];
|
||||
["1800-01-01 00:00:00 +0000", -5364662400],
|
||||
["1970-01-01 00:00:00 +0000", 0],
|
||||
["1970-01-01 00:01:00 +0000", 60],
|
||||
["1970-01-01 01:00:00 +0000", 60 * 60],
|
||||
["1970-01-02 00:00:00 +0000", 24 * 60 * 60],
|
||||
["2009-11-17 17:52:04 +0000", 1258480324],
|
||||
["2009-11-17 18:52:04 +0200", 1258476724],
|
||||
];
|
||||
|
||||
for (var i = 0; i < tests.length; i++)
|
||||
{
|
||||
@@ -65,6 +76,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testInitWithTimeIntervalSinceReferenceDate_
|
||||
{
|
||||
// Related issue #1556: "CPDateReferenceDate should be 'Jan 1 2001' instead of 'Feb 1 2001'".
|
||||
var referenceDate = [[CPDate alloc] initWithTimeIntervalSinceReferenceDate:0],
|
||||
referenceDatePlusOneHour = [[CPDate alloc] initWithTimeIntervalSinceReferenceDate:3600];
|
||||
|
||||
[self assert:[[CPDate alloc] initWithString:@"2001-01-01 00:00:00 +0000"] equals:referenceDate message:@"reference date"];
|
||||
[self assert:[[CPDate alloc] initWithString:@"2001-01-01 01:00:00 +0000"] equals:referenceDatePlusOneHour message:@"reference date plus one hour"];
|
||||
}
|
||||
|
||||
- (void)testEncoding
|
||||
{
|
||||
var date = new Date(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CPButton
|
||||
* CPButtonImageTest
|
||||
*
|
||||
* Created by Aparajita Fishman on August 31, 2010.
|
||||
*/
|
||||
@@ -16,6 +16,7 @@ CPLogRegister(CPLogConsole);
|
||||
|
||||
@outlet CPButton button;
|
||||
@outlet CPButton imageButton;
|
||||
@outlet CPButton imageDisabledButton;
|
||||
@outlet CPButton pushInButton;
|
||||
@outlet CPButton pushOnOffButton;
|
||||
@outlet CPButton toggleButton;
|
||||
@@ -36,6 +37,7 @@ CPLogRegister(CPLogConsole);
|
||||
{
|
||||
var path = [[CPBundle bundleForClass:[CPView class]] pathForResource:@"action_button.png"];
|
||||
[imageButton setImage:[[CPImage alloc] initWithContentsOfFile:path size:CGSizeMake(22.0, 14.0)]];
|
||||
[imageDisabledButton setImage:[[CPImage alloc] initWithContentsOfFile:path size:CGSizeMake(22.0, 14.0)]];
|
||||
|
||||
[self _setImagePosition:CPImageLeft];
|
||||
[positionMenu selectItemAtIndex:CPImageLeft];
|
||||
@@ -44,7 +46,7 @@ CPLogRegister(CPLogConsole);
|
||||
|
||||
- (void)_setupButtons
|
||||
{
|
||||
buttons = [button, imageButton];
|
||||
buttons = [button, imageButton, imageDisabledButton];
|
||||
checksAndRadios = [checkbox, multiCheckbox, radio1, radio2];
|
||||
|
||||
var checkboxHeight = [checkbox frameSize].height,
|
||||
@@ -61,7 +63,6 @@ CPLogRegister(CPLogConsole);
|
||||
|
||||
[[radio1 radioGroup] setTarget:self];
|
||||
[[radio1 radioGroup] setAction:@selector(radioGroupClicked:)];
|
||||
|
||||
[multiCheckbox setState:CPMixedState];
|
||||
|
||||
[pushInButton setButtonType:CPMomentaryLightButton];
|
||||
@@ -74,7 +75,7 @@ CPLogRegister(CPLogConsole);
|
||||
[momentaryChangeButton setAlternateTitle:@"Changed!"];
|
||||
}
|
||||
|
||||
- (IBAction)setImagePosition:(id)sender
|
||||
- (void)setImagePosition:(id)sender
|
||||
{
|
||||
[self _setImagePosition:[sender indexOfSelectedItem]];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
This test includes two tests for two ways to subclass CPDocumentController.
|
||||
|
||||
Please refer to the pull request and its discussion here.
|
||||
https://github.com/cappuccino/cappuccino/pull/1551
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CappDoc
|
||||
*
|
||||
* Created by You on May 24, 2012.
|
||||
* Copyright 2012, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "Document.j"
|
||||
@import "DocumentController.j"
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
// This is called when the application is done loading.
|
||||
}
|
||||
|
||||
- (void)applicationWillFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
// instantiate a subclass of DocumentController
|
||||
//subclassedCPDocumentController = [[DocumentController alloc] init];
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
// This is called when the cib is done loading.
|
||||
// You can implement this method on any object instantiated from a Cib.
|
||||
// It's a useful hook for setting up current UI values, and other things.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,12 @@
|
||||
@import <AppKit/CPDocument.j>
|
||||
|
||||
@implementation Document : CPDocument
|
||||
{
|
||||
}
|
||||
|
||||
- (CPString)windowCibName
|
||||
{
|
||||
return @"Document";
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
@import <AppKit/CPDocumentController.j>
|
||||
@import <AppKit/CPAlert.j>
|
||||
|
||||
@implementation DocumentController : CPDocumentController
|
||||
{
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
return [CPDocumentController sharedDocumentController];
|
||||
}
|
||||
|
||||
/* Instead of throwing error in browser environment, show an alert
|
||||
*/
|
||||
- (void)openDocument:(id)aSender
|
||||
{
|
||||
var anAlert = [CPAlert alertWithError:@"Opening a document is not available!"];
|
||||
[anAlert beginSheetModalForWindow:[[CPApplication sharedApplication] mainWindow]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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>CappDoc</string>
|
||||
<key>CPBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CPDocumentClass</key>
|
||||
<string>Document</string>
|
||||
<key>CPBundleTypeName</key>
|
||||
<string>CappDoc</string>
|
||||
<key>CFBundleTypeExtentions</key>
|
||||
<array>
|
||||
<string>cappdoc</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Jakefile
|
||||
* CappDoc
|
||||
*
|
||||
* Created by You on May 24, 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 ("CappDoc", function(task)
|
||||
{
|
||||
task.setBuildIntermediatesPath(FILE.join("Build", "CappDoc.build", configuration));
|
||||
task.setBuildPath(FILE.join("Build", configuration));
|
||||
|
||||
task.setProductName("CappDoc");
|
||||
task.setIdentifier("com.yourcompany.CappDoc");
|
||||
task.setVersion("1.0");
|
||||
task.setAuthor("Your Company");
|
||||
task.setEmail("feedback @nospam@ yourcompany.com");
|
||||
task.setSummary("CappDoc");
|
||||
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", ["CappDoc"], 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", "CappDoc", "index.html")]);
|
||||
});
|
||||
|
||||
task ("run-release", ["release"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Release", "CappDoc", "index.html")]);
|
||||
});
|
||||
|
||||
task ("deploy", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Deployment", "CappDoc"));
|
||||
OS.system(["press", "-f", FILE.join("Build", "Release", "CappDoc"), FILE.join("Build", "Deployment", "CappDoc")]);
|
||||
printResults("Deployment")
|
||||
});
|
||||
|
||||
task ("desktop", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Desktop", "CappDoc"));
|
||||
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CappDoc"), FILE.join("Build", "Desktop", "CappDoc", "CappDoc.app"));
|
||||
printResults("Desktop")
|
||||
});
|
||||
|
||||
task ("run-desktop", ["desktop"], function()
|
||||
{
|
||||
OS.system([FILE.join("Build", "Desktop", "CappDoc", "CappDoc.app", "Contents", "MacOS", "NativeHost"), "-i"]);
|
||||
});
|
||||
|
||||
function printResults(configuration)
|
||||
{
|
||||
print("----------------------------");
|
||||
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CappDoc"));
|
||||
print("----------------------------");
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1070</int>
|
||||
<string key="IBDocument.SystemVersion">11E53</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.47</string>
|
||||
<string key="IBDocument.HIToolboxVersion">569.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>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>NSTextField</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSWindowTemplate</string>
|
||||
<string>NSView</string>
|
||||
<string>NSCustomObject</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="580458321">
|
||||
<object class="NSCustomObject" id="512844837">
|
||||
<string key="NSClassName">Document</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="613418571">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="275939982">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{29, 539}, {507, 413}}</string>
|
||||
<int key="NSWTFlags">1886912512</int>
|
||||
<string key="NSWindowTitle">Window</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<string key="NSViewClass">View</string>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<string key="NSWindowContentMinSize">{94, 86}</string>
|
||||
<object class="NSView" key="NSWindowView" id="568628114">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="NSTextField" id="159857402">
|
||||
<reference key="NSNextResponder" ref="568628114"/>
|
||||
<int key="NSvFlags">301</int>
|
||||
<string key="NSFrame">{{201, 198}, {104, 17}}</string>
|
||||
<reference key="NSSuperview" ref="568628114"/>
|
||||
<reference key="NSWindow"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1505</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="521114378">
|
||||
<int key="NSCellFlags">68288064</int>
|
||||
<int key="NSCellFlags2">272630784</int>
|
||||
<string key="NSContents">Contents Here</string>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<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="159857402"/>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrameSize">{507, 413}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="159857402"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1920, 1058}}</string>
|
||||
<string key="NSMinSize">{94, 108}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="796877042">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">window</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="275939982"/>
|
||||
</object>
|
||||
<int key="connectionID">18</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="275939982"/>
|
||||
<reference key="destination" ref="512844837"/>
|
||||
</object>
|
||||
<int key="connectionID">17</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="580458321"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="512844837"/>
|
||||
<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="613418571"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">First Responder</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">5</int>
|
||||
<reference key="object" ref="275939982"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="568628114"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Window</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">6</int>
|
||||
<reference key="object" ref="568628114"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="159857402"/>
|
||||
</array>
|
||||
<reference key="parent" ref="275939982"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-3</int>
|
||||
<reference key="object" ref="796877042"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Application</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100098</int>
|
||||
<reference key="object" ref="159857402"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="521114378"/>
|
||||
</array>
|
||||
<reference key="parent" ref="568628114"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100099</int>
|
||||
<reference key="object" ref="521114378"/>
|
||||
<reference key="parent" ref="159857402"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="100098.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="100099.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="5.IBWindowTemplateEditedContentRect">{{133, 170}, {507, 413}}</string>
|
||||
<boolean value="NO" key="5.NSWindowTemplate.visibleAtLaunch"/>
|
||||
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">100100</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">Document</string>
|
||||
<string key="superclassName">NSDocument</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/Document.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
</data>
|
||||
</archive>
|
||||
|
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
|
||||
CappDoc
|
||||
|
||||
Created by You on May 24, 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>CappDoc</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 CappDoc...</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
|
||||
CappDoc
|
||||
|
||||
Created by You on May 24, 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>CappDoc</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 CappDoc...</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
|
||||
* CappDoc
|
||||
*
|
||||
* Created by You on May 24, 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,35 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CappDoc
|
||||
*
|
||||
* Created by You on May 24, 2012.
|
||||
* Copyright 2012, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
@import "Document.j"
|
||||
@import "DocumentController.j"
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
// This is called when the application is done loading.
|
||||
}
|
||||
|
||||
- (void)applicationWillFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
// instantiate a subclass of DocumentController
|
||||
[[DocumentController alloc] init];
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
// This is called when the cib is done loading.
|
||||
// You can implement this method on any object instantiated from a Cib.
|
||||
// It's a useful hook for setting up current UI values, and other things.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,12 @@
|
||||
@import <AppKit/CPDocument.j>
|
||||
|
||||
@implementation Document : CPDocument
|
||||
{
|
||||
}
|
||||
|
||||
- (CPString)windowCibName
|
||||
{
|
||||
return @"Document";
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
@import <AppKit/CPDocumentController.j>
|
||||
@import <AppKit/CPAlert.j>
|
||||
|
||||
@implementation DocumentController : CPDocumentController
|
||||
{
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Instead of throwing error in browser environment, show an alert
|
||||
*/
|
||||
- (void)openDocument:(id)aSender
|
||||
{
|
||||
var anAlert = [CPAlert alertWithError:@"Opening a document is not available!"];
|
||||
[anAlert beginSheetModalForWindow:[[CPApplication sharedApplication] mainWindow]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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>CappDoc</string>
|
||||
<key>CPBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CPDocumentClass</key>
|
||||
<string>Document</string>
|
||||
<key>CPBundleTypeName</key>
|
||||
<string>CappDoc</string>
|
||||
<key>CFBundleTypeExtentions</key>
|
||||
<array>
|
||||
<string>cappdoc</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Jakefile
|
||||
* CappDoc
|
||||
*
|
||||
* Created by You on May 24, 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 ("CappDoc", function(task)
|
||||
{
|
||||
task.setBuildIntermediatesPath(FILE.join("Build", "CappDoc.build", configuration));
|
||||
task.setBuildPath(FILE.join("Build", configuration));
|
||||
|
||||
task.setProductName("CappDoc");
|
||||
task.setIdentifier("com.yourcompany.CappDoc");
|
||||
task.setVersion("1.0");
|
||||
task.setAuthor("Your Company");
|
||||
task.setEmail("feedback @nospam@ yourcompany.com");
|
||||
task.setSummary("CappDoc");
|
||||
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", ["CappDoc"], 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", "CappDoc", "index.html")]);
|
||||
});
|
||||
|
||||
task ("run-release", ["release"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Release", "CappDoc", "index.html")]);
|
||||
});
|
||||
|
||||
task ("deploy", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Deployment", "CappDoc"));
|
||||
OS.system(["press", "-f", FILE.join("Build", "Release", "CappDoc"), FILE.join("Build", "Deployment", "CappDoc")]);
|
||||
printResults("Deployment")
|
||||
});
|
||||
|
||||
task ("desktop", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Desktop", "CappDoc"));
|
||||
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CappDoc"), FILE.join("Build", "Desktop", "CappDoc", "CappDoc.app"));
|
||||
printResults("Desktop")
|
||||
});
|
||||
|
||||
task ("run-desktop", ["desktop"], function()
|
||||
{
|
||||
OS.system([FILE.join("Build", "Desktop", "CappDoc", "CappDoc.app", "Contents", "MacOS", "NativeHost"), "-i"]);
|
||||
});
|
||||
|
||||
function printResults(configuration)
|
||||
{
|
||||
print("----------------------------");
|
||||
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CappDoc"));
|
||||
print("----------------------------");
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1070</int>
|
||||
<string key="IBDocument.SystemVersion">11E53</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.47</string>
|
||||
<string key="IBDocument.HIToolboxVersion">569.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>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>NSTextField</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSWindowTemplate</string>
|
||||
<string>NSView</string>
|
||||
<string>NSCustomObject</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="580458321">
|
||||
<object class="NSCustomObject" id="512844837">
|
||||
<string key="NSClassName">Document</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="613418571">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="275939982">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{29, 539}, {507, 413}}</string>
|
||||
<int key="NSWTFlags">1886912512</int>
|
||||
<string key="NSWindowTitle">Window</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<string key="NSViewClass">View</string>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<string key="NSWindowContentMinSize">{94, 86}</string>
|
||||
<object class="NSView" key="NSWindowView" id="568628114">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="NSTextField" id="159857402">
|
||||
<reference key="NSNextResponder" ref="568628114"/>
|
||||
<int key="NSvFlags">301</int>
|
||||
<string key="NSFrame">{{201, 198}, {104, 17}}</string>
|
||||
<reference key="NSSuperview" ref="568628114"/>
|
||||
<reference key="NSWindow"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1505</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="521114378">
|
||||
<int key="NSCellFlags">68288064</int>
|
||||
<int key="NSCellFlags2">272630784</int>
|
||||
<string key="NSContents">Contents Here</string>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<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="159857402"/>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrameSize">{507, 413}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="159857402"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1920, 1058}}</string>
|
||||
<string key="NSMinSize">{94, 108}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="796877042">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">window</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="275939982"/>
|
||||
</object>
|
||||
<int key="connectionID">18</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="275939982"/>
|
||||
<reference key="destination" ref="512844837"/>
|
||||
</object>
|
||||
<int key="connectionID">17</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="580458321"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="512844837"/>
|
||||
<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="613418571"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">First Responder</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">5</int>
|
||||
<reference key="object" ref="275939982"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="568628114"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Window</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">6</int>
|
||||
<reference key="object" ref="568628114"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="159857402"/>
|
||||
</array>
|
||||
<reference key="parent" ref="275939982"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-3</int>
|
||||
<reference key="object" ref="796877042"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Application</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100098</int>
|
||||
<reference key="object" ref="159857402"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="521114378"/>
|
||||
</array>
|
||||
<reference key="parent" ref="568628114"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100099</int>
|
||||
<reference key="object" ref="521114378"/>
|
||||
<reference key="parent" ref="159857402"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="100098.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="100099.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="5.IBWindowTemplateEditedContentRect">{{133, 170}, {507, 413}}</string>
|
||||
<boolean value="NO" key="5.NSWindowTemplate.visibleAtLaunch"/>
|
||||
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">100100</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">Document</string>
|
||||
<string key="superclassName">NSDocument</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/Document.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
</data>
|
||||
</archive>
|
||||
|
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
|
||||
CappDoc
|
||||
|
||||
Created by You on May 24, 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>CappDoc</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 CappDoc...</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
|
||||
CappDoc
|
||||
|
||||
Created by You on May 24, 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>CappDoc</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 CappDoc...</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
|
||||
* CappDoc
|
||||
*
|
||||
* Created by You on May 24, 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);
|
||||
}
|
||||
@@ -31,12 +31,19 @@
|
||||
var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(20.0, 50.0, 290.0, 250.0)],
|
||||
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)];
|
||||
|
||||
// Test CPImage -data method
|
||||
// Create an image from a filename based image
|
||||
var im = [[CPImage alloc] initWithData:[image data]],
|
||||
|
||||
// Create an image from a data based image
|
||||
otherImage = [[CPImage alloc] initWithData:[im data]];
|
||||
|
||||
[imageView setImageScaling:CPImageScaleNone];
|
||||
[imageViewShadow setImageScaling:CPImageScaleNone];
|
||||
|
||||
[imageView setImage:image];
|
||||
[imageViewShadow setImage:image];
|
||||
[imageView setImage:image];
|
||||
[imageViewShadow setImage:otherImage];
|
||||
[imageViewShadow setHasShadow:YES];
|
||||
|
||||
[contentView addSubview:imageView];
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
var path = [[CPBundle mainBundle] pathForResource:@"value.jpg"],
|
||||
image = [[CPImage alloc] initWithContentsOfFile:path],
|
||||
dict = [CPDictionary dictionaryWithObject:image forKey:@"image"];
|
||||
[theRows addObject:dict];
|
||||
|
||||
[theRows insertObject:dict atIndex:1];
|
||||
[self setContent:theRows];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,28 +3,28 @@
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1050</int>
|
||||
<string key="IBDocument.SystemVersion">11D50</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2427</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2488</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">2427</string>
|
||||
<string key="NS.object.0">2488</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSScroller</string>
|
||||
<string>NSArrayController</string>
|
||||
<string>NSTableHeaderView</string>
|
||||
<string>NSScrollView</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSImageView</string>
|
||||
<string>NSImageCell</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSCustomObject</string>
|
||||
<string>NSImageCell</string>
|
||||
<string>NSImageView</string>
|
||||
<string>NSScrollView</string>
|
||||
<string>NSScroller</string>
|
||||
<string>NSTableColumn</string>
|
||||
<string>NSTableHeaderView</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSView</string>
|
||||
<string>NSWindowTemplate</string>
|
||||
<string>NSTableColumn</string>
|
||||
<string>NSTextField</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -48,7 +48,7 @@
|
||||
<object class="NSWindowTemplate" id="972006081">
|
||||
<int key="NSWindowStyleMask">7</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{335, 390}, {794, 370}}</string>
|
||||
<string key="NSWindowRect">{{335, 390}, {803, 555}}</string>
|
||||
<int key="NSWTFlags">1946157056</int>
|
||||
<string key="NSWindowTitle">Window</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
@@ -72,7 +72,7 @@
|
||||
<object class="NSTableView" id="117414317">
|
||||
<reference key="NSNextResponder" ref="144065459"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrameSize">{430, 125}</string>
|
||||
<string key="NSFrameSize">{346, 125}</string>
|
||||
<reference key="NSSuperview" ref="144065459"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="205446087"/>
|
||||
@@ -81,7 +81,7 @@
|
||||
<object class="NSTableHeaderView" key="NSHeaderView" id="994663149">
|
||||
<reference key="NSNextResponder" ref="974040110"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrameSize">{430, 17}</string>
|
||||
<string key="NSFrameSize">{346, 17}</string>
|
||||
<reference key="NSSuperview" ref="974040110"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="144065459"/>
|
||||
@@ -156,7 +156,7 @@
|
||||
<reference key="NSTableView" ref="117414317"/>
|
||||
</object>
|
||||
<object class="NSTableColumn" id="516759045">
|
||||
<double key="NSWidth">257</double>
|
||||
<double key="NSWidth">88</double>
|
||||
<double key="NSMinWidth">40</double>
|
||||
<double key="NSMaxWidth">1000</double>
|
||||
<object class="NSTableHeaderCell" key="NSHeaderCell">
|
||||
@@ -180,13 +180,44 @@
|
||||
<bool key="NSIsResizeable">YES</bool>
|
||||
<reference key="NSTableView" ref="117414317"/>
|
||||
</object>
|
||||
<object class="NSTableColumn" id="508795204">
|
||||
<double key="NSWidth">82</double>
|
||||
<double key="NSMinWidth">10</double>
|
||||
<double key="NSMaxWidth">3.4028234663852886e+38</double>
|
||||
<object class="NSTableHeaderCell" key="NSHeaderCell">
|
||||
<int key="NSCellFlags">75628096</int>
|
||||
<int key="NSCellFlags2">2048</int>
|
||||
<string key="NSContents">CPData</string>
|
||||
<reference key="NSSupport" ref="26"/>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">headerColor</string>
|
||||
<object class="NSColor" key="NSColor" id="693868100">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<reference key="NSTextColor" ref="550243613"/>
|
||||
</object>
|
||||
<object class="NSTextFieldCell" key="NSDataCell" id="59889627">
|
||||
<int key="NSCellFlags">337772096</int>
|
||||
<int key="NSCellFlags2">2048</int>
|
||||
<string key="NSContents">Text Cell</string>
|
||||
<reference key="NSSupport" ref="1054154218"/>
|
||||
<reference key="NSControlView" ref="117414317"/>
|
||||
<reference key="NSBackgroundColor" ref="861330692"/>
|
||||
<reference key="NSTextColor" ref="782996589"/>
|
||||
</object>
|
||||
<int key="NSResizingMask">3</int>
|
||||
<bool key="NSIsResizeable">YES</bool>
|
||||
<bool key="NSIsEditable">YES</bool>
|
||||
<reference key="NSTableView" ref="117414317"/>
|
||||
</object>
|
||||
</object>
|
||||
<double key="NSIntercellSpacingWidth">3</double>
|
||||
<double key="NSIntercellSpacingHeight">2</double>
|
||||
<object class="NSColor" key="NSBackgroundColor" id="693868100">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<reference key="NSBackgroundColor" ref="693868100"/>
|
||||
<object class="NSColor" key="NSGridColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
@@ -197,7 +228,7 @@
|
||||
</object>
|
||||
</object>
|
||||
<double key="NSRowHeight">17</double>
|
||||
<int key="NSTvFlags">-566231040</int>
|
||||
<int key="NSTvFlags">-564133888</int>
|
||||
<reference key="NSDelegate"/>
|
||||
<reference key="NSDataSource"/>
|
||||
<int key="NSColumnAutoresizingStyle">4</int>
|
||||
@@ -208,7 +239,7 @@
|
||||
<int key="NSTableViewGroupRowStyle">1</int>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{1, 17}, {379, 125}}</string>
|
||||
<string key="NSFrame">{{1, 17}, {346, 125}}</string>
|
||||
<reference key="NSSuperview" ref="318333122"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="117414317"/>
|
||||
@@ -232,17 +263,16 @@
|
||||
</object>
|
||||
<object class="NSScroller" id="868381486">
|
||||
<reference key="NSNextResponder" ref="318333122"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrame">{{1, 127}, {379, 15}}</string>
|
||||
<int key="NSvFlags">-2147483392</int>
|
||||
<string key="NSFrame">{{1, 127}, {346, 15}}</string>
|
||||
<reference key="NSSuperview" ref="318333122"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="380387729"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:60</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<int key="NSsFlags">1</int>
|
||||
<reference key="NSTarget" ref="318333122"/>
|
||||
<string key="NSAction">_doScroller:</string>
|
||||
<double key="NSPercent">0.88139534883720927</double>
|
||||
<double key="NSPercent">0.99425287356321834</double>
|
||||
</object>
|
||||
<object class="NSClipView" id="974040110">
|
||||
<reference key="NSNextResponder" ref="318333122"/>
|
||||
@@ -251,7 +281,7 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="994663149"/>
|
||||
</object>
|
||||
<string key="NSFrame">{{1, 0}, {379, 17}}</string>
|
||||
<string key="NSFrame">{{1, 0}, {346, 17}}</string>
|
||||
<reference key="NSSuperview" ref="318333122"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="994663149"/>
|
||||
@@ -261,12 +291,12 @@
|
||||
<int key="NScvFlags">4</int>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{20, 198}, {381, 143}}</string>
|
||||
<string key="NSFrame">{{20, 383}, {348, 143}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="974040110"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<int key="NSsFlags">133810</int>
|
||||
<int key="NSsFlags">133682</int>
|
||||
<reference key="NSVScroller" ref="205446087"/>
|
||||
<reference key="NSHScroller" ref="868381486"/>
|
||||
<reference key="NSContentView" ref="144065459"/>
|
||||
@@ -288,7 +318,7 @@
|
||||
<string>NeXT TIFF v4.0 pasteboard type</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{421, 195}, {201, 149}}</string>
|
||||
<string key="NSFrame">{{421, 380}, {201, 149}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="781739936"/>
|
||||
@@ -308,7 +338,7 @@
|
||||
<object class="NSTextField" id="781739936">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{637, 210}, {149, 131}}</string>
|
||||
<string key="NSFrame">{{637, 395}, {149, 131}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="548598148"/>
|
||||
@@ -350,7 +380,7 @@
|
||||
<string>NeXT TIFF v4.0 pasteboard type</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{421, 33}, {201, 149}}</string>
|
||||
<string key="NSFrame">{{421, 218}, {201, 149}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="461563582"/>
|
||||
@@ -370,10 +400,10 @@
|
||||
<object class="NSTextField" id="461563582">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{637, 48}, {149, 131}}</string>
|
||||
<string key="NSFrame">{{637, 233}, {149, 131}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<reference key="NSNextKeyView" ref="104247625"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<string key="NSAntiCompressionPriority">{250, 750}</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
@@ -391,7 +421,7 @@
|
||||
<object class="NSTextField" id="1035519104">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{20, 87}, {381, 22}}</string>
|
||||
<string key="NSFrame">{{20, 272}, {381, 22}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="255391143"/>
|
||||
@@ -422,7 +452,7 @@
|
||||
<object class="NSTextField" id="548598148">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{17, 113}, {387, 51}}</string>
|
||||
<string key="NSFrame">{{17, 298}, {387, 51}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1035519104"/>
|
||||
@@ -440,8 +470,61 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
<reference key="NSTextColor" ref="782996589"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSImageView" id="104247625">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<object class="NSMutableSet" key="NSDragTypes">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="set.sortedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>Apple PDF pasteboard type</string>
|
||||
<string>Apple PICT pasteboard type</string>
|
||||
<string>Apple PNG pasteboard type</string>
|
||||
<string>NSFilenamesPboardType</string>
|
||||
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
|
||||
<string>NeXT TIFF v4.0 pasteboard type</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{421, 53}, {201, 149}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1066381201"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSImageCell" key="NSCell" id="212529575">
|
||||
<int key="NSCellFlags">270532608</int>
|
||||
<int key="NSCellFlags2">0</int>
|
||||
<string key="NSCellIdentifier">_NS:9</string>
|
||||
<int key="NSAlign">0</int>
|
||||
<int key="NSScale">3</int>
|
||||
<int key="NSStyle">2</int>
|
||||
<bool key="NSAnimates">NO</bool>
|
||||
</object>
|
||||
<bool key="NSEditable">YES</bool>
|
||||
</object>
|
||||
<object class="NSTextField" id="1066381201">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{637, 68}, {149, 131}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<string key="NSAntiCompressionPriority">{250, 750}</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="694023875">
|
||||
<int key="NSCellFlags">67108864</int>
|
||||
<int key="NSCellFlags2">272629760</int>
|
||||
<string type="base64-UTF8" key="NSContents">RWRpdGFibGUKQ1BEYXRhQmluZGluZy4</string>
|
||||
<reference key="NSSupport" ref="611501944"/>
|
||||
<string key="NSCellIdentifier">_NS:9</string>
|
||||
<reference key="NSControlView" ref="1066381201"/>
|
||||
<reference key="NSBackgroundColor" ref="779730611"/>
|
||||
<reference key="NSTextColor" ref="782996589"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{794, 370}</string>
|
||||
<string key="NSFrameSize">{803, 555}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="318333122"/>
|
||||
@@ -578,6 +661,38 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
</object>
|
||||
<int key="connectionID">511</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">data: selection.data</string>
|
||||
<reference key="source" ref="104247625"/>
|
||||
<reference key="destination" ref="191071672"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="104247625"/>
|
||||
<reference key="NSDestination" ref="191071672"/>
|
||||
<string key="NSLabel">data: selection.data</string>
|
||||
<string key="NSBinding">data</string>
|
||||
<string key="NSKeyPath">selection.data</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">518</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: arrangedObjects.data.className</string>
|
||||
<reference key="source" ref="508795204"/>
|
||||
<reference key="destination" ref="191071672"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="508795204"/>
|
||||
<reference key="NSDestination" ref="191071672"/>
|
||||
<string key="NSLabel">value: arrangedObjects.data.className</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">arrangedObjects.data.className</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">522</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -625,10 +740,12 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
<reference ref="318333122"/>
|
||||
<reference ref="380387729"/>
|
||||
<reference ref="781739936"/>
|
||||
<reference ref="255391143"/>
|
||||
<reference ref="461563582"/>
|
||||
<reference ref="1035519104"/>
|
||||
<reference ref="548598148"/>
|
||||
<reference ref="104247625"/>
|
||||
<reference ref="1066381201"/>
|
||||
<reference ref="255391143"/>
|
||||
</object>
|
||||
<reference key="parent" ref="972006081"/>
|
||||
</object>
|
||||
@@ -661,6 +778,7 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="702137802"/>
|
||||
<reference ref="516759045"/>
|
||||
<reference ref="508795204"/>
|
||||
</object>
|
||||
<reference key="parent" ref="318333122"/>
|
||||
</object>
|
||||
@@ -791,6 +909,48 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
<reference key="object" ref="346616969"/>
|
||||
<reference key="parent" ref="548598148"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">512</int>
|
||||
<reference key="object" ref="104247625"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="212529575"/>
|
||||
</object>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">513</int>
|
||||
<reference key="object" ref="1066381201"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="694023875"/>
|
||||
</object>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">514</int>
|
||||
<reference key="object" ref="694023875"/>
|
||||
<reference key="parent" ref="1066381201"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">515</int>
|
||||
<reference key="object" ref="212529575"/>
|
||||
<reference key="parent" ref="104247625"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">519</int>
|
||||
<reference key="object" ref="508795204"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="59889627"/>
|
||||
</object>
|
||||
<reference key="parent" ref="117414317"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">520</int>
|
||||
<reference key="object" ref="59889627"/>
|
||||
<reference key="parent" ref="508795204"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -827,6 +987,12 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
<string>507.IBPluginDependency</string>
|
||||
<string>508.IBPluginDependency</string>
|
||||
<string>509.IBPluginDependency</string>
|
||||
<string>512.IBPluginDependency</string>
|
||||
<string>513.IBPluginDependency</string>
|
||||
<string>514.IBPluginDependency</string>
|
||||
<string>515.IBPluginDependency</string>
|
||||
<string>519.IBPluginDependency</string>
|
||||
<string>520.IBPluginDependency</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -860,6 +1026,12 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</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">
|
||||
@@ -874,7 +1046,7 @@ c29sdXRlIHVybCBhbmQgaGl0IGVudGVyLg</string>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">511</int>
|
||||
<int key="maxID">522</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
* AppController.j
|
||||
* CPMenuTest
|
||||
*
|
||||
* Created by Alexander Ljungberg on August 31, 2010.
|
||||
* Copyright 2010, WireLoad, LLC All rights reserved.
|
||||
* Created by Blair Duncan on April 23, 2012.
|
||||
* Copyright 2012, SGL Studio, BBDO Toronto All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
@import "MyView.j"
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
@@ -17,16 +16,10 @@
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
|
||||
contentView = [[MyView alloc] initWithFrame:CGRectMakeZero()];
|
||||
contentView = [theWindow contentView],
|
||||
popupButton = [[CPPopUpButton alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
[theWindow setContentView:contentView];
|
||||
|
||||
var popupButton = [[CPPopUpButton alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[popupButton addItemWithTitle:@"Item 1"];
|
||||
[popupButton addItemWithTitle:@"Item 2"];
|
||||
[popupButton addItemWithTitle:@"Item 3"];
|
||||
[popupButton addItemsWithTitles:[[CPFontManager sharedFontManager] availableFonts]];
|
||||
[popupButton sizeToFit];
|
||||
|
||||
[popupButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
|
||||
@@ -37,7 +30,8 @@
|
||||
[theWindow orderFront:self];
|
||||
|
||||
// Uncomment the following line to turn on the standard menu bar.
|
||||
[CPMenu setMenuBarVisible:YES];
|
||||
//[CPMenu setMenuBarVisible:YES];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
@import <AppKit/CPView.j>
|
||||
|
||||
@implementation MyView : CPView
|
||||
{
|
||||
}
|
||||
|
||||
- (CPMenu)menu
|
||||
{
|
||||
var menu = [[CPMenu alloc] initWithTitle:@""];
|
||||
|
||||
[menu addItemWithTitle:@"Item 1" action:nil keyEquivalent:nil];
|
||||
[menu addItemWithTitle:@"Item 2" action:nil keyEquivalent:nil];
|
||||
[menu addItemWithTitle:@"Item 3" action:nil keyEquivalent:nil];
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CPToolbarTest
|
||||
*
|
||||
* Created by Alexander Ljungberg on June 12, 2012.
|
||||
* Copyright 2012, SlevenBits Ltd. All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
// We want to test all combinations of:
|
||||
// Label/Icon/Label and Icon/Small/Normal/Has oversized item.
|
||||
|
||||
var NO_LABEL = 1 << 0,
|
||||
NO_ICON = 1 << 1,
|
||||
HAS_TALL_ITEM = 1 << 2,
|
||||
IS_SMALL = 1 << 3,
|
||||
windows = [],
|
||||
x = 10,
|
||||
y = 30;
|
||||
|
||||
for (var i = 0; i < (NO_LABEL | NO_ICON | IS_SMALL | HAS_TALL_ITEM); i++)
|
||||
{
|
||||
var hasLabel = !(i & NO_LABEL),
|
||||
hasIcon = !(i & NO_ICON),
|
||||
isSmall = !!(i & IS_SMALL),
|
||||
hasTallItem = !!(i & HAS_TALL_ITEM);
|
||||
|
||||
if (!hasLabel && !hasIcon)
|
||||
continue;
|
||||
|
||||
// A tall item where the view isn't visible is just a label so don't bother showing that.
|
||||
if (!hasIcon && hasTallItem)
|
||||
continue;
|
||||
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(x, y, 400, 20) styleMask:CPTitledWindowMask],
|
||||
contentView = [theWindow contentView];
|
||||
|
||||
[theWindow setTitle:"Toolbar (LBL: " + hasLabel + " ICN: " + hasIcon + " SMALL: " + isSmall + " TALLITEM: " + hasTallItem + ")"];
|
||||
|
||||
var toolbarDelegate = [ToolbarDelegate new],
|
||||
items = [@"new"];
|
||||
if (!isSmall)
|
||||
[items addObject:@"colour"];
|
||||
if (hasTallItem)
|
||||
[items addObject:@"tallitem"];
|
||||
[toolbarDelegate setItems:items];
|
||||
|
||||
var toolbar = [CPToolbar new];
|
||||
[toolbar setSizeMode:isSmall ? CPToolbarSizeModeSmall : CPToolbarSizeModeRegular];
|
||||
if (hasLabel && hasIcon)
|
||||
[toolbar setDisplayMode:CPToolbarDisplayModeIconAndLabel];
|
||||
else if (hasLabel)
|
||||
[toolbar setDisplayMode:CPToolbarDisplayModeLabelOnly];
|
||||
else
|
||||
[toolbar setDisplayMode:CPToolbarDisplayModeIconOnly];
|
||||
|
||||
[toolbar setDelegate:toolbarDelegate];
|
||||
[theWindow setToolbar:toolbar];
|
||||
|
||||
windows[i] = theWindow;
|
||||
|
||||
[theWindow orderFront:nil];
|
||||
|
||||
y += [theWindow frame].size.height + 10;
|
||||
if (y + 80 > [[theWindow platformWindow] visibleFrame].size.height)
|
||||
{
|
||||
y = 30;
|
||||
x += 430;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation ToolbarDelegate : CPObject
|
||||
{
|
||||
CPArray items @accessors;
|
||||
}
|
||||
|
||||
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)toolbar
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
- (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
|
||||
{
|
||||
var toolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
|
||||
if (itemIdentifier == "colour")
|
||||
{
|
||||
[toolbarItem setLabel:@"Colour"];
|
||||
[toolbarItem setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"CPImageNameColorPanel.png"] size:CPSizeMake(26, 29)]];
|
||||
return toolbarItem;
|
||||
}
|
||||
else if (itemIdentifier == "new")
|
||||
{
|
||||
[toolbarItem setLabel:@"Small New"];
|
||||
[toolbarItem setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"New.png"] size:CPSizeMake(16, 16)]];
|
||||
return toolbarItem;
|
||||
}
|
||||
else if (itemIdentifier == "tallitem")
|
||||
{
|
||||
[toolbarItem setLabel:@"Tall Item"];
|
||||
[toolbarItem setMinSize:CGSizeMake(60, 70)];
|
||||
[toolbarItem setMaxSize:CGSizeMake(60, 70)];
|
||||
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 60, 70)];
|
||||
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
var slider = [[CPSlider alloc] initWithFrame: CGRectMake(0, i * 25, 60, 20)];
|
||||
[view addSubview:slider];
|
||||
}
|
||||
|
||||
[toolbarItem setView:view];
|
||||
return toolbarItem;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -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>CPToolbarTest</string>
|
||||
<key>CPPrincipalClass</key>
|
||||
<string>CPApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Jakefile
|
||||
* CPToolbarTest
|
||||
*
|
||||
* Created by Alexander Ljungberg on June 12, 2012.
|
||||
* Copyright 2012, SlevenBits Ltd. 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 ("CPToolbarTest", function(task)
|
||||
{
|
||||
task.setBuildIntermediatesPath(FILE.join("Build", "CPToolbarTest.build", configuration));
|
||||
task.setBuildPath(FILE.join("Build", configuration));
|
||||
|
||||
task.setProductName("CPToolbarTest");
|
||||
task.setIdentifier("com.slevenbits.CPToolbarTest");
|
||||
task.setVersion("1.0");
|
||||
task.setAuthor("Your Company");
|
||||
task.setEmail("feedback @nospam@ yourcompany.com");
|
||||
task.setSummary("CPToolbarTest");
|
||||
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", ["CPToolbarTest"], 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", "CPToolbarTest", "index.html")]);
|
||||
});
|
||||
|
||||
task ("run-release", ["release"], function()
|
||||
{
|
||||
OS.system(["open", FILE.join("Build", "Release", "CPToolbarTest", "index.html")]);
|
||||
});
|
||||
|
||||
task ("deploy", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Deployment", "CPToolbarTest"));
|
||||
OS.system(["press", "-f", FILE.join("Build", "Release", "CPToolbarTest"), FILE.join("Build", "Deployment", "CPToolbarTest")]);
|
||||
printResults("Deployment")
|
||||
});
|
||||
|
||||
task ("desktop", ["release"], function()
|
||||
{
|
||||
FILE.mkdirs(FILE.join("Build", "Desktop", "CPToolbarTest"));
|
||||
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPToolbarTest"), FILE.join("Build", "Desktop", "CPToolbarTest", "CPToolbarTest.app"));
|
||||
printResults("Desktop")
|
||||
});
|
||||
|
||||
task ("run-desktop", ["desktop"], function()
|
||||
{
|
||||
OS.system([FILE.join("Build", "Desktop", "CPToolbarTest", "CPToolbarTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
|
||||
});
|
||||
|
||||
function printResults(configuration)
|
||||
{
|
||||
print("----------------------------");
|
||||
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPToolbarTest"));
|
||||
print("----------------------------");
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 497 B |
|
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
|
||||
CPToolbarTest
|
||||
|
||||
Created by Alexander Ljungberg on June 12, 2012.
|
||||
Copyright 2012, SlevenBits Ltd. 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>CPToolbarTest</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 CPToolbarTest...</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,78 @@
|
||||
<!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
|
||||
CPToolbarTest
|
||||
|
||||
Created by Alexander Ljungberg on June 12, 2012.
|
||||
Copyright 2012, SlevenBits Ltd. 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>CPToolbarTest</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 CPToolbarTest...</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
|
||||
* CPToolbarTest
|
||||
*
|
||||
* Created by Alexander Ljungberg on June 12, 2012.
|
||||
* Copyright 2012, SlevenBits Ltd. All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
@import "AppController.j"
|
||||
|
||||
|
||||
function main(args, namedArgs)
|
||||
{
|
||||
CPApplicationMain(args, namedArgs);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* AppController.j
|
||||
* DragAndDrop
|
||||
*
|
||||
* Created by You on December 10, 2010.
|
||||
* Created by Mike Fellows on December 10, 2010.
|
||||
* Copyright 2010, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
@import <Foundation/CPIndexSet.j>
|
||||
@import <Foundation/CPRange.j>
|
||||
|
||||
TableTestDragAndDropTableViewDataType = "@TableTestDragAndDropTableViewDataType";
|
||||
TableTestDragAndDropTableViewDataType = @"TableTestDragAndDropTableViewDataType";
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
@@ -25,10 +25,10 @@ TableTestDragAndDropTableViewDataType = "@TableTestDragAndDropTableViewDataType"
|
||||
count = 100;
|
||||
|
||||
rowList = [];
|
||||
while(count--)
|
||||
while (count--)
|
||||
rowList[count] = count;
|
||||
|
||||
[scroll setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
|
||||
[scroll setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
var table = [[CPTableView alloc] initWithFrame:CGRectMakeZero()];
|
||||
[table setDataSource:self];
|
||||
@@ -101,7 +101,7 @@ TableTestDragAndDropTableViewDataType = "@TableTestDragAndDropTableViewDataType"
|
||||
|
||||
- (id)tableView:(id)tableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRow
|
||||
{
|
||||
if([aColumn identifier] == "Row")
|
||||
if ([aColumn identifier] == "Row")
|
||||
return aRow;
|
||||
else
|
||||
return "Col " + [aColumn identifier] + ", Started as Row " + rowList[aRow];
|
||||
@@ -133,7 +133,7 @@ TableTestDragAndDropTableViewDataType = "@TableTestDragAndDropTableViewDataType"
|
||||
destinationRange,
|
||||
destinationIndexes;
|
||||
|
||||
if(operation == CPTableViewDropAbove)
|
||||
if (operation == CPTableViewDropAbove)
|
||||
{
|
||||
// Save the first object in the list so we can determine where the
|
||||
// beginning of the moved block begins once all the selected rows have
|
||||
|
||||