mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 15:50:55 +00:00
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:
parent
81a8907f45
commit
a6ac9e24c7
4 changed files with 17 additions and 8 deletions
|
@ -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>
|
2009-11-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSImage.m (-copyWithZone:): Set the name of the copy to
|
* Source/NSImage.m (-copyWithZone:): Set the name of the copy to
|
||||||
|
|
|
@ -702,6 +702,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
|
|
||||||
|
|
||||||
// menu item cell drawing methods
|
// menu item cell drawing methods
|
||||||
|
- (NSImage *) arrowImageForMenuItemCell;
|
||||||
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
|
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
|
||||||
state: (GSThemeControlState)state;
|
state: (GSThemeControlState)state;
|
||||||
- (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell
|
- (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell
|
||||||
|
@ -710,6 +711,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
state: (GSThemeControlState)state
|
state: (GSThemeControlState)state
|
||||||
isHorizontal: (BOOL)isHorizontal;
|
isHorizontal: (BOOL)isHorizontal;
|
||||||
|
|
||||||
|
|
||||||
// NSColorWell drawing method
|
// NSColorWell drawing method
|
||||||
- (NSRect) drawColorWellBorder: (NSColorWell*)well
|
- (NSRect) drawColorWellBorder: (NSColorWell*)well
|
||||||
withBounds: (NSRect)bounds
|
withBounds: (NSRect)bounds
|
||||||
|
|
|
@ -682,6 +682,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSImage *) arrowImageForMenuItemCell
|
||||||
|
{
|
||||||
|
return [NSImage imageNamed: @"NSMenuArrow"];
|
||||||
|
}
|
||||||
|
|
||||||
// menu item cell drawing methods
|
// menu item cell drawing methods
|
||||||
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
|
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
|
||||||
state: (GSThemeControlState)state
|
state: (GSThemeControlState)state
|
||||||
|
|
|
@ -50,15 +50,11 @@
|
||||||
|
|
||||||
@implementation NSMenuItemCell
|
@implementation NSMenuItemCell
|
||||||
|
|
||||||
static NSImage *arrowImage = nil; /* Cache arrow image. */
|
|
||||||
|
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSMenuItemCell class])
|
if (self == [NSMenuItemCell class])
|
||||||
{
|
{
|
||||||
[self setVersion: 2];
|
[self setVersion: 2];
|
||||||
arrowImage = [[NSImage imageNamed: @"NSMenuArrow"] copy];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +294,7 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
|
||||||
// Submenu Arrow
|
// Submenu Arrow
|
||||||
if ([_menuItem hasSubmenu])
|
if ([_menuItem hasSubmenu])
|
||||||
{
|
{
|
||||||
componentSize = [arrowImage size];
|
componentSize = [[[GSTheme theme] arrowImageForMenuItemCell] size];
|
||||||
_keyEquivalentWidth = componentSize.width;
|
_keyEquivalentWidth = componentSize.width;
|
||||||
if (componentSize.height > neededMenuItemHeight)
|
if (componentSize.height > neededMenuItemHeight)
|
||||||
neededMenuItemHeight = componentSize.height;
|
neededMenuItemHeight = componentSize.height;
|
||||||
|
@ -661,12 +657,12 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
|
||||||
{
|
{
|
||||||
cellFrame = [self keyEquivalentRectForBounds: cellFrame];
|
cellFrame = [self keyEquivalentRectForBounds: cellFrame];
|
||||||
|
|
||||||
if ([_menuItem hasSubmenu] && arrowImage != nil)
|
if ([_menuItem hasSubmenu] && [[GSTheme theme] arrowImageForMenuItemCell] != nil)
|
||||||
{
|
{
|
||||||
NSSize size;
|
NSSize size;
|
||||||
NSPoint position;
|
NSPoint position;
|
||||||
|
|
||||||
size = [arrowImage size];
|
size = [[[GSTheme theme] arrowImageForMenuItemCell] size];
|
||||||
position.x = cellFrame.origin.x + cellFrame.size.width - size.width;
|
position.x = cellFrame.origin.x + cellFrame.size.width - size.width;
|
||||||
position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.);
|
position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.);
|
||||||
/*
|
/*
|
||||||
|
@ -676,7 +672,7 @@ static NSImage *arrowImage = nil; /* Cache arrow image. */
|
||||||
if ([controlView isFlipped])
|
if ([controlView isFlipped])
|
||||||
position.y += size.height;
|
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.
|
/* FIXME/TODO here - decide a consistent policy for images.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue