Parcourir la source

2007-05-23 Jonathan Pobst <[email protected]>

	* DefaultLayout.cs: Take parent's padding into account when docking
	children.

2007-05-23  Jonathan Pobst  <[email protected]>

	* DefaultLayoutTest.cs: Add test for docking when parent has Padding.

svn path=/trunk/mcs/; revision=77864
Jonathan Pobst il y a 18 ans
Parent
commit
0657121995

+ 5 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/ChangeLog

@@ -1,3 +1,8 @@
+2007-05-23  Jonathan Pobst  <[email protected]>
+
+	* DefaultLayout.cs: Take parent's padding into account when docking
+	children.
+
 2007-05-07  Jonathan Pobst  <[email protected]>
 	Applying contributed patch from Stefan Noack.
 

+ 7 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/DefaultLayout.cs

@@ -39,6 +39,13 @@ namespace System.Windows.Forms.Layout
 			Rectangle space = parent.DisplayRectangle;
 			MdiClient mdi = null;
 			
+#if NET_2_0
+			space.X += parent.Padding.Left;
+			space.Y += parent.Padding.Top;
+			space.Width -= parent.Padding.Horizontal;
+			space.Height -= parent.Padding.Vertical;
+#endif
+
 			// Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
 			for (int i = controls.Length - 1; i >= 0; i--) {
 				Control child = controls[i];

+ 4 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog

@@ -1,3 +1,7 @@
+2007-05-23  Jonathan Pobst  <[email protected]>
+
+	* DefaultLayoutTest.cs: Add test for docking when parent has Padding.
+
 2007-05-23  Everaldo Canuto  <[email protected]>
 
 	* TestHelper.cs: Remove Event log we already have a EventLogger class.

+ 19 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DefaultLayoutTest.cs

@@ -504,6 +504,25 @@ namespace MonoTests.System.Windows.Forms
 				ResumeLayout (false);
 			}
 		}
+
+#if NET_2_0
+		[Test]
+		public void TestDockFillWithPadding ()
+		{
+			Form f = new Form ();
+			f.ShowInTaskbar = false;
+			f.Padding = new Padding (15, 15, 15, 15);
+
+			Control c = new Control ();
+			c.Dock = DockStyle.Fill;
+			f.Controls.Add (c);
+
+			f.Show ();
+			Assert.AreEqual (new Size (f.ClientSize.Width - 30, f.ClientSize.Height - 30), c.Size, "K1");
+
+			f.Dispose ();
+		}
+#endif
 	}
 
 	[TestFixture]