diff --git a/ChangeLog b/ChangeLog index 39b758396..443ee753d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-01-09 Fred Kiefer + + * Headers/AppKit/NSWindow+Toolbar.h, + * Source/NSWindow+Toolbar.m: Remove these file and move all code ... + * Headers/AppKit/NSWindow.h, + * Source/NSWindow.m: ... to here. + * Source/NSToolbarFrameworkPrivate.h, + * Headers/AppKit/AppKit.h, + * Source/GNUmakefile: Remove references to these files. + * Source/NSToolbar.m (-_toolbarView): Create the toolbar view here + and not in [NSWindow setToolbar:]. + 2009-01-08 Richard Frith-Macdonald * Source/GSTheme.m: Fix nil pointer exception. diff --git a/Headers/AppKit/AppKit.h b/Headers/AppKit/AppKit.h index 7af807197..df2cd6368 100644 --- a/Headers/AppKit/AppKit.h +++ b/Headers/AppKit/AppKit.h @@ -175,7 +175,6 @@ #include #include #include -#include #endif #include diff --git a/Headers/AppKit/NSWindow+Toolbar.h b/Headers/AppKit/NSWindow+Toolbar.h deleted file mode 100644 index 282174984..000000000 --- a/Headers/AppKit/NSWindow+Toolbar.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - NSWindow+Toolbar.h - - The window toolbar category - - Copyright (C) 2004 Free Software Foundation, Inc. - - Author: Quentin Mathe - Date: January 2004 - - This file is part of the GNUstep GUI 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. -*/ - -#ifndef _GNUstep_H_NSWindow_Toolbar -#define _GNUstep_H_NSWindow_Toolbar - -#include "AppKit/NSWindow.h" - -@class NSToolbar; - -@interface NSWindow (Toolbar) -- (void) runToolbarCustomizationPalette: (id)sender; -- (void) toggleToolbarShown: (id)sender; -- (NSToolbar *) toolbar; -- (void) setToolbar: (NSToolbar*)toolbar; -@end - -#endif diff --git a/Headers/AppKit/NSWindow.h b/Headers/AppKit/NSWindow.h index e54122305..89c7867b8 100644 --- a/Headers/AppKit/NSWindow.h +++ b/Headers/AppKit/NSWindow.h @@ -3,7 +3,7 @@ The window class - Copyright (C) 1996,1999 Free Software Foundation, Inc. + Copyright (C) 1996,1999,2004 Free Software Foundation, Inc. Author: Scott Christley Date: 1996 @@ -11,6 +11,8 @@ Date: June 1998 Modified: Richard Frith-Macdonald Date: 1998,1999 + Author: Quentin Mathe + Date: January 2004 This file is part of the GNUstep GUI Library. @@ -746,6 +748,15 @@ APPKIT_EXPORT NSSize NSTokenSize; @end +@class NSToolbar; + +@interface NSWindow (Toolbar) +- (void) runToolbarCustomizationPalette: (id)sender; +- (void) toggleToolbarShown: (id)sender; +- (NSToolbar *) toolbar; +- (void) setToolbar: (NSToolbar*)toolbar; +@end + #if OS_API_VERSION(GS_API_NONE, GS_API_NONE) /* * GNUstep backend methods diff --git a/Source/GNUmakefile b/Source/GNUmakefile index c3294cea0..334b2f3e6 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -180,7 +180,6 @@ NSTokenField.m \ NSTokenFieldCell.m \ NSUserDefaultsController.m \ NSView.m \ -NSWindow+Toolbar.m \ NSWindow.m \ NSWindowController.m \ NSWorkspace.m \ @@ -378,7 +377,6 @@ NSUserDefaultsController.h \ NSView.h \ NSWindow.h \ NSWindowController.h \ -NSWindow+Toolbar.h \ NSWorkspace.h \ NSAttributedString.h \ NSColorPicking.h \ diff --git a/Source/NSToolbar.m b/Source/NSToolbar.m index 7c0378308..3f468a7e3 100644 --- a/Source/NSToolbar.m +++ b/Source/NSToolbar.m @@ -48,7 +48,6 @@ #include "AppKit/NSToolbarItem.h" #include "AppKit/NSView.h" #include "AppKit/NSWindow.h" -#include "AppKit/NSWindow+Toolbar.h" #include "GNUstepGUI/GSToolbarView.h" #include "AppKit/NSToolbar.h" @@ -837,8 +836,12 @@ static GSValidationCenter *vc = nil; - (void) setShowsBaselineSeparator: (BOOL)flag { - // FIXME _showsBaselineSeparator = flag; + + if (_showsBaselineSeparator) + [_toolbarView setBorderMask: GSToolbarViewBottomBorder]; + else + [_toolbarView setBorderMask: 0]; } // Private methods @@ -1226,6 +1229,26 @@ static GSValidationCenter *vc = nil; - (GSToolbarView *) _toolbarView { + if (_toolbarView == nil) + { + // Instantiate the toolbar view + // addToolbarView: method will set the toolbar view to the right + // frame + GSToolbarView *toolbarView = [[GSToolbarView alloc] + initWithFrame: + NSMakeRect(0, 0, 100, 100)]; + + [toolbarView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin]; + if (_showsBaselineSeparator) + [toolbarView setBorderMask: GSToolbarViewBottomBorder]; + else + [toolbarView setBorderMask: 0]; + + // Load the toolbar view inside the toolbar + _toolbarView = toolbarView; + [_toolbarView setToolbar: self]; + } + return _toolbarView; } diff --git a/Source/NSToolbarFrameworkPrivate.h b/Source/NSToolbarFrameworkPrivate.h index 5a3cfa6c8..d2ca85135 100644 --- a/Source/NSToolbarFrameworkPrivate.h +++ b/Source/NSToolbarFrameworkPrivate.h @@ -32,7 +32,6 @@ #include "AppKit/NSToolbar.h" #include "AppKit/NSToolbarItem.h" -#include "AppKit/NSWindow+Toolbar.h" #include "GNUstepGUI/GSToolbarView.h" #include "GSWindowDecorationView.h" diff --git a/Source/NSWindow+Toolbar.m b/Source/NSWindow+Toolbar.m deleted file mode 100644 index d4d20c41f..000000000 --- a/Source/NSWindow+Toolbar.m +++ /dev/null @@ -1,124 +0,0 @@ -/** NSWindow+Toolbar - - The window class category to include toolbar support - - Copyright (C) 2004 Free Software Foundation, Inc. - - Author: Quentin Mathe - Date: January 2004 - - This file is part of the GNUstep GUI 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. -*/ - -#include -#include -#include -#include "AppKit/NSWindow+Toolbar.h" -#include "AppKit/NSView.h" -#include "AppKit/NSToolbar.h" -#include "GNUstepGUI/GSToolbarView.h" - -#include "NSToolbarFrameworkPrivate.h" - -@implementation NSWindow (Toolbar) - -- (void) runToolbarCustomizationPalette: (id)sender -{ - [[self toolbar] runCustomizationPalette: sender]; -} - -- (void) toggleToolbarShown: (id)sender -{ - NSToolbar *toolbar = [self toolbar]; - BOOL isVisible = [toolbar isVisible]; - - if (!toolbar) - return; - - if (isVisible) - { - [_wv removeToolbarView: [toolbar _toolbarView]]; - } - else - { - [_wv addToolbarView: [toolbar _toolbarView]]; - } - - [toolbar setVisible: !isVisible]; - - [self display]; -} - -// Accessors - -- (NSToolbar *) toolbar -{ - return _toolbar; -} - -- (void) setToolbar: (NSToolbar*)toolbar -{ - if (toolbar == _toolbar) - return; - - if (_toolbar != nil) - { - // We throw the last toolbar out - if ([_toolbar isVisible]) - { - [_wv removeToolbarView: [_toolbar _toolbarView]]; - } - } - - ASSIGN(_toolbar, toolbar); - - if (toolbar != nil) - { - GSToolbarView *toolbarView = [toolbar _toolbarView]; - - if (toolbarView == nil) - { - // Instantiate the toolbar view - toolbarView = [[GSToolbarView alloc] - initWithFrame: - NSMakeRect(0, 0, - [NSWindow contentRectForFrameRect: [self frame] - styleMask: [self styleMask]].size.width, 100)]; - // addToolbarView: method will set the toolbar view to the right - // frame - [toolbarView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin]; - [toolbarView setBorderMask: GSToolbarViewBottomBorder]; - - // Load the toolbar view inside the toolbar - [toolbar _setToolbarView: toolbarView]; - RELEASE(toolbarView); - } - - // Make the toolbar view visible - if ([toolbar isVisible]) - { - [_wv addToolbarView: toolbarView]; - } - } - - // To show the changed toolbar - [self displayIfNeeded]; -} - -@end diff --git a/Source/NSWindow.m b/Source/NSWindow.m index eee7a15f4..764d51a8d 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -74,13 +74,13 @@ #include "AppKit/NSTextFieldCell.h" #include "AppKit/NSView.h" #include "AppKit/NSWindow.h" -#include "AppKit/NSWindow+Toolbar.h" #include "AppKit/NSWindowController.h" #include "AppKit/PSOperators.h" #include "GNUstepGUI/GSTrackingRect.h" #include "GNUstepGUI/GSDisplayServer.h" #include "GSToolTips.h" #include "GSWindowDecorationView.h" +#include "NSToolbarFrameworkPrivate.h" static GSToolTips *toolTipVisible = nil; static id windowDecorator = nil; @@ -5074,6 +5074,73 @@ current key view.
@end +@implementation NSWindow (Toolbar) + +- (void) runToolbarCustomizationPalette: (id)sender +{ + [[self toolbar] runCustomizationPalette: sender]; +} + +- (void) toggleToolbarShown: (id)sender +{ + NSToolbar *toolbar = [self toolbar]; + BOOL isVisible = [toolbar isVisible]; + + if (!toolbar) + return; + + if (isVisible) + { + [_wv removeToolbarView: [toolbar _toolbarView]]; + } + else + { + [_wv addToolbarView: [toolbar _toolbarView]]; + } + + [toolbar setVisible: !isVisible]; + + [self display]; +} + +// Accessors + +- (NSToolbar *) toolbar +{ + return _toolbar; +} + +- (void) setToolbar: (NSToolbar*)toolbar +{ + if (toolbar == _toolbar) + return; + + if (_toolbar != nil) + { + if ([_toolbar isVisible]) + { + // Throw the last toolbar view out + [_wv removeToolbarView: [_toolbar _toolbarView]]; + } + } + + ASSIGN(_toolbar, toolbar); + + if (_toolbar != nil) + { + if ([_toolbar isVisible]) + { + // Make the new toolbar view visible + [_wv addToolbarView: [_toolbar _toolbarView]]; + } + } + + // To show the changed toolbar + [self displayIfNeeded]; +} + +@end + /* * GNUstep backend methods */