Author: rolf
Date: 2006-11-28 13:42:19 -0500 (Tue, 28 Nov 2006)
New Revision: 68599

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/InternalWindowManager.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs
Log:
2006-11-28  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>

        * XplatUIStructs.cs: 
        - Added WM_NCMOUSEHOVER and WM_NCMOUSELEAVE.
        
        * XplatUIWin32.cs: 
        - Added TME_NONCLIENT to TMEFlags.
        - Handles WM_NCMOUSEMOVE in GetMessage to 
          generate WM_NCMOUSEHOVER and WM_NCMOUSELEAVE messages.

        * MdiWindowManager:
        - Now merges mdi child menu to parent menu when maximized.
        - Recalculate NC areas of both mdi child and mdi parent. 
          Fixes #79757 (4).
          on window state and size changes.Fixes #79844 (3).
        - Handle WM_NCCALCSIZE to properly calculate borders.

        * Form.cs:
        - Add/remove to the mdi containers list of mdi children 
          in the order they are added.
        - Pass on WM_NCLBUTTONUP, WM_NCMOUSEMOVE and WM_NCMOUSELEAVE 
          to the maximized mdi child.
        
        * InternalWindowManager.cs:
        - Only execute a click on the control buttons on the mouse up,
          not on the mouse down. Show the state of the button 
          (was only showing Normal state, never Pressed state). The
          pressed button now follows the mouse (if you click the Close 
          button and move the mouse over the Maximize button, the 
          Maximize button will be shown as pressed). Since Win32 does
          not generate WM_NCLBUTTONUP if you release the button outside
          of the nc area, we need to handle WM_NCMOUSELEAVE and treat
          it as a mouse up.
        
        * ThemeWin32Classic.cs:
        - Draw a missing border around mdi child forms. Fixes #79844 (2).

        * MdiClient.cs:
        - Added a list of forms which contains the order the forms are
          added to the mdi parent.
        - Handle WM_NCPAINT to properly draw a 3D border. Fixes #79844 (2).
        - Handle WM_NCCALCSIZE to properly calculate the 3D border.
        - If the active form changes set the scrollbars to the top
          of the Z order, otherwise the form could hide them.
        - Scrollbars are now sized according to ClientSize, not 
          to Size, and they take into account the other scrollbar
          to determine maximum.
        


Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-28 18:39:41 UTC (rev 68598)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-28 18:42:19 UTC (rev 68599)
@@ -1,3 +1,51 @@
+2006-11-28  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
+
+       * XplatUIStructs.cs: 
+       - Added WM_NCMOUSEHOVER and WM_NCMOUSELEAVE.
+       
+       * XplatUIWin32.cs: 
+       - Added TME_NONCLIENT to TMEFlags.
+       - Handles WM_NCMOUSEMOVE in GetMessage to 
+         generate WM_NCMOUSEHOVER and WM_NCMOUSELEAVE messages.
+
+       * MdiWindowManager:
+       - Now merges mdi child menu to parent menu when maximized.
+       - Recalculate NC areas of both mdi child and mdi parent. 
+         Fixes #79757 (4).
+         on window state and size changes.Fixes #79844 (3).
+       - Handle WM_NCCALCSIZE to properly calculate borders.
+
+       * Form.cs:
+       - Add/remove to the mdi containers list of mdi children 
+         in the order they are added.
+       - Pass on WM_NCLBUTTONUP, WM_NCMOUSEMOVE and WM_NCMOUSELEAVE 
+         to the maximized mdi child.
+       
+       * InternalWindowManager.cs:
+       - Only execute a click on the control buttons on the mouse up,
+         not on the mouse down. Show the state of the button 
+         (was only showing Normal state, never Pressed state). The
+         pressed button now follows the mouse (if you click the Close 
+         button and move the mouse over the Maximize button, the 
+         Maximize button will be shown as pressed). Since Win32 does
+         not generate WM_NCLBUTTONUP if you release the button outside
+         of the nc area, we need to handle WM_NCMOUSELEAVE and treat
+         it as a mouse up.
+       
+       * ThemeWin32Classic.cs:
+       - Draw a missing border around mdi child forms. Fixes #79844 (2).
+
+       * MdiClient.cs:
+       - Added a list of forms which contains the order the forms are
+         added to the mdi parent.
+       - Handle WM_NCPAINT to properly draw a 3D border. Fixes #79844 (2).
+       - Handle WM_NCCALCSIZE to properly calculate the 3D border.
+       - If the active form changes set the scrollbars to the top
+         of the Z order, otherwise the form could hide them.
+       - Scrollbars are now sized according to ClientSize, not 
+         to Size, and they take into account the other scrollbar
+         to determine maximum.
+       
 2006-11-28  Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
        
        * XplatUI.cs:

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-28 18:39:41 UTC (rev 68598)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs  
2006-11-28 18:42:19 UTC (rev 68599)
@@ -552,6 +552,7 @@
                                        throw new ArgumentException ();
 
                                if (mdi_parent != null) {
+                                       
mdi_parent.MdiContainer.original_order.Remove (this);
                                        mdi_parent.MdiContainer.Controls.Remove 
(this);
                                }
 
