From 0b14647109bd42dba76abc6669e3cb20661f6c0c Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Sat, 15 Dec 2007 12:34:39 +0000 Subject: [PATCH] Add some more KVB and move some. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25746 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSControl.m | 44 +++++++++++++++++++++++++++++++++++++++++++- Source/NSTextField.m | 14 +------------- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe7d49984..7286a2608 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-12-15 Fred Kiefer + + * Source/NSTextField.m: Move some KVB to NSControl, add binding + for text colour. + * Source/NSControl.m: Add some bindings from NSTextField plus + NSValueBinding. + 2007-12-13 Fred Kiefer * Source/GSBindingHelpers.h, diff --git a/Source/NSControl.m b/Source/NSControl.m index 0eb65758b..70995a855 100644 --- a/Source/NSControl.m +++ b/Source/NSControl.m @@ -39,9 +39,11 @@ #include "AppKit/NSControl.h" #include "AppKit/NSColor.h" #include "AppKit/NSEvent.h" +#include "AppKit/NSKeyValueBinding.h" #include "AppKit/NSTextStorage.h" #include "AppKit/NSTextView.h" #include "AppKit/NSWindow.h" +#include "GSBindingHelpers.h" /* * Class variables @@ -69,7 +71,13 @@ static NSNotificationCenter *nc; actionCellClass = [NSActionCell class]; // Cache the notifiaction centre for editing notifications nc = [NSNotificationCenter defaultCenter]; - } + + // expose bindings + [self exposeBinding: NSValueBinding]; + [self exposeBinding: NSEnabledBinding]; + [self exposeBinding: NSAlignmentBinding]; + [self exposeBinding: NSFontBinding]; + } } /**

Returns the cell Class used by NSControl. Used by subclasses.

@@ -959,4 +967,38 @@ static NSNotificationCenter *nc; return self; } +- (void) bind: (NSString *)binding + toObject: (id)anObject + withKeyPath: (NSString *)keyPath + options: (NSDictionary *)options +{ + if ([binding isEqual: NSValueBinding]) + { + [self unbind: binding]; + [[GSKeyValueOrBinding alloc] initWithBinding: @"objectValue" + withName: NSValueBinding + toObject: anObject + withKeyPath: keyPath + options: options + fromObject: self]; + } + else if ([binding hasPrefix: NSEnabledBinding]) + { + [self unbind: binding]; + [[GSKeyValueAndBinding alloc] initWithBinding: NSEnabledBinding + withName: binding + toObject: anObject + withKeyPath: keyPath + options: options + fromObject: self]; + } + else + { + [super bind: binding + toObject: anObject + withKeyPath: keyPath + options: options]; + } +} + @end diff --git a/Source/NSTextField.m b/Source/NSTextField.m index ee928ce26..391d86baf 100644 --- a/Source/NSTextField.m +++ b/Source/NSTextField.m @@ -68,9 +68,7 @@ static Class textFieldCellClass; nc = [NSNotificationCenter defaultCenter]; [self exposeBinding: NSEditableBinding]; - [self exposeBinding: NSEnabledBinding]; - [self exposeBinding: NSAlignmentBinding]; - [self exposeBinding: NSFontBinding]; + [self exposeBinding: NSTextColorBinding]; } } @@ -766,16 +764,6 @@ static Class textFieldCellClass; options: options fromObject: self]; } - else if ([binding hasPrefix: NSEnabledBinding]) - { - [self unbind: binding]; - [[GSKeyValueAndBinding alloc] initWithBinding: NSEnabledBinding - withName: binding - toObject: anObject - withKeyPath: keyPath - options: options - fromObject: self]; - } else { [super bind: binding