mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Use theme tiles (if available) to draw menu backgrounds and items.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29447 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a7b418e691
commit
7225f6e380
4 changed files with 77 additions and 28 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2010-01-29 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/GSTheme.m:
|
||||
* Source/GSThemeDrawing.m:
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h: Use theme tiles (if available)
|
||||
to draw menu backgrounds and items. New tile names:
|
||||
GSMenuHorizontalBackground
|
||||
GSMenuVerticalBackground
|
||||
GSMenuHorizontalItem
|
||||
GSMenuVerticalItem
|
||||
|
||||
2010-01-29 22:14-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h: Added new method
|
||||
|
|
|
@ -263,6 +263,14 @@ APPKIT_EXPORT NSString *GSScrollerVerticalSlot;
|
|||
APPKIT_EXPORT NSString *GSTableHeader;
|
||||
APPKIT_EXPORT NSString *GSTableCorner;
|
||||
|
||||
/*
|
||||
* Menu part names.
|
||||
*/
|
||||
APPKIT_EXPORT NSString *GSMenuHorizontalBackground;
|
||||
APPKIT_EXPORT NSString *GSMenuVerticalBackground;
|
||||
APPKIT_EXPORT NSString *GSMenuHorizontalItem;
|
||||
APPKIT_EXPORT NSString *GSMenuVerticalItem;
|
||||
|
||||
|
||||
/**
|
||||
* This defines how the values in a tile array should be used when
|
||||
|
|
|
@ -76,7 +76,11 @@ NSString *GSScrollerVerticalSlot = @"GSScrollerVerticalSlot";
|
|||
NSString *GSTableHeader = @"GSTableHeader";
|
||||
NSString *GSTableCorner = @"GSTableCorner";
|
||||
|
||||
|
||||
// Menu part names
|
||||
NSString *GSMenuHorizontalBackground = @"GSMenuHorizontalBackground";
|
||||
NSString *GSMenuVerticalBackground = @"GSMenuVerticalBackground";
|
||||
NSString *GSMenuHorizontalItem = @"GSMenuHorizontalItem";
|
||||
NSString *GSMenuVerticalItem = @"GSMenuVerticalItem";
|
||||
|
||||
NSString *GSThemeDidActivateNotification
|
||||
= @"GSThemeDidActivateNotification";
|
||||
|
|
|
@ -715,21 +715,33 @@
|
|||
dirtyRect: (NSRect)dirtyRect
|
||||
horizontal: (BOOL)horizontal
|
||||
{
|
||||
NSRectEdge sides[2];
|
||||
float grays[] = {NSDarkGray, NSDarkGray};
|
||||
|
||||
if (horizontal == YES)
|
||||
NSString *name = horizontal ? GSMenuHorizontalBackground :
|
||||
GSMenuVerticalBackground;
|
||||
GSDrawTiles *tiles = [self tilesNamed: name state: GSThemeNormalState];
|
||||
|
||||
if (tiles == nil)
|
||||
{
|
||||
sides[0] = NSMinYEdge;
|
||||
sides[1] = NSMinYEdge;
|
||||
NSDrawTiledRects(bounds, dirtyRect, sides, grays, 2);
|
||||
NSRectEdge sides[2];
|
||||
float grays[] = {NSDarkGray, NSDarkGray};
|
||||
if (horizontal == YES)
|
||||
{
|
||||
sides[0] = NSMinYEdge;
|
||||
sides[1] = NSMinYEdge;
|
||||
NSDrawTiledRects(bounds, dirtyRect, sides, grays, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
sides[0] = NSMinXEdge;
|
||||
sides[1] = NSMaxYEdge;
|
||||
// Draw the dark gray upper left lines.
|
||||
NSDrawTiledRects(bounds, dirtyRect, sides, grays, 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sides[0] = NSMinXEdge;
|
||||
sides[1] = NSMaxYEdge;
|
||||
// Draw the dark gray upper left lines.
|
||||
NSDrawTiledRects(bounds, dirtyRect, sides, grays, 2);
|
||||
[self fillRect: bounds
|
||||
withTiles: tiles
|
||||
background: [NSColor clearColor]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -739,30 +751,44 @@
|
|||
state: (GSThemeControlState)state
|
||||
isHorizontal: (BOOL)isHorizontal
|
||||
{
|
||||
NSColor *backgroundColor = [cell backgroundColor];
|
||||
|
||||
if (isHorizontal)
|
||||
NSString *name = isHorizontal ? GSMenuHorizontalItem :
|
||||
GSMenuVerticalItem;
|
||||
GSDrawTiles *tiles = [self tilesNamed: name state: state];
|
||||
|
||||
if (tiles == nil)
|
||||
{
|
||||
cellFrame = [cell drawingRectForBounds: cellFrame];
|
||||
|
||||
NSColor *backgroundColor = [cell backgroundColor];
|
||||
|
||||
if (isHorizontal)
|
||||
{
|
||||
cellFrame = [cell drawingRectForBounds: cellFrame];
|
||||
[backgroundColor set];
|
||||
NSRectFill(cellFrame);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set cell's background color
|
||||
[backgroundColor set];
|
||||
NSRectFill(cellFrame);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set cell's background color
|
||||
[backgroundColor set];
|
||||
NSRectFill(cellFrame);
|
||||
if (![cell isBordered])
|
||||
return;
|
||||
|
||||
if (![cell isBordered])
|
||||
return;
|
||||
|
||||
if (state == GSThemeSelectedState)
|
||||
{
|
||||
[self drawGrayBezel: cellFrame withClip: NSZeroRect];
|
||||
if (state == GSThemeSelectedState)
|
||||
{
|
||||
[self drawGrayBezel: cellFrame withClip: NSZeroRect];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self drawButton: cellFrame withClip: NSZeroRect];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self drawButton: cellFrame withClip: NSZeroRect];
|
||||
[self fillRect: cellFrame
|
||||
withTiles: tiles
|
||||
background: [NSColor clearColor]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue