GenView: 3.3 Basic View Attributes: Setting the Background Color

Up: GEOS SDK TechDocs | Up | Prev: 3.2 Dimensional Attributes | Next: 3.4 The GVI_increment Attribute
GVI_color, MSG_GEN_VIEW_SET_COLOR, MSG_GEN_VIEW_GET_COLOR, GVCD_INDEX, GVCD_RED, GVCD_FLAGS, GVCD_BLUE_AND_GREEN, GVCD_BLUE, GVCD_GREEN

A view can have its background color determined by an RGB value, a grayscale value, a CMY value, or as a GEOS color index.

If a view is managing generic objects or is displaying text, it may be most appropriate for the view to appear with the same background color as its parent Primary window. To do this, set the view's GVI_attrs field to the following:

GVI_attrs = @default | GVA_SAME_COLOR_AS_PARENT_WIN;

Otherwise, you will probably want to set the view to something other than the parent's color. To use a standard color index (16-color EGA set), set the GVI_color attribute as follows:

GVI_color = {index, 0, 0, 0};
	/* index is a GEOS color index, one
	 * of the Color enumerated type. */

There is no need to set any of the other color fields if you are using an index. The default background color is determined by the specific UI but is normally C_WHITE. (Color indexes are described in the Drawing Shapes chapter.)

If you want to use the RGB scheme for setting the background color, you must know the structure used for defining the color. The view uses the structure ColorQuad to hold all four of the color data fields. This structure is defined as follows:

typedef struct {
    byte			CQ_redOrIndex;
			/* color index or red value */
    ColorFlag			CQ_info;
    byte			CQ_green;		/* green value */
    byte			CQ_blue;		/* blue value */
} ColorQuad;

When using a color index, you only need to set the CQ_info field to the proper index and set the flags to zero. When using other types of value, however, you must set the CQ_info byte to the type and the other fields to their proper values as shown below:

GVI_color = { redVal,					/* red RGB value */
              CF_RGB,					/* RGB flag */
              greenVal,					/* green RGB value */
              blueVal }					/* blue RGB value */

The ColorFlag record determines how the color will appear on the screen. It record may have any of one the following values:

CF_INDEX
This flag indicates the color is a palette index, specified in the CQ_redOrIndex field.
CF_GRAY
This flag indicates the color will be set with a grayscale value as determined by the other three fields.
CF_SAME
This flag indicates the color will not be changed (used for hatch patterns, for example).
CF_CMY
This flag indicates the color is set with CMY values.
CF_RGB
This flag indicates the colors are specified in RGB values in the other three color fields.

As an alternative, you may retrieve, set, or change the view's background color during execution with the messages MSG_GEN_VIEW_SET_COLOR and MSG_GEN_VIEW_GET_COLOR . These messages are shown below. You may also use the macros referenced below to construct and extract color arguments.

MSG_GEN_VIEW_SET_COLOR

void	MSG_GEN_VIEW_SET_COLOR(
        byte		indexOrRed,				/* color index or red value */
        ColorFlag		flags,				/* color flags */
        word		greenBlue);				/* green and blue values */

This message sets the background color of the view. It will not affect the document or printing. The color may be specified either by standard GEOS color index or by RGB value.

Source: Unrestricted.

Destination: Any GenView object.

Parameters: indexOrRed If specifying the color as an index, this is the index value. If specifying as an RGB value, this is the red component of the value.

flags
A record of ColorFlag . If specifying the color as an RGB value, set this to CF_RGB. If specifying the color as a palette index, set this to CF_INDEX.
greenBlue
The green and blue components of the RGB value. If specifying color as an index, set this to zero. If specifying as an RGB value, combine the green and blue components into a single parameter with the macro GVC_GREEN_AND_BLUE.

Return: Nothing.

Interception: Generally not intercepted.

MSG_GEN_VIEW_GET_COLOR

dword	MSG_GEN_VIEW_GET_COLOR();

This message returns all four fields of the view's background color in a single dword value.

Source: Unrestricted.

Destination: Any GenView object.

Parameters: None.

Return: The four color specifier fields of the GenView's current background color. The individual values may be retrieved with the macros below.

Interception: Generally not intercepted.

GVCD_INDEX

byte	 GVCD_INDEX(val);
        dword	val;

This macro extracts the color index byte from the given dword value. It is intended for use when an index is used.

GVCD_RED

byte	 GVCD_RED(val)
        dword	val;

This macro extracts the red component byte from the given dword value. It is intended for use with RGB values.

GVCD_FLAGS

byte	 GVCD_FLAGS(val)
        dword	val;

This macro extracts the color flags byte from the given dword.

GVCD_GREEN

byte	 GVCD_GREEN(val)
        dword	val;

This macro extracts the green component byte from the given dword.

GVCD_BLUE

byte	 GVCD_BLUE(val)
        dword	val;

This macro extracts the blue component byte from the given dword.


Up: GEOS SDK TechDocs | Up | Prev: 3.2 Dimensional Attributes | Next: 3.4 The GVI_increment Attribute