@@ -559,6 +560,7 @@
                                        mdi_parent = value;
                                        window_manager = new MdiWindowManager 
(this,
                                                        
mdi_parent.MdiContainer);
+                                       
mdi_parent.MdiContainer.original_order.Add (this);
                                        mdi_parent.MdiContainer.Controls.Add 
(this);
 
                                        RecreateHandle ();
@@ -1873,18 +1875,47 @@
                                        }
 
                                        if (ActiveMaximizedMdiChild != null) {
-                                               
ActiveMaximizedMdiChild.HandleMenuMouseDown (ActiveMenu,
+                                               if 
(ActiveMaximizedMdiChild.HandleMenuMouseDown (ActiveMenu,
                                                                LowOrder ((int) 
m.LParam.ToInt32 ()),
-                                                               HighOrder 
((int) m.LParam.ToInt32 ()));
+                                                               HighOrder 
((int) m.LParam.ToInt32 ()))) {
+                                                       // Don't let base 
process this message, otherwise we won't
+                                                       // get a WM_NCLBUTTONUP.
+                                                       return;
+                                               }
                                        }
                                        base.WndProc(ref m);
                                        return;
                                }
+                               case Msg.WM_NCLBUTTONUP: {
+                                       if (ActiveMaximizedMdiChild != null) {
+                                               
ActiveMaximizedMdiChild.HandleMenuMouseUp (ActiveMenu,
+                                                               LowOrder 
((int)m.LParam.ToInt32 ()),
+                                                               HighOrder 
((int)m.LParam.ToInt32 ()));
+                                       }
+                                       base.WndProc (ref m);
+                                       return;
+                               }
 
+                               case Msg.WM_NCMOUSELEAVE: {
+                                       if (ActiveMaximizedMdiChild != null) {
+                                               
ActiveMaximizedMdiChild.HandleMenuMouseLeave(ActiveMenu,
+                                                               
LowOrder((int)m.LParam.ToInt32()),
+                                                               
HighOrder((int)m.LParam.ToInt32()));
+                                       }
+                                       base.WndProc(ref m);
+                                       return;
+                               }
+                               
                                case Msg.WM_NCMOUSEMOVE: {
                                        if (XplatUI.IsEnabled (Handle) && 
ActiveMenu != null) {
                                                ActiveMenu.OnMouseMove(this, 
new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()), 
mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) 
m.LParam.ToInt32 ()), 0));
                                        }
+                                       
+                                       if (ActiveMaximizedMdiChild != null) {
+                                               
ActiveMaximizedMdiChild.HandleMenuMouseMove (ActiveMenu,
+                                                               LowOrder 
((int)m.LParam.ToInt32 ()),
+                                                               HighOrder 
((int)m.LParam.ToInt32 ()));
+                                       }
                                        base.WndProc(ref m);
                                        return;
                                }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
 2006-11-28 18:39:41 UTC (rev 68598)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
 2006-11-28 18:42:19 UTC (rev 68599)
