X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7da982c4ec7482410a235c6045ce4a57bc5dd762..443aec6f41be3d7428a2c61accc611b42dc9238d:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 1ec178c99f..a6686ae562 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -297,9 +297,22 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_isRich = FALSE; #endif // wxUSE_RICHEDIT - if ( !MSWCreateControl(windowClass, msStyle, pos, size, value) ) + // we need to turn '\n's into "\r\n"s for the multiline controls + wxString valueWin; + if ( m_windowStyle & wxTE_MULTILINE ) + { + valueWin = wxTextFile::Translate(value, wxTextFileType_Dos); + } + else // single line + { + valueWin = value; + } + + if ( !MSWCreateControl(windowClass, msStyle, pos, size, valueWin) ) return FALSE; + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); + #if wxUSE_RICHEDIT if (m_isRich) { @@ -635,6 +648,34 @@ void wxTextCtrl::GetSelection(long* from, long* to) const } } +wxString wxTextCtrl::GetStringSelection() const +{ + // the base class version works correctly for the rich text controls + // because there the lines are terminated with just '\r' which means that + // the string length is not changed in the result of the translations doen + // in GetValue() but for the normal ones when we replace "\r\n" with '\n' + // we break the indices +#if wxUSE_RICHEDIT + if ( m_isRich ) + return wxTextCtrlBase::GetStringSelection(); +#endif // wxUSE_RICHEDIT + + long from, to; + GetSelection(&from, &to); + + wxString str; + if ( from < to ) + { + str = wxGetWindowText(GetHWND()).Mid(from, to - from); + + // and now that we have the correct selection, convert it to the + // correct format + str = wxTextFile::Translate(str, wxTextFileType_Unix); + } + + return str; +} + bool wxTextCtrl::IsEditable() const { long style = ::GetWindowLong(GetHwnd(), GWL_STYLE);