The CW_COLORSEL function creates a compound widget that displays all the colors in the current colormap in a 16 x 16 (320 x 320 pixels) grid. To select a color index, the user moves the mouse pointer over the desired color square and presses any mouse button. Alternatively, the color index can be selected by moving one of the three sliders provided around the grid.

This routine is written in the IDL language. Its source code can be found in the file cw_colorsel.pro in the lib subdirectory of the IDL distribution.

Using CW_COLORSEL

The command:

WIDGET_CONTROL, widgetID, SET_VALUE = -1 

informs the widget to initialize itself and redraw. It should be called when any of the following happen:

  • The widget is realized
  • The widget needs redrawing
  • The brightest or darkest color has changed

To set the current color index, use the command:

WIDGET_CONTROL, widgetID, SET_VALUE = index 

To retrieve the current color index and store it in the variable var, use the command:

WIDGET_CONTROL, widgetID, GET_VALUE = var 

Syntax


Result = CW_COLORSEL( Parent [, /FRAME] [, TAB_MODE=value][, UNAME=string] [, UVALUE=value] [, XOFFSET=value] [, YOFFSET=value] )

Return Value


This function returns the widget ID of the newly-created color index widget.

Arguments


Parent

The widget ID of the parent widget.

Keywords


FRAME

If set, a frame is drawn around the widget.

TAB_MODE

Set this keyword to one of the values shown in the table below to determine how the widget hierarchy can be navigated using the Tab key. The TAB_MODE setting is inherited by lower-level bases and child widgets unless it is explicitly set on an individual widget.

Note: It is not possible to tab to disabled (SENSITIVE=0) or hidden (MAP=0) widgets.

Valid settings are:

Value

Description

0

Disable navigation onto or off of the widget. This is the default. Child widgets automatically inherit the tab mode of the parent base as described in Inheriting the TAB_MODE Value.

1

Enable navigation onto and off of the widget.

2

Navigate only onto the widget.

3

Navigate only off of the widget.

Note: In widget applications on the UNIX platform, the Motif library controls what widgets are brought into and released from focus using tabbing. The TAB_MODE keyword value is always zero, and any attempt to change it is ignored when running a widget application on the UNIX platform. Tabbing behavior may vary significantly between UNIX platforms; do not rely on a particular behavior being duplicated on all UNIX systems.

UNAME

Set this keyword to a string that can be used to identify the widget in your code. You can associate a name with each widget in a specific hierarchy, and then use that name to query the widget hierarchy and get the correct widget ID.

To query the widget hierarchy, use the FIND_BY_UNAME keyword to the WIDGET_INFO function. The UNAME should be unique to the widget hierarchy; FIND_BY_UNAME returns the ID of the first widget with the specified name.

UVALUE

The “user value” to be assigned to the widget.

XOFFSET

The X offset position

YOFFSET

The Y offset position

Widget Events Returned by the CW_COLORSEL Widget


This widget generates event structures with the following definition:

Event = {COLORSEL_EVENT, ID: base, TOP: ev.top, HANDLER: 0L, VALUE:c}

The VALUE field is the color index selected.

Version History


Pre 4.0

Introduced

6.1

Added TAB_MODE keyword

See Also


CW_CLR_INDEX