@@ -53,6 +53,8 @@
                private FormPos sizing_edge;
                internal Rectangle virtual_position;
 
+               private bool is_mouse_down_menu;
+               
                public class TitleButton {
                        public Rectangle Rectangle;
                        public ButtonState State;
@@ -130,7 +132,7 @@
                        get { return TitleBarHeight - 5; }
                }
 
-               public bool HandleMessage (ref Message m)
+               public virtual bool HandleMessage (ref Message m)
                {
                        switch ((Msg)m.Msg) {
 
@@ -210,10 +212,18 @@
                                HandleNCLButtonDown (ref m);
                                return true;
 
+                       case Msg.WM_NCMOUSEMOVE:
+                               HandleNCMouseMove (ref m);
+                               return true;
+                               
                        case Msg.WM_NCLBUTTONDBLCLK:
                                HandleNCLButtonDblClick (ref m);
                                break;
 
+                       case Msg.WM_NCMOUSELEAVE:
+                               HandleNCMouseLeave (ref m);
+                               break;
+                       
                        case Msg.WM_MOUSE_LEAVE:
                                FormMouseLeave (ref m);
                                break;
@@ -272,19 +282,81 @@
                        CreateButtons ();
                }
 
-               public void HandleMenuMouseDown (MainMenu menu, int x, int y)
+               public bool HandleMenuMouseDown (MainMenu menu, int x, int y)
                {
                        Point pt = MenuTracker.ScreenToMenu (menu, new Point 
(x, y));
 
+                       is_mouse_down_menu = false;
                        foreach (TitleButton button in title_buttons) {
-                               if (button != null && button.Rectangle.Contains 
(pt)) {
-                                       button.Clicked (this, EventArgs.Empty);
+                               if (button != null) {
+                                       if (button.Rectangle.Contains (pt)) {
+                                               button.State = 
ButtonState.Pushed;
+                                               is_mouse_down_menu = true;
+                                       } else {
+                                               button.State = 
ButtonState.Normal;
+                                       }
+                               }
+                       }
+                       XplatUI.InvalidateNC (menu.GetForm().Handle);
+                       return is_mouse_down_menu;
+               }
+
+               public void HandleMenuMouseUp (MainMenu menu, int x, int y)
+               {
+                       Point pt = MenuTracker.ScreenToMenu (menu, new Point(x, 
y));
+
+                       foreach (TitleButton button in title_buttons) {
+                               if (button != null) {
+                                       if (button.Rectangle.Contains (pt)) {
+                                               button.Clicked (this, 
EventArgs.Empty);
+                                               button.State = 
ButtonState.Pushed;
+                                       } else {
+                                               button.State = 
ButtonState.Normal;
+                                       }
+                               }
+                       }
+                       XplatUI.InvalidateNC (menu.GetForm().Handle);
+                       is_mouse_down_menu = false;
+                       return;
+               }
+               
+               public void HandleMenuMouseLeave(MainMenu menu, int x, int y)
+               {
+                       Point pt = MenuTracker.ScreenToMenu (menu, new Point(x, 
y));
+
+                       foreach (TitleButton button in title_buttons) {
+                               if (button != null) {
+                                       button.State = ButtonState.Normal;
+                               }
+                       }
+                       XplatUI.InvalidateNC (menu.GetForm().Handle);
+                       return;
+               }
+               
+               public void HandleMenuMouseMove (MainMenu menu, int x, int y)
+               {
+                       Point pt = MenuTracker.ScreenToMenu (menu, new Point 
(x, y));
+                       
+                       if (!is_mouse_down_menu)
+                               return;
+                               
+                       bool any_change = false;
+                       foreach (TitleButton button in title_buttons) {
+                               if (button == null) 
+                                       continue;
+                               
+                               if (button.Rectangle.Contains(pt)) {
+                                       any_change |= button.State != 
ButtonState.Pushed;
                                        button.State = ButtonState.Pushed;
-                                       return;
+                               } else {
+                                       any_change |= button.State != 
ButtonState.Normal;
+                                       button.State = ButtonState.Normal;
                                }
                        }
+                       if (any_change)
+                               XplatUI.InvalidateNC (menu.GetForm().Handle);
                }
-
+               
                public virtual void SetWindowState (FormWindowState old_state, 
FormWindowState window_state)
                {
                }
@@ -384,6 +456,40 @@
                        return false;
                }
 
+               protected virtual bool HandleNCMouseLeave (ref Message m)
+               {
+                       int x = Control.LowOrder ((int)m.LParam.ToInt32 ());
+                       int y = Control.HighOrder ((int)m.LParam.ToInt32 ());
+
+                       NCPointToClient (ref x, ref y);
+                       FormPos pos = FormPosForCoords (x, y);
+
+                       if (pos != FormPos.TitleBar) {
+                               HandleTitleBarLeave (x, y);
+                               return true;
+                       }
+
+                       return true;
+               }
+               
+               protected virtual bool HandleNCMouseMove (ref Message m)
+               {
+
+                       int x = Control.LowOrder((int)m.LParam.ToInt32( ));
+                       int y = Control.HighOrder((int)m.LParam.ToInt32( ));
+
+                       NCPointToClient (ref x, ref y);
+                       FormPos pos = FormPosForCoords (x, y);
+
+                       if (pos == FormPos.TitleBar) {
+                               HandleTitleBarMove (x, y);
+                               return true;
+                       }
+
+                       return true;
+                       
+               }
+               
                protected virtual bool HandleNCLButtonDown (ref Message m)
                {
                        Activate ();
@@ -391,6 +497,8 @@
                        start = Cursor.Position;
                        virtual_position = form.Bounds;
 
+                       is_mouse_down_menu = false;
+                       
                        int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
                        int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
                        
@@ -421,8 +529,46 @@
                {
                }
                
+               protected virtual void HandleTitleBarLeave (int x, int y)
+               {
+                       is_mouse_down_menu = false;
+               }
+               
+               protected virtual void HandleTitleBarMove (int x, int y)
+               {
+                       if (!is_mouse_down_menu)
+                               return;
+                       
+                       bool any_change = false;
+                       foreach (TitleButton button in title_buttons) {
+                               if (button == null)
+                                       continue;
+                               
+                               if (button.Rectangle.Contains (x, y)) {
+                                       any_change |= button.State != 
ButtonState.Pushed;
+                                       button.State = ButtonState.Pushed;
+                               } else {
+                                       any_change |= button.State != 
ButtonState.Normal;
+                                       button.State = ButtonState.Normal;
+                               }
+                       }
+                       if (any_change)
+                               XplatUI.InvalidateNC (form.Handle);
+               }
+               
                protected virtual void HandleTitleBarUp (int x, int y)
                {
+                       is_mouse_down_menu = false;
+                       
+                       foreach (TitleButton button in title_buttons) {
+                               if (button == null)
+                                       continue;
+                                       
+                               button.State = ButtonState.Normal;
+                               if (button.Rectangle.Contains (x, y)) {
+                                       button.Clicked (this, EventArgs.Empty);
+                               } 
+                       }
                }
                
                protected virtual void HandleTitleBarDown (int x, int y)
@@ -430,6 +576,8 @@
                        foreach (TitleButton button in title_buttons) {
                                if (button != null && button.Rectangle.Contains 
(x, y)) {
                                        button.State = ButtonState.Pushed;
+                                       XplatUI.InvalidateNC (form.Handle);
+                                       is_mouse_down_menu = true;
                                        return;
                                }
                        }
@@ -611,13 +759,6 @@
                        NCPointToClient (ref x, ref y);
                        FormPos pos = FormPosForCoords (x, y);
 
-                       foreach (TitleButton button in title_buttons) {
-                               if (button != null && button.Rectangle.Contains 
(x, y)) {
-                                       button.Clicked (this, EventArgs.Empty);
-                                       return true;
-                               }
-                       }
-
                        if (pos == FormPos.TitleBar) {
                                HandleTitleBarUp (x, y);
                                return true;
@@ -632,9 +773,8 @@
                                return;
 
                        dc.FillRectangle (SystemBrushes.Control, 
button.Rectangle);
-
                        ControlPaint.DrawCaptionButton (dc, button.Rectangle,
-                                       button.Caption, ButtonState.Normal);
+                                       button.Caption, button.State);
                }
 
                public virtual void DrawMaximizedButtons (object sender, 
PaintEventArgs pe)

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-28 18:39:41 UTC (rev 68598)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs     
2006-11-28 18:42:19 UTC (rev 68599)
@@ -29,6 +29,7 @@
 using System.Collections;
 using System.ComponentModel;
 using System.Drawing;
+using System.Runtime.InteropServices;
 
 namespace System.Windows.Forms {
        [DesignTimeVisible(false)]
@@ -47,8 +48,9 @@
                private LayoutEventHandler initial_layout_handler;
                private bool setting_windowstates = false;
                internal ArrayList mdi_child_list;
-        private string form_text;
-        private bool setting_form_text;
+               private string form_text;
+               private bool setting_form_text;
+               internal ArrayList original_order = new ArrayList (); // The 
order the child forms are added (used by the main menu to show the window menu)
 
                #endregion      // Local Variables
 
@@ -152,6 +154,38 @@
                                }
                        }
                        */
