فهرست منبع

2006-11-23 Rolf Bjarne Kvinge <[email protected]>

	* MdiWindowManager.cs: 
	- Handle a click on the form's icon to show the 
	system menu (when maximized). Fixes #79775.
	- Change the existing click handler for the form's
	icon when not maximized to show on MouseUp.
	Fixes #79776.

	* Form.cs: In OnResize only layout the mdi child's
	parent if it actually has a parent. Might not if
	the window is closing.


svn path=/trunk/mcs/; revision=68400
Rolf Bjarne Kvinge 19 سال پیش
والد
کامیت
8efdd323a1

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

@@ -1,3 +1,16 @@
+2006-11-23  Rolf Bjarne Kvinge  <[email protected]> 
+
+	* MdiWindowManager.cs: 
+	- Handle a click on the form's icon to show the 
+	system menu (when maximized). Fixes #79775.
+	- Change the existing click handler for the form's
+	icon when not maximized to show on MouseUp.
+	Fixes #79776.
+
+	* Form.cs: In OnResize only layout the mdi child's
+	parent if it actually has a parent. Might not if
+	the window is closing.
+
 2006-11-23  Gert Driesen  <[email protected]>
 
 	* MdiClient.cs: Ignore active MDI client for text of parent, if

+ 4 - 5
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs

