How to draw in colors ?

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

2 posts / 0 new
Last post
How to draw in colors ?

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...

ICS_support

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.