This patch contains a refactoring of the managed VisualStyles API to allow multiple implementations. The existing implementation was moved to VisualStylesNative.
Design
The new code is split in two parts. The code in GtkPlus wraps GTK+ and exposes
methods to paint controls (mostly based on ThemeGtk in the experimental mode,
but faster and with less bugs). The VisualStyles implementation itself is
VisualStylesGtkPlus and it translates class name/part/state combinations to
calls to GtkPlus.
This new VisualStyles implementation combined with the VisualStyles theme would
achieve a native GTK+ look for many of the usual controls. However, due to some
differences between the VisualStyles and GTK+ APIs, a better (faster and more
flexible) long term solution for having a native GTK+ look would be to write a
new theme (or refactor ThemeGtk) to use the GtkPlus code directly. This would
be faster especially for controls with a solid color background and would allow
painting control elements not supported by the VisualStyles API (if there are
any).
Status
The code is far from finished. It is meant as proof of concept. I need to know
if the approach is good.
Only background painting for the
VisualStyleElement.Button.CheckBox.UncheckedNormal element is implemented.
You can use this to test it
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
class Test
{
static void Main ()
{
Application.Run (new TestForm ());
}
class TestForm : Form
{
public TestForm ()
{
SetStyle (ControlStyles.ResizeRedraw, true);
DoubleBuffered = true;
BackgroundImage = Icon.ToBitmap ();
}
protected override void OnPaint (PaintEventArgs e)
{
new VisualStyleRenderer
(VisualStyleElement.Button.CheckBox.UncheckedNormal).DrawBackground
(e.Graphics, ClientRectangle);
}
}
}
On Windows, in the HKEY_CURRENT_USER\Software\Mono registry key, you need to
add a string value named "VisualStyles" with the data "GTK+".
On non-Windows platforms you can either use DLL mapping for the GTK+ libraries
or disable the "#define Windows" line in GtkPlus.cs.
VisualStylesGtkPlus.patch.gz
Description: GNU Zip compressed data
_______________________________________________ Mono-winforms-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-winforms-list
