EditColor Widget Class


Overview

The EditColor widget displays a panel that lets the end-user change a color. The end-user can edit the color using sliders to select values for the RGB, CMY or HLS components of the color. Alternatively, the end-user can select a new color from a list of named colors. The programmer uses the EditColor widget's resources and children's widget IDs to control the layout and contents of the Editcolor panel. For instance, the programmer can specify that the end-user can use only the RGB color model or can select only from a list of named colors that are defined by the application.

Inherited Behavior and Resources

The EditColor widget inherits behavior and resources from the Core, Composite, Constraint, Manager, and BulletinBoard classes.
The following resources are defined by the EditColor widget class:
NameTypeDefaultAccess
XmNapplyCallbackXtCallbackListNULLC
XmNcancelCallbackXtCallbackListNULLC
XmNcolorFilenamechar */usr/lib/X11/rgb.txtCSG
XmNcolorModelintXintRGBCSG
XmNcolorSelectionModeintXintCOLOR_SLIDERCG
XmNeditPixelPixelwhiteCSG
XmNhelpCallbackXtCallbackListNULLC
XmNokCallbackXtCallbackListNULLC
XmNshowApplyButtonBooleanFalseCG
XmNshowHelpButtonBooleanFalseCG
XmNshowHexValueBooleanTrueCG
XmNsynchronizeScaleBooleanTrueCSG
XmNtitleFontListXmFontList"*helvetica-bold-r-*-180-*"CSG
XmNtitleStringXmStringNULLCSG


XmNapplyCallback

Specifies the list of callback procedures called when the user clicks on the Apply pushbutton on the EditColor panel.

XmNcancelCallback

Specifies the list of callback procedures called when the user clicks on the Cancel pushbutton on the EditColor panel.

XmNcolorFilename

Specifies the file containing the list of named colors to be used in the named color list box on the EditColor panel. The file must be formatted like the standard rgb.txt file. This resource is ignored if XmNcolorSelectionMode is set to XintCOLOR_SLIDER.

XmNcolorModel

Specifies which of the radio buttons in the color model radio box is initially selected. This resource is ignored if XmNcolorSelectionMode is set to XintCOLOR_LIST. You can specify one of the following values:

Resource ValueDescription
XintRGB (default)The RGB slider bars will be displayed initially.
XintCMYThe CMY slider bars will be displayed initially.
XintHLSThe HLS slider bars will be displayed initially.


XmNcolorSelectionMode

Specifies the methods available to the end-user for editing a color. You can specify one of the following values:

Resource ValueDescription
XintCOLOR_LISTOnly the named color list is available.
XintCOLOR_LIST_AND_SLIDERBoth the named color list and the color sliders are available.
XintCOLOR_SLIDER (default)Only the color sliders are available.


XmNeditPixel

Specifies the pixel ID of the color to be edited. If the specified pixel is associated with a read-only cell then the widget will try to allocate a read/write color cell for editing. The pixel value for this new cell can be obtained using function XintEditColorGetColor.

XmNhelpCallback

Specifies a list of callback procedures to be called each time the end-user clicks on the Help pushbutton on the EditColor panel.

XmNokCallback

Specifies the list of callback procedures called when the user clicks on the OK pushbutton on the EditColor panel.

XmNshowApplyButton

Specifies whether or not an Apply pushbutton will appear on the EditColor panel. The default is False, indicating that the Apply pushbutton will not be visible.

XmNshowHelpButton

Specifies whether or not a Help pushbutton will appear on the EditColor panel. The default is False, indicating that the Help pushbutton will not be visible.

XmNshowHexValue

Specifies whether or not a text widget will appear on the EditColor panel containing the current color value in hexadecimal format. The default is True, indicating that hex value will be visible.

XmNsynchronizeScale

Indicates whether or not the color displayed on the EditColor panel is updated while the user moves a slider bar. The default is True, indicating that the color displayed is updated as the slider is moved. In some hardware environments, it may be more efficient to set this resource to False, indicating that the color displayed on the EditColor panel is to be updated after the end-user stops moving a slider.

XmNtitleFontList

Specifies the font used for the title at the top of the EditColor panel.

XmNtitleString

Specifies the compound string containing the title to be placed at the top of the EditColor panel.

Internal Widgets

The following table lists the named widgets contained within an EditColor widget that are accessible to the application programmer. You can unmanage the internal widgets or change their appearance. The appearance and behavior of the internal widgets can also be specified in a resource file using the listed widget names.

