* Headers/Additions/GNUstepGUI/GSTheme.h: Add methods for drawing

stepper cell here.
	* Source/GSThemeDrawing.m: Implementations for stepper cell functions.
	* Source/NSStepperCell.m: Use new stepper cell functions.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28510 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2009-08-22 23:50:14 +00:00
parent 88a5d26a8b
commit b6789caaeb
4 changed files with 150 additions and 119 deletions

View file

@ -1,3 +1,10 @@
2009-08-22 19:49-EDT Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: Add methods for drawing
stepper cell here.
* Source/GSThemeDrawing.m: Implementations for stepper cell functions.
* Source/NSStepperCell.m: Use new stepper cell functions.
2009-08-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSMenuItemCell.m (-drawStateImageWithFrame:inView:,

View file

@ -521,7 +521,8 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
- (NSSize) sizeForImageFrameStyle: (NSImageFrameStyle)frameStyle;
/** Methods for scroller theming.
/**
* Methods for scroller theming.
*/
- (NSButtonCell*) cellForScrollerArrow: (NSScrollerArrow)part
horizontal: (BOOL)horizontal;
@ -529,12 +530,34 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
- (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal;
- (float) defaultScrollerWidth;
/** Method for toolbar theming.
/**
* Method for toolbar theming.
*/
- (void) drawToobarRect: (NSRect)aRect
frame: (NSRect)viewFrame
borderMask: (unsigned int)borderMask;
// Methods to deal with steppers..
/**
* Draw light colored stepper using the border and clip rects
*/
- (NSRect) drawStepperLightButton: (NSRect) border :(NSRect) clip;
/**
* Draw normal stepper up button.
*/
- (void) drawStepperUpButton: (NSRect) aRect;
/**
* Draw highlighted up stepper button.
*/
- (void) drawStepperHighlightUpButton: (NSRect) aRect;
/**
* Draw down button for stepper
*/
- (void) drawStepperDownButton: (NSRect) aRect;
/**
* Draw highlighted stepper down button
*/
- (void) drawStepperHighlightDownButton: (NSRect) aRect;
@end
/**

View file

@ -27,12 +27,14 @@
*/
#import "GSThemePrivate.h"
#include "AppKit/NSBezierPath.h"
#import "AppKit/NSBezierPath.h"
#import "AppKit/NSColorList.h"
#import "AppKit/NSGraphics.h"
#import "AppKit/NSImage.h"
#import "AppKit/PSOperators.h"
#include "GNUstepGUI/GSToolbarView.h"
#import "GNUstepGUI/GSToolbarView.h"
@implementation GSTheme (Drawing)
@ -432,5 +434,115 @@
}
}
- (NSRect) drawStepperLightButton: (NSRect) border :(NSRect) clip
{
/*
NSRect highlightRect = NSInsetRect(border, 1., 1.);
[[GSTheme theme] drawButton: border : clip];
return highlightRect;
*/
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge,
NSMinXEdge, NSMaxYEdge};
NSRectEdge dn_sides[] = {NSMaxXEdge, NSMaxYEdge,
NSMinXEdge, NSMinYEdge};
// These names are role names not the actual colours
NSColor *dark = [NSColor controlShadowColor];
NSColor *white = [NSColor controlLightHighlightColor];
NSColor *colors[] = {dark, dark, white, white};
if ([[NSView focusView] isFlipped] == YES)
{
return NSDrawColorTiledRects(border, clip, dn_sides, colors, 4);
}
else
{
return NSDrawColorTiledRects(border, clip, up_sides, colors, 4);
}
}
- (void) drawStepperUpButton: (NSRect) aRect
{
NSRect unHighlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
[[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect);
PSsetlinewidth(1.0);
[[NSColor controlShadowColor] set];
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke();
[[NSColor controlLightHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke();
}
- (void) drawStepperHighlightUpButton: (NSRect) aRect
{
NSRect highlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
[[NSColor selectedControlColor] set];
NSRectFill(highlightRect);
PSsetlinewidth(1.0);
[[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke();
[[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke();
}
- (void) drawStepperDownButton: (NSRect) aRect
{
NSRect unHighlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
[[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect);
PSsetlinewidth(1.0);
[[NSColor controlShadowColor] set];
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3);
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke();
[[NSColor controlLightHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke();
}
- (void) drawStepperHighlightDownButton: (NSRect) aRect
{
NSRect highlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
[[NSColor selectedControlColor] set];
NSRectFill(highlightRect);
PSsetlinewidth(1.0);
[[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3);
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke();
[[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke();
}
@end

View file

@ -36,7 +36,6 @@
#include "AppKit/NSGraphicsContext.h"
#include "AppKit/NSStepperCell.h"
#include "AppKit/NSWindow.h"
#include "AppKit/PSOperators.h"
#include "GNUstepGUI/GSTheme.h"
// Hard coded values for button sizes
@ -141,116 +140,6 @@
_valueWraps = valueWraps;
}
static inline NSRect DrawLightButton(NSRect border, NSRect clip)
{
/*
NSRect highlightRect = NSInsetRect(border, 1., 1.);
[[GSTheme theme] drawButton: border : clip];
return highlightRect;
*/
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge,
NSMinXEdge, NSMaxYEdge};
NSRectEdge dn_sides[] = {NSMaxXEdge, NSMaxYEdge,
NSMinXEdge, NSMinYEdge};
// These names are role names not the actual colours
NSColor *dark = [NSColor controlShadowColor];
NSColor *white = [NSColor controlLightHighlightColor];
NSColor *colors[] = {dark, dark, white, white};
if ([[NSView focusView] isFlipped] == YES)
{
return NSDrawColorTiledRects(border, clip, dn_sides, colors, 4);
}
else
{
return NSDrawColorTiledRects(border, clip, up_sides, colors, 4);
}
}
static inline void DrawUpButton(NSRect aRect)
{
NSRect unHighlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect);
PSsetlinewidth(1.0);
[[NSColor controlShadowColor] set];
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke();
[[NSColor controlLightHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke();
}
static inline void HighlightUpButton(NSRect aRect)
{
NSRect highlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor selectedControlColor] set];
NSRectFill(highlightRect);
PSsetlinewidth(1.0);
[[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke();
[[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke();
}
static inline void DrawDownButton(NSRect aRect)
{
NSRect unHighlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor controlBackgroundColor] set];
NSRectFill(unHighlightRect);
PSsetlinewidth(1.0);
[[NSColor controlShadowColor] set];
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3);
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke();
[[NSColor controlLightHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke();
}
static inline void HighlightDownButton(NSRect aRect)
{
NSRect highlightRect = DrawLightButton(aRect, NSZeroRect);
[[NSColor selectedControlColor] set];
NSRectFill(highlightRect);
PSsetlinewidth(1.0);
[[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3);
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke();
[[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke();
}
- (void) drawInteriorWithFrame: (NSRect)cellFrame
inView: (NSView*)controlView
{
@ -267,14 +156,14 @@ static inline void HighlightDownButton(NSRect aRect)
twoButtons.size.height = 2 * STEPPER_HEIGHT + 1;
if (highlightUp)
HighlightUpButton(upRect);
[[GSTheme theme] drawStepperHighlightUpButton: upRect];
else
DrawUpButton(upRect);
[[GSTheme theme] drawStepperUpButton: upRect];
if (highlightDown)
HighlightDownButton(downRect);
[[GSTheme theme] drawStepperHighlightDownButton: downRect];
else
DrawDownButton(downRect);
[[GSTheme theme] drawStepperDownButton: downRect];
{
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};