Properly update the combo box selected text when the current item is changed, and...
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / InternalWindowManager.cs
index a393c9467f95a8bd3b6016db68e6347277b89e1d..ea58417925e84ceedb6e206a1c7e674b14f49e53 100644 (file)
@@ -431,10 +431,8 @@ namespace System.Windows.Forms {
 
                public bool ShowIcon {
                        get {
-#if NET_2_0
                                if (!Form.ShowIcon)
                                        return false;
-#endif
                                if (!HasBorders)
                                        return false;
                                if (IsMinimized)
@@ -447,7 +445,8 @@ namespace System.Windows.Forms {
 
                protected virtual void Activate ()
                {
-                       form.Refresh ();
+                       form.Invalidate (true);
+                       form.Update ();
                }
 
                public virtual bool IsActive {
@@ -633,7 +632,7 @@ namespace System.Windows.Forms {
        
                protected virtual void HandleWindowMove (Message m)
                {
-                       Point move = MouseMove (m);
+                       Point move = MouseMove (Cursor.Position);
 
                        UpdateVP (virtual_position.X + move.X, virtual_position.Y + move.Y,
                                        virtual_position.Width, virtual_position.Height);
@@ -642,9 +641,17 @@ namespace System.Windows.Forms {
                private void HandleSizing (Message m)
                {
                        Rectangle pos = virtual_position;
-                       Size minimum_size = SystemInformation.MinWindowTrackSize;
-                       int mw = minimum_size.Width;
-                       int mh = minimum_size.Height;
+                       int mw;
+                       int mh;
+                       if (IsToolWindow) {
+                               int border_width = BorderWidth;
+                               mw = 2 * (border_width + Theme.ManagedWindowSpacingAfterLastTitleButton) + ThemeEngine.Current.ManagedWindowButtonSize (this).Width;
+                               mh = 2 * border_width + TitleBarHeight;
+                       } else {
+                               Size minimum_size = SystemInformation.MinWindowTrackSize;
+                               mw = minimum_size.Width;
+                               mh = minimum_size.Height;
+                       }
                        int x = Cursor.Position.X;
                        int y = Cursor.Position.Y;
 
@@ -805,10 +812,9 @@ namespace System.Windows.Forms {
                {
                }
 
-               protected Point MouseMove (Message m)
+               protected Point MouseMove (Point pos)
                {
-                       Point cp = Cursor.Position;
-                       return new Point (cp.X - start.X, cp.Y - start.Y);
+                       return new Point (pos.X - start.X, pos.Y - start.Y);
                }
 
                protected virtual void DrawVirtualPosition (Rectangle virtual_position)
@@ -1106,7 +1112,10 @@ namespace System.Windows.Forms {
                        foreach (TitleButton button in this) {
                                if (button == null)
                                        continue;
-
+                               
+                               if (button.State == ButtonState.Inactive)
+                                       continue;
+                                       
                                if (button == over_button) {
                                        if (any_pushed_buttons) {
                                                any_change |= button.State != ButtonState.Pushed;
@@ -1147,12 +1156,12 @@ namespace System.Windows.Forms {
                        ToolTipHide (false);
 
                        foreach (TitleButton button in this) {
-                               if (button != null) {
+                               if (button != null && button.State != ButtonState.Inactive) {
                                        button.State = ButtonState.Normal;
                                }
                        }
                        TitleButton clicked_button = FindButton (x, y);
-                       if (clicked_button != null) {
+                       if (clicked_button != null && clicked_button.State != ButtonState.Inactive) {
                                clicked_button.State = ButtonState.Pushed;
                        }
                }
@@ -1164,12 +1173,12 @@ namespace System.Windows.Forms {
                        }
                        
                        TitleButton clicked_button = FindButton (x, y);
-                       if (clicked_button != null) {
+                       if (clicked_button != null && clicked_button.State != ButtonState.Inactive) {
                                clicked_button.OnClick ();
                        }
 
                        foreach (TitleButton button in this) {
-                               if (button == null)
+                               if (button == null || button.State == ButtonState.Inactive)
                                        continue;
 
                                button.State = ButtonState.Normal;
@@ -1177,6 +1186,8 @@ namespace System.Windows.Forms {
 
                        if (clicked_button == CloseButton && !form.closing)
                                XplatUI.InvalidateNC (form.Handle);
+                               
+                       ToolTipHide (true);
                }
 
                internal void MouseLeave (int x, int y)
@@ -1186,7 +1197,7 @@ namespace System.Windows.Forms {
                        }
                        
                        foreach (TitleButton button in this) {
-                               if (button == null)
+                               if (button == null || button.State == ButtonState.Inactive)
                                        continue;
 
                                button.State = ButtonState.Normal;