如何在 Motif 中使用颜色
我是 C 和 Linux 中 GUI 编程的新手,而且我在这方面遇到了困难。这似乎是一个相当简单/直接的事情,但我无法通过谷歌搜索找到任何答案。我想为小部件添加背景颜色。 XmNbackground 似乎是我想要使用的,但我不明白我将其设置为什么,比如简单的蓝色,如何获得“蓝色”来将 XmNbackground 颜色设置为该颜色?
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 googling. 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅此处,了解函数
Pixel Convert_color_name_to_pixel
中的答案,还有此处。希望这有帮助。
See here for an answer in the function
Pixel convert_color_name_to_pixel
, and also here.Hope this helps.
您可以使用包含“*background: blue”的资源文件或使用 XSetArgVal 在代码中执行相同的操作。
You can use a resource file which includes "*background: blue" or use XSetArgVal to do the same thing in the code.
如果函数中有小部件,则可以像这样设置小部件背景颜色资源,假设小部件名称为
w
:其中
#c4c4c3
是十六进制颜色代码红色(前两个字符)、绿色(中间两个字符)和蓝色(最后两个字符)。您还可以使用文件
rgb.txt
中的任何文本颜色名称 - 该文件所在的位置似乎是一个移动目标,但在我目前使用的计算机上/usr/share/X11If you have the widget in a function, you can set the widget background color resource like this, assuming the widget name is
w
: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