+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();
+}
+
+// Refresh the area affected by a selection change
+bool wxRichTextCtrl::RefreshForSelectionChange(const wxRichTextRange& oldSelection, const wxRichTextRange& newSelection)
+{
+ // Calculate the refresh rectangle - just the affected lines
+ long firstPos, lastPos;
+ if (oldSelection.GetStart() == -2 && newSelection.GetStart() != -2)
+ {
+ firstPos = newSelection.GetStart();
+ lastPos = newSelection.GetEnd();
+ }
+ else if (oldSelection.GetStart() != -2 && newSelection.GetStart() == -2)
+ {
+ firstPos = oldSelection.GetStart();
+ lastPos = oldSelection.GetEnd();
+ }
+ else if (oldSelection.GetStart() == -2 && newSelection.GetStart() == -2)
+ {
+ return false;
+ }
+ else
+ {
+ firstPos = wxMin(oldSelection.GetStart(), newSelection.GetStart());
+ lastPos = wxMax(oldSelection.GetEnd(), newSelection.GetEnd());
+ }
+
+ wxRichTextLine* firstLine = GetBuffer().GetLineAtPosition(firstPos);
+ wxRichTextLine* lastLine = GetBuffer().GetLineAtPosition(lastPos);
+
+ if (firstLine && lastLine)
+ {
+ wxSize clientSize = GetClientSize();
+ wxPoint pt1 = GetPhysicalPoint(firstLine->GetAbsolutePosition());
+ wxPoint pt2 = GetPhysicalPoint(lastLine->GetAbsolutePosition()) + wxPoint(0, lastLine->GetSize().y);
+
+ pt1.x = 0;
+ pt1.y = wxMax(0, pt1.y);
+ pt2.x = 0;
+ pt2.y = wxMin(clientSize.y, pt2.y);
+
+ wxRect rect(pt1, wxSize(clientSize.x, pt2.y - pt1.y));
+ RefreshRect(rect, false);
+ }
+ else
+ Refresh(false);
+
+ return true;
+}
+
+#if wxRICHTEXT_USE_OWN_CARET
+
+// ----------------------------------------------------------------------------
+// initialization and destruction
+// ----------------------------------------------------------------------------
+
+void wxRichTextCaret::Init()
+{
+ m_hasFocus = true;
+
+ m_xOld =
+ m_yOld = -1;
+ m_richTextCtrl = NULL;
+ m_needsUpdate = false;
+}
+
+wxRichTextCaret::~wxRichTextCaret()
+{
+}
+
+// ----------------------------------------------------------------------------
+// showing/hiding/moving the caret (base class interface)
+// ----------------------------------------------------------------------------
+
+void wxRichTextCaret::DoShow()
+{
+ Refresh();
+}
+
+void wxRichTextCaret::DoHide()
+{
+ Refresh();
+}
+
+void wxRichTextCaret::DoMove()
+{
+ if (IsVisible())
+ {
+ Refresh();
+
+ if (m_xOld != -1 && m_yOld != -1)
+ {
+ if (m_richTextCtrl)
+ {
+ wxRect rect(GetPosition(), GetSize());
+ m_richTextCtrl->RefreshRect(rect, false);
+ }
+ }
+ }
+
+ m_xOld = m_x;
+ m_yOld = m_y;
+}
+
+void wxRichTextCaret::DoSize()
+{
+ int countVisible = m_countVisible;
+ if (countVisible > 0)
+ {
+ m_countVisible = 0;
+ DoHide();
+ }
+
+ if (countVisible > 0)
+ {
+ m_countVisible = countVisible;
+ DoShow();
+ }
+}
+
+// ----------------------------------------------------------------------------
+// handling the focus
+// ----------------------------------------------------------------------------
+
+void wxRichTextCaret::OnSetFocus()
+{
+ m_hasFocus = true;
+
+ if ( IsVisible() )
+ Refresh();
+}
+
+void wxRichTextCaret::OnKillFocus()
+{
+ m_hasFocus = false;
+}
+
+// ----------------------------------------------------------------------------
+// drawing the caret
+// ----------------------------------------------------------------------------
+
+void wxRichTextCaret::Refresh()
+{
+ if (m_richTextCtrl)
+ {
+ wxRect rect(GetPosition(), GetSize());
+ m_richTextCtrl->RefreshRect(rect, false);
+ }
+}
+
+void wxRichTextCaret::DoDraw(wxDC *dc)
+{
+ dc->SetPen( *wxBLACK_PEN );
+
+ dc->SetBrush(*(m_hasFocus ? wxBLACK_BRUSH : wxTRANSPARENT_BRUSH));
+ dc->SetPen(*wxBLACK_PEN);
+
+ // VZ: unfortunately, the rectangle comes out a pixel smaller when this is
+ // done under wxGTK - no idea why
+ //dc->SetLogicalFunction(wxINVERT);
+
+ wxPoint pt(m_x, m_y);
+
+ if (m_richTextCtrl)
+ {
+ pt = m_richTextCtrl->GetLogicalPoint(pt);
+ }
+ dc->DrawRectangle(pt.x, pt.y, m_width, m_height);
+}
+#endif
+ // wxRICHTEXT_USE_OWN_CARET
+