Browse Source

* MdiClient.cs: Add a method for activating mdi children. Very
basic right now. I imagine someday it might need more girth.
* MenuItem.cs: Implement MDI lists. When mdilist is true the mdi
children windows names are added to the menu item.
* ThemeWin32Classic.cs: Draw the arrow if the item is an
mdilist. This happens regardless of whether or not there are any
mdi windows to see in the list, and according to my tests happens
before the items are even added. Also happens if there isn't even
an mdi client to get windows from.


svn path=/trunk/mcs/; revision=53664

Jackson Harper 20 years ago
parent
commit
dbb3afa538

+ 12 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,15 @@
+2005-11-29  Jackson Harper  <[email protected]>
+
+	* MdiClient.cs: Add a method for activating mdi children. Very
+	basic right now. I imagine someday it might need more girth.
+	* MenuItem.cs: Implement MDI lists. When mdilist is true the mdi
+	children windows names are added to the menu item.
+	* ThemeWin32Classic.cs: Draw the arrow if the item is an
+	mdilist. This happens regardless of whether or not there are any
+	mdi windows to see in the list, and according to my tests happens
+	before the items are even added. Also happens if there isn't even
+	an mdi client to get windows from.
+
 2005-11-29  Alexander Olk  <[email protected]>
 
 	* ThemeWin32Classic.cs: Make DrawFlatStyleRadioButton protected

+ 6 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs

@@ -311,6 +311,12 @@ namespace System.Windows.Forms {
 			}
 		}
 
+		internal void ActivateChild (Form form)
+		{
+			form.BringToFront ();
+			active = form;
+		}
+
 		internal int ChildrenCreated {
 			get { return mdi_created; }
 			set { mdi_created = value; }

+ 53 - 2
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs

@@ -39,7 +39,7 @@ namespace System.Windows.Forms
 	[DesignTimeVisible(false)]
 	[ToolboxItem(false)]
 	public class MenuItem : Menu
-	{		
+	{
 		internal bool separator;
 		internal bool break_;
 		internal bool bar_break;
@@ -52,6 +52,8 @@ namespace System.Windows.Forms
 		private bool showshortcut;
 		private int index;
 		private bool mdilist;
+		private Hashtable mdilist_items;
+		private MdiClient mdicontainer;
 		private bool defaut_item;
 		private bool visible;
 		private bool ownerdraw;
@@ -195,7 +197,20 @@ namespace System.Windows.Forms
 		[DefaultValue(false)]
 		public bool MdiList {
 			get { return mdilist; }
-			set { mdilist = value; }
+			set {
+				if (mdilist == value)
+					return;
+				mdilist = value;
+
+				if (mdilist || mdilist_items == null)
+					return;
+
+				foreach (MenuItem item in mdilist_items.Keys)
+					MenuItems.Remove (item);
+				mdilist_items.Clear ();
+				mdilist_items = null;
+				
+			}
 		}
 
 		protected int MenuID {
@@ -481,6 +496,30 @@ namespace System.Windows.Forms
 
 		internal void PerformDrawItem (DrawItemEventArgs e)
 		{
+			if (mdilist && mdilist_items == null) {
+				do {
+					// Add the mdilist for the first time
+					mdilist_items = new Hashtable ();
+
+					MainMenu main = GetMainMenu ();
+					if (main == null || main.GetForm () == null)
+						break;
+
+					Form form = main.GetForm ();
+					mdicontainer = form.MdiContainer;
+					if (mdicontainer == null)
+						break;
+
+					foreach (Form mdichild in mdicontainer.Controls) {
+						MenuItem item = new MenuItem (mdichild.Text);
+						item.Click += new EventHandler (MdiWindowClickHandler);
+						MenuItems.Add (item);
+						mdilist_items.Add (item, form);
+					}
+
+				} while (false);
+			}
+
 			OnDrawItem (e);
 		}
 		
@@ -614,6 +653,18 @@ namespace System.Windows.Forms
 			return "";
 		}
 
+		private void MdiWindowClickHandler (object sender, EventArgs e)
+		{
+			Form mdichild = (Form) mdilist_items [SelectedItem];
+
+			// people could add weird items to the Window menu
+			// so we can't assume its just us
+			if (mdichild == null)
+				return;
+
+			mdicontainer.ActivateChild (mdichild);
+		}
+
 		#endregion Private Methods
 
 	}

+ 1 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs

@@ -1972,7 +1972,7 @@ namespace System.Windows.Forms
 			}
 
 			/* Draw arrow */
-			if (item.MenuBar == false && item.IsPopup) {
+			if (item.MenuBar == false && item.IsPopup || item.MdiList) {
 
 				int cx = ThemeEngine.Current.MenuCheckSize.Width;
 				int cy = ThemeEngine.Current.MenuCheckSize.Height;