mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-26 13:37:03 +00:00
Merge branch 'master' of git@github.com:tolmasky/cappuccino into tolmasky
This commit is contained in:
+2
-1
@@ -1 +1,2 @@
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
Frameworks
|
||||
|
||||
+26
-4
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+48
-12
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
@implementation CAAnimation : CPObject
|
||||
{
|
||||
BOOL _isRemovedOnCompletion;
|
||||
id _delegate;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
+10
-2
@@ -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 <code>aFunction</code>. This invokes
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user