make the arrow image in NSMenuItemCell themeable

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29001 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Hans Baier 2009-11-14 02:56:29 +00:00
parent 1bb1dec3a8
commit be3a29fd05
4 changed files with 17 additions and 8 deletions

View file

@ -1,3 +1,9 @@
2009-11-14 Hans Baier <hansfbaier@googlemail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h,
* Source/GSThemeDrawing.m,
* Source/NSMenuItemCell.m: Make the menu arrow image themeable
2009-11-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSImage.m (-copyWithZone:): Set the name of the copy to

View file

@ -702,6 +702,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
// menu item cell drawing methods
- (NSImage *) arrowImageForMenuItemCell;
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
state: (GSThemeControlState)state;
- (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell
@ -710,6 +711,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
state: (GSThemeControlState)state
isHorizontal: (BOOL)isHorizontal;
// NSColorWell drawing method
- (NSRect) drawColorWellBorder: (NSColorWell*)well
withBounds: (NSRect)bounds

View file

@ -682,6 +682,11 @@
}
}
- (NSImage *) arrowImageForMenuItemCell
{
return [NSImage imageNamed: @"NSMenuArrow"];
}
// menu item cell drawing methods
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
state: (GSThemeControlState)state

View file

@ -50,15 +50,11 @@
@implementation NSMenuItemCell
static NSImage *arrowImage = nil; /* Cache arrow image. */
+ (void) initialize
{
if (self == [NSMenuItemCell class])
{
[self setVersion: 2];
arrowImage = [[NSImage imageNamed: @"NSMenuArrow"] copy];
}
}
@ -298,7 +294,7 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
// Submenu Arrow
if ([_menuItem hasSubmenu])
{
componentSize = [arrowImage size];
componentSize = [[[GSTheme theme] arrowImageForMenuItemCell] size];
_keyEquivalentWidth = componentSize.width;
if (componentSize.height > neededMenuItemHeight)
neededMenuItemHeight = componentSize.height;
@ -661,12 +657,12 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
{
cellFrame = [self keyEquivalentRectForBounds: cellFrame];
if ([_menuItem hasSubmenu] && arrowImage != nil)
if ([_menuItem hasSubmenu] && [[GSTheme theme] arrowImageForMenuItemCell] != nil)
{
NSSize size;
NSPoint position;
size = [arrowImage size];
size = [[[GSTheme theme] arrowImageForMenuItemCell] size];
position.x = cellFrame.origin.x + cellFrame.size.width - size.width;
position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.);
/*
@ -676,7 +672,7 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
if ([controlView isFlipped])
position.y += size.height;
[arrowImage compositeToPoint: position operation: NSCompositeSourceOver];
[[[GSTheme theme] arrowImageForMenuItemCell] compositeToPoint: position operation: NSCompositeSourceOver];
}
/* FIXME/TODO here - decide a consistent policy for images.
*