mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Adding a number of changes. The skeleton implementations of NSToolbar and
NSToolbarItem as well as a number of miscellaneous things I have had laying around for a while. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@13997 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bcf07f45a6
commit
d2c4db3d9b
12 changed files with 762 additions and 15 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2002-06-30 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Headers/gnustep/gui/NSWindow.h: Added declaration for
|
||||
NSToolbar in NSWindow.
|
||||
* Headers/gnustep/gui/AppKit.h: Added #include lines for
|
||||
new header files in the AppKit.h file.
|
||||
* Source/NSWindow.m: Added code foe setToolbar method.
|
||||
* Source/GNUmakefile: Added NSToolbar and NSToolbarItem
|
||||
classes and headers to the makefile.
|
||||
* Source/NSOutlineView.m: Added dealloc for NSOutlineView to
|
||||
prevent memory leaks.
|
||||
* Source/NSSecureTextField.m: Removed some extraneous comments
|
||||
which were left from before I implemented the class.
|
||||
* Source/externs.m: Added notification constants for NSToolbar.
|
||||
* Source/NSToolbar.m: Added skeleton for implementation.
|
||||
* Source/NSToolbarItem.m: Added skeleton for implementation.
|
||||
* Headers/gnustep/gui/NSToolbar.h: Added.
|
||||
* Headers/gnustep/gui/NSToolbarItem.h: Added.
|
||||
|
||||
2002-06-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSWindow.m: ([-flushWindow]) don't flush context for
|
||||
|
|
|
@ -143,6 +143,8 @@
|
|||
#include <AppKit/NSTextStorage.h>
|
||||
#include <AppKit/NSUserInterfaceValidation.h>
|
||||
#include <AppKit/NSWindowController.h>
|
||||
#include <AppKit/NSToolbar.h>
|
||||
#include <AppKit/NSToolbarItem.h>
|
||||
#endif
|
||||
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
|
118
Headers/gnustep/gui/NSToolbar.h
Normal file
118
Headers/gnustep/gui/NSToolbar.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
NSToolbar.h
|
||||
|
||||
The toolbar class.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>,
|
||||
Fabien Vallon <fabien.vallon@fr.alcove.com>
|
||||
Date: May 2002
|
||||
|
||||
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 Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSToolbar
|
||||
#define _GNUstep_H_NSToolbar
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
@class NSString;
|
||||
@class NSDictionary;
|
||||
@class NSMutableDictionary;
|
||||
@class NSToolbarItem;
|
||||
@class NSNotification;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NSToolbarDisplayModeDefault,
|
||||
NSToolbarDisplayModeIconAndLabel,
|
||||
NSToolbarDisplayModeIconOnly,
|
||||
NSToolbarDisplayModeLabelOnly
|
||||
} NSToolbarDisplayMode;
|
||||
|
||||
APPKIT_EXPORT NSString *NSToolbarDidRemoveItemNotification;
|
||||
APPKIT_EXPORT NSString *NSToolbarWillAddItemNotification;
|
||||
|
||||
@interface NSToolbar : NSObject
|
||||
{
|
||||
BOOL _allowsUserCustomization;
|
||||
BOOL _autosavesConfiguration;
|
||||
NSMutableDictionary *_configurationDictionary;
|
||||
BOOL _customizationPaletteIsRunning;
|
||||
id _delegate;
|
||||
NSToolbarDisplayMode _displayMode;
|
||||
NSString *_identifier;
|
||||
BOOL _visible;
|
||||
NSMutableArray *_items;
|
||||
NSMutableArray *_visibleItems;
|
||||
id _toolbarView;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
- (BOOL)allowsUserCustomization;
|
||||
- (BOOL)autosavesConfiguration;
|
||||
- (NSDictionary *)configurationDictionary;
|
||||
- (BOOL)customizationPaletteIsRunning;
|
||||
- (id)delegate;
|
||||
- (NSToolbarDisplayMode)displayMode;
|
||||
- (NSString *)identifier;
|
||||
- (id)initWithIdentifier: (NSString *)indentifier;
|
||||
- (void)insertItemWithItemIdentifier: (NSString *)itemIdentifier
|
||||
atIndex: (int)index;
|
||||
- (BOOL)isVisible;
|
||||
- (NSArray *)items;
|
||||
- (void)removeItemAtIndex: (int)index;
|
||||
- (void)runCustomizationPalette: (id)sender;
|
||||
|
||||
- (void)setAllowsUserCustomization: (BOOL)flag;
|
||||
- (void)setAutosavesConfiguration: (BOOL)flag;
|
||||
- (void)setConfigurationFromDictionary: (NSDictionary *)configDict;
|
||||
- (void)setDelegate: (id)delegate;
|
||||
- (void)setDisplayMode: (NSToolbarDisplayMode)displayMode;
|
||||
- (void)setVisible: (BOOL)shown;
|
||||
- (void)validateVisibleItems;
|
||||
- (NSArray *)visibleItems;
|
||||
@end /* interface of NSToolbar */
|
||||
|
||||
/*
|
||||
* Methods Implemented by the Delegate
|
||||
*/
|
||||
@interface NSObject (NSToolbarDelegate)
|
||||
// notification methods
|
||||
- (void) toolbarDidRemoveItem: (NSNotification *)aNotification;
|
||||
- (void) toolbarWillAddItem: (NSNotification *)aNotification;
|
||||
|
||||
// delegate methods
|
||||
// required method
|
||||
- (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
|
||||
itemForItemIdentifier: (NSString *)itemIdentifier
|
||||
willBeInsertedIntoToolbar: (BOOL)flag;
|
||||
// required method
|
||||
- (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar;
|
||||
// required method
|
||||
- (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar;
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_NSToolbar */
|
114
Headers/gnustep/gui/NSToolbarItem.h
Normal file
114
Headers/gnustep/gui/NSToolbarItem.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
NSToolbarItem.h
|
||||
|
||||
The toolbar item class.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>,
|
||||
Fabien Vallon <fabien.vallon@fr.alcove.com>
|
||||
Date: May 2002
|
||||
|
||||
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 Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSToolbarItem
|
||||
#define _GNUstep_H_NSToolbarItem
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <AppKit/NSValidatedUserInterfaceItem.h>
|
||||
#include <AppKit/AppKitDefines.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSString;
|
||||
@class NSDictionary;
|
||||
@class NSMutableDictionary;
|
||||
@class NSToolbar;
|
||||
@class NSImage;
|
||||
@class NSMenuItem;
|
||||
@class NSView;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
APPKIT_EXPORT NSString *NSToolbarSeperatorItemIdentifier;
|
||||
APPKIT_EXPORT NSString *NSToolbarSpaceItemIdentifier;
|
||||
APPKIT_EXPORT NSString *NSToolbarFlexibleSpaveItemIdentifier;
|
||||
APPKIT_EXPORT NSString *NSToolbarShowColorsItemIdentifier;
|
||||
APPKIT_EXPORT NSString *NSToolbarShowFontsItemIdentifier;
|
||||
APPKIT_EXPORT NSString *NSToolbarCustomizeToolbarItemIdentifier;
|
||||
APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier;
|
||||
|
||||
@interface NSToolbarItem : NSObject <NSCopying, NSValidatedUserInterfaceItem>
|
||||
{
|
||||
// externally visible variables
|
||||
SEL _action;
|
||||
BOOL _allowsDuplicatesInToolbar;
|
||||
BOOL _enabled;
|
||||
NSImage *_image;
|
||||
NSString *_itemIdentifier;
|
||||
NSString *_label;
|
||||
NSSize _maxSize;
|
||||
NSMenuItem *_menuFormRepresentation;
|
||||
NSSize _minSize;
|
||||
NSString *_paletteLabel;
|
||||
int _tag;
|
||||
id _target;
|
||||
NSToolbar *_toolbar;
|
||||
NSString *_toolTip;
|
||||
NSView *_view;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
- (SEL)action;
|
||||
- (BOOL)allowsDuplicatesInToolbar;
|
||||
- (NSImage *)image;
|
||||
- (id)initWithItemIdentifier: (NSString *)itemIdentifier;
|
||||
- (BOOL)isEnabled;
|
||||
- (NSString *)itemIdentifier;
|
||||
- (NSString *)label;
|
||||
- (NSSize)maxSize;
|
||||
- (NSMenuItem *)menuFormRepresentation;
|
||||
- (NSSize)minSize;
|
||||
- (NSString *)paletteLabel;
|
||||
- (void)setAction: (SEL)action;
|
||||
- (void)setEnabled: (BOOL)enabled;
|
||||
- (void)setImage: (NSImage *)image;
|
||||
- (void)setLabel: (NSString *)label;
|
||||
- (void)setMaxSize: (NSSize)maxSize;
|
||||
- (void)setMenuFormRepresentation: (NSMenuItem *)menuItem;
|
||||
- (void)setMinSize: (NSSize)minSize;
|
||||
- (void)setPaletteLabel: (NSString *)paletteLabel;
|
||||
- (void)setTag: (int)tag;
|
||||
- (void)setTarget: (id)target;
|
||||
- (void)setToolTip: (NSString *)toolTip;
|
||||
- (void)setView: (NSView *)view;
|
||||
- (int)tag;
|
||||
- (id)target;
|
||||
- (NSString *)toolTip;
|
||||
- (NSToolbar *)toolbar;
|
||||
- (void)validate;
|
||||
- (NSView *)view;
|
||||
@end /* interface of NSToolbarItem */
|
||||
|
||||
@protocol NSToolbarItemValidation
|
||||
- (BOOL)validateToolbarItem: (NSToolbarItem *)theItem;
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_NSToolbarItem */
|
|
@ -139,6 +139,8 @@ APPKIT_EXPORT NSSize NSTokenSize;
|
|||
int _counterpart;
|
||||
float _alphaValue;
|
||||
|
||||
NSToolbar *_toolbar;
|
||||
|
||||
struct GSWindowFlagsType {
|
||||
unsigned accepts_drag:1;
|
||||
unsigned is_one_shot:1;
|
||||
|
|
|
@ -143,6 +143,8 @@ NSTextField.m \
|
|||
NSTextFieldCell.m \
|
||||
NSTextStorage.m \
|
||||
NSTextView.m \
|
||||
NSToolbar.m \
|
||||
NSToolbarItem.m \
|
||||
NSView.m \
|
||||
NSWindow.m \
|
||||
NSWindowController.m \
|
||||
|
@ -285,6 +287,8 @@ NSTextField.h \
|
|||
NSTextFieldCell.h \
|
||||
NSTextStorage.h \
|
||||
NSTextView.h \
|
||||
NSToolbar.h \
|
||||
NSToolbarItem.h \
|
||||
NSView.h \
|
||||
NSWindow.h \
|
||||
NSWindowController.h \
|
||||
|
@ -321,6 +325,7 @@ NSNibDeclarations.h \
|
|||
NSNibLoading.h \
|
||||
NSSpellProtocol.h \
|
||||
NSUserInterfaceValidation.h \
|
||||
NSValidatedUserInterfaceItem.h \
|
||||
PSOperators.h \
|
||||
nsimage-tiff.h
|
||||
|
||||
|
|
|
@ -141,6 +141,29 @@ static NSImage *unexpandable = nil;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_items);
|
||||
RELEASE(_expandedItems);
|
||||
NSFreeMapTable(_itemDict);
|
||||
NSFreeMapTable(_levelOfItems);
|
||||
|
||||
if(_autosaveExpandedItems)
|
||||
{
|
||||
// notify when an item expands...
|
||||
[nc removeObserver: self
|
||||
name: NSOutlineViewItemDidExpandNotification
|
||||
object: self];
|
||||
|
||||
// notify when an item collapses...
|
||||
[nc removeObserver: self
|
||||
name: NSOutlineViewItemDidCollapseNotification
|
||||
object: self];
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)autoResizesOutlineColumn
|
||||
{
|
||||
return _autoResizesOutlineColumn;
|
||||
|
|
|
@ -25,13 +25,6 @@
|
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
// All selecting methods have been overriden to do nothing, I don't know if this
|
||||
// will hinder overall behavior of the specs, as I have never used the real thing.
|
||||
//
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSSecureTextField.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
|
|
273
Source/NSToolbar.m
Normal file
273
Source/NSToolbar.m
Normal file
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
<title>NSToolbar.m</title>
|
||||
|
||||
<abstract>The toolbar class.</abstract>
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>,
|
||||
Fabien Vallon <fabien.vallon@fr.alcove.com>
|
||||
Date: May 2002
|
||||
|
||||
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 Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <AppKit/NSToolbarItem.h>
|
||||
#include <AppKit/NSToolbar.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSButton.h>
|
||||
// #include <AppKit/GSHbox.h>
|
||||
|
||||
static NSNotificationCenter *nc = nil;
|
||||
static const int current_version = 1;
|
||||
|
||||
@interface GSToolbarView : NSView
|
||||
{
|
||||
NSToolbar *_toolbar;
|
||||
}
|
||||
- (void)setToolbar: (NSToolbar *)toolbar;
|
||||
- (NSToolbar *)toolbar;
|
||||
@end
|
||||
|
||||
@implementation GSToolbarView
|
||||
- (void)setToolbar: (NSToolbar *)toolbar
|
||||
{
|
||||
ASSIGN(_toolbar, toolbar);
|
||||
}
|
||||
|
||||
- (NSToolbar *)toolbar
|
||||
{
|
||||
return _toolbar;
|
||||
}
|
||||
|
||||
- (void)drawRect: (NSRect)aRect
|
||||
{
|
||||
[super drawRect: aRect];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GSToolbarButton : NSButton
|
||||
{
|
||||
NSToolbarItem *_item;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GSToolbarButton
|
||||
- (id)initWithItem: (NSToolbarItem *)item
|
||||
{
|
||||
[super init];
|
||||
ASSIGN(_item, item);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect: (NSRect)aRect
|
||||
{
|
||||
// set the image and draw using the super class...
|
||||
[super drawRect: aRect];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSToolbar (GNUstepPrivate)
|
||||
- (GSToolbarView *) _toolbarView;
|
||||
@end
|
||||
|
||||
@implementation NSToolbar (GNUstepPrivate)
|
||||
- (GSToolbarView *) _toolbarView
|
||||
{
|
||||
return _toolbarView;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSToolbar
|
||||
// Initialize the class when it is loaded
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSToolbar class])
|
||||
{
|
||||
[self setVersion: current_version];
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
}
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
- (BOOL)allowsUserCustomization
|
||||
{
|
||||
return _allowsUserCustomization;
|
||||
}
|
||||
|
||||
- (BOOL)autosavesConfiguration
|
||||
{
|
||||
return _autosavesConfiguration;
|
||||
}
|
||||
|
||||
- (NSDictionary *)configurationDictionary
|
||||
{
|
||||
return _configurationDictionary;
|
||||
}
|
||||
|
||||
- (BOOL)customizationPaletteIsRunning
|
||||
{
|
||||
return _customizationPaletteIsRunning;
|
||||
}
|
||||
|
||||
- (id)delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
- (NSToolbarDisplayMode)displayMode
|
||||
{
|
||||
return _displayMode;
|
||||
}
|
||||
|
||||
- (NSString *)identifier
|
||||
{
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
- (void) _loadConfig
|
||||
{
|
||||
if(_identifier != nil)
|
||||
{
|
||||
NSUserDefaults *defaults;
|
||||
NSString *tableKey;
|
||||
id config;
|
||||
|
||||
defaults = [NSUserDefaults standardUserDefaults];
|
||||
tableKey = [NSString stringWithFormat: @"NSToolbar Config %@",
|
||||
_identifier];
|
||||
config = [defaults objectForKey: tableKey];
|
||||
|
||||
if (config != nil)
|
||||
{
|
||||
NSEnumerator *en = [config objectEnumerator];
|
||||
id item = nil;
|
||||
|
||||
while ((item = [en nextObject]) != nil)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithIdentifier: (NSString *)identifier
|
||||
{
|
||||
[super init];
|
||||
ASSIGN(_identifier, identifier);
|
||||
[self _loadConfig];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)insertItemWithItemIdentifier: (NSString *)itemIdentifier
|
||||
atIndex: (int)index
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)isVisible
|
||||
{
|
||||
return _visible;
|
||||
}
|
||||
|
||||
- (NSArray *)items
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
- (void)removeItemAtIndex: (int)index
|
||||
{
|
||||
}
|
||||
|
||||
- (void)runCustomizationPalette: (id)sender
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setAllowsUserCustomization: (BOOL)flag
|
||||
{
|
||||
_allowsUserCustomization = flag;
|
||||
}
|
||||
|
||||
- (void)setAutosavesConfiguration: (BOOL)flag
|
||||
{
|
||||
_autosavesConfiguration = flag;
|
||||
}
|
||||
|
||||
- (void)setConfigurationFromDictionary: (NSDictionary *)configDict
|
||||
{
|
||||
if(!_configurationDictionary)
|
||||
{
|
||||
RELEASE(_configurationDictionary);
|
||||
}
|
||||
ASSIGN(_configurationDictionary, configDict);
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id)anObject
|
||||
{
|
||||
#define CHECK_REQUIRED_METHOD(selector_name) \
|
||||
if (![anObject 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:);
|
||||
|
||||
if (_delegate)
|
||||
[nc removeObserver: _delegate name: nil object: self];
|
||||
_delegate = anObject;
|
||||
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
- (void)setDisplayMode: (NSToolbarDisplayMode)displayMode
|
||||
{
|
||||
_displayMode = displayMode;
|
||||
}
|
||||
|
||||
- (void)setVisible: (BOOL)shown
|
||||
{
|
||||
_visible = shown;
|
||||
}
|
||||
|
||||
- (void)validateVisibleItems
|
||||
{
|
||||
}
|
||||
|
||||
- (NSArray *)visibleItems
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
@end /* interface of NSToolbar */
|
||||
|
||||
|
188
Source/NSToolbarItem.m
Normal file
188
Source/NSToolbarItem.m
Normal file
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
NSToolbarItem.m
|
||||
|
||||
The Toolbar item class.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>,
|
||||
Fabien Vallon <fabien.vallon@fr.alcove.com>
|
||||
Date: May 2002
|
||||
|
||||
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 Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <AppKit/NSToolbarItem.h>
|
||||
#include <AppKit/NSToolbar.h>
|
||||
#include <AppKit/NSMenuItem.h>
|
||||
|
||||
@implementation NSToolbarItem
|
||||
- (BOOL)allowsDuplicatesInToolbar
|
||||
{
|
||||
return _allowsDuplicatesInToolbar;
|
||||
}
|
||||
|
||||
- (NSImage *)image
|
||||
{
|
||||
return _image;
|
||||
}
|
||||
|
||||
- (id)initWithItemIdentifier: (NSString *)itemIdentifier
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isEnabled
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
- (NSString *)itemIdentifier
|
||||
{
|
||||
return _itemIdentifier;
|
||||
}
|
||||
|
||||
- (NSString *)label
|
||||
{
|
||||
return _label;
|
||||
}
|
||||
|
||||
- (NSSize)maxSize
|
||||
{
|
||||
return _maxSize;
|
||||
}
|
||||
|
||||
- (NSMenuItem *)menuFormRepresentation
|
||||
{
|
||||
return _menuFormRepresentation;
|
||||
}
|
||||
|
||||
- (NSSize)minSize
|
||||
{
|
||||
return _minSize;
|
||||
}
|
||||
|
||||
- (NSString *)paletteLabel
|
||||
{
|
||||
return _paletteLabel;
|
||||
}
|
||||
|
||||
- (void)setAction: (SEL)action
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
||||
- (void)setEnabled: (BOOL)enabled
|
||||
{
|
||||
enabled = _enabled;
|
||||
}
|
||||
|
||||
- (void)setImage: (NSImage *)image
|
||||
{
|
||||
ASSIGN(_image, image);
|
||||
}
|
||||
|
||||
- (void)setLabel: (NSString *)label
|
||||
{
|
||||
ASSIGN(_label, label);
|
||||
}
|
||||
|
||||
- (void)setMaxSize: (NSSize)maxSize
|
||||
{
|
||||
_maxSize = maxSize;
|
||||
}
|
||||
|
||||
- (void)setMenuFormRepresentation: (NSMenuItem *)menuItem
|
||||
{
|
||||
ASSIGN(_menuFormRepresentation, menuItem);
|
||||
}
|
||||
|
||||
- (void)setMinSize: (NSSize)minSize
|
||||
{
|
||||
_minSize = minSize;
|
||||
}
|
||||
|
||||
- (void)setPaletteLabel: (NSString *)paletteLabel
|
||||
{
|
||||
ASSIGN(_paletteLabel, paletteLabel);
|
||||
}
|
||||
|
||||
- (void)setTag: (int)tag
|
||||
{
|
||||
_tag = tag;
|
||||
}
|
||||
|
||||
- (void)setTarget: (id)target
|
||||
{
|
||||
ASSIGN(_target, target);
|
||||
}
|
||||
|
||||
- (void)setToolTip: (NSString *)toolTip
|
||||
{
|
||||
ASSIGN(_toolTip, toolTip);
|
||||
}
|
||||
|
||||
- (void)setView: (NSView *)view
|
||||
{
|
||||
ASSIGN(_view, view);
|
||||
}
|
||||
|
||||
- (int)tag
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
- (NSString *)toolTip
|
||||
{
|
||||
return _toolTip;
|
||||
}
|
||||
|
||||
- (NSToolbar *)toolbar
|
||||
{
|
||||
return _toolbar;
|
||||
}
|
||||
|
||||
- (void)validate
|
||||
{
|
||||
}
|
||||
|
||||
- (NSView *)view
|
||||
{
|
||||
return _view;
|
||||
}
|
||||
|
||||
// NSValidatedUserInterfaceItem protocol
|
||||
- (SEL)action
|
||||
{
|
||||
return _action;
|
||||
}
|
||||
|
||||
- (id)target
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
|
||||
// NSCopying protocol
|
||||
- (id)copyWithZone: (NSZone *)zone
|
||||
{
|
||||
return self;
|
||||
}
|
||||
@end
|
|
@ -3814,17 +3814,14 @@ resetCursorRectsForView(NSView *theView)
|
|||
|
||||
- (void) setToolbar: (NSToolbar*)toolbar
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"drawers", "NSWindow");
|
||||
ASSIGN(_toolbar, toolbar);
|
||||
[_wv addSubview: [toolbar _toolbarView]];
|
||||
[self setViewsNeedDisplay: YES];
|
||||
}
|
||||
|
||||
- (NSToolbar *) toolbar
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"drawers", "NSWindow");
|
||||
return nil;
|
||||
return _toolbar;
|
||||
}
|
||||
|
||||
- (void) toggleToolbarShown: (id)sender
|
||||
|
@ -3836,7 +3833,7 @@ resetCursorRectsForView(NSView *theView)
|
|||
|
||||
- (void) runToolbarCustomizationPalette: (id)sender
|
||||
{
|
||||
// TODO
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"runToolbarCustomizationPalette:", "NSWindow");
|
||||
}
|
||||
|
|
|
@ -421,6 +421,19 @@ NSString *NSBaselineOffsetAttributeName = @"NSBaselineOffsetAttributeName";
|
|||
NSString *NSKernAttributeName = @"NSKernAttributeName";
|
||||
NSString *NSLinkAttributeName = @"NSLinkAttributeName";
|
||||
|
||||
// NSToolbar notifications
|
||||
NSString *NSToolbarDidRemoveItemNotification = @"NSToolbarDidRemoveItemNotification";
|
||||
NSString *NSToolbarWillAddItemNotification = @"NSToolbarWillAddItemNotification";
|
||||
|
||||
// NSToolbarItem constants
|
||||
NSString *NSToolbarSeperatorItemIdentifier = @"NSToolbarSeperatorItemIdentifier";
|
||||
NSString *NSToolbarSpaceItemIdentifier = @"NSToolbarSpaceItemIdentifier";
|
||||
NSString *NSToolbarFlexibleSpaveItemIdentifier = @"NSToolbarFlexibleSpaveItemIdentifier";
|
||||
NSString *NSToolbarShowColorsItemIdentifier = @"NSToolbarShowColorsItemIdentifier";
|
||||
NSString *NSToolbarShowFontsItemIdentifier = @"NSToolbarShowFontsItemIdentifier";
|
||||
NSString *NSToolbarCustomizeToolbarItemIdentifier = @"NSToolbarCustomizeToolbarItemIdentifier";
|
||||
NSString *NSToolbarPrintItemIdentifier = @"NSToolbarPrintItemIdentifier";
|
||||
|
||||
/*
|
||||
* NSTextView userInfo for notifications
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue