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

Developer

resources

Using themes in a Widget based applet

The code below is taken from the sample applet, c_widgettheming_app, which is on the http://developer.brewmp.com/resources along with this technology guide. A typical themed widget applet requires the following steps to use themes:

  1. Create the applet's widget tree.
  2. Enable theming on the Root Container.
    ERR_TRY( IWidget_EnableTheming(me->piwRoot) );
  3. Call IWidget_SetThemeTags() for widgets that do not use a default tag.
    nErr = IWidget_SetThemeTags(piwThemedWidget, "mybutton;button;base");
  4. Open the theme resource file.
    ERR_TRY( ISHELL_CreateInstance(me->a.m_pIShell,
       AEECLSID_ResFile, (void**)&me->pirNatureTheme) );
    ERR_TRY( IResFile_Open(me->pirNatureTheme,
       NATURETHEME_RES_FILE) );
  5. Create a theme manager.
    ERR_TRY( ISHELL_CreateInstance(me->a.m_pIShell,
          AEECLSID_CWidgetThemeMgr, (void**)&(piThemeMgr)) );
  6. Set the theme resource.
    ERR_TRY( IThemeMgr_QueryInterface(piThemeMgr,
          AEEIID_IThemeResource, (void**)&me->piThemeResource) );
    ERR_TRY( IThemeResource_Set(me->piThemeResource,
       IRESFILE_TO_IQI(me->pirNatureTheme)));
  7. Set the theme manager on the Root Container.
    ERR_TRY( IWidget_SetThemeMgr(me->piwRoot, piThemeMgr) );