diff --git a/ChangeLog b/ChangeLog index abbba0e52..69dbc3cc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-12-30 Fred Kiefer + + * Headers/Additions/GNUstepGUI/GSToolbar.h (-_toolbars): Remove. + * Source/NSWindow+Toolbar.m: Add [GSToolbar _toolbars] declaration + here. + * Source/GSToolbar.m, + * Source/NSToolbar.m: Simplify by adding helper methods and + removing dead code. + * Headers/AppKit/NSToolbarItemGroup.h, + * Source/NSToolbarItemGroup.m: New files. + * Source/GNUmakefile: Add new files. + * Headers/AppKit/NSToolbarItem.h: Add 10.5 methods and constants. + * Source/NSToolbarItem.m: New methods and general rewrite. + 2008-12-29 Richard Frith-Macdonald * Source/GSInfoPanel.m: diff --git a/Headers/Additions/GNUstepGUI/GSToolbar.h b/Headers/Additions/GNUstepGUI/GSToolbar.h index a621b7a2f..93a6ef0df 100644 --- a/Headers/Additions/GNUstepGUI/GSToolbar.h +++ b/Headers/Additions/GNUstepGUI/GSToolbar.h @@ -113,11 +113,6 @@ APPKIT_EXPORT NSString *NSToolbarWillAddItemNotification; - (void) setUsesStandardBackgroundColor: (BOOL)standard; - (NSToolbarSizeMode) sizeMode; - -// Private class method - -+ (NSMutableArray *) _toolbars; - @end /* interface of NSToolbar */ /* @@ -141,11 +136,4 @@ willBeInsertedIntoToolbar: (BOOL)flag; - (NSArray *) toolbarSelectableItemIdentifiers: (GSToolbar *)toolbar; @end - -// Extensions - -@interface NSArray (ObjectsWithValueForKey) -- (NSArray *) objectsWithValue: (id)value forKey: (NSString *)key; -@end - #endif /* _GNUstep_H_NSToolbar */ diff --git a/Headers/AppKit/NSToolbarItem.h b/Headers/AppKit/NSToolbarItem.h index 2ff67b064..09124c36e 100644 --- a/Headers/AppKit/NSToolbarItem.h +++ b/Headers/AppKit/NSToolbarItem.h @@ -57,10 +57,19 @@ APPKIT_EXPORT NSString *NSToolbarShowFontsItemIdentifier; APPKIT_EXPORT NSString *NSToolbarCustomizeToolbarItemIdentifier; APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +enum _NSToolbarItemVisibilityPriority { + NSToolbarItemVisibilityPriorityStandard = 0, + NSToolbarItemVisibilityPriorityLow = -1000, + NSToolbarItemVisibilityPriorityHigh = 1000, + NSToolbarItemVisibilityPriorityUser = 2000 +}; +#endif + @interface NSToolbarItem : NSObject { // externally visible variables - BOOL _allowsDuplicatesInToolbar; + BOOL _autovalidates; NSString *_itemIdentifier; NSString *_label; NSString *_paletteLabel; @@ -68,7 +77,8 @@ APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier; id _view; NSMenuItem *_menuFormRepresentation; NSString *_toolTip; - int _tag; + NSInteger _tag; + NSInteger _visibilityPriority; // toolbar GSToolbar *_toolbar; @@ -86,18 +96,17 @@ APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier; { // gets unsigned int _isEnabled:1; - unsigned int _tag:1; unsigned int _action:1; unsigned int _target:1; unsigned int _image:1; // sets unsigned int _setEnabled:1; - unsigned int _setTag:1; unsigned int _setAction:1; unsigned int _setTarget:1; unsigned int _setImage:1; - // to even out the long. - unsigned int RESERVED:22; + + // to even out the int. + unsigned int RESERVED:24; } _flags; } @@ -117,7 +126,7 @@ APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier; - (NSMenuItem *) menuFormRepresentation; - (NSSize) minSize; - (NSString *) paletteLabel; -- (int) tag; +- (NSInteger) tag; - (id) target; - (NSString *) toolTip; - (GSToolbar *) toolbar; @@ -130,10 +139,16 @@ APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier; - (void) setMenuFormRepresentation: (NSMenuItem *)menuItem; - (void) setMinSize: (NSSize)minSize; - (void) setPaletteLabel: (NSString *)paletteLabel; -- (void) setTag: (int)tag; +- (void) setTag: (NSInteger)tag; - (void) setTarget: (id)target; - (void) setToolTip: (NSString *)toolTip; - (void) setView: (NSView *)view; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (BOOL) autovalidates; +- (void) setAutovalidates: (BOOL)autovalidates; +- (NSInteger) visibilityPriority; +- (void) setVisibilityPriority: (NSInteger)visibilityPriority; +#endif @end /* interface of NSToolbarItem */ @@ -143,6 +158,6 @@ APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier; @end // Extra private stuff -extern NSString *GSMovableToolbarItemPboardType; +APPKIT_EXPORT NSString *GSMovableToolbarItemPboardType; #endif /* _GNUstep_H_NSToolbarItem */ diff --git a/Headers/AppKit/NSToolbarItemGroup.h b/Headers/AppKit/NSToolbarItemGroup.h new file mode 100644 index 000000000..8fd4a4796 --- /dev/null +++ b/Headers/AppKit/NSToolbarItemGroup.h @@ -0,0 +1,50 @@ +/* + NSToolbarItemGroup.h + + The toolbar item group class. + + Copyright (C) 2008 Free Software Foundation, Inc. + + Author: Fred Kiefer + Date: Dec 2008 + + 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_NSToolbarItemGroup +#define _GNUstep_H_NSToolbarItemGroup + +#include + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) + +@class NSArray; + +@interface NSToolbarItemGroup : NSToolbarItem +{ + NSArray *_subitems; +} + +- (void) setSubitems: (NSArray *)items; +- (NSArray *) subitems; + +@end + +#endif +#endif /* _GNUstep_H_NSToolbarItemGroup */ diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 89dcd8e01..0eca85664 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -175,6 +175,7 @@ NSTextTable.m \ NSTextTableBlock.m \ NSToolbar.m \ NSToolbarItem.m \ +NSToolbarItemGroup.m \ NSTokenField.m \ NSTokenFieldCell.m \ NSUserDefaultsController.m \ @@ -371,6 +372,7 @@ NSTextTable.h \ NSTextView.h \ NSToolbar.h \ NSToolbarItem.h \ +NSToolbarItemGroup.h \ NSTokenField.h \ NSTokenFieldCell.h \ NSUserDefaultsController.h \ diff --git a/Source/GSToolbar.m b/Source/GSToolbar.m index 0bfbb4304..59d3ad805 100644 --- a/Source/GSToolbar.m +++ b/Source/GSToolbar.m @@ -64,6 +64,10 @@ static const unsigned int ValidationInterval = 4; static GSValidationCenter *vc = nil; // Extensions +@interface NSArray (ObjectsWithValueForKey) +- (NSArray *) objectsWithValue: (id)value forKey: (NSString *)key; +@end + @implementation NSArray (ObjectsWithValueForKey) - (NSArray *) objectsWithValue: (id)value forKey: (NSString *)key @@ -359,6 +363,11 @@ static GSValidationCenter *vc = nil; [super dealloc]; } +- (GSValidationObject *) validationObjectForWindow: (NSWindow*)w +{ + return [[_vobjs objectsWithValue: w forKey: @"_window"] objectAtIndex: 0]; +} + - (NSArray *) observersWindow: (NSWindow *)window { int i; @@ -377,16 +386,13 @@ static GSValidationCenter *vc = nil; } else { - result = [[[_vobjs objectsWithValue: window forKey: @"_window"] - objectAtIndex: 0] observers]; - return result; + return [[self validationObjectForWindow: window] observers]; } } - (void) addObserver: (id)observer window: (NSWindow *)window { - GSValidationObject *vobj = - [[_vobjs objectsWithValue: window forKey: @"_window"] objectAtIndex: 0]; + GSValidationObject *vobj = [self validationObjectForWindow: window]; NSMutableArray *observersWindow = nil; if (window == nil) @@ -430,7 +436,7 @@ static GSValidationCenter *vc = nil; while ((w = [e nextObject]) != nil) { - vobj = [[_vobjs objectsWithValue: w forKey: @"_window"] objectAtIndex: 0]; + vobj = [self validationObjectForWindow: w]; observersWindow = [vobj observers]; if (observersWindow != nil && [observersWindow containsObject: observer]) @@ -452,8 +458,7 @@ static GSValidationCenter *vc = nil; // NSLog(@"Window will close"); - vobj = [[_vobjs objectsWithValue: [notification object] forKey: @"_window"] - objectAtIndex: 0]; + vobj = [self validationObjectForWindow: [notification object]]; if (vobj != nil) { [vobj clean]; @@ -469,7 +474,8 @@ static GSValidationCenter *vc = nil; // Private class method -+ (NSMutableArray *) _toolbars; ++ (NSArray *) _toolbars; ++ (NSArray *) _toolbarsWithIdentifier: (NSString *)identifier; - (void) _insertItemWithItemIdentifier: (NSString *)itemIdentifier atIndex: (int)index @@ -484,7 +490,6 @@ static GSValidationCenter *vc = nil; - (void) _setAutosavesConfiguration: (BOOL)flag broadcast: (BOOL)broadcast; - (void) _setConfigurationFromDictionary: (NSDictionary *)configDict broadcast: (BOOL)broadcast; -- (void) _setDelegate: (id)delegate broadcast: (BOOL)broadcast; - (void) _moveItemFromIndex: (int)index toIndex: (int)newIndex broadcast: (BOOL)broadcast; // Few other private methods @@ -545,11 +550,17 @@ static GSValidationCenter *vc = nil; // Private class method to access static variable toolbars in subclasses -+ (NSMutableArray *) _toolbars ++ (NSArray *) _toolbars { return toolbars; } ++ (NSArray *) _toolbarsWithIdentifier: (NSString *)identifier +{ + return [toolbars objectsWithValue: identifier + forKey: @"_identifier"]; +} + // Instance methods - (id) initWithIdentifier: (NSString *)identifier @@ -780,18 +791,40 @@ static GSValidationCenter *vc = nil; * -toolbarAllowedItemIdentifiers: and -toolbarDefaultItemIdentifiers: * messages. */ - - (void) setDelegate: (id)delegate { - [self _setDelegate: delegate broadcast: NO]; - //[self _setDelegate: delegate broadcast: YES]; + if (_delegate == delegate) + return; - // Deactivated the delegate synchronization because it can create segmentation - // faults when the application has not been written specially to support it - // which is the case for the Cocoa applications. Moreover it can be - // difficult to understand how it works in detail because it doesn't fit - // exactly with the delegate philosophy. - // Will be made optional later in the case the developers want to use it. + if (_delegate != nil) + [nc removeObserver: _delegate name: nil object: self]; + + // Assign the delegate... + _delegate = delegate; + + if (_delegate != nil) + { + #define CHECK_REQUIRED_METHOD(selector_name) \ + if (![_delegate respondsToSelector: @selector(selector_name)]) \ + [NSException raise: NSInternalInconsistencyException \ + format: @"delegate does not respond to %@",@#selector_name] + + CHECK_REQUIRED_METHOD(toolbar:itemForItemIdentifier: + willBeInsertedIntoToolbar:); + CHECK_REQUIRED_METHOD(toolbarAllowedItemIdentifiers:); + CHECK_REQUIRED_METHOD(toolbarDefaultItemIdentifiers:); + + #define SET_DELEGATE_NOTIFICATION(notif_name) \ + if ([_delegate respondsToSelector: @selector(toolbar##notif_name:)]) \ + [nc addObserver: _delegate \ + selector: @selector(toolbar##notif_name:) \ + name: NSToolbar##notif_name##Notification object: self] + + SET_DELEGATE_NOTIFICATION(DidRemoveItem); + SET_DELEGATE_NOTIFICATION(WillAddItem); + } + + [self _build]; } - (void) setSelectedItemIdentifier: (NSString *)itemIdentifier @@ -874,19 +907,19 @@ static GSValidationCenter *vc = nil; // Private methods +/* + * Toolbar build : + * will use the delegate when there is no toolbar model + */ - (void) _build { - /* - * Toolbar build : - * will use the delegate when there is no toolbar model - */ - GSToolbar *toolbarModel; NSArray *wantedItemIdentifiers; NSEnumerator *e; id itemIdentifier; int i = 0; + // Switch off toolbar view reload _build = YES; RELEASE(_items); @@ -920,6 +953,9 @@ static GSValidationCenter *vc = nil; } _build = NO; + // Now do the toolbar view reload + if (_toolbarView != nil) + [_toolbarView _reload]; } - (int) _indexOfItem: (NSToolbarItem *)item @@ -965,8 +1001,7 @@ static GSValidationCenter *vc = nil; NSArray *linked; id toolbar; - linked = [toolbars objectsWithValue: [self identifier] - forKey: @"_identifier"]; + linked = [isa _toolbarsWithIdentifier: [self identifier]]; if (linked != nil && [linked count] > 0) { @@ -1004,15 +1039,15 @@ static GSValidationCenter *vc = nil; /* * - * The methods below handles the toolbar edition and broacasts each associated + * The methods below handles the toolbar edition and broadcasts each associated * event to the other toolbars with identical identifiers. * Warning : broadcast process only happens between instances based on the same * class. */ #define TRANSMIT(signature) \ - NSEnumerator *e = [[toolbars objectsWithValue: _identifier forKey: \ - @"_identifier"] objectEnumerator]; \ + NSEnumerator *e = [[GSToolbar _toolbarsWithIdentifier: _identifier] \ + objectEnumerator]; \ GSToolbar *toolbar; \ \ while ((toolbar = [e nextObject]) != nil) \ @@ -1140,54 +1175,6 @@ static GSValidationCenter *vc = nil; } } -- (void) _setDelegate: (id)delegate broadcast: (BOOL)broadcast -{ - //if (_delegate) - // [nc removeObserver: _delegate name: nil object: self]; - - if (_delegate == delegate) - return; - - if (_delegate != nil) - [nc removeObserver: _delegate name: nil object: self]; - - // Assign the delegate... - _delegate = delegate; - - if (_delegate != nil) - { - #define CHECK_REQUIRED_METHOD(selector_name) \ - if (![_delegate respondsToSelector: @selector(selector_name)]) \ - [NSException raise: NSInternalInconsistencyException \ - format: @"delegate does not respond to %@",@#selector_name] - - CHECK_REQUIRED_METHOD(toolbar:itemForItemIdentifier: - willBeInsertedIntoToolbar:); - CHECK_REQUIRED_METHOD(toolbarAllowedItemIdentifiers:); - CHECK_REQUIRED_METHOD(toolbarDefaultItemIdentifiers:); - - #define SET_DELEGATE_NOTIFICATION(notif_name) \ - if ([_delegate respondsToSelector: @selector(toolbar##notif_name:)]) \ - [nc addObserver: _delegate \ - selector: @selector(toolbar##notif_name:) \ - name: NSToolbar##notif_name##Notification object: self] - - SET_DELEGATE_NOTIFICATION(DidRemoveItem); - SET_DELEGATE_NOTIFICATION(WillAddItem); - } - - [self _build]; - if (_toolbarView != nil) - [_toolbarView _reload]; - - // Broadcast now... - - if (broadcast) - { - TRANSMIT(_setDelegate: _delegate broadcast: NO); - } -} - - (void) _moveItemFromIndex: (int)index toIndex: (int)newIndex broadcast: (BOOL)broadcast { id item; @@ -1231,31 +1218,6 @@ static GSValidationCenter *vc = nil; // Don't do an ASSIGN here, the toolbar itself retains us. _toolbarView = toolbarView; - if (_toolbarView == nil) - return; - - /* In the case, the user hasn't set a delegate until now, we set it. - * Why ? - * We don't set it before when the toolbar is initialized, to do only one - * toolbar content load. - * ... - * 1 toolbar = [[GSToolbar alloc] initWithIdentifier: @"blabla"]; - * 2 [toolbar setDelegate: myDelegate]; - * In case such method like 1 sets a default delegate for the identifier by - * requesting a toolbar model, a toolbar content load would occur. - * With a method like 2 which follows immediatly : - * Another toolbar load content would occur related to a probably different - * delegate. - */ - //if (_delegate == nil) - //[self _setDelegate: [toolbarModel delegate] broadcast: NO]; - - // Deactivated the delegate synchronization because it can create segmentation - // faults when the application has not been written specially to support it - // which is the case for the Cocoa applications. Moreover it can be - // difficult to understand how it works in detail because it doesn't fit - // exactly with the delegate philosophy. - // Will be made optional later in the case the developers want to use it. } - (GSToolbarView *) _toolbarView diff --git a/Source/NSToolbar.m b/Source/NSToolbar.m index c5e7f77da..036c72cac 100644 --- a/Source/NSToolbar.m +++ b/Source/NSToolbar.m @@ -48,18 +48,18 @@ static NSNotificationCenter *nc = nil; static const int current_version = 1; +@interface GSToolbar (GNUstepPrivate) ++ (NSArray *) _toolbarsWithIdentifier: (NSString *)identifier; +@end @interface NSToolbar (GNUstepPrivate) -+ (NSMutableArray *) _toolbars; - // Private methods with broadcast support - (void) _setDisplayMode: (NSToolbarDisplayMode)displayMode broadcast: (BOOL)broadcast; - (void) _setSizeMode: (NSToolbarSizeMode)sizeMode broadcast: (BOOL)broadcast; - (void) _setVisible: (BOOL)shown broadcast: (BOOL)broadcast; -- (void) _setDelegate: (id)delegate broadcast: (BOOL)broadcast; // Few other private methods - (void) _loadConfig; @@ -185,7 +185,7 @@ static const int current_version = 1; */ #define TRANSMIT(signature) \ - NSEnumerator *e = [[[GSToolbar _toolbars] objectsWithValue: _identifier forKey: @"_identifier"] objectEnumerator]; \ + NSEnumerator *e = [[GSToolbar _toolbarsWithIdentifier: _identifier] objectEnumerator]; \ NSToolbar *toolbar; \ \ while ((toolbar = [e nextObject]) != nil) \ diff --git a/Source/NSToolbarItem.m b/Source/NSToolbarItem.m index 51893b132..33022cb46 100644 --- a/Source/NSToolbarItem.m +++ b/Source/NSToolbarItem.m @@ -31,9 +31,7 @@ #include #include -#include #include -#include #include #include "AppKit/NSApplication.h" #include "AppKit/NSAttributedString.h" @@ -87,7 +85,6 @@ static const int InsetItemTextY = 4; static NSFont *NormalFont = nil; // See NSToolbarItem -initialize method // [NSFont smallSystemFontSize] or better should be NSControlContentFontSize - static NSFont *SmallFont = nil; NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @@ -102,6 +99,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @interface NSToolbarItem (GNUstepPrivate) - (void) _layout; // --- +- (void) _computeFlags; - (NSView *) _backView; - (NSMenuItem *) _defaultMenuFormRepresentation; - (BOOL) _isFlexibleSpace; @@ -162,17 +160,19 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; { // Don't do an ASSIGN here, the toolbar item itself retains us. _toolbarItem = toolbarItem; - - //[self setCell: [[GSToolbarButtonCell alloc] init]]; - } - return self; -} -- (void) dealloc -{ - // Nothing to do currently - - [super dealloc]; + [self setTitle: @""]; + [self setEnabled: NO]; + [_cell setBezeled: YES]; + [self setImagePosition: NSImageAbove]; + [self setHighlightsBy: + NSChangeGrayCellMask | NSChangeBackgroundCellMask]; + [self setFont: [NSFont systemFontOfSize: 11]]; + /* [NSFont smallSystemFontSize] or better should be + controlContentFontSize. */ + } + + return self; } - (void) layout @@ -214,7 +214,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; ; // Invalid } - [[self cell] setFont: font]; + [self setFont: font]; // Adjust the layout in accordance with the border @@ -283,45 +283,45 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; if ([event modifierFlags] == NSCommandKeyMask && [toolbar allowsUserCustomization]) { - NSSize viewSize = [self frame].size; - NSImage *image = [[NSImage alloc] initWithSize: viewSize]; - NSCell *cell = [self cell]; - NSPasteboard *pboard; - int index; + NSSize viewSize = [self frame].size; + NSImage *image = [[NSImage alloc] initWithSize: viewSize]; + NSCell *cell = [self cell]; + NSPasteboard *pboard; + int index; - AUTORELEASE(image); - - // Prepare the drag + AUTORELEASE(image); + + // Prepare the drag + + RETAIN(self); + /* We need to keep this view (aka self) to be able to draw the drag + image. */ + + // Draw the drag content in an image + + /* The code below is only partially supported by GNUstep, then NSImage + needs to be improved. */ + [image lockFocus]; + [cell setShowsFirstResponder: NO]; // To remove the dotted rect + [cell drawWithFrame: + NSMakeRect(0, 0, viewSize.width, viewSize.height) inView: nil]; + [cell setShowsFirstResponder: YES]; + [image unlockFocus]; + + pboard = [NSPasteboard pasteboardWithName: NSDragPboard]; + [pboard declareTypes: [NSArray arrayWithObject: GSMovableToolbarItemPboardType] + owner: nil]; + index = [toolbar _indexOfItem: _toolbarItem]; + [pboard setString: [NSString stringWithFormat:@"%d", index] + forType: GSMovableToolbarItemPboardType]; - RETAIN(self); - /* We need to keep this view (aka self) to be able to draw the drag - image. */ - - // Draw the drag content in an image - - /* The code below is only partially supported by GNUstep, then NSImage - needs to be improved. */ - [image lockFocus]; - [cell setShowsFirstResponder: NO]; // To remove the dotted rect - [cell drawWithFrame: - NSMakeRect(0, 0, viewSize.width, viewSize.height) inView: nil]; - [cell setShowsFirstResponder: YES]; - [image unlockFocus]; - - pboard = [NSPasteboard pasteboardWithName: NSDragPboard]; - [pboard declareTypes: [NSArray arrayWithObject: GSMovableToolbarItemPboardType] - owner: nil]; - index = [toolbar _indexOfItem: _toolbarItem]; - [pboard setString: [NSString stringWithFormat:@"%d", index] - forType: GSMovableToolbarItemPboardType]; - - [self dragImage: image - at: NSMakePoint(0.0, 0.0) - offset: NSMakeSize(0.0, 0.0) - event: event - pasteboard: pboard - source: self - slideBack: NO]; + [self dragImage: image + at: NSMakePoint(0.0, 0.0) + offset: NSMakeSize(0.0, 0.0) + event: event + pasteboard: pboard + source: self + slideBack: NO]; } else if ([event modifierFlags] != NSCommandKeyMask) { @@ -333,6 +333,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; { GSToolbar *toolbar = [_toolbarItem toolbar]; + // FIXME: Where is this released? RETAIN(_toolbarItem); /* We retain the toolbar item to be able to have have it reinsered later by the dragging destination. */ @@ -381,7 +382,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; return _toolbarItem; } -- (void) setToolbarItemAction: (SEL) action +// FIXME: Why use this and not the action of the cell? +- (void) setToolbarItemAction: (SEL)action { _toolbarItemAction = action; } @@ -393,7 +395,6 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @end -// FIXME: Why does this class exists at all? @implementation GSToolbarButtonCell /* Overriden NSButtonCell method to handle cell type in a basic way which avoids @@ -513,6 +514,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (id) initWithToolbarItem: (NSToolbarItem *)toolbarItem; - (NSToolbarItem *) toolbarItem; +- (void) layout; - (BOOL) enabled; - (void) setEnabled: (BOOL)enabled; @end @@ -534,18 +536,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; return self; } -- (void) dealloc -{ - /* _font is pointing on a static variable then we do own it and don't need - to release it. */ - - [super dealloc]; -} - - (void) drawRect: (NSRect)rect { - [super drawRect: rect]; // We draw _view which is a subview - if (_showLabel) { NSAttributedString *attrString; @@ -738,8 +730,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; * The code below should be kept in sync with GSToolbarButton methods which * have identical names. */ - - + - (void) mouseDown: (NSEvent *)event { GSToolbar *toolbar = [_toolbarItem toolbar]; @@ -863,6 +854,9 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; NSImage *image = [NSImage imageNamed: @"common_ToolbarSeparatorItem"]; self = [super initWithItemIdentifier: itemIdentifier]; + if (!self) + return nil; + [(NSButton *)[self _backView] setImagePosition: NSImageOnly]; [(NSButton *)[self _backView] setImage: image]; /* We bypass the toolbar item accessor to set the image in order to have it @@ -941,6 +935,12 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; // Override the default implementation in order to reset the _backView to a zero width } + +- (BOOL) _isFlexibleSpace +{ + return YES; +} + @end // ---- NSToolbarShowColorsItemIdentifier @@ -952,11 +952,9 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @implementation GSToolbarShowColorsItem - (id) initWithItemIdentifier: (NSString *)itemIdentifier { - NSImage *image = [NSImage imageNamed: @"common_ToolbarShowColorsItem"]; - self = [super initWithItemIdentifier: itemIdentifier]; - [self setImage: image]; - [self setLabel: @"Colors"]; // FIX ME: localize + [self setImage: [NSImage imageNamed: @"common_ToolbarShowColorsItem"]]; + [self setLabel: _(@"Colors")]; // Set action... [self setTarget: nil]; // Goes to first responder.. @@ -975,11 +973,9 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @implementation GSToolbarShowFontsItem - (id) initWithItemIdentifier: (NSString *)itemIdentifier { - NSImage *image = [NSImage imageNamed: @"common_ToolbarShowFontsItem"]; - self = [super initWithItemIdentifier: itemIdentifier]; - [self setImage: image]; - [self setLabel: @"Fonts"]; // FIX ME: localize + [self setImage: [NSImage imageNamed: @"common_ToolbarShowFontsItem"]]; + [self setLabel: _(@"Fonts")]; // Set action... [self setTarget: nil]; // Goes to first responder.. @@ -998,11 +994,9 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @implementation GSToolbarCustomizeToolbarItem - (id) initWithItemIdentifier: (NSString *)itemIdentifier { - NSImage *image = [NSImage imageNamed: @"common_ToolbarCustomizeToolbarItem"]; - self = [super initWithItemIdentifier: itemIdentifier]; - [self setImage: image]; - [self setLabel: @"Customize"]; // FIX ME: localize + [self setImage: [NSImage imageNamed: @"common_ToolbarCustomizeToolbarItem"]]; + [self setLabel: _(@"Customize")]; // Set action... [self setTarget: nil]; // Goes to first responder.. @@ -1021,15 +1015,13 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @implementation GSToolbarPrintItem - (id) initWithItemIdentifier: (NSString *)itemIdentifier { - NSImage *image = [NSImage imageNamed: @"common_Printer"]; - self = [super initWithItemIdentifier: itemIdentifier]; - [self setImage: image]; - [self setLabel: @"Print..."]; // FIX ME: localize + [self setImage: [NSImage imageNamed: @"common_Printer"]]; + [self setLabel: _(@"Print...")]; // Set action... [self setTarget: nil]; // goes to first responder.. - [self setAction: @selector(print:)]; + [self setAction: @selector(printDocument:)]; return self; } @@ -1037,6 +1029,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; @implementation NSToolbarItem + + (void) initialize { NormalFont = RETAIN([NSFont systemFontOfSize: 11]); @@ -1047,114 +1040,76 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (id) initWithItemIdentifier: (NSString *)itemIdentifier { - GSToolbarButton *button; - NSButtonCell *cell; - - if ((self = [super init]) != nil) - { - - // GNUstep predefined toolbar items - - if ([itemIdentifier isEqualToString: @"NSToolbarSeparatorItemIdentifier"] - && [self isKindOfClass:[GSToolbarSeparatorItem class]] == NO) + // GNUstep predefined toolbar items + if ([itemIdentifier isEqualToString: NSToolbarSeparatorItemIdentifier] + && [self isKindOfClass: [GSToolbarSeparatorItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarSeparatorItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else if ([itemIdentifier isEqualToString: NSToolbarSpaceItemIdentifier] + && [self isKindOfClass: [GSToolbarSpaceItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarSpaceItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else if ([itemIdentifier + isEqualToString: NSToolbarFlexibleSpaceItemIdentifier] + && [self isKindOfClass: [GSToolbarFlexibleSpaceItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarFlexibleSpaceItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else if ([itemIdentifier + isEqualToString: NSToolbarShowColorsItemIdentifier] + && [self isKindOfClass: [GSToolbarShowColorsItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarShowColorsItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else if ([itemIdentifier + isEqualToString: NSToolbarShowFontsItemIdentifier] + && [self isKindOfClass: [GSToolbarShowFontsItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarShowFontsItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else if ([itemIdentifier + isEqualToString: NSToolbarCustomizeToolbarItemIdentifier] + && [self isKindOfClass: [GSToolbarCustomizeToolbarItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarCustomizeToolbarItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else if ([itemIdentifier isEqualToString: NSToolbarPrintItemIdentifier] + && [self isKindOfClass: [GSToolbarPrintItem class]] == NO) + { + RELEASE(self); + return [[GSToolbarPrintItem alloc] + initWithItemIdentifier: itemIdentifier]; + } + else + { + if ((self = [super init]) != nil) { - [self release]; - self = [[GSToolbarSeparatorItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - else if ([itemIdentifier isEqualToString: @"NSToolbarSpaceItemIdentifier"] - && [self isKindOfClass:[GSToolbarSpaceItem class]] == NO) - { - [self release]; - self = [[GSToolbarSpaceItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - else if ([itemIdentifier - isEqualToString: @"NSToolbarFlexibleSpaceItemIdentifier"] - && [self isKindOfClass:[GSToolbarFlexibleSpaceItem class]] == NO) - { - [self release]; - self = [[GSToolbarFlexibleSpaceItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - else if ([itemIdentifier - isEqualToString: @"NSToolbarShowColorsItemIdentifier"] - && [self isKindOfClass:[GSToolbarShowColorsItem class]] == NO) - { - [self release]; - self = [[GSToolbarShowColorsItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - else if ([itemIdentifier - isEqualToString: @"NSToolbarShowFontsItemIdentifier"] - && [self isKindOfClass:[GSToolbarShowFontsItem class]] == NO) - { - [self release]; - self = [[GSToolbarShowFontsItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - else if ([itemIdentifier - isEqualToString: @"NSToolbarCustomizeToolbarItemIdentifier"] - && [self isKindOfClass:[GSToolbarCustomizeToolbarItem class]] == NO) - { - [self release]; - self = [[GSToolbarCustomizeToolbarItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - else if ([itemIdentifier isEqualToString: @"NSToolbarPrintItemIdentifier"] - && [self isKindOfClass:[GSToolbarPrintItem class]] == NO) - { - [self release]; - self = [[GSToolbarPrintItem alloc] - initWithItemIdentifier: itemIdentifier]; - } - - // Normal toolbar items - else - { - + // Normal toolbar items + ASSIGN(_itemIdentifier, itemIdentifier); - - button = [[GSToolbarButton alloc] initWithToolbarItem: self]; - cell = [button cell]; - [button setTitle: @""]; - [button setEnabled: NO]; - [button setBordered: NO]; - [button setImagePosition: NSImageAbove]; - [cell setBezeled: YES]; - [cell setHighlightsBy: - NSChangeGrayCellMask | NSChangeBackgroundCellMask]; - [cell setFont: [NSFont systemFontOfSize: 11]]; - /* [NSFont smallSystemFontSize] or better should be - controlContentFontSize. */ + [self setAutovalidates: YES]; - [_backView release]; - _backView = button; - } - - // gets - _flags._isEnabled = [_backView respondsToSelector: @selector(isEnabled)]; - _flags._tag = YES; - _flags._action = - [_backView respondsToSelector: @selector(toolbarItemAction)]; - _flags._target = [_backView respondsToSelector: @selector(target)]; - _flags._image = [_backView respondsToSelector: @selector(image)]; - // sets - _flags._setEnabled = - [_backView respondsToSelector: @selector(setEnabled:)]; - _flags._setTag = YES; - _flags._setAction = - [_backView respondsToSelector: @selector(setToolbarItemAction:)]; - _flags._setTarget = - [_backView respondsToSelector: @selector(setTarget:)]; - _flags._setImage = [_backView respondsToSelector: @selector(setImage:)]; - + // Set the backview to an GSToolbarButton, will get reset to a + // GSToolbarBackView when setView: gets called. + RELEASE(_backView); + _backView = [[GSToolbarButton alloc] initWithToolbarItem: self]; + + [self _computeFlags]; + } } return self; @@ -1168,7 +1123,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; RELEASE(_menuFormRepresentation); RELEASE(_paletteLabel); RELEASE(_toolTip); - RELEASE(_view); + TEST_RELEASE(_view); RELEASE(_backView); [super dealloc]; @@ -1176,14 +1131,17 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (BOOL) allowsDuplicatesInToolbar { - return _allowsDuplicatesInToolbar; + return NO; } - (BOOL) isEnabled { if (_flags._isEnabled) { - return [(id)_backView isEnabled]; + if (_view) + return [_view isEnabled]; + else + return [(GSToolbarButton*)_backView isEnabled]; } return NO; } @@ -1192,10 +1150,13 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; { if (_flags._image) { - return _image; + if (_view) + return [_view image]; + else + return [(GSToolbarButton*)_backView image]; } - - return nil; + + return _image; } - (NSString *) itemIdentifier @@ -1205,17 +1166,16 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (NSString *) label { - NSMenuItem *menuItem = [self menuFormRepresentation]; - - if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly - && menuItem != nil) + // FIXME: I think this is not needed + if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly) { - return [menuItem title]; - } - else - { - return _label; + NSMenuItem *menuItem = [self menuFormRepresentation]; + + if (menuItem != nil) + return [menuItem title]; } + + return _label; } - (NSSize) maxSize @@ -1242,37 +1202,46 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; { if (_flags._setAction) { - if ([_backView isKindOfClass: [GSToolbarButton class]]) + if (_view) + [_view setAction: action]; + else [(GSToolbarButton *)_backView setToolbarItemAction: action]; - if (action != NULL) - { - [self setEnabled: YES]; - } - else - { - [self setEnabled: NO]; - } + if (action != NULL) + { + [self setEnabled: YES]; + } + else + { + [self setEnabled: NO]; + } } } - (void) setEnabled: (BOOL)enabled { if (_flags._setEnabled) - [(id)_backView setEnabled: enabled]; + { + if (_view) + [_view setEnabled: enabled]; + else + [(GSToolbarButton*)_backView setEnabled: enabled]; + } } - (void) setImage: (NSImage *)image { + ASSIGN(_image, image); + + [_image setScalesWhenResized: YES]; + //[_image setSize: NSMakeSize(32, 32)]; + if (_flags._setImage) - { - ASSIGN(_image, image); - - [_image setScalesWhenResized: YES]; - //[_image setSize: NSMakeSize(32, 32)]; - - if ([_backView isKindOfClass: [NSButton class]]) - [(NSButton *)_backView setImage: _image]; + { + if (_view) + [_view setImage: image]; + else + [(GSToolbarButton*)_backView setImage: image]; } } @@ -1280,8 +1249,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; { ASSIGN(_label, label); - if ([_backView isKindOfClass: [NSButton class]]) - [(NSButton *)_backView setTitle:_label]; + if ([_backView isKindOfClass: [GSToolbarButton class]]) + [(GSToolbarButton *)_backView setTitle: _label]; _modified = YES; if (_toolbar != nil) @@ -1308,19 +1277,20 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; ASSIGN(_paletteLabel, paletteLabel); } -- (void) setTag: (int)tag +- (void) setTag: (NSInteger)tag { - if (_flags._tag) - _tag = tag; + _tag = tag; } - (void) setTarget: (id)target { - if (_flags._target) - { - if ([_backView isKindOfClass: [NSButton class]]) - [(NSButton *)_backView setTarget: target]; - } + if (_flags._setTarget) + { + if (_view) + [_view setTarget: target]; + else + [(NSButton *)_backView setTarget: target]; + } } - (void) setToolTip: (NSString *)toolTip @@ -1331,8 +1301,29 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (void) setView: (NSView *)view { + if (_view == view) + return; + ASSIGN(_view, view); - + + if (view) + { + [_view setToolTip: _toolTip]; + + RELEASE(_backView); + _backView = [[GSToolbarBackView alloc] initWithToolbarItem: self]; + } + else + { + RELEASE(_backView); + _backView = [[GSToolbarButton alloc] initWithToolbarItem: self]; + } + + [self _computeFlags]; +} + +- (void) _computeFlags +{ if (_view == nil) { // gets @@ -1340,7 +1331,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; _flags._action = [_backView respondsToSelector: @selector(toolbarItemAction)]; _flags._target = [_backView respondsToSelector: @selector(target)]; - _flags._image = [_backView respondsToSelector: @selector(image)]; + _flags._image = NO; // sets _flags._setEnabled = [_backView respondsToSelector: @selector(setEnabled:)]; @@ -1356,25 +1347,18 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; _flags._isEnabled = [_view respondsToSelector: @selector(isEnabled)]; _flags._action = [_view respondsToSelector: @selector(action)]; _flags._target = [_view respondsToSelector: @selector(target)]; - _flags._image = [_backView respondsToSelector: @selector(image)]; + _flags._image = [_view respondsToSelector: @selector(image)]; // sets _flags._setEnabled = [_view respondsToSelector: @selector(setEnabled:)]; _flags._setAction = [_view respondsToSelector: @selector(setAction:)]; _flags._setTarget = [_view respondsToSelector: @selector(setTarget:)]; - _flags._setImage = [_backView respondsToSelector: @selector(setImage:)]; - [_view setToolTip: _toolTip]; + _flags._setImage = [_view respondsToSelector: @selector(setImage:)]; } - - [_backView release]; - _backView = [[GSToolbarBackView alloc] initWithToolbarItem: self]; } -- (int) tag +- (NSInteger) tag { - if (_flags._tag) - return _tag; - - return 0; + return _tag; } - (NSString *) toolTip @@ -1393,7 +1377,11 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; "standard" items are correct. */ NSMenuItem *menuItem = [self menuFormRepresentation]; id target = [self target]; - + + // No validation for custom views + if (_view) + return; + if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly && menuItem != nil) { @@ -1446,7 +1434,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (BOOL) _isFlexibleSpace { - return [self isKindOfClass: [GSToolbarFlexibleSpaceItem class]]; + return NO; } - (BOOL) _selectable @@ -1466,18 +1454,12 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; - (void) _setSelected: (BOOL)selected { - if (_selectable && [self _selected] == NO && selected) + if (_selectable) { - // FIXME: This is a hack to break a recursion. - // I think the code here is at fault. FK - //[(GSToolbarButton *)_backView performClick:self]; - [(GSToolbarButton *)_backView setState: YES]; + if ([self _selected] != selected) + [(GSToolbarButton *)_backView setState: selected]; } - else if (selected == NO) - { - [(GSToolbarButton *)_backView setState: NO]; - } - else if (_selectable == NO) + else { NSLog(@"The toolbar item %@ is not selectable", self); } @@ -1502,12 +1484,34 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; _toolbar = toolbar; } +- (BOOL) autovalidates +{ + return _autovalidates; +} + +- (void) setAutovalidates: (BOOL)autovalidates +{ + _autovalidates = autovalidates; +} + +- (NSInteger) visibilityPriority +{ + return _visibilityPriority; +} + +- (void) setVisibilityPriority: (NSInteger)visibilityPriority +{ + _visibilityPriority = visibilityPriority; +} + // NSValidatedUserInterfaceItem protocol - (SEL) action { if (_flags._action) { - if ([_backView isKindOfClass: [GSToolbarButton class]]) + if (_view) + return [_view action]; + else return [(GSToolbarButton *)_backView toolbarItemAction]; } return 0; @@ -1517,8 +1521,10 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; { if (_flags._target) { - if ([_backView isKindOfClass: [NSButton class]]) - return [(NSButton *)_backView target]; + if (_view) + return [_view target]; + else + return [(GSToolbarButton *)_backView target]; } return nil; @@ -1539,8 +1545,13 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType"; [new setImage: [[self image] copyWithZone: zone]]; [new setEnabled: [self isEnabled]]; [new setPaletteLabel: [[self paletteLabel] copyWithZone: zone]]; - [new setMinSize: NSMakeSize(_minSize.width, _minSize.height)]; - [new setMaxSize: NSMakeSize(_maxSize.width, _maxSize.height)]; + [new setLabel: [[self label] copyWithZone: zone]]; + [new setMinSize: [self minSize]]; + [new setMaxSize: [self maxSize]]; + [new setAutovalidates: [self autovalidates]]; + [new setVisibilityPriority: [self visibilityPriority]]; + [new setMenuFormRepresentation: [[self menuFormRepresentation] + copyWithZone: zone]]; return new; } diff --git a/Source/NSToolbarItemGroup.m b/Source/NSToolbarItemGroup.m new file mode 100644 index 000000000..6f04f3186 --- /dev/null +++ b/Source/NSToolbarItemGroup.m @@ -0,0 +1,64 @@ +/* + NSToolbarItemGroup.h + + The toolbar item group class. + + Copyright (C) 2008 Free Software Foundation, Inc. + + Author: Fred Kiefer + Date: Dec 2008 + + 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 "AppKit/NSToolbarItemGroup.h" + +@implementation NSToolbarItemGroup +// FIXME: Most of the implementation is missing. + +- (void) setSubitems: (NSArray *)items +{ + ASSIGN(_subitems, items); +} + +- (NSArray *) subitems +{ + return _subitems; +} + +- (void) dealloc +{ + RELEASE(_subitems); + + [super dealloc]; +} + +// NSCopying protocol +- (id) copyWithZone: (NSZone *)zone +{ + NSToolbarItemGroup *new = (NSToolbarItemGroup *)[super copyWithZone: zone]; + + [new setSubitems: [self subitems]]; + + return new; +} + +@end + diff --git a/Source/NSWindow+Toolbar.m b/Source/NSWindow+Toolbar.m index 3871bfd49..2a9cf9507 100644 --- a/Source/NSWindow+Toolbar.m +++ b/Source/NSWindow+Toolbar.m @@ -34,6 +34,9 @@ #include "AppKit/NSToolbar.h" #include "GNUstepGUI/GSToolbarView.h" +@interface GSToolbar (GNUstepPrivate) ++ (NSArray *) _toolbars; +@end @interface NSToolbar (GNUstepPrivate) - (GSToolbarView *) _toolbarView;