Procházet zdrojové kódy

- Added ability to control ScrollWindow expose
- Added overload for ScrollWindow to allow only scrolling a rectangle
- Added Form methods

svn path=/trunk/mcs/; revision=38574

Peter Dennis Bartok před 21 roky
rodič
revize
db4d030557

+ 12 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,15 @@
+2005-01-09  Peter Bartok <[email protected]>
+
+	* XplatUI.cs, XplatUIDriver.cs, XplatUIWin32.cs, XplatUIOSX.cs,
+	  XplatUIX11.cs: Added ability to control ScrollWindow expose and 
+	  an overload for ScrollWindow to allow only scrolling a rectangle
+
+2005-01-09  Peter Bartok <[email protected]>
+
+	* Form.cs:
+	  - Implemented SetDesktopBounds method
+	  - Implemented SetDesktopLocation method
+
 2005-01-08  Jackson Harper  <[email protected]>
 
 	* TreeView.cs: Only set the vbar's Maximum and LargeChange when

+ 8 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs

@@ -722,6 +722,14 @@ namespace System.Windows.Forms {
 			owned_forms.Remove(ownedForm);
 		}
 
+		public void SetDesktopBounds(int x, int y, int width, int height) {
+			DesktopBounds = new Rectangle(x, y, width, height);
+		}
+
+		public void SetDesktopLocation(int x, int y) {
+			DesktopLocation = new Point(x, y);
+		}
+
 		public DialogResult ShowDialog() {
 			return ShowDialog(null);
 		}

+ 7 - 3
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs

@@ -48,7 +48,7 @@ using System.Runtime.InteropServices;
 
 /// X11 Version
 namespace System.Windows.Forms {
-	internal class XplatUI {
+	public class XplatUI {
 		#region Local Variables
 		static XplatUIDriver		driver;
 		static String			default_class_name;
@@ -353,8 +353,12 @@ namespace System.Windows.Forms {
 			}
 		}
 
-		internal static void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount) {
-			driver.ScrollWindow(hwnd, XAmount, YAmount);
+		public static void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear) {
+			driver.ScrollWindow(hwnd, rectangle, XAmount, YAmount, clear);
+		}
+
+		public static void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
+			driver.ScrollWindow(hwnd, XAmount, YAmount, clear);
 		}
 		
 		// Santa's little helper

+ 2 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs

@@ -150,7 +150,8 @@ namespace System.Windows.Forms {
 		internal abstract void SetFocus(IntPtr hwnd);
 		internal abstract IntPtr GetActive();
 
-		internal abstract void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount);
+		internal abstract void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear);
+		internal abstract void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear);
 
 		internal abstract bool GetFontMetrics(Graphics g, Font font, out int ascent, out int descent);
 

+ 9 - 5
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIOSX.cs

@@ -1221,7 +1221,11 @@ DEBUG THIS:
 			return GetFontMetrics(g.GetHdc(), font.ToHfont(), out ascent, out descent);
 		}
 
-		internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount) {
+		internal override void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear) {
+			throw new NotImplementedException("Need to implement the overload that provides the rectangle for ScrollWindow");
+		}
+
+		internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
 			IntPtr rect = IntPtr.Zero;
 			HIRect vBounds = new HIRect ();
                         HIViewGetBounds (hwnd, ref vBounds);
@@ -1230,15 +1234,15 @@ DEBUG THIS:
 			ScrollRect (ref rect, (short)XAmount, (short)-YAmount, IntPtr.Zero);
 
 			if (YAmount > 0) {
-				Invalidate (hwnd, new Rectangle (0, YAmount, (int)vBounds.size.width, (int)(vBounds.size.height)), true);
+				Invalidate (hwnd, new Rectangle (0, YAmount, (int)vBounds.size.width, (int)(vBounds.size.height)), clear);
 			} else if (YAmount < 0) {
-				Invalidate (hwnd, new Rectangle (0, 0, (int)vBounds.size.width, -YAmount), true);
+				Invalidate (hwnd, new Rectangle (0, 0, (int)vBounds.size.width, -YAmount), clear);
 			}
 
 			if (XAmount > 0) {
-				Invalidate (hwnd, new Rectangle (0, 0, XAmount, (int)vBounds.size.height), true);
+				Invalidate (hwnd, new Rectangle (0, 0, XAmount, (int)vBounds.size.height), clear);
 			} else if (XAmount < 0) {
-				Invalidate (hwnd, new Rectangle ((int)(vBounds.size.width+XAmount), 0, (int)vBounds.size.width, (int)vBounds.size.height), true);
+				Invalidate (hwnd, new Rectangle ((int)(vBounds.size.width+XAmount), 0, (int)vBounds.size.width, (int)vBounds.size.height), clear);
 			}
 		}
 

+ 22 - 2
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs

