Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Theme tags

A theme tag is the name of a table of properties in the current theme. A widget that supports themes can have one or more tables of properties associated with it by setting the theme tags property.

When a theme is applied to a widget, the properties in all associated tables are merged. Then each property is set once on the widget. If a property is defined in more than one table, only the value in the table with the highest precedence is applied.

For example, setting a widget's theme tag property to "mybutton;button;base" applies the properties in the mybutton, base, and button tables. The first tag has the highest precedence and the last tag has the least precedence. If all three tables define PROP_BORDERCOLOR, only the value in the mybutton table is applied because mybutton has the highest precedence.

Default theme tags

A widget may have a default value for its theme tags. These are the tags (the tables of properties) that are used by default when a theme is applied to the widget.

Most of the UI Widget classes have default theme tags. A table of properties associated with a default theme tag can be specified using the ClassID of the widget (see the example in nr:PropertySkip).

The example below displays a static widget's default theme tag:

// Create widget
ERR_TRY( ISHELL_CreateInstance(me->a.m_pIShell, AEECLSID_CStaticWidget,
                               (void**) &piwLabel) );
//The string is owned by the widget and does not need to be freed
ERR_TRY( IWidget_GetThemeTags(piwLabel, &strTags) );
//prints
//"Static Widget's default theme tag is AEECLSID_CStaticWidget.properties"
DBGPRINTF("Static Widget's default theme tag is %s", strTags);

Default theme tags are different than default property values. For example, for a TextWidget the default value for the border color property is black. However, you can define a theme in which the TextWidget's default theme tag has the border color property set to green. When that theme is set to a Widget tree with a TextWidget, the border color is set to green.

Setting theme tags

A widget's theme tag can be changed using IWidget_SetThemeTags(), for example:

nErr = IWidget_SetThemeTags(piwThemedWidget, "mybutton;button;base");

See the http://developer.brewmp.com/reference/api-all for more details on IWidget_SetThemeTags().