set PushButton Widget Color From RGB values

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

Questions about motif? Contact us

3 posts / 0 new
Last post
set PushButton Widget Color From RGB values

Submitted by orank on Wed, 04/24/2002 - 14:54. Developers
Hi ,

I want to set colors to my PushButtons in my application using RGB values.
But I don?t want the complexity of storing the colors in the ColorMap and changing the color map cell all the time.

Does Motif have some built in function that just lets me choose RGB values and Set them on the PushButton Widget Foreground and Background ?
Or is there a simple motif code I can write that will do that ?

Thanks very much in advance . . .

Anonymous

Hi!

try setting a profile in /usr/lib/X11/app-defaults/

& within set

*XmPushButton*Foreground < colour required>

Background similar.

Hope this helps

Darryls@productcosting.com

ICS_support

That would certainly do the trick, but you can also also use a feature of Xt. See XtVaCreateManagedWidget with XtVaTypedArg.

Here`s some OK code from the comp.windows.x.motif FAQ (question #155)

Answer Use the XmNbackground resource to control the background color, e.g.

strcpy(bgcolor, "yellow");
XtVaSetValues(widget,
XtVaTypedArg, XmNbackground, XtRString, bgcolor,
strlen(bgcolor) + 1, NULL);

The length of the color string is plus one to include the null character.
XtRString is the type to be converted. The conversion is required because
XmNbackground expects a Pixel type.

Thanks to Martin Squicciarini (msquicci@resd.vf.ge.com).