diff options
author | Peter Dennis Bartok <pbartok@mono-cvs.ximian.com> | 2006-02-28 04:40:04 +0300 |
---|---|---|
committer | Peter Dennis Bartok <pbartok@mono-cvs.ximian.com> | 2006-02-28 04:40:04 +0300 |
commit | e06fd0b53d69263f0568b0ff73c31637f76525c5 (patch) | |
tree | e85d891c5509c410c02ba7a25bc03c94efdcc203 /mcs | |
parent | 1b88f8ea789ac56f768d9964e64dfd528f524c14 (diff) |
2006-02-27 Peter Dennis Bartok <pbartok@novell.com>
* TextControl.cs: Added property and implemented means to allow
disabling recalculation of a document (can be used to speed up
multiple inserts and is needed to make RTF inserts predictable, see
bug #77659)
* RichTextBox.cs: Using the new NoRecalc property of Document to
keep x/y insert locations predictable. Also makes it faster inserting
large chunks of RTF
svn path=/trunk/mcs/; revision=57366
Diffstat (limited to 'mcs')
3 files changed, 66 insertions, 0 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 835bb1f15cd..9e7f3a5d6ba 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,13 @@ +2006-02-27 Peter Dennis Bartok <pbartok@novell.com> + + * TextControl.cs: Added property and implemented means to allow + disabling recalculation of a document (can be used to speed up + multiple inserts and is needed to make RTF inserts predictable, see + bug #77659) + * RichTextBox.cs: Using the new NoRecalc property of Document to + keep x/y insert locations predictable. Also makes it faster inserting + large chunks of RTF + 2006-02-27 Peter Dennis Bartok <pbartok@novell.com> * Control.cs: Separated special WM_SYSKEYUP keyboard handling. That way diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs index 6662c87d5dd..1fc221f6bc4 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs @@ -1352,6 +1352,8 @@ namespace System.Windows.Forms { rtf_text_map = new RTF.TextMap(); RTF.TextMap.SetupStandardTable(rtf_text_map.Table); + document.NoRecalc = true; + try { rtf.Read(); // That's it FlushText(rtf, false); @@ -1366,6 +1368,8 @@ namespace System.Windows.Forms { to_y = rtf_cursor_y; document.RecalculateDocument(CreateGraphics(), cursor_y, document.Lines, false); + document.NoRecalc = false; + document.Invalidate(document.GetLine(cursor_y), 0, document.GetLine(document.Lines), -1); } diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs index 69a447c6144..98960cb1c0a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs @@ -726,6 +726,12 @@ namespace System.Windows.Forms { private bool calc_pass; private int char_count; + private bool no_recalc; + private bool recalc_pending; + private int recalc_start; + private int recalc_end; + private bool recalc_optimize; + internal bool multiline; internal bool wrap; @@ -763,6 +769,8 @@ namespace System.Windows.Forms { multiline = true; password_char = ""; calc_pass = false; + no_recalc = false; + recalc_pending = false; // Tree related stuff sentinel = new Line(); @@ -908,6 +916,22 @@ namespace System.Windows.Forms { } } + ///<summary>Setting NoRecalc to true will prevent the document from being recalculated. + ///This ensures that coordinates of added text are predictable after adding the text even with wrapped view</summary> + internal bool NoRecalc { + get { + return no_recalc; + } + + set { + no_recalc = value; + if (!no_recalc && recalc_pending) { + RecalculateDocument(owner.CreateGraphics(), recalc_start, recalc_end, recalc_optimize); + recalc_pending = false; + } + } + } + internal int ViewPortY { get { return viewport_y; @@ -1247,6 +1271,14 @@ namespace System.Windows.Forms { return; } + if (no_recalc) { + recalc_start = line.line_no; + recalc_end = line.line_no; + recalc_optimize = true; + recalc_pending = true; + 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 ) { @@ -1264,6 +1296,18 @@ namespace System.Windows.Forms { // Update display from line, down line_count lines; pos is unused, but required for the signature internal void UpdateView(Line line, int line_count, int pos) { + if (!owner.IsHandleCreated) { + return; + } + + if (no_recalc) { + recalc_start = line.line_no; + recalc_end = line.line_no + line_count - 1; + recalc_optimize = true; + recalc_pending = true; + return; + } + if (RecalculateDocument(owner.CreateGraphics(), line.line_no, line.line_no + line_count - 1, true)) { // Lineheight changed, invalidate the rest of the document if ((line.Y - viewport_y) >=0 ) { @@ -3442,6 +3486,14 @@ namespace System.Windows.Forms { bool changed; int shift; + if (no_recalc) { + recalc_pending = true; + recalc_start = start; + recalc_end = end; + recalc_optimize = optimize; + return false; + } + Y = GetLine(start).Y; line_no = start; new_width = 0; |