Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
|The NXColorPickingDefault protocol, together with the NXColorPickingCusom protocol, provides API for adding color pickers--custom user interfaces for color selection--to an application's NXColorPanel. The NXColorPickingDefault protocol provides basic behavior for a color picker. The NXColorPickingCustom protocol provides implementation-specific behavior.
The NXColorPicker class implements the NXColorPickingDefault protocol. The simplest way to implement your own color picker is to create a subclass of NXColorPicker and implement the NXColorPickingCustom protocol in that subclass. You can also implement custom color selection by creating a subclass of another class such as View, and using that subclass to implement the methods in this protocol and in NXColorPickingCustom.
Color Picker Bundles
A class that implements the NXColorPickingDefault and NXColorPickingCustom protocols needs to be compiled and linked in an application's object file. However, your application need not explicitly create an instance of this class. Instead, your application's file package should include a directory named ColorPickers; within this directory you should place a directory "MyPickerClass.bundle" for each custom color picker your application implements. This bundle should contain all resources required for your color picker: nib files, tiff files, and so on.
NXColorPanel will allocate and initialize an instance of each class for which a bundle is found in the "ColorPickers" directory.
Color Picker Buttons
NXColorPanel lets the user select a color picker from a Matrix of ButtonCells. The order in which a color picker's ButtonCell appears in this Matrix is determined by the return value of its insertionOrder method.
See also: NXColorPickingCustom, NXColorPicker (class), NXColorPanel (class)
|Alpha control check||alphaControlAddedOrRemoved:|
|Order of button appearance||insertionOrder|
|Using color lists||attachColorList:|
|Invoked automatically when the NXColorPanel's opacity slider is added or removed; you never invoke this method directly.
You can determine whether the slider is being added or removed by sending the doesShowAlpha message to sender. A return of YES means that the sender is displaying the opacity (alpha) slider; NO means it isn't.
|Tells the color picker to attach the given colorList (an NXColorList object). You never invoke this method; it's invoked automatically by the NXColorPanel when its attachColorList: method is invoked. Use this method if you implement a custom color picker that manages NXColorLists. If the color picker isn't displaying colorList, it should be added to the picker. This method ordinarily needs not do anything, since NXColorPanel's list mode manages NXColorLists. Returns self.
See also: attachColorList: (NXColorPanel), NXColorList class
|Tells the color picker to detach the given colorList (an NXColorList object). You never invoke this method; it's invoked automatically by the NXColorPanel when its detachColorList: method is invoked. Use this method if you implement a custom color picker that manages NXColorLists. If the color picker is displaying colorList, it should be removed from the picker. This method ordinarily needs not do anything, since NXColorPanel's list mode manages NXColorLists. Returns self.|
|Notifies the color picker of the color panel's mask and initializes the color picker. This method is sent by the NXColorPanel to all implementors of the color picking protocols when the application's color panel is first initialized. In order for your color picker to receive this message, it must have a bundle in your application's "ColorPickers" directory (described in "Color Picker Bundles" in the Protocol Description).
mask is determined by the argument to the NXColorPanel method setPickerMask:. If no mask has been set, mask is NX_ALLMODESMASK. If your color picker supports any additional modes, you should invoke the setPickerMask: method when your application intializes to notify the NXColorPanel class.
This method should examine the mask and determine whether it supports any of the modes included there. You may also check the value in mask to enable or disable any subpickers or optional controls implemented by your color picker. Your color picker may also retain appPanel in an instance variable for future communication with the color panel.
This method is provided to initialize your color picker; however, much of a color picker's initialization may be done lazily through the provideNewView: method. If your color picker responds to any of the modes represented in mask, it should perform its initialization and return self. Color pickers that do so will have their buttons inserted in the color panel and will continue to receive messages from the panel as the user manipulates it. If the color picker doesn't respond to any of the modes represented in mask, it should do nothing and return nil.
See also: + setPickerMask: (NXColorPanel class), provideNewView:
|Sets newImage as newButtonCell's image. buttonCell is the ButtonCell object that displays the color picker's representation in the NXColorPanel's picker Matrix--the control that lets the user choose the picker to use. Implement this method to perform application-specific manipulation of the image before it is inserted and displayed by the button cell.
See also: insertionOrder, provideNewButtonImage:
|Returns a float value representing the insertion order of the receiver's ButtonCell in the NXColorPanel's picker Matrix--the control that lets the user choose the picker to use. Values representing the insertion order of the standard color pickers are defined in the header file appkit/NXColorPanel.h. The standard color pickers used by NXColorPanel have symbolic constants (defined in NXColorPanel.h) that determine their insertion order:|
|Implement this method to place your color picker's ButtonCell in the desired position relative to these default color pickers. For example, to place the ButtonCell for your color picker between those for wheel and slider, implement a version of this method that returns 0.505.
See also: insertNewButtonImage:in:, provideNewButtonImage
|This method should return an NXImage to represent the color picker in the NXColorPanel's picker Matrix: the Matrix of ButtonCells from which the user selects a color picker.
See also: insertNewButtonImage:in:, insertionOrder
|Sets the mode of the color picker. This method is invoked by NXColorPanel's setMode: method to ensure that all color pickers reflect the current mode--for example, upon color picker initialization to ensure that all color pickers are restored to the mode the user left them in the last time an NXColorPanel was used.
Most color picker's have only one mode, and thus don't need to do any work in this method. An example of a color picker that uses this method is the slider picker, which can choose from one of several submodes depending on the value of mode. Returns self.
|Tells the color picker when a color list has been updated. This method is invoked when NXColorPanel's updateCustomColorList: method is invoked. If colorList is visible in the color picker, it should be updated; if colorList is nil, all color lists currently visible in the color picker should be updated.|
|Tells the color picker when the NXColorPanel's view size changes. sender is the sending NXColorPanel. Use this method to perform special preparation when resizing the color picker's view. Since this method is invoked only as appropriate, it is better to implement this method than to override the method superviewSizeChanged: for the View in which the color picker's user interface is contained.
See also: provideNewView: (NXColorPickingCustom)