X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cf1aac89dd673c73726ca83f4b9c1a4f5858ebaf..fb8d7eb7a880f1f2e32d8830f9c5e12b2536e05f:/src/os2/textctrl.cpp diff --git a/src/os2/textctrl.cpp b/src/os2/textctrl.cpp index f5ac61433c..8c38420a4a 100644 --- a/src/os2/textctrl.cpp +++ b/src/os2/textctrl.cpp @@ -55,8 +55,6 @@ // event tables and other macros // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) - BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_CHAR(wxTextCtrl::OnChar) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) @@ -125,6 +123,7 @@ bool wxTextCtrl::Create( m_windowStyle = lStyle; m_bIsMLE = false; + m_bSkipUpdate = false; long lSstyle = WS_VISIBLE | WS_TABSTOP; @@ -159,7 +158,7 @@ bool wxTextCtrl::Create( { m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle ,WC_MLE // Window class - ,(PSZ)rsValue.c_str() // Initial Text + ,rsValue.c_str() // Initial Text ,(ULONG)lSstyle // Style flags ,(LONG)0 // X pos of origin ,(LONG)0 // Y pos of origin @@ -176,7 +175,7 @@ bool wxTextCtrl::Create( { m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle ,WC_ENTRYFIELD // Window class - ,(PSZ)rsValue.c_str() // Initial Text + ,rsValue.c_str() // Initial Text ,(ULONG)lSstyle // Style flags ,(LONG)0 // X pos of origin ,(LONG)0 // Y pos of origin @@ -328,7 +327,8 @@ void wxTextCtrl::SetupColours() wxString wxTextCtrl::GetValue() const { wxString sStr = wxGetWindowText(GetHWND()); - char* zStr = (char*)sStr.c_str(); + wxCharBuffer buf(sStr.char_str()); + char* zStr = buf.data(); for ( ; *zStr; zStr++ ) { @@ -340,11 +340,12 @@ wxString wxTextCtrl::GetValue() const if (*zStr == '\r') *zStr = '\n'; } - return sStr; + return zStr; } // end of wxTextCtrl::GetValue -void wxTextCtrl::SetValue( - const wxString& rsValue +void wxTextCtrl::DoSetValue( + const wxString& rsValue, + int flags ) { // @@ -355,7 +356,10 @@ void wxTextCtrl::SetValue( // if ((rsValue.length() > 0x400) || (rsValue != GetValue())) { - ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str()); + if ( flags & SetValue_SendEvent ) + m_bSkipUpdate = true; + + ::WinSetWindowText(GetHwnd(), rsValue.c_str()); AdjustSpaceLimit(); } } // end of wxTextCtrl::SetValue @@ -365,9 +369,9 @@ void wxTextCtrl::WriteText( ) { if (m_bIsMLE) - ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0)); + ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM(rsValue.wx_str()), MPARAM(0)); else - ::WinSetWindowText(GetHwnd(), (PSZ)rsValue.c_str()); + ::WinSetWindowText(GetHwnd(), rsValue.c_str()); AdjustSpaceLimit(); } // end of wxTextCtrl::WriteText @@ -712,7 +716,7 @@ void wxTextCtrl::MarkDirty() ::WinSendMsg(GetHwnd(), MLM_SETCHANGED, MPFROMLONG(TRUE), 0); else // EM controls do not have a SETCHANGED, what can we do?? - wxFAIL_MSG( _T("not implemented") ); + wxFAIL_MSG( wxT("not implemented") ); } // @@ -1040,10 +1044,10 @@ void wxTextCtrl::OnChar( case WXK_RETURN: if ( !(m_windowStyle & wxTE_MULTILINE) ) { - wxCommandEvent vEvent(wxEVT_COMMAND_TEXT_ENTER, m_windowId); + wxCommandEvent vEvent(wxEVT_TEXT_ENTER, m_windowId); vEvent.SetEventObject(this); - if ( GetEventHandler()->ProcessEvent(vEvent)) + if ( HandleWindowEvent(vEvent)) return; } //else: multiline controls need Enter for themselves @@ -1065,7 +1069,7 @@ void wxTextCtrl::OnChar( vEventNav.SetWindowChange(false); vEventNav.SetEventObject(this); - if ( GetEventHandler()->ProcessEvent(vEventNav) ) + if ( HandleWindowEvent(vEventNav) ) return; } break; @@ -1089,13 +1093,19 @@ bool wxTextCtrl::OS2Command( ); vEvent.SetEventObject(this); - GetEventHandler()->ProcessEvent(vEvent); + HandleWindowEvent(vEvent); } break; case EN_CHANGE: { - wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED + if (m_bSkipUpdate) + { + m_bSkipUpdate = false; + break; + } + + wxCommandEvent vEvent( wxEVT_TEXT ,m_windowId ); @@ -1159,11 +1169,17 @@ void wxTextCtrl::AdjustSpaceLimit() } if (uLen >= uLimit) { - uLimit = uLen + 0x8000; // 32Kb - if (uLimit > 0xffff) + if (m_bIsMLE) { - uLimit = 0L; + uLimit = uLen + 0x8000; // 32Kb + if (uLimit > 0xffff) + { + uLimit = 0L; + } } + else + uLimit = 0x7fff; + if (m_bIsMLE) ::WinSendMsg(GetHwnd(), MLM_SETTEXTLIMIT, MPFROMLONG(uLimit), 0); else