All pastes #55421 Raw Edit

Anonymous

public text v1 · immutable
#55421 ·published 2006-05-12 18:38 UTC
rendered paste body
Index: XplatUI.cs
===================================================================
--- XplatUI.cs	(revision 60632)
+++ XplatUI.cs	(working copy)
@@ -456,6 +456,13 @@
 			return driver.GetAutoScaleSize(font);
 		}
 
+		internal static Region GetClipRegion(IntPtr handle) {
+			#if DriverDebug
+				Console.WriteLine("GetClipRegion({0}): Called", Window(handle));
+			#endif
+			return driver.GetClipRegion(handle);
+		}
+
 		internal static void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
 			#if DriverDebug
 				Console.WriteLine("GetCursorInfo({0}): Called", cursor.ToInt32());
@@ -708,6 +715,13 @@
 			driver.SetCaretPos(handle, x, y);
 		}
 
+		internal static void SetClipRegion(IntPtr handle, Region region) {
+			#if DriverDebug
+				Console.WriteLine("SetClipRegion({0}, {1}): Called", Window(handle), region);
+			#endif
+			driver.SetClipRegion(handle, region);
+		}
+
 		internal static void SetCursor(IntPtr handle, IntPtr cursor) {
 			#if DriverDebug
 				Console.WriteLine("SetCursor({0}, {1:X}): Called", Window(handle), cursor.ToInt32());
Index: Control.cs
===================================================================
--- Control.cs	(revision 60632)
+++ Control.cs	(working copy)
@@ -2126,19 +2126,12 @@
 		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 		public Region Region {
 			get {
-				return new Region(this.bounds);
+				return XplatUI.GetClipRegion(Handle);
 			}
 
 			set {
-				Graphics	g;
-				RectangleF	r;
 
-				g = this.CreateGraphics();
-				r = value.GetBounds(g);
-
-				SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
-
-				g.Dispose();
+				XplatUI.SetClipRegion(Handle, value);
 			}
 		}
 
Index: XplatUIX11.cs
===================================================================
--- XplatUIX11.cs	(revision 60632)
+++ XplatUIX11.cs	(working copy)
@@ -2748,6 +2748,17 @@
 			return active;
 		}
 
+		internal override Region GetClipRegion(IntPtr handle) {
+			Hwnd	hwnd;
+
+			hwnd = Hwnd.ObjectFromHandle(handle);
+			if (hwnd != null) {
+				return hwnd.UserClip;
+			}
+
+			return null;
+		}
+
 		internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
 			width = 20;
 			height = 20;
@@ -3211,7 +3222,6 @@
 								hwnd.whacky_wm = true;
 							}
 
-							msg.message = Msg.WM_WINDOWPOSCHANGED;
 							if (hwnd.opacity != 0xffffffff) {
 								IntPtr opacity;
 
@@ -3233,17 +3243,13 @@
 						#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);
 						#endif
-						msg.message = Msg.WM_WINDOWPOSCHANGED;
+						SendMessage(msg.hwnd, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
 						hwnd.configure_pending = false;
 
 						// We need to adjust our client window to track the resize of whole_window
 						PerformNCCalc(hwnd);
-					} else {
-						goto ProcessNextMessage;
 					}
-
-					msg.lParam=IntPtr.Zero;		// FIXME - Generate LPWINDOWPOS structure and pass on
-					break;
+					goto ProcessNextMessage;
 				}
 
 				case XEventName.FocusIn: {
@@ -3647,6 +3653,12 @@
 				foreach (Rectangle r in hwnd.ClipRectangles) {
 					clip_region.Union (r);
 				}
+				if (hwnd.UserClip != null) {
+Console.WriteLine("Setting user clip");
+					clip_region.Union(hwnd.UserClip);
+Console.WriteLine("Setting user clip done");
+				}
+
 				hwnd.client_dc.Clip = clip_region;
 				paint_event = new PaintEventArgs(hwnd.client_dc, hwnd.Invalid);
 				hwnd.expose_pending = false;
@@ -3950,6 +3962,17 @@
 			}
 		}
 
