开发者

How to use colors in Motif

开发者 https://www.devze.com 2022-12-18 15:14 出处:网络
I\'m new to GUI programming in C and Linux, and I\'m having a hard time with it. It seems like a fairly simple/straightforward thing, but I can\'t find any answers googlin开发者_开发技巧g. I want to a

I'm new to GUI programming in C and Linux, and I'm having a hard time with it. It seems like a fairly simple/straightforward thing, but I can't find any answers googlin开发者_开发技巧g. I want to add a background color to a widget. XmNbackground seems to be what I want to use, but I don't understand what I set it to, like a simple color blue, how do I get "blue" to set XmNbackground color to that?


See here for an answer in the function Pixel convert_color_name_to_pixel, and also here.

Hope this helps.


You can use a resource file which includes "*background: blue" or use XSetArgVal to do the same thing in the code.


If you have the widget in a function, you can set the widget background color resource like this, assuming the widget name is w:

XtVaSetValues(w, XmNbackground, XmRstring, "#c4c4c4", 8, NULL);

Where #c4c4c3 is the hex color code for red (first two characters), green (middle two characters) and blue (last two characters).

You can also use any of the textual color names from file rgb.txt - where that file is located seems to be something of a moving target, but on the computer I'm using at the moment it's in /usr/share/X11

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号