]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
OpenVMS update
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index bf06f72f309d7581073f5482dfd17ca1458709ad..c2df7e6062398794f1a5391226050e40b26922af 100644 (file)
@@ -129,9 +129,9 @@ wxRichTextCtrl::wxRichTextCtrl(wxWindow* parent,
 bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style,
                              const wxValidator& validator, const wxString& name)
 {
-    if (!wxTextCtrlBase::Create(parent, id, pos, size,
-                                style|wxFULL_REPAINT_ON_RESIZE,
-                                validator, name))
+    if (!wxControl::Create(parent, id, pos, size,
+                           style|wxFULL_REPAINT_ON_RESIZE,
+                           validator, name))
         return false;
 
     if (!GetFont().Ok())
@@ -151,7 +151,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
     // The base attributes must all have default values
     wxTextAttrEx attributes;
     attributes.SetFont(GetFont());
-    attributes.SetTextColour(*wxBLACK);
+    attributes.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
     attributes.SetAlignment(wxTEXT_ALIGNMENT_LEFT);
     attributes.SetLineSpacing(10);
     attributes.SetParagraphSpacingAfter(10);
@@ -166,7 +166,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
     wxTextAttrEx defaultAttributes;
     SetDefaultStyle(defaultAttributes);
 
-    SetBackgroundColour(*wxWHITE);
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
     SetBackgroundStyle(wxBG_STYLE_CUSTOM);
 
     // Tell the sizers to use the given or best size
@@ -229,7 +229,10 @@ void wxRichTextCtrl::Thaw()
 
     if (m_freezeCount == 0)
     {
-        SetupScrollbars();
+        if (GetBuffer().GetDirty())
+            LayoutContent();
+        else
+            SetupScrollbars();
         Refresh(false);
     }
 }
@@ -244,14 +247,13 @@ void wxRichTextCtrl::Clear()
     m_caretAtLineStart = false;
     m_selectionRange.SetRange(-2, -2);
 
-    SetScrollbars(0, 0, 0, 0, 0, 0);
-
     if (m_freezeCount == 0)
     {
-        SetupScrollbars();
+        LayoutContent();
         Refresh(false);
     }
-    SendTextUpdatedEvent();
+
+    wxTextCtrl::SendTextUpdatedEvent(this);
 }
 
 /// Painting
@@ -1878,7 +1880,7 @@ bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
     PositionCaret();
     SetupScrollbars(true);
     Refresh(false);
-    SendTextUpdatedEvent();
+    wxTextCtrl::SendTextUpdatedEvent(this);
 
     if (success)
         return true;
@@ -2077,7 +2079,7 @@ void wxRichTextCtrl::DoSetValue(const wxString& value, int flags)
     {
         // still send an event for consistency
         if (flags & SetValue_SendEvent)
-            SendTextUpdatedEvent();
+            wxTextCtrl::SendTextUpdatedEvent(this);
     }
     DiscardEdits();
 }
@@ -2094,7 +2096,7 @@ void wxRichTextCtrl::DoWriteText(const wxString& value, int flags)
     GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
 
     if ( flags & SetValue_SendEvent )
-        SendTextUpdatedEvent();
+        wxTextCtrl::SendTextUpdatedEvent(this);
 }
 
 void wxRichTextCtrl::AppendText(const wxString& text)
@@ -2527,8 +2529,14 @@ void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
     event.Enable(GetLastPosition() > 0);
 }
 
-void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& WXUNUSED(event))
+void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)
 {
+    if (event.GetEventObject() != this)
+    {
+        event.Skip();
+        return;
+    }
+
     if (!m_contextMenu)
     {
         m_contextMenu = new wxMenu;
@@ -2707,12 +2715,13 @@ void wxRichTextCtrl::PositionCaret()
     wxRect caretRect;
     if (GetCaretPositionForIndex(GetCaretPosition(), caretRect))
     {
-        wxPoint originalPt = caretRect.GetPosition();
-        wxPoint pt = GetPhysicalPoint(originalPt);
-        if (GetCaret()->GetPosition() != pt)
+        wxPoint newPt = caretRect.GetPosition();
+        wxSize newSz = caretRect.GetSize();
+        wxPoint pt = GetPhysicalPoint(newPt);
+        if (GetCaret()->GetPosition() != pt || GetCaret()->GetSize() != newSz)
         {
             GetCaret()->Move(pt);
-            GetCaret()->SetSize(caretRect.GetSize());
+            GetCaret()->SetSize(newSz);
         }
     }
 }