Grasshopper project system now uses csproj extension
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripMenuItem.cs
index e3d029cbde0ddb1a3d5163de78cc56d4ff3bbd43..4374b6353285de7a59faa68f7f2f3106bd07ab37 100644 (file)
 using System;
 using System.Drawing;
 using System.ComponentModel;
+using System.Windows.Forms.Design;
 
 namespace System.Windows.Forms
 {
+       [ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.MenuStrip | ToolStripItemDesignerAvailability.ContextMenuStrip)]
        public class ToolStripMenuItem : ToolStripDropDownItem
        {
                private CheckState checked_state;
@@ -40,6 +42,7 @@ namespace System.Windows.Forms
                private string shortcut_display_string;
                private Keys shortcut_keys = Keys.None;
                private bool show_shortcut_keys = true;
+               private Form mdi_client_form;
 
                #region Public Constructors
                public ToolStripMenuItem ()
@@ -89,6 +92,7 @@ namespace System.Windows.Forms
                #region Public Properties
                [Bindable (true)]
                [DefaultValue (false)]
+               [RefreshProperties (RefreshProperties.Repaint)]
                public bool Checked {
                        get {
                                switch (this.checked_state) {
@@ -117,8 +121,8 @@ namespace System.Windows.Forms
 
                [Bindable (true)]
                [DefaultValue (CheckState.Unchecked)]
-               public CheckState CheckState
-               {
+               [RefreshProperties (RefreshProperties.Repaint)]
+               public CheckState CheckState {
                        get { return this.checked_state; }
                        set
                        {
@@ -136,6 +140,11 @@ namespace System.Windows.Forms
                        set { base.Enabled = value; }
                }
 
+               [Browsable (false)]
+               public bool IsMdiWindowListEntry {
+                       get { return this.mdi_client_form != null; }
+               }
+               
                [MonoTODO ("Renderer doesn't support shortcut keys yet, they will never show.")]
                [Localizable (true)]
                public bool ShowShortcutKeys {
@@ -175,7 +184,9 @@ namespace System.Windows.Forms
                #region Protected Methods
                protected override ToolStripDropDown CreateDefaultDropDown ()
                {
-                       return new ToolStripDropDownMenu ();
+                       ToolStripDropDownMenu tsddm = new ToolStripDropDownMenu ();
+                       tsddm.OwnerItem = this;
+                       return tsddm;
                }
 
                protected override void Dispose (bool disposing)
@@ -228,6 +239,11 @@ namespace System.Windows.Forms
                                }
                        }
 
+                       if (this.IsMdiWindowListEntry) {
+                               this.mdi_client_form.MdiParent.MdiContainer.ActivateChild (this.mdi_client_form);
+                               return;
+                       }
+                       
                        if (this.check_on_click)
                                this.Checked = !this.Checked;
 
@@ -251,7 +267,7 @@ namespace System.Windows.Forms
 
                protected override void OnMouseDown (MouseEventArgs e)
                {
-                       if (this.HasDropDownItems)
+                       if (this.HasDropDownItems && Enabled)
                                if (!this.DropDown.Visible)
                                        this.ShowDropDown ();
 
@@ -260,7 +276,7 @@ namespace System.Windows.Forms
 
                protected override void OnMouseEnter (EventArgs e)
                {
-                       if (this.IsOnDropDown && this.HasDropDownItems)
+                       if (this.IsOnDropDown && this.HasDropDownItems && Enabled)
                                this.ShowDropDown ();
 
                        base.OnMouseEnter (e);
@@ -273,7 +289,8 @@ namespace System.Windows.Forms
 
                protected override void OnMouseUp (MouseEventArgs e)
                {
-                       base.OnMouseUp (e);
+                       if (!this.HasDropDownItems && Enabled)
+                               base.OnMouseUp (e);
                }
 
                protected override void OnOwnerChanged (EventArgs e)
@@ -318,6 +335,11 @@ namespace System.Windows.Forms
                                return;
                        }
                }
+
+               protected internal override void SetBounds (Rectangle bounds)
+               {
+                       base.SetBounds (bounds);
+               }
                #endregion
 
                #region Public Events
@@ -334,6 +356,13 @@ namespace System.Windows.Forms
                        remove {Events.RemoveHandler (CheckStateChangedEvent, value); }
                }
                #endregion
+
+               #region Internal Properties
+               internal Form MdiClientForm {
+                       get { return this.mdi_client_form; }
+                       set { this.mdi_client_form = value; }
+               }
+               #endregion
        }
 }
 #endif