+		internal override void SetClipRegion(IntPtr handle, Region region) {
+			Hwnd	hwnd;
+
+			hwnd = Hwnd.ObjectFromHandle(handle);
+			if (hwnd == null) {
+				return;
+			}
+
+			hwnd.UserClip = region;
+		}
+
 		internal override void SetCursor(IntPtr handle, IntPtr cursor) {
 			Hwnd	hwnd;
 
Index: XplatUIWin32.cs
===================================================================
--- XplatUIWin32.cs	(revision 60632)
+++ XplatUIWin32.cs	(working copy)
@@ -1707,6 +1707,20 @@
 			Win32SetCursorPos(x, y);
 		}
 
+		internal override Region GetClipRegion(IntPtr hwnd) {
+			Region region;
+
+			region = new Region();
+
+			Win32GetWindowRgn(hwnd, region.GetHrgn(Graphics.FromHwnd(hwnd)));
+
+			return region;
+		}
+
+		internal override void SetClipRegion(IntPtr hwnd, Region region) {
+			Win32SetWindowRgn(hwnd, region.GetHrgn(Graphics.FromHwnd(hwnd)), false);
+		}
+
 		internal override void EnableWindow(IntPtr handle, bool Enable) {
 			Win32EnableWindow(handle, Enable);
 		}
@@ -2619,6 +2633,12 @@
 
 		[DllImport ("winmm.dll", EntryPoint="PlaySoundW", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
 		internal extern static IntPtr Win32PlaySound(string pszSound, IntPtr hmod, SndFlags fdwSound);
+
+		[DllImport ("user32.dll", EntryPoint="SetWindowRgn", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
+		internal extern static int Win32SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool redraw);
+
+		[DllImport ("user32.dll", EntryPoint="GetWindowRgn", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
+		internal extern static IntPtr Win32GetWindowRgn(IntPtr hWnd, IntPtr hRgn);
 		#endregion
 	}
 }
Index: XplatUIDriver.cs
===================================================================
--- XplatUIDriver.cs	(revision 60632)
+++ XplatUIDriver.cs	(working copy)
@@ -201,6 +201,9 @@
 
 		internal abstract bool CalculateWindowRect(ref Rectangle ClientRect, int Style, int ExStyle, Menu menu, out Rectangle WindowRect);
 
+		internal abstract Region GetClipRegion(IntPtr hwnd);
+		internal abstract void SetClipRegion(IntPtr hwnd, Region region);
+
 		internal abstract void SetCursor(IntPtr hwnd, IntPtr cursor);
 		internal abstract void ShowCursor(bool show);
 		internal abstract void OverrideCursor(IntPtr cursor);
Index: XplatUIOSX.cs
===================================================================
--- XplatUIOSX.cs	(revision 60632)
+++ XplatUIOSX.cs	(working copy)
@@ -1154,7 +1154,11 @@
 
 			return IntPtr.Zero;
 		}
-		
+
+		internal override Region GetClipRegion(IntPtr hwnd) {
+			return null;
+		}
+
 		[MonoTODO]
 		internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
 			throw new NotImplementedException ();
@@ -1511,6 +1515,10 @@
 				}
 			}
 		}
+
+		internal override void SetClipRegion(IntPtr hwnd, Region region) {
+			throw new NotImplementedException();
+		}
 		
 		internal override void SetCursor(IntPtr window, IntPtr cursor) {
 			SetThemeCursor ((uint) cursor);
Index: Hwnd.cs
===================================================================
--- Hwnd.cs	(revision 60632)
+++ Hwnd.cs	(working copy)
@@ -73,6 +73,7 @@
 		internal int		tool_caption_height;
 		internal bool		whacky_wm;
 		internal bool		fixed_size;
+		internal Region		user_clip;
 		internal static Bitmap	bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 		internal XEventQueue	queue;
 		#endregion	// Local Variables
@@ -266,6 +267,16 @@
 			}
 		}
 
+		public Region UserClip {
+			get {
+				return user_clip;
+			}
+
+			set {
+				user_clip = value;
+			}
+		}
+
 		public Rectangle DefaultClientRect {
 			get {
 				// We pass a Zero for the menu handle so the menu size is