mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:31:56 +00:00
Made separator menu item themable, by moving the drawing code from
NSMenuItemCell to a new method in GSThemeDrawing. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34079 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
953db32805
commit
93988bdfbd
5 changed files with 90 additions and 28 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2011-10-28 Quentin Mathe <quentin.mathe@gmail.com>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||||
|
* Source/GSTheme.m:
|
||||||
|
* Source/GSThemeDrawing.m (-menuSeparatorItemColor,
|
||||||
|
-drawSeparatorItemForMenuItemCell:withFrame:inView:isHorizontal:):
|
||||||
|
* Source/NSMenuItemCell.m (-drawSeparatorItemWithFrame:inView:):
|
||||||
|
Made separator menu item themable, by moving the drawing code from
|
||||||
|
NSMenuItemCell to a new method in GSThemeDrawing.
|
||||||
|
|
||||||
2011-10-27 Fred Kiefer <FredKiefer@gmx.de>
|
2011-10-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSBitmapImageRep.m (+imageRepWithData:): Add missing AUTORELEASE.
|
* Source/NSBitmapImageRep.m (+imageRepWithData:): Add missing AUTORELEASE.
|
||||||
|
|
|
@ -276,6 +276,7 @@ APPKIT_EXPORT NSString *GSMenuHorizontalBackground;
|
||||||
APPKIT_EXPORT NSString *GSMenuVerticalBackground;
|
APPKIT_EXPORT NSString *GSMenuVerticalBackground;
|
||||||
APPKIT_EXPORT NSString *GSMenuHorizontalItem;
|
APPKIT_EXPORT NSString *GSMenuHorizontalItem;
|
||||||
APPKIT_EXPORT NSString *GSMenuVerticalItem;
|
APPKIT_EXPORT NSString *GSMenuVerticalItem;
|
||||||
|
APPKIT_EXPORT NSString *GSMenuSeparatorItem;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Progress Indicator part names.
|
* Progress Indicator part names.
|
||||||
|
@ -897,6 +898,34 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
inView: (NSView *)controlView
|
inView: (NSView *)controlView
|
||||||
state: (GSThemeControlState)state
|
state: (GSThemeControlState)state
|
||||||
isHorizontal: (BOOL)isHorizontal;
|
isHorizontal: (BOOL)isHorizontal;
|
||||||
|
/**
|
||||||
|
* <p>Returns the color used to draw a separator line in a menu.</p>
|
||||||
|
*
|
||||||
|
* <p>By default, looks up the color named <em>menuSeparatorItemColor</em>,
|
||||||
|
* otherwise returns the black color.</p>
|
||||||
|
*
|
||||||
|
* <p>The returned color is used by
|
||||||
|
* -drawSeparatorItemForMenuItemCell:withFrame:inView:isHorizontal:</p>
|
||||||
|
*
|
||||||
|
* <p>Can be overriden in subclasses to return a custom color.</p>
|
||||||
|
*/
|
||||||
|
- (NSColor *) menuSeparatorItemColor;
|
||||||
|
/**
|
||||||
|
* <p>Draws a separator between normal menu items in a menu.</p>
|
||||||
|
*
|
||||||
|
* <p>Each separator corresponds to a menu item that returns YES to
|
||||||
|
* -isSeparatorItem</p>
|
||||||
|
*
|
||||||
|
* <p>You can provide an image tile named <em>GSMenuSeparatoritem</em> to
|
||||||
|
* draw the separator.</br>
|
||||||
|
* Can be overriden in subclasses to customize the drawing.</p>
|
||||||
|
*
|
||||||
|
* <p>See also -menuSeparatorItemColor</p>
|
||||||
|
*/
|
||||||
|
- (void) drawSeparatorItemForMenuItemCell: (NSMenuItemCell *)cell
|
||||||
|
withFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView *)controlView
|
||||||
|
isHorizontal: (BOOL)isHorizontal;
|
||||||
/**
|
/**
|
||||||
* Returns the class used to create the title bar in the given menu view.
|
* Returns the class used to create the title bar in the given menu view.
|
||||||
*
|
*
|
||||||
|
|
|
@ -86,6 +86,7 @@ NSString *GSMenuHorizontalBackground = @"GSMenuHorizontalBackground";
|
||||||
NSString *GSMenuVerticalBackground = @"GSMenuVerticalBackground";
|
NSString *GSMenuVerticalBackground = @"GSMenuVerticalBackground";
|
||||||
NSString *GSMenuHorizontalItem = @"GSMenuHorizontalItem";
|
NSString *GSMenuHorizontalItem = @"GSMenuHorizontalItem";
|
||||||
NSString *GSMenuVerticalItem = @"GSMenuVerticalItem";
|
NSString *GSMenuVerticalItem = @"GSMenuVerticalItem";
|
||||||
|
NSString *GSMenuSeparatorItem = @"GSMenuSeparatorItem";
|
||||||
|
|
||||||
// Progress indicator part names
|
// Progress indicator part names
|
||||||
NSString *GSProgressIndicatorBarDeterminate
|
NSString *GSProgressIndicatorBarDeterminate
|
||||||
|
|
|
@ -908,6 +908,52 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSColor *) menuSeparatorItemColor
|
||||||
|
{
|
||||||
|
NSColor *color = [self colorNamed: @"menuSeparatorItemColor"
|
||||||
|
state: GSThemeNormalState];
|
||||||
|
if (color == nil)
|
||||||
|
{
|
||||||
|
color = [NSColor blackColor];
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) drawSeparatorItemForMenuItemCell: (NSMenuItemCell *)cell
|
||||||
|
withFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView *)controlView
|
||||||
|
isHorizontal: (BOOL)isHorizontal
|
||||||
|
{
|
||||||
|
GSDrawTiles *tiles = [self tilesNamed: GSMenuSeparatorItem state: GSThemeNormalState];
|
||||||
|
|
||||||
|
if (tiles == nil)
|
||||||
|
{
|
||||||
|
NSInterfaceStyle style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
|
||||||
|
|
||||||
|
if (style == NSMacintoshInterfaceStyle || style == NSWindows95InterfaceStyle)
|
||||||
|
{
|
||||||
|
NSBezierPath *path = [NSBezierPath bezierPath];
|
||||||
|
NSPoint start = NSMakePoint(3, cellFrame.size.height / 2 +
|
||||||
|
cellFrame.origin.y);
|
||||||
|
NSPoint end = NSMakePoint(cellFrame.size.width - 3,
|
||||||
|
cellFrame.size.height / 2 + cellFrame.origin.y);
|
||||||
|
|
||||||
|
[[NSColor blackColor] set];
|
||||||
|
|
||||||
|
[path moveToPoint: start];
|
||||||
|
[path lineToPoint: end];
|
||||||
|
|
||||||
|
[path stroke];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self fillRect: cellFrame
|
||||||
|
withTiles: tiles
|
||||||
|
background: [NSColor clearColor]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (Class) titleViewClassForMenuView: (NSMenuView *)aMenuView
|
- (Class) titleViewClassForMenuView: (NSMenuView *)aMenuView
|
||||||
{
|
{
|
||||||
return [GSTitleView class];
|
return [GSTitleView class];
|
||||||
|
|
|
@ -753,34 +753,10 @@ static NSString *commandKeyString = @"#";
|
||||||
- (void) drawSeparatorItemWithFrame:(NSRect)cellFrame
|
- (void) drawSeparatorItemWithFrame:(NSRect)cellFrame
|
||||||
inView:(NSView *)controlView
|
inView:(NSView *)controlView
|
||||||
{
|
{
|
||||||
NSInterfaceStyle style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
|
[[GSTheme theme] drawSeparatorItemForMenuItemCell: self
|
||||||
if (style == NSMacintoshInterfaceStyle
|
withFrame: cellFrame
|
||||||
|| style == NSWindows95InterfaceStyle)
|
inView: controlView
|
||||||
{
|
isHorizontal: [_menuView isHorizontal]];
|
||||||
NSBezierPath *path = [NSBezierPath bezierPath];
|
|
||||||
NSPoint start = NSMakePoint(3, cellFrame.size.height/2 +
|
|
||||||
cellFrame.origin.y);
|
|
||||||
NSPoint end = NSMakePoint(cellFrame.size.width - 3,
|
|
||||||
cellFrame.size.height/2 +
|
|
||||||
cellFrame.origin.y);
|
|
||||||
|
|
||||||
[[NSColor blackColor] set];
|
|
||||||
|
|
||||||
[path moveToPoint: start];
|
|
||||||
[path lineToPoint: end];
|
|
||||||
|
|
||||||
[path stroke];
|
|
||||||
/*
|
|
||||||
NSRect lineFrame = NSMakeRect(cellFrame.origin.x,
|
|
||||||
cellFrame.origin.y
|
|
||||||
+ cellFrame.size.height/2,
|
|
||||||
cellFrame.size.width,
|
|
||||||
1);
|
|
||||||
NSBox *line = [[NSBox alloc] initWithFrame: lineFrame];
|
|
||||||
[controlView addSubview:line];
|
|
||||||
RELEASE(line);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawStateImageWithFrame: (NSRect)cellFrame
|
- (void) drawStateImageWithFrame: (NSRect)cellFrame
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue