dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] Theme support in x11-winforms


From: Rhys Weatherley
Subject: [Pnet-developers] Theme support in x11-winforms
Date: Mon, 7 Jul 2003 15:03:11 +1000
User-agent: KMail/1.4.3

I've rearranged the theme-management code in x11-winforms in line with some 
discussions on #dotgnu.

There is a new namespace called "System.Windows.Forms.Themes", with three main 
classes:

    IThemePainter
    ThemeManager
    DefaultThemePainter

The "IThemePainter" interface is what you would implement to create a new 
theme.  Or you can inherit from "DefaultThemePainter" and override only those 
things that differ from the default behaviour.

The "ThemeManager" interface holds two "IThemePainter" instances: 
"MainPainter" and "SystemPainter".  The main painter is the one that you 
would normally use.  The system painter is for things like "ButtonBase" which 
have a special "FlatStyle.System" setting.

For example, to draw a border, you would use something like this:

    ThemeManager.MainPainter.DrawBorder(graphics, bounds, color, style);

If you need some new kind of theme-sensitive operation that isn't currently 
present, then add it to "IThemePainter" and "DefaultThemePainter".

Previously, all theme-related code was placed into the "ControlPaint" class.  
Now, "ControlPaint" merely redirects to the main IThemePainter.  Default 
implementations of theme-sensitive code should be placed into 
"DefaultThemePainter".  New code should avoid using "ControlPaint", and the 
existing code will be converted as time permits.

Right now, themes are not dynamically loadable, but that is easy to change 
once someone writes a new theme.

Cheers,

Rhys.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]