Author: jpobst
Date: 2007-04-20 15:29:16 -0400 (Fri, 20 Apr 2007)
New Revision: 76021

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Log:
2007-04-20  Jonathan Pobst  <[EMAIL PROTECTED]>

        * Control.cs: Use DefaultSize for Size, calculate ClientSize from
        that.  We were incorrectly doing it the other way around.  Also,
        update ClientSize if we change the BorderStyle before the control
        is created.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-04-20 18:43:10 UTC (rev 76020)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-04-20 19:29:16 UTC (rev 76021)
@@ -1,3 +1,10 @@
+2007-04-20  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * Control.cs: Use DefaultSize for Size, calculate ClientSize from
+       that.  We were incorrectly doing it the other way around.  Also,
+       update ClientSize if we change the BorderStyle before the control
+       is created.
+
 2007-04-20  Gert Driesen  <[EMAIL PROTECTED]>
 
        * XplatUI.cs: Added Border3DSize, BorderSize, CaptionButtonSize,

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-04-20 18:43:10 UTC (rev 76020)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-04-20 19:29:16 UTC (rev 76021)
@@ -1015,9 +1015,10 @@
                        window_target = new ControlWindowTarget(this);
                        window = new ControlNativeWindow(this);
                        child_controls = CreateControlsInstance();
-                       client_size = DefaultSize;
+                       
+                       bounds.Size = DefaultSize;
+                       client_size = ClientSizeFromSize (bounds.Size);
                        client_rect = new Rectangle (Point.Empty, client_size);
-                       bounds.Size = InternalSizeFromClientSize (client_size);
                        explicit_bounds = bounds;
                }
 
@@ -1140,7 +1141,8 @@
                                                XplatUI.SetBorderStyle 
(window.Handle, (FormBorderStyle)border_style);
                                                RecreateHandle ();
                                                Refresh ();
-                                       }
+                                       } else
+                                               client_size = 
ClientSizeFromSize (bounds.Size);
                                }
                        }
                }
@@ -1775,6 +1777,18 @@
                        return Size.Empty;
                }
                
+               internal Size ClientSizeFromSize (Size size)
+               {
+                       // Calling this gives us the difference in Size and 
ClientSize.
+                       // We just have to apply that difference to our given 
size.
+                       Size client_size = this.InternalSizeFromClientSize 
(size);
+                       
+                       if (client_size == Size.Empty)
+                               return Size.Empty;
+                               
+                       return new Size (size.Width - (client_size.Width - 
size.Width), size.Height - (client_size.Height - size.Height));
+               }
+               
                internal CreateParams GetCreateParams ()
                {
                        return CreateParams;

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

Reply via email to