Don't insert a newline when we get text

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2007-06-07 12:49:35 +00:00
parent d9605e634b
commit 1a75935d3f
2 changed files with 14 additions and 25 deletions

View File

@ -1429,8 +1429,6 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra
wxRichTextObject* child = node->GetData(); wxRichTextObject* child = node->GetData();
if (!child->GetRange().IsOutside(range)) if (!child->GetRange().IsOutside(range))
{ {
// if (lineCount > 0)
// text += wxT("\n");
wxRichTextRange childRange = range; wxRichTextRange childRange = range;
childRange.LimitTo(child->GetRange()); childRange.LimitTo(child->GetRange());
@ -1438,7 +1436,7 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra
text += childText; text += childText;
if (childRange.GetEnd() == child->GetRange().GetEnd()) if ((childRange.GetEnd() == child->GetRange().GetEnd()) && node->GetNext())
text += wxT("\n"); text += wxT("\n");
lineCount ++; lineCount ++;

View File

@ -409,7 +409,7 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
if (!urlTarget.IsEmpty()) if (!urlTarget.IsEmpty())
{ {
wxMouseEvent mouseEvent(event); wxMouseEvent mouseEvent(event);
long startPos = 0, endPos = 0; long startPos = 0, endPos = 0;
wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position); wxRichTextObject* obj = GetBuffer().GetLeafObjectAtPosition(position);
if (obj) if (obj)
@ -417,12 +417,12 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
startPos = obj->GetRange().GetStart(); startPos = obj->GetRange().GetStart();
endPos = obj->GetRange().GetEnd(); endPos = obj->GetRange().GetEnd();
} }
wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos); wxTextUrlEvent urlEvent(GetId(), mouseEvent, startPos, endPos);
InitCommandEvent(urlEvent); InitCommandEvent(urlEvent);
urlEvent.SetString(urlTarget); urlEvent.SetString(urlTarget);
GetEventHandler()->ProcessEvent(urlEvent); GetEventHandler()->ProcessEvent(urlEvent);
} }
} }
@ -513,7 +513,7 @@ void wxRichTextCtrl::OnRightClick(wxMouseEvent& WXUNUSED(event))
GetId()); GetId());
cmdEvent.SetEventObject(this); cmdEvent.SetEventObject(this);
cmdEvent.SetPosition(m_caretPosition+1); cmdEvent.SetPosition(m_caretPosition+1);
GetEventHandler()->ProcessEvent(cmdEvent); GetEventHandler()->ProcessEvent(cmdEvent);
} }
@ -525,7 +525,7 @@ void wxRichTextCtrl::OnLeftDClick(wxMouseEvent& WXUNUSED(event))
GetId()); GetId());
cmdEvent.SetEventObject(this); cmdEvent.SetEventObject(this);
cmdEvent.SetPosition(m_caretPosition+1); cmdEvent.SetPosition(m_caretPosition+1);
if (!GetEventHandler()->ProcessEvent(cmdEvent)) if (!GetEventHandler()->ProcessEvent(cmdEvent))
{ {
SelectWord(GetCaretPosition()+1); SelectWord(GetCaretPosition()+1);
@ -540,7 +540,7 @@ void wxRichTextCtrl::OnMiddleClick(wxMouseEvent& event)
GetId()); GetId());
cmdEvent.SetEventObject(this); cmdEvent.SetEventObject(this);
cmdEvent.SetPosition(m_caretPosition+1); cmdEvent.SetPosition(m_caretPosition+1);
if (!GetEventHandler()->ProcessEvent(cmdEvent)) if (!GetEventHandler()->ProcessEvent(cmdEvent))
event.Skip(); event.Skip();
} }
@ -2064,30 +2064,21 @@ void wxRichTextCtrl::DoSetValue(const wxString& value, int flags)
{ {
Clear(); Clear();
// if the text is long enough, it's faster to just set it instead of first if (!value.IsEmpty())
// comparing it with the old one (chances are that it will be different
// anyhow, this comparison is there to avoid flicker for small single-line
// edit controls mostly)
if ( (value.length() > 0x400) || (value != GetValue()) )
{ {
// Remove empty paragraph
GetBuffer().Clear();
DoWriteText(value); DoWriteText(value);
// for compatibility, don't move the cursor when doing SetValue() // for compatibility, don't move the cursor when doing SetValue()
SetInsertionPoint(0); SetInsertionPoint(0);
} }
else // same text else
{ {
if ( flags & SetValue_SendEvent ) // still send an event for consistency
{ if (flags & SetValue_SendEvent)
// still send an event for consistency
SendTextUpdatedEvent(); SendTextUpdatedEvent();
}
} }
// we should reset the modified flag even if the value didn't really change
// mark the control as being not dirty - we changed its text, not the
// user
DiscardEdits(); DiscardEdits();
} }