DekGenius.com
[ Team LiB ] Previous Section Next Section

NSColorList Mac OS X 10.0

This class manages an ordered, named list of NSColors. The operating system itself provides several color lists, which are visible in the Color panel of any application. To obtain an array of available color lists, use the class method availableColorLists. To manage the colors contained within a color list we have several methods at our disposal. The method colorWithKey: will return the color associated with the indicated key. Colors are added to the list using the method insertColor:key:atIndex:. To remove a color, use removeColorWithKey:. To change which color is associated with a key, use the method setColor:forKey:.

An important feature of color list objects is that they can be written to files that are kept in well-known locations in the filesystem, thus making them easily accessed by other applications. To store a color list to file, use the method writeToFile:. Passing nil to this method causes the color list to be stored in the users private color lists directory with the filename listname.clr. To initialize a color list object from a stored color list, use the initializer initWithName:fromFile:.

figs/cocn_1517.gif

@interface NSColorList : NSObject <NSCoding>
 // Initializers
   - (id)initWithName:(NSString *)name fromFile:(NSString *)path;
   - (id)initWithName:(NSString *)name;
 // Accessor Methods
   - (void)setColor:(NSColor *)color forKey:(NSString *)key;
 // Class Methods
   + (NSArray *)availableColorLists;
   + (NSColorList *)colorListNamed:(NSString *)name;
 // Instance Methods
   - (NSString *)name;
   - (void)removeColorWithKey:(NSString *)key;
   - (NSArray *)allKeys;
   - (NSColor *)colorWithKey:(NSString *)key;
   - (void)insertColor:(NSColor *)color key:(NSString *)key atIndex:(unsigned)loc;
   - (BOOL)isEditable;
   - (void)removeFile;
   - (BOOL)writeToFile:(NSString *)path;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
// Notifications
   NSColorListDidChangeNotification;

    [ Team LiB ] Previous Section Next Section