Assign values to base class.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / StatusStrip.cs
index 9d13347fa293b4e9b390abf86684859377e67ca8..3d3d8a51d5d887d753a6b41af91291366d27f00f 100644 (file)
@@ -25,7 +25,6 @@
 // Authors:
 //     Jonathan Pobst (monkey@jpobst.com)
 //
-#if NET_2_0
 
 using System;
 using System.Drawing;
@@ -47,6 +46,7 @@ namespace System.Windows.Forms
                        base.CanOverflow = false;
                        this.GripStyle = ToolStripGripStyle.Hidden;
                        base.LayoutStyle = ToolStripLayoutStyle.Table;
+                       base.RenderMode = ToolStripRenderMode.System;
                        this.sizing_grip = true;
                        base.Stretch = true;
                }
@@ -126,6 +126,11 @@ namespace System.Windows.Forms
                #endregion
 
                #region Protected Methods
+               protected override AccessibleObject CreateAccessibilityInstance ()
+               {
+                       return new StatusStripAccessibleObject ();
+               }
+               
                protected internal override ToolStripItem CreateDefaultItem (string text, Image image, EventHandler onClick)
                {
                        if (text == "-")
@@ -139,22 +144,24 @@ namespace System.Windows.Forms
                        base.Dispose (disposing);
                }
 
-               protected override void OnLayout (LayoutEventArgs e)
+               protected override void OnLayout (LayoutEventArgs levent)
                {
                        this.OnSpringTableLayoutCore ();
+                       this.Invalidate ();
                }
 
-               protected override void OnPaintBackground (PaintEventArgs pevent)
+               protected override void OnPaintBackground (PaintEventArgs e)
                {
-                       base.OnPaintBackground (pevent);
+                       base.OnPaintBackground (e);
                        
                        if (this.sizing_grip)
-                               this.Renderer.DrawStatusStripSizingGrip (new ToolStripRenderEventArgs (pevent.Graphics, this));
+                               this.Renderer.DrawStatusStripSizingGrip (new ToolStripRenderEventArgs (e.Graphics, this, Bounds, SystemColors.Control));
                }
 
                protected virtual void OnSpringTableLayoutCore ()
                {
-                       this.SetDisplayedItems ();
+                       if (!this.Created)
+                               return;
 
                        ToolStripItemOverflow[] overflow = new ToolStripItemOverflow[this.Items.Count];
                        ToolStripItemPlacement[] placement = new ToolStripItemPlacement[this.Items.Count];
@@ -169,6 +176,7 @@ namespace System.Windows.Forms
                                overflow[i] = tsi.Overflow;
                                widths[i] = tsi.GetPreferredSize (proposedSize).Width + tsi.Margin.Horizontal;
                                placement[i] = tsi.Overflow == ToolStripItemOverflow.Always ? ToolStripItemPlacement.None : ToolStripItemPlacement.Main;
+                               placement[i] = tsi.Available && tsi.InternalVisible ? placement[i] : ToolStripItemPlacement.None;
                                total_width += placement[i] == ToolStripItemPlacement.Main ? widths[i] : 0;
                                if (tsi is ToolStripStatusLabel && (tsi as ToolStripStatusLabel).Spring)
                                        spring_count++;
@@ -198,6 +206,10 @@ namespace System.Windows.Forms
                                                        removed_one = true;
                                                        break;
                                                }
+
+                               // There's nothing left to remove, break or we will loop forever        
+                               if (!removed_one)
+                                       break;
                        }
 
                        if (spring_count > 0) {
@@ -226,16 +238,21 @@ namespace System.Windows.Forms
                                }
 
                                i++;
-                       }                       
+                       }
+
+                       this.SetDisplayedItems ();
                }
 
                protected override void SetDisplayedItems ()
                {
-                       this.displayed_items.Clear ();
+                       // Only clean the internal collection, without modifying Owner/Parent on items.
+                       this.displayed_items.ClearInternal ();
 
                        foreach (ToolStripItem tsi in this.Items)
-                               if (tsi.Available)
+                               if (tsi.Placement == ToolStripItemPlacement.Main && tsi.Available) {
                                        this.displayed_items.AddNoOwnerOrLayout (tsi);
+                                       tsi.Parent = this;
+                               }
                }
                
                protected override void WndProc (ref Message m)
@@ -247,7 +264,7 @@ namespace System.Windows.Forms
                                                Point p = new Point (LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
                                                
                                                if (this.SizingGrip && this.SizeGripBounds.Contains (p)) {
-                                                       this.Cursor = Cursors.SizeNESW;
+                                                       this.Cursor = Cursors.SizeNWSE;
                                                        return;
                                                } else
                                                        this.Cursor = Cursors.Default;
@@ -259,9 +276,15 @@ namespace System.Windows.Forms
                                // send the WM a message to begin a window resize operation
                                case Msg.WM_LBUTTONDOWN: {
                                        Point p = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
+                                       Form form = FindForm ();
 
                                        if (this.SizingGrip && this.SizeGripBounds.Contains (p)) {
-                                               XplatUI.SendMessage (this.FindForm().Handle, Msg.WM_NCLBUTTONDOWN, (IntPtr) HitTest.HTBOTTOMRIGHT, IntPtr.Zero);
+                                               // For top level forms it's not enoug to send a NCLBUTTONDOWN message, so
+                                               // we make a direct call to our XplatUI engine.
+                                               if (!form.IsMdiChild)
+                                                       XplatUI.BeginMoveResize (form.Handle);
+
+                                               XplatUI.SendMessage (form.Handle, Msg.WM_NCLBUTTONDOWN, (IntPtr) HitTest.HTBOTTOMRIGHT, IntPtr.Zero);
                                                return;
                                        }
                                        
@@ -280,6 +303,11 @@ namespace System.Windows.Forms
                        remove { base.PaddingChanged -= value; }
                }
                #endregion
+
+               #region StatusStripAccessibleObject
+               private class StatusStripAccessibleObject : AccessibleObject
+               {
+               }
+               #endregion
        }
 }
-#endif