Browse Source

* TextBox.cs: Reduce the amount of invalidation we do.
* TextBoxBase.cs: Make shortcuts enabled true by default, at
* least
some of them are true by default on MS.
- Add some functions to reduce the amount of invalidates we do.
* TextControl.cs: Less invalidation.


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

Jackson Harper 19 years ago
parent
commit
aff37c7788

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

@@ -1,3 +1,11 @@
+2007-03-19  Jackson Harper  <[email protected]>
+
+	* TextBox.cs: Reduce the amount of invalidation we do.
+	* TextBoxBase.cs: Make shortcuts enabled true by default, at least
+	some of them are true by default on MS.
+	- Add some functions to reduce the amount of invalidates we do.
+	* TextControl.cs: Less invalidation.
+
 2007-03-19  Chris Toshok  <[email protected]>
 
 	[ Fixes #81773, and *seems* to fix #81553 as well ]

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

@@ -95,7 +95,8 @@ namespace System.Windows.Forms {
 
 		#region Private & Internal Methods
 		private void TextBox_LostFocus(object sender, EventArgs e) {
-			Invalidate();
+			if (hide_selection)
+				document.InvalidateSelectionArea ();
 		}
 #if NET_2_0
 		void OnAutoCompleteCustomSourceChanged(object sender, CollectionChangeEventArgs e) {
@@ -338,7 +339,7 @@ namespace System.Windows.Forms {
 
 		protected override void OnHandleCreated(EventArgs e) {
 			base.OnHandleCreated (e);
-			SelectAll ();
+			SelectAllNoInvalidate ();
 		}
 
 		protected override void OnMouseUp(MouseEventArgs e) {

+ 20 - 8
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

@@ -75,7 +75,7 @@ namespace System.Windows.Forms {
 		internal CaretSelection		click_mode;
 		internal Bitmap			bmp;
 		internal BorderStyle actual_border_style;
-		internal bool shortcuts_enabled;
+		internal bool shortcuts_enabled = true;
 		#if Debug
 		internal static bool	draw_lines = false;
 		#endif
@@ -535,12 +535,12 @@ namespace System.Windows.Forms {
 					start = document.LineTagToCharIndex(document.selection_start.line, document.selection_start.pos);
 
 					document.CharIndexToLineTag(start + value, out line, out tag, out pos);
-					document.SetSelectionEnd(line, pos);
+					document.SetSelectionEnd(line, pos, true);
 					document.PositionCaret(line, pos);
 				} else {
 					selection_length = -1;
 
-					document.SetSelectionEnd(document.selection_start.line, document.selection_start.pos);
+					document.SetSelectionEnd(document.selection_start.line, document.selection_start.pos, true);
 					document.PositionCaret(document.selection_start.line, document.selection_start.pos);
 				}
 			}
@@ -558,11 +558,11 @@ namespace System.Windows.Forms {
 			}
 
 			set {
-				document.SetSelectionStart(value);
+				document.SetSelectionStart(value, false);
 				if (selection_length > -1 ) {
-					document.SetSelectionEnd(value + selection_length);
+					document.SetSelectionEnd(value + selection_length, true);
 				} else {
-					document.SetSelectionEnd(value);
+					document.SetSelectionEnd(value, true);
 				}
 				document.PositionCaret(document.selection_start.line, document.selection_start.pos);
 				ScrollToCaret();
@@ -729,8 +729,20 @@ namespace System.Windows.Forms {
 			Line	last;
 
 			last = document.GetLine(document.Lines);
-			document.SetSelectionStart(document.GetLine(1), 0);
-			document.SetSelectionEnd(last, last.text.Length);
+			document.SetSelectionStart(document.GetLine(1), 0, false);
+			document.SetSelectionEnd(last, last.text.Length, true);
+			document.PositionCaret (document.selection_end.line, document.selection_end.pos);
+			selection_length = -1;
+		}
+
+		/// Sync with above (except the invalidation of course)
+		internal void SelectAllNoInvalidate ()
+		{
+			Line last;
+
+			last = document.GetLine(document.Lines);
+			document.SetSelectionStart(document.GetLine(1), 0, false);
+			document.SetSelectionEnd(last, last.text.Length, false);
 			document.PositionCaret (document.selection_end.line, document.selection_end.pos);
 			selection_length = -1;
 		}

+ 15 - 12
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

@@ -1515,7 +1515,7 @@ namespace System.Windows.Forms {
 				DisplayCaret ();
 			}
 
-			if (owner.IsHandleCreated && selection_visible) {
+			if (owner.IsHandleCreated && owner.selection_length > 0) {
 				InvalidateSelectionArea ();
 			}
 		}
@@ -3243,9 +3243,10 @@ namespace System.Windows.Forms {
 			}
 		}
 
-		internal void SetSelectionStart(Line start, int start_pos) {
+		internal void SetSelectionStart(Line start, int start_pos, bool invalidate) {
 			// Invalidate from the previous to the new start pos
-			Invalidate(selection_start.line, selection_start.pos, start, start_pos);
+			if (invalidate)
+				Invalidate(selection_start.line, selection_start.pos, start, start_pos);
 
 			selection_start.line = start;
 			selection_start.pos = start_pos;
@@ -3264,10 +3265,11 @@ namespace System.Windows.Forms {
 				SetSelectionVisible (false);
 			}
 
-			Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+			if (invalidate)
+				Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
 		}
 
-		internal void SetSelectionStart(int character_index) {
+		internal void SetSelectionStart(int character_index, bool invalidate) {
 			Line	line;
 			LineTag	tag;
 			int	pos;
@@ -3277,10 +3279,10 @@ namespace System.Windows.Forms {
 			}
 
 			CharIndexToLineTag(character_index, out line, out tag, out pos);
-			SetSelectionStart(line, pos);
+			SetSelectionStart(line, pos, invalidate);
 		}
 
-		internal void SetSelectionEnd(Line end, int end_pos) {
+		internal void SetSelectionEnd(Line end, int end_pos, bool invalidate) {
 
 			if (end == selection_end.line && end_pos == selection_start.pos) {
 				selection_anchor.line = selection_start.line;
@@ -3316,14 +3318,15 @@ namespace System.Windows.Forms {
 
 			if ((selection_end.line != selection_start.line) || (selection_end.pos != selection_start.pos)) {
 				SetSelectionVisible (true);
-				Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
+				if (invalidate)
+					Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos);
 			} else {
 				SetSelectionVisible (false);
 				// ?? Do I need to invalidate here, tests seem to work without it, but I don't think they should :-s
 			}
 		}
 
-		internal void SetSelectionEnd(int character_index) {
+		internal void SetSelectionEnd(int character_index, bool invalidate) {
 			Line	line;
 			LineTag	tag;
 			int	pos;
@@ -3333,7 +3336,7 @@ namespace System.Windows.Forms {
 			}
 
 			CharIndexToLineTag(character_index, out line, out tag, out pos);
-			SetSelectionEnd(line, pos);
+			SetSelectionEnd(line, pos, invalidate);
 		}
 
 		internal void SetSelection(Line start, int start_pos) {
@@ -5201,8 +5204,8 @@ namespace System.Windows.Forms {
 				document.Combine(line.line_no, line.line_no + 1);
 
 				if (select) {
-					document.SetSelectionStart (line, pos);
-					document.SetSelectionEnd (line, pos + insert.text.Length);
+					document.SetSelectionStart (line, pos, false);
+					document.SetSelectionEnd (line, pos + insert.text.Length, false);
 				}
 
 				document.UpdateView(line, pos);