diff --git a/ChangeLog b/ChangeLog index 249885165..e4e909c5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-06-11 Fred Kiefer + + * Headers/AppKit/NSKeyValueBinding.h + * Source/NSPopUpButton.m + * Source/NSMatrix.m + * Source/NSLayoutManager.m + * Source/NSTextView.m + * Source/NSDocumentController.m + * Source/externs.m: Add a few key value bindings. + 2011-06-10 Fred Kiefer * Source/NSBitmapImageRep+ICNS.m: Remove comment about libicns diff --git a/Headers/AppKit/NSKeyValueBinding.h b/Headers/AppKit/NSKeyValueBinding.h index f519d9a83..88245c6bc 100644 --- a/Headers/AppKit/NSKeyValueBinding.h +++ b/Headers/AppKit/NSKeyValueBinding.h @@ -111,6 +111,7 @@ APPKIT_EXPORT NSString *NSFontNameBinding; APPKIT_EXPORT NSString *NSFontSizeBinding; APPKIT_EXPORT NSString *NSHiddenBinding; APPKIT_EXPORT NSString *NSSelectedIndexBinding; +APPKIT_EXPORT NSString *NSSelectedObjectBinding; APPKIT_EXPORT NSString *NSSelectedTagBinding; APPKIT_EXPORT NSString *NSTextColorBinding; APPKIT_EXPORT NSString *NSTitleBinding; diff --git a/Source/NSDocumentController.m b/Source/NSDocumentController.m index 24d711f55..3e03b7cb2 100644 --- a/Source/NSDocumentController.m +++ b/Source/NSDocumentController.m @@ -41,6 +41,7 @@ #import "AppKit/NSDocumentController.h" #import "AppKit/NSOpenPanel.h" #import "AppKit/NSApplication.h" +#import "AppKit/NSKeyValueBinding.h" #import "AppKit/NSMenu.h" #import "AppKit/NSMenuItem.h" #import "AppKit/NSWorkspace.h" @@ -246,6 +247,8 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName) allTypes = [[NSArray alloc] initWithObjects: valid count: nValid]; } } + + [self exposeBinding: @"autosavingDelay"]; } } diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index 114f90bee..f64128ae7 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -109,8 +109,10 @@ first. Remaining cases, highest priority first: #import #import #import "AppKit/NSAttributedString.h" +#import "AppKit/NSBezierPath.h" #import "AppKit/NSColor.h" #import "AppKit/NSImage.h" +#import "AppKit/NSKeyValueBinding.h" #import "AppKit/NSLayoutManager.h" #import "AppKit/NSParagraphStyle.h" #import "AppKit/NSRulerMarker.h" @@ -118,7 +120,6 @@ first. Remaining cases, highest priority first: #import "AppKit/NSTextStorage.h" #import "AppKit/NSWindow.h" #import "AppKit/DPSOperators.h" -#import "AppKit/NSBezierPath.h" #import "GNUstepGUI/GSLayoutManager_internal.h" @@ -2058,6 +2059,17 @@ static void GSDrawPatternLine(NSPoint start, NSPoint end, NSInteger pattern, CGF @implementation NSLayoutManager +/* + * Class methods + */ ++ (void) initialize +{ + if (self == [NSLayoutManager class]) + { + [self exposeBinding: @"hyphenationFactor"]; + } +} + -(void) insertTextContainer: (NSTextContainer *)aTextContainer atIndex: (unsigned int)index { diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 04ffc97d1..3ff9a336e 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -59,6 +59,8 @@ #import #import #import +#import +#import #import #import #import @@ -71,6 +73,7 @@ #import "AppKit/NSCursor.h" #import "AppKit/NSEvent.h" #import "AppKit/NSGraphics.h" +#import "AppKit/NSKeyValueBinding.h" #import "AppKit/NSMatrix.h" #import "AppKit/NSWindow.h" @@ -219,6 +222,8 @@ static SEL getSel; defaultCellClass = [NSActionCell class]; // nc = [NSNotificationCenter defaultCenter]; + + [self exposeBinding: NSSelectedTagBinding]; } } @@ -1191,6 +1196,7 @@ static SEL getSel; - (void) _selectCell: (NSCell *)aCell atRow: (int)row column: (int)column { + [self willChangeValueForKey: NSSelectedTagBinding]; if (aCell) { NSRect cellFrame; @@ -1236,6 +1242,7 @@ static SEL getSel; _selectedCell = nil; _selectedRow = _selectedColumn = -1; } + [self didChangeValueForKey: NSSelectedTagBinding]; } - (void) selectCell: (NSCell *)aCell @@ -3885,6 +3892,30 @@ static SEL getSel; } } +- (void) setValue: (id)anObject forKey: (NSString*)aKey +{ + if ([aKey isEqual: NSSelectedTagBinding]) + { + [self selectCellWithTag: [anObject integerValue]]; + } + else + { + [super setValue: anObject forKey: aKey]; + } +} + +- (id) valueForKey: (NSString*)aKey +{ + if ([aKey isEqual: NSSelectedTagBinding]) + { + return [NSNumber numberWithInteger: [self selectedTag]]; + } + else + { + return [super valueForKey: aKey]; + } +} + @end diff --git a/Source/NSPopUpButton.m b/Source/NSPopUpButton.m index 2bf48eddf..7479ac44d 100644 --- a/Source/NSPopUpButton.m +++ b/Source/NSPopUpButton.m @@ -65,6 +65,9 @@ Class _nspopupbuttonCellClass = 0; [self setCellClass: [NSPopUpButtonCell class]]; [self exposeBinding: NSSelectedIndexBinding]; + [self exposeBinding: NSSelectedObjectBinding]; + [self setKeys: [NSArray arrayWithObject: NSSelectedIndexBinding] + triggerChangeNotificationsForDependentKey: NSSelectedObjectBinding]; [self exposeBinding: NSSelectedTagBinding]; [self setKeys: [NSArray arrayWithObject: NSSelectedIndexBinding] triggerChangeNotificationsForDependentKey: NSSelectedTagBinding]; @@ -575,6 +578,10 @@ this to return nil to indicate that we have no context menu. { [self selectItemWithTag: [anObject integerValue]]; } + else if ([aKey isEqual: NSSelectedObjectBinding]) + { + [self selectItemWithTag: [anObject intValue]]; + } else { [super setValue: anObject forKey: aKey]; @@ -591,6 +598,10 @@ this to return nil to indicate that we have no context menu. { return [NSNumber numberWithInteger: [self selectedTag]]; } + else if ([aKey isEqual: NSSelectedObjectBinding]) + { + return [NSNumber numberWithInt: [self selectedTag]]; + } else { return [super valueForKey: aKey]; diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 2bceebe09..a851ea25b 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -73,6 +73,7 @@ #import "AppKit/NSFileWrapper.h" #import "AppKit/NSGraphics.h" #import "AppKit/NSImage.h" +#import "AppKit/NSKeyValueBinding.h" #import "AppKit/NSLayoutManager.h" #import "AppKit/NSMenu.h" #import "AppKit/NSMenuItem.h" @@ -599,6 +600,8 @@ static NSMenu *textViewMenu; [NSCharacterSet punctuationCharacterSet]]; smartRightChars = [temp copy]; [temp release]; + + [self exposeBinding: NSEditableBinding]; } } diff --git a/Source/externs.m b/Source/externs.m index 8691e1f81..33ed0176d 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -668,6 +668,7 @@ NSString *NSFontNameBinding = @"fontName"; NSString *NSFontSizeBinding = @"fontSize"; NSString *NSHiddenBinding = @"hidden"; NSString *NSSelectedIndexBinding = @"selectedIndex"; +NSString *NSSelectedObjectBinding = @"selectedObject"; NSString *NSSelectedTagBinding = @"selectedTag"; NSString *NSTextColorBinding = @"textColor"; NSString *NSTitleBinding = @"title";