Submitted by Anonymous on Fri, 05/11/2001 - 16:14. Developers
Hello
I would like to draw colored lines in a drawing widget. I tried to use the default color map
//w is the drawing widget
Display * Disp=XtDisplay(a->w);
int Screen=DefaultScreen(Disp);
Colormap cm=XDefaultColormap(Disp,Screen);
//then I add a color
XColor c;
c.flags=DoRed|DoBlue|DoGreen;
c.red=255;
c.green=0;
c.blue=0;
XAllocColor(Disp,cm,&c);
//And then I change the GC
XGCValues gcv;
gcv.foreground=c.pixel;
XChangeGC(Disp,gc,GCForeground,&gcv);
But it doesn`t work...
The values are, I believe, in the range 0..65535,
not 0..255, so you should shift the "red" value by 8 bits.
You may also want to use XtAllocateGC (http//www.motifzone.com/resources/man/XtAllocateGC.html) or XtGetGC (http//www.motifzone.com/resources/man/XtGetGC.html), having set an XGCValues structure with a foreground value of a red pixel and flags of GCForeground.