// Authors:
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
using System;
using System.Drawing;
base.CanOverflow = false;
this.GripStyle = ToolStripGripStyle.Hidden;
base.LayoutStyle = ToolStripLayoutStyle.Table;
+ base.RenderMode = ToolStripRenderMode.System;
this.sizing_grip = true;
base.Stretch = true;
}
#endregion
#region Protected Methods
+ protected override AccessibleObject CreateAccessibilityInstance ()
+ {
+ return new StatusStripAccessibleObject ();
+ }
+
protected internal override ToolStripItem CreateDefaultItem (string text, Image image, EventHandler onClick)
{
if (text == "-")
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];
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++;
removed_one = true;
break;
}
+
+ // There's nothing left to remove, break or we will loop forever
+ if (!removed_one)
+ break;
}
if (spring_count > 0) {
}
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)
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;
// 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;
}
remove { base.PaddingChanged -= value; }
}
#endregion
+
+ #region StatusStripAccessibleObject
+ private class StatusStripAccessibleObject : AccessibleObject
+ {
+ }
+ #endregion
}
}
-#endif