]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
don't append anything back in DoDeleteOneItem() if the control becomes empty (fixes...
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index bf1f301f10e6571d7de6c6acfc9cbaa6523d6c96..c5ac3408e95ad18305c18afd480db10eafea23bc 100644 (file)
@@ -76,6 +76,7 @@ BEGIN_EVENT_TABLE( wxRichTextCtrl, wxControl )
     EVT_KILL_FOCUS(wxRichTextCtrl::OnKillFocus)
     EVT_MOUSE_CAPTURE_LOST(wxRichTextCtrl::OnCaptureLost)
     EVT_CONTEXT_MENU(wxRichTextCtrl::OnContextMenu)
+    EVT_SYS_COLOUR_CHANGED(wxRichTextCtrl::OnSysColourChanged)
 
     EVT_MENU(wxID_UNDO, wxRichTextCtrl::OnUndo)
     EVT_UPDATE_UI(wxID_UNDO, wxRichTextCtrl::OnUpdateUndo)
@@ -200,7 +201,6 @@ wxRichTextCtrl::~wxRichTextCtrl()
 /// Member initialisation
 void wxRichTextCtrl::Init()
 {
-    m_freezeCount = 0;
     m_contextMenu = NULL;
     m_caret = NULL;
     m_caretPosition = -1;
@@ -216,25 +216,13 @@ void wxRichTextCtrl::Init()
     m_caretPositionForDefaultStyle = -2;
 }
 
-/// Call Freeze to prevent refresh
-void wxRichTextCtrl::Freeze()
+void wxRichTextCtrl::DoThaw()
 {
-    m_freezeCount ++;
-}
-
-/// Call Thaw to refresh
-void wxRichTextCtrl::Thaw()
-{
-    m_freezeCount --;
-
-    if (m_freezeCount == 0)
-    {
-        if (GetBuffer().GetDirty())
-            LayoutContent();
-        else
-            SetupScrollbars();
-        Refresh(false);
-    }
+    if (GetBuffer().GetDirty())
+        LayoutContent();
+    else
+        SetupScrollbars();
+    Refresh(false);
 }
 
 /// Clear all text
@@ -247,7 +235,7 @@ void wxRichTextCtrl::Clear()
     m_caretAtLineStart = false;
     m_selectionRange.SetRange(-2, -2);
 
-    if (m_freezeCount == 0)
+    if (!IsFrozen())
     {
         LayoutContent();
         Refresh(false);
@@ -268,11 +256,12 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
 #else
         wxPaintDC dc(this);
 #endif
-        PrepareDC(dc);
 
-        if (m_freezeCount > 0)
+        if (IsFrozen())
             return;
 
+        PrepareDC(dc);
+
         dc.SetFont(GetFont());
 
         // Paint the background
@@ -506,7 +495,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
 }
 
 /// Right-click
-void wxRichTextCtrl::OnRightClick(wxMouseEvent& WXUNUSED(event))
+void wxRichTextCtrl::OnRightClick(wxMouseEvent& event)
 {
     SetFocus();
 
@@ -516,7 +505,8 @@ void wxRichTextCtrl::OnRightClick(wxMouseEvent& WXUNUSED(event))
     cmdEvent.SetEventObject(this);
     cmdEvent.SetPosition(m_caretPosition+1);
 
-    GetEventHandler()->ProcessEvent(cmdEvent);
+    if (!GetEventHandler()->ProcessEvent(cmdEvent))
+        event.Skip();
 }
 
 /// Left-double-click
@@ -1787,7 +1777,7 @@ void wxRichTextCtrl::OnScroll(wxScrollWinEvent& event)
 /// Set up scrollbars, e.g. after a resize
 void wxRichTextCtrl::SetupScrollbars(bool atTop)
 {
-    if (m_freezeCount)
+    if (IsFrozen())
         return;
 
     if (GetBuffer().IsEmpty())
@@ -2248,6 +2238,8 @@ void wxRichTextCtrl::SetInsertionPoint(long pos)
     SelectNone();
 
     m_caretPosition = pos - 1;
+
+    PositionCaret();
 }
 
 void wxRichTextCtrl::SetInsertionPointEnd()
@@ -3111,5 +3103,17 @@ void wxRichTextCtrl::ClearAvailableFontNames()
     sm_availableFontNames.Clear();
 }
 
+void wxRichTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
+{
+    //wxLogDebug(wxT("wxRichTextCtrl::OnSysColourChanged"));
+
+    wxTextAttrEx basicStyle = GetBasicStyle();
+    basicStyle.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+    SetBasicStyle(basicStyle);
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
+
+    Refresh();
+}
+
 #endif
     // wxUSE_RICHTEXT