X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6bdd4f5d1e127efc2b6d9f8e0acfb8e3018692d5..9470921fbb927af3a4432a27d52c372998311964:/src/mac/textctrl.cpp diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index 4ba38713d4..2b03417c0f 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -55,9 +55,9 @@ #include #endif #include -#include "ATSUnicode.h" -#include "TextCommon.h" -#include "TextEncodingConverter.h" +#include +#include +#include #include "wx/mac/uma.h" #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL @@ -69,8 +69,6 @@ extern wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ; // moment is to avoid setting the true focus on the control, the proper solution at the end would be to have // an alternate path for carbon key events that routes automatically into the same wx flow of events -#include "MacTextEditor.h" - /* part codes */ /* kmUPTextPart is the part code we return to indicate the user has clicked @@ -662,16 +660,16 @@ END_EVENT_TABLE() static void SetTXNData( TXNObject txn , const wxString& st , TXNOffset start , TXNOffset end ) { #if wxUSE_UNICODE - size_t len = st.Len() ; #if SIZEOF_WCHAR_T == 2 + size_t len = st.Len() ; TXNSetData( txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end); #else - ByteCount byteBufferLen = len * sizeof( UniChar ) ; - UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; wxMBConvUTF16BE converter ; + ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ; + UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ; converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ; - TXNSetData( txn , kTXNUnicodeTextData, (void*)unibuf, len * 2, + TXNSetData( txn , kTXNUnicodeTextData, (void*)unibuf, byteBufferLen , start, end); free( unibuf ) ; #endif @@ -852,7 +850,7 @@ wxString wxTextCtrl::GetValue() const } else { - actualSize = GetHandleSize( theText ) ; + actualSize = GetHandleSize( theText ) / sizeof( UniChar) ; if ( actualSize > 0 ) { wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ; @@ -861,11 +859,11 @@ wxString wxTextCtrl::GetValue() const #else wxMBConvUTF16BE converter ; HLock( theText ) ; - converter.MB2WC( ptr , (const char*)*theText , actualSize*sizeof(wxChar) ) ; + converter.MB2WC( ptr , (const char*)*theText , actualSize ) ; HUnlock( theText ) ; #endif ptr[actualSize] = 0 ; - result.UngetWriteBuf( actualSize ) ; + result.UngetWriteBuf( actualSize *sizeof(wxChar) ) ; } DisposeHandle( theText ) ; }