LMD 2007 - Theme Engine

From LMD
Revision as of 21:05, 3 June 2007 by Rafael (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<< Back to Getting started or Product Resources page

[edit]

Introduction

This text describes use of standalone theme engine in LMD 2k7 packages. The engine provides allows an application to load and apply visual styles defined by msstyles file and some customizations such as controlling how readonly & disable states are rendered. The engine makes it possible to use visual styles in applications running under older OS (Windows 95-98, Windows 2000).


Switches

Units

Theme engine consists of one unit from rtl packages (LMDXPStyles.pas) and eleven units from rtlx package.

  • LMDXPStyles.pas defines theme related constants, types and pointers to theme engine routines.
  • LMDThemes.pas defines facade class TLMDThemeEngine and helper class TLMDThemeEngineController. If LMDDISABLE_LMDTHEMEENGINE is undefined, i.e. usning theme engine is allowed, then an instance of TLMDThemeEngine class is created in initialization section of the unit. Creating this instance initializes theme engine and reassigns procedural variables of LMDXPStyles unit so that calls to system theme routines are redirected to standalone theme engine routines.
  • LMDFormThemeProvider.pas defines TLMDFormThemeProvider class.
  • LMDThemesGeneral.pas holds ancestor classes TTheme, TThemePart and TThemeManager which define theme tree-like framework.
  • LMDThemesGraphics.pas defines several drawing routines.
  • LMDThemesMain.pas holds all necessary theme related routines that are actually called if standalone theme engine is used.
  • LMDThemesWindowsXP.pas defines classes TWindowsXPTheme, TWindowsXPThemePart and TWindowsXPThemeManager (descendants of TTheme, TThemePart and TThemeManager) which implement details specific to XP theming: parsing msstyles file, general drawing routines, metrics routines. These classes are initialized when msstyles file is parsed and hold all necessary data to render XP themed controls.
  • LMDThemesWindowsXPConsts.pas specifies XP theme constants.
  • LMDThemesWindowsXPParts.pas defines classes that specify themed rendering details for controls.
  • LMDThemesWindowsXPTypes.pas defines XP theme specific enumeration types.
  • LMDThemesWindowsXPUtils.pas holds helper converting routines.


Classes

The theme engine framework is defined by three main classes TThemeManager, TTheme and TThemePart (LMDThemesGeneral unit). ThemeManager mantains a list of Themes, each of which is actually a root of tree of theme parts.

  • TThemeManager - abstract generic class, corresponds to a generic visual style.
  • TTheme - generic class, corresponds to a generic control theme.
  • TThemePart - abstract generic class, corresponds to a generic theme for a control part.

One can access theme engine by means of two classes, TLMDThemeEngine and TLMDThemeEngineController:

  • TLMDThemeEngine - a facade class, provides a single access point to theme engine interface. A single instance of this class is created when LMDThemes unit is initialized. One can access theme engine properties and methods via LMDThemeEngine instance at runtime. By several reasons this class, though is a descendant of TLMDCustomComponent, is not placed on component palette. Main reasons are:
    • If theme engine is turned on, one single instance of TLMDThemeEngine must be created at runtime even if no instances were placed on the form at design time.
    • If instances of TLMDThemeEngine were allowed to be created at design time, then standard notification mechanism would have had to be implemented, which is unnecessary.
  • TLMDThemeEngineController - a simple helper class that allows to access theme engine settings at design time. All get- and set- methods of this class actually deal with corresponding properties in LMDThemeEngine. There can be created arbitrary number of instances of this class. Changing property in any of of them would change property with the same name in the instance of TLMDThemeEngine (though one instance would suffice). At design time, theme engine properties can be accessed via LMDThemeEngineController instance.

Windows XP visual styles are implemented by TWindowsXPThemeManager, TWindowsXPTheme and TWindowsXPThemePart classes along with a bundle of TWindowsXPThemePart's descendants (e.g. TWindowsXPThemeCheckBox, TWindowsXPThemeComboBoxDropDown etc) each of which implements specific rendering details for corresponding themed control.

TLMDFormThemeProvider allows to apply current theme to the owner form on which it resides. Also, it provides alternative mechanism for theme changes notification: each form theme provider registers itself by LMDThemeEngine.RegisterFormThemeProvider method. Thus, LMDThemeEngine maintains a list of all for theme providers.