Inherits from: NSObject
Conforms to: NSCoding
NSObject (NSObject)
Declared in: AppKit/NSColorList.h
An NSColorList is an ordered list of NSColors, identified by keys. Instances of NSColorList, or more simply, color lists, are used to manage named lists of NSColors. NSColorPanel's list-mode color picker uses instances of NSColorList to represent any lists of colors that come with the system, as well as any lists created by the user. An application can use NSColorList to manage document-specific color lists, which may be added to an application's NSColorPanel using its attachColorList: method.
An NSColorList is similar to a dictionary object: An NSColor is added to, looked up in, and removed from the list by specifying its key, which is an NSString. These keys are used to identify the colors in the list and are used to display the color to the user in the color panel. In addition, colors can be inserted at specified positions in the list.
The color list has a name, specified when you create the object using either the initWithName: or initWithName:fromFile: method.
Instances of NSColorList are created for all user-created color lists (those in the color panel) and various color catalogs available on the system.
An NSColorList saves and retrieves its colors from files with the extension ".clr" in directories defined by a standard search path. To access all the color lists in the standard search path, use the availableColorLists method; this returns an array of NSColorLists, from which you can retrieve the individual color lists by name.
The standard search path for color lists is:
NSColorList reads color list files in several different formats; it saves color lists using the archiver API.
NSColorList posts an NSColorListChanged notification when a color list is changed.
- NSCoding
- - encodeWithCoder:
- - initWithCoder:
- Initializing an NSColorList
- - initWithName:
- - initWithName:fromFile:
- Getting All Color Lists
- + availableColorLists
- Getting a Color List by Name
- + colorListNamed:
- - name
- Managing Colors by Key
- - allKeys
- - colorWithKey:
- - insertColor:key:atIndex:
- - removeColorWithKey:
- - setColor:forKey:
- Editing
- - isEditable
- Writing and Removing Files
- - removeFile
- - writeToFile:
+ (NSArray *)availableColorLists
See Also: + colorListNamed:
+ (NSColorList *)colorListNamed:(NSString
*)name
nil
if
no such color list exists. name must
not include the ".clr
"
suffix.See Also: - name
- (NSArray *)allKeys
- (NSColor *)colorWithKey:(NSString
*)key
nil
if
there is none.- (id)initWithName:(NSString
*)name
nil
,
indicating that the color list doesn't need to be initialized
from a file. <<So what happens if the name *is* in use?>>- (id)initWithName:(NSString
*)name fromFile:(NSString *)path
.clr
"
extension). A nil
path indicates
the color list should be initialized with no colors.. <<So
what happens if the name *is* in use?>>- (void)insertColor:(NSColor
*)color key:(NSString
*)key atIndex:(unsigned)location
See Also: - colorWithKey:, :, - removeColorWithKey:, - setColor:forKey:
- (BOOL)isEditable
YES
if
the color list can be modified. This depends on
the source of the list: If it came from a write-protected file,
this method returns NO
.- (NSString *)name
public void removeColorWithKey(String key)
- (void)removeColorWithKey:(NSString
*)key
See Also: - insertColor:key:atIndex:, - setColor:forKey:
- (void)removeFile
- (void)setColor:(NSColor
*)color forKey:(NSString
*)key
See Also: - colorWithKey:, - insertColor:key:atIndex:, - removeColorWithKey:
- (BOOL)writeToFile:(NSString
*)path
.clr
in that
directory (where listname is the name with which the NSColorList
was initialized). If path includes
a file name, this method saves the file under that name. If path is nil
,
this method saves the file as listname.clr
in
the standard location. Returns YES
upon
success and NO
if it fails to write
the file.See Also: - removeFile
Posted whenever a color list changes. This notification contains a notification object but no userInfo dictionary. The notification object is the NSColorList object that changed.