Colors
The background and foreground color of widgets can be set and queried by the application using the backgroundColor and foregroundColor resources. The foregroundColor is used for text or other foreground graphics, and the backgroundColor is used to fill the background of the widget. The color values are specified using CgRGBColor objects which allow the application to specify the red, green, and blue components of the desired color. See Specifying colors for more information concerning the use of CgRGBColor objects. There are platform-specific limitations concerning setting the colors of certain widgets. See Appendix E, Common widgets platform differences for the details of these limitations.
Tip:
Due to platform-specific limitations, a widget might not take on a requested color setting, or it might take on a slightly different color setting than requested. To determine the exact color a widget is using, the resource can be queried after it is set. Querying the color resource always returns the color the widget is actually using. For details on platform limitations, see "Appendix".
The following code creates a multiline text widget and sets its foregroundColor to black and its backgroundColor to blue.
| shell text |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: [:w | w title: 'Color Example'].
text := shell
createText: 'text'
argBlock: [:w | w
editMode: XmMULTILINEEDIT;
columns: 50;
rows: 4;
value: 'Hello';
foregroundColor: CgRGBColor white;
backgroundColor: (shell screen lookupColor: 'blue')].
text manageChild.
shell realizeWidget
Last modified date: 04/11/2019