- Inherits from:
- NSObject
- Package:
- com.apple.yellow.application
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 a String. 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 one of the NSColorList constructors.
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:
/System/Library/Colors
/Local/Library/Colors
~/Library/Colors
NSColorList reads color list files in several different formats; it saves color lists using the archiver API.
NSColorList posts a ColorListDidChangeNotification when a color list is changed.
- Constructors
- NSColorList
- Getting All Color Lists
- availableColorLists
- Getting a Color List by Name
- colorListNamed
- name
- Managing Colors by Key
- allKeys
- colorWithKey
- insertColorForKeyAtIndex
- removeColorWithKey
- setColorForKey
- Editing
- isEditable
- Writing and Removing Files
- removeFile
- writeToFile
public NSColorlist()
public NSColorList(String name)
null
as
the additional argument, indicating that the color list doesn't
need to be initialized from a file.
public NSColorList(
String name,
String path)
.clr
"
extension). A null
path
indicates the color list should be initialized with no colors.public static NSArray availableColorLists()
See Also: colorListNamed
public static NSColorList colorListNamed(String name)
null
if no such color
list exists. name must
not include the ".clr
"
suffix.See Also: name
public NSArray allKeys()
public NSColor colorWithKey(String key)
null
if
there is none.public void insertColorForKeyAtIndex(
NSColor color,
String key,
int location)
See Also: colorWithKey, removeColorWithKey, setColorForKey
public boolean isEditable()
true
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 false
.public String name()
public void removeColorWithKey(String key)
See Also: insertColorForKeyAtIndex, setColorForKey
public void removeFile()
public void setColorForKey(
NSColor color,
String key)
See Also: colorWithKey, insertColorForKeyAtIndex, removeColorWithKey
public boolean writeToFile(String 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 null
,
this method saves the file as listname.clr
in the
users' private colorlists directory. Returns true
upon
success and false
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.