New drawing function and small patches on button cell.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18593 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-02-13 18:27:34 +00:00
parent e447a55ea3
commit 38d9d84c34
4 changed files with 113 additions and 5 deletions

View file

@ -26,8 +26,8 @@
#include "GNUstepGUI/GSDrawFunctions.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSView.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSView.h"
#include "AppKit/PSOperators.h"
@ -237,4 +237,58 @@
}
}
/** Draw a gradient border. */
+ (NSRect) drawGradientBorder: (NSGradientType)gradientType
inRect: (NSRect)border
withClip: (NSRect)clip
{
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge,
NSMinXEdge, NSMaxYEdge};
NSRectEdge dn_sides[] = {NSMaxXEdge, NSMaxYEdge,
NSMinXEdge, NSMinYEdge};
NSColor *black = [NSColor controlDarkShadowColor];
NSColor *dark = [NSColor controlShadowColor];
NSColor *light = [NSColor controlColor];
NSColor **colors;
NSColor *concaveWeak[] = {dark, dark,
light, light};
NSColor *concaveStrong[] = {black, black,
light, light};
NSColor *convexWeak[] = {light, light,
dark, dark};
NSColor *convexStrong[] = {light, light,
black, black};
NSRect rect;
switch (gradientType)
{
case NSGradientConcaveWeak:
colors = concaveWeak;
break;
case NSGradientConcaveStrong:
colors = concaveStrong;
break;
case NSGradientConvexWeak:
colors = convexWeak;
break;
case NSGradientConvexStrong:
colors = convexStrong;
break;
case NSGradientNone:
default:
return border;
}
if ([[NSView focusView] isFlipped] == YES)
{
rect = NSDrawColorTiledRects(border, clip, dn_sides, colors, 4);
}
else
{
rect = NSDrawColorTiledRects(border, clip, up_sides, colors, 4);
}
return rect;
}
@end