Author: gert
Date: 2007-03-31 07:32:38 -0500 (Sat, 31 Mar 2007)
New Revision: 75239
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
Log:
* RichTextBoxTest.cs: Added BackColor test. Improved ReadOnly tests.
Added ScrollBars tests.
* TextBoxTest.cs: Improve BackColor test. Added ScrollBars tests.
Improved ReadOnly tests.
* TextBox.cs: Added internal ChangeBackColor method to special-case
Color.Empty. Added check for invalid ScrollBars value.
* TextBoxBase.cs: Added internal ChangeBackColor method.
* RichTextBox.cs: Only set backcolor_set on 2.0 profile. Added
internal ChangeBackColor method to special-case Color.Empty. Added
check for invalid ScrollBars value.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-03-30 22:26:05 UTC (rev 75238)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-03-31 12:32:38 UTC (rev 75239)
@@ -1,3 +1,12 @@
+2007-03-31 Gert Driesen <[EMAIL PROTECTED]>
+
+ * TextBox.cs: Added internal ChangeBackColor method to special-case
+ Color.Empty. Added check for invalid ScrollBars value.
+ * TextBoxBase.cs: Added internal ChangeBackColor method.
+ * RichTextBox.cs: Only set backcolor_set on 2.0 profile. Added
+ internal ChangeBackColor method to special-case Color.Empty. Added
+ check for invalid ScrollBars value.
+
2007-03-30 Everaldo Canuto <[EMAIL PROTECTED]>
* MenuItem.cs: On invalidate prevent form to create handle. [Fixes
#81272]
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2007-03-30 22:26:05 UTC (rev 75238)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2007-03-31 12:32:38 UTC (rev 75239)
@@ -83,7 +83,9 @@
LostFocus += new EventHandler(RichTextBox_LostFocus);
GotFocus += new EventHandler(RichTextBox_GotFocus);
BackColor = ThemeEngine.Current.ColorWindow;
+#if NET_2_0
backcolor_set = false;
+#endif
ForeColor = ThemeEngine.Current.ColorWindowText;
base.HScrolled += new
EventHandler(RichTextBox_HScrolled);
@@ -96,6 +98,21 @@
#endregion // Public Constructors
#region Private & Internal Methods
+ internal override Color ChangeBackColor (Color backColor)
+ {
+ if (backColor == Color.Empty) {
+#if NET_2_0
+ backcolor_set = false;
+ if (!ReadOnly) {
+ backColor = SystemColors.Window;
+ }
+#else
+ backColor = SystemColors.Window;
+#endif
+ }
+ return backColor;
+ }
+
private void RichTextBox_LostFocus(object sender, EventArgs e) {
Invalidate();
}
@@ -306,6 +323,10 @@
}
set {
+ if (!Enum.IsDefined (typeof
(RichTextBoxScrollBars), value))
+ throw new InvalidEnumArgumentException
("value", (int) value,
+ typeof (RichTextBoxScrollBars));
+
scrollbars = value;
}
}
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
2007-03-30 22:26:05 UTC (rev 75238)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
2007-03-31 12:32:38 UTC (rev 75239)
@@ -94,13 +94,27 @@
}
#endregion // Public Constructors
-
#region Private & Internal Methods
private void TextBox_LostFocus(object sender, EventArgs e) {
if (hide_selection)
document.InvalidateSelectionArea ();
}
+
+ internal override Color ChangeBackColor (Color backColor)
+ {
+ if (backColor == Color.Empty) {
#if NET_2_0
+ if (!ReadOnly)
+ backColor = SystemColors.Window;
+#else
+ backColor = SystemColors.Window;
+#endif
+ backcolor_set = false;
+ }
+ return backColor;
+ }
+
+#if NET_2_0
void OnAutoCompleteCustomSourceChanged(object sender,
CollectionChangeEventArgs e) {
if(auto_complete_source ==
AutoCompleteSource.CustomSource) {
//FIXME: handle add, remove and refresh events
in AutoComplete algorithm.
@@ -247,6 +261,10 @@
}
set {
+ if (!Enum.IsDefined (typeof (ScrollBars),
value))
+ throw new InvalidEnumArgumentException
("value", (int) value,
+ typeof (ScrollBars));
+
if (value != (ScrollBars)scrollbars) {
scrollbars =
(RichTextBoxScrollBars)value;
base.CalculateScrollBars();
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
2007-03-30 22:26:05 UTC (rev 75238)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
2007-03-31 12:32:38 UTC (rev 75239)
@@ -238,7 +238,7 @@
}
set {
backcolor_set = true;
- base.BackColor = value;
+ base.BackColor = ChangeBackColor (value);
}
}
@@ -1965,6 +1965,9 @@
return true;
}
+
+ internal abstract Color ChangeBackColor (Color backColor);
+
#endregion // Private Methods
#if NET_2_0
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-03-30 22:26:05 UTC (rev 75238)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-03-31 12:32:38 UTC (rev 75239)
@@ -1,3 +1,10 @@
+2007-03-31 Gert Driesen <[EMAIL PROTECTED]>
+
+ * RichTextBoxTest.cs: Added BackColor test. Improved ReadOnly tests.
+ Added ScrollBars tests.
+ * TextBoxTest.cs: Improve BackColor test. Added ScrollBars tests.
+ Improved ReadOnly tests.
+
2007-03-30 Gert Driesen <[EMAIL PROTECTED]>
* FormHandleTest.cs: Enabled test for bug #81272.
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
2007-03-30 22:26:05 UTC (rev 75238)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/RichTextBoxTest.cs
2007-03-31 12:32:38 UTC (rev 75239)
@@ -8,6 +8,7 @@
//
using System;
+using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
@@ -71,8 +72,6 @@
// S
- // [MonoTODO ("Assert.AreEqual (ScrollBars.Both,
rTBox.ScrollBars, "#S1");")]
- Assert.AreEqual (RichTextBoxScrollBars.Both,
rTBox.ScrollBars, "#S1");
Assert.AreEqual ("", rTBox.SelectedText, "#S3");
rTBox.Text = "sample TextBox";
Assert.AreEqual (HorizontalAlignment.Left,
rTBox.SelectionAlignment, "#S5");
@@ -111,8 +110,19 @@
Assert.AreEqual (true, rTextBox.CanPaste (myFormat),
"#Mtd1");
}
#endif
-
+
[Test]
+ public void BackColor ()
+ {
+ RichTextBox rtb = new RichTextBox ();
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#1");
+ rtb.BackColor = Color.Red;
+ Assert.AreEqual (Color.Red, rtb.BackColor, "#2");
+ rtb.BackColor = Color.Empty;
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#3");
+ }
+
+ [Test]
public void FindCharTest ()
{
RichTextBox rTextBox = new RichTextBox ();
@@ -195,7 +205,6 @@
}
[Test]
- [Category ("NotWorking")]
public void ReadOnly_BackColor_NotSet ()
{
RichTextBox rtb = new RichTextBox ();
@@ -219,29 +228,45 @@
Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#B2");
#endif
- rtb.ReadOnly = false;
- Assert.IsFalse (rtb.ReadOnly, "#C1");
+ rtb.ResetBackColor ();
+ Assert.IsTrue (rtb.ReadOnly, "#C1");
+#if NET_2_0
+ Assert.AreEqual (SystemColors.Control, rtb.BackColor,
"#C2");
+#else
Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#C2");
+#endif
+ rtb.ReadOnly = false;
+ Assert.IsFalse (rtb.ReadOnly, "#D1");
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#D2");
+
rtb.ReadOnly = true;
- Assert.IsTrue (rtb.ReadOnly, "#D1");
+ Assert.IsTrue (rtb.ReadOnly, "#E1");
#if NET_2_0
- Assert.AreEqual (SystemColors.Control, rtb.BackColor,
"#D2");
+ Assert.AreEqual (SystemColors.Control, rtb.BackColor,
"#E2");
#else
- Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#D2");
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#E2");
#endif
rtb.BackColor = Color.Red;
- Assert.IsTrue (rtb.ReadOnly, "#E1");
- Assert.AreEqual (Color.Red, rtb.BackColor, "#E2");
+ Assert.IsTrue (rtb.ReadOnly, "#F1");
+ Assert.AreEqual (Color.Red, rtb.BackColor, "#F2");
rtb.ReadOnly = false;
- Assert.IsFalse (rtb.ReadOnly, "#F1");
- Assert.AreEqual (Color.Red, rtb.BackColor, "#F2");
+ Assert.IsFalse (rtb.ReadOnly, "#G1");
+ Assert.AreEqual (Color.Red, rtb.BackColor, "#G2");
rtb.ReadOnly = true;
- Assert.IsTrue (rtb.ReadOnly, "#G1");
- Assert.AreEqual (Color.Red, rtb.BackColor, "#G2");
+ Assert.IsTrue (rtb.ReadOnly, "#H1");
+ Assert.AreEqual (Color.Red, rtb.BackColor, "#H2");
+
+ rtb.ResetBackColor ();
+ Assert.IsTrue (rtb.ReadOnly, "#I1");
+#if NET_2_0
+ Assert.AreEqual (SystemColors.Control, rtb.BackColor,
"#I2");
+#else
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#I2");
+#endif
}
[Test]
@@ -277,28 +302,58 @@
Assert.IsFalse (rtb.ReadOnly, "#F1");
Assert.AreEqual (Color.Red, rtb.BackColor, "#F2");
+ rtb.ReadOnly = true;
+ rtb.ResetBackColor ();
+ Assert.IsTrue (rtb.ReadOnly, "#G1");
+#if NET_2_0
+ Assert.AreEqual (SystemColors.Control, rtb.BackColor,
"#G2");
+#else
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#G2");
+#endif
+
form.Dispose ();
rtb = new RichTextBox ();
rtb.ReadOnly = true;
rtb.BackColor = Color.Blue;
- Assert.IsTrue (rtb.ReadOnly, "#G1");
- Assert.AreEqual (Color.Blue, rtb.BackColor, "#G2");
+ Assert.IsTrue (rtb.ReadOnly, "#H1");
+ Assert.AreEqual (Color.Blue, rtb.BackColor, "#H2");
form = new Form ();
form.ShowInTaskbar = false;
form.Controls.Add (rtb);
form.Show ();
- Assert.IsTrue (rtb.ReadOnly, "#H1");
- Assert.AreEqual (Color.Blue, rtb.BackColor, "#H2");
+ Assert.IsTrue (rtb.ReadOnly, "#I1");
+ Assert.AreEqual (Color.Blue, rtb.BackColor, "#I2");
rtb.ReadOnly = false;
- Assert.IsFalse (rtb.ReadOnly, "#I1");
- Assert.AreEqual (Color.Blue, rtb.BackColor, "#I2");
+ Assert.IsFalse (rtb.ReadOnly, "#J1");
+ Assert.AreEqual (Color.Blue, rtb.BackColor, "#J2");
+
+ rtb.ResetBackColor ();
+ Assert.IsFalse (rtb.ReadOnly, "#K1");
+ Assert.AreEqual (SystemColors.Window, rtb.BackColor,
"#K2");
}
[Test]
+ public void ScrollBarsTest ()
+ {
+ RichTextBox rtb = new RichTextBox ();
+ Assert.AreEqual (RichTextBoxScrollBars.Both,
rtb.ScrollBars, "#1");
+ rtb.ScrollBars = RichTextBoxScrollBars.Vertical;
+ Assert.AreEqual (RichTextBoxScrollBars.Vertical,
rtb.ScrollBars, "#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void ScrollBars_Invalid ()
+ {
+ RichTextBox rtb = new RichTextBox ();
+ rtb.ScrollBars = (RichTextBoxScrollBars) 666;
+ }
+
+ [Test]
public void SelectionFontTest ()
{
RichTextBox t = new RichTextBox();
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
2007-03-30 22:26:05 UTC (rev 75238)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs
2007-03-31 12:32:38 UTC (rev 75239)
@@ -6,11 +6,13 @@
//
using System;
+using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using NUnit.Framework;
+using CategoryAttribute = NUnit.Framework.CategoryAttribute;
namespace MonoTests.System.Windows.Forms
{
@@ -57,7 +59,7 @@
Assert.AreEqual (false, textBox.CanUndo, "#6c");
Assert.AreEqual (true, textBox.HideSelection, "#8");
- Assert.AreEqual (1, textBox.Lines.Length, "#9");
+ Assert.AreEqual (0, textBox.Lines.Length, "#9");
Assert.AreEqual (32767, textBox.MaxLength, "#10");
Assert.AreEqual (true, textBox.Modified, "#11");
Assert.AreEqual (true, textBox.Multiline, "#12a");
@@ -234,6 +236,10 @@
Assert.AreEqual (Color.Blue, textBox.BackColor, "#B10");
Assert.AreEqual (2, _invalidated, "#B11");
Assert.AreEqual (0, _paint, "#B12");
+ textBox.BackColor = Color.Empty;
+ Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#B13");
+ Assert.AreEqual (3, _invalidated, "#B14");
+ Assert.AreEqual (0, _paint, "#B15");
}
[Test]
@@ -443,29 +449,45 @@
Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#B2");
#endif
- textBox.ReadOnly = false;
- Assert.IsFalse (textBox.ReadOnly, "#C1");
+ textBox.ResetBackColor ();
+ Assert.IsTrue (textBox.ReadOnly, "#C1");
+#if NET_2_0
+ Assert.AreEqual (SystemColors.Control,
textBox.BackColor, "#C2");
+#else
Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#C2");
+#endif
+ textBox.ReadOnly = false;
+ Assert.IsFalse (textBox.ReadOnly, "#D1");
+ Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#D2");
+
textBox.ReadOnly = true;
- Assert.IsTrue (textBox.ReadOnly, "#D1");
+ Assert.IsTrue (textBox.ReadOnly, "#E1");
#if NET_2_0
- Assert.AreEqual (SystemColors.Control,
textBox.BackColor, "#D2");
+ Assert.AreEqual (SystemColors.Control,
textBox.BackColor, "#E2");
#else
- Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#D2");
+ Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#E2");
#endif
textBox.BackColor = Color.Red;
- Assert.IsTrue (textBox.ReadOnly, "#E1");
- Assert.AreEqual (Color.Red, textBox.BackColor, "#E2");
+ Assert.IsTrue (textBox.ReadOnly, "#F1");
+ Assert.AreEqual (Color.Red, textBox.BackColor, "#F2");
textBox.ReadOnly = false;
- Assert.IsFalse (textBox.ReadOnly, "#F1");
- Assert.AreEqual (Color.Red, textBox.BackColor, "#F2");
+ Assert.IsFalse (textBox.ReadOnly, "#G1");
+ Assert.AreEqual (Color.Red, textBox.BackColor, "#G2");
textBox.ReadOnly = true;
- Assert.IsTrue (textBox.ReadOnly, "#G1");
- Assert.AreEqual (Color.Red, textBox.BackColor, "#G2");
+ Assert.IsTrue (textBox.ReadOnly, "#H1");
+ Assert.AreEqual (Color.Red, textBox.BackColor, "#H2");
+
+ textBox.ResetBackColor ();
+ Assert.IsTrue (textBox.ReadOnly, "#I1");
+#if NET_2_0
+ Assert.AreEqual (SystemColors.Control,
textBox.BackColor, "#I2");
+#else
+ Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#I2");
+#endif
}
[Test]
@@ -500,28 +522,56 @@
Assert.IsFalse (textBox.ReadOnly, "#F1");
Assert.AreEqual (Color.Red, textBox.BackColor, "#F2");
+ textBox.ReadOnly = true;
+ textBox.ResetBackColor ();
+ Assert.IsTrue (textBox.ReadOnly, "#G1");
+#if NET_2_0
+ Assert.AreEqual (SystemColors.Control,
textBox.BackColor, "#G2");
+#else
+ Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#G2");
+#endif
+
form.Dispose ();
textBox = new TextBox ();
textBox.ReadOnly = true;
textBox.BackColor = Color.Blue;
- Assert.IsTrue (textBox.ReadOnly, "#G1");
- Assert.AreEqual (Color.Blue, textBox.BackColor, "#G2");
+ Assert.IsTrue (textBox.ReadOnly, "#H1");
+ Assert.AreEqual (Color.Blue, textBox.BackColor, "#H2");
form = new Form ();
form.ShowInTaskbar = false;
form.Controls.Add (textBox);
form.Show ();
- Assert.IsTrue (textBox.ReadOnly, "#H1");
- Assert.AreEqual (Color.Blue, textBox.BackColor, "#H2");
+ Assert.IsTrue (textBox.ReadOnly, "#I1");
+ Assert.AreEqual (Color.Blue, textBox.BackColor, "#I2");
textBox.ReadOnly = false;
- Assert.IsFalse (textBox.ReadOnly, "#I1");
- Assert.AreEqual (Color.Blue, textBox.BackColor, "#I2");
+ Assert.IsFalse (textBox.ReadOnly, "#J1");
+ Assert.AreEqual (Color.Blue, textBox.BackColor, "#J2");
+
+ textBox.ResetBackColor ();
+ Assert.IsFalse (textBox.ReadOnly, "#K1");
+ Assert.AreEqual (SystemColors.Window,
textBox.BackColor, "#K2");
}
[Test]
+ public void ScrollBarsTest ()
+ {
+ Assert.AreEqual (ScrollBars.None, textBox.ScrollBars,
"#1");
+ textBox.ScrollBars = ScrollBars.Vertical;
+ Assert.AreEqual (ScrollBars.Vertical,
textBox.ScrollBars, "#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void ScrollBars_Invalid ()
+ {
+ textBox.ScrollBars = (ScrollBars) 666;
+ }
+
+ [Test]
public void ToStringTest ()
{
Assert.AreEqual ("System.Windows.Forms.TextBox, Text:
", textBox.ToString(), "#35");
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches