Author: ggiolfan
Date: 2007-08-23 17:14:43 -0400 (Thu, 23 Aug 2007)
New Revision: 84756

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlowLayoutPanel.cs
Log:
2007-08-23  George Giolfan  <[EMAIL PROTECTED]>

        * FlowLayoutPanel.cs: Add GetPreferredSizeCore.  [Fixes bug #82537]

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-08-23 21:13:09 UTC (rev 84755)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-08-23 21:14:43 UTC (rev 84756)
@@ -1,3 +1,7 @@
+2007-08-23  George Giolfan  <[EMAIL PROTECTED]>
+
+       * FlowLayoutPanel.cs: Add GetPreferredSizeCore.  [Fixes bug #82537]
+
 2007-08-23  Jonathan Pobst  <[EMAIL PROTECTED]>
 
        * TreeView.cs: IsInputKey: don't ask for any keys if the handle hasn't

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlowLayoutPanel.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlowLayoutPanel.cs   
    2007-08-23 21:13:09 UTC (rev 84755)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlowLayoutPanel.cs   
    2007-08-23 21:14:43 UTC (rev 84756)
@@ -30,6 +30,7 @@
 using System.Windows.Forms.Layout;
 using System.ComponentModel;
 using System.Runtime.InteropServices;
+using System.Drawing;
 
 namespace System.Windows.Forms
 {
@@ -102,6 +103,65 @@
                        return false;
                }
                #endregion
+
+               #region Internal Methods
+               internal override Size GetPreferredSizeCore (Size proposedSize)
+               {
+                       int width = 0;
+                       int height = 0;
+                       bool horizontal = FlowDirection == 
FlowDirection.LeftToRight || FlowDirection == FlowDirection.RightToLeft;
+                       if (!WrapContents || (horizontal && proposedSize.Width 
== 0) || (!horizontal && proposedSize.Height == 0)) {
+                               foreach (Control control in Controls) {
+                                       Size control_preferred_size = 
control.PreferredSize;
+                                       Padding control_margin = control.Margin;
+                                       if (horizontal) {
+                                               width += 
control_preferred_size.Width + control_margin.Horizontal;
+                                               height = Math.Max (height, 
control_preferred_size.Height + control_margin.Vertical);
+                                       } else {
+                                               height += 
control_preferred_size.Height + control_margin.Vertical;
+                                               width = Math.Max (width, 
control_preferred_size.Width + control_margin.Horizontal);
+                                       }
+                               }
+                       } else {
+                               int size_in_flow_direction = 0;
+                               int size_in_other_direction = 0;
+                               int increase;
+                               foreach (Control control in Controls) {
+                                       Size control_preferred_size = 
control.PreferredSize;
+                                       Padding control_margin = control.Margin;
+                                       if (horizontal) {
+                                               increase = 
control_preferred_size.Width + control_margin.Horizontal;
+                                               if (size_in_flow_direction != 0 
&& size_in_flow_direction + increase >= proposedSize.Width) {
+                                                       width = Math.Max 
(width, size_in_flow_direction);
+                                                       size_in_flow_direction 
= 0;
+                                                       height += 
size_in_other_direction;
+                                                       size_in_other_direction 
= 0;
+                                               }
+                                               size_in_flow_direction += 
increase;
+                                               size_in_other_direction = 
Math.Max (size_in_other_direction, control_preferred_size.Height + 
control_margin.Vertical);
+                                       } else {
+                                               increase = 
control_preferred_size.Height + control_margin.Vertical;
+                                               if (size_in_flow_direction != 0 
&& size_in_flow_direction + increase >= proposedSize.Height) {
+                                                       height = Math.Max 
(height, size_in_flow_direction);
+                                                       size_in_flow_direction 
= 0;
+                                                       width += 
size_in_other_direction;
+                                                       size_in_other_direction 
= 0;
+                                               }
+                                               size_in_flow_direction += 
increase;
+                                               size_in_other_direction = 
Math.Max (size_in_other_direction, control_preferred_size.Width + 
control_margin.Horizontal);
+                                       }
+                               }
+                               if (horizontal) {
+                                       width = Math.Max (width, 
size_in_flow_direction);
+                                       height += size_in_other_direction;
+                               } else {
+                                       height = Math.Max (height, 
size_in_flow_direction);
+                                       width += size_in_other_direction;
+                               }
+                       }
+                       return new Size (width, height);
+               }
+               #endregion
        }
 }
 #endif

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to