|
Here are some ideas stolen from Doug Young.
-------
..
...
Widget create_color_bar(parent)
Widget parent;
{
Widget panel;
WidgetList colors;
int i, n;
char name[10];
Arg wargs[10];
colors = (WidgetList) XtMalloc( ncolors * sizeof(Widget));
/*
* Create the row column manager to hold all
* color buttons.
*/
n = 0;
panel = XtCreateManagedWidget("colorpanel",
xmRowColumnWidgetClass,
parent, wargs, n);
/*
* Create ncolors widgets. Use the relative color
* cell number as the name of each color. Add a
* XmNactivateCallback for each cell with the color
* index as client_data.
*/
for(i=0;i<ncolors;i++){
n = 0;
XtSetArg(wargs[n], XtNbackground, i); n++;
sprintf(name,"%d",i);
colors[i] = XtCreateWidget(name, xmLabelWidgetClass,
panel, wargs, n);
XtAddEventHandler(colors[i], ButtonPressMask, False,
set_current_color, i);
}
XtManageChildren(colors, ncolors);
return panel;
}
..
..
--------
Kris..
|