Hi,
The attached patch makes a small change to Theme (and derived classes)
to make it more compatible with MS (see included unit tests).
On both the 1.0 and 2.0 profile, Theme.DefaultFont is now MS Sans Sarif
8.25 (instead of 8). This matches Control.Font and
SystemFonts.DefaultFont on MS.
On the 2.0 profile, Theme.DefaultFont is initialized with
SystemFonts.DefaultFont.
I modified the accessibility of the default_font field to private, since
Theme.DefaultFont is virtual anyway.
Let me know if it's ok to commit.
Gert
Index: System.Windows.Forms/Theme.cs
===================================================================
--- System.Windows.Forms/Theme.cs (revision 70199)
+++ System.Windows.Forms/Theme.cs (working copy)
@@ -187,16 +187,25 @@
}
internal abstract class Theme
- {
+ {
protected Array syscolors;
- protected Font default_font;
- protected Font window_border_font;
+ private readonly Font default_font;
+ protected Font window_border_font;
protected Color defaultWindowBackColor;
protected Color defaultWindowForeColor;
protected bool always_draw_hotkeys = true;
internal SystemResPool ResPool = new SystemResPool ();
private Type system_colors = Type.GetType("System.Drawing.SystemColors, System.Drawing");
+ protected Theme ()
+ {
+#if NET_2_0
+ default_font = SystemFonts.DefaultFont;
+#else
+ default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
+#endif
+ }
+
private void SetSystemColors(string name, Color value) {
if (system_colors != null) {
MethodInfo update;
Index: System.Windows.Forms/ThemeGtk.cs
===================================================================
--- System.Windows.Forms/ThemeGtk.cs (revision 70199)
+++ System.Windows.Forms/ThemeGtk.cs (working copy)
@@ -383,7 +383,6 @@
{
Console.WriteLine ("ThemeGtk constructor");
InitGtk ();
- default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
LoadSysDefaultColors ();
Index: System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- System.Windows.Forms/ThemeWin32Classic.cs (revision 70199)
+++ System.Windows.Forms/ThemeWin32Classic.cs (working copy)
@@ -67,7 +67,6 @@
{
defaultWindowBackColor = this.ColorWindow;
defaultWindowForeColor = this.ColorControlText;
- default_font = new Font (FontFamily.GenericSansSerif, 8f);
window_border_font = new Font(FontFamily.GenericSansSerif, 8.25f, FontStyle.Bold);
/* Menu string formats */
Index: Test/System.Windows.Forms/ControlTest.cs
===================================================================
--- Test/System.Windows.Forms/ControlTest.cs (revision 70201)
+++ Test/System.Windows.Forms/ControlTest.cs (working copy)
@@ -445,6 +445,47 @@
}
[Test]
+ public void FontTest ()
+ {
+ Control c = new Control ();
+ Assert.IsFalse (c.Font.Bold, "#A1");
+ //Assert.AreEqual ("Microsoft Sans Serif", c.Font.FontFamily.Name, "#A2");
+ Assert.IsFalse (c.Font.Italic, "#A3");
+ //Assert.AreEqual ("Microsoft Sans Serif", c.Font.Name, "#A4");
+ Assert.AreEqual (8.25, c.Font.Size, "#A5");
+ Assert.AreEqual (8.25, c.Font.SizeInPoints, "#A6");
+ Assert.IsFalse (c.Font.Strikeout, "#A7");
+ Assert.IsFalse (c.Font.Underline, "#A8");
+ Assert.AreEqual (GraphicsUnit.Point, c.Font.Unit, "#A9");
+#if NET_2_0
+ Assert.IsTrue (c.Font.IsSystemFont, "#A10");
+#endif
+
+ c.Font = new Font (c.Font.FontFamily, 3, FontStyle.Italic);
+ Assert.IsFalse (c.Font.Bold, "#B1");
+ //Assert.AreEqual ("Microsoft Sans Serif", c.Font.FontFamily.Name, "#B2");
+ Assert.IsTrue (c.Font.Italic, "#B3");
+ //Assert.AreEqual ("Microsoft Sans Serif", c.Font.Name, "#B4");
+ Assert.AreEqual (3, c.Font.Size, "#B5");
+ Assert.AreEqual (3, c.Font.SizeInPoints, "#B6");
+ Assert.IsFalse (c.Font.Strikeout, "#B7");
+ Assert.IsFalse (c.Font.Underline, "#B8");
+ Assert.AreEqual (GraphicsUnit.Point, c.Font.Unit, "#B9");
+#if NET_2_0
+ Assert.AreEqual (false, c.Font.IsSystemFont, "#B10");
+#endif
+ }
+
+ [Test]
+ [Category ("NotWorking")] // on Unix mapping is done to Bitstream Vera Sans
+ public void FontTest_Names ()
+ {
+ Control c = new Control ();
+ Assert.AreEqual ("Microsoft Sans Serif", c.Font.FontFamily.Name, "#1");
+ Assert.AreEqual ("Microsoft Sans Serif", c.Font.Name, "#2");
+ }
+
+ [Test]
public void PubPropTest()
{
Control c = new Control();
@@ -1212,7 +1253,27 @@
}
}
-
+ [Test]
+ public void ResetFontTest ()
+ {
+ Control c = new Control ();
+ c.Font = new Font (c.Font.FontFamily, 3, FontStyle.Italic);
+ c.ResetFont ();
+
+ Assert.IsFalse (c.Font.Bold, "#1");
+ //Assert.AreEqual ("Microsoft Sans Serif", c.Font.FontFamily.Name, "#2");
+ Assert.IsFalse (c.Font.Italic, "#3");
+ //Assert.AreEqual ("Microsoft Sans Serif", c.Font.Name, "#4");
+ Assert.AreEqual (8.25, c.Font.Size, "#5");
+ Assert.AreEqual (8.25, c.Font.SizeInPoints, "#6");
+ Assert.IsFalse (c.Font.Strikeout, "#7");
+ Assert.IsFalse (c.Font.Underline, "#8");
+ Assert.AreEqual (GraphicsUnit.Point, c.Font.Unit, "#9");
+#if NET_2_0
+ Assert.AreEqual (true, c.Font.IsSystemFont, "#10");
+#endif
+ }
+
public class LayoutTestControl : Control {
public int LayoutCount;
Index: Test/System.Windows.Forms/DataGridTest.cs
===================================================================
--- Test/System.Windows.Forms/DataGridTest.cs (revision 70199)
+++ Test/System.Windows.Forms/DataGridTest.cs (working copy)
@@ -163,7 +163,7 @@
Assert.AreEqual (dg.CaptionFont.FontFamily, dg.Font.FontFamily, "#A2");
Assert.AreEqual (dg.CaptionFont.Height, dg.Font.Height, "#A3");
#if NET_2_0
- Assert.AreEqual (dg.CaptionFont.IsSystemFont, dg.Font.IsSystemFont, "#A4");
+ Assert.IsFalse(dg.CaptionFont.IsSystemFont, "#A4");
#endif
Assert.AreEqual (dg.CaptionFont.Italic, dg.Font.Italic, "#A5");
Assert.AreEqual (dg.CaptionFont.Name, dg.Font.Name, "#A6");
Index: System.Windows.Forms/ChangeLog
===================================================================
--- System.Windows.Forms/ChangeLog (revision 70199)
+++ System.Windows.Forms/ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2006-12-29 Gert Driesen <[EMAIL PROTECTED]>
+
+ * Theme.cs: Marked default_font as private, and initialize it in ctor
+ with MS Sans Sarif 8.25 on 1.0 profile, and SystemFonts.DefaultFont
+ on 2.0 profile.
+ * ThemeGtk.cs: Removed default_font intialization.
+ * ThemeWin32Classic.cs: Removed default_font initialization.
+
2006-12-28 Chris Toshok <[EMAIL PROTECTED]>
* Control.cs: fix a couple of place where we were creating handles
Index: Test/System.Windows.Forms/ChangeLog
===================================================================
--- Test/System.Windows.Forms/ChangeLog (revision 70201)
+++ Test/System.Windows.Forms/ChangeLog (working copy)
@@ -1,5 +1,10 @@
2006-12-29 Gert Driesen <[EMAIL PROTECTED]>
+ * ControlTest.cs: Added test for Font and ResetFont.
+ * DataGridTest.cs: Fixed CaptionFont test on 2.0 profile.
+
+2006-12-29 Gert Driesen <[EMAIL PROTECTED]>
+
* ControlTest.cs: Improved DoubleBufferedTest.
2006-12-28 Chris Toshok <[EMAIL PROTECTED]>
_______________________________________________
Mono-winforms-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list