2007-01-07 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / StatusBarPanel.cs
index d949f3d119e3ce998566669aea314afff14cba7a..a8610cc856718cee63b7ea549e7c553bec9a89aa 100644 (file)
@@ -45,10 +45,10 @@ 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
 
                #region Constructors
@@ -63,7 +63,7 @@ namespace System.Windows.Forms {
                        get { return alignment; }
                        set { 
                                alignment = value; 
-                               Invalidate ();
+                               InvalidateContents ();
                        }
                }
 
@@ -92,7 +92,7 @@ namespace System.Windows.Forms {
                        get { return icon; }
                        set { 
                                icon = value; 
-                               Invalidate ();
+                               InvalidateContents ();
                        }
                }
 
@@ -101,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 ();
                        }
                }
@@ -122,10 +127,10 @@ namespace System.Windows.Forms {
                                        throw new ArgumentException ("value");
 
                                if (initializing)
-                                       twidth = value;
-                               else
                                        width = value;
-                       
+                               else
+                                       SetWidth(value);
+                               
                                Invalidate ();
                        }
                }
@@ -145,7 +150,7 @@ namespace System.Windows.Forms {
                        get { return text; }
                        set { 
                                text = value; 
-                               Invalidate ();
+                               InvalidateContents ();
                        }
                }
 
@@ -161,12 +166,18 @@ namespace System.Windows.Forms {
                        get { return parent; }
                }
 
-               void Invalidate ()
+               private void Invalidate ()
                {
                        if (parent == null)
                                return;
+                       parent.UpdatePanel (this);
+               }
 
-                       parent.Refresh ();
+               private void InvalidateContents ()
+               {
+                       if (parent == null)
+                               return;
+                       parent.UpdatePanelContents (this);
                }
 
                internal void SetParent (StatusBar parent)
@@ -174,6 +185,13 @@ namespace System.Windows.Forms {
                        this.parent = parent;
                }
 
+               internal void SetWidth (int width)
+               {
+                       this.width = width;
+                       if (min_width > this.width)
+                               this.width = min_width;
+               }
+
                public override string ToString ()
                {
                        return "StatusBarPanel: {" + Text +"}";
@@ -183,18 +201,19 @@ namespace System.Windows.Forms {
                {
                }
 
-               public virtual void BeginInit ()
+               public void BeginInit ()
                {
                        initializing = true;
                }
 
-               public virtual void EndInit ()
+               public void EndInit ()
                {
-                       if (!initializing || twidth == -1)
+                       if (!initializing)
                                return;
-
-                       width = twidth;
-                       twidth = -1;
+                       
+                       if (min_width > width)
+                               width = min_width;
+                       
                        initializing = false;
                }
        }