* 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
This commit is contained in:
gcasa 2012-10-16 21:23:48 +00:00
parent 235abf3330
commit 38f4d601ef
4 changed files with 34 additions and 14 deletions

View file

@ -1,3 +1,11 @@
2012-10-16 17:22-EDT Gregory John Casamento <greg.casamento@gmail.com>
* 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 <greg.casamento@gmail.com>
* Source/NSButtonCell.m: Implementation for change request

View file

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

View file

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

View file

@ -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];
}
}
/** <p>Sets the modifier mask of the NSButtonCell's key equivalent to