diff --git a/AppKit/AppKit.j b/AppKit/AppKit.j index a31ee2e9d..2a34e76f4 100644 --- a/AppKit/AppKit.j +++ b/AppKit/AppKit.j @@ -39,6 +39,7 @@ @import "CPCibLoading.j" @import "CPCibOutletConnector.j" @import "CPCibRuntimeAttributesConnector.j" +@import "CPCibHelpConnector.j" @import "CPClipView.j" @import "CPCollectionView.j" @import "CPCollectionViewItem.j" diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 24a758d2f..b79b72c93 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -802,9 +802,7 @@ var CPButtonImageKey = @"CPButtonImageKey", _title = [aCoder decodeObjectForKey:CPButtonTitleKey]; _alternateTitle = [aCoder decodeObjectForKey:CPButtonAlternateTitleKey]; - - if ([aCoder containsValueForKey:CPButtonAllowsMixedStateKey]) - _allowsMixedState = [aCoder decodeBoolForKey:CPButtonAllowsMixedStateKey]; + _allowsMixedState = [aCoder decodeBoolForKey:CPButtonAllowsMixedStateKey]; [self setImageDimsWhenDisabled:[aCoder decodeObjectForKey:CPButtonImageDimsWhenDisabledKey]]; diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 1ed66000d..f49631587 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -1008,11 +1008,11 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK _itemSize = CGSizeMakeZero(); - _minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero(); - _maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero(); + _minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey]; + _maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey]; - _maxNumberOfRows = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfRowsKey] || 0; - _maxNumberOfColumns = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfColumnsKey] || 0; + _maxNumberOfRows = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfRowsKey]; + _maxNumberOfColumns = [aCoder decodeIntForKey:CPCollectionViewMaxNumberOfColumnsKey]; _verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey]; diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index 535a7f86c..8540a9c1c 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -516,7 +516,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey", [self setHasShadow:[aCoder decodeBoolForKey:CPImageViewHasShadowKey]]; [self setImageAlignment:[aCoder decodeIntForKey:CPImageViewImageAlignmentKey]]; - if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey] || NO) + if ([aCoder decodeBoolForKey:CPImageViewIsEditableKey]) [self setEditable:YES]; [self setNeedsLayout]; diff --git a/AppKit/CPMenuItem/CPMenuItem.j b/AppKit/CPMenuItem/CPMenuItem.j index 6d70ba1b4..063fed763 100644 --- a/AppKit/CPMenuItem/CPMenuItem.j +++ b/AppKit/CPMenuItem/CPMenuItem.j @@ -932,34 +932,33 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey", _action = [aCoder decodeObjectForKey:CPMenuItemActionKey]; _isEnabled = DEFAULT_VALUE(CPMenuItemIsEnabledKey, YES); - _isHidden = DEFAULT_VALUE(CPMenuItemIsHiddenKey, NO); - _tag = DEFAULT_VALUE(CPMenuItemTagKey, 0); - _state = DEFAULT_VALUE(CPMenuItemStateKey, CPOffState); + _isHidden = [aCoder decodeBoolForKey:CPMenuItemIsHiddenKey]; + _tag = [aCoder decodeIntForKey:CPMenuItemTagKey]; + _state = [aCoder decodeIntForKey:CPMenuItemStateKey]; - _image = DEFAULT_VALUE(CPMenuItemImageKey, nil); - _alternateImage = DEFAULT_VALUE(CPMenuItemAlternateImageKey, nil); + _image = [aCoder decodeObjectForKey:CPMenuItemImageKey]; + _alternateImage = [aCoder decodeObjectForKey:CPMenuItemAlternateImageKey]; // CPImage _onStateImage; // CPImage _offStateImage; // CPImage _mixedStateImage; // This order matters because setSubmenu: needs _menu to be around. - _menu = DEFAULT_VALUE(CPMenuItemMenuKey, nil); - [self setSubmenu:DEFAULT_VALUE(CPMenuItemSubmenuKey, nil)]; + _menu = [aCoder decodeObjectForKey:CPMenuItemMenuKey]; + [self setSubmenu:[aCoder decodeObjectForKey:CPMenuItemSubmenuKey]]; _keyEquivalent = [aCoder decodeObjectForKey:CPMenuItemKeyEquivalentKey] || @""; - _keyEquivalentModifierMask = [aCoder decodeObjectForKey:CPMenuItemKeyEquivalentModifierMaskKey] || 0; + _keyEquivalentModifierMask = [aCoder decodeIntForKey:CPMenuItemKeyEquivalentModifierMaskKey]; // int _mnemonicLocation; // BOOL _isAlternate; - // Default is 0. - [self setIndentationLevel:[aCoder decodeIntForKey:CPMenuItemIndentationLevelKey] || 0]; + [self setIndentationLevel:[aCoder decodeIntForKey:CPMenuItemIndentationLevelKey]]; // CPString _toolTip; - _representedObject = DEFAULT_VALUE(CPMenuItemRepresentedObjectKey, nil); - _view = DEFAULT_VALUE(CPMenuItemViewKey, nil); + _representedObject = [aCoder decodeObjectForKey:CPMenuItemRepresentedObjectKey]; + _view = [aCoder decodeObjectForKey:CPMenuItemViewKey]; } return self; diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index 4905413e8..8999f84da 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -371,7 +371,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo [self setObjectClass:objectClass || [CPMutableDictionary class]]; [self setEditable:[aCoder decodeBoolForKey:CPObjectControllerIsEditableKey]]; - [self setAutomaticallyPreparesContent:[aCoder decodeBoolForKey:CPObjectControllerAutomaticallyPreparesContentKey] || NO]; + [self setAutomaticallyPreparesContent:[aCoder decodeBoolForKey:CPObjectControllerAutomaticallyPreparesContentKey]]; [self setContent:[aCoder decodeObjectForKey:CPObjectControllerContentKey]]; _observedKeys = [[CPCountedSet alloc] init]; diff --git a/AppKit/CPRuleEditor/CPPredicateEditor.j b/AppKit/CPRuleEditor/CPPredicateEditor.j index 5c4aadb64..ebf1985d2 100644 --- a/AppKit/CPRuleEditor/CPPredicateEditor.j +++ b/AppKit/CPRuleEditor/CPPredicateEditor.j @@ -374,12 +374,13 @@ if (rowType == CPRuleEditorRowTypeCompound) { var subrows = [rowItem valueForKey:_subrowsArrayKeyPath], - count = [subrows count]; + count = [subrows count]; for (var i = 0; i < count; i++) { - var subrow = [subrows objectAtIndex:i]; - var predicate = [self _predicateFromRowItem:subrow]; + var subrow = [subrows objectAtIndex:i], + predicate = [self _predicateFromRowItem:subrow]; + [subpredicates addObject:predicate]; } } @@ -484,9 +485,11 @@ var CPPredicateTemplatesKey = @"CPPredicateTemplates"; - (id)initWithCoder:(id)aCoder { self = [super initWithCoder:aCoder]; + if (self != nil) { var nibTemplates = [aCoder decodeObjectForKey:CPPredicateTemplatesKey]; + if (nibTemplates != nil) [self setRowTemplates:nibTemplates]; } diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 391389553..1d55fc2bd 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -1506,8 +1506,8 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView", _scrollTimer = nil; _implementedDelegateMethods = 0; - _scrollerStyle = [aCoder decodeIntForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal; - _scrollerKnobStyle = [aCoder decodeIntForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault; + _scrollerStyle = [aCoder decodeObjectForKey:CPScrollViewScrollerStyleKey] || CPScrollerStyleGlobal; + _scrollerKnobStyle = [aCoder decodeObjectForKey:CPScrollViewScrollerKnobStyleKey] || CPScrollerKnobStyleDefault; [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_didReceiveDefaultStyleChange:) diff --git a/AppKit/CPStepper.j b/AppKit/CPStepper.j index 6ad75afe1..b16833262 100644 --- a/AppKit/CPStepper.j +++ b/AppKit/CPStepper.j @@ -263,10 +263,10 @@ var CPStepperMinValue = @"CPStepperMinValue", if (self = [super initWithCoder:aCoder]) { _increment = [aCoder decodeIntForKey:CPStepperIncrement]; - _minValue = [aCoder decodeIntForKey:CPStepperMinValue] || 0; - _maxValue = [aCoder decodeIntForKey:CPStepperMaxValue] || 0; - _valueWraps = [aCoder decodeBoolForKey:CPStepperValueWraps] || NO; - _autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat] || NO; + _minValue = [aCoder decodeIntForKey:CPStepperMinValue]; + _maxValue = [aCoder decodeIntForKey:CPStepperMaxValue]; + _valueWraps = [aCoder decodeBoolForKey:CPStepperValueWraps]; + _autorepeat = [aCoder decodeBoolForKey:CPStepperAutorepeat]; [self _init]; } diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 7fb26a8bf..38b86ff85 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -4782,15 +4782,14 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey", _tableColumns = [aCoder decodeObjectForKey:CPTableViewTableColumnsKey] || []; [_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self]; - if ([aCoder containsValueForKey:CPTableViewRowHeightKey]) - _rowHeight = [aCoder decodeFloatForKey:CPTableViewRowHeightKey]; - else - _rowHeight = 23.0; + _rowHeight = [aCoder decodeFloatForKey:CPTableViewRowHeightKey] || 23.0; + _intercellSpacing = [aCoder decodeSizeForKey:CPTableViewIntercellSpacingKey]; - _intercellSpacing = [aCoder decodeSizeForKey:CPTableViewIntercellSpacingKey] || _CGSizeMake(3.0, 2.0); + if (_CGSizeEqualToSize(_intercellSpacing, _CGSizeMakeZero())) + _intercellSpacing = _CGSizeMake(3.0, 2.0); [self setGridColor:[aCoder decodeObjectForKey:CPTableViewGridColorKey]]; - _gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone; + _gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey]; _usesAlternatingRowBackgroundColors = [aCoder decodeObjectForKey:CPTableViewUsesAlternatingBackgroundKey]; [self setAlternatingRowBackgroundColors:[aCoder decodeObjectForKey:CPTableViewAlternatingRowColorsKey]]; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 7129b8cad..315650a60 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -98,6 +98,10 @@ var CPViewFlags = { }, CPViewHasCustomDrawRect = 1 << 0, CPViewHasCustomLayoutSubviews = 1 << 1; +var CPCurrentToolTip, + CPCurrentToolTipTimer, + CPToolTipDelay = 1.0; + /*! @ingroup appkit @class CPView @@ -189,7 +193,10 @@ var CPViewFlags = { }, unsigned _viewClassFlags; // ToolTips - CPString _toolTip @accessors(property=toolTip); + CPString _toolTip @accessors(getter=toolTip); + Function _toolTipFunctionIn; + Function _toolTipFunctionOut; + BOOL _toolTipInstalled; } /* @@ -215,7 +222,7 @@ var CPViewFlags = { }, CachedNotificationCenter = [CPNotificationCenter defaultCenter]; } -- (void)setupViewFlags +- (void)_setupViewFlags { var theClass = [self class], classUID = [theClass UID]; @@ -236,6 +243,13 @@ var CPViewFlags = { }, _viewClassFlags = CPViewFlags[classUID]; } +- (void)_setupToolTipHandlers +{ + _toolTipInstalled = NO; + _toolTipFunctionIn = function(e){[self _fireToolTip];} + _toolTipFunctionOut = function(e){[self _invalidateToolTip];}; +} + + (CPSet)keyPathsForValuesAffectingFrame { return [CPSet setWithObjects:@"frameOrigin", @"frameSize"]; @@ -302,7 +316,8 @@ var CPViewFlags = { }, _theme = [CPTheme defaultTheme]; _themeState = CPThemeStateNormal; - [self setupViewFlags]; + [self _setupToolTipHandlers]; + [self _setupViewFlags]; [self _loadThemeAttributes]; } @@ -310,6 +325,118 @@ var CPViewFlags = { }, return self; } + +/*! + Sets the tooltip for the receiver. + + @param aToolTip the tooltip +*/ +- (void)setToolTip:(CPString)aToolTip +{ + if (_toolTip == aToolTip) + return; + + _toolTip = aToolTip; + + if (_toolTip) + [self _installToolTipEventHandlers]; + else + [self _uninstallToolTipEventHandlers]; +} + +/*! @ignore + + Install the handlers for the tooltip +*/ +- (void)_installToolTipEventHandlers +{ + if (_toolTipInstalled) + return; + + if (_DOMElement.addEventListener) + { + _DOMElement.addEventListener("mouseover", _toolTipFunctionIn, NO); + _DOMElement.addEventListener("keypress", _toolTipFunctionOut, NO); + _DOMElement.addEventListener("mouseout", _toolTipFunctionOut, NO); + } + else if (_DOMElement.attachEvent) + { + _DOMElement.attachEvent("onmouseover", _toolTipFunctionIn); + _DOMElement.attachEvent("onkeypress", _toolTipFunctionOut); + _DOMElement.attachEvent("onmouseout", _toolTipFunctionOut); + } + _toolTipInstalled = YES; +} + +/*! @ignore + + Uninstall the handlers for the tooltip +*/ +- (void)_uninstallToolTipEventHandlers +{ + if (!_toolTipInstalled) + return; + + if (_DOMElement.removeEventListener) + { + _DOMElement.removeEventListener("mouseover", _toolTipFunctionIn, NO); + _DOMElement.removeEventListener("keypress", _toolTipFunctionOut, NO); + _DOMElement.removeEventListener("mouseout", _toolTipFunctionOut, NO); + } + else if (_DOMElement.detachEvent) + { + _DOMElement.detachEvent("onmouseover", _toolTipFunctionIn); + _DOMElement.detachEvent("onkeypress", _toolTipFunctionOut); + _DOMElement.detachEvent("onmouseout", _toolTipFunctionOut); + } + _toolTipInstalled = NO; +} + +/*! @ignore + Starts the tooltip timer. +*/ +- (void)_fireToolTip +{ + if (CPCurrentToolTipTimer) + { + [CPCurrentToolTipTimer invalidate]; + if (CPCurrentToolTip) + [CPCurrentToolTip close]; + CPCurrentToolTip = nil; + } + + if (_toolTip) + CPCurrentToolTipTimer = [CPTimer scheduledTimerWithTimeInterval:CPToolTipDelay target:self selector:@selector(_showToolTip:) userInfo:nil repeats:NO]; +} + +/*! @ignore + Stop the tooltip timer if any +*/ +- (void)_invalidateToolTip +{ + if (CPCurrentToolTipTimer) + { + [CPCurrentToolTipTimer invalidate]; + CPCurrentToolTipTimer = nil; + } + + if (CPCurrentToolTip) + { + [CPCurrentToolTip close]; + CPCurrentToolTip = nil; + } +} + +/*! @ignore + Actually shows the tooltip if any +*/ +- (void)_showToolTip:(CPTimer)aTimer +{ + if (CPCurrentToolTip) + [CPCurrentToolTip close]; + CPCurrentToolTip = [_CPToolTip toolTipWithString:_toolTip]; +} + /*! Returns the container view of the receiver @return the receiver's containing view @@ -2707,6 +2834,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", CPViewBoundsKey = @"CPViewBoundsKey", CPViewFrameKey = @"CPViewFrameKey", CPViewHitTestsKey = @"CPViewHitTestsKey", + CPViewToolTipKey = @"CPViewToolTipKey", CPViewIsHiddenKey = @"CPViewIsHiddenKey", CPViewOpacityKey = @"CPViewOpacityKey", CPViewSubviewsKey = @"CPViewSubviewsKey", @@ -2761,7 +2889,12 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", _autoresizesSubviews = ![aCoder containsValueForKey:CPViewAutoresizesSubviewsKey] || [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey]; - _hitTests = ![aCoder containsValueForKey:CPViewHitTestsKey] || [aCoder decodeObjectForKey:CPViewHitTestsKey]; + _hitTests = ![aCoder containsValueForKey:CPViewHitTestsKey] || [aCoder decodeBoolForKey:CPViewHitTestsKey]; + + [self _setupToolTipHandlers]; + _toolTip = [aCoder decodeObjectForKey:CPViewToolTipKey]; + if (_toolTip) + [self _installToolTipEventHandlers]; // DOM SETUP #if PLATFORM(DOM) @@ -2781,10 +2914,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", } #endif - if ([aCoder containsValueForKey:CPViewIsHiddenKey]) - [self setHidden:[aCoder decodeBoolForKey:CPViewIsHiddenKey]]; - else - _isHidden = NO; + [self setHidden:[aCoder decodeBoolForKey:CPViewIsHiddenKey]]; if ([aCoder containsValueForKey:CPViewOpacityKey]) [self setAlphaValue:[aCoder decodeIntForKey:CPViewOpacityKey]]; @@ -2792,8 +2922,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", _opacity = 1.0; [self setBackgroundColor:[aCoder decodeObjectForKey:CPViewBackgroundColorKey]]; - - [self setupViewFlags]; + [self _setupViewFlags]; _theme = [CPTheme defaultTheme]; _themeClass = [aCoder decodeObjectForKey:CPViewThemeClassKey]; @@ -2874,6 +3003,9 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", if (_isHidden) [aCoder encodeBool:_isHidden forKey:CPViewIsHiddenKey]; + if (_toolTip) + [aCoder encodeObject:_toolTip forKey:CPViewToolTipKey]; + var nextKeyView = [self nextKeyView]; if (nextKeyView !== nil && ![nextKeyView isEqual:self]) @@ -2997,3 +3129,5 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView) return transform; }; + + diff --git a/AppKit/Cib/CPCibHelpConnector.j b/AppKit/Cib/CPCibHelpConnector.j new file mode 100644 index 000000000..8049abda9 --- /dev/null +++ b/AppKit/Cib/CPCibHelpConnector.j @@ -0,0 +1,59 @@ +/* + * CPCibHelpConnector.j + * AppKit + * + * Created by Antoine Mercadal. + * Copyright 2012, The Cappuccino Project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import "CPCibConnector.j" + +@implementation CPCibHelpConnector : CPCibConnector +{ + id _destination; + id _file; + id _marker; +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + if (self = [super initWithCoder:aCoder]) + { + _destination = [aCoder decodeObjectForKey:@"_destination"]; + _file = [aCoder decodeObjectForKey:@"_file"]; + _marker = [aCoder decodeObjectForKey:@"_marker"]; + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [super encodeWithCoder:aCoder]; + + [aCoder encodeObject:_destination forKey:@"_destination"]; + [aCoder encodeObject:_file forKey:@"_file"]; + [aCoder encodeObject:_marker forKey:@"_marker"]; +} + +- (void)establishConnection +{ + [_destination setToolTip:_marker]; +} + +@end + diff --git a/AppKit/Cib/_CPCibObjectData.j b/AppKit/Cib/_CPCibObjectData.j index 79a982bab..2d1eecf95 100644 --- a/AppKit/Cib/_CPCibObjectData.j +++ b/AppKit/Cib/_CPCibObjectData.j @@ -30,6 +30,7 @@ @import "CPCibOutletConnector.j" @import "CPCibBindingConnector.j" @import "CPCibRuntimeAttributesConnector.j" +@import "CPCibHelpConnector.j" @implementation _CPCibObjectData : CPObject diff --git a/AppKit/Cib/_CPCibWindowTemplate.j b/AppKit/Cib/_CPCibWindowTemplate.j index 6d232a76c..9ea2b4096 100644 --- a/AppKit/Cib/_CPCibWindowTemplate.j +++ b/AppKit/Cib/_CPCibWindowTemplate.j @@ -77,8 +77,8 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemp _windowTitle = [aCoder decodeObjectForKey:_CPCibWindowTemplateWindowTitleKey]; _windowView = [aCoder decodeObjectForKey:_CPCibWindowTemplateWindowViewKey]; - _windowAutorecalculatesKeyViewLoop = !![aCoder decodeObjectForKey:_CPCibWindowTemplateWindowAutorecalculatesKeyViewLoop]; - _windowIsFullPlatformWindow = !![aCoder decodeObjectForKey:_CPCibWindowTemplateWindowIsFullPlatformWindowKey]; + _windowAutorecalculatesKeyViewLoop = [aCoder decodeBoolForKey:_CPCibWindowTemplateWindowAutorecalculatesKeyViewLoop]; + _windowIsFullPlatformWindow = [aCoder decodeBoolForKey:_CPCibWindowTemplateWindowIsFullPlatformWindowKey]; } return self; diff --git a/AppKit/_CPToolTip.j b/AppKit/_CPToolTip.j index cc4591a16..db37f34e3 100644 --- a/AppKit/_CPToolTip.j +++ b/AppKit/_CPToolTip.j @@ -27,10 +27,7 @@ _CPToolTipWindowMask = 1 << 27; var _CPToolTipHeight = 24.0, - _CPToolTipFontSize = 11.0, - _CPCurrentToolTip, - _CPCurrentToolTipTimer, - _CPToolTipDelay = 1.0; + _CPToolTipFontSize = 11.0; /*! @ingroup appkit This is a basic tooltip that behaves mostly like Cocoa ones. @@ -178,118 +175,4 @@ var _CPToolTipHeight = 24.0, -/*! @ingroup appkit - Add tooltip support to CPView. -*/ -@implementation CPView (toolTips) -/*! - Sets the tooltip for the receiver. - - @param aToolTip the tooltip -*/ -- (void)setToolTip:(CPString)aToolTip -{ - if (_toolTip == aToolTip) - return; - - _toolTip = aToolTip; - - if (!_DOMElement) - return; - - var fIn = function(e) - { - [self _fireToolTip]; - }, - fOut = function(e) - { - [self _invalidateToolTip]; - }; - - if (_toolTip) - { - if (_DOMElement.addEventListener) - { - _DOMElement.addEventListener("mouseover", fIn, NO); - _DOMElement.addEventListener("keypress", fOut, NO); - _DOMElement.addEventListener("mouseout", fOut, NO); - } - else if (_DOMElement.attachEvent) - { - _DOMElement.attachEvent("onmouseover", fIn); - _DOMElement.attachEvent("onkeypress", fOut); - _DOMElement.attachEvent("onmouseout", fOut); - } - } - else - { - if (_DOMElement.removeEventListener) - { - _DOMElement.removeEventListener("mouseover", fIn, NO); - _DOMElement.removeEventListener("keypress", fOut, NO); - _DOMElement.removeEventListener("mouseout", fOut, NO); - } - else if (_DOMElement.detachEvent) - { - _DOMElement.detachEvent("onmouseover", fIn); - _DOMElement.detachEvent("onkeypress", fOut); - _DOMElement.detachEvent("onmouseout", fOut); - } - } -} - -/*! - Returns the receiver's tooltip. -*/ -- (CPString)toolTip -{ - return _toolTip; -} - -/*! @ignore - Starts the tooltip timer. -*/ -- (void)_fireToolTip -{ - if (_CPCurrentToolTipTimer) - { - [_CPCurrentToolTipTimer invalidate]; - if (_CPCurrentToolTip) - [_CPCurrentToolTip close]; - _CPCurrentToolTip = nil; - } - - if (_toolTip) - _CPCurrentToolTipTimer = [CPTimer scheduledTimerWithTimeInterval:_CPToolTipDelay target:self selector:@selector(_showToolTip:) userInfo:nil repeats:NO]; -} - -/*! @ignore - Stop the tooltip timer if any -*/ -- (void)_invalidateToolTip -{ - if (_CPCurrentToolTipTimer) - { - [_CPCurrentToolTipTimer invalidate]; - _CPCurrentToolTipTimer = nil; - } - - if (_CPCurrentToolTip) - { - [_CPCurrentToolTip close]; - _CPCurrentToolTip = nil; - } -} - -/*! @ignore - Actually shows the tooltip if any -*/ -- (void)_showToolTip:(CPTimer)aTimer -{ - if (_CPCurrentToolTip) - [_CPCurrentToolTip close]; - _CPCurrentToolTip = [_CPToolTip toolTipWithString:_toolTip]; -} - -@end diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 22cef5289..9d5f0a3f6 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -251,7 +251,9 @@ var CPArrayClass = Ni */ - (float)decodeFloatForKey:(CPString)aKey { - return [self decodeObjectForKey:aKey]; + var f = [self decodeObjectForKey:aKey]; + + return f === nil ? 0.0 : f; } /* @@ -261,7 +263,9 @@ var CPArrayClass = Ni */ - (double)decodeDoubleForKey:(CPString)aKey { - return [self decodeObjectForKey:aKey]; + var d = [self decodeObjectForKey:aKey]; + + return d === nil ? 0.0 : d; } /* @@ -271,7 +275,9 @@ var CPArrayClass = Ni */ - (int)decodeIntForKey:(CPString)aKey { - return [self decodeObjectForKey:aKey]; + var i = [self decodeObjectForKey:aKey]; + + return i === nil ? 0 : i; } /* @@ -284,9 +290,9 @@ var CPArrayClass = Ni var object = [self decodeObjectForKey:aKey]; if (object) - return CPPointFromString(object); + return CGPointFromString(object); else - return CPPointMake(0.0, 0.0); + return CGPointMakeZero(); } /* @@ -299,9 +305,9 @@ var CPArrayClass = Ni var object = [self decodeObjectForKey:aKey]; if (object) - return CPRectFromString(object); + return CGRectFromString(object); else - return CPRectMakeZero(); + return CGRectMakeZero(); } /* @@ -314,9 +320,9 @@ var CPArrayClass = Ni var object = [self decodeObjectForKey:aKey]; if (object) - return CPSizeFromString(object); + return CGSizeFromString(object); else - return CPSizeMake(0.0, 0.0); + return CGSizeMakeZero(); } /* @@ -366,6 +372,7 @@ var CPArrayClass = Ni return nil; var objectClass = data.isa; + if (objectClass === CPDataClass) return data.bytes(); diff --git a/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj b/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj index 18ea9cb55..cdfdfecf2 100644 --- a/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj +++ b/Tools/XcodeCapp/XcodeCapp.xcodeproj/project.pbxproj @@ -24,6 +24,8 @@ 02998CEB1369BF7D006C73DB /* Growl Registration Ticket.growlRegDict in Resources */ = {isa = PBXBuildFile; fileRef = 02998CEA1369BF7D006C73DB /* Growl Registration Ticket.growlRegDict */; }; 02998CF71369C339006C73DB /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02998CF61369C339006C73DB /* Growl.framework */; }; 02998CF91369C38A006C73DB /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 02998CF61369C339006C73DB /* Growl.framework */; }; + 4E2D0D01154840B400475C01 /* help.rtfd in Resources */ = {isa = PBXBuildFile; fileRef = 4E2D0D00154840B400475C01 /* help.rtfd */; }; + 4E2D0D03154840BC00475C01 /* help.rtfd in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4E2D0D00154840B400475C01 /* help.rtfd */; }; 651DAE1F13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 651DAE1D13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.m */; }; /* End PBXBuildFile section */ @@ -35,6 +37,7 @@ dstSubfolderSpec = 10; files = ( 02998CF91369C38A006C73DB /* Growl.framework in CopyFiles */, + 4E2D0D03154840BC00475C01 /* help.rtfd in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -62,6 +65,7 @@ 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 4E2D0D00154840B400475C01 /* help.rtfd */ = {isa = PBXFileReference; lastKnownFileType = wrapper.rtfd; path = help.rtfd; sourceTree = ""; }; 651DAE1C13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.objj.h; path = PRHEmptyGrowlDelegate.h; sourceTree = ""; }; 651DAE1D13B0CAB900ECA3F0 /* PRHEmptyGrowlDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PRHEmptyGrowlDelegate.m; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -152,6 +156,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 4E2D0D00154840B400475C01 /* help.rtfd */, 022BCEA61468632000B72910 /* project.pbxproj.sample */, 027FE4B91462F64E00B1AB92 /* xcodecapp-icon-working.png */, 026F3B6413866E7D00EE5B83 /* xcodecapp-icon-active.png */, @@ -236,6 +241,7 @@ 027FE4BA1462F64E00B1AB92 /* xcodecapp-icon-working.png in Resources */, 0289AC9414668CAF003CD975 /* XcodeCapp.icns in Resources */, 022BCEA71468632000B72910 /* project.pbxproj.sample in Resources */, + 4E2D0D01154840B400475C01 /* help.rtfd in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Tools/capp_lint/README b/Tools/capp_lint/README index 47a2ca97a..976a5aeb8 100644 --- a/Tools/capp_lint/README +++ b/Tools/capp_lint/README @@ -5,3 +5,6 @@ http://cappuccino.org/contribute/coding-style.php To install capp_lint and its man page, execute install.sh in Terminal. You must have sudo access to run the install script. + +To run capp_lint automatically as a git pre-commit hook, copy "pre-commit" to +.git/hooks/ at the root level of a git repository. diff --git a/Tools/nib2cib/NSBox.j b/Tools/nib2cib/NSBox.j index 86e74b8c1..17ec6c6f1 100644 --- a/Tools/nib2cib/NSBox.j +++ b/Tools/nib2cib/NSBox.j @@ -36,13 +36,14 @@ _borderColor = [aCoder decodeObjectForKey:@"NSBorderColor2"] || [CPColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.42]; _fillColor = [aCoder decodeObjectForKey:@"NSFillColor2"] || [CPColor clearColor]; - _cornerRadius = [aCoder decodeFloatForKey:@"NSCornerRadius2"] || 0.0; + _cornerRadius = [aCoder decodeFloatForKey:@"NSCornerRadius2"]; _borderWidth = [aCoder decodeFloatForKey:@"NSBorderWidth2"] || 1.0; _contentMargin = [aCoder decodeSizeForKey:@"NSOffsets"]; _title = [[aCoder decodeObjectForKey:@"NSTitleCell"] objectValue] || @""; _titlePosition = [aCoder decodeObjectForKey:@"NSTitlePosition"]; + if (_titlePosition === undefined) _titlePosition = CPAtTop; } diff --git a/Tools/nib2cib/NSLevelIndicator.j b/Tools/nib2cib/NSLevelIndicator.j index 44245daec..8e936d566 100644 --- a/Tools/nib2cib/NSLevelIndicator.j +++ b/Tools/nib2cib/NSLevelIndicator.j @@ -102,17 +102,17 @@ { _objectValue = [aCoder decodeDoubleForKey:@"NSValue"]; - _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"] || 0; + _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"]; _maxValue = [aCoder decodeDoubleForKey:@"NSMaxValue"]; _warningValue = [aCoder decodeDoubleForKey:@"NSWarningValue"]; _criticalValue = [aCoder decodeDoubleForKey:@"NSCriticalValue"]; - _levelIndicatorStyle = [aCoder decodeIntForKey:@"NSIndicatorStyle"] || 0; + _levelIndicatorStyle = [aCoder decodeIntForKey:@"NSIndicatorStyle"]; // None of these are included in the XIB if the defaults are used. - _tickMarkPosition = [aCoder decodeIntForKey:@"NSTickMarkPosition"] || 0; - _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfTickMarks"] || 0; - _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfMajorTickMarks"] || 0; + _tickMarkPosition = [aCoder decodeIntForKey:@"NSTickMarkPosition"]; + _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfTickMarks"]; + _numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfMajorTickMarks"]; } return self; diff --git a/Tools/nib2cib/NSMenuItem.j b/Tools/nib2cib/NSMenuItem.j index 5ce252950..bc7b8b740 100644 --- a/Tools/nib2cib/NSMenuItem.j +++ b/Tools/nib2cib/NSMenuItem.j @@ -34,7 +34,7 @@ if (self) { - _isSeparator = [aCoder decodeObjectForKey:@"NSIsSeparator"] || NO; + _isSeparator = [aCoder decodeBoolForKey:@"NSIsSeparator"]; _title = [aCoder decodeObjectForKey:"NSTitle"]; @@ -109,4 +109,4 @@ { } -@end \ No newline at end of file +@end diff --git a/Tools/nib2cib/NSNibConnector.j b/Tools/nib2cib/NSNibConnector.j index 17f29e76b..e2bedde15 100644 --- a/Tools/nib2cib/NSNibConnector.j +++ b/Tools/nib2cib/NSNibConnector.j @@ -24,6 +24,7 @@ @import @import @import +@import NIB_CONNECTION_EQUIVALENCY_TABLE = {}; @@ -213,3 +214,35 @@ var NSTransformers = [CPSet setWithObjects: } @end + +@implementation CPCibHelpConnector (NSCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + self = [super NS_initWithCoder:aCoder]; + + if (self) + { + _destination = [aCoder decodeObjectForKey:@"NSDestination"]; + _file = [aCoder decodeObjectForKey:@"NSFile"]; + _marker = [aCoder decodeObjectForKey:@"NSMarker"]; + } + + return self; +} + +@end + +@implementation NSIBHelpConnector : CPCibHelpConnector + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPCibHelpConnector class]; +} + +@end diff --git a/Tools/nib2cib/NSProgressIndicator.j b/Tools/nib2cib/NSProgressIndicator.j index c3bc5505e..11d8bae12 100644 --- a/Tools/nib2cib/NSProgressIndicator.j +++ b/Tools/nib2cib/NSProgressIndicator.j @@ -34,7 +34,7 @@ var NSProgressIndicatorSpinningFlag = 1 << 12; { var NS_flags = [aCoder decodeIntForKey:@"NSpiFlags"]; - _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"] || 0; + _minValue = [aCoder decodeDoubleForKey:@"NSMinValue"]; _maxValue = [aCoder decodeDoubleForKey:@"NSMaxValue"]; _style = (NS_flags & NSProgressIndicatorSpinningFlag) ? CPProgressIndicatorSpinningStyle : CPProgressIndicatorBarStyle; diff --git a/Tools/nib2cib/NSSearchField.j b/Tools/nib2cib/NSSearchField.j index d002a7d4a..ce762cc80 100644 --- a/Tools/nib2cib/NSSearchField.j +++ b/Tools/nib2cib/NSSearchField.j @@ -84,10 +84,10 @@ { _recentsAutosaveName = [aCoder decodeObjectForKey:@"NSRecentsAutosaveName"]; _maximumRecents = [aCoder decodeIntForKey:@"NSMaximumRecents"]; - _sendsWholeSearchString = [aCoder decodeBoolForKey:@"NSSendsWholeSearchString"] ? YES : NO; + _sendsWholeSearchString = [aCoder decodeBoolForKey:@"NSSendsWholeSearchString"]; // These bytes don't seem to be used for anything else but the send immediately flag - _sendsSearchStringImmediately = [aCoder decodeBytesForKey:@"NSSearchFieldFlags"] ? YES: NO; + _sendsSearchStringImmediately = [aCoder decodeBytesForKey:@"NSSearchFieldFlags"] ? YES : NO; } return self; diff --git a/Tools/nib2cib/NSSegmentedControl.j b/Tools/nib2cib/NSSegmentedControl.j index fe00f5aaf..da94613d4 100644 --- a/Tools/nib2cib/NSSegmentedControl.j +++ b/Tools/nib2cib/NSSegmentedControl.j @@ -95,9 +95,13 @@ if (self = [super initWithCoder:aCoder]) { _segments = [aCoder decodeObjectForKey:"NSSegmentImages"]; - _selectedSegment = [aCoder decodeIntForKey:"NSSelectedSegment"] || -1; + _selectedSegment = [aCoder decodeObjectForKey:"NSSelectedSegment"]; + + if (_selectedSegment === nil) + _selectedSegment = -1; + _segmentStyle = [aCoder decodeIntForKey:"NSSegmentStyle"]; - _trackingMode = [aCoder decodeIntForKey:"NSTrackingMode"] || CPSegmentSwitchTrackingSelectOne; + _trackingMode = [aCoder decodeIntForKey:"NSTrackingMode"]; if (_trackingMode == CPSegmentSwitchTrackingSelectOne && _selectedSegment == -1) _selectedSegment = 0; diff --git a/Tools/nib2cib/NSSlider.j b/Tools/nib2cib/NSSlider.j index 8e80eb887..683c10be5 100644 --- a/Tools/nib2cib/NSSlider.j +++ b/Tools/nib2cib/NSSlider.j @@ -91,7 +91,7 @@ _altIncrementValue = [aCoder decodeDoubleForKey:@"NSAltIncValue"]; _isVertical = [aCoder decodeBoolForKey:@"NSVertical"]; - _sliderType = [aCoder decodeIntForKey:@"NSSliderType"] || 0; + _sliderType = [aCoder decodeIntForKey:@"NSSliderType"]; } return self; diff --git a/Tools/nib2cib/NSSplitView.j b/Tools/nib2cib/NSSplitView.j index 7d5bc5365..6079cbd7b 100644 --- a/Tools/nib2cib/NSSplitView.j +++ b/Tools/nib2cib/NSSplitView.j @@ -30,7 +30,7 @@ if (self = [super NS_initWithCoder:aCoder]) { _isVertical = [aCoder decodeBoolForKey:@"NSIsVertical"]; - _isPaneSplitter = [aCoder decodeIntForKey:@"NSDividerStyle"] == 3 ? YES : NO; + _isPaneSplitter = [aCoder decodeIntForKey:@"NSDividerStyle"] == 3; _autosaveName = [aCoder decodeObjectForKey:@"NSAutosaveName"]; } diff --git a/Tools/nib2cib/NSTableView.j b/Tools/nib2cib/NSTableView.j index acf653ce4..b54ebb1a8 100644 --- a/Tools/nib2cib/NSTableView.j +++ b/Tools/nib2cib/NSTableView.j @@ -69,7 +69,7 @@ _usesAlternatingRowBackgroundColors = (flags & 0x00800000) ? YES : NO; _alternatingRowBackgroundColors = [[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]]; - _selectionHighlightStyle = [aCoder decodeIntForKey:@"NSTableViewSelectionHighlightStyle"] || CPTableViewSelectionHighlightStyleRegular; + _selectionHighlightStyle = [aCoder decodeIntForKey:@"NSTableViewSelectionHighlightStyle"]; _columnAutoResizingStyle = [aCoder decodeIntForKey:@"NSColumnAutoresizingStyle"]; _allowsMultipleSelection = (flags & 0x08000000) ? YES : NO; diff --git a/Tools/nib2cib/NSTokenField.j b/Tools/nib2cib/NSTokenField.j index a03d898d8..b6216d48a 100644 --- a/Tools/nib2cib/NSTokenField.j +++ b/Tools/nib2cib/NSTokenField.j @@ -83,7 +83,7 @@ if (self) { - _tokenStyle = [aCoder decodeObjectForKey:@"NSTokenStyle"] || 0; + _tokenStyle = [aCoder decodeIntForKey:@"NSTokenStyle"]; } return self; diff --git a/Tools/nib2cib/NSToolbarItem.j b/Tools/nib2cib/NSToolbarItem.j index 33086e730..892425295 100644 --- a/Tools/nib2cib/NSToolbarItem.j +++ b/Tools/nib2cib/NSToolbarItem.j @@ -47,8 +47,8 @@ NS_CPToolbarItemIdentifierMap = _itemIdentifier = NS_CPToolbarItemIdentifierMap[NS_itemIdentifier] || NS_itemIdentifier; - _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"] || CGSizeMakeZero(); - _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"] || CGSizeMakeZero(); + _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"]; + _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"]; [self setLabel:[aCoder decodeObjectForKey:@"NSToolbarItemLabel"]]; [self setPaletteLabel:[aCoder decodeObjectForKey:@"NSToolbarItemPaletteLabel"]]; diff --git a/Tools/nib2cib/NSView.j b/Tools/nib2cib/NSView.j index 743068b30..d730f768e 100644 --- a/Tools/nib2cib/NSView.j +++ b/Tools/nib2cib/NSView.j @@ -45,10 +45,7 @@ var NSViewAutoresizingMask = 0x3F, if (self) { - _tag = 0; - - if ([aCoder containsValueForKey:@"NSTag"]) - _tag = [aCoder decodeIntForKey:@"NSTag"]; + _tag = [aCoder decodeIntForKey:@"NSTag"]; _bounds = CGRectMake(0.0, 0.0, CGRectGetWidth(_frame), CGRectGetHeight(_frame));