Browse Source

2005-09-20 Peter Dennis Bartok <[email protected]>

	* Control.cs, TextBoxBase.cs, TextControl.cs: Don't do certain
	  things if our window handle isn't created yet. Also disabled 
	  debug for TextBoxBase


svn path=/trunk/mcs/; revision=50346
Peter Dennis Bartok 20 years ago
parent
commit
041916ec80

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

@@ -1,3 +1,9 @@
+2005-09-20  Peter Dennis Bartok  <[email protected]>
+
+	* Control.cs, TextBoxBase.cs, TextControl.cs: Don't do certain
+	  things if our window handle isn't created yet. Also disabled 
+	  debug for TextBoxBase
+
 2005-09-20  Peter Dennis Bartok  <[email protected]> 
 
 	* MenuAPI.cs: Remove filtering of events to allow menu usage

+ 13 - 6
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs

@@ -3174,12 +3174,16 @@ namespace System.Windows.Forms
 		protected virtual void SetVisibleCore(bool value) {
 			if (value!=is_visible) {
 				is_visible=value;
-				XplatUI.SetVisible(Handle, value);
-				// Explicitly move Toplevel windows to where we want them;
-				// apparently moving unmapped toplevel windows doesn't work
-				if (is_visible && (this is Form)) {
-					XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
+
+				if (IsHandleCreated) {
+					XplatUI.SetVisible(Handle, value);
+					// Explicitly move Toplevel windows to where we want them;
+					// apparently moving unmapped toplevel windows doesn't work
+					if (is_visible && (this is Form)) {
+						XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
+					}
 				}
+
 				OnVisibleChanged(EventArgs.Empty);
 
 				if (!is_visible) {
@@ -3194,7 +3198,6 @@ namespace System.Windows.Forms
 					}
 				} else {
 					this.CreateBuffers(bounds.Width, bounds.Height);
-
 					CreateControl();
 				}
 
@@ -3309,6 +3312,10 @@ namespace System.Windows.Forms
 				XplatUI.SetZOrder(ctl.child_controls[i].window.Handle, ctl.child_controls[i-1].window.Handle, false, false); 
 			}
 #else
+			if (!IsHandleCreated) {
+				return;
+			}
+
 			children = child_controls.Count;
 			for (int i = 1; i < children; i++ ) {
 				XplatUI.SetZOrder(child_controls[i].Handle, child_controls[i-1].Handle, false, false); 

+ 7 - 4
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

@@ -25,7 +25,7 @@
 //
 
 // NOT COMPLETE
-#define Debug
+#undef Debug
 
 using System.ComponentModel;
 using System.ComponentModel.Design;
@@ -84,7 +84,7 @@ namespace System.Windows.Forms {
 			modified = false;
 			multiline = false;
 			read_only = false;
-			word_wrap = false;
+			word_wrap = true;
 			richtext = false;
 			document = new Document(this);
 			document.WidthChanged += new EventHandler(document_WidthChanged);
@@ -340,9 +340,9 @@ namespace System.Windows.Forms {
 				document.multiline = multiline;
 
 				if (multiline) {
-					document.wrap = word_wrap;
+					document.Wrap = word_wrap;
 				} else {
-					document.wrap = false;
+					document.Wrap = false;
 				}
 			}
 		}
@@ -1172,6 +1172,9 @@ static int current;
 		}
 
 		protected void CalculateDocument() {
+			if (!IsHandleCreated) {
+				return;
+			}
 			document.RecalculateDocument(CreateGraphics());
 			CalculateScrollBars();
 //blah Console.WriteLine("TextBox.cs(1175) Invalidate called in CalculateDocument");

+ 16 - 4
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

@@ -573,9 +573,8 @@ namespace System.Windows.Forms {
 			last_found = sentinel;
 
 			// We always have a blank line
+			owner.HandleCreated += new EventHandler(owner_HandleCreated);
 			Add(1, "", owner.Font, new SolidBrush(owner.ForeColor));
-			this.RecalculateDocument(owner.CreateGraphics());
-			PositionCaret(0, 0);
 			lines=1;
 
 			selection_visible = false;
@@ -706,7 +705,6 @@ namespace System.Windows.Forms {
 
 			set {
 				wrap = value;
-				// FIXME - force recalc/redisplay
 			}
 		}
 
@@ -957,6 +955,10 @@ namespace System.Windows.Forms {
 
 
 		internal void UpdateView(Line line, int pos) {
+			if (!owner.IsHandleCreated) {
+				return;
+			}
+
 			if (RecalculateDocument(owner.CreateGraphics(), line.line_no, line.line_no, true)) {
 				// Lineheight changed, invalidate the rest of the document
 				if ((line.Y - viewport_y) >=0 ) {
@@ -1066,6 +1068,10 @@ namespace System.Windows.Forms {
 		}
 
 		internal void AlignCaret() {
+			if (!owner.IsHandleCreated) {
+				return;
+			}
+
 			caret.tag = LineTag.FindTag(caret.line, caret.pos);
 			caret.height = caret.tag.height;
 
@@ -1828,6 +1834,7 @@ namespace System.Windows.Forms {
 			if (soft && (caret.line == line) && (caret.pos >= pos)) {
 				move_caret = true;
 			}
+			// FIXME - what about selection?
 
 			// cover the easy case first
 			if (pos == line.text.Length) {
@@ -2847,6 +2854,11 @@ namespace System.Windows.Forms {
 		internal int Size() {
 			return lines;
 		}
+
+		private void owner_HandleCreated(object sender, EventArgs e) {
+			this.RecalculateDocument(owner.CreateGraphics());
+			PositionCaret(0, 0);
+		}
 		#endregion	// Internal Methods
 
 		#region Events
@@ -2888,7 +2900,7 @@ namespace System.Windows.Forms {
 		public override string ToString() {
 			return "document " + this.document_id;
 		}
-		#endregion	// Administrative
+		#endregion	// Administrative
 	}
 
 	internal class LineTag {