+                       switch ((Msg)m.Msg) {
+                       case Msg.WM_NCCALCSIZE:
+                               XplatUIWin32.NCCALCSIZE_PARAMS  ncp;
+
+                               if (m.WParam == (IntPtr) 1) {
+                                       ncp = (XplatUIWin32.NCCALCSIZE_PARAMS) 
Marshal.PtrToStructure (m.LParam,
+                                                       typeof 
(XplatUIWin32.NCCALCSIZE_PARAMS));
+
+                                       int bw = 2;
+
+                                       ncp.rgrc1.top += bw;
+                                       ncp.rgrc1.bottom -= bw;
+                                       ncp.rgrc1.left += bw;
+                                       ncp.rgrc1.right -= bw;
+                                       
+                                       Marshal.StructureToPtr (ncp, m.LParam, 
true);
+                               }
+
+                               break;
+
+                       case Msg.WM_NCPAINT:
+                               PaintEventArgs pe = XplatUI.PaintEventStart 
(Handle, false);
+
+                               Rectangle clip;
+                               clip = new Rectangle (0, 0, Width, Height);
+
+                               ControlPaint.DrawBorder3D (pe.Graphics, clip, 
Border3DStyle.Sunken);
+                               XplatUI.PaintEventEnd (Handle, false);
+                               m.Result = IntPtr.Zero;
+                               return ;
+                       }
+
                        base.WndProc (ref m);
                }
 
