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