@@ -324,6 +324,7 @@ namespace System.Windows.Forms {
 
 		[Flags]
 		private enum ScrollWindowExFlags {
+			SW_NONE				= 0x0000,
 			SW_SCROLLCHILDREN		= 0x0001,
 			SW_INVALIDATE			= 0x0002,
 			SW_ERASE			= 0x0004,
@@ -1057,8 +1058,21 @@ namespace System.Windows.Forms {
 			return true;
 		}
 
-		internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount) {
-			Win32ScrollWindowEx(hwnd, XAmount, YAmount, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ScrollWindowExFlags.SW_INVALIDATE | ScrollWindowExFlags.SW_ERASE);
+		internal override void ScrollWindow(IntPtr hwnd, Rectangle rectangle, int XAmount, int YAmount, bool clear) {
+			RECT	rect;
+
+			rect = new RECT();
+			rect.left = rectangle.X;
+			rect.top = rectangle.Y;
+			rect.right = rectangle.Right;
+			rect.bottom = rectangle.Bottom;
+
+			Win32ScrollWindowEx(hwnd, XAmount, YAmount, ref rect, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, clear ? (ScrollWindowExFlags.SW_INVALIDATE | ScrollWindowExFlags.SW_ERASE) : ScrollWindowExFlags.SW_NONE);
+			Win32UpdateWindow(hwnd);
+		}
+
+		internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
+			Win32ScrollWindowEx(hwnd, XAmount, YAmount, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, clear ? (ScrollWindowExFlags.SW_INVALIDATE | ScrollWindowExFlags.SW_ERASE) : ScrollWindowExFlags.SW_NONE);
 		}
 
 
@@ -1283,6 +1297,12 @@ namespace System.Windows.Forms {
 		[DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
 		private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, ref RECT prcScroll, ref RECT prcClip, IntPtr hrgnUpdate, out RECT prcUpdate, ScrollWindowExFlags flags);
 
+		[DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
+		private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, ref RECT prcScroll, ref RECT prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, ScrollWindowExFlags flags);
+
+		[DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
+		private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, ref RECT prcScroll, IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, ScrollWindowExFlags flags);
+
 		[DllImport ("user32.dll", EntryPoint="ScrollWindowEx", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
 		private extern static bool Win32ScrollWindowEx(IntPtr hwnd, int dx, int dy, IntPtr prcScroll, IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, ScrollWindowExFlags flags);
 

+ 34 - 7
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

@@ -1787,7 +1787,34 @@ namespace System.Windows.Forms {
 			return GetFontMetrics(g.GetHdc(), font.ToHfont(), out ascent, out descent);
 		}
 
-		internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount) {
+		internal override void ScrollWindow(IntPtr hwnd, Rectangle area, int XAmount, int YAmount, bool clear) {
+			IntPtr		gc;
+			XGCValues	gc_values;
+
+			gc_values = new XGCValues();
+
+			gc = XCreateGC(DisplayHandle, hwnd, 0, ref gc_values);
+
+			XCopyArea(DisplayHandle, hwnd, hwnd, gc, area.X - XAmount, area.Y - YAmount, area.Width, area.Height, area.X, area.Y);
+
+			// Generate an expose for the area exposed by the horizontal scroll
+			if (XAmount > 0) {
+				XClearArea(DisplayHandle, hwnd, area.X, area.Y, XAmount, area.Height, clear);
+			} else if (XAmount < 0) {
+				XClearArea(DisplayHandle, hwnd, XAmount + area.X + area.Width, area.Y, -XAmount, area.Height, clear);
+			}
+
+			// Generate an expose for the area exposed by the vertical scroll
+			if (YAmount > 0) {
+				XClearArea(DisplayHandle, hwnd, area.X, area.Y, area.Width, YAmount, clear);
+			} else if (YAmount < 0) {
+				XClearArea(DisplayHandle, hwnd, area.X, YAmount + area.Y + area.Height, area.Width, -YAmount, clear);
+			}
+
+			XFreeGC(DisplayHandle, gc);
+		}
+
+		internal override void ScrollWindow(IntPtr hwnd, int XAmount, int YAmount, bool clear) {
 			IntPtr		gc;
 			XGCValues	gc_values;
 			IntPtr		root;
@@ -1809,16 +1836,16 @@ namespace System.Windows.Forms {
 
 			// Generate an expose for the area exposed by the horizontal scroll
 			if (XAmount > 0) {
-				XClearArea(DisplayHandle, hwnd, 0, 0, XAmount, height, true);
-			} else {
-				XClearArea(DisplayHandle, hwnd, XAmount + width, 0, -XAmount, height, true);
+				XClearArea(DisplayHandle, hwnd, 0, 0, XAmount, height, clear);
+			} else if (XAmount < 0) {
+				XClearArea(DisplayHandle, hwnd, XAmount + width, 0, -XAmount, height, clear);
 			}
 
 			// Generate an expose for the area exposed by the vertical scroll
 			if (YAmount > 0) {
-				XClearArea(DisplayHandle, hwnd, 0, 0, width, YAmount, true);
-			} else {
-				XClearArea(DisplayHandle, hwnd, 0, YAmount + height, width, -YAmount, true);
+				XClearArea(DisplayHandle, hwnd, 0, 0, width, YAmount, clear);
+			} else if (YAmount < 0) {
+				XClearArea(DisplayHandle, hwnd, 0, YAmount + height, width, -YAmount, clear);
 			}
 
 			XFreeGC(DisplayHandle, gc);