X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0b6a49c21fb59ab3b03480a299ce2beab5fa6811..f8d0234d39c66f3d1d7fc2346562cb96c8c7be20:/src/osx/carbon/textctrl.cpp diff --git a/src/osx/carbon/textctrl.cpp b/src/osx/carbon/textctrl.cpp index fc47348ff9..1949980f8f 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,6 +223,10 @@ class wxMacMLTEControl : public wxMacControl, public wxTextWidgetImpl public : wxMacMLTEControl( wxTextCtrl *peer ) ; ~wxMacMLTEControl() {} + + virtual bool CanFocus() const + { return true; } + virtual wxString GetStringValue() const ; virtual void SetStringValue( const wxString &str ) ; @@ -290,7 +294,7 @@ public : const wxSize& size, long style ) ; virtual ~wxMacMLTEHIViewControl() ; - virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; + virtual bool SetFocus() ; virtual bool HasFocus() const ; virtual void SetBackgroundColour(const wxColour& col ) ; @@ -505,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) @@ -946,7 +951,7 @@ void wxMacMLTEControl::SetBackgroundColour(const wxColour& col ) static inline int wxConvertToTXN(int x) { - return wx_static_cast(int, x / 254.0 * 72 + 0.5); + return static_cast(x / 254.0 * 72 + 0.5); } void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to ) @@ -1058,7 +1063,8 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo if ( typeAttrCount > 0 ) { verify_noerr( TXNSetTypeAttributes( m_txn , typeAttrCount, typeAttr, from , to ) ); - relayout = true; + if (from != to) + relayout = true; } if ( tabs != NULL ) @@ -1366,8 +1372,10 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse #else wxMBConvUTF16 converter ; ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ; - UniChar *unibuf = (UniChar*)malloc( byteBufferLen ) ; - converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen ) ; + wxASSERT_MSG( byteBufferLen != wxCONV_FAILED, + _T("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 ) ; free( unibuf ) ; #endif @@ -1902,6 +1910,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer, MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()), &bounds, featureSet, &m_controlRef ); verify_noerr( err ); + SetControlReference( m_controlRef , (URefCon) wxPeer ); DoCreate(); @@ -2222,7 +2231,7 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer, { HIViewAddSubview( m_scrollView , m_textView ) ; m_controlRef = m_scrollView ; - wxMacControl::MacInstallEventHandler( m_textView, wxPeer ) ; + InstallEventHandler( (WXWidget) m_textView ) ; } else { @@ -2248,9 +2257,9 @@ wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl() { } -OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart ) +bool wxMacMLTEHIViewControl::SetFocus() { - return SetKeyboardFocus( GetControlOwner( m_textView ), m_textView, focusPart ) ; + return SetKeyboardFocus( GetControlOwner( m_textView ), m_textView, kControlFocusNextPart ) == noErr ; } bool wxMacMLTEHIViewControl::HasFocus() const