/////////////////////////////////////////////////////////////////////////////
-// Name: src/richtext/richeditctrl.cpp
+// Name: src/richtext/richtextctrl.cpp
// Purpose: A rich edit control
// Author: Julian Smart
// Modified by:
validator, name))
return false;
- if (!GetFont().Ok())
+ if (!GetFont().IsOk())
{
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
}
// Accelerators
wxAcceleratorEntry entries[6];
- entries[0].Set(wxACCEL_CMD, (int) 'C', wxID_COPY);
- entries[1].Set(wxACCEL_CMD, (int) 'X', wxID_CUT);
- entries[2].Set(wxACCEL_CMD, (int) 'V', wxID_PASTE);
- entries[3].Set(wxACCEL_CMD, (int) 'A', wxID_SELECTALL);
- entries[4].Set(wxACCEL_CMD, (int) 'Z', wxID_UNDO);
- entries[5].Set(wxACCEL_CMD, (int) 'Y', wxID_REDO);
+ entries[0].Set(wxACCEL_CTRL, (int) 'C', wxID_COPY);
+ entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_CUT);
+ entries[2].Set(wxACCEL_CTRL, (int) 'V', wxID_PASTE);
+ entries[3].Set(wxACCEL_CTRL, (int) 'A', wxID_SELECTALL);
+ entries[4].Set(wxACCEL_CTRL, (int) 'Z', wxID_UNDO);
+ entries[5].Set(wxACCEL_CTRL, (int) 'Y', wxID_REDO);
wxAcceleratorTable accel(6, entries);
SetAcceleratorTable(accel);
if (GetCaret())
GetCaret()->Show();
PositionCaret();
+#else
+#if !defined(__WXMAC__)
+ // Causes caret dropouts on Mac
+ PositionCaret();
+#endif
#endif
}
// 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();
}
SetDefaultStyleToCursorStyle();
ScrollIntoView(m_caretPosition, WXK_RIGHT);
+ cmdEvent.SetPosition(m_caretPosition);
GetEventHandler()->ProcessEvent(cmdEvent);
Update();
wxSize clientSize = GetClientSize();
clientSize.y -= GetBuffer().GetBottomMargin();
- return (rect.GetBottom() > (startY + GetBuffer().GetTopMargin())) && (rect.GetTop() < (startY + clientSize.y));
+ return (rect.GetTop() >= (startY + GetBuffer().GetTopMargin())) && (rect.GetBottom() <= (startY + clientSize.y));
}
void wxRichTextCtrl::SetCaretPosition(long position, bool showAtLineStart)
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)
void wxRichTextCtrl::PaintBackground(wxDC& dc)
{
wxColour backgroundColour = GetBackgroundColour();
- if (!backgroundColour.Ok())
+ if (!backgroundColour.IsOk())
backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
// Clear the background
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);
- return m_bufferBitmap.Ok();
+ return m_bufferBitmap.IsOk();
}
#endif
bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
- if (bitmap.Ok())
+ if (bitmap.IsOk())
{
wxRichTextImageBlock imageBlock;
wxImage image = bitmap.ConvertToImage();
- if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
+ if (image.IsOk() && imageBlock.MakeImageBlock(image, bitmapType))
return WriteImage(imageBlock, textAttr);
}
// Editing
// ----------------------------------------------------------------------------
-void wxRichTextCtrl::Replace(long WXUNUSED(from), long WXUNUSED(to),
+void wxRichTextCtrl::Replace(long from, long to,
const wxString& value)
{
BeginBatchUndo(_("Replace"));
+ SetSelection(from, to);
+
+ wxRichTextAttr attr = GetDefaultStyle();
+
DeleteSelectedContent();
+ SetDefaultStyle(attr);
+
DoWriteText(value, SetValue_SelectionOnly);
EndBatchUndo();