Index: Source/GSTheme.m =================================================================== --- Source/GSTheme.m (revision 25503) +++ Source/GSTheme.m (working copy) @@ -38,6 +38,7 @@ #include "AppKit/NSButton.h" #include "AppKit/NSColor.h" #include "AppKit/NSColorList.h" +#include "AppKit/NSEvent.h" #include "AppKit/NSGraphics.h" #include "AppKit/NSImage.h" #include "AppKit/NSImageView.h" @@ -693,6 +694,67 @@ @end address@hidden GSTheme (Factory) + +- (NSButtonCell*) makeScrollerUpCell { + NSButtonCell* upCell = [NSButtonCell new]; + [upCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; + [upCell setImage: [NSImage imageNamed: @"common_ArrowUp"]]; + [upCell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]]; + [upCell setImagePosition: NSImageOnly]; + [upCell setContinuous: YES]; + [upCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; + [upCell setPeriodicDelay: 0.3 interval: 0.03]; + return upCell; +} + +- (NSButtonCell*) makeScrollerDownCell { + NSButtonCell* downCell = [NSButtonCell new]; + [downCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; + [downCell setImage: [NSImage imageNamed: @"common_ArrowDown"]]; + [downCell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]]; + [downCell setImagePosition: NSImageOnly]; + [downCell setContinuous: YES]; + [downCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; + [downCell setPeriodicDelay: 0.3 interval: 0.03]; + return downCell; +} + +- (NSButtonCell*) makeScrollerLeftCell { + NSButtonCell* leftCell = [NSButtonCell new]; + [leftCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; + [leftCell setImage: [NSImage imageNamed: @"common_ArrowLeft"]]; + [leftCell setAlternateImage: [NSImage imageNamed: @"common_ArrowLeftH"]]; + [leftCell setImagePosition: NSImageOnly]; + [leftCell setContinuous: YES]; + [leftCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; + [leftCell setPeriodicDelay: 0.3 interval: 0.03]; + return leftCell; +} + +- (NSButtonCell*) makeScrollerRightCell { + NSButtonCell* rightCell = [NSButtonCell new]; + [rightCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; + [rightCell setImage: [NSImage imageNamed: @"common_ArrowRight"]]; + [rightCell setAlternateImage: [NSImage imageNamed: @"common_ArrowRightH"]]; + [rightCell setImagePosition: NSImageOnly]; + [rightCell setContinuous: YES]; + [rightCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; + [rightCell setPeriodicDelay: 0.3 interval: 0.03]; + return rightCell; +} + +- (NSButtonCell*) makeScrollerKnobCell { + NSButtonCell* knobCell = [NSButtonCell new]; + [knobCell setButtonType: NSMomentaryChangeButton]; + [knobCell setImage: [NSImage imageNamed: @"common_Dimple"]]; + [knobCell setImagePosition: NSImageOnly]; + return knobCell; +} + address@hidden + + @implementation GSTheme (Drawing) - (void) drawButton: (NSRect)frame Index: Source/NSScroller.m =================================================================== --- Source/NSScroller.m (revision 25503) +++ Source/NSScroller.m (working copy) @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "AppKit/NSApplication.h" #include "AppKit/NSButtonCell.h" @@ -42,6 +44,7 @@ #include "AppKit/NSScroller.h" #include "AppKit/NSScrollView.h" #include "AppKit/NSWindow.h" +#include "GNUstepGUI/GSTheme.h" /**

TODO Description

*/ @@ -72,9 +75,29 @@ { [self setVersion: 1]; ASSIGN (scrollBarColor, [NSColor scrollBarColor]); + + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(themeDeactivated:) + name: GSThemeDidActivateNotification + object: nil]; } } +/* + * Called when the current theme is activated. + */ ++ (void) themeActivated: (NSNotification*)notif +{ + // release button cells so that the new theme can + // provide them later. + DESTROY(upCell); + DESTROY(downCell); + DESTROY(leftCell); + DESTROY(rightCell); + DESTROY(knobCell); +} + /**

Returns the NSScroller's width. By default 18.

Subclasses can override this to provide different scrollbar width. But you may need to also override -drawParts .

@@ -326,47 +349,16 @@ */ if (knobCell) return; - - upCell = [NSButtonCell new]; - [upCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; - [upCell setImage: [NSImage imageNamed: @"common_ArrowUp"]]; - [upCell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]]; - [upCell setImagePosition: NSImageOnly]; - [upCell setContinuous: YES]; - [upCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; - [upCell setPeriodicDelay: 0.3 interval: 0.03]; - - downCell = [NSButtonCell new]; - [downCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; - [downCell setImage: [NSImage imageNamed: @"common_ArrowDown"]]; - [downCell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]]; - [downCell setImagePosition: NSImageOnly]; - [downCell setContinuous: YES]; - [downCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; - [downCell setPeriodicDelay: 0.3 interval: 0.03]; - - leftCell = [NSButtonCell new]; - [leftCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; - [leftCell setImage: [NSImage imageNamed: @"common_ArrowLeft"]]; - [leftCell setAlternateImage: [NSImage imageNamed: @"common_ArrowLeftH"]]; - [leftCell setImagePosition: NSImageOnly]; - [leftCell setContinuous: YES]; - [leftCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; - [leftCell setPeriodicDelay: 0.3 interval: 0.03]; - - rightCell = [NSButtonCell new]; - [rightCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask]; - [rightCell setImage: [NSImage imageNamed: @"common_ArrowRight"]]; - [rightCell setAlternateImage: [NSImage imageNamed: @"common_ArrowRightH"]]; - [rightCell setImagePosition: NSImageOnly]; - [rightCell setContinuous: YES]; - [rightCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)]; - [rightCell setPeriodicDelay: 0.3 interval: 0.03]; - - knobCell = [NSButtonCell new]; - [knobCell setButtonType: NSMomentaryChangeButton]; - [knobCell setImage: [NSImage imageNamed: @"common_Dimple"]]; - [knobCell setImagePosition: NSImageOnly]; + + GSTheme* theme = [GSTheme theme]; + + upCell = [theme makeScrollerUpCell]; + downCell = [theme makeScrollerDownCell]; + leftCell = [theme makeScrollerLeftCell]; + rightCell = [theme makeScrollerRightCell]; + knobCell = [theme makeScrollerKnobCell]; + + NSAssert(upCell && downCell && leftCell && rightCell && knobCell, @"Scroller cell factory methods broken."); } - (void) _setTargetAndActionToCells Index: Headers/Additions/GNUstepGUI/GSTheme.h =================================================================== --- Headers/Additions/GNUstepGUI/GSTheme.h (revision 25503) +++ Headers/Additions/GNUstepGUI/GSTheme.h (working copy) @@ -372,6 +372,45 @@ @end /** + * Theme factory methods + */ address@hidden GSTheme (Factory) + +/** + * Creates and returns a new button cell to be used for a scroller's + * "up" button. + */ +- (NSButtonCell*) makeScrollerUpCell; + +/** + * Creates and returns a new button cell to be used for a scroller's + * "down" button. + */ +- (NSButtonCell*) makeScrollerDownCell; + + +/** + * Creates and returns a new button cell to be used for a scroller's + * "right" button. + */ +- (NSButtonCell*) makeScrollerRightCell; + +/** + * Creates and returns a new button cell to be used for a scroller's + * "left" button. + */ +- (NSButtonCell*) makeScrollerLeftCell; + +/** + * Creates and returns a new button cell to be used for a scroller's + * "knob". + */ +- (NSButtonCell*) makeScrollerKnobCell; + address@hidden + + +/** * Theme drawing methods */ @interface GSTheme (Drawing)