Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.

NXColorPickingCustom



Adopted By: no NEXTSTEP classes
Declared In: appkit/colorPicking.h



Protocol Description

Together with the NXColorPickingDefault protocol, NXColorPickingCustom provides a way to add color pickers--custom user interfaces for color selection--to an application's NXColorPanel. The NXColorPickingDefault protocol provides basic behavior for a color picker. The NXColorPicker class adopts the NXColorPickingDefault protocol. The easiest way to implement a color picker is to create a subclass of NXColorPicker and use it to implement the NXColorPickingCustom protocol.

See also:  NXColorPickingDefault, NXColorPicker (class)



Method Types

View management provideNewView:
Mode supportsMode:
currentMode
Setting color setColor:



Instance Methods

currentMode
(int)currentMode

Returns the current mode of the color picker. The returned value should be unique to your color picker. Unique values for the standard color pickers are defined in NXColorPanel.h; they are:

NX_GRAYMODE 0
NX_RGBMODE 1
NX_CMYKMODE 2
NX_HSBMODE 3
NX_CUSTOMPALETTEMODE 4
NX_COLORLISTMODE 5
NX_WHEELMODE 6

If your color picker includes submodes, you should define a unique integer for each submode. As an example, the slider picker has four values defined in the above list (NX_GRAYMODE, NX_RGBMODE, NX_CMYKMODE, and NX_HSBMODE), one for each of its submodes.



provideNewView:
provideNewView:(BOOL)firstRequest

This method returns a view containing the user interface for the color picker. This message is sent to your color picker whenever the color panel attempts to display it. This may be when the panel is first presented, when the user switches pickers, or when the picker is switched through API. firstRequest is YES only when this method is first invoked for your color picker--you may use this opportunity to lazily load nib files, initialize the view and perform any other custom initialization required for your picker. The View returned by this method should be set to automatically resize both its width and height.



setColor:
setColor:(NXColor)newColor

Sets the color of the color picker. This method is invoked on the current color picker each time NXColorPanel's setColor: method is invoked. If newColor is actually different from the color picker's color (as it would be if, for example, the user dragged a color into NXColorPanel's color well) this method could be used to update the color picker's color to reflect the change.



supportsMode:
(BOOL)supportsMode:(int)mode

Returns YES if the NXColorPicking protocol implementor supports the picking mode represented by mode. This method is invoked when the NXColorPanel's is first initialized--it is used to attempt to restore the user's previously selected mode. It is also invoked by NXColorPanel's setMode: to find the color picker that supports a particular mode.