bool visible;\r
object tag;\r
protected bool mouseIsInside_;\r
+ bool recreatingHandle;\r
\r
// BeginInvoke() etc. helpers\r
static int InvokeMessage = Win32.RegisterWindowMessage("mono_control_invoke_helper");\r
visible = true;\r
parent = null;\r
mouseIsInside_ = false;\r
+ recreatingHandle = false;\r
// Do not create Handle here, only in CreateHandle\r
// CreateHandle();//sets window handle. FIXME: No it does not\r
}\r
} else return bounds;\r
}\r
set {\r
- if (IsHandleCreated)\r
- Win32.SetWindowPos (\r
- //Handle, (IntPtr) 0, value.X, value.Y,\r
- Handle, SetWindowPosZOrder.HWND_TOPMOST, value.X, value.Y,\r
- value.Width, value.Height, 0);\r
- else bounds = value;\r
+ SetBounds(value.Left, value.Top, value.Width, value.Height);\r
}\r
}\r
\r
else {\r
Win32.AdjustWindowRect( ref rc, styleIfNoWindow, menuIfNoWindow ? 1 : 0);\r
}\r
- Width = rc.right - rc.left;\r
- Height = rc.bottom - rc.top;\r
+ Size = new Size(rc.right - rc.left, rc.bottom - rc.top);\r
} \r
\r
public bool ContainsFocus {\r
return bounds.Height;\r
}\r
set {\r
- bounds.Height = value;\r
+ //bounds.Height = value;\r
if (IsHandleCreated) {\r
// FIXME: SetWindowPos\r
}\r
+ SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);\r
}\r
}\r
\r
} else return bounds.X;\r
}\r
set {\r
- bounds.X = value;\r
- \r
if (IsHandleCreated) {\r
// FIXME: SetWindowPos\r
}\r
+ SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);\r
}\r
}\r
\r
return new Point (Top, Left);\r
}\r
set {\r
- bounds.X = value.X;\r
- bounds.Y = value.Y;\r
- \r
if (IsHandleCreated) {\r
// FIXME: SetWindowPos\r
}\r
- \r
+ SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);\r
}\r
}\r
\r
[MonoTODO]\r
public bool RecreatingHandle {\r
get {\r
- throw new NotImplementedException ();\r
+ return recreatingHandle;\r
}\r
}\r
\r
}\r
set {\r
if( IsHandleCreated) {\r
+/*\r
Win32.SetWindowPos(Handle, SetWindowPosZOrder.HWND_TOP, 0, 0, value.Width, value.Height,\r
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOMOVE | \r
SetWindowPosFlags.SWP_NOZORDER);// Activating might be a good idea?? | SetWindowPosFlags.SWP_NOACTIVATE);\r
+*/ \r
}\r
-\r
- Width = value.Width;\r
- Height = value.Height;\r
- }\r
+ SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);\r
+ }\r
}\r
+\r
internal int tabindex;//for debug/test only. remove\r
[MonoTODO]\r
public int TabIndex {\r
} else return bounds.Top;\r
}\r
set {\r
- bounds.Y = value;\r
- \r
if (IsHandleCreated) {\r
// FIXME: SetWindowPos\r
}\r
- }\r
+ SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);\r
+ }\r
}\r
\r
[MonoTODO]\r
return bounds.Width;\r
}\r
set {\r
- bounds.Width = value;\r
if (IsHandleCreated) {\r
// FIXME: SetWindowPos\r
}\r
- }\r
+ SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);\r
+ }\r
}\r
\r
/// --- methods ---\r
\r
protected virtual void OnMouseEnter (EventArgs e) \r
{\r
- System.Console.WriteLine("OnMouseEnter");\r
+ //System.Console.WriteLine("OnMouseEnter");\r
if (MouseEnter != null)\r
MouseEnter (this, e);\r
}\r
\r
protected virtual void OnMouseLeave (EventArgs e) \r
{\r
- System.Console.WriteLine("OnMouseLeave");\r
+ //System.Console.WriteLine("OnMouseLeave");\r
\r
mouseIsInside_ = false;\r
if (MouseLeave != null)\r
// are big enough to warrant recreating the HWND\r
protected void RecreateHandle() \r
{\r
+ recreatingHandle = true;\r
if( IsHandleCreated) {\r
DestroyHandle ();\r
CreateHandle ();\r
}\r
- }\r
+ recreatingHandle = false;\r
+ }\r
\r
//Compact Framework\r
[MonoTODO]\r
public Rectangle RectangleToClient (Rectangle r) \r
{\r
- throw new NotImplementedException ();\r
+ // FIXME: What to return if Handle is not created yet ?\r
+ RECT rect = new RECT();\r
+ rect.left = r.Left;\r
+ rect.top = r.Top;\r
+ rect.right = r.Right;\r
+ rect.bottom = r.Bottom;\r
+ Win32.ScreenToClient(Handle,ref rect);\r
+ return new Rectangle( rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);\r
}\r
\r
//Compact Framework\r
[MonoTODO]\r
public Rectangle RectangleToScreen (Rectangle r) \r
{\r
- throw new NotImplementedException ();\r
- }\r
+ // FIXME: What to return if Handle is not created yet ?\r
+ RECT rect = new RECT();\r
+ rect.left = r.Left;\r
+ rect.top = r.Top;\r
+ rect.right = r.Right;\r
+ rect.bottom = r.Bottom;\r
+ Win32.ClientToScreen(Handle,ref rect);\r
+ return new Rectangle( rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);\r
+ }\r
\r
[MonoTODO]\r
protected static bool ReflectMessage (IntPtr hWnd, ref Message m) {\r
[MonoTODO]\r
public void SetBounds (int x, int y, int width, int height) \r
{\r
- //FIXME:\r
+ SetBounds(x, y, width, height, BoundsSpecified.All);\r
}\r
\r
[MonoTODO]\r
- public void SetBounds (int x, int y, int width, int height,\r
- BoundsSpecified specified) \r
+ public void SetBounds (int x, int y, int width, int height, BoundsSpecified specified) \r
{\r
- //FIXME:\r
+ SetBoundsCore( x, y, width, height, specified);\r
}\r
\r
[MonoTODO]\r
- protected virtual void SetBoundsCore (\r
- int x, int y, int width, int height,\r
- BoundsSpecified specified) \r
+ protected virtual void SetBoundsCore ( int x, int y, int width, int height, BoundsSpecified specified) \r
{\r
- //FIXME:\r
+ if( IsHandleCreated) {\r
+// SetWindowPosFlags flags = SetWindowPosFlags.SWP_NOOWNERZORDER | SetWindowPosFlags.SWP_NOZORDER |\r
+// SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_DRAWFRAME;\r
+ SetWindowPosFlags flags = SetWindowPosFlags.SWP_NOZORDER |\r
+ SetWindowPosFlags.SWP_FRAMECHANGED | SetWindowPosFlags.SWP_DRAWFRAME;\r
+ Win32.SetWindowPos( Handle, SetWindowPosZOrder.HWND_NOTOPMOST, x, y, width, height, flags);\r
+ RECT rect = new RECT();\r
+ Win32.GetWindowRect (Handle, ref rect);\r
+ if( Parent != null) {\r
+ Win32.ScreenToClient(Parent.Handle, ref rect);\r
+ }\r
+ bounds = new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);\r
+ }\r
+ else {\r
+ if( (specified & BoundsSpecified.X) != 0) {\r
+ bounds.X = x;\r
+ }\r
+ if( (specified & BoundsSpecified.Y) != 0) {\r
+ bounds.Y = y;\r
+ }\r
+ if( (specified & BoundsSpecified.Width) != 0) {\r
+ bounds.Width = width;\r
+ }\r
+ if( (specified & BoundsSpecified.Height) != 0) {\r
+ bounds.Height = height;\r
+ }\r
+ }\r
}\r
\r
[MonoTODO]\r