Style Schemes of Graphics Objects

Last modified by Microchip on 2024/12/05 12:59

This page contains information for the Graphics Library found in Microchip Libraries for Applications (MLA). It is not relevant for MPLAB® Harmony Graphics Library.

​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
EmbossDkColorDark color is used for the 3-D effect of the object.
EmbossLtColorLight color is used for the 3-D effect of the object.
TextColor0Generic text colors used by the objects. Usage may vary from one object type to another.
TextColor1Generic text colors used by the objects. Usage may vary from one object type to another.
TextColorDisabledText color is used when the object state bit is set to "disabled".
Color0Generic color used to render objects. Usage may vary from one object type to another.
Color1Generic color used to render objects. Usage may vary from one object type to another.
ColorDisabledColor used to render objects that are disabled.
pFontPointer to the font table used by the object.
fillStyleDetermines gradient type. Only used when Color Gradients are enabled.
ComonBkColorUsed to hide objects from view without deleting them.
ComonBkLeftHorizontal starting point of the background.
ComonBkTopVertical starting point of the background.
ComonBkTypeSpecifies the type of background to use.
*ComonBkImagepointer to an image used as the background image.
EmbossSizeSize of the panel for 3-D effects. Will be set to 0 if 3D is not used.
AlphaValueAlpha value used for alpha blending, this is only available only when GFX_CONFIG_ALPHABLEND_DISABLE is not commented out in gfx_config.h.
gradientStartColorStarting color for gradient color scheme. Only exists when GFX_CONFIG_GRADIENT_DISABLE is not commented out in gfx_config.h.
gradientEndColorEnding color for gradient color scheme. Only exists when GFX_CONFIG_GRADIENT_DISABLE is not commented out in gfx_config.h.

Back to top

Default Style Scheme

​If the file gfx_gol_scheme_default.c is added to a project, it will create a style scheme called GOLSchemeDefault. The default scheme will be populated with the colors defined in gfx_gol_scheme_default.c. This default scheme may be used as is or may be modified to meet the application needs.

Back to top

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:

  1. Create an instance of the style scheme structure and give it a name.
  2. Populate the newly created structure with the desired style scheme elements.
  3. 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.

Back to top

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.

Scheme Pointer

Create a pointer to a style scheme structure. In this example, the pointer is called MyNewScheme.

Pointer to a style scheme structure

Copy the content of the exisitng default scheme to the newly create scheme.

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.

Asssign the newly created style scheme to an object.

Assign the newly created style scheme to an object.

Back to top

Learn More

Back to top