* Source/NSControl.m (+initialize, -valueForKey:,

-setValue:forKey:): Add support for the bindings NSFontNameBinding
  and NSFontSizeBinding.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33834 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2011-09-12 21:04:53 +00:00
parent 507b4c76e8
commit c74c96ca81
2 changed files with 51 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2011-09-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSControl.m (+initialize, -valueForKey:,
-setValue:forKey:): Add support for the bindings NSFontNameBinding
and NSFontSizeBinding.
2011-09-09 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSImage.m (_cacheForRep:): Don't assume rep is non-nil. This should fix

View file

@ -32,13 +32,18 @@
#import <Foundation/NSDebug.h>
#import <Foundation/NSException.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSKeyValueObserving.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSValue.h>
#import "AppKit/NSActionCell.h"
#import "AppKit/NSApplication.h"
#import "AppKit/NSCell.h"
#import "AppKit/NSControl.h"
#import "AppKit/NSColor.h"
#import "AppKit/NSEvent.h"
#import "AppKit/NSFont.h"
#import "AppKit/NSFontManager.h"
#import "AppKit/NSKeyValueBinding.h"
#import "AppKit/NSTextStorage.h"
#import "AppKit/NSTextView.h"
@ -77,6 +82,12 @@ static NSNotificationCenter *nc;
[self exposeBinding: NSEnabledBinding];
[self exposeBinding: NSAlignmentBinding];
[self exposeBinding: NSFontBinding];
[self exposeBinding: NSFontNameBinding];
[self setKeys: [NSArray arrayWithObject: NSFontBinding]
triggerChangeNotificationsForDependentKey: NSFontNameBinding];
[self exposeBinding: NSFontSizeBinding];
[self setKeys: [NSArray arrayWithObject: NSFontBinding]
triggerChangeNotificationsForDependentKey: NSFontSizeBinding];
}
}
@ -1080,4 +1091,38 @@ static NSNotificationCenter *nc;
}
}
- (void) setValue: (id)anObject forKey: (NSString*)aKey
{
if ([aKey isEqual: NSFontNameBinding])
{
[self setFont: [[NSFontManager sharedFontManager] convertFont: [self font]
toFace: anObject]];
}
else if ([aKey isEqual: NSFontSizeBinding])
{
[self setFont: [[NSFontManager sharedFontManager] convertFont: [self font]
toSize: [anObject doubleValue]]];
}
else
{
[super setValue: anObject forKey: aKey];
}
}
- (id) valueForKey: (NSString*)aKey
{
if ([aKey isEqual: NSFontNameBinding])
{
return [[self font] fontName];
}
else if ([aKey isEqual: NSFontSizeBinding])
{
return [NSNumber numberWithDouble: (double)[[self font] pointSize]];
}
else
{
return [super valueForKey: aKey];
}
}
@end