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
This commit is contained in:
Fred Kiefer 2007-12-15 12:34:39 +00:00
parent 295b663a75
commit f25c62f57b
3 changed files with 51 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2007-12-15 Fred Kiefer <FredKiefer@gmx.de>
* 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 <FredKiefer@gmx.de>
* Source/GSBindingHelpers.h,

View file

@ -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];
}
}
/**<p> Returns the cell Class used by NSControl. Used by subclasses.</p>
@ -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

View file

@ -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