home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSColorList.h < prev    next >
Text File  |  1996-10-17  |  4KB  |  93 lines

  1. /*
  2.     NSColorList.h
  3.     Application Kit
  4.     Copyright (c) 1994-1996, NeXT Software, Inc.
  5.     All rights reserved.
  6. */
  7.  
  8. /* An NSColorList is an ordered list of NSColors, identified by keys. 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. Note that the key is only used in indentifying a color in a color list; it has nothing to do with the contents of the color, unless, of course the color list was set up in such a way that the keys matched the color names.
  9.  
  10. Instances of NSColorList are created for all user-created color lists (those in the color panel) and various color catalogs (such as Pantone) available on the system.
  11.  
  12. NSColorLists post "NSColorListDidChangeNotification" when changed.
  13. */
  14.  
  15. #import <Foundation/Foundation.h>
  16. #import <AppKit/AppKitDefines.h>
  17.  
  18. @class NSColor;
  19.  
  20. @interface NSColorList : NSObject <NSCoding> {
  21.     NSMutableArray *_keyArray;
  22.     NSMutableArray *_colorArray;
  23.     id _hashTable;
  24.     NSString *_name;
  25.     NSString *_printerType;
  26.     NSString *_fileName;
  27.     struct _colorListFlags {
  28.     unsigned int colorsLoaded:1;
  29.     unsigned int editable:1;
  30.     unsigned int hasDeviceSpecificLists:1;
  31.     unsigned int dirty:1;
  32.     unsigned int hasFrozen:1;
  33.     unsigned int notificationsDisabled:1;
  34.     unsigned int :26;
  35.     } _flags;
  36.     unsigned int _reservedCList;
  37. }
  38.  
  39. /* Returns all color lists in the user's color list path, including those added at runtime. Creating a named color list and saving with writeToFile:nil will add it to this list; removeFile will remove it from this list. (That is what happens as the user creates and destroys color lists in the color panel.)
  40. */
  41. + (NSArray *)availableColorLists;            
  42.  
  43. /* Returns the named color list from availableColorLists
  44. */
  45. + (NSColorList *)colorListNamed:(NSString *)name;
  46.  
  47. /* Creates a color list; specify @"" if you don't want a name. NOTE that this does not add the color list to availableColorLists until the color list is saved into the user's path with writeToFile:nil.
  48. */
  49. - (id)initWithName:(NSString *)name;            
  50. - (id)initWithName:(NSString *)name fromFile:(NSString *)path;    /* Load initial contents */
  51.  
  52. /* Name of the color list
  53. */
  54. - (NSString *)name;
  55.  
  56. /* If key already exists, sets the corresponding color. Otherwise inserts the color at the end.
  57. */
  58. - (void)setColor:(NSColor *)color forKey:(NSString *)key;
  59.  
  60. /* Inserts color at the specified location. If a color by the same key is already in the list but at a different location it is removed from there.
  61. */
  62. - (void)insertColor:(NSColor *)color key:(NSString *)key atIndex:(unsigned)loc;
  63.  
  64. /* No-op if key doesn't exist.
  65. */
  66. - (void)removeColorWithKey:(NSString *)key;
  67.  
  68. /* Returns nil if key doesn't exist.
  69. */
  70. - (NSColor *)colorWithKey:(NSString *)key;
  71.  
  72. /* Use this array to get count of colors and enumerate them according to the ordering specified when inserting.
  73. */
  74. - (NSArray *)allKeys;
  75.  
  76. /* Depends on the source of the colorlist file
  77. */
  78. - (BOOL)isEditable;
  79.  
  80. /* Use "nil" to save to the user's private colorlists directory. If the color list is named, this method will also insert the color list into availableColorLists.
  81. */
  82. - (BOOL)writeToFile:(NSString *)path;    
  83.  
  84. /* If the color list is in the user's path, removes the corresponding file in user's private colorlists directory. Also removes the color list from availableColorLists. If there are no outstanding references to the color list this might deallocate the object as well.
  85. */
  86. - (void)removeFile;
  87.  
  88. @end
  89.  
  90. /* Notifications */
  91. APPKIT_EXTERN NSString *NSColorListDidChangeNotification;
  92.  
  93.