@@ -159,6 +193,8 @@
                {
                        base.OnResize (e);
 
+                       if (Parent != null)
+                               XplatUI.InvalidateNC (Parent.Handle);
                        // Should probably make this into one loop
                        SizeScrollBars ();
                        ArrangeWindows ();
@@ -253,6 +289,8 @@
                                        hbar.Visible = false;
                                if (vbar != null)
                                        vbar.Visible = false;
+                               if (sizegrip != null)
+                                       sizegrip.Visible = false;
                                return;
                        }
                                
@@ -354,13 +392,15 @@
                        int virtual_left = Math.Min (left, 0);
                        int virtual_right = Math.Max (right, right_edge);
                        int diff = (virtual_right - virtual_left) - right_edge;
+
                        hbar.Left = 0;
-                       hbar.Top = Height - hbar.Height;
-                       hbar.Width = Width - (vert_vis ? 
SystemInformation.VerticalScrollBarWidth : 0);
+                       hbar.Top = ClientRectangle.Bottom - hbar.Height;
+                       hbar.Width = ClientRectangle.Width - (vert_vis ? 
SystemInformation.VerticalScrollBarWidth : 0);
                        hbar.LargeChange = 50;
-                       hbar.Maximum = diff + 51;
+                       hbar.Maximum = diff + 51 + (vert_vis ? 
SystemInformation.VerticalScrollBarWidth : 0);
                        hbar.Value = -virtual_left;
                        hbar.ValueChanged += new EventHandler 
