DekGenius.com
[ Team LiB ] Previous Section Next Section

NSColor Mac OS X 10.0

This class represents a color in the Application Kit. Each color has a colorspace associated with it, and the color components that are recognized by that color space. NSColor supports six color spaces identified by the following constants:

  • NSDeviceCMYKColorSpace

  • NSDeviceWhiteColorSpace

  • NSDeviceRGBColor

  • NSCalibratedWhiteColorSpace

  • NSCalibratedRGBColorSpace

  • NSNamedColorSpace

Calibrated colorspaces use Apple's ColorSync technology to ensure that colors look the same on all output devices. Device colorspaces, on the other hand, do not employ ColorSync calibration, and the appearance of colors is thus device-dependent.

The set method is one of the most commonly used methods of NSColor, as it sets the color that all subsequent drawing operations should use. NSColor declares a number of methods for determining the values of various color components, converting colors between colorspaces, creating NSColor objects by changing components of an existing color object, and more. Additionally, there are a number of convenience contructors such as blueColor, redColor, and blackColor that return premade colors without having to specify component values.

figs/cocn_1516.gif

@interface NSColor : NSObject <NSCoding, NSCopying>
 // Convenience Constructors
   + (NSColor *)colorForControlTint:(NSControlTint)controlTint;
   + (NSColor *)colorFromPasteboard:(NSPasteboard *)pasteBoard;
   + (NSColor *)colorWithCalibratedHue:(float)hue saturation:(float)saturation brightness:(float)brightness
        alpha:(float)alpha;
   + (NSColor *)colorWithCalibratedRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha;
   + (NSColor *)colorWithCalibratedWhite:(float)white alpha:(float)alpha;
   + (NSColor *)colorWithCatalogName:(NSString *)listName colorName:(NSString *)colorName;
   + (NSColor *)colorWithDeviceCyan:(float)cyan magenta:(float)magenta yellow:(float)yellow
        black:(float)black alpha:(float)alpha;
   + (NSColor *)colorWithDeviceHue:(float)hue saturation:(float)saturation brightness:(float)brightness
        alpha:(float)alpha;
   + (NSColor *)colorWithDeviceRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha;
   + (NSColor *)colorWithDeviceWhite:(float)white alpha:(float)alpha;
   + (NSColor*)colorWithPatternImage:(NSImage*)image;
 // Class Methods
   + (NSColor *)alternateSelectedControlColor;
   + (NSColor *)alternateSelectedControlTextColor;
   + (NSColor *)blackColor;
   + (NSColor *)blueColor;
   + (NSColor *)brownColor;
   + (NSColor *)clearColor;
   + (NSColor *)controlBackgroundColor;
   + (NSColor *)controlColor;
   + (NSColor *)controlDarkShadowColor;
   + (NSColor *)controlHighlightColor;
   + (NSColor *)controlLightHighlightColor;
   + (NSColor *)controlShadowColor;
   + (NSColor *)controlTextColor;
   + (NSColor *)cyanColor;
   + (NSColor *)darkGrayColor;
   + (NSColor *)disabledControlTextColor;
   + (NSColor *)grayColor;
   + (NSColor *)greenColor;
   + (NSColor *)gridColor;
   + (NSColor *)headerColor;
   + (NSColor *)headerTextColor;
   + (NSColor *)highlightColor;
   + (BOOL)ignoresAlpha;
   + (NSColor *)keyboardFocusIndicatorColor;
   + (NSColor *)knobColor;
   + (NSColor *)lightGrayColor;
   + (NSColor *)magentaColor;
   + (NSColor *)orangeColor;
   + (NSColor *)purpleColor;
   + (NSColor *)redColor;
   + (NSColor *)scrollBarColor;
   + (NSColor *)secondarySelectedControlColor;
   + (NSColor *)selectedControlColor;
   + (NSColor *)selectedControlTextColor;
   + (NSColor *)selectedKnobColor;
   + (NSColor *)selectedMenuItemColor;
   + (NSColor *)selectedMenuItemTextColor;
   + (NSColor *)selectedTextBackgroundColor;
   + (NSColor *)selectedTextColor;
   + (void)setIgnoresAlpha:(BOOL)flag;
   + (NSColor *)shadowColor;
   + (NSColor *)textBackgroundColor;
   + (NSColor *)textColor;
   + (NSColor *)whiteColor;
   + (NSColor *)windowBackgroundColor;
   + (NSColor *)windowFrameColor;
   + (NSColor *)windowFrameTextColor;
   + (NSColor *)yellowColor;
 // Instance Methods
   - (NSColor *)blendedColorWithFraction:(float)fraction ofColor:(NSColor *)color;
   - (float)blueComponent;
   - (void)set;
   - (float)alphaComponent;
   - (float)blackComponent;
   - (float)brightnessComponent;
   - (NSString *)catalogNameComponent;
   - (NSString *)colorNameComponent;
   - (NSString *)colorSpaceName;
   - (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace;
   - (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace device:(NSDictionary *)deviceDescription;
   - (NSColor *)colorWithAlphaComponent:(float)alpha;
   - (float)cyanComponent;
   - (void)drawSwatchInRect:(NSRect)rect;
   - (void)getCyan:(float *)cyan magenta:(float *)magenta yellow:(float *)yellow black:(float *)black
        alpha:(float *)alpha; brightness:(float *)brightness alpha:(float *)alpha;
   - (void)getHue:(float *)hue saturation:(float *)saturation
   - (void)getRed:(float *)red green:(float *)green blue:(float *)blue alpha:(float *)alpha;
   - (void)getWhite:(float *)white alpha:(float *)alpha;
   - (float)greenComponent;
   - (NSColor *)highlightWithLevel:(float)val;
   - (float)hueComponent;
   - (NSString *)localizedCatalogNameComponent;
   - (NSString *)localizedColorNameComponent;
   - (float)magentaComponent;
   - (NSImage*)patternImage;
   - (float)redComponent;
   - (float)saturationComponent;
   - (NSColor *)shadowWithLevel:(float)val;
   - (float)whiteComponent;
   - (void)writeToPasteboard:(NSPasteboard *)pasteBoard;
   - (float)yellowComponent;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
 // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;

    [ Team LiB ] Previous Section Next Section