+2007-09-06 Jonathan Pobst <monkey@jpobst.com>
+
+ * DefaultLayout.cs: Only LayoutAutoSizeContainer if the container is
+ a Form, others should be taken care of by their parent.
+ * TableLayout.cs: If a control is AutoSize, default to its preferred
+ size if possible. [Fixes bug #82605]
+
2007-07-31 Jonathan Pobst <monkey@jpobst.com>
* ArrangedElementCollection.cs: Rename internal method RemoveAt
LayoutAnchoredChildren (parent, controls);
#if NET_2_0
LayoutAutoSizedChildren (parent, controls);
- LayoutAutoSizeContainer (parent);
+ if (parent is Form) LayoutAutoSizeContainer (parent);
#endif
return false;
{
Control c = panel.actual_positions[x,y];
- if(c != null && c != dummy_control)
-
- {
+ if(c != null && c != dummy_control) {
+ Size preferred;
+
+ if (c.AutoSize)
+ preferred = c.PreferredSize;
+ else
+ preferred = c.Size;
+
int new_x = 0;
int new_y = 0;
int new_width = 0;
if (c.Dock == DockStyle.Fill || c.Dock == DockStyle.Top || c.Dock == DockStyle.Bottom || ((c.Anchor & AnchorStyles.Left) == AnchorStyles.Left && (c.Anchor & AnchorStyles.Right) == AnchorStyles.Right))
new_width = column_width - c.Margin.Left - c.Margin.Right;
else
- new_width = Math.Min (c.Width, column_width - c.Margin.Left - c.Margin.Right);
+ new_width = Math.Min (preferred.Width, column_width - c.Margin.Left - c.Margin.Right);
// Figure out the height of the control
int column_height = panel.row_heights[y];
if (c.Dock == DockStyle.Fill || c.Dock == DockStyle.Left || c.Dock == DockStyle.Right || ((c.Anchor & AnchorStyles.Top) == AnchorStyles.Top && (c.Anchor & AnchorStyles.Bottom) == AnchorStyles.Bottom))
new_height = column_height - c.Margin.Top - c.Margin.Bottom;
else
- new_height = Math.Min (c.Height, column_height - c.Margin.Top - c.Margin.Bottom);
+ new_height = Math.Min (preferred.Height, column_height - c.Margin.Top - c.Margin.Bottom);
// Figure out the left location of the control
if (c.Dock == DockStyle.Left || c.Dock == DockStyle.Fill || (c.Anchor & AnchorStyles.Left) == AnchorStyles.Left)
+2007-09-06 Jonathan Pobst <monkey@jpobst.com>
+
+ * TableLayoutTest.cs: Add test for bug #82605.
+
2007-08-31 Jonathan Pobst <monkey@jpobst.com>
* ToolStripItemTest.cs: Added test to show that Enabled can
f.Dispose ();\r
}\r
\r
+ [Test]\r
+ public void Bug82605 ()\r
+ {\r
+ Form f = new Form ();\r
+ f.ShowInTaskbar = false;\r
+ \r
+ Label l = new Label ();\r
+\r
+ TableLayoutPanel table = new TableLayoutPanel ();\r
+ table.ColumnCount = 1;\r
+ table.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 100F));\r
+\r
+ table.RowCount = 2;\r
+ table.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));\r
+ table.RowStyles.Add (new RowStyle (SizeType.Absolute, 20F));\r
+\r
+ table.Controls.Add (l, 0, 1);\r
+ table.Location = new Point (0, 0);\r
+ table.Width = 250;\r
+\r
+ l.Anchor = AnchorStyles.Left | AnchorStyles.Right;\r
+ l.AutoSize = true;\r
+ l.Location = new Point (3, 352);\r
+ l.Size = new Size (578, 13);\r
+ l.Text = "label1";\r
+ l.TextAlign = ContentAlignment.MiddleCenter;\r
+\r
+ f.Controls.Add (table);\r
+ f.Show ();\r
+ \r
+ \r
+ Assert.AreEqual (new Size (244, 17), l.Size, "A1");\r
+ }\r
+ \r
[Test] // bug #82040\r
public void ShowNoChildren ()\r
{\r