Author: rolf
Date: 2007-04-02 12:54:59 -0400 (Mon, 02 Apr 2007)
New Revision: 75287
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
* Control.cs: Call ContainerControl.ChildControlRemoved whenever a
control is removed from a control collecftion.
* XplatUIX11.cs: The first location for toplevel form is (22, 22).
Fixes FormPropertyTest (failed on rare occasions).
* XplatUIWin32.cs: Add a workaround in SetParent for strange behaviour
of Win32SetParent (when changing from no parent to a parent it
might add the new parent's location in screen coordinates to this
window's location).
* Form.cs: Rework ChangingParent once again, now the handle is
recreated whenever a FormWindowManager is added or removed (that is
whenever a normal form is parented or abandoned). Also change
CreateParams so that all non-toplevel windows always get the
specified sice (StartupPosition is never considered for
non-TopLevel forms).
* ContainerControl.cs: Add ChildControlRemoved, the container control
needs to be notified when a control is removed from it's
collection, in the case the removed control is the active control.
* Hwnd.cs: Completely reworked GetWindowRectangle and
GetClientRectangle - they are now passed a CreateParams and they
only use Style and ExStyle to determine the rectangles (they should
now work just like Win32AdjustWindowRectEx - though quite a few
special cases are probably missing). They should also be 100%
complimentary (i.e. GetWindowRectangle (GetClientRectangle (rect))
== rect), and all numbers (borders, menu sizes) are taken from the
current theme. Added a GetBorders helper function that will return
the borders for any given CreateParams (including captions and
menus), and GetBorderSize that returns the given border size only.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-02 16:45:25 UTC (rev 75286)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-02 16:54:59 UTC (rev 75287)
@@ -1,3 +1,33 @@
+2007-04-02 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+
+ * Control.cs: Call ContainerControl.ChildControlRemoved whenever a
+ control is removed from a control collecftion.
+ * XplatUIX11.cs: The first location for toplevel form is (22, 22).
+ Fixes FormPropertyTest (failed on rare occasions).
+ * XplatUIWin32.cs: Add a workaround in SetParent for strange behaviour
+ of Win32SetParent (when changing from no parent to a parent it
+ might add the new parent's location in screen coordinates to this
+ window's location).
+ * Form.cs: Rework ChangingParent once again, now the handle is
+ recreated whenever a FormWindowManager is added or removed (that is
+ whenever a normal form is parented or abandoned). Also change
+ CreateParams so that all non-toplevel windows always get the
+ specified sice (StartupPosition is never considered for
+ non-TopLevel forms).
+ * ContainerControl.cs: Add ChildControlRemoved, the container control
+ needs to be notified when a control is removed from it's
+ collection, in the case the removed control is the active control.
+ * Hwnd.cs: Completely reworked GetWindowRectangle and
+ GetClientRectangle - they are now passed a CreateParams and they
+ only use Style and ExStyle to determine the rectangles (they should
+ now work just like Win32AdjustWindowRectEx - though quite a few
+ special cases are probably missing). They should also be 100%
+ complimentary (i.e. GetWindowRectangle (GetClientRectangle (rect))
+ == rect), and all numbers (borders, menu sizes) are taken from the
+ current theme. Added a GetBorders helper function that will return
+ the borders for any given CreateParams (including captions and
+ menus), and GetBorderSize that returns the given border size only.
+
2007-04-02 Jackson Harper <[EMAIL PROTECTED]>
* RichTextBox.cs: Use the new methods for setting the font and
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
2007-04-02 16:45:25 UTC (rev 75286)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
2007-04-02 16:54:59 UTC (rev 75287)
@@ -524,6 +524,15 @@
#endregion // Protected Instance Methods
#region Internal Methods
+ internal void ChildControlRemoved (Control control)
+ {
+ if (control == active_control) {
+ SelectNextControl (this, true, true, true,
true);
+ if (control == active_control) {
+ active_control = null;
+ }
+ }
+ }
internal virtual void CheckAcceptButton()
{
// do nothing here, only called if it is a Form
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2007-04-02 16:45:25 UTC (rev 75286)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2007-04-02 16:54:59 UTC (rev 75287)
@@ -779,6 +779,13 @@
all_controls = null;
list.Remove(value);
+ ContainerControl container = owner as
ContainerControl;
+ if (container != null) {
+ // Inform any container controls about
the loss of a child control
+ // so that they can update their active
control
+ container.ChildControlRemoved (value);
+ }
+
value.ChangeParent(null);
owner.UpdateChildrenZOrder();
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
2007-04-02 16:45:25 UTC (rev 75286)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
2007-04-02 16:54:59 UTC (rev 75287)
@@ -191,16 +191,21 @@
return;
}
+ bool recreate_necessary = false;
+
if (new_parent == null) {
+ recreate_necessary = window_manager is
FormWindowManager;
window_manager = null;
} else if (new_parent is MdiClient) {
window_manager = new MdiWindowManager (this,
(MdiClient) new_parent);
} else {
- if (IsHandleCreated) {
- RecreateHandle
();//XplatUI.SetWindowStyle (Handle, CreateParams);
- }
window_manager = new FormWindowManager (this);
+ recreate_necessary = true;
}
+
+ if (recreate_necessary && IsHandleCreated) {
+ RecreateHandle ();
+ }
if (window_manager != null) {
window_manager.UpdateWindowState (window_state,
window_state, true);
@@ -1123,8 +1128,8 @@
cp.menu = ActiveMenu;
cp.control = this;
- if (Parent != null && !IsMdiChild) {
- // Parented forms always gets the
specified location, no matter what
+ if (((Parent != null || !TopLevel) &&
!IsMdiChild)) {
+ // Parented forms and non-toplevel
forms always gets the specified location, no matter what
cp.X = Left;
cp.Y = Top;
} else {
@@ -1264,7 +1269,7 @@
cp.ExStyle |=
(int)WindowExStyles.WS_EX_CONTEXTHELP;
}
- if (VisibleInternal && this.IsRecreating)
+ if (VisibleInternal || this.IsRecreating)
cp.Style |=
(int)WindowStyles.WS_VISIBLE;
if (opacity < 1.0 || TransparencyKey !=
Color.Empty) {
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
2007-04-02 16:45:25 UTC (rev 75286)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
2007-04-02 16:54:59 UTC (rev 75287)
@@ -1854,10 +1854,34 @@
else
SetVisible (handle, c.is_visible, true);
- if (parent == IntPtr.Zero)
- return Win32SetParent (handle, FosterParent);
- else
- return Win32SetParent(handle, parent);
+ // The Win32SetParent is lame, it can very well move
the window
+ // ref:
http://groups.google.com/group/microsoft.public.vb.winapi/browse_thread/thread/1b82ccc54231ecee/afa82835bfc0422a%23afa82835bfc0422a
+ // Here we save the position before changing the
parent, and if it has changed afterwards restore it.
+ // Another possibility would be to intercept
WM_WINDOWPOSCHANGING and restore the coords there, but this would require
plumbing in weird places
+ // (either inside Control or add handling to
InternalWndProc)
+ // We also need to remove WS_CHILD if making the window
parent-less, and add it if we're parenting it.
+ RECT rect, rect2;
+ IntPtr result;
+ WindowStyles style, new_style;
+
+ Win32GetWindowRect (handle, out rect);
+ style = (WindowStyles) Win32GetWindowLong (handle,
WindowLong.GWL_STYLE);
+
+ if (parent == IntPtr.Zero) {
+ new_style = style & ~WindowStyles.WS_CHILD;
+ result = Win32SetParent (handle, FosterParent);
+ } else {
+ new_style = style | WindowStyles.WS_CHILD;
+ result = Win32SetParent (handle, parent);
+ }
+ if (style != new_style) {
+ Win32SetWindowLong (handle,
WindowLong.GWL_STYLE, (uint) new_style);
+ }
+ Win32GetWindowRect (handle, out rect2);
+ if (rect.top != rect2.top && rect.left != rect2.left) {
+ Win32SetWindowPos (handle, IntPtr.Zero,
rect.top, rect.left, rect.Width, rect.Height, SetWindowPosFlags.SWP_NOZORDER |
SetWindowPosFlags.SWP_NOREDRAW | SetWindowPosFlags.SWP_NOOWNERZORDER |
SetWindowPosFlags.SWP_NOENDSCHANGING | SetWindowPosFlags.SWP_NOACTIVATE);
+ }
+ return result;
}
// If we ever start using this, we should probably replace
FosterParent with IntPtr.Zero
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
2007-04-02 16:45:25 UTC (rev 75286)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
2007-04-02 16:54:59 UTC (rev 75287)
@@ -2477,6 +2477,10 @@
next = Point.Empty;
}
+ if (next == Point.Empty && cp.Parent ==
IntPtr.Zero) {
+ next = new Point (22, 22);
+ }
+
if (parent_hwnd != null) {
parent_hwnd.previous_child_startup_location = next;
} else {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches