From f248bc9988a835cecf67944dded7dfce90947ff4 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 16 Oct 2012 21:23:48 +0000 Subject: [PATCH] * Headers/Additions/GNUstepGUI/GSTheme.h: Add declaration for method setKeyEquivalent:forButtonCell: * Source/GSThemeDrawing.m: Add implementation for method setKeyEquivalent:forButtonCell: * Source/NSButtonCell.m: Add call to new method. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35702 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Headers/Additions/GNUstepGUI/GSTheme.h | 7 +++++++ Source/GSThemeDrawing.m | 17 +++++++++++++++++ Source/NSButtonCell.m | 16 ++-------------- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7375ee9a7..7e779ee80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-10-16 17:22-EDT Gregory John Casamento + + * Headers/Additions/GNUstepGUI/GSTheme.h: Add declaration + for method setKeyEquivalent:forButtonCell: + * Source/GSThemeDrawing.m: Add implementation for method + setKeyEquivalent:forButtonCell: + * Source/NSButtonCell.m: Add call to new method. + 2012-10-15 18:02-EDT Gregory John Casamento * Source/NSButtonCell.m: Implementation for change request diff --git a/Headers/Additions/GNUstepGUI/GSTheme.h b/Headers/Additions/GNUstepGUI/GSTheme.h index 02234ba73..ac68850b0 100644 --- a/Headers/Additions/GNUstepGUI/GSTheme.h +++ b/Headers/Additions/GNUstepGUI/GSTheme.h @@ -730,6 +730,13 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification; */ @interface GSTheme (Drawing) +/** + * Allows the theme to set an image or set attributes for drawing the + * button differently based on the key equivalent which is set. + */ +- (void) setKeyEquivalent: (NSString *)key + forButtonCell: (NSButtonCell *)cell; + /** * Draws a button frame and background (not its content) for the specified * cell and view. diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index c25bec074..bd6f16bb4 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -77,6 +77,23 @@ @end @implementation GSTheme (Drawing) +- (void) setKeyEquivalent: (NSString *)key + forButtonCell: (NSButtonCell *)cell +{ + if([cell image] == nil && ([key isEqualToString:@"\r"] || + [key isEqualToString:@"\n"])) + { + [cell setImagePosition: NSImageRight]; + [cell setImage: [NSImage imageNamed:@"common_ret"]]; + [cell setAlternateImage: [NSImage imageNamed:@"common_retH"]]; + } + else if([key isEqualToString:@"\r"] == NO && + [key isEqualToString:@"\n"] == NO) + { + [cell setImage: nil]; + [cell setAlternateImage: nil]; + } +} - (void) drawButton: (NSRect)frame in: (NSCell*)cell diff --git a/Source/NSButtonCell.m b/Source/NSButtonCell.m index a1adffb1c..4f44d15a5 100644 --- a/Source/NSButtonCell.m +++ b/Source/NSButtonCell.m @@ -629,21 +629,9 @@ typedef struct _GSButtonCellFlags */ - (void) setKeyEquivalent: (NSString*)key { + [[GSTheme theme] setKeyEquivalent: key + forButtonCell: self]; ASSIGNCOPY(_keyEquivalent, key); - - if([self image] == nil && ([_keyEquivalent isEqualToString:@"\r"] || - [_keyEquivalent isEqualToString:@"\n"])) - { - [self setImagePosition: NSImageRight]; - [self setImage: [NSImage imageNamed:@"common_ret"]]; - [self setAlternateImage: [NSImage imageNamed:@"common_retH"]]; - } - else - { - [self setImagePosition: NSNoImage]; - [self setImage: nil]; - [self setAlternateImage: nil]; - } } /**

Sets the modifier mask of the NSButtonCell's key equivalent to