WoColorButton Function
Creates a button that brings up a color table dialog box used to set colors in a VDA Tool. The button has an associated color pixmap that reflects the currently selected color.
Usage
widget = WoColorButton(parent)
Input Parameters
parent — Specifies the parent widget ID of the color button (long).
Returned Value
widget — The ID of the layout widget.
Keywords
Layout_Name — Specifies a string containing the name of the container form.
Name — Specifies a string containing the name of the button.
Position — A two-element array specifying the x, y coordinates of the color button in the bulletin board. (Default: [0,0])
Range — A 2-element integer array specifying the range of color values in the color grid. The default range is [0, (!D.Table_Size – 1)].
Start_Value — Specifies the color index to use as the original color for the color pixmap (integer).
Title — Specifies a string containing the title of the colortable dialog box.
Attachment Keywords
Bottom — If a widget ID is specified (for example, Bottom=wid), then the bottom of the button is attached to the top of the specified widget. If no widget ID is specified (for example, /Bottom), then the bottom of the button is attached to the bottom of the parent widget.
Left — If a widget ID is specified (for example, Left=wid), then the left side of the button is attached to the right side of the specified widget. If no widget ID is specified (for example, /Left), then the left side of the button is attached to the left side of the parent widget.
Right — If a widget ID is specified (for example, Right=wid), then the right side of the button is attached to the left side of the specified widget. If no widget ID is specified (for example, /Right), then the right side of the button is attached to the right side of the parent widget.
Top — If a widget ID is specified (for example, Top=wid), then the top of the button is attached to the bottom of the specified widget. If no widget ID is specified (for example, /Top), then the top of the button is attached to the top of the parent widget.
Discussion
This function is used in the Attributes dialog boxes of graphical VDA Tools.
note | Do not use WwSetValue with the Userdata keyword on the returned widget or on its parent widget after calling this routine. This use will cause unexpected side-effects, because WwSetValue changes the user data for a widget and for all of its children. |
Contents of the Colortable Dialog Box
The Colortable dialog box has three main parts — the color palette area, the control area, and the action buttons.
Palette Area
An array of cells, one for each color index from the colormap. Numbers by the corners of the palette indicate the color index of the upper-left, upper-right, lower-left, and lower-right color square in the palette.
Controls Area
Selected Color — The index number of the currently selected color in the color table. Once a color is selected, the color pixmap next to the text field is updated. Select a color by clicking the left mouse button on a color cell in the palette of cells, or by entering the color’s index number in this text field and pressing <Return>.
Action Buttons
OK — Apply the selected color and exit the dialog box. Updates the color pixmap next to the color button.
Apply — Apply the selected color, but do not exit the dialog box. Updates the color pixmap next to the color button.
Cancel — Exit the dialog box; do not apply any color changes.
Help — Display online help on the dialog box.
Example
This example creates a color button inside a layout widget. The color button brings up a dialog box used to edit the current plot color. The name of the color button is specified in a resource file.
PRO OkApplyCB, wid, which
; ...
; Retrieve the currently selected color from the color button.
; The returned value is integer color index between 0 and 255.
colorButtonWid = WwGetValue (wid, /Userdata)
color = WoColorButtonGetValue (colorButtonWid)
; ...
END
PRO ChangeColorCB, wid, which
; ...
; Set the color button color index. The new index should be an
; integer value in the range of the current plot colors.
colorButtonWid = WwGetValue (wid, /Userdata)
WoColorButtonSetValue, colorButtonWid, new_index
; ...
END
PRO CreateStuff
; ...
top = WwInit ('example', 'Example', layout)
; Create a color button as a child of the layout widget. Color
; 5 will be displayed when the color button becomes visible.
; The title appears in the frame bar of the dialog that pops
; up when the user presses the color button. The button label
; is specified in a resource, as follows:
*line_color_button.labelString: Line Color
colorButtonWid=WoColorButton (layout, Title = 'Line Color', $
Name = 'line_color_button', Start_value = 5)
; ...
status = WwSetValue (top, /Display)
WwLoop
END
See Also