2008-06-02 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Mon, 2 Jun 2008 22:22:40 +0000 (22:22 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Mon, 2 Jun 2008 22:22:40 +0000 (22:22 -0000)
* TableLayoutPanel.cs: Use border sizes when calculating the
panel's preferred size.  [Fixes part of bug #396433]

2008-06-02  Jonathan Pobst  <monkey@jpobst.com>

* TableLayout.cs: Fix a c&p error so we correctly calculate row
border heights.  [Fixes part of bug #396433]

2008-06-02  Jonathan Pobst  <monkey@jpobst.com>

* TableLayoutTest.cs Add test for bug #396433.

svn path=/trunk/mcs/; revision=104726

mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/TableLayout.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TableLayoutPanel.cs
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TableLayoutTest.cs

index 0d65974fd830efba168c05d05326f5869d9e16c3..6b3a3af7a2488608cb0acb33649bf97593cf7553 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-02  Jonathan Pobst  <monkey@jpobst.com>
+
+       * TableLayout.cs: Fix a c&p error so we correctly calculate row
+       border heights.  [Fixes part of bug #396433]
+
 2008-03-05  Jonathan Pobst  <monkey@jpobst.com>
 
        ArrangedElementCollection.cs: corcompare - fix parameter names.
index 7c8576b1b6bb34a3d6ec74b028482aec9120373d..d1f4254982cf517e80728558a3efccc7f675b625 100644 (file)
@@ -319,7 +319,7 @@ namespace System.Windows.Forms.Layout
                                panel.column_widths[col_styles.Count - 1] += total_width;
 
                        // Figure up all the row heights
-                       int total_height = parentDisplayRectangle.Height - (border_width * columns);
+                       int total_height = parentDisplayRectangle.Height - (border_width * (rows + 1));
                        index = 0;
 
                        // First assign all the Absolute sized rows..
index 6ba854575d61623f0a474f033c944f44b7492b9c..6173a5fc26da952d3925691637f79689f77529b3 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-02  Jonathan Pobst  <monkey@jpobst.com>
+
+       * TableLayoutPanel.cs: Use border sizes when calculating the
+       panel's preferred size.  [Fixes part of bug #396433]
+
 2008-06-02  Ivan N. Zlatev  <contact@i-nz.net>
 
        * SplitContainer.cs:
index 944e63260082e2f912791a7e82ba6ea4094e6988..f0e962c2f7b97841a74c9bab9683c9040edd1b47 100644 (file)
@@ -592,7 +592,8 @@ namespace System.Windows.Forms
                                        non_percent_total_height += row_heights[j];
                        }
 
-                       return new Size (non_percent_total_width + percent_total_width, non_percent_total_height + percent_total_height);
+                       int border_width = GetCellBorderWidth (CellBorderStyle);
+                       return new Size (non_percent_total_width + percent_total_width + (border_width * (actual_cols + 1)), non_percent_total_height + percent_total_height + (border_width * (actual_rows + 1)));
                }
                #endregion
                
index fb690522726effb26269e677d9bbb9d4d868b05b..6a04c2902dc184bc1e7906a66d61f5b80896c055 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-02  Jonathan Pobst  <monkey@jpobst.com>
+
+       * TableLayoutTest.cs Add test for bug #396433.
+
 2008-06-02  Andreia Gaita <avidigal@novell.com> 
 
        * TextBoxTest.cs: Fix endif
index 6bcd332e5752562cecbfe0f497c6b8c1f1a51954..8d724409c417b2d7785e13965297e1cc83a5aa41 100644 (file)
@@ -1427,6 +1427,41 @@ namespace MonoTests.System.Windows.Forms
 \r
                        f.Dispose ();\r
                }\r
+               \r
+               [Test]\r
+               public void Bug396433 ()\r
+               {\r
+                       // We were not taking the CellBorderStyle into account when calculating\r
+                       // the preferred size.\r
+\r
+                       Form f = new Form ();\r
+                       f.ClientSize = new Size (300, 300);\r
+                       f.ShowInTaskbar = false;\r
+\r
+                       TableLayoutPanel tlp = new TableLayoutPanel ();\r
+                       tlp.AutoSize = true;\r
+                       tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;\r
+                       tlp.ColumnCount = 2;\r
+                       tlp.RowCount = 1;\r
+\r
+                       f.Controls.Add (tlp);\r
+\r
+                       Button t1 = new Button ();\r
+                       tlp.Controls.Add (t1);\r
+\r
+                       Button t2 = new Button ();\r
+                       tlp.Controls.Add (t2);\r
+\r
+                       f.Show ();\r
+\r
+                       Assert.AreEqual (new Size (162, 29), tlp.PreferredSize, "A1");\r
+                       \r
+                       tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;\r
+\r
+                       Assert.AreEqual (new Size (165, 31), tlp.PreferredSize, "A2");\r
+\r
+                       f.Dispose ();\r
+               }\r
        }\r
 }\r
 #endif\r