X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b2d5a7ee008faae08694abd039f7da235da8bce5..e7300ec6d9ebbd1cfa2fcf12c0ce6e5aee85a152:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 3b742402c4..a5acb508d2 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -357,10 +357,16 @@ void wxTextCtrl::AdoptAttributesFromHWND() WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const { + // default border for the text controls is the sunken one + if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) + { + style |= wxBORDER_SUNKEN; + } + long msStyle = wxControl::MSWGetStyle(style, exstyle); // default styles - msStyle |= ES_LEFT | WS_TABSTOP; + msStyle |= ES_LEFT; if ( style & wxTE_MULTILINE ) { @@ -633,7 +639,7 @@ void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly) #if wxUSE_UNICODE_MSLU // RichEdit doesn't have Unicode version of EM_REPLACESEL on Win9x, // but EM_STREAMIN works - if ( wxGetOsVersion() == wxWIN95 && GetRichVersion() > 1 ) + if ( wxUsingUnicowsDll() && GetRichVersion() > 1 ) { done = StreamIn(valueDos, wxFONTENCODING_SYSTEM, selectionOnly); } @@ -686,6 +692,25 @@ void wxTextCtrl::Clear() ::SetWindowText(GetHwnd(), wxT("")); } +#ifdef __WIN32__ + +bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& event) +{ + SetFocus(); + + size_t lenOld = GetValue().length(); + + wxUint32 code = event.GetRawKeyCode(); + ::keybd_event(code, 0, 0 /* key press */, NULL); + ::keybd_event(code, 0, KEYEVENTF_KEYUP, NULL); + + // assume that any alphanumeric key changes the total number of characters + // in the control - this should work in 99% of cases + return GetValue().length() != lenOld; +} + +#endif // __WIN32__ + // ---------------------------------------------------------------------------- // Clipboard operations // ---------------------------------------------------------------------------- @@ -838,6 +863,12 @@ void wxTextCtrl::GetSelection(long* from, long* to) const bool wxTextCtrl::IsEditable() const { + // strangely enough, we may be called before the control is created: our + // own Create() calls MSWGetStyle() which calls AcceptsFocus() which calls + // us + if ( !m_hWnd ) + return TRUE; + long style = ::GetWindowLong(GetHwnd(), GWL_STYLE); return (style & ES_READONLY) == 0; @@ -1186,7 +1217,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) long wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { - // we always want the characters and the arrows if ( nMsg == WM_GETDLGCODE ) { // we always want the chars and the arrows @@ -1194,14 +1224,18 @@ long wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) // we may have several different cases: // 1. normal case: both TAB and ENTER are used for dialog navigation - // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next - // control in the dialog - // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation - // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to - // the next control - if ( m_windowStyle & wxTE_PROCESS_ENTER ) + // 2. ctrl which wants TAB for itself: ENTER is used to pass to the + // next control in the dialog + // 3. ctrl which wants ENTER for itself: TAB is used for dialog + // navigation + // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass + // to the next control + + // the multiline edit control should always get for itself + if ( HasFlag(wxTE_PROCESS_ENTER) || HasFlag(wxTE_MULTILINE) ) lDlgCode |= DLGC_WANTMESSAGE; - if ( m_windowStyle & wxTE_PROCESS_TAB ) + + if ( HasFlag(wxTE_PROCESS_TAB) ) lDlgCode |= DLGC_WANTTAB; return lDlgCode; @@ -1477,7 +1511,6 @@ bool wxTextCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *re ::SetCursor(GetHcursorOf(wxCursor(wxCURSOR_HAND))); *result = TRUE; break; - case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: @@ -1718,7 +1751,7 @@ bool wxRichEditModule::OnInit() void wxRichEditModule::OnExit() { - for ( int i = 0; i < WXSIZEOF(ms_hRichEdit); i++ ) + for ( size_t i = 0; i < WXSIZEOF(ms_hRichEdit); i++ ) { if ( ms_hRichEdit[i] ) {