[Mono-winforms-list] patch

Aleksey Ryabchuk ryabchuk@yahoo.com
Wed, 9 Apr 2003 03:56:43 -0700 (PDT)


--0-982347424-1049885803=:2609
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

Hello all,

This patch makes possible to CreateControl even if the
real parent has not been assigned yet. It uses
invisible "parkingWindow". It also fixes flickering
problem.

It will be needed to update the rest of controls, so
they will use the base implementation of CreateParams.

Regards
Aleksey



__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--0-982347424-1049885803=:2609
Content-Type: text/plain; name=patch
Content-Description: patch
Content-Disposition: inline; filename=patch

Index: Control.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs,v
retrieving revision 1.34
diff -u -r1.34 Control.cs
--- Control.cs	8 Apr 2003 02:41:37 -0000	1.34
+++ Control.cs	9 Apr 2003 10:46:54 -0000
@@ -6,6 +6,7 @@
     //	Dennis Hayes (dennish@rayetk.com)
     //   WINELib implementation started by John Sohn (jsohn@columbus.rr.com)
     //	 Alexandre Pigolkine (pigolkine@gmx.de)
+    //	Aleksey Ryabchuk (ryabchuk@yahoo.com)
     //
     // (C) Ximian, Inc., 2002
     //
@@ -51,6 +52,7 @@
     		private ControlCollection childControls;
     		private Control parent;
     		static private Hashtable controlsCollection = new Hashtable ();
+		static private NativeWindow parkingWindow = null;
 
     		// private fields
     		// it seems these are stored in case the window is not created,
@@ -195,7 +197,10 @@
     			parent = null;
 			isDisposed = false;
 
-				mouseIsInside_ = false;
+			bounds.Width = DefaultSize.Width;
+			bounds.Height= DefaultSize.Height;
+
+			mouseIsInside_ = false;
 				recreatingHandle = false;
 				// Do not create Handle here, only in CreateHandle
     			// CreateHandle();//sets window handle. FIXME: No it does not
@@ -533,7 +538,6 @@
     			get {
   					CreateParams createParams = new CreateParams ();
   					createParams.Caption = Text;
-  					createParams.ClassName = "CONTROL";
   					createParams.X = Left;
   					createParams.Y = Top;
   					createParams.Width = Width;
@@ -545,7 +549,7 @@
   					if (parent != null)
   						createParams.Parent = parent.Handle;
   					else 
-  						createParams.Parent = (IntPtr) 0;
+  						createParams.Parent = ParkingWindowHandle;
 	  
   					createParams.Style = (int) WindowStyles.WS_OVERLAPPEDWINDOW;
 	  
@@ -899,6 +903,22 @@
     			}
     		}
     		
+		private static IntPtr ParkingWindowHandle {
+			get {
+				if ( parkingWindow == null )
+					parkingWindow = new NativeWindow ( );
+
+				if ( parkingWindow.Handle == IntPtr.Zero ) {
+					CreateParams pars = new CreateParams ( );
+					pars.ClassName = "mono_native_window";
+					pars.Style = (int) WindowStyles.WS_OVERLAPPED;
+					parkingWindow.CreateHandle ( pars );
+				}
+
+				return parkingWindow.Handle;
+			}
+		}
+
     		[MonoTODO]
     		public string ProductName {
     			get {
@@ -2947,7 +2967,7 @@
     			public virtual void Add (Control value) 
     			{
 					if( !Contains(value)) {
-						value.parent = owner;
+						value.Parent = owner;
 						collection.Add (value);
 					}
 				}
Index: DateTimePicker.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/DateTimePicker.cs,v
retrieving revision 1.13
diff -u -r1.13 DateTimePicker.cs
--- DateTimePicker.cs	8 Apr 2003 02:27:00 -0000	1.13
+++ DateTimePicker.cs	9 Apr 2003 10:46:54 -0000
@@ -76,7 +76,6 @@
 			showCheckBox = false;
 			showUpDown = false;
 			val = DateTime.Now;
-			Size = DefaultSize;
 		}
 
 		[MonoTODO]
@@ -435,39 +434,28 @@
 		[MonoTODO]
 		protected override CreateParams CreateParams {
 			get {
-				if ( Parent != null ) {
-					CreateParams createParams = new CreateParams ();
+				CreateParams createParams = base.CreateParams;
 
-					createParams.Caption = Text;
-					createParams.ClassName = "SysDateTimePick32";
-					createParams.X = Left;
-					createParams.Y = Top;
-					createParams.Width = Width;
-					createParams.Height = Height;
-					createParams.ClassStyle = 0;
-					createParams.ExStyle = 0;
-					createParams.Param = 0;
-					createParams.Parent = Parent.Handle;
-					createParams.Style = (int) (
-						WindowStyles.WS_CHILDWINDOW | 
-						WindowStyles.WS_VISIBLE |
-						WindowStyles.WS_CLIPCHILDREN|
-						WindowStyles.WS_CLIPSIBLINGS);
-					
-					if ( ShowUpDown )
-						createParams.Style |= (int) DateTimePickerControlStyles.DTS_UPDOWN;
-
-					if ( ShowCheckBox )
-						createParams.Style |= (int) DateTimePickerControlStyles.DTS_SHOWNONE;
+				createParams.ClassName = "SysDateTimePick32";
 
-					if ( DropDownAlign == LeftRightAlignment.Right )
-						createParams.Style |= (int) DateTimePickerControlStyles.DTS_RIGHTALIGN;
+				createParams.Style = (int) (
+					WindowStyles.WS_CHILDWINDOW | 
+					WindowStyles.WS_VISIBLE |
+					WindowStyles.WS_CLIPCHILDREN|
+					WindowStyles.WS_CLIPSIBLINGS);
+				
+				if ( ShowUpDown )
+					createParams.Style |= (int) DateTimePickerControlStyles.DTS_UPDOWN;
 
-					createParams.Style |= formatStyle ( Format );
+				if ( ShowCheckBox )
+					createParams.Style |= (int) DateTimePickerControlStyles.DTS_SHOWNONE;
 
-					return createParams;
-				}
-				return null;
+				if ( DropDownAlign == LeftRightAlignment.Right )
+					createParams.Style |= (int) DateTimePickerControlStyles.DTS_RIGHTALIGN;
+
+				createParams.Style |= formatStyle ( Format );
+
+				return createParams;
 			}		
 		}
 
Index: Form.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/Form.cs,v
retrieving revision 1.34
diff -u -r1.34 Form.cs
--- Form.cs	8 Apr 2003 02:41:37 -0000	1.34
+++ Form.cs	9 Apr 2003 10:46:55 -0000
@@ -628,9 +628,13 @@
 					pars.ExStyle |= (int)WindowExStyles.WS_EX_MDICHILD;
 				}
 				else 
