LMDThemes Overview

From LMD
Jump to: navigation, search

Short structure overview: units, classes, globals

Themezation in LMD Tools 2011 is supported by LMDThemes.pas unit found in lmdrtlx package and units found in lmdthemes package.

LMDThemes unit contains general definitions needed for supporting themes:

  • Enumeration types, constants;
  • Base class for theme renderers (TLMDThemeRenderer);
  • Base class for theme renderer controllers (TLMDThemesControllerBase);
  • Facade class TLMDThemeServices which serves as a single entry point for all themed rendering of controls.

Almost all controls of LMD Tools/ElPack have ThemeMode property which can be set to ttmNone (classic look), ttmPlatform (themed look implemented by OS), ttmNative (themed look implemented by LMD Theme renderers). Thus, three kind of look and fee; are available simultaneously: non-themed, themed with currently available platform theme, and themed by any of available renderers. There can be only one native renderer active at any particular moment of time, that is, it is impossible to make one button on the form look like in Office 2007 theme, and another like in Office 2003 theme.

Main changes from 2010 - short list

From 2010 to 2011, LMDThemes unit was changed as following.

Several enumeration types and event types were added: TLMDStateColorMode, TLMDFormThemeProviderOption, TLMDFormThemeProviderOptions, TLMDThemedButtonState, TLMDThemesOnDrawCheckMarkEvent, TLMDThemesOnDrawArrowEvent, TLMDThemesOnDrawGradientArrowEvent, TLMDThemesOnDrawSimpleSignEvent, TLMDThemesOnDrawScrollThumbGripperEvent.

TLMDThemesControllerBase class was added. This is a base class for theme renderer controllers, or, shortly, theme controllers. Theme controller components allow to add needed renderers units at design time, implement custom drawing of some elements via events, and enable/disable renderers.

TLMDThemeRenderer received three class methods:

class function Controller: TLMDThemesControllerBase; class procedure Init; virtual; class function GetThemeRendererName: TLMDString; virtual;

The latter one was introduced earlier in 2010 version, but in 2011 it is made a class method, so that one can retrieve renderer's name without instantiating it. Also, interface of TLMDThemeRenderer received two methods for supporting form theme providers. Form theme provider is a component that allows to apply themed look to non-client area of forms. In 2010, TLMDFormThemeProvider supported only one renderer - TLMDThemeEngine, which implements Windows XP themes. TLMDFormThemeProvider will support other renderers in subsequent updates.

IsEnabled method removed (use Enabled property instead).

In 2010, theme renderers automatically registered themselves in initialization sections of corresponding units. In 2011, this approach is not used any more. Instead of automatic self-registering, renderers must be registered explicitly by calling class method Init or by using theme controllers.

Short history from the very beginning

In LMD 2003, themed look was implemented by a LMDXPStyles.pas unit. It allowed to use themed look in Delphi 6 on operating systems with theme support (Windows XP and higher).

In LMD 2007, a native theme engine was ported to LMD Tools from ElPack. This engine allowed to use XP-themed look on operating systems without support of XP themes (Windows 2000 and earlier). Enabling/disabling themes required changing switches in lmdcmps.inc file and recompiling.

From LMD 2007 to LMD 2009, the architecture of themezation was reworked and simplified. Controls received two main properties ThemeMode and ThemeGlobalMode. LMDXPStyles unit was removed, and standard wrapper units uxtheme.pas and themes.pas are used instead. All calls to themed drawings are performed via single instance of TLMDThemeServices class, which dispatches calls either to uxtheme.dll (if ThemeMode = ttmPlatform) or to native theme renderer (if ThemeMode = ttmNative).

In LMD 2010, a universal gradient theme renderer was introduced for rendering Office 2007 like themes.

In LMD 2011, a universal gradient theme renderer was enhanced, Office2010-like theme was added, many fixes were made; also the theme editor was implemented. New components added: controllers for gradient theme renderers (TLMDThemesGradientThemeController, TLMDSimpleGradientThemeController, TLMDSimpleGradientExtThemeController); ribbon control theme adapter (TLMDThemeRibbonAdapter).

Theme-related properties in LMD Tools/ElPack

Obsolete properties

  • CtlXP (LMD Tools)
  • UseXPThemes (ElPack)

These properties are left for compatibility, do not use them.

Currently used properties:

  • ThemeMode
  • ThemeGlobalMode

Transparency and themes (ElPack controls)

There are two properties concerning transparency In ElPack:

  • Transparent
  • TransparentXPThemes

They are used to control transparency independently for themed and non-themed mode. TransparentXPThemes property is used when control is themed.