(HBarValueChanged);
+                       XplatUI.SetZOrder (hbar.Handle, IntPtr.Zero, true, 
false);
                        initializing_scrollbars = false;
                }
 
@@ -370,13 +410,15 @@
                        int virtual_top = Math.Min (top, 0);
                        int virtual_bottom = Math.Max (bottom, bottom_edge);
                        int diff = (virtual_bottom - virtual_top) - bottom_edge;
+                       
                        vbar.Top = 0;
-                       vbar.Left = Width - vbar.Width;
-                       vbar.Height = Height - (horz_vis ? 
SystemInformation.HorizontalScrollBarHeight : 0);
+                       vbar.Left = ClientRectangle.Right - vbar.Width;
+                       vbar.Height = ClientRectangle.Height - (horz_vis ? 
SystemInformation.HorizontalScrollBarHeight : 0);
                        vbar.LargeChange = 50;
-                       vbar.Maximum = diff + 51;
-                       vbar.Value = -virtual_top;
+                       vbar.Minimum = virtual_top;
+                       vbar.Maximum = diff + 51 + (horz_vis ? 
SystemInformation.HorizontalScrollBarHeight : 0);
                        vbar.ValueChanged += new EventHandler 
(VBarValueChanged);
+                       XplatUI.SetZOrder (vbar.Handle, IntPtr.Zero, true, 
false);
                        initializing_scrollbars = false;
                }
 
@@ -554,24 +596,21 @@
                                return;
 
                        Form current = (Form) Controls [0];
-
+                       form.SuspendLayout ();
                        form.BringToFront ();
-
+                       if (vbar != null && vbar.Visible)
+                               XplatUI.SetZOrder (vbar.Handle, IntPtr.Zero, 
true, false);
+                       if (hbar != null && hbar.Visible)
+                               XplatUI.SetZOrder (hbar.Handle, IntPtr.Zero, 
true, false);
+                       SetWindowStates ((MdiWindowManager) 
form.window_manager);
+                       form.ResumeLayout (false);
                        if (current != form) {
-                               Message m = new Message ();
-                               m.Msg = (int) Msg.WM_NCPAINT;
-                               m.HWnd = current.Handle;
-                               m.LParam = IntPtr.Zero;
-                               m.WParam = new IntPtr (1);
-                               XplatUI.SendMessage (ref m);
-
-                               m.HWnd = form.Handle;
-                               XplatUI.SendMessage (ref m);
-                               this.SetWindowStates ((MdiWindowManager) 
form.window_manager, form.WindowState);
+                               XplatUI.InvalidateNC (current.Handle);
+                               XplatUI.InvalidateNC (form.Handle);
                        }
                }
                
