2007-01-08 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / RichTextBox.cs
index 17b5752ed8761fc16612e900952a70e7aa6ce153..775b0c3c74afbec231aa9e4c677cc178604ffb25 100644 (file)
@@ -92,12 +92,10 @@ namespace System.Windows.Forms {
 
                #region Private & Internal Methods
                private void RichTextBox_LostFocus(object sender, EventArgs e) {
-                       has_focus = false;
                        Invalidate();
                }
 
                private void RichTextBox_GotFocus(object sender, EventArgs e) {
-                       has_focus = true;
                        Invalidate();
                }
                #endregion      // Private & Internal Methods
@@ -139,13 +137,8 @@ namespace System.Windows.Forms {
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Never)]
                public override System.Drawing.Image BackgroundImage {
-                       get {
-                               return background_image;
-                       }
-
-                       set {
-                               base.BackgroundImage = value;
-                       }
+                       get { return base.BackgroundImage; }
+                       set { base.BackgroundImage = value; }
                }
 
                [DefaultValue(0)]
@@ -200,7 +193,7 @@ namespace System.Windows.Forms {
                                        // Font changes always set the whole doc to that font
                                        start = document.GetLine(1);
                                        end = document.GetLine(document.Lines);
-                                       document.FormatText(start, 1, end, end.text.Length + 1, base.Font, new SolidBrush(this.ForeColor));
+                                       document.FormatText(start, 1, end, end.text.Length + 1, base.Font, null, null, FormatSpecified.Font);
                                }
                        }
                }
@@ -880,6 +873,10 @@ namespace System.Windows.Forms {
                        }
 
                        InsertRTFFromStream(data, 0, 1);
+
+                       document.PositionCaret (document.GetLine (1), 0);
+                       document.SetSelectionToCaret (true);
+                       ScrollToCaret ();
                }
 
                [MonoTODO("Make smarter RTF detection?")]
@@ -1458,7 +1455,7 @@ namespace System.Windows.Forms {
                                line = document.GetLine(rtf_cursor_y);
                                if (rtf_line.Length > 0) {
                                        document.InsertString(line, rtf_cursor_x, rtf_line.ToString());
-                                       document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color); // FormatText is 1-based
+                                       document.FormatText(line, rtf_cursor_x + 1, line, rtf_cursor_x + 1 + length, font, rtf_color, null, FormatSpecified.Font | FormatSpecified.Color); // FormatText is 1-based
                                }
                                if (newline) {
                                        document.Split(line, rtf_cursor_x + length);