Up

# NSColorList

### Authors

Scott Christley (`scottc@net-community.com`)
Nicola Pero (`n.pero@mi.flashnet.it`)

> Manage named lists of NSColors.

Copyright: (C) 1996, 2000 Free Software Foundation, Inc.

# Software documentation for the NSColorList class

## NSColorList : NSObject

> Declared in:
>   AppKit/NSColorList.h

> Conforms to:
>   NSCoding

Availability: OpenStep
Description forthcoming.

Instance Variables
Method summary

- +availableColorLists
- +colorListNamed:
- -allKeys
- -colorWithKey:
- -encodeWithCoder:
- -initWithCoder:
- -initWithName:
- -initWithName:fromFile:
- -insertColor:key:atIndex:
- -isEditable
- -name
- -removeColorWithKey:
- -removeFile
- -setColor:forKey:
- -writeToFile:

### availableColorLists

+ (NSArray*) availableColorLists;
Availability: OpenStep
Description forthcoming.

### colorListNamed:

+ (NSColorList*) colorListNamed: (NSString*)name;
Availability: OpenStep
Returns the first color list (from the array of available lists) matching name.

### allKeys

- (NSArray*) allKeys;
Availability: OpenStep
Returns an array containing all the keyus in the color list

### colorWithKey:

- (NSColor*) colorWithKey: (NSString*)key;
Availability: OpenStep
Returns the color for the specified key (if any).

### encodeWithCoder:

- (void) encodeWithCoder: (NSCoder*)aCoder;
Availability: OpenStep
Description forthcoming.

### initWithCoder:

- (id) initWithCoder: (NSCoder*)aDecoder;
Availability: OpenStep
Description forthcoming.

### initWithName:

- (id) initWithName: (NSString*)name;
Availability: OpenStep
Initializes a new, empty color list registered under given name.

### initWithName: fromFile:

- (id) initWithName: (NSString*)name fromFile: (NSString*)path;
Availability: OpenStep

Initializes a new color list registered under given name, taking contents from the file specified in path. (Path should include the filename with extension (usually ".clr"), and by convention name should be the same as filename without the extension.)

The format of the file can be either an archive of an NSColorList or an ASCII format. ASCII files follow this format:

first line = [#/colors]
each subsequent line describes a color as [int float+ string]
the first int describes the method (RGBA, etc.), the floats provide its arguments (e.g., r, g, b, alpha), and string is name.

The method corresponds to one of the NSColor initializers. We are looking for documentation of the exact correspondence on OpenStep; for now the only supported method is "0", which is an RGBA format with the arguments in order R,G,B, A.

### insertColor: key: atIndex:

- (void) insertColor: (NSColor*)color key: (NSString*)key atIndex: (unsigned)location;
Availability: OpenStep
Inserts a color into the color list at the specified index. Removes any other color with the same name.

### isEditable

- (BOOL) isEditable;
Availability: OpenStep
Returns a flag indicating whether the receiver is editable.

### name

- (NSString*) name;
Availability: OpenStep
Returns the name of the receiver.

### removeColorWithKey:

- (void) removeColorWithKey: (NSString*)key;
Availability: OpenStep
Removes the color for the specified key from the list.

### removeFile

- (void) removeFile;
Availability: OpenStep
Removes the on-disk representation of the list.

### setColor: forKey:

- (void) setColor: (NSColor*)aColor forKey: (NSString*)key;
Availability: OpenStep
Sets the color for this key and appends it to the color list.

### writeToFile:

- (BOOL) writeToFile: (NSString*)path;
Availability: OpenStep
Writes the receiver to the specified path .
If path is `nil`, writes to a file located in the current user's personal Colors directory whose name is that of the list with the extension 'clr' appended.
If path is a directory, writes to a file in that directory whose name is that of the list with the extension 'clr' appended.
Otherwise ( path is neither `nil` nor a directory), writes to the path without appending the l.ist name.
Returns `YES` on success, `NO` on failure.
Writing with a path of `nil` will cause the receiver to be added to the +availableColorLists if it is not already there.

## Instance Variables for NSColorList Class

### _colorDictionary

@protected NSMutableDictionary* _colorDictionary;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _fullFileName

@protected NSString* _fullFileName;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _is_editable

@protected BOOL _is_editable;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _name

@protected NSString* _name;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _orderedColorKeys

@protected NSMutableArray* _orderedColorKeys;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

Up