DekGenius.com
[ Team LiB ] Previous Section Next Section

NSColorPanel Mac OS X 10.0

This class implements the system-wide color picker used by all applications. To obtain the shared color panel, use the class method sharedColorPanel. NSColorPanel is a subclass of NSPanel, so to display the color panel on screen, invoke NSWindow's orderFront: method. NSColorPanel takes a target and an action that are used to notify the application of the user changing the color selection in the color panel. To obtain the color, use the method color.

The color panel optionally displays a slider to change the alpha value of the selected color. This behavior is set with the method setShowsAlpha:. To determine if the color panel is set to use alpha, invoke showsAlpha. It is also possible for an application to add a color list—which is an instance of NSColorList—to the color panel. Color lists are managed using the methods attachColorList: and detachColorList:.

The Application Kit provides the class NSColorWell as an interface to Cocoa's color-picking system. It is generally sufficient to use NSColorWell as an interface for users to select colors in an application, as it both displays the color associated with it, and provides a means to open the color panel so the user can choose a new color.

figs/cocn_1518.gif

@interface NSColorPanel : NSPanel
 // Accessor Methods
   - (void)setAction:(SEL)aSelector;
   - (void)setColor:(NSColor *)color;
   - (NSColor *)color;
   - (void)setAccessoryView:(NSView *)aView;
   - (NSView *)accessoryView;
   - (void)setMode:(int)mode;
   - (int)mode;
   - (void)setTarget:(id)anObject;
   - (void)setContinuous:(BOOL)flag;
   - (void)setShowsAlpha:(BOOL)flag;
   - (BOOL)showsAlpha;
 // Class Methods
   + (BOOL)dragColor:(NSColor *)color withEvent:(NSEvent *)theEvent fromView:(NSView *)sourceView;
   + (void)setPickerMask:(int)mask;
   + (void)setPickerMode:(int)mode;
   + (NSColorPanel *)sharedColorPanel;
   + (BOOL)sharedColorPanelExists;
 // Instance Methods
   - (float)alpha;
   - (void)attachColorList:(NSColorList *)colorList;
   - (void)detachColorList:(NSColorList *)colorList;
   - (BOOL)isContinuous;
// Notifications
   NSColorPanelColorDidChangeNotification;

    [ Team LiB ] Previous Section Next Section