2007-01-07 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / StatusBarPanel.cs
index 8aa7f7ccd52e96fe6927479be872c86fcbcfe216..a8610cc856718cee63b7ea549e7c553bec9a89aa 100644 (file)
@@ -45,9 +45,8 @@ namespace System.Windows.Forms {
                private HorizontalAlignment alignment = HorizontalAlignment.Left;
                private StatusBarPanelAutoSize auto_size = StatusBarPanelAutoSize.None;
                private StatusBarPanelBorderStyle border_style = StatusBarPanelBorderStyle.Sunken;
-               private StatusBarPanelStyle style;
+               private StatusBarPanelStyle style = StatusBarPanelStyle.Text;
                private int width = 100;
-               private int twidth = -1;
                private int min_width = 10;
                internal int X;
                #endregion      // Local Variables
@@ -102,14 +101,19 @@ namespace System.Windows.Forms {
                [RefreshProperties(RefreshProperties.All)]
                public int MinWidth {
                        get {
-                               if (AutoSize == StatusBarPanelAutoSize.None)
-                                       return Width;
+                       /*
+                               MSDN says that when AutoSize = None then MinWidth is automatically
+                               set to Width, but neither v1.1 nor v2.0 behave that way.
+                       */
                                return min_width;
                        }
                        set {
                                if (value < 0)
                                        throw new ArgumentException ("value");
                                min_width = value;
+                               if (min_width > width)
+                                       width = min_width;
+                               
                                Invalidate ();
                        }
                }
@@ -123,10 +127,10 @@ namespace System.Windows.Forms {
                                        throw new ArgumentException ("value");
 
                                if (initializing)
-                                       twidth = value;
-                               else
                                        width = value;
-                       
+                               else
+                                       SetWidth(value);
+                               
                                Invalidate ();
                        }
                }
@@ -184,6 +188,8 @@ namespace System.Windows.Forms {
                internal void SetWidth (int width)
                {
                        this.width = width;
+                       if (min_width > this.width)
+                               this.width = min_width;
                }
 
                public override string ToString ()
@@ -202,11 +208,12 @@ namespace System.Windows.Forms {
 
                public void EndInit ()
                {
-                       if (!initializing || twidth == -1)
+                       if (!initializing)
                                return;
-
-                       width = twidth;
-                       twidth = -1;
+                       
+                       if (min_width > width)
+                               width = min_width;
+                       
                        initializing = false;
                }
        }