@@ -1592,11 +1592,10 @@ namespace System.Windows.Forms {
 		protected override void OnResize(EventArgs e) {
 			base.OnResize(e);
 
-            if (this.IsMdiChild)
-            {
-                ParentForm.PerformLayout();
-                ParentForm.Size = ParentForm.Size;
-            }
+			if (this.IsMdiChild && ParentForm != null) {
+				ParentForm.PerformLayout();
+				ParentForm.Size = ParentForm.Size;
+			}
 		}
 
 		[EditorBrowsable(EditorBrowsableState.Advanced)]

+ 44 - 45
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs

@@ -99,32 +99,29 @@ namespace System.Windows.Forms {
 		#endregion	// Public Constructors
 
 
-        internal void SetParentText(bool text_changed)
-        {
-            if (setting_form_text)
-                return;
-
-            setting_form_text = true;
-
-            if (text_changed)
-                form_text = ParentForm.Text;
-
-            if (ParentForm.ActiveMaximizedMdiChild == null)
-            {
-                ParentForm.Text = form_text;
-            }
-            else
-            {
+		internal void SetParentText(bool text_changed)
+		{
+			if (setting_form_text)
+				return;
+
+			setting_form_text = true;
+
+			if (text_changed)
+				form_text = ParentForm.Text;
+
+			if (ParentForm.ActiveMaximizedMdiChild == null) {
+				ParentForm.Text = form_text;
+			} else {
 				string childText = ParentForm.ActiveMaximizedMdiChild.form.Text;
 				if (childText.Length > 0) {
 					ParentForm.Text = form_text + " - [" + ParentForm.ActiveMaximizedMdiChild.form.Text + "]";
 				} else {
 					ParentForm.Text = form_text;
 				}
-            }
+			}
 
-            setting_form_text = false;
-        }
+			setting_form_text = false;
+		}
 
 		internal override void OnPaintBackgroundInternal (PaintEventArgs pe)
 		{
@@ -262,9 +259,9 @@ namespace System.Windows.Forms {
 			bool vbar_required = false;
 
 			int right = 0;
-            int left = 0;
-            int top = 0;
-            int bottom = 0;
+			int left = 0;
+			int top = 0;
+			int bottom = 0;
 
 			foreach (Form child in Controls) {
 				if (!child.Visible)
@@ -274,21 +271,21 @@ namespace System.Windows.Forms {
 				if (child.Left < left) {
 					hbar_required = true;
 					left = child.Left;
-                }
-
-                if (child.Bottom > bottom)
-                    bottom = child.Bottom;
-                if (child.Top < 0) {
-                    vbar_required = true;
-                    top = child.Top;
-                }
 			}
 
+			if (child.Bottom > bottom)
+				bottom = child.Bottom;
+			if (child.Top < 0) {
+				vbar_required = true;
+				top = child.Top;
+			}
+		}
 
-            int first_right = Width;
-            int first_bottom = Height;
-            int right_edge = first_right;
-            int bottom_edge = first_bottom;
+
+			int first_right = Width;
+			int first_bottom = Height;
+			int right_edge = first_right;
+			int bottom_edge = first_bottom;
 			int prev_right_edge;
 			int prev_bottom_edge;
 
@@ -301,18 +298,18 @@ namespace System.Windows.Forms {
 
 				if (hbar_required || right > right_edge) {
 					need_hbar = true;
-                    bottom_edge = first_bottom - SystemInformation.HorizontalScrollBarHeight;
+					bottom_edge = first_bottom - SystemInformation.HorizontalScrollBarHeight;
 				} else {
 					need_hbar = false;
-                    bottom_edge = first_bottom;
+					bottom_edge = first_bottom;
 				}
 
 				if (vbar_required || bottom > bottom_edge) {
 					need_vbar = true;
-                    right_edge = first_right - SystemInformation.VerticalScrollBarWidth;
+					right_edge = first_right - SystemInformation.VerticalScrollBarWidth;
 				} else {
 					need_vbar = false;
-                    right_edge = first_right;
+					right_edge = first_right;
 				}
 
 			} while (right_edge != prev_right_edge || bottom_edge != prev_bottom_edge);
@@ -509,7 +506,9 @@ namespace System.Windows.Forms {
 		{
 			if (Controls.Count < 1)
 				return;
-
+			if (Controls.Count == 1 && Controls[0] == ActiveMdiChild)
+				return;
+				
 			Form front = (Form) Controls [0];
 			Form form = (Form) Controls [1];
 
@@ -581,15 +580,15 @@ namespace System.Windows.Forms {
 				}
 			}
 			if (maximize_this) {
-			    form.WindowState = FormWindowState.Maximized;
-            }
-            SetParentText(false);
-            SizeScrollBars();
-            XplatUI.RequestNCRecalc(ParentForm.Handle);
+				form.WindowState = FormWindowState.Maximized;
+			}
+			SetParentText(false);
+			SizeScrollBars();
+			XplatUI.RequestNCRecalc(ParentForm.Handle);
 
 			setting_windowstates = false;
 
-            return maximize_this;
+			return maximize_this;
 		}
 
 		internal int ChildrenCreated {

+ 34 - 2
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs

@@ -136,6 +136,7 @@ namespace System.Windows.Forms {
 			icon_menu.OwnerDraw = true;
 			icon_menu.MeasureItem += new MeasureItemEventHandler (MeasureIconMenuItem);
 			icon_menu.DrawItem += new DrawItemEventHandler (DrawIconMenuItem);
+			icon_menu.Click += new EventHandler (ClickIconMenuItem);
 
 			MenuItem restore = new MenuItem ("Restore", new EventHandler (RestoreItemHandler));
 			MenuItem move = new MenuItem ("Move", new EventHandler (MoveItemHandler));
@@ -151,6 +152,24 @@ namespace System.Windows.Forms {
 									maximize, close, next });
 		}
 
+		private void ClickIconMenuItem(object sender, EventArgs e)
+		{
+			ShowPopup ();
+		}
+		
+		private void ShowPopup ()
+		{
+			icon_popup_menu.MenuItems[0].Enabled = form.window_state != FormWindowState.Normal;    // restore
+			icon_popup_menu.MenuItems[1].Enabled = form.window_state != FormWindowState.Maximized; // move
+			icon_popup_menu.MenuItems[2].Enabled = form.window_state != FormWindowState.Maximized; // size
+			icon_popup_menu.MenuItems[3].Enabled = form.window_state != FormWindowState.Minimized; // minimize
+			icon_popup_menu.MenuItems[4].Enabled = form.window_state != FormWindowState.Maximized; // maximize
+			icon_popup_menu.MenuItems[5].Enabled = true;  // close
+			icon_popup_menu.MenuItems[6].Enabled = true;  // next
+			
+			icon_popup_menu.Show(form, Point.Empty);
+		}
+		
 		private void RestoreItemHandler (object sender, EventArgs e)
 		{
 			form.WindowState = FormWindowState.Normal;
@@ -357,6 +376,21 @@ namespace System.Windows.Forms {
 			close_button.Rectangle.Y -= pnt.Y;
 		}
 
+		protected override void HandleTitleBarUp (int x, int y)
+		{
+			if (form.Icon != null) {
+				int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);
+				Rectangle icon = new Rectangle (bw + 3,
+						bw + 2, IconWidth, IconWidth);
+				if (icon.Contains (x, y)) {
+					ShowPopup ();
+					return;
+				}
+			}
+
+			base.HandleTitleBarUp (x, y);
+		}
+
 		protected override void HandleTitleBarDown (int x, int y)
 		{
 			if (form.Icon != null) {
@@ -364,14 +398,12 @@ namespace System.Windows.Forms {
 				Rectangle icon = new Rectangle (bw + 3,
 						bw + 2, IconWidth, IconWidth);
 				if (icon.Contains (x, y)) {
-					icon_popup_menu.Show (form, Point.Empty);
 					return;
 				}
 			}
 
 			base.HandleTitleBarDown (x, y);
 		}
-
 		protected override bool ShouldRemoveWindowManager (FormBorderStyle style)
 		{
 			return false;