diff --git a/.gitignore b/.gitignore index 496ee2ca6..68dba5b20 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +Frameworks diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index 152fe19ef..9d7572f57 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -84,6 +84,7 @@ var CPAlertWarningImage, CPImageView _alertImageView; CPAlertStyle _alertStyle; + CPString _windowTitle; int _windowStyle; int _buttonCount; CPArray _buttons; @@ -163,6 +164,23 @@ var CPAlertWarningImage, [[_alertPanel contentView] addSubview:_alertImageView]; } +/*! + Sets the window's title. If this is not defined, a default title based on your warning level will be used. + @param aTitle the title to use in place of the default. Set to nil to use default. +*/ +- (void)setTitle:(CPString)aTitle +{ + _windowTitle = aTitle; +} + +/*! + Gets the window's title. +*/ +- (CPString)title +{ + return _windowTitle; +} + /*! Gets the window's style. */ @@ -252,19 +270,23 @@ var CPAlertWarningImage, */ - (void)runModal { + var theTitle; + switch (_alertStyle) { case CPWarningAlertStyle: [_alertImageView setImage:CPAlertWarningImage]; - [_alertPanel setTitle:@"Warning"]; + theTitle = @"Warning"; break; case CPInformationalAlertStyle: [_alertImageView setImage:CPAlertInformationImage]; - [_alertPanel setTitle:@"Information"]; + theTitle = @"Information"; break; case CPCriticalAlertStyle: [_alertImageView setImage:CPAlertErrorImage]; - [_alertPanel setTitle:@"Error"]; + theTitle = @"Error"; break; } - + + [_alertPanel setTitle:_windowTitle ? _windowTitle : theTitle]; + [CPApp runModalForWindow:_alertPanel]; } diff --git a/AppKit/CPClipView.j b/AppKit/CPClipView.j index 3ee0dd8a2..a525716a0 100644 --- a/AppKit/CPClipView.j +++ b/AppKit/CPClipView.j @@ -139,7 +139,7 @@ */ - (void)viewBoundsChanged:(CPNotification)aNotification { - [self viewFrameChanged:aNotification]; + [self _constrainScrollPoint]; } /*! @@ -147,6 +147,17 @@ @param aNotification the notification event */ - (void)viewFrameChanged:(CPNotification)aNotification +{ + [self _constrainScrollPoint]; +} + +- (void)resizeSubviewsWithOldSize:(CGSize)aSize +{ + [super resizeSubviewsWithOldSize:aSize]; + [self _constrainScrollPoint]; +} + +- (void)_constrainScrollPoint { var oldScrollPoint = [self bounds].origin; diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index a5522a56c..d339f88c2 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -230,6 +230,14 @@ return _title; } +/*! + Set's the item's text color +*/ +- (void)setTextColor:(CPString)aColor +{ + //FIXME IMPLEMENT +} + /*! Sets the font for the text of this menu item @param aFont the font for the menu item diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 0597d995e..36341556f 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -136,6 +136,15 @@ var CPPopUpButtonArrowsImage = nil; } // Inserting and Deleting Items + +/*! + Adds a new menu item using a CPMenuItem object. +*/ +- (void)addItem:(CPMenuItem)anItem +{ + [_menu addItem:anItem]; +} + /*! Adds a new menu item with the specified title. @param the new menu item's tite diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 703fa8c9c..38d001f14 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -459,20 +459,56 @@ var CPSplitViewHorizontalImage = nil, var index = 0, count = [_subviews count], bounds = [self bounds], - dividerThickness = [self dividerThickness]; - - for (; index < count; ++index) + dividerThickness = [self dividerThickness], + totalDividers = count - 1, + totalSizableSpace = 0, + nonSizableSpace = 0, + lastSizableIndex = -1, + totalSizablePanes = 0, + isVertical = [self isVertical]; + + for (index = 0; index < count; ++index) { var view = _subviews[index], - viewFrame = CGRectMakeCopy(bounds); - - if (index + 1 == count) - viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] - viewFrame.origin[_originComponent]; - else - viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] * ([view frame].size[_sizeComponent] / oldSize[_sizeComponent]); - - bounds.origin[_originComponent] += viewFrame.size[_sizeComponent] + dividerThickness; - + isSizable = isVertical ? [view autoresizingMask] & CPViewWidthSizable : [view autoresizingMask] & CPViewHeightSizable; + + if (isSizable) + { + totalSizableSpace += [view frame].size[_sizeComponent]; + lastSizableIndex = index; + totalSizablePanes++; + } + } + + if (totalSizablePanes === count) + totalSizableSpace = 0; + + var nonSizableSpace = totalSizableSpace ? bounds.size[_sizeComponent] - totalSizableSpace : 0, + ratio = (bounds.size[_sizeComponent] - totalDividers*dividerThickness - nonSizableSpace) / (oldSize[_sizeComponent]- totalDividers*dividerThickness - nonSizableSpace), + remainingFlexibleSpace = bounds.size[_sizeComponent] - oldSize[_sizeComponent]; + + for (index = 0; index < count; ++index) + { + var view = _subviews[index], + viewFrame = CGRectMakeCopy(bounds), + isSizable = isVertical ? [view autoresizingMask] & CPViewWidthSizable : [view autoresizingMask] & CPViewHeightSizable; + + if (index + 1 == count) + viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] - viewFrame.origin[_originComponent]; + else if (totalSizableSpace && isSizable && lastSizableIndex === index) + viewFrame.size[_sizeComponent] = MAX(0, ROUND([view frame].size[_sizeComponent] + remainingFlexibleSpace)) + else if (isSizable || !totalSizableSpace) + { + viewFrame.size[_sizeComponent] = MAX(0, ROUND(ratio * [view frame].size[_sizeComponent])); + remainingFlexibleSpace -= (viewFrame.size[_sizeComponent] - [view frame].size[_sizeComponent]); + } + else if (totalSizableSpace && !isSizable) + viewFrame.size[_sizeComponent] = [view frame].size[_sizeComponent]; + else + alert("SHOULD NEVER GET HERE"); + + bounds.origin[_originComponent] += viewFrame.size[_sizeComponent] + dividerThickness; + [view setFrame:viewFrame]; } diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 1a6b7a564..e3edb99cf 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1,3 +1,4 @@ + /* * CPTextField.j * AppKit @@ -402,7 +403,7 @@ var _CPTextFieldSquareBezelColor = nil, /* @ignore */ - (BOOL)acceptsFirstResponder { - return _isEditable; + return _isEditable && _isEnabled; } /* @ignore */ @@ -412,7 +413,7 @@ var _CPTextFieldSquareBezelColor = nil, var string = [self stringValue]; [self setStringValue:""]; - + #if PLATFORM(DOM) var element = [[self class] _inputElement]; @@ -512,7 +513,7 @@ var _CPTextFieldSquareBezelColor = nil, // If current value is the placeholder value, remove it to allow user to update. if ([string lowercaseString] == [[self placeholderString] lowercaseString]) - [self setStringValue:""]; + element.value = ""; //post CPControlTextDidBeginEditingNotification [self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]]; @@ -552,7 +553,7 @@ var _CPTextFieldSquareBezelColor = nil, { if (![self isEditable]) return [[self nextResponder] mouseDown:anEvent]; - + [super mouseDown:anEvent]; } /* @@ -616,7 +617,7 @@ var _CPTextFieldSquareBezelColor = nil, else displayString += aValue; } - + if ([[self window] firstResponder] == self) [[self class] _inputElement].value = displayString; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 03923bef4..34e067387 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -577,6 +577,27 @@ var DOMElementPrototype = nil, return _CGRectMakeCopy(_frame); } +/*! + Moves the center of the receiver's frame to the provided point. The point is defined in the superview's coordinate system. + The method posts a CPViewFrameDidChangeNotification to the default notification center if the receiver + is configured to do so. If the specified origin is the same as the frame's current origin, the method will + simply return (and no notification will be posted). + @param aPoint the new origin point +*/ +- (void)setCenter:(CGPoint)aPoint +{ + [self setFrameOrigin:CGPointMake(aPoint.x - _frame.size.width / 2.0, aPoint.y - _frame.size.height / 2.0)]; +} + +/*! + Returns the center of the receiver's frame to the provided point. The point is defined in the superview's coordinate system. + @return CGPoint the center point of the receiver's frame +*/ +- (CGPoint)center +{ + return CGPointMake(_frame.size.width / 2.0 + _frame.origin.x, _frame.size.height / 2.0 + _frame.origin.y); +} + /*! Sets the receiver's frame origin to the provided point. The point is defined in the superview's coordinate system. The method posts a CPViewFrameDidChangeNotification to the default notification center if the receiver @@ -870,6 +891,15 @@ var DOMElementPrototype = nil, } // Fullscreen Mode + +/*! + Puts the receiver into full screen mode. +*/ +- (BOOL)enterFullScreenMode +{ + return [self enterFullScreenMode:nil withOptions:nil]; +} + /*! Puts the receiver into full screen mode. @param aScreen the that should be used @@ -901,6 +931,14 @@ var DOMElementPrototype = nil, return YES; } +/*! + The receiver should exit full screen mode. +*/ +- (void)exitFullScreenMode +{ + [self exitFullScreenModeWithOptions:nil]; +} + /*! The receiver should exit full screen mode. @param options configurations options diff --git a/AppKit/CoreAnimation/CAAnimation.j b/AppKit/CoreAnimation/CAAnimation.j index fbaca60fd..8303b7ef4 100644 --- a/AppKit/CoreAnimation/CAAnimation.j +++ b/AppKit/CoreAnimation/CAAnimation.j @@ -31,6 +31,7 @@ @implementation CAAnimation : CPObject { BOOL _isRemovedOnCompletion; + id _delegate; } /*! diff --git a/Foundation/CPArray.j b/Foundation/CPArray.j index cb4951ad6..98b5bcf05 100755 --- a/Foundation/CPArray.j +++ b/Foundation/CPArray.j @@ -51,7 +51,7 @@ if (++_index >= [_array count]) return nil; - return _array[_index]; + return [_array objectAtIndex:_index]; } @end @@ -81,7 +81,7 @@ if (--_index < 0) return nil; - return _array[_index]; + return [_array objectAtIndex:_index]; } @end @@ -735,6 +735,14 @@ return sorted; } +/*! + Return a copy of the receiver sorted using the function passed into the first parameter. +*/ +- (CPArray)sortedArrayUsingFunction:(Function)aFunction +{ + return [self sortedArrayUsingFunction:aFunction context:nil]; +} + /*! Returns an array in which the objects are ordered according to a sort with aFunction. This invokes diff --git a/Foundation/CPSet.j b/Foundation/CPSet.j index fe272d5c4..6b2abaf53 100644 --- a/Foundation/CPSet.j +++ b/Foundation/CPSet.j @@ -68,7 +68,7 @@ argLength = arguments.length, i = 2; - for(; i < argLength && (argument = arguments[i]) != nil; ++i) + for(; i < argLength && ((argument = arguments[i]) !== nil); ++i) [set addObject:argument]; return set; diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 6a83344a5..96be2311f 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -662,4 +662,22 @@ var CPStringHashes = new objj_dictionary(); @end + +@implementation CPString (UUID) + +/*! + Returns a randomly generated Universally Unique Identifier. +*/ ++ (CPString)UUID +{ + var g = @""; + + for(var i = 0; i < 32; i++) + g += FLOOR(RAND() * 0xF).toString(0xF); + + return g; +} + +@end + String.prototype.isa = CPString; diff --git a/Foundation/CPURLResponse.j b/Foundation/CPURLResponse.j index 1287a0c15..15bf17f66 100644 --- a/Foundation/CPURLResponse.j +++ b/Foundation/CPURLResponse.j @@ -53,13 +53,13 @@ } /* Creating a Response -Ð initWithURL:MIMEType:expectedContentLength:textEncodingName: +initWithURL:MIMEType:expectedContentLength:textEncodingName: Getting the Response Properties -Ð expectedContentLength -Ð suggestedFilename -Ð MIMEType -Ð textEncodingName -Ð URL +expectedContentLength +suggestedFilename +MIMEType +textEncodingName +URL */ @end diff --git a/Tools/nib2cib/NSButton.j b/Tools/nib2cib/NSButton.j index 3c746316c..be8bc539b 100644 --- a/Tools/nib2cib/NSButton.j +++ b/Tools/nib2cib/NSButton.j @@ -49,17 +49,6 @@ _CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20; _isBordered = [cell isBordered]; _bezelStyle = [cell bezelStyle]; - var theme = nil, - theClass = [self class]; - - _bezelInset = CPThemedValueMake(CGInsetMakeZero(), "bezel-inset", theme, theClass); - _contentInset = CPThemedValueMake(CGInsetMakeZero(), "content-inset", theme, theClass); - - _bezelColor = CPThemedValueMake(nil, "bezel-color", theme, theClass); - - _image = CPThemedValueMake(nil, @"image", theme, theClass); - _title = CPThemedValueMake(nil, @"title", theme, theClass); - // clean up: switch (_bezelStyle) @@ -98,11 +87,11 @@ _CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20; _bezelStyle = CPHUDBezelStyle; } - if (_CPButtonBezelStyleHeights[_bezelStyle] != undefined) + //if (_CPButtonBezelStyleHeights[_bezelStyle] != undefined) { - CPLog.warn("Adjusting CPButton height from " +_frame.size.height+ " / " + _bounds.size.height+" to " + _CPButtonBezelStyleHeights[_bezelStyle]); - _frame.size.height = _CPButtonBezelStyleHeights[_bezelStyle]; - _bounds.size.height = _CPButtonBezelStyleHeights[_bezelStyle]; + //CPLog.warn("Adjusting CPButton height from " +_frame.size.height+ " / " + _bounds.size.height+" to " + _CPButtonBezelStyleHeights[_bezelStyle]); + _frame.size.height = 24.0;//_CPButtonBezelStyleHeights[_bezelStyle]; + _bounds.size.height = 24.0;//_CPButtonBezelStyleHeights[_bezelStyle]; } }