Author: jpobst
Date: 2007-04-24 13:23:35 -0400 (Tue, 24 Apr 2007)
New Revision: 76204
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripDropDownTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripTest.cs
Log:
2007-04-24 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStrip.cs: Fully implement GetNextItem. Call
OnParentRightToLeftChanged
for each ToolStripItem when the parent's RightToLeftChanged is called.
2007-04-24 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStripDropDownTest.cs: Add Assert for default orientation.
* ToolStripTest.cs: Enable tests for CanOverflow and
DefaultDropDownDirection.
Add test for GetNextItem.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-24 16:47:28 UTC (rev 76203)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-24 17:23:35 UTC (rev 76204)
@@ -1,3 +1,8 @@
+2007-04-24 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * ToolStrip.cs: Fully implement GetNextItem. Call
OnParentRightToLeftChanged
+ for each ToolStripItem when the parent's RightToLeftChanged is called.
+
2007-04-24 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* ComboBox.cs: Forward ContextMenu to the underlying textbox, if any.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
2007-04-24 16:47:28 UTC (rev 76203)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
2007-04-24 17:23:35 UTC (rev 76204)
@@ -515,24 +515,88 @@
if (!Enum.IsDefined (typeof (ArrowDirection),
direction))
throw new InvalidEnumArgumentException
(string.Format ("Enum argument value '{0}' is not valid for ArrowDirection",
direction));
- int index = this.items.IndexOf (start);
+ if (this.Items.Count == 1)
+ return null;
+
+ ToolStripItem current_best = null;
+ int current_best_point;
+
+ switch (direction) {
+ case ArrowDirection.Right:
+ current_best_point = int.MaxValue;
- switch (direction) {
+ if (start != null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Left >=
start.Right && loop_tsi.Left < current_best_point && loop_tsi.Visible &&
loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Left;
+ }
+
+ if (current_best == null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Left <
current_best_point && loop_tsi.Visible && loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Left;
+ }
+
+ break;
+ case ArrowDirection.Up:
+ current_best_point = int.MinValue;
+
+ if (start != null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Bottom <=
start.Top && loop_tsi.Top > current_best_point && loop_tsi.Visible &&
loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Top;
+ }
+
+ if (current_best == null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Top >
current_best_point && loop_tsi.Visible && loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Top;
+ }
+
+ break;
case ArrowDirection.Left:
- case ArrowDirection.Up:
- if (index > 0)
- return this.items[index - 1];
-
- return this.items[this.items.Count - 1];
- case ArrowDirection.Right:
+ current_best_point = int.MinValue;
+
+ if (start != null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Right <=
start.Left && loop_tsi.Left > current_best_point && loop_tsi.Visible &&
loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Left;
+ }
+
+ if (current_best == null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Left >
current_best_point && loop_tsi.Visible && loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Left;
+ }
+
+ break;
case ArrowDirection.Down:
- if (index + 1 >= this.items.Count)
- return this.items[0];
+ current_best_point = int.MaxValue;
- return this.items[index + 1];
+ if (start != null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Top >=
start.Bottom && loop_tsi.Bottom < current_best_point && loop_tsi.Visible &&
loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Top;
+ }
+
+ if (current_best == null)
+ foreach (ToolStripItem loop_tsi
in this.DisplayedItems)
+ if (loop_tsi.Top <
current_best_point && loop_tsi.Visible && loop_tsi.CanSelect) {
+ current_best =
loop_tsi;
+
current_best_point = loop_tsi.Top;
+ }
+
+ break;
}
- return null;
+ return current_best;
}
public void ResetMinimumSize ()
@@ -883,6 +947,9 @@
protected override void OnRightToLeftChanged (EventArgs e)
{
base.OnRightToLeftChanged (e);
+
+ foreach (ToolStripItem tsi in this.Items)
+ tsi.OnParentRightToLeftChanged (e);
}
protected override void OnScroll (ScrollEventArgs se)
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-04-24 16:47:28 UTC (rev 76203)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-04-24 17:23:35 UTC (rev 76204)
@@ -1,3 +1,9 @@
+2007-04-24 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * ToolStripDropDownTest.cs: Add Assert for default orientation.
+ * ToolStripTest.cs: Enable tests for CanOverflow and
DefaultDropDownDirection.
+ Add test for GetNextItem.
+
2007-04-24 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* MdiFormTest.cs: Added tests for #81409.
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripDropDownTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripDropDownTest.cs
2007-04-24 16:47:28 UTC (rev 76203)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripDropDownTest.cs
2007-04-24 17:23:35 UTC (rev 76204)
@@ -50,6 +50,7 @@
Assert.AreEqual (true, tsdd.DropShadowEnabled, "A5");
Assert.AreEqual (false, tsdd.IsAutoGenerated, "A6");
Assert.AreEqual (1, tsdd.Opacity, "A7");
+ Assert.AreEqual (Orientation.Horizontal,
tsdd.Orientation, "A7-2");
Assert.AreEqual (null, tsdd.OwnerItem, "A8");
Assert.AreEqual (null, tsdd.Region, "A9");
Assert.AreEqual (RightToLeft.No, tsdd.RightToLeft,
"A10");
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripTest.cs
2007-04-24 16:47:28 UTC (rev 76203)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ToolStripTest.cs
2007-04-24 17:23:35 UTC (rev 76204)
@@ -255,16 +255,16 @@
Assert.AreEqual (string.Empty, ew.ToString (), "B2");
}
- //[Test]
- //public void PropertyCanOverflow ()
- //{
- // ToolStrip ts = new ToolStrip ();
- // EventWatcher ew = new EventWatcher (ts);
+ [Test]
+ public void PropertyCanOverflow ()
+ {
+ ToolStrip ts = new ToolStrip ();
+ EventWatcher ew = new EventWatcher (ts);
- // ts.CanOverflow = false;
- // Assert.AreEqual (false, ts.CanOverflow, "B1");
- // Assert.AreEqual (string.Empty, ew.ToString (), "B2");
- //}
+ ts.CanOverflow = false;
+ Assert.AreEqual (false, ts.CanOverflow, "B1");
+ Assert.AreEqual (string.Empty, ew.ToString (), "B2");
+ }
[Test]
public void PropertyCausesValidation ()
@@ -296,26 +296,26 @@
Assert.AreEqual (string.Empty, ew.ToString (), "B3");
}
- //[Test]
- //public void PropertyDefaultDropDownDirection ()
- //{
- // ToolStrip ts = new ToolStrip ();
- // EventWatcher ew = new EventWatcher (ts);
+ [Test]
+ public void PropertyDefaultDropDownDirection ()
+ {
+ ToolStrip ts = new ToolStrip ();
+ EventWatcher ew = new EventWatcher (ts);
- // ts.DefaultDropDownDirection =
ToolStripDropDownDirection.AboveLeft;
- // Assert.AreEqual
(ToolStripDropDownDirection.AboveLeft, ts.DefaultDropDownDirection, "B1");
- // Assert.AreEqual (string.Empty, ew.ToString (), "B2");
- //}
+ ts.DefaultDropDownDirection =
ToolStripDropDownDirection.AboveLeft;
+ Assert.AreEqual (ToolStripDropDownDirection.AboveLeft,
ts.DefaultDropDownDirection, "B1");
+ Assert.AreEqual (string.Empty, ew.ToString (), "B2");
+ }
- //[Test]
- //[ExpectedException (typeof (InvalidEnumArgumentException))]
- //public void PropertyDefaultDropDownDirectionIEAE ()
- //{
- // ToolStrip ts = new ToolStrip ();
- // EventWatcher ew = new EventWatcher (ts);
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void PropertyDefaultDropDownDirectionIEAE ()
+ {
+ ToolStrip ts = new ToolStrip ();
+ EventWatcher ew = new EventWatcher (ts);
- // ts.DefaultDropDownDirection =
(ToolStripDropDownDirection) 42;
- //}
+ ts.DefaultDropDownDirection =
(ToolStripDropDownDirection)42;
+ }
[Test]
[ExpectedException (typeof (InvalidEnumArgumentException))]
@@ -635,6 +635,39 @@
}
[Test]
+ public void MethodGetNextItem ()
+ {
+ ToolStrip ts = new ToolStrip ();
+ ts.Items.Add ("Test Item 1");
+
+
+ Assert.AreEqual (null, ts.GetNextItem (null,
ArrowDirection.Right), "A1");
+ Assert.AreEqual (null, ts.GetNextItem (ts.Items[0],
ArrowDirection.Right), "A2");
+
+ ts.Items.Add ("Test Item 2");
+ Assert.AreEqual (ts.Items[0], ts.GetNextItem (null,
ArrowDirection.Right), "A3");
+ Assert.AreEqual (ts.Items[0], ts.GetNextItem
(ts.Items[0], ArrowDirection.Right), "A4");
+
+ Form f = new Form ();
+ f.ShowInTaskbar = false;
+ f.Controls.Add (ts);
+ f.Show ();
+
+ Assert.AreEqual (ts.Items[0], ts.GetNextItem (null,
ArrowDirection.Right), "A5");
+ Assert.AreEqual (ts.Items[1], ts.GetNextItem
(ts.Items[0], ArrowDirection.Right), "A6");
+
+ f.Dispose ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidEnumArgumentException))]
+ public void MethodGetNextItemIEAE ()
+ {
+ ToolStrip ts = new ToolStrip ();
+ ts.GetNextItem (null, (ArrowDirection)42);
+ }
+
+ [Test]
public void TestToolStrip ()
{
ToolStrip ts = new ToolStrip ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches