diff --git a/ChangeLog b/ChangeLog index 11263a215..cb981932b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-22 19:49-EDT Gregory John Casamento + + * 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 * Source/NSMenuItemCell.m (-drawStateImageWithFrame:inView:, diff --git a/Headers/Additions/GNUstepGUI/GSTheme.h b/Headers/Additions/GNUstepGUI/GSTheme.h index 43dac0d10..2b78992be 100644 --- a/Headers/Additions/GNUstepGUI/GSTheme.h +++ b/Headers/Additions/GNUstepGUI/GSTheme.h @@ -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 /** diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index 36fc96581..02122ad4f 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -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 diff --git a/Source/NSStepperCell.m b/Source/NSStepperCell.m index 95326da3b..126fa73f8 100644 --- a/Source/NSStepperCell.m +++ b/Source/NSStepperCell.m @@ -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};