< Previous PageNext Page > Hide TOC

Choosing the Color Pickers in a Color Panel

The color mask determines which of the color modes are enabled for an NSColorPanel object. This mask is set before you initialize a new instance of NSColorPanel. NSColorPanelAllModesMask represents the logical OR of the other color mask constants: It causes the NSColorPanel object to display all standard color pickers. When initializing a new instance of NSColorPanel, you can logically OR any combination of color mask constants to restrict the available color modes.

Mode

Color Mask Constant

Grayscale-Alpha

NSColorPanelGrayModeMask

Red-Green-Blue

NSColorPanelRGBModeMask

Cyan-Yellow-Magenta-Black

NSColorPanelCMYKModeMask

Hue-Saturation-Brightness

NSColorPanelHSBModeMask

Custom palette

NSColorPanelCustomPaletteModeMask

Custom color list

NSColorPanelColorListModeMask

Color wheel

NSColorPanelWheelModeMask

All of the above

NSColorPanelAllModesMask

The a color panel’s color mode mask is set using the class method setPickerMask:. The mask must be set before creating an application’s instance of NSColorPanel.

When an application’s instance of NSColorPanel is masked for more than one color mode, your program can set its active mode by invoking the setMode: method with a color mode constant as its argument; the user can set the mode by clicking buttons on the panel. Here are the standard color modes and mode constants:

Mode

Color Mode Constant

Grayscale-Alpha

NSGrayModeColorPanel

Red-Green-Blue

NSRGBModeColorPanel

Cyan-Yellow-Magenta-Black

NSCMYKModeColorPanel

Hue-Saturation-Brightness

NSHSBModeColorPanel

Custom palette

NSCustomPaletteModeColorPanel

Custom color list

NSColorListModeColorPanel

Color wheel

NSWheelModeColorPanel

In grayscale-alpha, red-green-blue, cyan-magenta-yellow-black, and hue-saturation-brightness modes, the user adjusts colors by manipulating sliders. In the custom palette mode, the user can load an NSImage file (TIFF or EPS) into the color panel, then select colors from the image. In custom color list mode, the user can create and load lists of named colors. The two custom modes provide pop-up buttons for loading and saving files. Finally, color wheel mode provides a simplified control for selecting colors.

If a color panel has been used, it uses whatever mode it was in last as the default mode when NSColorPanelAllModesMask is used to initialize the NSColorPanel. Otherwise, it uses color wheel mode.



< Previous PageNext Page > Hide TOC


© 2005, 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-03-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.