2007-11-19 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Tue, 20 Nov 2007 03:37:19 +0000 (03:37 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Tue, 20 Nov 2007 03:37:19 +0000 (03:37 -0000)
* ToolStrip.cs: Handle flow layout in GetPreferredSize to fix PDN3.
[Fixes bug #342123]

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs

index 6d61c66353dbca5a6f1bf9eaff02006e2a7121ab..27e6c7a5de377825325907227156165b36b908be 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-19  Jonathan Pobst  <monkey@jpobst.com>
+
+       * ToolStrip.cs: Handle flow layout in GetPreferredSize to fix PDN3.
+       [Fixes bug #342123]
+
 2007-11-19  Everaldo Canuto  <ecanuto@novell.com>
 
        * Form.cs: Check for empty Text before assign to cp.Caption in CreateParams
index 5a8cb504a4b5427b45fdefa144a99ff706749fa5..431e7729cac77ffd94e37362cd20f9da165625e1 100644 (file)
@@ -1401,6 +1401,34 @@ namespace System.Windows.Forms
                {
                        Size new_size = Size.Empty;
 
+                       // TODO: This is total duct tape.  We really have to call into the correct
+                       // layout engine, do a dry run of the layout, and find out our true
+                       // preferred dimensions.
+                       if (this.LayoutStyle == ToolStripLayoutStyle.Flow) {
+                               Point currentLocation = Point.Empty;
+                               int tallest = 0;
+                               
+                               foreach (ToolStripItem tsi in items) {
+                                       if ((DisplayRectangle.Width - currentLocation.X) < (tsi.Width + tsi.Margin.Horizontal)) {
+
+                                               currentLocation.Y += tallest;
+                                               tallest = 0;
+                                               
+                                               currentLocation.X = DisplayRectangle.Left;
+                                       }
+
+                                       // Offset the left margin and set the control to our point
+                                       currentLocation.Offset (tsi.Margin.Left, 0);
+                                       tallest = Math.Max (tallest, tsi.Height + tsi.Margin.Vertical);
+                                       
+                                       // Update our location pointer
+                                       currentLocation.X += tsi.Width + tsi.Margin.Right;
+                               }
+
+                               currentLocation.Y += tallest;
+                               return new Size (currentLocation.X, currentLocation.Y);
+                       }
+                               
                        if (this.orientation == Orientation.Vertical) {
                                foreach (ToolStripItem tsi in this.items)
                                        if (tsi.Available)  {