-               internal bool SetWindowStates (MdiWindowManager wm, 
FormWindowState window_state)
+               internal bool SetWindowStates (MdiWindowManager wm)
                {
                /*
                        MDI WindowState behaviour:
@@ -618,9 +657,12 @@
                                form.WindowState = FormWindowState.Maximized;
                        }
                        SetParentText(false);
-                       SizeScrollBars();
+                       
                        XplatUI.RequestNCRecalc(ParentForm.Handle);
+                       XplatUI.RequestNCRecalc (Handle);
 
+                       SizeScrollBars ();
+
                        setting_windowstates = false;
 
                        return maximize_this;

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-28 18:39:41 UTC (rev 68598)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs  
    2006-11-28 18:42:19 UTC (rev 68599)
@@ -28,6 +28,7 @@
 using System;
 using System.Drawing;
 using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
 
 namespace System.Windows.Forms {
 
@@ -76,11 +77,14 @@
                {
                        if (form.window_state == FormWindowState.Minimized)
                                IconicBounds = form.Bounds;
+                       XplatUI.RequestNCRecalc (mdi_container.Handle);
                        form.MdiParent.MdiContainer.SizeScrollBars ();
                }
 
                private void FormSizeChangedHandler (object sender, EventArgs e)
                {
+                       XplatUI.RequestNCRecalc 
(form.MdiParent.MdiContainer.Handle);
+                       XplatUI.RequestNCRecalc (form.Handle);
                        form.MdiParent.MdiContainer.SizeScrollBars ();
                }
        
@@ -124,9 +128,15 @@
                                MainMenu clone = (MainMenu) 
parent.Menu.CloneMenu ();
                                res.MergeMenu (clone);
                        }
-
-                       res.MenuItems.Add (new MenuItem ()); // Dummy item to 
get the menu height correct
                        
+                       if (form.Menu != null) {
+                               MainMenu clone = (MainMenu) form.Menu.CloneMenu 
();
+                               res.MergeMenu (clone);
+                       }
+                       
+                       if (res.MenuItems.Count == 0)
+                               res.MenuItems.Add (new MenuItem ()); // Dummy 
item to get the menu height correct
+                       
                        res.SetForm (parent);
                        return res;
                }
@@ -253,7 +263,7 @@
 
                public override void SetWindowState (FormWindowState old_state, 
FormWindowState window_state)
                {
-                       if (this.mdi_container.SetWindowStates (this, 
window_state))
+                       if (this.mdi_container.SetWindowStates (this))
                                return;
                        
                        if (prev_window_state == window_state)
@@ -292,6 +302,7 @@
 
                        form.ResetCursor ();
                        XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
+                       XplatUI.RequestNCRecalc (form.Handle);
                        mdi_container.SizeScrollBars ();
                }
 
@@ -315,7 +326,7 @@
                        y += TitleBarHeight;
                        FormPos pos = FormPosForCoords (x, y);
 
-                       if (pos != FormPos.TitleBar)
+                       if (pos != FormPos.TitleBar && pos != FormPos.Top)
                                return;
 
                        form.WindowState = FormWindowState.Maximized;
@@ -324,11 +335,7 @@
                private void FormClosed (object sender, EventArgs e)
                {
                        mdi_container.CloseChildForm (form);
-                       if (form.WindowState == FormWindowState.Maximized) {
-                               XplatUI.RequestNCRecalc 
(mdi_container.Parent.Handle);
-                               mdi_container.ParentForm.PerformLayout();
-                               
XplatUI.SendMessage(mdi_container.ParentForm.Handle, Msg.WM_NCPAINT, 
IntPtr.Zero, new IntPtr(1)); 
-                       }
+                       XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
                        mdi_container.SizeScrollBars ();
                }
 
@@ -413,6 +420,59 @@
                        start = Cursor.Position;
                }
 
+               public override bool HandleMessage (ref Message m)
+               {
+                       switch ((Msg)m.Msg) {
+                       case Msg.WM_NCMOUSEMOVE:
+                               XplatUI.RequestAdditionalWM_NCMessages 
(form.Handle, true, true);
+                               break;
+                               
+                       case Msg.WM_NCCALCSIZE:
+                               XplatUIWin32.NCCALCSIZE_PARAMS ncp;
+
+                               if (m.WParam == (IntPtr)1) {
+                                       ncp = 
(XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure (m.LParam,
+                                                       
typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
+
+                                       int bw = 
ThemeEngine.Current.ManagedWindowBorderWidth (this);
+                                       if (!IsMaximized)
+                                               bw++;
+
+                                       if (HasBorders) {
+                                               ncp.rgrc1.top += TitleBarHeight 
+ bw;
+                                               if (!IsMaximized) {
+                                                       ncp.rgrc1.left += bw;
+                                                       ncp.rgrc1.bottom -= bw;
+                                                       ncp.rgrc1.right -= bw;
+                                               } else {
+                                                       ncp.rgrc1.left += 1;
+                                                       ncp.rgrc1.bottom -= 2; 
+                                                       ncp.rgrc1.right -= 3;
+                                               }
+                                       }
+                                       
+                                       if (ncp.rgrc1.bottom < ncp.rgrc1.top)
+                                               ncp.rgrc1.bottom = 
ncp.rgrc1.top + 1;
+                                               
+                                       Marshal.StructureToPtr (ncp, m.LParam, 
true);
+                               }
+
+                               return false;
+
+                       //case Msg.WM_NCPAINT:
+                       //        PaintEventArgs pe = XplatUI.PaintEventStart 
(form.Handle, false);
+
+                       //        Rectangle clip;
+                       //        clip = new Rectangle (0, 0, form.Width, 
form.Height);
+
+                       //        
ThemeEngine.Current.DrawManagedWindowDecorations (pe.Graphics, clip, this);
+                       //        XplatUI.PaintEventEnd (form.Handle, false);
+                       //        return true;
+                       }
+               
+                       return base.HandleMessage (ref m);
+               }
+       
                protected override void DrawVirtualPosition (Rectangle 
virtual_position)
                {
                        ClearVirtualPosition ();
@@ -446,7 +506,7 @@
                {
                        if (mdi_container.ActiveMdiChild != form) {
                                mdi_container.ActivateChild (form);
-                               mdi_container.SetWindowStates (this, 
form.WindowState);
+                               mdi_container.SetWindowStates (this);
                        }
                        base.Activate ();
                }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2006-11-28 18:39:41 UTC (rev 68598)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2006-11-28 18:42:19 UTC (rev 68599)
@@ -4745,10 +4745,20 @@
                        Color titlebar_color = Color.FromArgb (255, 0, 0, 255);
                        
                        if (wm.HasBorders) {
+                               Pen pen = new Pen(ColorControl, 1);
                                Rectangle borders = new Rectangle (0, 0, 
form.Width, form.Height);
                                // The 3d border is only 2 pixels wide, so we 
draw the innermost pixel ourselves
                                dc.DrawRectangle (new Pen (ColorControl, 1), 2, 
2, form.Width - 5, form.Height - 5);
                                ControlPaint.DrawBorder3D (dc, borders, 
Border3DStyle.Raised);
+                               
+                               if (!wm.IsMaximized) {
+                                       borders.Y += tbheight + bdwidth;
+                                       borders.X += bdwidth;
+                                       borders.Height -= tbheight + bdwidth * 
2 + 1;
+                                       borders.Width -= bdwidth * 2 + 1;
+                                       
+                                       dc.DrawRectangle (pen, borders);
+                               }
                        }
 
                        Color color = ThemeEngine.Current.ColorControlDark;
@@ -4780,7 +4790,7 @@
                                format.LineAlignment = StringAlignment.Center;
 
                                if (tb.IntersectsWith (clip))
-                    dc.DrawString(form.Text, WindowBorderFont,
+                                       dc.DrawString (form.Text, 
WindowBorderFont,
                                                
ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
                                                tb, format);
                        }
@@ -4829,7 +4839,7 @@
                        dc.FillRectangle (SystemBrushes.Control, 
button.Rectangle);
 
                        ControlPaint.DrawCaptionButton (dc, button.Rectangle,
-                                       button.Caption, ButtonState.Normal);
+                                       button.Caption, button.State);
                }
 
                #region ControlPaint

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs    
    2006-11-28 18:39:41 UTC (rev 68598)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIStructs.cs    
    2006-11-28 18:42:19 UTC (rev 68599)
@@ -302,7 +302,9 @@
                WM_IME_REQUEST            = 0x0288,
                WM_IME_KEYDOWN            = 0x0290,
                WM_IME_KEYUP              = 0x0291,
+               WM_NCMOUSEHOVER           = 0x02A0,
                WM_MOUSEHOVER             = 0x02A1,
+               WM_NCMOUSELEAVE           = 0x02A2,
                WM_MOUSELEAVE             = 0x02A3,
                WM_CUT                    = 0x0300,
                WM_COPY                   = 0x0301,

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

Reply via email to