EVT_SIZE(wxRichTextCtrl::OnSize)
EVT_SET_FOCUS(wxRichTextCtrl::OnSetFocus)
EVT_KILL_FOCUS(wxRichTextCtrl::OnKillFocus)
+ EVT_MOUSE_CAPTURE_LOST(wxRichTextCtrl::OnCaptureLost)
EVT_CONTEXT_MENU(wxRichTextCtrl::OnContextMenu)
EVT_MENU(wxID_UNDO, wxRichTextCtrl::OnUndo)
// Refresh(false);
}
+void wxRichTextCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
+{
+ m_dragging = false;
+}
+
/// Left-click
void wxRichTextCtrl::OnLeftClick(wxMouseEvent& event)
{
// See if we need to change the cursor
{
- if (hit != wxRICHTEXT_HITTEST_NONE)
+ if (hit != wxRICHTEXT_HITTEST_NONE & !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
{
wxTextAttrEx attr;
if (GetStyle(position, attr))
}
}
}
+ else
+ SetCursor(m_textCursor);
}
if (!event.Dragging())
DeleteSelectedContent(& newPos);
- GetBuffer().InsertNewlineWithUndo(newPos+1, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
+ if (event.ShiftDown())
+ {
+ wxString text;
+ text = wxRichTextLineBreakChar;
+ GetBuffer().InsertTextWithUndo(newPos+1, text, this);
+ }
+ else
+ GetBuffer().InsertNewlineWithUndo(newPos+1, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
+
EndBatchUndo();
SetDefaultStyleToCursorStyle();
// so subtract 1 for deleted character and add 1 for conversion to character position.
if (m_caretPosition > -1 && !HasSelection())
{
- GetBuffer().DeleteRangeWithUndo(wxRichTextRange(m_caretPosition, m_caretPosition),
- m_caretPosition, // Current caret position
- m_caretPosition-1, // New caret position
- this);
+ GetBuffer().DeleteRangeWithUndo(wxRichTextRange(m_caretPosition, m_caretPosition), this);
}
else
DeleteSelectedContent();
// Submit range in character positions, which are greater than caret positions,
if (m_caretPosition < GetBuffer().GetRange().GetEnd()+1 && !HasSelection())
{
- GetBuffer().DeleteRangeWithUndo(wxRichTextRange(m_caretPosition+1, m_caretPosition+1),
- m_caretPosition, // Current caret position
- m_caretPosition+1, // New caret position
- this);
+ GetBuffer().DeleteRangeWithUndo(wxRichTextRange(m_caretPosition+1, m_caretPosition+1), this);
}
else
DeleteSelectedContent();
if (HasSelection())
{
long pos = m_selectionRange.GetStart();
- GetBuffer().DeleteRangeWithUndo(m_selectionRange,
- m_caretPosition, // Current caret position
- pos, // New caret position
- this);
+ GetBuffer().DeleteRangeWithUndo(m_selectionRange, this);
m_selectionRange.SetRange(-2, -2);
if (newPos)
// we want to be at the end of the last line but with m_caretAtLineStart set to true,
// so we view the caret at the start of the line.
bool caretLineStart = false;
- if (hitTest == wxRICHTEXT_HITTEST_BEFORE)
+ if (hitTest & wxRICHTEXT_HITTEST_BEFORE)
{
wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1);
wxRichTextRange lineRange;
int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos);
- switch ( hit )
- {
- case wxRICHTEXT_HITTEST_BEFORE:
- return wxTE_HT_BEFORE;
-
- case wxRICHTEXT_HITTEST_AFTER:
- return wxTE_HT_BEYOND;
-
- case wxRICHTEXT_HITTEST_ON:
- return wxTE_HT_ON_TEXT;
- }
+ if ((hit & wxRICHTEXT_HITTEST_BEFORE) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
+ return wxTE_HT_BEFORE;
+ else if ((hit & wxRICHTEXT_HITTEST_AFTER) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
+ return wxTE_HT_BEYOND;
+ else if (hit & wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_AFTER)
+ return wxTE_HT_ON_TEXT;
+ else
+ return wxTE_HT_UNKNOWN;
return wxTE_HT_UNKNOWN;
}
{
wxString valueUnix = wxTextFile::Translate(value, wxTextFileType_Unix);
- GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this);
+ GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
if ( flags & SetValue_SendEvent )
SendTextUpdatedEvent();
return GetBuffer().InsertNewlineWithUndo(m_caretPosition+1, this);
}
+/// Insert a line break at the current insertion point.
+bool wxRichTextCtrl::LineBreak()
+{
+ wxString text;
+ text = wxRichTextLineBreakChar;
+ return GetBuffer().InsertTextWithUndo(m_caretPosition+1, text, this);
+}
// ----------------------------------------------------------------------------
// Clipboard operations
{
m_selectionAnchor = from;
m_selectionRange.SetRange(from, to-1);
+ if (from > -2)
+ m_caretPosition = from-1;
Refresh(false);
PositionCaret();
{
SelectNone();
- GetBuffer().DeleteRangeWithUndo(wxRichTextRange(from, to),
- m_caretPosition, // Current caret position
- from, // New caret position
- this);
+ GetBuffer().DeleteRangeWithUndo(wxRichTextRange(from, to), this);
LayoutContent();
if (!IsFrozen())
{
// Flags are defined within each definition, so only certain
// attributes are applied.
- wxRichTextAttr attr(def->GetStyle());
+ wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;
return GetBuffer().PromoteList(promoteBy, range.ToInternal(), defName, flags, specifiedLevel);
}
+/// Deletes the content in the given range
+bool wxRichTextCtrl::Delete(const wxRichTextRange& range)
+{
+ return GetBuffer().DeleteRangeWithUndo(range.ToInternal(), this);
+}
+
const wxArrayString& wxRichTextCtrl::GetAvailableFontNames()
{
if (sm_availableFontNames.GetCount() == 0)