diff --git a/ChangeLog b/ChangeLog index 1c9a8b868..086da9486 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-23 14:05-EDT Gregory John Casamento + + * Headers/Additions/GNUstepGUI/GSTheme.h: Added new method declaration + for drawButtonCell:... + * Source/GSThemeDrawing.m: Added implementation for new method. The + purpose of the method is to allow the theme to override images with + native images which may be theme dependent. + * Source/NSButtonCell.m: Use the new method. + 2009-08-23 Doug Simons * Source/GSHorizontalTypesetter.m: Remove unlock and diff --git a/Headers/Additions/GNUstepGUI/GSTheme.h b/Headers/Additions/GNUstepGUI/GSTheme.h index 2b78992be..9b4f71a34 100644 --- a/Headers/Additions/GNUstepGUI/GSTheme.h +++ b/Headers/Additions/GNUstepGUI/GSTheme.h @@ -558,6 +558,16 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification; * Draw highlighted stepper down button */ - (void) drawStepperHighlightDownButton: (NSRect) aRect; + +// Draw a button cell. +/** + * In some themes it may be necessary to override the drawing + * of an image a button cell and replace it with a rendered + * version (from the native theme). + */ +- (void) drawButtonCellImage: (NSButtonCell *) cell + withFrame: (NSRect) aRect + position: (NSPoint) position; @end /** diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index 02122ad4f..acab510dd 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -544,5 +544,23 @@ PSstroke(); } +- (void) drawButtonCellImage: (NSButtonCell *) cell + withFrame: (NSRect) aRect + position: (NSPoint) position +{ + NSImage *anImage = [cell image]; + BOOL disabled = [cell isEnabled]; + BOOL dims = [cell imageDimsWhenDisabled]; + + if (disabled && dims) + { + [anImage dissolveToPoint: position fraction: 0.5]; + } + else + { + [anImage compositeToPoint: position + operation: NSCompositeSourceOver]; + } +} @end diff --git a/Source/NSButtonCell.m b/Source/NSButtonCell.m index 834d8a3e1..62c5d7948 100644 --- a/Source/NSButtonCell.m +++ b/Source/NSButtonCell.m @@ -915,16 +915,10 @@ typedef struct _GSButtonCellFlags { position.y += size.height; } - - if (_cell.is_disabled && _image_dims_when_disabled) - { - [anImage dissolveToPoint: position fraction: 0.5]; - } - else - { - [anImage compositeToPoint: position - operation: NSCompositeSourceOver]; - } + + [[GSTheme theme] drawButtonCellImage: self + withFrame: aRect + position: position]; } }