-					pars.Style |= (int)( WindowStyles.WS_OVERLAPPEDWINDOW | 
+					pars.Style = (int)( WindowStyles.WS_OVERLAPPEDWINDOW | 
 							WindowStyles.WS_CLIPSIBLINGS /* |
 							WindowStyles.WS_CLIPCHILDREN */);
+
+				if ( Parent == null ) 
+					pars.Parent = IntPtr.Zero;
+
 				// should have WS_CLIPCHILDREN style but there are
 				// problems with GroupBox at the moment
 
Index: ProgressBar.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/ProgressBar.cs,v
retrieving revision 1.8
diff -u -r1.8 ProgressBar.cs
--- ProgressBar.cs	8 Apr 2003 02:28:15 -0000	1.8
+++ ProgressBar.cs	9 Apr 2003 10:46:56 -0000
@@ -61,27 +61,17 @@
 		[MonoTODO]
 		protected override CreateParams CreateParams {
 			get {
-				if( Parent != null) {
-					CreateParams createParams = new CreateParams ();
+				CreateParams createParams = base.CreateParams;
 
-					createParams.Caption = Text;
-					createParams.ClassName = "msctls_progress32";
-					createParams.X = Left;
-					createParams.Y = Top;
-					createParams.Width = Width;
-					createParams.Height = Height;
-					createParams.ClassStyle = 0;
-					createParams.ExStyle = 0;
-					createParams.Param = 0;
-					createParams.Parent = Parent.Handle;
-					createParams.Style = (int) (
-						WindowStyles.WS_CHILD | 
-						WindowStyles.WS_VISIBLE |
-						WindowStyles.WS_CLIPCHILDREN |
-						WindowStyles.WS_CLIPSIBLINGS );
-					return createParams;
-				}
-				return null;
+				createParams.ClassName = "msctls_progress32";
+
+				createParams.Style = (int) (
+					WindowStyles.WS_CHILD | 
+					WindowStyles.WS_VISIBLE |
+					WindowStyles.WS_CLIPCHILDREN |
+					WindowStyles.WS_CLIPSIBLINGS );
+
+				return createParams;
 			}		
 		}
 
Index: ScrollableControl.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/ScrollableControl.cs,v
retrieving revision 1.19
diff -u -r1.19 ScrollableControl.cs
--- ScrollableControl.cs	8 Apr 2003 02:41:37 -0000	1.19
+++ ScrollableControl.cs	9 Apr 2003 10:46:57 -0000
@@ -93,7 +93,7 @@
 				if (!classRegistered) {
 					WNDCLASS wndClass = new WNDCLASS();
  
-					wndClass.style = (int) (CS_.CS_OWNDC | CS_.CS_VREDRAW | CS_.CS_HREDRAW);
+					wndClass.style = (int) (CS_.CS_OWNDC);
 					wndClass.lpfnWndProc = NativeWindow.GetWindowProc();
 					wndClass.cbClsExtra = 0;
 					wndClass.cbWndExtra = 0;
@@ -108,29 +108,13 @@
 						classRegistered = true; 
 				}		
 
-				CreateParams createParams = new CreateParams ();
+				CreateParams createParams = base.CreateParams;
 				createParams.Caption = "Hello World";
 				createParams.ClassName = "mono_scrollable_control";
-				createParams.X = Left;
-				createParams.Y = Top;
-				createParams.Width = Width;
-				createParams.Height = Height;
-				createParams.ClassStyle = 0;
-				createParams.ExStyle = 0;
-				createParams.Param = 0;
   				
-				createParams.Style = (int) (WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPCHILDREN);
+				createParams.Style = (int) (WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CHILD);
 				//test version with scroll bars.
 				//createParams.Style = (int) (WindowStyles.WS_OVERLAPPEDWINDOW | WindowStyles.WS_HSCROLL | WindowStyles.WS_VSCROLL);
-				
-				if (Parent != null) {
-					createParams.Parent = Parent.Handle;
-					createParams.Style |= (int) WindowStyles.WS_CHILD;
-				}
-				else {
-					createParams.Parent = (IntPtr) 0;
-					createParams.Style |= (int) WindowStyles.WS_OVERLAPPEDWINDOW;
-				}
 				
 				return createParams;			
 			}
