فهرست منبع

2005-06-22 Peter Bartok <[email protected]>

	* TextControl.cs: Added sanity check
	* TextBoxBase.cs: 
	  - Fixed wrapping behaviour, don't set wrap on single line controls
	    (this fixes the breakage of colordialog introduced in an earlier
	     checkin)
	  - Added rudimentary support for autoscrolling right-aligned controls
	    (still needs fixing, also, center alignment scroll is missing)


svn path=/trunk/mcs/; revision=46375
Peter Dennis Bartok 20 سال پیش
والد
کامیت
d792d226bc

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

@@ -1,3 +1,13 @@
+2005-06-22  Peter Bartok  <[email protected]> 
+
+	* TextControl.cs: Added sanity check
+	* TextBoxBase.cs: 
+	  - Fixed wrapping behaviour, don't set wrap on single line controls
+	    (this fixes the breakage of colordialog introduced in an earlier
+	     checkin)
+	  - Added rudimentary support for autoscrolling right-aligned controls
+	    (still needs fixing, also, center alignment scroll is missing)
+
 2005-06-22  Jordi Mas i Hernandez <[email protected]>
 	
 	* ScrollBar.cs: Fixes thumbpos on Maximum values

+ 47 - 21
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

@@ -84,12 +84,12 @@ namespace System.Windows.Forms {
 			modified = false;
 			multiline = false;
 			read_only = false;
-			word_wrap = true;
+			word_wrap = false;
 			richtext = false;
 			document = new Document(this);
 			document.WidthChanged += new EventHandler(document_WidthChanged);
 			//document.CaretMoved += new EventHandler(CaretMoved);
-			document.Wrap = true;
+			document.Wrap = false;
 			requested_height = -1;
 
 			MouseDown += new MouseEventHandler(TextBoxBase_MouseDown);
@@ -328,7 +328,6 @@ namespace System.Windows.Forms {
 			set {
 				if (value != multiline) {
 					multiline = value;
-
 					// Make sure we update our size; the user may have already set the size before going to multiline
 					if (multiline && requested_height != -1) {
 						Height = requested_height;
@@ -339,6 +338,12 @@ namespace System.Windows.Forms {
 				}
 
 				document.multiline = multiline;
+
+				if (multiline) {
+					document.wrap = word_wrap;
+				} else {
+					document.wrap = false;
+				}
 			}
 		}
 
@@ -521,8 +526,10 @@ namespace System.Windows.Forms {
 
 			set {
 				if (value != word_wrap) {
-					word_wrap = value;
-					document.Wrap = value;
+					if (multiline) {
+						word_wrap = value;
+						document.Wrap = value;
+					}
 				}
 			}
 		}
@@ -898,6 +905,7 @@ namespace System.Windows.Forms {
 						document.DeleteChar(document.CaretTag, document.CaretPosition, true);
 						OnTextChanged(EventArgs.Empty);
 					}
+					document.UpdateCaret();
 					CaretMoved(this, null);
 					return true;
 				}
@@ -917,8 +925,8 @@ namespace System.Windows.Forms {
 				}
 			}
 
-			document.ViewPortWidth = this.Width;
-			document.ViewPortHeight = this.Height;
+			document.ViewPortWidth = width;
+			document.ViewPortHeight = height;
 
 			CalculateDocument();
 
@@ -1167,12 +1175,14 @@ static int current;
 		}
 
 		protected void CalculateScrollBars() {
+			// FIXME - need separate calculations for center and right alignment
 			// No scrollbars for a single line
 			if (document.Width >= this.Width) {
 				hscroll.Enabled = true;
 				hscroll.Minimum = 0;
 				hscroll.Maximum = document.Width - this.Width;
 			} else {
+				hscroll.Maximum = document.ViewPortWidth;
 				hscroll.Enabled = false;
 			}
 
@@ -1181,6 +1191,7 @@ static int current;
 				vscroll.Minimum = 0;
 				vscroll.Maximum = document.Height - this.Height;
 			} else {
+				vscroll.Maximum = document.ViewPortHeight;
 				vscroll.Enabled = false;
 			}
 
@@ -1263,24 +1274,39 @@ static int current;
 			//Console.WriteLine("Caret now at {0} (Thumb: {1}x{2}, Canvas: {3}x{4}, Document {5}x{6})", pos, hscroll.Value, vscroll.Value, canvas_width, canvas_height, document.Width, document.Height);
 
 			// Handle horizontal scrolling
-			if (pos.X < (document.ViewPortX + track_width)) {
-				do {
-					if ((hscroll.Value - track_width) >= hscroll.Minimum) {
-						hscroll.Value -= track_width;
+			if (document.CaretLine.alignment == HorizontalAlignment.Left) {
+				if (pos.X < (document.ViewPortX + track_width)) {
+					do {
+						if ((hscroll.Value - track_width) >= hscroll.Minimum) {
+							hscroll.Value -= track_width;
+						} else {
+							hscroll.Value = hscroll.Minimum;
+						}
+					} while (hscroll.Value > pos.X);
+				}
+
+				if ((pos.X > (this.canvas_width + document.ViewPortX - track_width)) && (hscroll.Value != hscroll.Maximum)) {
+					do {
+						if ((hscroll.Value + track_width) <= hscroll.Maximum) {
+							hscroll.Value += track_width;
+						} else {
+							hscroll.Value = hscroll.Maximum;
+						}
+					} while (pos.X > (hscroll.Value + this.canvas_width));
+				}
+			} else if (document.CaretLine.alignment == HorizontalAlignment.Right) {
+				if (pos.X < document.ViewPortX) {
+					if (pos.X > hscroll.Minimum) {
+						hscroll.Value = pos.X;
 					} else {
 						hscroll.Value = hscroll.Minimum;
 					}
-				} while (hscroll.Value > pos.X);
-			}
+				}
 
-			if ((pos.X > (this.canvas_width + document.ViewPortX - track_width)) && (hscroll.Value != hscroll.Maximum)) {
-				do {
-					if ((hscroll.Value + track_width) <= hscroll.Maximum) {
-						hscroll.Value += track_width;
-					} else {
-						hscroll.Value = hscroll.Maximum;
-					}
-				} while (pos.X > (hscroll.Value + this.canvas_width));
+				if ((pos.X > (this.canvas_width + document.ViewPortX)) && (hscroll.Value != hscroll.Maximum)) {
+					hscroll.Value = hscroll.Maximum;
+				}
+			} else {
 			}
 
 			if (!multiline) {

+ 2 - 3
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

@@ -31,7 +31,6 @@
 // Stuff missing (in no particular order):
 // - Align text after RecalculateLine
 // - Implement tag types to support wrapping (ie have a 'newline' tag), for images, etc.
-// - Wrap and recalculate lines
 // - Implement CaretPgUp/PgDown
 // - Finish selection calculations (invalidate only changed, more ways to select)
 // - Implement C&P
@@ -568,7 +567,7 @@ namespace System.Windows.Forms {
 			selection_end.line = this.document;
 			selection_end.pos = 0;
 
-			viewport_x = -2;
+			viewport_x = 0;
 			viewport_y = -2;
 
 			// Default selection is empty
@@ -2514,7 +2513,7 @@ if (end != null) {
 			while (line_no <= lines) {
 				line = GetLine(line_no);
 
-				if (line.alignment != HorizontalAlignment.Left) {
+				if (line != null && line.alignment != HorizontalAlignment.Left) {
 					if (line.alignment == HorizontalAlignment.Center) {
 						line.align_shift = (viewport_width - (int)line.widths[line.text.Length]) / 2;
 					} else {