NameClassDescription
apply_buttonXmPushButtonGadgetThe Apply pushbutton.
cancel_buttonXmPushButtonGadgetThe Cancel pushbutton.
color_displayXmDrawingAreaDisplays the current color.
color_listXmListList box containing named colors.
cmy_toggleXmToggleButtonGadgetSelects the CMY color model.
hls_toggleXmToggleButtonGadgetSelects the HLS color model.
help_buttonXmPushButtonGadgetThe Help pushbutton.
hex_textXmTextDisplays the hexadecimal value of the current color.
ok_buttonXmPushButtonGadgetThe OK pushbutton
radio_boxXmRowColumnContains the RGB, HLS, and CMY radio buttons.
rgb_toggleXmToggleButtonGadgetSelects the RGB color model.
scale1XmScaleTop slider bar.
scale2XmScaleMiddle slider bar.
scale3XmScaleBottom slider bar.
separator1XmSeparatorGadgetSeparator above the color selection mode radio box.
separator2XmSeparatorGadgetSeparator above the OK, Apply, Cancel, and Help pushbuttons.
title_labelXmLabelGadgetContains the optional title.


Defined Callbacks

The following callbacks are defined by an EditColor widget.

NameStructureReason
XmNapplyCallbackXmAnyCallbackStructXmCR_APPLY
XmNcancelCallbackXmAnyCallbackStructXmCR_CANCEL
XmNhelpCallbackXmAnyCallbackStructXmCR_HELP
XmNokCallbackXmAnyCallbackStructXmCR_OK


XmAnyCallbackStruct

The following ordered table lists the members of the callback structure, XmAnyCallbackStruct, used by the EditColor widget for all of its callbacks.

Data TypeMemberDescription
intreasonIndicates why the callback was invoked.
XEvent *eventPoints to the XEvent that triggered the callback.


Defined Functions

The following functions are defined for creating and manipulating the EditColor widget.

Function NameDescription
XintCreateEditColorCreates an EditColor widget.
XintCreateEditColorDialogCreates a dialog shell containing an EditColor widget.
XintEditColorGetColorReturns the original color and the new color.
XintEditColorGetChildReturns the widget ID of a named child of an EditColor widget.
XintEditColorGetScaleReturns the widget IDs of the three scale widgets.


XintCreateEditColor

XintCreateEditColor creates an unmanaged EditColor widget.

     Widget XintCreateEditColor (...)

WidgetparentParent of new EditColor widget.
char *nameName of new EditColor widget.
ArgListarglistList of resource/value items.
CardinalargcountNumber of items in arglist.


XintCreateEditColorDialog

XintCreateEditColorDialog creates an unmanaged dialog shell containing an EditColor widget.

     Widget XintCreateEditColorDialog (...)

WidgetparentParent of new dialog shell.
char *nameName of new dialog shell.
ArgListarglistList of resource/value items.
CardinalargcountNumber of items in arglist.

XintEditColorGetColor

Call this function to get the new color selected by the end-user.

     void XintEditColorGetColor (...)

WidgetwidgetEditColor widget ID.
XColor *initial_colorAddress of an XColor structure where information about the original color will be returned.
XColor *current_colorAddress of an XColor structure where information about the edited color will be returned.

XintEditColorGetChild

This function returns the widget ID of a named widget internal to the EditColor widget.

     Widget XintEditColorGetChild (...)

WidgetwidgetEditColor widget ID.
intchildCode specifying the child of interest.

The following defined constants can be used to specify the value for child:

Constant NameDescription
XintEDIT_COLOR_COLOR_SQUARECurrent color drawing area.
XintEDIT_COLOR_HEX_TEXTCurrent color hex value text.
XintEDIT_COLOR_SEPARATORPushbutton separator.
XintEDIT_COLOR_APPLYApply pushbutton.
XintEDIT_COLOR_CANCELCancel pushbutton.
XintEDIT_COLOR_HELPHelp pushbutton.
XintEDIT_COLOR_OKOK pushbutton.
XintEDIT_COLOR_LISTNamed color list box.
XintEDIT_COLOR_FRAMEFrame containing color square.


XintEditColorGetScale

Call this function to get the widget IDs of the three sliders on the EditColor panel.

     void XintEditColorGetScale (...)

WidgetwidgetEditColor widget ID.
Widget *scale1Widget ID returned for top slider.
Widget *scale2Widget ID returned for middle slider.
Widget *scale3Widget ID returned for bottom slider.