Author: jpobst
Date: 2007-05-04 15:51:28 -0400 (Fri, 04 May 2007)
New Revision: 76721
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GetChildAtPointSkip.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
Log:
2007-05-04 Jonathan Pobst <[EMAIL PROTECTED]>
* Control.cs: Implement GetChildAtPoint and OnParentCursorChanged.
* GetChildAtPointSkip.cs: Make internal for 1.1 profile.
2007-05-04 Jonathan Pobst <[EMAIL PROTECTED]>
* ControlTest.cs: Expand GetChildAtPointTest to cover 2.0 cases.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-05-04 19:37:52 UTC (rev 76720)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-05-04 19:51:28 UTC (rev 76721)
@@ -1,3 +1,8 @@
+2007-05-04 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * Control.cs: Implement GetChildAtPoint and OnParentCursorChanged.
+ * GetChildAtPointSkip.cs: Make internal for 1.1 profile.
+
2007-05-04 Andreia Gaita <[EMAIL PROTECTED]>
* ContainerControl.cs: Fix active_control attribution when going
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2007-05-04 19:37:52 UTC (rev 76720)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2007-05-04 19:51:28 UTC (rev 76721)
@@ -3460,20 +3460,35 @@
return null;
}
- public Control GetChildAtPoint(Point pt) {
+ public Control GetChildAtPoint(Point pt)
+ {
+ return GetChildAtPoint (pt, GetChildAtPointSkip.None);
+ }
+
+#if NET_2_0
+ public
+#endif
+ Control GetChildAtPoint (Point pt, GetChildAtPointSkip
skipValue)
+ {
// MS's version causes the handle to be created. The
stack trace shows that get_Handle is called here, but
// we'll just call CreateHandle instead.
if (!IsHandleCreated)
CreateHandle ();
-
+
// Microsoft's version of this function doesn't seem to
work, so I can't check
// if we only consider children or also grandchildren,
etc.
// I'm gonna say 'children only'
- for (int i=0; i<child_controls.Count; i++) {
- if (child_controls[i].Bounds.Contains(pt)) {
- return child_controls[i];
- }
+ foreach (Control child in Controls) {
+ if ((skipValue & GetChildAtPointSkip.Disabled)
== GetChildAtPointSkip.Disabled && !child.Enabled)
+ continue;
+ else if ((skipValue &
GetChildAtPointSkip.Invisible) == GetChildAtPointSkip.Invisible &&
!child.Visible)
+ continue;
+ else if ((skipValue &
GetChildAtPointSkip.Transparent) == GetChildAtPointSkip.Transparent &&
child.BackColor.A == 0x0)
+ continue;
+ else if (child.Bounds.Contains (pt))
+ return child;
}
+
return null;
}
@@ -5278,6 +5293,10 @@
EventHandler eh = (EventHandler)(Events
[CursorChangedEvent]);
if (eh != null)
eh (this, e);
+
+#if NET_2_0
+ for (int i = 0; i < child_controls.Count; i++)
child_controls[i].OnParentCursorChanged (e);
+#endif
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
@@ -5644,7 +5663,14 @@
eh (this, e);
}
- [EditorBrowsable(EditorBrowsableState.Advanced)]
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnParentCursorChanged (EventArgs e)
+ {
+ }
+#endif
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnParentEnabledChanged(EventArgs e) {
if (is_enabled) {
OnEnabledChanged(e);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GetChildAtPointSkip.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GetChildAtPointSkip.cs
2007-05-04 19:37:52 UTC (rev 76720)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GetChildAtPointSkip.cs
2007-05-04 19:51:28 UTC (rev 76721)
@@ -27,16 +27,17 @@
//
-#if NET_2_0
namespace System.Windows.Forms
{
[Flags]
- public enum GetChildAtPointSkip
+#if NET_2_0
+ public
+#endif
+ enum GetChildAtPointSkip
{
None = 0,
Invisible = 1,
Disabled = 2,
Transparent = 4
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-05-04 19:37:52 UTC (rev 76720)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-05-04 19:51:28 UTC (rev 76721)
@@ -1,3 +1,7 @@
+2007-05-04 Jonathan Pobst <[EMAIL PROTECTED]>
+
+ * ControlTest.cs: Expand GetChildAtPointTest to cover 2.0 cases.
+
2007-05-04 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
Added.
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
2007-05-04 19:37:52 UTC (rev 76720)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
2007-05-04 19:51:28 UTC (rev 76721)
@@ -1309,7 +1309,8 @@
[Test]
public void GetChildAtPointTest ()
{
- Control c = null, d = null, e = null;
+ Control c = null, d = null;
+ TransparentControl e = null;
try {
c = new Control ();
@@ -1321,7 +1322,7 @@
d.SetBounds (10, 10, 40, 40);
c.Controls.Add (d);
- e = new Control ();
+ e = new TransparentControl ();
e.Name = "e1";
e.SetBounds (55, 55, 10, 10);
@@ -1330,22 +1331,40 @@
Assert.IsFalse (e.Name == l.Name, "Child2");
l = c.GetChildAtPoint (new Point (57, 57));
- Assert.IsNull (l, "Child3");
+ Assert.AreEqual (null, l, "Child3");
l = c.GetChildAtPoint (new Point (10, 10));
Assert.AreEqual (d.Name, l.Name, "Child4");
// GetChildAtPointSkip is not implemented and
the following test is breaking for Net_2_0 profile
-// #if NET_2_0
-// c.Controls.Add (e);
-// e.Visible = false;
-// l = c.GetChildAtPoint (new Point (57,
57), GetChildAtPointSkip.Invisible);
-// Assert.IsNull (l, "Child5");
+#if NET_2_0
+ c.Controls.Add (e);
+ e.Visible = false;
+ l = c.GetChildAtPoint (new Point (57, 57),
GetChildAtPointSkip.Invisible);
+ Assert.IsNull (l, "Child5");
-// e.Visible = true;
-// l = c.GetChildAtPoint (new Point (57,
57), GetChildAtPointSkip.Invisible);
-// Assert.AreSame (e.Name, l.Name,
"Child6");
-// #endif // NET_2_0
+ e.Visible = true;
+ l = c.GetChildAtPoint (new Point (57, 57),
GetChildAtPointSkip.Invisible);
+ Assert.AreSame (e.Name, l.Name, "Child6");
+
+ e.Enabled = false;
+ l = c.GetChildAtPoint (new Point (57, 57),
GetChildAtPointSkip.Disabled);
+ Assert.IsNull (l, "Child7");
+
+ e.Enabled = true;
+ l = c.GetChildAtPoint (new Point (57, 57),
GetChildAtPointSkip.Disabled);
+ Assert.AreSame (e.Name, l.Name, "Child8");
+
+
+ e.BackColor = Color.Transparent;
+ l = c.GetChildAtPoint (new Point (57, 57),
GetChildAtPointSkip.Transparent);
+ Assert.IsNull (l, "Child9");
+
+ e.BackColor = Color.Green;
+ l = c.GetChildAtPoint (new Point (57, 57),
GetChildAtPointSkip.Transparent);
+ Assert.AreSame (e.Name, l.Name, "Child10");
+
+#endif // NET_2_0
} finally {
if (c != null)
c.Dispose ();
@@ -1354,6 +1373,24 @@
}
}
+ private class TransparentControl : Control
+ {
+ public TransparentControl ()
+ {
+ SetStyle
(ControlStyles.SupportsTransparentBackColor, true);
+ }
+
+ protected override CreateParams CreateParams
+ {
+ get
+ {
+ CreateParams cp = base.CreateParams;
+ cp.ExStyle |= 0x00000020;
+ return cp;
+ }
+ }
+ }
+
[Test]
public void ResetFontTest ()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches