+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
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);
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);
}
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;
multiline = true;
password_char = "";
calc_pass = false;
+ no_recalc = false;
+ recalc_pending = false;
// Tree related stuff
sentinel = new Line();
}
}
+ ///<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;
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 ) {
// 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 ) {
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;