Color Chooser Item

The color chooser item may be placed on a dialog box with a specified width and height allowing the user to select one color form a palette of choices.

v8colorchooser.jpg

Item list specification

The DialogItemRsc field extent specifies the location, width and height of the color chooser.

The type field should be ColorChooser.

The ID determines the DItem_ColorChooserRsc instance to load.

The attributes field can be ON or OFF and optionally combined with HIDDEN. It will usually be ON.

The itemArg field is unused and should usually be set to 0.

The label field can override the label contained in the DItem_ColorChooserRsc instance.

The following is an example of a color chooser item list specification:

{{XC, YC, 34*XC, 34*XC}, ColorChooser, COLORCHOOSERID_ElementColor, ON, 0, "", ""}

Item resource specification

The color chooser item is defined in a resource file with the following structure:

typedef struct ditem_colorchooserrsc
{
ULong commandNumber;
ULong commandSource;
long synonymsId;
ULong helpInfo;
ULong helpSource;
long itemHookId;
long itemHookArg;
#if defined (resource)
char label[];
char accessStr[];
#else
long labelLength;
char label[1];
#endif
#if defined (resource)
extendedAttributes, extendedIntAttributes, extendedWideAttributes;
#define ColorChooser RTYPE_ColorChooser
#endif

The DItem_ColorChooserRsc structure has the following unique fields. See CommonItemResourceFields for a description of any field not shown in this table.

Field Description
accessStr For a color chooser, accessStr specifies a variable used to determine the current color index.


The following is an example of a color chooser item resource:

DItem_ColorChooser COLORCHOOSERID_Color =
{
HOOKITEMID_ColorChooser, NOARG,
"",
"gData.colorNumber"
};

Item hook function messages

The following messages are sent to item hook functions that are attached to color chooser items:

  DITEM_MESSAGE_CREATE
  DITEM_MESSAGE_INIT
  DITEM_MESSAGE_DESTROY
  DITEM_MESSAGE_BUTTON
  DITEM_MESSAGE_SYNCHRONIZE
  DITEM_MESSAGE_GETSTATE
  DITEM_MESSAGE_SETSTATE
  DITEM_MESSAGE_STATECHANGED
  DITEM_MESSAGE_QUEUECOMMAND

ColorChooser item functions

Function Description
mdlDialog_colorPickerSetColorTable sets the color table for the color chooser item. It is applicable to both the ColorPicker and the ColorChooser dialog items.

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.