mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-24 06:28:54 +00:00
Fixed the toolbar bug #11393
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20503 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2f2183fca1
commit
f43c0326c6
3 changed files with 320 additions and 220 deletions
46
ChangeLog
46
ChangeLog
|
@ -1,29 +1,37 @@
|
|||
2004-12-28 12:04 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
2004-12-30 Quentin Mathe <qmathe@club-internet.fr>
|
||||
|
||||
* Source/NSWindow.m: Correction for bug#11409.
|
||||
* Source/GSToolbarView.m: Modified to be more compliant with GNUstep
|
||||
coding standards.
|
||||
(-draggingEntered:):
|
||||
(-draggingUpdated:): Prevents the user to customize the toolbar when
|
||||
-allowsUserCustomization returns NO (bug #11393).
|
||||
* Source/NSToolbarItem.m: Modified to be more compliant with GNUstep
|
||||
coding standards.
|
||||
(-mouseDown:): Prevents the user to customize the toolbar when
|
||||
-allowsUserCustomization returns NO (bug #11393).
|
||||
|
||||
2004-12-23 05:38 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Images/MagnifyGlass.tiff: Added. The NSColorPanel class uses
|
||||
this image.
|
||||
* Images/MagnifyGlass.tiff: Added. The NSColorPanel class uses
|
||||
this image.
|
||||
|
||||
2004-12-13 Quentin Mathe <qmathe@club-internet.fr>
|
||||
|
||||
* Source/NSComboBoxCell.m: Modified the code to be clearer
|
||||
Renamed internal class GSFirstMouseTableView to GSComboBoxTableView
|
||||
Removed GSComboWindow _localSelection ivar which is not needed, because
|
||||
the user selection is now handled in -clickItem and not in
|
||||
-tableViewSelectionDidChange: which is now reserved to the internal (aka
|
||||
local) selection support.
|
||||
(-[GSComboWindow selectItem:]) Renamed the method name to -clickItem:
|
||||
(-[GSComboWindow clickItem:]): Reworked to the method to be used by the
|
||||
NSTableView (or NSBrowser) action to track the user clicks.
|
||||
(-[GSComboWindow validateSelection:]): Rewritten the method to handle
|
||||
itself the selection, the method updates now the cell object value and
|
||||
sends the action bound to the cell.
|
||||
(-selectItemAtIndex:): Updated the method to match the Cocoa
|
||||
specification which states that this method should adjust the selection
|
||||
in the combo box list but not simulate a user click.
|
||||
* Source/NSComboBoxCell.m: Modified the code to be clearer
|
||||
Renamed internal class GSFirstMouseTableView to GSComboBoxTableView
|
||||
Removed GSComboWindow _localSelection ivar which is not needed, because
|
||||
the user selection is now handled in -clickItem and not in
|
||||
-tableViewSelectionDidChange: which is now reserved to the internal (aka
|
||||
local) selection support.
|
||||
(-[GSComboWindow selectItem:]): Renamed the method name to -clickItem:
|
||||
(-[GSComboWindow clickItem:]): Reworked to the method to be used by the
|
||||
NSTableView (or NSBrowser) action to track the user clicks.
|
||||
(-[GSComboWindow validateSelection:]): Rewritten the method to handle
|
||||
itself the selection, the method updates now the cell object value and
|
||||
sends the action bound to the cell.
|
||||
(-selectItemAtIndex:): Updated the method to match the Cocoa
|
||||
specification which states that this method should adjust the selection
|
||||
in the combo box list but not simulate a user click.
|
||||
|
||||
2004-12-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ typedef enum {
|
|||
|
||||
static const int ClippedItemsViewWidth = 28;
|
||||
|
||||
// internal
|
||||
// Internal
|
||||
static const int current_version = 1;
|
||||
static NSColorList *SystemExtensionsColors;
|
||||
static NSColor *StandardBackgroundColor;
|
||||
|
@ -76,30 +76,32 @@ static void initSystemExtensionsColors(void)
|
|||
NSColor *toolbarBorderColor;
|
||||
NSDictionary *colors;
|
||||
|
||||
// Set up a dictionary containing the names of all the system extensions
|
||||
// colors as keys and with colors in string format as values.
|
||||
/* Set up a dictionary containing the names of all the system extensions
|
||||
colors as keys and with colors in string format as values. */
|
||||
toolbarBorderColor = [NSColor colorWithCalibratedRed: 0.5
|
||||
green: 0.5
|
||||
blue: 0.5
|
||||
alpha: 1.0];
|
||||
toolbarBackgroundColor = [NSColor clearColor]; // window background color by tranparency
|
||||
|
||||
// Window background color by tranparency
|
||||
toolbarBackgroundColor = [NSColor clearColor];
|
||||
|
||||
// Window backgound color hardcoded
|
||||
/* toolbarBackgroundColor = [NSColor colorWithCalibratedRed: 0.8
|
||||
green: 0.8
|
||||
blue: 0.8
|
||||
alpha: 1.0]; */
|
||||
colors = [[NSDictionary alloc]
|
||||
initWithObjectsAndKeys: toolbarBackgroundColor,
|
||||
@"toolbarBackgroundColor",
|
||||
toolbarBorderColor,
|
||||
@"toolbarBorderColor",
|
||||
nil];
|
||||
|
||||
colors = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
toolbarBackgroundColor, @"toolbarBackgroundColor",toolbarBorderColor,
|
||||
@"toolbarBorderColor", nil];
|
||||
|
||||
SystemExtensionsColors = [NSColorList colorListNamed: @"System extensions"];
|
||||
if (SystemExtensionsColors == nil)
|
||||
{
|
||||
SystemExtensionsColors = [[NSColorList alloc] initWithName: @"System extensions"];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
NSEnumerator *e;
|
||||
NSString *colorKey;
|
||||
|
@ -202,9 +204,8 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
// Accessors
|
||||
- (NSMenu *) returnMenu;
|
||||
|
||||
// This method cannot be called "menu" otherwise it would override NSResponder
|
||||
// method with the same name.
|
||||
/* This method cannot be called "menu" otherwise it would override NSResponder
|
||||
method with the same name. */
|
||||
|
||||
- (void) layout;
|
||||
- (void) setToolbar: (GSToolbar *)toolbar;
|
||||
|
@ -221,9 +222,10 @@ static void initSystemExtensionsColors(void)
|
|||
- (id) init
|
||||
{
|
||||
NSImage *image = [NSImage imageNamed: @"common_ToolbarClippedItemsMark"];
|
||||
NSRect dummyRect = NSMakeRect(0, 0, ClippedItemsViewWidth, 100);
|
||||
// The correct height will be set by the layout method
|
||||
|
||||
if ((self = [super initWithFrame: NSMakeRect(0, 0, ClippedItemsViewWidth,
|
||||
100)]) != nil) // The correct height will be set by the layout method
|
||||
if ((self = [super initWithFrame: dummyRect]) != nil)
|
||||
{
|
||||
[self setBordered: NO];
|
||||
[[self cell] setHighlightsBy: NSChangeGrayCellMask
|
||||
|
@ -238,14 +240,20 @@ static void initSystemExtensionsColors(void)
|
|||
return nil;
|
||||
}
|
||||
|
||||
// Not really used, it is here to be used by the developer who want to adjust
|
||||
// easily a toolbar view attached to a toolbar which is not bind to a window
|
||||
- (void) layout {
|
||||
[self setFrameSize: NSMakeSize([self frame].size.width,
|
||||
[[_toolbar _toolbarView] _heightFromLayout])];
|
||||
/*
|
||||
* Not really used, it is here to be used by the developer who want to adjust
|
||||
* easily a toolbar view attached to a toolbar which is not bind to a window.
|
||||
*/
|
||||
- (void) layout
|
||||
{
|
||||
NSSize layoutSize = NSMakeSize([self frame].size.width,
|
||||
[[_toolbar _toolbarView] _heightFromLayout]);
|
||||
|
||||
[self setFrameSize: layoutSize];
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent *)event {
|
||||
- (void) mouseDown: (NSEvent *)event
|
||||
{
|
||||
NSMenu *clippedItemsMenu = [self menuForEvent: event];
|
||||
|
||||
[super highlight: YES];
|
||||
|
@ -259,18 +267,20 @@ static void initSystemExtensionsColors(void)
|
|||
[super highlight: NO];
|
||||
}
|
||||
|
||||
- (NSMenu *) menuForEvent: (NSEvent *)event {
|
||||
- (NSMenu *) menuForEvent: (NSEvent *)event
|
||||
{
|
||||
if ([event type] == NSLeftMouseDown)
|
||||
{
|
||||
return [self returnMenu];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSMenu *) returnMenu
|
||||
{
|
||||
// This method cannot be called "menu" otherwise it would
|
||||
// override NSResponder method with the same name
|
||||
/* This method cannot be called "menu" otherwise it would
|
||||
override NSResponder method with the same name. */
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle: @""];
|
||||
NSEnumerator *e;
|
||||
id item;
|
||||
|
@ -326,9 +336,10 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
initSystemExtensionsColors();
|
||||
StandardBackgroundColor =
|
||||
RETAIN([NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 0.8 alpha: 1.0]);
|
||||
// Never released, but that's not a problem because the variable is static and then will be
|
||||
// deallocated with the class when the application quits.
|
||||
[NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 0.8 alpha: 1.0];
|
||||
RETAIN(StandardBackgroundColor);
|
||||
/* Never released, but that's not a problem because the variable is static and
|
||||
then will be deallocated with the class when the application quits. */
|
||||
}
|
||||
|
||||
- (id) initWithFrame: (NSRect)frame
|
||||
|
@ -344,7 +355,6 @@ static void initSystemExtensionsColors(void)
|
|||
{
|
||||
if ((self = [super initWithFrame: frame]) != nil)
|
||||
{
|
||||
|
||||
_displayMode = displayMode;
|
||||
_sizeMode = sizeMode;
|
||||
|
||||
|
@ -364,35 +374,39 @@ static void initSystemExtensionsColors(void)
|
|||
_heightFromLayout = 0;
|
||||
}
|
||||
|
||||
[self setFrame: NSMakeRect(frame.origin.x,
|
||||
frame.origin.y,
|
||||
frame.size.width,
|
||||
_heightFromLayout)];
|
||||
[self setFrame: NSMakeRect(frame.origin.x, frame.origin.y,
|
||||
frame.size.width, _heightFromLayout)];
|
||||
|
||||
// ---
|
||||
|
||||
_clipView = [[GSToolbarClipView alloc] initWithFrame: NSMakeRect(0, 0, 100, 100)];
|
||||
_clipView =
|
||||
[[GSToolbarClipView alloc] initWithFrame: NSMakeRect(0, 0, 100, 100)];
|
||||
|
||||
[_clipView setAutoresizingMask: (NSViewWidthSizable |
|
||||
NSViewHeightSizable)];
|
||||
|
||||
[self setBorderMask: GSToolbarViewTopBorder | GSToolbarViewBottomBorder
|
||||
| GSToolbarViewRightBorder | GSToolbarViewLeftBorder]; // Adjust the clip view frame
|
||||
| GSToolbarViewRightBorder | GSToolbarViewLeftBorder];
|
||||
// Adjust the clip view frame
|
||||
|
||||
[self addSubview: _clipView];
|
||||
|
||||
_clippedItemsMark = [[GSToolbarClippedItemsButton alloc] init];
|
||||
|
||||
BackgroundColor = [SystemExtensionsColors colorWithKey: @"toolbarBackgroundColor"];
|
||||
BorderColor = [SystemExtensionsColors colorWithKey: @"toolbarBorderColor"];
|
||||
BackgroundColor =
|
||||
[SystemExtensionsColors colorWithKey: @"toolbarBackgroundColor"];
|
||||
BorderColor =
|
||||
[SystemExtensionsColors colorWithKey: @"toolbarBorderColor"];
|
||||
RETAIN(BackgroundColor);
|
||||
RETAIN(BorderColor);
|
||||
// Never released, but that's not a problem because the variables are static and then will be
|
||||
// deallocated with the class when the application quits.
|
||||
/* Never released, but that's not a problem because the variables are
|
||||
static and then will be deallocated with the class when the application
|
||||
quits. */
|
||||
|
||||
// ---
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObject: GSMovableToolbarItemPboardType]];
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObject: GSMovableToolbarItemPboardType]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -422,20 +436,34 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
- (NSDragOperation) draggingEntered: (id <NSDraggingInfo>)info
|
||||
{
|
||||
if ([self _insertionIndexAtPoint: [info draggingLocation]] != NSNotFound);
|
||||
GSToolbar *toolbar = [self toolbar];
|
||||
NSArray *allowedItemIdentifiers =
|
||||
[[toolbar delegate] toolbarAllowedItemIdentifiers: toolbar];
|
||||
NSString *itemIdentifier =
|
||||
[(NSToolbarItem *)[[info draggingSource] toolbarItem] itemIdentifier];
|
||||
|
||||
if ([self _insertionIndexAtPoint: [info draggingLocation]] != NSNotFound
|
||||
&& [allowedItemIdentifiers containsObject: itemIdentifier]);
|
||||
{
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
}
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (NSDragOperation) draggingUpdated: (id <NSDraggingInfo>)info
|
||||
{
|
||||
if ([self _insertionIndexAtPoint: [info draggingLocation]] != NSNotFound);
|
||||
GSToolbar *toolbar = [self toolbar];
|
||||
NSArray *allowedItemIdentifiers =
|
||||
[[toolbar delegate] toolbarAllowedItemIdentifiers: toolbar];
|
||||
NSString *itemIdentifier =
|
||||
[(NSToolbarItem *)[[info draggingSource] toolbarItem] itemIdentifier];
|
||||
|
||||
if ([self _insertionIndexAtPoint: [info draggingLocation]] != NSNotFound
|
||||
&& [allowedItemIdentifiers containsObject: itemIdentifier]);
|
||||
{
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
}
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
@ -447,7 +475,8 @@ static void initSystemExtensionsColors(void)
|
|||
int index = [str intValue];
|
||||
GSToolbar *toolbar = [self toolbar];
|
||||
|
||||
[toolbar _concludeRemoveItem: [[info draggingSource] toolbarItem] atIndex: index broadcast: YES];
|
||||
[toolbar _concludeRemoveItem:
|
||||
[[info draggingSource] toolbarItem] atIndex: index broadcast: YES];
|
||||
}
|
||||
|
||||
- (void) draggingExited: (id <NSDraggingInfo>)info
|
||||
|
@ -467,11 +496,13 @@ static void initSystemExtensionsColors(void)
|
|||
int index = [str intValue];
|
||||
GSToolbar *toolbar = [self toolbar];
|
||||
NSToolbarItem *item = [[info draggingSource] toolbarItem];
|
||||
int newIndex = [self _insertionIndexAtPoint: [info draggingLocation]]; // Calculate the index
|
||||
int newIndex = [self _insertionIndexAtPoint: [info draggingLocation]];
|
||||
// Calculate the index
|
||||
|
||||
[toolbar _insertPassivelyItem:item atIndex: index];
|
||||
RELEASE(item);
|
||||
[toolbar _moveItemFromIndex: index toIndex: newIndex broadcast: YES];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -503,7 +534,8 @@ static void initSystemExtensionsColors(void)
|
|||
}
|
||||
if (_borderMask & GSToolbarViewTopBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0, viewFrame.size.height - 0.5)
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0,
|
||||
viewFrame.size.height - 0.5)
|
||||
toPoint: NSMakePoint(viewFrame.size.width,
|
||||
viewFrame.size.height - 0.5)];
|
||||
}
|
||||
|
@ -516,7 +548,7 @@ static void initSystemExtensionsColors(void)
|
|||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(viewFrame.size.width - 0.5,0)
|
||||
toPoint: NSMakePoint(viewFrame.size.width - 0.5,
|
||||
viewFrame.size.height)];
|
||||
viewFrame.size.height)];
|
||||
}
|
||||
|
||||
[super drawRect: aRect];
|
||||
|
@ -554,8 +586,8 @@ static void initSystemExtensionsColors(void)
|
|||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
// NSView method called when a view is moved to a window (NSView has a
|
||||
// variable _window)
|
||||
/* NSView method called when a view is moved to a window (NSView has a
|
||||
variable _window). */
|
||||
[super viewDidMoveToWindow];
|
||||
|
||||
[nc removeObserver: self name: NSWindowDidResizeNotification object: nil];
|
||||
|
@ -604,22 +636,26 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
if (_borderMask & GSToolbarViewBottomBorder)
|
||||
{
|
||||
rect = NSMakeRect(rect.origin.x, ++rect.origin.y, rect.size.width, --rect.size.height);
|
||||
rect = NSMakeRect(rect.origin.x, ++rect.origin.y, rect.size.width,
|
||||
--rect.size.height);
|
||||
}
|
||||
|
||||
if (_borderMask & GSToolbarViewTopBorder)
|
||||
{
|
||||
rect = NSMakeRect(rect.origin.x, rect.origin.y, rect.size.width, --rect.size.height);
|
||||
rect = NSMakeRect(rect.origin.x, rect.origin.y, rect.size.width,
|
||||
--rect.size.height);
|
||||
}
|
||||
|
||||
if (_borderMask & GSToolbarViewLeftBorder)
|
||||
{
|
||||
rect = NSMakeRect(++rect.origin.x, rect.origin.y, --rect.size.width, rect.size.height);
|
||||
rect = NSMakeRect(++rect.origin.x, rect.origin.y, --rect.size.width,
|
||||
rect.size.height);
|
||||
}
|
||||
|
||||
if (_borderMask & GSToolbarViewRightBorder)
|
||||
{
|
||||
rect = NSMakeRect(rect.origin.x, rect.origin.y, --rect.size.width, rect.size.height);
|
||||
rect = NSMakeRect(rect.origin.x, rect.origin.y, --rect.size.width,
|
||||
rect.size.height);
|
||||
}
|
||||
|
||||
[_clipView setFrame: rect];
|
||||
|
@ -659,7 +695,7 @@ static void initSystemExtensionsColors(void)
|
|||
while ((item = [e nextObject]) != nil)
|
||||
{
|
||||
itemBackView = [item _backView];
|
||||
if (![subviews containsObject: itemBackView]
|
||||
if ([subviews containsObject: itemBackView] == NO
|
||||
|| [item _isModified]
|
||||
|| [item _isFlexibleSpace])
|
||||
{
|
||||
|
@ -670,10 +706,9 @@ static void initSystemExtensionsColors(void)
|
|||
}
|
||||
|
||||
itemBackViewFrame = [itemBackView frame];
|
||||
[itemBackView setFrame: NSMakeRect(x,
|
||||
itemBackViewFrame.origin.y,
|
||||
itemBackViewFrame.size.width,
|
||||
itemBackViewFrame.size.height)];
|
||||
[itemBackView setFrame: NSMakeRect(x, itemBackViewFrame.origin.y,
|
||||
itemBackViewFrame.size.width, itemBackViewFrame.size.height)];
|
||||
|
||||
x += [itemBackView frame].size.width;
|
||||
|
||||
if (itemBackViewFrame.size.height > newHeight)
|
||||
|
@ -688,12 +723,12 @@ static void initSystemExtensionsColors(void)
|
|||
{
|
||||
NSArray *items = [_toolbar items];
|
||||
|
||||
// The back views which are associated with each toolbar item (the toolbar
|
||||
// items doesn't reflect the toolbar view content)
|
||||
/* The back views which are associated with each toolbar item (the toolbar
|
||||
items doesn't reflect the toolbar view content) */
|
||||
NSArray *backViews = [items valueForKey: @"_backView"];
|
||||
|
||||
// The back views which will be visible in the toolbar view (when
|
||||
// _handleViewsVisibility will be terminated)
|
||||
/* The back views which will be visible in the toolbar view (when
|
||||
_handleViewsVisibility will be terminated). */
|
||||
NSArray *visibleBackViews;
|
||||
|
||||
NSArray *subviews;
|
||||
|
@ -717,7 +752,7 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
while ((backView = [e nextObject]) != nil)
|
||||
{
|
||||
if (![backViews containsObject: backView])
|
||||
if ([backViews containsObject: backView] == NO)
|
||||
{
|
||||
if ([backView superview] != nil)
|
||||
[backView removeFromSuperview];
|
||||
|
@ -731,7 +766,7 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
while ((backView = [e nextObject]) != nil)
|
||||
{
|
||||
if (![subviews containsObject: backView])
|
||||
if ([subviews containsObject: backView] == NO)
|
||||
{
|
||||
[_clipView addSubview: backView];
|
||||
}
|
||||
|
@ -739,8 +774,8 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
// ---
|
||||
|
||||
// We manage the clipped items view in the case it should become visible or
|
||||
// invisible
|
||||
/* We manage the clipped items view in the case it should become visible or
|
||||
invisible */
|
||||
|
||||
clipViewFrame = [_clipView frame];
|
||||
|
||||
|
@ -758,8 +793,7 @@ static void initSystemExtensionsColors(void)
|
|||
width,
|
||||
clipViewFrame.size.height)];
|
||||
|
||||
// Adjust the clipped items mark
|
||||
// Frame handling
|
||||
// Adjust the clipped items mark frame handling
|
||||
|
||||
[_clippedItemsMark layout];
|
||||
|
||||
|
@ -778,10 +812,9 @@ static void initSystemExtensionsColors(void)
|
|||
{
|
||||
[_clippedItemsMark removeFromSuperview];
|
||||
|
||||
[_clipView setFrame: NSMakeRect(clipViewFrame.origin.x,
|
||||
clipViewFrame.origin.y,
|
||||
[self frame].size.width,
|
||||
clipViewFrame.size.height)];
|
||||
[_clipView setFrame: NSMakeRect(clipViewFrame.origin.x,
|
||||
clipViewFrame.origin.y, [self frame].size.width,
|
||||
clipViewFrame.size.height)];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -866,7 +899,7 @@ static void initSystemExtensionsColors(void)
|
|||
int index;
|
||||
|
||||
if ((hitView != nil)
|
||||
& ([hitView isKindOfClass: [GSToolbarButton class]]
|
||||
&& ([hitView isKindOfClass: [GSToolbarButton class]]
|
||||
|| [hitView isKindOfClass: [GSToolbarBackView class]]))
|
||||
{
|
||||
index = [_toolbar _indexOfItem: [hitView toolbarItem]];
|
||||
|
@ -897,9 +930,11 @@ static void initSystemExtensionsColors(void)
|
|||
return height;
|
||||
}
|
||||
|
||||
// Will return the visible (not clipped) back views in the toolbar view even
|
||||
// when the toolbar is not visible .
|
||||
// May be should be renamed _notClippedBackViews method.
|
||||
/*
|
||||
* Will return the visible (not clipped) back views in the toolbar view even
|
||||
* when the toolbar is not visible.
|
||||
* May be should be renamed _notClippedBackViews method.
|
||||
*/
|
||||
- (NSArray *) _visibleBackViews
|
||||
{
|
||||
NSArray *items = [_toolbar items];
|
||||
|
@ -937,8 +972,10 @@ static void initSystemExtensionsColors(void)
|
|||
return _sizeMode;
|
||||
}
|
||||
|
||||
// _willBeVisible indicates that the toolbar view previously hidden is in
|
||||
// process to become visible again before the end of current the event loop.
|
||||
/*
|
||||
* _willBeVisible indicates that the toolbar view previously hidden is in
|
||||
* process to become visible again before the end of current the event loop.
|
||||
*/
|
||||
- (BOOL) _willBeVisible
|
||||
{
|
||||
return _willBeVisible;
|
||||
|
|
|
@ -51,17 +51,17 @@
|
|||
#include "AppKit/NSToolbarItem.h"
|
||||
|
||||
/*
|
||||
* Each NSToolbarItem object are coupled with a backView which is their representation
|
||||
* on the screen.
|
||||
* backView for the standard toolbar item (without custom view) are NSButton subclass
|
||||
* called GSToolbarButton.
|
||||
* Each NSToolbarItem object are coupled with a backView which is their
|
||||
* representation on the screen.
|
||||
* backView for the standard toolbar item (without custom view) are NSButton
|
||||
* subclass called GSToolbarButton.
|
||||
* backView for the toolbar item with a custom view are NSView subclass called
|
||||
* GSToolbarBackView.
|
||||
* GSToolbarButton and GSToolbarBackView are adjusted according to their content and
|
||||
* their title when the method layout is called.
|
||||
* The predefined GNUstep toolbar items are implemented with a class cluster pattern :
|
||||
* initWithToolbarItemIdentifier: returns differents concrete subclass in accordance
|
||||
* with the item identifier.
|
||||
* GSToolbarButton and GSToolbarBackView are adjusted according to their content
|
||||
* and their title when the method layout is called.
|
||||
* The predefined GNUstep toolbar items are implemented with a class cluster
|
||||
* pattern: initWithToolbarItemIdentifier: returns differents concrete subclass
|
||||
* in accordance with the item identifier.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
|
@ -202,10 +202,10 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
layoutedWidth = ItemBackViewSmallWidth;
|
||||
layoutedHeight = ItemBackViewSmallHeight;
|
||||
[[_toolbarItem image] setSize: NSMakeSize(24, 24)];
|
||||
// Not use [self image] here because it can return nil, when image position is
|
||||
// set to NSNoImage. Even if NSToolbarDisplayModeTextOnly is not true anymore
|
||||
// -setImagePosition: is only called below, then [self image] can still returns
|
||||
// nil.
|
||||
/* Not use [self image] here because it can return nil, when image
|
||||
position is set to NSNoImage. Even if NSToolbarDisplayModeTextOnly
|
||||
is not true anymore -setImagePosition: is only called below, then
|
||||
[self image] can still returns nil. */
|
||||
font = SmallFont;
|
||||
break;
|
||||
default:
|
||||
|
@ -270,49 +270,58 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
}
|
||||
|
||||
/*
|
||||
* The code below should be kept in sync with GSToolbarBackView methods which have identical names
|
||||
* The code below should be kept in sync with GSToolbarBackView methods which
|
||||
* have identical names.
|
||||
*/
|
||||
|
||||
- (void) mouseDown: (NSEvent *)event
|
||||
{
|
||||
if ([event modifierFlags] == NSCommandKeyMask)
|
||||
GSToolbar *toolbar = [_toolbarItem toolbar];
|
||||
|
||||
if ([event modifierFlags] == NSCommandKeyMask
|
||||
&& [toolbar allowsUserCustomization])
|
||||
{
|
||||
NSSize viewSize = [self frame].size;
|
||||
NSImage *image = [[NSImage alloc] initWithSize: viewSize];
|
||||
NSCell *cell = [self cell];
|
||||
NSPasteboard *pboard;
|
||||
GSToolbar *toolbar = [_toolbarItem toolbar];
|
||||
int index;
|
||||
|
||||
AUTORELEASE(image);
|
||||
|
||||
// Prepare the drag
|
||||
|
||||
RETAIN(self); // We need to keep this view (aka self) to be able to draw the drag image.
|
||||
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
|
||||
/* 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];
|
||||
[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];
|
||||
[pboard declareTypes: [NSArray arrayWithObject: GSMovableToolbarItemPboardType]
|
||||
owner: nil];
|
||||
index = [toolbar _indexOfItem: _toolbarItem];
|
||||
[pboard setString: [NSString stringWithFormat:@"%d", index] forType: GSMovableToolbarItemPboardType];
|
||||
[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
|
||||
offset: NSMakeSize(0.0, 0.0)
|
||||
event: event
|
||||
pasteboard: pboard
|
||||
source: self
|
||||
slideBack: NO];
|
||||
slideBack: NO];
|
||||
}
|
||||
else
|
||||
else if ([event modifierFlags] != NSCommandKeyMask)
|
||||
{
|
||||
[super mouseDown: event];
|
||||
}
|
||||
|
@ -323,12 +332,15 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
GSToolbar *toolbar = [_toolbarItem toolbar];
|
||||
|
||||
RETAIN(_toolbarItem);
|
||||
// We retain the toolbar item to be able to have have it reinsered later by the dragging destination.
|
||||
/* We retain the toolbar item to be able to have have it reinsered later by
|
||||
the dragging destination. */
|
||||
|
||||
[toolbar _performRemoveItem: _toolbarItem];
|
||||
}
|
||||
|
||||
- (void) draggedImage: (NSImage *)dragImage endedAt: (NSPoint)location operation: (NSDragOperation)operation
|
||||
- (void) draggedImage: (NSImage *)dragImage
|
||||
endedAt: (NSPoint)location
|
||||
operation: (NSDragOperation)operation
|
||||
{
|
||||
RELEASE(self); // The view is no more needed : no more drawing to do with it.
|
||||
}
|
||||
|
@ -345,11 +357,16 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
- (BOOL) sendAction: (SEL)action to: (id)target
|
||||
{
|
||||
if ([_toolbarItem _selectable])
|
||||
[[_toolbarItem toolbar] setSelectedItemIdentifier: [_toolbarItem itemIdentifier]];
|
||||
{
|
||||
[[_toolbarItem toolbar]
|
||||
setSelectedItemIdentifier: [_toolbarItem itemIdentifier]];
|
||||
}
|
||||
|
||||
if (_toolbarItemAction)
|
||||
{
|
||||
return [NSApp sendAction: _toolbarItemAction to: target from: _toolbarItem];
|
||||
return [NSApp sendAction: _toolbarItemAction
|
||||
to: target
|
||||
from: _toolbarItem];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -382,7 +399,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
NSSize titleSize = [[self attributedTitle] size];
|
||||
// We ignore alternateAttributedTitle, it is not needed
|
||||
|
||||
// We store the values we need to customize the drawing into titleRect and imageRect
|
||||
/* We store the values we need to customize the drawing into titleRect and
|
||||
imageRect. */
|
||||
|
||||
titleRect.origin.x = cellFrame.origin.x;
|
||||
titleRect.origin.y = cellFrame.origin.y + InsetItemTextY;
|
||||
|
@ -408,13 +426,12 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
if (aString == nil)
|
||||
return;
|
||||
|
||||
/** Important: text should always be vertically centered without
|
||||
* considering descender [as if descender did not exist].
|
||||
* This is particularly important for single line texts.
|
||||
* Please make sure the output remains always correct.
|
||||
*/
|
||||
// We ignore aRect value
|
||||
[aString drawInRect: titleRect];
|
||||
/* Important: text should always be vertically centered without considering
|
||||
descender (as if descender did not exist). This is particularly important
|
||||
for single line texts.Please make sure the output remains always
|
||||
correct. */
|
||||
|
||||
[aString drawInRect: titleRect]; // We ignore aRect value
|
||||
}
|
||||
|
||||
// Overriden NSButtonCell method
|
||||
|
@ -429,10 +446,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
position.x = MAX(NSMidX(imageRect) - (size.width / 2.), 0.);
|
||||
position.y = MAX(NSMidY(imageRect) - (size.height / 2.), 0.);
|
||||
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner at the origin
|
||||
* so we must adjust the position to take account of a flipped view.
|
||||
*/
|
||||
/* Images are always drawn with their bottom-left corner at the origin so we
|
||||
must adjust the position to take account of a flipped view. */
|
||||
if (flipped)
|
||||
{
|
||||
position.y += size.height;
|
||||
|
@ -472,8 +487,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
- (id)initWithToolbarItem: (NSToolbarItem *)toolbarItem
|
||||
{
|
||||
self = [super initWithFrame: NSMakeRect(ItemBackViewX, ItemBackViewY, ItemBackViewDefaultWidth,
|
||||
ItemBackViewDefaultHeight)];
|
||||
self = [super initWithFrame: NSMakeRect(ItemBackViewX, ItemBackViewY,
|
||||
ItemBackViewDefaultWidth, ItemBackViewDefaultHeight)];
|
||||
// Frame will be reset by the layout method
|
||||
|
||||
if (self != nil)
|
||||
|
@ -487,8 +502,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
// _font is pointing on a static variable then we do own it and don't need
|
||||
// to release it.
|
||||
/* _font is pointing on a static variable then we do own it and don't need
|
||||
to release it. */
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -519,13 +534,10 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
// We draw the label
|
||||
attr = [NSDictionary dictionaryWithObjectsAndKeys: _font,
|
||||
NSFontAttributeName,
|
||||
color,
|
||||
NSForegroundColorAttributeName,
|
||||
pStyle,
|
||||
NSParagraphStyleAttributeName,
|
||||
nil];
|
||||
attrString = [[NSAttributedString alloc] initWithString: [_toolbarItem label] attributes: attr];
|
||||
NSFontAttributeName, color, NSForegroundColorAttributeName, pStyle,
|
||||
NSParagraphStyleAttributeName, nil];
|
||||
attrString = [[NSAttributedString alloc]
|
||||
initWithString: [_toolbarItem label] attributes: attr];
|
||||
|
||||
titleRect.origin.x = viewBounds.origin.x;
|
||||
titleRect.origin.y = viewBounds.origin.y + InsetItemTextY;
|
||||
|
@ -576,7 +588,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
[view removeFromSuperview];
|
||||
break;
|
||||
default:
|
||||
NSLog(@"Invalid NSToolbarSizeMode"); // invalid
|
||||
NSLog(@"Invalid NSToolbarSizeMode"); // Invalid
|
||||
}
|
||||
|
||||
// Adjust the layout in accordance with the border
|
||||
|
@ -608,8 +620,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
_enabled = YES;
|
||||
_showLabel = YES;
|
||||
// This boolean variable is used to known when it's needed to draw the label in the -drawRect:
|
||||
// method.
|
||||
/* This boolean variable is used to known when it's needed to draw the label
|
||||
in the -drawRect: method. */
|
||||
|
||||
switch ([[_toolbarItem toolbar] displayMode])
|
||||
{
|
||||
|
@ -631,38 +643,41 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
; // Invalid
|
||||
}
|
||||
|
||||
// If the view is visible...
|
||||
// Adjust the layout in accordance with the view width in the case it is needed
|
||||
/* If the view is visible...
|
||||
Adjust the layout in accordance with the view width in the case it is
|
||||
needed. */
|
||||
|
||||
if ([view superview] != nil)
|
||||
{
|
||||
if (layoutedWidth < [view frame].size.width + 2 * InsetItemViewX)
|
||||
layoutedWidth = [view frame].size.width + 2 * InsetItemViewX;
|
||||
if (layoutedWidth < [view frame].size.width + 2 * InsetItemViewX)
|
||||
layoutedWidth = [view frame].size.width + 2 * InsetItemViewX;
|
||||
}
|
||||
|
||||
// Set the frame size to use the new layout
|
||||
|
||||
[self setFrameSize: NSMakeSize(layoutedWidth, layoutedHeight)];
|
||||
|
||||
// If the view is visible...
|
||||
// Adjust the view position in accordance with the new layout
|
||||
/* If the view is visible...
|
||||
Adjust the view position in accordance with the new layout. */
|
||||
|
||||
if ([view superview] != nil)
|
||||
{
|
||||
if (_showLabel)
|
||||
{
|
||||
insetItemViewY = ([self frame].size.height
|
||||
- [view frame].size.height - [attrStr size].height - InsetItemTextX) / 2
|
||||
insetItemViewY = ([self frame].size.height - [view frame].size.height
|
||||
- [attrStr size].height - InsetItemTextX) / 2
|
||||
+ [attrStr size].height + InsetItemTextX;
|
||||
}
|
||||
else
|
||||
{
|
||||
insetItemViewY = ([self frame].size.height - [view frame].size.height) / 2;
|
||||
insetItemViewY = ([self frame].size.height
|
||||
- [view frame].size.height) / 2;
|
||||
}
|
||||
|
||||
[view setFrameOrigin:
|
||||
NSMakePoint((layoutedWidth - [view frame].size.width) / 2, insetItemViewY)];
|
||||
[view setFrameOrigin: NSMakePoint((layoutedWidth
|
||||
- [view frame].size.width) / 2, insetItemViewY)];
|
||||
}
|
||||
|
||||
DESTROY(attrStr);
|
||||
}
|
||||
|
||||
|
@ -683,44 +698,56 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
}
|
||||
|
||||
/*
|
||||
* The code below should be kept in sync with GSToolbarButton methods which have identical names
|
||||
* The code below should be kept in sync with GSToolbarButton methods which
|
||||
* have identical names.
|
||||
*/
|
||||
|
||||
|
||||
- (void) mouseDown: (NSEvent *)event
|
||||
{
|
||||
if ([event modifierFlags] == NSCommandKeyMask)
|
||||
GSToolbar *toolbar = [_toolbarItem toolbar];
|
||||
|
||||
if ([event modifierFlags] == NSCommandKeyMask
|
||||
&& [toolbar allowsUserCustomization])
|
||||
{
|
||||
NSSize viewSize = [self frame].size;
|
||||
NSImage *image = [[NSImage alloc] initWithSize: viewSize];
|
||||
NSPasteboard *pboard;
|
||||
GSToolbar *toolbar = [_toolbarItem toolbar];
|
||||
int index;
|
||||
|
||||
AUTORELEASE(image);
|
||||
|
||||
// Prepare the drag
|
||||
|
||||
RETAIN(self); // We need to keep this view (aka self) to be able to draw the drag image.
|
||||
RETAIN(self);
|
||||
/* We need to keep this view (aka self) to be able to draw the drag
|
||||
image. */
|
||||
|
||||
// The code below is only partially supported by GNUstep, then NSImage needs to be improved
|
||||
// Draw the drag content in an image
|
||||
|
||||
/* The code below is only partially supported by GNUstep, then NSImage
|
||||
needs to be improved. */
|
||||
[image lockFocus];
|
||||
[self drawRect: NSMakeRect(0, 0, viewSize.width, viewSize.height)];
|
||||
[self drawRect:
|
||||
NSMakeRect(0, 0, viewSize.width, viewSize.height)];
|
||||
[image unlockFocus];
|
||||
|
||||
|
||||
pboard = [NSPasteboard pasteboardWithName: NSDragPboard];
|
||||
[pboard declareTypes: [NSArray arrayWithObject: GSMovableToolbarItemPboardType] owner: nil];
|
||||
[pboard declareTypes: [NSArray arrayWithObject: GSMovableToolbarItemPboardType]
|
||||
owner: nil];
|
||||
index = [toolbar _indexOfItem: _toolbarItem];
|
||||
[pboard setString: [NSString stringWithFormat:@"%d", index] forType: GSMovableToolbarItemPboardType];
|
||||
[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
|
||||
offset: NSMakeSize(0.0, 0.0)
|
||||
event: event
|
||||
pasteboard: pboard
|
||||
source: self
|
||||
slideBack: NO];
|
||||
slideBack: NO];
|
||||
}
|
||||
else
|
||||
else if ([event modifierFlags] != NSCommandKeyMask)
|
||||
{
|
||||
[super mouseDown: event];
|
||||
}
|
||||
|
@ -731,12 +758,15 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
GSToolbar *toolbar = [_toolbarItem toolbar];
|
||||
|
||||
RETAIN(_toolbarItem);
|
||||
// We retain the toolbar item to be able to have have it reinsered later by the dragging destination.
|
||||
/* We retain the toolbar item to be able to have have it reinsered later by
|
||||
the dragging destination. */
|
||||
|
||||
[toolbar _performRemoveItem: _toolbarItem];
|
||||
}
|
||||
|
||||
- (void) draggedImage: (NSImage *)dragImage endedAt: (NSPoint)location operation: (NSDragOperation)operation
|
||||
- (void) draggedImage: (NSImage *)dragImage
|
||||
endedAt: (NSPoint)location
|
||||
operation: (NSDragOperation)operation
|
||||
{
|
||||
RELEASE(self); // The view is no more needed : no more drawing to do with it.
|
||||
}
|
||||
|
@ -781,9 +811,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
@end
|
||||
|
||||
/*
|
||||
*
|
||||
* Standard toolbar items.
|
||||
*
|
||||
*/
|
||||
|
||||
// ---- NSToolbarSeparatorItemIdentifier
|
||||
|
@ -800,7 +828,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
self = [super initWithItemIdentifier: itemIdentifier];
|
||||
[(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 (48 * 48) not resized
|
||||
/* We bypass the toolbar item accessor to set the image in order to have it
|
||||
(48 * 48) not resized. */
|
||||
|
||||
[[self _backView] setFrameSize: NSMakeSize(30, ItemBackViewDefaultHeight)];
|
||||
|
||||
|
@ -990,52 +1019,63 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
// GNUstep predefined toolbar items
|
||||
|
||||
if ([itemIdentifier isEqualToString: @"NSToolbarSeparatorItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarSeparatorItem class]])
|
||||
&& ![self isKindOfClass:[GSToolbarSeparatorItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarSeparatorItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarSeparatorItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
else if ([itemIdentifier isEqualToString: @"NSToolbarSpaceItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarSpaceItem class]])
|
||||
&& [self isKindOfClass:[GSToolbarSpaceItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarSpaceItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarSpaceItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
else if ([itemIdentifier isEqualToString: @"NSToolbarFlexibleSpaceItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarFlexibleSpaceItem class]])
|
||||
else if ([itemIdentifier
|
||||
isEqualToString: @"NSToolbarFlexibleSpaceItemIdentifier"]
|
||||
&& [self isKindOfClass:[GSToolbarFlexibleSpaceItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarFlexibleSpaceItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarFlexibleSpaceItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
else if ([itemIdentifier isEqualToString: @"NSToolbarShowColorsItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarShowColorsItem class]])
|
||||
else if ([itemIdentifier
|
||||
isEqualToString: @"NSToolbarShowColorsItemIdentifier"]
|
||||
&& [self isKindOfClass:[GSToolbarShowColorsItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarShowColorsItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarShowColorsItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
else if ([itemIdentifier isEqualToString: @"NSToolbarShowFontsItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarShowFontsItem class]])
|
||||
else if ([itemIdentifier
|
||||
isEqualToString: @"NSToolbarShowFontsItemIdentifier"]
|
||||
&& [self isKindOfClass:[GSToolbarShowFontsItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarShowFontsItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarShowFontsItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
else if ([itemIdentifier isEqualToString: @"NSToolbarCustomizeToolbarItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarCustomizeToolbarItem class]])
|
||||
else if ([itemIdentifier
|
||||
isEqualToString: @"NSToolbarCustomizeToolbarItemIdentifier"]
|
||||
&& [self isKindOfClass:[GSToolbarCustomizeToolbarItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarCustomizeToolbarItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarCustomizeToolbarItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
else if ([itemIdentifier isEqualToString: @"NSToolbarPrintItemIdentifier"]
|
||||
&& ![self isKindOfClass:[GSToolbarPrintItem class]])
|
||||
&& [self isKindOfClass:[GSToolbarPrintItem class]] == NO)
|
||||
{
|
||||
[self release];
|
||||
self = [[GSToolbarPrintItem alloc] initWithItemIdentifier: itemIdentifier];
|
||||
self = [[GSToolbarPrintItem alloc]
|
||||
initWithItemIdentifier: itemIdentifier];
|
||||
}
|
||||
|
||||
// Normal toolbar items
|
||||
|
@ -1051,9 +1091,11 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
[button setBordered: NO];
|
||||
[button setImagePosition: NSImageAbove];
|
||||
[cell setBezeled: YES];
|
||||
[cell setHighlightsBy: NSChangeGrayCellMask | NSChangeBackgroundCellMask];
|
||||
[cell setHighlightsBy:
|
||||
NSChangeGrayCellMask | NSChangeBackgroundCellMask];
|
||||
[cell setFont: [NSFont systemFontOfSize: 11]];
|
||||
// [NSFont smallSystemFontSize] or better should be controlContentFontSize
|
||||
/* [NSFont smallSystemFontSize] or better should be
|
||||
controlContentFontSize. */
|
||||
|
||||
[_backView release];
|
||||
_backView = button;
|
||||
|
@ -1062,14 +1104,18 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
// gets
|
||||
_flags._isEnabled = [_backView respondsToSelector: @selector(isEnabled)];
|
||||
_flags._tag = YES;
|
||||
_flags._action = [_backView respondsToSelector: @selector(toolbarItemAction)];
|
||||
_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._setEnabled =
|
||||
[_backView respondsToSelector: @selector(setEnabled:)];
|
||||
_flags._setTag = YES;
|
||||
_flags._setAction = [_backView respondsToSelector: @selector(setToolbarItemAction:)];
|
||||
_flags._setTarget = [_backView respondsToSelector: @selector(setTarget:)];
|
||||
_flags._setAction =
|
||||
[_backView respondsToSelector: @selector(setToolbarItemAction:)];
|
||||
_flags._setTarget =
|
||||
[_backView respondsToSelector: @selector(setTarget:)];
|
||||
_flags._setImage = [_backView respondsToSelector: @selector(setImage:)];
|
||||
|
||||
}
|
||||
|
@ -1111,6 +1157,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
{
|
||||
return _image;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -1123,7 +1170,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
{
|
||||
NSMenuItem *menuItem = [self menuFormRepresentation];
|
||||
|
||||
if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly && menuItem != nil)
|
||||
if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly
|
||||
&& menuItem != nil)
|
||||
{
|
||||
return [menuItem title];
|
||||
}
|
||||
|
@ -1159,6 +1207,7 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
{
|
||||
if ([_backView isKindOfClass: [GSToolbarButton class]])
|
||||
[(GSToolbarButton *)_backView setToolbarItemAction: action];
|
||||
|
||||
if (action != NULL)
|
||||
{
|
||||
[self setEnabled: YES];
|
||||
|
@ -1250,13 +1299,17 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
{
|
||||
// gets
|
||||
_flags._isEnabled = [_backView respondsToSelector: @selector(isEnabled)];
|
||||
_flags._action = [_backView respondsToSelector: @selector(toolbarItemAction)];
|
||||
_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._setAction = [_backView respondsToSelector: @selector(setToolbarItemAction:)];
|
||||
_flags._setTarget = [_backView respondsToSelector: @selector(setTarget:)];
|
||||
_flags._setEnabled =
|
||||
[_backView respondsToSelector: @selector(setEnabled:)];
|
||||
_flags._setAction =
|
||||
[_backView respondsToSelector: @selector(setToolbarItemAction:)];
|
||||
_flags._setTarget =
|
||||
[_backView respondsToSelector: @selector(setTarget:)];
|
||||
_flags._setImage = [_backView respondsToSelector: @selector(setImage:)];
|
||||
}
|
||||
else
|
||||
|
@ -1297,12 +1350,13 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
- (void) validate
|
||||
{
|
||||
// Validate by default, we know that all of the
|
||||
// "standard" items are correct.
|
||||
/* Validate by default, we know that all of the
|
||||
"standard" items are correct. */
|
||||
NSMenuItem *menuItem = [self menuFormRepresentation];
|
||||
id target = [self target];
|
||||
|
||||
if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly && menuItem != nil)
|
||||
if ([[self toolbar] displayMode] == NSToolbarDisplayModeLabelOnly
|
||||
&& menuItem != nil)
|
||||
{
|
||||
if ([target respondsToSelector: @selector(validateMenuItem:)])
|
||||
[self setEnabled: [target validateMenuItem: menuItem]];
|
||||
|
@ -1373,15 +1427,15 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
|
||||
- (void) _setSelected: (BOOL)selected
|
||||
{
|
||||
if (_selectable && ![self _selected] && selected)
|
||||
if (_selectable && [self _selected] == NO && selected)
|
||||
{
|
||||
[(GSToolbarButton *)_backView performClick:self];
|
||||
}
|
||||
else if (!selected)
|
||||
else if (selected == NO)
|
||||
{
|
||||
[(GSToolbarButton *)_backView setState: NO];
|
||||
}
|
||||
else if (!_selectable)
|
||||
else if (_selectable == NO)
|
||||
{
|
||||
NSLog(@"The toolbar item %@ is not selectable", self);
|
||||
}
|
||||
|
@ -1431,7 +1485,8 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
|||
// NSCopying protocol
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
NSToolbarItem *new = [[NSToolbarItem allocWithZone: zone] initWithItemIdentifier: _itemIdentifier];
|
||||
NSToolbarItem *new = [[NSToolbarItem allocWithZone: zone]
|
||||
initWithItemIdentifier: _itemIdentifier];
|
||||
|
||||
// Copy all items individually...
|
||||
[new setTarget: [self target]];
|
||||
|
|
Loading…
Reference in a new issue