Author: pbartok
Date: 2005-02-27 18:56:08 -0500 (Sun, 27 Feb 2005)
New Revision: 41270
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/Hwnd.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
Log:
2005-02-27 Peter Bartok <[EMAIL PROTECTED]>
* XplatUI.cs, XplatUIDriver.cs: Added new GetMenuOrigin() method
* XplatUIOSX.cs: Added GetMenuOrigin() stub
* XplatUIWin32.cs: Implemented GetMenuOrigin()
* XplatUIX11.cs:
- Implemented GetMenuDC()
- Implemented GetMenuOrigin()
- Implemented ReleaseMenuDC()
- Implemented generation of WM_NCPAINT message
- Implemented generation and handling of WM_NCCALCSIZE message
* Form.cs: Added debug helper message for Jordi's menu work
* Hwnd.cs:
- Modified ClientRect property; added setter, fixed getter to handle
setting of ClientRect
- Added MenuOrigin property
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-02-27 23:56:08 UTC (rev 41270)
@@ -1,3 +1,20 @@
+2005-02-27 Peter Bartok <[EMAIL PROTECTED]>
+
+ * XplatUI.cs, XplatUIDriver.cs: Added new GetMenuOrigin() method
+ * XplatUIOSX.cs: Added GetMenuOrigin() stub
+ * XplatUIWin32.cs: Implemented GetMenuOrigin()
+ * XplatUIX11.cs:
+ - Implemented GetMenuDC()
+ - Implemented GetMenuOrigin()
+ - Implemented ReleaseMenuDC()
+ - Implemented generation of WM_NCPAINT message
+ - Implemented generation and handling of WM_NCCALCSIZE message
+ * Form.cs: Added debug helper message for Jordi's menu work
+ * Hwnd.cs:
+ - Modified ClientRect property; added setter, fixed getter to handle
+ setting of ClientRect
+ - Added MenuOrigin property
+
2005-02-26 Peter Bartok <[EMAIL PROTECTED]>
* XplatUIX11.cs:
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -941,7 +941,8 @@
}
case Msg.WM_NCPAINT: {
- if (this.menu != null) {
+ if (this.menu != null) {
+Console.WriteLine("This should be the origin for the menu: {0}, and the
width:{1}", XplatUI.GetMenuOrigin(window.Handle), ClientSize.Width);
MenuAPI.DrawMenuBar
(menu.Handle);
}
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Hwnd.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -31,6 +31,10 @@
using System.Drawing;
using System.Runtime.InteropServices;
+// NOTE: Possible optimization:
+// Several properties calculate dimensions on the fly; instead; they can
+// be stored in a field and only be recalculated when a style is changed
+
namespace System.Windows.Forms {
internal class Hwnd : IDisposable {
#region Local Variables
@@ -57,6 +61,7 @@
internal bool nc_expose_pending;
internal Graphics client_dc;
internal object user_data;
+ internal Rectangle client_rectangle;
#endregion // Local Variables
#region Constructors and destructors
@@ -76,11 +81,13 @@
expose_pending = false;
nc_expose_pending = false;
edge_style = Border3DStyle.Raised;
+ client_rectangle = Rectangle.Empty;
}
public void Dispose() {
windows[client_window] = null;
windows[whole_window] = null;
+Console.WriteLine("Disposing window {0:X} (whole: {1:X})",
client_window.ToInt32(), whole_window.ToInt32());
}
#endregion
@@ -207,36 +214,44 @@
public Rectangle ClientRect {
get {
- Rectangle rect;
+ if (client_rectangle == Rectangle.Empty) {
+ Rectangle rect;
- rect = new Rectangle(0, 0, width, height);
+ rect = new Rectangle(0, 0, width,
height);
- if (menu_handle != IntPtr.Zero) {
- rect.Y += menu_height;
- rect.Height -= menu_height;
- }
+ if (menu_handle != IntPtr.Zero) {
+ rect.Y += menu_height;
+ rect.Height -= menu_height;
+ }
- if (border_style == BorderStyle.Fixed3D) {
- rect.X += 2;
- rect.Y += 2;
- rect.Width -= 4;
- rect.Height -= 4;
- } else if (border_style ==
BorderStyle.FixedSingle) {
- rect.X += 1;
- rect.Y += 1;
- rect.Width -= 2;
- rect.Height -= 2;
- }
+ if (border_style ==
BorderStyle.Fixed3D) {
+ rect.X += 2;
+ rect.Y += 2;
+ rect.Width -= 4;
+ rect.Height -= 4;
+ } else if (border_style ==
BorderStyle.FixedSingle) {
+ rect.X += 1;
+ rect.Y += 1;
+ rect.Width -= 2;
+ rect.Height -= 2;
+ }
- if (this.title_style == TitleStyle.Normal) {
- rect.Y += caption_height;
- rect.Height -= caption_height;
- } else if (this.title_style ==
TitleStyle.Normal) {
- rect.Y += tool_caption_height;
- rect.Height -= tool_caption_height;
+ if (this.title_style ==
TitleStyle.Normal) {
+ rect.Y += caption_height;
+ rect.Height -= caption_height;
+ } else if (this.title_style ==
TitleStyle.Normal) {
+ rect.Y += tool_caption_height;
+ rect.Height -=
tool_caption_height;
+ }
+
+ return rect;
+ } else {
+ return client_rectangle;
}
+ }
- return rect;
+ set {
+ client_rectangle = value;
}
}
@@ -304,6 +319,29 @@
}
}
+ public Point MenuOrigin {
+ get {
+ Point pt;
+
+ pt = new Point(0, 0);
+
+ if (border_style == BorderStyle.Fixed3D) {
+ pt.X += 2;
+ pt.Y += 2;
+ } else if (border_style ==
BorderStyle.FixedSingle) {
+ pt.X += 1;
+ pt.Y += 1;
+ }
+
+ if (this.title_style == TitleStyle.Normal) {
+ pt.Y += caption_height;
+ } else if (this.title_style ==
TitleStyle.Normal) {
+ pt.Y += tool_caption_height;
+ }
+
+ return pt;
+ }
+ }
public Rectangle Invalid {
get {
return invalid;
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -375,6 +375,13 @@
return driver.GetMenuDC(handle, ncpaint_region);
}
+ internal static Point GetMenuOrigin(IntPtr handle) {
+ #if DriverDebug
+ Console.WriteLine("GetMenuOrigin({0:X}):
Called", handle.ToInt32());
+ #endif
+ return driver.GetMenuOrigin(handle);
+ }
+
internal static bool GetMessage(ref MSG msg, IntPtr hWnd, int
wFilterMin, int wFilterMax) {
return driver.GetMessage(ref msg, hWnd, wFilterMin,
wFilterMax);
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -189,6 +189,7 @@
internal abstract void SystrayRemove(IntPtr hwnd, ref ToolTip
tt);
internal abstract Graphics GetMenuDC(IntPtr hwnd, IntPtr
ncpaint_region);
+ internal abstract Point GetMenuOrigin(IntPtr hwnd);
internal abstract void ReleaseMenuDC(IntPtr hwnd, Graphics dc);
// System information
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -1157,6 +1157,11 @@
throw new NotImplementedException();
}
+ [MonoTODO]
+ internal override Point GetMenuOrigin(IntPtr hwnd) {
+ throw new NotImplementedException();
+ }
+
internal override bool GetMessage(ref MSG msg, IntPtr hWnd, int
wFilterMin, int wFilterMax) {
IntPtr evtRef = IntPtr.Zero;
IntPtr target = GetEventDispatcherTarget();
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -1544,6 +1544,12 @@
return g;
}
+ internal override Point GetMenuOrigin(IntPtr handle) {
+ // FIXME - this does not yet consider different window
styles
+ return new
Point(SystemInformation.FrameBorderSize.Width,
SystemInformation.FrameBorderSize.Height + ThemeEngine.Current.CaptionHeight);
+ }
+
+
internal override void ReleaseMenuDC(IntPtr hwnd, Graphics dc) {
dc.Dispose();
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
2005-02-27 23:14:22 UTC (rev 41269)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
2005-02-27 23:56:08 UTC (rev 41270)
@@ -1812,10 +1812,25 @@
return GetFontMetrics(g.GetHdc(), font.ToHfont(), out
ascent, out descent);
}
- internal override Graphics GetMenuDC(IntPtr hwnd, IntPtr
ncpaint_region) {
- throw new NotImplementedException();
+ internal override Graphics GetMenuDC(IntPtr handle, IntPtr
ncpaint_region) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ return Graphics.FromHwnd(hwnd.whole_window);
}
+ internal override Point GetMenuOrigin(IntPtr handle) {
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(handle);
+
+ if (hwnd != null) {
+ return hwnd.MenuOrigin;
+ }
+ return Point.Empty;
+ }
+
internal override bool GetMessage(ref MSG msg, IntPtr handle,
int wFilterMin, int wFilterMax) {
XEvent xevent;
bool client;
@@ -2043,7 +2058,9 @@
case XEventName.ConfigureNotify: {
if (!client &&
(xevent.ConfigureEvent.xevent == xevent.ConfigureEvent.window)) { //
Ignore events for children (SubstructureNotify) and client areas
- Rectangle rect;
+ XplatUIWin32.NCCALCSIZE_PARAMS
ncp;
+ IntPtr
ptr;
+ Rectangle
rect;
#if DriverDebugExtra
Console.WriteLine("GetMessage(): Window {0:X} ConfigureNotify x={1} y={2}
width={3} height={4}", hwnd.client_window.ToInt32(), xevent.ConfigureEvent.x,
xevent.ConfigureEvent.y, xevent.ConfigureEvent.width,
xevent.ConfigureEvent.height);
@@ -2069,6 +2086,21 @@
// We need to adjust our client
window to track the resize of whole_window
rect = hwnd.ClientRect;
+ ncp = new
XplatUIWin32.NCCALCSIZE_PARAMS();
+ ptr =
Marshal.AllocHGlobal(Marshal.SizeOf(ncp));
+
+ ncp.rgrc1.left = rect.Left;
+ ncp.rgrc1.top = rect.Top;
+ ncp.rgrc1.right = rect.Right;
+ ncp.rgrc1.bottom = rect.Bottom;
+
+ Marshal.StructureToPtr(ncp,
ptr, true);
+
NativeWindow.WndProc(hwnd.client_window, Msg.WM_NCCALCSIZE, (IntPtr)1, ptr);
+ ncp =
(XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(ptr,
typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
+ Marshal.FreeHGlobal(ptr);
+
+ hwnd.ClientRect = new
Rectangle(ncp.rgrc1.left, ncp.rgrc1.top, ncp.rgrc1.right - ncp.rgrc1.left,
ncp.rgrc1.bottom - ncp.rgrc1.top);
+
XMoveResizeWindow(DisplayHandle, hwnd.client_window, rect.X, rect.Y,
rect.Width, rect.Height);
} else {
goto ProcessNextMessage;
@@ -2091,6 +2123,14 @@
}
case XEventName.Expose: {
+ if (!client) {
+ #if DriverDebugExtra
+
Console.WriteLine("GetMessage(): Window {0:X} Exposed non-client area {1},{2}
{3}x{4}", hwnd.client_window.ToInt32(), xevent.ExposeEvent.x,
xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
+ #endif
+ msg.message = Msg.WM_NCPAINT;
+ hwnd.nc_expose_pending = false;
+ break;
+ }
#if DriverDebugExtra
Console.WriteLine("GetMessage(): Window {0:X} Exposed area {1},{2} {3}x{4}",
hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y,
xevent.ExposeEvent.width, xevent.ExposeEvent.height);
#endif
@@ -2105,7 +2145,6 @@
ShowCaret();
Caret.Paused = false;
}
-
msg.message = Msg.WM_PAINT;
break;
}
@@ -2431,8 +2470,8 @@
MessageQueue.Enqueue (xevent);
}
- internal override void ReleaseMenuDC(IntPtr hwnd, Graphics dc) {
- throw new NotImplementedException();
+ internal override void ReleaseMenuDC(IntPtr handle, Graphics
dc) {
+ dc.Dispose();
}
internal override void ScreenToClient(IntPtr handle, ref int x,
ref int y) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches