Setting Colors and Fonts
Colors and fonts are common attributes of all Wave Widgets. Keywords are provided for setting these attributes.
Setting Colors
Many Wave Widgets provide keywords for setting colors. The keywords include: Basecolor, Background, and Foreground.
Basecolor—The color of the “container” or “box” for the following widgets: ButtonBox, RadioBox, ToolBox, and ControlsBox.
Background—The color of a button.
Foreground—The color of the text on a button.
Figure 5-29: Color Keywords illustrates the use of each color keyword.
 
Figure 5-29: Color Keywords
The color keywords have the form:
Keyword = 'colorname'
where colorname is the name of an X library color. For example:
Background = 'Skyblue'
Color names are commonly found in the following files on most systems:
(UNIX) /usr/lib/X11/rgb.txt
(WIN) <maindir>\wave\lib\std\windows\rgb.txt
where <maindir> is the main PV‑WAVE directory.
 
note
For Windows, this file is a reference file only. Any modifications made to this file will not affect the colors used by PV‑WAVE.
If you cannot find these color files on your system, see your System Administrator.
Predefined Colors for Windows Systems
In addition to the colors listed in the rgb.txt file, you may use any of the predefined Windows system colors listed in Table 5-2: Predefined WIndows System Colors as your widget colors.
 
Predefined WIndows System Colors  
Windows System Colors
Corresponding Widget Color
COLOR_3DDKSHADOW
Dark shadow for 3D display elements.
COLOR_3DFACE,
COLOR_BTNFACE
Face color for 3D display elements.
COLOR_3DHILIGHT,
COLOR_3DHIGHLIGHT,
COLOR_BTNHILIGHT,
COLOR_BTNHIGHLIGHT
Highlight color for 3D display elements (for edges facing the light source).
COLOR_3DLIGHT
Light color for 3D display elements (for edges facing the light source).
COLOR_3DSHADOW,
COLOR_BTNSHADOW
Shadow color for 3D display elements (for edges facing away from the light source).
COLOR_ACTIVEBORDER
Active window border.
COLOR_ACTIVECAPTION
Active window caption.
COLOR_APPWORKSPACE
Background color of multiple document interface (MDI) applications.
COLOR_BACKGROUND,
COLOR_DESKTOP
Desktop.
COLOR_BTNTEXT
Text on push buttons.
COLOR_CAPTIONTEXT
Text in caption, size box, and scroll bar arrow box.
COLOR_GRAYTEXT
Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.
COLOR_HIGHLIGHT
Items selected in a control.
COLOR_HIGHLIGHTTEXT
Text of selected items in a control.
COLOR_INACTIVEBORDER
Inactive window border.
COLOR_INACTIVECAPTION
Inactive window caption.
COLOR_INFOBK
Color of text in an inactive caption.
COLOR_INFOTEXT
Text color for tool tip controls.
COLOR_MENU
Menu background.
COLOR_MENUTEXT
Text in menus.
COLOR_SCROLLBAR
Scroll bar gray area.
COLOR_WINDOW
Window background.
COLOR_WINDOWFRAME
Window frame.
COLOR_WINDOWTEXT
Text in windows.
Specifying XtDefaultForeground or XtDefaultBackground causes the widget to use the appropriate Windows system colors.
Setting Fonts on UNIX
The Font keyword is used to set the font used to create text in a widget. The Font keyword has the form:
Font = 'fontname'
where fontname is the name of a font available on your system. On UNIX, for example, Font may be specified as follows:
Font = '-b&h-lucida-bold-r-normal-sans-14-*'
 
note
Use the command xlsfonts to obtain a list of fonts available on your X server.
If you inadvertently specify a font that cannot be found by the X server, a different font will be substituted.
Setting Fonts on Windows
On Windows, use the MSFont keyword to specify fonts for use in Wave Widgets. The MSFont keyword is specified as a string of the following form:
'face_name, point size, attribute'
where face_name specifies the type face, and attribute specifies font attributes such as bold, italic, underline, etc.
For example: MSFont = 'Arial, 8, bold'
You can also specify Windows system fonts as shown in Table 5-3: Window System Fonts.
 
Window System Fonts
Windows System Fonts
Corresponding Widget Fonts
ANSI_FIXED
Windows fixed-pitch (monospace) system font.
ANSI_VAR
Windows variable-pitch (proportional space) system font.
DEFAULT_GUI
Default font for user interface objects such as menus and dialog boxes.
DEVICE_DEFAULT
The standard font for the current graphics device.
OEM_FIXED
Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.
SYSTEM
The standard Windows variable-width system font.
SYSTEM_FIXED
The standard, fixed-width Windows system font.
If the font you specify isn’t supported on your system, Windows substitutes another font, which is usually the system font.
Using a Resource File to Set Colors and Fonts
Characteristics such as foreground color, background color, and font are known as resources, and these characteristics can be initialized using a resource file. Wave Widgets provides the ability to specify these resources with the keywords Foreground, Background, Basecolor, and Font, as discussed in the previous two sections.
When the Resource File is Checked
If widget resources are not specified with the keywords Foreground, Background, Basecolor, and Font, PV-WAVE will query the X resource database and use the values defined there.
 
note
Using a resource file for Wave Widgets is optional.
Adding resources to the resource database is a two step process.
*The first step is to create a resource file. The following is a sample resource file for setting application-wide resources for foreground color, background color, and font of a Wave Widgets application called my_gui:
my_gui*foreground: Black
my_gui*background: Cyan
my_gui*font: fixed
*The name my_gui is defined in the WwInit command. For example:
top = WwInit('my_gui', 'Examples', layout, /Vertical)
*You can also put the resource names in your .Xdefaults file, if you only need to customize your own version of the software. Either way, the new values of the resources will not take effect until the next time PV-WAVE is started.
*The second step is to install the resource file into the X resource database. The simplest way to install resources is to merge your resource file with X resource database using the following command:
xrdb -merge resource_filename
*where resource_filename is the name of your resource file.
 
note
It is also possible to set the resources for particular widgets or groups of widgets in your application. To do this, you will have to know the names of all or some of the widgets in the widget hierarchy. (A widget’s name is determined by its placement in the hierarchy.) The more specific the widget hierarchy you provide, the fewer the number of widgets that are affected by the change.
For more information about how widgets are related to one another, see "The Widget Hierarchy".
To find out widget names of particular Wave Widgets, refer to the appropriate Wave Widgets .pro files located in the standard library directory:
(UNIX) $RW_DIR/wave/lib/std/motif
(WIN) %RW_DIR%\wave\lib\std\windows
Where RW_DIR is the main Rogue Wave directory.
For more information about how to write and install X Window System resource files, refer to Volume 4 of the X Toolkit Intrinsics Programming Manual, O’Reilly & Associates, Inc., Sebastopol, CA, 1990.