
Example 21-3. The color_objs.c program (continued)
{
int cnt;
Xv_opaque object, get_object();
unsigned objs = (unsigned)xv_get(objects, PANEL_VALUE);
int fg = (int)xv_get(xv_get(panel_item, PANEL_CLIENT_DATA),
PANEL_VALUE);
/* the value of the objects panel item is a bit mask ... "on" bits
* mean that the choice is selected. Get the object associated
* with the choice and set it’s color. "&" tests bits in a mask.
*/
for (cnt = 0; objs; cnt++, objs >>= 1)
if (objs & 1)
if ((object = get_object(cnt)) != panel)
xv_set(object,
fg? WIN_FOREGROUND_COLOR : WIN_BACKGROUND_COLOR,
CMS_CONTROL_COLORS + choice, NULL);
else if (fg)
PANEL_EACH_ITEM(panel, panel_item)
xv_set(panel_item,
PANEL_ITEM_COLOR, CMS_CONTROL_COLORS + choice,
NULL);
PANEL_END_EACH
else
notice_prompt(panel, NULL,
NOTICE_FOCUS_XY, event_x(event), event_y(event),
NOTICE_MESSAGE_STRINGS,
"You can’t set the color of a panel.", NULL,
NOTICE_BUTTON_YES, "Ok",
NULL);
}
/*
* Return the XView handle to nth object.
*/
Xv_opaque
get_object(n)
int n;
{
switch (n) {
case SELECT_TEXTSW:
return textsw;
case SELECT_TEXTSW_VIEW:
return xv_get(textsw, OPENWIN_NTH_VIEW, 0);
case SELECT_PANEL:
return panel;
case SELECT_ICON:
return icon;
default:
return textsw;
}
}
Color
Color 533