diff --git a/ChangeLog b/ChangeLog index 7353c253b..8bfa57fbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-01-29 Eric Wasylishen + + * Source/GSTheme.m: + * Source/GSThemeDrawing.m: + * Source/GSThemePrivate.h: Add GSStringFromBezelStyle and + GSStringFromSegmentStyle functions which return the string name of + the style constant for buttons and segmented controls. + In -[GSThemeDrawing drawButton:view:style:state], use + GSStringFromBezelStyle to try to get tiles for the specified bezel + style, falling back to the normal NSButton tiles if the fancy tiles + aren't present. + 2010-01-28 Eric Wasylishen * Headers/AppKit/NSPanel.h: Added panel style constants diff --git a/Source/GSTheme.m b/Source/GSTheme.m index c8108e5c9..d954d7aaa 100644 --- a/Source/GSTheme.m +++ b/Source/GSTheme.m @@ -40,6 +40,7 @@ #import "GNUstepBase/GSObjCRuntime.h" #import "GNUstepGUI/GSTheme.h" #import "AppKit/NSApplication.h" +#import "AppKit/NSButtonCell.h" #import "AppKit/NSButton.h" #import "AppKit/NSColor.h" #import "AppKit/NSColorList.h" @@ -50,6 +51,7 @@ #import "AppKit/NSMenu.h" #import "AppKit/NSPanel.h" #import "AppKit/NSScrollView.h" +#import "AppKit/NSSegmentedControl.h" #import "AppKit/NSTextContainer.h" #import "AppKit/NSTextField.h" #import "AppKit/NSTextView.h" @@ -124,6 +126,49 @@ GSThemeFillStyleFromString(NSString *s) return GSThemeFillStyleNone; } +NSString * +GSStringFromSegmentStyle(NSSegmentStyle segmentStyle) +{ + switch (segmentStyle) + { + case NSSegmentStyleAutomatic: return @"NSSegmentStyleAutomatic"; + case NSSegmentStyleRounded: return @"NSSegmentStyleRounded"; + case NSSegmentStyleTexturedRounded: return @"NSSegmentStyleTexturedRounded"; + case NSSegmentStyleRoundRect: return @"NSSegmentStyleRoundRect"; + case NSSegmentStyleTexturedSquare: return @"NSSegmentStyleTexturedSquare"; + case NSSegmentStyleCapsule: return @"NSSegmentStyleCapsule"; + case NSSegmentStyleSmallSquare: return @"NSSegmentStyleSmallSquare"; + default: return nil; + } +} + +NSString * +GSStringFromBezelStyle(NSBezelStyle bezelStyle) +{ + switch (bezelStyle) + { + case NSRoundedBezelStyle: return @"NSRoundedBezelStyle"; + case NSRegularSquareBezelStyle: return @"NSRegularSquareBezelStyle"; + case NSThickSquareBezelStyle: return @"NSThickSquareBezelStyle"; + case NSThickerSquareBezelStyle: return @"NSThickerSquareBezelStyle"; + case NSDisclosureBezelStyle: return @"NSDisclosureBezelStyle"; + case NSShadowlessSquareBezelStyle: return @"NSShadowlessSquareBezelStyle"; + case NSCircularBezelStyle: return @"NSCircularBezelStyle"; + case NSTexturedSquareBezelStyle: return @"NSTexturedSquareBezelStyle"; + case NSHelpButtonBezelStyle: return @"NSHelpButtonBezelStyle"; + case NSSmallSquareBezelStyle: return @"NSSmallSquareBezelStyle"; + case NSTexturedRoundedBezelStyle: return @"NSTexturedRoundedBezelStyle"; + case NSRoundRectBezelStyle: return @"NSRoundRectBezelStyle"; + case NSRecessedBezelStyle: return @"NSRecessedBezelStyle"; + case NSRoundedDisclosureBezelStyle: return @"NSRoundedDisclosureBezelStyle"; + case NSNeXTBezelStyle: return @"NSNeXTBezelStyle"; + case NSPushButtonBezelStyle: return @"NSPushButtonBezelStyle"; + case NSSmallIconButtonBezelStyle: return @"NSSmallIconButtonBezelStyle"; + case NSMediumIconButtonBezelStyle: return @"NSMediumIconButtonBezelStyle"; + case NSLargeIconButtonBezelStyle: return @"NSLargeIconButtonBezelStyle"; + default: return nil; + } +} @interface NSImage (GSTheme) + (NSImage*) _setImage: (NSImage*)image name: (NSString*)name; diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index 5df6867a8..c857d4219 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -62,7 +62,7 @@ if (name == nil) { - name = @"NSButton"; + name = GSStringFromBezelStyle(style); } color = [self colorNamed: name state: state]; @@ -83,6 +83,11 @@ } tiles = [self tilesNamed: name state: state]; + if (tiles == nil) + { + tiles = [self tilesNamed: @"NSButton" state: state]; + } + if (tiles == nil) { switch (style) @@ -157,10 +162,15 @@ if (name == nil) { - name = @"NSButton"; + name = GSStringFromBezelStyle(style); } tiles = [self tilesNamed: name state: state]; + if (tiles == nil) + { + tiles = [self tilesNamed: @"NSButton" state: state]; + } + if (tiles == nil) { switch (style) diff --git a/Source/GSThemePrivate.h b/Source/GSThemePrivate.h index 63095fff3..2222e4683 100644 --- a/Source/GSThemePrivate.h +++ b/Source/GSThemePrivate.h @@ -30,10 +30,15 @@ #import #import "AppKit/NSPanel.h" +#import "AppKit/NSButtonCell.h" +#import "AppKit/NSSegmentedControl.h" #import "GNUstepGUI/GSTheme.h" @class NSImage, NSMatrix, NSScrollView, NSView; +NSString *GSStringFromSegmentStyle(NSSegmentStyle segmentStyle); +NSString *GSStringFromBezelStyle(NSBezelStyle bezelStyle); + /** These are the nine types of tile used to draw a rectangular object. */ typedef enum {