mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 18:50:48 +00:00
* Headers/AppKit/NSTokenFieldCell.h
* Headers/AppKit/NSTokenField.h: Headers for new class. * Source/GNUmakefile * Source/NSDocumentController.m: Added code to handle the CF keys as well as the NS keys for document oriented apps. * Source/NSTokenFieldCell.m * Source/NSTokenField.m: Start of implementation for this class git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26801 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fb69a9fd22
commit
975469ff71
7 changed files with 452 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2008-08-07 18:23-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSTokenFieldCell.h
|
||||||
|
* Headers/AppKit/NSTokenField.h: Headers for new class.
|
||||||
|
* Source/GNUmakefile
|
||||||
|
* Source/NSDocumentController.m: Added code to handle the
|
||||||
|
CF keys as well as the NS keys for document oriented apps.
|
||||||
|
* Source/NSTokenFieldCell.m
|
||||||
|
* Source/NSTokenField.m: Start of implementation for this class.
|
||||||
|
|
||||||
2008-08-02 Fred Kiefer <FredKiefer@gmx.de>
|
2008-08-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSScrollView.m (-initWithCoder:): Handle non-retained
|
* Source/NSScrollView.m (-initWithCoder:): Handle non-retained
|
||||||
|
|
53
Headers/AppKit/NSTokenField.h
Normal file
53
Headers/AppKit/NSTokenField.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
NSTokenField.h
|
||||||
|
|
||||||
|
Token field control class for text entry
|
||||||
|
|
||||||
|
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory Casamento <greg.casamento@gmail.com>
|
||||||
|
Date: 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 <http://www.gnu.org/licenses/> or write to the
|
||||||
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNUstep_H_NSTokenField
|
||||||
|
#define _GNUstep_H_NSTokenField
|
||||||
|
|
||||||
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
|
#include <AppKit/NSTextField.h>
|
||||||
|
#include <AppKit/NSTokenFieldCell.h>
|
||||||
|
|
||||||
|
@interface NSTokenField : NSTextField
|
||||||
|
// Style...
|
||||||
|
- (NSTokenStyle)tokenStyle;
|
||||||
|
- (void)setTokenStyle:(NSTokenStyle)style;
|
||||||
|
|
||||||
|
// Completion delay...
|
||||||
|
+ (NSTimeInterval)defaultCompletionDelay;
|
||||||
|
- (NSTimeInterval)completionDelay;
|
||||||
|
- (void)setCompletionDelay:(NSTimeInterval)delay;
|
||||||
|
|
||||||
|
// Character set...
|
||||||
|
+ (NSCharacterSet *)defaultTokenizingCharacterSet;
|
||||||
|
- (void)setTokenizingCharacterSet:(NSCharacterSet *)characterSet;
|
||||||
|
- (NSCharacterSet *)tokenizingCharacterSet;
|
||||||
|
@end;
|
||||||
|
|
||||||
|
#endif // _GNUstep_H_NSTokenField
|
66
Headers/AppKit/NSTokenFieldCell.h
Normal file
66
Headers/AppKit/NSTokenFieldCell.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
NSTokenFieldCell.h
|
||||||
|
|
||||||
|
Cell class for the token field entry control
|
||||||
|
|
||||||
|
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory Casamento <greg.casamento@gmail.com>
|
||||||
|
Date: 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 <http://www.gnu.org/licenses/> or write to the
|
||||||
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNUstep_H_NSTokenFieldCell
|
||||||
|
#define _GNUstep_H_NSTokenFieldCell
|
||||||
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
|
|
||||||
|
#include <AppKit/NSTextFieldCell.h>
|
||||||
|
|
||||||
|
typedef enum _NSTokenStyle
|
||||||
|
{
|
||||||
|
NSDefaultTokenStyle = 0,
|
||||||
|
NSPlainTextTokenStyle,
|
||||||
|
NSRoundedTokenStyle
|
||||||
|
} NSTokenStyle;
|
||||||
|
|
||||||
|
|
||||||
|
@interface NSTokenFieldCell : NSTextFieldCell <NSCoding>
|
||||||
|
{
|
||||||
|
NSTokenStyle tokenStyle;
|
||||||
|
NSTimeInterval completionDelay;
|
||||||
|
NSCharacterSet *tokenizingCharacterSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Style...
|
||||||
|
- (NSTokenStyle)tokenStyle;
|
||||||
|
- (void)setTokenStyle:(NSTokenStyle)style;
|
||||||
|
|
||||||
|
// Completion delay...
|
||||||
|
+ (NSTimeInterval)defaultCompletionDelay;
|
||||||
|
- (NSTimeInterval)completionDelay;
|
||||||
|
- (void)setCompletionDelay:(NSTimeInterval)delay;
|
||||||
|
|
||||||
|
// Character set...
|
||||||
|
+ (NSCharacterSet *)defaultTokenizingCharacterSet;
|
||||||
|
- (void)setTokenizingCharacterSet:(NSCharacterSet *)characterSet;
|
||||||
|
- (NSCharacterSet *)tokenizingCharacterSet;
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // _GNUstep_H_NSTokenFieldCell
|
|
@ -175,6 +175,8 @@ NSTextTable.m \
|
||||||
NSTextTableBlock.m \
|
NSTextTableBlock.m \
|
||||||
NSToolbar.m \
|
NSToolbar.m \
|
||||||
NSToolbarItem.m \
|
NSToolbarItem.m \
|
||||||
|
NSTokenField.m \
|
||||||
|
NSTokenFieldCell.m \
|
||||||
NSUserDefaultsController.m \
|
NSUserDefaultsController.m \
|
||||||
NSView.m \
|
NSView.m \
|
||||||
NSWindow+Toolbar.m \
|
NSWindow+Toolbar.m \
|
||||||
|
@ -365,6 +367,8 @@ NSTextTable.h \
|
||||||
NSTextView.h \
|
NSTextView.h \
|
||||||
NSToolbar.h \
|
NSToolbar.h \
|
||||||
NSToolbarItem.h \
|
NSToolbarItem.h \
|
||||||
|
NSTokenField.h \
|
||||||
|
NSTokenFieldCell.h \
|
||||||
NSUserDefaultsController.h \
|
NSUserDefaultsController.h \
|
||||||
NSView.h \
|
NSView.h \
|
||||||
NSWindow.h \
|
NSWindow.h \
|
||||||
|
|
|
@ -54,6 +54,11 @@ static NSString *NSDOSExtensionsKey = @"NSDOSExtensions";
|
||||||
//static NSString *NSMIMETypesKey = @"NSMIMETypes";
|
//static NSString *NSMIMETypesKey = @"NSMIMETypes";
|
||||||
static NSString *NSDocumentClassKey = @"NSDocumentClass";
|
static NSString *NSDocumentClassKey = @"NSDocumentClass";
|
||||||
|
|
||||||
|
static NSString *CFBundleDocumentTypes = @"CFBundleDocumentTypes";
|
||||||
|
static NSString *CFBundleTypeExtensions = @"CFBundleTypeExtensions";
|
||||||
|
static NSString *CFBundleTypeName = @"CFBundleTypeName";
|
||||||
|
static NSString *CFBundleTypeRole = @"CFBundleTypeRole";
|
||||||
|
|
||||||
static NSString *NSRecentDocuments = @"NSRecentDocuments";
|
static NSString *NSRecentDocuments = @"NSRecentDocuments";
|
||||||
static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
|
static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
|
||||||
|
|
||||||
|
@ -73,6 +78,10 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
|
||||||
{
|
{
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
else if ([[dict objectForKey: CFBundleTypeName] isEqualToString: typeName])
|
||||||
|
{
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -89,6 +98,10 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
{
|
{
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
else if ([[dict objectForKey: CFBundleTypeName] isEqualToString: typeName])
|
||||||
|
{
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -156,8 +169,9 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
*/
|
*/
|
||||||
+ (BOOL) isDocumentBasedApplication
|
+ (BOOL) isDocumentBasedApplication
|
||||||
{
|
{
|
||||||
return ([[[NSBundle mainBundle] infoDictionary] objectForKey: NSTypesKey])
|
return ([[[NSBundle mainBundle] infoDictionary] objectForKey: NSTypesKey] ||
|
||||||
? YES : NO;
|
[[[NSBundle mainBundle] infoDictionary] objectForKey: CFBundleDocumentTypes])
|
||||||
|
? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** </init>Initializes the document controller class. The first
|
/** </init>Initializes the document controller class. The first
|
||||||
|
@ -169,6 +183,12 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
NSDictionary *customDict = [[NSBundle mainBundle] infoDictionary];
|
NSDictionary *customDict = [[NSBundle mainBundle] infoDictionary];
|
||||||
|
|
||||||
ASSIGN (_types, [customDict objectForKey: NSTypesKey]);
|
ASSIGN (_types, [customDict objectForKey: NSTypesKey]);
|
||||||
|
|
||||||
|
if(_types == nil)
|
||||||
|
{
|
||||||
|
ASSIGN(_types, [customDict objectForKey: CFBundleDocumentTypes]);
|
||||||
|
}
|
||||||
|
|
||||||
_documents = [[NSMutableArray alloc] init];
|
_documents = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
/* Get list of recent documents */
|
/* Get list of recent documents */
|
||||||
|
@ -344,12 +364,19 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
|
|
||||||
- (NSString*) defaultType
|
- (NSString*) defaultType
|
||||||
{
|
{
|
||||||
|
NSString *defaultName = nil;
|
||||||
if ([_types count] == 0)
|
if ([_types count] == 0)
|
||||||
{
|
{
|
||||||
return nil; // raise exception?
|
return nil; // raise exception?
|
||||||
}
|
}
|
||||||
|
|
||||||
return [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: NSNameKey];
|
defaultName = [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: NSNameKey];
|
||||||
|
if(defaultName == nil)
|
||||||
|
{
|
||||||
|
defaultName = [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: CFBundleTypeName];
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultName;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) addDocument: (NSDocument *)document
|
- (void) addDocument: (NSDocument *)document
|
||||||
|
@ -577,6 +604,7 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
||||||
[array addObjectsFromArray: [typeInfo objectForKey: NSUnixExtensionsKey]];
|
[array addObjectsFromArray: [typeInfo objectForKey: NSUnixExtensionsKey]];
|
||||||
[array addObjectsFromArray: [typeInfo objectForKey: NSDOSExtensionsKey]];
|
[array addObjectsFromArray: [typeInfo objectForKey: NSDOSExtensionsKey]];
|
||||||
|
[array addObjectsFromArray: [typeInfo objectForKey: CFBundleTypeExtensions]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
|
@ -943,9 +971,16 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
||||||
if ([[typeInfo objectForKey:NSUnixExtensionsKey]
|
if ([[typeInfo objectForKey:NSUnixExtensionsKey]
|
||||||
containsObject: fileExtension] ||
|
containsObject: fileExtension] ||
|
||||||
[[typeInfo objectForKey:NSDOSExtensionsKey]
|
[[typeInfo objectForKey:NSDOSExtensionsKey]
|
||||||
|
containsObject: fileExtension] ||
|
||||||
|
[[typeInfo objectForKey:CFBundleTypeExtensions]
|
||||||
containsObject: fileExtension])
|
containsObject: fileExtension])
|
||||||
{
|
{
|
||||||
return [typeInfo objectForKey: NSNameKey];
|
NSString *type = [typeInfo objectForKey: NSNameKey];
|
||||||
|
if(type == nil)
|
||||||
|
{
|
||||||
|
type = [typeInfo objectForKey: CFBundleTypeName];
|
||||||
|
}
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,12 +1107,23 @@ static NSString *NSViewerRole = @"Viewer";
|
||||||
NSString *className = [typeInfo objectForKey: NSDocumentClassKey];
|
NSString *className = [typeInfo objectForKey: NSDocumentClassKey];
|
||||||
NSString *role = [typeInfo objectForKey: NSRoleKey];
|
NSString *role = [typeInfo objectForKey: NSRoleKey];
|
||||||
|
|
||||||
|
// if the standard one isn't filled... check the CF key.
|
||||||
|
if(role == nil)
|
||||||
|
{
|
||||||
|
role = [typeInfo objectForKey: CFBundleTypeRole];
|
||||||
|
}
|
||||||
|
|
||||||
if ([docClassName isEqualToString: className]
|
if ([docClassName isEqualToString: className]
|
||||||
&& (role == nil
|
&& (role == nil
|
||||||
|| [role isEqual: NSEditorRole]
|
|| [role isEqual: NSEditorRole]
|
||||||
|| [role isEqual: NSViewerRole]))
|
|| [role isEqual: NSViewerRole]))
|
||||||
{
|
{
|
||||||
[types addObject: [typeInfo objectForKey: NSNameKey]];
|
NSString *name = [typeInfo objectForKey: NSNameKey];
|
||||||
|
if(name == nil)
|
||||||
|
{
|
||||||
|
name = [typeInfo objectForKey: CFBundleTypeName];
|
||||||
|
}
|
||||||
|
[types addObject: name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1145,12 @@ static NSString *NSViewerRole = @"Viewer";
|
||||||
if ([docClassName isEqualToString: className] &&
|
if ([docClassName isEqualToString: className] &&
|
||||||
(role == nil || [role isEqual: NSEditorRole]))
|
(role == nil || [role isEqual: NSEditorRole]))
|
||||||
{
|
{
|
||||||
[types addObject: [typeInfo objectForKey: NSNameKey]];
|
NSString *name = [typeInfo objectForKey: NSNameKey];
|
||||||
|
if(name == nil)
|
||||||
|
{
|
||||||
|
name = [typeInfo objectForKey: CFBundleTypeName];
|
||||||
|
}
|
||||||
|
[types addObject: name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
140
Source/NSTokenField.m
Normal file
140
Source/NSTokenField.m
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
/** <title>NSTokenField</title>
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
Token field control class for token entry. The default token is ",".
|
||||||
|
</abstract>
|
||||||
|
|
||||||
|
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory Casamento <greg.casamento@gmail.com>
|
||||||
|
Date: July 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 <http://www.gnu.org/licenses/> or write to the
|
||||||
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "AppKit/NSApplication.h"
|
||||||
|
#include "AppKit/NSCursor.h"
|
||||||
|
#include "AppKit/NSGraphics.h"
|
||||||
|
#include "AppKit/NSTokenField.h"
|
||||||
|
#include "AppKit/NSTokenFieldCell.h"
|
||||||
|
#include "AppKit/NSWindow.h"
|
||||||
|
#include "AppKit/NSKeyValueBinding.h"
|
||||||
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include "GSBindingHelpers.h"
|
||||||
|
|
||||||
|
static NSNotificationCenter *nc = nil;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class variables
|
||||||
|
*/
|
||||||
|
static Class usedCellClass;
|
||||||
|
static Class tokenFieldCellClass;
|
||||||
|
|
||||||
|
@implementation NSTokenField
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class methods
|
||||||
|
//
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
if (self == [NSTokenField class])
|
||||||
|
{
|
||||||
|
[self setVersion: 1];
|
||||||
|
tokenFieldCellClass = [NSTokenFieldCell class];
|
||||||
|
usedCellClass = tokenFieldCellClass;
|
||||||
|
nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
|
[self exposeBinding: NSEditableBinding];
|
||||||
|
[self exposeBinding: NSTextColorBinding];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithFrame: (NSRect)frame
|
||||||
|
{
|
||||||
|
if((self = [super initWithFrame: frame]) == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
// initialize...
|
||||||
|
[_cell setTokenStyle: NSDefaultTokenStyle];
|
||||||
|
[_cell setCompletionDelay: [_cell defaultCompletionDelay]];
|
||||||
|
[_cell setTokenizingCharacterSet: [_cell defaultTokenizingCharacterSet]];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setting the Cell class
|
||||||
|
*/
|
||||||
|
+ (Class) cellClass
|
||||||
|
{
|
||||||
|
return usedCellClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) setCellClass: (Class)factoryId
|
||||||
|
{
|
||||||
|
usedCellClass = factoryId ? factoryId : tokenFieldCellClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Style...
|
||||||
|
- (NSTokenStyle)tokenStyle
|
||||||
|
{
|
||||||
|
return [_cell tokenStyle];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTokenStyle:(NSTokenStyle)style
|
||||||
|
{
|
||||||
|
[_cell setTokenStyle: style];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Completion delay...
|
||||||
|
+ (NSTimeInterval)defaultCompletionDelay
|
||||||
|
{
|
||||||
|
return [usedCellClass defaultCompletionDelay];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSTimeInterval)completionDelay
|
||||||
|
{
|
||||||
|
return [_cell completionDelay];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setCompletionDelay:(NSTimeInterval)delay
|
||||||
|
{
|
||||||
|
[_cell setCompletionDelay: delay];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Character set...
|
||||||
|
+ (NSCharacterSet *)defaultTokenizingCharacterSet
|
||||||
|
{
|
||||||
|
return [usedCellClass defaultTokenizingCharacterSet];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTokenizingCharacterSet:(NSCharacterSet *)characterSet
|
||||||
|
{
|
||||||
|
[_cell setTokenizingCharacterSet: characterSet];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSCharacterSet *)tokenizingCharacterSet
|
||||||
|
{
|
||||||
|
return [_cell tokenizingCharacterSet];
|
||||||
|
}
|
||||||
|
@end
|
122
Source/NSTokenFieldCell.m
Normal file
122
Source/NSTokenFieldCell.m
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
/** <title>NSTokenFieldCell</title>
|
||||||
|
|
||||||
|
<abstract>Cell class for the token field entry control</abstract>
|
||||||
|
|
||||||
|
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Gregory Casamento <greg.casamento@gmail.com>
|
||||||
|
Date: July 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 <http://www.gnu.org/licenses/> or write to the
|
||||||
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include <Foundation/NSCharacterSet.h>
|
||||||
|
#include "AppKit/NSControl.h"
|
||||||
|
#include "AppKit/NSEvent.h"
|
||||||
|
#include "AppKit/NSTokenField.h"
|
||||||
|
#include "AppKit/NSTokenFieldCell.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSTokenFieldCell
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
if (self == [NSTokenFieldCell class])
|
||||||
|
{
|
||||||
|
[self setVersion: 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
RELEASE(tokenizingCharacterSet);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// NSCoding protocol
|
||||||
|
//
|
||||||
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
|
{
|
||||||
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
|
if ([aCoder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
|
{
|
||||||
|
self = [super initWithCoder: aDecoder];
|
||||||
|
|
||||||
|
if ([aDecoder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
// Style...
|
||||||
|
- (NSTokenStyle)tokenStyle
|
||||||
|
{
|
||||||
|
return tokenStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTokenStyle:(NSTokenStyle)style
|
||||||
|
{
|
||||||
|
tokenStyle = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Completion delay...
|
||||||
|
+ (NSTimeInterval)defaultCompletionDelay
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSTimeInterval)completionDelay
|
||||||
|
{
|
||||||
|
return completionDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setCompletionDelay:(NSTimeInterval)delay
|
||||||
|
{
|
||||||
|
completionDelay = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Character set...
|
||||||
|
+ (NSCharacterSet *)defaultTokenizingCharacterSet
|
||||||
|
{
|
||||||
|
return [NSCharacterSet characterSetWithCharactersInString: @","];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTokenizingCharacterSet:(NSCharacterSet *)characterSet
|
||||||
|
{
|
||||||
|
ASSIGN(tokenizingCharacterSet, characterSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSCharacterSet *)tokenizingCharacterSet
|
||||||
|
{
|
||||||
|
return tokenizingCharacterSet;
|
||||||
|
}
|
||||||
|
@end
|
Loading…
Add table
Add a link
Reference in a new issue