From 0a96cb8eb3cc4aa9804674332c51ecada3511674 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Thu, 6 May 2010 17:36:11 +0200 Subject: [PATCH 01/13] call willChange* and didChange* methods on the actual classes --- Foundation/CPKeyValueObserving.j | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index b88f766a0..39f29779d 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -480,6 +480,11 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld, - (void)willChangeValueForKey:(CPString)aKey { + var superClass = [self class], + methodSelector = @selector(willChangeValueForKey:), + methodImp = class_getMethodImplementation(superClass, methodSelector); + methodImp(self, methodSelector, aKey); + if (!aKey) return; @@ -490,6 +495,11 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld, - (void)didChangeValueForKey:(CPString)aKey { + var superClass = [self class], + methodSelector = @selector(didChangeValueForKey:), + methodImp = class_getMethodImplementation(superClass, methodSelector); + methodImp(self, methodSelector, aKey); + if (!aKey) return; @@ -498,6 +508,11 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld, - (void)willChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey { + var superClass = [self class], + methodSelector = @selector(willChange:valuesAtIndexes:forKey:), + methodImp = class_getMethodImplementation(superClass, methodSelector); + methodImp(self, methodSelector, change, indexes, aKey); + if (!aKey) return; @@ -508,6 +523,11 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld, - (void)didChange:(CPKeyValueChange)change valuesAtIndexes:(CPIndexSet)indexes forKey:(CPString)aKey { + var superClass = [self class], + methodSelector = @selector(didChange:valuesAtIndexes:forKey:), + methodImp = class_getMethodImplementation(superClass, methodSelector); + methodImp(self, methodSelector, change, indexes, aKey); + if (!aKey) return; From db568af302ac3a9085a439cf165c2ffd083283ef Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Mon, 17 May 2010 12:32:56 +0200 Subject: [PATCH 02/13] made sure CPViewController calls viewDidLoad if it's view property is set directly --- AppKit/CPViewController.j | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AppKit/CPViewController.j b/AppKit/CPViewController.j index 3fffe261d..ab8c3a22e 100644 --- a/AppKit/CPViewController.j +++ b/AppKit/CPViewController.j @@ -162,8 +162,6 @@ var CPViewControllerCachedCibs; if ([cibOwner respondsToSelector:@selector(viewControllerDidLoadCib:)]) [cibOwner viewControllerDidLoadCib:self]; - - [self viewDidLoad]; } return _view; @@ -189,7 +187,13 @@ var CPViewControllerCachedCibs; */ - (void)setView:(CPView)aView { + var viewWasLoaded = !_view; + _view = aView; + + // Make sure the viewDidLoad method is called if the view is set directly + if (viewWasLoaded) + [self viewDidLoad]; } @end From 322d8c67b3d675ff4526cd007516a9ad111d973e Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 19 May 2010 18:31:21 +0200 Subject: [PATCH 03/13] Fixed NSTableColumn user resizable nib2cib --- Tools/nib2cib/NSTableColumn.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/nib2cib/NSTableColumn.j b/Tools/nib2cib/NSTableColumn.j index 735ed5fc5..635889344 100644 --- a/Tools/nib2cib/NSTableColumn.j +++ b/Tools/nib2cib/NSTableColumn.j @@ -51,9 +51,9 @@ _minWidth = [aCoder decodeFloatForKey:@"NSMinWidth"]; _maxWidth = [aCoder decodeFloatForKey:@"NSMaxWidth"]; - _resizingMask = [aCoder decodeBoolForKey:@"NSIsResizable"]; + _resizingMask = [aCoder decodeBoolForKey:@"NSIsResizeable"] ? CPTableColumnUserResizingMask : CPTableColumnAutoresizingMask; } - + return self; } From 76df9be4fbbe2a88c374c6143a579a5258ec1aef Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 19 May 2010 18:51:18 +0200 Subject: [PATCH 04/13] implemented CPTableColumn isHidden nib2cib support --- AppKit/CPTableColumn.j | 5 ++++- Tools/nib2cib/NSTableColumn.j | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index 5c6b91cea..2d4e5af03 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -395,7 +395,8 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey", CPTableColumnWidthKey = @"CPTableColumnWidthKey", CPTableColumnMinWidthKey = @"CPTableColumnMinWidthKey", CPTableColumnMaxWidthKey = @"CPTableColumnMaxWidthKey", - CPTableColumnResizingMaskKey = @"CPTableColumnResizingMaskKey"; + CPTableColumnResizingMaskKey = @"CPTableColumnResizingMaskKey", + CPTableColumnIsHiddenkey = @"CPTableColumnIsHiddenKey"; @implementation CPTableColumn (CPCoding) @@ -417,6 +418,7 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey", [self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]]; _resizingMask = [aCoder decodeBoolForKey:CPTableColumnResizingMaskKey]; + _isHidden = [aCoder decodeBoolForKey:CPTableColumnIsHiddenkey]; } return self; @@ -434,6 +436,7 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey", [aCoder encodeObject:_dataView forKey:CPTableColumnDataViewKey]; [aCoder encodeObject:_resizingMask forKey:CPTableColumnResizingMaskKey]; + [aCoder encodeBool:_isHidden forKey:CPTableColumnIsHiddenkey]; } @end diff --git a/Tools/nib2cib/NSTableColumn.j b/Tools/nib2cib/NSTableColumn.j index 635889344..bcbea7422 100644 --- a/Tools/nib2cib/NSTableColumn.j +++ b/Tools/nib2cib/NSTableColumn.j @@ -52,6 +52,7 @@ _maxWidth = [aCoder decodeFloatForKey:@"NSMaxWidth"]; _resizingMask = [aCoder decodeBoolForKey:@"NSIsResizeable"] ? CPTableColumnUserResizingMask : CPTableColumnAutoresizingMask; + _isHidden = [aCoder decodeBoolForKey:@"NSHidden"]; } return self; From 6a33acbb7c7bf92e566e5d42ff3cbf9dbbf4b8a9 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Thu, 20 May 2010 11:39:47 +0200 Subject: [PATCH 05/13] implemented CPCoding support for CPSortDescriptor and made CPTableColumn decode it's _sortDescriptorPrototype --- AppKit/CPTableColumn.j | 7 ++++++- Foundation/CPSortDescriptor.j | 28 +++++++++++++++++++++++++ Tools/nib2cib/NSAppKit.j | 1 + Tools/nib2cib/NSSortDescriptor.j | 35 ++++++++++++++++++++++++++++++++ Tools/nib2cib/NSTableColumn.j | 2 ++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 Tools/nib2cib/NSSortDescriptor.j diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index e8b6f1c5e..14f239484 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -396,7 +396,8 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey", CPTableColumnMinWidthKey = @"CPTableColumnMinWidthKey", CPTableColumnMaxWidthKey = @"CPTableColumnMaxWidthKey", CPTableColumnResizingMaskKey = @"CPTableColumnResizingMaskKey", - CPTableColumnIsHiddenkey = @"CPTableColumnIsHiddenKey"; + CPTableColumnIsHiddenkey = @"CPTableColumnIsHiddenKey", + CPSortDescriptorPrototypeKey = @"CPSortDescriptorPrototypeKey"; @implementation CPTableColumn (CPCoding) @@ -419,6 +420,8 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey", _resizingMask = [aCoder decodeBoolForKey:CPTableColumnResizingMaskKey]; _isHidden = [aCoder decodeBoolForKey:CPTableColumnIsHiddenkey]; + + _sortDescriptorPrototype = [aCoder decodeObjectForKey:CPSortDescriptorPrototypeKey]; } return self; @@ -437,6 +440,8 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey", [aCoder encodeObject:_resizingMask forKey:CPTableColumnResizingMaskKey]; [aCoder encodeBool:_isHidden forKey:CPTableColumnIsHiddenkey]; + + [aCoder encodeObject:_sortDescriptorPrototype forKey:CPSortDescriptorPrototypeKey]; } @end diff --git a/Foundation/CPSortDescriptor.j b/Foundation/CPSortDescriptor.j index c7b78c840..c7d29f16a 100755 --- a/Foundation/CPSortDescriptor.j +++ b/Foundation/CPSortDescriptor.j @@ -149,3 +149,31 @@ CPOrderedDescending = 1; } @end + +var CPSortDescriptorKeyKey = @"CPSortDescriptorKeyKey", // Don't you just love naming schemes ;) + CPSortDescriptorAscendingKey = @"CPSortDescriptorAscendingKey", + CPSortDescriptorSelectorKey = @"CPSortDescriptorSelectorKey"; + +@implementation CPSortDescriptor (CPCoding) + +- (id)initWithCoder:(CPCoder)aCoder +{ + if (self = [super init]) + { + _key = [aCoder decodeObjectForKey:CPSortDescriptorKeyKey]; + _ascending = [aCoder decodeBoolForKey:CPSortDescriptorAscendingKey]; + _selector = CPSelectorFromString([aCoder decodeObjectForKey:CPSortDescriptorSelectorKey]); + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [aCoder encodeObject:_key forKey:CPSortDescriptorKeyKey]; + [aCoder encodeBool:_ascending forKey:CPSortDescriptorAscendingKey]; + [aCoder encodeObject:CPStringFromSelector(_selector) forKey:CPSortDescriptorSelectorKey]; +} + +@end + diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index 8a54fb2d1..96a3a52b8 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -67,6 +67,7 @@ @import "NSViewController.j" @import "NSWindowTemplate.j" @import "WebView.j" +@import "NSSortDescriptor.j" function CP_NSMapClassName(aClassName) diff --git a/Tools/nib2cib/NSSortDescriptor.j b/Tools/nib2cib/NSSortDescriptor.j new file mode 100644 index 000000000..c4f0beb87 --- /dev/null +++ b/Tools/nib2cib/NSSortDescriptor.j @@ -0,0 +1,35 @@ +@import + +@implementation CPSortDescriptor (NSCoding) +{ +} + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + if (self = [super init]) + { + _key = [aCoder decodeObjectForKey:@"NSKey"]; + _selector = CPSelectorFromString([aCoder decodeObjectForKey:@"NSSelector"]); + _ascending = [aCoder decodeBoolForKey:@"NSAscending"]; + } + + return self; +} + +@end + +@implementation NSSortDescriptor : CPSortDescriptor +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPSortDescriptor class]; +} + +@end \ No newline at end of file diff --git a/Tools/nib2cib/NSTableColumn.j b/Tools/nib2cib/NSTableColumn.j index bcbea7422..bdafee212 100644 --- a/Tools/nib2cib/NSTableColumn.j +++ b/Tools/nib2cib/NSTableColumn.j @@ -53,6 +53,8 @@ _resizingMask = [aCoder decodeBoolForKey:@"NSIsResizeable"] ? CPTableColumnUserResizingMask : CPTableColumnAutoresizingMask; _isHidden = [aCoder decodeBoolForKey:@"NSHidden"]; + + _sortDescriptorPrototype = [aCoder decodeObjectForKey:@"NSSortDescriptorPrototype"]; } return self; From f7dd6e4387ca7bc770445a752c9822c9d0004f8b Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Thu, 20 May 2010 18:52:43 +0200 Subject: [PATCH 06/13] fixed a typo where CPThemeStateSelectedDataView was set on the header view of a table column --- AppKit/CPTableView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 2ef0dde9b..aad636598 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -1837,7 +1837,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; if (_headerView) { if (_currentHighlightedTableColumn != nil) - [[_currentHighlightedTableColumn headerView] unsetThemeState:CPThemeStateSelectedDataView]; + [[_currentHighlightedTableColumn headerView] unsetThemeState:CPThemeStateSelected]; if (aTableColumn != nil) [[aTableColumn headerView] setThemeState:CPThemeStateSelected]; From 528203d8e51dd029a84a9407dc827e49997ce522 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Tue, 25 May 2010 20:37:00 +0200 Subject: [PATCH 07/13] made CPDictionary call [super valueForKey:] on keys prefixed with @ --- Foundation/CPKeyValueCoding.j | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Foundation/CPKeyValueCoding.j b/Foundation/CPKeyValueCoding.j index 36ef5b48c..6543d04b6 100644 --- a/Foundation/CPKeyValueCoding.j +++ b/Foundation/CPKeyValueCoding.j @@ -267,7 +267,10 @@ CPUnknownUserInfoKey = @"CPUnknownUserInfoKey"; - (id)valueForKey:(CPString)aKey { - return [self objectForKey:aKey]; + if ([aKey hasPrefix:@"@"]) + return [super valueForKey:aKey.substr(1)]; + + return [self objectForKey:aKey]; } - (void)setValue:(id)aValue forKey:(CPString)aKey From 468d8e7c33ed453aa3379898a7081f5bdc4d550a Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Mon, 31 May 2010 13:45:51 +0200 Subject: [PATCH 08/13] call windowWillLoad and windowDidLoad if the window is set directly from the initializer --- AppKit/CPWindowController.j | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index aebbc5e89..a123238ab 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -72,11 +72,17 @@ if (self) { + if (aWindow) + [self windowWillLoad]; + [self setWindow:aWindow]; [self setShouldCloseDocument:NO]; [self setNextResponder:CPApp]; + if (aWindow) + [self windowDidLoad]; + _documents = []; } From 43f0e43de7e8fbec69fb59dac6c7d2496ed70ae1 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Mon, 31 May 2010 15:41:52 +0200 Subject: [PATCH 09/13] call tableview doubleclick action even if target is nil (action will travel down the responder chain) --- AppKit/CPTableView.j | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 8dd282e4e..1b866b17f 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2709,7 +2709,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; } //end of editing conditional //double click actions - if([[CPApp currentEvent] clickCount] === 2 && _doubleAction && _target) + if([[CPApp currentEvent] clickCount] === 2 && _doubleAction) + { + _clickedRow = [self rowAtPoint:aPoint]; [self sendAction:_doubleAction to:_target]; } From 83ea50a8360c357893a8adb26efbc152172e60f3 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 30 Jun 2010 11:41:22 +0200 Subject: [PATCH 10/13] don't send windowWillLoad and windowDidLoad if the window is not loaded from cib --- AppKit/CPWindowController.j | 6 ------ 1 file changed, 6 deletions(-) diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index c5496a7e5..2d011af98 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -72,17 +72,11 @@ if (self) { - if (aWindow) - [self windowWillLoad]; - [self setWindow:aWindow]; [self setShouldCloseDocument:NO]; [self setNextResponder:CPApp]; - if (aWindow) - [self windowDidLoad]; - _documents = []; } From af0ca527399825a133895d7e46eb83fa53d65c5c Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 30 Jun 2010 11:50:53 +0200 Subject: [PATCH 11/13] made CPViewController equal cappuccino master --- AppKit/CPViewController.j | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/AppKit/CPViewController.j b/AppKit/CPViewController.j index ab8c3a22e..3fffe261d 100644 --- a/AppKit/CPViewController.j +++ b/AppKit/CPViewController.j @@ -162,6 +162,8 @@ var CPViewControllerCachedCibs; if ([cibOwner respondsToSelector:@selector(viewControllerDidLoadCib:)]) [cibOwner viewControllerDidLoadCib:self]; + + [self viewDidLoad]; } return _view; @@ -187,13 +189,7 @@ var CPViewControllerCachedCibs; */ - (void)setView:(CPView)aView { - var viewWasLoaded = !_view; - _view = aView; - - // Make sure the viewDidLoad method is called if the view is set directly - if (viewWasLoaded) - [self viewDidLoad]; } @end From 71408e7c3a48657c14b243a3903fd1905a59201d Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Thu, 15 Apr 2010 11:15:21 +0200 Subject: [PATCH 12/13] made CPObjectController call it's designated initializer (init) --- AppKit/CPObjectController.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index f070d33bf..5bc7a6988 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -53,7 +53,7 @@ - (id)initWithContent:(id)aContent { - self = [super init]; + self = [self init]; if (self) { From 60dd1863b37f30df0861ffa50ef736bb373c0c98 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Fri, 16 Apr 2010 13:56:16 +0200 Subject: [PATCH 13/13] Implement objectsAtIndexes on _CPObservableArray to return another _CPObservableArray instance --- AppKit/CPObjectController.j | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index 5bc7a6988..838f15c84 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -455,6 +455,11 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb [super removeObjectAtIndex:anIndex]; } +- (_CPObservableArray)objectsAtIndexes:(CPIndexSet)theIndexes +{ + return [_CPObservableArray arrayWithArray:[super objectsAtIndexes:theIndexes]]; +} + - (void)addObject:(id)anObject { [self insertObject:anObject atIndex:[self count]];