This is NSColorPanel.rtf in view mode; [Download] [Up]
paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc. All Rights Reserved. s4 li100 fi0 ri1007 ql f0 b fs36 fs100 fs36 NSColorPanel pard s14 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSPanel : NSWindow : NSResponder : NSObject fs20 fs28 s7 f0 b fs24 Conforms To:tab b0 fs28 f1 NSCoding (NSResponder) fi0 NSObject (NSObject) fs20 fs28 s8 fi-2771 f0 b fs24 Declared In:tab b0 fs28 f1 AppKit/NSColorPanel.h fs20 fs28 pard s19 li100 fi0 ri1007 ql f0 b fs28 fs20 fs28 Class Description fs14 fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 fs28 NSColorPanel provides a standard user interface for selecting color in an application. It provides a number of standard color selection modes, and, with the NSColorPickingDefault and NSColorPickingCustom protocols, allows an application to add its own color selection modes. It allows the user to save swatches containing frequently used colors. Once set, these swatches are displayed by NSColorPanel in any application where it is used, giving the user color consistency between applications. NSColorPanel enables users to capture a color anywhere on the screen for use in the active application, and allows dragging colors from itself into views in an application. NSColorPanel'27s action message is sent to the target object when the user changes the current color. fs16 fs28 An application has only one instance of NSColorPanel, the shared instance. Invoking the b sharedColorPanel: b0 method returns the shared instance of NSColorPanel, instantiating it if necessary. You can also initialize an NSColorPanel for your application by invoking NSApplication'27s b orderFrontColorPanelb0 method. fs16 fs28 You can put NSColorPanel in any application created with Interface Builder by adding the 'aaColors...'ba item from the Menu palette to the application'27s menu. fs16 fs28 pard s18 li477 fi0 ri1007 ql f0 b fs24 fs4 fs24 Color Mask and Color Modes pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 fs28 The color mask determines which of the color modes are enabled for NSColorPanel. 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 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. fs16 fs28 pard s22 li854 fi0 ri1007 ql tx4509 tx10180 f0 b fs24 Modetab Color Mask Constant fs6 fs24 s20 f1 b0 fs28 Grayscale-Alphatab NSColorPanelGrayModeMask fi0 Red-Green-Bluetab NSColorPanelRGBModeMask fi0 Cyan-Yellow-Magenta-Blacktab NSColorPanelCMYKModeMask fi0 Hue-Saturation-Brightnesstab NSColorPanelHSBModeMask fi0 TIFF imagetab NSColorPanelCustomPaletteModeMask fi0 Custom color liststab NSColorPanelColorListModeMask fi0 Color wheeltab NSColorPanelWheelModeMask fi0 All of the abovetab NSColorPanelAllModesMask fs6 fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 fs10 fs28 The NSColorPanel'27s color mode mask is set using the class method b setPickerMask:. b0 The mask must be set before creating an application'27s instance of NSColorPanel. fs16 fs28 When an application'27s instance of NSColorPanel is masked for more than one color mode, your program can set its active mode by invoking the b setModeb0 : 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: fs16 fs28 pard s22 li854 fi0 ri1007 ql tx4509 tx10180 f0 b fs24 Modetab Color Mode Constant fs6 fs24 s20 f1 b0 fs28 Grayscale-Alphatab NSGrayModeColorPanel fi0 Red-Green-Bluetab NSRGBModeColorPanel fi0 Cyan-Yellow-Magenta-Blacktab NSCMYKModeColorPanel fi0 Hue-Saturation-Brightnesstab NSHSBModeColorPanel fi0 TIFF imagetab NSCustomPaletteModeColorPanel fi0 Color liststab NSColorListModeColorPanel fi0 Color wheeltab NSWheelModeColorPanel fs6 fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 fs10 fs28 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 a TIFF file into the NSColorPanel, then select colors from the TIFF image. In custom color list mode, the user can create and load lists of named colors. The two custom modes provide NSPopUpLists 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. fs16 fs28 pard s18 li477 fi0 ri1007 ql f0 b fs24 fs4 fs24 Associated Classes and Protocols pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 fs28 The NSColorList class provides an API for managing custom color lists. The NSColorPanel methods b attachColorList:b0 and b detachColorList:b0 let your application add and remove custom lists from the NSColorPanel'27s user interface. fs16 fs28 The protocols NSColorPickingDefault and NSColorPickingCustom provide an API for adding custom color selection to the user interface. The NSColorPicker class implements the NSColorPickingDefault protocol; you can subclass NSColorPicker and implement the NSColorPickingCustom protocol in your subclass to create your own user interface for color selection. fs16 fs28 pard s0 f0 b fs24 See also: b0 fs28 f1 NSColorList, NSColorPickingDefault, NSColorPicker, NSColorPickingDefault protocol, NSColorPickingCustom protocol, NSColorWell fs14 fs28 s19 li100 fi0 ri1007 ql f0 b fs24 fs28 Creating the NSColorPanel fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 + (NSColorPanel *)b sharedColorPanelb0 tab Creates if necessary and returns the shared NSColorPanel. fi-6552 fs16 fs28 fi-6552 + (BOOL)b sharedColorPanelExiststab b0 Returns YES if the NSColorPanelb b0 has been created already. pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Setting the NSColorPanel fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 + (void)b setPickerMask:b0 (int)i maski0 tab Sets the mask that determines which color selection modes are available in the color panel. fi-6552 fs16 fs28 fi-6552 + (void)b setPickerMode:b0 (int)i modei0 tab Sets the color picker mode. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSView *)b accessoryViewtab b0 Returns the accessory view, orb nil b0 if there is none. fi-6552 fs16 fs28 fi-6552 {f3 -} (BOOL)b isContinuousb0 tab Returns YES if the NSColorPanel continuously sends the action message to the target. fi-6552 fs16 fs28 fi-6552 {f3 -} (int)b modeb0 tab Returns the mode of the NSColorPanel. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setAccessoryView:b0 (NSView *)i aViewi0 tab Sets the accessory view to i aViewi0 . fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setAction:b0 (SEL)i aSelectori0 tab Sets the action message sent to the target. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setContinuous:b0 (BOOL)i flagi0 tab Sets the NSColorPanel to continuously send the action message to the target. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setMode:b0 (int)i modei0 tab Sets the mode of the NSColorPanel. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setShowsAlpha:b0 (BOOL)i flagi0 tab Sets the NSColorPanel to show alpha values. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setTarget:b0 (id)i anObjecti0 tab Sets the target of the NSColorPanel. fi-6552 fs16 fs28 fi-6552 {f3 -} (BOOL)b showsAlphab0 tab Returns YES if the NSColorPanel shows alpha values. pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Attaching a Color List fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (void)b attachColorList:b0 (NSColorList *)i aColorListtab s11 li7030 fi-6553 fi-5796 i0 tab Adds the specified list of NSColorsi i0 to all the color pickers in the color panel that display color lists. s9 li7029 fi-5794 fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b detachColorList:b0 (NSColorList *)i aColorListtab s11 li7030 fi-6553 fi-5796 i0 tab Removes the specified list of NSColorsi i0 from all the color pickers in the color paneli i0 that display color lists. pard s19 li100 fi0 ri1007 ql f0 b fs48 fs28 Setting Color fs14 fs28 pard s9 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 +(BOOL)b dragColor:b0 (NSColor **)i aColori0 tab Drags i aColori0 into a destination view from i sourceViewi0 . s11 li7030 fi-6553 fi-5796 b withEvent:b0 (NSEvent *)i anEventi0 tab b fromView:b0 (NSView *)i sourceView s9 li7029 fi-5794 fi-6552 i0 fs16 fs28 fi-6552 {f3 -} (float)b alphab0 tab Returns the NSColorPanel'27s current alpha value, or 1.0 (opaque) if the panel has no opacity slider. fi-6552 fs16 fs28 fi-6552 {f3 -} (NSColor *)b colorb0 tab Returns the currently displayed color. fi-6552 fs16 fs28 fi-6552 {f3 -} (void)b setColor:b0 (NSColor *)i aColori0 tab Sets the color to be displayed. This method posts the NSColorPanelChangedNotification notification with the receiving object to the default notification center. s11 li7030 fi-6553 fi-5796 }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.