Index: StatusBar.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs,v
retrieving revision 1.15
diff -u -r1.15 StatusBar.cs
--- StatusBar.cs	8 Apr 2003 02:28:15 -0000	1.15
+++ StatusBar.cs	9 Apr 2003 10:46:57 -0000
@@ -37,7 +37,6 @@
 			Dock = DockStyle.Bottom;
 			showPanels = false;
 			sizingGrip = true;
-			Size = DefaultSize;
 		}
 
 		public override string ToString()
@@ -231,18 +230,10 @@
 		[MonoTODO]
 		protected override CreateParams CreateParams {
 			get {
-				CreateParams createParams = new CreateParams ();
+				CreateParams createParams = base.CreateParams;
 
-				createParams.Caption = Text;
 				createParams.ClassName = "msctls_statusbar32";
-				createParams.X = Left;
-				createParams.Y = Top;
-				createParams.Width = Width;
-				createParams.Height = Height;
-				createParams.ClassStyle = 0;
-				createParams.ExStyle = 0;
-				createParams.Param = 0;
-				createParams.Parent = Parent.Handle;
+
 				createParams.Style = (int) (
 					WindowStyles.WS_CHILD | 
 					WindowStyles.WS_VISIBLE |
Index: StatusBarPanel.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs,v
retrieving revision 1.12
diff -u -r1.12 StatusBarPanel.cs
--- StatusBarPanel.cs	8 Apr 2003 02:28:15 -0000	1.12
+++ StatusBarPanel.cs	9 Apr 2003 10:46:57 -0000
@@ -178,7 +178,9 @@
 
 		public int GetContentWidth ( ) {
 			if( Parent != null) {
-				int cxsize = Win32.GetTextExtent( Parent.Handle, Text ).cx;
+				int cxsize = 0;
+				if ( Text != null )
+					cxsize = Win32.GetTextExtent( Parent.Handle, Text ).cx;
 				return cxsize < MinWidth ? MinWidth : cxsize;
 			}
 			return Width;
Index: TrackBar.cs
===================================================================
RCS file: /mono/mcs/class/System.Windows.Forms/System.Windows.Forms/TrackBar.cs,v
retrieving revision 1.16
diff -u -r1.16 TrackBar.cs
--- TrackBar.cs	8 Apr 2003 02:28:15 -0000	1.16
+++ TrackBar.cs	9 Apr 2003 10:46:58 -0000
@@ -34,7 +34,6 @@
 		[MonoTODO]
 		public TrackBar()
 		{
-			Size = DefaultSize;
 		}
 		//
 		// --- Public Properties
@@ -227,18 +226,10 @@
 		[MonoTODO]
 		protected override CreateParams CreateParams {
 			get {
-				CreateParams createParams = new CreateParams ();
+				CreateParams createParams = base.CreateParams;
 
-				createParams.Caption = Text;
 				createParams.ClassName = "msctls_trackbar32";
-				createParams.X = Left;
-				createParams.Y = Top;
-				createParams.Width = Width;
-				createParams.Height = Height;
-				createParams.ClassStyle = 0;
-				createParams.ExStyle = 0;
-				createParams.Param = 0;
-				createParams.Parent = Parent.Handle;
+
 				createParams.Style = (int) (
 					WindowStyles.WS_CHILD | 
 					WindowStyles.WS_VISIBLE) | GetTickStyle() | 

--0-982347424-1049885803=:2609--