From 7345965f7b54e8cc49ccdf81bc651e3686f7bd52 Mon Sep 17 00:00:00 2001 From: gcasa Date: Fri, 26 Jun 2015 00:13:05 +0000 Subject: [PATCH] Add more theme methods for theming windows. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38687 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 +++ Headers/Additions/GNUstepGUI/GSTheme.h | 15 +++++ Source/GNUmakefile | 1 + Source/GSThemeWindow.m | 89 ++++++++++++++++++++++++++ Source/NSWindow.m | 45 +------------ 5 files changed, 117 insertions(+), 42 deletions(-) create mode 100644 Source/GSThemeWindow.m diff --git a/ChangeLog b/ChangeLog index c416799d8..084aadc24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-06-25 20:11-EDT Gregory John Casamento + + * Headers/Additions/GNUstepGUI/GSTheme.h: Add declarations for method + * Source/GNUmakefile: Add new file GSThemeWindow.m + * Source/GSThemeWindow.m: Add method standardWindowButton: + forStyleMask:. + * Source/NSWindow.m: Call theme methods to return standardWindowButton: + forStyleMask:. + 2015-06-25 14:17-EDT Gregory John Casamento * Headers/Additions/GNUstepGUI/GSTheme.h: Declarations for new theme diff --git a/Headers/Additions/GNUstepGUI/GSTheme.h b/Headers/Additions/GNUstepGUI/GSTheme.h index a3b0fc647..94370e779 100644 --- a/Headers/Additions/GNUstepGUI/GSTheme.h +++ b/Headers/Additions/GNUstepGUI/GSTheme.h @@ -1465,5 +1465,20 @@ withRepeatedImage: (NSImage*)image - (Class) pageLayoutClass; @end +@interface GSTheme (NSWindow) +/** + * This method returns the standard window button for the + * given mask for the current theme. + */ +- (NSButton *) standardWindowButton: (NSWindowButton)button + forStyleMask: (NSUInteger) mask; + +/** + * This method does any additional setup after the default + * cell is set. + */ +- (void) didSetDefaultButtonCell: (NSButtonCell *)aCell; +@end + #endif /* OS_API_VERSION */ #endif /* _GNUstep_H_GSTheme */ diff --git a/Source/GNUmakefile b/Source/GNUmakefile index a883f52c7..35c27c183 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -235,6 +235,7 @@ GSThemeOpenSavePanels.m \ GSThemePanel.m \ GSThemePrintPanels.m \ GSThemeTools.m \ +GSThemeWindow.m \ GSTitleView.m \ GSToolTips.m \ GSToolbarView.m \ diff --git a/Source/GSThemeWindow.m b/Source/GSThemeWindow.m new file mode 100644 index 000000000..554c2de91 --- /dev/null +++ b/Source/GSThemeWindow.m @@ -0,0 +1,89 @@ +/** GSThemeWindow + + The theme methods for window specific functions + + Copyright (C) 2015 Free Software Foundation, Inc. + + Author: Gregory Casamento + Date: Jun 2015 + + This file is part of the GNU Objective C User interface library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#import "AppKit/NSWindow.h" +#import "AppKit/NSImage.h" +#import "AppKit/NSButton.h" + +#import "GNUstepGUI/GSTheme.h" +#import "GNUstepGUI/GSWindowDecorationView.h" +#import "GSThemePrivate.h" + +@implementation GSTheme (NSWindow) +- (NSButton *) standardWindowButton: (NSWindowButton)button + forStyleMask: (NSUInteger) mask +{ + NSButton *newButton; + + newButton = [[NSButton alloc] init]; + [newButton setRefusesFirstResponder: YES]; + [newButton setButtonType: NSMomentaryChangeButton]; + [newButton setImagePosition: NSImageOnly]; + [newButton setBordered: YES]; + [newButton setTag: button]; + + switch (button) + { + case NSWindowCloseButton: + [newButton setImage: [NSImage imageNamed: @"common_Close"]]; + [newButton setAlternateImage: [NSImage imageNamed: @"common_CloseH"]]; + /* TODO: -performClose: should (but doesn't currently) highlight the + button, which is wrong here. When -performClose: is fixed, we'll need a + different method here. */ + [newButton setAction: @selector(performClose:)]; + break; + + case NSWindowMiniaturizeButton: + [newButton setImage: [NSImage imageNamed: @"common_Miniaturize"]]; + [newButton setAlternateImage: [NSImage imageNamed: @"common_MiniaturizeH"]]; + [newButton setAction: @selector(miniaturize:)]; + break; + + case NSWindowZoomButton: + // FIXME + [newButton setAction: @selector(zoom:)]; + break; + + case NSWindowToolbarButton: + // FIXME + [newButton setAction: @selector(toggleToolbarShown:)]; + break; + case NSWindowDocumentIconButton: + default: + // FIXME + break; + } + + return AUTORELEASE(newButton); +} + +- (void) didSetDefaultButtonCell: (NSButtonCell *)aCell +{ + // default implementation does nothing... +} +@end diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 7fdeb1cc0..77b8e91d9 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -3234,48 +3234,8 @@ checkCursorRectanglesExited(NSView *theView, NSEvent *theEvent, NSPoint lastPoi + (NSButton *) standardWindowButton: (NSWindowButton)button forStyleMask: (NSUInteger) mask { - NSButton *newButton; - - newButton = [[NSButton alloc] init]; - [newButton setRefusesFirstResponder: YES]; - [newButton setButtonType: NSMomentaryChangeButton]; - [newButton setImagePosition: NSImageOnly]; - [newButton setBordered: YES]; - [newButton setTag: button]; - - switch (button) - { - case NSWindowCloseButton: - [newButton setImage: [NSImage imageNamed: @"common_Close"]]; - [newButton setAlternateImage: [NSImage imageNamed: @"common_CloseH"]]; - /* TODO: -performClose: should (but doesn't currently) highlight the - button, which is wrong here. When -performClose: is fixed, we'll need a - different method here. */ - [newButton setAction: @selector(performClose:)]; - break; - - case NSWindowMiniaturizeButton: - [newButton setImage: [NSImage imageNamed: @"common_Miniaturize"]]; - [newButton setAlternateImage: [NSImage imageNamed: @"common_MiniaturizeH"]]; - [newButton setAction: @selector(miniaturize:)]; - break; - - case NSWindowZoomButton: - // FIXME - [newButton setAction: @selector(zoom:)]; - break; - - case NSWindowToolbarButton: - // FIXME - [newButton setAction: @selector(toggleToolbarShown:)]; - break; - case NSWindowDocumentIconButton: - default: - // FIXME - break; - } - - return AUTORELEASE(newButton); + return [[GSTheme theme] standardWindowButton: button + forStyleMask: mask]; } - (NSButton *) standardWindowButton: (NSWindowButton)button @@ -5164,6 +5124,7 @@ current key view.
[aCell setKeyEquivalent: @"\r"]; [aCell setKeyEquivalentModifierMask: 0]; + [[GSTheme theme] didSetDefaultButtonCell: aCell]; } - (void) disableKeyEquivalentForDefaultButtonCell