Author: rolf
Date: 2006-11-23 11:04:51 -0500 (Thu, 23 Nov 2006)
New Revision: 68400

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
Log:
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.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-23 16:01:44 UTC (rev 68399)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-23 16:04:51 UTC (rev 68400)
@@ -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

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2006-11-23 16:01:44 UTC (rev 68399)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2006-11-23 16:04:51 UTC (rev 68400)
@@ -1592,11 +1592,10 @@
                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)]

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs     
2006-11-23 16:01:44 UTC (rev 68399)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs     
2006-11-23 16:04:51 UTC (rev 68400)
@@ -99,32 +99,29 @@
                #endregion      // Public Constructors
 
 
-        internal void SetParentText(bool text_changed)
-        {
-            if (setting_form_text)
-                return;
+               internal void SetParentText(bool text_changed)
+               {
+                       if (setting_form_text)
+                               return;
 
-            setting_form_text = true;
+                       setting_form_text = true;
 
-            if (text_changed)
-                form_text = ParentForm.Text;
+                       if (text_changed)
+                               form_text = ParentForm.Text;
 
-            if (ParentForm.ActiveMaximizedMdiChild == null)
-            {
-                ParentForm.Text = form_text;
-            }
-            else
-            {
+                       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 @@
                        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 @@
                                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 @@
 
                                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 @@
                {
                        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 @@
                                }
                        }
                        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 {

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs  
    2006-11-23 16:01:44 UTC (rev 68399)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs  
    2006-11-23 16:04:51 UTC (rev 68400)
@@ -136,6 +136,7 @@
                        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 @@
                                                                        
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 @@
                        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 @@
                                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;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to