SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
}
+ GetBuffer().Reset();
GetBuffer().SetRichTextCtrl(this);
+
+ SetCaret(new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16));
+ GetCaret()->Show();
if (style & wxTE_READONLY)
SetEditable(false);
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
// Tell the sizers to use the given or best size
- SetBestFittingSize(size);
+ SetInitialSize(size);
#if wxRICHTEXT_BUFFERED_PAINTING
// Create a buffer
/// Clear all text
void wxRichTextCtrl::Clear()
{
- m_buffer.Reset();
+ m_buffer.ResetAndClearCommands();
m_buffer.SetDirty(true);
m_caretPosition = -1;
m_caretPositionForDefaultStyle = -2;
/// Painting
void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
{
- if (GetCaret())
+ if (GetCaret() && GetCaret()->IsVisible())
GetCaret()->Hide();
{
// Paint the background
PaintBackground(dc);
- wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
+ // wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
+
+ wxRect drawingArea(GetUpdateRegion().GetBox());
+ drawingArea.SetPosition(GetLogicalPoint(drawingArea.GetPosition()));
+
wxRect availableSpace(GetClientSize());
if (GetBuffer().GetDirty())
{
GetBuffer().Draw(dc, GetBuffer().GetRange(), GetInternalSelectionRange(), drawingArea, 0 /* descent */, 0 /* flags */);
}
- if (GetCaret())
+ if (GetCaret() && !GetCaret()->IsVisible())
GetCaret()->Show();
PositionCaret();
void wxRichTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event))
{
- wxCaret* caret = new wxCaret(this, wxRICHTEXT_DEFAULT_CARET_WIDTH, 16);
- SetCaret(caret);
- caret->Show();
- PositionCaret();
+ if (GetCaret())
+ {
+ if (!GetCaret()->IsVisible())
+ GetCaret()->Show();
+ PositionCaret();
+ }
- if (!IsFrozen())
- Refresh(false);
+ // if (!IsFrozen())
+ // Refresh(false);
}
void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event))
{
- SetCaret(NULL);
+ if (GetCaret() && GetCaret()->IsVisible())
+ GetCaret()->Hide();
- if (!IsFrozen())
- Refresh(false);
+ // if (!IsFrozen())
+ // Refresh(false);
}
/// Left-click
{
if (attr.HasFlag(wxTEXT_ATTR_URL))
{
- if (GetCursor() != m_urlCursor)
- SetCursor(m_urlCursor);
+ SetCursor(m_urlCursor);
}
else if (!attr.HasFlag(wxTEXT_ATTR_URL))
{
- if (GetCursor() != m_textCursor)
- SetCursor(m_textCursor);
+ SetCursor(m_textCursor);
}
}
}
GetEventHandler()->ProcessEvent(textEvent);
}
+ Update();
}
else if (event.GetKeyCode() == WXK_BACK)
{
EndBatchUndo();
- // Shouldn't this be in Do()?
if (GetLastPosition() == -1)
{
GetBuffer().Reset();
}
ScrollIntoView(m_caretPosition, WXK_LEFT);
+ Update();
}
else if (event.GetKeyCode() == WXK_DELETE)
{
EndBatchUndo();
- // Shouldn't this be in Do()?
if (GetLastPosition() == -1)
{
GetBuffer().Reset();
PositionCaret();
SetDefaultStyleToCursorStyle();
}
+ Update();
}
else
{
SetDefaultStyleToCursorStyle();
ScrollIntoView(m_caretPosition, WXK_RIGHT);
+ Update();
}
}
}
return 0;
}
+/// Get the first visible point in the window
+wxPoint wxRichTextCtrl::GetFirstVisiblePoint() const
+{
+ int ppuX, ppuY;
+ int startXUnits, startYUnits;
+
+ GetScrollPixelsPerUnit(& ppuX, & ppuY);
+ GetViewStart(& startXUnits, & startYUnits);
+
+ return wxPoint(startXUnits * ppuX, startYUnits * ppuY);
+}
+
/// The adjusted caret position is the character position adjusted to take
/// into account whether we're at the start of a paragraph, in which case
/// style information should be taken from the next position, not current one.