X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..2ac013b1a5d8210ab0c53f7eb9687399b9312162:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 34956b23ae..f21acdc2cc 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -444,6 +444,9 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const void wxTextCtrl::SetWindowStyleFlag(long style) { + if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) + style |= wxBORDER_SUNKEN; + #if wxUSE_RICHEDIT // we have to deal with some styles separately because they can't be // changed by simply calling SetWindowLong(GWL_STYLE) but can be changed @@ -753,7 +756,10 @@ void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly) #endif // wxUSE_RICHEDIT ) { - SendUpdateEvent(); + // Windows already sends an update event for single-line + // controls. + if ( m_windowStyle & wxTE_MULTILINE ) + SendUpdateEvent(); } } @@ -787,7 +793,11 @@ void wxTextCtrl::Clear() // rich edit controls send EN_UPDATE from WM_SETTEXT handler themselves // but the normal ones don't -- make Clear() behaviour consistent by // always sending this event - SendUpdateEvent(); + + // Windows already sends an update event for single-line + // controls. + if ( m_windowStyle & wxTE_MULTILINE ) + SendUpdateEvent(); } } @@ -1003,6 +1013,26 @@ void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret) #if wxUSE_RICHEDIT if ( IsRich() ) { + // richedit 3.0 (i.e. the version living in riched20.dll distributed + // with Windows 2000 and beyond) doesn't honour EM_SCROLLCARET when + // emulating richedit 2.0 unless the control has focus or ECO_NOHIDESEL + // option is set (but it does work ok in richedit 1.0 mode...) + // + // so to make it work we either need to give focus to it here which + // will probably create many problems (dummy focus events; window + // containing the text control being brought to foreground + // unexpectedly; ...) or to temporarily set ECO_NOHIDESEL which may + // create other problems too -- or it might not, so let's try to do it + if ( GetRichVersion() > 1 ) + { + if ( !HasFlag(wxTE_NOHIDESEL) ) + { + ::SendMessage(GetHwnd(), EM_SETOPTIONS, + ECOOP_OR, ECO_NOHIDESEL); + } + //else: everything is already ok + } + CHARRANGE range; range.cpMin = from; range.cpMax = to; @@ -1018,6 +1048,16 @@ void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret) { SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0); } + +#if wxUSE_RICHEDIT + // restore ECO_NOHIDESEL if we changed it + if ( GetRichVersion() > 1 && !HasFlag(wxTE_NOHIDESEL) ) + { + ::SendMessage(GetHwnd(), EM_SETOPTIONS, + ECOOP_AND, ~ECO_NOHIDESEL); + } +#endif // wxUSE_RICHEDIT + #else // Win16 // WPARAM is 0: selection is scrolled into view SendMessage(hWnd, EM_SETSEL, (WPARAM)0, (LPARAM)MAKELONG(from, to)); @@ -1564,8 +1604,10 @@ bool wxTextCtrl::AdjustSpaceLimit() bool wxTextCtrl::AcceptsFocus() const { - // we don't want focus if we can't be edited - return IsEditable() && wxControl::AcceptsFocus(); + // we don't want focus if we can't be edited unless we're a multiline + // control because then it might be still nice to get focus from keyboard + // to be able to scroll it without mouse + return (IsEditable() || IsMultiLine()) && wxControl::AcceptsFocus(); } wxSize wxTextCtrl::DoGetBestSize() const