Style Schemes of Graphics Objects
Style Scheme
- A style scheme is a data structure that determines how an object will be rendered on the screen. Style schemes contain all the colors, images, fonts, and text used in displaying an object. Style schemes are defined independently of objects. Upon the object’s creation, a user-defined style scheme is assigned to the object. A single style scheme may be assigned to many different objects.
Structure of a Style Scheme
The structure GFX_GOL_OBJ_SCHEME is used to hold instances of style schemes. GFX_GOL_OBJ_SCHEME is defined in GFX_GOL_SCHEME.h.
Styles schemes contain at least 16 items. Additional items will be added if Alpha Blending defined in GFX_CONFIG.h or Gradient Color Filling defined in GFX_CONFIG.h are enabled.
When an object is displayed, elements from the style scheme are applied to object-based upon the state bits of the object.
Structure Member | Function |
EmbossDkColor | Dark color is used for the 3-D effect of the object. |
EmbossLtColor | Light color is used for the 3-D effect of the object. |
TextColor0 | Generic text colors used by the objects. Usage may vary from one object type to another. |
TextColor1 | Generic text colors used by the objects. Usage may vary from one object type to another. |
TextColorDisabled | Text color is used when the object state bit is set to "disabled". |
Color0 | Generic color used to render objects. Usage may vary from one object type to another. |
Color1 | Generic color used to render objects. Usage may vary from one object type to another. |
ColorDisabled | Color used to render objects that are disabled. |
pFont | Pointer to the font table used by the object. |
fillStyle | Determines gradient type. Only used when Color Gradients are enabled. |
ComonBkColor | Used to hide objects from view without deleting them. |
ComonBkLeft | Horizontal starting point of the background. |
ComonBkTop | Vertical starting point of the background. |
ComonBkType | Specifies the type of background to use. |
*ComonBkImage | pointer to an image used as the background image. |
EmbossSize | Size of the panel for 3-D effects. Will be set to 0 if 3D is not used. |
AlphaValue | Alpha value used for alpha blending, this is only available only when GFX_CONFIG_ALPHABLEND_DISABLE is not commented out in gfx_config.h. |
gradientStartColor | Starting color for gradient color scheme. Only exists when GFX_CONFIG_GRADIENT_DISABLE is not commented out in gfx_config.h. |
gradientEndColor | Ending color for gradient color scheme. Only exists when GFX_CONFIG_GRADIENT_DISABLE is not commented out in gfx_config.h. |
Default Style Scheme
Creating and Using Style Schemes
It is quite common for an application to use several different style schemes. To create a style scheme, several steps must be taken:
- Create an instance of the style scheme structure and give it a name.
- Populate the newly created structure with the desired style scheme elements.
- Assign the new style scheme as graphic objects are created.
For instances where only a few elements of a new style scheme differ from an existing style scheme, many programmers find it more convenient to copy an existing scheme into a newly defined scheme, then edit a few different elements.
Example: Creating and Using a Custom Style Scheme
The following steps presume the gfx_gol_scheme_default file has been added to the project, resulting in the creation of a default scheme GOLSchemeDefault.
Create a pointer to a style scheme structure. In this example, the pointer is called MyNewScheme.
Copy the content of the exisitng default scheme to the newly create scheme.
Modify the contents of the scheme as needed to meet the application requirements. For this example, several of the elements of the new scheme have been modified.
Assign the newly created style scheme to an object.