X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c33522fca7cddc441a316f5b9fb50d7685435ba..b90817de2b4543762b308f15f7010a19e941991e:/src/osx/carbon/textctrl.cpp?ds=sidebyside diff --git a/src/osx/carbon/textctrl.cpp b/src/osx/carbon/textctrl.cpp index fc308b6712..549c81b172 100644 --- a/src/osx/carbon/textctrl.cpp +++ b/src/osx/carbon/textctrl.cpp @@ -144,7 +144,7 @@ void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( con class WXDLLEXPORT wxMacPortSaver { - DECLARE_NO_COPY_CLASS(wxMacPortSaver) + wxDECLARE_NO_COPY_CLASS(wxMacPortSaver); public: wxMacPortSaver( GrafPtr port ); @@ -160,7 +160,7 @@ private : class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver { - DECLARE_NO_COPY_CLASS(wxMacWindowClipper) + wxDECLARE_NO_COPY_CLASS(wxMacWindowClipper); public: wxMacWindowClipper( const wxWindow* win ); @@ -223,7 +223,7 @@ class wxMacMLTEControl : public wxMacControl, public wxTextWidgetImpl public : wxMacMLTEControl( wxTextCtrl *peer ) ; ~wxMacMLTEControl() {} - + virtual bool CanFocus() const { return true; } @@ -234,7 +234,7 @@ public : void AdjustCreationAttributes( const wxColour& background, bool visible ) ; - virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle ) ; + virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle, bool ignoreBlack ) ; virtual void SetBackgroundColour(const wxColour& col ); virtual void SetStyle( long start, long end, const wxTextAttr& style ) ; virtual void Copy() ; @@ -332,7 +332,7 @@ public : return true; } - virtual void Move(int x, int y, int width, int height); + virtual void Move(int x, int y, int width, int height); protected : OSStatus DoCreate(); @@ -361,14 +361,14 @@ private : SInt32 m_lastVerticalValue ; }; -wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, - wxWindowMac* parent, - wxWindowID id, +wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, + wxWindowMac* WXUNUSED(parent), + wxWindowID WXUNUSED(id), const wxString& str, - const wxPoint& pos, + const wxPoint& pos, const wxSize& size, - long style, - long extraStyle) + long style, + long WXUNUSED(extraStyle)) { bool forceMLTE = false ; @@ -509,11 +509,12 @@ void wxMacUnicodeTextControl::InstallEventHandlers() { ::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(), GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this, - NULL); + (EventHandlerRef*) &m_macTextCtrlEventHandler); } wxMacUnicodeTextControl::~wxMacUnicodeTextControl() { + ::RemoveEventHandler((EventHandlerRef) m_macTextCtrlEventHandler); } void wxMacUnicodeTextControl::VisibilityChanged(bool shown) @@ -743,11 +744,11 @@ wxString wxMacMLTEControl::GetStringValue() const (((UniChar*)*theText)[actualSize]) = 0 ; wxMBConvUTF16 converter ; size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ; - wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") ); + wxASSERT_MSG( noChars != wxCONV_FAILED, wxT("Unable to count the number of characters in this string!") ); ptr = new wxChar[noChars + 1] ; noChars = converter.MB2WC( ptr , (const char*)*theText , noChars + 1 ) ; - wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") ); + wxASSERT_MSG( noChars != wxCONV_FAILED, wxT("Conversion of string failed!") ); ptr[noChars] = 0 ; HUnlock( theText ) ; #endif @@ -892,7 +893,7 @@ void wxMacMLTEControl::AdjustCreationAttributes(const wxColour &background, } ; err = TXNSetTypeAttributes( - m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes), + m_txn, WXSIZEOF(typeAttr), typeAttr, kTXNStartOffset, kTXNEndOffset ); verify_noerr( err ); @@ -1079,7 +1080,8 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo void wxMacMLTEControl::SetFont(const wxFont & font, const wxColour& foreground, - long WXUNUSED(windowStyle)) + long WXUNUSED(windowStyle), + bool WXUNUSED(ignoreBlack)) { wxMacEditHelper help( m_txn ) ; TXNSetAttribute( wxTextAttr( foreground, wxNullColour, font ), kTXNStartOffset, kTXNEndOffset ) ; @@ -1123,6 +1125,15 @@ long wxMacMLTEControl::GetLastPosition() const wxTextPos actualsize = 0 ; Handle theText ; +#if wxUSE_UNICODE + OSErr err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText, kTXNUnicodeTextData ); + // all done + if ( err == noErr ) + { + actualsize = GetHandleSize( theText )/sizeof(UniChar); + DisposeHandle( theText ) ; + } +#else OSErr err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText, kTXNTextData ); // all done @@ -1131,6 +1142,7 @@ long wxMacMLTEControl::GetLastPosition() const actualsize = GetHandleSize( theText ) ; DisposeHandle( theText ) ; } +#endif else { actualsize = 0 ; @@ -1359,7 +1371,7 @@ void wxMacMLTEControl::ShowPosition( long pos ) // there will be an error returned for classic MLTE implementation when the control is // invisible, but HITextView works correctly, so we don't assert that one - // wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") ); + // wxASSERT_MSG( theErr == noErr, wxT("TXNScroll returned an error!") ); } void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffset end ) @@ -1372,7 +1384,7 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse wxMBConvUTF16 converter ; ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ; wxASSERT_MSG( byteBufferLen != wxCONV_FAILED, - _T("Conversion to UTF-16 unexpectedly failed") ); + wxT("Conversion to UTF-16 unexpectedly failed") ); UniChar *unibuf = (UniChar*)malloc( byteBufferLen + 2 ) ; // 2 for NUL in UTF-16 converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen + 2 ) ; TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ; @@ -1720,7 +1732,7 @@ void wxMacMLTEClassicControl::MacUpdatePosition() } } -void wxMacMLTEClassicControl::Move(int x, int y, int width, int height) +void wxMacMLTEClassicControl::Move(int x, int y, int width, int height) { wxMacControl::Move(x,y,width,height) ; MacUpdatePosition() ;