]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
Fix recursion problems when loading pages from a virtual file system using the WebKit...
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index 14266aa8c1a72e1bae62b86afd032040bd6ed87d..f5039443c53ca55def1aacda60d6fd5128189d2d 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        src/richtext/richeditctrl.cpp
+// Name:        src/richtext/richtextctrl.cpp
 // Purpose:     A rich edit control
 // Author:      Julian Smart
 // Modified by:
 // Purpose:     A rich edit control
 // Author:      Julian Smart
 // Modified by:
@@ -230,7 +230,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
                            validator, name))
         return false;
 
                            validator, name))
         return false;
 
-    if (!GetFont().Ok())
+    if (!GetFont().IsOk())
     {
         SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
     }
     {
         SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
     }
@@ -456,6 +456,11 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
     if (GetCaret())
         GetCaret()->Show();
     PositionCaret();
     if (GetCaret())
         GetCaret()->Show();
     PositionCaret();
+#else
+#if !defined(__WXMAC__)
+    // Causes caret dropouts on Mac
+    PositionCaret();
+#endif
 #endif
 }
 
 #endif
 }
 
@@ -563,12 +568,7 @@ void wxRichTextCtrl::OnLeftClick(wxMouseEvent& event)
 
         // For now, don't handle shift-click when we're selecting multiple objects.
         if (event.ShiftDown() && GetFocusObject() == oldFocusObject && m_selectionState == wxRichTextCtrlSelectionState_Normal)
 
         // For now, don't handle shift-click when we're selecting multiple objects.
         if (event.ShiftDown() && GetFocusObject() == oldFocusObject && m_selectionState == wxRichTextCtrlSelectionState_Normal)
-        {
-            if (!m_selection.IsValid())
-                ExtendSelection(oldCaretPos, m_caretPosition, wxRICHTEXT_SHIFT_DOWN);
-            else
-                ExtendSelection(m_caretPosition, m_caretPosition, wxRICHTEXT_SHIFT_DOWN);
-        }
+            ExtendSelection(oldCaretPos, m_caretPosition, wxRICHTEXT_SHIFT_DOWN);
         else
             SelectNone();
     }
         else
             SelectNone();
     }
@@ -1221,6 +1221,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
                 SetDefaultStyleToCursorStyle();
                 ScrollIntoView(m_caretPosition, WXK_RIGHT);
 
                 SetDefaultStyleToCursorStyle();
                 ScrollIntoView(m_caretPosition, WXK_RIGHT);
 
+                cmdEvent.SetPosition(m_caretPosition);
                 GetEventHandler()->ProcessEvent(cmdEvent);
 
                 Update();
                 GetEventHandler()->ProcessEvent(cmdEvent);
 
                 Update();
@@ -2203,6 +2204,19 @@ void wxRichTextCtrl::OnSize(wxSizeEvent& event)
     event.Skip();
 }
 
     event.Skip();
 }
 
+// Force any pending layout due to large buffer
+void wxRichTextCtrl::ForceDelayedLayout()
+{
+    if (m_fullLayoutRequired)
+    {
+        m_fullLayoutRequired = false;
+        m_fullLayoutTime = 0;
+        GetBuffer().Invalidate(wxRICHTEXT_ALL);
+        ShowPosition(m_fullLayoutSavedPosition);
+        Refresh(false);
+        Update();
+    }
+}
 
 /// Idle-time processing
 void wxRichTextCtrl::OnIdle(wxIdleEvent& event)
 
 /// Idle-time processing
 void wxRichTextCtrl::OnIdle(wxIdleEvent& event)
@@ -2309,7 +2323,7 @@ void wxRichTextCtrl::SetupScrollbars(bool atTop)
 void wxRichTextCtrl::PaintBackground(wxDC& dc)
 {
     wxColour backgroundColour = GetBackgroundColour();
 void wxRichTextCtrl::PaintBackground(wxDC& dc)
 {
     wxColour backgroundColour = GetBackgroundColour();
-    if (!backgroundColour.Ok())
+    if (!backgroundColour.IsOk())
         backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
 
     // Clear the background
         backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
 
     // Clear the background
@@ -2336,9 +2350,9 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size)
     if (sz.x < 1 || sz.y < 1)
         return false;
 
     if (sz.x < 1 || sz.y < 1)
         return false;
 
-    if (!m_bufferBitmap.Ok() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y)
+    if (!m_bufferBitmap.IsOk() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y)
         m_bufferBitmap = wxBitmap(sz.x, sz.y);
         m_bufferBitmap = wxBitmap(sz.x, sz.y);
-    return m_bufferBitmap.Ok();
+    return m_bufferBitmap.IsOk();
 }
 #endif
 
 }
 #endif
 
@@ -2650,12 +2664,12 @@ bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock, const wx
 
 bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
 {
 
 bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
 {
-    if (bitmap.Ok())
+    if (bitmap.IsOk())
     {
         wxRichTextImageBlock imageBlock;
 
         wxImage image = bitmap.ConvertToImage();
     {
         wxRichTextImageBlock imageBlock;
 
         wxImage image = bitmap.ConvertToImage();
-        if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
+        if (image.IsOk() && imageBlock.MakeImageBlock(image, bitmapType))
             return WriteImage(imageBlock, textAttr);
     }
 
             return WriteImage(imageBlock, textAttr);
     }
 
@@ -2911,13 +2925,19 @@ void wxRichTextCtrl::SetSelection(long from, long to)
 // Editing
 // ----------------------------------------------------------------------------
 
 // Editing
 // ----------------------------------------------------------------------------
 
-void wxRichTextCtrl::Replace(long WXUNUSED(from), long WXUNUSED(to),
+void wxRichTextCtrl::Replace(long from, long to,
                              const wxString& value)
 {
     BeginBatchUndo(_("Replace"));
 
                              const wxString& value)
 {
     BeginBatchUndo(_("Replace"));
 
+    SetSelection(from, to);
+
+    wxRichTextAttr attr = GetDefaultStyle();
+
     DeleteSelectedContent();
 
     DeleteSelectedContent();
 
+    SetDefaultStyle(attr);
+
     DoWriteText(value, SetValue_SelectionOnly);
 
     EndBatchUndo();
     DoWriteText(value, SetValue_SelectionOnly);
 
     EndBatchUndo();